From patchwork Sat Nov 27 21:45:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John-Paul Stewart X-Patchwork-Id: 31784 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp4121590iob; Sat, 27 Nov 2021 13:46:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv1tUwyufhcD6t3yqZxsbWHQayK/qJbO+zKWNqV3eRHa6FQLPdWukkQUeBjyyPxbD5ioEJ X-Received: by 2002:a17:906:398:: with SMTP id b24mr48411759eja.49.1638049580934; Sat, 27 Nov 2021 13:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638049580; cv=none; d=google.com; s=arc-20160816; b=GX87obJCyLdOHhMs/aoYsxrE9yRyFycqJd060lKkiICTXkzVSOs1zLFNUzfz9Q5ww7 WyH+/3/3wx1kNp+MOd4b/Tg7IOHoGrifKAfU3nCgRIh2JyqSQk52WWofU6uzAl979dZt E6rsjtQas8AKUZOvNV8/uLJV18CD/RQIW/gOBP8aIabO4Z8mjDJyDKmwNAeRIWiiMTq+ zZMRm2YT7dAtiVfkSxdiYPRDeGJ5WQb4CAN0KsF0sc8H2OmbEVBRdCYcg4/uHmwhrifh fXvYEjavdHYWrb9fcqLpDWSp07WGj2IkfK1+aj+Slj9vCn5hZTFb2xwdKMGdOZF13kel 6p/w== 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:dkim-signature:delivered-to; bh=ff8rPFVfpREE+i0RFKlF8Qlc5TdXSQPPqya1J2SWovY=; b=fptD6jiF+wcAuSbKGmuFCUkiIUECKJhYL56GTg4TrcD6GqsH847q/ObT4TEXVRq4Kd YoNPYW5xpY1yqxkZWr1U0lnaY9OwsJ8mQ/B3Pxzeo+71fwISj0bO/EK2o8vjMbxVymh5 oQ0Ew0lxXUQnJLyAhEsu7OChI/thMouaLjUqcy1dIW7RtGqARChDEckvkkkiCJa+mzqZ xVoGF7YbhJhBP++fgmGvsK2xzzfq4HOjAvji7Tf7AVuvASgQGpqLF+NSJqBoM+IOhhUN gZdcmzLztKsyvCGlRcElDcPiqVbzzAde/NYfsSZzpiwfwtyCu7gn1E7U7MUxrLlvWjsa BlPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@personalprojects.net header.s=20210601 header.b=KIvvBwGL; 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; dmarc=fail (p=QUARANTINE sp=REJECT dis=NONE) header.from=personalprojects.net Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c5si13563801edw.461.2021.11.27.13.46.20; Sat, 27 Nov 2021 13:46:20 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@personalprojects.net header.s=20210601 header.b=KIvvBwGL; 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; dmarc=fail (p=QUARANTINE sp=REJECT dis=NONE) header.from=personalprojects.net Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E3C4A68A987; Sat, 27 Nov 2021 23:46:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.personalprojects.net (mail.personalprojects.net [51.79.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F703689F02 for ; Sat, 27 Nov 2021 23:46:04 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=personalprojects.net; s=20210601; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9njp2sIiBJZLtqD/8Izx6jTehtlRAc3+PtZUGjT/atQ=; b=KIvvBwGLjiWD7Fem/gd2aKCX6f HKdC/ygy2GOi/b+U6NptIKNsGO2kN/Z7QcEOHfVYdmRd9pru3GmM8A8ofgPShZXrdWau40BNGIUDG zE+N+YnKXpIx9XZGb1sqT+MJzBMdeac98HInH49qwWcqCLeNCmK2YtX9CTbbKvID0R/g=; Received: from bras-base-simcon3012w-grc-05-64-231-188-105.dsl.bell.ca ([64.231.188.105] helo=courtney.binaryfoundry.ca) by mail.personalprojects.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mr5WE-0002Wi-Vb for ffmpeg-devel@ffmpeg.org; Sat, 27 Nov 2021 16:46:03 -0500 From: John-Paul Stewart To: ffmpeg-devel@ffmpeg.org Date: Sat, 27 Nov 2021 16:45:51 -0500 Message-Id: <20211127214551.22949-2-jpstewart@personalprojects.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211127214551.22949-1-jpstewart@personalprojects.net> References: <20211127214551.22949-1-jpstewart@personalprojects.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/mvdec: handle audio sample size X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: MucgV2rrGBrG Adds support for reading audio sample size from the data instead of assuming all audio is 16 bits per sample. --- libavformat/mvdec.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index 8492928820..8b54a9ab04 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -299,6 +299,8 @@ static int mv_read_header(AVFormatContext *avctx) if (version == 2) { uint64_t timestamp; int v; + uint32_t bytes_per_sample; + avio_skip(pb, 22); /* allocate audio track first to prevent unnecessary seeking @@ -341,11 +343,21 @@ static int mv_read_header(AVFormatContext *avctx) } avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate); - avio_skip(pb, 4); + bytes_per_sample = avio_rb32(pb); v = avio_rb32(pb); if (v == AUDIO_FORMAT_SIGNED) { - ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; + switch (bytes_per_sample) { + case 1: + ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8; + break; + case 2: + ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; + break; + default: + avpriv_request_sample(avctx, "Audio sample size %i bytes", bytes_per_sample); + break; + } } else { avpriv_request_sample(avctx, "Audio compression (format %i)", v); } @@ -369,7 +381,7 @@ static int mv_read_header(AVFormatContext *avctx) avio_skip(pb, 8); av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); - timestamp += asize / (ast->codecpar->channels * 2LL); + timestamp += asize / (ast->codecpar->channels * bytes_per_sample); } } else if (!version && avio_rb16(pb) == 3) { avio_skip(pb, 4);