FFmpeg
Loading...
Searching...
No Matches
lcevcdec.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 "libavutil/avassert.h"
20#include "libavutil/frame.h"
21#include "libavutil/imgutils.h"
22#include "libavutil/log.h"
23#include "libavutil/mem.h"
24#include "libavutil/opt.h"
25#include "libavutil/refstruct.h"
26
27#include "cbs.h"
28#include "cbs_lcevc.h"
29#include "decode.h"
30#include "lcevc_parse.h"
31#include "lcevcdec.h"
32#include "lcevctab.h"
33
34static LCEVC_ColorFormat map_format(int format)
35{
36 switch (format) {
38 return LCEVC_I420_8;
40 return LCEVC_I420_10_LE;
42 return LCEVC_I420_12_LE;
44 return LCEVC_I420_14_LE;
46 return LCEVC_I422_8;
48 return LCEVC_I422_10_LE;
50 return LCEVC_I422_12_LE;
52 return LCEVC_I422_14_LE;
54 return LCEVC_I444_8;
56 return LCEVC_I444_10_LE;
58 return LCEVC_I444_12_LE;
60 return LCEVC_I444_14_LE;
61 case AV_PIX_FMT_NV12:
62 return LCEVC_NV12_8;
63 case AV_PIX_FMT_NV21:
64 return LCEVC_NV21_8;
66 return LCEVC_GRAY_8;
68 return LCEVC_GRAY_10_LE;
70 return LCEVC_GRAY_12_LE;
72 return LCEVC_GRAY_14_LE;
73 }
74
75 return LCEVC_ColorFormat_Unknown;
76}
77
79 const AVFrame *frame, LCEVC_PictureHandle *picture)
80{
81 LCEVC_PictureDesc desc;
82 LCEVC_ColorFormat fmt = map_format(frame->format);
83 LCEVC_PicturePlaneDesc planes[AV_VIDEO_MAX_PLANES] = { 0 };
84 int width = frame->width - frame->crop_left - frame->crop_right;
85 int height = frame->height - frame->crop_top - frame->crop_bottom;
86 LCEVC_ReturnCode res;
87
88 res = LCEVC_DefaultPictureDesc(&desc, fmt, width, height);
89 if (res != LCEVC_Success)
90 return AVERROR_EXTERNAL;
91
92 desc.cropTop = frame->crop_top;
93 desc.cropBottom = frame->crop_bottom;
94 desc.cropLeft = frame->crop_left;
95 desc.cropRight = frame->crop_right;
96 desc.sampleAspectRatioNum = frame->sample_aspect_ratio.num;
97 desc.sampleAspectRatioDen = frame->sample_aspect_ratio.den;
98 desc.colorRange = LCEVC_ColorRange_Unknown;
99 if (frame->color_range == AVCOL_RANGE_JPEG)
100 desc.colorRange = LCEVC_ColorRange_Full;
101 else if (frame->color_range == AVCOL_RANGE_MPEG)
102 desc.colorRange = LCEVC_ColorRange_Limited;
103 desc.colorPrimaries = (LCEVC_ColorPrimaries)frame->color_primaries;
104 desc.matrixCoefficients = (LCEVC_MatrixCoefficients)frame->colorspace;
105 desc.transferCharacteristics = (LCEVC_TransferCharacteristics)frame->color_trc;
106
107 for (int i = 0; i < AV_VIDEO_MAX_PLANES; i++) {
108 planes[i].firstSample = frame->data[i];
109 planes[i].rowByteStride = frame->linesize[i];
110 }
111
112 /* Allocate LCEVC Picture */
113 res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture);
114 if (res != LCEVC_Success) {
115 return AVERROR_EXTERNAL;
116 }
117
118 return 0;
119}
120
121static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx,
122 LCEVC_PictureHandle *picture)
123{
124 FFLCEVCContext *lcevc = frame_ctx->lcevc;
125 LCEVC_PictureDesc desc ;
126 LCEVC_ColorFormat fmt = map_format(frame_ctx->frame->format);
127 LCEVC_PicturePlaneDesc planes[4] = { 0 };
128 LCEVC_ReturnCode res;
129
130 res = LCEVC_DefaultPictureDesc(&desc, fmt, frame_ctx->frame->width, frame_ctx->frame->height);
131 if (res != LCEVC_Success)
132 return AVERROR_EXTERNAL;
133
134 /* Set plane description */
135 for (int i = 0; i < 4; i++) {
136 planes[i].firstSample = frame_ctx->frame->data[i];
137 planes[i].rowByteStride = frame_ctx->frame->linesize[i];
138 }
139
140 /* Allocate LCEVC Picture */
141 res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture);
142 if (res != LCEVC_Success) {
143 return AVERROR_EXTERNAL;
144 }
145 return 0;
146}
147
148static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
149{
150 FFLCEVCContext *lcevc = frame_ctx->lcevc;
151 LCEVC_ColorFormat fmt = map_format(in->format);
153 AVFrame *opaque;
154 LCEVC_PictureHandle picture;
155 LCEVC_ReturnCode res;
156 int ret;
157
158 if (!sd || fmt == LCEVC_ColorFormat_Unknown)
159 return 1;
160
161 res = LCEVC_SendDecoderEnhancementData(lcevc->decoder, lcevc->last_pts,
162 sd->data, sd->size);
163 if (res != LCEVC_Success) {
164 ret = AVERROR_EXTERNAL;
165 goto end;
166 }
167
168 ret = alloc_base_frame(lcevc, in, &picture);
169 if (ret < 0)
170 goto end;
171
172 opaque = av_frame_clone(in);
173 if (!opaque) {
174 LCEVC_FreePicture(lcevc->decoder, picture);
175 ret = AVERROR(ENOMEM);
176 goto end;
177 }
178
179 res = LCEVC_SetPictureUserData(lcevc->decoder, picture, opaque);
180 if (res != LCEVC_Success) {
181 LCEVC_FreePicture(lcevc->decoder, picture);
182 av_frame_free(&opaque);
183 ret = AVERROR_EXTERNAL;
184 goto end;
185 }
186
187 res = LCEVC_SendDecoderBase(lcevc->decoder, lcevc->last_pts, picture, -1, opaque);
188 if (res != LCEVC_Success) {
189 LCEVC_FreePicture(lcevc->decoder, picture);
190 av_frame_free(&opaque);
191 ret = AVERROR_EXTERNAL;
192 goto end;
193 }
194
195 memset(&picture, 0, sizeof(picture));
196 ret = alloc_enhanced_frame(frame_ctx, &picture);
197 if (ret < 0)
198 goto end;
199
200 res = LCEVC_SendDecoderPicture(lcevc->decoder, picture);
201 if (res != LCEVC_Success) {
202 LCEVC_FreePicture(lcevc->decoder, picture);
203 ret = AVERROR_EXTERNAL;
204 goto end;
205 }
206
207 ret = 0;
208end:
209 lcevc->last_pts++;
210
211 return ret;
212}
213
214static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
215{
216 FFLCEVCContext *lcevc = frame_ctx->lcevc;
217 LCEVC_PictureDesc desc;
218 LCEVC_DecodeInformation info;
219 LCEVC_PictureHandle picture;
220 LCEVC_ReturnCode res;
221
222 do {
223 res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info);
224 } while (res == LCEVC_Again);
225 if (res != LCEVC_Success)
226 return AVERROR_EXTERNAL;
227
228 res = LCEVC_GetPictureDesc(lcevc->decoder, picture, &desc);
229 if (res != LCEVC_Success) {
230 LCEVC_FreePicture(lcevc->decoder, picture);
231 return AVERROR_EXTERNAL;
232 }
233
235 av_frame_copy_props(frame_ctx->frame, (AVFrame *)info.baseUserData);
236 av_frame_move_ref(out, frame_ctx->frame);
237
238 out->crop_top = desc.cropTop;
239 out->crop_bottom = desc.cropBottom;
240 out->crop_left = desc.cropLeft;
241 out->crop_right = desc.cropRight;
242 out->sample_aspect_ratio.num = desc.sampleAspectRatioNum;
243 out->sample_aspect_ratio.den = desc.sampleAspectRatioDen;
244 out->width = desc.width + out->crop_left + out->crop_right;
245 out->height = desc.height + out->crop_top + out->crop_bottom;
246 out->color_range = AVCOL_RANGE_UNSPECIFIED;
247 if (desc.colorRange == LCEVC_ColorRange_Full)
248 out->color_range = AVCOL_RANGE_JPEG;
249 else if (desc.colorRange == LCEVC_ColorRange_Limited)
250 out->color_range = AVCOL_RANGE_MPEG;
251 out->color_primaries = (enum AVColorPrimaries)desc.colorPrimaries;
252 out->colorspace = (enum AVColorSpace)desc.matrixCoefficients;
253 out->color_trc = (enum AVColorTransferCharacteristic)desc.transferCharacteristics;
254
255 av_log(lcevc, AV_LOG_DEBUG, "out PTS %"PRId64", %dx%d, "
256 "%zu/%zu/%zu/%zu, "
257 "SAR %d:%d, "
258 "color_range %d, color_primaries %d, colorspace %d, color_trc %d, "
259 "hasEnhancement %d, enhanced %d\n",
260 out->pts, out->width, out->height,
261 out->crop_top, out->crop_bottom, out->crop_left, out->crop_right,
262 out->sample_aspect_ratio.num, out->sample_aspect_ratio.den,
263 out->color_range, out->color_primaries, out->colorspace, out->color_trc,
264 info.hasEnhancement, info.enhanced);
265
266 res = LCEVC_FreePicture(lcevc->decoder, picture);
267 if (res != LCEVC_Success)
268 return AVERROR_EXTERNAL;
269
270 return 0;
271}
272
274{
275 LCEVC_PictureHandle picture;
276 LCEVC_ReturnCode res;
277
278 while (1) {
279 AVFrame *base = NULL;
280 res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture);
281 if (res != LCEVC_Success && res != LCEVC_Again)
282 return AVERROR_EXTERNAL;
283
284 if (res == LCEVC_Again)
285 break;
286
287 LCEVC_GetPictureUserData(lcevc->decoder, picture, (void **)&base);
289
290 res = LCEVC_FreePicture(lcevc->decoder, picture);
291 if (res != LCEVC_Success)
292 return AVERROR_EXTERNAL;
293 }
294
295 return 0;
296}
297
299{
300 FFLCEVCContext *lcevc = frame_ctx->lcevc;
301 int ret;
302
303 ret = generate_output(frame_ctx, out);
304 if (ret < 0)
305 return ret;
306
307 return lcevc_flush_pictures(lcevc);
308}
309
310static const uint8_t level_map[LCEVC_LogLevelCount] = {
311 [LCEVC_LogFatal] = AV_LOG_FATAL,
312 [LCEVC_LogError] = AV_LOG_ERROR,
313 [LCEVC_LogWarning] = AV_LOG_WARNING,
314 [LCEVC_LogInfo] = AV_LOG_INFO,
315 [LCEVC_LogDebug] = AV_LOG_DEBUG,
316 [LCEVC_LogTrace] = AV_LOG_TRACE,
317};
318
319static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event,
320 LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info,
321 const uint8_t *data, uint32_t size, void *logctx)
322{
323 switch (event) {
324 case LCEVC_Log: {
325 unsigned int level = 0;
326 if (size < 3)
327 break;
328 int ret = sscanf(data, "%u ", &level);
329 if (ret != 1 || level >= LCEVC_LogLevelCount || !level_map[level])
330 break;
331 av_log(logctx, level_map[level], "%s\n", data + 2);
332 break;
333 }
334 default:
335 break;
336 }
337}
338
339static void lcevc_free(AVRefStructOpaque unused, void *obj)
340{
341 FFLCEVCContext *lcevc = obj;
342 if (lcevc->initialized == FF_LCEVCDEC_INIT) {
343 LCEVC_FlushDecoder(lcevc->decoder);
345 LCEVC_DestroyDecoder(lcevc->decoder);
346 }
347 if (lcevc->frag)
348 ff_cbs_fragment_free(lcevc->frag);
349 av_freep(&lcevc->frag);
350 ff_cbs_close(&lcevc->cbc);
352 memset(lcevc, 0, sizeof(*lcevc));
353}
354
356{
358
359 frame->frame = av_frame_alloc();
360 if (!frame->frame)
361 return AVERROR(ENOMEM);
362 return 0;
363}
364
366{
368
369 av_frame_unref(frame->frame);
370 av_refstruct_unref(&frame->lcevc);
371}
372
374{
376
377 av_frame_free(&frame->frame);
378}
379
380static int get_log_level(int level)
381{
382 if (level <= AV_LOG_QUIET)
383 return LCEVC_LogDisabled;
384 if (level <= AV_LOG_FATAL)
385 return LCEVC_LogFatal;
386 if (level <= AV_LOG_ERROR)
387 return LCEVC_LogError;
388 if (level <= AV_LOG_WARNING)
389 return LCEVC_LogWarning;
390 if (level <= AV_LOG_INFO)
391 return LCEVC_LogInfo;
392 if (level <= AV_LOG_DEBUG)
393 return LCEVC_LogDebug;
394
395 return LCEVC_LogTrace;
396}
397
398static int lcevc_init(FFLCEVCContext *lcevc)
399{
400 LCEVC_AccelContextHandle dummy = { 0 };
401 const int32_t event = LCEVC_Log;
402 LCEVC_ReturnCode res;
403 int level;
404
406
407 if (LCEVC_CreateDecoder(&lcevc->decoder, dummy) != LCEVC_Success) {
408 av_log(lcevc, AV_LOG_ERROR, "Failed to create LCEVC decoder\n");
409 return AVERROR_EXTERNAL;
410 }
411
412 if (lcevc->pipeline) {
413 res = LCEVC_ConfigureDecoderString(lcevc->decoder, "pipeline", lcevc->pipeline);
414 if (res != LCEVC_Success) {
415 av_log(lcevc, AV_LOG_ERROR, "Failed to set pipeline to \"%s\"\n", lcevc->pipeline);
416 LCEVC_DestroyDecoder(lcevc->decoder);
417 return AVERROR_EXTERNAL;
418 }
419 }
420
421 level = get_log_level(lcevc->loglevel);
422
423 LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", level);
424 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "threads", lcevc->threads);
425 if (res != LCEVC_Success) {
426 av_log(lcevc, AV_LOG_ERROR, "Failed to set threads to %d\n", lcevc->threads);
427 LCEVC_DestroyDecoder(lcevc->decoder);
428 return AVERROR_EXTERNAL;
429 }
430 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "passthrough_mode", lcevc->passthrough_mode);
431 if (res != LCEVC_Success) {
432 av_log(lcevc, AV_LOG_ERROR, "Failed to set passthrough_mode to %d\n", lcevc->passthrough_mode);
433 LCEVC_DestroyDecoder(lcevc->decoder);
434 return AVERROR_EXTERNAL;
435 }
436 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "allow_dithering", lcevc->allow_dithering);
437 if (res != LCEVC_Success) {
438 av_log(lcevc, AV_LOG_ERROR, "Failed to set allow_dithering to %d\n", lcevc->allow_dithering);
439 LCEVC_DestroyDecoder(lcevc->decoder);
440 return AVERROR_EXTERNAL;
441 }
442 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "highlight_residuals", lcevc->highlight_residuals);
443 if (res != LCEVC_Success) {
444 av_log(lcevc, AV_LOG_ERROR, "Failed to set highlight_residuals to %d\n", lcevc->highlight_residuals);
445 LCEVC_DestroyDecoder(lcevc->decoder);
446 return AVERROR_EXTERNAL;
447 }
448 LCEVC_ConfigureDecoderIntArray(lcevc->decoder, "events", 1, &event);
449 LCEVC_SetDecoderEventCallback(lcevc->decoder, event_callback, lcevc);
450
451 if (LCEVC_InitializeDecoder(lcevc->decoder) != LCEVC_Success) {
452 av_log(lcevc, AV_LOG_ERROR, "Failed to initialize LCEVC decoder\n");
453 LCEVC_DestroyDecoder(lcevc->decoder);
454 return AVERROR_EXTERNAL;
455 }
456
458
459 return 0;
460}
461
462int ff_lcevc_process(void *logctx, AVFrame *frame)
463{
464 FrameDecodeData *fdd = frame->private_ref;
465 FFLCEVCFrame *frame_ctx = fdd->post_process_opaque;
466 FFLCEVCContext *lcevc = frame_ctx->lcevc;
467 int ret;
468
469 if (lcevc->initialized == FF_LCEVCDEC_UNINIT) {
470 ret = lcevc_init(lcevc);
471 if (ret < 0)
472 return ret;
473 } else if (lcevc->initialized == FF_LCEVCDEC_FAIL)
474 return 0;
475
476 av_assert0(frame_ctx->frame);
477
478
479 ret = lcevc_send_frame(frame_ctx, frame);
480 if (ret)
481 return ret < 0 ? ret : 0;
482
483 ret = lcevc_receive_frame(frame_ctx, frame);
484 if (ret < 0)
485 return ret;
486
488
489 return 0;
490}
491
493 enum AVPixelFormat *format, int *width, int *height)
494{
496 const LCEVCRawGlobalConfig *gc;
498 int ret;
499
500 ret = ff_cbs_read(lcevc->cbc, lcevc->frag, NULL, sd->data, sd->size);
501 if (ret < 0) {
502 av_log(lcevc, AV_LOG_ERROR, "Failed to parse Access Unit.\n");
503 goto end;
504 }
505
506 ret = ff_cbs_lcevc_find_process_block(lcevc->cbc, lcevc->frag,
508 if (ret < 0) {
509 ret = 0;
510 goto end;
511 }
512
513 gc = block->payload;
514
516 if (gc->resolution_type < 63) {
519 } else {
522 }
523
524 ret = 0;
525end:
526 ff_cbs_fragment_reset(lcevc->frag);
527
528 return ret;
529}
530
535
536#define OFFSET(x) offsetof(FFLCEVCContext, x)
537#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM)
538static const AVOption lcevc_opts[] = {
539 { "passthrough_mode", "Set passthrough mode", OFFSET(passthrough_mode), AV_OPT_TYPE_INT,
540 { .i64 = 0 }, -1, 2, FLAGS, .unit = "passthrough_mode" },
541 { "disable", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, .unit = "passthrough_mode" },
542 { "allow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .unit = "passthrough_mode" },
543 { "force", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .unit = "passthrough_mode" },
544 { "scale", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .unit = "passthrough_mode" },
545 { "allow_dithering", "Allow dithering", OFFSET(allow_dithering), AV_OPT_TYPE_BOOL,
546 { .i64 = 1 }, 0, 1, FLAGS },
547 { "highlight_residuals", "Highlight residuals", OFFSET(highlight_residuals), AV_OPT_TYPE_BOOL,
548 { .i64 = 0 }, 0, 1, FLAGS },
549 { "threads", "Thread count", OFFSET(threads), AV_OPT_TYPE_INT,
550 { .i64 = 1 }, 0, INT_MAX, FLAGS },
551 { "pipeline", "Decoding pipeline", OFFSET(pipeline), AV_OPT_TYPE_STRING,
552 { .str = NULL }, 0, 0, FLAGS },
553 { NULL },
554};
555#undef OFFSET
556#undef FLAGS
557
559 .class_name = "liblcevc_dec",
560 .item_name = av_default_item_name,
561 .option = lcevc_opts,
562 .version = LIBAVUTIL_VERSION_INT,
563 .category = AV_CLASS_CATEGORY_DECODER,
564};
565
566int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
567{
568 FFLCEVCContext *lcevc = NULL;
569 const AVDictionaryEntry *t;
570 int ret;
571
572 lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
573 if (!lcevc)
574 return AVERROR(ENOMEM);
575
577 av_opt_set_defaults(lcevc);
578
579 lcevc->loglevel = loglevel;
580
581 ret = av_opt_set_dict2(lcevc, options, 0);
582 if (ret < 0)
583 return ret;
584
585 if (t = av_dict_iterate(*options, NULL)) {
586 av_log(NULL, AV_LOG_FATAL, "liblcevc-dec option %s not found.\n", t->key);
588 }
589
590 lcevc->frag = av_mallocz(sizeof(*lcevc->frag));
591 if (!lcevc->frag) {
592 ret = AVERROR(ENOMEM);
593 goto fail;
594 }
595
596 ret = ff_cbs_init(&lcevc->cbc, AV_CODEC_ID_LCEVC, lcevc);
597 if (ret < 0)
598 goto fail;
599
602
607 if (!lcevc->frame_pool) {
608 ret = AVERROR(ENOMEM);
609 goto fail;
610 }
611
612 *plcevc = lcevc;
613 return 0;
614fail:
615 av_refstruct_unref(&lcevc);
616 return ret;
617}
static const char *const format[]
Definition af_aiir.c:445
static FILE * out
static const CodedBitstreamUnitType decompose_unit_types[]
Definition apv_parser.c:178
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
int ff_cbs_lcevc_find_process_block(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, uint32_t payload_type, LCEVCRawProcessBlock **iter)
Iterate over blocks with the given payload type in an access unit.
Definition cbs_lcevc.c:662
#define FLAGS
Definition cmdutils.c:596
#define NULL
Definition coverity.c:32
static int16_t block[64]
Definition dct.c:125
static AVFrame * frame
static int dummy
Definition ffplay.c:4846
reference-counted frame API
#define fail
Definition test.h:479
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
@ AV_CODEC_ID_LCEVC
Definition codec_id.h:613
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition dict.c:43
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition error.h:59
#define AVERROR(e)
Definition error.h:45
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition error.h:63
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition frame.c:496
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition frame.c:659
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Definition frame.c:725
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition frame.c:523
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:483
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
Definition frame.h:236
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_QUIET
Print no output.
Definition log.h:192
#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_FATAL
Something went wrong and recovery is not possible.
Definition log.h:204
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1758
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition opt.c:2042
misc image utilities
static LCEVC_ColorFormat map_format(int format)
Definition lcevcdec.c:34
static av_cold int lcevc_frame_init_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:355
static int alloc_base_frame(FFLCEVCContext *lcevc, const AVFrame *frame, LCEVC_PictureHandle *picture)
Definition lcevcdec.c:78
static void lcevc_frame_reset_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:365
int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const AVFrame *frame, enum AVPixelFormat *format, int *width, int *height)
Definition lcevcdec.c:492
static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx, LCEVC_PictureHandle *picture)
Definition lcevcdec.c:121
static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:214
int ff_lcevc_process(void *logctx, AVFrame *frame)
Definition lcevcdec.c:462
static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:298
static const AVOption lcevc_opts[]
Definition lcevcdec.c:538
static int lcevc_flush_pictures(FFLCEVCContext *lcevc)
Definition lcevcdec.c:273
static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info, const uint8_t *data, uint32_t size, void *logctx)
Definition lcevcdec.c:319
static av_cold void lcevc_frame_free_entry_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:373
static const uint8_t level_map[LCEVC_LogLevelCount]
Definition lcevcdec.c:310
static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
Definition lcevcdec.c:148
static int lcevc_init(FFLCEVCContext *lcevc)
Definition lcevcdec.c:398
int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
Definition lcevcdec.c:566
#define OFFSET(x)
Definition lcevcdec.c:536
static void lcevc_free(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:339
static const AVClass lcevcdec_context_class
Definition lcevcdec.c:558
@ FF_LCEVCDEC_INIT
Definition lcevcdec.h:39
@ FF_LCEVCDEC_FAIL
Definition lcevcdec.h:40
@ FF_LCEVCDEC_UNINIT
Definition lcevcdec.h:38
uintptr_t LCEVC_DecoderHandle
Definition lcevcdec.h:31
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition cbs.h:66
@ LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG
Definition lcevc.h:71
@ LCEVC_NON_IDR_NUT
Definition lcevc.h:60
@ LCEVC_IDR_NUT
Definition lcevc.h:61
enum AVPixelFormat ff_lcevc_depth_type[4][4]
Definition lcevctab.c:38
const struct FFLCEVCDim ff_lcevc_resolution_type[63]
Definition lcevctab.c:22
#define av_cold
Definition attributes.h:117
const char * desc
Definition libsvtav1.c:83
static const struct @257111027162314367033347246032313251342043035002 planes[]
@ AV_CLASS_CATEGORY_DECODER
Definition log.h:35
Memory handling functions.
static const char * obj
Definition mscl.c:57
const char data[16]
Definition mxf.c:149
AVOptions.
#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:771
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:754
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:788
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_VIDEO_MAX_PLANES
Maximum number of planes in any pixel format.
Definition pixfmt.h:40
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
Definition pixfmt.h:321
@ 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_NV21
as above, but U and V bytes are swapped
Definition pixfmt.h:97
@ 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_GRAY12LE
Y , 12bpp, little-endian.
Definition pixfmt.h:319
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
Definition pixfmt.h:361
@ 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
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_YUV444P10
Definition pixfmt.h:551
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:711
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 void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition refstruct.h:292
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition refstruct.h:94
static AVRefStructPool * av_refstruct_pool_alloc_ext(size_t size, unsigned flags, void *opaque, int(*init_cb)(AVRefStructOpaque opaque, void *obj), void(*reset_cb)(AVRefStructOpaque opaque, void *obj), void(*free_entry_cb)(AVRefStructOpaque opaque, void *obj), void(*free_cb)(AVRefStructOpaque opaque))
A wrapper around av_refstruct_pool_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition refstruct.h:258
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
Definition log.h:76
char * key
Definition dict.h:91
Structure to hold side data for an AVFrame.
Definition frame.h:334
size_t size
Definition frame.h:337
uint8_t * data
Definition frame.h:336
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 width
Definition frame.h:551
int height
Definition frame.h:551
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
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition frame.h:566
AVOption.
Definition opt.h:428
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
int passthrough_mode
Definition lcevcdec.h:52
struct CodedBitstreamContext * cbc
Definition lcevcdec.h:46
int64_t last_pts
Definition lcevcdec.h:49
int highlight_residuals
Definition lcevcdec.h:54
LCEVC_DecoderHandle decoder
Definition lcevcdec.h:45
uint8_t * pipeline
Definition lcevcdec.h:55
struct CodedBitstreamFragment * frag
Definition lcevcdec.h:47
struct AVRefStructPool * frame_pool
pool of FFLCEVCFrame
Definition lcevcdec.h:48
int allow_dithering
Definition lcevcdec.h:53
const AVClass * class
Definition lcevcdec.h:44
FFLCEVCContext * lcevc
Definition lcevcdec.h:62
struct AVFrame * frame
Definition lcevcdec.h:63
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
Definition decode.h:33
void * post_process_opaque
RefStruct reference.
Definition decode.h:45
uint8_t chroma_sampling_type
Definition cbs_lcevc.h:53
uint16_t custom_resolution_width
Definition cbs_lcevc.h:82
uint8_t resolution_type
Definition cbs_lcevc.h:51
uint8_t enhancement_depth_type
Definition cbs_lcevc.h:55
uint16_t custom_resolution_height
Definition cbs_lcevc.h:83
uint8_t level
Definition svq3.c:208
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
int size
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition refstruct.h:58
static enum pl_log_level get_log_level(void)
uint8_t base
Definition vp3data.h:128