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 489544292F for ; Mon, 10 Jan 2022 07:29:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E86568A6E0; Mon, 10 Jan 2022 09:29:28 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 154116897E7 for ; Mon, 10 Jan 2022 09:29:21 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 28C374952D; Mon, 10 Jan 2022 08:29:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1641799760; bh=59pvigri0Dp4wKy+8x6K2v4kW7KGMSlHQibA6gXbj4A=; h=From:To:Cc:Subject:Date:From; b=J3hzvqF99U0mMpFmJlMQIm7D2LLde4zRlA8DXAjVzh7AW3OY9y726P9I3M1vJzz11 qg1wPV8TyRU9FHMPtYqFMedV8g1mGTM/0MmhYTpeHFVk4Tdvwy/DEKQRjqykhU9X0j ddItAMyi0aC6zaNNoLue6BoIh5KtRDHvH0IjOzg4= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Jan 2022 08:29:17 +0100 Message-Id: <20220110072917.2140-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavfi/vf_libplacebo: fix side data stripping logic 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 was accidentally comparing s->colorspace against out->colorspace, which is wrong - the intent was to compare in->colorspace against out->colorspace. We also forgot to strip mastering metadata. Finally, the order is sort of wrong - we should strip this side data *before* process_frames, because otherwise it may end up being seen and used by libplacebo. Signed-off-by: Niklas Haas --- libavfilter/vf_libplacebo.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 1386aaeb3a..31ae28ac38 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -390,7 +390,7 @@ fail: static int filter_frame(AVFilterLink *link, AVFrame *in) { - int err, changed; + int err, changed_csp; AVFilterContext *ctx = link->dst; LibplaceboContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -426,22 +426,25 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) if (s->color_primaries >= 0) out->color_primaries = s->color_primaries; - RET(process_frames(ctx, out, in)); - - int changed_csp = s->colorspace != out->colorspace || - s->color_range != out->color_range || - s->color_trc != out->color_trc || - s->color_primaries != out->color_primaries; + changed_csp = in->colorspace != out->colorspace || + in->color_range != out->color_range || + in->color_trc != out->color_trc || + in->color_primaries != out->color_primaries; + /* Strip side data if no longer relevant */ + if (changed_csp) { + av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + } if (s->apply_dovi || changed_csp) { - /* Strip side data if no longer relevant */ av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER); av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA); } - if (s->apply_filmgrain) av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); + RET(process_frames(ctx, out, in)); + av_frame_free(&in); return ff_filter_frame(outlink, out); -- 2.34.1 _______________________________________________ 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".