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 | |
parent | f58f238936104b6683ff4a9b584d4cd597f06709 (diff) | |
download | ffmpeg-1f63225f2b79032586f099fef73fc26e1670eeb7.tar.gz |
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>
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | libavcodec/librav1e.c | 28 |
2 files changed, 28 insertions, 2 deletions
@@ -6675,7 +6675,7 @@ enabled libopus && { enabled libplacebo && require_pkg_config libplacebo "libplacebo >= 4.192.0" libplacebo/vulkan.h pl_vulkan_create enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection -enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new +enabled librav1e && require_pkg_config librav1e "rav1e >= 0.5.0" rav1e.h rav1e_context_new enabled librist && require_pkg_config librist "librist >= 0.2.7" librist/librist.h rist_receiver_create enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket 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", |