From patchwork Sun Nov 6 21:44:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anssi Hannula X-Patchwork-Id: 1317 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp835541vsb; Sun, 6 Nov 2016 13:52:21 -0800 (PST) X-Received: by 10.28.91.143 with SMTP id p137mr5948788wmb.51.1478469141525; Sun, 06 Nov 2016 13:52:21 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ee10si26189965wjd.270.2016.11.06.13.52.21; Sun, 06 Nov 2016 13:52:21 -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 BEBCB68921B; Sun, 6 Nov 2016 23:52:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from webmail.tpnet.fi (webmail.tpnet.fi [62.106.63.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B7EF687EB8 for ; Sun, 6 Nov 2016 23:52:09 +0200 (EET) Received: from mail.onse.fi (host-109-204-145-182.tp-fne.tampereenpuhelin.net [109.204.145.182]) by webmail.tpnet.fi (Postfix) with ESMTPS id 14CF324F71 for ; Sun, 6 Nov 2016 23:44:30 +0200 (EET) Received: by mail.onse.fi (Postfix, from userid 501) id E28DC40ECC; Sun, 6 Nov 2016 23:44:29 +0200 (EET) From: Anssi Hannula To: ffmpeg-devel@ffmpeg.org Date: Sun, 6 Nov 2016 23:44:14 +0200 Message-Id: <1478468655-2874-3-git-send-email-anssi.hannula@iki.fi> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478468655-2874-1-git-send-email-anssi.hannula@iki.fi> References: <1478468655-2874-1-git-send-email-anssi.hannula@iki.fi> Subject: [FFmpeg-devel] [PATCH 2/3 v2] avformat/hls: Fix probing mpegts audio streams that use probing 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Commit 04964ac311abe670f ("avformat/hls: Fix missing streams in some cases with MPEG TS") caused a regression where subdemuxer streams that use probing (e.g. dts/eac3/mp2 in mpegts) no longer get probed properly. This is because the codec parameters from the subdemuxer stream, once probed, are not passed on to the main stream. Fix that by updating the codec parameters if the codec id changes. Signed-off-by: Anssi Hannula --- v2: Added need_context_update = 1 and shortened the av_rescale_q() call to use the new ist pointer. libavformat/hls.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 6fb652c..ce52bf5 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1536,6 +1536,8 @@ static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE); else avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); + + st->internal->need_context_update = 1; } /* add new subdemuxer streams to our context, if any */ @@ -1950,6 +1952,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) /* If we got a packet, return it */ if (minplaylist >= 0) { struct playlist *pls = c->playlists[minplaylist]; + AVStream *ist; + AVStream *st; ret = update_streams_from_subdemuxer(s, pls); if (ret < 0) { @@ -1972,15 +1976,23 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_BUG; } + ist = pls->ctx->streams[pls->pkt.stream_index]; + st = pls->main_streams[pls->pkt.stream_index]; + *pkt = pls->pkt; - pkt->stream_index = pls->main_streams[pls->pkt.stream_index]->index; + pkt->stream_index = st->index; reset_packet(&c->playlists[minplaylist]->pkt); if (pkt->dts != AV_NOPTS_VALUE) c->cur_timestamp = av_rescale_q(pkt->dts, - pls->ctx->streams[pls->pkt.stream_index]->time_base, + ist->time_base, AV_TIME_BASE_Q); + /* There may be more situations where this would be useful, but this at least + * handles newly probed codecs properly (i.e. request_probe by mpegts). */ + if (ist->codecpar->codec_id != st->codecpar->codec_id) + set_stream_info_from_input_stream(st, pls, ist); + return 0; } return AVERROR_EOF;