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 1825B48D95 for ; Fri, 26 Apr 2024 12:28:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1121068D449; Fri, 26 Apr 2024 15:28:17 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1947768D412 for ; Fri, 26 Apr 2024 15:28:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1714134486; bh=7FeBke4bjCpnM9Lt6vqYFjWc4t+w7gETWVQerVk+8+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvV7+XTcNQN97PEqBvsqpY46+dESYgaWCNeWROuMo8nmmnzJjojv5zs1kDukHBAir OvNFxRp9VVYLyugh+tbsuzKHWpa/wq8vH5wJhKI/X9AgclvI19PQ5E4qGbR5uEilna QuqCK6gMXgGy6OshOPGX1MCv7EASO5W56EbUKRcY= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id CDD8B4255D; Fri, 26 Apr 2024 14:28:06 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Apr 2024 14:28:01 +0200 Message-ID: <20240426122803.19967-4-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 4/6] avfilter/vf_libplacebo: update metadata 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 Switches to av_frame_remove_side_data_changed(), covering a number of cases that we previously ignored. Additionally, stop stripping metadata when merely changing colorspace or color range, since these do not affect the actual color volume of the image data, only the encoding. --- libavfilter/vf_libplacebo.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index be9000aa8e..17da6fc71d 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -806,7 +806,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, /* Construct and emit an output frame for a given timestamp */ static int output_frame(AVFilterContext *ctx, int64_t pts) { - int err = 0, ok, changed_csp; + int err = 0, ok, changed; LibplaceboContext *s = ctx->priv; pl_options opts = s->opts; AVFilterLink *outlink = ctx->outputs[0]; @@ -842,6 +842,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) * output colorspace defaults */ out->color_primaries = AVCOL_PRI_BT2020; out->color_trc = AVCOL_TRC_SMPTE2084; + changed |= AV_FRAME_CHANGED_COLOR_VOLUME; } if (s->color_trc >= 0) @@ -849,21 +850,13 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) if (s->color_primaries >= 0) out->color_primaries = s->color_primaries; - changed_csp = ref->colorspace != out->colorspace || - ref->color_range != out->color_range || - ref->color_trc != out->color_trc || - ref->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); - av_frame_remove_side_data(out, AV_FRAME_DATA_ICC_PROFILE); - } - if (s->apply_dovi || changed_csp) { - av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER); - av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA); - } + if (out->width != ref->width || out->height != ref->height) + changed |= AV_FRAME_CHANGED_SIZE; + if (ref->color_trc != out->color_trc || ref->color_primaries != out->color_primaries) + changed |= AV_FRAME_CHANGED_COLOR_VOLUME; + av_frame_remove_side_data_changed(out, changed); + if (s->apply_filmgrain) av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); -- 2.44.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".