[vlc-devel] commit: Read frame rate from asf container if presents. (Laurent Aimar )

git version control git at videolan.org
Thu Oct 9 23:35:47 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Oct  9 23:34:34 2008 +0200| [76795ad90a0bfa8854517e47102765ac6d92db13] | committer: Laurent Aimar 

Read frame rate from asf container if presents.

It helps when reconstructing the video pts as asf does not have them :(

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76795ad90a0bfa8854517e47102765ac6d92db13
---

 modules/demux/asf/asf.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 0919397..dfc18ee 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -729,11 +729,14 @@ static int DemuxInit( demux_t *p_demux )
     {
         asf_track_t    *tk;
         asf_object_stream_properties_t *p_sp;
+        asf_object_extended_stream_properties_t *p_esp;
+        asf_object_t *p_hdr_ext;
         bool b_access_selected;
 
         p_sp = ASF_FindObject( p_sys->p_root->p_hdr,
                                &asf_object_stream_properties_guid,
                                i_stream );
+        p_esp = NULL;
 
         tk = p_sys->track[p_sp->i_stream_number] = malloc( sizeof( asf_track_t ) );
         memset( tk, 0, sizeof( asf_track_t ) );
@@ -754,6 +757,26 @@ static int DemuxInit( demux_t *p_demux )
             continue;
         }
 
+        /* Find the associated extended_stream_properties if any */
+        p_hdr_ext = ASF_FindObject( p_sys->p_root->p_hdr,
+                                    &asf_object_header_extension_guid, 0 );
+        if( p_hdr_ext )
+        {
+            int i_ext_stream = ASF_CountObject( p_hdr_ext,
+                                                &asf_object_extended_stream_properties );
+            for( i = 0; i < i_ext_stream; i++ )
+            {
+                asf_object_t *p_tmp =
+                    ASF_FindObject( p_hdr_ext,
+                                    &asf_object_extended_stream_properties, i );
+                if( p_tmp->ext_stream.i_stream_number == p_sp->i_stream_number )
+                {
+                    p_esp = &p_tmp->ext_stream;
+                    break;
+                }
+            }
+        }
+
         if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) &&
             p_sp->i_type_specific_data_length >= sizeof( WAVEFORMATEX ) - 2 )
         {
@@ -803,6 +826,11 @@ static int DemuxInit( demux_t *p_demux )
             fmt.video.i_width = GetDWLE( p_data + 4 );
             fmt.video.i_height= GetDWLE( p_data + 8 );
 
+            if( p_esp && p_esp->i_average_time_per_frame > 0 )
+            {
+                fmt.video.i_frame_rate = 10000000;
+                fmt.video.i_frame_rate_base = p_esp->i_average_time_per_frame;
+            }
 
             if( fmt.i_codec == VLC_FOURCC( 'D','V','R',' ') )
             {
@@ -853,7 +881,7 @@ static int DemuxInit( demux_t *p_demux )
                         (int64_t)fmt.video.i_width * VOUT_ASPECT_FACTOR /
                         fmt.video.i_height / i_aspect_y;
                 }
-        }
+            }
 
             tk->i_cat = VIDEO_ES;
             tk->p_es = es_out_Add( p_demux->out, &fmt );




More information about the vlc-devel mailing list