From patchwork Sun Nov 27 17:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39493 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6959157pzb; Sun, 27 Nov 2022 09:06:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cniSRAyRG2BKvQlyQEKtsbtGfa2ZkvjE/rnElHqTy2F/qJF3kzu9V5GV0ZPU85K6veSsQ X-Received: by 2002:a05:6402:3644:b0:45f:c7f2:297d with SMTP id em4-20020a056402364400b0045fc7f2297dmr45067920edb.266.1669568773730; Sun, 27 Nov 2022 09:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568773; cv=none; d=google.com; s=arc-20160816; b=eFveP2AH4dq9A42k9Y1TA9vncFR+4CCwxCTsmTZ0GPwZI/7DxWvBFyrct7Hn1Av3Wa /a50dz7oLvfE2uLb6U8LnC5XHtPt1J/KDiAbEzyPMwP/aJOALZ9DAeDbiMKtnShINtgW E8ut53+mNs0DMok2k0MMUBIYIYYlCPEYjXmQyoV27PJ+0gPCndX8/yVClE9oWqssUjWg 5Zz+wJFWbetu9hdKJ1Pz2QyFxMVVKc4e+J+uRjp8KYiRv+Q6+mEl6XRQqCHzakkhz8bK PQDfR4wMz4YcZwZuDIt9jxhza4cp8AJ73F1yoZf6WO8VtIeG2WvNa420jH4zVOlV29mx rfpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:delivered-to; bh=++xfF4WMcZqpnLPDgAN7H6B9hrowiYSO5NKm46d3Y7s=; b=m5CM+lrjv2Ru2h2E67hSPXfMOJZwzzU5igvIeXh/+NO7pJKis0qgE6h8m388NZCZAT uaqhqSuhBn8j24L424jTbom8L1cP+rQnjy63J9tq3m5pbxhyNairAgf5IU6+N0xBCNJU lGZJnBO4kY7aLYl68zy6kzBG1uhSNK2UgjY9JntqRHvZTAmn0oXIwoK2L2C8AP6LovKg /pcP+z6r2QzCUgJHqy+ItvnXYzHagpNXEhJchvYt6omyZY3Cvh/WfwAGgToeVzD2Bc2L 5yVeUKnYpCW1Mk6GG5TZM+oLpCNtsvx4K55TwPTYVBL9OjK+eCO0a6cgBw/2Ulx2vf3c XAgA== 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 ESMTP id xe14-20020a170907318e00b00781df60a2c8si8556906ejb.342.2022.11.27.09.06.13; Sun, 27 Nov 2022 09:06:13 -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 58EF868B0A7; Sun, 27 Nov 2022 19:06:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 48B9068AE59 for ; Sun, 27 Nov 2022 19:05:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 059622400F5 for ; Sun, 27 Nov 2022 18:05:53 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yb9agdCkUbi1 for ; Sun, 27 Nov 2022 18:05:52 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 621AF2404F7 for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DEF7B3A1A3B for ; Sun, 27 Nov 2022 18:05:45 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:24 +0100 Message-Id: <20221127170351.11477-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/30] lavc/libx264: use a local variable for input frame in setup_frame() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: wwK+Ne0XeWgz --- libavcodec/libx264.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 36c36d0e09..8f03eecabf 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -337,7 +337,8 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, x264_picture_t **ppic) { X264Context *x4 = ctx->priv_data; - x264_sei_t *sei = &x4->pic.extra_sei; + x264_picture_t *pic = &x4->pic; + x264_sei_t *sei = &pic->extra_sei; unsigned int sei_data_size = 0; int64_t wallclock = 0; int bit_depth, ret; @@ -347,45 +348,44 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, if (!frame) return 0; - x264_picture_init( &x4->pic ); - x4->pic.img.i_csp = x4->params.i_csp; + 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) - x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH; - x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); + pic->img.i_csp |= X264_CSP_HIGH_DEPTH; + pic->img.i_plane = avfmt2_num_planes(ctx->pix_fmt); - for (int i = 0; i < x4->pic.img.i_plane; i++) { - x4->pic.img.plane[i] = frame->data[i]; - x4->pic.img.i_stride[i] = frame->linesize[i]; + for (int i = 0; i < pic->img.i_plane; i++) { + pic->img.plane[i] = frame->data[i]; + pic->img.i_stride[i] = frame->linesize[i]; } - x4->pic.i_pts = frame->pts; + pic->i_pts = frame->pts; x4->reordered_opaque[x4->next_reordered_opaque].reordered_opaque = frame->reordered_opaque; x4->reordered_opaque[x4->next_reordered_opaque].wallclock = wallclock; if (ctx->export_side_data & AV_CODEC_EXPORT_DATA_PRFT) x4->reordered_opaque[x4->next_reordered_opaque].wallclock = av_gettime(); - x4->pic.opaque = &x4->reordered_opaque[x4->next_reordered_opaque]; + pic->opaque = &x4->reordered_opaque[x4->next_reordered_opaque]; x4->next_reordered_opaque++; x4->next_reordered_opaque %= x4->nb_reordered_opaque; switch (frame->pict_type) { case AV_PICTURE_TYPE_I: - x4->pic.i_type = x4->forced_idr > 0 ? X264_TYPE_IDR - : X264_TYPE_KEYFRAME; + pic->i_type = x4->forced_idr > 0 ? X264_TYPE_IDR : X264_TYPE_KEYFRAME; break; case AV_PICTURE_TYPE_P: - x4->pic.i_type = X264_TYPE_P; + pic->i_type = X264_TYPE_P; break; case AV_PICTURE_TYPE_B: - x4->pic.i_type = X264_TYPE_B; + pic->i_type = X264_TYPE_B; break; default: - x4->pic.i_type = X264_TYPE_AUTO; + pic->i_type = X264_TYPE_AUTO; break; } reconfig_encoder(ctx, frame); @@ -398,17 +398,17 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); } else if (sei_data) { - x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0])); - if (x4->pic.extra_sei.payloads == NULL) { + pic->extra_sei.payloads = av_mallocz(sizeof(pic->extra_sei.payloads[0])); + if (pic->extra_sei.payloads == NULL) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); av_free(sei_data); } else { - x4->pic.extra_sei.sei_free = av_free; + pic->extra_sei.sei_free = av_free; - x4->pic.extra_sei.payloads[0].payload_size = sei_size; - x4->pic.extra_sei.payloads[0].payload = sei_data; - x4->pic.extra_sei.num_payloads = 1; - x4->pic.extra_sei.payloads[0].payload_type = 4; + pic->extra_sei.payloads[0].payload_size = sei_size; + pic->extra_sei.payloads[0].payload = sei_data; + pic->extra_sei.num_payloads = 1; + pic->extra_sei.payloads[0].payload_type = 4; } } } @@ -473,8 +473,8 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, } } - x4->pic.prop.quant_offsets = qoffsets; - x4->pic.prop.quant_offsets_free = av_free; + pic->prop.quant_offsets = qoffsets; + pic->prop.quant_offsets_free = av_free; } else { if (!x4->roi_warned) { x4->roi_warned = 1; @@ -510,7 +510,7 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, } } - *ppic = &x4->pic; + *ppic = pic; return 0; }