]> git.sesse.net Git - vlc/commitdiff
AVCodec : Move ffmpeg_OpenCodec to avcodec.c and mark it as non-static.
authorJai Menon <jmenon86@gmail.com>
Thu, 5 Aug 2010 10:48:16 +0000 (16:18 +0530)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 9 Aug 2010 20:21:42 +0000 (22:21 +0200)
This will allow us to re-use this function later.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/avcodec/avcodec.c
modules/codec/avcodec/avcodec.h
modules/codec/avcodec/video.c

index c5b844f21caefc651c70a239a8d23f73245796bd..bbff589b86d98609df82095a583f73766c9f8700 100644 (file)
@@ -397,3 +397,60 @@ void InitLibavcodec( vlc_object_t *p_object )
 
     vlc_avcodec_unlock();
 }
+
+/*****************************************************************************
+ * ffmpeg_OpenCodec:
+ *****************************************************************************/
+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;
+}
index 33c4c178175ec2b95ecf86358b53fc928e4edcd9..0f1cf65f4c5dee3b927e934f2518ba60153232b8 100644 (file)
@@ -62,6 +62,8 @@ int InitSubtitleDec( decoder_t *p_dec, AVCodecContext *p_context,
                      AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
 void EndSubtitleDec( decoder_t *p_dec );
 
+/* Initialize decoder */
+int ffmpeg_OpenCodec( decoder_t *p_dec );
 
 /*****************************************************************************
  * Module descriptor help strings
index 755b1d77a43e4ac6e61c5d2612923bc114d97285..9313dcab3ee1323c5291f298e14a831ec5472e97 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 * );
@@ -867,61 +866,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).