From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8999C43CE8 for ; Sat, 4 Feb 2023 10:07:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2782168BE16; Sat, 4 Feb 2023 12:07:35 +0200 (EET) Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 66A7068B934 for ; Sat, 4 Feb 2023 12:07:28 +0200 (EET) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4P87Vj6Lk4z9sSx for ; Sat, 4 Feb 2023 11:07:25 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Feb 2023 15:36:57 +0530 Message-Id: <20230204100657.6882-1-ffmpeg@gyani.pro> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4P87Vj6Lk4z9sSx Subject: [FFmpeg-devel] [PATCH v2] avcodec/h264_metadata_bsf: remove AUDs at any position X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Some files, likely due to faulty packetization or muxing, can have AUDs at other positions besides the head unit of a packet. Remove these too. --- libavcodec/h264_metadata_bsf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d318bf0cee..b9cfeaba94 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -469,12 +469,13 @@ static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, H264MetadataContext *ctx = bsf->priv_data; int err, i, has_sps, seek_point; - // If an AUD is present, it must be the first NAL unit. - if (au->nb_units && au->units[0].type == H264_NAL_AUD) { - if (ctx->aud == BSF_ELEMENT_REMOVE) - ff_cbs_delete_unit(au, 0); - } else { - if (pkt && ctx->aud == BSF_ELEMENT_INSERT) { + if (ctx->aud == BSF_ELEMENT_REMOVE) { + for (i = au->nb_units - 1; i >= 0; i--) { + if (au->units[i].type == H264_NAL_AUD) + ff_cbs_delete_unit(au, i); + } + } else if (ctx->aud == BSF_ELEMENT_INSERT) { + if (pkt) { err = h264_metadata_insert_aud(bsf, au); if (err < 0) return err; -- 2.39.1 _______________________________________________ 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".