From patchwork Mon Feb 6 15:14:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksym Veremeyenko X-Patchwork-Id: 2434 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1820747vsb; Mon, 6 Feb 2017 07:14:18 -0800 (PST) X-Received: by 10.28.234.66 with SMTP id i63mr9378546wmh.43.1486394058667; Mon, 06 Feb 2017 07:14:18 -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 u126si8413261wmg.128.2017.02.06.07.14.18; Mon, 06 Feb 2017 07:14:18 -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 15F05689B6C; Mon, 6 Feb 2017 17:14:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from kazbek.m1stereo.tv (mail.m1stereo.tv [91.244.124.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 435C9689AD0 for ; Mon, 6 Feb 2017 17:14:06 +0200 (EET) Received: from [10.1.5.65] (dev-3.internal.m1stereo.tv [10.1.5.65]) by kazbek.m1stereo.tv (8.14.4/8.14.4) with ESMTP id v16FE74Q031862 for ; Mon, 6 Feb 2017 17:14:07 +0200 To: FFmpeg development discussions and patches From: Maksym Veremeyenko Message-ID: <589892C6.9080608@m1stereo.tv> Date: Mon, 6 Feb 2017 17:14:14 +0200 User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Fix chroma positioning for 4:2:0 pixel format 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" Hi, Attached patch fixes chroma positioning during scaling interlaced 4:2:0. On a first iteration default context value been overwritten by new value and not been update on next iterations for fields. This mean that vertical chroma position remain 128 for field#0 and field#1 instead of *64* and *192*. Attached patch use local variable for storing this intermediate value of chroma vertical position not modifying default context value. diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 22bee96..a7dfd3d 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -374,6 +374,7 @@ static int config_props(AVFilterLink *outlink) int i; for (i = 0; i < 3; i++) { + int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos; struct SwsContext **s = swscs[i]; *s = sws_alloc_context(); if (!*s) @@ -406,17 +407,17 @@ static int config_props(AVFilterLink *outlink) * MPEG-2 chroma positions are used by convention * XXX: support other 4:2:0 pixel formats */ if (inlink0->format == AV_PIX_FMT_YUV420P && scale->in_v_chr_pos == -513) { - scale->in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; } if (outlink->format == AV_PIX_FMT_YUV420P && scale->out_v_chr_pos == -513) { - scale->out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; } av_opt_set_int(*s, "src_h_chr_pos", scale->in_h_chr_pos, 0); - av_opt_set_int(*s, "src_v_chr_pos", scale->in_v_chr_pos, 0); + av_opt_set_int(*s, "src_v_chr_pos", in_v_chr_pos, 0); av_opt_set_int(*s, "dst_h_chr_pos", scale->out_h_chr_pos, 0); - av_opt_set_int(*s, "dst_v_chr_pos", scale->out_v_chr_pos, 0); + av_opt_set_int(*s, "dst_v_chr_pos", out_v_chr_pos, 0); if ((ret = sws_init_context(*s, NULL, NULL)) < 0) return ret;