40 return LCEVC_I420_10_LE;
42 return LCEVC_I420_12_LE;
44 return LCEVC_I420_14_LE;
48 return LCEVC_I422_10_LE;
50 return LCEVC_I422_12_LE;
52 return LCEVC_I422_14_LE;
56 return LCEVC_I444_10_LE;
58 return LCEVC_I444_12_LE;
60 return LCEVC_I444_14_LE;
68 return LCEVC_GRAY_10_LE;
70 return LCEVC_GRAY_12_LE;
72 return LCEVC_GRAY_14_LE;
75 return LCEVC_ColorFormat_Unknown;
79 LCEVC_PictureDesc *
desc, LCEVC_PictureHandle *picture)
88 if (res != LCEVC_Success)
95 desc->sampleAspectRatioNum =
frame->sample_aspect_ratio.num;
96 desc->sampleAspectRatioDen =
frame->sample_aspect_ratio.den;
97 desc->colorRange = LCEVC_ColorRange_Unknown;
99 desc->colorRange = LCEVC_ColorRange_Full;
101 desc->colorRange = LCEVC_ColorRange_Limited;
102 desc->colorPrimaries = (LCEVC_ColorPrimaries)
frame->color_primaries;
103 desc->matrixCoefficients = (LCEVC_MatrixCoefficients)
frame->colorspace;
104 desc->transferCharacteristics = (LCEVC_TransferCharacteristics)
frame->color_trc;
113 if (res != LCEVC_Success) {
121 LCEVC_PictureHandle *picture)
124 LCEVC_PictureDesc
desc ;
126 LCEVC_PicturePlaneDesc
planes[4] = { 0 };
127 LCEVC_ReturnCode res;
130 if (res != LCEVC_Success)
134 for (
int i = 0;
i < 4;
i++) {
141 if (res != LCEVC_Success) {
149 LCEVC_PictureHandle picture;
150 LCEVC_ReturnCode res;
154 res = LCEVC_ReceiveDecoderBase (lcevc->
decoder, &picture);
155 if (res != LCEVC_Success && res != LCEVC_Again)
158 if (res == LCEVC_Again)
161 LCEVC_GetPictureUserData(lcevc->
decoder, picture, (
void **)&
base);
164 res = LCEVC_FreePicture(lcevc->
decoder, picture);
165 if (res != LCEVC_Success)
178 LCEVC_PictureHandle picture;
179 LCEVC_PictureDesc
desc, base_desc;
180 LCEVC_ReturnCode res;
183 if (!sd || fmt == LCEVC_ColorFormat_Unknown || lcevc->
passthrough_mode == 1)
186 res = LCEVC_SendDecoderEnhancementData(lcevc->
decoder, lcevc->
last_pts,
188 if (res != LCEVC_Success) {
199 LCEVC_FreePicture(lcevc->
decoder, picture);
204 res = LCEVC_SetPictureUserData(lcevc->
decoder, picture, opaque);
205 if (res != LCEVC_Success) {
206 LCEVC_FreePicture(lcevc->
decoder, picture);
212 res = LCEVC_SendDecoderBase(lcevc->
decoder, lcevc->
last_pts, picture, -1, opaque);
213 if (res != LCEVC_Success) {
214 LCEVC_FreePicture(lcevc->
decoder, picture);
221 if (res != LCEVC_Success ||
225 if (res == LCEVC_Success &&
226 desc.width == base_desc.width &&
227 desc.height == base_desc.height &&
228 desc.colorFormat == base_desc.colorFormat) {
238 memset(&picture, 0,
sizeof(picture));
243 res = LCEVC_SendDecoderPicture(lcevc->
decoder, picture);
244 if (res != LCEVC_Success) {
245 LCEVC_FreePicture(lcevc->
decoder, picture);
254 LCEVC_SynchronizeDecoder(lcevc->
decoder, 0);
265 LCEVC_PictureDesc
desc;
266 LCEVC_DecodeInformation info;
267 LCEVC_PictureHandle picture;
268 LCEVC_ReturnCode res;
271 res = LCEVC_ReceiveDecoderPicture(lcevc->
decoder, &picture, &info);
272 }
while (res == LCEVC_Again);
273 if (res != LCEVC_Success)
276 res = LCEVC_GetPictureDesc(lcevc->
decoder, picture, &
desc);
277 if (res != LCEVC_Success) {
278 LCEVC_FreePicture(lcevc->
decoder, picture);
287 out->crop_bottom =
desc.cropBottom;
288 out->crop_left =
desc.cropLeft;
289 out->crop_right =
desc.cropRight;
290 out->sample_aspect_ratio.num =
desc.sampleAspectRatioNum;
291 out->sample_aspect_ratio.den =
desc.sampleAspectRatioDen;
293 out->height =
desc.height +
out->crop_top +
out->crop_bottom;
295 if (
desc.colorRange == LCEVC_ColorRange_Full)
297 else if (
desc.colorRange == LCEVC_ColorRange_Limited)
306 "color_range %d, color_primaries %d, colorspace %d, color_trc %d, "
307 "hasEnhancement %d, enhanced %d\n",
309 out->crop_top,
out->crop_bottom,
out->crop_left,
out->crop_right,
310 out->sample_aspect_ratio.num,
out->sample_aspect_ratio.den,
311 out->color_range,
out->color_primaries,
out->colorspace,
out->color_trc,
312 info.hasEnhancement, info.enhanced);
314 res = LCEVC_FreePicture(lcevc->
decoder, picture);
315 if (res != LCEVC_Success)
343 LCEVC_PictureHandle pic,
const LCEVC_DecodeInformation *info,
344 const uint8_t *
data, uint32_t
size,
void *logctx)
348 unsigned int level = 0;
366 LCEVC_FlushDecoder(lcevc->
decoder);
368 LCEVC_DestroyDecoder(lcevc->
decoder);
371 ff_cbs_fragment_free(lcevc->
frag);
373 ff_cbs_close(&lcevc->
cbc);
376 memset(lcevc, 0,
sizeof(*lcevc));
407 return LCEVC_LogDisabled;
409 return LCEVC_LogFatal;
411 return LCEVC_LogError;
413 return LCEVC_LogWarning;
415 return LCEVC_LogInfo;
417 return LCEVC_LogDebug;
419 return LCEVC_LogTrace;
424 LCEVC_AccelContextHandle
dummy = { 0 };
425 const int32_t event = LCEVC_Log;
426 LCEVC_ReturnCode res;
431 if (LCEVC_CreateDecoder(&lcevc->
decoder,
dummy) != LCEVC_Success) {
437 res = LCEVC_ConfigureDecoderString(lcevc->
decoder,
"pipeline", lcevc->
pipeline);
438 if (res != LCEVC_Success) {
440 LCEVC_DestroyDecoder(lcevc->
decoder);
447 LCEVC_ConfigureDecoderInt(lcevc->
decoder,
"log_level",
level);
448 res = LCEVC_ConfigureDecoderInt(lcevc->
decoder,
"threads", lcevc->
threads);
449 if (res != LCEVC_Success) {
451 LCEVC_DestroyDecoder(lcevc->
decoder);
455 if (res != LCEVC_Success) {
457 LCEVC_DestroyDecoder(lcevc->
decoder);
461 if (res != LCEVC_Success) {
463 LCEVC_DestroyDecoder(lcevc->
decoder);
467 if (res != LCEVC_Success) {
469 LCEVC_DestroyDecoder(lcevc->
decoder);
472 LCEVC_ConfigureDecoderIntArray(lcevc->
decoder,
"events", 1, &event);
475 if (LCEVC_InitializeDecoder(lcevc->
decoder) != LCEVC_Success) {
477 LCEVC_DestroyDecoder(lcevc->
decoder);
552 ff_cbs_fragment_reset(lcevc->
frag);
562#define OFFSET(x) offsetof(FFLCEVCContext, x)
563#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM)
566 { .i64 = 0 }, -1, 2,
FLAGS, .unit =
"passthrough_mode" },
572 { .i64 = 1 }, 0, 1,
FLAGS },
574 { .i64 = 0 }, 0, 1,
FLAGS },
576 { .i64 = 1 }, 0, INT_MAX,
FLAGS },
585 .class_name =
"liblcevc_dec",
static const char *const format[]
static const CodedBitstreamUnitType decompose_unit_types[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
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.
reference-counted frame API
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ 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...
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_QUIET
Print no output.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
void av_opt_free(void *obj)
Free all allocated objects in obj.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
static LCEVC_ColorFormat map_format(int format)
static int alloc_base_frame(FFLCEVCContext *lcevc, const AVFrame *frame, LCEVC_PictureDesc *desc, LCEVC_PictureHandle *picture)
static av_cold int lcevc_frame_init_cb(AVRefStructOpaque unused, void *obj)
static void lcevc_frame_reset_cb(AVRefStructOpaque unused, void *obj)
static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx, LCEVC_PictureHandle *picture)
int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const AVFrame *frame, enum AVPixelFormat *format, enum AVPixelFormat *base_format, int *width, int *height)
static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
int ff_lcevc_process(void *logctx, AVFrame *frame)
static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, AVFrame *out)
static const AVOption lcevc_opts[]
static int lcevc_flush_pictures(FFLCEVCContext *lcevc)
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)
static av_cold void lcevc_frame_free_entry_cb(AVRefStructOpaque unused, void *obj)
static const uint8_t level_map[LCEVC_LogLevelCount]
static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
static int lcevc_init(FFLCEVCContext *lcevc)
int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
static void lcevc_free(AVRefStructOpaque unused, void *obj)
static const AVClass lcevcdec_context_class
uintptr_t LCEVC_DecoderHandle
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
@ LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG
enum AVPixelFormat ff_lcevc_depth_type[4][4]
const struct FFLCEVCDim ff_lcevc_resolution_type[63]
static const struct @257111027162314367033347246032313251342043035002 planes[]
@ AV_CLASS_CATEGORY_DECODER
Memory handling functions.
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_VIDEO_MAX_PLANES
Maximum number of planes in any pixel format.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ 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...
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_PIX_FMT_YUV422P14
AVColorPrimaries
Chromaticity coordinates of the source primaries.
AVColorTransferCharacteristic
Color Transfer Characteristic.
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P10
AVColorSpace
YUV colorspace type.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
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.
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.
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
const CodedBitstreamUnitType * decompose_unit_types
Array of unit types which should be decomposed when reading.
int nb_decompose_unit_types
Length of the decompose_unit_types array.
struct CodedBitstreamContext * cbc
LCEVC_DecoderHandle decoder
struct CodedBitstreamFragment * frag
struct AVRefStructPool * frame_pool
pool of FFLCEVCFrame
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
void * post_process_opaque
RefStruct reference.
uint8_t chroma_sampling_type
uint16_t custom_resolution_width
uint8_t enhancement_depth_type
uint16_t custom_resolution_height
RefStruct is an API for creating reference-counted objects with minimal overhead.
static enum pl_log_level get_log_level(void)