]> git.sesse.net Git - vlc/commitdiff
Moved out avcodec SampleFormat -> VLC formats to its own function.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 1 May 2010 22:01:06 +0000 (00:01 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 1 May 2010 22:23:29 +0000 (00:23 +0200)
modules/codec/avcodec/audio.c
modules/codec/avcodec/avcodec.h

index 15b1e11439794e5650648ae0800384921e720413..920ed22a73f3581b7f31d85b666db2d853701ab9 100644 (file)
@@ -404,6 +404,35 @@ void EndAudioDec( decoder_t *p_dec )
  *
  *****************************************************************************/
 
+void GetVlcAudioFormat( vlc_fourcc_t *pi_codec, unsigned *pi_bits, int i_sample_fmt )
+{
+    switch( i_sample_fmt )
+    {
+    case SAMPLE_FMT_U8:
+        *pi_codec = VLC_CODEC_U8;
+        *pi_bits = 8;
+        break;
+    case SAMPLE_FMT_S32:
+        *pi_codec = VLC_CODEC_S32N;
+        *pi_bits = 32;
+        break;
+    case SAMPLE_FMT_FLT:
+        *pi_codec = VLC_CODEC_FL32;
+        *pi_bits = 32;
+        break;
+    case SAMPLE_FMT_DBL:
+        *pi_codec = VLC_CODEC_FL64;
+        *pi_bits = 64;
+        break;
+
+    case SAMPLE_FMT_S16:
+    default:
+        *pi_codec = VLC_CODEC_S16N;
+        *pi_bits = 16;
+        break;
+    }
+}
+
 static const uint64_t pi_channels_map[][2] =
 {
     { CH_FRONT_LEFT,        AOUT_CHAN_LEFT },
@@ -432,32 +461,10 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    switch( p_sys->p_context->sample_fmt )
-    {
-    case SAMPLE_FMT_U8:
-        p_dec->fmt_out.i_codec = VLC_CODEC_U8;
-        p_dec->fmt_out.audio.i_bitspersample = 8;
-        break;
-    case SAMPLE_FMT_S32:
-        p_dec->fmt_out.i_codec = VLC_CODEC_S32N;
-        p_dec->fmt_out.audio.i_bitspersample = 32;
-        break;
-    case SAMPLE_FMT_FLT:
-        p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
-        p_dec->fmt_out.audio.i_bitspersample = 32;
-        break;
-    case SAMPLE_FMT_DBL:
-        p_dec->fmt_out.i_codec = VLC_CODEC_FL64;
-        p_dec->fmt_out.audio.i_bitspersample = 64;
-        break;
-
-    case SAMPLE_FMT_S16:
-    default:
-        p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
-        p_dec->fmt_out.audio.i_bitspersample = 16;
-        break;
-    }
-    p_dec->fmt_out.audio.i_rate     = p_sys->p_context->sample_rate;
+    GetVlcAudioFormat( &p_dec->fmt_out.i_codec,
+                       &p_dec->fmt_out.audio.i_bitspersample,
+                       p_sys->p_context->sample_fmt );
+    p_dec->fmt_out.audio.i_rate = p_sys->p_context->sample_rate;
 
     /* */
     if( p_sys->i_previous_channels == p_sys->p_context->channels &&
index 3cfc0d7dd74af4ac5a93366f16df150b65b18225..b14b9572e07d39b1cca614f88046ba9071af3b17 100644 (file)
@@ -29,6 +29,7 @@ int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
 int TestFfmpegChroma( const int i_ffmpeg_id, const vlc_fourcc_t i_vlc_fourcc );
 int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t fmt );
 int GetVlcChroma( video_format_t *fmt, const int i_ffmpeg_chroma );
+void GetVlcAudioFormat( vlc_fourcc_t *, unsigned *pi_bits, int i_sample_fmt );
 
 
 picture_t * DecodeVideo    ( decoder_t *, block_t ** );