From patchwork Wed Jun 13 17:10:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9392 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp892908jad; Wed, 13 Jun 2018 10:11:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKOnqs+Y2vdA6hi9DmGYwSErV8pQ2CpamPxxqtcqAn8T7pEqUhDp4rN0eZq8YlwLV8uS5NQ X-Received: by 2002:adf:9187:: with SMTP id 7-v6mr5181812wri.69.1528909879864; Wed, 13 Jun 2018 10:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528909879; cv=none; d=google.com; s=arc-20160816; b=Kuy/Thj5IBDrwCaow5mVwEGOow3aIwv76i8qisgYiGQOqzQCYNh4W4C7u62a3/vdw3 kGgV2Bg5gBtG5GC92aJd4P4p3dAYUJhBiAvskR8gKsS6CRCQ4UnCgc0itpP7lvpay3fI uHhvagZ1yCp3nA6M0JiON6GsnSIQiIZoPMDEfORuCDnQpqQh7W+Yair2o3T8Z1byeorI JJk4HKk7Xkbiv+7rnjV3nB2RF9iRG8BNx/6jhvAl9mv99hcrjkSIOIv2KZpVDjU1i0Qz hrcW1g8PNOCBHrQB7A6gyHHsPI/DWlWsKwo2oxQ1imv61Uwd+BeAsoS8wBFsazrBIwSZ 5AiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=xxzYPABs0yK2+g5WljXgZp917wo9vKJW2rJaEoRNCV4=; b=M/ZmzgVyGsX3xlJkv7tw7jcSgfw2IDz8ooKhohmXj7yZMF7LcRGcejWSdyS2VTbHRP rTvu5RLOIHuMewByQud8eapD30OKs11AupZDg9p+AxjUsm8v1YtjGLDrT6RrjI9XMHzt Vbzg3QdktWT8uqVZ9hnWLo+BzcfgapGdGntpwe/E93aPTPYsAHQc6sk0ighBDvcFGRx1 1mMEPZwxjm8sa8LiI2ikbFzDh0SGm0jY2gkRPDnxvvHJ2aVFJIQHhbAy+nymLCsO8rY4 E1M1ZxJ91eOXcQ72G/4Yt9J3BglxQK3z8+noGKUoSnNKSl+Ln2SAudwmvFNm91zhkBHt hnGw== 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 n44-v6si2569330wrn.186.2018.06.13.10.11.19; Wed, 13 Jun 2018 10:11:19 -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 704C368B102; Wed, 13 Jun 2018 20:10:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-3.mx.upcmail.net (vie01a-qmta-pe01-3.mx.upcmail.net [62.179.121.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0D6268B0DC for ; Wed, 13 Jun 2018 20:10:13 +0300 (EEST) Received: from [172.31.218.49] (helo=vie01a-dmta-pe07-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fT9IV-0003DV-SN for ffmpeg-devel@ffmpeg.org; Wed, 13 Jun 2018 19:11:03 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fT9IQ-0007ug-4j for ffmpeg-devel@ffmpeg.org; Wed, 13 Jun 2018 19:10:58 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id yHAu1x0450S5wYM01HAwSP; Wed, 13 Jun 2018 19:10:56 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 13 Jun 2018 19:10:26 +0200 Message-Id: <20180613171027.12538-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613171027.12538-1-michael@niedermayer.cc> References: <20180613171027.12538-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg: Fallback to duration if sample rate is unavailable 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Regression since: af1761f7 Fixes: Division by 0 Fixes: ffmpeg_crash_1 Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart Signed-off-by: Michael Niedermayer --- fftools/ffmpeg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index d4ac6903cc..ba8789a43c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2710,8 +2710,12 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo ist->dts = ist->next_dts; switch (ist->dec_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO: - ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) / - ist->dec_ctx->sample_rate; + if (ist->dec_ctx->sample_rate) { + ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) / + ist->dec_ctx->sample_rate; + } else { + ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + } break; case AVMEDIA_TYPE_VIDEO: if (ist->framerate.num) {