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';
66 value = value << 1 | k;
77 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
78 name, value, range_min, range_max);
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';
133 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
134 name, value, range_min, range_max);
143 const char *
name,
const int *subscripts,
145 uint32_t range_min, uint32_t range_max)
151 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
152 name, value, range_min, range_max);
165 for (i = 0; i <
len; i++)
168 for (i = 0; i <
len; i++)
169 bits[len + i + 1] = (value + 1) >> (len - i - 1) & 1 ?
'1' :
'0';
170 bits[len + len + 1] = 0;
173 name, subscripts, bits, value);
186 const char *
name,
const int *subscripts,
195 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
196 name, value, range_min, range_max);
204 uvalue = 2 * (uint32_t)value - 1;
206 uvalue = 2 * (uint32_t)-value;
216 for (i = 0; i <
len; i++)
219 for (i = 0; i <
len; i++)
220 bits[len + i + 1] = (uvalue + 1) >> (len - i - 1) & 1 ?
'1' :
'0';
221 bits[len + len + 1] = 0;
224 name, subscripts, bits, value);
241 int bits_left = payload_size * 8 - cur_pos;
242 return (bits_left > 0 &&
246 #define HEADER(name) do { \ 247 ff_cbs_trace_header(ctx, name); \ 250 #define CHECK(call) do { \ 256 #define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name 257 #define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name) 258 #define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name) 259 #define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name) 260 #define FUNC_SEI(name) FUNC_NAME1(READWRITE, sei, name) 262 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) 264 #define u(width, name, range_min, range_max) \ 265 xu(width, name, current->name, range_min, range_max, 0, ) 266 #define ub(width, name) \ 267 xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0, ) 268 #define flag(name) ub(1, name) 269 #define ue(name, range_min, range_max) \ 270 xue(name, current->name, range_min, range_max, 0, ) 271 #define i(width, name, range_min, range_max) \ 272 xi(width, name, current->name, range_min, range_max, 0, ) 273 #define ib(width, name) \ 274 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0, ) 275 #define se(name, range_min, range_max) \ 276 xse(name, current->name, range_min, range_max, 0, ) 278 #define us(width, name, range_min, range_max, subs, ...) \ 279 xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__) 280 #define ubs(width, name, subs, ...) \ 281 xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__) 282 #define flags(name, subs, ...) \ 283 xu(1, name, current->name, 0, 1, subs, __VA_ARGS__) 284 #define ues(name, range_min, range_max, subs, ...) \ 285 xue(name, current->name, range_min, range_max, subs, __VA_ARGS__) 286 #define is(width, name, range_min, range_max, subs, ...) \ 287 xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__) 288 #define ibs(width, name, subs, ...) \ 289 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__) 290 #define ses(name, range_min, range_max, subs, ...) \ 291 xse(name, current->name, range_min, range_max, subs, __VA_ARGS__) 293 #define fixed(width, name, value) do { \ 294 av_unused uint32_t fixed_value = value; \ 295 xu(width, name, fixed_value, value, value, 0, ); \ 300 #define READWRITE read 301 #define RWContext GetBitContext 303 #define xu(width, name, var, range_min, range_max, subs, ...) do { \ 305 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \ 306 SUBSCRIPTS(subs, __VA_ARGS__), \ 307 &value, range_min, range_max)); \ 310 #define xue(name, var, range_min, range_max, subs, ...) do { \ 312 CHECK(cbs_read_ue_golomb(ctx, rw, #name, \ 313 SUBSCRIPTS(subs, __VA_ARGS__), \ 314 &value, range_min, range_max)); \ 317 #define xi(width, name, var, range_min, range_max, subs, ...) do { \ 319 CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ 320 SUBSCRIPTS(subs, __VA_ARGS__), \ 321 &value, range_min, range_max)); \ 324 #define xse(name, var, range_min, range_max, subs, ...) do { \ 326 CHECK(cbs_read_se_golomb(ctx, rw, #name, \ 327 SUBSCRIPTS(subs, __VA_ARGS__), \ 328 &value, range_min, range_max)); \ 333 #define infer(name, value) do { \ 334 current->name = value; \ 349 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw)) 351 #define bit_position(rw) (get_bits_count(rw)) 352 #define byte_alignment(rw) (get_bits_count(rw) % 8) 354 #define allocate(name, size) do { \ 355 name ## _ref = av_buffer_allocz(size + \ 356 AV_INPUT_BUFFER_PADDING_SIZE); \ 358 return AVERROR(ENOMEM); \ 359 name = name ## _ref->data; \ 362 #define FUNC(name) FUNC_SEI(name) 366 #define FUNC(name) FUNC_H264(name) 370 #define FUNC(name) FUNC_H265(name) 382 #undef more_rbsp_data 384 #undef byte_alignment 389 #define READWRITE write 390 #define RWContext PutBitContext 392 #define xu(width, name, var, range_min, range_max, subs, ...) do { \ 393 uint32_t value = var; \ 394 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \ 395 SUBSCRIPTS(subs, __VA_ARGS__), \ 396 value, range_min, range_max)); \ 398 #define xue(name, var, range_min, range_max, subs, ...) do { \ 399 uint32_t value = var; \ 400 CHECK(cbs_write_ue_golomb(ctx, rw, #name, \ 401 SUBSCRIPTS(subs, __VA_ARGS__), \ 402 value, range_min, range_max)); \ 404 #define xi(width, name, var, range_min, range_max, subs, ...) do { \ 405 int32_t value = var; \ 406 CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ 407 SUBSCRIPTS(subs, __VA_ARGS__), \ 408 value, range_min, range_max)); \ 410 #define xse(name, var, range_min, range_max, subs, ...) do { \ 411 int32_t value = var; \ 412 CHECK(cbs_write_se_golomb(ctx, rw, #name, \ 413 SUBSCRIPTS(subs, __VA_ARGS__), \ 414 value, range_min, range_max)); \ 417 #define infer(name, value) do { \ 418 if (current->name != (value)) { \ 419 av_log(ctx->log_ctx, AV_LOG_ERROR, \ 420 "%s does not match inferred value: " \ 421 "%"PRId64", but should be %"PRId64".\n", \ 422 #name, (int64_t)current->name, (int64_t)(value)); \ 423 return AVERROR_INVALIDDATA; \ 427 #define more_rbsp_data(var) (var) 429 #define bit_position(rw) (put_bits_count(rw)) 430 #define byte_alignment(rw) (put_bits_count(rw) % 8) 432 #define allocate(name, size) do { \ 434 av_log(ctx->log_ctx, AV_LOG_ERROR, "%s must be set " \ 435 "for writing.\n", #name); \ 436 return AVERROR_INVALIDDATA; \ 440 #define FUNC(name) FUNC_SEI(name) 444 #define FUNC(name) FUNC_H264(name) 448 #define FUNC(name) FUNC_H265(name) 465 #undef more_rbsp_data 467 #undef byte_alignment 477 for (i = 0; i < packet->
nb_nals; i++) {
486 while (size > 0 && nal->
data[size - 1] == 0)
520 size_t size, start, end;
530 version = bytestream2_get_byte(&gbc);
533 "first byte %u.\n", version);
541 count = bytestream2_get_byte(&gbc) & 0x1f;
543 for (i = 0; i <
count; i++) {
546 size = bytestream2_get_be16(&gbc);
554 frag->
data + start, end - start,
565 count = bytestream2_get_byte(&gbc);
567 for (i = 0; i <
count; i++) {
570 size = bytestream2_get_be16(&gbc);
578 frag->
data + start, end - start,
595 size_t size, start, end;
596 int i, j, nb_arrays, nal_unit_type, nb_nals,
version;
605 version = bytestream2_get_byte(&gbc);
608 "first byte %u.\n", version);
615 nb_arrays = bytestream2_get_byte(&gbc);
616 for (i = 0; i < nb_arrays; i++) {
617 nal_unit_type = bytestream2_get_byte(&gbc) & 0x3f;
618 nb_nals = bytestream2_get_be16(&gbc);
621 for (j = 0; j < nb_nals; j++) {
624 size = bytestream2_get_be16(&gbc);
632 frag->
data + start, end - start,
636 "HVCC array %d (%d NAL units of type %d).\n",
637 i, nb_nals, nal_unit_type);
664 #define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \ 665 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ 666 CodedBitstreamUnit *unit) \ 668 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \ 669 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \ 670 unsigned int id = ps_var->id_element; \ 672 if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \ 673 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \ 674 " id : %d.\n", id); \ 675 return AVERROR_INVALIDDATA; \ 677 err = ff_cbs_make_unit_refcounted(ctx, unit); \ 680 if (priv->ps_var[id] == priv->active_ ## ps_var) \ 681 priv->active_ ## ps_var = NULL ; \ 682 av_buffer_unref(&priv->ps_var ## _ref[id]); \ 683 av_assert0(unit->content_ref); \ 684 priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ 685 if (!priv->ps_var ## _ref[id]) \ 686 return AVERROR(ENOMEM); \ 687 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \ 693 cbs_h2645_replace_ps(5, VPS,
vps, vps_video_parameter_set_id)
694 cbs_h2645_replace_ps(5,
SPS,
sps, sps_seq_parameter_set_id)
695 cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
711 switch (unit->type) {
716 err = cbs_h264_read_sps(ctx, &gbc, sps);
720 err = cbs_h264_replace_sps(ctx, unit);
728 err = cbs_h264_read_sps_extension(ctx, &gbc, unit->content);
738 err = cbs_h264_read_pps(ctx, &gbc, pps);
742 err = cbs_h264_replace_pps(ctx, unit);
755 err = cbs_h264_read_slice_header(ctx, &gbc, &slice->
header);
763 len = unit->data_size;
769 slice->
data = unit->data + pos / 8;
776 err = cbs_h264_read_aud(ctx, &gbc, unit->content);
784 err = cbs_h264_read_sei(ctx, &gbc, unit->content);
792 err = cbs_h264_read_filler(ctx, &gbc, unit->content);
802 cbs_h264_read_end_of_sequence :
803 cbs_h264_read_end_of_stream)(ctx, &gbc, unit->content);
830 switch (unit->
type) {
835 err = cbs_h265_read_vps(ctx, &gbc, vps);
839 err = cbs_h265_replace_vps(ctx, unit);
848 err = cbs_h265_read_sps(ctx, &gbc, sps);
852 err = cbs_h265_replace_sps(ctx, unit);
862 err = cbs_h265_read_pps(ctx, &gbc, pps);
866 err = cbs_h265_replace_pps(ctx, unit);
892 err = cbs_h265_read_slice_segment_header(ctx, &gbc, &slice->
header);
913 err = cbs_h265_read_aud(ctx, &gbc, unit->
content);
922 err = cbs_h265_read_sei(ctx, &gbc, unit->
content,
939 size_t data_size,
int data_bit_start)
941 size_t rest = data_size - (data_bit_start + 7) / 8;
942 const uint8_t *
pos = data + data_bit_start / 8;
945 data_size > data_bit_start / 8);
951 goto rbsp_stop_one_bit;
956 if (data_bit_start % 8)
957 put_bits(pbc, 8 - data_bit_start % 8,
974 for (; rest > 4; rest -= 4, pos += 4)
977 for (; rest > 1; rest--, pos++)
981 temp = rest ? *pos : *pos &
MAX_UINT_BITS(8 - data_bit_start % 8);
986 i = rest ? (8 -
i) : (8 - i - data_bit_start % 8);
1001 switch (unit->
type) {
1006 err = cbs_h264_write_sps(ctx, pbc, sps);
1010 err = cbs_h264_replace_sps(ctx, unit);
1020 err = cbs_h264_write_sps_extension(ctx, pbc, sps_ext);
1030 err = cbs_h264_write_pps(ctx, pbc, pps);
1034 err = cbs_h264_replace_pps(ctx, unit);
1046 err = cbs_h264_write_slice_header(ctx, pbc, &slice->
header);
1065 err = cbs_h264_write_aud(ctx, pbc, unit->
content);
1073 err = cbs_h264_write_sei(ctx, pbc, unit->
content);
1081 err = cbs_h264_write_filler(ctx, pbc, unit->
content);
1089 err = cbs_h264_write_end_of_sequence(ctx, pbc, unit->
content);
1097 err = cbs_h264_write_end_of_stream(ctx, pbc, unit->
content);
1105 "NAL unit type %"PRIu32
".\n", unit->
type);
1118 switch (unit->
type) {
1123 err = cbs_h265_write_vps(ctx, pbc, vps);
1127 err = cbs_h265_replace_vps(ctx, unit);
1137 err = cbs_h265_write_sps(ctx, pbc, sps);
1141 err = cbs_h265_replace_sps(ctx, unit);
1151 err = cbs_h265_write_pps(ctx, pbc, pps);
1155 err = cbs_h265_replace_pps(ctx, unit);
1180 err = cbs_h265_write_slice_segment_header(ctx, pbc, &slice->
header);
1198 err = cbs_h265_write_aud(ctx, pbc, unit->
content);
1207 err = cbs_h265_write_sei(ctx, pbc, unit->
content,
1217 "NAL unit type %"PRIu32
".\n", unit->
type);
1229 if (nal_unit_index == 0) {
1244 size_t max_size, dp,
sp;
1245 int err,
i, zero_run;
1247 for (i = 0; i < frag->
nb_units; i++) {
1253 for (i = 0; i < frag->
nb_units; i++) {
1263 for (i = 0; i < frag->
nb_units; i++) {
1267 if (i < frag->nb_units - 1)
1269 "unaligned padding on non-final NAL unit.\n");
1284 for (sp = 0; sp < unit->
data_size; sp++) {
1286 if (unit->
data[sp] == 0)
1291 if ((unit->
data[sp] & ~3) == 0) {
1295 zero_run = unit->
data[
sp] == 0;
1297 data[dp++] = unit->
data[
sp];
1410 .nb_ref_offsets = 1,
1446 .nb_ref_offsets = 1,
1458 .nb_ref_offsets = 1,
1481 .unit_types = cbs_h264_unit_types,
1484 .read_unit = &cbs_h264_read_nal_unit,
1497 .unit_types = cbs_h265_unit_types,
1646 for (i = 0; cbs_sei_common_types[
i].
type >= 0; i++) {
1647 if (cbs_sei_common_types[i].
type == payload_type)
1648 return &cbs_sei_common_types[
i];
1662 for (i = 0; codec_list[
i].
type >= 0; i++) {
1663 if (codec_list[i].
type == payload_type)
1664 return &codec_list[
i];
int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
int nb_units
Number of units in this fragment.
H265RawPPS * pps[HEVC_MAX_PPS_COUNT]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const SEIMessageTypeDescriptor cbs_sei_h265_types[]
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
static int cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
AVBufferRef * sps_ref[H264_MAX_SPS_COUNT]
static int FUNC() sei_display_orientation(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIDisplayOrientation *current, SEIMessageState *sei)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define AV_LOG_WARNING
Something somehow does not look correct.
static int FUNC() user_data_registered(CodedBitstreamContext *ctx, RWContext *rw, SEIRawUserDataRegistered *current, SEIMessageState *state)
H264RawPPS * pps[H264_MAX_PPS_COUNT]
AVBufferRef * sps_ref[HEVC_MAX_SPS_COUNT]
CodedBitstreamUnitType type
Codec-specific type of this unit.
static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
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 CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[]
static int FUNC() alternative_transfer_characteristics(CodedBitstreamContext *ctx, RWContext *rw, SEIRawAlternativeTransferCharacteristics *current, SEIMessageState *state)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
#define FF_ARRAY_ELEMS(a)
CodedBitstreamH2645Context common
#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func)
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)
Macro definitions for various function/variable attributes.
static int FUNC() sei_buffering_period(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIBufferingPeriod *current, SEIMessageState *sei)
static int FUNC() user_data_unregistered(CodedBitstreamContext *ctx, RWContext *rw, SEIRawUserDataUnregistered *current, SEIMessageState *state)
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int trace_enable
Enable trace output during read/write operations.
#define SEI_MESSAGE_TYPE_END
SEIRawMessageList message_list
static void cbs_h264_flush(CodedBitstreamContext *ctx)
static int FUNC() sei_recovery_point(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIRecoveryPoint *current, SEIMessageState *sei)
AVBufferRef * pps_ref[HEVC_MAX_PPS_COUNT]
const SEIMessageTypeDescriptor * ff_cbs_sei_find_type(CodedBitstreamContext *ctx, int payload_type)
Find the type descriptor for the given payload type.
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
#define MAX_UINT_BITS(length)
GLsizei GLboolean const GLfloat * value
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.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
H265RawSPS * sps[HEVC_MAX_SPS_COUNT]
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
static int get_bits_count(const GetBitContext *s)
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
static int FUNC() sei_active_parameter_sets(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIActiveParameterSets *current, SEIMessageState *sei)
H264RawSPS * sps[H264_MAX_SPS_COUNT]
#define AV_LOG_VERBOSE
Detailed information.
static void cbs_h264_close(CodedBitstreamContext *ctx)
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
static const uint8_t header[24]
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, int cur_pos)
size_t data_size
The number of bytes in the bitstream.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
H.264 common definitions.
static int get_bits_left(GetBitContext *gb)
static int FUNC() extension_data(CodedBitstreamContext *ctx, RWContext *rw, H265RawExtensionData *current)
#define i(width, name, range_min, range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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_left(PutBitContext *s)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
simple assert() macros that are a bit more flexible than ISO C assert().
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
void ff_cbs_sei_free_message_list(SEIRawMessageList *list)
Free all SEI messages in a message list.
static int put_bits_count(PutBitContext *s)
void * log_ctx
Logging context to be passed to all av_log() calls associated with this context.
const CodedBitstreamType ff_cbs_type_h264
static void cbs_h265_close(CodedBitstreamContext *ctx)
static int FUNC() mastering_display_colour_volume(CodedBitstreamContext *ctx, RWContext *rw, SEIRawMasteringDisplayColourVolume *current, SEIMessageState *state)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
#define CBS_UNIT_TYPE_POD(type, structure)
uint8_t last_slice_nal_unit_type
static void cbs_h265_flush(CodedBitstreamContext *ctx)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define SEI_MESSAGE_RW(codec, name)
uint8_t * data
Pointer to the bitstream form of this fragment.
#define CBS_UNIT_TYPE_END_OF_LIST
AVBufferRef * pps_ref[H264_MAX_PPS_COUNT]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
static int FUNC() sei_pic_timing(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTiming *current, SEIMessageState *sei)
const H265RawSPS * active_sps
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Coded bitstream fragment structure, combining one or more units.
AVBufferRef * rbsp_buffer_ref
static int FUNC() sei_alpha_channel_info(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIAlphaChannelInfo *current, SEIMessageState *sei)
SEIRawMessageList message_list
static unsigned int get_bits1(GetBitContext *s)
static int FUNC() sei_pan_scan_rect(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPanScanRect *current, SEIMessageState *sei)
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Context structure for coded bitstream operations.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const H265RawVPS * active_vps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
const H265RawPPS * active_pps
static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id, CodedBitstreamUnitType type, int nal_unit_index)
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static void cbs_h265_free_sei(void *opaque, uint8_t *content)
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)
AVBufferRef * vps_ref[HEVC_MAX_VPS_COUNT]
void * priv_data
Internal codec-specific data.
A reference to a data buffer.
static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[]
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int ref[MAX_W *MAX_W]
static const SEIMessageTypeDescriptor cbs_sei_h264_types[]
static void cbs_h264_free_sei(void *opaque, uint8_t *content)
AVBufferRef * data_ref
A reference to the buffer containing data.
static int FUNC() filler_payload(CodedBitstreamContext *ctx, RWContext *rw, SEIRawFillerPayload *current, SEIMessageState *state)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
const CodedBitstreamType ff_cbs_type_h265
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static const SEIMessageTypeDescriptor cbs_sei_common_types[]
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
H265RawSliceHeader header
H264RawSliceHeader header
const H264RawPPS * active_pps
CodedBitstreamH2645Context common
static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
const struct CodedBitstreamType * codec
Internal codec-specific hooks.
static int FUNC() sei_decoded_picture_hash(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIDecodedPictureHash *current, SEIMessageState *sei)
#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element)
static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
H265RawVPS * vps[HEVC_MAX_VPS_COUNT]
AVBufferRef * data_ref
A reference to the buffer containing data.
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)
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *str, const int *subscripts, const char *bits, int64_t value)
static int FUNC() sei_time_code(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEITimeCode *current, SEIMessageState *sei)
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
const H264RawSPS * active_sps
static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet)
static int FUNC() content_light_level_info(CodedBitstreamContext *ctx, RWContext *rw, SEIRawContentLightLevelInfo *current, SEIMessageState *state)