diff libmpcodecs/vf_zrmjpeg.c @ 31959:f957f330aa6d

Introduce init_avcodec function to avoid duplicated FFmpeg initializations. Vlad Seryakov, vseryakov gmail com
author diego
date Sat, 04 Sep 2010 08:11:31 +0000
parents a972c1a4a012
children e613306a8556
line wrap: on
line diff
--- a/libmpcodecs/vf_zrmjpeg.c	Sat Sep 04 00:20:08 2010 +0000
+++ b/libmpcodecs/vf_zrmjpeg.c	Sat Sep 04 08:11:31 2010 +0000
@@ -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;