[vlc-devel] [PATCH] switcher: Fix compilation with ffmpeg-0.10.2

Richard Grenville pyxlcy at gmail.com
Wed Mar 21 02:58:51 CET 2012


Removes the deprecated symbols used in switcher.c to make it compile
correctly against ffmpeg-0.10.2

I left the deprecated function call avcodec_encode_audio() unchanged
since I guess I'm not capable to convert it to use the new
avcodec_encode_audio2(), it requires too many changes.

Originally posted on: https://bugs.gentoo.org/show_bug.cgi?id=409001

I have no knowledge about the ffmpeg API, so please review the patch
carefully, as I could not guarantee it's 100% correct.
---
 modules/stream_out/switcher.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/modules/stream_out/switcher.c b/modules/stream_out/switcher.c
index 372eef8..50c961f 100644
--- a/modules/stream_out/switcher.c
+++ b/modules/stream_out/switcher.c
@@ -292,7 +292,6 @@ static int Open( vlc_object_t *p_this )
     p_stream->pf_send   = Send;
     p_stream->p_sys     = p_sys;
 
-    avcodec_init();
     avcodec_register_all();
 
     return VLC_SUCCESS;
@@ -355,7 +354,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             return NULL;
         }
 
-        id->ff_enc_c = avcodec_alloc_context();
+        id->ff_enc_c = avcodec_alloc_context3( NULL );
 
         /* Set CPU capabilities */
         unsigned i_cpu = vlc_CPU();
@@ -388,7 +387,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         id->ff_enc_c->bit_rate    = p_fmt->i_bitrate;
 
         vlc_avcodec_lock();
-        if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
+        if( avcodec_open2( id->ff_enc_c, id->ff_enc, NULL ) )
         {
             vlc_avcodec_unlock();
             msg_Err( p_stream, "cannot open encoder" );
@@ -748,7 +747,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
             return 0;
         }
 
-        id->ff_enc_c = avcodec_alloc_context();
+        id->ff_enc_c = avcodec_alloc_context3( NULL );
 
         /* Set CPU capabilities */
         unsigned i_cpu = vlc_CPU();
@@ -803,7 +802,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
         id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P;
 
         vlc_avcodec_lock();
-        if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
+        if( avcodec_open2( id->ff_enc_c, id->ff_enc, NULL ) )
         {
             vlc_avcodec_unlock();
             msg_Err( p_stream, "cannot open encoder" );
@@ -844,7 +843,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 
     if ( id->i_nb_pred >= p_sys->i_gop )
     {
-        id->p_frame->pict_type = FF_I_TYPE;
+        id->p_frame->pict_type = AV_PICTURE_TYPE_I;
 #if 0
         id->p_frame->me_threshold = 0;
         id->p_frame->mb_threshold = 0;
@@ -853,7 +852,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
     }
     else
     {
-        id->p_frame->pict_type = FF_P_TYPE;
+        id->p_frame->pict_type = AV_PICTURE_TYPE_P;
 #if 0
         if ( id->p_frame->mb_type != NULL )
         {
@@ -873,7 +872,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 
 #if 0
     if ( id->p_frame->mb_type == NULL
-          && id->ff_enc_c->coded_frame->pict_type != FF_I_TYPE )
+          && id->ff_enc_c->coded_frame->pict_type != AV_PICTURE_TYPE_I )
     {
         int mb_width = (id->ff_enc_c->width + 15) / 16;
         int mb_height = (id->ff_enc_c->height + 15) / 16;
@@ -926,13 +925,13 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 
     switch ( id->ff_enc_c->coded_frame->pict_type )
     {
-    case FF_I_TYPE:
+    case AV_PICTURE_TYPE_I:
         p_out->i_flags |= BLOCK_FLAG_TYPE_I;
         break;
-    case FF_P_TYPE:
+    case AV_PICTURE_TYPE_P:
         p_out->i_flags |= BLOCK_FLAG_TYPE_P;
         break;
-    case FF_B_TYPE:
+    case AV_PICTURE_TYPE_B:
         p_out->i_flags |= BLOCK_FLAG_TYPE_B;
         break;
     default:
-- 
1.7.8.5




More information about the vlc-devel mailing list