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 2C1474A1E3 for ; Sun, 24 Mar 2024 12:23:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A295768D3A2; Sun, 24 Mar 2024 14:23:35 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EDCDF68D27C for ; Sun, 24 Mar 2024 14:23:28 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1711283008; bh=MZ77gCl6s8uJTS0RvabITOfhkKydBBgBeAzIFUURxRE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GkseYWHYI92fAIM+Q14Y3778RcotIBoCvmh1hA5jczCvzGMEr06z1otvyTVSapIKs 1b9rMOzLGSIJ0XsRXGkaao0o3RAyF4NvHD1HYZKcXkhjgX+QKlAGKjhj7AMK0B9xp/ LjrInLih3I7SuCHp1ZwfXX/0qiwOaVCygwX3tucM= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 97E8B416A7; Sun, 24 Mar 2024 13:23:28 +0100 (CET) Date: Sun, 24 Mar 2024 13:23:28 +0100 Message-ID: <20240324132328.GC37148@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20240324092635.17850-1-damiog@gmail.com> References: <20240324092635.17850-1-damiog@gmail.com> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter: propagate colorspace and color_range from buffer filter and between AVFilterLink. 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: Damiano Galassi 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: On Sun, 24 Mar 2024 10:26:35 +0100 Damiano Galassi wrote: > There two new fields were never sent down the filter chain, > and no filter after the first had colorspace and color_range set, > causing breakage in zscale and possible other filters. > --- > libavfilter/avfilter.c | 4 ++++ > libavfilter/buffersrc.c | 2 ++ > 2 files changed, 6 insertions(+) > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 831871de90..66733f5ecf 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -391,6 +391,10 @@ int ff_filter_config_links(AVFilterContext *filter) > link->w = inlink->w; > if (!link->h) > link->h = inlink->h; > + if (link->colorspace == AVCOL_SPC_UNSPECIFIED) > + link->colorspace = inlink->colorspace; > + if (link->color_range == AVCOL_RANGE_UNSPECIFIED) > + link->color_range = inlink->color_range; > } else if (!link->w || !link->h) { > av_log(link->src, AV_LOG_ERROR, > "Video source filters must set their output link's " > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c > index ddcd403785..2760097edf 100644 > --- a/libavfilter/buffersrc.c > +++ b/libavfilter/buffersrc.c > @@ -499,6 +499,8 @@ static int config_props(AVFilterLink *link) > link->w = c->w; > link->h = c->h; > link->sample_aspect_ratio = c->pixel_aspect; > + link->colorspace = c->color_space; > + link->color_range = c->color_range; > > if (c->hw_frames_ctx) { > link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx); This still breaks FATE. I think the problem is that AVCOL_SPC_UNSPECIFIED is a valid, configurable possibility for this field. So we need to set it to -1 initially to distinguish "not set" from "unspecified". This diff resolves the FATE breakage: diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 153fb700d30..2f22c9143df 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -186,7 +186,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, link->type = src->output_pads[srcpad].type; av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1); link->format = -1; - link->colorspace = AVCOL_SPC_UNSPECIFIED; + link->colorspace = AVCOL_SPC_NONE; + link->color_range = AVCOL_RANGE_NONE; ff_framequeue_init(&li->fifo, &fffiltergraph(src->graph)->frame_queues); return 0; @@ -391,9 +392,9 @@ int ff_filter_config_links(AVFilterContext *filter) link->w = inlink->w; if (!link->h) link->h = inlink->h; - if (link->colorspace == AVCOL_SPC_UNSPECIFIED) + if (link->colorspace < 0) link->colorspace = inlink->color_range; - if (link->color_range == AVCOL_RANGE_UNSPECIFIED) + if (link->color_range < 0) link->color_range = inlink->color_range; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 4aa20e4e585..605881a43de 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -607,6 +607,7 @@ enum AVColorTransferCharacteristic { * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.3. */ enum AVColorSpace { + AVCOL_SPC_NONE = -1, ///< invalid (reserved for internal use) AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1 AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B AVCOL_SPC_UNSPECIFIED = 2, @@ -646,6 +647,7 @@ enum AVColorSpace { * bit unsigned integer range, please refer to BT.2100 (Table 9). */ enum AVColorRange { + AVCOL_RANGE_NONE = -1, ///< invalid (reserved for internal use) AVCOL_RANGE_UNSPECIFIED = 0, /** diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv index 1cbed136dde..99234f10523 100644 --- a/tests/ref/fate/rgb24-mkv +++ b/tests/ref/fate/rgb24-mkv @@ -1,5 +1,5 @@ -7d767e8238c674ecfa80458cb281c09e *tests/data/fate/rgb24-mkv.matroska -58236 tests/data/fate/rgb24-mkv.matroska +e181dc84058c3584598333dabd110123 *tests/data/fate/rgb24-mkv.matroska +58225 tests/data/fate/rgb24-mkv.matroska #tb 0: 1/10 #media_type 0: video #codec_id 0: rawvideo _______________________________________________ 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".