Go to the documentation of this file.
19 #ifndef AVCODEC_CBS_INTERNAL_H
20 #define AVCODEC_CBS_INTERNAL_H
46 #define CBS_APV CONFIG_CBS_APV
49 #define CBS_AV1 CONFIG_CBS_AV1
52 #define CBS_H264 CONFIG_CBS_H264
55 #define CBS_H265 CONFIG_CBS_H265
58 #define CBS_H266 CONFIG_CBS_H266
61 #define CBS_JPEG CONFIG_CBS_JPEG
64 #define CBS_MPEG2 CONFIG_CBS_MPEG2
67 #define CBS_VP8 CONFIG_CBS_VP8
70 #define CBS_VP9 CONFIG_CBS_VP9
209 const int *subscripts, uint32_t *write_to,
210 uint32_t range_min, uint32_t range_max);
213 int width,
const char *
name, uint32_t *write_to);
217 const int *subscripts, uint32_t
value,
218 uint32_t range_min, uint32_t range_max);
225 const int *subscripts,
int32_t *write_to,
235 #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
239 #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
243 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
248 #define CBS_TRACE_READ_START() \
249 GetBitContext trace_start; \
251 if (ctx->trace_enable) \
252 trace_start = *gbc; \
256 #define CBS_TRACE_READ_END() \
258 if (ctx->trace_enable) { \
259 int start_position = get_bits_count(&trace_start); \
260 int end_position = get_bits_count(gbc); \
261 av_assert0(start_position <= end_position); \
262 ctx->trace_read_callback(ctx->trace_context, &trace_start, \
263 end_position - start_position, \
264 name, subscripts, value); \
269 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \
271 const int *subscripts = NULL; \
272 CBS_TRACE_READ_END(); \
277 #define CBS_TRACE_READ_END_VALUE_ONLY() \
279 if (ctx->trace_enable) { \
280 ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
281 name, subscripts, value); \
286 #define CBS_TRACE_WRITE_START() \
287 int start_position; \
289 if (ctx->trace_enable) \
290 start_position = put_bits_count(pbc);; \
294 #define CBS_TRACE_WRITE_END() \
296 if (ctx->trace_enable) { \
297 int end_position = put_bits_count(pbc); \
298 av_assert0(start_position <= end_position); \
299 ctx->trace_write_callback(ctx->trace_context, pbc, \
300 end_position - start_position, \
301 name, subscripts, value); \
306 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \
308 const int *subscripts = NULL; \
309 CBS_TRACE_WRITE_END(); \
316 #define CBS_TRACE_WRITE_END_VALUE_ONLY() \
318 if (ctx->trace_enable) { \
320 init_put_bits(&tmp, pbc->buf, start_position); \
321 skip_put_bits(&tmp, start_position); \
322 ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
323 name, subscripts, value); \
328 #define CBS_TRACE_READ_START() do { } while (0)
329 #define CBS_TRACE_READ_END() do { } while (0)
330 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() do { } while (0)
331 #define CBS_TRACE_READ_END_VALUE_ONLY() do { } while (0)
332 #define CBS_TRACE_WRITE_START() do { } while (0)
333 #define CBS_TRACE_WRITE_END() do { } while (0)
334 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() do { } while (0)
335 #define CBS_TRACE_WRITE_END_VALUE_ONLY() do { } while (0)
338 #define TYPE_LIST(...) { __VA_ARGS__ }
339 #define CBS_UNIT_TYPE_POD(type_, structure) { \
340 .nb_unit_types = 1, \
341 .unit_type.list = { type_ }, \
342 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
343 .content_size = sizeof(structure), \
344 .type.ref = { .nb_offsets = 0 }, \
346 #define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
347 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
348 .unit_type.range.start = range_start, \
349 .unit_type.range.end = range_end, \
350 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
351 .content_size = sizeof(structure), \
352 .type.ref = { .nb_offsets = 0 }, \
355 #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
356 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
357 .unit_type.list = TYPE_LIST types, \
358 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
359 .content_size = sizeof(structure), \
360 .type.ref = { .nb_offsets = 1, \
361 .offsets = { offsetof(structure, ref_field) } }, \
363 #define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
364 CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
366 #define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field) { \
367 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
368 .unit_type.range.start = range_start, \
369 .unit_type.range.end = range_end, \
370 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
371 .content_size = sizeof(structure), \
372 .type.ref = { .nb_offsets = 1, \
373 .offsets = { offsetof(structure, ref_field) } }, \
376 #define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func) { \
377 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
378 .unit_type.list = TYPE_LIST types, \
379 .content_type = CBS_CONTENT_TYPE_COMPLEX, \
380 .content_size = sizeof(structure), \
381 .type.complex = { .content_free = free_func }, \
383 #define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) \
384 CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
386 #define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
CodedBitstreamUnitType start
struct CodedBitstreamUnitTypeDescriptor::@84::@86 ref
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
void(* close)(CodedBitstreamContext *ctx)
RefStruct is an API for creating reference-counted objects with minimal overhead.
const AVClass * priv_class
enum CBSContentType content_type
Context structure for coded bitstream operations.
void(* content_free)(AVRefStructOpaque opaque, void *content)
int CBS_FUNC() read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, uint32_t *write_to)
int CBS_FUNC() write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
CodedBitstreamUnitType end
Coded bitstream unit structure.
int(* discarded_unit)(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
CodedBitstreamUnitType list[CBS_MAX_LIST_UNIT_TYPES]
Coded bitstream fragment structure, combining one or more units.
int(* content_clone)(void **new_content, CodedBitstreamUnit *unit)
void CBS_FUNC() trace_header(CodedBitstreamContext *ctx, const char *name)
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
struct CodedBitstreamUnitTypeDescriptor::@84::@87 complex
int(* read_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Describe the class of an AVClass context structure.
int CBS_FUNC() read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
size_t offsets[CBS_MAX_REF_OFFSETS]
int CBS_FUNC() write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
struct CodedBitstreamUnitTypeDescriptor::@83::@85 range
const CodedBitstreamUnitTypeDescriptor * unit_types
int CBS_FUNC() read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max)
@ CBS_CONTENT_TYPE_COMPLEX
static const uint8_t header[24]
int(* write_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
union CodedBitstreamUnitTypeDescriptor::@84 type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
const CodedBitstreamType CBS_FUNC(type_apv)
void(* flush)(CodedBitstreamContext *ctx)
@ CBS_MAX_LIST_UNIT_TYPES
int CBS_FUNC() write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max)
int(* assemble_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int(* split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
union CodedBitstreamUnitTypeDescriptor::@83 unit_type
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.