[vlc-commits] avcodec: pass explicit parameters to ffmpeg_OpenCodec()

Rémi Denis-Courmont git at videolan.org
Mon Jun 19 19:58:59 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jun 19 18:41:57 2017 +0300| [8dc541c67fbf88432191c0d3435c1c3aa176caa1] | committer: Rémi Denis-Courmont

avcodec: pass explicit parameters to ffmpeg_OpenCodec()

This avoids relying on p_sys.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8dc541c67fbf88432191c0d3435c1c3aa176caa1
---

 modules/codec/avcodec/audio.c   |  2 +-
 modules/codec/avcodec/avcodec.c | 10 +++++-----
 modules/codec/avcodec/avcodec.h |  2 +-
 modules/codec/avcodec/video.c   |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index fc9cab1ce8..30630bf773 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -148,7 +148,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
         ctx->sample_rate >  0)
         ctx->bits_per_coded_sample = ctx->bit_rate / ctx->sample_rate;
 
-    return ffmpeg_OpenCodec( p_dec );
+    return ffmpeg_OpenCodec( p_dec, ctx, codec );
 }
 
 /**
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 1dc779f2ed..1c15f6ef01 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -354,9 +354,9 @@ static void CloseDecoder( vlc_object_t *p_this )
 /*****************************************************************************
  * ffmpeg_OpenCodec:
  *****************************************************************************/
-int ffmpeg_OpenCodec( decoder_t *p_dec )
+int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *ctx,
+                      const AVCodec *codec )
 {
-    decoder_sys_t *p_sys = p_dec->p_sys;
     char *psz_opts = var_InheritString( p_dec, "avcodec-options" );
     AVDictionary *options = NULL;
     int ret;
@@ -367,7 +367,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
     }
 
     vlc_avcodec_lock();
-    ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, options ? &options : NULL );
+    ret = avcodec_open2( ctx, codec, options ? &options : NULL );
     vlc_avcodec_unlock();
 
     AVDictionaryEntry *t = NULL;
@@ -378,10 +378,10 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
 
     if( ret < 0 )
     {
-        msg_Err( p_dec, "cannot start codec (%s)", p_sys->p_codec->name );
+        msg_Err( p_dec, "cannot start codec (%s)", codec->name );
         return VLC_EGENERIC;
     }
 
-    msg_Dbg( p_dec, "codec (%s) started", p_sys->p_codec->name );
+    msg_Dbg( p_dec, "codec (%s) started", codec->name );
     return VLC_SUCCESS;
 }
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 557b2e0f97..1ca97c8f87 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -47,7 +47,7 @@ int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
 void EndSubtitleDec( decoder_t * );
 
 /* Initialize decoder */
-int ffmpeg_OpenCodec( decoder_t *p_dec );
+int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *, const AVCodec * );
 
 /*****************************************************************************
  * Module descriptor help strings
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 4e655dc849..6526bcbea8 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -400,7 +400,7 @@ static int OpenVideoCodec( decoder_t *p_dec )
     cc_Init( &p_sys->cc );
 
     post_mt( p_sys );
-    ret = ffmpeg_OpenCodec( p_dec );
+    ret = ffmpeg_OpenCodec( p_dec, ctx, codec );
     wait_mt( p_sys );
     if( ret < 0 )
         return ret;



More information about the vlc-commits mailing list