From patchwork Fri Jan 12 08:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 45578 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bf2f:b0:199:de12:6fa6 with SMTP id gc47csp2204246pzb; Fri, 12 Jan 2024 00:30:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIl4ZdTF2T/6ZIgQ+dZG+Lwnkcps0Bpis84RVydijKgkKLDebQY3Dso/Gg0k8yj3nvLqux X-Received: by 2002:a17:907:8e93:b0:a2c:ab73:9311 with SMTP id tx19-20020a1709078e9300b00a2cab739311mr376453ejc.31.1705048247513; Fri, 12 Jan 2024 00:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705048247; cv=none; d=google.com; s=arc-20160816; b=dsdGtYL/LeyHt+yMGlUVM3KwTYl6IDqJkRxQN5R7VlQgBJjFQKkZrxu6iQIqCpkgYo C2wzFp8I1epyLFYHTkzfIMSN9jNTF60BDQ+GRMoGPVAFNOKMZwvR//W77M9a7ZF21cjS qps0CJ20H7XKbUsco6ix/SIaJTE66vlX7IeW4KHE9Pxjb3rTJB+ndsIcuXJSyr0qeMlO Tj+6xT69Ik0ZTs2l2PeIrdQoNjzqxI4vmRGVOP9+jj369XXzAVxDKLDze1Ixk3DJkUi3 Blwx+E1J44fEWZUUKWuyZeQXlW6O0F5MnkpVCQS5mI4tJnnWZtLaCUCn2jlED35NKmvY oZrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=b40WiKXA7swq1EIWYyRviKGZ+xjCW9MtS2/dics5spc=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=HTPJ9/4IqW3b4QlXRK0D0sv2CpV1sQnxs8D+3sAaxNf2wT61CYosh+ngI7/rM4npD3 1QZwGfStKVi8kHegCybGyzArHEe3MnjuyTXfjd16oRSZRFsbxnH0v/9BEhHSapfhEaJo UJzgikrnm5hQOtmx4mQ5I6mqvf9TeloFNMkNtDMv1ac/1Pa9ZyonzK6ap2Log8Prx+Qw OnZRGeod+Id1P4NXohljSGlVkBGdNnHvaBH/meaZbIY6ysttS9/dBBwQqvB9c+BvDPN6 u0QrPUp4SEasEGFgvM4k9BJfF2kEHahzQHcnQib5/Xde1Ym30FKWgZOS+GegURdR30Yr eOnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=sOprgXpM; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m22-20020a170906259600b00a26aaf93de6si1191776ejb.108.2024.01.12.00.30.47; Fri, 12 Jan 2024 00:30:47 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=sOprgXpM; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0F3D68D08F; Fri, 12 Jan 2024 10:30:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BE7368D068 for ; Fri, 12 Jan 2024 10:29:59 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id E7DCF4B78B; Fri, 12 Jan 2024 09:29:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1705048199; bh=piqyGAbZJokKNtm//g8SNBMv8xisqOrcm4RBXAeEmqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOprgXpMJ3h2NVzi5b70Ea+Gg7YD3ViDGkbtSpNWfqLWyGlPqD+5RlyKUCdlmFo7y fpK8B+RAxjnCNtJ+vw5pxFCTPigckb4a4sOJnIxbcygMzviaFFOnug3ce37jr7rGru llKpMC1gKtaNxpPQcLW0BGaAuKUBeXI8+d3xLqQE= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 Jan 2024 09:26:01 +0100 Message-ID: <20240112082950.41637-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240112082950.41637-1-ffmpeg@haasn.xyz> References: <20240112082950.41637-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/11] 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rvKl+zwRKLCd From: Niklas Haas This is motivated primarily by a desire for YUVJ removal, which will require signalling the supported color ranges as part of the codec capabilities. But since we're adding YUV range, we might as well add the YUV color matrix as well - since some codecs (e.g. VP8, JPEG) only support certain values. I decided to preserve the ambiguous and misleading "color_spaces" name, for symmetry with AVFrame.colorspace. (Though this would IMO be better called "color_matrix" or "color_system") I also decided to omit the other AVColor* fields for now, because vf_scale cannot handle auto-conversion between primaries/transfer/etc. There is little value in adding metadata we cannot do anything with, and no harm in extending the API again in the future. In theory, vf_scale can handle conversion between chroma locations, but also the signalling for this is annoying, so I'll defer it to a future commit. --- doc/APIchanges | 3 +++ libavcodec/codec.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index e477ed78e0..99eeda1779 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-11-xx - xxxxxxxxxx - lavc 60.37.100 - avcodec.h + Add AVCodec.color_ranges and AVCodec.color_spaces. + 2023-11-xx - xxxxxxxxxx - lavfi 9.16.100 - buffersink.h buffersrc.h Add av_buffersink_get_colorspace and av_buffersink_get_color_range. Add AVBufferSrcParameters.color_space and AVBufferSrcParameters.color_range. diff --git a/libavcodec/codec.h b/libavcodec/codec.h index 8034f1a53c..8bd678de7a 100644 --- a/libavcodec/codec.h +++ b/libavcodec/codec.h @@ -235,6 +235,12 @@ typedef struct AVCodec { * Array of supported channel layouts, terminated with a zeroed layout. */ const AVChannelLayout *ch_layouts; + + /** + * Array of supported YUV color formats. Ignored for RGB/Gray formats. + */ + const enum AVColorRange *color_ranges; ///< terminated by AVCOL_RANGE_UNSPECIFIED + const enum AVColorSpace *color_spaces; ///< terminated by AVCOL_SPC_UNSPECIFIED } AVCodec; /**