From 7ee40713621dbabf3d62e3cc3c4b26ce19b43146 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 26 Nov 2012 01:44:29 +0100 Subject: [PATCH 1/3] x86: fix build without inline asm The qpel functions referenced here are not related to h264 and should thus never have been under CONFIG_H264QPEL. Signed-off-by: Mans Rullgard Signed-off-by: Diego Biurrun --- libavcodec/x86/dsputil_mmx.c | 42 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index d403a14e61..58b6389753 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2263,6 +2263,18 @@ static void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx, #if HAVE_INLINE_ASM c->prefetch = prefetch_mmxext; + SET_QPEL_FUNCS(avg_qpel, 0, 16, mmxext, ); + SET_QPEL_FUNCS(avg_qpel, 1, 8, mmxext, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmxext, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmxext, ); + + SET_QPEL_FUNCS(put_qpel, 0, 16, mmxext, ); + SET_QPEL_FUNCS(put_qpel, 1, 8, mmxext, ); + SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmxext, ); + SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmxext, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmxext, ); + if (!high_bit_depth) { c->put_pixels_tab[0][1] = put_pixels16_x2_mmxext; c->put_pixels_tab[0][2] = put_pixels16_y2_mmxext; @@ -2306,13 +2318,6 @@ static void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx, #if HAVE_MMXEXT_EXTERNAL if (CONFIG_H264QPEL) { - SET_QPEL_FUNCS(put_qpel, 0, 16, mmxext, ); - SET_QPEL_FUNCS(put_qpel, 1, 8, mmxext, ); - SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, ); - SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmxext, ); - SET_QPEL_FUNCS(avg_qpel, 0, 16, mmxext, ); - SET_QPEL_FUNCS(avg_qpel, 1, 8, mmxext, ); - if (!high_bit_depth) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmxext, ); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmxext, ); @@ -2330,11 +2335,6 @@ static void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx, SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_); } - - SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmxext, ); - SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmxext, ); - SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmxext, ); - SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmxext, ); } if (!high_bit_depth && CONFIG_H264CHROMA) { @@ -2461,10 +2461,19 @@ static void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, int mm_flags) static void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx, int mm_flags) { -#if HAVE_SSE2_EXTERNAL const int bit_depth = avctx->bits_per_raw_sample; const int high_bit_depth = bit_depth > 8; +#if HAVE_SSE2_INLINE + if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { + c->idct_put = ff_idct_xvid_sse2_put; + c->idct_add = ff_idct_xvid_sse2_add; + c->idct = ff_idct_xvid_sse2; + c->idct_permutation_type = FF_SSE2_IDCT_PERM; + } +#endif /* HAVE_SSE2_INLINE */ + +#if HAVE_SSE2_EXTERNAL if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) { // these functions are slower than mmx on AMD, but faster on Intel if (!high_bit_depth) { @@ -2491,13 +2500,6 @@ static void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx, H264_QPEL_FUNCS(3, 3, sse2); } - if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { - c->idct_put = ff_idct_xvid_sse2_put; - c->idct_add = ff_idct_xvid_sse2_add; - c->idct = ff_idct_xvid_sse2; - c->idct_permutation_type = FF_SSE2_IDCT_PERM; - } - if (bit_depth == 10) { if (CONFIG_H264QPEL) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_sse2, ff_); From 706acb558a38eba633056773280155d66c2f4b24 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 16 Nov 2012 14:31:09 +0100 Subject: [PATCH 2/3] h264: enable low delay only if no delayed frames were seen Dropping frames is undesirable but that is the only way by which the decoder could return to low delay mode. Instead emit a warning and continue with delayed frames. Fixes a crash in fuzzed sample nasa-8s2.ts_s20033 caused by a larger than expected has_b_frames value. Low delay keeps getting re-enabled from a presumely broken SPS. CC: libav-stable@libav.org --- libavcodec/h264.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index f45c572a41..658d865339 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3867,8 +3867,14 @@ again: if (s->flags & CODEC_FLAG_LOW_DELAY || (h->sps.bitstream_restriction_flag && - !h->sps.num_reorder_frames)) - s->low_delay = 1; + !h->sps.num_reorder_frames)) { + if (s->avctx->has_b_frames > 1 || h->delayed_pic[0]) + av_log(avctx, AV_LOG_WARNING, "Delayed frames seen " + "reenabling low delay requires a codec " + "flush.\n"); + else + s->low_delay = 1; + } if (avctx->has_b_frames < 2) avctx->has_b_frames = !s->low_delay; From 5ae72f54532960cb9eae82a1c9e8d505106c022b Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 24 Nov 2012 15:50:03 +0100 Subject: [PATCH 3/3] flashsv: check for keyframe before using differential coding Fixes a segfault in te fuzzed sample resolutionchange.flv_s211713. CC: libav-stable@libav.org --- libavcodec/flashsv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 2ba32641b7..ac57f9f68a 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -377,6 +377,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, } if (has_diff) { + if (!s->keyframe) { + av_log(avctx, AV_LOG_ERROR, + "inter frame without keyframe\n"); + return AVERROR_INVALIDDATA; + } s->diff_start = get_bits(&gb, 8); s->diff_height = get_bits(&gb, 8); av_log(avctx, AV_LOG_DEBUG,