From patchwork Tue Aug 3 14:07:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sergio M. Ammirata, Ph.D." X-Patchwork-Id: 29216 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp2503703ioh; Tue, 3 Aug 2021 07:08:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvZcJywA3NymCJ9PAms62Fl3i84GUb6N45QPyG+hvNeMBzI2X5a1etopMTDP0Bhr2lojnw X-Received: by 2002:a17:906:5959:: with SMTP id g25mr20196954ejr.243.1627999720320; Tue, 03 Aug 2021 07:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627999720; cv=none; d=google.com; s=arc-20160816; b=Ad6f9QLrhi3dhDS+HOWaBicvT0+8aofgCZ826Zdl6ayLEYSEMP6DXh1zTTvqvYnOSq PomWLDfmUmcl2ovI2q4uTpFdWkc6wkCJ4qzwqe8/ojQM5rtMIPG/LtdCRex3tUWV6f9o LjVZLT8jcS0ezDKFGDHjuGkEf5tFkOadEMMnha3rEOgcTvkUoSydhQyecYG0RPou0xDG +U0lAECujvHIwZkgdfky1I7/ignfPH/qcFIKDx3aBnwYwIZMUVsKZZwFqTB/wp6f30J0 juBVyRKrUoJPBuVVRDk16gjLY0uByCN7LCB/TqruLKPdpZ6agfXEOVub/2lgoczQ1x3y J09g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :feedback-id:mime-version:date:to:from:message-id:dkim-signature :dkim-signature:delivered-to; bh=5uhXdw9YfR4sil3/UtxY7qZBistKaun2+IX3uSq6TfY=; b=iFQqtI/sa/2tzUlJ4U400HGqvrH2D2/LzFtvgqWb9Bi7MrKcs0W14CRRPNPs+8NxNV PMJq5YKosHHaE9T5dq5VPKJVglWJqseWBZJ/TR4GEQ3xLxS34a8DYxBtwmqPbFGRb+ag IIe43Yxi0c4aEhlRzHqyE8dbalIPqf/ch8JRxz+WZQH2tvj7gs6T5kjKOqF9Ic1P4mCU eUfOMFoOsBfn8Lrpya6WTkatlfaoDmU8y8E/TMfV6o7VA9nu49reVAslLsRcCEg53x1T P0dLo4d4af8AisiUA+0JYQoNf+X+pXieEWXf5BxJQkhoe/qhI7KNhHTgQM+cNFMllegF IDOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpcorp.com header.s=a1-4 header.b=ZYe51pKc; dkim=neutral (body hash did not verify) header.i=@ammirata.net header.s=s472648 header.b=Kf+fDUYa; 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 se2si13644548ejb.241.2021.08.03.07.08.39; Tue, 03 Aug 2021 07:08:40 -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; dkim=neutral (body hash did not verify) header.i=@smtpcorp.com header.s=a1-4 header.b=ZYe51pKc; dkim=neutral (body hash did not verify) header.i=@ammirata.net header.s=s472648 header.b=Kf+fDUYa; 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 7491C689D6F; Tue, 3 Aug 2021 17:08:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i682.smtp2go.com (unknown [103.47.206.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8FCC36808EB for ; Tue, 3 Aug 2021 17:08:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a1-4; h=Feedback-ID:X-Smtpcorp-Track:Date:To:From:Subject: Message-ID:Reply-To:Sender:List-Unsubscribe; bh=N6sB0TMqaxzu5pwYpS1ZqLEfemRXtAHshcidjdRKh0I=; b=ZYe51pKcv0BoXpCyg86c+xSdCT Aad4CcI2cIZ8tV4/5p0YQmSaXQtUQ3V7+BexITvcEmubTu3aE6Zb7Cb4a2Uzs9JzrYaCeqOAQiWgw 1oCJC0s46qX+EGVWWH0Gp8WUe8tO3LIf7nim6CeU8NBZKuNowdsPcuIPzEMVwWPZMzg9BaIOexalx MeMBa2S90WUwfku2WSfAhKPCvYcgElDeiRdan+fLklopy2l3wAzvkqs1ww+9syIHLi9RBwj1Q5mB6 uSy9FFCZbFp8k2tat56pfULq/36EVuGo6lhN0QheZ5i0hDHNd5rFjcDTURVfF/iKHHLGJ12JlNolT zJ/IB4sw==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ammirata.net; i=@ammirata.net; q=dns/txt; s=s472648; t=1627999709; h=from : subject : to : message-id : date; bh=N6sB0TMqaxzu5pwYpS1ZqLEfemRXtAHshcidjdRKh0I=; b=Kf+fDUYazR6IUWzYYQwudm8o17llNLwWqt622mQfJlpsr+zjflgb8og5/cRHzpWKhMCDd OfvH3jK4NKVwKdnQCjPJ1EQZ4WOhUh1fQ1cNCrRJQtD3oUNMC6omUS8pN7amx6cEUpaJZWa ew1Ka1YHqDkUIotR2/rKnmO9NrHzJB/jEYZdNmC3RjWO2cbjnxr3Z5E/rl4804k9TnzqWqf vnCthAhbB4JeDbLjp2kVn+E3/23iPDKOlUT8ZmRL3/24/lfuS+s/cSd6/FxGq/xQUUmUJcl LXscixx8CP/jKZKb9A8dze0pB3vAXhPIetGHovLtAqh1g0Vf1jcQQMvucGlg== Received: from [10.45.79.170] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1mAv5n-piP17j-5P for ffmpeg-devel@ffmpeg.org; Tue, 03 Aug 2021 14:08:27 +0000 Received: from [10.99.93.62] (helo=mail2.sipradius.com) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_SECP521R1__RSA_SHA512__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1mAv5m-bMEpQF-HI for ffmpeg-devel@ffmpeg.org; Tue, 03 Aug 2021 14:08:26 +0000 Received: from localhost (localhost [127.0.0.1]) by mail2.sipradius.com (Postfix) with ESMTP id 8353A1034438B for ; Tue, 3 Aug 2021 10:08:25 -0400 (EDT) Received: from mail2.sipradius.com ([127.0.0.1]) by localhost (mail2.sipradius.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8BpkawO0lyEo for ; Tue, 3 Aug 2021 10:08:24 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail2.sipradius.com (Postfix) with ESMTP id CDC3B1047CFDE for ; Tue, 3 Aug 2021 10:08:24 -0400 (EDT) Received: from mail2.sipradius.com ([127.0.0.1]) by localhost (mail2.sipradius.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BlGKY1Gfc3vJ for ; Tue, 3 Aug 2021 10:08:24 -0400 (EDT) Received: from sergio-ThinkPad-X1-Extreme-2nd (104-12-104-240.lightspeed.miamfl.sbcglobal.net [104.12.104.240]) by mail2.sipradius.com (Postfix) with ESMTPSA id A8EDF102F38A6 for ; Tue, 3 Aug 2021 10:08:24 -0400 (EDT) Message-ID: <4b90cd303402a9f87964aef883271c53c4ee8c78.camel@ammirata.net> From: "Sergio M. Ammirata, Ph.D." To: ffmpeg-devel@ffmpeg.org Date: Tue, 03 Aug 2021 10:07:34 -0400 Mime-Version: 1.0 X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 X-Smtpcorp-Track: 1Xjv5XPuEpQFHm.CY3PDnISqf-oE Feedback-ID: 472648m:472648a-fcoam:472648sgvCITS8RT X-Report-Abuse: Please forward a copy of this message, including all headers, to X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] Fix for PES packets with too much padding 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: uCM/SlLtkfV5 PES packet with too much padding trigger unlimited error messages "PES packet size mismatch" because the code that corrects the length is wrong. Here is a sample file: http://99.93.62.129/smpte2038.ts PID 300 is the one triggering the errors. I am attaching a patch that fixes the problem. Subject: [PATCH] Fix setting the correct size for PES packets with too much padding --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 640c9afa5d..40439c26c0 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1355,7 +1355,7 @@ skip: buf_size > pes->total_size) { // pes packet size is < ts size packet and pes data is padded with 0xff // not sure if this is legal in ts but see issue #2392 - buf_size = pes->total_size; + buf_size = PES_START_SIZE + pes->total_size - pes->pes_header_size; } memcpy(pes->buffer->data + pes->data_index, p, buf_size); pes->data_index += buf_size;