]> git.sesse.net Git - mlt/blobdiff - src/modules/core/filter_mono.c
fix rounding causes by -ffast-math
[mlt] / src / modules / core / filter_mono.c
index 01b6f462deda35c10d4a4e1edea60c4a13764be6..3d2eba71334d66b5576be9ee6be13962c4d4ee90 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * filter_mono.c -- mix all channels to a mono signal across n channels
- * Copyright (C) 2003-2009 Ushodaya Enterprises Limited
+ * Copyright (C) 2003-2012 Ushodaya Enterprises Limited
  * Author: Dan Dennedy <dan@dennedy.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -58,6 +58,34 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
                        *buffer = new_buffer;
                        break;
                }
+               case mlt_audio_s32le:
+               {
+                       int32_t *new_buffer = mlt_pool_alloc( size );
+                       for ( i = 0; i < *samples; i++ )
+                       {
+                               int32_t mixdown = 0;
+                               for ( j = 0; j < *channels; j++ )
+                                       mixdown += ((int32_t*) *buffer)[ ( i * *channels ) + j ] / *channels;
+                               for ( j = 0; j < channels_out; j++ )
+                                       new_buffer[ ( i * channels_out ) + j ] = mixdown;
+                       }
+                       *buffer = new_buffer;
+                       break;
+               }
+               case mlt_audio_f32le:
+               {
+                       float *new_buffer = mlt_pool_alloc( size );
+                       for ( i = 0; i < *samples; i++ )
+                       {
+                               float mixdown = 0;
+                               for ( j = 0; j < *channels; j++ )
+                                       mixdown += ((float*) *buffer)[ ( i * *channels ) + j ] / *channels;
+                               for ( j = 0; j < channels_out; j++ )
+                                       new_buffer[ ( i * channels_out ) + j ] = mixdown;
+                       }
+                       *buffer = new_buffer;
+                       break;
+               }
                case mlt_audio_s32:
                {
                        int32_t *new_buffer = mlt_pool_alloc( size );