From patchwork Tue May 23 13:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41802 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp601179pzb; Tue, 23 May 2023 07:00:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+adzltHlaecL5adKzgX9KBE6n3L+RroW+5SGgxSTCKILqwLkzhNpvUehZ2EBLsHIaaoke X-Received: by 2002:a17:907:7b9e:b0:96f:b58e:7e21 with SMTP id ne30-20020a1709077b9e00b0096fb58e7e21mr11233025ejc.52.1684850439521; Tue, 23 May 2023 07:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850439; cv=none; d=google.com; s=arc-20160816; b=B2KhKIbkkZUDE1Wq1vNYmidkoevLWkvxztGygU7g6zLH8M6cOnYE81WP4LUwPgvkS1 0q9P/hWvR49FsIVXdraYQ3kCVT+dW7aAuCsUsr6J0o2j7SrvkCXKCfcvplv8ZCRU2xq5 MF+9I322FboniPYZE+Vdd4oyQWOQe3Kjx6woMdOUT6kjp71eQL7DGMJoLyZJgUhy2+HC 0MxPI9JdiFJ61oPXZlQGsgll3rHaoXipKVYrxA2SMCyXu7Z4yjwpzBB6t08tbxBzc+Vu ljc1fY9rhPpP3s24IN7RXV1fEbH10bzjodl5v4k7NNxDNNJ5YT2jCu7vIZVydzvHQlAY Wg1w== 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=fzgvc28s/T+o1chJxIF52vnmvAX9V699M9u7gAc8eZw=; b=YQE+VWdDqBz3CPFARS5ksuCd9dNqzTKAvlZ0dsuFOLfeB3crPDJf8bcoAfF6IAj0Q9 JG+FcokjzyAX7ov5AR4QzMmfxcXp3Blgo5oR4XUuQ8QJhSVqHtrTbrXNI9gOIbXQoWPw Z8yhKFqXNcupZdVqCyWLUyDcyqT37F1DFVq8t+nJSSYb9RJT95Tk3z/0MrG5hteRMbfp x2cy5MLRoFxbIk7XzNrJ5UweZldMwaybyFtsPR1W7jz6wPCG0geMZdjIJRIIhrUYY6lu 0YnWaTRLDrLvZ0O82LvEDB7swT7jjxlPKc5DhgnzhawQAaqYOTvGpvONWosGdW0VAU1n YgXw== 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 dc9-20020a170906c7c900b00966448e2cefsi1491987ejb.395.2023.05.23.07.00.39; Tue, 23 May 2023 07:00:39 -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 D5E2468C110; Tue, 23 May 2023 16:59:13 +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 05A3C68C11A for ; Tue, 23 May 2023 16:59:03 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BFF9A2405B5 for ; Tue, 23 May 2023 15:58:59 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id G5SLcABM4q6s for ; Tue, 23 May 2023 15:58:59 +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 963B62406CA for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 87BD43A11B4 for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 May 2023 15:58:37 +0200 Message-Id: <20230523135842.20388-10-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523135842.20388-1-anton@khirnov.net> References: <20230523135842.20388-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/15] fftools/ffmpeg_dec: move InputStream.pkt to Decoder 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: lD4i3cWU33ED It is purely internal to decoding. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_dec.c | 8 +++++++- fftools/ffmpeg_demux.c | 5 ----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 92e56ee80c..b377871980 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -349,7 +349,6 @@ typedef struct InputStream { AVCodecContext *dec_ctx; const AVCodec *dec; const AVCodecDescriptor *codec_desc; - AVPacket *pkt; AVRational framerate_guessed; diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index f4531684d5..23c50cc272 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -33,6 +33,7 @@ struct Decoder { AVFrame *frame; + AVPacket *pkt; }; void dec_free(Decoder **pdec) @@ -43,6 +44,7 @@ void dec_free(Decoder **pdec) return; av_frame_free(&dec->frame); + av_packet_free(&dec->pkt); av_freep(pdec); } @@ -61,6 +63,10 @@ static int dec_alloc(Decoder **pdec) if (!dec->frame) goto fail; + dec->pkt = av_packet_alloc(); + if (!dec->pkt) + goto fail; + *pdec = dec; @@ -418,7 +424,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof) int ret; if (dec->codec_type == AVMEDIA_TYPE_SUBTITLE) - return transcode_subtitles(ist, pkt ? pkt : ist->pkt); + return transcode_subtitles(ist, pkt ? pkt : d->pkt); // With fate-indeo3-2, we're getting 0-sized packets before EOF for some // reason. This seems like a semi-critical bug. Don't trigger EOF, and diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 29691cf68b..c65c72f556 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -817,7 +817,6 @@ static void ist_free(InputStream **pist) dec_free(&ist->decoder); - av_packet_free(&ist->pkt); av_dict_free(&ist->decoder_opts); avsubtitle_free(&ist->prev_sub.subtitle); av_frame_free(&ist->sub2video.frame); @@ -1197,10 +1196,6 @@ static void add_input_streams(const OptionsContext *o, Demuxer *d) exit_program(1); } - ist->pkt = av_packet_alloc(); - if (!ist->pkt) - report_and_exit(AVERROR(ENOMEM)); - if (o->bitexact) ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;