From patchwork Sat Nov 27 21:45:50 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: 31783 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp4121489iob; Sat, 27 Nov 2021 13:46:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYrQF3pji5PiReoW0yJfjBcQoK2jJZIDK7zMvzWSKV7zbhKlZ3q6yyvlaL7pPlUUGlCd4Q X-Received: by 2002:a17:906:9744:: with SMTP id o4mr50232925ejy.322.1638049572636; Sat, 27 Nov 2021 13:46:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638049572; cv=none; d=google.com; s=arc-20160816; b=h/R0G9QZWWCc6+BcwuVcj+hiAC8810baXXrUDF2LDuTqaJavQP2aWjDyE3lBuYw3td Z+4ruCwHQqYVT/DpQGU/VPwRdBReHZvRQ8vtXZVlrtyrII1QO1mOwFfofmNvJSn3kSbZ x6hZvUTs98hZSXaKtU5ayooc4JWlzi7CCQTvIKLowRuzfcdHALe0qiunuf6Hj8d76/MZ +8dwnx50dThLGASgvJG8pRxcuJTCk06zUN4zUDZSp+W803nHJU6c83UPkoFQZSjD6LOK 36dlgCG1Y4luzD85VX8mXuDaQKz3sL9jQGSXE4KSJamYkbjBXxji4ABZ3W7Vzibp4BFK SfxQ== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=tGCFR/pwyLf/cievr2sTowfo+Y3STtC+h3ci4Xe/fiU=; b=KVZMvSs1dwZKYXmWoPy5kyjxHhIDPFPIwHQ72g4FjspN6D1ynXTlEpl6EMQyfkKesj Nz6bgyuy2sDwj/oTv6MNvkI/yK0/JHWWQYh0twDdWKZwsXEaqXYifpEtKTmAuSGu7vUC wszES4daUSGIx5ZClcRffb8X0CRxBLbSMA4HWU4cg5pwG6u3NpA0lJUVZsMKSKezbyQm mLEYsT64HnH+4bwynZZnXfBaOZL5u9Eo+pnkFnYFrqCa8F/OYP/rLJCXRkbCSEYjVkuh ZyxH/gPq3HVDRdRRfgMnPk8dB5QJ/49QBljrrt7pyfyGNicpcNiO2VNHbbfRJmt5fjo6 LqXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@personalprojects.net header.s=20210601 header.b=RfLzUhhK; 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 ar21si15016613ejc.732.2021.11.27.13.46.11; Sat, 27 Nov 2021 13:46:12 -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=RfLzUhhK; 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 EA800689A1E; Sat, 27 Nov 2021 23:46:08 +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 53B26689A1E for ; Sat, 27 Nov 2021 23:46:02 +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: 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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=KjtOrBKkrHvUk5uTp1t8tI5s90HWDKUUQkd9ZNlSD84=; b=RfLzUhhKHYxPTzgrrdOU0YlpTw EBqfM9kdmzWeFcUn60dmIBdjZr+T5AH/HD3l64Ej77exXT5yVPyh9zY95xEYBXXdkwht87bR9uaOJ CUuEPWzzC8QR94m5cN3mEW/mKNP03XOQGn6sGElbzCr5YDRXXHRDdUrto4Ob7xtrfvnU=; 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 1mr5WD-0002Wi-3T for ffmpeg-devel@ffmpeg.org; Sat, 27 Nov 2021 16:46:01 -0500 From: John-Paul Stewart To: ffmpeg-devel@ffmpeg.org Date: Sat, 27 Nov 2021 16:45:50 -0500 Message-Id: <20211127214551.22949-1-jpstewart@personalprojects.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/mvdec: fix reading number of audio channels 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: IUFXlblY7TOR The number of audio channels is stored after the magic number identifying the audio format. Prior to this patch the code has been reading it earlier, causing files with only one audio channel to be handled incorrectly. --- libavformat/mvdec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index d58281c3a9..8492928820 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -340,8 +340,8 @@ static int mv_read_header(AVFormatContext *avctx) return AVERROR_INVALIDDATA; } avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate); - if (set_channels(avctx, ast, avio_rb32(pb)) < 0) - return AVERROR_INVALIDDATA; + + avio_skip(pb, 4); v = avio_rb32(pb); if (v == AUDIO_FORMAT_SIGNED) { @@ -350,7 +350,11 @@ static int mv_read_header(AVFormatContext *avctx) avpriv_request_sample(avctx, "Audio compression (format %i)", v); } - avio_skip(pb, 12); + if (set_channels(avctx, ast, avio_rb32(pb)) < 0) + return AVERROR_INVALIDDATA; + + avio_skip(pb, 8); + var_read_metadata(avctx, "title", 0x80); var_read_metadata(avctx, "comment", 0x100); avio_skip(pb, 0x80); 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);