From: Parallelc <realparallelc@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Parallelc <realparallelc@gmail.com> Subject: [FFmpeg-devel] [PATCH] avformat/rtpdec_av1: Fix fragment continuation check when OBU_HAS_SIZE_FIELD is set Date: Sun, 13 Apr 2025 23:56:45 +0800 Message-ID: <20250413155645.805210-1-realparallelc@gmail.com> (raw) When OBU_HAS_SIZE_FIELD is set in the OBU header, frag_obu_size remains 0. The code used !frag_obu_size to check for unexpected fragment continuation, which resulted in incorrect drops. Introduce expect_frag_cont to explicitly track continuation expectation. Signed-off-by: Parallelc <realparallelc@gmail.com> --- libavformat/rtpdec_av1.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavformat/rtpdec_av1.c b/libavformat/rtpdec_av1.c index 7cfc83b03c..87f8cd2b0b 100644 --- a/libavformat/rtpdec_av1.c +++ b/libavformat/rtpdec_av1.c @@ -53,6 +53,7 @@ struct PayloadContext { unsigned int frag_pkt_leb_pos; ///< offset in buffer where OBU LEB starts unsigned int frag_lebs_res; ///< number of bytes reserved for LEB unsigned int frag_header_size; ///< size of OBU header (1 or 2) + int expect_frag_cont; ///< expect fragment continuation in packet int needs_td; ///< indicates that a TD should be output int drop_fragment; ///< drop all fragments until next frame int keyframe_seen; ///< keyframe was seen @@ -165,7 +166,7 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, seq, expected_seq); goto drop_fragment; } - if (!pkt->size || !data->frag_obu_size) { + if (!pkt->size || !data->expect_frag_cont) { av_log(ctx, AV_LOG_WARNING, "Unexpected fragment continuation in AV1 RTP packet\n"); goto drop_fragment; // avoid repeated output for the same fragment } @@ -187,9 +188,11 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, av_log(ctx, AV_LOG_TRACE, "Timestamp changed to %u (or first pkt %d), forcing TD\n", *timestamp, is_first_pkt); data->needs_td = 1; data->frag_obu_size = 0; // new temporal unit might have been caused by dropped packets + data->expect_frag_cont = 0; } - if (data->frag_obu_size) { + if (data->expect_frag_cont) { data->frag_obu_size = 0; // make sure we recover + data->expect_frag_cont = 0; av_log(ctx, AV_LOG_ERROR, "Missing fragment continuation in AV1 RTP packet\n"); return AVERROR_INVALIDDATA; } @@ -362,6 +365,7 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, write_leb(lebptr, final_obu_size); data->frag_obu_size = 0; // signal end of fragment + data->expect_frag_cont = 0; } else if (is_last_fragmented && !rem_pkt_size) { // add to total OBU size, so we can fix that in OBU header // (but only if the OBU size was missing!) @@ -370,6 +374,7 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, } // fragment not yet finished! result = -1; + data->expect_frag_cont = 1; } is_frag_cont = 0; @@ -391,6 +396,7 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, if (!is_last_fragmented) { data->frag_obu_size = 0; data->frag_pkt_leb_pos = 0; + data->expect_frag_cont = 0; } #ifdef RTPDEC_AV1_VERBOSE_TRACE @@ -409,6 +415,7 @@ drop_fragment: data->keyframe_seen = 0; data->drop_fragment = 1; data->frag_obu_size = 0; + data->expect_frag_cont = 0; data->needs_td = 1; if (pkt->size) { av_log(ctx, AV_LOG_TRACE, "Dumping current AV1 frame packet\n"); -- 2.43.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-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2025-04-13 15:57 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-04-13 15:56 Parallelc [this message] 2025-04-14 7:13 ` Chris Hodges 2025-04-14 9:57 ` Parallelc
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250413155645.805210-1-realparallelc@gmail.com \ --to=realparallelc@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git