[vlc-commits] avcodec: remove redundant codec_id parameter

Rémi Denis-Courmont git at videolan.org
Thu Sep 11 22:38:35 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Sep 11 23:31:19 2014 +0300| [894a06046f8bc1710a2d367202bac8bbc2c2b4a2] | committer: Rémi Denis-Courmont

avcodec: remove redundant codec_id parameter

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

 modules/codec/avcodec/audio.c    |   14 +++++++-------
 modules/codec/avcodec/avcodec.c  |    6 +++---
 modules/codec/avcodec/avcodec.h  |   10 +++-------
 modules/codec/avcodec/subtitle.c |    7 +++----
 modules/codec/avcodec/video.c    |   23 ++++++++++++-----------
 5 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index f68e7f5..61f89fa 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -122,8 +122,8 @@ static int OpenAudioCodec( decoder_t *p_dec )
 
     if( p_sys->p_context->extradata_size <= 0 )
     {
-        if( p_sys->i_codec_id == AV_CODEC_ID_VORBIS ||
-            ( p_sys->i_codec_id == AV_CODEC_ID_AAC &&
+        if( p_sys->p_codec->id == AV_CODEC_ID_VORBIS ||
+            ( p_sys->p_codec->id == AV_CODEC_ID_AAC &&
               !p_dec->fmt_in.b_packetized ) )
         {
             msg_Warn( p_dec, "waiting for extra data for codec %s",
@@ -139,7 +139,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
     p_sys->p_context->bits_per_coded_sample =
                                            p_dec->fmt_in.audio.i_bitspersample;
 
-    if( p_sys->i_codec_id == AV_CODEC_ID_ADPCM_G726 &&
+    if( p_sys->p_codec->id == AV_CODEC_ID_ADPCM_G726 &&
         p_sys->p_context->bit_rate > 0 &&
         p_sys->p_context->sample_rate >  0)
         p_sys->p_context->bits_per_coded_sample = p_sys->p_context->bit_rate
@@ -236,7 +236,7 @@ static int GetAudioBuf( AVCodecContext *ctx, AVFrame *buf )
  * The avcodec codec will be opened, some memory allocated.
  *****************************************************************************/
 int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
-                  const AVCodec *p_codec, int i_codec_id )
+                  const AVCodec *p_codec )
 {
     decoder_sys_t *p_sys;
 
@@ -247,7 +247,7 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
     }
 
     p_context->codec_type = AVMEDIA_TYPE_AUDIO;
-    p_context->codec_id = i_codec_id;
+    p_context->codec_id = p_codec->id;
 #if (LIBAVCODEC_VERSION_MAJOR >= 55)
     p_context->refcounted_frames = true;
 #else
@@ -255,7 +255,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
 #endif
     p_sys->p_context = p_context;
     p_sys->p_codec = p_codec;
-    p_sys->i_codec_id = i_codec_id;
     p_sys->b_delayed_open = true;
 
     // Initialize decoder extradata
@@ -316,7 +315,8 @@ static block_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
         avcodec_flush_buffers( ctx );
         date_Set( &p_sys->end_date, 0 );
 
-        if( p_sys->i_codec_id == AV_CODEC_ID_MP2 || p_sys->i_codec_id == AV_CODEC_ID_MP3 )
+        if( ctx->codec_id == AV_CODEC_ID_MP2 ||
+            ctx->codec_id == AV_CODEC_ID_MP3 )
             p_sys->i_reject_count = 3;
 
         goto end;
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 40489df..52ae465 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -298,13 +298,13 @@ static int OpenDecoder( vlc_object_t *p_this )
     switch( i_cat )
     {
     case VIDEO_ES:
-        i_result =  InitVideoDec( p_dec, p_context, p_codec, i_codec_id );
+        i_result =  InitVideoDec( p_dec, p_context, p_codec );
         break;
     case AUDIO_ES:
-        i_result =  InitAudioDec( p_dec, p_context, p_codec, i_codec_id );
+        i_result =  InitAudioDec( p_dec, p_context, p_codec );
         break;
     case SPU_ES:
-        i_result =  InitSubtitleDec( p_dec, p_context, p_codec, i_codec_id );
+        i_result =  InitSubtitleDec( p_dec, p_context, p_codec );
         break;
     default:
         return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 3b8ec20..43e2637 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -44,17 +44,14 @@ int  OpenDeinterlace( vlc_object_t * );
 void CloseDeinterlace( vlc_object_t * );
 
 /* Video Decoder */
-int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
-                  const AVCodec *p_codec, int i_codec_id );
+int InitVideoDec( decoder_t *, AVCodecContext *, const AVCodec * );
 void EndVideoDec( decoder_t *p_dec );
 
 /* Audio Decoder */
-int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
-                  const AVCodec *p_codec, int i_codec_id );
+int InitAudioDec( decoder_t *, AVCodecContext *, const AVCodec * );
 
 /* Subtitle Decoder */
-int InitSubtitleDec( decoder_t *p_dec, AVCodecContext *p_context,
-                     const AVCodec *p_codec, int i_codec_id );
+int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
 
 /* Initialize decoder */
 int ffmpeg_OpenCodec( decoder_t *p_dec );
@@ -243,7 +240,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
    "hev1 and hev2 are currently supported only with libfdk-aac enabled libavcodec" )
 
 #define AVCODEC_COMMON_MEMBERS   \
-    int i_codec_id;             \
     AVCodecContext *p_context;  \
     const AVCodec  *p_codec;    \
     bool b_delayed_open;
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index d2d4ba1..7d103e2 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -50,12 +50,12 @@ static subpicture_t *DecodeSubtitle(decoder_t *, block_t **);
  * Initialize subtitle decoder
  */
 int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
-                    const AVCodec *codec, int codec_id)
+                    const AVCodec *codec)
 {
     decoder_sys_t *sys;
 
     /* */
-    switch (codec_id) {
+    switch (codec->id) {
     case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
     case AV_CODEC_ID_XSUB:
     case AV_CODEC_ID_DVB_SUBTITLE:
@@ -71,10 +71,9 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
         return VLC_ENOMEM;
 
     context->codec_type = AVMEDIA_TYPE_SUBTITLE;
-    context->codec_id = codec_id;
+    context->codec_id = codec->id;
     sys->p_context = context;
     sys->p_codec = codec;
-    sys->i_codec_id = codec_id;
     sys->b_delayed_open = false;
 
     /* */
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 2f12c96..b1a2b03 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -202,8 +202,8 @@ static int OpenVideoCodec( decoder_t *p_dec )
 
     if( p_sys->p_context->extradata_size <= 0 )
     {
-        if( p_sys->i_codec_id == AV_CODEC_ID_VC1 ||
-            p_sys->i_codec_id == AV_CODEC_ID_THEORA )
+        if( p_sys->p_codec->id == AV_CODEC_ID_VC1 ||
+            p_sys->p_codec->id == AV_CODEC_ID_THEORA )
         {
             msg_Warn( p_dec, "waiting for extra data for codec %s",
                       p_sys->p_codec->name );
@@ -258,7 +258,7 @@ static int OpenVideoCodec( decoder_t *p_dec )
  * opened (done after the first decoded frame).
  *****************************************************************************/
 int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
-                  const AVCodec *p_codec, int i_codec_id )
+                  const AVCodec *p_codec )
 {
     decoder_sys_t *p_sys;
     int i_val;
@@ -268,10 +268,9 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
         return VLC_ENOMEM;
 
     p_context->codec_type = AVMEDIA_TYPE_VIDEO;
-    p_context->codec_id = i_codec_id;
+    p_context->codec_id = p_codec->id;
     p_sys->p_context = p_context;
     p_sys->p_codec = p_codec;
-    p_sys->i_codec_id = i_codec_id;
     p_sys->p_ff_pic = avcodec_alloc_frame();
     p_sys->b_delayed_open = true;
     p_sys->p_va = NULL;
@@ -329,8 +328,9 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     if( var_CreateGetBool( p_dec, "avcodec-dr" ) &&
        (p_codec->capabilities & CODEC_CAP_DR1) &&
         /* No idea why ... but this fixes flickering on some TSCC streams */
-        p_sys->i_codec_id != AV_CODEC_ID_TSCC && p_sys->i_codec_id != AV_CODEC_ID_CSCD &&
-        p_sys->i_codec_id != AV_CODEC_ID_CINEPAK )
+        p_sys->p_codec->id != AV_CODEC_ID_TSCC &&
+        p_sys->p_codec->id != AV_CODEC_ID_CSCD &&
+        p_sys->p_codec->id != AV_CODEC_ID_CINEPAK )
     {
         /* Some codecs set pix_fmt only after the 1st frame has been decoded,
          * so we need to do another check in ffmpeg_GetFrameBuf() */
@@ -377,7 +377,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_context->thread_count = i_thread_count;
     p_context->thread_safe_callbacks = true;
 
-    switch( i_codec_id )
+    switch( p_codec->id )
     {
         case AV_CODEC_ID_MPEG4:
         case AV_CODEC_ID_H263:
@@ -393,6 +393,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
         case AV_CODEC_ID_WMV3:
             p_context->thread_type &= ~FF_THREAD_FRAME;
 # endif
+        default:
+            break;
     }
 
     /* Workaround: frame multithreading is not compatible with
@@ -838,7 +840,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
 
     if( !i_size ) return;
 
-    if( p_sys->i_codec_id == AV_CODEC_ID_SVQ3 )
+    if( p_sys->p_codec->id == AV_CODEC_ID_SVQ3 )
     {
         uint8_t *p;
 
@@ -1176,7 +1178,6 @@ static int ffmpeg_va_GetFrameBuf( struct AVCodecContext *p_context, AVFrame *p_f
 static picture_t *ffmpeg_dr_GetFrameBuf(struct AVCodecContext *p_context)
 {
     decoder_t *p_dec = (decoder_t *)p_context->opaque;
-    decoder_sys_t *p_sys = p_dec->p_sys;
 
     int i_width = p_context->width;
     int i_height = p_context->height;
@@ -1202,7 +1203,7 @@ static picture_t *ffmpeg_dr_GetFrameBuf(struct AVCodecContext *p_context)
     for( int i = 0; i < p_pic->i_planes; i++ )
     {
         unsigned i_align;
-        switch( p_sys->i_codec_id )
+        switch( p_context->codec_id )
         {
         case AV_CODEC_ID_SVQ1:
         case AV_CODEC_ID_VP5:



More information about the vlc-commits mailing list