Index: libmpcodecs/vf_fspp.c =================================================================== --- libmpcodecs/vf_fspp.c (revision 32006) +++ libmpcodecs/vf_fspp.c (working copy) @@ -636,7 +636,7 @@ vf->control= control; vf->priv=av_mallocz(sizeof(struct vf_priv_s));//assumes align 16 ! - avcodec_init(); + init_avcodec(); //vf->priv->avctx= avcodec_alloc_context(); //dsputil_init(&vf->priv->dsp, vf->priv->avctx); Index: libmpcodecs/ad_ffmpeg.c =================================================================== --- libmpcodecs/ad_ffmpeg.c (revision 32006) +++ libmpcodecs/ad_ffmpeg.c (working copy) @@ -44,7 +44,6 @@ #include "libavcodec/avcodec.h" -extern int avcodec_initialized; static int preinit(sh_audio_t *sh) { @@ -95,11 +94,7 @@ AVCodec *lavc_codec; mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n"); - if(!avcodec_initialized){ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); if(!lavc_codec){ Index: libmpcodecs/vf_lavcdeint.c =================================================================== --- libmpcodecs/vf_lavcdeint.c (revision 32006) +++ libmpcodecs/vf_lavcdeint.c (working copy) @@ -30,7 +30,6 @@ #include "vf.h" #include "libavcodec/avcodec.h" -extern int avcodec_initialized; struct vf_priv_s { @@ -175,12 +174,7 @@ /* This may not technically be necessary just for a deinterlace, * but it seems like a good idea. */ - if(!avcodec_initialized) - { - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); return 1; } Index: libmpcodecs/vf_uspp.c =================================================================== --- libmpcodecs/vf_uspp.c (revision 32006) +++ libmpcodecs/vf_uspp.c (working copy) @@ -353,8 +353,7 @@ vf->priv=malloc(sizeof(struct vf_priv_s)); memset(vf->priv, 0, sizeof(struct vf_priv_s)); - avcodec_init(); - avcodec_register_all(); + init_avcodec(); vf->priv->log2_count= 4; Index: libmpcodecs/vd_ffmpeg.c =================================================================== --- libmpcodecs/vd_ffmpeg.c (revision 32006) +++ libmpcodecs/vd_ffmpeg.c (working copy) @@ -252,12 +252,7 @@ int lowres_w=0; int do_vis_debug= lavc_param_vismv || (lavc_param_debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP)); - if(!avcodec_initialized){ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - av_log_set_callback(mp_msp_av_log_callback); - } + init_avcodec(); ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); if (!ctx) @@ -976,3 +971,13 @@ return selected_format; } #endif /* CONFIG_XVMC || CONFIG_VDPAU */ + +void init_avcodec() +{ + if(!avcodec_initialized){ + avcodec_init(); + avcodec_register_all(); + avcodec_initialized=1; + av_log_set_callback(mp_msp_av_log_callback); + } +} Index: libmpcodecs/vf_spp.c =================================================================== --- libmpcodecs/vf_spp.c (revision 32006) +++ libmpcodecs/vf_spp.c (working copy) @@ -575,7 +575,7 @@ vf->priv=malloc(sizeof(struct vf_priv_s)); memset(vf->priv, 0, sizeof(struct vf_priv_s)); - avcodec_init(); + init_avcodec(); vf->priv->avctx= avcodec_alloc_context(); dsputil_init(&vf->priv->dsp, vf->priv->avctx); Index: libmpcodecs/vf_zrmjpeg.c =================================================================== --- libmpcodecs/vf_zrmjpeg.c (revision 32006) +++ libmpcodecs/vf_zrmjpeg.c (working copy) @@ -63,10 +63,6 @@ #define WARNING(...) mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ "vf_zrmjpeg: " __VA_ARGS__) -// "local" flag in vd_ffmpeg.c. If not set, avcodec_init() et. al. need to be called -// set when init is done, so that initialization is not done twice. -extern int avcodec_initialized; - /// The get_pixels() routine to use. The real routine comes from dsputil static void (*get_pixels)(DCTELEM *restrict block, const uint8_t *pixels, int line_size); @@ -473,15 +469,7 @@ j->cheap_upsample = cu; j->bw = b; - // Is this needed? - /* if libavcodec is used by the decoder then we must not - * initialize again, but if it is not initialized then we must - * initialize it here. */ - if (!avcodec_initialized) { - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); // Build mjpeg huffman code tables, setting up j->s->mjpeg_ctx if (ff_mjpeg_encode_init(j->s) < 0) { @@ -919,14 +907,7 @@ priv->hdec = 1; priv->vdec = 1; - /* if libavcodec is already initialized, we must not initialize it - * again, but if it is not initialized then we mustinitialize it now. */ - if (!avcodec_initialized) { - /* we need to initialize libavcodec */ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); if (args) { char *arg, *tmp, *ptr, junk; Index: libmpcodecs/vf_mcdeint.c =================================================================== --- libmpcodecs/vf_mcdeint.c (revision 32006) +++ libmpcodecs/vf_mcdeint.c (working copy) @@ -316,8 +316,7 @@ vf->priv=malloc(sizeof(struct vf_priv_s)); memset(vf->priv, 0, sizeof(struct vf_priv_s)); - avcodec_init(); - avcodec_register_all(); + init_avcodec(); vf->priv->mode=0; vf->priv->parity= -1; Index: libmpcodecs/ve.h =================================================================== --- libmpcodecs/ve.h (revision 32006) +++ libmpcodecs/ve.h (working copy) @@ -20,6 +20,7 @@ #define MPLAYER_VE_H #include "m_option.h" +#include "mpc_info.h" extern const m_option_t lavcopts_conf[]; extern const m_option_t vfwopts_conf[]; Index: libmpcodecs/vf_lavc.c =================================================================== --- libmpcodecs/vf_lavc.c (revision 32006) +++ libmpcodecs/vf_lavc.c (working copy) @@ -30,7 +30,6 @@ #include "vf.h" #include "libavcodec/avcodec.h" -extern int avcodec_initialized; struct vf_priv_s { unsigned char* outbuf; @@ -140,11 +139,7 @@ vf->priv=malloc(sizeof(struct vf_priv_s)); memset(vf->priv,0,sizeof(struct vf_priv_s)); - if (!avcodec_initialized){ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name("mpeg1video"); if (!vf->priv->codec) { Index: libmpcodecs/ae.h =================================================================== --- libmpcodecs/ae.h (revision 32006) +++ libmpcodecs/ae.h (working copy) @@ -20,6 +20,7 @@ #define MPLAYER_AE_H #include "libmpdemux/muxer.h" +#include "mpc_info.h" #define ACODEC_COPY 0 #define ACODEC_PCM 1 Index: libmpcodecs/ae_lavc.c =================================================================== --- libmpcodecs/ae_lavc.c (revision 32006) +++ libmpcodecs/ae_lavc.c (working copy) @@ -44,7 +44,6 @@ extern int lavc_param_atag; extern int lavc_param_audio_global_header; extern char *lavc_param_audio_avopt; -extern int avcodec_initialized; static int compressed_frame_size = 0; #ifdef CONFIG_LIBAVFORMAT #include "libavformat/avformat.h" @@ -190,11 +189,7 @@ return 0; } - if(!avcodec_initialized){ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); lavc_acodec = avcodec_find_encoder_by_name(lavc_param_acodec); if (!lavc_acodec) Index: libmpcodecs/mpc_info.h =================================================================== --- libmpcodecs/mpc_info.h (revision 32006) +++ libmpcodecs/mpc_info.h (working copy) @@ -40,4 +40,6 @@ #define CONTROL_ERROR -2 #define CONTROL_NA -3 +extern void init_avcodec(void); + #endif /* MPLAYER_MPC_INFO_H */ Index: libmpcodecs/ve_lavc.c =================================================================== --- libmpcodecs/ve_lavc.c (revision 32006) +++ libmpcodecs/ve_lavc.c (working copy) @@ -53,7 +53,6 @@ #include "libavcodec/avcodec.h" -extern int avcodec_initialized; /* video options */ static char *lavc_param_vcodec = "mpeg4"; @@ -1033,11 +1032,7 @@ mux_v->bih->biCompression = mmioFOURCC(lavc_param_vcodec[0], lavc_param_vcodec[1], lavc_param_vcodec[2], lavc_param_vcodec[3]); /* FIXME!!! */ - if (!avcodec_initialized){ - avcodec_init(); - avcodec_register_all(); - avcodec_initialized=1; - } + init_avcodec(); vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name(lavc_param_vcodec); if (!vf->priv->codec) { Index: libmpcodecs/vf.h =================================================================== --- libmpcodecs/vf.h (revision 32006) +++ libmpcodecs/vf.h (working copy) @@ -21,6 +21,7 @@ #include "m_option.h" #include "mp_image.h" +#include "mpc_info.h" extern m_obj_settings_t* vf_settings; extern const m_obj_list_t vf_obj_list;