FFmpeg
Loading...
Searching...
No Matches
vvc_parser.c
Go to the documentation of this file.
1/*
2 * H.266 / VVC parser
3 *
4 * Copyright (C) 2021 Nuo Mi <nuomi2021@gmail.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "libavutil/mem.h"
24#include "cbs.h"
25#include "cbs_h266.h"
26#include "parser.h"
27#include "parser_internal.h"
28
29#define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
30#define IS_IDR(nut) (nut == VVC_IDR_W_RADL || nut == VVC_IDR_N_LP)
31#define IS_H266_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= VVC_GDR_NUT))
32
33typedef struct PuInfo {
39} PuInfo;
40
41typedef struct AuDetector {
46
60
65
70
75
80
85
86static int get_format(const H266RawSPS *sps)
87{
88 switch (sps->sps_bitdepth_minus8) {
89 case 0:
90 return pix_fmts_8bit[sps->sps_chroma_format_idc];
91 case 2:
92 return pix_fmts_10bit[sps->sps_chroma_format_idc];
93 case 4:
94 return pix_fmts_12bit[sps->sps_chroma_format_idc];
95 case 6:
96 return pix_fmts_14bit[sps->sps_chroma_format_idc];
97 case 8:
98 return pix_fmts_16bit[sps->sps_chroma_format_idc];
99 }
100 return AV_PIX_FMT_NONE;
101}
102
103/**
104 * Find the end of the current frame in the bitstream.
105 * @return the position of the first byte of the next frame, or END_NOT_FOUND
106 */
107static int find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
108 int buf_size)
109{
110 VVCParserContext *ctx = s->priv_data;
111 ParseContext *pc = &ctx->pc;
112 int i;
113
114 for (i = 0; i < buf_size; i++) {
115 int nut, code_len;
116
117 pc->state64 = (pc->state64 << 8) | buf[i];
118
119 if (((pc->state64 >> 3 * 8) & 0xFFFFFF) != START_CODE)
120 continue;
121
122 code_len = ((pc->state64 >> 3 * 8) & 0xFFFFFFFF) == 0x01 ? 4 : 3;
123
124 nut = (pc->state64 >> (8 + 3)) & 0x1F;
125 // 7.4.2.4.3 and 7.4.2.4.4
126 if ((nut >= VVC_OPI_NUT && nut <= VVC_PREFIX_APS_NUT &&
127 nut != VVC_PH_NUT) || nut == VVC_AUD_NUT
128 || nut == VVC_PREFIX_SEI_NUT
129 || nut == VVC_RSV_NVCL_26 || nut == VVC_UNSPEC_28
130 || nut == VVC_UNSPEC_29) {
131 if (pc->frame_start_found) {
132 pc->frame_start_found = 0;
133 return i - (code_len + 2);
134 }
135 } else if (nut == VVC_PH_NUT || IS_H266_SLICE(nut)) {
136 int sh_picture_header_in_slice_header_flag = buf[i] >> 7;
137
138 if (nut == VVC_PH_NUT || sh_picture_header_in_slice_header_flag) {
139 if (!pc->frame_start_found) {
140 pc->frame_start_found = 1;
141 } else { // First slice of next frame found
142 pc->frame_start_found = 0;
143 return i - (code_len + 2);
144 }
145 }
146 }
147 }
148 return END_NOT_FOUND;
149}
150
152{
153 int has_p = 0;
154 for (int i = 0; i < pu->nb_units; i++) {
155 CodedBitstreamUnit *unit = &pu->units[i];
156 if (IS_H266_SLICE(unit->type)) {
157 const H266RawSlice *slice = unit->content;
158 uint8_t type = slice->header.sh_slice_type;
159 if (type == VVC_SLICE_TYPE_B) {
160 return AV_PICTURE_TYPE_B;
161 }
162 if (type == VVC_SLICE_TYPE_P) {
163 has_p = 1;
164 }
165 }
166 }
167 return has_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
168}
169
171 const PuInfo *pu)
172{
173 static const uint8_t h266_sub_width_c[] = {
174 1, 2, 2, 1
175 };
176 static const uint8_t h266_sub_height_c[] = {
177 1, 2, 1, 1
178 };
179 const H266RawSPS *sps = pu->sps;
180 const H266RawPPS *pps = pu->pps;
182
183 s->pict_type = pu->pic_type;
184 s->format = get_format(sps);
185 s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
186
187 s->key_frame = nal->nal_unit_type == VVC_IDR_W_RADL ||
188 nal->nal_unit_type == VVC_IDR_N_LP ||
189 nal->nal_unit_type == VVC_CRA_NUT ||
190 nal->nal_unit_type == VVC_GDR_NUT;
191
192 s->coded_width = pps->pps_pic_width_in_luma_samples;
193 s->coded_height = pps->pps_pic_height_in_luma_samples;
194 s->width = pps->pps_pic_width_in_luma_samples -
195 (pps->pps_conf_win_left_offset + pps->pps_conf_win_right_offset) *
196 h266_sub_width_c[sps->sps_chroma_format_idc];
197 s->height = pps->pps_pic_height_in_luma_samples -
198 (pps->pps_conf_win_top_offset + pps->pps_conf_win_bottom_offset) *
199 h266_sub_height_c[sps->sps_chroma_format_idc];
200
201 avctx->profile = sps->profile_tier_level.general_profile_idc;
202 avctx->level = sps->profile_tier_level.general_level_idc;
203
204 avctx->colorspace = (enum AVColorSpace) sps->vui.vui_matrix_coeffs;
205 avctx->color_primaries = (enum AVColorPrimaries) sps->vui.vui_colour_primaries;
206 avctx->color_trc = (enum AVColorTransferCharacteristic) sps->vui.vui_transfer_characteristics;
207 avctx->color_range =
208 sps->vui.vui_full_range_flag ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
209
210 if (sps->sps_ptl_dpb_hrd_params_present_flag &&
211 sps->sps_timing_hrd_params_present_flag) {
212 uint32_t num = sps->sps_general_timing_hrd_parameters.num_units_in_tick;
213 uint32_t den = sps->sps_general_timing_hrd_parameters.time_scale;
214
215 if (num != 0 && den != 0)
216 av_reduce(&avctx->framerate.den, &avctx->framerate.num,
217 num, den, 1 << 30);
218 }
219}
220
221//8.3.1 Decoding process for picture order count.
222//VTM did not follow the spec, and it's much simpler than spec.
223//We follow the VTM.
224static void get_slice_poc(VVCParserContext *s, int *poc,
225 const H266RawSPS *sps,
227 const H266RawSliceHeader *slice, void *log_ctx)
228{
229 int poc_msb, max_poc_lsb, poc_lsb;
230 AuDetector *d = &s->au_detector;
231 max_poc_lsb = 1 << (sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4);
232 poc_lsb = ph->ph_pic_order_cnt_lsb;
234 if (ph->ph_poc_msb_cycle_present_flag)
235 poc_msb = ph->ph_poc_msb_cycle_val * max_poc_lsb;
236 else
237 poc_msb = 0;
238 } else {
239 int prev_poc = d->prev_tid0_poc;
240 int prev_poc_lsb = prev_poc & (max_poc_lsb - 1);
241 int prev_poc_msb = prev_poc - prev_poc_lsb;
242 if (ph->ph_poc_msb_cycle_present_flag) {
243 poc_msb = ph->ph_poc_msb_cycle_val * max_poc_lsb;
244 } else {
245 if ((poc_lsb < prev_poc_lsb) && ((prev_poc_lsb - poc_lsb) >=
246 (max_poc_lsb / 2)))
247 poc_msb = prev_poc_msb + (unsigned)max_poc_lsb;
248 else if ((poc_lsb > prev_poc_lsb) && ((poc_lsb - prev_poc_lsb) >
249 (max_poc_lsb / 2)))
250 poc_msb = prev_poc_msb - (unsigned)max_poc_lsb;
251 else
252 poc_msb = prev_poc_msb;
253 }
254 }
255
256 *poc = poc_msb + poc_lsb;
257}
258
260{
261 d->prev_layer_id = UINT8_MAX;
262 d->prev_poc = INT_MAX;
263 d->prev_tid0_poc = INT_MAX;
264}
265
266static int is_au_start(VVCParserContext *s, const PuInfo *pu, void *log_ctx)
267{
268 //7.4.2.4.3
269 AuDetector *d = &s->au_detector;
270 const H266RawSPS *sps = pu->sps;
272 const H266RawPictureHeader *ph = pu->ph;
273 const H266RawSlice *slice = pu->slice;
274 int ret, poc, nut;
275
276 get_slice_poc(s, &poc, sps, ph, &slice->header, log_ctx);
277
278 ret = (nal->nuh_layer_id <= d->prev_layer_id) || (poc != d->prev_poc);
279
280 nut = nal->nal_unit_type;
281 d->prev_layer_id = nal->nuh_layer_id;
282 d->prev_poc = poc;
283 if (nal->nuh_temporal_id_plus1 == 1 &&
284 !ph->ph_non_ref_pic_flag && nut != VVC_RADL_NUT
285 && nut != VVC_RASL_NUT) {
286 d->prev_tid0_poc = poc;
287 }
288 return ret;
289}
290
291static int get_pu_info(PuInfo *info, const CodedBitstreamH266Context *h266,
292 const CodedBitstreamFragment *pu, void *logctx)
293{
295 int ret;
296
297 memset(info, 0, sizeof(*info));
298 for (int i = 0; i < pu->nb_units; i++) {
299 nal = pu->units[i].content;
300 if (!nal)
301 continue;
302 if ( nal->nal_unit_type == VVC_PH_NUT ) {
303 const H266RawPH *ph = pu->units[i].content;
304 info->ph = &ph->ph_picture_header;
305 } else if (IS_H266_SLICE(nal->nal_unit_type)) {
306 info->slice = pu->units[i].content;
308 info->ph = &info->slice->header.sh_picture_header;
309 if (!info->ph) {
310 av_log(logctx, AV_LOG_ERROR,
311 "can't find picture header in picture unit.\n");
313 goto error;
314 }
315 break;
316 }
317 }
318 if (!info->slice) {
319 av_log(logctx, AV_LOG_ERROR, "can't find slice in picture unit.\n");
321 goto error;
322 }
323 info->pps = h266->pps[info->ph->ph_pic_parameter_set_id];
324 if (!info->pps) {
325 av_log(logctx, AV_LOG_ERROR, "PPS id %d is not available.\n",
328 goto error;
329 }
330 info->sps = h266->sps[info->pps->pps_seq_parameter_set_id];
331 if (!info->sps) {
332 av_log(logctx, AV_LOG_ERROR, "SPS id %d is not available.\n",
335 goto error;
336 }
337 info->pic_type = get_pict_type(pu);
338 return 0;
339error:
340 memset(info, 0, sizeof(*info));
341 return ret;
342}
343
344static int append_au(AVPacket *pkt, const uint8_t *buf, int buf_size)
345{
346 int offset = pkt->size;
347 int ret;
348 if ((ret = av_grow_packet(pkt, buf_size)) < 0)
349 goto end;
350 memcpy(pkt->data + offset, buf, buf_size);
351end:
352 return ret;
353}
354
355/**
356 * Parse NAL units of found picture and decode some basic information.
357 *
358 * @param s parser context.
359 * @param avctx codec context.
360 * @param buf buffer with field/frame data.
361 * @param buf_size size of the buffer.
362 * @return < 0 for error, == 0 for a complete au, > 0 is not a completed au.
363 */
364static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
365 int buf_size, AVCodecContext *avctx)
366{
367 VVCParserContext *ctx = s->priv_data;
368 const CodedBitstreamH266Context *h266 = ctx->cbc->priv_data;
369
370 CodedBitstreamFragment *pu = &ctx->picture_unit;
371 int ret;
372 PuInfo info;
373
374 if (!buf_size) {
375 if (ctx->au.size) {
376 av_packet_move_ref(&ctx->last_au, &ctx->au);
377 return 0;
378 }
379 return 1;
380 }
381
382 if ((ret = ff_cbs_read(ctx->cbc, pu, NULL, buf, buf_size)) < 0) {
383 av_log(avctx, AV_LOG_ERROR, "Failed to parse picture unit.\n");
384 goto end;
385 }
386 if ((ret = get_pu_info(&info, h266, pu, avctx)) < 0)
387 goto end;
388 if (append_au(&ctx->au, buf, buf_size) < 0) {
389 ret = AVERROR(ENOMEM);
390 goto end;
391 }
392 if (is_au_start(ctx, &info, avctx)) {
393 set_parser_ctx(s, avctx, &info);
394 av_packet_move_ref(&ctx->last_au, &ctx->au);
395 } else {
396 ret = 1; //not a completed au
397 }
398end:
399 ff_cbs_fragment_reset(pu);
400 return ret;
401}
402
403/**
404 * Combine PU to AU
405 *
406 * @param s parser context.
407 * @param avctx codec context.
408 * @param buf buffer to a PU.
409 * @param buf_size size of the buffer.
410 * @return < 0 for error, == 0 a complete au, > 0 not a completed au.
411 */
413 const uint8_t **buf, int *buf_size)
414{
415 VVCParserContext *ctx = s->priv_data;
416 int ret;
417
418 ctx->cbc->log_ctx = avctx;
419
420 av_packet_unref(&ctx->last_au);
421 ret = parse_nal_units(s, *buf, *buf_size, avctx);
422 if (ret == 0) {
423 if (ctx->last_au.size) {
424 *buf = ctx->last_au.data;
425 *buf_size = ctx->last_au.size;
426 } else {
427 ret = 1; //no output
428 }
429 }
430 ctx->cbc->log_ctx = NULL;
431 return ret;
432}
433
435 const uint8_t **poutbuf, int *poutbuf_size,
436 const uint8_t *buf, int buf_size)
437{
438 int next, ret;
439 VVCParserContext *ctx = s->priv_data;
440 ParseContext *pc = &ctx->pc;
441 CodedBitstreamFragment *pu = &ctx->picture_unit;
442
443 int is_dummy_buf = !buf_size;
444 int flush = !buf_size;
445 const uint8_t *dummy_buf = buf;
446
447 *poutbuf = NULL;
448 *poutbuf_size = 0;
449
450 if (avctx->extradata_size && !ctx->parsed_extradata) {
451 ctx->parsed_extradata = 1;
452
453 ret = ff_cbs_read_extradata_from_codec(ctx->cbc, pu, avctx);
454 if (ret < 0)
455 av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n");
456
457 ff_cbs_fragment_reset(pu);
458 }
459
460 if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
461 next = buf_size;
462 } else {
463 next = find_frame_end(s, buf, buf_size);
464 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0)
465 return buf_size;
466 }
467
468 is_dummy_buf &= (dummy_buf == buf);
469
470 if (!is_dummy_buf) {
471 ret = combine_au(s, avctx, &buf, &buf_size);
472 if (ret > 0 && flush) {
473 buf_size = 0;
474 ret = combine_au(s, avctx, &buf, &buf_size);
475 }
476 if (ret != 0)
477 return next;
478 }
479
480 *poutbuf = buf;
481 *poutbuf_size = buf_size;
482
483 return next;
484}
485
501
503{
504 VVCParserContext *ctx = s->priv_data;
505 int ret;
506
507 ret = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_VVC, NULL);
508 if (ret < 0)
509 return ret;
510 au_detector_init(&ctx->au_detector);
511
512 ctx->cbc->decompose_unit_types = decompose_unit_types;
513 ctx->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
514
515 return ret;
516}
517
519{
520 VVCParserContext *ctx = s->priv_data;
521
522 av_packet_unref(&ctx->au);
523 av_packet_unref(&ctx->last_au);
524 ff_cbs_fragment_free(&ctx->picture_unit);
525
526 ff_cbs_close(&ctx->cbc);
527 av_freep(&ctx->pc.buffer);
528}
529
static AVFormatContext * ctx
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition apv_parser.c:92
static const CodedBitstreamUnitType decompose_unit_types[]
Definition apv_parser.c:178
static enum AVPixelFormat pix_fmts_12bit[2][2]
Definition av1_parser.c:46
static enum AVPixelFormat pix_fmts_8bit[2][2]
Definition av1_parser.c:38
static enum AVPixelFormat pix_fmts_10bit[2][2]
Definition av1_parser.c:42
#define PARSER_FLAG_COMPLETE_FRAMES
Definition avcodec.h:2672
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
static AVPacket * pkt
uint64_t pps
Definition dovi_rpuenc.c:36
void(* flush)(AVBSFContext *ctx)
Definition dts2pts.c:615
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
static enum AVPixelFormat pix_fmts_16bit[NUM_CHROMA_FORMATS]
Definition evc_parser.c:60
static enum AVPixelFormat pix_fmts_14bit[NUM_CHROMA_FORMATS]
Definition evc_parser.c:56
int ret
Definition ffplay.c:391
@ AV_CODEC_ID_VVC
Definition codec_id.h:247
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition packet.c:121
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition packet.c:492
@ AV_PICTURE_STRUCTURE_FRAME
coded as frame
Definition avcodec.h:2635
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition rational.c:35
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition avutil.h:280
enum MPFType type
Definition jpegmpfenc.c:55
unsigned offset
Definition libaomenc.c:812
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition cbs.c:118
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition cbs.h:66
@ VVC_SLICE_TYPE_B
Definition vvc.h:64
@ VVC_SLICE_TYPE_P
Definition vvc.h:65
@ VVC_RASL_NUT
Definition vvc.h:32
@ VVC_SPS_NUT
Definition vvc.h:44
@ VVC_PREFIX_SEI_NUT
Definition vvc.h:52
@ VVC_CRA_NUT
Definition vvc.h:38
@ VVC_IDR_N_LP
Definition vvc.h:37
@ VVC_TRAIL_NUT
Definition vvc.h:29
@ VVC_OPI_NUT
Definition vvc.h:41
@ VVC_RSV_NVCL_26
Definition vvc.h:55
@ VVC_RADL_NUT
Definition vvc.h:31
@ VVC_PH_NUT
Definition vvc.h:48
@ VVC_VPS_NUT
Definition vvc.h:43
@ VVC_IDR_W_RADL
Definition vvc.h:36
@ VVC_STSA_NUT
Definition vvc.h:30
@ VVC_GDR_NUT
Definition vvc.h:39
@ VVC_AUD_NUT
Definition vvc.h:49
@ VVC_PREFIX_APS_NUT
Definition vvc.h:46
@ VVC_PPS_NUT
Definition vvc.h:45
@ VVC_UNSPEC_29
Definition vvc.h:58
@ VVC_UNSPEC_28
Definition vvc.h:57
#define av_cold
Definition attributes.h:117
Memory handling functions.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
Definition parser.c:213
#define END_NOT_FOUND
Definition parser.h:40
#define PARSER_CODEC_LIST(...)
const FFCodecParser ff_vvc_parser
Definition vvc_parser.c:530
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:559
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:775
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:792
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:529
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:557
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:528
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:530
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:560
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:531
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:647
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:677
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:711
#define START_CODE
#define FF_ARRAY_ELEMS(a)
main external API structure.
Definition avcodec.h:443
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition avcodec.h:685
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition avcodec.h:658
AVRational framerate
Definition avcodec.h:563
int level
Encoding level descriptor.
Definition avcodec.h:1656
int profile
profile
Definition avcodec.h:1646
enum AVColorSpace colorspace
YUV colorspace type.
Definition avcodec.h:672
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition avcodec.h:665
int extradata_size
Definition avcodec.h:527
This structure stores compressed data.
Definition packet.h:587
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
int prev_tid0_poc
Definition vvc_parser.c:43
uint8_t prev_layer_id
Definition vvc_parser.c:42
Context structure for coded bitstream operations.
Definition cbs.h:226
Coded bitstream fragment structure, combining one or more units.
Definition cbs.h:129
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
Definition cbs.h:175
int nb_units
Number of units in this fragment.
Definition cbs.h:160
H266RawSPS * sps[VVC_MAX_SPS_COUNT]
RefStruct references.
Definition cbs_h266.h:871
H266RawPPS * pps[VVC_MAX_PPS_COUNT]
RefStruct references.
Definition cbs_h266.h:872
Coded bitstream unit structure.
Definition cbs.h:77
void * content
Pointer to the decomposed form of this unit.
Definition cbs.h:114
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition cbs.h:81
uint8_t nal_unit_type
Definition cbs_h266.h:31
uint8_t pps_seq_parameter_set_id
Definition cbs_h266.h:501
uint8_t ph_pic_parameter_set_id
Definition cbs_h266.h:683
uint8_t sh_slice_type
Definition cbs_h266.h:781
H266RawNALUnitHeader nal_unit_header
Definition cbs_h266.h:773
H266RawPictureHeader sh_picture_header
Definition cbs_h266.h:775
uint8_t sh_picture_header_in_slice_header_flag
Definition cbs_h266.h:774
H266RawSliceHeader header
Definition cbs_h266.h:845
uint64_t state64
contains the last 8 bytes in MSB order
Definition parser.h:37
int frame_start_found
Definition parser.h:34
int pic_type
Definition vvc_parser.c:38
const H266RawSPS * sps
Definition vvc_parser.c:35
const H266RawPictureHeader * ph
Definition vvc_parser.c:36
const H266RawPPS * pps
Definition vvc_parser.c:34
const H266RawSlice * slice
Definition vvc_parser.c:37
CodedBitstreamFragment picture_unit
Definition vvc_parser.c:51
AuDetector au_detector
Definition vvc_parser.c:56
AVPacket last_au
Definition vvc_parser.c:54
CodedBitstreamContext * cbc
Definition vvc_parser.c:49
ParseContext pc
Definition vvc_parser.c:48
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
int num
Definition error.c:23
static int get_pu_info(PuInfo *info, const CodedBitstreamH266Context *h266, const CodedBitstreamFragment *pu, void *logctx)
Definition vvc_parser.c:291
static void au_detector_init(AuDetector *d)
Definition vvc_parser.c:259
static av_cold void vvc_parser_close(AVCodecParserContext *s)
Definition vvc_parser.c:518
static av_cold int vvc_parser_init(AVCodecParserContext *s)
Definition vvc_parser.c:502
static int append_au(AVPacket *pkt, const uint8_t *buf, int buf_size)
Definition vvc_parser.c:344
static int get_pict_type(const CodedBitstreamFragment *pu)
Definition vvc_parser.c:151
static void set_parser_ctx(AVCodecParserContext *s, AVCodecContext *avctx, const PuInfo *pu)
Definition vvc_parser.c:170
static int find_frame_end(AVCodecParserContext *s, const uint8_t *buf, int buf_size)
Find the end of the current frame in the bitstream.
Definition vvc_parser.c:107
static int is_au_start(VVCParserContext *s, const PuInfo *pu, void *log_ctx)
Definition vvc_parser.c:266
static void get_slice_poc(VVCParserContext *s, int *poc, const H266RawSPS *sps, const H266RawPictureHeader *ph, const H266RawSliceHeader *slice, void *log_ctx)
Definition vvc_parser.c:224
#define IS_IDR(nut)
Definition vvc_parser.c:30
#define IS_H266_SLICE(nut)
Definition vvc_parser.c:31
static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx)
Parse NAL units of found picture and decode some basic information.
Definition vvc_parser.c:364
static int combine_au(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **buf, int *buf_size)
Combine PU to AU.
Definition vvc_parser.c:412
static int vvc_parser_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition vvc_parser.c:434
static int get_format(const H266RawSPS *sps)
Definition vvc_parser.c:86