From patchwork Tue Apr 9 13:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47984 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9c8d:b0:1a7:a0dc:8de5 with SMTP id mj13csp342147pzb; Tue, 9 Apr 2024 06:12:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUUCW2fnqPBEVUZm2tqNfwa8bkmJ+bWSdBnqFmFSQNDSU9gcEgwAcLPTAg+23tORK10tZpL+iAaV6TTgADPxvMvuvR4L/EF+fJTdA== X-Google-Smtp-Source: AGHT+IF3EgT62Zpme2SCz+CX1fAFQm3v94HlnbT2agzrF06BB+6tTP/fKPcW+i6rbdy0VFIZJ0Pg X-Received: by 2002:a17:907:bd3:b0:a52:ec:af12 with SMTP id ez19-20020a1709070bd300b00a5200ecaf12mr480252ejc.3.1712668339355; Tue, 09 Apr 2024 06:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712668339; cv=none; d=google.com; s=arc-20160816; b=KGI9Qil2lm8Pnyyz/pqbZeygdKXuprMp5xCnSybT8awHGuJ8giuNSKOQ9MeiT6v/iV Mz+Fs0cEw4D+vme4kKlcS0tiX+kqu3ABE+i8t1WhTzj40I6dd2yP27EwwUKKqrw1S/jx Wo3tX22hIm3N4H01yJF2y7FRWOwGu9gZP3uLKrnnTgDtkqZ+bfx7HUkFHzdWJP19g9qL HE70mzHAT6Rv8TyEYY7+DFXa1PFh+DcjgCUm3rMkjWv/v1lQjYvac3yjKto3ZMKK0a02 voVMyz+/KVdm6zJl0gSgFYs+kPlP9xuybunKicqV8Ap9ORghVxjnfOyUBj0nifkZiYiK lc7Q== 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=CtaQQV5tA9owefOv5PdVFZjcUVGkibha7JOjCQal0aw=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=BwB9M4PiTWTBoQWicVEH03K/6iyv9X2oji4l1EQhCIhDOiwoMsOcBN0Hr/9Cuj+/9k POfMIPAJRFBYrn42dpXPznmSO2j7RRmr0Bp2oeHmyT2w+uN3AMNiIX6Bh9u80gRJinTD WgAfIZVFhYgJGAEnAPb/31KNJfyhoo83ba5Zi8F9kh9ARzd7y+/a+2OSz85gYC8yeObc 8qPEqmJWj0lwcLCDA+PY+dBu+RYnB2KvHitJKmqmUPILnvnks/ksQ4b3sNruwxI6Htee 0oQD1IMwo6vewqz0yhANXCbdnH6StpoTaflSh6TYXmbdcOOYisGatgVEANJu1eDjI9es buBg==; 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=ddAh9Abd; 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 m4-20020a1709066d0400b00a47363fb3ffsi4698855ejr.346.2024.04.09.06.12.19; Tue, 09 Apr 2024 06:12:19 -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=ddAh9Abd; 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 07D9F68D0B1; Tue, 9 Apr 2024 16:12:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E71668C7C2 for ; Tue, 9 Apr 2024 16:12:10 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712668329; bh=SAqk9kHhG2N4IVGCRJuT/xIISA9b72AM/7ETUFQgXjM=; h=From:To:Cc:Subject:Date:From; b=ddAh9AbdzQsGUFW5jZ0t11dV54MGzUAaJaWlsAe/w+ErNkXx4oZQ2RTzRfkHhE3gB NYv1HLFlUmgucXrpH+ncDaoCl8XGO5i6+5S6RShcLQwFvApEoNn5lYMBZH4l2KOd0l QYHg8kkKe2NxtGzqLvMuIejMnsFJ8q4q2EvWiNnk= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id BF39540006; Tue, 9 Apr 2024 15:12:09 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Apr 2024 15:12:05 +0200 Message-ID: <20240409131205.57457-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/libx264: bump minimum required version to 155 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: nG4ghDxGcqcI From: Niklas Haas This version is seven years old, and present in Debian oldoldstable, Ubuntu 20.04 and Leap 15.0. Allows cleaning up the file substantially. In particular, this is motivated by the desire to stop relying on init_static_data. --- configure | 2 +- libavcodec/libx264.c | 52 ++++++-------------------------------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/configure b/configure index f511fbae492..248ce2040d6 100755 --- a/configure +++ b/configure @@ -7007,7 +7007,7 @@ enabled libwebp && { enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; } enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && - require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { + require_cpp_condition libx264 x264.h "X264_BUILD >= 155" && { [ "$toolchain" != "msvc" ] || require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && check_cpp_condition libx264_hdr10 x264.h "X264_BUILD >= 163" && diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index eadb20d2b39..2715f277f1f 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -270,11 +270,9 @@ static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame) case AV_STEREO3D_FRAMESEQUENCE: fpa_type = 5; break; -#if X264_BUILD >= 145 case AV_STEREO3D_2D: fpa_type = 6; break; -#endif default: fpa_type = -1; break; @@ -394,14 +392,14 @@ static int setup_mb_info(AVCodecContext *ctx, x264_picture_t *pic, return 0; } -static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth, +static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, const AVFrame *frame, const uint8_t *data, size_t size) { X264Context *x4 = ctx->priv_data; int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE; int mby = (frame->height + MB_SIZE - 1) / MB_SIZE; - int qp_range = 51 + 6 * (bit_depth - 8); + int qp_range = 51 + 6 * (x4->params.i_bitdepth - 8); int nb_rois; const AVRegionOfInterest *roi; uint32_t roi_size; @@ -476,7 +474,7 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, x264_sei_t *sei = &pic->extra_sei; unsigned int sei_data_size = 0; int64_t wallclock = 0; - int bit_depth, ret; + int ret; AVFrameSideData *sd; AVFrameSideData *mbinfo_sd; @@ -486,12 +484,7 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, x264_picture_init(pic); pic->img.i_csp = x4->params.i_csp; -#if X264_BUILD >= 153 - bit_depth = x4->params.i_bitdepth; -#else - bit_depth = x264_bit_depth; -#endif - if (bit_depth > 8) + if (x4->params.i_bitdepth > 8) pic->img.i_csp |= X264_CSP_HIGH_DEPTH; pic->img.i_plane = av_pix_fmt_count_planes(ctx->pix_fmt); @@ -564,7 +557,7 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { - ret = setup_roi(ctx, pic, bit_depth, frame, sd->data, sd->size); + ret = setup_roi(ctx, pic, frame, sd->data, sd->size); if (ret < 0) goto fail; } @@ -1109,9 +1102,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt); -#if X264_BUILD >= 153 x4->params.i_bitdepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth; -#endif PARSE_X264_OPT("weightp", wpredp); @@ -1180,11 +1171,10 @@ static av_cold int X264_init(AVCodecContext *avctx) else if (x4->params.i_level_idc > 0) { int i; int mbn = AV_CEIL_RSHIFT(avctx->width, 4) * AV_CEIL_RSHIFT(avctx->height, 4); - int scale = X264_BUILD < 129 ? 384 : 1; for (i = 0; iparams.i_level_idc) - x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn / scale, 1, x4->params.i_frame_reference); + x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn, 1, x4->params.i_frame_reference); } if (avctx->trellis >= 0) @@ -1228,12 +1218,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.b_vfr_input = 0; } if (x4->avcintra_class >= 0) -#if X264_BUILD >= 142 x4->params.i_avcintra_class = x4->avcintra_class; -#else - av_log(avctx, AV_LOG_ERROR, - "x264 too old for AVC Intra, at least version 142 needed\n"); -#endif if (x4->avcintra_class > 200) { #if X264_BUILD < 164 @@ -1395,11 +1380,9 @@ FF_ENABLE_DEPRECATION_WARNINGS } } -#if X264_BUILD >= 142 /* Separate headers not supported in AVC-Intra mode */ if (x4->avcintra_class >= 0) x4->params.b_repeat_headers = 1; -#endif { AVDictionaryEntry *en = NULL; @@ -1513,18 +1496,6 @@ static const enum AVPixelFormat pix_fmts_8bit_rgb[] = { }; #endif -#if X264_BUILD < 153 -static av_cold void X264_init_static(FFCodec *codec) -{ - if (x264_bit_depth == 8) - codec->p.pix_fmts = pix_fmts_8bit; - else if (x264_bit_depth == 9) - codec->p.pix_fmts = pix_fmts_9bit; - else if (x264_bit_depth == 10) - codec->p.pix_fmts = pix_fmts_10bit; -} -#endif - #define OFFSET(x) offsetof(X264Context, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -1544,9 +1515,7 @@ static const AVOption options[] = { { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_NONE}, INT_MIN, INT_MAX, VE, .unit = "aq_mode" }, { "variance", "Variance AQ (complexity mask)", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, .unit = "aq_mode" }, { "autovariance", "Auto-variance AQ", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, .unit = "aq_mode" }, -#if X264_BUILD >= 144 { "autovariance-biased", "Auto-variance AQ with bias to dark scenes", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE_BIASED}, INT_MIN, INT_MAX, VE, .unit = "aq_mode" }, -#endif { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, VE}, { "psy", "Use psychovisual optimizations.", OFFSET(psy), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE }, { "psy-rd", "Strength of psychovisual optimization, in : format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING, {0 }, 0, 0, VE}, @@ -1644,10 +1613,7 @@ static const AVClass x264_class = { .version = LIBAVUTIL_VERSION_INT, }; -#if X264_BUILD >= 153 -const -#endif -FFCodec ff_libx264_encoder = { +const FFCodec ff_libx264_encoder = { .p.name = "libx264", CODEC_LONG_NAME("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, @@ -1665,11 +1631,7 @@ FFCodec ff_libx264_encoder = { .flush = X264_flush, .close = X264_close, .defaults = x264_defaults, -#if X264_BUILD < 153 - .init_static_data = X264_init_static, -#else .p.pix_fmts = pix_fmts_all, -#endif .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS #if X264_BUILD < 158 | FF_CODEC_CAP_NOT_INIT_THREADSAFE