From patchwork Sat Nov 12 11:31:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 1398 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp205511vsb; Sat, 12 Nov 2016 03:31:48 -0800 (PST) X-Received: by 10.194.122.101 with SMTP id lr5mr12641403wjb.210.1478950308022; Sat, 12 Nov 2016 03:31:48 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w65si37536411wmf.6.2016.11.12.03.31.46; Sat, 12 Nov 2016 03:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6BE0689FB8; Sat, 12 Nov 2016 13:31:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-2.mx.upcmail.net (vie01a-dmta-pe01-2.mx.upcmail.net [62.179.121.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF5FE689FA1 for ; Sat, 12 Nov 2016 13:31:38 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1c5WX4-0001bP-B8 for ffmpeg-devel@ffmpeg.org; Sat, 12 Nov 2016 12:31:38 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 6zXd1u00F0S5wYM01zXe16; Sat, 12 Nov 2016 12:31:38 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 12 Nov 2016 12:31:35 +0100 Message-Id: <20161112113135.20799-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161112113135.20799-1-michael@niedermayer.cc> References: <20161112113135.20799-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/mpeg4videodec: Workaround interlaced mpeg4 edge MC bug X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/avcodec.h | 1 + libavcodec/mpeg4videodec.c | 5 +++++ libavcodec/mpegvideo.c | 2 ++ libavcodec/mpegvideo_motion.c | 4 ++++ libavcodec/options_table.h | 1 + 5 files changed, 13 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 211112f..e5e7f42 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2878,6 +2878,7 @@ typedef struct AVCodecContext { #define FF_BUG_DC_CLIP 4096 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. #define FF_BUG_TRUNCATED 16384 +#define FF_BUG_IEDGE 32768 /** * strictly follow the standard (MPEG-4, ...). diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 3adf28d..cdd0dd4 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2195,6 +2195,11 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) if (ctx->lavc_build <= 4712U) s->workaround_bugs |= FF_BUG_DC_CLIP; + if ((ctx->lavc_build&0xFF) >= 100) { + if (ctx->lavc_build > 3621476 && ctx->lavc_build < 3752550) + s->workaround_bugs |= FF_BUG_IEDGE; + } + if (ctx->divx_version >= 0) s->workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE; if (ctx->divx_version == 501 && ctx->divx_build == 20020416) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 59be078..e5424cb 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2117,6 +2117,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf =ubuf + 10 * s->uvlinesize; + if (s->workaround_bugs & FF_BUG_IEDGE) + vbuf -= s->uvlinesize; s->vdsp.emulated_edge_mc(ubuf, ptr_cb, uvlinesize >> field_based, uvlinesize >> field_based, 9, 9 + field_based, diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index b97a6cb..a310bd4 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -327,6 +327,8 @@ void mpeg_motion_internal(MpegEncContext *s, if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf = ubuf + 10 * s->uvlinesize; + if (s->workaround_bugs & FF_BUG_IEDGE) + vbuf -= s->uvlinesize; uvsrc_y = (unsigned)uvsrc_y << field_based; s->vdsp.emulated_edge_mc(ubuf, ptr_cb, s->uvlinesize, s->uvlinesize, @@ -550,6 +552,8 @@ static inline void qpel_motion(MpegEncContext *s, if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf = ubuf + 10 * s->uvlinesize; + if (s->workaround_bugs & FF_BUG_IEDGE) + vbuf -= s->uvlinesize; s->vdsp.emulated_edge_mc(ubuf, ptr_cb, s->uvlinesize, s->uvlinesize, 9, 9 + field_based, diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 4323ae9..b65acea 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -163,6 +163,7 @@ static const AVOption avcodec_options[] = { {"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"}, {"ms", "work around various bugs in Microsoft's broken decoders", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"}, {"trunc", "truncated frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"}, +{"iedge", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_IEDGE }, INT_MIN, INT_MAX, V|D, "bug"}, {"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"}, {"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, A|V|D|E, "strict"}, {"strict", "strictly conform to all the things in the spec no matter what the consequences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},