From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 2140D4F1D7 for ; Mon, 16 Jun 2025 18:05:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0A8FA68D8E3; Mon, 16 Jun 2025 21:05:07 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 5D56E68D591 for ; Mon, 16 Jun 2025 21:05:00 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id 17F68406B8; Mon, 16 Jun 2025 20:05:00 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Jun 2025 20:04:57 +0200 Message-ID: <20250616180457.140213-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_scale: set correct AVFrame SAR if reset_sar=1 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 This otherwise generates an inconsistency between the frame state and the link state, since the link state is set to 1:1 explicitly when `reset_sar` is enabled, but this line of code unconditionally overwrote the output frame SAR with the value that would be computed in the absence of `reset_sar`. cf. vf_scale_cuda, which does this correctly --- libavfilter/vf_scale.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 62aa872c77..aec765b441 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -854,10 +854,14 @@ scale: AV_SIDE_DATA_PROP_COLOR_DEPENDENT); } - av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, - (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, - (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, - INT_MAX); + if (scale->reset_sar) { + out->sample_aspect_ratio = outlink->sample_aspect_ratio; + } else { + av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, + (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, + (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, + INT_MAX); + } if (sws_is_noop(out, in)) { av_frame_free(&out); -- 2.49.0 _______________________________________________ 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".