From patchwork Sat Aug 24 18:18:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14694 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 EA19E44918A for ; Sat, 24 Aug 2019 21:26:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DB31068ABDA; Sat, 24 Aug 2019 21:26:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F5C66808AE for ; Sat, 24 Aug 2019 21:26:41 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1i1aeQ-0004wk-4S for ffmpeg-devel@ffmpeg.org; Sat, 24 Aug 2019 20:20:34 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 1adRiqaIIwlys1adRitODw; Sat, 24 Aug 2019 20:19:33 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=i09VpkoyrKZ5DAlLVgwA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 24 Aug 2019 20:18:27 +0200 Message-Id: <20190824181829.25724-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190824181829.25724-1-michael@niedermayer.cc> References: <20190824181829.25724-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfLJyJk9zOXdBBKl+yiH1S4QwzUr2znbxnFFA2vafryaBEVRa3g1iHn3Qwty3kkVPKV5PJTDGnnZwXbMK0hvn6ADtPoDhUWgwHhilJyMC6vYGpUDPoOp1 PhOfK7W3gYMwMioE9q3VAsQtN8BV+OOU/pNBe+KDF1irzuHuZVD440zB Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/internal: Add need_flush, simplify the next 2 commits 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/decode.c | 4 +++- libavcodec/internal.h | 3 +++ libavcodec/pthread_frame.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 72482e2168..a757249f93 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2054,8 +2054,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx) if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ff_thread_flush(avctx); - else if (avctx->codec->flush) + else if (avctx->codec->flush) { + avctx->internal->need_flush = 0; avctx->codec->flush(avctx); + } avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 15ef0bbefc..4bb1b1af36 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -233,6 +233,9 @@ typedef struct AVCodecInternal { int initial_sample_rate; int initial_channels; uint64_t initial_channel_layout; + + /* used for preserving a frame at the last PTS */ + int need_flush; } AVCodecInternal; struct AVCodecDefault { diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 36ac0ac1e5..4556b2101e 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -864,6 +864,7 @@ void ff_thread_flush(AVCodecContext *avctx) release_delayed_buffers(p); + avctx->internal->need_flush = 0; if (avctx->codec->flush) avctx->codec->flush(p->avctx); }