This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 1434d99b193c81fdaa60c7ee78eff81ae93af40d Author: James Almer <[email protected]> AuthorDate: Fri Mar 13 19:34:31 2026 -0300 Commit: James Almer <[email protected]> CommitDate: Sun Mar 15 19:20:06 2026 -0300 avcodec/bsf/extract_extradata: write correct length start codes for LCEVC The specification for LCEVC states that start codes may be three or four bytes long except for the first NALU in an AU, which must be four bytes long. Signed-off-by: James Almer <[email protected]> --- libavcodec/bsf/extract_extradata.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavcodec/bsf/extract_extradata.c b/libavcodec/bsf/extract_extradata.c index c8a73797e7..aee1642f84 100644 --- a/libavcodec/bsf/extract_extradata.c +++ b/libavcodec/bsf/extract_extradata.c @@ -364,6 +364,7 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt, PutByteContext pb_extradata; int extradata_size = 0, filtered_size = 0; size_t nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types); + int extradata_nb_nals = 0, filtered_nb_nals = 0; int i, ret = 0; ret = ff_h2645_packet_split(&s->h2645_pkt, pkt->data, pkt->size, @@ -377,9 +378,11 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt, bytestream2_init_writer(&pb_extradata, NULL, 0); // dummy pass to find sc, gc or ai if (!write_lcevc_nalu(ctx, &pb_extradata, nal, 0)) - extradata_size += nal->raw_size + 3; + extradata_size += nal->raw_size + 3 + + ff_h2645_unit_requires_zero_byte(ctx->par_in->codec_id, nal->type, extradata_nb_nals++); } - filtered_size += nal->raw_size + 3; + filtered_size += nal->raw_size + 3 + + ff_h2645_unit_requires_zero_byte(ctx->par_in->codec_id, nal->type, filtered_nb_nals++); } if (extradata_size) { @@ -405,11 +408,14 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt, if (s->remove) bytestream2_init_writer(&pb_filtered_data, filtered_buf->data, filtered_size); + extradata_nb_nals = filtered_nb_nals = 0; for (i = 0; i < s->h2645_pkt.nb_nals; i++) { H2645NAL *nal = &s->h2645_pkt.nals[i]; if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) { - bytestream2_put_be24(&pb_extradata, 1); //startcode + if (ff_h2645_unit_requires_zero_byte(ctx->par_in->codec_id, nal->type, extradata_nb_nals++)) + bytestream2_put_byteu(&pb_extradata, 0); // zero_byte + bytestream2_put_be24u(&pb_extradata, 1); //startcode ret = write_lcevc_nalu(ctx, &pb_extradata, nal, 0); if (ret < 0) { av_freep(&extradata); @@ -417,7 +423,9 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt, return ret; } if (s->remove) { - bytestream2_put_be24(&pb_filtered_data, 1); //startcode + if (ff_h2645_unit_requires_zero_byte(ctx->par_in->codec_id, nal->type, filtered_nb_nals++)) + bytestream2_put_byteu(&pb_filtered_data, 0); // zero_byte + bytestream2_put_be24u(&pb_filtered_data, 1); //startcode ret = write_lcevc_nalu(ctx, &pb_filtered_data, nal, 1); if (ret < 0) { av_freep(&extradata); @@ -426,7 +434,9 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt, } } } else if (s->remove) { - bytestream2_put_be24(&pb_filtered_data, 1); //startcode + if (ff_h2645_unit_requires_zero_byte(ctx->par_in->codec_id, nal->type, filtered_nb_nals++)) + bytestream2_put_byteu(&pb_filtered_data, 0); // zero_byte + bytestream2_put_be24u(&pb_filtered_data, 1); //startcode bytestream2_put_bufferu(&pb_filtered_data, nal->raw_data, nal->raw_size); } } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
