[vlc-commits] commit: AVCodec : Move ffmpeg_OpenCodec to avcodec. c and mark it as non-static. (Jai Menon )

git at videolan.org git at videolan.org
Mon Aug 9 23:08:31 CEST 2010


vlc | branch: master | Jai Menon <jmenon86 at gmail.com> | Thu Aug  5 16:36:16 2010 +0530| [512acd87b9562ed50cad02dffa37f12a7e37e644] | committer: Jean-Baptiste Kempf 

AVCodec : Move ffmpeg_OpenCodec to avcodec.c and mark it as non-static.

This will allow us to re-use this function later.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/avcodec/avcodec.c |   57 +++++++++++++++++++++++++++++++++++++++
 modules/codec/avcodec/avcodec.h |    2 +
 modules/codec/avcodec/video.c   |   56 --------------------------------------
 3 files changed, 59 insertions(+), 56 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index c5b844f..bbff589 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -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;
+}
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 33c4c17..0f1cf65 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -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
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 755b1d7..9313dca 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -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 * );
@@ -868,61 +867,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).
  *****************************************************************************/



More information about the vlc-commits mailing list