mlt_repository.[hc]:
[melted] / src / modules / normalize / filter_volume.c
index 04fb936..e745363 100644 (file)
@@ -18,8 +18,7 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include "filter_volume.h"
-
+#include <framework/mlt_filter.h>
 #include <framework/mlt_frame.h>
 
 #include <stdio.h>
@@ -31,7 +30,7 @@
 #define MAX_CHANNELS 6
 #define EPSILON 0.00001
 
-/* The normalise functions come from the normalize utility:
+/* The following normalise functions come from the normalize utility:
    Copyright (C) 1999--2002 Chris Vaill */
 
 #define samp_width 16
@@ -167,7 +166,7 @@ double signal_max_power( int16_t *buffer, int channels, int samples, int16_t *pe
 static int filter_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples )
 {
        // Get the properties of the a frame
-       mlt_properties properties = mlt_frame_properties( frame );
+       mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
        double gain = mlt_properties_get_double( properties, "volume.gain" );
        double max_gain = mlt_properties_get_double( properties, "volume.max_gain" );
        double limiter_level = 0.5; /* -6 dBFS */
@@ -181,14 +180,11 @@ static int filter_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format
        mlt_filter this = mlt_properties_get_data( properties, "filter_volume", NULL );
 
        // Get the properties from the filter
-       mlt_properties filter_props = mlt_filter_properties( this );
+       mlt_properties filter_props = MLT_FILTER_PROPERTIES( this );
 
        if ( mlt_properties_get( properties, "volume.limiter" ) != NULL )
                limiter_level = mlt_properties_get_double( properties, "volume.limiter" );
        
-       // Restore the original get_audio
-       frame->get_audio = mlt_properties_get_data( properties, "volume.get_audio", NULL );
-
        // Get the producer's audio
        mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
 //     fprintf( stderr, "filter_volume: frequency %d\n", *frequency );
@@ -283,8 +279,8 @@ static int filter_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
-       mlt_properties properties = mlt_frame_properties( frame );
-       mlt_properties filter_props = mlt_filter_properties( this );
+       mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
+       mlt_properties filter_props = MLT_FILTER_PROPERTIES( this );
 
        // Parse the gain property
        if ( mlt_properties_get( properties, "gain" ) == NULL )
@@ -435,11 +431,8 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        // Put a filter reference onto the frame
        mlt_properties_set_data( properties, "filter_volume", this, 0, NULL, NULL );
 
-       // Backup the original get_audio (it's still needed)
-       mlt_properties_set_data( properties, "volume.get_audio", frame->get_audio, 0, NULL, NULL );
-
        // Override the get_audio method
-       frame->get_audio = filter_get_audio;
+       mlt_frame_push_audio( frame, filter_get_audio );
 
        return frame;
 }
@@ -447,12 +440,12 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 /** Constructor for the filter.
 */
 
-mlt_filter filter_volume_init( char *arg )
+mlt_filter filter_volume_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
 {
        mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
        if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
        {
-               mlt_properties properties = mlt_filter_properties( this );
+               mlt_properties properties = MLT_FILTER_PROPERTIES( this );
                this->process = filter_process;
                if ( arg != NULL )
                        mlt_properties_set( properties, "gain", arg );