diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-07-16 16:36:23 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-08-02 10:46:11 +0200 |
commit | e3838b856f3cfa0a85db0bf427a0f733110c5158 (patch) | |
tree | f999c1f000992123e85a5857e9b111862f8a3c03 /libavcodec/encode.c | |
parent | eede1d2927db18b962741e6a09ec1401fdad6277 (diff) | |
download | ffmpeg-e3838b856f3cfa0a85db0bf427a0f733110c5158.tar.gz |
lavc: add API for exporting reconstructed frames from encoders
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r-- | libavcodec/encode.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 7cf13bf6d6..7919b165da 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -656,6 +656,18 @@ int ff_encode_preinit(AVCodecContext *avctx) return AVERROR(ENOMEM); } + if ((avctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)) { + av_log(avctx, AV_LOG_ERROR, "Reconstructed frame output requested " + "from an encoder not supporting it\n"); + return AVERROR(ENOSYS); + } + + avci->recon_frame = av_frame_alloc(); + if (!avci->recon_frame) + return AVERROR(ENOMEM); + } + return 0; } @@ -692,3 +704,16 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame) return 0; } + +int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame) +{ + AVCodecInternal *avci = avctx->internal; + + if (!avci->recon_frame) + return AVERROR(EINVAL); + if (!avci->recon_frame->buf[0]) + return avci->draining_done ? AVERROR_EOF : AVERROR(EAGAIN); + + av_frame_move_ref(frame, avci->recon_frame); + return 0; +} |