From patchwork Mon Apr 11 08:39:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35252 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp936136pzh; Mon, 11 Apr 2022 02:00:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySy2yaW6P/pAtaPnwBLzxGmH58cxsHdRJVBPY3zfuap1XRXBWV5ISEke9SZw5Sh5kUNWGn X-Received: by 2002:a17:907:6e04:b0:6e0:95c0:47b8 with SMTP id sd4-20020a1709076e0400b006e095c047b8mr29112432ejc.483.1649667658757; Mon, 11 Apr 2022 02:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649667658; cv=none; d=google.com; s=arc-20160816; b=t6UzqpB4XfRGjAIYUUcvzVOrTdgsSxC2tuny5vGon4PZ+sZmPUmzqDyn7Atc6K7WBw aUqpJhvEJMnr3nxmPrIT8BWUD8LDhhKPCr9e1BPCTGehxNsttH9Oz7gAbj9762uhIq+t QEdgDrkFw1sc94OGegvbSPrswKSHJChF/HJtYKDI2ZkT4Gn1dkEPEQcwSaPs4ZdgVO19 hYhesB+lqyf1leNZdHWLWS7qMAwxpFCmwzfpB6y+5smWOSpBbdXgDlWrV60L/ztOPgLU ceJWYs/R3J4H2YUDgQElVrUU7C696ufGTvrVyU7ITDPkFKuJ7Xz3rkUweHOt/DQg+1sA YoOw== 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=LgIXDDbJzk/rmWXM5d4yxuku18xe45HjeAC3TaUEc2U=; b=e3wdn1kPUxfRU7hplkmPWG75vso4t1BVFj7Yps5gYqLBklofB6CiwO7jU5/oxtG75e SierSQeSSg4ZdpxAB+56qhYNs+ThFyk5t9QsvqoOmCjfYsYlgfTOZtz9EIZjfgjiTgaK WoZgBasc4Yb6oX/vsmJWXpL6ahu141UtokOLJODNDtE1AJbzxB0ZFsmfshWFm+KPOkb0 K5kELbM4bSyEYBoZZ6cAU91FHRdeHt1yfF38t/ryKPb0/1nSQk6srUrnpwwvD/k1UsVH EjqIzoHLF+scJ3qrsQCDGQh4ypr3Zyfa7Ktl8/3W9JHqSHAUVXYX2MDLsd1li4JYjnKM Y6Ug== 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 ne23-20020a1709077b9700b006e1479aec80si7425444ejc.843.2022.04.11.02.00.58; Mon, 11 Apr 2022 02:00:58 -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; 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 5A6D768B3A1; Mon, 11 Apr 2022 12:00:56 +0300 (EEST) 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 3211368B324 for ; Mon, 11 Apr 2022 12:00:50 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D863B240179 for ; Mon, 11 Apr 2022 11:00:49 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id GwszA0o4mipe for ; Mon, 11 Apr 2022 11:00:49 +0200 (CEST) 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 3A2D62400F5 for ; Mon, 11 Apr 2022 11:00:49 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id CCD033A0406; Mon, 11 Apr 2022 10:39:15 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Apr 2022 10:39:08 +0200 Message-Id: <20220411083908.28802-1-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <367f4d8c-5a36-af62-b4de-f2b0f69458d0@gmail.com> References: <367f4d8c-5a36-af62-b4de-f2b0f69458d0@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/encode: drop EncodeSimpleContext 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: o7PKOi/miYOp It has only a single member. --- libavcodec/avcodec.c | 4 ++-- libavcodec/encode.c | 7 +++---- libavcodec/internal.h | 12 +++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index c7daa385e7..e0f38ac42a 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -432,7 +432,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0) av_packet_unref(avci->last_pkt_props); - av_frame_unref(avci->es.in_frame); + av_frame_unref(avci->in_frame); av_packet_unref(avci->in_pkt); if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) @@ -498,7 +498,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_packet_free(&avci->last_pkt_props); av_packet_free(&avci->in_pkt); - av_frame_free(&avci->es.in_frame); + av_frame_free(&avci->in_frame); av_buffer_unref(&avci->pool); diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 837ffaa40d..8b0d4443cd 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -175,8 +175,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; - EncodeSimpleContext *es = &avci->es; - AVFrame *frame = es->in_frame; + AVFrame *frame = avci->in_frame; const FFCodec *const codec = ffcodec(avctx->codec); int got_packet; int ret; @@ -565,8 +564,8 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY; if (ffcodec(avctx->codec)->encode2) { - avci->es.in_frame = av_frame_alloc(); - if (!avci->es.in_frame) + avci->in_frame = av_frame_alloc(); + if (!avci->in_frame) return AVERROR(ENOMEM); } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index f9d08fcb60..2fa56d3a59 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -47,10 +47,6 @@ # define STRIDE_ALIGN 8 #endif -typedef struct EncodeSimpleContext { - AVFrame *in_frame; -} EncodeSimpleContext; - typedef struct AVCodecInternal { /** * When using frame-threaded decoding, this field is set for the first @@ -101,7 +97,13 @@ typedef struct AVCodecInternal { void *frame_thread_encoder; - EncodeSimpleContext es; + /** + * The input frame is stored here for encoders implementing the simple + * encode API. + * + * Not allocated in other cases. + */ + AVFrame *in_frame; /** * If this is set, then FFCodec->close (if existing) needs to be called