changeset 31960:1ba5eef167aa

Refactor more instances of avcodec_initialized handling into init_avcodec(). This is a leftover from the previous commit.
author diego
date Sat, 04 Sep 2010 08:36:38 +0000
parents f957f330aa6d
children 744b676c1654
files libaf/af_lavcac3enc.c libmpdemux/demuxer.c libvo/jpeg_enc.c
diffstat 3 files changed, 8 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_lavcac3enc.c	Sat Sep 04 08:11:31 2010 +0000
+++ b/libaf/af_lavcac3enc.c	Sat Sep 04 08:36:38 2010 +0000
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "libmpcodecs/vd_ffmpeg.h"
 #include "config.h"
 #include "af.h"
 #include "help_mp.h"
@@ -46,8 +47,6 @@
     int min_channel_num;
 } af_ac3enc_t;
 
-extern int  avcodec_initialized;
-
 // Initialization and runtime control
 static int control(struct af_instance_s *af, int cmd, void *arg)
 {
@@ -273,11 +272,7 @@
     af->data=calloc(1,sizeof(af_data_t));
     af->setup=s;
 
-    if (!avcodec_initialized){
-        avcodec_init();
-        avcodec_register_all();
-        avcodec_initialized=1;
-    }
+    init_avcodec();
 
     s->lavc_acodec = avcodec_find_encoder_by_name("ac3");
     if (!s->lavc_acodec) {
--- a/libmpdemux/demuxer.c	Sat Sep 04 08:11:31 2010 +0000
+++ b/libmpdemux/demuxer.c	Sat Sep 04 08:36:38 2010 +0000
@@ -42,6 +42,7 @@
 
 #include "libaf/af_format.h"
 #include "libmpcodecs/dec_teletext.h"
+#include "libmpcodecs/vd_ffmpeg.h"
 
 #ifdef CONFIG_ASS
 #include "libass/ass.h"
@@ -460,12 +461,9 @@
 static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parser, unsigned format)
 {
     enum CodecID codec_id = CODEC_ID_NONE;
-    extern int avcodec_initialized;
-    if (!avcodec_initialized) {
-        avcodec_init();
-        avcodec_register_all();
-        avcodec_initialized = 1;
-    }
+
+    init_avcodec();
+
     switch (format) {
     case 0x2000:
     case 0x332D6361:
--- a/libvo/jpeg_enc.c	Sat Sep 04 08:11:31 2010 +0000
+++ b/libvo/jpeg_enc.c	Sat Sep 04 08:36:38 2010 +0000
@@ -41,10 +41,9 @@
 #include "libavcodec/mpegvideo.h"
 #include "libavcodec/mjpegenc.h"
 
+#include "libmpcodecs/vd_ffmpeg.h"
 #include "jpeg_enc.h"
 
-extern int avcodec_initialized;
-
 
 /* Begin excessive code duplication ************************************/
 /* Code coming from mpegvideo.c and mjpeg.c in ../libavcodec ***********/
@@ -320,15 +319,7 @@
 	j->cheap_upsample = cu;
 	j->bw = b;
 
-	/* 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) {
-		/* we need to initialize libavcodec */
-		avcodec_init();
-		avcodec_register_all();
-		avcodec_initialized=1;
-	}
+	init_avcodec();
 
 	if (ff_mjpeg_encode_init(j->s) < 0) {
 		av_free(j->s);