From patchwork Mon Jun 11 07:43:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 9362 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp3819814jad; Mon, 11 Jun 2018 01:10:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIwYPZDHXF50Gq4hzE0LJ8Ul9uXmQ9X6WJgFzqLlmWpfOc6cdVKjNUjtq1NnweNzrX5sJFa X-Received: by 2002:a1c:7d56:: with SMTP id y83-v6mr8349463wmc.65.1528704643792; Mon, 11 Jun 2018 01:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528704643; cv=none; d=google.com; s=arc-20160816; b=n/Xk64MIXiaTr9koACn73T5ZWWE8wiT2sX2ulwTJGA3DFAeRYvMkU8Edygn/zOMjDO F3vBfERe4alUnapA9TB0orWpjNElcGaXRhlaUhG11B7aYaGbU0N0tImaHp9Zii2Q9u1G wchwxDg39vGEn8I5KC8MLreElEjdtR+GDdNwaIhWlAkza7yrfL7yEyP7cEpLUImPjTtF sUf6Mnv+zethEDM18/Y+CtRzdHJkJBtoLcDBcUE63MXwfrDs6iHpRl8MMO/KeAqieD3s ErPFNjwlQUsgJ79geGWAl6abfte5+hSvgT5WrShJBh7Nx9nq9X2tVlc8svPuM4GQ5WEn q6Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=iBT73sPKZC+EZDv/8Stc8xSRGJDiC83i4n1m0T6WY8g=; b=HYOIGgQmoCMwSsRmSFOyuBihwuvrA05z7+aWs2zRfTZwhGSTK7iHQt47KqosVqneG0 Aqnqa2pIzoPVTFsKiiwGNibXwDnIl0VRQXrbFnSRCodlOi6MeDfpt/pFmYIvhGhhLyJx AIVzBVl+cNhtQ8ct+pzjgWxDjiJzP+ic69u9liik510bJ2jTK+cEvFp3Z1Hs62F9IWF/ lhg0nWn5BTpYdLCBfRPpvpW/OybnSFlOLnB8GFbyQK9Q1wAOGeIJuMIxc1JzCR+fCVR0 kRPBAiCH0fAgTmvlKQRXQMP4zNmUyXSs2s0eu4iZoboeNuahTY8J1TNBezJzVxFfdL3o rBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=Rwh9Uhk9; 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 j194-v6si5675999wmd.60.2018.06.11.01.10.42; Mon, 11 Jun 2018 01:10:43 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=Rwh9Uhk9; 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 33F8168ACC5; Mon, 11 Jun 2018 11:09:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1721568ACA9 for ; Mon, 11 Jun 2018 11:09:46 +0300 (EEST) Received: by mail-pg0-f65.google.com with SMTP id z1-v6so9368412pgv.12 for ; Mon, 11 Jun 2018 01:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=rUG5UoJ/iF5B/DfE5w6G81Df+7QV4Uqnx4Ue+IHnwiM=; b=Rwh9Uhk9xhvDuSFZN9EpIq8JVCx/GGQUR4vXgYGnBt5cFpdf28Oa374MC4cQtPfa67 4/KR0lBN0zD4Pt++mLfh50zp/qTHjw0OStNIxDwKWTTlOSZMWaYdpDXR2VXPXhQrlIx4 fBp+YiAWlQfseex5ZIGUd5kZU2JtDrreqCgar39ht6HVB6yUlc8IJU1JVXwmd5PF2G94 BGSoZyOOsUtKQBCywyI7jRsIV3cu1QoZN9wnx9hzkd9kV8k/E217ay/hzRB24RH+lbFh hnaUKMoUH66oqBLvCr8RwgTh/9t88frMPryGMyR8JBTfSmkKZoVCcaPTNcmP1hWUG8i6 3kTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=rUG5UoJ/iF5B/DfE5w6G81Df+7QV4Uqnx4Ue+IHnwiM=; b=tHrYeDqBTS+37nqdIGL3zdqXn1juO1B1tNAGOAjS0450eHIZliVSEi7rU9WmhvBpUB OShThLFQfIjIWqUISYflGxI9zQdMWpF7Yni1AKaneRr20MRlPy31KKYHHRCMRtdGdm8g /acEMf4abfhxIrSW9TTmZNv26AGTaCd2jQWcFeQ6F7c6sc5D/XHd8Qt/vYOMEfvT6Q83 j8ZJu94i83buKudGMIrG40+GrA+4Sl44tFmCEhDrBdzMP+vlk0dJePLleeFzyf1zxNbZ jN159NsvorRQ8BuwuOyQ9V4aamtCcfd8fBpKuRziwm1Ls2tLjPoxHFqNz0nsglpCuX3m YzMQ== X-Gm-Message-State: APt69E0WHeq8HBJBFMt6aklNe+JmjYC3umgLxWia1K6KNWcnEwDVD3d1 T2MYfQvZp49zxGLK4lPI8aNC/Oc8 X-Received: by 2002:aa7:818b:: with SMTP id g11-v6mr7720960pfi.50.1528703019634; Mon, 11 Jun 2018 00:43:39 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id 131-v6sm112677392pfa.128.2018.06.11.00.43.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jun 2018 00:43:38 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Jun 2018 00:43:31 -0700 Message-Id: <20180611074331.28844-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH] avformat/mpegts: parse large PMTs with multiple tables X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: michael@niedermayer.cc, Aman Gupta , jeebjp@gmail.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta In 9152c1e4955, the mpegts parser was taught how to parse PMT sections which contained multiple tables. That commit fixed parsing of PMT packets from some cable providers, which included a special SCTE table (0xc0) before the standard program map table (0x2). Sometimes, however, the combined 0xc0 and 0x2 tables are larger than a single TS packet (188 bytes). The mpegts parser already attempts to parse sections which span multiple packets, but still assumed that the split section only contained one table. This patch fixes parsing of such a sample[1]. Before: Input #0, mpegts, from 'combined-pmt-tids-split.ts': Duration: 00:00:01.26, start: 39188.931756, bitrate: 597 kb/s Program 1 No Program Stream #0:0[0xeff]: Audio: ac3, 48000 Hz, mono, fltp, 64 kb/s Stream #0:1[0xefd]: Audio: mp3, 0 channels, fltp Stream #0:2[0xefe]: Unknown: none After: Input #0, mpegts, from 'combined-pmt-tids-split.ts': Duration: 00:00:01.27, start: 39188.931756, bitrate: 589 kb/s Program 1 Stream #0:0[0xefd]: Video: h264 ([27][0][0][0] / 0x001B), none, 59.94 fps, 59.94 tbr, 90k tbn, 180k tbc Stream #0:1[0xefe](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 384 kb/s Stream #0:2[0xeff](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, mono, fltp, 64 kb/s Stream #0:3[0xf00]: Data: scte_35 Stream #0:4[0xf01]: Unknown: none (ETV1 / 0x31565445) Stream #0:5[0xf02]: Unknown: none (ETV1 / 0x31565445) Stream #0:6[0xf03]: Unknown: none ([192][0][0][0] / 0x00C0) With the patch, the PMT is parsed correctly so the streams are created in the correct order, are associated with "Program 1", and their codecs are set correctly. [1] https://s3.amazonaws.com/tmm1/combined-pmt-tids-split.ts Signed-off-by: Aman Gupta --- libavformat/mpegts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 5f53f77d89..a5cb17ac16 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -465,6 +465,7 @@ static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1, offset += tss->section_h_size; tss->section_h_size = -1; } else { + tss->section_h_size = -1; tss->end_of_section_reached = 0; break; }