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),