FFmpeg
Loading...
Searching...
No Matches
apv_decode.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <stdatomic.h>
20
22#include "libavutil/avassert.h"
25#include "libavutil/pixdesc.h"
26#include "libavutil/thread.h"
27
28#include "apv.h"
29#include "apv_decode.h"
30#include "avcodec.h"
31#include "cbs_apv.h"
32#include "codec_internal.h"
33#include "decode.h"
34#include "internal.h"
35#include "thread.h"
36#include "hwconfig.h"
37#include "hwaccel_internal.h"
38#include "config_components.h"
39
47
49
52{
53 enum AVPixelFormat pix_fmts[] = {
54#if CONFIG_APV_VULKAN_HWACCEL
56#endif
57 pix_fmt,
59 };
60
61 return ff_get_format(avctx, pix_fmts);
62}
63
66{
67 int err, bit_depth;
69 int coded_width = FFALIGN(header->frame_info.frame_width, 16);
70 int coded_height = FFALIGN(header->frame_info.frame_height, 16);
71 APVDecodeContext *apv = avctx->priv_data;
72
73 avctx->profile = header->frame_info.profile_idc;
74 avctx->level = header->frame_info.level_idc;
75
76 bit_depth = header->frame_info.bit_depth_minus8 + 8;
77 av_assert1(bit_depth >= 10 && bit_depth <= 16); // checked by CBS
78 if (bit_depth % 2) {
79 avpriv_request_sample(avctx, "Bit depth %d", bit_depth);
81 }
82
83 pix_fmt = apv_format_table[header->frame_info.chroma_format_idc][(bit_depth - 10) >> 1];
84 if (pix_fmt == AV_PIX_FMT_NONE) {
85 avpriv_request_sample(avctx, "YUVA444P14");
87 }
88
89 if (avctx->coded_width != coded_width ||
90 avctx->coded_height != coded_height) {
91 err = ff_set_dimensions(avctx, coded_width, coded_height);
92 if (err < 0) {
93 // Unsupported frame size.
94 return err;
95 }
96 }
97
98 avctx->width = header->frame_info.frame_width;
99 avctx->height = header->frame_info.frame_height;
100
101 if (pix_fmt != apv->pix_fmt) {
102 apv->pix_fmt = pix_fmt;
103
104 err = get_pixel_format(avctx, pix_fmt);
105 if (err < 0)
106 return err;
107
108 avctx->pix_fmt = err;
109 }
110
111 avctx->sample_aspect_ratio = (AVRational){ 1, 1 };
112
113 avctx->color_primaries = header->color_primaries;
114 avctx->color_trc = header->transfer_characteristics;
115 avctx->colorspace = header->matrix_coefficients;
116 avctx->color_range = header->full_range_flag ? AVCOL_RANGE_JPEG
119
120 avctx->refs = 0;
121 avctx->has_b_frames = 0;
122
123 return 0;
124}
125
130
132
137
139{
140 APVDecodeContext *apv = avctx->priv_data;
141 int err;
142
144
146
147 err = ff_cbs_init(&apv->cbc, AV_CODEC_ID_APV, avctx);
148 if (err < 0)
149 return err;
150
155
156 // Extradata could be set here, but is ignored by the decoder.
157
158 apv->pkt = avctx->internal->in_pkt;
159 ff_apv_dsp_init(&apv->dsp);
160
161 atomic_init(&apv->tile_errors, 0);
162
163 return 0;
164}
165
167{
168 APVDecodeContext *apv = avctx->priv_data;
169
170 apv->nb_unit = 0;
171 av_packet_unref(apv->pkt);
172 ff_cbs_fragment_reset(&apv->au);
173 ff_cbs_flush(apv->cbc);
174}
175
177{
178 APVDecodeContext *apv = avctx->priv_data;
179
181 ff_cbs_fragment_free(&apv->au);
182 ff_cbs_close(&apv->cbc);
183
184 return 0;
185}
186
188 void *output,
189 ptrdiff_t pitch,
190 GetBitContext *gbc,
191 APVEntropyState *entropy_state,
192 const void *constants)
193{
194 APVDecodeContext *apv = avctx->priv_data;
195 int err;
196
197 // Aligned for SIMD use in transquant.
198 LOCAL_ALIGNED_32(int16_t, coeff, [APV_ENTROPY_COEFF_SIZE]);
199 // Zero only the used entries, padding entries may be written but
200 // are never read.
201 memset(coeff, 0, 64 * sizeof(int16_t));
202
203 err = ff_apv_entropy_decode_block(coeff, gbc, entropy_state);
204 if (err < 0)
205 return err;
206
207 apv->dsp.decode_transquant(output, pitch, coeff, constants);
208
209 return 0;
210}
211
213 int job, int thread)
214{
215 APVRawFrame *input = data;
216 APVDecodeContext *apv = avctx->priv_data;
218 const AVPixFmtDescriptor *pix_fmt_desc =
220 int nb_components = pix_fmt_desc->nb_components;
221
222 int tile_index = job / nb_components;
223 int comp_index = job % nb_components;
224
225 int sub_w_shift = comp_index == 0 ? 0 : pix_fmt_desc->log2_chroma_w;
226 int sub_h_shift = comp_index == 0 ? 0 : pix_fmt_desc->log2_chroma_h;
227
228 APVRawTile *tile = &input->tile[tile_index];
229
230 int tile_y = tile_index / tile_info->tile_cols;
231 int tile_x = tile_index % tile_info->tile_cols;
232
233 int tile_start_x = tile_info->col_starts[tile_x];
234 int tile_start_y = tile_info->row_starts[tile_y];
235
236 int tile_width = tile_info->col_starts[tile_x + 1] - tile_start_x;
237 int tile_height = tile_info->row_starts[tile_y + 1] - tile_start_y;
238
239 int tile_mb_width = tile_width / APV_MB_WIDTH;
240 int tile_mb_height = tile_height / APV_MB_HEIGHT;
241
242 int blk_mb_width = 2 >> sub_w_shift;
243 int blk_mb_height = 2 >> sub_h_shift;
244
246
247 GetBitContext gbc;
248
249 APVEntropyState entropy_state = {
250 .log_ctx = avctx,
251 .decode_lut = &ff_apv_decode_lut,
252 .prev_dc = 0,
253 .prev_k_dc = 5,
254 .prev_k_level = 0,
255 };
256
257 int err;
258
259 err = init_get_bits8(&gbc, tile->tile_data[comp_index],
260 tile->tile_header.tile_data_size[comp_index]);
261 if (err < 0)
262 goto fail;
263
264 // Combine the bitstream quantisation matrix with the qp scaling
265 // in advance. (Including qp_shift as well would overflow 16 bits.)
266 // Fix the row ordering at the same time. Everything else which
267 // is constant for the tile component is derived from this by the
268 // DSP code.
269 {
270 static const uint8_t apv_level_scale[6] = { 40, 45, 51, 57, 64, 71 };
271 int qp = tile->tile_header.tile_qp[comp_index];
272 int level_scale = apv_level_scale[qp % 6];
274 int16_t qmatrix_scaled[64];
275
276 for (int y = 0; y < 8; y++) {
277 for (int x = 0; x < 8; x++)
278 qmatrix_scaled[y * 8 + x] = level_scale *
279 input->frame_header.quantization_matrix.q_matrix[comp_index][x][y];
280 }
281
282 apv->dsp.prepare_constants(constants, qmatrix_scaled,
283 bit_depth, qp / 6);
284 }
285
286 for (int mb_y = 0; mb_y < tile_mb_height; mb_y++) {
287 for (int mb_x = 0; mb_x < tile_mb_width; mb_x++) {
288 for (int blk_y = 0; blk_y < blk_mb_height; blk_y++) {
289 for (int blk_x = 0; blk_x < blk_mb_width; blk_x++) {
290 int frame_y = (tile_start_y +
291 APV_MB_HEIGHT * mb_y +
292 APV_TR_SIZE * blk_y) >> sub_h_shift;
293 int frame_x = (tile_start_x +
294 APV_MB_WIDTH * mb_x +
295 APV_TR_SIZE * blk_x) >> sub_w_shift;
296
297 ptrdiff_t frame_pitch = apv->output_frame->linesize[comp_index];
298 uint8_t *block_start = apv->output_frame->data[comp_index] +
299 frame_y * frame_pitch + 2 * frame_x;
300
301 err = apv_decode_block(avctx,
302 block_start, frame_pitch,
303 &gbc, &entropy_state,
304 constants);
305 if (err < 0) {
306 // Error in block decode means entropy desync,
307 // so this is not recoverable.
308 goto fail;
309 }
310 }
311 }
312 }
313 }
314
315 av_log(avctx, AV_LOG_TRACE,
316 "Decoded tile %d component %d: %dx%d MBs starting at (%d,%d)\n",
317 tile_index, comp_index, tile_mb_width, tile_mb_height,
318 tile_start_x, tile_start_y);
319
320 return 0;
321
322fail:
323 av_log(avctx, AV_LOG_VERBOSE,
324 "Decode error in tile %d component %d.\n",
325 tile_index, comp_index);
327 return err;
328}
329
331 const APVRawFrameHeader *fh)
332{
333 int frame_width_in_mbs = (fh->frame_info.frame_width + (APV_MB_WIDTH - 1)) >> 4;
334 int frame_height_in_mbs = (fh->frame_info.frame_height + (APV_MB_HEIGHT - 1)) >> 4;
335 int start_mb, i;
336
337 start_mb = 0;
338 for (i = 0; start_mb < frame_width_in_mbs; i++) {
339 ti->col_starts[i] = start_mb * APV_MB_WIDTH;
340 start_mb += fh->tile_info.tile_width_in_mbs;
341 }
342 ti->col_starts[i] = frame_width_in_mbs * APV_MB_WIDTH;
343 ti->tile_cols = i;
344
345 start_mb = 0;
346 for (i = 0; start_mb < frame_height_in_mbs; i++) {
347 ti->row_starts[i] = start_mb * APV_MB_HEIGHT;
348 start_mb += fh->tile_info.tile_height_in_mbs;
349 }
350 ti->row_starts[i] = frame_height_in_mbs * APV_MB_HEIGHT;
351 ti->tile_rows = i;
352
353 ti->num_tiles = ti->tile_cols * ti->tile_rows;
354}
355
356static int apv_decode(AVCodecContext *avctx, AVFrame *output,
357 APVRawFrame *input)
358{
359 APVDecodeContext *apv = avctx->priv_data;
362 int err, job_count;
363
364 if (!ff_thread_can_start_frame(avctx)) {
365 av_log(avctx, AV_LOG_ERROR, "Multiple primary frames in a packet "
366 "are not supported with frame threading.\n");
368 }
369
370 err = apv_decode_check_format(avctx, &input->frame_header);
371 if (err < 0) {
372 av_log(avctx, AV_LOG_ERROR, "Unsupported format parameters.\n");
373 return err;
374 }
375
376 if (avctx->skip_frame == AVDISCARD_ALL)
377 return 0;
378
381
382 err = ff_thread_get_buffer(avctx, output, 0);
383 if (err < 0)
384 return err;
385
386 apv->cur_raw_frame = input;
387 apv->output_frame = output;
389
391
394 if (err < 0)
395 return err;
396
398
399 if (avctx->hwaccel) {
400 const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
401
402 err = hwaccel->start_frame(avctx, apv->pkt->buf,
403 apv->pkt->data, apv->pkt->size);
404 if (err < 0)
405 return err;
406
407 for (int j = 0; j < desc->nb_components; j++) {
408 for (int i = 0; i < tile_info->num_tiles; i++) {
409 APVRawTile *tile = &input->tile[i];
410 err = hwaccel->decode_slice(avctx, tile->tile_data[j],
411 tile->tile_header.tile_data_size[j]);
412 if (err < 0)
413 return err;
414 }
415 }
416
417 err = hwaccel->end_frame(avctx);
418 if (err < 0)
419 return err;
420
422 } else {
423 // Each component within a tile is independent of every other,
424 // so we can decode all in parallel.
425 job_count = tile_info->num_tiles * desc->nb_components;
426
428 input, NULL, job_count);
429
431 if (err > 0) {
432 av_log(avctx, AV_LOG_ERROR,
433 "Decode errors in %d tile components.\n", err);
434 if (avctx->flags & AV_CODEC_FLAG_OUTPUT_CORRUPT) {
435 // Output the frame anyway.
436 output->flags |= AV_FRAME_FLAG_CORRUPT;
437 } else {
438 return AVERROR_INVALIDDATA;
439 }
440 }
441 }
442
443 return 0;
444}
445
447 const APVRawMetadata *md)
448{
449 int err;
450
451 for (int i = 0; i < md->metadata_count; i++) {
452 const APVRawMetadataPayload *pl = &md->payloads[i];
453
454 switch (pl->payload_type) {
456 {
457 const APVRawMetadataMDCV *mdcv = &pl->mdcv;
459
460 err = ff_decode_mastering_display_new(avctx, frame, &mdm);
461 if (err < 0)
462 return err;
463
464 if (mdm) {
465 for (int j = 0; j < 3; j++) {
466 mdm->display_primaries[j][0] =
467 av_make_q(mdcv->primary_chromaticity_x[j], 1 << 16);
468 mdm->display_primaries[j][1] =
469 av_make_q(mdcv->primary_chromaticity_y[j], 1 << 16);
470 }
471
472 mdm->white_point[0] =
474 mdm->white_point[1] =
476
477 mdm->max_luminance =
478 av_make_q(mdcv->max_mastering_luminance, 1 << 8);
479 mdm->min_luminance =
480 av_make_q(mdcv->min_mastering_luminance, 1 << 14);
481
482 mdm->has_primaries = 1;
483 mdm->has_luminance = 1;
484 }
485 }
486 break;
487 case APV_METADATA_CLL:
488 {
489 const APVRawMetadataCLL *cll = &pl->cll;
491
492 err = ff_decode_content_light_new(avctx, frame, &clm);
493 if (err < 0)
494 return err;
495
496 if (clm) {
497 clm->MaxCLL = cll->max_cll;
498 clm->MaxFALL = cll->max_fall;
499 }
500 }
501 break;
502 default:
503 // Ignore other types of metadata.
504 break;
505 }
506 }
507
508 return 0;
509}
510
512{
513 APVDecodeContext *apv = avctx->priv_data;
514 CodedBitstreamFragment *au = &apv->au;
515 int i, err;
516
517 for (i = apv->nb_unit; i < au->nb_units; i++) {
518 CodedBitstreamUnit *pbu = &au->units[i];
519
520 switch (pbu->type) {
522 err = apv_decode(avctx, frame, pbu->content);
523 frame->pkt_dts = apv->pkt->dts;
524 i++;
525 goto end;
526 case APV_PBU_METADATA:
527 apv_decode_metadata(avctx, frame, pbu->content);
528 break;
533 if (!avctx->internal->is_copy &&
535 av_log(avctx, AV_LOG_WARNING,
536 "Stream contains additional non-primary frames "
537 "which will be ignored by the decoder.\n");
539 }
540 break;
542 case APV_PBU_FILLER:
543 // Not relevant to the decoder.
544 break;
545 default:
546 if (!avctx->internal->is_copy &&
548 av_log(avctx, AV_LOG_WARNING,
549 "Stream contains PBUs with unknown types "
550 "which will be ignored by the decoder.\n");
552 }
553 break;
554 }
555 }
556
557 err = AVERROR(EAGAIN);
558end:
560 apv->nb_unit = i;
561
562 if ((err < 0 && err != AVERROR(EAGAIN)) || apv->au.nb_units == i) {
563 av_packet_unref(apv->pkt);
564 ff_cbs_fragment_reset(&apv->au);
565 apv->nb_unit = 0;
566 }
567 if (!err && !frame->buf[0])
568 err = AVERROR(EAGAIN);
569
570 return err;
571}
572
574{
575 APVDecodeContext *apv = avctx->priv_data;
576 int err;
577
578 do {
579 if (!apv->au.nb_units) {
580 err = ff_decode_get_packet(avctx, apv->pkt);
581 if (err < 0)
582 return err;
583
584 err = ff_cbs_read_packet(apv->cbc, &apv->au, apv->pkt);
585 if (err < 0) {
586 ff_cbs_fragment_reset(&apv->au);
587 av_packet_unref(apv->pkt);
588 av_log(avctx, AV_LOG_ERROR, "Failed to read packet.\n");
589 return err;
590 }
591
592 apv->nb_unit = 0;
593 av_log(avctx, AV_LOG_DEBUG, "Total PBUs on this packet: %d.\n",
594 apv->au.nb_units);
595 }
596
597 err = apv_receive_frame_internal(avctx, frame);
598 } while (err == AVERROR(EAGAIN));
599
600 return err;
601}
602
603#if HAVE_THREADS
604static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
605{
606 APVDecodeContext *asrc = src->priv_data;
607 APVDecodeContext *adst = dst->priv_data;
608
609 adst->pix_fmt = asrc->pix_fmt;
610
611 return 0;
612}
613#endif
614
616 .p.name = "apv",
617 CODEC_LONG_NAME("Advanced Professional Video"),
618 .p.type = AVMEDIA_TYPE_VIDEO,
619 .p.id = AV_CODEC_ID_APV,
620 .priv_data_size = sizeof(APVDecodeContext),
625 UPDATE_THREAD_CONTEXT(update_thread_context),
626 .p.capabilities = AV_CODEC_CAP_DR1 |
629 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
630 .hw_configs = (const AVCodecHWConfigInternal *const []) {
631#if CONFIG_APV_VULKAN_HWACCEL
632 HWACCEL_VULKAN(apv),
633#endif
634 NULL
635 },
636};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
const FFCodec ff_apv_decoder
Definition apv_decode.c:615
static AVOnce apv_entropy_once
Definition apv_decode.c:131
static av_cold void apv_decode_flush(AVCodecContext *avctx)
Definition apv_decode.c:166
static av_cold int apv_decode_init(AVCodecContext *avctx)
Definition apv_decode.c:138
static enum AVPixelFormat get_pixel_format(AVCodecContext *avctx, enum AVPixelFormat pix_fmt)
Definition apv_decode.c:50
static int apv_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
Definition apv_decode.c:511
static av_cold void apv_entropy_build_decode_lut(void)
Definition apv_decode.c:133
static enum AVPixelFormat apv_format_table[5][4]
Definition apv_decode.c:40
static int apv_decode_tile_component(AVCodecContext *avctx, void *data, int job, int thread)
Definition apv_decode.c:212
static int apv_decode_block(AVCodecContext *avctx, void *output, ptrdiff_t pitch, GetBitContext *gbc, APVEntropyState *entropy_state, const void *constants)
Definition apv_decode.c:187
static int apv_decode_metadata(AVCodecContext *avctx, AVFrame *frame, const APVRawMetadata *md)
Definition apv_decode.c:446
APVVLCLUT ff_apv_decode_lut
Definition apv_decode.c:48
static void apv_derive_tile_info(APVDerivedTileInfo *ti, const APVRawFrameHeader *fh)
Definition apv_decode.c:330
static int apv_decode(AVCodecContext *avctx, AVFrame *output, APVRawFrame *input)
Definition apv_decode.c:356
static av_cold int apv_decode_close(AVCodecContext *avctx)
Definition apv_decode.c:176
static int apv_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition apv_decode.c:573
static const CodedBitstreamUnitType apv_decompose_unit_types[]
Definition apv_decode.c:126
static int apv_decode_check_format(AVCodecContext *avctx, const APVRawFrameHeader *header)
Definition apv_decode.c:64
#define APV_ENTROPY_COEFF_SIZE
Definition apv_decode.h:110
int ff_apv_entropy_decode_block(int16_t *restrict coeff, GetBitContext *restrict gbc, APVEntropyState *restrict state)
Entropy decode a single 8x8 block to coefficients.
void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
Build the decoder VLC look-up tables.
Definition apv_entropy.c:62
#define APV_DSP_CONSTANTS_SIZE
Size of the buffer holding constants for decode_transquant(), which must be large enough for the layo...
Definition apv_dsp.h:31
static const uint8_t apv_level_scale[6]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Libavcodec external API header.
static int FUNC tile_info(CodedBitstreamContext *ctx, RWContext *rw, APVRawTileInfo *current, const APVRawFrameHeader *fh)
static int FUNC tile(CodedBitstreamContext *ctx, RWContext *rw, APVRawTile *current, int tile_idx, uint32_t tile_size)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters if all frames are skipped due to the skip_frame setting...
#define CODEC_LONG_NAME(str)
#define NULL
Definition coverity.c:32
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
Definition decode.c:2355
int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
Definition decode.c:2310
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition decode.c:255
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition decode.c:1248
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
Definition decode.c:2383
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Definition utils.c:91
static enum AVPixelFormat pix_fmt
static AVFrame * frame
void(* flush)(AVBSFContext *ctx)
Definition dts2pts.c:615
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
static const char * hwaccel
Definition ffplay.c:406
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition get_bits.h:544
#define fail
Definition test.h:479
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition codec.h:102
#define AV_CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
Definition avcodec.h:221
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition codec.h:98
@ AV_CODEC_ID_APV
Definition codec_id.h:323
@ AVDISCARD_ALL
discard all
Definition defs.h:248
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
Definition frame.h:690
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition rational.h:71
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
#define HWACCEL_VULKAN(codec)
Definition hwconfig.h:78
static const vec_s16 constants[5]
static const int level_scale[2][6]
Definition intra.c:336
@ APV_PBU_ALPHA_FRAME
Definition apv.h:31
@ APV_PBU_PRIMARY_FRAME
Definition apv.h:27
@ APV_PBU_PREVIEW_FRAME
Definition apv.h:29
@ APV_PBU_NON_PRIMARY_FRAME
Definition apv.h:28
@ APV_PBU_FILLER
Definition apv.h:34
@ APV_PBU_ACCESS_UNIT_INFORMATION
Definition apv.h:32
@ APV_PBU_DEPTH_FRAME
Definition apv.h:30
@ APV_PBU_METADATA
Definition apv.h:33
@ APV_TR_SIZE
Definition apv.h:42
@ APV_MB_HEIGHT
Definition apv.h:41
@ APV_MB_WIDTH
Definition apv.h:40
@ APV_METADATA_CLL
Definition apv.h:84
@ APV_METADATA_MDCV
Definition apv.h:83
av_cold void ff_apv_dsp_init(APVDSPContext *dsp)
Definition apv_dsp.c:144
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
common internal api header.
Multithreading API for decoders.
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
const char * desc
Definition libsvtav1.c:83
#define FFALIGN(x, a)
Definition macros.h:78
#define LOCAL_ALIGNED_32(t, v,...)
const char data[16]
Definition mxf.c:155
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition pixfmt.h:815
@ 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_YUVA444P10
Definition pixfmt.h:601
#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
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379
#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
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:606
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:603
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
int ff_thread_can_start_frame(AVCodecContext *avctx)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:121
static const uint8_t header[24]
Definition sdr2.c:68
#define FF_ARRAY_ELEMS(a)
@ memory_order_relaxed
Definition stdatomic.h:29
#define atomic_fetch_add_explicit(object, operand, order)
Definition stdatomic.h:297
#define atomic_load_explicit(object, order)
Definition stdatomic.h:247
#define atomic_store_explicit(object, desired, order)
Definition stdatomic.h:253
#define atomic_init(obj, value)
Definition stdatomic.h:119
void(* prepare_constants)(void *constants, const int16_t *qmatrix, int bit_depth, int qp_shift)
Fill the constants buffer used by decode_transquant() for all blocks with the same quantisation param...
Definition apv_dsp.h:39
void(* decode_transquant)(void *output, ptrdiff_t pitch, const int16_t *input, const void *constants)
Run transquant for a single block.
Definition apv_dsp.h:49
atomic_int tile_errors
Definition apv_decode.h:146
APVRawFrame * cur_raw_frame
Definition apv_decode.h:141
uint8_t warned_unknown_pbu_types
Definition apv_decode.h:152
CodedBitstreamFragment au
Definition apv_decode.h:139
uint8_t warned_additional_frames
Definition apv_decode.h:151
APVDSPContext dsp
Definition apv_decode.h:137
enum AVPixelFormat pix_fmt
Definition apv_decode.h:148
CodedBitstreamContext * cbc
Definition apv_decode.h:136
AVPacket * pkt
Definition apv_decode.h:143
APVDerivedTileInfo tile_info
Definition apv_decode.h:140
void * hwaccel_picture_private
Definition apv_decode.h:145
AVFrame * output_frame
Definition apv_decode.h:144
uint16_t col_starts[APV_MAX_TILE_COLS+1]
Definition apv_decode.h:131
uint16_t row_starts[APV_MAX_TILE_ROWS+1]
Definition apv_decode.h:132
APVRawTileInfo tile_info
Definition cbs_apv.h:80
APVRawFrameInfo frame_info
Definition cbs_apv.h:68
APVRawQuantizationMatrix quantization_matrix
Definition cbs_apv.h:78
uint32_t frame_width
Definition cbs_apv.h:48
uint8_t bit_depth_minus8
Definition cbs_apv.h:51
uint32_t frame_height
Definition cbs_apv.h:49
APVRawFrameHeader frame_header
Definition cbs_apv.h:103
APVRawTile tile[APV_MAX_TILE_COUNT]
Definition cbs_apv.h:105
uint16_t max_cll
Definition cbs_apv.h:143
uint16_t max_fall
Definition cbs_apv.h:144
uint16_t primary_chromaticity_x[3]
Definition cbs_apv.h:134
uint16_t white_point_chromaticity_y
Definition cbs_apv.h:137
uint16_t primary_chromaticity_y[3]
Definition cbs_apv.h:135
uint32_t min_mastering_luminance
Definition cbs_apv.h:139
uint16_t white_point_chromaticity_x
Definition cbs_apv.h:136
uint32_t max_mastering_luminance
Definition cbs_apv.h:138
APVRawMetadataMDCV mdcv
Definition cbs_apv.h:170
uint32_t payload_type
Definition cbs_apv.h:166
APVRawMetadataCLL cll
Definition cbs_apv.h:171
uint8_t q_matrix[APV_MAX_NUM_COMP][APV_TR_SIZE][APV_TR_SIZE]
Definition cbs_apv.h:57
uint32_t tile_width_in_mbs
Definition cbs_apv.h:61
uint32_t tile_height_in_mbs
Definition cbs_apv.h:62
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:644
int width
picture width / height.
Definition avcodec.h:605
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 sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition avcodec.h:629
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition avcodec.h:1429
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition avcodec.h:713
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
int refs
number of reference frames
Definition avcodec.h:705
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition avcodec.h:665
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition avcodec.h:692
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Definition avcodec.h:1638
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition avcodec.h:620
struct AVCodecInternal * internal
Private context used for internal data.
Definition avcodec.h:478
void * priv_data
Definition avcodec.h:470
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition avcodec.h:1677
int is_copy
When using frame-threaded decoding, this field is set for the first worker thread (e....
Definition internal.h:54
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition internal.h:83
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition frame.h:723
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:524
Mastering display metadata capable of representing the color volume of the display used to master the...
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition packet.h:593
int size
Definition packet.h:611
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition packet.h:609
uint8_t * data
Definition packet.h:610
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition pixdesc.h:80
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition pixdesc.h:89
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition pixdesc.h:71
Rational number (pair of numerator and denominator).
Definition rational.h:58
const CodedBitstreamUnitType * decompose_unit_types
Array of unit types which should be decomposed when reading.
Definition cbs.h:255
int nb_decompose_unit_types
Length of the decompose_unit_types array.
Definition cbs.h:259
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
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
#define avpriv_request_sample(...)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
#define md