From patchwork Sat Aug 24 18:18:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14693 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 1C1D744918A 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 0701C68ABCF; 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-pe07-3.mx.upcmail.net (vie01a-dmta-pe07-3.mx.upcmail.net [84.116.36.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A2D968ABCA 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-pe07.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1i1aeR-0005ry-38 for ffmpeg-devel@ffmpeg.org; Sat, 24 Aug 2019 20:20:35 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 1adRiqaI7wlys1adRitODo; 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=pGLkceISAAAA:8 a=A1Fiyq-W55v5j_h-NXQA:9 a=pHzHmUro8NiASowvMSCR:22 a=6VlIyEUom7LUIeUMNQJH:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 24 Aug 2019 20:18:26 +0200 Message-Id: <20190824181829.25724-3-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 PhOfK7W3gYMwMgsyy+FYEUpzRxbQRD3Z/1l+Ia4LUPsVFzNLwdGqhboVtfHc5Pwk32bKtXhOyBxuW6CPGYEk/z25QfWVQYuoIdY= Subject: [FFmpeg-devel] [PATCH 3/6] avcodec: Add ff_setup_buffered_frame_for_return() 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: James Almer Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Suggested-by: James Almer Signed-off-by: Michael Niedermayer --- libavcodec/decode.c | 17 +++++++++++++++++ libavcodec/internal.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5976da78c8..72482e2168 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2015,6 +2015,23 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame) return ret; } +int ff_setup_buffered_frame_for_return(AVCodecContext *avctx, AVFrame *out, AVFrame *frame, AVPacket *pkt) +{ + int ret; + + if ((ret = ff_reget_buffer(avctx, frame)) < 0) + return ret; + frame->pkt_pos = pkt->pos; + frame->pkt_duration = pkt->duration; + frame->pkt_dts = pkt->dts; + frame->pkt_pts = + frame->pts = pkt->pts; + if ((ret = av_frame_ref(out, frame)) < 0) + return ret; + + return 0; +} + static void bsfs_flush(AVCodecContext *avctx) { DecodeFilterContext *s = &avctx->internal->filter; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index f9e87eacc6..15ef0bbefc 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -337,6 +337,11 @@ int ff_thread_can_start_frame(AVCodecContext *avctx); int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); +/** + * sets up frame to be returned based on fields from pkt. + */ +int ff_setup_buffered_frame_for_return(AVCodecContext *avctx, AVFrame *out, AVFrame *frame, AVPacket *pkt); + /** * Call avcodec_open2 recursively by decrementing counter, unlocking mutex, * calling the function and then restoring again. Assumes the mutex is