commit 66da497b2046f3835321bc9d83170285267e106a Author: Rafaël Carré Date: Wed Mar 21 12:54:25 2012 -0400 switcher: convert to lavc 54 API based on patch by Richard Grenville Index: vlc-2.0.1/modules/stream_out/switcher.c =================================================================== --- vlc-2.0.1.orig/modules/stream_out/switcher.c +++ vlc-2.0.1/modules/stream_out/switcher.c @@ -292,7 +292,9 @@ static int Open( vlc_object_t *p_this ) p_stream->pf_send = Send; p_stream->p_sys = p_sys; +#if LIBAVCODEC_VERSION_MAJOR < 54 avcodec_init(); +#endif avcodec_register_all(); return VLC_SUCCESS; @@ -355,7 +357,11 @@ static sout_stream_id_t *Add( sout_strea return NULL; } +#if LIBAVCODEC_VERSION_MAJOR < 54 id->ff_enc_c = avcodec_alloc_context(); +#else + id->ff_enc_c = avcodec_alloc_context3( id->ff_enc ); +#endif /* Set CPU capabilities */ unsigned i_cpu = vlc_CPU(); @@ -388,7 +394,11 @@ static sout_stream_id_t *Add( sout_strea id->ff_enc_c->bit_rate = p_fmt->i_bitrate; vlc_avcodec_lock(); +#if LIBAVCODEC_VERSION_MAJOR >= 54 + if( avcodec_open2( id->ff_enc_c, id->ff_enc, NULL /* options */ ) ) +#else if( avcodec_open( id->ff_enc_c, id->ff_enc ) ) +#endif { vlc_avcodec_unlock(); msg_Err( p_stream, "cannot open encoder" ); @@ -748,7 +758,11 @@ static mtime_t VideoCommand( sout_stream return 0; } +#if LIBAVCODEC_VERSION_MAJOR < 54 id->ff_enc_c = avcodec_alloc_context(); +#else + id->ff_enc_c = avcodec_alloc_context3( id->ff_enc ); +#endif /* Set CPU capabilities */ unsigned i_cpu = vlc_CPU(); @@ -803,7 +817,11 @@ static mtime_t VideoCommand( sout_stream id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P; vlc_avcodec_lock(); +#if LIBAVCODEC_VERSION_MAJOR >= 54 + if( avcodec_open2( id->ff_enc_c, id->ff_enc, NULL /* options */ ) ) +#else if( avcodec_open( id->ff_enc_c, id->ff_enc ) ) +#endif { vlc_avcodec_unlock(); msg_Err( p_stream, "cannot open encoder" ); @@ -844,7 +862,7 @@ static block_t *VideoGetBuffer( sout_str 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 +871,7 @@ static block_t *VideoGetBuffer( sout_str } 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 +891,7 @@ static block_t *VideoGetBuffer( sout_str #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 +944,13 @@ static block_t *VideoGetBuffer( sout_str 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: