@@ -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;
@@ -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
Suggested-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/decode.c | 17 +++++++++++++++++ libavcodec/internal.h | 5 +++++ 2 files changed, 22 insertions(+)