aboutsummaryrefslogtreecommitdiff
path: root/src/gav1/decoder_buffer.h
blob: 0a5586e5ec975703bbcd8643370cc0fa27abb69f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
/*
 * Copyright 2019 The libgav1 Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LIBGAV1_SRC_GAV1_DECODER_BUFFER_H_
#define LIBGAV1_SRC_GAV1_DECODER_BUFFER_H_

#if defined(__cplusplus)
#include <cstdint>
#else
#include <stdint.h>
#endif  // defined(__cplusplus)

#include "gav1/symbol_visibility.h"

// All the declarations in this file are part of the public ABI.

// The documentation for the enum values in this file can be found in Section
// 6.4.2 of the AV1 spec.

typedef enum Libgav1ChromaSamplePosition {
  kLibgav1ChromaSamplePositionUnknown,
  kLibgav1ChromaSamplePositionVertical,
  kLibgav1ChromaSamplePositionColocated,
  kLibgav1ChromaSamplePositionReserved
} Libgav1ChromaSamplePosition;

typedef enum Libgav1ImageFormat {
  kLibgav1ImageFormatYuv420,
  kLibgav1ImageFormatYuv422,
  kLibgav1ImageFormatYuv444,
  kLibgav1ImageFormatMonochrome400
} Libgav1ImageFormat;

typedef enum Libgav1ColorPrimary {
  // 0 is reserved.
  kLibgav1ColorPrimaryBt709 = 1,
  kLibgav1ColorPrimaryUnspecified,
  // 3 is reserved.
  kLibgav1ColorPrimaryBt470M = 4,
  kLibgav1ColorPrimaryBt470Bg,
  kLibgav1ColorPrimaryBt601,
  kLibgav1ColorPrimarySmpte240,
  kLibgav1ColorPrimaryGenericFilm,
  kLibgav1ColorPrimaryBt2020,
  kLibgav1ColorPrimaryXyz,
  kLibgav1ColorPrimarySmpte431,
  kLibgav1ColorPrimarySmpte432,
  // 13-21 are reserved.
  kLibgav1ColorPrimaryEbu3213 = 22,
  // 23-254 are reserved.
  kLibgav1MaxColorPrimaries = 255
} Libgav1ColorPrimary;

typedef enum Libgav1TransferCharacteristics {
  // 0 is reserved.
  kLibgav1TransferCharacteristicsBt709 = 1,
  kLibgav1TransferCharacteristicsUnspecified,
  // 3 is reserved.
  kLibgav1TransferCharacteristicsBt470M = 4,
  kLibgav1TransferCharacteristicsBt470Bg,
  kLibgav1TransferCharacteristicsBt601,
  kLibgav1TransferCharacteristicsSmpte240,
  kLibgav1TransferCharacteristicsLinear,
  kLibgav1TransferCharacteristicsLog100,
  kLibgav1TransferCharacteristicsLog100Sqrt10,
  kLibgav1TransferCharacteristicsIec61966,
  kLibgav1TransferCharacteristicsBt1361,
  kLibgav1TransferCharacteristicsSrgb,
  kLibgav1TransferCharacteristicsBt2020TenBit,
  kLibgav1TransferCharacteristicsBt2020TwelveBit,
  kLibgav1TransferCharacteristicsSmpte2084,
  kLibgav1TransferCharacteristicsSmpte428,
  kLibgav1TransferCharacteristicsHlg,
  // 19-254 are reserved.
  kLibgav1MaxTransferCharacteristics = 255
} Libgav1TransferCharacteristics;

typedef enum Libgav1MatrixCoefficients {
  kLibgav1MatrixCoefficientsIdentity,
  kLibgav1MatrixCoefficientsBt709,
  kLibgav1MatrixCoefficientsUnspecified,
  // 3 is reserved.
  kLibgav1MatrixCoefficientsFcc = 4,
  kLibgav1MatrixCoefficientsBt470BG,
  kLibgav1MatrixCoefficientsBt601,
  kLibgav1MatrixCoefficientsSmpte240,
  kLibgav1MatrixCoefficientsSmpteYcgco,
  kLibgav1MatrixCoefficientsBt2020Ncl,
  kLibgav1MatrixCoefficientsBt2020Cl,
  kLibgav1MatrixCoefficientsSmpte2085,
  kLibgav1MatrixCoefficientsChromatNcl,
  kLibgav1MatrixCoefficientsChromatCl,
  kLibgav1MatrixCoefficientsIctcp,
  // 15-254 are reserved.
  kLibgav1MaxMatrixCoefficients = 255
} Libgav1MatrixCoefficients;

typedef enum Libgav1ColorRange {
  // The color ranges are scaled by value << (bitdepth - 8) for 10 and 12bit
  // streams.
  kLibgav1ColorRangeStudio,  // Y [16..235], UV [16..240]
  kLibgav1ColorRangeFull     // YUV/RGB [0..255]
} Libgav1ColorRange;

typedef struct Libgav1ObuMetadataHdrCll {  // NOLINT
  uint16_t max_cll;                        // Maximum content light level.
  uint16_t max_fall;                       // Maximum frame-average light level.
} Libgav1ObuMetadataHdrCll;

typedef struct Libgav1ObuMetadataHdrMdcv {  // NOLINT
  uint16_t primary_chromaticity_x[3];
  uint16_t primary_chromaticity_y[3];
  uint16_t white_point_chromaticity_x;
  uint16_t white_point_chromaticity_y;
  uint32_t luminance_max;
  uint32_t luminance_min;
} Libgav1ObuMetadataHdrMdcv;

typedef struct Libgav1ObuMetadataItutT35 {  // NOLINT
  uint8_t country_code;
  uint8_t country_code_extension_byte;  // Valid if country_code is 0xFF.
  uint8_t* payload_bytes;
  int payload_size;
} Libgav1ObuMetadataItutT35;

typedef struct Libgav1DecoderBuffer {
#if defined(__cplusplus)
  LIBGAV1_PUBLIC int NumPlanes() const {
    return (image_format == kLibgav1ImageFormatMonochrome400) ? 1 : 3;
  }
#endif  // defined(__cplusplus)

  Libgav1ChromaSamplePosition chroma_sample_position;
  Libgav1ImageFormat image_format;
  Libgav1ColorRange color_range;
  Libgav1ColorPrimary color_primary;
  Libgav1TransferCharacteristics transfer_characteristics;
  Libgav1MatrixCoefficients matrix_coefficients;

  int bitdepth;  // Stored image bitdepth.

  // Image display dimensions in Y/U/V order.
  int displayed_width[3];   // Displayed image width.
  int displayed_height[3];  // Displayed image height.

  // Values are given in Y/U/V order.
  int stride[3];      // The width in bytes of one row of the |plane| buffer.
                      // This may include padding bytes for alignment or
                      // internal use by the decoder.
  uint8_t* plane[3];  // The reconstructed image plane(s).

  // Spatial id of this frame.
  int spatial_id;
  // Temporal id of this frame.
  int temporal_id;

  Libgav1ObuMetadataHdrCll hdr_cll;
  int has_hdr_cll;  // 1 if the values in hdr_cll are valid for this frame. 0
                    // otherwise.

  Libgav1ObuMetadataHdrMdcv hdr_mdcv;
  int has_hdr_mdcv;  // 1 if the values in hdr_mdcv are valid for this frame. 0
                     // otherwise.

  Libgav1ObuMetadataItutT35 itut_t35;
  int has_itut_t35;  // 1 if the values in itut_t35 are valid for this frame. 0
                     // otherwise.

  // The |user_private_data| argument passed to Decoder::EnqueueFrame().
  int64_t user_private_data;
  // The |private_data| field of FrameBuffer. Set by the get frame buffer
  // callback when it allocates a frame buffer.
  void* buffer_private_data;
} Libgav1DecoderBuffer;

#if defined(__cplusplus)
namespace libgav1 {

using ChromaSamplePosition = Libgav1ChromaSamplePosition;
constexpr ChromaSamplePosition kChromaSamplePositionUnknown =
    kLibgav1ChromaSamplePositionUnknown;
constexpr ChromaSamplePosition kChromaSamplePositionVertical =
    kLibgav1ChromaSamplePositionVertical;
constexpr ChromaSamplePosition kChromaSamplePositionColocated =
    kLibgav1ChromaSamplePositionColocated;
constexpr ChromaSamplePosition kChromaSamplePositionReserved =
    kLibgav1ChromaSamplePositionReserved;

using ImageFormat = Libgav1ImageFormat;
constexpr ImageFormat kImageFormatYuv420 = kLibgav1ImageFormatYuv420;
constexpr ImageFormat kImageFormatYuv422 = kLibgav1ImageFormatYuv422;
constexpr ImageFormat kImageFormatYuv444 = kLibgav1ImageFormatYuv444;
constexpr ImageFormat kImageFormatMonochrome400 =
    kLibgav1ImageFormatMonochrome400;

using ColorPrimary = Libgav1ColorPrimary;
constexpr ColorPrimary kColorPrimaryBt709 = kLibgav1ColorPrimaryBt709;
constexpr ColorPrimary kColorPrimaryUnspecified =
    kLibgav1ColorPrimaryUnspecified;
constexpr ColorPrimary kColorPrimaryBt470M = kLibgav1ColorPrimaryBt470M;
constexpr ColorPrimary kColorPrimaryBt470Bg = kLibgav1ColorPrimaryBt470Bg;
constexpr ColorPrimary kColorPrimaryBt601 = kLibgav1ColorPrimaryBt601;
constexpr ColorPrimary kColorPrimarySmpte240 = kLibgav1ColorPrimarySmpte240;
constexpr ColorPrimary kColorPrimaryGenericFilm =
    kLibgav1ColorPrimaryGenericFilm;
constexpr ColorPrimary kColorPrimaryBt2020 = kLibgav1ColorPrimaryBt2020;
constexpr ColorPrimary kColorPrimaryXyz = kLibgav1ColorPrimaryXyz;
constexpr ColorPrimary kColorPrimarySmpte431 = kLibgav1ColorPrimarySmpte431;
constexpr ColorPrimary kColorPrimarySmpte432 = kLibgav1ColorPrimarySmpte432;
constexpr ColorPrimary kColorPrimaryEbu3213 = kLibgav1ColorPrimaryEbu3213;
constexpr ColorPrimary kMaxColorPrimaries = kLibgav1MaxColorPrimaries;

using TransferCharacteristics = Libgav1TransferCharacteristics;
constexpr TransferCharacteristics kTransferCharacteristicsBt709 =
    kLibgav1TransferCharacteristicsBt709;
constexpr TransferCharacteristics kTransferCharacteristicsUnspecified =
    kLibgav1TransferCharacteristicsUnspecified;
constexpr TransferCharacteristics kTransferCharacteristicsBt470M =
    kLibgav1TransferCharacteristicsBt470M;
constexpr TransferCharacteristics kTransferCharacteristicsBt470Bg =
    kLibgav1TransferCharacteristicsBt470Bg;
constexpr TransferCharacteristics kTransferCharacteristicsBt601 =
    kLibgav1TransferCharacteristicsBt601;
constexpr TransferCharacteristics kTransferCharacteristicsSmpte240 =
    kLibgav1TransferCharacteristicsSmpte240;
constexpr TransferCharacteristics kTransferCharacteristicsLinear =
    kLibgav1TransferCharacteristicsLinear;
constexpr TransferCharacteristics kTransferCharacteristicsLog100 =
    kLibgav1TransferCharacteristicsLog100;
constexpr TransferCharacteristics kTransferCharacteristicsLog100Sqrt10 =
    kLibgav1TransferCharacteristicsLog100Sqrt10;
constexpr TransferCharacteristics kTransferCharacteristicsIec61966 =
    kLibgav1TransferCharacteristicsIec61966;
constexpr TransferCharacteristics kTransferCharacteristicsBt1361 =
    kLibgav1TransferCharacteristicsBt1361;
constexpr TransferCharacteristics kTransferCharacteristicsSrgb =
    kLibgav1TransferCharacteristicsSrgb;
constexpr TransferCharacteristics kTransferCharacteristicsBt2020TenBit =
    kLibgav1TransferCharacteristicsBt2020TenBit;
constexpr TransferCharacteristics kTransferCharacteristicsBt2020TwelveBit =
    kLibgav1TransferCharacteristicsBt2020TwelveBit;
constexpr TransferCharacteristics kTransferCharacteristicsSmpte2084 =
    kLibgav1TransferCharacteristicsSmpte2084;
constexpr TransferCharacteristics kTransferCharacteristicsSmpte428 =
    kLibgav1TransferCharacteristicsSmpte428;
constexpr TransferCharacteristics kTransferCharacteristicsHlg =
    kLibgav1TransferCharacteristicsHlg;
constexpr TransferCharacteristics kMaxTransferCharacteristics =
    kLibgav1MaxTransferCharacteristics;

using MatrixCoefficients = Libgav1MatrixCoefficients;
constexpr MatrixCoefficients kMatrixCoefficientsIdentity =
    kLibgav1MatrixCoefficientsIdentity;
constexpr MatrixCoefficients kMatrixCoefficientsBt709 =
    kLibgav1MatrixCoefficientsBt709;
constexpr MatrixCoefficients kMatrixCoefficientsUnspecified =
    kLibgav1MatrixCoefficientsUnspecified;
constexpr MatrixCoefficients kMatrixCoefficientsFcc =
    kLibgav1MatrixCoefficientsFcc;
constexpr MatrixCoefficients kMatrixCoefficientsBt470BG =
    kLibgav1MatrixCoefficientsBt470BG;
constexpr MatrixCoefficients kMatrixCoefficientsBt601 =
    kLibgav1MatrixCoefficientsBt601;
constexpr MatrixCoefficients kMatrixCoefficientsSmpte240 =
    kLibgav1MatrixCoefficientsSmpte240;
constexpr MatrixCoefficients kMatrixCoefficientsSmpteYcgco =
    kLibgav1MatrixCoefficientsSmpteYcgco;
constexpr MatrixCoefficients kMatrixCoefficientsBt2020Ncl =
    kLibgav1MatrixCoefficientsBt2020Ncl;
constexpr MatrixCoefficients kMatrixCoefficientsBt2020Cl =
    kLibgav1MatrixCoefficientsBt2020Cl;
constexpr MatrixCoefficients kMatrixCoefficientsSmpte2085 =
    kLibgav1MatrixCoefficientsSmpte2085;
constexpr MatrixCoefficients kMatrixCoefficientsChromatNcl =
    kLibgav1MatrixCoefficientsChromatNcl;
constexpr MatrixCoefficients kMatrixCoefficientsChromatCl =
    kLibgav1MatrixCoefficientsChromatCl;
constexpr MatrixCoefficients kMatrixCoefficientsIctcp =
    kLibgav1MatrixCoefficientsIctcp;
constexpr MatrixCoefficients kMaxMatrixCoefficients =
    kLibgav1MaxMatrixCoefficients;

using ColorRange = Libgav1ColorRange;
constexpr ColorRange kColorRangeStudio = kLibgav1ColorRangeStudio;
constexpr ColorRange kColorRangeFull = kLibgav1ColorRangeFull;

using ObuMetadataHdrCll = Libgav1ObuMetadataHdrCll;
using ObuMetadataHdrMdcv = Libgav1ObuMetadataHdrMdcv;
using ObuMetadataItutT35 = Libgav1ObuMetadataItutT35;

using DecoderBuffer = Libgav1DecoderBuffer;

}  // namespace libgav1
#endif  // defined(__cplusplus)

#endif  // LIBGAV1_SRC_GAV1_DECODER_BUFFER_H_