From patchwork Fri Aug 30 10:15: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: 51244 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4027:b0:48e:c0f8:d0de with SMTP id ky39csp311380vqb; Fri, 30 Aug 2024 03:50:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+Yiuui+U9uOFIe4nSzAFonUbjb5vU2AmTWY9mZ7Lupn8iRPqHRmN1pVNUOvm43/nWwuITlQm/wcAh9SCntU2l@gmail.com X-Google-Smtp-Source: AGHT+IGPNdojG6w7mjSObqJVEjhVpNuafH14jwuYmo97F1DOqVN5dXsWVtIMNFwYjD21TyAA+XK8 X-Received: by 2002:a05:651c:b24:b0:2f0:25dc:186d with SMTP id 38308e7fff4ca-2f6105b5d76mr44545231fa.1.1725015023362; Fri, 30 Aug 2024 03:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725015023; cv=none; d=google.com; s=arc-20240605; b=ZMDf2pCVA3HuxNLEKCTXW7kOu5EaDYvBrRjnvZINb+oNEL4oGU26PUcd71bOHo3tRB yee+MtkREJnkx+lVg+ol2kJXq5bQwhgK67VfPdzAgen5uRrzgLZVP07xwCYzKvvKjmKP alo44hvXYNEt/v8M763R3bymo9brh61sBKza4PJeyheQnYRhR3eDCPM58zYKVZobNsb+ yX2F3E1HFUlL71kEwNfTKPuHo2E8My+Ca7ZzeugT4H2ObQBiv7ihMz9lxroEabXaavro gi3elrUBX6vzEdkOwm0mhLc9g8cIzp+tx5KSMNc+P8DyOaxvR6AssTQNCPPJ+iw8mfbt lEvg== 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=DnNg3Xu1BNpLaI1BlmoUq0EDGdw2NZ+jp6H5XARYw/WEIV1paf71y1hpXQ5Bb57+9s QR5cHrkL+XaU3Z966q42owRBbQ+uK9RLnbiwcgdGaU2AoNZQGFD9IUh6OExQKFYxTGDZ LF7mJ0LChgkJ+WSHd2haSNotj6s6444bsR/PMWjk4RbOevvI8rIPK7A/WYy3bdR+z4Dt VWRSGfPW54Yjxzp0zOCFphAxXawCuA5dHm7x15ngZq0b3Hgyvyi3t1wjhXc6UK5Lt1+X C3w/ZtdBQkGhKEW3mLN2Fj8IB3CCEdsilc4SqA1qKubs6BvK2tAls34EbJfjTNObhHZp zKng==; 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=iIwPC1XE; 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-2f615161e8bsi11332811fa.356.2024.08.30.03.50.22; Fri, 30 Aug 2024 03:50:23 -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=iIwPC1XE; 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 8198A68DC85; Fri, 30 Aug 2024 13:24: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 BF5C368DBCC for ; Fri, 30 Aug 2024 13:24:13 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1725013449; bh=0Yn+CoQlaFDsoLQCU1ZdoBLFxe5IrBwVxLwJY6QD670=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iIwPC1XE7nPeYHVEtuRngz7p9pETcmPVVmjG9mGOS83w3kxGvNekvWvUuLNXAlbTc +RbZXcpqALwCOQZC9YIaHu6P0bbKL24Hc//+B6E18theU0T67hOcC86Rmcdu8DEZZM LR1rw8D06ozrJs9YNQLaBqBWyvzgpfsyv7vRnQxI= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 81D8C441F2; Fri, 30 Aug 2024 12:24:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Aug 2024 12:15:30 +0200 Message-ID: <20240830102402.18149-8-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240830102402.18149-1-ffmpeg@haasn.xyz> References: <20240830102402.18149-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: IzGNetWiBHqB 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, };