From patchwork Fri Apr 26 12:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 48270 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp333523pzb; Fri, 26 Apr 2024 05:28:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVgEjG2iOU3k8F3xaZMYJuT95FQZ7UnnzM8zDVlwGIbI9A4/qXyEni06JsD2EW5i6dmSRFtoO0MD+sbFNue7sYCz5Hrbs909gUUQA== X-Google-Smtp-Source: AGHT+IHbUJ91toTxVrUZevUs1vWS239Eqp8OvrF0uQL0zRlJI4nGMU0S4DudXpUOI9Vd47lEYKku X-Received: by 2002:a19:381a:0:b0:51c:7a01:6ea2 with SMTP id f26-20020a19381a000000b0051c7a016ea2mr1511369lfa.6.1714134507090; Fri, 26 Apr 2024 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714134507; cv=none; d=google.com; s=arc-20160816; b=c3clmCgrlFiX1gkX3fYbQH8iDdRUl3WoMFCi4NmFn7Z0bixxUAoq4MlK4Qm0QxUjm8 7Njt1egqLewhThyIPjcf8VUhpNEKSgR15sDO/BxlS4BdfsDKPFYMHILvpkOOhHJhzxo9 Q/tF5vPGRMZ1HIuQbMnRteV3TvLeNxs0Pgj5ZcjfzTEVYMtVovJPVbu16O6o8umFKlj1 nLzoKxNl/POvVUv14Tx/AiOhiq3jW3X8EpxEIoX4SfjmaIUW16E5+B/OtyVZV1VQVBc9 jEnyr2zA5ptfsBWdsKa4SsAIPPQJgZJtBJDp4qq8OFi1Ufe+jBdQVa1dAf9w9tzliwRc vpUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ByarjMohcsvGF93Dy4yqE/c3Zk583FrEMX3swOUxW4o=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=kHYfmEX6/SG38FnF1iPNJg0+rOXp1052ZxAv0kCO8uq6WPfVdP9Qqid8uKxq/jX3Bj C0nukdbW6qVQOx/cS6DNPpg13Nm0soPRrBtSxCyGNAzqjIZdbGzioUfgVWuhjsYtsn97 B1fUv7LvOQs7w72cPIfw4a4vM08EqaTVcEKBxl2cYlm8iciw+8F3V2u9Q30cshfVtASy 1ts7EtKTpmJlBmH7Rky78CXH+mDQgo8N2+UFwZ247NSOTKcD4GK5mWtCwzWDWIoC6FfU RdVzMMNG42kNw+1vwbPDtX8+k7NP9cfC2xDVE+RJVSxOg4T1HGcZ/GJQgSOPi8SCxFfB o5Ew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ndBNjyoE; 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 dv25-20020a170906b81900b00a58db255493si135920ejb.592.2024.04.26.05.28.26; Fri, 26 Apr 2024 05:28:27 -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=@haasn.xyz header.s=mail header.b=ndBNjyoE; 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 CE50068D43E; Fri, 26 Apr 2024 15:28:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC03668D412 for ; Fri, 26 Apr 2024 15:28:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1714134486; bh=O9MrkcjVzUDMgn/l+WPChPulp9mqHEJd2RtF4cBMfh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndBNjyoET0lauNZKSYxHCARBnFtsu3x3kpdzDnolouaFN7wIz04c60Im0UfV/szBm wvv7pXJWDksH6XkE6auw07SfGrzt/ujO0NbqrqXUeJPZJ5GdTQ+sxO6S/XY2tdJqbO SOeO2FzWqcnLTGXoyf+RFlKGlkKza0wD87L4nPK8= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 698D440356; Fri, 26 Apr 2024 14:28:06 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Apr 2024 14:27:59 +0200 Message-ID: <20240426122803.19967-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240426122803.19967-1-ffmpeg@haasn.xyz> References: <20240426122803.19967-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avfilter/vf_scale*: strip metadata on size change 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UK9bfZaceC39 From: Niklas Haas --- libavfilter/vf_scale.c | 2 ++ libavfilter/vf_scale_cuda.c | 3 +++ libavfilter/vf_scale_npp.c | 3 +++ libavfilter/vf_scale_vaapi.c | 3 +++ libavfilter/vf_scale_vt.c | 3 +++ libavfilter/vf_scale_vulkan.c | 3 +++ 6 files changed, 17 insertions(+) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 1c07daeddf..7b9be039ad 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -870,6 +870,8 @@ scale: out->height = outlink->h; out->color_range = outlink->color_range; out->colorspace = outlink->colorspace; + if (out->width != in->width || out->height != in->height) + av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE); if (scale->output_is_pal) avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format); diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index 5571a52b1e..1e381d6e52 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -525,6 +525,9 @@ static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in) if (ret < 0) return ret; + if (out->width != in->width || out->height != in->height) + av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE); + return 0; } diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index 27e5e584ae..ed09f4f301 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -892,6 +892,9 @@ scale: if (ret < 0) return ret; + if (out->width != in->width || out->height != in->height) + av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE); + return 0; } diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c index 5f20b8a43c..cf7af5c68e 100644 --- a/libavfilter/vf_scale_vaapi.c +++ b/libavfilter/vf_scale_vaapi.c @@ -137,6 +137,9 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) if (err < 0) goto fail; + if (output_frame->width != input_frame->width || output_frame->height != input_frame->height) + av_frame_remove_side_data_changed(output_frame, AV_FRAME_CHANGED_SIZE); + if (ctx->colour_primaries != AVCOL_PRI_UNSPECIFIED) output_frame->color_primaries = ctx->colour_primaries; if (ctx->colour_transfer != AVCOL_TRC_UNSPECIFIED) diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c index af4a8b32c6..085f14d5fe 100644 --- a/libavfilter/vf_scale_vt.c +++ b/libavfilter/vf_scale_vt.c @@ -141,6 +141,9 @@ static int scale_vt_filter_frame(AVFilterLink *link, AVFrame *in) if (ret < 0) goto fail; + if (out->width != in->width || out->height != in->height) + av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE); + 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, diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c index 7210509de3..957f99a4d5 100644 --- a/libavfilter/vf_scale_vulkan.c +++ b/libavfilter/vf_scale_vulkan.c @@ -288,6 +288,9 @@ static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) if (err < 0) goto fail; + if (out->width != in->width || out->height != in->height) + av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE); + if (s->out_range != AVCOL_RANGE_UNSPECIFIED) out->color_range = s->out_range; if (s->vkctx.output_format != s->vkctx.input_format)