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:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-01-21 18:14:10 +0300
committerRostislav Pehlivanov <atomnuker@gmail.com>2016-01-21 18:18:25 +0300
commita849ebb54e187a70eabc69cbd1b1a342e6587ec3 (patch)
tree21e7fc4be1762b2d7225f4c75214338478cffe06 /libavcodec/dirac_parser.c
parentb65efbc0f4195421c15d2a6c228d331eec5b31c3 (diff)
dirac_parser: Improve parsing and silence pointless warnings
The parser scans for "BBCD" to appear in the bitstream which indicate a parse info header and once that happens, checks if the parse offsets are sane. Since random BBCD strings might appear in the bitstream the parser will emit a pointless warning if that happens. This commit improves parsing by checking for a valid parse code as well as keeping the original checks for valid parse offsets. The warnings were removed as they serve no real purpose. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/dirac_parser.c')
-rw-r--r--libavcodec/dirac_parser.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libavcodec/dirac_parser.c b/libavcodec/dirac_parser.c
index 1ca7e31f1c..a8aa664ea9 100644
--- a/libavcodec/dirac_parser.c
+++ b/libavcodec/dirac_parser.c
@@ -100,7 +100,11 @@ typedef struct DiracParseUnit {
static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
int offset)
{
+ int i;
int8_t *start;
+ static const uint8_t valid_pu_types[] = {
+ 0x00, 0x10, 0x20, 0x30, 0x08, 0x48, 0xC8, 0xE8
+ };
if (offset < 0 || pc->index - 13 < offset)
return 0;
@@ -111,17 +115,20 @@ static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
pu->next_pu_offset = AV_RB32(start + 5);
pu->prev_pu_offset = AV_RB32(start + 9);
+ /* Check for valid parse code */
+ for (i = 0; i < 8; i++)
+ if (valid_pu_types[i] == pu->pu_type)
+ break;
+ if (i == 8)
+ return 0;
+
if (pu->pu_type == 0x10 && pu->next_pu_offset == 0)
- pu->next_pu_offset = 13;
+ pu->next_pu_offset = 13; /* The length of a parse info header */
- if (pu->next_pu_offset && pu->next_pu_offset < 13) {
- av_log(NULL, AV_LOG_ERROR, "next_pu_offset %d is invalid\n", pu->next_pu_offset);
+ /* Check if the parse offsets are somewhat sane */
+ if ((pu->next_pu_offset && pu->next_pu_offset < 13) ||
+ (pu->prev_pu_offset && pu->prev_pu_offset < 13))
return 0;
- }
- if (pu->prev_pu_offset && pu->prev_pu_offset < 13) {
- av_log(NULL, AV_LOG_ERROR, "prev_pu_offset %d is invalid\n", pu->prev_pu_offset);
- return 0;
- }
return 1;
}