[vlc-devel] [PATCH 6/7] Avcodec: provide a replacement for avcodec_open2 for older versions

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


---
 modules/codec/avcodec/avcodec.c         | 4 ----
 modules/codec/avcodec/avcommon_compat.h | 1 +
 modules/codec/avcodec/encoder.c         | 8 --------
 modules/codec/avcodec/subtitle.c        | 4 ----
 4 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index fe06d83..743a315 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -418,11 +418,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
     }
     int ret;
     vlc_avcodec_lock();
-#if LIBAVCODEC_VERSION_MAJOR >= 54
     ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, NULL /* options */ );
-#else
-    ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
-#endif
     vlc_avcodec_unlock();
     if( ret < 0 )
         return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
index 7d896b7..574d4fe 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -473,6 +473,7 @@ enum {
 
 #if LIBAVCODEC_VERSION_MAJOR < 54
 # define avcodec_alloc_context3(a) avcodec_alloc_context()
+# define avcodec_open2(a, b, c) avcodec_open(a, b)
 #endif
 
 #endif /* HAVE_LIBAVCODEC_AVCODEC_H */
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index f4a008b..56e6453 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -701,11 +701,7 @@ int OpenEncoder( vlc_object_t *p_this )
 
     int ret;
     vlc_avcodec_lock();
-#if LIBAVCODEC_VERSION_MAJOR < 54
-    ret = avcodec_open( p_context, p_codec );
-#else
     ret = avcodec_open2( p_context, p_codec, NULL /* options */ );
-#endif
     vlc_avcodec_unlock();
     if( ret )
     {
@@ -759,11 +755,7 @@ int OpenEncoder( vlc_object_t *p_this )
 
             p_context->codec = NULL;
             vlc_avcodec_lock();
-#if LIBAVCODEC_VERSION_MAJOR < 54
-            ret = avcodec_open( p_context, p_codec );
-#else
             ret = avcodec_open2( p_context, p_codec, NULL /* options */ );
-#endif
             vlc_avcodec_unlock();
             if( ret )
             {
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index d4bfdbe..a1543ef 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -83,11 +83,7 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
     /* */
     int ret;
     vlc_avcodec_lock();
-#if LIBAVCODEC_VERSION_MAJOR < 54
-    ret = avcodec_open(context, codec);
-#else
     ret = avcodec_open2(context, codec, NULL /* options */);
-#endif
     vlc_avcodec_unlock();
     if (ret < 0) {
         msg_Err(dec, "cannot open codec (%s)", namecodec);
-- 
1.8.1.5




More information about the vlc-devel mailing list