diff options
author | James Almer <jamrial@gmail.com> | 2022-10-10 23:43:31 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-10-19 11:15:38 -0300 |
commit | 1f63225f2b79032586f099fef73fc26e1670eeb7 (patch) | |
tree | d7b090494e2696220b1d6b5cc92123b0415b6d9c /libavcodec | |
parent | f58f238936104b6683ff4a9b584d4cd597f06709 (diff) |
avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME
This bumps the minimum required version to 0.5.0
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/librav1e.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 604115476c..4f424caf5b 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -538,6 +538,32 @@ retry: pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque); av_free(rpkt->opaque); + + if (avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { + AVCodecInternal *avci = avctx->internal; + AVFrame *frame = avci->recon_frame; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); + + av_frame_unref(frame); + + frame->format = avctx->pix_fmt; + frame->width = avctx->width; + frame->height = avctx->height; + + ret = ff_encode_alloc_frame(avctx, frame); + if (ret < 0) { + rav1e_packet_unref(rpkt); + return ret; + } + + for (int i = 0; i < desc->nb_components; i++) { + int shift = i ? desc->log2_chroma_h : 0; + rav1e_frame_extract_plane(rpkt->rec, i, frame->data[i], + (frame->height >> shift) * frame->linesize[i], + frame->linesize[i], desc->comp[i].step); + } + } + rav1e_packet_unref(rpkt); return 0; @@ -601,7 +627,7 @@ const FFCodec ff_librav1e_encoder = { .defaults = librav1e_defaults, .p.pix_fmts = librav1e_pix_fmts, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | - AV_CODEC_CAP_DR1, + AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_RECON_FRAME, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .p.wrapper_name = "librav1e", |