History

avcodec/cbs_vp8: Use little endian in fixed()

This commit adds value range checks to cbs_vp8_read_unsigned_le, migrates fixed() to use it, and enforces little-endian consistency for all read methods.

Dai, Jianhui J committed 2 years ago

Commit 63dea3c1 parent ea2e0e91 file · +17 −6Browse files

Unified · Split

libavcodec/cbs_vp8.c+17−6
@@ -181,9 +181,11 @@ static int cbs_vp8_bool_decoder_read_signed( · 180 unmodified lines
181 return 0;181 return 0;
182}182}
183 183
184static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *gbc,184static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
185 int width, const char *name,185 GetBitContext *gbc, int width,
186 const int *subscripts, uint32_t *write_to)186 const char *name, const int *subscripts,
187 uint32_t *write_to, uint32_t range_min,
188 uint32_t range_max)
187{189{
188 int32_t value;190 int32_t value;
189 191
@@ -200,6 +202,14 @@ static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g · 10 unmodified lines
200 202
201 CBS_TRACE_READ_END();203 CBS_TRACE_READ_END();
202 204
205 if (value < range_min || value > range_max) {
206 av_log(ctx->log_ctx, AV_LOG_ERROR,
207 "%s out of range: "
208 "%" PRIu32 ", but must be in [%" PRIu32 ",%" PRIu32 "].\n",
209 name, value, range_min, range_max);
210 return AVERROR_INVALIDDATA;
211 }
212
203 *write_to = value;213 *write_to = value;
204 return 0;214 return 0;
205}215}
@@ -246,15 +256,16 @@ static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g · 40 unmodified lines
246 do { \256 do { \
247 uint32_t value; \257 uint32_t value; \
248 CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \258 CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
249 SUBSCRIPTS(subs, __VA_ARGS__), &value)); \259 SUBSCRIPTS(subs, __VA_ARGS__), &value, \
260 0, MAX_UINT_BITS(width))); \
250 current->name = value; \261 current->name = value; \
251 } while (0)262 } while (0)
252 263
253#define fixed(width, name, value) \264#define fixed(width, name, value) \
254 do { \265 do { \
255 uint32_t fixed_value; \266 uint32_t fixed_value; \
256 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, 0, &fixed_value, \267 CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0, &fixed_value, \
257 value, value)); \268 value, value)); \
258 } while (0)269 } while (0)
259 270
260#define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \271#define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t