aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2012-04-21 22:31:11 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2012-04-21 22:31:11 +0200
commit2f06b56382ddd4ae1bbe09fd07f6e7658bfece08 (patch)
treea7d2c59d3e835bb5f21e76b6ea10b5150ead887c
parent6c0027bb3971dc9a06b5847c51a106e10c7b6fcb (diff)
downloadffmpeg-2f06b56382ddd4ae1bbe09fd07f6e7658bfece08.tar.gz
Support broken v210 files with 64 byte padding.
Fixes ticket #743. Reviewed-by: Paul B Mahol
-rw-r--r--libavcodec/v210dec.c17
-rw-r--r--libavcodec/v210dec.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 6ff1cd7ee8..453390322d 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -86,6 +86,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
stride = aligned_width * 8 / 3;
}
+ if (avpkt->size < stride * avctx->height) {
+ if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
+ stride = avpkt->size / avctx->height;
+ if (!s->stride_warning_shown)
+ av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (64 byte) detected\n");
+ s->stride_warning_shown = 1;
+ } else {
+ av_log(avctx, AV_LOG_ERROR, "packet too small\n");
+ return -1;
+ }
+ }
+
aligned_input = !((uintptr_t)psrc & 0xf) && !(stride & 0xf);
if (aligned_input != s->aligned_input) {
s->aligned_input = aligned_input;
@@ -96,11 +108,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (pic->data[0])
avctx->release_buffer(avctx, pic);
- if (avpkt->size < stride * avctx->height) {
- av_log(avctx, AV_LOG_ERROR, "packet too small\n");
- return -1;
- }
-
pic->reference = 0;
if (avctx->get_buffer(avctx, pic) < 0)
return -1;
diff --git a/libavcodec/v210dec.h b/libavcodec/v210dec.h
index 48be729a5f..1f06f9eac9 100644
--- a/libavcodec/v210dec.h
+++ b/libavcodec/v210dec.h
@@ -26,6 +26,7 @@ typedef struct {
AVClass *av_class;
int custom_stride;
int aligned_input;
+ int stride_warning_shown;
void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width);
} V210DecContext;