From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 15C944A27B for ; Tue, 21 Oct 2025 09:44:43 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b't1BvxbEgR3w203AxYvZtQY5n84KOk4dD63kZe8Cd68Y=', expected b'4zFAglUiFw/XT5Q5gfnFRXXmbTjXd+LqKOBXx+Un+6Y=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1761039870; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=t1BvxbEgR3w203AxYvZtQY5n84KOk4dD63kZe8Cd68Y=; b=2JcsGZQmZJLKR19dbX0YP4WUWCycFt4kWUkIZvvHUJAapkvr3sNQvjR9DduB8gMQcjVxp /YkIP9xkkKz6Dm/MtxXLI2/gWXkvslp6CdQ/p5v8UPdlhxqJvEHYQh+X11LLxL0uqwLvUeF s3C9+FDUylUeoThqOnzP/8frIww5F06PLo35/uJ810eyPjWXwd312rAYt/SC0SN8OnjhfD5 0m71hKcmZ/ZIqyIdTTPzE9HM0KEQgrfsSLM4JOv86sGwatbvWrRsMklTkziDkdFH6TdrMSk new0IuGZV+3qCFYQi+WS7wcDaMD1kebNJsJ1oaSqFFA4KX7QHuwrf1KgfMYA== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id D9D3868F536; Tue, 21 Oct 2025 12:44:30 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1761039854; b=O5MGasoDuRwnwAjl/yRxOtAbtOu5ZnZGhg8tPK15imGhfazA2XhQ1MomkiS7T8QSym2pB 46H83FDLjvlVTXhLCIVV39AKzOrAg4arfYNtOUmwopIYHcNpId19OfcVs5CuhMa9Q6QRvUy qzSC1f/4c2dGcx3DBmIiGKNoZ7WN7iSmeijEz4hEgXmFpJwL/YySFRZ4+4gStJRFiasX/ZG 1qKpIaAsOsgllzf0ojJ+S8e91xfc6SSw19lhRAQRGKCfWJt9udqUgzHCU5lAzVhqyq5S3D1 cEieQvyM9eM7k7woaQ1ddDZ5F6jwzbahcwq+GZ1WgB2x0pVemiipe+RqJpMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1761039854; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=esfN1BjKAc3xWugIrEemNq4yELoLd3i/whfuLDbxoQE=; b=XrwUtbMZKtYn8ZtxAvC1rmgIHbhyGJxKFABBJ+9PHe9YIbYDoz49znCnsQmBe4fVXByqZ XHtOH9h638zP/B3kLgFqbouIC/M4YJeuE2A9G+DD0vCMIHSBiHNGNpa+1GeQv/Dgj2pmsRK OLtPSaBG7cZIMRbK5N6nu85zPA3lelrQrtk3fXcaHHsZHl1lnr7SvU0zVbmfqVse+tyODzy J5Z6Uaasd+KfVot72vTZJI4hEd8vucfv0TV6Vp5ReDIv7DJW9ShrJaSCmwc1z4EXF0p6HAR yzibWBmuituvDxSgvubAoFQoaU9/E6AvZFqjm1RxC8UrQsRXSuFi5Zp3E/7Q== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1761039847; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=4zFAglUiFw/XT5Q5gfnFRXXmbTjXd+LqKOBXx+Un+6Y=; b=GFdY7mie25yzHdyYDf7bg7cxzX11wwRMeZU9x3kePXKOlyijBc0WJF17xJLf8/d1L+NLJ +hF5Qrf1Cw3gDKURQ+BDmTE3jpbdTGzLAxxWjV4fnJNkMMrzFANd1tfV1frS4wbaVWBxp0s Ae+CqpPT3KB7bOS88dRjhWw0XtHFW2NVlWd/+V9wl/hlbei83eUrGUQlXB7gN0QT/b7YZga 9yWIx7krrvotD1xXuvYk8OxiXwaEAspF4tE0xJ4BgQLQUky7Cc31PB2NYvQ8fPO3BCG3g9w qT838G+77flZFQbVO6sHX2/bMcrlqa4YDVYK26i/CdIXMc4p0gAqk0kkmQIQ== Received: from 547bf0a948a1 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A249168F4C4 for ; Tue, 21 Oct 2025 12:44:07 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Oct 2025 09:44:07 -0000 Message-ID: <176103984784.62.1736271583547636045@bf907ddaa564> Message-ID-Hash: GLFCU74PVEQZKAJRFP2QPTVA45IS7LFT X-Message-ID-Hash: GLFCU74PVEQZKAJRFP2QPTVA45IS7LFT X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] libavformat: fix rtpdec_av1 regarding OBU size (PR #20732) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Chris Hodges via ffmpeg-devel Cc: Chris Hodges Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20732 opened by Chris Hodges (platon42) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20732 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20732.patch Fix the AV1 RTP depacketizer for instances where the OBU elements did not have their OBU size fields removed according to the recommendation (SHOULD) of the AV1 RTP specification. Roger Hardiman courteously reported that the depacketizer doesn't work correctly for fragmented OBU elements with their OBU size fields still present and will incorrectly state that the continuation of such a fragment was unexpected, because the frag_obu_size field was used as a state and only incremented when the size field needed to be updated on OBU size field restoration. This patch solves the slip. Signed-off-by: Chris Hodges >>From 6b0ccace6b3317d50804515bdcd999a0e47236bf Mon Sep 17 00:00:00 2001 From: Chris Hodges Date: Tue, 21 Oct 2025 11:41:06 +0200 Subject: [PATCH] libavformat: fix rtpdec_av1 regarding OBU size Fix the AV1 RTP depacketizer for instances where the OBU elements did not have their OBU size fields removed according to the recommendation (SHOULD) of the AV1 RTP specification. Roger Hardiman courteously reported that the depacketizer doesn't work correctly for fragmented OBU elements with their OBU size fields still present and will incorrectly state that the continuation of such a fragment was unexpected, because the frag_obu_size field was used as a state and only incremented when the size field needed to be updated on OBU size field restoration. This patch solves the slip. Change-Id: I95af8cc89862e8ecf79aabcf029dd95a20dfd7ad --- libavformat/rtpdec_av1.c | 49 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/libavformat/rtpdec_av1.c b/libavformat/rtpdec_av1.c index 7cfc83b03c..dda17be4a1 100644 --- a/libavformat/rtpdec_av1.c +++ b/libavformat/rtpdec_av1.c @@ -329,6 +329,8 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, num_lebs = write_leb(pkt->data + pktpos, obu_payload_size); data->frag_lebs_res = num_lebs; pktpos += num_lebs; + } else if (!is_frag_cont) { + data->frag_lebs_res = 0; } // copy verbatim or without above header size patch memcpy(pkt->data + pktpos, buf_ptr, obu_payload_size); @@ -339,35 +341,32 @@ static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, // if we were handling a fragmented packet and this was the last // fragment, correct OBU size field if (data->frag_obu_size && (rem_pkt_size || !is_last_fragmented)) { - uint32_t final_obu_size = data->frag_obu_size + obu_size - data->frag_header_size; - uint8_t *lebptr = pkt->data + data->frag_pkt_leb_pos; - num_lebs = calc_leb_size(final_obu_size); + if (data->frag_lebs_res) { + uint32_t final_obu_size = data->frag_obu_size + obu_size - data->frag_header_size; + uint8_t *lebptr = pkt->data + data->frag_pkt_leb_pos; + num_lebs = calc_leb_size(final_obu_size); - // check if we had allocated enough LEB bytes in header, - // otherwise make some extra space - if (num_lebs > data->frag_lebs_res) { - int extra_bytes = num_lebs - data->frag_lebs_res; - if ((result = av_grow_packet(pkt, extra_bytes)) < 0) - return result; - // update pointer in case buffer address changed - lebptr = pkt->data + data->frag_pkt_leb_pos; - // move existing data for OBU back a bit - memmove(lebptr + extra_bytes, lebptr, - pkt->size - extra_bytes - data->frag_pkt_leb_pos); - // move pktpos further down for following OBUs in same packet. - pktpos += extra_bytes; + // check if we had allocated enough LEB bytes in header, + // otherwise make some extra space + if (num_lebs > data->frag_lebs_res) { + int extra_bytes = num_lebs - data->frag_lebs_res; + if ((result = av_grow_packet(pkt, extra_bytes)) < 0) + return result; + // update pointer in case buffer address changed + lebptr = pkt->data + data->frag_pkt_leb_pos; + // move existing data for OBU back a bit + memmove(lebptr + extra_bytes, lebptr, + pkt->size - extra_bytes - data->frag_pkt_leb_pos); + // move pktpos further down for following OBUs in same packet. + pktpos += extra_bytes; + } + + // update OBU size field + write_leb(lebptr, final_obu_size); } - - // update OBU size field - write_leb(lebptr, final_obu_size); - data->frag_obu_size = 0; // signal end of fragment } 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!) - if (needs_size_field || data->frag_obu_size) { - data->frag_obu_size += obu_size; - } + data->frag_obu_size += obu_size; // fragment not yet finished! result = -1; } -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org