36 int bits_left = payload_size * 8 - cur_pos;
42 const char *
name,
const int *subscripts,
44 uint32_t range_min, uint32_t range_max)
46 uint32_t leading_bits,
value;
47 int max_length, leading_zeroes;
54 if (leading_bits == 0) {
55 if (max_length >= 32) {
57 "%s: more than 31 zeroes.\n",
name);
61 "%s: bitstream ended.\n",
name);
66 leading_zeroes = max_length - 1 -
av_log2(leading_bits);
71 "%s: bitstream ended.\n",
name);
81 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
91 const char *
name,
const int *subscripts,
95 uint32_t leading_bits, unsigned_value;
96 int max_length, leading_zeroes;
104 if (leading_bits == 0) {
105 if (max_length >= 32) {
107 "%s: more than 31 zeroes.\n",
name);
111 "%s: bitstream ended.\n",
name);
116 leading_zeroes = max_length - 1 -
av_log2(leading_bits);
121 "%s: bitstream ended.\n",
name);
127 if (unsigned_value & 1)
130 value = unsigned_value / 2;
136 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
146 const char *
name,
const int *subscripts,
148 uint32_t range_min, uint32_t range_max)
156 "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
178 const char *
name,
const int *subscripts,
189 "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
198 uvalue = 2 * (uint32_t)
value - 1;
200 uvalue = 2 * (uint32_t)-
value;
256 err = ff_cbs_append_unit_data(frag,
nal->type,
267 size_t data_size,
int data_bit_start)
269 size_t rest = data_size - (data_bit_start + 7) / 8;
270 const uint8_t *
pos =
data + data_bit_start / 8;
273 data_size > data_bit_start / 8);
279 goto rbsp_stop_one_bit;
284 if (data_bit_start % 8)
285 put_bits(pbc, 8 - data_bit_start % 8,
302 for (; rest > 4; rest -= 4,
pos += 4)
305 for (; rest > 1; rest--,
pos++)
314 i = rest ? (8 -
i) : (8 -
i - data_bit_start % 8);
327 size_t max_size, dp, sp;
328 int err,
i, zero_run;
352 "unaligned padding on non-final NAL unit.\n");
367 for (sp = 0; sp < unit->
data_size; sp++) {
369 if (unit->
data[sp] == 0)
374 if ((unit->
data[sp] & ~3) == 0) {
378 zero_run = unit->
data[sp] == 0;
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_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)
int ff_cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet)
int ff_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)
int ff_cbs_h2645_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, int cur_pos)
payload_extension_present() - true if we are before the last 1-bit in the payload structure,...
int ff_cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
int ff_cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
int ff_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)
int ff_cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int ff_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)
#define i(width, name, range_min, range_max)
#define CBS_TRACE_READ_END()
#define CBS_TRACE_READ_START()
#define MAX_UINT_BITS(length)
#define CBS_TRACE_WRITE_END()
#define CBS_TRACE_WRITE_START()
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
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.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#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.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
H.264 common definitions.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int ff_h2645_unit_requires_zero_byte(enum AVCodecID codec_id, unsigned int type, int nal_unit_index)
Macro definitions for various function/variable attributes.
Memory handling functions.
static int put_bits_count(PutBitContext *s)
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 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 av_unused void put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
A reference to a data buffer.
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.
Coded bitstream unit structure.
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 * rbsp_buffer_ref
static int ref[MAX_W *MAX_W]
static AVFormatContext * ctx