mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-23 09:01:00 +08:00
lavc: add API for exporting reconstructed frames from encoders
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user