From patchwork Thu Feb 2 17:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40221 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp550233pzk; Thu, 2 Feb 2023 09:51:44 -0800 (PST) X-Google-Smtp-Source: AK7set9GU51x4oD9dedpIcP2db9YGIgULkALcNkD8L1wgRUy7vTPLchqpj2q0LCtBXK2qqVQfb8m X-Received: by 2002:a17:906:9610:b0:878:5e84:e1d6 with SMTP id s16-20020a170906961000b008785e84e1d6mr8331725ejx.75.1675360304789; Thu, 02 Feb 2023 09:51:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675360304; cv=none; d=google.com; s=arc-20160816; b=jsUZeXuhOgS8M0fb7X7ltIT9w6gk5P9clfhgCz929y6t+4d+hiyfsxNVBGFWQ6IFgC UibhLiMk+p3tGXvzQ7mkslFWbkOLwckNQtKRsI6oX3cFGWamceqTAXJUd8j9AYEJDnWy bxjLJgGCa/UMt7aUJ/HFBLHxX/R4lbI40yyWf1O60mHf58yqzevS2D6Ebmb/GQkzLoIb 3HHhpi9ScPsEF2Ki6WHZ5YasJJVnETQT3Yk3dAv6d/tj1HpPjJ7ZhTj+kjxulmFpyHrq Gg8f3GF7BZcCHJbasuBnmsPboogbfYOE2BLmORlmC3m6sopvafb1obT1qNhvSVGp7EqU CKlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Zm1TrNiFLDTrJvC49Y6KRh216dLUe5lVsSjZ8rLtXF4=; b=vJl2Wuam9lkH8v/RnDTidHJvVNqopCBOiO6oyUvWzE8DPR8MxgG8tm3/TU1ZvQByQL gSbwxhC4cK1sTVDI6J54mtLofr6++bT5sS1rqzqUZEJ3oWPiNwtqZwn7IFQ2WezaO5rw SnUJgzVi2Mnl5H49e6Df5BOOAwtbDdTfRXC02jLQgdzlHNI/WiJeZKet3wjw7vijEfRV 6zVYqBZo+sD/azjNBXbP5KzF9XQLjG+SUS/HzVQ9U5qTkQygWtmQsBNnNZD6KWcpNKFx krmGUtnAWhevXjfdloaH4M7PyPS3vkA5ZB0t2D1VKIvATIBQyN2dlufuQjE4hW9MMazY xHkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fr37-20020a170906892500b0087865d02fa9si202646ejc.183.2023.02.02.09.51.44; Thu, 02 Feb 2023 09:51:44 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 809AA68BDB3; Thu, 2 Feb 2023 19:51:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 7F15568B4A7 for ; Thu, 2 Feb 2023 19:51:34 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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 4P75v76zDXz9swx for ; Thu, 2 Feb 2023 18:51:31 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Feb 2023 23:21:01 +0530 Message-Id: <20230202175101.1871-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OrrjGtsxzRNj 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..6fab0190d4 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 = 0; i < au->nb_units; 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;