av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) ||
!(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
+ if (frame->private_ref) {
+ FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
+
+ if (fdd->post_process) {
+ ret = fdd->post_process(avctx, frame);
+ if (ret < 0) {
+ av_frame_unref(frame);
+ return ret;
+ }
+ }
+ }
+
av_buffer_unref(&frame->private_ref);
}
{
FrameDecodeData *fdd = (FrameDecodeData*)data;
+ if (fdd->post_process_opaque_free)
+ fdd->post_process_opaque_free(fdd->post_process_opaque);
+
av_freep(&fdd);
}
#define AVCODEC_DECODE_H
#include "libavutil/buffer.h"
+#include "libavutil/frame.h"
#include "avcodec.h"
* private_ref.
*/
typedef struct FrameDecodeData {
+ /**
+ * The callback to perform some delayed processing on the frame right
+ * before it is returned to the caller.
+ *
+ * @note This code is called at some unspecified point after the frame is
+ * returned from the decoder's decode/receive_frame call. Therefore it cannot rely
+ * on AVCodecContext being in any specific state, so it does not get to
+ * access AVCodecContext directly at all. All the state it needs must be
+ * stored in the post_process_opaque object.
+ */
+ int (*post_process)(void *logctx, AVFrame *frame);
+ void *post_process_opaque;
+ void (*post_process_opaque_free)(void *opaque);
} FrameDecodeData;
/**