Commit 3dc6adf3 authored by James Almer's avatar James Almer

avcodec/cbs_h2645: add helper macros for signed values

Reviewed-by: 's avatarMark Thompson <sw@jkqxz.net>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 5006dcdf
...@@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, ...@@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
#define flag(name) u(1, name, 0, 1) #define flag(name) u(1, name, 0, 1)
#define ue(name, range_min, range_max) \ #define ue(name, range_min, range_max) \
xue(name, current->name, range_min, range_max, 0) xue(name, current->name, range_min, range_max, 0)
#define i(width, name, range_min, range_max) \
xi(width, name, current->name, range_min, range_max, 0)
#define se(name, range_min, range_max) \ #define se(name, range_min, range_max) \
xse(name, current->name, range_min, range_max, 0) xse(name, current->name, range_min, range_max, 0)
...@@ -264,6 +266,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, ...@@ -264,6 +266,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
xu(1, name, current->name, 0, 1, subs, __VA_ARGS__) xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
#define ues(name, range_min, range_max, subs, ...) \ #define ues(name, range_min, range_max, subs, ...) \
xue(name, current->name, range_min, range_max, subs, __VA_ARGS__) xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
#define is(width, name, range_min, range_max, subs, ...) \
xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
#define ses(name, range_min, range_max, subs, ...) \ #define ses(name, range_min, range_max, subs, ...) \
xse(name, current->name, range_min, range_max, subs, __VA_ARGS__) xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
...@@ -291,6 +295,13 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, ...@@ -291,6 +295,13 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
&value, range_min, range_max)); \ &value, range_min, range_max)); \
var = value; \ var = value; \
} while (0) } while (0)
#define xi(width, name, var, range_min, range_max, subs, ...) do { \
int32_t value = range_min; \
CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), \
&value, range_min, range_max)); \
var = value; \
} while (0)
#define xse(name, var, range_min, range_max, subs, ...) do { \ #define xse(name, var, range_min, range_max, subs, ...) do { \
int32_t value = range_min; \ int32_t value = range_min; \
CHECK(cbs_read_se_golomb(ctx, rw, #name, \ CHECK(cbs_read_se_golomb(ctx, rw, #name, \
...@@ -338,6 +349,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) ...@@ -338,6 +349,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
#undef READWRITE #undef READWRITE
#undef RWContext #undef RWContext
#undef xu #undef xu
#undef xi
#undef xue #undef xue
#undef xse #undef xse
#undef infer #undef infer
...@@ -362,6 +374,12 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) ...@@ -362,6 +374,12 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
SUBSCRIPTS(subs, __VA_ARGS__), \ SUBSCRIPTS(subs, __VA_ARGS__), \
value, range_min, range_max)); \ value, range_min, range_max)); \
} while (0) } while (0)
#define xi(width, name, var, range_min, range_max, subs, ...) do { \
int32_t value = var; \
CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), \
value, range_min, range_max)); \
} while (0)
#define xse(name, var, range_min, range_max, subs, ...) do { \ #define xse(name, var, range_min, range_max, subs, ...) do { \
int32_t value = var; \ int32_t value = var; \
CHECK(cbs_write_se_golomb(ctx, rw, #name, \ CHECK(cbs_write_se_golomb(ctx, rw, #name, \
...@@ -402,9 +420,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) ...@@ -402,9 +420,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
#undef READWRITE #undef READWRITE
#undef RWContext #undef RWContext
#undef xu #undef xu
#undef xi
#undef xue #undef xue
#undef xse #undef xse
#undef u #undef u
#undef i
#undef flag #undef flag
#undef ue #undef ue
#undef se #undef se
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment