]> git.sesse.net Git - vlc/blobdiff - modules/codec/avcodec/video.c
add_float: remove callback parameter
[vlc] / modules / codec / avcodec / video.c
index 6cc839c3aec729cc63d9ce8bde9c28e6dd672b3e..4e3904b8e4b3feca51fae0ebf77ad487bff7478d 100644 (file)
@@ -116,7 +116,6 @@ static const AVPaletteControl palette_control;
  * Local prototypes
  *****************************************************************************/
 static void ffmpeg_InitCodec      ( decoder_t * );
-static int  ffmpeg_OpenCodec      ( decoder_t * );
 static void ffmpeg_CopyPicture    ( decoder_t *, picture_t *, AVFrame * );
 static int  ffmpeg_GetFrameBuf    ( struct AVCodecContext *, AVFrame * );
 static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * );
@@ -306,9 +305,11 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
        (p_sys->p_codec->capabilities & CODEC_CAP_DR1) &&
         /* No idea why ... but this fixes flickering on some TSCC streams */
         p_sys->i_codec_id != CODEC_ID_TSCC &&
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 52, 68, 2 )
         /* avcodec native vp8 decode doesn't handle EMU_EDGE flag, and I
            don't have idea howto implement fallback to libvpx decoder */
         p_sys->i_codec_id != CODEC_ID_VP8 &&
+#endif
         !p_sys->p_context->debug_mv )
     {
         /* Some codecs set pix_fmt only after the 1st frame has been decoded,
@@ -618,6 +619,12 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             continue;
         }
 
+        /* Sanity check (seems to be needed for some streams) */
+        if( p_sys->p_ff_pic->pict_type == FF_B_TYPE )
+        {
+            p_sys->b_has_b_frames = true;
+        }
+
         /* Compute the PTS */
         mtime_t i_pts = VLC_TS_INVALID;
         if( p_sys->p_ff_pic->reordered_opaque != INT64_MIN )
@@ -631,6 +638,15 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
                     !p_sys->p_ff_pic->reference ||
                     p_sys->i_pts <= VLC_TS_INVALID )
                     i_pts = i_ts;
+
+                /* Guess what ? The rules are different for Real Video :( */
+                if( (p_dec->fmt_in.i_codec == VLC_CODEC_RV30 ||
+                     p_dec->fmt_in.i_codec == VLC_CODEC_RV40) &&
+                    p_sys->b_has_b_frames )
+                {
+                    i_pts = VLC_TS_INVALID;
+                    if(p_sys->p_ff_pic->reference) i_pts = i_ts;
+                }
             }
             else
             {
@@ -656,13 +672,9 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             }
             else if( p_context->time_base.den > 0 )
             {
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,20,0)
                 int i_tick = p_context->ticks_per_frame;
                 if( i_tick <= 0 )
                     i_tick = 1;
-#else
-                int i_tick = 1;
-#endif
 
                 p_sys->i_pts += INT64_C(1000000) *
                     (2 + p_sys->p_ff_pic->repeat_pict) *
@@ -710,12 +722,6 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             decoder_LinkPicture( p_dec, p_pic );
         }
 
-        /* Sanity check (seems to be needed for some streams) */
-        if( p_sys->p_ff_pic->pict_type == FF_B_TYPE )
-        {
-            p_sys->b_has_b_frames = true;
-        }
-
         if( !p_dec->fmt_in.video.i_sar_num || !p_dec->fmt_in.video.i_sar_den )
         {
             /* Fetch again the aspect ratio in case it changed */
@@ -869,61 +875,6 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
     }
 }
 
-/*****************************************************************************
- * ffmpeg_OpenCodec:
- *****************************************************************************/
-static int ffmpeg_OpenCodec( decoder_t *p_dec )
-{
-    decoder_sys_t *p_sys = p_dec->p_sys;
-
-    if( p_sys->p_context->extradata_size <= 0 )
-    {
-        if( p_sys->i_codec_id == CODEC_ID_VC1 ||
-            p_sys->i_codec_id == CODEC_ID_VORBIS ||
-            p_sys->i_codec_id == CODEC_ID_THEORA )
-        {
-            msg_Warn( p_dec, "waiting for extra data for codec %s",
-                      p_sys->psz_namecodec );
-            return 1;
-        }
-    }
-    p_sys->p_context->width  = p_dec->fmt_in.video.i_width;
-    p_sys->p_context->height = p_dec->fmt_in.video.i_height;
-    p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
-
-    int ret;
-    vlc_avcodec_lock();
-    ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
-    vlc_avcodec_unlock();
-    if( ret < 0 )
-        return VLC_EGENERIC;
-    msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
-#ifdef HAVE_AVCODEC_MT
-    switch( p_sys->p_context->active_thread_type )
-    {
-    case FF_THREAD_FRAME:
-        msg_Dbg( p_dec, "using frame thread mode with %d threads",
-                 p_sys->p_context->thread_count );
-        break;
-    case FF_THREAD_SLICE:
-        msg_Dbg( p_dec, "using slice thread mode with %d threads",
-                 p_sys->p_context->thread_count );
-        break;
-    case 0:
-        if( p_sys->p_context->thread_count > 1 )
-            msg_Warn( p_dec, "failed to enable threaded decoding" );
-        break;
-    default:
-        msg_Warn( p_dec, "using unknown thread mode with %d threads",
-                  p_sys->p_context->thread_count );
-        break;
-    }
-#endif
-
-    p_sys->b_delayed_open = false;
-
-    return VLC_SUCCESS;
-}
 /*****************************************************************************
  * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a
  *                     picture_t structure (when not in direct rendering mode).