diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-16 00:12:29 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-19 11:59:05 +0100 |
commit | 83186275588c6482da5d4abb827914252736655a (patch) | |
tree | c6120b5378c8aa405fe255aa4516a28f2bb66344 /libavformat/matroskaenc.c | |
parent | 5f973193e56ef0a8506dc2ff2784a25948154a69 (diff) |
avformat/matroskaenc: Redo reformatting AV1
This avoids allocations+copies in all cases, not only those
in which the desired OBUs are contiguous in the input buffer.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index ed1a817759..a71fd9c6e5 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2389,6 +2389,16 @@ static int mkv_reformat_wavpack(MatroskaMuxContext *mkv, AVIOContext *pb, } #endif +static int mkv_reformat_av1(MatroskaMuxContext *mkv, AVIOContext *pb, + const AVPacket *pkt, int *size) +{ + int ret = ff_av1_filter_obus(pb, pkt->data, pkt->size); + if (ret < 0) + return ret; + *size = ret; + return 0; +} + static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint32_t blockid, const AVPacket *pkt, int keyframe) { @@ -2426,9 +2436,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, err = ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL); } else #endif - if (par->codec_id == AV_CODEC_ID_AV1) { - err = ff_av1_filter_obus_buf(pkt->data, &data, &size, &offset); - } else if (track->reformat) { + if (track->reformat) { err = track->reformat(mkv, NULL, pkt, &size); } else data = pkt->data; @@ -3106,6 +3114,9 @@ static int mkv_init(struct AVFormatContext *s) track->reformat = mkv_reformat_wavpack; break; #endif + case AV_CODEC_ID_AV1: + track->reformat = mkv_reformat_av1; + break; } if (s->flags & AVFMT_FLAG_BITEXACT) { |