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.rheinha...@outlook.com> --- ff_av1_filter_obus_buf() now has only one user left: movenc.c Maybe movenc.c should be modified accordingly to remove it? libavformat/matroskaenc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 08d2d338a6..d275d6cd6c 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) { -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".