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 ESMTPS id 5C9B84D32D for ; Wed, 19 Feb 2025 20:48:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B10B68C4A0; Wed, 19 Feb 2025 22:46:16 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9418968C3BB for ; Wed, 19 Feb 2025 22:45:59 +0200 (EET) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with ESMTP id 1ABE9436C8; Wed, 19 Feb 2025 21:45:56 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Feb 2025 21:45:48 +0100 Message-ID: <20250219204550.2826561-12-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250219204550.2826561-1-ffmpeg@haasn.xyz> References: <20250219204550.2826561-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/12] avfilter/vf_libplacebo: add an alpha_mode setting 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 Chooses the desired output alpha mode. Note that this depends on an upstream version of libplacebo new enough to respect the corresponding AVFrame field in pl_map_avframe_ex. --- doc/filters.texi | 4 ++++ libavfilter/vf_libplacebo.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 6e8272fd81..7b8fc3d4e4 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16486,6 +16486,10 @@ leading to no change. For any other value, conversion will be performed. See the @ref{setparams} filter for a list of possible values. +@item alpha_mode +Choose the desired output alpha mode, when the output format has an alpha +channel. See the @ref{setparams} filter for a list of possible values. + @item apply_filmgrain Apply film grain (e.g. AV1 or H.274) if present in source frames, and strip it from the output. Enabled by default. diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index cc07ccd8be..078e262f87 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -192,6 +192,7 @@ typedef struct LibplaceboContext { int color_range; int color_primaries; int color_trc; + int alpha_mode; AVDictionary *extra_opts; int have_hwdevice; @@ -862,6 +863,11 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) if (s->color_primaries >= 0) out->color_primaries = s->color_primaries; + if (outdesc->flags & AV_PIX_FMT_FLAG_ALPHA) { + if (s->alpha_mode >= 0) + out->alpha_mode = s->alpha_mode; + } + /* Strip side data if no longer relevant */ if (out->width != ref->width || out->height != ref->height) changed |= AV_SIDE_DATA_PROP_SIZE_DEPENDENT; @@ -1349,6 +1355,13 @@ static const AVOption libplacebo_options[] = { {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, .unit = "color_trc"}, {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, .unit = "color_trc"}, + {"alpha_mode", "select alpha moda", OFFSET(alpha_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVALPHA_MODE_NB-1, DYNAMIC, .unit = "alpha_mode"}, + {"auto", "keep the same alpha mode", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, DYNAMIC, .unit = "alpha_mode"}, + {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, DYNAMIC, .unit = "alpha_mode"}, + {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, DYNAMIC, .unit = "alpha_mode"}, + {"premultiplied", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_PREMULTIPLIED}, 0, 0, DYNAMIC, .unit = "alpha_mode"}, + {"straight", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_STRAIGHT}, 0, 0, DYNAMIC, .unit = "alpha_mode"}, + { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC }, { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC }, { "frame_mixer", "Frame mixing function", OFFSET(frame_mixer), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = DYNAMIC }, -- 2.47.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".