aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <stebbins@jetheaddev.com>2014-06-18 13:38:36 -0700
committerMichael Niedermayer <michaelni@gmx.at>2014-06-30 16:46:25 +0200
commitca7f2a737256c2ed59955b600554a12af0ec82af (patch)
tree021619138d1bed6ccf360d657c08e76796634940
parent376f353e3d76678944c33e5caac0052a78c0ccbe (diff)
downloadffmpeg-ca7f2a737256c2ed59955b600554a12af0ec82af.tar.gz
avcodec/pgssubdec: do not fail when part of the packet is faulty unless AV_EF_EXPLODE is set
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/pgssubdec.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 7d1039add6..f572d81bcf 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -254,7 +254,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
* @param buf pointer to the packet to process
* @param buf_size size of packet to process
*/
-static void parse_palette_segment(AVCodecContext *avctx,
+static int parse_palette_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
@@ -283,6 +283,7 @@ static void parse_palette_segment(AVCodecContext *avctx,
/* Store color in palette */
ctx->clut[color_id] = RGBA(r,g,b,alpha);
}
+ return 0;
}
/**
@@ -493,17 +494,16 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
break;
+ ret = 0;
switch (segment_type) {
case PALETTE_SEGMENT:
- parse_palette_segment(avctx, buf, segment_length);
+ ret = parse_palette_segment(avctx, buf, segment_length);
break;
case OBJECT_SEGMENT:
- parse_picture_segment(avctx, buf, segment_length);
+ ret = parse_picture_segment(avctx, buf, segment_length);
break;
case PRESENTATION_SEGMENT:
ret = parse_presentation_segment(avctx, buf, segment_length, sub->pts);
- if (ret < 0)
- return ret;
break;
case WINDOW_SEGMENT:
/*
@@ -516,13 +516,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
*/
break;
case DISPLAY_SEGMENT:
- *data_size = display_end_segment(avctx, data, buf, segment_length);
+ ret = display_end_segment(avctx, data, buf, segment_length);
+ if (ret >= 0)
+ *data_size = ret;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n",
segment_type, segment_length);
+ ret = AVERROR_INVALIDDATA;
break;
}
+ if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
+ return ret;
buf += segment_length;
}