* [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio
@ 2022-10-12 13:08 James Almer
2022-10-12 13:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/librav1e: export extradata on init() James Almer
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: James Almer @ 2022-10-12 13:08 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
Changes since v1:
- Ensure we're not passing values like 0/1 as they are not supported by
librav1e.
libavcodec/librav1e.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 0601efed2c..a13d6c9eaf 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -298,6 +298,12 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
goto end;
}
+ if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0)
+ rav1e_config_set_sample_aspect_ratio(cfg, (RaRational) {
+ avctx->sample_aspect_ratio.num,
+ avctx->sample_aspect_ratio.den
+ });
+
rret = rav1e_config_parse_int(cfg, "threads", avctx->thread_count);
if (rret < 0)
av_log(avctx, AV_LOG_WARNING, "Invalid number of threads, defaulting to auto.\n");
--
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avcodec/librav1e: export extradata on init()
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 ` James Almer
2022-10-12 13:08 ` [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME James Almer
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2022-10-12 13:08 UTC (permalink / raw)
To: ffmpeg-devel
librav1e provides a function to create extradata, so use it instead of
extracting the sequence header OBU from packets.
Signed-off-by: James Almer <jamrial@gmail.com>
---
configure | 1 -
libavcodec/librav1e.c | 66 +++++++++++--------------------------------
2 files changed, 17 insertions(+), 50 deletions(-)
diff --git a/configure b/configure
index ab6ff27249..84641fd03e 100755
--- a/configure
+++ b/configure
@@ -3378,7 +3378,6 @@ libopus_decoder_deps="libopus"
libopus_encoder_deps="libopus"
libopus_encoder_select="audio_frame_queue"
librav1e_encoder_deps="librav1e"
-librav1e_encoder_select="extract_extradata_bsf"
librsvg_decoder_deps="librsvg"
libshine_encoder_deps="libshine"
libshine_encoder_select="audio_frame_queue mpegaudioheader"
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index a13d6c9eaf..604115476c 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -30,7 +30,6 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
-#include "bsf.h"
#include "codec_internal.h"
#include "encode.h"
#include "internal.h"
@@ -41,7 +40,6 @@ typedef struct librav1eContext {
RaContext *ctx;
AVFrame *frame;
RaFrame *rframe;
- AVBSFContext *bsf;
uint8_t *pass_data;
size_t pass_pos;
@@ -176,7 +174,6 @@ static av_cold int librav1e_encode_close(AVCodecContext *avctx)
}
av_frame_free(&ctx->frame);
- av_bsf_free(&ctx->bsf);
av_freep(&ctx->pass_data);
return 0;
@@ -245,36 +242,6 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
}
}
- if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
- const AVBitStreamFilter *filter = av_bsf_get_by_name("extract_extradata");
- int bret;
-
- if (!filter) {
- av_log(avctx, AV_LOG_ERROR, "extract_extradata bitstream filter "
- "not found. This is a bug, please report it.\n");
- ret = AVERROR_BUG;
- goto end;
- }
-
- bret = av_bsf_alloc(filter, &ctx->bsf);
- if (bret < 0) {
- ret = bret;
- goto end;
- }
-
- bret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx);
- if (bret < 0) {
- ret = bret;
- goto end;
- }
-
- bret = av_bsf_init(ctx->bsf);
- if (bret < 0) {
- ret = bret;
- goto end;
- }
- }
-
{
AVDictionaryEntry *en = NULL;
while ((en = av_dict_get(ctx->rav1e_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
@@ -427,6 +394,23 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
goto end;
}
+ if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+ RaData *seq_hdr = rav1e_container_sequence_header(ctx->ctx);
+
+ if (seq_hdr)
+ avctx->extradata = av_mallocz(seq_hdr->len + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!seq_hdr || !avctx->extradata) {
+ rav1e_data_unref(seq_hdr);
+ av_log(avctx, AV_LOG_ERROR, "Failed to get extradata.\n");
+ ret = seq_hdr ? AVERROR(ENOMEM) : AVERROR_EXTERNAL;
+ goto end;
+ }
+
+ memcpy(avctx->extradata, seq_hdr->data, seq_hdr->len);
+ avctx->extradata_size = seq_hdr->len;
+ rav1e_data_unref(seq_hdr);
+ }
+
ret = 0;
end:
@@ -556,22 +540,6 @@ retry:
av_free(rpkt->opaque);
rav1e_packet_unref(rpkt);
- if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
- int ret = av_bsf_send_packet(ctx->bsf, pkt);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "extradata extraction send failed.\n");
- av_packet_unref(pkt);
- return ret;
- }
-
- ret = av_bsf_receive_packet(ctx->bsf, pkt);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "extradata extraction receive failed.\n");
- av_packet_unref(pkt);
- return ret;
- }
- }
-
return 0;
}
--
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME
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
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
3 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2022-10-12 13:08 UTC (permalink / raw)
To: ffmpeg-devel
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avcodec/librav1e: use lavu image helpers where adequate
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 ` [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME James Almer
@ 2022-10-12 13:08 ` James Almer
2022-10-18 22:38 ` [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio James Almer
3 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2022-10-12 13:08 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/librav1e.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 130417622a..284af34ec4 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -437,6 +437,8 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
if (frame->buf[0]) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+ ptrdiff_t linesizes[4];
+ size_t sizes[4];
int64_t *pts = av_malloc(sizeof(int64_t));
if (!pts) {
@@ -453,12 +455,20 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
return AVERROR(ENOMEM);
}
+ for (int i = 0; i < 4; i++)
+ linesizes[i] = frame->linesize[i];
+
+ ret = av_image_fill_plane_sizes(sizes, frame->format, frame->height, linesizes);
+ if (ret < 0) {
+ rav1e_frame_unref(rframe);
+ av_frame_unref(frame);
+ av_freep(&pts);
+ return ret;
+ }
+
for (int i = 0; i < desc->nb_components; i++) {
- int shift = i ? desc->log2_chroma_h : 0;
- int bytes = desc->comp[0].depth == 8 ? 1 : 2;
- rav1e_frame_fill_plane(rframe, i, frame->data[i],
- (frame->height >> shift) * frame->linesize[i],
- frame->linesize[i], bytes);
+ rav1e_frame_fill_plane(rframe, i, frame->data[i], sizes[i],
+ linesizes[i], desc->comp[i].step);
}
av_frame_unref(frame);
rav1e_frame_set_opaque(rframe, pts, av_free);
--
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio
2022-10-12 13:08 [FFmpeg-devel] [PATCH 1/4 v2] avcodec/librav1e: support setting sample aspect ratio James Almer
` (2 preceding siblings ...)
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 ` James Almer
3 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2022-10-18 22:38 UTC (permalink / raw)
To: ffmpeg-devel
On 10/12/2022 10:08 AM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Changes since v1:
> - Ensure we're not passing values like 0/1 as they are not supported by
> librav1e.
>
> libavcodec/librav1e.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
> index 0601efed2c..a13d6c9eaf 100644
> --- a/libavcodec/librav1e.c
> +++ b/libavcodec/librav1e.c
> @@ -298,6 +298,12 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
> goto end;
> }
>
> + if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0)
> + rav1e_config_set_sample_aspect_ratio(cfg, (RaRational) {
> + avctx->sample_aspect_ratio.num,
> + avctx->sample_aspect_ratio.den
> + });
> +
> rret = rav1e_config_parse_int(cfg, "threads", avctx->thread_count);
> if (rret < 0)
> av_log(avctx, AV_LOG_WARNING, "Invalid number of threads, defaulting to auto.\n");
Will apply set.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-18 22:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME James Almer
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
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