1// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5library fuchsia.sysmem;
6
7// Describes how an image is represented.
8// TODO(ZX-2260): change struct to table
9struct ImageFormat {
10    // Row width in pixels.
11    uint32 width;
12
13    // Number of rows.
14    uint32 height;
15
16    // Number of layers within a multi-layered image.
17    // Defaults to 1 if not specified.
18    uint32 layers;
19
20    // Pixel format.
21    PixelFormat pixel_format;
22
23    // Color space.
24    ColorSpace color_space;
25
26    array<ImagePlane>:4 planes;
27};
28
29struct ImagePlane {
30    // Byte offset of the start of the plane from the beginning of the image.
31    uint32 byte_offset;
32
33    // Stride in bytes per row.
34    // Only meaningful for linear buffer formats.
35    uint32 bytes_per_row;
36};
37
38// Describes constraints for allocating images of some desired form.
39// TODO(ZX-2260): change struct to table
40struct ImageSpec {
41    // Minimum width in pixels.
42    uint32 min_width;
43
44    // Minimum height in pixels.
45    uint32 min_height;
46
47    // Number of layers within a multi-layered image.
48    // Defaults to 1 if not specified.
49    uint32 layers = 1;
50
51    // Pixel format.
52    PixelFormat pixel_format;
53
54    // Color space.
55    ColorSpace color_space;
56
57    // TODO(ZX-2270): Add tiling formats.
58};
59
60// Describes how the pixels within an image are represented.
61// Simple formats need only a type.
62// Parametric pixel formats may require additional properties.
63// TODO(ZX-2260): change struct to table
64struct PixelFormat {
65    PixelFormatType type;
66};
67
68// TODO(ZX-2270): add more formats.
69// The ordering of the channels in the format name reflects how
70// the actual layout of the channel.
71enum PixelFormatType {
72    INVALID = 0;
73    R8G8B8A8 = 1;
74    BGRA32 = 101; // 32bpp BGRA, 1 plane. For UVC compliance.
75    I420 = 102; // For UVC compliance.
76    M420 = 103; // For UVC compliance.
77    NV12 = 104; // For UVC compliance.
78    YUY2 = 105; // For UVC compliance.
79    MJPEG = 106; // For UVC compliance.
80};
81
82// Describes how the pixels within an image are meant to be presented.
83// Simple color spaces need only a type.
84// Parametric color spaces may require additional properties.
85// TODO(ZX-2260): change struct to table
86struct ColorSpace {
87    ColorSpaceType type;
88};
89
90enum ColorSpaceType {
91    SRGB = 1;
92    REC601_NTSC = 2;
93    REC601_NTSC_FULL_RANGE = 3;
94    REC601_PAL = 4;
95    REC601_PAL_FULL_RANGE = 5;
96    REC709 = 6;
97    REC2020 = 7;
98    REC2100 = 8;
99};
100