From patchwork Tue Mar 26 15:09:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 35090 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp17425pzb; Tue, 26 Mar 2024 08:10:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUpx7c8u6+l6vPtBOuiN/aI/OLMlaEOftptSWPGDAtCRnsachi+Pz3Ac1tEu3/gt9GAhT62HPN4BPPL7NnmGtNU2w6lNevzyGJ9vA== X-Google-Smtp-Source: AGHT+IHPmzr5MyIddOHm2ZSyWJsQvEx5XdLmYVyNj94C3qHOOpzh0zEQwl8p2BY07yoBSl6QfxEG X-Received: by 2002:a50:8d17:0:b0:568:1a8:58b with SMTP id s23-20020a508d17000000b0056801a8058bmr1167269eds.14.1711465824752; Tue, 26 Mar 2024 08:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711465824; cv=none; d=google.com; s=arc-20160816; b=EDymO1rlacKF4GBdx86Xir0/xLYdQsn7GQaqLNkNmSF95kACFbuHWjLmYEUA81TA6S oO2LgAoubpMYhyZQV9fX0HUg03lL07wayiq4tYrvfSEAYIhBh8tRZz5v76d5ivbQlEiw 1hL5jYRu1OkPkRu1653PYtawK+fSqx0uCq+75nRPzkvE2awah1Wy1oE7EmUMXWzJjWL3 KF4fdgxJjYLSXvMJ+BQmaiqbSdpiwUBsFfmFuvvjq0kUByd6VC7ObkQtu31lF70kxFLm A1ZeOFVnclW2Eh8pzo9uLF+UW651HtZIqkjjdQ8Paaft1gXSIpKRiLmVlecLlX76ya8c o4ZQ== 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=+njPHg2Cw00DDUxIZmzP/xVN/N/bis3VmuLuljcfSBQ=; fh=zgMS+X4RExv2k7fU8QdWClnqVJdqO/9UbUuBS5xxJDs=; b=lOweZy7ctOOevg3mgi6dl8SUo3oYwhoiEqmG7K//VCSpdRuPjEBbit/VFsKQAZ0SkN JGsL7lAYzB6tdk4TEhiinO6IzG3+UnL5mYX2KFkp8g8/L5teWhny7JR3mukhrwEzse6W o2wQqnFrfkGPaOmB8Q7YIKfVQWXbxpY+172rqGjMxw/HcpSqMc43r16Jp7WhKYOt5Fc+ rwylQNDPxVvWwQ8yLkLCQUuTUdxsc7Ebjz3BS6BEiMh2rl+z3HnoApb/tHhs5jfl4OFD f9/L6JxGmd+OQ1jR8/AgwA7qQorADYMniLFe5AvOPVuLWvzDelC5Z9VCsDORTbJXYLdb D1PA==; 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 y19-20020a056402441300b0056bfcbd41a9si3240570eda.151.2024.03.26.08.10.00; Tue, 26 Mar 2024 08:10:24 -0700 (PDT) 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 081E268D19E; Tue, 26 Mar 2024 17:09:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from srv-infra-2.infra.inf.glb.tvvideoms.com (www.inf.tvvideoms.com [213.205.126.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F140168D07E for ; Tue, 26 Mar 2024 17:09:49 +0200 (EET) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-2.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id B408C4135C; Tue, 26 Mar 2024 15:09:48 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Mar 2024 16:09:45 +0100 Message-Id: <20240326150946.314054-1-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 0/1] avcodec/h264_parser: fix start of packet for some broken 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: Nicolas Gaullier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: trFfGuiJ//pP This is a patch from my patch serie https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=10999 Maybe it is easier to review it this way, independantly. This patch shows some benefits by itself, but most importantly, it is required for my patch serie to avoid any regression with some invalid streams. This patch is active in mpegts/h264 when the NAL Access Unit Delimiter is missing the zero_byte (= a invalid stream case). In such a case, if it happens that the last data byte from the previous frame is a null byte, this byte is "kidnaped" to form the full NAL_AUD... This is not good, but even worser, with my patch serie above applied, it means that the start of the editunit is in the previous frame, which means the pts has to be taken in it, which is not the expected behaviour in such a missleading scenario. Michael sent me a sample from the wild but it can't be shared, so here it is: I have another sample of my own with NAL_AUD missing zero_byte similarly, but it is missing the ending null byte, so I have patched/inserted the null byte (I shrinked the adaptation field) to show how the code behave. Sample original (invalid NAL_AUDs): https://0x0.st/Xs9Q.ts Same sample modified to exhibit the issue (invalid NAL_AUDs + an available null ending byte at 0x291F): https://0x0.st/Xs9j.ts I use this simple command line and then compare the xml, it seems quite clear: ffprobe xxx.ts -show_packets -show_data -print_format xml Nicolas Gaullier (1): avcodec/h264_parser: fix start of packet for some broken streams libavcodec/h264_parser.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)