[FFmpeg-devel] [PATCH 3/6] avcodec: Add ff_setup_buffered_frame_for_return()
Michael Niedermayer
michael at niedermayer.cc
Sat Aug 24 21:18:26 EEST 2019
Suggested-by: James Almer <jamrial at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
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
--
2.23.0
More information about the ffmpeg-devel
mailing list