]> git.sesse.net Git - vlc/blobdiff - modules/demux/avformat/demux.c
AVFormat Demuxer : Set video ES frame rate.
[vlc] / modules / demux / avformat / demux.c
index 9472b5d90d73d7f02509ac41cf13c20341f17f40..98d857cbbfb2d3030f2ac54c7f1b89be43b47957 100644 (file)
@@ -116,6 +116,7 @@ int OpenDemux( vlc_object_t *p_this )
     AVInputFormat *fmt;
     unsigned int  i;
     int64_t       i_start_time = -1;
+    bool          b_can_seek;
 
     /* Init Probe data */
     pd.filename = p_demux->psz_path;
@@ -200,6 +201,18 @@ int OpenDemux( vlc_object_t *p_this )
     init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size,
                    0, &p_sys->url, IORead, NULL, IOSeek );
 
+    stream_Control( p_demux->s, STREAM_CAN_SEEK, &b_can_seek );
+    if( !b_can_seek )
+    {
+       /* Tell avformat that input is stream, so it doesn't get stuck
+       when trying av_find_stream_info() trying to seek all the wrong places
+       init_put_byte defaults io.is_streamed=0, so thats why we set them after it
+       */
+       p_sys->url.is_streamed = 1;
+       p_sys->io.is_streamed = 1;
+    }
+
+
     /* Open it */
     if( av_open_input_stream( &p_sys->ic, &p_sys->io, p_demux->psz_path,
                               p_sys->fmt, NULL ) )
@@ -212,7 +225,6 @@ int OpenDemux( vlc_object_t *p_this )
     vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
     if( av_find_stream_info( p_sys->ic ) < 0 )
     {
-        vlc_avcodec_unlock();
         msg_Warn( p_demux, "av_find_stream_info failed" );
     }
     vlc_avcodec_unlock();
@@ -269,6 +281,8 @@ int OpenDemux( vlc_object_t *p_this )
                 *fmt.video.p_palette = *(video_palette_t *)cc->palctrl;
             }
             psz_type = "video";
+            fmt.video.i_frame_rate = cc->time_base.den;
+            fmt.video.i_frame_rate_base = cc->time_base.num;
             break;
 
         case CODEC_TYPE_SUBTITLE:
@@ -508,12 +522,18 @@ static int Demux( demux_t *p_demux )
     {
         p_frame = BuildSsaFrame( &pkt, p_sys->i_ssa_order++ );
         if( !p_frame )
+        {
+            av_free_packet( &pkt );
             return 1;
+        }
     }
     else
     {
         if( ( p_frame = block_New( p_demux, pkt.size ) ) == NULL )
+        {
+            av_free_packet( &pkt );
             return 0;
+        }
         memcpy( p_frame->p_buffer, pkt.data, pkt.size );
     }