[vlc-devel] [PATCH 5/7] Avcodec: create an avcodec_alloc_context3 replacement for older versions

Jean-Baptiste Kempf jb at videolan.org
Tue Mar 12 14:30:21 CET 2013


---
 modules/codec/avcodec/avcodec.c         | 4 ----
 modules/codec/avcodec/avcommon_compat.h | 4 ++++
 modules/codec/avcodec/encoder.c         | 4 ----
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index f42621f..fe06d83 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -293,11 +293,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
 
     /* *** get a p_context *** */
-#if LIBAVCODEC_VERSION_MAJOR >= 54
     p_context = avcodec_alloc_context3(p_codec);
-#else
-    p_context = avcodec_alloc_context();
-#endif
     if( !p_context )
         return VLC_ENOMEM;
     p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" );
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
index b094223..7d896b7 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -471,6 +471,10 @@ enum {
 
 #endif /* LIBAVCODEC_VERSION < 54.25 */
 
+#if LIBAVCODEC_VERSION_MAJOR < 54
+# define avcodec_alloc_context3(a) avcodec_alloc_context()
+#endif
+
 #endif /* HAVE_LIBAVCODEC_AVCODEC_H */
 
 #ifdef HAVE_LIBAVUTIL_AVUTIL_H
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 66664cf..f4a008b 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -304,11 +304,7 @@ int OpenEncoder( vlc_object_t *p_this )
     p_sys->p_buffer = NULL;
     p_sys->i_buffer_out = 0;
 
-#if LIBAVCODEC_VERSION_MAJOR < 54
-    p_context = avcodec_alloc_context();
-#else
     p_context = avcodec_alloc_context3(p_codec);
-#endif
     p_sys->p_context = p_context;
     p_sys->p_context->codec_id = p_sys->p_codec->id;
     p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" );
-- 
1.8.1.5




More information about the vlc-devel mailing list