MLT_REGISTER( filter_type, "audioconvert", filter_audioconvert_init );
MLT_REGISTER( filter_type, "brightness", filter_brightness_init );
MLT_REGISTER( filter_type, "channelcopy", filter_channelcopy_init );
- MLT_REGISTER( filter_type, "crop", filter_crop_init );
+ MLT_REGISTER( filter_type, "channelswap", filter_channelcopy_init );
+ MLT_REGISTER( filter_type, "crop", filter_crop_init );
MLT_REGISTER( filter_type, "data_feed", filter_data_feed_init );
MLT_REGISTER( filter_type, "data_show", filter_data_show_init );
MLT_REGISTER( filter_type, "gamma", filter_gamma_init );
int from = mlt_properties_get_int( properties, "channelcopy.from" );
int to = mlt_properties_get_int( properties, "channelcopy.to" );
+ int swap = mlt_properties_get_int( properties, "channelcopy.swap" );
// Get the producer's audio
mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
{
int16_t *f = (int16_t*) *buffer + from;
int16_t *t = (int16_t*) *buffer + to;
+ int16_t x;
int i;
- for ( i = 0; i < *samples; i++, f += *channels, t += *channels )
- *t = *f;
+
+ if ( swap )
+ for ( i = 0; i < *samples; i++, f += *channels, t += *channels )
+ {
+ x = *t;
+ *t = *f;
+ *f = x;
+ }
+ else
+ for ( i = 0; i < *samples; i++, f += *channels, t += *channels )
+ *t = *f;
break;
}
case mlt_audio_s32:
{
int32_t *f = (int32_t*) *buffer + from * *samples;
int32_t *t = (int32_t*) *buffer + to * *samples;
- memcpy( t, f, *samples * sizeof(int32_t) );
+
+ if ( swap )
+ {
+ int32_t *x = malloc( *samples * sizeof(int32_t) );
+ memcpy( x, t, *samples * sizeof(int32_t) );
+ memcpy( t, f, *samples * sizeof(int32_t) );
+ memcpy( f, x, *samples * sizeof(int32_t) );
+ free( x );
+ }
+ else
+ {
+ memcpy( t, f, *samples * sizeof(int32_t) );
+ }
break;
}
case mlt_audio_float:
{
float *f = (float*) *buffer + from * *samples;
float *t = (float*) *buffer + to * *samples;
- memcpy( t, f, *samples * sizeof(float) );
+
+ if ( swap )
+ {
+ float *x = malloc( *samples * sizeof(float) );
+ memcpy( x, t, *samples * sizeof(float) );
+ memcpy( t, f, *samples * sizeof(float) );
+ memcpy( f, x, *samples * sizeof(float) );
+ free( x );
+ }
+ else
+ {
+ memcpy( t, f, *samples * sizeof(float) );
+ }
break;
}
default:
// Propogate the parameters
mlt_properties_set_int( frame_props, "channelcopy.to", mlt_properties_get_int( properties, "to" ) );
mlt_properties_set_int( frame_props, "channelcopy.from", mlt_properties_get_int( properties, "from" ) );
+ mlt_properties_set_int( frame_props, "channelcopy.swap", mlt_properties_get_int( properties, "swap" ) );
// Override the get_audio method
mlt_frame_push_audio( frame, this );
mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "to", atoi( arg ) );
else
mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "to", 1 );
+ if ( strcmp(id, "channelswap") == 0 )
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "swap", 1 );
}
return this;
}