Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-05-22 04:04:32 +0300
committerMark Thompson <sw@jkqxz.net>2019-05-29 01:59:29 +0300
commit9c3f2a8894a66d6b5b9285caa25f91fbfca7b3bc (patch)
tree29895d8300511513362fe0ed953e2b5daeb012b5 /libavcodec/cbs_mpeg2.c
parentcfe4389d477064b0424590a7b3e1ec94059db2fd (diff)
cbs_mpeg2: Improve checks for invalid values
MPEG-2 contains several elements that mustn't be zero according to the specifications: horizontal/vertical_size_value, aspect_ratio_information, frame_rate_code, the quantiser matrices, the colour_description elements, picture_coding_type, the f_code[r][s] values and quantiser_scale_code. It is now checked that the invalid values don't occur. The colour_description elements are treated specially in this regard: Given that there are files in the wild which use illegal values for the colour_description elements (some of them created by mpeg2_metadata), they will be corrected to the value meaning "unknown" (namely 2) during reading. This has been done in such a way that trace_headers will nevertheless report the original value, together with a message about the fixup. Furthermore, the trace_headers output of user_data has been beautified. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index f9f1d86b49..4605b2056e 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -41,20 +41,24 @@
#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
#define ui(width, name) \
- xui(width, name, current->name, 0)
+ 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, ...) \
- xui(width, name, current->name, subs, __VA_ARGS__)
+ xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
+#define uirs(width, name, subs, ...) \
+ xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__)
#define READ
#define READWRITE read
#define RWContext GetBitContext
-#define xui(width, name, var, subs, ...) do { \
+#define xui(width, name, var, range_min, range_max, subs, ...) do { \
uint32_t value = 0; \
CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), \
- &value, 0, (1 << width) - 1)); \
+ &value, range_min, range_max)); \
var = value; \
} while (0)
@@ -81,10 +85,10 @@
#define READWRITE write
#define RWContext PutBitContext
-#define xui(width, name, var, subs, ...) do { \
+#define xui(width, name, var, range_min, range_max, subs, ...) do { \
CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), \
- var, 0, (1 << width) - 1)); \
+ var, range_min, range_max)); \
} while (0)
#define marker_bit() do { \