]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/converter/mpgatofixed32.c
Used VLC_CODEC_* and vlc_fourcc_GetCodec when suitable.
[vlc] / modules / audio_filter / converter / mpgatofixed32.c
index 9cf40a57c888d2a6aae85751076a339336f86c0e..1bee61dc33eff45508f3f22b3601c8047947a6eb 100644 (file)
@@ -33,7 +33,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_block.h>
@@ -66,18 +66,18 @@ struct filter_sys_t
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACODEC );
-    set_description( N_("MPEG audio decoder") );
-    set_capability( "audio filter", 100 );
-    set_callbacks( Create, Destroy );
-
-    add_submodule();
-    set_description( N_("MPEG audio decoder") );
-    set_capability( "audio filter2", 100 );
-    set_callbacks( OpenFilter, CloseFilter );
-vlc_module_end();
+vlc_module_begin ()
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACODEC )
+    set_description( N_("MPEG audio decoder") )
+    set_capability( "audio filter", 100 )
+    set_callbacks( Create, Destroy )
+
+    add_submodule ()
+    set_description( N_("MPEG audio decoder") )
+    set_capability( "audio filter2", 100 )
+    set_callbacks( OpenFilter, CloseFilter )
+vlc_module_end ()
 
 /*****************************************************************************
  * Create:
@@ -87,10 +87,10 @@ static int Create( vlc_object_t *p_this )
     aout_filter_t *p_filter = (aout_filter_t *)p_this;
     struct filter_sys_t *p_sys;
 
-    if ( (p_filter->input.i_format != VLC_FOURCC('m','p','g','a')
+    if ( (p_filter->input.i_format != VLC_CODEC_MPGA
            && p_filter->input.i_format != VLC_FOURCC('m','p','g','3'))
-            || (p_filter->output.i_format != VLC_FOURCC('f','l','3','2')
-                 && p_filter->output.i_format != VLC_FOURCC('f','i','3','2')) )
+            || (p_filter->output.i_format != VLC_CODEC_FL32
+                 && p_filter->output.i_format != VLC_CODEC_FI32) )
     {
         return -1;
     }
@@ -104,10 +104,7 @@ static int Create( vlc_object_t *p_this )
     p_sys = malloc( sizeof(filter_sys_t) );
     p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
     if( p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
         return -1;
-    }
 
     /* Initialize libmad */
     mad_stream_init( &p_sys->mad_stream );
@@ -150,7 +147,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
 
     if( p_sys->i_reject_count > 0 )
     {
-        if( p_filter->output.i_format == VLC_FOURCC('f','l','3','2') )
+        if( p_filter->output.i_format == VLC_CODEC_FL32 )
         {
             int i;
             int i_size = p_out_buf->i_nb_bytes / sizeof(float);
@@ -170,7 +167,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
 
     mad_synth_frame( &p_sys->mad_synth, &p_sys->mad_frame );
 
-    if ( p_filter->output.i_format == VLC_FOURCC('f','i','3','2') )
+    if ( p_filter->output.i_format == VLC_CODEC_FI32 )
     {
         /* Interleave and keep buffers in mad_fixed_t format */
         mad_fixed_t * p_samples = (mad_fixed_t *)p_out_buf->p_buffer;
@@ -307,7 +304,7 @@ static int OpenFilter( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys;
 
-    if( p_filter->fmt_in.i_codec != VLC_FOURCC('m','p','g','a') &&
+    if( p_filter->fmt_in.i_codec != VLC_CODEC_MPGA &&
         p_filter->fmt_in.i_codec != VLC_FOURCC('m','p','g','3') )
     {
         return VLC_EGENERIC;
@@ -316,10 +313,7 @@ static int OpenFilter( vlc_object_t *p_this )
     /* Allocate the memory needed to store the module's structure */
     p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
         return -1;
-    }
     p_sys->i_reject_count = 0;
 
     p_filter->pf_audio_filter = Convert;
@@ -331,10 +325,12 @@ static int OpenFilter( vlc_object_t *p_this )
     mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC );
 
     if( vlc_CPU() & CPU_CAPABILITY_FPU )
-        p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2');
+        p_filter->fmt_out.i_codec = VLC_CODEC_FL32;
     else
-        p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2');
+        p_filter->fmt_out.i_codec = VLC_CODEC_FI32;
     p_filter->fmt_out.audio.i_format = p_filter->fmt_out.i_codec;
+    p_filter->fmt_out.audio.i_bitspersample =
+        aout_BitsPerSample( p_filter->fmt_out.i_codec );
 
     p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate;
 
@@ -369,7 +365,8 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
 
     if( !p_block || !p_block->i_samples )
     {
-        if( p_block ) p_block->pf_release( p_block );
+        if( p_block )
+            block_Release( p_block );
         return NULL;
     }
 
@@ -381,7 +378,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     if( !p_out )
     {
         msg_Warn( p_filter, "can't get output buffer" );
-        p_block->pf_release( p_block );
+        block_Release( p_block );
         return NULL;
     }
 
@@ -406,7 +403,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
 
     DoWork( (aout_instance_t *)p_filter, &aout_filter, &in_buf, &out_buf );
 
-    p_block->pf_release( p_block );
+    block_Release( p_block );
 
     p_out->i_buffer = out_buf.i_nb_bytes;
     p_out->i_samples = out_buf.i_nb_samples;