From patchwork Tue Feb 4 13:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 17687 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 812B44495AC for ; Tue, 4 Feb 2020 15:49:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5887168AA74; Tue, 4 Feb 2020 15:49:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 785E068A9F3 for ; Tue, 4 Feb 2020 15:49:43 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1iyyaF-0009j3-0Z for ffmpeg-devel@ffmpeg.org; Tue, 04 Feb 2020 14:49:43 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id yyZGiUgD0wlysyyZGiQOwy; Tue, 04 Feb 2020 14:48:43 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=gOTRDTDy0XsTEYgJxJMA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 4 Feb 2020 14:48:42 +0100 Message-Id: <20200204134842.32297-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfHNhV8ONkYz0G9efoTPHKGeD1SDnvDJ/lqWag0o0hMQh7GR7a1dZIZFhByGPUXlfYXztTsiM3kGg/tiVLLBvYHdCegjnxnz77RtiMzyIBKL+oQImX0Lx gTl81msZq2vm/z1/HStU9hb8xKSP6ejhznptkGgN0xoMpU1ZYPWB4jRb Subject: [FFmpeg-devel] [PATCH] avformat/mov: Discard last STSC if its empty 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" Fixes: Ticket8508 --- libavformat/mov.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index bbaf266a4b..726e69ba53 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2665,6 +2665,10 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->stsc_data[i].id < 1) { av_log(c->fc, AV_LOG_WARNING, "STSC entry %d is invalid (first=%d count=%d id=%d)\n", i, sc->stsc_data[i].first, sc->stsc_data[i].count, sc->stsc_data[i].id); if (i+1 >= sc->stsc_count) { + if (sc->stsc_data[i].count == 0 && i > 0) { + sc->stsc_count --; + continue; + } sc->stsc_data[i].first = FFMAX(sc->stsc_data[i].first, first_min); if (i > 0 && sc->stsc_data[i].first <= sc->stsc_data[i-1].first) sc->stsc_data[i].first = FFMIN(sc->stsc_data[i-1].first + 1LL, INT_MAX);