Go to the documentation of this file.
19 #ifndef AVCODEC_CBS_INTERNAL_H
20 #define AVCODEC_CBS_INTERNAL_H
170 const int *subscripts, uint32_t *write_to,
171 uint32_t range_min, uint32_t range_max);
174 int width,
const char *
name, uint32_t *write_to);
178 const int *subscripts, uint32_t
value,
179 uint32_t range_min, uint32_t range_max);
186 const int *subscripts,
int32_t *write_to,
196 #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
200 #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
204 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
208 #define CBS_TRACE_READ_START() \
209 GetBitContext trace_start; \
211 if (ctx->trace_enable) \
212 trace_start = *gbc; \
216 #define CBS_TRACE_READ_END() \
218 if (ctx->trace_enable) { \
219 int start_position = get_bits_count(&trace_start); \
220 int end_position = get_bits_count(gbc); \
221 av_assert0(start_position <= end_position); \
222 ctx->trace_read_callback(ctx->trace_context, &trace_start, \
223 end_position - start_position, \
224 name, subscripts, value); \
229 #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \
231 const int *subscripts = NULL; \
232 CBS_TRACE_READ_END(); \
237 #define CBS_TRACE_READ_END_VALUE_ONLY() \
239 if (ctx->trace_enable) { \
240 ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
241 name, subscripts, value); \
246 #define CBS_TRACE_WRITE_START() \
247 int start_position; \
249 if (ctx->trace_enable) \
250 start_position = put_bits_count(pbc);; \
254 #define CBS_TRACE_WRITE_END() \
256 if (ctx->trace_enable) { \
257 int end_position = put_bits_count(pbc); \
258 av_assert0(start_position <= end_position); \
259 ctx->trace_write_callback(ctx->trace_context, pbc, \
260 end_position - start_position, \
261 name, subscripts, value); \
266 #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \
268 const int *subscripts = NULL; \
269 CBS_TRACE_WRITE_END(); \
276 #define CBS_TRACE_WRITE_END_VALUE_ONLY() \
278 if (ctx->trace_enable) { \
280 init_put_bits(&tmp, pbc->buf, start_position); \
281 skip_put_bits(&tmp, start_position); \
282 ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
283 name, subscripts, value); \
287 #define TYPE_LIST(...) { __VA_ARGS__ }
288 #define CBS_UNIT_TYPE_POD(type_, structure) { \
289 .nb_unit_types = 1, \
290 .unit_type.list = { type_ }, \
291 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
292 .content_size = sizeof(structure), \
293 .type.ref = { .nb_offsets = 0 }, \
295 #define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
296 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
297 .unit_type.range.start = range_start, \
298 .unit_type.range.end = range_end, \
299 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
300 .content_size = sizeof(structure), \
301 .type.ref = { .nb_offsets = 0 }, \
304 #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
305 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
306 .unit_type.list = TYPE_LIST types, \
307 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
308 .content_size = sizeof(structure), \
309 .type.ref = { .nb_offsets = 1, \
310 .offsets = { offsetof(structure, ref_field) } }, \
312 #define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
313 CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
315 #define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field) { \
316 .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
317 .unit_type.range.start = range_start, \
318 .unit_type.range.end = range_end, \
319 .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
320 .content_size = sizeof(structure), \
321 .type.ref = { .nb_offsets = 1, \
322 .offsets = { offsetof(structure, ref_field) } }, \
325 #define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func) { \
326 .nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
327 .unit_type.list = TYPE_LIST types, \
328 .content_type = CBS_CONTENT_TYPE_COMPLEX, \
329 .content_size = sizeof(structure), \
330 .type.complex = { .content_free = free_func }, \
332 #define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) \
333 CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
335 #define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
CodedBitstreamUnitType start
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)
const AVClass * priv_class
int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, uint32_t value)
enum CBSContentType content_type
const CodedBitstreamType ff_cbs_type_vp9
Context structure for coded bitstream operations.
RefStruct is an API for creating reference-counted objects with minimal overhead.
@ CBS_MAX_LIST_UNIT_TYPES
int ff_cbs_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)
CodedBitstreamUnitType end
Coded bitstream unit structure.
union CodedBitstreamUnitTypeDescriptor::@47 type
int ff_cbs_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)
int(* discarded_unit)(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
CodedBitstreamUnitType list[CBS_MAX_LIST_UNIT_TYPES]
const CodedBitstreamType ff_cbs_type_mpeg2
Coded bitstream fragment structure, combining one or more units.
int ff_cbs_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)
int(* content_clone)(void **new_content, CodedBitstreamUnit *unit)
void(* content_free)(FFRefStructOpaque opaque, void *content)
int(* read_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Describe the class of an AVClass context structure.
size_t offsets[CBS_MAX_REF_OFFSETS]
void ff_cbs_trace_header(CodedBitstreamContext *ctx, const char *name)
union CodedBitstreamUnitTypeDescriptor::@46 unit_type
AVCodecID
Identify the syntax and semantics of the bitstream.
const CodedBitstreamType ff_cbs_type_jpeg
const CodedBitstreamUnitTypeDescriptor * unit_types
@ CBS_CONTENT_TYPE_COMPLEX
static const uint8_t header[24]
const CodedBitstreamType ff_cbs_type_av1
const CodedBitstreamType ff_cbs_type_h266
struct CodedBitstreamUnitTypeDescriptor::@46::@48 range
int(* write_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
int ff_cbs_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)
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 ff_cbs_type_vp8
int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, uint32_t *write_to)
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
const CodedBitstreamType ff_cbs_type_h265
void(* flush)(CodedBitstreamContext *ctx)
struct CodedBitstreamUnitTypeDescriptor::@47::@49 ref
int(* assemble_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int(* split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
const CodedBitstreamType ff_cbs_type_h264
struct CodedBitstreamUnitTypeDescriptor::@47::@50 complex