[FFmpeg-cvslog] avformat/mov: read PCM audio configuration box ('pcmC') if available

Ivan Baykalov git at videolan.org
Mon Jun 27 21:36:31 EEST 2022


ffmpeg | branch: master | Ivan Baykalov <4rusxg at gmail.com> | Tue Jun  7 15:26:18 2022 +0700| [cbe216d3a62fe22b16a1ba40b9b3f13e5b4ac9a9] | committer: Marton Balint

avformat/mov: read PCM audio configuration box ('pcmC') if available

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 <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbe216d3a62fe22b16a1ba40b9b3f13e5b4ac9a9
---

 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 }
 };
 



More information about the ffmpeg-cvslog mailing list