aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/cbs_mpeg2.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-07-01 11:44:36 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-07-30 21:36:31 +0200
commita105b11a9d1d8be33cd9ba29da41314c1abf7c82 (patch)
tree8a94e3d946e86d691dd2d51e8ad1f745a2883e58 /libavcodec/cbs_mpeg2.c
parentb85557b231782f3bc89746c86512d81f777dab1b (diff)
downloadffmpeg-a105b11a9d1d8be33cd9ba29da41314c1abf7c82.tar.gz
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>
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 04b0c7f87d..37fc28a4e6 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -40,8 +40,6 @@
#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
-#define ui(width, name) \
- xui(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )
#define uir(width, name) \
xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0, )
#define uis(width, name, subs, ...) \
@@ -65,6 +63,12 @@
#define READWRITE read
#define RWContext GetBitContext
+#define ui(width, name) do { \
+ uint32_t value; \
+ CHECK(ff_cbs_read_simple_unsigned(ctx, rw, width, #name, \
+ &value)); \
+ current->name = value; \
+ } while (0)
#define xuia(width, string, var, range_min, range_max, subs, ...) do { \
uint32_t value; \
CHECK(ff_cbs_read_unsigned(ctx, rw, width, string, \
@@ -95,6 +99,7 @@
#undef READ
#undef READWRITE
#undef RWContext
+#undef ui
#undef xuia
#undef xsi
#undef nextbits
@@ -105,6 +110,11 @@
#define READWRITE write
#define RWContext PutBitContext
+#define ui(width, name) do { \
+ CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \
+ current->name)); \
+ } while (0)
+
#define xuia(width, string, var, range_min, range_max, subs, ...) do { \
CHECK(ff_cbs_write_unsigned(ctx, rw, width, string, \
SUBSCRIPTS(subs, __VA_ARGS__), \
@@ -134,6 +144,7 @@
#undef WRITE
#undef READWRITE
#undef RWContext
+#undef ui
#undef xuia
#undef xsi
#undef nextbits