aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-10-10 23:38:57 -0300
committerJames Almer <jamrial@gmail.com>2022-10-19 10:13:37 -0300
commitf58f238936104b6683ff4a9b584d4cd597f06709 (patch)
tree4584ddd7c8d457f78d79455f9422a1a63314aa5e /libavcodec
parentd569958d2952ac5b5ed4334ffba04bfe1a55a967 (diff)
downloadffmpeg-f58f238936104b6683ff4a9b584d4cd597f06709.tar.gz
avcodec/librav1e: export extradata on init()
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>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/librav1e.c66
1 files changed, 17 insertions, 49 deletions
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;
}