35 const char *
name,
const int *subscripts,
37 uint32_t range_min, uint32_t range_max)
46 for (
i = 0;
i < 32;
i++) {
49 "%s: bitstream ended.\n",
name);
53 bits[
i] = k ?
'1' :
'0';
59 "%s: more than 31 zeroes.\n",
name);
63 for (j = 0; j <
i; j++) {
65 bits[
i + j + 1] = k ?
'1' :
'0';
71 if (
ctx->trace_enable)
75 if (value < range_min || value > range_max) {
77 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
87 const char *
name,
const int *subscripts,
99 for (
i = 0;
i < 32;
i++) {
102 "%s: bitstream ended.\n",
name);
106 bits[
i] = k ?
'1' :
'0';
112 "%s: more than 31 zeroes.\n",
name);
116 for (j = 0; j <
i; j++) {
118 bits[
i + j + 1] = k ?
'1' :
'0';
127 if (
ctx->trace_enable)
131 if (value < range_min || value > range_max) {
133 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
143 const char *
name,
const int *subscripts,
145 uint32_t range_min, uint32_t range_max)
149 if (value < range_min || value > range_max) {
151 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
161 if (
ctx->trace_enable) {
186 const char *
name,
const int *subscripts,
193 if (value < range_min || value > range_max) {
195 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
204 uvalue = 2 * (uint32_t)
value - 1;
206 uvalue = 2 * (uint32_t)-
value;
212 if (
ctx->trace_enable) {
220 bits[
len +
i + 1] = (uvalue + 1) >> (
len -
i - 1) & 1 ?
'1' :
'0';
241 int bits_left = payload_size * 8 - cur_pos;
242 return (bits_left > 0 &&
250 unsigned int ctb_log2_size_y =
sps->log2_min_luma_coding_block_size_minus3 + 3 +
251 sps->log2_diff_max_min_luma_coding_block_size;
256 #define HEADER(name) do { \
257 ff_cbs_trace_header(ctx, name); \
260 #define CHECK(call) do { \
266 #define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
267 #define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name)
268 #define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name)
269 #define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name)
270 #define FUNC_SEI(name) FUNC_NAME1(READWRITE, sei, name)
272 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
274 #define u(width, name, range_min, range_max) \
275 xu(width, name, current->name, range_min, range_max, 0, )
276 #define ub(width, name) \
277 xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )
278 #define flag(name) ub(1, name)
279 #define ue(name, range_min, range_max) \
280 xue(name, current->name, range_min, range_max, 0, )
281 #define i(width, name, range_min, range_max) \
282 xi(width, name, current->name, range_min, range_max, 0, )
283 #define ib(width, name) \
284 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0, )
285 #define se(name, range_min, range_max) \
286 xse(name, current->name, range_min, range_max, 0, )
288 #define us(width, name, range_min, range_max, subs, ...) \
289 xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
290 #define ubs(width, name, subs, ...) \
291 xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
292 #define flags(name, subs, ...) \
293 xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
294 #define ues(name, range_min, range_max, subs, ...) \
295 xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
296 #define is(width, name, range_min, range_max, subs, ...) \
297 xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
298 #define ibs(width, name, subs, ...) \
299 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__)
300 #define ses(name, range_min, range_max, subs, ...) \
301 xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
303 #define fixed(width, name, value) do { \
304 av_unused uint32_t fixed_value = value; \
305 xu(width, name, fixed_value, value, value, 0, ); \
310 #define READWRITE read
311 #define RWContext GetBitContext
313 #define xu(width, name, var, range_min, range_max, subs, ...) do { \
315 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
316 SUBSCRIPTS(subs, __VA_ARGS__), \
317 &value, range_min, range_max)); \
320 #define xue(name, var, range_min, range_max, subs, ...) do { \
322 CHECK(cbs_read_ue_golomb(ctx, rw, #name, \
323 SUBSCRIPTS(subs, __VA_ARGS__), \
324 &value, range_min, range_max)); \
327 #define xi(width, name, var, range_min, range_max, subs, ...) do { \
329 CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
330 SUBSCRIPTS(subs, __VA_ARGS__), \
331 &value, range_min, range_max)); \
334 #define xse(name, var, range_min, range_max, subs, ...) do { \
336 CHECK(cbs_read_se_golomb(ctx, rw, #name, \
337 SUBSCRIPTS(subs, __VA_ARGS__), \
338 &value, range_min, range_max)); \
343 #define infer(name, value) do { \
344 current->name = value; \
359 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
361 #define bit_position(rw) (get_bits_count(rw))
362 #define byte_alignment(rw) (get_bits_count(rw) % 8)
364 #define allocate(name, size) do { \
365 name ## _ref = av_buffer_allocz(size + \
366 AV_INPUT_BUFFER_PADDING_SIZE); \
368 return AVERROR(ENOMEM); \
369 name = name ## _ref->data; \
372 #define FUNC(name) FUNC_SEI(name)
376 #define FUNC(name) FUNC_H264(name)
380 #define FUNC(name) FUNC_H265(name)
392 #undef more_rbsp_data
394 #undef byte_alignment
399 #define READWRITE write
400 #define RWContext PutBitContext
402 #define xu(width, name, var, range_min, range_max, subs, ...) do { \
403 uint32_t value = var; \
404 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
405 SUBSCRIPTS(subs, __VA_ARGS__), \
406 value, range_min, range_max)); \
408 #define xue(name, var, range_min, range_max, subs, ...) do { \
409 uint32_t value = var; \
410 CHECK(cbs_write_ue_golomb(ctx, rw, #name, \
411 SUBSCRIPTS(subs, __VA_ARGS__), \
412 value, range_min, range_max)); \
414 #define xi(width, name, var, range_min, range_max, subs, ...) do { \
415 int32_t value = var; \
416 CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
417 SUBSCRIPTS(subs, __VA_ARGS__), \
418 value, range_min, range_max)); \
420 #define xse(name, var, range_min, range_max, subs, ...) do { \
421 int32_t value = var; \
422 CHECK(cbs_write_se_golomb(ctx, rw, #name, \
423 SUBSCRIPTS(subs, __VA_ARGS__), \
424 value, range_min, range_max)); \
427 #define infer(name, value) do { \
428 if (current->name != (value)) { \
429 av_log(ctx->log_ctx, AV_LOG_ERROR, \
430 "%s does not match inferred value: " \
431 "%"PRId64", but should be %"PRId64".\n", \
432 #name, (int64_t)current->name, (int64_t)(value)); \
433 return AVERROR_INVALIDDATA; \
437 #define more_rbsp_data(var) (var)
439 #define bit_position(rw) (put_bits_count(rw))
440 #define byte_alignment(rw) (put_bits_count(rw) % 8)
442 #define allocate(name, size) do { \
444 av_log(ctx->log_ctx, AV_LOG_ERROR, "%s must be set " \
445 "for writing.\n", #name); \
446 return AVERROR_INVALIDDATA; \
450 #define FUNC(name) FUNC_SEI(name)
454 #define FUNC(name) FUNC_H264(name)
458 #define FUNC(name) FUNC_H265(name)
475 #undef more_rbsp_data
477 #undef byte_alignment
530 size_t size, start, end;
540 version = bytestream2_get_byte(&gbc);
551 count = bytestream2_get_byte(&gbc) & 0x1f;
553 for (
i = 0;
i < count;
i++) {
556 size = bytestream2_get_be16(&gbc);
564 frag->
data + start, end - start,
575 count = bytestream2_get_byte(&gbc);
577 for (
i = 0;
i < count;
i++) {
580 size = bytestream2_get_be16(&gbc);
588 frag->
data + start, end - start,
605 size_t size, start, end;
606 int i, j, nb_arrays, nal_unit_type, nb_nals,
version;
615 version = bytestream2_get_byte(&gbc);
625 nb_arrays = bytestream2_get_byte(&gbc);
626 for (
i = 0;
i < nb_arrays;
i++) {
627 nal_unit_type = bytestream2_get_byte(&gbc) & 0x3f;
628 nb_nals = bytestream2_get_be16(&gbc);
631 for (j = 0; j < nb_nals; j++) {
634 size = bytestream2_get_be16(&gbc);
642 frag->
data + start, end - start,
646 "HVCC array %d (%d NAL units of type %d).\n",
647 i, nb_nals, nal_unit_type);
674 #define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \
675 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
676 CodedBitstreamUnit *unit) \
678 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
679 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
680 unsigned int id = ps_var->id_element; \
682 if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \
683 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \
684 " id : %d.\n", id); \
685 return AVERROR_INVALIDDATA; \
687 err = ff_cbs_make_unit_refcounted(ctx, unit); \
690 if (priv->ps_var[id] == priv->active_ ## ps_var) \
691 priv->active_ ## ps_var = NULL ; \
692 av_buffer_unref(&priv->ps_var ## _ref[id]); \
693 av_assert0(unit->content_ref); \
694 priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
695 if (!priv->ps_var ## _ref[id]) \
696 return AVERROR(ENOMEM); \
697 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \
721 switch (unit->
type) {
726 err = cbs_h264_read_sps(
ctx, &gbc,
sps);
730 err = cbs_h264_replace_sps(
ctx, unit);
738 err = cbs_h264_read_sps_extension(
ctx, &gbc, unit->
content);
748 err = cbs_h264_read_pps(
ctx, &gbc,
pps);
752 err = cbs_h264_replace_pps(
ctx, unit);
765 err = cbs_h264_read_slice_header(
ctx, &gbc, &slice->
header);
786 err = cbs_h264_read_aud(
ctx, &gbc, unit->
content);
794 err = cbs_h264_read_sei(
ctx, &gbc, unit->
content);
802 err = cbs_h264_read_filler(
ctx, &gbc, unit->
content);
812 cbs_h264_read_end_of_sequence :
813 cbs_h264_read_end_of_stream)(
ctx, &gbc, unit->
content);
840 switch (unit->
type) {
845 err = cbs_h265_read_vps(
ctx, &gbc,
vps);
849 err = cbs_h265_replace_vps(
ctx, unit);
858 err = cbs_h265_read_sps(
ctx, &gbc,
sps);
862 err = cbs_h265_replace_sps(
ctx, unit);
872 err = cbs_h265_read_pps(
ctx, &gbc,
pps);
876 err = cbs_h265_replace_pps(
ctx, unit);
902 err = cbs_h265_read_slice_segment_header(
ctx, &gbc, &slice->
header);
923 err = cbs_h265_read_aud(
ctx, &gbc, unit->
content);
932 err = cbs_h265_read_sei(
ctx, &gbc, unit->
content,
949 size_t data_size,
int data_bit_start)
951 size_t rest = data_size - (data_bit_start + 7) / 8;
955 data_size > data_bit_start / 8);
961 goto rbsp_stop_one_bit;
966 if (data_bit_start % 8)
967 put_bits(pbc, 8 - data_bit_start % 8,
984 for (; rest > 4; rest -= 4,
pos += 4)
987 for (; rest > 1; rest--,
pos++)
996 i = rest ? (8 -
i) : (8 -
i - data_bit_start % 8);
1011 switch (unit->
type) {
1016 err = cbs_h264_write_sps(
ctx, pbc,
sps);
1020 err = cbs_h264_replace_sps(
ctx, unit);
1030 err = cbs_h264_write_sps_extension(
ctx, pbc, sps_ext);
1040 err = cbs_h264_write_pps(
ctx, pbc,
pps);
1044 err = cbs_h264_replace_pps(
ctx, unit);
1056 err = cbs_h264_write_slice_header(
ctx, pbc, &slice->
header);
1075 err = cbs_h264_write_aud(
ctx, pbc, unit->
content);
1083 err = cbs_h264_write_sei(
ctx, pbc, unit->
content);
1091 err = cbs_h264_write_filler(
ctx, pbc, unit->
content);
1099 err = cbs_h264_write_end_of_sequence(
ctx, pbc, unit->
content);
1107 err = cbs_h264_write_end_of_stream(
ctx, pbc, unit->
content);
1115 "NAL unit type %"PRIu32
".\n", unit->
type);
1128 switch (unit->
type) {
1133 err = cbs_h265_write_vps(
ctx, pbc,
vps);
1137 err = cbs_h265_replace_vps(
ctx, unit);
1147 err = cbs_h265_write_sps(
ctx, pbc,
sps);
1151 err = cbs_h265_replace_sps(
ctx, unit);
1161 err = cbs_h265_write_pps(
ctx, pbc,
pps);
1165 err = cbs_h265_replace_pps(
ctx, unit);
1190 err = cbs_h265_write_slice_segment_header(
ctx, pbc, &slice->
header);
1208 err = cbs_h265_write_aud(
ctx, pbc, unit->
content);
1217 err = cbs_h265_write_sei(
ctx, pbc, unit->
content,
1227 "NAL unit type %"PRIu32
".\n", unit->
type);
1239 if (nal_unit_index == 0) {
1256 int err,
i, zero_run;
1280 if (i < frag->nb_units - 1)
1282 "unaligned padding on non-final NAL unit.\n");
1304 if ((unit->
data[
sp] & ~3) == 0) {
1308 zero_run = unit->
data[
sp] == 0;
1423 .nb_ref_offsets = 1,
1459 .nb_ref_offsets = 1,
1471 .nb_ref_offsets = 1,
1497 .read_unit = &cbs_h264_read_nal_unit,
1664 switch (
ctx->codec->codec_id) {
static void flush(AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_tell(GetByteContext *g)
int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf)
Insert a new unit into a fragment with the given data bitstream.
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *str, const int *subscripts, const char *bits, int64_t value)
int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
static void cbs_h264_close(CodedBitstreamContext *ctx)
static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
static void cbs_h264_flush(CodedBitstreamContext *ctx)
static void cbs_h265_flush(CodedBitstreamContext *ctx)
static int cbs_write_ue_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max)
const CodedBitstreamType ff_cbs_type_h265
static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, int cur_pos)
static void cbs_h265_pic_size_in_ctbs(const H265RawSPS *sps, unsigned int *width, unsigned int *height)
static int cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet)
static const CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[]
static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
static void cbs_h264_free_sei(void *opaque, uint8_t *content)
static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
const SEIMessageTypeDescriptor * ff_cbs_sei_find_type(CodedBitstreamContext *ctx, int payload_type)
Find the type descriptor for the given payload type.
static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max)
static const SEIMessageTypeDescriptor cbs_sei_h264_types[]
static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
#define i(width, name, range_min, range_max)
static int cbs_read_se_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max)
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id, CodedBitstreamUnitType type, int nal_unit_index)
const CodedBitstreamType ff_cbs_type_h264
static void cbs_h265_free_sei(void *opaque, uint8_t *content)
static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[]
#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element)
static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
static const SEIMessageTypeDescriptor cbs_sei_common_types[]
static void cbs_h265_close(CodedBitstreamContext *ctx)
static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
static const SEIMessageTypeDescriptor cbs_sei_h265_types[]
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC() sei_buffering_period(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIBufferingPeriod *current, SEIMessageState *sei)
static int FUNC() sei_pic_timing(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTiming *current, SEIMessageState *sei)
static int FUNC() sei_pan_scan_rect(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPanScanRect *current, SEIMessageState *sei)
static int FUNC() sei_recovery_point(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIRecoveryPoint *current, SEIMessageState *sei)
static int FUNC() sei_display_orientation(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIDisplayOrientation *current, SEIMessageState *sei)
static int FUNC() sei_decoded_picture_hash(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIDecodedPictureHash *current, SEIMessageState *sei)
static int FUNC() sei_active_parameter_sets(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIActiveParameterSets *current, SEIMessageState *sei)
static int FUNC() sei_alpha_channel_info(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIAlphaChannelInfo *current, SEIMessageState *sei)
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static int FUNC() extension_data(CodedBitstreamContext *ctx, RWContext *rw, H265RawExtensionData *current)
static int FUNC() sei_time_code(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEITimeCode *current, SEIMessageState *sei)
#define CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
@ CBS_CONTENT_TYPE_COMPLEX
#define CBS_UNIT_TYPE_POD(type, structure)
#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func)
#define MAX_UINT_BITS(length)
void ff_cbs_sei_free_message_list(SEIRawMessageList *list)
Free all SEI messages in a message list.
#define SEI_MESSAGE_RW(codec, name)
#define SEI_MESSAGE_TYPE_END
static int FUNC() alternative_transfer_characteristics(CodedBitstreamContext *ctx, RWContext *rw, SEIRawAlternativeTransferCharacteristics *current, SEIMessageState *state)
static int FUNC() user_data_unregistered(CodedBitstreamContext *ctx, RWContext *rw, SEIRawUserDataUnregistered *current, SEIMessageState *state)
static int FUNC() filler_payload(CodedBitstreamContext *ctx, RWContext *rw, SEIRawFillerPayload *current, SEIMessageState *state)
static int FUNC() user_data_registered(CodedBitstreamContext *ctx, RWContext *rw, SEIRawUserDataRegistered *current, SEIMessageState *state)
static int FUNC() mastering_display_colour_volume(CodedBitstreamContext *ctx, RWContext *rw, SEIRawMasteringDisplayColourVolume *current, SEIMessageState *state)
static int FUNC() content_light_level_info(CodedBitstreamContext *ctx, RWContext *rw, SEIRawContentLightLevelInfo *current, SEIMessageState *state)
#define AV_CEIL_RSHIFT(a, b)
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id, int small_padding, int use_ref)
Split an input packet into NAL units.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
H.264 common definitions.
@ H264_NAL_AUXILIARY_SLICE
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static int put_bits_count(PutBitContext *s)
static int put_bits_left(PutBitContext *s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static const uint8_t header[24]
@ SEI_TYPE_ALPHA_CHANNEL_INFO
@ SEI_TYPE_DECODED_PICTURE_HASH
@ SEI_TYPE_RECOVERY_POINT
@ SEI_TYPE_FILLER_PAYLOAD
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_ACTIVE_PARAMETER_SETS
@ SEI_TYPE_DISPLAY_ORIENTATION
@ SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
@ SEI_TYPE_USER_DATA_UNREGISTERED
@ SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
@ SEI_TYPE_BUFFERING_PERIOD
@ SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
void * priv_data
Format private data.
Context structure for coded bitstream operations.
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
size_t data_size
The number of bytes in the bitstream.
uint8_t * data
Pointer to the bitstream form of this fragment.
AVBufferRef * data_ref
A reference to the buffer containing data.
uint8_t last_slice_nal_unit_type
const H264RawPPS * active_pps
AVBufferRef * sps_ref[H264_MAX_SPS_COUNT]
const H264RawSPS * active_sps
AVBufferRef * pps_ref[H264_MAX_PPS_COUNT]
H264RawSPS * sps[H264_MAX_SPS_COUNT]
H264RawPPS * pps[H264_MAX_PPS_COUNT]
CodedBitstreamH2645Context common
const H265RawVPS * active_vps
AVBufferRef * vps_ref[HEVC_MAX_VPS_COUNT]
const H265RawSPS * active_sps
H265RawVPS * vps[HEVC_MAX_VPS_COUNT]
CodedBitstreamH2645Context common
AVBufferRef * pps_ref[HEVC_MAX_PPS_COUNT]
H265RawSPS * sps[HEVC_MAX_SPS_COUNT]
const H265RawPPS * active_pps
AVBufferRef * sps_ref[HEVC_MAX_SPS_COUNT]
H265RawPPS * pps[HEVC_MAX_PPS_COUNT]
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
CodedBitstreamUnitType type
Codec-specific type of this unit.
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
AVBufferRef * data_ref
A reference to the buffer containing data.
AVBufferRef * rbsp_buffer_ref
H264RawSliceHeader header
H265RawSliceHeader header
static int ref[MAX_W *MAX_W]