From patchwork Sat Apr 21 19:05:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Borsboom X-Patchwork-Id: 8547 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1997805jad; Sat, 21 Apr 2018 12:05:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48xUP46tBj9fNEcr52ugnUTOhoDTivptmsRYYN/eePFzfI9sL7T5v5s9jqo9gW/lb4VXoB8 X-Received: by 2002:adf:d0ce:: with SMTP id z14-v6mr12026143wrh.157.1524337541900; Sat, 21 Apr 2018 12:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524337541; cv=none; d=google.com; s=arc-20160816; b=eSdCb7pY2fazGiChTRN+5OTHfPr2neEGq+PIf8pz6FztPE66AWZjhJBpELs3X1iBel eJHTVBOxX0UYhLvED0AMOY5L0k31actlZQgnMzRdNNogbJjiOYJ416zV7sQi+l4qipiq KpFGdpTU5a93VX0GTZ5ybjsZRvDCLO2aL/Oaz1xRYHOPop5tcPc5QRbyUT+TB4yIE23J TJgSXt+qnydRvOX6beFU/Ud+1iOiMLBoBJoghpscMzF4vN8buBbcpnzy+jYfJMDL4WTy uKxbEVQJAF7wWEhRMZPyAA4alpkbyyBHDV0q9PV2H+bGHuMUnqLCl/YNYJu2SPqb8iJN i/gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:dkim-signature :delivered-to:arc-authentication-results; bh=gec6B788Wi7S0pPaKpWpVVkQ0s7U8yHokppwPN03x+I=; b=Bmv+JW3EAXgawvpEIqhtHUFxH/Qh3a36hAVXmXKjcnFgO1g1R/Ok2ikXwzIfGiui2E VqAptRiy9MHhAZodSejcxbcDJzyLlJARkkuBxOap6NSornPR86aVEwofiJFjGq7CR6QW i6ruFEOW4ZNeAkqI13B484uPRkp6suLG8ZmYwWBWFwToBXhYEnQnUBFgqYM65xs5vb7J mu6TESPW2Ux1xySa9QUwZt9lRNPAhIpoEVixaVPNqsW8qwD0dno59bBxKbSyFi/HSuo+ tB3jeIR56DaN44KElnUVZI23iu7IjUylCIc8qwMw7sAk5e79q6I+Y6jG28mFaILKZpqL Y9KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@carpalis.nl header.s=default header.b=ZUtIuBjN; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w75-v6si6823277wrb.317.2018.04.21.12.05.40; Sat, 21 Apr 2018 12:05:41 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@carpalis.nl header.s=default header.b=ZUtIuBjN; 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 7748568A043; Sat, 21 Apr 2018 22:05:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from kyoto.xs4all.nl (kyoto.xs4all.nl [83.161.153.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8AFCA689BC3 for ; Sat, 21 Apr 2018 22:05:02 +0300 (EEST) Received: from [IPv6:2001:980:9507:0:8e70:5aff:fec6:83fc] ([IPv6:2001:980:9507:0:8e70:5aff:fec6:83fc]) (authenticated bits=0) by kyoto.xs4all.nl (8.14.7/8.14.7) with ESMTP id w3LJ5Six005775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 21 Apr 2018 21:05:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carpalis.nl; s=default; t=1524337529; bh=3pKGrcuc4rEMXLjA6S0gyVTRr6UNAtloD0UgdxXYtCI=; h=To:References:Subject:From:Date:In-Reply-To; b=ZUtIuBjNBTe+mRWlyWBEbMnENdZfNu1s/ZLpXEXot8f2KY85fbDAqvGbgESG13DBH KC7tHwriD6yVqb7Abi9cskJK8n/sGk7JV06gy5x7w9+lwf4/6iAZk+LrjrSU6dQP1c C0em+w1HyLzQkmW8uihafQbj1Bk2iEYfqkUrcWkN+Tw7SxCUqhoB6DqOKa6U1wG4uF Blw1/RAk5A4/N6e04/xjsOyW/hV2JcV/S/ItEq+qKUnX0fxfm6qMHu7bv1YZXspRYf cDiMS/dD7/dDfsSC32rFZKxS9+Y4v2v47g08Yh8O5ZZ1VEW/g2SGJcpYKlvgBTZns/ pC/M6xetZAGHg== To: ffmpeg-devel@ffmpeg.org References: <20180421082252.4186-1-onemda@gmail.com> From: Jerome Borsboom Message-ID: <0310ef16-586e-c2d0-fd90-b4e481eb4e2d@carpalis.nl> Date: Sat, 21 Apr 2018 21:05:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180421082252.4186-1-onemda@gmail.com> Content-Language: nl Subject: Re: [FFmpeg-devel] [PATCH] avcodec/vc1_pred: properly clip interlaced motion vectors 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" > Fixes #2557. > > Signed-off-by: Paul B Mahol > --- > libavcodec/vc1_pred.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c > index 54712f6b7a..9f42a930fe 100644 > --- a/libavcodec/vc1_pred.c > +++ b/libavcodec/vc1_pred.c > @@ -98,9 +98,9 @@ static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, > } > > if (v->cur_field_type && !v->ref_field_type[dir]) > - return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2); > + return av_clip(scaledvalue, -v->range_y / 2 - 1, v->range_y / 2); > else > - return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1); > + return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 + 1); > } > > static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */) > -- > 2.11.0 scaleforsame_y references ref_field_type. Therefore, it needs to be set before scaleforsame is called. Signed-off-by: Jerome Borsboom --- I am not sure your patch is correct. The existing implementation agrees with VC-1 spec. See Figure 119 in 10.3.5.4.3.4.2 in particular. Please have a look if the patch below solves the issue. ref_field_type is referenced in scaleforsame_y and needs to be set earlier in ff_vc1_pred_mv to have the desired effect. libavcodec/vc1_pred.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c index 54712f6b7a..3a52a22bc6 100644 --- a/libavcodec/vc1_pred.c +++ b/libavcodec/vc1_pred.c @@ -341,6 +341,8 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, } else opposite = 0; if (opposite) { + v->mv_f[dir][xy + v->blocks_off] = 1; + v->ref_field_type[dir] = !v->cur_field_type; if (a_valid && !a_f) { field_predA[0] = scaleforopp(v, field_predA[0], 0, dir); field_predA[1] = scaleforopp(v, field_predA[1], 1, dir); @@ -353,9 +355,9 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, field_predC[0] = scaleforopp(v, field_predC[0], 0, dir); field_predC[1] = scaleforopp(v, field_predC[1], 1, dir); } - v->mv_f[dir][xy + v->blocks_off] = 1; - v->ref_field_type[dir] = !v->cur_field_type; } else { + v->mv_f[dir][xy + v->blocks_off] = 0; + v->ref_field_type[dir] = v->cur_field_type; if (a_valid && a_f) { field_predA[0] = scaleforsame(v, n, field_predA[0], 0, dir); field_predA[1] = scaleforsame(v, n, field_predA[1], 1, dir); @@ -368,8 +370,6 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, field_predC[0] = scaleforsame(v, n, field_predC[0], 0, dir); field_predC[1] = scaleforsame(v, n, field_predC[1], 1, dir); } - v->mv_f[dir][xy + v->blocks_off] = 0; - v->ref_field_type[dir] = v->cur_field_type; } if (a_valid) {