PR #25564 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25564 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25564.patch
Use the existing lcevc_metadata filter, as it does the job without the need for an explicit bsf for this purpose (No need to insert specific NALs at certain intervals like h264 and others). >From aca740a45d3b094b8ff9b090711055c00cda2555 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 28 Oct 2026 14:58:07 -0300 Subject: [PATCH 1/2] avcodec/lcevc_parser: handle four byte long start codes Start codes can be 0x000001 or 0x00000001, but lcevc_find_frame_end() was only looking for the former, without considering it might have found the latter. This resulted in a stray zero being included in the following packet. Signed-off-by: James Almer <[email protected]> --- libavcodec/lcevc_parser.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/lcevc_parser.c b/libavcodec/lcevc_parser.c index d3d6c38bd3c..b6bae5b2af9 100644 --- a/libavcodec/lcevc_parser.c +++ b/libavcodec/lcevc_parser.c @@ -50,14 +50,15 @@ static int lcevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, ParseContext *pc = &ctx->pc; for (int i = 0; i < buf_size; i++) { - int nut; + int nut, zero_byte_present = 0; - pc->state = (pc->state << 8) | buf[i]; + pc->state64 = (pc->state64 << 8) | buf[i]; - if (((pc->state >> 8) & 0xFFFFFF) != START_CODE) + if (((pc->state64 >> 8) & 0xFFFFFF) != START_CODE) continue; - nut = (pc->state >> 1) & 0x1F; + zero_byte_present = i > 3 && !((pc->state64 >> 32) & 0xFF); + nut = (pc->state64 >> 1) & 0x1F; // Beginning of access unit if (nut == LCEVC_IDR_NUT || nut == LCEVC_NON_IDR_NUT) { @@ -65,7 +66,7 @@ static int lcevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, pc->frame_start_found = 1; else { pc->frame_start_found = 0; - return i - 3; + return i - (3 + zero_byte_present); } } } -- 2.54.0 >From 0e5fe88db428c0be873ba45b63d906ceb704959c Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 28 Oct 2026 14:59:55 -0300 Subject: [PATCH 2/2] avformat/mpegtsenc: convert MP4 style LCEVC packets into Annex B before muxing Use the existing lcevc_metadata filter, as it does the job without the need for an explicit bsf for this purpose (No need to insert specific NALs at certain intervals like h264 and others). Signed-off-by: James Almer <[email protected]> --- libavformat/mpegtsenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index e57889cb2d3..66ef27876d4 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -2439,6 +2439,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st, } list[] = { { AV_CODEC_ID_H264, "h264_mp4toannexb", 0xff, 0x01 /* configurationVersion in AVCDecoderConfigurationRecord */}, { AV_CODEC_ID_HEVC, "hevc_mp4toannexb", 0xff, 0x01 /* configurationVersion in HEVCDecoderConfigurationRecord */}, + { AV_CODEC_ID_LCEVC, "lcevc_metadata", 0xff, 0x01 /* configurationVersion in HEVCDecoderConfigurationRecord */}, { AV_CODEC_ID_VVC, "vvc_mp4toannexb", 0xf8, 0xf8 /* reserved '11111'b in VVCDecoderConfigurationRecord */}, }; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
