From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 27028430AF for ; Sun, 19 Jun 2022 21:54:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE9F468B5D7; Mon, 20 Jun 2022 00:54:13 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 815ED68B453 for ; Mon, 20 Jun 2022 00:54:07 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D92E7E73AD; Sun, 19 Jun 2022 23:54:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p9n9d-wxLl0i; Sun, 19 Jun 2022 23:54:06 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EBBEBE73A6; Sun, 19 Jun 2022 23:54:05 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Jun 2022 23:53:40 +0200 Message-Id: <20220619215340.9508-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220619215340.9508-1-cus@passwd.hu> References: <20220619215340.9508-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: read PCM audio configuration box ('pcmC') if available 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 Cc: Ivan Baykalov <4rusxg@gmail.com>, Marton Balint Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Ivan Baykalov <4rusxg@gmail.com> For ipcm and fpcm streams, big-endian format is the default, but it can be changed with additional 'pcmC' sub-atom of audio sample description. Details can be found in ISO/IEC 23003-5:2020 Fixes ticket #9763. Fixes ticket #9790. Patch simplified by Marton Balint. Signed-off-by: Marton Balint --- libavformat/mov.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0660a51492..c6fbe511c0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1553,6 +1553,9 @@ static void set_last_stream_little_endian(AVFormatContext *fc) st = fc->streams[fc->nb_streams-1]; switch (st->codecpar->codec_id) { + case AV_CODEC_ID_PCM_S16BE: + st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; + break; case AV_CODEC_ID_PCM_S24BE: st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; break; @@ -1579,6 +1582,24 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + int format_flags; + + if (atom.size < 6) { + av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n"); + return AVERROR_INVALIDDATA; + } + + avio_r8(pb); // version + avio_rb24(pb); // flags + format_flags = avio_r8(pb); + if (format_flags == 1) // indicates little-endian format. If not present, big-endian format is used + set_last_stream_little_endian(c->fc); + + return 0; +} + static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -7674,6 +7695,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */ { MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */ { MKTAG('i','l','o','c'), mov_read_iloc }, +{ MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ { 0, NULL } }; -- 2.35.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".