]> git.sesse.net Git - vlc/blobdiff - modules/codec/vorbis.c
* modules/demux/ogg.c: provide some file info. Tested with the tarzan.ogm
[vlc] / modules / codec / vorbis.c
index a7a40383c00cf995945b337a7134da3721b78568..0a138059238a0509d5b94f6fd3d3398ae33a1915 100644 (file)
@@ -2,7 +2,7 @@
  * vorbis.c: vorbis decoder module making use of libvorbis.
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: vorbis.c,v 1.5 2002/11/14 22:38:47 massiot Exp $
+ * $Id: vorbis.c,v 1.9 2002/12/19 23:23:25 sigmunau Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 #include <vlc/input.h>
 
 #include <ogg/ogg.h>
+#ifdef MODULE_NAME_IS_tremor
+#include <tremor/ivorbiscodec.h>
+#else
 #include <vorbis/codec.h>
+#endif
 
 /*****************************************************************************
  * dec_thread_t : vorbis decoder thread descriptor
@@ -79,7 +83,8 @@ static int pi_channels_maps[6] =
     0,
     AOUT_CHAN_CENTER,   AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
     AOUT_CHAN_CENTER | AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
-    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
+    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
+     | AOUT_CHAN_REARRIGHT,
     AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
      | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
 };
@@ -94,14 +99,22 @@ static void CloseDecoder ( dec_thread_t * );
 static void DecodePacket ( dec_thread_t * );
 static int  GetOggPacket ( dec_thread_t *, ogg_packet *, mtime_t * );
 
+#ifdef MODULE_NAME_IS_tremor
+static void Interleave   ( int32_t *, const int32_t **, int, int );
+#else
 static void Interleave   ( float *, const float **, int, int );
+#endif
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
     set_description( _("Vorbis decoder module") );
+#ifdef MODULE_NAME_IS_tremor
+    set_capability( "decoder", 90 );
+#else
     set_capability( "decoder", 100 );
+#endif
     set_callbacks( OpenDecoder, NULL );
 vlc_module_end();
 
@@ -169,7 +182,26 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
         msg_Err( p_dec->p_fifo, "2nd Vorbis header is corrupted" );
         goto error;
     }
-
+    /* parse the vorbis comment */
+    {
+        input_thread_t *p_input = p_fifo->p_parent;
+        input_info_category_t *p_cat = input_InfoCategory( p_input,
+                                                           "Vorbis Comment" );
+        int i = 0;
+        char *psz_name, *psz_value, *psz_comment;
+        while ( i < p_dec->vc.comments )
+        {
+            psz_comment = strdup( p_dec->vc.user_comments[i] );
+            psz_name = psz_comment;
+            psz_value = strchr( psz_comment, '=' );
+            *psz_value = '\0';
+            psz_value++;
+            input_AddInfo( p_cat, psz_name, psz_value );
+            free( psz_comment );
+            i++;
+        }
+    }
+    
     if( GetOggPacket( p_dec, &oggpacket, &i_pts ) != VLC_SUCCESS )
         goto error;
 
@@ -183,8 +215,14 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
     vorbis_synthesis_init( &p_dec->vd, &p_dec->vi );
     vorbis_block_init( &p_dec->vd, &p_dec->vb );
 
+#ifdef MODULE_NAME_IS_tremor
+    p_dec->output_format.i_format = VLC_FOURCC('f','i','3','2');
+#else
     p_dec->output_format.i_format = VLC_FOURCC('f','l','3','2');
-    p_dec->output_format.i_channels = pi_channels_maps[p_dec->vi.channels];
+#endif
+    p_dec->output_format.i_physical_channels =
+        p_dec->output_format.i_original_channels =
+            pi_channels_maps[p_dec->vi.channels];
     p_dec->output_format.i_rate = p_dec->vi.rate;
 
     aout_DateInit( &p_dec->end_date, p_dec->vi.rate );
@@ -238,7 +276,11 @@ static void DecodePacket( dec_thread_t *p_dec )
 {
     aout_buffer_t *p_aout_buffer;
     ogg_packet    oggpacket;
+#ifdef MODULE_NAME_IS_tremor
+    int32_t       **pp_pcm;
+#else
     float         **pp_pcm;
+#endif
     int           i_samples;
     mtime_t       i_pts;
 
@@ -275,8 +317,13 @@ static void DecodePacket( dec_thread_t *p_dec )
         }
 
         /* Interleave the samples */
-        Interleave( (float *)p_aout_buffer->p_buffer, (const float **)pp_pcm,
-                    p_dec->vi.channels, i_samples );
+#ifdef MODULE_NAME_IS_tremor
+        Interleave( (int32_t *)p_aout_buffer->p_buffer,
+                    (const int32_t **)pp_pcm, p_dec->vi.channels, i_samples );
+#else
+        Interleave( (float *)p_aout_buffer->p_buffer,
+                    (const float **)pp_pcm, p_dec->vi.channels, i_samples );
+#endif
 
         /* Tell libvorbis how many samples we actually consumed */
         vorbis_synthesis_read( &p_dec->vd, i_samples );
@@ -321,8 +368,12 @@ static int GetOggPacket( dec_thread_t *p_dec, ogg_packet *p_oggpacket,
 /*****************************************************************************
  * Interleave: helper function to interleave channels
  *****************************************************************************/
-static void Interleave( float *p_out, const float **pp_in, int i_nb_channels,
-                        int i_samples )
+#ifdef MODULE_NAME_IS_tremor
+static void Interleave( int32_t *p_out, const int32_t **pp_in,
+#else
+static void Interleave( float *p_out, const float **pp_in,
+#endif
+                        int i_nb_channels, int i_samples )
 {
     int i, j;