mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-15 05:11:37 +08:00
avcodec/cbs: Add specialization for ff_cbs_(read|write)_unsigned()
These functions allow not only to read and write unsigned values, but also to check ranges and to emit trace output which can be beautified when processing arrays (indices like "[i]" are replaced by their actual numbers). Yet lots of callers actually only need something simpler: Their range is only implicitly restricted by the amount of bits used and they are not part of arrays, hence don't need this beautification. This commit adds specializations for these callers; this is very beneficial size-wise (it reduced the size of .text by 23312 bytes here), as a call is now cheaper. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -546,10 +546,13 @@ void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position,
|
||||
position, name, pad, bits, value);
|
||||
}
|
||||
|
||||
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)
|
||||
static av_always_inline int 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)
|
||||
{
|
||||
uint32_t value;
|
||||
int position;
|
||||
@@ -589,6 +592,22 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return cbs_read_unsigned(ctx, gbc, width, name, subscripts,
|
||||
write_to, range_min, range_max);
|
||||
}
|
||||
|
||||
int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name, uint32_t *write_to)
|
||||
{
|
||||
return cbs_read_unsigned(ctx, gbc, width, name, NULL,
|
||||
write_to, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, uint32_t value,
|
||||
@@ -625,6 +644,13 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name, uint32_t value)
|
||||
{
|
||||
return ff_cbs_write_unsigned(ctx, pbc, width, name, NULL,
|
||||
value, 0, MAX_UINT_BITS(width));
|
||||
}
|
||||
|
||||
int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, int32_t *write_to,
|
||||
|
Reference in New Issue
Block a user