[vlc-commits] [Git][videolan/vlc][master] 12 commits: packetizer: mpeg4: initialize i_mux_versionA once

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun May 31 11:29:26 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
abdefa04 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: initialize i_mux_versionA once

- - - - -
2a4814ed by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: only check i_mux_versionA is not 0 when meaningful

- - - - -
8d60cd6a by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: remove always true i_mux_versionA test

This code can only be reached when i_mux_versionA is 0.

- - - - -
9d3fe02f by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: remove unnecessary local i_mux_versionA variable

- - - - -
c53e8104 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: read the mux version as a flag

It's only 1 bit. It can either be 0 or 1, true or false.

And use the same naming as in ISO/IEC 14496-3.

- - - - -
a9495095 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: read the continue flag as a boolean

- - - - -
e326bc75 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: rename i_sub_frames to numSubFrames

To match the ISO/IEC 14496-3 naming.
And do not increment by 1 to have the same meaning/value.

- - - - -
26489852 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: rename b_same_time_framing to allStreamsSameTimeFraming

To match the ISO/IEC 14496-3 naming.

- - - - -
9544741c by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: skip unused CRC

- - - - -
a19d703f by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: skip other data bits

Use the same naming as in ISO/IEC 14496-3.

- - - - -
560dad26 by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: rename i_programs to numProgram

To match the ISO/IEC 14496-3 naming.
And do not increment by 1 to have the same meaning/value.

- - - - -
a9e4b73c by Steve Lhomme at 2026-05-31T13:12:25+02:00
packetizer: mpeg4: rename pi_layers to p_numLayer

To match the ISO/IEC 14496-3 naming.
And do not increment by 1 to have the same meaning/value.

- - - - -


2 changed files:

- modules/packetizer/mpeg4audio.c
- modules/packetizer/mpeg4audio.h


Changes:

=====================================
modules/packetizer/mpeg4audio.c
=====================================
@@ -493,15 +493,15 @@ static int LOASParse(decoder_t *p_dec, uint8_t *p_buffer, int i_buffer)
         goto truncated;
 
     /* FIXME do we need to split the subframe into independent packet ? */
-    if (p_sys->latm.i_sub_frames > 1)
+    if (p_sys->latm.numSubFrames != 0)
         msg_Err(p_dec, "latm sub frames not yet supported, please send a sample");
 
-    for (uint8_t i_sub = 0; i_sub < p_sys->latm.i_sub_frames; i_sub++) {
+    for (uint8_t i_sub = 0; i_sub <= p_sys->latm.numSubFrames; i_sub++) {
         unsigned pi_payload[MPEG4_STREAMMUX_MAX_PROGRAM][MPEG4_STREAMMUX_MAX_LAYER];
-        if (p_sys->latm.b_same_time_framing) {
+        if (p_sys->latm.allStreamsSameTimeFraming) {
             /* Payload length */
-            for (uint8_t i_program = 0; i_program < p_sys->latm.i_programs; i_program++) {
-                for (uint8_t i_layer = 0; i_layer < p_sys->latm.pi_layers[i_program]; i_layer++) {
+            for (uint8_t i_program = 0; i_program <= p_sys->latm.numProgram; i_program++) {
+                for (uint8_t i_layer = 0; i_layer <= p_sys->latm.p_numLayer[i_program]; i_layer++) {
                     const MPEG4_audio_stream_t *st = &p_sys->latm.stream[p_sys->latm.pi_stream[i_program][i_layer]];
                     if (st->i_frame_length_type == 0) {
                         unsigned i_payload = 0;
@@ -526,8 +526,8 @@ static int LOASParse(decoder_t *p_dec, uint8_t *p_buffer, int i_buffer)
             }
 
             /* Payload Data */
-            for (uint8_t i_program = 0; i_program < p_sys->latm.i_programs; i_program++) {
-                for (uint8_t i_layer = 0; i_layer < p_sys->latm.pi_layers[i_program]; i_layer++) {
+            for (uint8_t i_program = 0; i_program <= p_sys->latm.numProgram; i_program++) {
+                for (uint8_t i_layer = 0; i_layer <= p_sys->latm.p_numLayer[i_program]; i_layer++) {
                     /* XXX we only extract 1 stream */
                     if (i_program != 0 || i_layer != 0)
                         break;
@@ -594,10 +594,8 @@ static int LOASParse(decoder_t *p_dec, uint8_t *p_buffer, int i_buffer)
         }
     }
 
-#if 0
-    if (p_sys->latm.i_other_data > 0)
-        ; // TODO
-#endif
+
+    bs_skip(&s, p_sys->latm.otherDataLenBits);
     bs_align(&s);
 
     return i_accumulated;


=====================================
modules/packetizer/mpeg4audio.h
=====================================
@@ -469,19 +469,18 @@ typedef struct
 #define MPEG4_STREAMMUX_MAX_PROGRAM 16
 typedef struct
 {
-    bool b_same_time_framing;
-    uint8_t i_sub_frames;
-    uint8_t i_programs;
+    bool allStreamsSameTimeFraming;
+    uint8_t numSubFrames;
+    uint8_t numProgram;
 
-    uint8_t pi_layers[MPEG4_STREAMMUX_MAX_PROGRAM];
+    uint8_t p_numLayer[MPEG4_STREAMMUX_MAX_PROGRAM];
 
     uint8_t pi_stream[MPEG4_STREAMMUX_MAX_PROGRAM][MPEG4_STREAMMUX_MAX_LAYER];
 
     uint8_t i_streams;
     MPEG4_audio_stream_t stream[MPEG4_STREAMMUX_MAX_PROGRAM*MPEG4_STREAMMUX_MAX_LAYER];
 
-    uint32_t i_other_data;
-    int16_t  i_crc;  /* -1 if not set */
+    uint32_t otherDataLenBits;
 } MPEG4_streammux_config_t;
 
 static inline uint32_t MPEG4_LatmGetValue(bs_t *s)
@@ -504,36 +503,32 @@ static inline size_t AudioSpecificConfigBitsToBytes(bs_t *s, uint32_t i_bits, ui
 
 static inline int MPEG4_parse_StreamMuxConfig(bs_t *s, MPEG4_streammux_config_t *m)
 {
-    int i_mux_version;
-    int i_mux_versionA;
+    bool audioMuxVersion;
 
-    i_mux_version = bs_read(s, 1);
-    i_mux_versionA = 0;
-    if (i_mux_version)
-        i_mux_versionA = bs_read(s, 1);
-
-    if (i_mux_versionA != 0) /* support only A=0 */
-        return -1;
+    audioMuxVersion = bs_read(s, 1);
+    if (audioMuxVersion) {
+        if (bs_read(s, 1) != 0) /* support only audioMuxVersionA=0 */
+            return -1;
+    }
 
     memset(m, 0, sizeof(*m));
 
-    if (i_mux_versionA == 0)
-        if (i_mux_version == 1)
-            MPEG4_LatmGetValue(s); /* taraBufferFullness */
+    if (audioMuxVersion)
+        MPEG4_LatmGetValue(s); /* taraBufferFullness */
 
     if(bs_eof(s))
         return -1;
 
-    m->b_same_time_framing = bs_read1(s);
-    m->i_sub_frames = 1 + bs_read(s, 6);
-    m->i_programs = 1 + bs_read(s, 4);
+    m->allStreamsSameTimeFraming = bs_read1(s);
+    m->numSubFrames = bs_read(s, 6);
+    m->numProgram = bs_read(s, 4);
 
-    for (uint8_t i_program = 0; i_program < m->i_programs; i_program++) {
+    for (uint8_t i_program = 0; i_program <= m->numProgram; i_program++) {
         if(bs_eof(s))
             return -1;
-        m->pi_layers[i_program] = 1+bs_read(s, 3);
+        m->p_numLayer[i_program] = bs_read(s, 3);
 
-        for (uint8_t i_layer = 0; i_layer < m->pi_layers[i_program]; i_layer++) {
+        for (uint8_t i_layer = 0; i_layer <= m->p_numLayer[i_program]; i_layer++) {
             MPEG4_audio_stream_t *st = &m->stream[m->i_streams];
             bool b_previous_cfg;
 
@@ -550,11 +545,11 @@ static inline int MPEG4_parse_StreamMuxConfig(bs_t *s, MPEG4_streammux_config_t
                 st->cfg = m->stream[m->i_streams-1].cfg;
             } else {
                 uint32_t asc_size = 0;
-                if(i_mux_version > 0)
+                if(audioMuxVersion)
                     asc_size = MPEG4_LatmGetValue(s);
                 bs_t asc_bs = *s;
-                MPEG4_read_AudioSpecificConfig(&asc_bs, &st->cfg, i_mux_version > 0);
-                if (i_mux_version == 0)
+                MPEG4_read_AudioSpecificConfig(&asc_bs, &st->cfg, audioMuxVersion);
+                if (!audioMuxVersion)
                     asc_size = bs_pos(&asc_bs) - bs_pos(s);
                 asc_bs = *s;
                 st->i_extra = AudioSpecificConfigBitsToBytes(&asc_bs, asc_size, st->extra);
@@ -567,7 +562,7 @@ static inline int MPEG4_parse_StreamMuxConfig(bs_t *s, MPEG4_streammux_config_t
             case 0:
             {
                 bs_skip(s, 8); /* latmBufferFullnes */
-                if (!m->b_same_time_framing)
+                if (!m->allStreamsSameTimeFraming)
                     if (st->cfg.i_object_type == MPEG4_AOT_AAC_SC ||
                         st->cfg.i_object_type == MPEG4_AOT_CELP ||
                         st->cfg.i_object_type == MPEG4_AOT_ER_AAC_SC ||
@@ -595,23 +590,23 @@ static inline int MPEG4_parse_StreamMuxConfig(bs_t *s, MPEG4_streammux_config_t
         return -1;
 
     /* other data */
-    if (bs_read1(s)) {
-        if (i_mux_version == 1)
-            m->i_other_data = MPEG4_LatmGetValue(s);
+    if (bs_read1(s)) { // otherDataPresent
+        if (audioMuxVersion)
+            m->otherDataLenBits = MPEG4_LatmGetValue(s);
         else {
-            int b_continue;
+            bool otherDataLenEsc;
             do {
-                b_continue = bs_read1(s);
-                m->i_other_data = (m->i_other_data << 8) + bs_read(s, 8);
-            } while (b_continue);
+                otherDataLenEsc = bs_read1(s);
+                m->otherDataLenBits = (m->otherDataLenBits << 8) + bs_read(s, 8);
+            } while (otherDataLenEsc);
         }
     }
+    else
+        m->otherDataLenBits = 0;
 
     /* crc */
-    m->i_crc = -1;
     if (bs_read1(s))
-        m->i_crc = bs_read(s, 8);
+        bs_skip(s, 8);
 
     return bs_error(s) ? -1 : 0;
 }
-



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8958ff65724b211a9ec2bfb2e561f9a73247f5ae...a9e4b73c0201ad25de675af1e5faf38d120370f9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8958ff65724b211a9ec2bfb2e561f9a73247f5ae...a9e4b73c0201ad25de675af1e5faf38d120370f9
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list