From patchwork Mon Nov 11 03:40:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 52673 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:650d:10b0:4a6:526f:395 with SMTP id ml13-n1csp37977vqb; Sun, 10 Nov 2024 19:41:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVEsKDzatF1EBfai7+JafJ3lhC/0n1SRN5ZVPnTnF3097PmmU5m0AeRmv7bZdZ13H+RjxsLgs+ja5ZylLdlQLdf@gmail.com X-Google-Smtp-Source: AGHT+IGg/sugSS7KYNPbqwlTUShZ7b9gXzgtPMDUl8GgKH6cDKGLSMbUdgFo6RYWqRXIk4xns8La X-Received: by 2002:a17:907:9492:b0:a9e:b0a3:db75 with SMTP id a640c23a62f3a-a9eeff44ac1mr948539166b.35.1731296484696; Sun, 10 Nov 2024 19:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731296484; cv=none; d=google.com; s=arc-20240605; b=ksNtZNahLiRiqTzuYoPQw87DhoPAXBUTto4dsoe2nHOo7eqQNWYIBdXRMGcSJGZ7oc PcWp8XtGEA8GtuFa1Uah7Mc4u56fKj+cg97j/n4s886Ef5c6sNvTpAd3jcFvGkLT1APu SzatfhxDPyXNdnpqOByuCLBSIStZDV4s1XYMSUBHh/mqglPNQ9Xi+klt23ifAba6rsOS LIrDXhUcAKyHMp+yTO//NKPWZxzziY2TKqS1FgUUpw9IuU7xHO65gz6EMgZTJeffDTkG +mqBCoZH6MrkjVC90aN7uKwzVsEVJ0g4xJj7twBaP3zCi3ySCfZsy3Th+GN8wym4mpyF N3bQ== 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:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=0Ko+9BFDcNqqrd0ruLlPzxlYSCBYGcPtFky0U4TJnrQ=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=WIfveKRWsiB+cUwkUyr7OCnNGJC+G0HVkWaNGKYRRJXpEjWaHPz0nRp6xfKckSPK1A fSNRv3EeI9nnypIenRZTVl7AO4pYexxQHqb8ey8vmX+4DbwG5IyGAJJXdKfFnfYwcH9Q dEY14BgxMvkJ4iuJUwh9v9viaKXfskUm2Gzkosull79rl5ymq8uFmrAXGwh/uwceBnPC tM8FjsTPuIBnXEIXp7EWOlDyymwigrh5VWvjjQQM42kYm73X76yI5Z9QicFVKEpxJ4Yw E9nimw8lcTdd6Kk4GiWj5oyDu8HXmjjpLJRs8XI6y8BMHMd4cCACLZKuArjg0izKj27l ehYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 ESMTPS id a640c23a62f3a-a9ee0e0f92bsi598377266b.669.2024.11.10.19.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 19:41:24 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 DE7E268DE64; Mon, 11 Nov 2024 05:40:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0286968DE1B for ; Mon, 11 Nov 2024 05:40:39 +0200 (EET) To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Nov 2024 04:40:16 +0100 Message-ID: <20241111034028.20487-4-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20241111034028.20487-1-dev@lynne.ee> References: <20241111034028.20487-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/6] ffv1enc: move plane info init into a separate function 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uu0GU7xhCsvv --- libavcodec/ffv1enc.c | 40 ++++++++++++++++++++++++---------------- libavcodec/ffv1enc.h | 2 ++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index ca2c9f32e2..a106e2130a 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -731,22 +731,14 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx) return 0; } -static int encode_init_internal(AVCodecContext *avctx) +av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, + enum AVPixelFormat pix_fmt) { - int ret; FFV1Context *s = avctx->priv_data; - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); - - if ((ret = ff_ffv1_common_init(avctx)) < 0) - return ret; - - if (s->ac == 1) // Compatbility with common command line usage - s->ac = AC_RANGE_CUSTOM_TAB; - else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE) - s->ac = AC_RANGE_DEFAULT_TAB; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); s->plane_count = 3; - switch(avctx->pix_fmt) { + switch(pix_fmt) { case AV_PIX_FMT_GRAY9: case AV_PIX_FMT_YUV444P9: case AV_PIX_FMT_YUV422P9: @@ -879,6 +871,26 @@ static int encode_init_internal(AVCodecContext *avctx) } av_assert0(s->bits_per_raw_sample >= 8); + return av_pix_fmt_get_chroma_sub_sample (avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); +} + +static int encode_init_internal(AVCodecContext *avctx) +{ + int ret; + FFV1Context *s = avctx->priv_data; + + if ((ret = ff_ffv1_common_init(avctx)) < 0) + return ret; + + if (s->ac == 1) // Compatbility with common command line usage + s->ac = AC_RANGE_CUSTOM_TAB; + else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE) + s->ac = AC_RANGE_DEFAULT_TAB; + + ret = ff_ffv1_encode_setup_plane_info(avctx, avctx->pix_fmt); + if (ret < 0) + return ret; + if (s->bits_per_raw_sample > 8) { if (s->ac == AC_GOLOMB_RICE) { av_log(avctx, AV_LOG_INFO, @@ -887,10 +899,6 @@ static int encode_init_internal(AVCodecContext *avctx) } } - ret = av_pix_fmt_get_chroma_sub_sample (avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); - if (ret) - return ret; - { int plane_count = 1 + 2*s->chroma_planes + s->transparency; int max_h_slices = AV_CEIL_RSHIFT(avctx->width , s->chroma_h_shift); diff --git a/libavcodec/ffv1enc.h b/libavcodec/ffv1enc.h index c062af0bf5..f7b2e6cdbf 100644 --- a/libavcodec/ffv1enc.h +++ b/libavcodec/ffv1enc.h @@ -26,5 +26,7 @@ #include "avcodec.h" av_cold int ff_ffv1_encode_init(AVCodecContext *avctx); +av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, + enum AVPixelFormat pix_fmt); #endif /* AVCODEC_FFV1ENC_H */