From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 62FA24A69D for ; Thu, 4 Jul 2024 11:54:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7F9E68D949; Thu, 4 Jul 2024 14:54:05 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6B7568DA12 for ; Thu, 4 Jul 2024 14:53:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720094030; bh=95knvmWuOEtA4tyVc+nJk7D7pMYalEilxDEYKoRMMsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ousrc4C34CQyljf2+4GEb/OlCYUwIwts1uQEw7PiIZtfm3iQ35mO8cYrHx/TZxwSh oRJLtrI5iOWsWtNXICfSXJfMRYuVoU6xyahB5C+lPNVznGw4fwaEz6mDoFnuwGETY0 mAGnz6CNovKldj5NwNN97mk+vOxPfYorYDK8z3Xs= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 469F840564; Thu, 4 Jul 2024 13:53:50 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 13:51:59 +0200 Message-ID: <20240704115202.1235954-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240704115202.1235954-1-ffmpeg@haasn.xyz> References: <20240704115202.1235954-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] avfilter/swscale: always fix interlaced chroma location X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Niklas Haas The current logic only fixes it when the user does not explicitly specify the chroma location. However, this does not make a lot of sense. Since there is no way to specify this property per-field, it effectively *prevents* the user from being able to correctly scale interlaced frames with top-aligned chroma. It makes more sense to consider the user setting in the progressive case only, and automatically adapt it to the correct interlaced field positions, following the details of the MPEG specification. --- libavfilter/vf_scale.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 841075193e..0b6701673f 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -709,12 +709,18 @@ static int config_props(AVFilterLink *outlink) * chroma positions. MPEG chroma positions are used by convention. * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma * locations, since they share a vertical alignment */ - if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) { - in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + if (desc->log2_chroma_h == 1) { + if (in_v_chr_pos == -513) + in_v_chr_pos = 128; /* explicitly default missing info */ + in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */ + in_v_chr_pos >>= i > 0; /* double luma row distance */ } - if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) { - out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + if (outdesc->log2_chroma_h == 1) { + if (out_v_chr_pos == -513) + out_v_chr_pos = 128; + out_v_chr_pos += 256 * (i == 2); + out_v_chr_pos >>= i > 0; } av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0); -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".