From patchwork Thu Feb 29 23:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 46675 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp926751pzb; Thu, 29 Feb 2024 15:18:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU6RAxwrnqLwZhbwdSNQGuX+KA1Ow8z/2Ez9fVT7ukCHE3DRuJq9DyC01Z+iFP4p+Ass/V9HO5VdKj5X583RntAuHlHWttlLrfcOg== X-Google-Smtp-Source: AGHT+IHMWfUTowhxCwzcs21Ppw+DNfA9qSelwJCTTJBFuZx95rCnGcqIjuTtfif0bjBsut/H3JnY X-Received: by 2002:a05:6402:793:b0:566:cd51:6dec with SMTP id d19-20020a056402079300b00566cd516decmr93214edy.15.1709248712742; Thu, 29 Feb 2024 15:18:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709248712; cv=none; d=google.com; s=arc-20160816; b=j8aihMBXRuzsigt1EpDNnTKT35rRGukKg9tSTDuDFmQVydPuN2XaUYKYYo8JAjPBsn qjIks6fuSBB4g1f/TrM9A0UMhyKAV+Kvsb13A9aJreH0N/NwnTYdLY6zVrIuVnYuSaN7 nZN1jFZyCI3cWwQPGkzXcwQzOv8c3yLHI5e8+LC5kiVJanQ+HlKoflD5kLO9Opigy4PP EiYNE2gpupyd+XtaatvJBV5NUfKRQNg2EQk81R5zytJf8oIYmJGAOYmR+NPrAVnfSk52 +q9M/9ozmuI/THFpUxelnsoFAhwzUFTWUM87Mf9SfDgx+E5qlTSvVJe6QV5bKSFHOqkS N2pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=F4Qd7NIuMsjOKAG0g1lr2dVyF3wxbaWatsJgMdaOaoE=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=l27e10wlCw0J4i6Sh7eleie4CeJEetF2aqWm0j2wR8yVNN7vT66me1uMLoJPYePade qRY44c2PbQgXy0/MvRhF0F45a6ZWQSg13X52rNV/KpWpjWG+Kyfkk1T708H/yJlSexI1 OU+0cmc9PiR27/38qaZijbM5oaMqqJ6k//1HKlzEpFfBECXeSzTMJ13xpbQNeigT9pCw lavKGxDjQcnwraH4J6p8FGjPLNo9J+83VSRix1jOKDj9fpvyO0b07J/ej91Y6DcWXjo1 xXeNnOVv/wQ1GdaOeIPCQRFHgBEJBAT3UhY6et1r8YSWAAjTEukIBznVGBE3AY1lBTXA VIAg==; dara=google.com 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 dn5-20020a05640222e500b00565765b4bb8si963779edb.563.2024.02.29.15.18.32; Thu, 29 Feb 2024 15:18:32 -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 8F09768D21C; Fri, 1 Mar 2024 01:18:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F316868D0A6 for ; Fri, 1 Mar 2024 01:18:21 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5E3C4EA0EB; Fri, 1 Mar 2024 00:18:21 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13dT7oKElEEF; Fri, 1 Mar 2024 00:18:19 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7BFE6EA01D; Fri, 1 Mar 2024 00:18:19 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Mar 2024 00:18:12 +0100 Message-Id: <20240229231812.13981-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mpegts: detect synchronous metadata KLV more reliably 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4TzL8dETKbXt The mpegts code historically tries to strip (the first) metadata access unit header from synchronous KLV metadata, but the detection for such streams was unreliable causing strips of asynchronous metadata or ID3 as well. MISB ST 1402 specifies required stream type, stream id and registration descriptor (which eventually maps to the codec ID) so let's use all of these for reliable detection. Fixes ticket #10828, #10883. Signed-off-by: Marton Balint --- libavformat/mpegts.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 836d5dd5a3..01f6c04223 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1307,8 +1307,11 @@ skip: p += sl_header_bytes; buf_size -= sl_header_bytes; } - if (pes->st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV && buf_size >= 5) { - /* skip metadata access unit header */ + if (pes->stream_type == STREAM_TYPE_METADATA && + pes->stream_id == STREAM_ID_METADATA_STREAM && + pes->st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV && + buf_size >= 5) { + /* skip metadata access unit header - see MISB ST 1402 */ pes->pes_header_size += 5; p += 5; buf_size -= 5;