]> git.sesse.net Git - vlc/blobdiff - modules/demux/mp4/mp4.c
typos
[vlc] / modules / demux / mp4 / mp4.c
index 10e9fe07a16a63288cc4b8e5f565570e09329065..68d3d9d118ed4730e5302cb1ad5e2d62af793756 100644 (file)
@@ -56,6 +56,7 @@ vlc_module_begin ()
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_DEMUX )
     set_description( N_("MP4 stream demuxer") )
+    set_shortname( N_("MP4") )
     set_capability( "demux", 242 )
     set_callbacks( Open, Close )
 vlc_module_end ()
@@ -76,8 +77,8 @@ typedef struct
     uint32_t     i_sample_count; /* how many samples in this chunk */
     uint32_t     i_sample_first; /* index of the first sample in this chunk */
 
-    /* now provide way to calculate pts, dts, and offset without to
-        much memory and with fast acces */
+    /* now provide way to calculate pts, dts, and offset without too
+        much memory and with fast access */
 
     /* with this we can calculate dts/pts without waste memory */
     uint64_t     i_first_dts;
@@ -416,8 +417,7 @@ static int Open( vlc_object_t * p_this )
                     free( psz_path );
                 }
                 msg_Dbg( p_demux, "adding ref = `%s'", psz_ref );
-                input_item_t *p_input = input_item_NewExt( p_demux, psz_ref
-                                                           , NULL, 0, NULL, 0, -1 );
+                input_item_t *p_input = input_item_New( p_demux, psz_ref, NULL );
                 input_item_CopyOptions( p_current, p_input );
                 input_item_AddSubItem( p_current, p_input );
                 vlc_gc_decref( p_input );
@@ -756,7 +756,7 @@ static void MP4_UpdateSeekpoint( demux_t *p_demux )
     }
 }
 /*****************************************************************************
- * Seek: Got to i_date
+ * Seek: Go to i_date
 ******************************************************************************/
 static int Seek( demux_t *p_demux, mtime_t i_date )
 {
@@ -903,7 +903,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                     break;
 
                 case FOURCC_0xa9trk: /* Track */
-                    SET( vlc_meta_SetTracknum );
+                    SET( vlc_meta_SetTrackNum );
                     break;
 
                 case FOURCC_0xa9cmt: /* Commment */
@@ -1486,6 +1486,70 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
         }
     }
 
+    /* */
+    switch( p_track->fmt.i_cat )
+    {
+    case VIDEO_ES:
+        p_track->fmt.video.i_width = p_sample->data.p_sample_vide->i_width;
+        p_track->fmt.video.i_height = p_sample->data.p_sample_vide->i_height;
+        p_track->fmt.video.i_bits_per_pixel =
+            p_sample->data.p_sample_vide->i_depth;
+
+        /* fall on display size */
+        if( p_track->fmt.video.i_width <= 0 )
+            p_track->fmt.video.i_width = p_track->i_width;
+        if( p_track->fmt.video.i_height <= 0 )
+            p_track->fmt.video.i_height = p_track->i_height;
+
+        /* Find out apect ratio from display size */
+        if( p_track->i_width > 0 && p_track->i_height > 0 &&
+            /* Work-around buggy muxed files */
+            p_sample->data.p_sample_vide->i_width != p_track->i_width )
+            p_track->fmt.video.i_aspect =
+                VOUT_ASPECT_FACTOR * p_track->i_width / p_track->i_height;
+
+        /* Support for cropping (eg. in H263 files) */
+        p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width;
+        p_track->fmt.video.i_visible_height = p_track->fmt.video.i_height;
+
+        /* Frame rate */
+        p_track->fmt.video.i_frame_rate = p_track->i_timescale;
+        p_track->fmt.video.i_frame_rate_base = 1;
+
+        if( p_track->fmt.video.i_frame_rate &&
+            (p_box = MP4_BoxGet( p_track->p_stbl, "stts" )) &&
+            p_box->data.p_stts->i_entry_count >= 1 )
+        {
+            p_track->fmt.video.i_frame_rate_base =
+                p_box->data.p_stts->i_sample_delta[0];
+        }
+
+        break;
+
+    case AUDIO_ES:
+        p_track->fmt.audio.i_channels =
+            p_sample->data.p_sample_soun->i_channelcount;
+        p_track->fmt.audio.i_rate =
+            p_sample->data.p_sample_soun->i_sampleratehi;
+        p_track->fmt.i_bitrate = p_sample->data.p_sample_soun->i_channelcount *
+            p_sample->data.p_sample_soun->i_sampleratehi *
+                p_sample->data.p_sample_soun->i_samplesize;
+        p_track->fmt.audio.i_bitspersample =
+            p_sample->data.p_sample_soun->i_samplesize;
+
+        if( p_track->i_sample_size != 0 &&
+            p_sample->data.p_sample_soun->i_qt_version == 1 && p_sample->data.p_sample_soun->i_sample_per_packet <= 0 )
+        {
+            msg_Err( p_demux, "Invalid sample per packet value for qt_version 1" );
+            return VLC_EGENERIC;
+        }
+        break;
+
+    default:
+        break;
+    }
+
+
     /* It's a little ugly but .. there are special cases */
     switch( p_sample->i_type )
     {
@@ -1498,6 +1562,34 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
                 p_soun->i_qt_version = 0;
             break;
         }
+        case( VLC_FOURCC( 'a', 'c', '-', '3' ) ):
+        {
+            MP4_Box_t *p_dac3_box = MP4_BoxGet(  p_sample, "dac3", 0 );
+
+            p_track->fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
+            if( p_dac3_box )
+            {
+                static const int pi_bitrate[] = {
+                     32,  40,  48,  56,
+                     64,  80,  96, 112,
+                    128, 160, 192, 224,
+                    256, 320, 384, 448,
+                    512, 576, 640,
+                };
+                MP4_Box_data_dac3_t *p_dac3 = p_dac3_box->data.p_dac3;
+                p_track->fmt.audio.i_channels = 0;
+                p_track->fmt.i_bitrate = 0;
+                if( p_dac3->i_bitrate_code < sizeof(pi_bitrate)/sizeof(*pi_bitrate) )
+                    p_track->fmt.i_bitrate = pi_bitrate[p_dac3->i_bitrate_code] * 1000;
+                p_track->fmt.audio.i_bitspersample = 0;
+            }
+            break;
+        }
+        case( VLC_FOURCC( 'e', 'c', '-', '3' ) ):
+        {
+            p_track->fmt.i_codec = VLC_FOURCC( 'e', 'a', 'c', '3' );
+            break;
+        }
 
         case( VLC_FOURCC( 'r', 'a', 'w', ' ' ) ):
         case( VLC_FOURCC( 'N', 'O', 'N', 'E' ) ):
@@ -1740,69 +1832,6 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
 
 #undef p_decconfig
 
-    /* some last initialisation */
-    switch( p_track->fmt.i_cat )
-    {
-    case VIDEO_ES:
-        p_track->fmt.video.i_width = p_sample->data.p_sample_vide->i_width;
-        p_track->fmt.video.i_height = p_sample->data.p_sample_vide->i_height;
-        p_track->fmt.video.i_bits_per_pixel =
-            p_sample->data.p_sample_vide->i_depth;
-
-        /* fall on display size */
-        if( p_track->fmt.video.i_width <= 0 )
-            p_track->fmt.video.i_width = p_track->i_width;
-        if( p_track->fmt.video.i_height <= 0 )
-            p_track->fmt.video.i_height = p_track->i_height;
-
-        /* Find out apect ratio from display size */
-        if( p_track->i_width > 0 && p_track->i_height > 0 &&
-            /* Work-around buggy muxed files */
-            p_sample->data.p_sample_vide->i_width != p_track->i_width )
-            p_track->fmt.video.i_aspect =
-                VOUT_ASPECT_FACTOR * p_track->i_width / p_track->i_height;
-
-        /* Support for cropping (eg. in H263 files) */
-        p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width;
-        p_track->fmt.video.i_visible_height = p_track->fmt.video.i_height;
-
-        /* Frame rate */
-        p_track->fmt.video.i_frame_rate = p_track->i_timescale;
-        p_track->fmt.video.i_frame_rate_base = 1;
-
-        if( p_track->fmt.video.i_frame_rate &&
-            (p_box = MP4_BoxGet( p_track->p_stbl, "stts" )) &&
-            p_box->data.p_stts->i_entry_count >= 1 )
-        {
-            p_track->fmt.video.i_frame_rate_base =
-                p_box->data.p_stts->i_sample_delta[0];
-        }
-
-        break;
-
-    case AUDIO_ES:
-        p_track->fmt.audio.i_channels =
-            p_sample->data.p_sample_soun->i_channelcount;
-        p_track->fmt.audio.i_rate =
-            p_sample->data.p_sample_soun->i_sampleratehi;
-        p_track->fmt.i_bitrate = p_sample->data.p_sample_soun->i_channelcount *
-            p_sample->data.p_sample_soun->i_sampleratehi *
-                p_sample->data.p_sample_soun->i_samplesize;
-        p_track->fmt.audio.i_bitspersample =
-            p_sample->data.p_sample_soun->i_samplesize;
-
-        if( p_track->i_sample_size != 0 &&
-            p_sample->data.p_sample_soun->i_qt_version == 1 && p_sample->data.p_sample_soun->i_sample_per_packet <= 0 )
-        {
-            msg_Err( p_demux, "Invalid sample per packet value for qt_version 1" );
-            return VLC_EGENERIC;
-        }
-        break;
-
-    default:
-        break;
-    }
-
     if( pp_es )
         *pp_es = es_out_Add( p_demux->out, &p_track->fmt );