Go to the documentation of this file.
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 &&
246 #define HEADER(name) do { \
247 ff_cbs_trace_header(ctx, name); \
250 #define CHECK(call) do { \
256 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
257 #define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
258 #define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
260 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
262 #define u(width, name, range_min, range_max) \
263 xu(width, name, current->name, range_min, range_max, 0, )
264 #define ub(width, name) \
265 xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )
266 #define flag(name) ub(1, name)
267 #define ue(name, range_min, range_max) \
268 xue(name, current->name, range_min, range_max, 0, )
269 #define i(width, name, range_min, range_max) \
270 xi(width, name, current->name, range_min, range_max, 0, )
271 #define ib(width, name) \
272 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0, )
273 #define se(name, range_min, range_max) \
274 xse(name, current->name, range_min, range_max, 0, )
276 #define us(width, name, range_min, range_max, subs, ...) \
277 xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
278 #define ubs(width, name, subs, ...) \
279 xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
280 #define flags(name, subs, ...) \
281 xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
282 #define ues(name, range_min, range_max, subs, ...) \
283 xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
284 #define is(width, name, range_min, range_max, subs, ...) \
285 xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
286 #define ibs(width, name, subs, ...) \
287 xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__)
288 #define ses(name, range_min, range_max, subs, ...) \
289 xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
291 #define fixed(width, name, value) do { \
292 av_unused uint32_t fixed_value = value; \
293 xu(width, name, fixed_value, value, value, 0, ); \
298 #define READWRITE read
299 #define RWContext GetBitContext
301 #define xu(width, name, var, range_min, range_max, subs, ...) do { \
303 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
304 SUBSCRIPTS(subs, __VA_ARGS__), \
305 &value, range_min, range_max)); \
308 #define xue(name, var, range_min, range_max, subs, ...) do { \
310 CHECK(cbs_read_ue_golomb(ctx, rw, #name, \
311 SUBSCRIPTS(subs, __VA_ARGS__), \
312 &value, range_min, range_max)); \
315 #define xi(width, name, var, range_min, range_max, subs, ...) do { \
317 CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
318 SUBSCRIPTS(subs, __VA_ARGS__), \
319 &value, range_min, range_max)); \
322 #define xse(name, var, range_min, range_max, subs, ...) do { \
324 CHECK(cbs_read_se_golomb(ctx, rw, #name, \
325 SUBSCRIPTS(subs, __VA_ARGS__), \
326 &value, range_min, range_max)); \
331 #define infer(name, value) do { \
332 current->name = value; \
347 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
349 #define byte_alignment(rw) (get_bits_count(rw) % 8)
351 #define allocate(name, size) do { \
352 name ## _ref = av_buffer_allocz(size + \
353 AV_INPUT_BUFFER_PADDING_SIZE); \
355 return AVERROR(ENOMEM); \
356 name = name ## _ref->data; \
359 #define FUNC(name) FUNC_H264(READWRITE, name)
363 #define FUNC(name) FUNC_H265(READWRITE, name)
375 #undef more_rbsp_data
376 #undef byte_alignment
381 #define READWRITE write
382 #define RWContext PutBitContext
384 #define xu(width, name, var, range_min, range_max, subs, ...) do { \
385 uint32_t value = var; \
386 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
387 SUBSCRIPTS(subs, __VA_ARGS__), \
388 value, range_min, range_max)); \
390 #define xue(name, var, range_min, range_max, subs, ...) do { \
391 uint32_t value = var; \
392 CHECK(cbs_write_ue_golomb(ctx, rw, #name, \
393 SUBSCRIPTS(subs, __VA_ARGS__), \
394 value, range_min, range_max)); \
396 #define xi(width, name, var, range_min, range_max, subs, ...) do { \
397 int32_t value = var; \
398 CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
399 SUBSCRIPTS(subs, __VA_ARGS__), \
400 value, range_min, range_max)); \
402 #define xse(name, var, range_min, range_max, subs, ...) do { \
403 int32_t value = var; \
404 CHECK(cbs_write_se_golomb(ctx, rw, #name, \
405 SUBSCRIPTS(subs, __VA_ARGS__), \
406 value, range_min, range_max)); \
409 #define infer(name, value) do { \
410 if (current->name != (value)) { \
411 av_log(ctx->log_ctx, AV_LOG_ERROR, \
412 "%s does not match inferred value: " \
413 "%"PRId64", but should be %"PRId64".\n", \
414 #name, (int64_t)current->name, (int64_t)(value)); \
415 return AVERROR_INVALIDDATA; \
419 #define more_rbsp_data(var) (var)
421 #define byte_alignment(rw) (put_bits_count(rw) % 8)
423 #define allocate(name, size) do { \
425 av_log(ctx->log_ctx, AV_LOG_ERROR, "%s must be set " \
426 "for writing.\n", #name); \
427 return AVERROR_INVALIDDATA; \
431 #define FUNC(name) FUNC_H264(READWRITE, name)
435 #define FUNC(name) FUNC_H265(READWRITE, name)
452 #undef more_rbsp_data
453 #undef byte_alignment
491 for (
i = 0;
i <
sei->payload_count;
i++)
564 for (
i = 0;
i <
sei->payload_count;
i++)
628 version = bytestream2_get_byte(&gbc);
639 count = bytestream2_get_byte(&gbc) & 0x1f;
641 for (
i = 0;
i < count;
i++) {
644 size = bytestream2_get_be16(&gbc);
652 frag->
data + start,
end - start,
663 count = bytestream2_get_byte(&gbc);
665 for (
i = 0;
i < count;
i++) {
668 size = bytestream2_get_be16(&gbc);
676 frag->
data + start,
end - start,
694 int i, j, nb_arrays, nal_unit_type, nb_nals,
version;
703 version = bytestream2_get_byte(&gbc);
713 nb_arrays = bytestream2_get_byte(&gbc);
714 for (
i = 0;
i < nb_arrays;
i++) {
715 nal_unit_type = bytestream2_get_byte(&gbc) & 0x3f;
716 nb_nals = bytestream2_get_be16(&gbc);
719 for (j = 0; j < nb_nals; j++) {
722 size = bytestream2_get_be16(&gbc);
730 frag->
data + start,
end - start,
734 "HVCC array %d (%d NAL units of type %d).\n",
735 i, nb_nals, nal_unit_type);
762 #define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \
763 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
764 CodedBitstreamUnit *unit) \
766 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
767 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
768 unsigned int id = ps_var->id_element; \
769 if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \
770 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \
771 " id : %d.\n", id); \
772 return AVERROR_INVALIDDATA; \
774 if (priv->ps_var[id] == priv->active_ ## ps_var) \
775 priv->active_ ## ps_var = NULL ; \
776 av_buffer_unref(&priv->ps_var ## _ref[id]); \
777 if (unit->content_ref) \
778 priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
780 priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \
781 if (!priv->ps_var ## _ref[id]) \
782 return AVERROR(ENOMEM); \
783 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \
784 if (!unit->content_ref) \
785 memcpy(priv->ps_var[id], ps_var, sizeof(*ps_var)); \
805 switch (unit->
type) {
815 err = cbs_h264_read_sps(
ctx, &gbc,
sps);
819 err = cbs_h264_replace_sps(
ctx, unit);
833 err = cbs_h264_read_sps_extension(
ctx, &gbc, unit->
content);
849 err = cbs_h264_read_pps(
ctx, &gbc,
pps);
853 err = cbs_h264_replace_pps(
ctx, unit);
872 err = cbs_h264_read_slice_header(
ctx, &gbc, &slice->
header);
898 err = cbs_h264_read_aud(
ctx, &gbc, unit->
content);
911 err = cbs_h264_read_sei(
ctx, &gbc, unit->
content);
924 err = cbs_h264_read_filler(
ctx, &gbc, unit->
content);
940 cbs_h264_read_end_of_sequence :
941 cbs_h264_read_end_of_stream)(
ctx, &gbc, unit->
content);
964 switch (unit->
type) {
975 err = cbs_h265_read_vps(
ctx, &gbc,
vps);
979 err = cbs_h265_replace_vps(
ctx, unit);
994 err = cbs_h265_read_sps(
ctx, &gbc,
sps);
998 err = cbs_h265_replace_sps(
ctx, unit);
1014 err = cbs_h265_read_pps(
ctx, &gbc,
pps);
1018 err = cbs_h265_replace_pps(
ctx, unit);
1050 err = cbs_h265_read_slice_segment_header(
ctx, &gbc, &slice->
header);
1076 err = cbs_h265_read_aud(
ctx, &gbc, unit->
content);
1091 err = cbs_h265_read_sei(
ctx, &gbc, unit->
content,
1108 size_t data_size,
int data_bit_start)
1110 size_t rest = data_size - (data_bit_start + 7) / 8;
1114 data_size > data_bit_start / 8);
1120 goto rbsp_stop_one_bit;
1125 if (data_bit_start % 8)
1126 put_bits(pbc, 8 - data_bit_start % 8,
1143 for (; rest > 4; rest -= 4,
pos += 4)
1146 for (; rest > 1; rest--,
pos++)
1155 i = rest ? (8 -
i) : (8 -
i - data_bit_start % 8);
1170 switch (unit->
type) {
1175 err = cbs_h264_write_sps(
ctx, pbc,
sps);
1179 err = cbs_h264_replace_sps(
ctx, unit);
1189 err = cbs_h264_write_sps_extension(
ctx, pbc, sps_ext);
1199 err = cbs_h264_write_pps(
ctx, pbc,
pps);
1203 err = cbs_h264_replace_pps(
ctx, unit);
1215 err = cbs_h264_write_slice_header(
ctx, pbc, &slice->
header);
1234 err = cbs_h264_write_aud(
ctx, pbc, unit->
content);
1242 err = cbs_h264_write_sei(
ctx, pbc, unit->
content);
1250 err = cbs_h264_write_filler(
ctx, pbc, unit->
content);
1258 err = cbs_h264_write_end_of_sequence(
ctx, pbc, unit->
content);
1266 err = cbs_h264_write_end_of_stream(
ctx, pbc, unit->
content);
1274 "NAL unit type %"PRIu32
".\n", unit->
type);
1287 switch (unit->
type) {
1292 err = cbs_h265_write_vps(
ctx, pbc,
vps);
1296 err = cbs_h265_replace_vps(
ctx, unit);
1306 err = cbs_h265_write_sps(
ctx, pbc,
sps);
1310 err = cbs_h265_replace_sps(
ctx, unit);
1320 err = cbs_h265_write_pps(
ctx, pbc,
pps);
1324 err = cbs_h265_replace_pps(
ctx, unit);
1349 err = cbs_h265_write_slice_segment_header(
ctx, pbc, &slice->
header);
1367 err = cbs_h265_write_aud(
ctx, pbc, unit->
content);
1376 err = cbs_h265_write_sei(
ctx, pbc, unit->
content,
1386 "NAL unit type %"PRIu32
".\n", unit->
type);
1397 size_t max_size, dp,
sp;
1398 int err,
i, zero_run;
1420 if (i < frag->nb_units - 1)
1422 "unaligned padding on non-final NAL unit.\n");
1451 if ((unit->
data[
sp] & ~3) == 0) {
1455 zero_run = unit->
data[
sp] == 0;
1514 .read_unit = &cbs_h264_read_nal_unit,
1564 sei->nal_unit_header.nal_ref_idc = 0;
1587 memcpy(&
sei->payload[
sei->payload_count], payload,
sizeof(*payload));
1588 ++
sei->payload_count;
1604 av_assert0(position >= 0 && position < sei->payload_count);
1606 if (position == 0 &&
sei->payload_count == 1) {
1611 if (&au->
units[
i] == nal)
1619 --
sei->payload_count;
1620 memmove(
sei->payload + position,
1621 sei->payload + position + 1,
1622 (
sei->payload_count - position) *
sizeof(*
sei->payload));
@ H264_SEI_TYPE_BUFFERING_PERIOD
buffering period (H.264, D.1.1)
H265RawVPS * vps[HEVC_MAX_VPS_COUNT]
@ HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
#define AV_LOG_WARNING
Something somehow does not look correct.
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
@ HEVC_SEI_TYPE_DISPLAY_ORIENTATION
AVBufferRef * pps_ref[HEVC_MAX_PPS_COUNT]
static int get_bits_left(GetBitContext *gb)
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
AVBufferRef * sps_ref[HEVC_MAX_SPS_COUNT]
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
static void cbs_h265_free_sps(void *opaque, uint8_t *content)
CodedBitstreamH2645Context common
void * content
Pointer to the decomposed form of this unit.
@ H264_SEI_TYPE_RECOVERY_POINT
recovery point (frame # to decoder sync)
H265RawSliceHeader header
static int get_bits_count(const GetBitContext *s)
static void cbs_h264_free_pps(void *opaque, uint8_t *content)
static av_cold int end(AVCodecContext *avctx)
H264RawPPS * pps[H264_MAX_PPS_COUNT]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
H265RawSPS * sps[HEVC_MAX_SPS_COUNT]
Context structure for coded bitstream operations.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
union H264RawSEIPayload::@28 payload
#define AV_LOG_VERBOSE
Detailed information.
CodedBitstreamUnitType type
Codec-specific type of this unit.
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.
static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
AVBufferRef * sps_ref[H264_MAX_SPS_COUNT]
@ HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
@ H264_SEI_TYPE_USER_DATA_REGISTERED
registered user data as specified by Rec. ITU-T T.35
CodedBitstreamH2645Context common
void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, CodedBitstreamUnit *nal, int position)
Delete an SEI message from an access unit.
int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, H264RawSEIPayload *payload)
Add an SEI message to an access unit.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Coded bitstream unit structure.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet)
struct H265RawSEIPayload::@33::@34 other
@ H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
mastering display properties
static int put_bits_left(PutBitContext *s)
static void cbs_h265_free_pps(void *opaque, uint8_t *content)
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx, 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.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
@ HEVC_SEI_TYPE_TIME_CODE
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
H264RawSEIUserDataUnregistered user_data_unregistered
static void cbs_h265_free_sei(void *opaque, uint8_t *content)
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)
Coded bitstream fragment structure, combining one or more units.
H264RawSEIUserDataRegistered user_data_registered
size_t data_size
The number of bytes in the bitstream.
@ HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element)
void ff_cbs_delete_unit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position)
Delete a unit from a fragment and free all memory it uses.
@ HEVC_SEI_TYPE_PAN_SCAN_RECT
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
#define MAX_UINT_BITS(length)
static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, int cur_pos)
@ HEVC_SEI_TYPE_RECOVERY_POINT
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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_h265_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
static unsigned int get_bits1(GetBitContext *s)
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
@ H264_NAL_AUXILIARY_SLICE
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
AVCodecID
Identify the syntax and semantics of the bitstream.
union H265RawSEIPayload::@33 payload
static av_always_inline int bytestream2_tell(GetByteContext *g)
struct H264RawSEIPayload::@28::@29 other
AVBufferRef * vps_ref[HEVC_MAX_VPS_COUNT]
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
H265RawSEIUserDataUnregistered user_data_unregistered
AVBufferRef * pps_ref[H264_MAX_PPS_COUNT]
@ HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO
uint8_t * data
Pointer to the bitstream form of this fragment.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
H265RawSEIUserDataRegistered user_data_registered
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
static void cbs_h264_free_sei(void *opaque, uint8_t *content)
static const uint8_t header[24]
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.
@ H264_SEI_TYPE_USER_DATA_UNREGISTERED
unregistered user data
@ HEVC_SEI_TYPE_PICTURE_TIMING
@ HEVC_SEI_TYPE_BUFFERING_PERIOD
H265RawExtensionData extension_data
static void cbs_h265_close(CodedBitstreamContext *ctx)
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *str, const int *subscripts, const char *bits, int64_t value)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
H264RawSliceHeader header
AVBufferRef * data_ref
A reference to the buffer containing data.
#define i(width, name, range_min, range_max)
static int put_bits_count(PutBitContext *s)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
@ HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO
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
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * rbsp_buffer_ref
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 void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
@ H264_SEI_TYPE_DISPLAY_ORIENTATION
display orientation
@ H264_SEI_TYPE_PAN_SCAN_RECT
pan-scan rectangle
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 void cbs_h265_free_slice(void *opaque, uint8_t *content)
static void cbs_h264_close(CodedBitstreamContext *ctx)
@ HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS
H265RawPPS * pps[HEVC_MAX_PPS_COUNT]
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define AV_INPUT_BUFFER_PADDING_SIZE
#define FF_ARRAY_ELEMS(a)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, size_t size, void(*free)(void *opaque, uint8_t *data))
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static int ref[MAX_W *MAX_W]
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)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static void cbs_h265_free_vps(void *opaque, uint8_t *content)
static void cbs_h264_free_slice(void *opaque, uint8_t *content)
A reference to a data buffer.
@ H264_SEI_TYPE_PIC_TIMING
picture timing
int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
static int cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
const CodedBitstreamType ff_cbs_type_h264
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVBufferRef * data_ref
A reference to the buffer containing data.
@ HEVC_SEI_TYPE_DECODED_PICTURE_HASH
H264RawSPS * sps[H264_MAX_SPS_COUNT]
const CodedBitstreamType ff_cbs_type_h265
void * priv_data
Format private data.
static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
@ H264_SEI_TYPE_ALTERNATIVE_TRANSFER
alternative transfer
static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int nb_units
Number of units in this fragment.
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
@ HEVC_SEI_TYPE_USER_DATA_UNREGISTERED