From f0d124f005ff02dba56b09fdd5fe2a9ba961f650 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 30 Oct 2012 03:21:48 +0100 Subject: [PATCH 1/5] x86inc: Set program_name outside of x86inc.asm This reduces the local difference to the x264 upstream version. --- libavutil/x86/x86inc.asm | 2 +- libavutil/x86/x86util.asm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm index b0df2b20f0..52ee46ab76 100644 --- a/libavutil/x86/x86inc.asm +++ b/libavutil/x86/x86inc.asm @@ -35,7 +35,7 @@ ; to x264-devel@videolan.org . %ifndef program_name - %define program_name ff + %define program_name x264 %endif %define WIN64 0 diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm index 31163eec7b..cf11183e71 100644 --- a/libavutil/x86/x86util.asm +++ b/libavutil/x86/x86util.asm @@ -23,6 +23,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** +%define program_name ff %define cpuflags_mmxext cpuflags_mmx2 %include "libavutil/x86/x86inc.asm" From e5e1a06e443f4994cdeff39e99f67ce2c518ed2a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 3 Nov 2012 08:14:11 +0100 Subject: [PATCH 2/5] configure: add lavu dependency to lavr/lavfi .pc files --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 515a3c9395..d67fc85396 100755 --- a/configure +++ b/configure @@ -3903,6 +3903,6 @@ pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION" -pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" -pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" +pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" From b077eb07805dc5d139b2f118ddb122cc9df8b87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Delm=C3=A1s?= Date: Sun, 11 Nov 2012 09:23:06 +0100 Subject: [PATCH 3/5] mss2: fix handling of unmasked implicit WMV9 rectangles Signed-off-by: Kostya Shishkov --- libavcodec/mss2.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 597ebb646e..ceeff5a32d 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -474,7 +474,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, int keyframe, has_wmv9, has_mv, is_rle, is_555, ret; Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r; - int used_rects = 0, i, implicit_rect, av_uninit(wmv9_mask); + int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask); av_assert0(FF_INPUT_BUFFER_PADDING_SIZE >= ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); @@ -650,7 +650,14 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, return AVERROR_INVALIDDATA; buf_size -= bytestream2_tell(&gB); - } else if (is_rle) { + } else { + if (keyframe) { + c->corrupted = 0; + ff_mss12_slicecontext_reset(&ctx->sc[0]); + if (c->slice_split) + ff_mss12_slicecontext_reset(&ctx->sc[1]); + } + if (is_rle) { init_get_bits(&gb, buf, buf_size * 8); if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, @@ -669,14 +676,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, align_get_bits(&gb); buf += get_bits_count(&gb) >> 3; buf_size -= get_bits_count(&gb) >> 3; - } else { - if (keyframe) { - c->corrupted = 0; - ff_mss12_slicecontext_reset(&ctx->sc[0]); - if (c->slice_split) - ff_mss12_slicecontext_reset(&ctx->sc[1]); - } - else if (c->corrupted) + } else if (!implicit_rect || wmv9_mask != -1) { + if (c->corrupted) return AVERROR_INVALIDDATA; bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); arith2_init(&acoder, &gB); @@ -702,6 +703,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, buf += arith2_get_consumed_bytes(&acoder); buf_size -= arith2_get_consumed_bytes(&acoder); } + } else + memset(c->pal_pic, 0, c->pal_stride * avctx->height); } if (has_wmv9) { From 6d93308c0ca3783b3278aef8e6e64d8f0558f319 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 11 Nov 2012 15:00:38 +0100 Subject: [PATCH 4/5] mss2: reindent after last commit --- libavcodec/mss2.c | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index ceeff5a32d..5f99b7afa4 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -657,54 +657,54 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, if (c->slice_split) ff_mss12_slicecontext_reset(&ctx->sc[1]); } - if (is_rle) { - init_get_bits(&gb, buf, buf_size * 8); - if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, - c->rgb_pic, c->rgb_stride, c->pal, keyframe, - ctx->split_position, 0, - avctx->width, avctx->height)) - return ret; - align_get_bits(&gb); - - if (c->slice_split) + if (is_rle) { + init_get_bits(&gb, buf, buf_size * 8); if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, - ctx->split_position, 1, + ctx->split_position, 0, avctx->width, avctx->height)) return ret; + align_get_bits(&gb); - align_get_bits(&gb); - buf += get_bits_count(&gb) >> 3; - buf_size -= get_bits_count(&gb) >> 3; - } else if (!implicit_rect || wmv9_mask != -1) { - if (c->corrupted) - return AVERROR_INVALIDDATA; - bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); - arith2_init(&acoder, &gB); - c->keyframe = keyframe; - if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0, - avctx->width, - ctx->split_position)) - return AVERROR_INVALIDDATA; + if (c->slice_split) + if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, + c->rgb_pic, c->rgb_stride, c->pal, keyframe, + ctx->split_position, 1, + avctx->width, avctx->height)) + return ret; - buf += arith2_get_consumed_bytes(&acoder); - buf_size -= arith2_get_consumed_bytes(&acoder); - if (c->slice_split) { - if (buf_size < 1) + align_get_bits(&gb); + buf += get_bits_count(&gb) >> 3; + buf_size -= get_bits_count(&gb) >> 3; + } else if (!implicit_rect || wmv9_mask != -1) { + if (c->corrupted) return AVERROR_INVALIDDATA; bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); arith2_init(&acoder, &gB); - if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0, - ctx->split_position, + c->keyframe = keyframe; + if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0, avctx->width, - avctx->height - ctx->split_position)) + ctx->split_position)) return AVERROR_INVALIDDATA; buf += arith2_get_consumed_bytes(&acoder); buf_size -= arith2_get_consumed_bytes(&acoder); - } - } else - memset(c->pal_pic, 0, c->pal_stride * avctx->height); + if (c->slice_split) { + if (buf_size < 1) + return AVERROR_INVALIDDATA; + bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); + arith2_init(&acoder, &gB); + if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0, + ctx->split_position, + avctx->width, + avctx->height - ctx->split_position)) + return AVERROR_INVALIDDATA; + + buf += arith2_get_consumed_bytes(&acoder); + buf_size -= arith2_get_consumed_bytes(&acoder); + } + } else + memset(c->pal_pic, 0, c->pal_stride * avctx->height); } if (has_wmv9) { From 802713c4e7b41bc2deed754d78649945c3442063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Delm=C3=A1s?= Date: Sun, 11 Nov 2012 09:47:39 +0100 Subject: [PATCH 5/5] mss2: prevent potential uninitialized reads The alternative to zeroing on init is setting the corrupted flag in all cases where pal_pic is not fully written, at the cost of added complexity. Signed-off-by: Kostya Shishkov --- libavcodec/mss2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 5f99b7afa4..bec3f45075 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -839,8 +839,8 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1])) return ret; c->pal_stride = c->mask_stride; - c->pal_pic = av_malloc(c->pal_stride * avctx->height); - c->last_pal_pic = av_malloc(c->pal_stride * avctx->height); + c->pal_pic = av_mallocz(c->pal_stride * avctx->height); + c->last_pal_pic = av_mallocz(c->pal_stride * avctx->height); if (!c->pal_pic || !c->last_pal_pic) { mss2_decode_end(avctx); return AVERROR(ENOMEM);