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 79A67430B9 for ; Sun, 19 Jun 2022 21:51:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A71268B5A5; Mon, 20 Jun 2022 00:51:17 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C1975689B6B for ; Mon, 20 Jun 2022 00:51:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1A9B4E73AD for ; Sun, 19 Jun 2022 23:51:12 +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 OTynPa-kFfMw for ; Sun, 19 Jun 2022 23:51:10 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id CEF24E73A6 for ; Sun, 19 Jun 2022 23:51:09 +0200 (CEST) Date: Sun, 19 Jun 2022 23:51:09 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20220607082618.64814-1-4rusxg@gmail.com> Message-ID: References: <20220607082618.64814-1-4rusxg@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 7 Jun 2022, Ivan Baykalov wrote: > 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 Thanks for this, I have factorized the duplicated code from existing endianness setting and also simplified your patch a bit. Will post it as a reply to this mail. Regards, Marton > --- > libavformat/mov.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index d7be593a86..f71a470d9c 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -7567,6 +7567,65 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return atom.size; > } > > +static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + int version, format_flags, pcm_sample_size; > + AVStream *st; > + > + if (atom.size < 6) { > + av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n"); > + return AVERROR_INVALIDDATA; > + } > + > + version = avio_r8(pb); > + if (version) { > + av_log(c->fc, AV_LOG_WARNING, "Unsupported pcmC box version %d\n", version); > + return 0; > + } > + > + avio_rb24(pb); // flags > + > + if (c->fc->nb_streams < 1) > + return 0; > + st = c->fc->streams[c->fc->nb_streams-1]; > + if (!st || !st->codecpar) > + return 0; > + > + format_flags = avio_r8(pb); > + if (format_flags == 1) { // indicates little-endian format. If not present, big-endian format is used > + if (st->codecpar->codec_tag == MKTAG('i','p','c','m')) { > + 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; > + case AV_CODEC_ID_PCM_S32BE: > + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; > + break; > + } > + } > + else if (st->codecpar->codec_tag == MKTAG('f','p','c','m')) { > + switch (st->codecpar->codec_id) { > + case AV_CODEC_ID_PCM_F32BE: > + st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; > + break; > + case AV_CODEC_ID_PCM_F64BE: > + st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE; > + break; > + } > + } > + } > + > + pcm_sample_size = avio_r8(pb); > + if (pcm_sample_size != st->codecpar->bits_per_coded_sample) { > + av_log(c->fc, AV_LOG_WARNING, "Unexpected pcmC sample size (%d vs %d)\n", pcm_sample_size, st->codecpar->bits_per_coded_sample); > + } > + > + return 0; > +} > + > static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('A','C','L','R'), mov_read_aclr }, > { MKTAG('A','P','R','G'), mov_read_avid }, > @@ -7670,6 +7729,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.1 > > _______________________________________________ > 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". > _______________________________________________ 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".