From patchwork Sat Sep 5 12:05:03 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: 22113 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 0A9CD44AECC for ; Sat, 5 Sep 2020 15:05:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B7C1E68A9AA; Sat, 5 Sep 2020 15:05:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5EBEB689F1A for ; Sat, 5 Sep 2020 15:05:09 +0300 (EEST) Date: Sat, 05 Sep 2020 12:05:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail2; t=1599307507; bh=DIcYacvEMbiOSegfcgdbDBb6XGbFgW2sghO93g4hmT8=; h=Date:To:From:Cc:Reply-To:Subject:From; b=jNefgvx1zgOiVIUPOsUqqAeIycP/o7Yq1kKdnpeRCe7DoojB5inN4Vl55hQdSmlUI Hs0dBBAS/+xCrGrHcxQnhg8W0XLZIiSJivLLXRIxAR2FpwSVS3TUekhDuEjYEROdIS sOR4v+gCIWtxChUPJBB9z/cZF6dqrTzxjifAZmnzpOMoc5xfav+eqE0STVW7gtWbvK JojlGXpO5YTtwbpfhOxVs0Apai1sQ7oqR5zC2c4tXtOvTSPpMDKwBUaefGyrq/9Mq8 xv04BRJp/Edwo4LL4/710tk0qOXPhFBUZKE6Dy97HCp3qE61N/nHf0xxD5za5gak9y //eVkrjFpql1w== To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200905120444.26620-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] avformat/argo_asf: fix handling of v1.1 files 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" Version 1.1 (FX Fighter) files all have a sample rate of 44100 in the header, but only play back correctly at 22050. Force the sample rate to 22050 when reading, and restrict it when muxing. Signed-off-by: Zane van Iperen --- libavformat/argo_asf.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 37ad2bf5e9..bf9b5d0c0a 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -187,7 +187,11 @@ static int argo_asf_read_header(AVFormatContext *s) st->codecpar->channels = 1; } - st->codecpar->sample_rate = asf->ckhdr.sample_rate; + /* v1.1 files (FX Fighter) are all marked as 44100, but are actually 22050. */ + if (asf->fhdr.version_major == 1 && asf->fhdr.version_minor == 1) + st->codecpar->sample_rate = 22050; + else + st->codecpar->sample_rate = asf->ckhdr.sample_rate; st->codecpar->bits_per_coded_sample = 4; @@ -264,6 +268,7 @@ AVInputFormat ff_argo_asf_demuxer = { #if CONFIG_ARGO_ASF_MUXER static int argo_asf_write_init(AVFormatContext *s) { + ArgoASFMuxContext *ctx = s->priv_data; const AVCodecParameters *par; if (s->nb_streams != 1) { @@ -279,6 +284,11 @@ static int argo_asf_write_init(AVFormatContext *s) return AVERROR(EINVAL); } + if (ctx->version_major == 1 && ctx->version_minor == 1 && par->sample_rate != 22050) { + av_log(s, AV_LOG_ERROR, "ASF v1.1 files only support a sample rate of 22050\n"); + return AVERROR(EINVAL); + } + if (par->channels > 2) { av_log(s, AV_LOG_ERROR, "ASF files only support up to 2 channels\n"); return AVERROR(EINVAL); @@ -351,7 +361,12 @@ static int argo_asf_write_header(AVFormatContext *s) chdr.num_blocks = 0; chdr.num_samples = ASF_SAMPLE_COUNT; chdr.unk1 = 0; - chdr.sample_rate = par->sample_rate; + + if (ctx->version_major == 1 && ctx->version_minor == 1) + chdr.sample_rate = 44100; + else + chdr.sample_rate = par->sample_rate; + chdr.unk2 = ~0; chdr.flags = ASF_CF_BITS_PER_SAMPLE | ASF_CF_ALWAYS1;