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 65BB749367 for ; Thu, 8 Feb 2024 11:30:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0ACED68D147; Thu, 8 Feb 2024 13:30:08 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B596568C9AA for ; Thu, 8 Feb 2024 13:30:01 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707391801; bh=iyimFLRkG2DjYWHE8us0Xng1IqVB36M2ilo+xfcAce4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=DBHPiRS5S0CAL104uv6ppv03Zv/lCAfDoJTWxtZWkh7A2n3jfe87f9SsOAAd7MCn+ PdKI2GdN5oPwNg9aOZUah/189H6xdI3deCnlVxHTvasvCXmQoDqNgd74m9zDySFVrs 1r6DoNOv0nFEMFlTCXKTHgA4inZ8nZzPkdgKVh98= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 72BB041AB0 for ; Thu, 8 Feb 2024 12:30:01 +0100 (CET) Date: Thu, 8 Feb 2024 12:30:01 +0100 Message-ID: <20240208123001.GD8023@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20240205193748.GB37488@haasn.xyz> References: <20240205174413.92730-1-ffmpeg@haasn.xyz> <20240205193748.GB37488@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add YUV color space metadata to AVCodec 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 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 Mon, 05 Feb 2024 19:37:48 +0100 Niklas Haas wrote: > On Mon, 05 Feb 2024 19:04:30 +0100 Andreas Rheinhardt wrote: > > This presumes the relevant states to be a cartesian product. Which need > > not be true. A callback would be better; this would also allow to base > > the list on other values already set in an AVCodecContext. And if this > > were extended, it would also allow to remove init_static_data one day. > > It is furthermore quite wasteful to store color_ranges in a list, > > although there are only very few states for it. > > What signature would you propose for such a callback? Well, there are two fundamental approaches here: 1. The callback somehow sets or returns a list of supported colorspaces. 2. The callback accepts a particular configuration and simply returns if it's supported or not, with fields set to AVCOL_*_UNKNOWN being ignored. The first case has the pro of simplicity, and the ability to enumerate more easily, but the drawback of only being scalable if we return a cartesian set (i.e. set each attribute list independently, rather than generating one big list). The second case has the pro of flexibility, and the ability to handle non-cartesian use cases, but the con of being slightly more awkward to recover a list (for e.g. filtering purpose). Fortunately, we can recover the minimal cartesian superset of the actual supported set in O(n) time, and then still verify the exact format chosen at encode time. One possibility could be to add a `test()` callback which simply tests if the current codec context has valid parameters. For example: struct AVCodecContext { ... int (*test)(const AVCodecContext *ctx); } But this suggests a very stateful API, where you have to mutate AVCodecContext in order to query what formats would be supported. I don't like this. So probably it makes more sense to just directly ingest a new struct for this purpose, which we can then extend easily. (Or should we just ingest AVFrame directly, i.e. int (*test_avframe)(ctx, AVFrame *frame)?) _______________________________________________ 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".