mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
avcodec/v210dec: add support for invalid paddings up to 16 bytes
Fixes ticket #1528. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
2e895edb5d
commit
a10132b967
@ -126,6 +126,11 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int v210_stride(int width, int align) {
|
||||||
|
int aligned_width = ((width + align - 1) / align) * align;
|
||||||
|
return aligned_width * 8 / 3;
|
||||||
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
|
static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
|
||||||
int *got_frame, AVPacket *avpkt)
|
int *got_frame, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
@ -137,20 +142,25 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
|
|||||||
if (s->custom_stride )
|
if (s->custom_stride )
|
||||||
stride = s->custom_stride;
|
stride = s->custom_stride;
|
||||||
else {
|
else {
|
||||||
int aligned_width = ((avctx->width + 47) / 48) * 48;
|
stride = v210_stride(avctx->width, 48);
|
||||||
stride = aligned_width * 8 / 3;
|
if (avpkt->size < stride * avctx->height) {
|
||||||
|
int align;
|
||||||
|
for (align = 24; align >= 6; align >>= 1) {
|
||||||
|
int small_stride = v210_stride(avctx->width, align);
|
||||||
|
if (avpkt->size == small_stride * avctx->height) {
|
||||||
|
stride = small_stride;
|
||||||
|
if (!s->stride_warning_shown)
|
||||||
|
av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (%d byte) detected\n", align * 8 / 3);
|
||||||
|
s->stride_warning_shown = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avpkt->size < (int64_t)stride * avctx->height) {
|
if (avpkt->size < (int64_t)stride * avctx->height) {
|
||||||
if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
|
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
|
||||||
stride = avpkt->size / avctx->height;
|
return AVERROR_INVALIDDATA;
|
||||||
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 AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
td.stride = stride;
|
td.stride = stride;
|
||||||
if ( avctx->codec_tag == MKTAG('C', '2', '1', '0')
|
if ( avctx->codec_tag == MKTAG('C', '2', '1', '0')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user