Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME
Date: Wed, 12 Oct 2022 10:08:28 -0300
Message-ID: <20221012130829.2392-3-jamrial@gmail.com> (raw)
In-Reply-To: <20221012130829.2392-1-jamrial@gmail.com>

This bumps the minimum required version to 0.5.0

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure             |  2 +-
 libavcodec/librav1e.c | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 84641fd03e..96479d48d6 100755
--- a/configure
+++ b/configure
@@ -6674,7 +6674,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..130417622a 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -23,6 +23,7 @@
 #include <rav1e.h>
 
 #include "libavutil/internal.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
 #include "libavutil/common.h"
@@ -538,6 +539,40 @@ 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;
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+        ptrdiff_t linesizes[4];
+        size_t sizes[4];
+
+        av_frame_unref(avci->recon_frame);
+
+        avci->recon_frame->format = avctx->pix_fmt;
+        avci->recon_frame->width  = avctx->width;
+        avci->recon_frame->height = avctx->height;
+
+        ret = av_frame_get_buffer(avci->recon_frame, 0);
+        if (ret < 0) {
+            rav1e_packet_unref(rpkt);
+            return ret;
+        }
+
+        for (int i = 0; i < 4; i++)
+            linesizes[i] = avci->recon_frame->linesize[i];
+
+        ret = av_image_fill_plane_sizes(sizes, avctx->pix_fmt, avctx->height, linesizes);
+        if (ret < 0) {
+            rav1e_packet_unref(rpkt);
+            return ret;
+        }
+
+        for (int i = 0; i < desc->nb_components; i++) {
+            rav1e_frame_extract_plane(rpkt->rec, i, avci->recon_frame->data[i],
+                                      sizes[i], linesizes[i], desc->comp[i].step);
+        }
+    }
+
     rav1e_packet_unref(rpkt);
 
     return 0;
@@ -601,7 +636,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",
-- 
2.37.3

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-10-12 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 13:08 [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio James Almer
2022-10-12 13:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/librav1e: export extradata on init() James Almer
2022-10-12 13:08 ` James Almer [this message]
2022-10-12 13:08 ` [FFmpeg-devel] [PATCH 4/4] avcodec/librav1e: use lavu image helpers where adequate James Almer
2022-10-18 22:38 ` [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio James Almer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221012130829.2392-3-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git