From patchwork Sun Sep 20 08:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 22513 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 9AB71449284 for ; Sun, 20 Sep 2020 11:06:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7DFC468B6CB; Sun, 20 Sep 2020 11:06:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2707568B682 for ; Sun, 20 Sep 2020 11:06:27 +0300 (EEST) Date: Sun, 20 Sep 2020 08:06:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail2; t=1600589186; bh=b7TDvoVDgYNL7d8tmyNR8WRYYJNoIoGn1JuLw54YtVg=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=OwiGhUilL3uq29AyqbZyTalXABZFURoSkVltYf30k/OoLY3hyh/j5uqGhpC5uJGx8 K3CH7cAaKKb2U24w1gN96i+xNOE800Xfz6P9ty8BUnZpN1Cp43DbMzg/lM0FMyBVcK JYL4eYWR/+3Q+cN1YU+fzWMuosOaRRhBI/Lxt8qx5culSW80XLtsEAMotXrFdfHGoo QbYXQpoOJGxp0BAxjQUuuJB1DTD2t44PFl0O/+JaL/AbOkuZ5mlrHYzEEAhVPjU6AM XQTFd1YSllR9qiMu50NmNKeJgEbhpRd/FSaWXHxRr3kpDcVV0rxqRL8VNfQd6XENho zIq4orh97rQ2Q== To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200920080528.26200-2-zane@zanevaniperen.com> In-Reply-To: <20200920080528.26200-1-zane@zanevaniperen.com> References: <20200920080528.26200-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Subject: [FFmpeg-devel] [PATCH 01/10] avformat/argo_asf: fix enforcement of chunk count 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: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Enforcing num_chunks == 1 only makes sense when demuxing from an ASF file. When embedded in a BRP file, an ASF stream can have multiple chunks. Signed-off-by: Zane van Iperen --- libavformat/argo_asf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 048e5441d6..eb0c18601d 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -59,11 +59,6 @@ int ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader if (hdr->magic != ASF_TAG || hdr->num_chunks == 0) return AVERROR_INVALIDDATA; - if (hdr->num_chunks > 1) { - avpriv_request_sample(s, ">1 chunk"); - return AVERROR_PATCHWELCOME; - } - if (hdr->chunk_offset < ASF_FILE_HEADER_SIZE) return AVERROR_INVALIDDATA; @@ -139,8 +134,12 @@ int ff_argo_asf_fill_stream(AVStream *st, const ArgoASFFileHeader *fhdr, avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); st->start_time = 0; - st->duration = ckhdr->num_blocks * ckhdr->num_samples; - st->nb_frames = ckhdr->num_blocks; + + if (fhdr->num_chunks == 1) { + st->duration = ckhdr->num_blocks * ckhdr->num_samples; + st->nb_frames = ckhdr->num_blocks; + } + return 0; } @@ -199,6 +198,10 @@ static int argo_asf_read_header(AVFormatContext *s) if ((ret = ff_argo_asf_validate_file_header(s, &asf->fhdr)) < 0) return ret; + /* This should only be 1 in ASF files. >1 is fine if in BRP. */ + if (asf->fhdr.num_chunks != 1) + return AVERROR_INVALIDDATA; + if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0) return ret;