[vlc-commits] [Git][videolan/vlc][3.0.x] demux: mp4: convert and forward Opus extradata

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Apr 28 12:05:04 UTC 2025



Felix Paul Kühne pushed to branch 3.0.x at VideoLAN / VLC


Commits:
698aaa84 by François Cartegnie at 2025-04-28T11:41:25+00:00
demux: mp4: convert and forward Opus extradata

refs #29135

(cherry picked from commit 6ac95c00183ff8f7a8172f216d306a0d56d14b2b)
Signed-off-by: Tristan Matthews <tmatth at videolan.org>

- - - - -


1 changed file:

- modules/demux/mp4/essetup.c


Changes:

=====================================
modules/demux/mp4/essetup.c
=====================================
@@ -948,6 +948,35 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
             }
             break;
         }
+        case ATOM_Opus:
+        {
+            const MP4_Box_t *p_dOps = MP4_BoxGet(  p_sample, "dOps" );
+            if( p_dOps && p_dOps->data.p_binary->i_blob > 10 )
+            {
+                size_t i_src = p_dOps->data.p_binary->i_blob;
+                const uint8_t *p_src = p_dOps->data.p_binary->p_blob;
+                if(p_src[0] != 0x00 || (SIZE_MAX - p_dOps->data.p_binary->i_blob < 26))
+                    break;
+                size_t i_dst = 2 + 8 + p_dOps->data.p_binary->i_blob + 8 + 8;
+                uint8_t *p_dst = malloc(i_dst);
+                if( likely( p_dst ) )
+                {
+                    p_dst[0] = 0x01;
+                    p_dst[1] = 8 + i_src;
+                    memcpy(&p_dst[2], "OpusHead", 8);
+                    memcpy(&p_dst[10], p_src, i_src);
+                    p_dst[10] = 0x01; // set version != ISOBMFF mapping
+                    SetWLE(&p_dst[12], GetWBE(&p_dst[12])); // swap endianness for PreSkip
+                    SetDWLE(&p_dst[14], GetDWBE(&p_dst[14])); // swap endianness for InputSampleRate
+                    SetWLE(&p_dst[18], GetWBE(&p_dst[18])); // swap endianness for OutputGain
+                    memcpy(&p_dst[10 + i_src], "OpusTags\x00\x00\x00\x00\x00\x00\x00", 16);
+                    p_track->fmt.i_extra = i_dst;
+                    p_track->fmt.p_extra = p_dst;
+                    p_track->fmt.i_codec = VLC_CODEC_OPUS;
+                }
+            }
+            break;
+        }
         case( ATOM_eac3 ):
         {
             p_track->fmt.i_codec = VLC_CODEC_EAC3;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/698aaa846e48d9bd1ac3fe737818f72bc1354864

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/698aaa846e48d9bd1ac3fe737818f72bc1354864
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list