From patchwork Tue Jul 26 10:51:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anssi Hannula X-Patchwork-Id: 3 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1225097vsd; Tue, 26 Jul 2016 03:51:26 -0700 (PDT) X-Received: by 10.28.232.149 with SMTP id f21mr23537911wmi.51.1469530286132; Tue, 26 Jul 2016 03:51:26 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dd7si178720wjc.269.2016.07.26.03.51.25; Tue, 26 Jul 2016 03:51:26 -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 C568D68A3FF; Tue, 26 Jul 2016 13:51:18 +0300 (EEST) 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 E8CDE68A3F9 for ; Tue, 26 Jul 2016 13:51:09 +0300 (EEST) 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 345E6230EE for ; Tue, 26 Jul 2016 13:51:08 +0300 (EEST) Received: by mail.onse.fi (Postfix, from userid 501) id 19966404C6; Tue, 26 Jul 2016 13:51:08 +0300 (EEST) From: Anssi Hannula To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Jul 2016 13:51:04 +0300 Message-Id: <1469530264-30423-1-git-send-email-anssi.hannula@iki.fi> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found 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 9200514ad8717c6 ("lavf: replace AVStream.codec with AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed avformat_find_stream_info() to put the extradata it got from st->parser->parser->split() to avctx instead of st->codec. However, in the same function, the "is stream ready?" check was changed to check for extradata in st->codecpar instead of st->codec. Extradata retrieved from split() is therefore not considered anymore, and avformat_find_stream_info() will therefore needlessly continue probing in some cases. Fix that by putting the extradata in st->codecpar, from where it will be copied to avctx at the end of avformat_find_stream_info() along with all other parameters. --- I'm not overly familiar with this code, so review accordingly :) This can be reproduced e.g. with a simple sample generated with "ffmpeg -t 20 -f lavfi -i cellauto out.ts", where ffprobe will analyze for 7 seconds (mpegts max_stream_analyze_duration) instead of the expected 5 seconds (max_analyze_duration). The difference will be more dramatic with streams that trigger the "stop find_stream_info from waiting for more streams when all programs have received a PMT" check in mpegts demuxer. libavformat/utils.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index e5a99ff..392143e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3581,16 +3581,16 @@ FF_ENABLE_DEPRECATION_WARNINGS if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ff_rfps_add_frame(ic, st, pkt->dts); #endif - if (st->parser && st->parser->parser->split && !avctx->extradata) { + if (st->parser && st->parser->parser->split && !st->codecpar->extradata) { int i = st->parser->parser->split(avctx, pkt->data, pkt->size); if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { - avctx->extradata_size = i; - avctx->extradata = av_mallocz(avctx->extradata_size + - AV_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) + st->codecpar->extradata_size = i; + st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!st->codecpar->extradata) return AVERROR(ENOMEM); - memcpy(avctx->extradata, pkt->data, - avctx->extradata_size); + memcpy(st->codecpar->extradata, pkt->data, + st->codecpar->extradata_size); } }