From patchwork Wed Sep 4 11:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51345 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp156045vqb; Wed, 4 Sep 2024 04:34:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/hTp6JNq97zAFy+peWr/1376H/19CADMeO4XTDmsZH9WUTIZO56EJlPDEFW7tIKUWChcFFuT4S8x4u/TUBL0w@gmail.com X-Google-Smtp-Source: AGHT+IGcvAbg9k5SC4KE5klPkdjcWlIRZK0sBHmqX23ju7GakedK+5SmYtiw1agltzFWSVmwexmm X-Received: by 2002:a05:651c:150b:b0:2f1:59ed:87ab with SMTP id 38308e7fff4ca-2f6265855f1mr92991351fa.24.1725449662645; Wed, 04 Sep 2024 04:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725449662; cv=none; d=google.com; s=arc-20240605; b=AxMyliYrlsK5vVLZPEWMBkKbiaAdcDv/z51jBsgyeVTx7q4VdWM24ltyjja/sLN8FF +nw7SBp2luetSzassGYX9nOsvfGszGDAAziyF09ZNB1diGzy2i5dGlMpbI1gbyeiYGQv hK3oPJXHQOhdbF7UVmnHQ9CYtG1SA6WLkhsu38cJw8vHOghi+zswxFYHM7o+eoqYs8nr rZlblGPoyZ2E7iEX6LNO0GkbeV3ijNwvYz4U2Te3VGQTTtM2JRUz1sQ6urON2vr0PycY 8grWOCTWk/QKA81MvXfV3a6Yieri21Jg8337iI68H4lQjnrpGWdATYzjBZoakNlhqi54 6fJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=eO/S6Nyuxv0OzUxGREVdDOeu8Tlc+HCWKh2niDJtNf4=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=gknxF93rYDegyszdk3Ey+0BR6aH00eHwjip14w/IYSJZbLFkJePSXwenCt5dLjJ2lu 7wZmru1XAjCNubmQinrJFWmZEjM5UD79Rb0eNJduaWix++9SW9wqV+Ixw0El87KwlG8Z nVamBJQdFQKTXGXslDap79mt9+Iio9D10g42MhSKWjreL2JjC1Xkqejgut/p6zotqOJn pe24Ic/Ehwh9EhxbkyNUBjmcBCgNud62et771nuY/0edvbCTtMPMtF/QOjm2+XOKJKCf odYqze5YlGcHeX/EGBHnFWINYtO9FSg721dZIcZoGSR9TjnQkK+blxoesG3Lyq1tQU/G HeSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=EVYbCnI6; 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 4fb4d7f45d1cf-5c2480738c4si6539787a12.305.2024.09.04.04.34.22; Wed, 04 Sep 2024 04:34:22 -0700 (PDT) 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=EVYbCnI6; 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 4423168DE2A; Wed, 4 Sep 2024 14:08:14 +0300 (EEST) 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 E4FD768DC1E for ; Wed, 4 Sep 2024 14:08:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448086; bh=3N+kWwpV1jags3aswuO5KAUnBd5Nrh39BMWwBJE77dQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVYbCnI6SKAnP5gq3kOz/U4ZhtbSxNTvpfToqVwZPL0jaPG2XT3neaxuEi0/rd8lq ma0kLjQvYUBx/5LfwR8eTPkfAJY4A15U7NsP8ea9FuWgD4uloyOqC0ezRZ7ZYc9SGo p/DBW6KIky19Pk5trFeVtbGsrtHdSNbsoG12kCRE= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 9567A41603; Wed, 4 Sep 2024 13:08:06 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:30 +0200 Message-ID: <20240904110720.11713-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 01/17] avcodec/internal: add FFCodec.color_ranges 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: AtdKsH4NNt7A From: Niklas Haas I went through all codecs and put them into five basic categories: 1. JPEG range only 2. MPEG range only 3. Explicitly tagged 4. Broken (codec supports both but encoder ignores tags) 5. N/A (headerless or pseudo-formats) Filters in category 5 remain untouched. The rest gain an explicit assignment of their supported color ranges, with codecs in category 4 being set to MPEG-only for safety. It might be considered redundant to distinguish between 0 (category 5) and MPEG+JPEG (category 3), but in doing so we effectively communicate that we can guarantee that these tags will be encoded, which is distinct from the situation where there are some codecs that simply don't have tagging or implied semantics (e.g. rawvideo). A full list of codecs follows: JPEG range only: - amv - roqvideo MPEG range only: - asv1, asv2 - avui - cfhd - cljr - dnxhd - dvvideo - ffv1 - flv - h261, h263, h263p - {h263,vp8}_v4l2m2m - huffyuv, ffvhuff - jpeg2000 - libopenjpeg - libtheora - libwebp, libwebp_anim - libx262 - libxavs, libxavs2 - libxvid - mpeg1video, mpeg2video - mpeg2_qsv - mpeg2_vaapi - mpeg4, msmpeg4, msmpeg4v2, wmv1, wmv2 - mpeg4_omx - prores, prores_aw, prores_ks - rv10, rv20 - snow - speedhq - svq1 - tiff - utvideo Explicitly tagged (MPEG/JPEG): - {av1,h264,hevc}_nvenc - {av1,h264,hevc}_vaapi - {av1,h264,hevc,vp8,vp9,mpeg4}_mediacodec - {av1,h264,hevc,vp9}_qsv - h264_amf - {h264,hevc,prores}_videotoolbox - libaom-av1 - libkvazaar - libopenh264 - librav1e - libsvtav1 - libvpx, libvpx-vp9 - libx264 - libx265 - ljpeg - mjpeg - vc2 Broken (encoder ignores tags): - {av1,hevc}_amf - {h264,hevc,mpeg4}_v4l2m2m - h264_omx - libxeve - magicyuv - {vp8,vp9,mjpeg}_vaapi N/A: - ayuv, yuv4, y41p, v308, v210, v410, v408 (headerless) - pgmyuv (headerless) - rawvideo, bitpacked (headerless) - vnull, wrapped_avframe (pseudocodecs) --- libavcodec/amfenc_av1.c | 1 + libavcodec/amfenc_h264.c | 1 + libavcodec/amfenc_hevc.c | 1 + libavcodec/asvenc.c | 2 ++ libavcodec/avuienc.c | 1 + libavcodec/cfhdenc.c | 1 + libavcodec/cljrenc.c | 1 + libavcodec/codec_internal.h | 8 +++++++- libavcodec/dnxhdenc.c | 1 + libavcodec/dvenc.c | 1 + libavcodec/ffv1enc.c | 1 + libavcodec/flvenc.c | 1 + libavcodec/h261enc.c | 1 + libavcodec/huffyuvenc.c | 2 ++ libavcodec/ituh263enc.c | 2 ++ libavcodec/j2kenc.c | 1 + libavcodec/libaomenc.c | 1 + libavcodec/libkvazaar.c | 1 + libavcodec/libopenh264enc.c | 1 + libavcodec/libopenjpegenc.c | 1 + libavcodec/librav1e.c | 1 + libavcodec/libsvtav1.c | 1 + libavcodec/libtheoraenc.c | 1 + libavcodec/libvpxenc.c | 2 ++ libavcodec/libwebpenc.c | 1 + libavcodec/libwebpenc_animencoder.c | 1 + libavcodec/libx264.c | 2 ++ libavcodec/libx265.c | 1 + libavcodec/libxavs.c | 1 + libavcodec/libxavs2.c | 1 + libavcodec/libxeve.c | 1 + libavcodec/libxvid.c | 1 + libavcodec/ljpegenc.c | 1 + libavcodec/magicyuvenc.c | 1 + libavcodec/mediacodecenc.c | 1 + libavcodec/mjpegenc.c | 2 ++ libavcodec/mpeg12enc.c | 2 ++ libavcodec/mpeg4videoenc.c | 1 + libavcodec/msmpeg4enc.c | 3 +++ libavcodec/nvenc_av1.c | 1 + libavcodec/nvenc_h264.c | 1 + libavcodec/nvenc_hevc.c | 1 + libavcodec/omx.c | 2 ++ libavcodec/proresenc_anatoliy.c | 2 ++ libavcodec/proresenc_kostya.c | 1 + libavcodec/qsvenc_av1.c | 1 + libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + libavcodec/qsvenc_jpeg.c | 1 + libavcodec/qsvenc_mpeg2.c | 1 + libavcodec/qsvenc_vp9.c | 1 + libavcodec/roqvideoenc.c | 1 + libavcodec/rv10enc.c | 1 + libavcodec/rv20enc.c | 1 + libavcodec/snowenc.c | 1 + libavcodec/speedhqenc.c | 1 + libavcodec/svq1enc.c | 1 + libavcodec/tiffenc.c | 1 + libavcodec/utvideoenc.c | 1 + libavcodec/v4l2_m2m_enc.c | 1 + libavcodec/vaapi_encode_av1.c | 1 + libavcodec/vaapi_encode_h264.c | 1 + libavcodec/vaapi_encode_h265.c | 1 + libavcodec/vaapi_encode_mjpeg.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 1 + libavcodec/vaapi_encode_vp8.c | 1 + libavcodec/vaapi_encode_vp9.c | 1 + libavcodec/vc2enc.c | 3 ++- libavcodec/videotoolboxenc.c | 2 ++ libavcodec/wmv2enc.c | 1 + 70 files changed, 89 insertions(+), 2 deletions(-) diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index f2ad06c083..15d2582bfd 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -603,6 +603,7 @@ const FFCodec ff_av1_amf_encoder = { AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = ff_amf_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .p.wrapper_name = "amf", .hw_configs = ff_amfenc_hw_configs, }; diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index c80854c5f8..e628eabef0 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -586,6 +586,7 @@ const FFCodec ff_h264_amf_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = ff_amf_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.wrapper_name = "amf", .hw_configs = ff_amfenc_hw_configs, }; diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 51fc243747..b67fadf371 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -507,6 +507,7 @@ const FFCodec ff_hevc_amf_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = ff_amf_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .p.wrapper_name = "amf", .hw_configs = ff_amfenc_hw_configs, }; diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 6179b50583..4f81a4015d 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -367,6 +367,7 @@ const FFCodec ff_asv1_encoder = { FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, }; #endif @@ -382,5 +383,6 @@ const FFCodec ff_asv2_encoder = { FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, }; #endif diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c index 495f6d36fb..a2391b31ef 100644 --- a/libavcodec/avuienc.c +++ b/libavcodec/avuienc.c @@ -100,6 +100,7 @@ const FFCodec ff_avui_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .init = avui_encode_init, FF_CODEC_ENCODE_CB(avui_encode_frame), }; diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 7084509f6e..3be6798d8d 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -870,5 +870,6 @@ const FFCodec ff_cfhd_encoder = { AV_PIX_FMT_GBRAP12, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c index 31ad5ce0cf..4698dfd725 100644 --- a/libavcodec/cljrenc.c +++ b/libavcodec/cljrenc.c @@ -118,5 +118,6 @@ const FFCodec ff_cljr_encoder = { FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &cljr_class, }; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 1cd1f684f9..2f9eb479d4 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -132,7 +132,13 @@ typedef struct FFCodec { /** * Internal codec capabilities FF_CODEC_CAP_*. */ - unsigned caps_internal:29; + unsigned caps_internal:27; + + /** + * This field determines the video color ranges supported by an encoder. + * Should be set to a bitmask of AVCOL_RANGE_MPEG and AVCOL_RANGE_JPEG. + */ + unsigned color_ranges:2; /** * This field determines the type of the codec (decoder/encoder) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 53e3669a30..b12a2e8851 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1367,6 +1367,7 @@ const FFCodec ff_dnxhd_encoder = { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &dnxhd_class, .defaults = dnxhd_defaults, .p.profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles), diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 19137e8b50..db79497b50 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -1251,5 +1251,6 @@ const FFCodec ff_dvvideo_encoder = { AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &dvvideo_encode_class, }; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 23d757e5c6..1c37f61ada 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1309,6 +1309,7 @@ const FFCodec ff_ffv1_encoder = { AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ffv1_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_EOF_FLUSH, }; diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 6a96cb0f2f..40eec07b3e 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -105,5 +105,6 @@ const FFCodec ff_flv_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index a901c32e42..f417366e75 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -385,5 +385,6 @@ const FFCodec ff_h261_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 294d6ad41c..5e8b5c0dd7 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1026,6 +1026,7 @@ const FFCodec ff_huffyuv_encoder = { AV_PIX_FMT_YUV422P, AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; @@ -1066,6 +1067,7 @@ const FFCodec ff_ffvhuff_encoder = { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 3982b1e675..8c41e45ab2 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -920,6 +920,7 @@ const FFCodec ff_h263_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263, .p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &h263_class, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, @@ -951,6 +952,7 @@ const FFCodec ff_h263p_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263P, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &h263p_class, .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 91e66d8104..60cc0f3093 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1865,6 +1865,7 @@ const FFCodec ff_jpeg2000_encoder = { AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &j2k_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index fd9bea2505..32bda992cb 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1548,6 +1548,7 @@ FFCodec ff_libaom_av1_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_ENCODER_RECON_FRAME | AV_CODEC_CAP_OTHER_THREADS, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .p.priv_class = &class_aom, .p.wrapper_name = "libaom", diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index cd731ae9d0..e82be2a35f 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -334,6 +334,7 @@ const FFCodec ff_libkvazaar_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .p.pix_fmts = pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .priv_data_size = sizeof(LibkvazaarContext), diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 0aa2a54e68..7107c1a679 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -445,6 +445,7 @@ const FFCodec ff_libopenh264_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .defaults = svc_enc_defaults, .p.priv_class = &class, .p.wrapper_name = "libopenh264", diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 6a4364b1fe..01b67dffda 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -785,6 +785,7 @@ const FFCodec ff_libopenjpeg_encoder = { AV_PIX_FMT_XYZ12, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &openjpeg_class, .p.wrapper_name = "libopenjpeg", }; diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index b83e2118ed..546d00297d 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -668,6 +668,7 @@ const FFCodec ff_librav1e_encoder = { .p.priv_class = &class, .defaults = librav1e_defaults, .p.pix_fmts = librav1e_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_RECON_FRAME | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index e7b12fb488..79b28eb4df 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -769,6 +769,7 @@ const FFCodec ff_libsvtav1_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = eb_enc_defaults, .p.wrapper_name = "libsvtav1", diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 58da008a82..8844f4be6a 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -391,5 +391,6 @@ const FFCodec ff_libtheora_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.wrapper_name = "libtheora", }; diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 5490246d9e..1d5e9c33e8 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -2045,6 +2045,7 @@ const FFCodec ff_libvpx_vp8_encoder = { FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class_vp8, .defaults = defaults, .p.wrapper_name = "libvpx", @@ -2116,6 +2117,7 @@ FFCodec ff_libvpx_vp9_encoder = { .p.wrapper_name = "libvpx", .priv_data_size = sizeof(VPxContext), .init = vp9_init, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, FF_CODEC_ENCODE_CB(vpx_encode), .close = vpx_free, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c index f40dd01345..670412cc6e 100644 --- a/libavcodec/libwebpenc.c +++ b/libavcodec/libwebpenc.c @@ -95,6 +95,7 @@ const FFCodec ff_libwebp_encoder = { .p.id = AV_CODEC_ID_WEBP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = ff_libwebpenc_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ff_libwebpenc_class, .p.wrapper_name = "libwebp", .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c index 6f52fa7cf1..c5361d7f92 100644 --- a/libavcodec/libwebpenc_animencoder.c +++ b/libavcodec/libwebpenc_animencoder.c @@ -168,6 +168,7 @@ const FFCodec ff_libwebp_anim_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = ff_libwebpenc_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ff_libwebpenc_class, .p.wrapper_name = "libwebp", .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index d07a65a103..ff849a7ac4 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1634,6 +1634,7 @@ const FFCodec ff_libx264_encoder = { .close = X264_close, .defaults = x264_defaults, .p.pix_fmts = pix_fmts_all, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS #if X264_BUILD < 158 | FF_CODEC_CAP_NOT_INIT_THREADSAFE @@ -1691,6 +1692,7 @@ const FFCodec ff_libx262_encoder = { AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = pix_fmts_8bit, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &X262_class, .p.wrapper_name = "libx264", .priv_data_size = sizeof(X264Context), diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index dbc5b2aab1..de0ad03ee3 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -1009,6 +1009,7 @@ FFCodec ff_libx265_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .p.wrapper_name = "libx265", .init = libx265_encode_init, diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index 4c7b1908cc..d0f6e141c7 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -435,6 +435,7 @@ const FFCodec ff_libxavs_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_AUTO_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &xavs_class, .defaults = xavs_defaults, .p.wrapper_name = "libxavs", diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index c493ddc325..1021d2ae2f 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -301,6 +301,7 @@ const FFCodec ff_libxavs2_encoder = { FF_CODEC_CAP_AUTO_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &libxavs2, .defaults = xavs2_defaults, .p.wrapper_name = "libxavs2", diff --git a/libavcodec/libxeve.c b/libavcodec/libxeve.c index aca994702a..61376f3e65 100644 --- a/libavcodec/libxeve.c +++ b/libavcodec/libxeve.c @@ -614,5 +614,6 @@ const FFCodec ff_libxeve_encoder = { .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), .p.wrapper_name = "libxeve", .p.pix_fmts = supported_pixel_formats, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE, }; diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index a490f16b3f..fbd33b7065 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -908,6 +908,7 @@ const FFCodec ff_libxvid_encoder = { FF_CODEC_ENCODE_CB(xvid_encode_frame), .close = xvid_encode_close, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &xvid_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.wrapper_name = "libxvid", diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 46546e2160..927420c2d4 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -328,4 +328,5 @@ const FFCodec ff_ljpeg_encoder = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P , AV_PIX_FMT_YUV444P , AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE}, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, }; diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index 6e640d24cc..3364207f81 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -696,5 +696,6 @@ const FFCodec ff_magicyuv_encoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c index a42270551b..6ca3968a24 100644 --- a/libavcodec/mediacodecenc.c +++ b/libavcodec/mediacodecenc.c @@ -776,6 +776,7 @@ const FFCodec ff_ ## short_name ## _mediacodec_encoder = { \ AV_CODEC_CAP_ENCODER_FLUSH, \ .priv_data_size = sizeof(MediaCodecEncContext), \ .p.pix_fmts = avc_pix_fmts, \ + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, \ .init = mediacodec_init, \ FF_CODEC_RECEIVE_PACKET_CB(mediacodec_encode), \ .close = mediacodec_close, \ diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 9d4c3a4f41..b3bc355501 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -657,6 +657,7 @@ const FFCodec ff_mjpeg_encoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &mjpeg_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), }; @@ -683,6 +684,7 @@ const FFCodec ff_amv_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_JPEG, .p.priv_class = &amv_class, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 42c0f94930..e56571da03 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1241,6 +1241,7 @@ const FFCodec ff_mpeg1video_encoder = { .p.supported_framerates = ff_mpeg12_frame_rate_tab + 1, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, @@ -1260,6 +1261,7 @@ const FFCodec ff_mpeg2video_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 0b18776497..98254c2c63 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1393,6 +1393,7 @@ const FFCodec ff_mpeg4_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = ff_mpv_encode_end, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 3103a73663..5ce4e6e30c 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -681,6 +681,7 @@ const FFCodec ff_msmpeg4v2_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V2, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ff_mpv_enc_class, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, @@ -696,6 +697,7 @@ const FFCodec ff_msmpeg4v3_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V3, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ff_mpv_enc_class, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, @@ -711,6 +713,7 @@ const FFCodec ff_wmv1_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV1, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &ff_mpv_enc_class, .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/nvenc_av1.c b/libavcodec/nvenc_av1.c index ca15ebddba..79253cff66 100644 --- a/libavcodec/nvenc_av1.c +++ b/libavcodec/nvenc_av1.c @@ -202,6 +202,7 @@ const FFCodec ff_av1_nvenc_encoder = { .p.priv_class = &av1_nvenc_class, .defaults = defaults, .p.pix_fmts = ff_nvenc_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 4d6f968e0b..8cbe4dca39 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -265,6 +265,7 @@ const FFCodec ff_h264_nvenc_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = ff_nvenc_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.wrapper_name = "nvenc", .hw_configs = ff_nvenc_hw_configs, }; diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index d54e5f2512..5696e14dd4 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -264,6 +264,7 @@ const FFCodec ff_hevc_nvenc_encoder = { .p.priv_class = &hevc_nvenc_class, .defaults = defaults, .p.pix_fmts = ff_nvenc_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, diff --git a/libavcodec/omx.c b/libavcodec/omx.c index 86913237b2..2c3865506f 100644 --- a/libavcodec/omx.c +++ b/libavcodec/omx.c @@ -948,6 +948,7 @@ const FFCodec ff_mpeg4_omx_encoder = { FF_CODEC_ENCODE_CB(omx_encode_frame), .close = omx_encode_end, .p.pix_fmts = omx_encoder_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, .p.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &omx_mpeg4enc_class, @@ -969,6 +970,7 @@ const FFCodec ff_h264_omx_encoder = { FF_CODEC_ENCODE_CB(omx_encode_frame), .close = omx_encode_end, .p.pix_fmts = omx_encoder_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .p.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &omx_h264enc_class, diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 2300301af9..4493ed03ba 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -956,6 +956,7 @@ const FFCodec ff_prores_aw_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, .close = prores_encode_close, @@ -973,6 +974,7 @@ const FFCodec ff_prores_encoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, .close = prores_encode_close, diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index fe8cc5f0fd..226f95f8c6 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -1385,6 +1385,7 @@ const FFCodec ff_prores_ks_encoder = { AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &proresenc_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/qsvenc_av1.c b/libavcodec/qsvenc_av1.c index f7505a69f8..a86b409bed 100644 --- a/libavcodec/qsvenc_av1.c +++ b/libavcodec/qsvenc_av1.c @@ -221,6 +221,7 @@ FFCodec ff_av1_qsv_encoder = { AV_PIX_FMT_P010, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 53e4e744b2..304d1e7dcb 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -202,6 +202,7 @@ const FFCodec ff_h264_qsv_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index e6c038e67d..2a397a2919 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -407,6 +407,7 @@ const FFCodec ff_hevc_qsv_encoder = { AV_PIX_FMT_VUYX, AV_PIX_FMT_XV30, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index 2add12adc9..b2458eee06 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -93,6 +93,7 @@ const FFCodec ff_mjpeg_qsv_encoder = { AV_PIX_FMT_BGRA, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .p.wrapper_name = "qsv", diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index fabf461fe3..ad3da6d672 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -105,6 +105,7 @@ const FFCodec ff_mpeg2_qsv_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index a760e4932e..b247c39c86 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -117,6 +117,7 @@ const FFCodec ff_vp9_qsv_encoder = { AV_PIX_FMT_QSV, AV_PIX_FMT_XV30, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &class, .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index a6c167b1dc..7cbe820f9a 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1128,6 +1128,7 @@ const FFCodec ff_roq_encoder = { .close = roq_encode_end, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_JPEG, .p.priv_class = &roq_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 8a405b8686..2104ee0a24 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -78,4 +78,5 @@ const FFCodec ff_rv10_encoder = { .close = ff_mpv_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, }; diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index dc26877d5e..d0e24f2f26 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -75,4 +75,5 @@ const FFCodec ff_rv20_encoder = { .close = ff_mpv_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, }; diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index eac81d0d7c..0623c9d196 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -2146,6 +2146,7 @@ const FFCodec ff_snow_encoder = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &snowenc_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 4995b19f3b..81a5151b75 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -300,6 +300,7 @@ const FFCodec ff_speedhq_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = ff_mpv_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .color_ranges = AVCOL_RANGE_MPEG, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 4065c9b21a..d969be25c1 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -747,5 +747,6 @@ const FFCodec ff_svq1_encoder = { .close = svq1_encode_end, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 25539d03dc..5e65979c79 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -589,5 +589,6 @@ const FFCodec ff_tiff_encoder = { AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .p.priv_class = &tiffenc_class, }; diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index b35b34d5a1..54b1caa9e3 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -675,5 +675,6 @@ const FFCodec ff_utvideo_encoder = { AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, + .color_ranges = AVCOL_RANGE_MPEG, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index e08db5d5d3..5770e87ea1 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -433,6 +433,7 @@ static const FFCodecDefault v4l2_m2m_defaults[] = { .close = v4l2_encode_close, \ .defaults = v4l2_m2m_defaults, \ .p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \ + .color_ranges = AVCOL_RANGE_MPEG, \ .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \ FF_CODEC_CAP_INIT_CLEANUP, \ .p.wrapper_name = "v4l2m2m", \ diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c index 26a5707bf5..dfdb424185 100644 --- a/libavcodec/vaapi_encode_av1.c +++ b/libavcodec/vaapi_encode_av1.c @@ -1053,6 +1053,7 @@ const FFCodec ff_av1_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index d156719728..84f306b95f 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1397,6 +1397,7 @@ const FFCodec ff_h264_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index bbd174f975..548029a645 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1511,6 +1511,7 @@ const FFCodec ff_hevc_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index 0ca8d676dd..7667845c3d 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -586,6 +586,7 @@ const FFCodec ff_mjpeg_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index be801d21d2..30a333ecd4 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -710,6 +710,7 @@ const FFCodec ff_mpeg2_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG, .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index 634b849cd2..b2576f4a45 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -264,6 +264,7 @@ const FFCodec ff_vp8_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .hw_configs = ff_vaapi_encode_hw_configs, .p.wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index eac9be82b0..7ce24cb864 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -317,6 +317,7 @@ const FFCodec ff_vp9_vaapi_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .defaults = vaapi_encode_vp9_defaults, + .color_ranges = AVCOL_RANGE_MPEG, /* FIXME: implement tagging */ .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 7fa6ddc4ca..508defc0b9 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -1244,5 +1244,6 @@ const FFCodec ff_vc2_encoder = { FF_CODEC_ENCODE_CB(vc2_encode_frame), .p.priv_class = &vc2enc_class, .defaults = vc2enc_defaults, - .p.pix_fmts = allowed_pix_fmts + .p.pix_fmts = allowed_pix_fmts, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, }; diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index f4070571d3..da7b291b03 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2997,6 +2997,7 @@ const FFCodec ff_hevc_videotoolbox_encoder = { .priv_data_size = sizeof(VTEncContext), .p.pix_fmts = hevc_pix_fmts, .defaults = vt_defaults, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .init = vtenc_init, FF_CODEC_ENCODE_CB(vtenc_frame), .close = vtenc_close, @@ -3037,6 +3038,7 @@ const FFCodec ff_prores_videotoolbox_encoder = { .priv_data_size = sizeof(VTEncContext), .p.pix_fmts = prores_pix_fmts, .defaults = vt_defaults, + .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .init = vtenc_init, FF_CODEC_ENCODE_CB(vtenc_frame), .close = vtenc_close, diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 13ec2bf6ff..fded6f0e76 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -249,6 +249,7 @@ const FFCodec ff_wmv2_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = ff_mpv_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .color_ranges = AVCOL_RANGE_MPEG, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, }; From patchwork Wed Sep 4 11:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51349 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp303349vqb; Wed, 4 Sep 2024 08:24:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxXIB6PkR6zto7CT2ZO7S7k9ZkX7UjmEW3omWqfIArhKv36+5DmoqqhDgDYOndDj5BLtMTY8UbYsDT0UANfzb+@gmail.com X-Google-Smtp-Source: AGHT+IHyCwYZsftLg9i+UOpBIXmtlg/efzQoRW9Nbm9ZZ2AIM4Jd0l54nPQgjtqI26GcyeDvdfmK X-Received: by 2002:a17:907:724a:b0:a86:a694:aaff with SMTP id a640c23a62f3a-a89a34b4e5fmr714020366b.1.1725463450052; Wed, 04 Sep 2024 08:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725463450; cv=none; d=google.com; s=arc-20240605; b=OyCPHNmUEj5HnlkUZ7HeSYNWXAaCDq3/fxIwdHrm6g6x/u5Ew4U+qvUJvywLujzNPL rpyMX43mZ5+eFl5RlVRlMpewy5Z48fpvSgFEXTXTV7Om70G5h9MdNAVPTUgM3ubKzVzO 9Hp05AUIYBtc1c/TQ8xdnB0wZqGhCvBXYlvnyE1/dqA9lYwlvi9om6yB3OysfT8orIV3 Ww2hEvhXv+VW5vyhFXCePJTkBMan1iSVbdGOxhkri39YYFzSRRDsawK99GnbYXbN0e8W DGLLk4ljv6S8hl8TQhzvsIgCJ543Jl63btGIVvRPx1+vYpwBRRbYSOzopxBEKFdPbmHD pqxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=vlBNa+ynMEObd38hTQg0h3mowyiptEdPYGeqedqeVpk=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=NI42EmDFZl89EjEjRRZan9L3OFSuAZ/fUggB+4dOcI0j30V4AZ7WSiQNgHXhiZgeq/ Zs1j2tmEXJFOqjQG14n4wSHW0BO3zeGJiK/DrxIYXfVOPKpEZSBbCH65dUFAMxei5wIK s6vwa3zkRMXh62zuYbn+UvvjXMQFrd6K2hlkx9n3nZq6lkyGWK8xhvdH+lb2jN71qrbM viTjGC1ZxKfmpg3cyrO16CeTaGo21MqWWMoH5oKxMQ17eMuSnINW/b4g+nIu9EgPQ8Eq eSuyPZ2HtKHO/JGEsFSIyxFX4kNySmRSCdS6LGcmth3DxhqhCG2O7W+YT8c4xse1THgS VS8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=alU3r6gr; 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 a640c23a62f3a-a8a61fdd8ecsi7335566b.120.2024.09.04.08.24.09; Wed, 04 Sep 2024 08:24:10 -0700 (PDT) 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=alU3r6gr; 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 488E768DE43; Wed, 4 Sep 2024 14:08:15 +0300 (EEST) 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 2CA2D68DD4A for ; Wed, 4 Sep 2024 14:08:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448086; bh=ctoF0pvUMe+9sMe3x/OpzIA6jg0Kd/CXhPpQO/zv/UA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=alU3r6gr6+ccAgI5k4Dk5kAmNMGjTB28xl0KyStZ3lLoQRSIzfhoW7NVNP90IPCqR 6ce2muOoh2hetu6EdQJNLnObW5afCEzt5PoJL+WbPZJ+FSvWpppsZIj/y2veOvwVsn v5UYdENV06jZtyPMRd5q1QWNlUrSFtgRtvyacVko= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D6D2041683; Wed, 4 Sep 2024 13:08:06 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:31 +0200 Message-ID: <20240904110720.11713-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 02/17] avcodec: add avcodec_get_supported_config() 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: +BrPKk44uOEN From: Niklas Haas This replaces the myriad of existing lists in AVCodec by a unified API call, allowing us to (ultimately) trim down the sizeof(AVCodec) quite substantially, while also making this more trivially extensible. In addition to the already covered lists, add two new entries for color space and color range, mirroring the newly added negotiable fields in libavfilter. Once the deprecation period passes for the existing public fields, the rough plan is to move the commonly used fields (such as pix_fmt/sample_fmt) into FFCodec, possibly as a union of audio and video configuration types, and then implement the rarely used fields with custom callbacks. --- doc/APIchanges | 5 ++ libavcodec/avcodec.c | 94 +++++++++++++++++++++++++++++++++++++ libavcodec/avcodec.h | 30 ++++++++++++ libavcodec/codec.h | 19 ++++++-- libavcodec/codec_internal.h | 27 +++++++++++ libavcodec/version.h | 2 +- 6 files changed, 172 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 226c6f8b10..e81e8b1841 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-08-xx - xxxxxxxxxx - lavc 61.12.100 - avcodec.h + Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate + AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates, + AVCodec.supported_samplerates and AVCodec.ch_layouts. + 2024-08-xx - xxxxxxxxx - lavu 59.35.100 - opt.h Add av_opt_get_array_size() and av_opt_get_array(). diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 765328660b..cb89236549 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -28,6 +28,7 @@ #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/common.h" #include "libavutil/emms.h" #include "libavutil/fifo.h" #include "libavutil/imgutils.h" @@ -706,3 +707,96 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr return ff_decode_receive_frame(avctx, frame); return ff_encode_receive_frame(avctx, frame); } + +#define WRAP_CONFIG(allowed_type, field, terminator) \ + do { \ + static const __typeof__(*(field)) end = terminator; \ + if (codec->type != (allowed_type)) \ + return AVERROR(EINVAL); \ + *out_configs = (field); \ + if (out_num_configs) { \ + for (int i = 0;; i++) { \ + if (!(field) || !memcmp(&(field)[i], &end, sizeof(end))) { \ + *out_num_configs = i; \ + break; \ + } \ + } \ + } \ + return 0; \ + } while (0) + +static const enum AVColorRange color_range_jpeg[] = { + AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED +}; + +static const enum AVColorRange color_range_mpeg[] = { + AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED +}; + +static const enum AVColorRange color_range_all[] = { + AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED +}; + +static const enum AVColorRange *color_range_table[] = { + [AVCOL_RANGE_MPEG] = color_range_mpeg, + [AVCOL_RANGE_JPEG] = color_range_jpeg, + [AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG] = color_range_all, +}; + +int ff_default_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_configs, + int *out_num_configs) +{ + switch (config) { +FF_DISABLE_DEPRECATION_WARNINGS + case AV_CODEC_CONFIG_PIX_FORMAT: + WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->pix_fmts, AV_PIX_FMT_NONE); + case AV_CODEC_CONFIG_FRAME_RATE: + WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->supported_framerates, (AVRational){0}); + case AV_CODEC_CONFIG_SAMPLE_RATE: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->supported_samplerates, 0); + case AV_CODEC_CONFIG_SAMPLE_FORMAT: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->sample_fmts, AV_SAMPLE_FMT_NONE); + case AV_CODEC_CONFIG_CHANNEL_LAYOUT: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->ch_layouts, (AVChannelLayout){0}); +FF_ENABLE_DEPRECATION_WARNINGS + + case AV_CODEC_CONFIG_COLOR_RANGE: + if (codec->type != AVMEDIA_TYPE_VIDEO) + return AVERROR(EINVAL); + *out_configs = color_range_table[ffcodec(codec)->color_ranges]; + if (out_num_configs) + *out_num_configs = av_popcount(ffcodec(codec)->color_ranges); + return 0; + + case AV_CODEC_CONFIG_COLOR_SPACE: + *out_configs = NULL; + if (out_num_configs) + *out_num_configs = 0; + return 0; + default: + return AVERROR(EINVAL); + } +} + +int avcodec_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, + enum AVCodecConfig config, unsigned flags, + const void **out, int *out_num) +{ + const FFCodec *codec2; + int dummy_num = 0; + if (!codec) + codec = avctx->codec; + if (!out_num) + out_num = &dummy_num; + + codec2 = ffcodec(codec); + if (codec2->get_supported_config) { + return codec2->get_supported_config(avctx, codec, config, flags, out, out_num); + } else { + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); + } +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7a67300134..376e130f7d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2695,6 +2695,36 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, enum AVPixelFormat hw_pix_fmt, AVBufferRef **out_frames_ref); +enum AVCodecConfig { + AV_CODEC_CONFIG_PIX_FORMAT, ///< AVPixelFormat, terminated by AV_PIX_FMT_NONE + AV_CODEC_CONFIG_FRAME_RATE, ///< AVRational, terminated by {0, 0} + AV_CODEC_CONFIG_SAMPLE_RATE, ///< int, terminated by 0 + AV_CODEC_CONFIG_SAMPLE_FORMAT, ///< AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE + AV_CODEC_CONFIG_CHANNEL_LAYOUT, ///< AVChannelLayout, terminated by {0} + AV_CODEC_CONFIG_COLOR_RANGE, ///< AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED + AV_CODEC_CONFIG_COLOR_SPACE, ///< AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED +}; + +/** + * Retrieve a list of all supported values for a given configuration type. + * + * @param avctx An optional context to use. Values such as + * `strict_std_compliance` may affect the result. If NULL, + * default values are used. + * @param codec The codec to query, or NULL to use avctx->codec. + * @param config The configuration to query. + * @param flags Currently unused; should be set to zero. + * @param out_configs On success, set to a list of configurations, terminated + * by a config-specific terminator, or NULL if all + * possible values are supported. + * @param out_num_configs On success, set to the number of elements in + *out_configs, excluding the terminator. Optional. + */ +int avcodec_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, enum AVCodecConfig config, + unsigned flags, const void **out_configs, + int *out_num_configs); + /** diff --git a/libavcodec/codec.h b/libavcodec/codec.h index 6f9b42760d..f7541ffc42 100644 --- a/libavcodec/codec.h +++ b/libavcodec/codec.h @@ -205,10 +205,19 @@ typedef struct AVCodec { */ int capabilities; uint8_t max_lowres; ///< maximum value for lowres supported by the decoder - const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} - const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 - const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 - const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + + /** + * Deprecated codec capabilities. + */ + attribute_deprecated + const AVRational *supported_framerates; ///< @deprecated use avcodec_get_supported_config() + attribute_deprecated + const enum AVPixelFormat *pix_fmts; ///< @deprecated use avcodec_get_supported_config() + attribute_deprecated + const int *supported_samplerates; ///< @deprecated use avcodec_get_supported_config() + attribute_deprecated + const enum AVSampleFormat *sample_fmts; ///< @deprecated use avcodec_get_supported_config() + const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN} @@ -226,7 +235,9 @@ typedef struct AVCodec { /** * Array of supported channel layouts, terminated with a zeroed layout. + * @deprecated use avcodec_get_supported_config() */ + attribute_deprecated const AVChannelLayout *ch_layouts; } AVCodec; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 2f9eb479d4..5863760564 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -22,6 +22,7 @@ #include #include "libavutil/attributes.h" +#include "avcodec.h" #include "codec.h" #include "config.h" @@ -269,8 +270,34 @@ typedef struct FFCodec { * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. */ const uint32_t *codec_tags; + + /** + * Custom callback for avcodec_get_supported_config(). If absent, + * ff_default_get_supported_config() will be used. `out_num_configs` will + * always be set to a valid pointer. + */ + int (*get_supported_config)(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_configs, + int *out_num_configs); } FFCodec; +/** + * Default implementation for avcodec_get_supported_config(). Will return the + * relevant fields from AVCodec if present, or NULL otherwise. + * + * For AVCODEC_CONFIG_COLOR_RANGE, the output will depend on the bitmask in + * FFCodec.color_ranges, with a value of 0 returning NULL. + */ +int ff_default_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_configs, + int *out_num_configs); + #if CONFIG_SMALL #define CODEC_LONG_NAME(str) .p.long_name = NULL #else diff --git a/libavcodec/version.h b/libavcodec/version.h index 8b53586be1..da2264a097 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 11 +#define LIBAVCODEC_VERSION_MINOR 12 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Wed Sep 4 11:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51332 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp142494vqb; Wed, 4 Sep 2024 04:08:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2C7q/DkppbvotvRFFS6mv+DzmSrfEDer5BkXxQFBHrO3ry6ytiErkwTv0NeYj9EiHBFpQIXyPrnn7UfqRWYpC@gmail.com X-Google-Smtp-Source: AGHT+IGo+aKhhtcfId862/9t70JnEK1kpSyDIjvw96UNzMNIv5jSRLbkPw+/R6wvkK/tXzI7ktJg X-Received: by 2002:a05:6512:2393:b0:52e:9beb:bc09 with SMTP id 2adb3069b0e04-53546b057ccmr6215275e87.3.1725448130986; Wed, 04 Sep 2024 04:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448130; cv=none; d=google.com; s=arc-20240605; b=ON59J0MsjNWj0TUD0LSBXWkf2dAzHWoBYCRPFwexko+mi1Qy+nBWHOEwOlE9x06TQW 1eXdew0IxgQd3vEJpFJ6v5HHMFcPWrMEJe18twARmCUOFltemt7P/CsM53wXU7881e11 +0h7v7TJwCgPkitr7Bh6CGFfXFMGAVoMU7wSV6qcZBYP4WCn8BCJjFLz8YN1J2ho1be2 ElBpZhW9WXmgCmm4xeWwokBFsqLJXk7oG9Jth75dtZHCgALDj1Ud+HLULcmC2htkLaHm xpKmyEbCEU1rLmRR9nquIrsbncy5VC0LbeuqG2fCtyX3qi5X0Ao02cBAPLjz5No6EM5A 1gKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=SIob+fQNlKEdzuxioQfeedCaczuZICR3bSU1CaidimM=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=B+DpP6z4NwbW+Mn6BTM48crDR0ORHjJEdeOVifvID2ipJUesZRCauWsT9EkuMEx/+X HflVewRozuwvffNVwn5VHtg8o6XzBkLxTMsbeUKWv9FpFXsND1zAZIFvy3nltDR/yIIf 5sv0CwX3yqTvzDRsbTT0htcqXb0ZgD76Z1BEvq3r8HtYxTFTuVvIDjqGxyc61Q0QiFgK Jl4hbfagZkg7LEtlW8zofSs1X+ssnLsI94c03UKASMZs32r8jzdFL1f7jZHLJTXtofw1 xGtvzEEjVrxywtPB5u02N576yRrEozAPr3vpsuWSQDG4na97gO2ci441qhhnwhvD/nNX 8V6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="B4v/0HAM"; 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 2adb3069b0e04-5356a9d742esi32932e87.313.2024.09.04.04.08.50; Wed, 04 Sep 2024 04:08:50 -0700 (PDT) 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="B4v/0HAM"; 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 6636368DD69; Wed, 4 Sep 2024 14:08:16 +0300 (EEST) 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 595B068DC49 for ; Wed, 4 Sep 2024 14:08:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448087; bh=PL//jY9jmb91knPl0XVwBFqixbZJW+F+Ai/xxGO7Sag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B4v/0HAM5fBJsW12zkAvqZB+vUNsBc9wUn+JED21cjLNiwcTCuBsR3QxUgOruQREm gWujugxwknoZEhnxruOTLf0G9yQrw1VdUstmSf2XzOPtVANor8Wo6wKlD8dHtjo09L W8Gho4OopVaO53MolpLRcgFE52IBFvwh1czl2epM= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 1B1CB416A6; Wed, 4 Sep 2024 13:08:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:32 +0200 Message-ID: <20240904110720.11713-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 03/17] avcodec/encode: switch to avcodec_get_supported_config() 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: yHCIjA3B3Tii From: Niklas Haas --- libavcodec/encode.c | 90 ++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 34658d13d0..bc5acf985d 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -563,7 +563,8 @@ static int encode_preinit_video(AVCodecContext *avctx) { const AVCodec *c = avctx->codec; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt); - int i; + const enum AVPixelFormat *pix_fmts; + int ret, i, num_pix_fmts; if (!av_get_pix_fmt_name(avctx->pix_fmt)) { av_log(avctx, AV_LOG_ERROR, "Invalid video pixel format: %d\n", @@ -571,28 +572,33 @@ static int encode_preinit_video(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (c->pix_fmts) { - for (i = 0; c->pix_fmts[i] != AV_PIX_FMT_NONE; i++) - if (avctx->pix_fmt == c->pix_fmts[i]) + ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, + 0, (const void **) &pix_fmts, &num_pix_fmts); + if (ret < 0) + return ret; + + if (pix_fmts) { + for (i = 0; i < num_pix_fmts; i++) + if (avctx->pix_fmt == pix_fmts[i]) break; - if (c->pix_fmts[i] == AV_PIX_FMT_NONE) { + if (i == num_pix_fmts) { av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is not supported by the %s encoder.\n", av_get_pix_fmt_name(avctx->pix_fmt), c->name); av_log(avctx, AV_LOG_ERROR, "Supported pixel formats:\n"); - for (int p = 0; c->pix_fmts[p] != AV_PIX_FMT_NONE; p++) { + for (int p = 0; pix_fmts[p] != AV_PIX_FMT_NONE; p++) { av_log(avctx, AV_LOG_ERROR, " %s\n", - av_get_pix_fmt_name(c->pix_fmts[p])); + av_get_pix_fmt_name(pix_fmts[p])); } return AVERROR(EINVAL); } - if (c->pix_fmts[i] == AV_PIX_FMT_YUVJ420P || - c->pix_fmts[i] == AV_PIX_FMT_YUVJ411P || - c->pix_fmts[i] == AV_PIX_FMT_YUVJ422P || - c->pix_fmts[i] == AV_PIX_FMT_YUVJ440P || - c->pix_fmts[i] == AV_PIX_FMT_YUVJ444P) + if (pix_fmts[i] == AV_PIX_FMT_YUVJ420P || + pix_fmts[i] == AV_PIX_FMT_YUVJ411P || + pix_fmts[i] == AV_PIX_FMT_YUVJ422P || + pix_fmts[i] == AV_PIX_FMT_YUVJ440P || + pix_fmts[i] == AV_PIX_FMT_YUVJ444P) avctx->color_range = AVCOL_RANGE_JPEG; } @@ -646,7 +652,10 @@ FF_ENABLE_DEPRECATION_WARNINGS static int encode_preinit_audio(AVCodecContext *avctx) { const AVCodec *c = avctx->codec; - int i; + const enum AVSampleFormat *sample_fmts; + const int *supported_samplerates; + const AVChannelLayout *ch_layouts; + int ret, i, num_sample_fmts, num_samplerates, num_ch_layouts; if (!av_get_sample_fmt_name(avctx->sample_fmt)) { av_log(avctx, AV_LOG_ERROR, "Invalid audio sample format: %d\n", @@ -659,53 +668,68 @@ static int encode_preinit_audio(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (c->sample_fmts) { - for (i = 0; c->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { - if (avctx->sample_fmt == c->sample_fmts[i]) + ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT, + 0, (const void **) &sample_fmts, + &num_sample_fmts); + if (ret < 0) + return ret; + if (sample_fmts) { + for (i = 0; i < num_sample_fmts; i++) { + if (avctx->sample_fmt == sample_fmts[i]) break; if (avctx->ch_layout.nb_channels == 1 && av_get_planar_sample_fmt(avctx->sample_fmt) == - av_get_planar_sample_fmt(c->sample_fmts[i])) { - avctx->sample_fmt = c->sample_fmts[i]; + av_get_planar_sample_fmt(sample_fmts[i])) { + avctx->sample_fmt = sample_fmts[i]; break; } } - if (c->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { + if (i == num_sample_fmts) { av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is not supported by the %s encoder\n", av_get_sample_fmt_name(avctx->sample_fmt), c->name); av_log(avctx, AV_LOG_ERROR, "Supported sample formats:\n"); - for (int p = 0; c->sample_fmts[p] != AV_SAMPLE_FMT_NONE; p++) { + for (int p = 0; sample_fmts[p] != AV_SAMPLE_FMT_NONE; p++) { av_log(avctx, AV_LOG_ERROR, " %s\n", - av_get_sample_fmt_name(c->sample_fmts[p])); + av_get_sample_fmt_name(sample_fmts[p])); } return AVERROR(EINVAL); } } - if (c->supported_samplerates) { - for (i = 0; c->supported_samplerates[i] != 0; i++) - if (avctx->sample_rate == c->supported_samplerates[i]) + + ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_SAMPLE_RATE, + 0, (const void **) &supported_samplerates, + &num_samplerates); + if (ret < 0) + return ret; + if (supported_samplerates) { + for (i = 0; i < num_samplerates; i++) + if (avctx->sample_rate == supported_samplerates[i]) break; - if (c->supported_samplerates[i] == 0) { + if (i == num_samplerates) { av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported by the %s encoder\n", avctx->sample_rate, c->name); av_log(avctx, AV_LOG_ERROR, "Supported sample rates:\n"); - for (int p = 0; c->supported_samplerates[p]; p++) - av_log(avctx, AV_LOG_ERROR, " %d\n", c->supported_samplerates[p]); + for (int p = 0; supported_samplerates[p]; p++) + av_log(avctx, AV_LOG_ERROR, " %d\n", supported_samplerates[p]); return AVERROR(EINVAL); } } - if (c->ch_layouts) { - for (i = 0; c->ch_layouts[i].nb_channels; i++) { - if (!av_channel_layout_compare(&avctx->ch_layout, &c->ch_layouts[i])) + ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_CHANNEL_LAYOUT, + 0, (const void **) &ch_layouts, &num_ch_layouts); + if (ret < 0) + return ret; + if (ch_layouts) { + for (i = 0; i < num_ch_layouts; i++) { + if (!av_channel_layout_compare(&avctx->ch_layout, &ch_layouts[i])) break; } - if (!c->ch_layouts[i].nb_channels) { + if (i == num_ch_layouts) { char buf[512]; int ret = av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf)); av_log(avctx, AV_LOG_ERROR, @@ -713,8 +737,8 @@ static int encode_preinit_audio(AVCodecContext *avctx) ret > 0 ? buf : "?", c->name); av_log(avctx, AV_LOG_ERROR, "Supported channel layouts:\n"); - for (int p = 0; c->ch_layouts[p].nb_channels; p++) { - ret = av_channel_layout_describe(&c->ch_layouts[p], buf, sizeof(buf)); + for (int p = 0; ch_layouts[p].nb_channels; p++) { + ret = av_channel_layout_describe(&ch_layouts[p], buf, sizeof(buf)); av_log(avctx, AV_LOG_ERROR, " %s\n", ret > 0 ? buf : "?"); } return AVERROR(EINVAL); From patchwork Wed Sep 4 11:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51333 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp142556vqb; Wed, 4 Sep 2024 04:08:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHANrgxYFUZuNrHGSH7/QkZ4e7oV7XmviMtLeo8/XHmYZ/OYgE9h0eh8DfEy/8KNZ5p5lIGGhZE86gNzJeWT8g@gmail.com X-Google-Smtp-Source: AGHT+IH+WOjIvHGnGKrWXd6deCTbsufXneztmVLPnkMdRTOWKZO7fTslpdGLkd3Wn4tD8guGKdXW X-Received: by 2002:a17:907:7e9c:b0:a77:cca9:b212 with SMTP id a640c23a62f3a-a897fa751e1mr1550727866b.45.1725448139552; Wed, 04 Sep 2024 04:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448139; cv=none; d=google.com; s=arc-20240605; b=ADdlhgmVq4Y2hgZDCSO1uJcnkzDe2og+iJoIlmgIxbojfiyvKjTvzLUFU+9NUEBVM6 9uJbPj+AXOsb4ytP1kyuMIRu22nJTxQILH+2Ij0f/QSCu57y2TidWY2ufpisJZ6LrVwz TnZtWpV+pJAYKY3oDshILoVVNoyYHHYZoW3UFD5P5ub/klHdBFMkKeytdSQL83ujqHLp Bnwl6NXXGBGoCi9obvardmPsezfxsZXmpcAYPl6LZYZBvyMw/u0JWdnhbhw2beab/FRt DzGNegibR8cQqipgMgTyd5APCOZj9TL0BXtyZ1Zc2KoMJsUv0oY6notBn+dtrXdwwuXB BGAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=eyeL7JRpzjzkPOA2tzPgP9u/UhJv7m36aciPFhVJX9Y=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=HATioa6SO3xUDCdvC1UN2ocYoRoTadDz9cnaAE80QoA5862E+A3iP368skkwMG8P58 I/zoIk26FfqTFSh3NzBXiV/2V5HjGd7bj3oUsl6WKPz94l44Tk6Ap8+xSb4lpnLUlx1d aWTziUAN5rXozEUWiZy/+AMt74unOWOmf35y+JMQ+YH0Sr3v/XyUG7RYRtjCvY9hYXW3 tU+6W6XDGqfMYwE8moKGJx/DzR0kbQx5AMDEFrhxMk4XUysEgMRrlaSTiT/V6ohXzc95 17HsDoYb9ejBJbf4O96kJ2VeYP7Pv/0WWJrn0SPzYQTJuJcIBxEefSlUzgM62MnnlzHz VG6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=XKybOtAi; 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 a640c23a62f3a-a8988f44cb9si1085160566b.202.2024.09.04.04.08.59; Wed, 04 Sep 2024 04:08:59 -0700 (PDT) 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=XKybOtAi; 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 7368368DE7A; Wed, 4 Sep 2024 14:08:17 +0300 (EEST) 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 9149868DC49 for ; Wed, 4 Sep 2024 14:08:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448087; bh=H1ONcKXjj/Y/XUTYfkg9rjp5qrig56o93EiafAPv9Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKybOtAiLhy9KF5o02xv+ku7JiNrrcDRBflGeeHtTHODFmv4OW4aLM5x2t+Gn//0j UEBr9lOu27AkJwxMxqjM/FdD/9xxQAtpxSKCmA/yhzaXNoVJ63qrffOrWoL0dlEv9X BH+VTHEx32aLvnhOANsvDFgVd0W391F98y9EQ/HI= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 538B7416EC; Wed, 4 Sep 2024 13:08:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:33 +0200 Message-ID: <20240904110720.11713-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 04/17] avcodec/allcodecs: add backcompat for new config API 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: 0P4JyRdpra+h From: Niklas Haas In order to avoid breaking older clients not yet using the new API, we need to add backwards compatibility for codecs which have switched from init_static() to get_supported_config(). This function can be removed entirely once the deprecated static fields are removed. --- libavcodec/allcodecs.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 563afde355..0d61b665af 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -913,9 +913,48 @@ const FFCodec * codec_list[] = { static AVOnce av_codec_static_init = AV_ONCE_INIT; static void av_codec_init_static(void) { + int dummy; for (int i = 0; codec_list[i]; i++) { - if (codec_list[i]->init_static_data) - codec_list[i]->init_static_data((FFCodec*)codec_list[i]); + const FFCodec *codec = codec_list[i]; + if (codec->init_static_data) { + codec->init_static_data((FFCodec*) codec); + continue; + } + + /* Backward compatibility with deprecated public fields */ + if (!codec->get_supported_config) + continue; + +FF_DISABLE_DEPRECATION_WARNINGS + switch (codec->p.type) { + case AVMEDIA_TYPE_VIDEO: + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void **) &codec->p.pix_fmts, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_FRAME_RATE, 0, + (const void **) &codec->p.supported_framerates, + &dummy); + break; + case AVMEDIA_TYPE_AUDIO: + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **) &codec->p.sample_fmts, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **) &codec->p.supported_samplerates, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &codec->p.ch_layouts, + &dummy); + break; + default: + break; + } +FF_ENABLE_DEPRECATION_WARNINGS } } From patchwork Wed Sep 4 11:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51338 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148296vqb; Wed, 4 Sep 2024 04:19:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+kX5onJyPqvkp59nhY2VEWBn0IstTYd2NfEO8+DcT6LER+7W8gBXKolOhDJV2Pipq+hQLVhhOJNkF27faTkJQ@gmail.com X-Google-Smtp-Source: AGHT+IFiDnnXegpIE1HdMZirwMNnj/jMtt64bQUznahWs+RlRxmxczmKHB3dLCbC5UpJcmuPX7fE X-Received: by 2002:a2e:a983:0:b0:2ef:80:a68c with SMTP id 38308e7fff4ca-2f61e0c610bmr62556371fa.8.1725448754052; Wed, 04 Sep 2024 04:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448754; cv=none; d=google.com; s=arc-20240605; b=SYGqKpdSzehdYbRZA6gY8FWJYMFOy45MAQK8FTyc1iGuKxqMDLwE4skLdpqiN3XdXQ NfCuRAXEVPROSDBEWq1GVjkJREDnDRCPJzFkYE6hYIhHWBwyFkfG1qW7oa3MFrsuxLnN 7SBhDucLSSNWvHX+5RMrxdrFQxbDiSnTqja9eDB79GP/t0VtYCof+KWPA2djuHerVFRf QAzRuCS3rbst76ILT3+amw+TsttycxYtG7+isx5adSy/3xIeezU3MeBqrhA4XLU4xg8h 11WloOnRxfS2/QB1sV6oGMZgGqQXAqiNyrH5ljo5s5kUye2rbStjXnBFqHYXscQavz62 0Zug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Upz3shGyxKBodoz1e/5PlEzfqEVermIyE2WqKqJIY+o=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=GjnMkr32OUcofizWMs6XCKowohUrIKkIt63S/o+SsasIzOHuV4w9q0JPaZdCP/GcAi sHg/FKVIKfzlKhaVFwplj8lKsLGb5tQc4XnAkxowcHpV0EtsY3DbsWaUkN6IdQSNokee /9Q8UpAsQl2BQANnz+sXX9aDVnB6K69v6/W1MCT+QHge8HWmd56Gn2Tt/wC9916UobaG 6ghXJiHSyL3+VJpNCVunBNF/sdsjHunxyK9IoQPCC9YwI6rcoQeZgX9P7dwDFxVqB4W/ LdQcTDuwIr5uJdalQbK/pcQdvSKxHZkY8jGCwyDoFlQrMPkYVKZKxihteEt0cEOP9tg1 vpNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=NOBI5pGy; 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 38308e7fff4ca-2f6610755d2si738211fa.136.2024.09.04.04.19.13; Wed, 04 Sep 2024 04:19:14 -0700 (PDT) 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=NOBI5pGy; 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 58CE568DEE2; Wed, 4 Sep 2024 14:08:24 +0300 (EEST) 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 DFD8368DE23 for ; Wed, 4 Sep 2024 14:08:11 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448087; bh=MRT6IG8NPkXk2I6DDMH88MZutbwxDwmmHrlGAY5Aizc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NOBI5pGyyvxLnTwLkK/wSDZSxs3fPr/IZXv+C4N3Nw9hYHMKv8tL/mlEwWdVuDemF QYwvea38DvcAVOJjMChyq1wN3JC6SeFXKE6d/5gj8jpVg079udvSBhI2m4LLrLCr7c C/zJTfgpIu92EBfWsBO+/h5mKKXVLJQDbXiRI0mQ= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 8D03D41761; Wed, 4 Sep 2024 13:08:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:34 +0200 Message-ID: <20240904110720.11713-6-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 05/17] avcodec/libx265: switch to get_supported_config() 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: w0CkAqIrkLLV From: Niklas Haas --- libavcodec/libx265.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index de0ad03ee3..513f473307 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -949,14 +949,28 @@ static const enum AVPixelFormat x265_csp_twelve[] = { AV_PIX_FMT_NONE }; -static av_cold void libx265_encode_init_csp(FFCodec *codec) +static int libx265_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, const void **out, + int *out_num) { - if (x265_api_get(12)) - codec->p.pix_fmts = x265_csp_twelve; - else if (x265_api_get(10)) - codec->p.pix_fmts = x265_csp_ten; - else if (x265_api_get(8)) - codec->p.pix_fmts = x265_csp_eight; + if (config == AV_CODEC_CONFIG_PIX_FORMAT) { + if (x265_api_get(12)) { + *out = x265_csp_twelve; + *out_num = FF_ARRAY_ELEMS(x265_csp_twelve) - 1; + } else if (x265_api_get(10)) { + *out = x265_csp_ten; + *out_num = FF_ARRAY_ELEMS(x265_csp_ten) - 1; + } else if (x265_api_get(8)) { + *out = x265_csp_eight; + *out_num = FF_ARRAY_ELEMS(x265_csp_eight) - 1; + } else + return AVERROR_EXTERNAL; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); } #define OFFSET(x) offsetof(libx265Context, x) @@ -1013,7 +1027,7 @@ FFCodec ff_libx265_encoder = { .p.priv_class = &class, .p.wrapper_name = "libx265", .init = libx265_encode_init, - .init_static_data = libx265_encode_init_csp, + .get_supported_config = libx265_get_supported_config, FF_CODEC_ENCODE_CB(libx265_encode_frame), .close = libx265_encode_close, .priv_data_size = sizeof(libx265Context), From patchwork Wed Sep 4 11:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51339 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148320vqb; Wed, 4 Sep 2024 04:19:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKqKtb82Vvd+dDbksDfF+7SocQXAKvWB/gb6b0JklB79+JCPRtsPxg/1i/fuPt8yAEi8G6ch+RKrtApE6sHIeD@gmail.com X-Google-Smtp-Source: AGHT+IEOg5p9XoU84+oBJz/uDZ7Xy6hmmTIyiqZMkMjCS1iomIHvTlg9r57H3qwN1yBuU1MlFKE9 X-Received: by 2002:a05:6512:3e26:b0:533:43bf:565d with SMTP id 2adb3069b0e04-53546b45292mr11777051e87.27.1725448756361; Wed, 04 Sep 2024 04:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448756; cv=none; d=google.com; s=arc-20240605; b=g8RMTtDqG9lxDIPx39RCCVERTAL+ezkkqq0eDdQpKG3fcvvFjs5N5Rsf6gtG+SAYOo BVSvz8uwxDoXvJBaGE046xGJctuSSh+GZIhs/g4ENcW2JUOabT89gYJSDLA9OQ8oKTAX 7G/w0ak2nABhAUppgH0Yo4t8vvOiqGkRk+yiBNDI/X9+cwSvMNwx6guWbmM/MrC1HuYo hdG3SzC/cnoJPOgm5lMv5zu8DOJQcqkHoUJP/DvMc/aQpcAWnR3zXDONpYCodav5B7v2 Ud2+VeYlTHzWCCq6L7SysODP9UKbzrgmiHR9jtpjo0Skq8GmuM1lxk/0uNWHR00virD0 4a9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=bqKFLR+V2pnxLfGr5U+zDRq1ISd2P66tjGSdbtaHMzQ=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=PbjKBMYnxfW6/JkmwVjos3xifWsoV9B3Zcie7xuHIyXdeZtvZMTgNQaWlVj6g6H2GB X1wR7SK8414JsN14HYlhPyfrUUSSQtYhD9TUJzTD/p35ryfNsdVlLP22/X8WEVm9ozu7 HiP9HjkgBYBqmEyyqOi05bAndKb/LHr/4DG6eknQNwJvEJATjMBLvDOo8lbFcjGTRa1q Kl2W8vRJst1PNc5t85KFvDV5GK+W1lRBvkggUG8z7ElWphQ0UXOOKULUXfZoC39e7XbY /L2BLUVMB+w1H82d3gv6aM4CyODn8ouYwdnrfo/jDzMRq/ZMuDxFUtvq8lp84ChFEBXt kUVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=cV7REVPj; 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 2adb3069b0e04-5354077ca34si4395312e87.10.2024.09.04.04.19.15; Wed, 04 Sep 2024 04:19:16 -0700 (PDT) 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=cV7REVPj; 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 7847168DEE4; Wed, 4 Sep 2024 14:08:25 +0300 (EEST) 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 F346568DE5C for ; Wed, 4 Sep 2024 14:08:11 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448087; bh=I+77vsy/A8XtXB1zzf2JpBwljIP74Rsw11e1avpO0p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cV7REVPjNI1uqtOv72BuypK3rihYL/TWDkB7eozgcCJs340vRkdW4kyeeqNgTZsWq LVYVY9P1u1lVvzvVrwv2W37FYUpTcySVZ2gFX/qcRyM3DZJFIU0ZVt7JSdv2HEqZ3H tzK6vmW4lph06eZPzLjx3M8Kz0z9K6G8NFWUG7JU= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id C3C1C417D8; Wed, 4 Sep 2024 13:08:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:35 +0200 Message-ID: <20240904110720.11713-7-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 06/17] avcodec/libvpxenc: switch to get_supported_config() 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: JhXfaqvsBeiJ From: Niklas Haas --- libavcodec/libvpxenc.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 1d5e9c33e8..228ede7c84 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -2088,13 +2088,25 @@ static const enum AVPixelFormat vp9_pix_fmts_highbd[] = { AV_PIX_FMT_NONE }; -static av_cold void vp9_init_static(FFCodec *codec) +static int vp9_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, const void **out, + int *out_num) { - vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx()); - if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) - codec->p.pix_fmts = vp9_pix_fmts_highbd; - else - codec->p.pix_fmts = vp9_pix_fmts_highcol; + if (config == AV_CODEC_CONFIG_PIX_FORMAT) { + vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx()); + if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { + *out = vp9_pix_fmts_highbd; + *out_num = FF_ARRAY_ELEMS(vp9_pix_fmts_highbd) - 1; + } else { + *out = vp9_pix_fmts_highcol; + *out_num = FF_ARRAY_ELEMS(vp9_pix_fmts_highcol) - 1; + } + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); } static const AVClass class_vp9 = { @@ -2124,6 +2136,6 @@ FFCodec ff_libvpx_vp9_encoder = { FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .defaults = defaults, - .init_static_data = vp9_init_static, + .get_supported_config = vp9_get_supported_config, }; #endif /* CONFIG_LIBVPX_VP9_ENCODER */ From patchwork Wed Sep 4 11:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51342 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp155959vqb; Wed, 4 Sep 2024 04:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuDkVA4QG+FzoAKzaO80+P9/3MuGwoiBCGC/pqVBtVysCzskDeRKT3MvHSjXe+brOsJqlUgfpxEKoZumLzZcH0@gmail.com X-Google-Smtp-Source: AGHT+IHNSv2MIZDSu4GAiJlDA8deQLGpCN3QrEl+D7n8dbOUw84kX1USiknjB8/NDiweyT9F3Ie8 X-Received: by 2002:a05:651c:2115:b0:2ef:2373:5f90 with SMTP id 38308e7fff4ca-2f61df9f4b8mr62195761fa.0.1725449653294; Wed, 04 Sep 2024 04:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725449653; cv=none; d=google.com; s=arc-20240605; b=fVot+cgVRvF8Vn1kJvaKYgAlClOV6LW0aW/v8zPQvg3LS8YlgKLmmlS6vUUJ56Kbqu I+lnO2R7CRruEtUOL0BPhyNsurFsQJrZDNkB0l/QpvL5KWR8zjgACXK/yjHNy8OsauCt E9Q93jyURaQyXT51qOgHKI7TCzI0n5Xy5zoCvXtsxJAAEal8h2PO4p0LBjc27REPswFl N0/GB2yOwXrCumhMKOH5Jx+a6F8/1RBaruvlDPRktPFef9H5IjGe5UZQZ0PaxTYDSeRq obEcs6ZAdMnOLM6qRCZUS0I6LlQN6tvCWJng5GNy66MCzxGWb0q+bA3cQenuZ7FJCxRq vRug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=mobSvPCCjmZQlXGuSpKqqhOL7+UIE2GqiAIqEizNRes=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=bwyLQ0wD1BcY36kTNakQZp/xDz0D7nBlWzehO7pWH0dWDjtnqJxyBbTUQnBfq973oF 7qLUchGsI7fKUHGSWSmEYSfYxdLDRNb4NvO2LFQ/C08HFvPayLMoEJW7lTuLWVX6s3DU lL9hRJDgrOzCSrGoAsfw6S2MPX/yZSUNCO7PaCSc/ZVYBJY9fcYOYF29aPilhNuiBpmZ zAMYnZdPee1+3sMD8faZGY7+D6ioxSoghZ3xbbZiv8DsK8uBmdN/Gf0FAuFNG1PxKLKB nOG2vvmSLCO06VCaW/quGjhdOsBum4HkCqc7LK5f8y/JwbsPVMXuQHxIt7a9ZfbPDzKS 5gpA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=GhIgwlqq; 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 38308e7fff4ca-2f615188c42si43974251fa.603.2024.09.04.04.34.12; Wed, 04 Sep 2024 04:34:13 -0700 (PDT) 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=GhIgwlqq; 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 AE94768DEF7; Wed, 4 Sep 2024 14:08:26 +0300 (EEST) 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 3134668DE6D for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448088; bh=0Yn+CoQlaFDsoLQCU1ZdoBLFxe5IrBwVxLwJY6QD670=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhIgwlqqRnyHAwxF0WlLQbbw5Va0J7VAc7AVC7Qrcqo9dtwrjby9cMMFlG/Km5+he Tkgd6xvB4hdRlGf3q9aAzqXMcqd2eNSZ4HlxHbJdU0dEVkVn/CGn8A7iwgherSGyIV +D2SpOrD8K/DK56gj5TpvGDtPHx9bcfQDbugRYQA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 08195417DE; Wed, 4 Sep 2024 13:08:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:36 +0200 Message-ID: <20240904110720.11713-8-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 07/17] avcodec/libaomenc: switch to get_supported_config() 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: 2564BDuHnjGH From: Niklas Haas --- libavcodec/libaomenc.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 32bda992cb..0f7571ee7a 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1427,16 +1427,36 @@ static const enum AVPixelFormat av1_pix_fmts_highbd_with_gray[] = { AV_PIX_FMT_NONE }; -static av_cold void av1_init_static(FFCodec *codec) +static int av1_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, const void **out, + int *out_num) { - int supports_monochrome = aom_codec_version() >= 20001; - aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx()); - if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) - codec->p.pix_fmts = supports_monochrome ? av1_pix_fmts_highbd_with_gray : - av1_pix_fmts_highbd; - else - codec->p.pix_fmts = supports_monochrome ? av1_pix_fmts_with_gray : - av1_pix_fmts; + if (config == AV_CODEC_CONFIG_PIX_FORMAT) { + int supports_monochrome = aom_codec_version() >= 20001; + aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx()); + if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) { + if (supports_monochrome) { + *out = av1_pix_fmts_highbd_with_gray; + *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_highbd_with_gray) - 1; + } else { + *out = av1_pix_fmts_highbd; + *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_highbd) - 1; + } + } else { + if (supports_monochrome) { + *out = av1_pix_fmts_with_gray; + *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_with_gray) - 1; + } else { + *out = av1_pix_fmts; + *out_num = FF_ARRAY_ELEMS(av1_pix_fmts) - 1; + } + } + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); } static av_cold int av1_init(AVCodecContext *avctx) @@ -1560,5 +1580,5 @@ FFCodec ff_libaom_av1_encoder = { FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .defaults = defaults, - .init_static_data = av1_init_static, + .get_supported_config = av1_get_supported_config, }; From patchwork Wed Sep 4 11:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51334 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148230vqb; Wed, 4 Sep 2024 04:19:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6KdCcG6abyfut6A8zWmJf/68OCpTPNsrlm4jypKfETbbfjEVHs3xeXQ6o1Hq5daKP+d8hvCIrw1XSW7B9+yzl@gmail.com X-Google-Smtp-Source: AGHT+IELcM9XPdYMCtRpBg2nGI4WNGUjyvjcutAvgEzTUofG/5U2lBRhvi+ealZgLn+84WJj3Ycw X-Received: by 2002:a17:907:6d27:b0:a7a:8378:625c with SMTP id a640c23a62f3a-a897f8d50aemr1634810566b.36.1725448748105; Wed, 04 Sep 2024 04:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448748; cv=none; d=google.com; s=arc-20240605; b=R3R8Tgh1EcwHMMz+OVaMWqopqn0pZKaq63pvP3/LYUZgfnjWj2JO6LcZk3HE+jQ24Z /PYQpC5ElnYbYRFYFbXL2n9b2mwNERIG/cwrRJSIxUDPZ/crD8Lz/dZNNRLhKyNfAma3 uqrY8ejLmrkW+Md/3WN6HKbtjO7PeTo82M9wG5au3izychADLjtNMbPd71HRSGdyp6Qd EieNChSdGS1VyqGy1wT5/23hcscuhRgSaG3M/fHYDltCVYzVomKGIJcMy6jo2YyCzmSH DMbyIT8Srv1oIKI8ZLXXRuDocsuJ522yHt8pjyYhOTG1DlNAfnMlsTIzVjRVDbfTB09f sBsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=nbmYRd5GeCVm95kJ2zmM4HgRTxOJ4btzMmElKsnM6uo=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=etrSIHBDqGuZfP9/VUWJUZ+upzJWiLs/IHrpphO475hqUVZBKdypYtkFY3RtPeleW/ 7AxrtZzkwAq+BTGRo5gVztXCUe5xr9fmhOJgnba25rNVtEbHnNlznZCmw2UkaEn9gknL rqxb8astgmlE9zJoijldlrFr6M1Cz6qT7yUTTYo7IeonQXd7UKpfZFX+TMuQu5yEW1Mh MlIqoSTywXIXNidlUb1tatmapWt5L+fIBDDo7asiHa8MxJ2jBrjLB4Md0+7EsDvpk4le LMXoGwbPO4zR2xvxS54GPyONfhQPThFzZ0dbH+IZ66eG0cwOjXGE+iOEjfOSPC96NBpA m1vg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=vZ42kDaU; 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 a640c23a62f3a-a89891c499csi1035805366b.712.2024.09.04.04.19.07; Wed, 04 Sep 2024 04:19:08 -0700 (PDT) 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=vZ42kDaU; 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 2B5E168DF03; Wed, 4 Sep 2024 14:08:28 +0300 (EEST) 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 3CDC268DE6F for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448088; bh=Yht1bLO1F9l/8pSn9fEbYfcRWrxhxmXQaCFRvnKI+B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZ42kDaU7Nw0e5e80wjl0c7r+xt+ETzAwfwEm8Oyjt3Zxh/c+o05sYYQwbM4/uJot xh3T3iAS1bwIttK3BXi+Me8kBQcoImcuQp7vNtTZbQiOthreUyXR6nGRYdYpvwvAAi 9EH7ZXU5lMZxsRlAUiIGbfM4MTIb9ptDEahUT7Tk= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 4003541842; Wed, 4 Sep 2024 13:08:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:37 +0200 Message-ID: <20240904110720.11713-9-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 08/17] avcodec/mjpegenc: switch to get_supported_config() 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: EpgX2w7qnKgy From: Niklas Haas This codec's capabilities should be set dynamically based on the value of strict_std_compliance, when available. This will allow us to finally get rid of the strictness hack in ffmpeg_filter.c. --- libavcodec/mjpegenc.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index b3bc355501..40da602a6d 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -640,7 +640,27 @@ static const AVClass mjpeg_class = { .version = LIBAVUTIL_VERSION_INT, }; -const FFCodec ff_mjpeg_encoder = { +static int mjpeg_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, const void **out, + int *out_num) +{ + if (config == AV_CODEC_CONFIG_COLOR_RANGE) { + static const enum AVColorRange mjpeg_ranges[] = { + AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED, + }; + int strict = avctx ? avctx->strict_std_compliance : 0; + int index = strict > FF_COMPLIANCE_UNOFFICIAL ? 1 : 0; + *out = &mjpeg_ranges[index]; + *out_num = FF_ARRAY_ELEMS(mjpeg_ranges) - index - 1; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); +} + +FFCodec ff_mjpeg_encoder = { .p.name = "mjpeg", CODEC_LONG_NAME("MJPEG (Motion JPEG)"), .p.type = AVMEDIA_TYPE_VIDEO, @@ -657,9 +677,9 @@ const FFCodec ff_mjpeg_encoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, - .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.priv_class = &mjpeg_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), + .get_supported_config = mjpeg_get_supported_config, }; #endif From patchwork Wed Sep 4 11:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51335 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148258vqb; Wed, 4 Sep 2024 04:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZCCGPnceNLp5MVKxAUs1wmTs7yJgVA8ah8pXjuaZqHv7k+DP5TrqwiTNmj08row8NLXlahCoHz+MF9Hg8t6+n@gmail.com X-Google-Smtp-Source: AGHT+IFlKbQziON0Mnxh+fECOzZkf9Golm/KAQ2A2jKTCevwtDF7Z02GRWSnAE9zl9fYXwP2Ik5T X-Received: by 2002:a05:6512:3094:b0:52c:ce28:82bf with SMTP id 2adb3069b0e04-53546b56070mr6913413e87.5.1725448750791; Wed, 04 Sep 2024 04:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448750; cv=none; d=google.com; s=arc-20240605; b=DCvvBoVJ9EcBEzXGp/dOhOHgCC92VegE5oA+I16UZs9xoy5phtm9l7DLaT56XMNEqj 5aZYRceUnMdceVpKmHIFhbQuH+GMsY+zsA6pYe8lNNaYLy4EoVbQ60LM4D5lkCsAoiG0 ih6TXdwGpffmbe5urjZ6SD7Fvr2ORW4LsfOk4DbP2IBQ9vJ7a78fcFaWPxLumP5KPjHI AGQw+bk+bUCXtBcsowFB88c0Hz0GAqpW0S5yjTUjY5XpRUt7AbBsu3B4DWGLCIw3g9AY HWfO01KGJRdB6hEazJ8LVm/rKSYj7JrpH/eGSSBMFSH0Ui6JHWuQzug5UaexFt71MK+b boWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=NpTcT0bJxQLHKaAQYIzrA7z5zTOVtR3ypxlTRbj5Q1k=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=cPG7x+Y74bAGswvs0nriN7jk5Xy+YvxzLa96h6bsr/Pt4g6JlrK9+sLwbdTpJXMeLO u83CZAItHP6j6IluqugyGKKkWMxDxodlEsVJ3dtP4qBJkz6MBzDGoEx9ZFTw+BiisKR1 9y7wIjqnqTDM6Fp1EC27v1OTyFJTYupwmOw9AP/jku/Sa3qILx3qkATLcdl7iIAZZQ79 9xQhEoCJE+0tQowO+zvaw+WXtCW7n6wF3GFXBIevE+n3tzZsjyU8C4PfmuZprCRdNjiG YwybzAn6n6tNOcxMuJsU4bBg07Z2z86Sb/9PEGGd3z4JXChss+TmZ6ZlgV4RudxABQ5n EHHg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=hnjvz6XS; 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 a640c23a62f3a-a898912d82dsi1012597266b.297.2024.09.04.04.19.09; Wed, 04 Sep 2024 04:19:10 -0700 (PDT) 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=hnjvz6XS; 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 9720A68DF11; Wed, 4 Sep 2024 14:08:29 +0300 (EEST) 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 5331D68DE70 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448088; bh=gqxq8b+yW9RpBenUTNCnQsL+hmQpkZZq3Mj+vPRFkcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hnjvz6XSQw55ZslcTEH/pTE6WUKIpZiU5DRMgPc/TSoHeIQdm9zkUk6zmLgDeaQc5 sjj1lzFmUMk7lTT7RsHG8JXhlsC13xJ5kwz0GyAxoudTpj3tOHgzGuLehdCWYwCC4r VTLzZ0EL6ToFMbmmCCzOsqLpUOstbjZQk7qrHbtA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 790B8418EF; Wed, 4 Sep 2024 13:08:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:38 +0200 Message-ID: <20240904110720.11713-10-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 09/17] avcodec/codec_internal: nuke init_static_data() 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: L4XGX2+ckJnQ From: Niklas Haas All hail get_supported_config() --- libavcodec/allcodecs.c | 7 +------ libavcodec/codec_internal.h | 8 -------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 0d61b665af..d773ac36c2 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -915,13 +915,8 @@ static void av_codec_init_static(void) { int dummy; for (int i = 0; codec_list[i]; i++) { - const FFCodec *codec = codec_list[i]; - if (codec->init_static_data) { - codec->init_static_data((FFCodec*) codec); - continue; - } - /* Backward compatibility with deprecated public fields */ + const FFCodec *codec = codec_list[i]; if (!codec->get_supported_config) continue; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 5863760564..5b2db74590 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -173,14 +173,6 @@ typedef struct FFCodec { */ const FFCodecDefault *defaults; - /** - * Initialize codec static data, called from av_codec_iterate(). - * - * This is not intended for time consuming operations as it is - * run for every codec regardless of that codec being used. - */ - void (*init_static_data)(struct FFCodec *codec); - int (*init)(struct AVCodecContext *); union { From patchwork Wed Sep 4 11:02:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51344 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp156037vqb; Wed, 4 Sep 2024 04:34:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXomEKx2ZQyl52X+cEehY9sT+lb48NAP3R87+EKMjxTqCUHAZwwYNE69VtWUuAV8lINas4KEdbcdou0ZwFAJUed@gmail.com X-Google-Smtp-Source: AGHT+IHSE6ax/DC7gjS4232Z8d6W7CisGBemBNIlXEBPc3YgDio3TWWeB04XCXTiF+M0HsJkJ8Qj X-Received: by 2002:a05:6512:33c3:b0:535:6400:1da8 with SMTP id 2adb3069b0e04-53565f218c1mr1637503e87.28.1725449661226; Wed, 04 Sep 2024 04:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725449661; cv=none; d=google.com; s=arc-20240605; b=UJWtCRJMcPZ8J/1/RNAr4fpwdp5UtRLQKrsm3Ptm0GuBDcHg8vG+3AjFR2cmq2rHs4 MEREoBdglT/0YSKy2xEZNC2FRNFQNybLdwiC4beOMYNy6lCowQQ7p+8js5aoCNR6jiGF kdBeSQTt8Yea/mFCNZmJHzBblYMxmv5hCvPqNZB3d+huUVQ7Xs1xu+/ZK9tuV56nGF45 vj4QpqvROUj7pCDJ2ZdJn9AvqN4dPXYE1QMgrjKeRe7Scy3lI5lFEqAvb0JdinQv1AwE dhpB9pbHzI979t76wMgtcN8x6ykZanoKTtF0tBlwxIGrT7g0nrB340ID2PJStRCTZMEd gk0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=IvVRP7trVK9e6UPP0VpacW5/qG/xBDsvPd7HPcvHSE8=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=C307x/bO8I1OcEGBP0LT3eEhiXEz3tm5eYNELCzSbrs1aIuz3yXfKGrJ9v8/Z5Zcvb 7gpKxL1hM/wQTg71Th0WhsbR0RxGs4qEwDV27MZ0yqwRwKMsLKVa7dXQyG+TGrjZdFz9 3dXIF0VeeZMzhLWTN9gcih5/TrBHnxzAILHeeq2Suow45HsGbT1QKEnocVguD2hWgnlh SinqzxzO5eVOiMNTj0IbTgKoGOCWCWJpFLaYLRqJey0kHs5FswacEeTbg4q8u4sej3v+ 2vpr9I/TJwPT92GKg2xVYS71nRX/b9RBVqaEK/ATzqdy4wmyQ3GAFNo4Q3x2Ah2sAlk8 5c1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ZgordPCs; 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 2adb3069b0e04-5354084435fsi4062357e87.570.2024.09.04.04.34.20; Wed, 04 Sep 2024 04:34:21 -0700 (PDT) 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=ZgordPCs; 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 C775668DF1B; Wed, 4 Sep 2024 14:08:30 +0300 (EEST) 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 5DEF268DE72 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448088; bh=0YZeWtqTeY3zK6nfGACeZEW4hjJtYGKkqirxMTTBALM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZgordPCsfKky5ZU/iRWgTyzs8WWt+PoIYe3wM8qoMjGiuN1/hkM3U3ThvOiljnKYM T+G3EXTL133zmDjcWgWcJDdI42jgqbiqLbJcbLYX8IIaquOF8dX+YJK3i/rbrBIe8H ArT+ixIcNxTuHZaP0xq408awnvTWyb7b7blve2xs= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id AFB6A41905; Wed, 4 Sep 2024 13:08:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:39 +0200 Message-ID: <20240904110720.11713-11-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 10/17] fftools/opt_common: switch to avcodec_get_supported_config() 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: ZF9p6x1lnM65 From: Niklas Haas While rewriting this macro, I decided to make it a bit more flexible so it can work for all of the fields (including future fields) in a more generic way, and to also print the channel layout using an AVBPrint to avoid hard-coding the assumption that the length is less than 128 characters. --- fftools/opt_common.c | 91 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/fftools/opt_common.c b/fftools/opt_common.c index 9d2d5184a0..f44fc4c97c 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -262,22 +262,36 @@ int show_buildconf(void *optctx, const char *opt, const char *arg) return 0; } -#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ - if (codec->field) { \ - const type *p = codec->field; \ - \ - printf(" Supported " list_name ":"); \ - while (*p != term) { \ - get_name(*p); \ - printf(" %s", name); \ - p++; \ - } \ - printf("\n"); \ - } \ +#define PRINT_CODEC_SUPPORTED(codec, config, type, name, elem, fmt, ...) \ + do { \ + int num = 0; \ + const type *elem = NULL; \ + avcodec_get_supported_config(NULL, codec, config, 0, \ + (const void **) &elem, &num); \ + if (elem) { \ + printf(" Supported " name ":"); \ + for (int i = 0; i < num; i++) { \ + printf(" " fmt, __VA_ARGS__); \ + elem++; \ + } \ + printf("\n"); \ + } \ + } while (0) + +static const char *get_channel_layout_desc(const AVChannelLayout *layout, AVBPrint *bp) +{ + int ret; + av_bprint_clear(bp); + ret = av_channel_layout_describe_bprint(layout, bp); + if (!av_bprint_is_complete(bp) || ret < 0) + return "unknown/invalid"; + return bp->str; +} static void print_codec(const AVCodec *c) { int encoder = av_codec_is_encoder(c); + AVBPrint desc; printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name, c->long_name ? c->long_name : ""); @@ -343,35 +357,20 @@ static void print_codec(const AVCodec *c) printf("\n"); } - if (c->supported_framerates) { - const AVRational *fps = c->supported_framerates; - - printf(" Supported framerates:"); - while (fps->num) { - printf(" %d/%d", fps->num, fps->den); - fps++; - } - printf("\n"); - } - PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", - AV_PIX_FMT_NONE, GET_PIX_FMT_NAME); - PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0, - GET_SAMPLE_RATE_NAME); - PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats", - AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME); - - if (c->ch_layouts) { - const AVChannelLayout *p = c->ch_layouts; - - printf(" Supported channel layouts:"); - while (p->nb_channels) { - char name[128]; - av_channel_layout_describe(p, name, sizeof(name)); - printf(" %s", name); - p++; - } - printf("\n"); - } + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_FRAME_RATE, AVRational, "framerates", + fps, "%d/%d", fps->num, fps->den); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_PIX_FORMAT, enum AVPixelFormat, + "pixel formats", fmt, "%s", av_get_pix_fmt_name(*fmt)); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_SAMPLE_RATE, int, "sample rates", + rate, "%d", *rate); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_SAMPLE_FORMAT, enum AVSampleFormat, + "sample formats", fmt, "%s", av_get_sample_fmt_name(*fmt)); + + av_bprint_init(&desc, 0, AV_BPRINT_SIZE_AUTOMATIC); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_CHANNEL_LAYOUT, AVChannelLayout, + "channel layouts", layout, "%s", + get_channel_layout_desc(layout, &desc)); + av_bprint_finalize(&desc, NULL); if (c->priv_class) { show_help_children(c->priv_class, @@ -566,8 +565,14 @@ static void show_help_bsf(const char *name) } printf("Bit stream filter %s\n", bsf->name); - PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs", - AV_CODEC_ID_NONE, GET_CODEC_NAME); + if (bsf->codec_ids) { + const enum AVCodecID *id = bsf->codec_ids; + printf(" Supported codecs:"); + while (*id != AV_CODEC_ID_NONE) { + printf(" %s", avcodec_descriptor_get(*id)->name); + id++; + } + } if (bsf->priv_class) show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM); } From patchwork Wed Sep 4 11:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51337 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148283vqb; Wed, 4 Sep 2024 04:19:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVplXBAtKLqwnkDjuqDmXDYoWCAcs00GiKmQ8J0zbx2hJUtjYCmJfBBa/2HlvdVbA4olL16iREC+a3JJeCmCWtm@gmail.com X-Google-Smtp-Source: AGHT+IGKRJFDjG8M7fDgfNd7DDC1wxaLExHf5lJ2S13WBgcLrVPyXF50Qi9OxN9Y+615MQtF5KCz X-Received: by 2002:a05:6512:b9f:b0:533:4591:fc03 with SMTP id 2adb3069b0e04-53546bde01dmr13971792e87.46.1725448752802; Wed, 04 Sep 2024 04:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448752; cv=none; d=google.com; s=arc-20240605; b=WoYUBMFzqiGpd122JSPEo8P37w/FqQRFkSC+nZAd1opG7DxnIXf3jiAO9K0m6lmOAh zZOBwc3cIT/0yZbVb3QV7xBbFQaVA/QqgnMOVQCTa/dctM+WD+zHL1NCu0U2SxNCU0Z5 4oYwgr6raRTCd28hA/QBE2WfZqFASF/xNJY8/xgkLRrmN/jOrgJ7Xh1yRviBk54EOL/L lrz0lanrnSwJuy4JXNmqW0Rj/o8I5cBe2451ud7/t9V3TTaXNAr+mPvXZpppQtUO75wr wStKiQJbXXRmdByGfTC43QRDNrFbxbyGwKmS4e25he8eYrd7yLboI0xvdSiC7DHgdFPd QyGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=GSjxT1x+GLUCxE224DfJkyyIKRVrw9KIF5mZLyqO3X4=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=dBiPwuY4bedOIvczKI8CkLLBRVxF3NEk38Uju5MoPyUfHwtin810ovn0+Hn4AomAHK VT0fLc8MSP7kNMcYPVAnWtUxiRlGuc7R+nb+eGxsxyGZCMUzxyCde7S5rlQIQnccJF79 ce4ziPgY4rutiM94sLXk6u6mz133hCmWoJ1da4nRMjtijMgxH3Et2itb4MjeYFyQ3UtZ fm4IydJBunrqQJexE0ef4JWKIq8YWigO/VJu9Q926YnQ57xxNAruZhYE10amu0LV5fvC xfNmXWub9Bn16dkHAaps3NqDUjKmUpKLzYys8th0cDkM9I+hCvj/Siy6XSATjDx0uvwS dtUg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=tqQIeEm3; 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 2adb3069b0e04-535408441c4si4824439e87.557.2024.09.04.04.19.12; Wed, 04 Sep 2024 04:19:12 -0700 (PDT) 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=tqQIeEm3; 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 5DAE368DF2B; Wed, 4 Sep 2024 14:08:33 +0300 (EEST) 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 8EDCE68DE72 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448089; bh=W+oEIfIwaCXFCkOqbW+9qjNOvXlSVMRKzKCwaCFby3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqQIeEm30DY4O0qFQeqFrD8hjmyRAt0nAzSGL/cyMmEYBaD9/Jf/69kRc29LdYcHV NllGGjQmcknDSPi+v6Ie6dFL/GZu2RDdb7y+IuKOPCaJQdLoamovNz6+PX0SsazzMT eTIvN/oevSNE7oMC7gZkhHR66SENcPzXNnfyY3+c= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id E8C2441B14; Wed, 4 Sep 2024 13:08:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:40 +0200 Message-ID: <20240904110720.11713-12-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 11/17] fftools: drop unused/hacky macros 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: xe59tRPC6T2q From: Niklas Haas Having macros initialize local variables seems strange to me, and there are no more current users of these macros. (The one that was commented out was incorrect anyway, since the macro has changed in the meantime) --- fftools/cmdutils.h | 13 ------------- fftools/ffmpeg_filter.c | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 9609c6c739..9441d5726b 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -530,19 +530,6 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); #define GROW_ARRAY(array, nb_elems)\ grow_array((void**)&array, sizeof(*array), &nb_elems, nb_elems + 1) -#define GET_PIX_FMT_NAME(pix_fmt)\ - const char *name = av_get_pix_fmt_name(pix_fmt); - -#define GET_CODEC_NAME(id)\ - const char *name = avcodec_descriptor_get(id)->name; - -#define GET_SAMPLE_FMT_NAME(sample_fmt)\ - const char *name = av_get_sample_fmt_name(sample_fmt) - -#define GET_SAMPLE_RATE_NAME(rate)\ - char name[16];\ - snprintf(name, sizeof(name), "%d", rate); - double get_rotation(const int32_t *displaymatrix); /* read file contents into a string */ diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index b562e8417c..d54beb26b7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -416,7 +416,7 @@ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \ } //DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE, -// GET_PIX_FMT_NAME) +// av_get_pix_fmt_name) DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, AV_SAMPLE_FMT_NONE, "%s", av_get_sample_fmt_name) From patchwork Wed Sep 4 11:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51343 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp155991vqb; Wed, 4 Sep 2024 04:34:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZ4HIYQdiXQoa8EtKD2UI+NAxlpsYkfFyUEi8T//rq+KpzAUfRGh6IYz0lzHT0mhx4Ckq+Xq0Rutx1tcSeakQv@gmail.com X-Google-Smtp-Source: AGHT+IFeU4CX4WXvQejS4wt5GK90BRp4I1KNBg9UKCh2eWMdmnyg6GSsbepG2KbKDNfsPn/O6Yb6 X-Received: by 2002:a2e:9a04:0:b0:2f6:4e78:e0ea with SMTP id 38308e7fff4ca-2f64e78eae5mr13398901fa.5.1725449656515; Wed, 04 Sep 2024 04:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725449656; cv=none; d=google.com; s=arc-20240605; b=P7p0aR4Q+lfeLQdVuXSsTB122kxbtJI1KmiwGwEIBXq+79qukebZ58KriSOFxXohK9 Cw6I9R9rmjX3oeLCkifCXbkPi/Z4Qb5YXhz0DXrp5GSOllYuliVTs7Xu2EPwLiYmZLO7 oXgzLIY/ClmBMBdaNxVLDgGCN37YXWIsPqy77AiTT/Tz4wJnEV6un/LXRx9VYU3raFvP 72sXMI0wnkPhAp4ouu9ocf5LozkD6H64bWCaEedNCTcbnHgsBTC6YAU2cTBF8wbJZH2G sQCQGF2S+g4aYhuApr+m8w96dFlC/0cBTrJdXjFsW0aiBoJO8GuqcsFtPr2Sm6EESxT0 gzXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Y+MZJx+D9xm4ZFFhQ5m3+Tj2siMunlyIU4xdO/U3TK0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=bfqZyHQuNLkPsH+NUG3GB7o/HlfxE0gGJAIcRdU4PmmVWMZEvZTy3whTA7azAtWjwE Cj1mlFyFBmv0+Ac+2A3hNbkw27UjIe0jd+QX2dGReMvKw0uKpQP09j3d+/+Mn1yuvtCe g2rUn/8NZ80EZR8kXMBOqr+w8BfzGergqS23ifnpGUdBv2ZChJrCl+zhaJ6CF9auvBdP hxSzzu7D7yxa/1Hj8hrg97IQ1tYA/qlw0SWtsdfTtjpTHvFpAh6yspLri/SfKgZxSelc jikP+b0BQNIEs2rCb+HfOlvp3INwbNVKY2zONurAAe0v6+mDcz+f+AeM3ta9dBcz2Daq AL4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=iSpZRTLx; 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 4fb4d7f45d1cf-5c254d5e3cbsi5511149a12.665.2024.09.04.04.34.16; Wed, 04 Sep 2024 04:34:16 -0700 (PDT) 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=iSpZRTLx; 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 0269068DF25; Wed, 4 Sep 2024 14:08:32 +0300 (EEST) 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 8668668DE70 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448089; bh=0cIpfKBdyl0bpT11PeB4XiC8V6hX5KRBhiNoH7cdO38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iSpZRTLxfJwHSQ5aP/AiLSjemFv2QenN4EkEO5AW6zqYss+/UfbuoKhXkyN6yaXR5 WyygXwrfWUUDgJy4t1bOmOo24ZJ0ESL/I+2mVuPuz8qMlIYJP9tyJt9/nl50vcqHVI epBsZsW3uMZYVOhdA/41QGmmsoidPE8xiPVaVOxo= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 2C81D41B22; Wed, 4 Sep 2024 13:08:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:41 +0200 Message-ID: <20240904110720.11713-13-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 12/17] fftools/ffmpeg_mux_init: switch to avcodec_get_supported_config() 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: 50404Bi+BerX From: Niklas Haas --- fftools/ffmpeg_mux_init.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index e84fa9719f..6b101dcbbc 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -511,13 +511,19 @@ static int fmt_in_list(const int *formats, int format) } static enum AVPixelFormat -choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) +choose_pixel_fmt(const AVCodecContext *avctx, enum AVPixelFormat target) { - const enum AVPixelFormat *p = codec->pix_fmts; + const enum AVPixelFormat *p; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target); //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; enum AVPixelFormat best= AV_PIX_FMT_NONE; + int ret; + + ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, + 0, (const void **) &p, NULL); + if (ret < 0) + return AV_PIX_FMT_NONE; for (; *p != AV_PIX_FMT_NONE; p++) { best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL); @@ -529,7 +535,7 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) av_log(NULL, AV_LOG_WARNING, "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", av_get_pix_fmt_name(target), - codec->name, + avctx->codec->name, av_get_pix_fmt_name(best)); return best; } @@ -538,8 +544,9 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) { - const enum AVPixelFormat *fmts = ost->enc_ctx->codec->pix_fmts; + const enum AVPixelFormat *fmts; enum AVPixelFormat fmt; + int ret; fmt = av_get_pix_fmt(name); if (fmt == AV_PIX_FMT_NONE) { @@ -547,6 +554,11 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) return AV_PIX_FMT_NONE; } + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, + 0, (const void **) &fmts, NULL); + if (ret < 0) + return AV_PIX_FMT_NONE; + /* when the user specified-format is an alias for an endianness-specific * one (e.g. rgb48 -> rgb48be/le), it gets translated into the native * endianness by av_get_pix_fmt(); @@ -574,7 +586,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } if (fmts && !fmt_in_list(fmts, fmt)) - fmt = choose_pixel_fmt(ost->enc_ctx->codec, fmt); + fmt = choose_pixel_fmt(ost->enc_ctx, fmt); return fmt; } From patchwork Wed Sep 4 11:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51346 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp171608vqb; Wed, 4 Sep 2024 05:04:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWpCOe7yJ9rtoMcKXQEvzyfQomi2CuBeXf4dANKTUuTsu5OfBxf87aF45kgRiMLkJ6Ht4RSj8KyzGHRbrnKopUm@gmail.com X-Google-Smtp-Source: AGHT+IFZ4OopMPBkCzVwecn/cBNpOSToTReI6EHyMIE/ycUcxQ96bxiyLo/cyhEU4BoQsC5AhNXV X-Received: by 2002:a05:6512:3193:b0:52f:c285:323d with SMTP id 2adb3069b0e04-53546b2be87mr7476359e87.5.1725451452672; Wed, 04 Sep 2024 05:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725451452; cv=none; d=google.com; s=arc-20240605; b=I7ilvyvbwt+utRNyYgLJ93EMY1VylJvfUd+f11vH1E9R2rDYLkuP05ttqGdlxa1z/O hS95yQRqWr0+K/7r/GBty0ESnwMZjY9AbGUmHMuULR9jZs2wzFOEKvKFxqyQS/Jv2eW+ PCrCwmUXtVj+heaO4blJ6QYAwCDHN/Nb4BWqxkigmR7iirnEmloiCTk2OM5uFwzU8/9k sjfPGKA/GH8nQJHc9olzS0eNaY6uhpcgHKv5CnChHrTTTrccsL0emeg2Dt4aQpPirRWY yQKEZx3RyEQ9GKu8BP9VSAvMSFNYpfGHxmLED63byGkeuH9PQHwQzEaKXY56b/8/O5es MdZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=8fZD7oMuNl8NKaX6wN9SdaUnuEojWBEhIlt78+KbOZM=; fh=tuUXnhgwUopqrbuJY3BExN6aocuFs1Cf//owLTlTyNI=; b=Lmd3pytLbMHqGbZ3NnUo3aX5UUwA74ZvAALKiiLB7y9zuLbVGT+lGkGQgXnamPmBjD jcS1UUz0u1sVLkbBqEUWKxGN/3W6W3tWt8NZ+J4RKd1pzRUrnQriKNx3Ug3fw4D371WP +OBlht22yDTi8CsOdUz2LMjz3n36BgTk+zf0xceOlMosEd103KbG/tDq1/E5E0mDe3cI Sw8m0FE6n5A7ciYvTHLkgC8QtPu51VoXwrf7PdPxvxTQwdhNcgt48/auQsOx91pPeNk/ rpmBTTaMtHdS6ohfgOhsOR9kBgjQvBcGyByID0KuecDXoBpmR+Rac8PTRHhNpNchUTxd kgoQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=DIvy1HmE; 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 a640c23a62f3a-a8988f44d8fsi1063628566b.166.2024.09.04.05.04.11; Wed, 04 Sep 2024 05:04:12 -0700 (PDT) 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=DIvy1HmE; 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 8260668DDE0; Wed, 4 Sep 2024 14:08:18 +0300 (EEST) 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 B936C68DC49 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448089; bh=JTRvErYpiBBPZFQBJ2T+wDzVCjqrlMgDbt6DsXd3gkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIvy1HmEWk55+9LAuSc4AJpM6zVzRD7ojDb+mDFH8N2QbXBF48bGcu4iXPNJBOhXn hrtV5UY3ct+xI43Mih7xHNFL7ZL/fu6/ALPHJOxfgy9iqpbhKHHBRM9NGyZmF63TNP hRkucN+j82scnVzqAQKpmit0OfPW2ax6U3r0msBk= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 6528241B26; Wed, 4 Sep 2024 13:08:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:42 +0200 Message-ID: <20240904110720.11713-14-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 13/17] fftools/ffmpeg_filter: simplify choose_pix_fmts 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: Anton Khirnov , Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gLyPYU8xwbM2 From: Niklas Haas The only meaningful difference between choose_pix_fmts and the default code was the inclusion of an extra branch for `keep_pix_fmt` being true. However, in this case, we either: 1. Force the specific `ofp->format` that we inherited from ofilter_bind_ost, or if no format was set: 2. Print an empty format list Both of these goals can be accomplished by simply moving the decision logic to ofilter_bind_ost, to avoid setting any format list when keep_pix_fmt is enabled. This is arguably cleaner as it moves format selection logic to a single function. In the case of branch 1, nothing else needs to be done as we already force the format provided in ofp->format, if any is set. Add an assertion to verify this assumption just in case. (Side note: The "choose_*" family of functions are arguably misnomers, as they should really be called "print_*" - their current behavior is to print the relevant format lists to the `vf/af_format` filter arguments) Signed-off-by: Anton Khirnov Signed-off-by: Niklas Haas --- fftools/ffmpeg_filter.c | 49 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d54beb26b7..4411985548 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -364,35 +364,6 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, ifp->sub2video.initialize = 0; } -/* *dst may return be set to NULL (no pixel format found), a static string or a - * string backed by the bprint. Nothing has been written to the AVBPrint in case - * NULL is returned. The AVBPrint provided should be clean. */ -static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, - const char **dst) -{ - OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); - - *dst = NULL; - - if (ofp->flags & OFILTER_FLAG_DISABLE_CONVERT || ofp->format != AV_PIX_FMT_NONE) { - *dst = ofp->format == AV_PIX_FMT_NONE ? NULL : - av_get_pix_fmt_name(ofp->format); - } else if (ofp->formats) { - const enum AVPixelFormat *p = ofp->formats; - - for (; *p != AV_PIX_FMT_NONE; p++) { - const char *name = av_get_pix_fmt_name(*p); - av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|'); - } - if (!av_bprint_is_complete(bprint)) - return AVERROR(ENOMEM); - - *dst = bprint->str; - } - - return 0; -} - /* Define a function for appending a list of allowed formats * to an AVBPrint. If nonempty, the list will have a header. */ #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \ @@ -415,8 +386,8 @@ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \ av_bprint_chars(bprint, ':', 1); \ } -//DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE, -// av_get_pix_fmt_name) +DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, + AV_PIX_FMT_NONE, "%s", av_get_pix_fmt_name) DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, AV_SAMPLE_FMT_NONE, "%s", av_get_sample_fmt_name) @@ -850,7 +821,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->format = opts->format; } else if (opts->pix_fmts) ofp->formats = opts->pix_fmts; - else if (opts->enc) + else if (opts->enc && + !(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT)) ofp->formats = opts->enc->pix_fmts; fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); @@ -1481,7 +1453,6 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, AVBPrint bprint; int pad_idx = out->pad_idx; int ret; - const char *pix_fmts; char name[255]; snprintf(name, sizeof(name), "out_%s", ofp->name); @@ -1515,17 +1486,19 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, pad_idx = 0; } + av_assert0(!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT) || + ofp->format != AV_PIX_FMT_NONE || !ofp->formats); av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); - ret = choose_pix_fmts(ofilter, &bprint, &pix_fmts); - if (ret < 0) - return ret; + choose_pix_fmts(ofp, &bprint); + if (!av_bprint_is_complete(&bprint)) + return AVERROR(ENOMEM); - if (pix_fmts) { + if (bprint.len) { AVFilterContext *filter; ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("format"), - "format", pix_fmts, NULL, graph); + "format", bprint.str, NULL, graph); av_bprint_finalize(&bprint, NULL); if (ret < 0) return ret; From patchwork Wed Sep 4 11:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51336 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148266vqb; Wed, 4 Sep 2024 04:19:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEyU0aWZGFaS7Ej6HBBTw6kLx7EDdsdUcHsAAPRl44zS/un0XrX6UYn7ENGhdL4rdSd444tAAHnbTLxI3XSNkq@gmail.com X-Google-Smtp-Source: AGHT+IF1Ujz+EKR1/fHNNVaBRk4Ci2OmO2I6JNAiah8jvNZFGeAPs53yIdLs4GPe+el+/HxpD91Q X-Received: by 2002:a17:907:7ba8:b0:a86:a178:42da with SMTP id a640c23a62f3a-a8a32e7404emr319812066b.21.1725448751813; Wed, 04 Sep 2024 04:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448751; cv=none; d=google.com; s=arc-20240605; b=Ca93n+3eTgWpOzoKY+tRVzrwHxw62KnzUzXR7Uvc4haOfoH0bW+Kx3ZX9h8FFfkTSi L9QTo/n0D7iKGP7e0+T4eCbbu6jMa39mnHnLWb/zPpmbOKMBg7q6jmmurGWgfwmmhQCr 9NvPiStpT/00bjVHGgzGGgtc/A1qyrLl/0bvyo3Mt5txrM19piCmcLD8FHNP2+oI6aAq cfeqXiCrB1mhHYQ2veCEt9VicXRCGhweqkPtAkHzYWzqwooUxQC5aX54I9x+J44UEkBU 7OQCxZA7qYv8987peAdD6gaOhRgIEDG8mE1AudzEqx7vRcdJBP+MFTBkqm1MvYLmKbSr OXQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=6M7UHw7Nzj29Uz3pQEtggOIf3ZN9ne7YkTqzl8JKT80=; fh=Avpk+LKcNkHKoWajGZeevGRAc++LPBUE4dPECo0/YT8=; b=bNgAYibghbmoDCEed+x4ANhHOtRVpgO73L2VzAKj+uh+HLf9d88HmSBn5HmbfLnDSO q/HV6IHHoFZ+I6xAIoO6yQj0k4YdUZf0zr2rWkxluJh6H06B7iwR4dXzYS1fS3LQTYtt Z4NWfrN5WRpQCwbaxhj6G8UJfZS2uqlha+sDmGx1T+sTzTAGXvEz6669UvsDt4PrfGz9 Ck1lmbCmxFXcn+7Ot/83ydCtpJfisqNBc7emnJdVR7eDSR1iBnkAlx3/1VOsvPmZfMyG t+pRkfBT2/6GYkLN9Gf8dJfqxZhVY/ovaytmrnje4WgxCYuFi6h7lW8686BLAK1K566d OjNg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=rdWK18Ir; 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 a640c23a62f3a-a8988f40e91si1031843466b.6.2024.09.04.04.19.10; Wed, 04 Sep 2024 04:19:11 -0700 (PDT) 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=rdWK18Ir; 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 9751768DEAC; Wed, 4 Sep 2024 14:08:19 +0300 (EEST) 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 C472768DDC0 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448089; bh=UBbrQS7WNK38offINKvhxW06U8AU74L3U9jE9bJA1ZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rdWK18IrNVDlIgMZ5aLHI/yZLKarCSft4VF2my+uLO3nGthqjNDXp3h5ncEnWbCOd rOGWZicekdE8hGJqfllAhrC7s9LYWZIC7km/bvZJWxdoVyd9vnadg6a3LvsEIa+NxC J6U9d0QYXZ56n724IXNye6D66nfIpQFSgrCTcxeU= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 9B45741BA4; Wed, 4 Sep 2024 13:08:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:43 +0200 Message-ID: <20240904110720.11713-15-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 14/17] fftools/ffmpeg_mux_init: factor out binding filters to output streams 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: Anton Khirnov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bGEhH7W3eneD From: Anton Khirnov --- fftools/ffmpeg_mux_init.c | 137 ++++++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 59 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6b101dcbbc..c6dc4a0699 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -916,6 +916,82 @@ static int new_stream_subtitle(Muxer *mux, const OptionsContext *o, return 0; } +static int +ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, + const OptionsContext *o, char *filters, + AVRational enc_tb, enum VideoSyncMethod vsync_method, + int keep_pix_fmt, int autoscale, int threads_manual) +{ + OutputStream *ost = &ms->ost; + AVCodecContext *enc_ctx = ost->enc_ctx; + char name[16]; + int ret; + + OutputFilterOptions opts = { + .enc = enc_ctx->codec, + .name = name, + .format = (ost->type == AVMEDIA_TYPE_VIDEO) ? + enc_ctx->pix_fmt : enc_ctx->sample_fmt, + .width = enc_ctx->width, + .height = enc_ctx->height, + .vsync_method = vsync_method, + .sample_rate = enc_ctx->sample_rate, + .ch_layout = enc_ctx->ch_layout, + .sws_opts = o->g->sws_dict, + .swr_opts = o->g->swr_opts, + .output_tb = enc_tb, + .trim_start_us = mux->of.start_time, + .trim_duration_us = mux->of.recording_time, + .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? + 0 : mux->of.start_time, + + .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt | + OFILTER_FLAG_AUTOSCALE * !!autoscale | + OFILTER_FLAG_AUDIO_24BIT * !!(av_get_exact_bits_per_sample(enc_ctx->codec_id) == 24), + }; + + snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); + + // MJPEG encoder exports a full list of supported pixel formats, + // but the full-range ones are experimental-only. + // Restrict the auto-conversion list unless -strict experimental + // has been specified. + if (!strcmp(enc_ctx->codec->name, "mjpeg")) { + // FIXME: YUV420P etc. are actually supported with full color range, + // yet the latter information isn't available here. + static const enum AVPixelFormat mjpeg_formats[] = + { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_NONE }; + + if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) + opts.pix_fmts = mjpeg_formats; + } + + if (threads_manual) { + ret = av_opt_get(enc_ctx, "threads", 0, (uint8_t**)&opts.nb_threads); + if (ret < 0) + return ret; + } + + if (ofilter) { + ost->filter = ofilter; + ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc, &opts); + } else { + ret = init_simple_filtergraph(ost->ist, ost, filters, + mux->sch, ms->sch_idx_enc, &opts); + } + av_freep(&opts.nb_threads); + if (ret < 0) + return ret; + + ret = sch_connect(mux->sch, SCH_ENC(ms->sch_idx_enc), + SCH_MSTREAM(mux->sch_idx, ms->sch_idx)); + if (ret < 0) + return ret; + + return ret; +} + static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **encoder_opts) { MuxStream *ms = ms_from_ost(ost); @@ -1398,65 +1474,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { - char name[16]; - OutputFilterOptions opts = { - .enc = enc, - .name = name, - .format = (type == AVMEDIA_TYPE_VIDEO) ? - ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt, - .width = ost->enc_ctx->width, - .height = ost->enc_ctx->height, - .vsync_method = vsync_method, - .sample_rate = ost->enc_ctx->sample_rate, - .ch_layout = ost->enc_ctx->ch_layout, - .sws_opts = o->g->sws_dict, - .swr_opts = o->g->swr_opts, - .output_tb = enc_tb, - .trim_start_us = mux->of.start_time, - .trim_duration_us = mux->of.recording_time, - .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? - 0 : mux->of.start_time, - .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt | - OFILTER_FLAG_AUTOSCALE * !!autoscale | - OFILTER_FLAG_AUDIO_24BIT * !!(av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24), - }; - - snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); - - // MJPEG encoder exports a full list of supported pixel formats, - // but the full-range ones are experimental-only. - // Restrict the auto-conversion list unless -strict experimental - // has been specified. - if (!strcmp(enc->name, "mjpeg")) { - // FIXME: YUV420P etc. are actually supported with full color range, - // yet the latter information isn't available here. - static const enum AVPixelFormat mjpeg_formats[] = - { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, - AV_PIX_FMT_NONE }; - - if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) - opts.pix_fmts = mjpeg_formats; - } - - if (threads_manual) { - ret = av_opt_get(ost->enc_ctx, "threads", 0, (uint8_t**)&opts.nb_threads); - if (ret < 0) - goto fail; - } - - if (ofilter) { - ost->filter = ofilter; - ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc, &opts); - } else { - ret = init_simple_filtergraph(ost->ist, ost, filters, - mux->sch, ms->sch_idx_enc, &opts); - } - av_freep(&opts.nb_threads); - if (ret < 0) - goto fail; - - ret = sch_connect(mux->sch, SCH_ENC(ms->sch_idx_enc), - SCH_MSTREAM(mux->sch_idx, ms->sch_idx)); + ret = ost_bind_filter(mux, ms, ofilter, o, filters, enc_tb, vsync_method, + keep_pix_fmt, autoscale, threads_manual); if (ret < 0) goto fail; } else if (ost->ist) { From patchwork Wed Sep 4 11:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51340 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148347vqb; Wed, 4 Sep 2024 04:19:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWVc8AOt58cfoHfqn97DKBC/AEY4Iu2wpfUBPkT1jm2GvdCKwLUrTkUz0OGso7OmPFEfdRAm9FNFyUyWyoR0MUT@gmail.com X-Google-Smtp-Source: AGHT+IEDW6c7h6Pogr7c4n91PDqeGecaSN4K53XwiLwRnWLwHz7ot5I9RkP2BifXAk3Dc8YSvLOl X-Received: by 2002:a17:907:7e91:b0:a80:f63e:159b with SMTP id a640c23a62f3a-a89a30b5b14mr741475166b.0.1725448758944; Wed, 04 Sep 2024 04:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448758; cv=none; d=google.com; s=arc-20240605; b=MKKgOGdD4NnVH/g6Fj7Yj8337d1p5ngMA6568GSE34Q5lW0uSbG9BSc76qGjOCjnIb LKVXHvRDad8JKnkDwfU6vCmcq1E29WZb1SMukiNiV/FQ7YxYnnHXIN6U2I660NFeOGfc mlJQtFl2ivAH7Kik0soRl90WGUoo8ypQAaIELasHllBJp7U+7GZHNMRUVW6DXFJsu1SP EDJvchFXlclF7nSkKyGLgu5oUJGUOCObY1+ybpqhW535rUIZCa2xNIDpia2rDqzqDfVr Khna5udC9/PTOwTWIeMdfG/ResIDIoUt/NUhEC57ILp1CFSIPSqm2YLullANQg5jVhc+ gC9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=TkJ7b0WgyfVwMfVuYdGozIxCDmFJ8EVNmV8TFdAUDw4=; fh=tuUXnhgwUopqrbuJY3BExN6aocuFs1Cf//owLTlTyNI=; b=P34laZEEyghYcDNgzHv8/AWQJllamMa+h2q78uJTgQ9aEzfwzGW0YgmbHJEicK9Gym 37gnptMFgy2aLWd63rK+VQbqkTJLN3m5WkoAtVAuQ3oHIz7q5g2sLnexQIv6tdgfp3Wz rvfTSAYd97M9zfjZFBKlj/x3RyiTacPs7S+8t263Ah7p6y3nwow6wUhARvfsNSwwHaQK yPkU8KCJJYYvdw2GctuuTZCxgNWhAPpVHrmyO0e5wWfz/DLC6712b7mPcE2xNjc2DgPZ Npj5oWxS4UKIr4qtijXwlWMoNWiAdm3qE5sXgGQqzSRyNV3Qw9sz+kWpUXtgR8DJCB91 ZmTg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=uGQWk0Nt; 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 a640c23a62f3a-a898912d4dfsi963101466b.336.2024.09.04.04.19.18; Wed, 04 Sep 2024 04:19:18 -0700 (PDT) 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=uGQWk0Nt; 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 BFC5068DE7F; Wed, 4 Sep 2024 14:08:20 +0300 (EEST) 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 D234368DDC4 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448089; bh=vkZgYtBjdel0y1EWrdYPaxvTt9ahHHBBUlQH6XhLcnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGQWk0NtjAD7BcJh9opSxPyQEcoiFSnArw6AfuA4xkPv1tA5wDtkgTfLRoXQdlJrj 5jPDiQFNpVFX3UAllpf5w6dSumcjm49gpR4l4zak0xt/RThUje09d7uyzBx30X9Kji pCoO26HNUM0wIrSw20NttNRPcRnmuO2uYSfSC8l4= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D5C1041BEF; Wed, 4 Sep 2024 13:08:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:44 +0200 Message-ID: <20240904110720.11713-16-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 15/17] fftools/ffmpeg_filter: switch to avcodec_get_supported_config() 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: Anton Khirnov , Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zS5H3Hrb2068 From: Niklas Haas Signed-off-by: Anton Khirnov --- fftools/ffmpeg.h | 7 +++++-- fftools/ffmpeg_filter.c | 25 ++++++++++--------------- fftools/ffmpeg_mux_init.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 3c5d933e17..ca24b20640 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -283,8 +283,6 @@ typedef struct OutputFilterOptions { // Codec used for encoding, may be NULL const AVCodec *enc; - // Overrides encoder pixel formats when set. - const enum AVPixelFormat *pix_fmts; int64_t trim_start_us; int64_t trim_duration_us; @@ -311,6 +309,11 @@ typedef struct OutputFilterOptions { int sample_rate; AVChannelLayout ch_layout; + + const int *formats; + const int *sample_rates; + const AVChannelLayout *ch_layouts; + const AVRational *frame_rates; } OutputFilterOptions; typedef struct InputFilter { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4411985548..9effa96aac 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -819,11 +819,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->height = opts->height; if (opts->format != AV_PIX_FMT_NONE) { ofp->format = opts->format; - } else if (opts->pix_fmts) - ofp->formats = opts->pix_fmts; - else if (opts->enc && - !(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT)) - ofp->formats = opts->enc->pix_fmts; + } else + ofp->formats = opts->formats; fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); @@ -835,7 +832,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->fps.framerate = ost->frame_rate; ofp->fps.framerate_max = ost->max_frame_rate; ofp->fps.framerate_supported = ost->force_fps || !opts->enc ? - NULL : opts->enc->supported_framerates; + NULL : opts->frame_rates; // reduce frame rate for mpeg4 to be within the spec limits if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4) @@ -847,21 +844,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, case AVMEDIA_TYPE_AUDIO: if (opts->format != AV_SAMPLE_FMT_NONE) { ofp->format = opts->format; - } else if (opts->enc) { - ofp->formats = opts->enc->sample_fmts; + } else { + ofp->formats = opts->formats; } if (opts->sample_rate) { ofp->sample_rate = opts->sample_rate; - } else if (opts->enc) { - ofp->sample_rates = opts->enc->supported_samplerates; - } + } else + ofp->sample_rates = opts->sample_rates; if (opts->ch_layout.nb_channels) { - int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL, - &opts->ch_layout); + int ret = set_channel_layout(ofp, opts->ch_layouts, &opts->ch_layout); if (ret < 0) return ret; - } else if (opts->enc) { - ofp->ch_layouts = opts->enc->ch_layouts; + } else { + ofp->ch_layouts = opts->ch_layouts; } break; } diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index c6dc4a0699..decf63e7d5 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -952,6 +952,39 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); + if (ost->type == AVMEDIA_TYPE_VIDEO) { + if (!keep_pix_fmt) { + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void **) &opts.formats, NULL); + if (ret < 0) + return ret; + } + if (!ost->force_fps) { + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_FRAME_RATE, 0, + (const void **) &opts.frame_rates, NULL); + if (ret < 0) + return ret; + } + } else { + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **) &opts.formats, NULL); + if (ret < 0) + return ret; + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **) &opts.sample_rates, NULL); + if (ret < 0) + return ret; + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &opts.ch_layouts, NULL); + if (ret < 0) + return ret; + } + // MJPEG encoder exports a full list of supported pixel formats, // but the full-range ones are experimental-only. // Restrict the auto-conversion list unless -strict experimental @@ -964,7 +997,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, AV_PIX_FMT_NONE }; if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) - opts.pix_fmts = mjpeg_formats; + opts.formats = mjpeg_formats; } if (threads_manual) { From patchwork Wed Sep 4 11:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51341 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp148362vqb; Wed, 4 Sep 2024 04:19:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWjI/NMwrUz2voLQ/zTAr0P0duF78ZO2YQt5SN/ns10qLSosw/kCVJKNxA9+4ZS/oDq5A7eX3R145++oA2ZcMj/@gmail.com X-Google-Smtp-Source: AGHT+IFcn69y0YhHGcX62+9CcVSOO4Z5cdvauL8/e1M3yt7+cvOy/xlufBJpeDQJIkyiwIemljOY X-Received: by 2002:a17:907:c21:b0:a7a:9d1e:3b28 with SMTP id a640c23a62f3a-a89a377d761mr723527566b.5.1725448760984; Wed, 04 Sep 2024 04:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725448760; cv=none; d=google.com; s=arc-20240605; b=TWGqltzEsqcqCAUuFgbhIfzyDjF+TcVGRj0xXpZUcB1u8JcsZNDLJ5eVFINeGWwPrI adEzwuGBQdTyE2AHV/SS1g013I9/SOdkrNwiJCrR+NukhfymaEDE9u5mvU2XKehzvKvx yzl7+MwBcxNEn2UP98tMOfU245G8QnNm4/mJwH442GjEHrRQotmKdUIeihsazUNXAGvR 14Zf/A7x4Fb4xfpmXd/75w8AQiENVSNxOXnkKtup489a4K5Q7zdsQarjdEwZ02mMcGaO /oYkaZLtrFGXPmyhtR9vQAb6ZrHu2k2lU7rUMeFKCx7rM7wfoK0/pHXfLv0fKv1zbBrH /jFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=/+4GGwIeBDijSdCth6YZOBfk3jS+WlaN3JqQtv0MD1w=; fh=tuUXnhgwUopqrbuJY3BExN6aocuFs1Cf//owLTlTyNI=; b=g09hHzixElb0axSvc9RJIZB1Ulc4nFACSIY6/DDvYlUo1f+7p+a5gS+yOPAAcB7yyz 8gG0X2X4gFQuxmjSLvWphosZGCoTlylixBdDV1XJRfbQKMhAKEdo1hDpYdbtq1F3GWcG t/7naP89IaRMK8Ng1+IdPyGl2cg+00WogO+aTufo+GVBeOc5xdKt5TgvkkIdkdX2K9He dQkXSuVTJHnimEB5nnr6xttN35EGig4S2puDS9ROmm/oOkp9+YKfhG4df3itbsrkN8X+ mFiBUfAdEKPvrUU34WSSHI4EMFE62B52xG1szvbtoWnooJ/pTTKK3wVT3ies4Bx6c9l3 t5eg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=Y3v4DoHH; 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 a640c23a62f3a-a898912d2ffsi1034997066b.345.2024.09.04.04.19.20; Wed, 04 Sep 2024 04:19:20 -0700 (PDT) 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=Y3v4DoHH; 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 19D8268DED1; Wed, 4 Sep 2024 14:08:23 +0300 (EEST) 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 F307F68DDC0 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448090; bh=iDksPM24skfEbAgcvSsyGmZ14DqacHqUmT5Bi9QQm1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y3v4DoHHtPrmUuLDgiY2/wcBpmg/p19dkRpmcXtVJlZMP3aMit71VOQH+iaXcVwQj 5+7yBk4yUWdKP++dD4jPjeYr8+21K0XUPnQKZ3y7ArxIRi0LaEStJXZOkDPd1kHks1 by7NP9DgYwr06yAVl0l8FC7w+DUbdkOSMi61Wx0Q= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 1C12541C0F; Wed, 4 Sep 2024 13:08:10 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:45 +0200 Message-ID: <20240904110720.11713-17-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 16/17] fftools/ffmpeg_filter: propagate codec yuv metadata to filters 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: Anton Khirnov , Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zliXJqx3NHHI From: Niklas Haas To convert between color spaces/ranges, if needed by the codec properties. Signed-off-by: Anton Khirnov --- fftools/ffmpeg.h | 4 ++++ fftools/ffmpeg_filter.c | 26 ++++++++++++++++++++++++++ fftools/ffmpeg_mux_init.c | 12 ++++++++++++ 3 files changed, 42 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ca24b20640..f4a10b2a66 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -304,6 +304,8 @@ typedef struct OutputFilterOptions { int format; int width; int height; + enum AVColorSpace color_space; + enum AVColorRange color_range; enum VideoSyncMethod vsync_method; @@ -314,6 +316,8 @@ typedef struct OutputFilterOptions { const int *sample_rates; const AVChannelLayout *ch_layouts; const AVRational *frame_rates; + const enum AVColorSpace *color_spaces; + const enum AVColorRange *color_ranges; } OutputFilterOptions; typedef struct InputFilter { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 9effa96aac..8b420e68ab 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -202,6 +202,8 @@ typedef struct OutputFilterPriv { int width, height; int sample_rate; AVChannelLayout ch_layout; + enum AVColorSpace color_space; + enum AVColorRange color_range; // time base in which the output is sent to our downstream // does not need to match the filtersink's timebase @@ -220,6 +222,8 @@ typedef struct OutputFilterPriv { const int *formats; const AVChannelLayout *ch_layouts; const int *sample_rates; + const enum AVColorSpace *color_spaces; + const enum AVColorRange *color_ranges; AVRational enc_timebase; int64_t trim_start_us; @@ -395,6 +399,12 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0, "%d", ) +DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, color_space, color_spaces, + AVCOL_SPC_UNSPECIFIED, "%s", av_color_space_name); + +DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges, + AVCOL_RANGE_UNSPECIFIED, "%s", av_color_range_name); + static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint) { if (av_channel_layout_check(&ofp->ch_layout)) { @@ -639,6 +649,8 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type) ofilter->graph = fg; ofilter->type = type; ofp->format = -1; + ofp->color_space = AVCOL_SPC_UNSPECIFIED; + ofp->color_range = AVCOL_RANGE_UNSPECIFIED; ofp->index = fg->nb_outputs - 1; snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d", @@ -822,6 +834,16 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, } else ofp->formats = opts->formats; + if (opts->color_space != AVCOL_SPC_UNSPECIFIED) + ofp->color_space = opts->color_space; + else + ofp->color_spaces = opts->color_spaces; + + if (opts->color_range != AVCOL_RANGE_UNSPECIFIED) + ofp->color_range = opts->color_range; + else + ofp->color_ranges = opts->color_ranges; + fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); ofp->fps.last_frame = av_frame_alloc(); @@ -1485,6 +1507,8 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, ofp->format != AV_PIX_FMT_NONE || !ofp->formats); av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); choose_pix_fmts(ofp, &bprint); + choose_color_spaces(ofp, &bprint); + choose_color_ranges(ofp, &bprint); if (!av_bprint_is_complete(&bprint)) return AVERROR(ENOMEM); @@ -1907,6 +1931,8 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) ofp->width = av_buffersink_get_w(sink); ofp->height = av_buffersink_get_h(sink); + ofp->color_space = av_buffersink_get_colorspace(sink); + ofp->color_range = av_buffersink_get_color_range(sink); // If the timing parameters are not locked yet, get the tentative values // here but don't lock them. They will only be used if no output frames diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index decf63e7d5..d65167bf7e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -934,6 +934,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, enc_ctx->pix_fmt : enc_ctx->sample_fmt, .width = enc_ctx->width, .height = enc_ctx->height, + .color_space = enc_ctx->colorspace, + .color_range = enc_ctx->color_range, .vsync_method = vsync_method, .sample_rate = enc_ctx->sample_rate, .ch_layout = enc_ctx->ch_layout, @@ -967,6 +969,16 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, if (ret < 0) return ret; } + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_COLOR_SPACE, 0, + (const void **) &opts.color_spaces, NULL); + if (ret < 0) + return ret; + ret = avcodec_get_supported_config(enc_ctx, NULL, + AV_CODEC_CONFIG_COLOR_RANGE, 0, + (const void **) &opts.color_ranges, NULL); + if (ret < 0) + return ret; } else { ret = avcodec_get_supported_config(enc_ctx, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, From patchwork Wed Sep 4 11:02:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 51347 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2543:b0:48e:c0f8:d0de with SMTP id hf3csp171617vqb; Wed, 4 Sep 2024 05:04:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwYWECu27qHxQHCWpem/CD+5Y1c5N9GY3GO7pyWgigFNxoG/5JeUhV48LTAJmkfBINdqNiPu/rMEJze4h6V3bW@gmail.com X-Google-Smtp-Source: AGHT+IETZMWU5QrGiCpvInzNVrKM+5brFzmtJ1tS+V2gI0fNapEJSYcAVzZSkzVbnCFaelWPAr3N X-Received: by 2002:ac2:4e13:0:b0:52e:fd53:a25e with SMTP id 2adb3069b0e04-53565f0ee5fmr1917528e87.2.1725451453022; Wed, 04 Sep 2024 05:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725451453; cv=none; d=google.com; s=arc-20240605; b=QbTqcjl+9VniWAK7l0BxN4scyhDxlBLOm0jVkFS5YflIuAR8gjd9kK0oukafqKGR3q 8qMprgDNp1gXYzVhKNfqe233CKuxYMKAtN/9BVwnmRJaky2LHIDL1nhr31n0M2Lhknmu z1yQTmjio7ys6kdJEburDULjSrAZM7Xb7DgpA8UPga3/YCynhta+GuNSFl5UC0bZT00Z VL/DJL5K1LipI4Ex21srap3gazMmJuxcztLRPBfT8+/M0QRdtJMMvKh7qgCWEEbnT0j6 lIOytQoVtNv52/Kbh7cRQl2yJIR1Dj18qkZtsDjC7fnRV3zeagudMYcWT7B/khR/6LNQ owew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=w/5l1C5Dv6CMmb3HAoxKG74qVQwgwSn8SngCH5adTUM=; fh=tuUXnhgwUopqrbuJY3BExN6aocuFs1Cf//owLTlTyNI=; b=KNcfpR9PpcxS7s1ep5LfxW4nYhsfdtxmRD/hlBfIoPX7uhvg/N5Ms96oBhbUQdg2dl p/Oe1Ky+J61lqDbI/xLlXL5CXliV3MGOaGQFsD8Al/FGNQwojyYe0TvsulWVd3PUdE8E ftAruRE5rj1RnqFKRrjR8mBTqVUed/6gfVW/RTecg039GGsx3KbEAhN81sxc2oBD7Qgo MtlUaX2waCNhGtoYt6h/PdCPotDV5KFxAusfxbLHnGLhHu4vnKCRFZ6OOY6IjrUG0fnR oRdD9C4VhAn8E5LG9e863cM7zKKIywgjK1ZAenyp9u/nPL7RpY++yqU1vocCwBexYaMe ezeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=tQ1cI3KC; 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 2adb3069b0e04-53566ddf99dsi459690e87.177.2024.09.04.05.04.11; Wed, 04 Sep 2024 05:04:13 -0700 (PDT) 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=tQ1cI3KC; 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 DE23668DEC7; Wed, 4 Sep 2024 14:08:21 +0300 (EEST) 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 E2E5668DC49 for ; Wed, 4 Sep 2024 14:08:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725448090; bh=PLnSTlvWAZ3IPgkSlsOb5Zrh96noodhvzimRioZSFzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQ1cI3KCFLeX0yJ3BpFuZqiGSu8V7jojugMpBdfbvtMl4olajoa9zjXvfEnvEEq0N PPUUjekxh4TcHZJV2Bwsqvk1eD6FKWzJn0tCqIh+zvfYWpuPlfi9MTfdjN21avXHjg ixdaPHoeKZI6rERWQPXJL8RgKR9ztb7DDbAR76JI= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 5412041C1E; Wed, 4 Sep 2024 13:08:10 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Sep 2024 13:02:46 +0200 Message-ID: <20240904110720.11713-18-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904110720.11713-1-ffmpeg@haasn.xyz> References: <20240904110720.11713-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 17/17] fftools/ffmpeg_filter: remove YUVJ hack 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: Anton Khirnov , Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KHm2S48Z0wfF From: Niklas Haas This is no longer needed, since we now correctly negotiate the required range from the mjpeg encoder via avcodec_get_supported_config(). Signed-off-by: Anton Khirnov --- fftools/ffmpeg_mux_init.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index d65167bf7e..b0fe4c0f7e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -997,21 +997,6 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, return ret; } - // MJPEG encoder exports a full list of supported pixel formats, - // but the full-range ones are experimental-only. - // Restrict the auto-conversion list unless -strict experimental - // has been specified. - if (!strcmp(enc_ctx->codec->name, "mjpeg")) { - // FIXME: YUV420P etc. are actually supported with full color range, - // yet the latter information isn't available here. - static const enum AVPixelFormat mjpeg_formats[] = - { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, - AV_PIX_FMT_NONE }; - - if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) - opts.formats = mjpeg_formats; - } - if (threads_manual) { ret = av_opt_get(enc_ctx, "threads", 0, (uint8_t**)&opts.nb_threads); if (ret < 0)