From patchwork Sun Feb 7 21:06:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 25488 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E41D344A84D for ; Sun, 7 Feb 2021 23:06:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C003268836F; Sun, 7 Feb 2021 23:06:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EC79768834D for ; Sun, 7 Feb 2021 23:06:44 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 934ADE4E9D; Sun, 7 Feb 2021 22:06:44 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2LuqNlkc9dKZ; Sun, 7 Feb 2021 22:06:42 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A87EBE4B09; Sun, 7 Feb 2021 22:06:42 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Feb 2021 22:06:32 +0100 Message-Id: <20210207210634.16494-2-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210207210634.16494-1-cus@passwd.hu> References: <20210207210634.16494-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] fftools/ffplay: use context AVPacket in decoder_decode_frame() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- fftools/ffplay.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 70d8548a64..0054fec076 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -589,8 +589,6 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { int ret = AVERROR(EAGAIN); for (;;) { - AVPacket pkt; - if (d->queue->serial == d->pkt_serial) { do { if (d->queue->abort_request) @@ -636,11 +634,10 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { if (d->queue->nb_packets == 0) SDL_CondSignal(d->empty_queue_cond); if (d->packet_pending) { - av_packet_move_ref(&pkt, &d->pkt); d->packet_pending = 0; } else { int old_serial = d->pkt_serial; - if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0) + if (packet_queue_get(d->queue, &d->pkt, 1, &d->pkt_serial) < 0) return -1; if (old_serial != d->pkt_serial) { avcodec_flush_buffers(d->avctx); @@ -651,30 +648,30 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { } if (d->queue->serial == d->pkt_serial) break; - av_packet_unref(&pkt); + av_packet_unref(&d->pkt); } while (1); { if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { int got_frame = 0; - ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, &pkt); + ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, &d->pkt); if (ret < 0) { ret = AVERROR(EAGAIN); } else { - if (got_frame && !pkt.data) { + if (got_frame && !d->pkt.data) { d->packet_pending = 1; - av_packet_move_ref(&d->pkt, &pkt); } - ret = got_frame ? 0 : (pkt.data ? AVERROR(EAGAIN) : AVERROR_EOF); + ret = got_frame ? 0 : (d->pkt.data ? AVERROR(EAGAIN) : AVERROR_EOF); } + av_packet_unref(&d->pkt); } else { - if (avcodec_send_packet(d->avctx, &pkt) == AVERROR(EAGAIN)) { + if (avcodec_send_packet(d->avctx, &d->pkt) == AVERROR(EAGAIN)) { av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n"); d->packet_pending = 1; - av_packet_move_ref(&d->pkt, &pkt); + } else { + av_packet_unref(&d->pkt); } } - av_packet_unref(&pkt); } } }