From patchwork Fri Apr 5 18:57:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47860 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157586pzd; Fri, 5 Apr 2024 11:57:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWt8qnLyGO7C+zS6jaj7sC0Ncbc5G71LgAjofogARgBf1M0/DI9xlB5j48nTyjm2dQ4sPyp+D9IWetRnOg0hWIKvK/c/txcbh4pTw== X-Google-Smtp-Source: AGHT+IGsqrJfEJgOwZMm3GF0mmGrwKOJr18LFP98AH4xAoN+KVd5IDpl2efSwj54xuCuULiEwS7F X-Received: by 2002:a17:906:cc15:b0:a51:930c:5713 with SMTP id ml21-20020a170906cc1500b00a51930c5713mr1443914ejb.5.1712343458247; Fri, 05 Apr 2024 11:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343458; cv=none; d=google.com; s=arc-20160816; b=DugpLhW5ry4b1Gnuexy1LFp2AbtNAvyw5wr5GEKLddIqmZvRjIytbDuMZQrySUI2Mf oWYPVEvl+Zjwss7Xg4WibuRShdCSXExNzE05OnSyUxQVhgK9uepEMw633ijnadZQzdx1 5VddBCxXvGjiCFcATDevQJy0nJ4SRgQhVUkapo4UCuoOuz+RXblTYDjdYwhO6ugwDkXc ADY2H6vxjXlzdqxIe6TUZQa0M6tdRuza4I4ynEDXN5ESLIwHdEJOHd/B6GKAq6qtqkrv 2ujS5bkOGwMkJRA8RSK+WzbfcYRWcNC+PzRB74jOZ+cpsj8KmgO8+wqoWSEdP957Axso 5kOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=MkKCGPGmYsgDRq/bExWureUWfJvRml2wp4whKVuR2O0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=gdUCRM1KZyhg8vM5CnjnRE99Dk/0y+qGSn67qtjjkBRgswxnBQRDNrYPiSm9bp2Gi8 8A3hh9Q2y2j+CORpnnXvMtHLYZdal490rMJX1Af3AX38pz6ioYmUdOqiQLa1iWLJdznH XLNYCeoZ9eYjQ4HM1Sok3Vou/cqw7COezA1cWczMPFKfqQbDvczQgQlaI9HS5K0rGUUT L1zuAYm9n62P3QZQ4ty+pjYI2EP0rJ44+Q5LpLSVLRQU4+jHzGpuNjBYAjHl6i7muhLu rjFHAiD7IxuAzBqQ80hmy4oojqHqyei+R4N/uyeRnl0SJGzNWvdwpt3bNOH3AfBOD31p pXAg==; 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=ApNggkUu; 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 pj12-20020a170906d78c00b00a51a0a1aeaesi951735ejb.675.2024.04.05.11.57.37; Fri, 05 Apr 2024 11:57:38 -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=ApNggkUu; 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 4FE9068D135; Fri, 5 Apr 2024 21:57: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 353D868D095 for ; Fri, 5 Apr 2024 21:57:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343445; bh=ymHusjWhgngbWdDmjBB2I1v2nAT1oCkQ45qEpwiIs24=; h=From:To:Cc:Subject:Date:From; b=ApNggkUu3q33hmwA/dQcPZtpCYwLAhAtmW5mTGIj2GZIqW1GonoTqiggKRj3wc1kR fI1qdTgGbb33p7XpTyRrRc1D9C+NdeebXFNim02VDeGzKPQ5SvuY+xjTsGDNLOBdlx y2zgixIRb+4/kgGE/exaMpq+JVn91/EnJxYh7G3w= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id DF54F402FF; Fri, 5 Apr 2024 20:57:25 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:11 +0200 Message-ID: <20240405185721.111072-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/11] 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: EhqPAColjfnF 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. I decided to drop the explicit length field from the API proposed by Andreas Rheinhardt, because having it in place ended up complicating both the codec side and the client side implementations, while also being strictly less flexible (it's trivial to recover a length given a terminator, but requires allocation to add a terminator given a length). Using a terminator also presents less of a porting challenge for existing users of the current API. 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 | 51 +++++++++++++++++++++++++++++++++++++ libavcodec/avcodec.h | 27 ++++++++++++++++++++ libavcodec/codec.h | 19 +++++++++++--- libavcodec/codec_internal.h | 21 +++++++++++++++ libavcodec/version.h | 4 +-- 6 files changed, 121 insertions(+), 6 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0a39b6d7ab8..fdeae67159d 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-04-xx - xxxxxxxxxx - lavc 59.6.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-04-03 - xxxxxxxxxx - lavu 59.13.100 - pixfmt.h Add AVCOL_SPC_IPT_C2, AVCOL_SPC_YCGCO_RE and AVCOL_SPC_YCGCO_RO to map new matrix coefficients defined by H.273 v3. diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 525fe516bd2..3615dc7c1f3 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -700,3 +700,54 @@ 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) \ + do { \ + if (codec->type != (allowed_type)) \ + return AVERROR(EINVAL); \ + *out_configs = (field); \ + return 0; \ + } while (0) + +int ff_default_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_configs) +{ + switch (config) { +FF_DISABLE_DEPRECATION_WARNINGS + case AV_CODEC_CONFIG_PIX_FORMAT: + WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->pix_fmts); + case AV_CODEC_CONFIG_FRAME_RATE: + WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->supported_framerates); + case AV_CODEC_CONFIG_SAMPLE_RATE: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->supported_samplerates); + case AV_CODEC_CONFIG_SAMPLE_FORMAT: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->sample_fmts); + case AV_CODEC_CONFIG_CHANNEL_LAYOUT: + WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->ch_layouts); +FF_ENABLE_DEPRECATION_WARNINGS + case AV_CODEC_CONFIG_COLOR_RANGE: + case AV_CODEC_CONFIG_COLOR_SPACE: + *out_configs = NULL; + 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) +{ + const FFCodec *codec2; + if (!codec) + codec = avctx->codec; + codec2 = ffcodec(codec); + if (codec2->get_supported_config) { + return codec2->get_supported_config(avctx, codec, config, flags, out); + } else { + return ff_default_get_supported_config(avctx, codec, config, flags, out); + } +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 83dc487251c..64f31375fc6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2690,6 +2690,33 @@ 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. + */ +int avcodec_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, enum AVCodecConfig config, + unsigned flags, const void **out_configs); + /** diff --git a/libavcodec/codec.h b/libavcodec/codec.h index 6f9b42760d7..f7541ffc42b 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 d6757e2deff..3c6328364cb 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" @@ -264,8 +265,28 @@ 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. + */ + int (*get_supported_config)(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_configs); } FFCodec; +/** + * Default implementation for avcodec_get_supported_config(). Will return the + * relevant fields from AVCodec if present, or NULL otherwise. + */ +int ff_default_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, + const void **out_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 84a1c02ce4a..da54f878874 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 5 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 6 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From patchwork Fri Apr 5 18:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47861 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157658pzd; Fri, 5 Apr 2024 11:57:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4apwIHfeFA2XenU/dI+lDg1MLaMxYotB4ZVLUJH+9ZfUo5MiEE3xi59LNJX2E+iUtjzsFCPsYEU1/ULkcnZWvMnCCqmxvxOeW3g== X-Google-Smtp-Source: AGHT+IEINlKTuTB1D+xj0BQjVhHHUF58/eU3pb5spSC591sbaZSsIfrzB1yRBv3lxpjm9lH2tMd4 X-Received: by 2002:a17:907:72c2:b0:a4e:8508:d807 with SMTP id du2-20020a17090772c200b00a4e8508d807mr2095334ejc.0.1712343468932; Fri, 05 Apr 2024 11:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343468; cv=none; d=google.com; s=arc-20160816; b=tIiVuQuSrKMSV8IOk7ri68U0B4ecCJiy3ubBs7JRSHRvYqVH0V0SmrOT8wJFJxI3p4 VWKbTXd00FQAzAPYIpduKocvhPnN3SN4Pr+VVpKO0BxYbcYHFwDH6Bdr+08+UpKXq1P1 cWGaqPPrhY4r1ejiCojtcZaqmd61O0Ulby8ThxAOuy5UxJGmONgkYx7S/kgIfqnwKYMC nIlozQIPiBtsfQZWT/7uBX6TphYxLLIAS5wMctL+xNDWKxAzhOQp9qIfXrFC9n4upnXi bRXpGt2y+XdrXsvw8Ps915H5deqzV6VSMIuj0iAgnC8DJGUPdmNf0u7dNue2qWrd22dE BuWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=2Y202rhFJHCGUXWaGV5maD7cdvir070NX1QUL4qfv6Q=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=blrR1rK1xNpRDOvFhbVw3AwcqFjN/zI6aXdfXH+hI1sK2q7k0mdLnnVd+ELOFJ19Mg ZwIUtLskOZP3okVRsVInWN0abslQmsPlwRqeBsaw/bEjet1pkkjz2Sn6+RHxXHlID+WJ YFCyTLW8yTuRWIEKl3MqrA4WQ5AP60PtuHNPqTIySxTBgEwxKYZVgP6gqAbbglx33oiW D0qANBa31m/juHck06LfbLnvjyvk5TJVGyVwBP+XX9UfAp4TuCaJYvpR+K+756rDQc1E biIO5CHRRE6+2+FV5Xw5Ozj1G8x1Z6sCkB/nQ4sTSAmlAdGQv9f7ImpFDYZ7kBoYLTw2 8BdA==; 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="lyny/sUD"; 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 u15-20020a170906408f00b00a519056b86dsi928901ejj.381.2024.04.05.11.57.48; Fri, 05 Apr 2024 11:57:48 -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="lyny/sUD"; 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 936F868D16C; Fri, 5 Apr 2024 21:57:34 +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 6545468D095 for ; Fri, 5 Apr 2024 21:57:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343446; bh=M05+RXa7tCLEcr/XD9YkzRUNJQEklDILgd6nsZaiGNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyny/sUDoghHhXsBt9oVhWsm935o3ok06s1WwzUals+q+bU/itufFmQzUvsePihDY ItnhQZ+lUt1KhN9b+eWs7xFzl5Axz4bdWYuIVlWt0pEeNfJDC1JbWVoh9z7RUigH+f 14GX6W1kYmMmclTnm33Qb/TiyoCmlKCzk6DgwAbc= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 2199D4255D; Fri, 5 Apr 2024 20:57:26 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:12 +0200 Message-ID: <20240405185721.111072-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/11] 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: L1yAF1/KdGZ5 From: Niklas Haas --- libavcodec/encode.c | 88 ++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 34658d13d0c..d0e79379048 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; 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); + if (ret < 0) + return ret; + + if (pix_fmts) { + for (i = 0; pix_fmts[i] != AV_PIX_FMT_NONE; i++) + if (avctx->pix_fmt == pix_fmts[i]) break; - if (c->pix_fmts[i] == AV_PIX_FMT_NONE) { + if (pix_fmts[i] == AV_PIX_FMT_NONE) { 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; if (!av_get_sample_fmt_name(avctx->sample_fmt)) { av_log(avctx, AV_LOG_ERROR, "Invalid audio sample format: %d\n", @@ -659,53 +668,66 @@ 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); + if (ret < 0) + return ret; + if (sample_fmts) { + for (i = 0; sample_fmts[i] != AV_SAMPLE_FMT_NONE; 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 (sample_fmts[i] == AV_SAMPLE_FMT_NONE) { 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); + if (ret < 0) + return ret; + if (supported_samplerates) { + for (i = 0; supported_samplerates[i] != 0; i++) + if (avctx->sample_rate == supported_samplerates[i]) break; - if (c->supported_samplerates[i] == 0) { + if (supported_samplerates[i] == 0) { 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); + if (ret < 0) + return ret; + if (ch_layouts) { + for (i = 0; ch_layouts[i].nb_channels; i++) { + if (!av_channel_layout_compare(&avctx->ch_layout, &ch_layouts[i])) break; } - if (!c->ch_layouts[i].nb_channels) { + if (!ch_layouts[i].nb_channels) { char buf[512]; int ret = av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf)); av_log(avctx, AV_LOG_ERROR, @@ -713,8 +735,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 Fri Apr 5 18:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47862 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157706pzd; Fri, 5 Apr 2024 11:57:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVqr/bMkBszoNtpbMBXC+yTM/DJ9sTWtBOKffbS6LOiRS/tbZLIt+HLda2qJ7zlMZgYpQ6q5na+y7jUBX1cuUvJxK1TPPANDbuaZw== X-Google-Smtp-Source: AGHT+IGkwqkK7JHW51HWxR+ZN6XnPOTMyXY4DUPMnPjvDAsDcc2YcJuiMVbz2AsLz7/Vkb8akSwT X-Received: by 2002:a05:6402:26d4:b0:56e:4069:9ae2 with SMTP id x20-20020a05640226d400b0056e40699ae2mr145253edd.3.1712343477530; Fri, 05 Apr 2024 11:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343477; cv=none; d=google.com; s=arc-20160816; b=YV9+WrQtifv7foTocF0+oepyXAtMvWZpxMyHcj9DsootKLn0h6DUqLrDpht6l3EW+q NYPaGbS0RM8+5sENO7tjxoEJZHHUTw4KMJbSnHP5jNLc+8kpM+gIZoPFRigpIcbuHkA5 7hZxynbawYe/I2QGg1Jl+ZAcEP+cpXYHgC9s/VXvyynJZGMamS2GW/1AifMDWSVfcnP2 eBo1kH4EAX13IGjuEndGlE1wkeyNwzTRa/imbse/R/bqGMB/kpsDP36Ams3jrl6M47DX llgSdGXG3SJyrALylHZIFwxx4VjlTKXTxRNu+ktddLF0/BPtjwo/MC11V/U+pUAnS/jy Pg+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Iq8fU6LZBphVtmOD1rMJ2i0kQtCR03CeT9mK52K/cz0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=0yN1xtbuTENoGOF/z3unaW2vj0okjuGjJ+dMF6N6tpchWjgoC0LqPEsWfnL6Mpj5Ug kgHiODyxlzoH3U45lW16Grc6EDvtxKa22hq9amhO7RhsGiRcCUR2I8gCv0cHV/ye5QbK U6y+yleTrCM2OOJ/YxIov7P586EBnB/cherIt8Y1Dyh8hGQ5Jc/sCgoLzeokyHvisKXR 49x3I2LKBFJi2o+VU2fVTAIwNc7KTGnZani7jnfYyoHD4WK6oX2bGrAaUYOLlW1p+7SX XBfSq7icyUJvzXLHaqS06lSaxFj6mQGn051lOLe9bJEnrZEndhwj3sRk+AOUdvv6cGhS bIpQ==; 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=bHuwwC9Q; 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 j1-20020a50d001000000b0056e07a2e666si960322edf.193.2024.04.05.11.57.57; Fri, 05 Apr 2024 11:57:57 -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=bHuwwC9Q; 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 98B0468D18A; Fri, 5 Apr 2024 21:57:35 +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 920DF68D095 for ; Fri, 5 Apr 2024 21:57:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343446; bh=0waB0ZRpG4JRcU/69Vg8TSniLYKB5lbR7owghTOYBJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHuwwC9QQsBg65hwv9BnhIAviqFds4FY0/whFxgr2hvakg1IhjENP8nV8DbgbDxac GYBvzbYtPzqC6Ycrne0150gLHjzrOOMEFRieXHEbzYWrie2aLhQdJHV1Q1AihW+4mb UTOM+fF8roTGAtM1Z2owEwoGCdayD9FispJcF4o4= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 5142042835; Fri, 5 Apr 2024 20:57:26 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:13 +0200 Message-ID: <20240405185721.111072-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/11] 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: EH6HOUOGGey7 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 | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f4705651fb8..a9f1797930a 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -916,8 +916,41 @@ static AVOnce av_codec_static_init = AV_ONCE_INIT; static void av_codec_init_static(void) { 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); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_FRAME_RATE, 0, + (const void **) &codec->p.supported_framerates); + break; + case AVMEDIA_TYPE_AUDIO: + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **) &codec->p.sample_fmts); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **) &codec->p.supported_samplerates); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &codec->p.ch_layouts); + break; + default: + break; + } +FF_ENABLE_DEPRECATION_WARNINGS } } From patchwork Fri Apr 5 18:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47863 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157758pzd; Fri, 5 Apr 2024 11:58:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+Y2ToxVOYlYx3L9Q2fqmHskv5VZS5LfrAly27HLdx4epRUPFPwBA3TojV2doLsF8TLJ8xEB9Wo1zs3MoIns+fUZJEWR3xLo5iGA== X-Google-Smtp-Source: AGHT+IE/dRnQqWS/8FsyKSEUWbdBunc4C5AMBxUJyyVdGRDbDEQ7GfvX5EEsbcRfqr+A+kdRdoyw X-Received: by 2002:a50:d702:0:b0:56e:b68:1b98 with SMTP id t2-20020a50d702000000b0056e0b681b98mr2137135edi.28.1712343485443; Fri, 05 Apr 2024 11:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343485; cv=none; d=google.com; s=arc-20160816; b=zCWqECr7X8+tH02BnyxMocC6j9KeIBbHHA3W/+6MRI74nx1sCI1Oyb+8miYld+WqgY LCgjFH7BcGyBi/lfa7E6Rgy3UXOxE4deMNSkEWZVhzUeX9lFJuxigBQ1EUIPPzR0frUK 1Fcte4GmJR3vrHtYL2AKha5Tx2bItJlg5ifL+BIeowZI+rKH5YV8URVczN8mQ6jxrsCv rKpDTGTbbx42JHBjvjmGdjJtZbsq2awVoYJGhplS56Skx3EjM2K8lLxyD/cfs5uAUDkG V8AdMV1NqQFNp0F4IN/ljFtVnF4ovfQQvPop0C76YpKOUgk/N/TfqnvQTm9FC2sbBw6U 93NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=K2VtaePu5lyZdqgrun5hXo8Sy0yTltQb9xgX1JBZnG0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=SJaZ1mGyFH9SfhTGAtfeP8OgdkZM7Wvb+ZxOomFOV+DD4dsEl7Tp2QVdmJ/UuTjB3v ouaukDApB9AfeDzelPSig/qb2Qr4seUlEiFW10ZAmagWOETrPuaYYZTYeDqc795PVgZp B945o+3CQowQl2zWGxh7Qo1pAkfKfnYfzQVhBBfYGP7odsQWeS57IyFtbn2kuVsOqgiD Fya+OvP6xlOZ80AkxZXj9X7VPSNRGgA3SfkEPcLw1d/ZNiengxo0BWZoCnPA2V3O/FUO HjLhm6b3wsC9UUPjt1ndiMwr7lnrRsBOgutszq/be+qJfXQkmKr5gCVUR9dQ0WutD/Bl QWKQ==; 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=JGOUjexL; 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 g40-20020a056402322800b0056dfc8dcaeesi959513eda.409.2024.04.05.11.58.05; Fri, 05 Apr 2024 11:58:05 -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=JGOUjexL; 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 A116C68D1C0; Fri, 5 Apr 2024 21:57:36 +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 C11BE68D095 for ; Fri, 5 Apr 2024 21:57:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343446; bh=Ge9oXuzwsrP/gCsGtWY89yY71e2NxYUVYlhhj9u+QjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JGOUjexLnfupWdU5YjVitiA+ALvhWgQxrNUZ0o7l2eVRc0YRDE07v3O4KyyCZp3x4 KakF/tjP3H1zzf8p/b5zpvS7cN70tMYb5OpenjIYgwZd3ujOCUDk0mimQPLtM6A/Kb EpYgJIDCiAwmJ45OqVPTBQtFvoMzbzvmJjsGdFKo= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 8481E428D7; Fri, 5 Apr 2024 20:57:26 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:14 +0200 Message-ID: <20240405185721.111072-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/11] 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: bEzaQam9UFTe From: Niklas Haas --- libavcodec/libx265.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 0645cd20457..ff1e8463aa1 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -892,14 +892,24 @@ 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) { - 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; + else if (x265_api_get(10)) + *out = x265_csp_ten; + else if (x265_api_get(8)) + *out = x265_csp_eight; + else + return AVERROR_EXTERNAL; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out); } #define OFFSET(x) offsetof(libx265Context, x) @@ -951,7 +961,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 Fri Apr 5 18:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47864 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157807pzd; Fri, 5 Apr 2024 11:58:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmQY0iNCWBQtBBJwUzaccNgUWexrj+7GnqATe+6meC/BMjj/Zaru6ERERu1w/3r9zOpYVLrIOX06Po7b68tHcIsi2PExHttXAf0A== X-Google-Smtp-Source: AGHT+IE/exRhgkdHXq1vUIOv+DijaGVfB1sgDR+4o/FlZWYyhdbWL2h7UsEOvx+NN5NHsPbjpNpJ X-Received: by 2002:a50:9fe3:0:b0:56e:a76:b79a with SMTP id c90-20020a509fe3000000b0056e0a76b79amr2426475edf.7.1712343493771; Fri, 05 Apr 2024 11:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343493; cv=none; d=google.com; s=arc-20160816; b=o1fgeicdHqUF0JFgJjEevJNmSM7BBWpTmKgD27Ysdy2q0GFgdpTsilIZ69yS1dJ9h1 mmzJl2ccVROqGwQNWY2LupkIJr/vqcFMI/NgdWelbXhFiYExumT9EW/Ylx8q9RyHfD9b AWh2ViURTpK4E21xNASxBLRQ62oZcg14v7AR56s84iGOttndqBvgEOdLVKLukGeudHKo KzDHZ4MIMwSo/81hJESuMztew79kI33mtjlOoDEa78aAzBoMQ1dG+RsJQh5o+CzzEsLe hKOKnQmHMvJvLsSjLrx8Dx8CFqS7z/MGSNDBXIJ26Mm5rsOJmr7W7DsWpUgxpLhnRwHn Zhzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=dle471v9IGswlm3c8P0mGbbcfG3wD5wxbnUtv43nK6g=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=wS4piOjbyBZfMIbELDKVZ4CqoVL7mQ4vrU3HOpUp67XXVyyILtN+Fk1PeUuTIvpTKk bDdppWS//PQOpaSnHKcCCVY7565oR/0GibL1dPq7HJU51jrDiBQwIpgGB4TokXaCt2DB OSEviaAPAuWY8dGKKlRaide66NXP1t49pE5tZgTjfdWqqKay5+HROKXLRspXxVAysCNM 41bZ+HrsJJL3Pr6qVf6ehtB55+Oi9Wjx7fb8yro4hEArYQJbdCZG3YNwGZ419i5KrkSd P7q66yEf3nGkFVAkNsOaOohuFXBd9mgLOXv8MwLDH0hAcmIj8ToQlMh7amr+3MBycPdD ucgw==; 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=JTWyH6fU; 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 b64-20020a509f46000000b0056c07b5c8ccsi994352edf.318.2024.04.05.11.58.13; Fri, 05 Apr 2024 11:58: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=JTWyH6fU; 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 A75E268D1CA; Fri, 5 Apr 2024 21:57:37 +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 F382468D095 for ; Fri, 5 Apr 2024 21:57:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343446; bh=i4h1F8Czw22Scr6ZNQH/gBGQ4wBb6lIZkvkQ76CeEzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JTWyH6fUEv2+j8L/CMDdQvP4R8TEoyG7eWviC6Xx+seFRYTjCWsmQ2KGHKhqj1P8T Fs3sRly/GzXL+Q70mDI2ecqPopF6TlTFERpcS/4OMKRwqhiKi2EUsfFWe2TVuUn4eM u7C3Y4y1SSU9mVbRV5QGCi3QBwh41Adqr0RfHuuw= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id BB4FA42A98; Fri, 5 Apr 2024 20:57:26 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:15 +0200 Message-ID: <20240405185721.111072-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/11] 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: Le0onJV2OSW8 From: Niklas Haas --- libavcodec/libvpxenc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index bcbdc4981e5..ac7f01e2aa9 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -2086,13 +2086,21 @@ 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) { - 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; + else + *out = vp9_pix_fmts_highcol; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out); } static const AVClass class_vp9 = { @@ -2120,6 +2128,6 @@ FFCodec ff_libvpx_vp9_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | 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 Fri Apr 5 18:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47865 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157869pzd; Fri, 5 Apr 2024 11:58:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWfPwUyxU3dc6WMpInTy1AQv59XQtFwMMengpWh542UbSUVcCIM+GTVMMmJO7cS1jnngayDpWiyea54e1d8vRaEli4F7l+mjz3Wg== X-Google-Smtp-Source: AGHT+IH6Prin8B76pqvInATWM4gMg5RA7L/hDvbdF2Rc26GgG6p9Q9VtA/hO60392qBdIVSPt7cY X-Received: by 2002:a50:d781:0:b0:56e:2bf4:fe02 with SMTP id w1-20020a50d781000000b0056e2bf4fe02mr2663843edi.11.1712343501964; Fri, 05 Apr 2024 11:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343501; cv=none; d=google.com; s=arc-20160816; b=RkzAIi0fOvtVzoZ7lkdeffshg/wqzWNxy6UTHoAh8zd263Y1A5XTZy31CPtpS+hP+E vuXomYCM441RBkLzVrrNqZxuZoZpxfzSCEiT/ttIAj15jd9bchhSsNOuRBRAK/g+EYkQ j9ySwUoYEK1ARO6lEiY3NnBZAYF7tw+4v1oJlDKEhWy/6bYqaSp0+K+k9McQ8OmcbloM zTWBClsPAzMbup/T+5nQjQ4Yib1toNtSoG+fP6BnyDqmpWgipVNOgMTBez5ePzfTOosU 9sFNSBGqiGS1o/RC9fMuZ2FpbjaEl7ImrsRDIVDeZ1l5PZHCSbfWCXalEiwG0/uSRjxi 8tEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=dfckm0H2yEknQP2jIMByimyG1N2b9MtSwdekIXqhV14=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=PIGlzeFiNsQ9aBVlqYEMANLRUCeY25Goz0SXnhQwkVheRWQ93QE4Et3yUE8aTyu5li HGg1UoXbV29X6UDAaMZagchXq3rVOdnMNM7zOoNoqsY+m2+mu8bwi7CW+1iRrcRnqAt2 T/Lugyt2GJAinfiNOPZ4Lo8h9D5P0DbGPzqXO3OinOVLmPJNS6B+1nmNv+xkidgPowPA e6C6YYowoCiHZXw71OGphPSDj453sfGIXUPKLWciaSAL/axCqJEY5uWMQIa4gA5Q6Kl4 77YdhtBdVBU9Cx3vKYj0jvqiBlMicgCmSu6PtnbRw4yCDmEK8P9Lw2kfRUwSnJp7STfD X/cQ==; 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=Z+zo5gwp; 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 z13-20020a056402274d00b0056de9b2f1b1si1002709edd.286.2024.04.05.11.58.21; Fri, 05 Apr 2024 11:58: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=Z+zo5gwp; 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 C980868D1CF; Fri, 5 Apr 2024 21:57:38 +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 63B3B68D198 for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343447; bh=NWy4vbMmSNZU+7cl0RLALU/3x7t6zQSDXODn/bT2kOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+zo5gwpSlb9KzCOchIXik2qyZvp6cR321+3fR8pNdV6HgPs/CgA9oUz2qGYstavj LWV3TitRRyEo6gnHfEoOf1XqkP/YPVm9Wqx3Mko2kcB5+nRzwBykT3SqS/rjd2+Qhj +ZhZMJF96YqyS0ftzfrvh675cwjdXzYR6Vi0AIRA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id F046D42B62; Fri, 5 Apr 2024 20:57:26 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:16 +0200 Message-ID: <20240405185721.111072-6-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/11] 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: N4372dMvdZRc From: Niklas Haas --- libavcodec/libaomenc.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 4a71bba9c9c..899aa2b261f 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1398,16 +1398,24 @@ 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 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) + *out = supports_monochrome ? av1_pix_fmts_highbd_with_gray : + av1_pix_fmts_highbd; + else + *out = supports_monochrome ? av1_pix_fmts_with_gray : + av1_pix_fmts; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out); } static av_cold int av1_init(AVCodecContext *avctx) @@ -1528,5 +1536,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 Fri Apr 5 18:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47866 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1157929pzd; Fri, 5 Apr 2024 11:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVAazOBYD6y4swsKv05/uPrH7/KnCqe73wZddGyssBemkN9zBaWGCBe7E4YLUDbmqZmtoD8OA5uxvj0HxpG6EgDeJ/mBuo/Inntew== X-Google-Smtp-Source: AGHT+IEiIDi/tuP32P6ZE0/BTueIND/GlrIllAp5E+2SGvy6B5IO0XyPtsAu40aKSsKvpK+CC5bM X-Received: by 2002:ac2:5462:0:b0:516:a0a2:ba1b with SMTP id e2-20020ac25462000000b00516a0a2ba1bmr1616610lfn.47.1712343510912; Fri, 05 Apr 2024 11:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343510; cv=none; d=google.com; s=arc-20160816; b=FReP5u9U1L9L7mIu76MJlDK/NEdBSSwhvc4jv86qsuepLVpMEYJf2RQFFDMbNTldH6 Rdt79VF7BCW/rVNl9r6Yd2dmwJD018R+c87yhWUrJFAp1eKo/FahjisfasyRIWH+b3F6 ks1y49JlzCrg00eHA0ucdPOvvWcUUr+IM2zS8Ri4Fyi/Ra9xb81J50mbxSgYnPOmTaMP kVKyDw1McefYujbc4t3jzHJE99hFM6u/3CdlH/lZGz0LTjzKAdhv2sTSyp1WEAXe5RbR TEmPsbN4xL23A3ofAkc0fDqL+kwX2i2FgH4t4ud/jBNDSGbep9PY4C4+wvhKJOZds9nC VnYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=0A/a30l+SwthKOWZ1UeFU/0StsT3aWiYAExDO/VDwcU=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=XBcgJ67/NDQ2xCM/P+9wtZaiIhtQnODyfYiMIf4bPYCGVAtCn3Xr34mJBaBXL4TbqN b4Ux0OEM0XYegLNuQG6RzVnMY/FWCsfN00R0nAey4AMQKH7qwutLBEIZrjHMGmeU/ba2 7ZrCTsq5UTGs5TEAFHQh268i0J47CxpIXHSHwpd92QXDavGpeoKNQVyweG2BJtiFFhN2 t2hvk3KuZVW0RWttxoiGdK8uplkTl5U7hQSgH4qW5xwQ9sbwBOBrjtW7SvEvoePjYZh1 WmNIm2wbNZEoV30jsl60zKPVzc9rqZJmGK5z48RC0oooOyJPWGI+Mb6xoMfpWF8LT/UM WoGg==; 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="gvQe/Nqd"; 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 z36-20020a509e27000000b0056e2e603216si952228ede.391.2024.04.05.11.58.30; Fri, 05 Apr 2024 11:58:30 -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="gvQe/Nqd"; 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 BB84E68D1FC; Fri, 5 Apr 2024 21:57:39 +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 7452368D1A6 for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343447; bh=DqhcKgUt48Ko/wDcefHE/z8O4FDMP26Gj7o2J7WH0Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvQe/Nqd+nPKrzEWJvXXVwu8SkIfOHqjB++kcLnJRQvKs1O+BW+31iXqAFR4i/OiW yarHrj/cdIHxR/7xF5gAycr3X9M9mBPtNsZgtMMlbgoX1j2VOFZih8RXgMUFxT9SHi XO1domjHBQd7Fj4OKUJreJaiFOrQLTJbkFKhZQGQ= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 3282C4301F; Fri, 5 Apr 2024 20:57:27 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:17 +0200 Message-ID: <20240405185721.111072-7-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/11] 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: QOAH5nH+Dheu 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 a9f1797930a..1f22e06e710 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -916,13 +916,8 @@ static AVOnce av_codec_static_init = AV_ONCE_INIT; static void av_codec_init_static(void) { 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 3c6328364cb..f4e97d0fbcd 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -168,14 +168,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 Fri Apr 5 18:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47868 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1158050pzd; Fri, 5 Apr 2024 11:58:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBbABwsQgkNRXl9PDPJ3aH5V8RljBGXB95UxbiDvGDh9DLCfNguJeyvAgBedVeUmlWNLMnKIPa5P72uKScYyiO2i/F+oyw19fAnA== X-Google-Smtp-Source: AGHT+IEIU7tRLHWlQBgGgbMq4xil8Ibr2VXCXaWBEhaUluEjpgIKeIFNyuay1B7ysput7019DoS5 X-Received: by 2002:a19:9108:0:b0:515:d60d:bbb with SMTP id t8-20020a199108000000b00515d60d0bbbmr1504925lfd.0.1712343527520; Fri, 05 Apr 2024 11:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343527; cv=none; d=google.com; s=arc-20160816; b=k41WhwlO+uqBA1kiiF2jk301gPdauGYUOfjdO+ost1XUL+Ic4Vg1oHbxug4Z3c7wY0 UhoA+nCm0Mp6ncGOy7tZs1OX8ZlnBqB8222GjXCqU+rX91Ptkie1qLtjIcpLjTb2U+hS zVxKsq91X7yWIwI1dw2S9oIbNLmzbxsTF7aXTEy854gOOIEst23Rv+jb7iT0mbNGChB/ a/crrUpLapqNyToNvpKtcsEyjNkOzcKJUP9gne6nAznBhLX9hWE7ntn1Oxpq+2cFbhTW byA8zAgvi9VHITb64z6o5QaplMb6vR9yPh5jSgDc7Jqvfu5XOuRFeyxKQ3ezp5InJzgd 2KGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=pPHZZs+nLamE/eaYxT8tKd0OZCmc1P2eNIqPutokZ6Q=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=j1ubDYz+1yIMsxA4dpF9yingw0WxL2LpO2Z4X8eAad9lqH5y/SiVCzverZ4dmT1ea0 6/rCBUxSCOFzzhhp8wm85IztWSPQGyd3G13DQgPk1yOb0VVUOSgck+gP5NAIY2ztXWyB XsqskkXFUd4u6XXZ2UmdIU2SbgxTygYUKew/D3R0QJF6P6N6WbsI2UpkknoFO3HmEvSc f6OP/NubIIoSzucg8ujV+QjuBOmXLlmWzZm9CEu4IFxHpKtT8WFmHrT/3ptKLZtxDBLz rmmWw+0fX+1KEa3gCmBuLts/g1Qtlrn/XdrcRjJqoZ0BuKOWT1XQxK+nQACoPzrZewao 3hFw==; 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=r29jSxdZ; 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 b97-20020a509f6a000000b0056e2e99b24asi905760edf.506.2024.04.05.11.58.47; Fri, 05 Apr 2024 11:58:47 -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=r29jSxdZ; 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 A308D68D20C; Fri, 5 Apr 2024 21:57:41 +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 9AA5D68D1BE for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343447; bh=SJNvqas+6SyHfK+3VkIYknIWBqNBEqM7lAwZuTFTbD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r29jSxdZg2MuzhD0Uo4kYLYAFZc4nsr1wzXTx+YeHA2topg3MUUkcAwjrL6TjUgMj gOe7q61SJbB4mLETn/OY2obVsYcNmP6QrDjvneDQMynp8tOYaMKL3hxI3lxrjazrvi zC5ZjEWNapRh6UIeaDWG5CRIlFI9QROz1GH5kxfw= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 6757A4344E; Fri, 5 Apr 2024 20:57:27 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:18 +0200 Message-ID: <20240405185721.111072-8-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/11] 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: hPaSBGbknHM6 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. --- fftools/opt_common.c | 86 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/fftools/opt_common.c b/fftools/opt_common.c index 947a226d8d1..1bf66580192 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -262,22 +262,32 @@ 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, cond, fmt, ...) \ + do { \ + const type *elem = NULL; \ + avcodec_get_supported_config(NULL, codec, config, 0, \ + (const void **) &elem); \ + if (elem) { \ + printf(" Supported " name ":"); \ + while (cond) { \ + printf(" " fmt, __VA_ARGS__); \ + elem++; \ + } \ + printf("\n"); \ + } \ + } while (0) + +static char *get_channel_layout_desc(const AVChannelLayout *layout, + char desc[], int desc_size) +{ + av_channel_layout_describe(layout, desc, desc_size); + return desc; +} static void print_codec(const AVCodec *c) { int encoder = av_codec_is_encoder(c); + char desc[128]; printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name, c->long_name ? c->long_name : ""); @@ -343,35 +353,19 @@ 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, fps->num, "%d/%d", fps->num, fps->den); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_PIX_FORMAT, enum AVPixelFormat, + "pixel formats", fmt, *fmt != AV_PIX_FMT_NONE, + "%s", av_get_pix_fmt_name(*fmt)); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_SAMPLE_RATE, int, "sample rates", + rate, *rate != 0, "%d", *rate); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_SAMPLE_FORMAT, enum AVSampleFormat, + "sample formats", fmt, *fmt != AV_SAMPLE_FMT_NONE, + "%s", av_get_sample_fmt_name(*fmt)); + PRINT_CODEC_SUPPORTED(c, AV_CODEC_CONFIG_CHANNEL_LAYOUT, AVChannelLayout, + "channel layouts", layout, layout->nb_channels, + "%s", get_channel_layout_desc(layout, desc, sizeof(desc))); if (c->priv_class) { show_help_children(c->priv_class, @@ -566,8 +560,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 Fri Apr 5 18:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47867 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1158004pzd; Fri, 5 Apr 2024 11:58:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXWNBcg7zhTS422xMWTNqJdjiBaSLn0jG2W39C0H4CX93HDbIM/lIqzcmu6Ji/mlwAN8R+Q+5tcUjoVGfzQBC8Fnh1MPqmRaIn7Ig== X-Google-Smtp-Source: AGHT+IH88pNDu2yeyNlHrRiglThMvVVIEsdfoXnf5TWahfLJIXJR3eeFdvl3lMeZByI4yFDmLQ7v X-Received: by 2002:a17:907:2cec:b0:a51:a259:a5e8 with SMTP id hz12-20020a1709072cec00b00a51a259a5e8mr1559043ejc.3.1712343519410; Fri, 05 Apr 2024 11:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343519; cv=none; d=google.com; s=arc-20160816; b=ROW3xvmJS6Uv6DLYr6HudL09QKDQvJH3fMw0mVneadFvhgVRa3EPSWTJK3fdmjLmo+ NRBWTmj5kyB3rWWtlF3WF3lsv6Dava7Xc0eyEPo5p7qv2v4NnKAJhYzDE4o2wSxDTjdI z//7wjdc2dRP18aVBo0RY2atcsK63qTXQCGNn5Ul3U5PZb/ZqGVkLJhmrAjWUBFr5o12 Ot3zRFa0f+ZrKXMQJP2lKlvEf+XoU9fSzg4mkfHQHTTxgWNG4maX6f6gN3fHvB9NHQaV n/RPYwvpleFOJsX5Bq8+oVHVlHBK0ZLZSORQEBxDz1oTYfTpOKBNHvKi+OPLpmE/NCBP CbrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=1xT1JLEjXv/pthbDq1Z0KcuNczhRiPL+RdGG0w3l7dQ=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=H9Xl86b5KymEaQqpEsc3JxZYJc0NeZNkXg32VrqdYolTiQir2tX+Qoqg17lDXRJBRQ JRP0bvDcbmYypFt34vqOHh0UhNlOHcK1zHmIHLEkj9Fa1cTDhUn8LwnDUYyokNd3V5B6 EXbk3PqfNHjP18RcYGFLYFWGzjeH0s+Dgdrrb2WuTV1BroZCOe3AboxrjuuKqQJpTK1O zEoTukpdCt9GSbn2MbHLRnjtMJObIBJTSiqTsx/v2UeH8WUgyPdcvPsSocUPELiA2Smv 1ZDQZ4dw89JQ+cZlVFv6TVvtSK3V2kiuSRtoYDaImsCBaM+sqoZabknGe319XFN1BuGx PVOw==; 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="Ln/D2HMq"; 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 h19-20020a1709063b5300b00a4e25f6b5d7si933151ejf.655.2024.04.05.11.58.38; Fri, 05 Apr 2024 11:58:39 -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="Ln/D2HMq"; 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 ADB5868D200; Fri, 5 Apr 2024 21:57:40 +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 90F1468D1B0 for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343447; bh=3/VAVPZZSeAp2OfHaHXLchGI9H0VELGXWZz8M97gZM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ln/D2HMqg3pYvSzcvt9NVWMwv7p3A1nj09ajPVsDueoGhscLWsb/AiEoOsJVDRrAl hezsIe9dcSwP3RJ2SK79A9zqIKElZqBdWQQUKnHB/6WksiBPyfJx6kUbg0mPHKVMzK NG4z4AWPqSATYpeajxA/z3/yvkyjBNb3CWjuz6CE= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 9E38143961; Fri, 5 Apr 2024 20:57:27 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:19 +0200 Message-ID: <20240405185721.111072-9-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/11] 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: ef2ehfVvnau7 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 d0c773663ba..940541b9eaf 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -465,19 +465,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 2308abf82af..ac04841a16c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -401,7 +401,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 Fri Apr 5 18:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47869 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1158094pzd; Fri, 5 Apr 2024 11:58:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUS1XISoO9xgWYrD6Tyn1d9jG0rMmXlyYbbbFsyph5ubN4NmB7ri2si9fiBKtZ4ucYR5ngAbksD4zLg8CbQFDt95DZzFDKy8wZIOQ== X-Google-Smtp-Source: AGHT+IFFvBKeC6apxX9HTn25LYIqdiQc3FmvUB0yRm8BAlN4udpgb8ka4Ty2e4VvDUuCjJkGyFsb X-Received: by 2002:a05:6512:36c9:b0:516:9f03:6a9e with SMTP id e9-20020a05651236c900b005169f036a9emr1306674lfs.2.1712343535479; Fri, 05 Apr 2024 11:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343535; cv=none; d=google.com; s=arc-20160816; b=dDvzcYSo8cLVuAw02/0N+IQeVvw31fehH+k5NqufHvWbNXCR9yoRAuz4UA9k2EbLh3 fAlMyXXg9cTpjU09DaEs3UwHh2QSQfxvtlt8n7BiX5hdddfuLg1Z755kO/bYIGRMWHm/ gyBocFBJSq4pu0NkqIQKqCBa21ni5OyV9/rHSlI2hBUXZFbgQ86KnYGvJXGzq/o+pIpl AikjFJyMfEDsdnjYERamckdVCjIYxOQ+Fo0AwjbdDHt/yIx/fh1zi0Y/CMKNhFf0QbNZ pVvjW+VadNymliBZ0SmHQfx4TVx9cs+o//hNr5F0JFHd0/NI7oc2d6eKvGntvUBJRd/R UeUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Ck85+/MGx1mm+ZQo+6yU1l/iayFetRbq23IXzKDLlEE=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=JMBMAvUJxP+CbuGWSqVsRevhpMBUQhRjOsQqeHygAf2ztkQrKwWpZCpEoXDvC5na5n nRqkKG0TmTUAn1hRB6eKvPVlQZDEyL+TKLhGHf421IMabD0hc+NqBFFW4mkqLh8MOpZc pgGeW7da2GKZMpmFWdlgsW0Jdx0kHI8HBGLPPp/dDvszaK9N1ANsuU9E+F/6512GmBJt 3wh9RPKgwboIlZk3eQqCFxCsGWQ/VmqUYjgVSHKo9vzaiOzjTpN3dx4l6Ie7ddo13lD4 YDfpE6/Ah1q02K9Lmvn8WL1Ay7wTnVlmFSR1Ne7nNFgRiPeRkfvrtDZgg5/ple+U5VkB 14Pg==; 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="A+/jhcvM"; 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 d8-20020a17090648c800b00a474dc7185csi938291ejt.538.2024.04.05.11.58.55; Fri, 05 Apr 2024 11:58:55 -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="A+/jhcvM"; 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 B031468D215; Fri, 5 Apr 2024 21:57:42 +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 B9F4B68D1C4 for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343447; bh=5smtYd2WTdYZO407xvqR3MGUUNXFLcaSGKDlLqe3cwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+/jhcvMxmADobuTbto83WAwjc2A6bEfHmDEhu8o2rR/CHZMsDSkKz4k3BnOYaaZ1 mGhieCRjFyVZyoiq3qFifkXcX4Nt8E04//EOFZip5bqhsmjFKXIZMgwMmlPVsvmDHr plFfeLcdIJGqZQ+Rjx4Rdj97o+avy9ilhA8Fdoxw= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D43E044480; Fri, 5 Apr 2024 20:57:27 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:20 +0200 Message-ID: <20240405185721.111072-10-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/11] 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: po9xGE+CNnJE 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 d3d7d022ff6..508c4f7a697 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); + 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;// = ost->enc_ctx->codec->pix_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); + 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 Fri Apr 5 18:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47870 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1158134pzd; Fri, 5 Apr 2024 11:59:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKGzKwYv1O0mKaN0UU9qIX7ZNXU0V5NvegIVIsBjYNcrzw18V4NppsDC5nHe261W6A/xgoun/MAAu9/QRWJuUx+Jl6rIlVId6ENg== X-Google-Smtp-Source: AGHT+IENBJDVtiR7kp78YKXYoYkTikZofkHtn6oDjqlANmYtRluZt/pSjxRzqlWN/zd3bIIHhM0o X-Received: by 2002:a17:906:3941:b0:a51:99ec:7062 with SMTP id g1-20020a170906394100b00a5199ec7062mr1595315eje.66.1712343543757; Fri, 05 Apr 2024 11:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712343543; cv=none; d=google.com; s=arc-20160816; b=kTNYRQvEq8WTKLODovk2hzlLTQyW6GHXVg4wifaMgC0PZqfw/nBVXDwOnzGpmk0boF tIXQhbsG2A29UT5Z+P1w9nTo2AdUeCa/JDB9hPZ7RivCYi8YGQ1NTpUD4Cwtl3xQIsn9 T1LeMkM5SrjZCMczUTVntCm2srICL4HBlguvCKqsJxMeM5OjXIQF4fPr6T4wr9DcF3hv h/5YH39T6+eDainPBh9zLJhNZjJNiFHOBaTaO+237tTu3/f9eD0XdFKQr98atMHh+075 maO46JRCpuXXMRbiJufudKfhdIWrNlc+IJGJzA0AnnvBlBRwbkNRcfxW1fQpyoH0qVXI iZFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=mvSXo3Ys566MteFqoio2tNpzSOelN1HMpt1GLiP1WYI=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=Tqw9AVQxpiToorss0kX5e4AGaLHo9Cr74RwAhgaxlnfA6zX+nGNjfbE2yYKkfNIfll hFGULBk8H5X17Qy0WL4afdPHW21hdVx/b2qT1eQu++RKzHqv8t8Sj9qPrs9lQNizG0oX 1qLdzVKavNEG+O5nXXj/FxX6My9dkVBG09UNMJoPEFd5Q7Q8Cevr0DbNparYnps/CLVO HgRV+VQ3vUGCV+pUPHCjA4YoHkackWfrT/sw9kkn1HQ7VdjqqTrrVaETmB6G1MkT/JSg kJZlc8canPAN0UJruBsjNMldNK80SKXOjOLyw2Gn4+KSA/NdERGtArsUmaokPQ3AuNZ+ aUSQ==; 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=IMP7TZkv; 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 x25-20020a170906135900b00a5198910903si939059ejb.70.2024.04.05.11.59.03; Fri, 05 Apr 2024 11:59:03 -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=IMP7TZkv; 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 B138568D21C; Fri, 5 Apr 2024 21:57:43 +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 C24FF68D1BE for ; Fri, 5 Apr 2024 21:57:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712343448; bh=dgJQEa04pg2CvYhLE0BQRCInKpO4jyjM4IV61Tcck84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMP7TZkvcoicYbzjehMy79jOIGfDFPPglRQGMZAspAT4VaLBWO3C9edp0tAEiJgJF 3ghe2Ta9eA4I/SeMOB09ZAbrF2IkZW7pqPO3VmbK17859XSBrG88UziSjb54JFFO2f dcrtXWjubNQuJhrcvwXwIW5PRxYh/eCecvuiDvKs= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 159F7444D6; Fri, 5 Apr 2024 20:57:28 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 20:57:21 +0200 Message-ID: <20240405185721.111072-11-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405185721.111072-1-ffmpeg@haasn.xyz> References: <20240405185721.111072-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/11] 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2Wn5hUq4tUUm From: Niklas Haas I preserved the no-op condition on `!ch_layouts`, even though I suspect it's not actually needed. --- fftools/ffmpeg_filter.c | 59 ++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ac04841a16c..e617b9da289 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -724,7 +724,7 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec) static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) { - const AVCodec *c = ost->enc_ctx->codec; + const AVChannelLayout *ch_layouts; int i, err; if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { @@ -735,8 +735,14 @@ static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) return 0; } + err = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &ch_layouts); + if (err < 0) + return err; + /* Requested layout is of order UNSPEC */ - if (!c->ch_layouts) { + if (!ch_layouts) { /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); @@ -744,13 +750,13 @@ static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) } /* Encoder has a list of supported layouts. Pick the first layout in it with the same amount of channels as the requested layout */ - for (i = 0; c->ch_layouts[i].nb_channels; i++) { - if (c->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) + for (i = 0; ch_layouts[i].nb_channels; i++) { + if (ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) break; } - if (c->ch_layouts[i].nb_channels) { + if (ch_layouts[i].nb_channels) { /* Use it if one is found */ - err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]); + err = av_channel_layout_copy(&f->ch_layout, &ch_layouts[i]); if (err < 0) return err; return 0; @@ -787,7 +793,11 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { ofp->format = ost->enc_ctx->pix_fmt; } else { - ofp->formats = c->pix_fmts; + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void **) &ofp->formats); + if (ret < 0) + return ret; // MJPEG encoder exports a full list of supported pixel formats, // but the full-range ones are experimental-only. @@ -822,8 +832,16 @@ 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 ? - NULL : c->supported_framerates; + + if (ost->force_fps) { + ofp->fps.framerate_supported = NULL; + } else { + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_FRAME_RATE, 0, + (const void **) &ofp->fps.framerate_supported); + if (ret < 0) + return ret; + } // reduce frame rate for mpeg4 to be within the spec limits if (c->id == AV_CODEC_ID_MPEG4) @@ -836,19 +854,34 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { ofp->format = ost->enc_ctx->sample_fmt; } else { - ofp->formats = c->sample_fmts; + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **) &ofp->formats); + if (ret < 0) + return ret; } if (ost->enc_ctx->sample_rate) { ofp->sample_rate = ost->enc_ctx->sample_rate; } else { - ofp->sample_rates = c->supported_samplerates; + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **) &ofp->sample_rates); + if (ret < 0) + return ret; } if (ost->enc_ctx->ch_layout.nb_channels) { int ret = set_channel_layout(ofp, ost); if (ret < 0) return ret; - } else if (c->ch_layouts) { - ofp->ch_layouts = c->ch_layouts; + } else { + const AVChannelLayout *ch_layouts; + ret = avcodec_get_supported_config(ost->enc_ctx, NULL, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &ch_layouts); + if (ret < 0) + return ret; + if (ch_layouts) + ofp->ch_layouts = ch_layouts; } break; }