]> git.sesse.net Git - mlt/commitdiff
new volume, mix, and resample filters and transitions
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 17 Jan 2004 00:02:22 +0000 (00:02 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 17 Jan 2004 00:02:22 +0000 (00:02 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@83 d19143bc-622f-0410-bfdd-b5b2a6649095

46 files changed:
docs/services.txt
mlt/docs/services.txt
mlt/src/miracle/miracle_log.c
mlt/src/miracle/miracle_unit.c
mlt/src/modules/Makefile
mlt/src/modules/core/Makefile
mlt/src/modules/core/configure
mlt/src/modules/core/factory.c
mlt/src/modules/core/filter_volume.c [new file with mode: 0644]
mlt/src/modules/core/filter_volume.h [new file with mode: 0644]
mlt/src/modules/core/transition_composite.c
mlt/src/modules/core/transition_composite.h
mlt/src/modules/core/transition_luma.c
mlt/src/modules/core/transition_mix.c [new file with mode: 0644]
mlt/src/modules/core/transition_mix.h [new file with mode: 0644]
mlt/src/modules/gtk2/producer_pango.c
mlt/src/modules/gtk2/producer_pixbuf.c
mlt/src/modules/resample/Makefile [new file with mode: 0644]
mlt/src/modules/resample/configure [new file with mode: 0755]
mlt/src/modules/resample/factory.c [new file with mode: 0644]
mlt/src/modules/resample/filter_resample.c [new file with mode: 0644]
mlt/src/modules/resample/filter_resample.h [new file with mode: 0644]
mlt/src/tests/luma.c
mlt/src/tests/pango.c
src/miracle/miracle_log.c
src/miracle/miracle_unit.c
src/modules/Makefile
src/modules/core/Makefile
src/modules/core/configure
src/modules/core/factory.c
src/modules/core/filter_volume.c [new file with mode: 0644]
src/modules/core/filter_volume.h [new file with mode: 0644]
src/modules/core/transition_composite.c
src/modules/core/transition_composite.h
src/modules/core/transition_luma.c
src/modules/core/transition_mix.c [new file with mode: 0644]
src/modules/core/transition_mix.h [new file with mode: 0644]
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pixbuf.c
src/modules/resample/Makefile [new file with mode: 0644]
src/modules/resample/configure [new file with mode: 0755]
src/modules/resample/factory.c [new file with mode: 0644]
src/modules/resample/filter_resample.c [new file with mode: 0644]
src/modules/resample/filter_resample.h [new file with mode: 0644]
src/tests/luma.c
src/tests/pango.c

index 16c42cc58fba45381f5df7640a2beca8fc6b7885..0477176507a5b7ac69f7e333b92a4c5774f5f90a 100644 (file)
@@ -24,8 +24,8 @@ Producers
                        int audio_channels - audio channels (default: 2)
                        int audio_track - audio track to use (default: 0)
                        int audio_loop - loop audio until video exhausted (default: 0)
-                       timecode in - in point
-                       timecode out - out point
+                       intint in - in point
+                       int out - out point
                        double fps - output frames per second (default: 25)
                        double aspect_ratio - aspect ratio of video
 
@@ -56,15 +56,15 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video]
-                       timecode length - duration of resource (in seconds)
+                       int length - duration of resource (in frames)
 
                Dependencies
 
@@ -86,15 +86,15 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video
-                       timecode length - duration of resource (in seconds)
+                       int length - duration of resource (in frames)
 
                Dependencies
 
@@ -118,13 +118,13 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video
 
                Dependencies
@@ -137,7 +137,7 @@ Producers
                        None.
 
        pango
-       
+
                Description
 
                        A title generator that uses the Pango international text layout
@@ -151,11 +151,11 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Mutable Properties
-               
+
                        int video_standard - enum mlt_video_standard from mlt_frame.h
                                             PAL = 0, NTSC = 1
                                             this determines proper pixel aspect ratio
@@ -212,8 +212,8 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Mutable Properties
 
@@ -240,13 +240,32 @@ Producers
                        in/out settings are incorrectly handled.
 
        ppm
+       
                Description
+
+                       Reads a stream of contiguous PPM images.
+                       
                Constructor Argument
+
+                       command - a shell command to run something that produces ppm
+                                 streams on stdout.
+                       
                Initialisation Properties
+
+                       none
+                       
                Read Only Properties
+
+                       string resource - the command
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
 
+                       Since it uses pipes, it is not compatible with bluefish.
+
 
 Filters
 -------
@@ -254,48 +273,196 @@ Filters
        deinterlace
        
                Description
+
+                       Deinterlace a frame consisting of two fields by linearly blending.
+               
                Constructor Argument
+
+                       none
+               
                Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+               
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       Not a bug, but it only provides fair quality at a fair performance;
+                               i.e., it excels at neither.
                
        ffmpeg_dub
        
                Description
+
+                       Use ffmpeg executable to substitute audio stream.
+               
                Constructor Argument
+
+                       file - filename of a WAV, Ogg Vorbis (--enable-vorbis),
+                              MP3 (--enable-mp3lame), or AC-3 (--enable-a52) audio file.
+               
                Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+               
                Read Only Properties
+               
+                       string resource - file
+                       
                Dependencies
+
+                       ffmpeg plus for ffmpeg:
+                       libogg and libvorbis for Ogg Vorbis, libmp3lame for MP3, liba52 for AC-3.
+                       
                Known Bugs
 
+                       Uses pipes and is therefore not compatible with bluefish.
+
        gamma
        
                Description
+
+                       Adjust image luma using a non-linear power-law curve
+                       
                Constructor Argument
+
+                       gamma - a floating point value
+               
                Initialisation Properties
-               Read Only Properties
+               
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double gamma - the exponential factor of the power-law curve
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       none
        
        greyscale
        
                Description
+
+                       Convert color image to greyscale
+                       
                Constructor Argument
+
+                       none
+                       
                Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       none
                
        resize
        
                Description
+
+                       Image scaling and padding
+                       
                Constructor Argument
+
+                       scale - "affine" to use affine transform scaling, otherwise
+                                center and pad.
+                       
                Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+                       
+               Dependencies
+
+                       none
+                       
+               Known Bugs
+
+                       none
+
+       volume
+
+               Description
+
+                       Adjust an audio stream's volume level
+                       
+               Constructor Argument
+
+                       volume - a floating point value of the factor
+                       
+               Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double volume - the factor applied to each sample
+                       
+               Dependencies
+
+                       none
+                       
+               Known Bugs
+
+                       none
+
+       resample
+
+               Description
+
+                       Adjust an audio stream's sampling rate
+
+               Constructor Argument
+
+                       frequency - a numeric value for the new sample rate
+
+               Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       int frequency - the target sample rate
+
                Dependencies
+
+                       libresample
+
                Known Bugs
 
+                       none
+
 Transitions
 -----------
 
@@ -307,14 +474,20 @@ Transitions
                        
                Constructor Argument
 
-                       none
+                       mix - see below
+
+               Initialisation Properties
                        
+                       int in - in point
+                       int out - out point
+
                Mutable Properties
 
                        int x - the horizontal offset from the left edge of the frame
                        int y - the vertical offset from the top edge of the frame
                        double mix - the opacity factor to apply to the second frame
                                     (used in addition to alpha channel).
+                                  - any negative value causes an automatic dissolve
                
                Read Only Properties
 
@@ -342,7 +515,12 @@ Transitions
                Constructor Argument
 
                        string file - the luma map file name. If not supplied, a dissolve.
+
+               Initialisation Properties
                
+                       int in - in point
+                       int out - out point
+
                Mutable Properties
 
                        string filename - same as above
@@ -362,6 +540,38 @@ Transitions
 
                        The luma map must be the same size as the B frame.
 
+       mix
+
+               Description
+
+                       An two stream audio mixer.
+
+               Constructor Argument
+
+                       mix - see below
+
+               Initalisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double mix - the mix level to apply to the second frame.
+                                  - any negative value causes an automatic crossfade.
+
+               Read Only Properties
+
+                       none
+
+               Dependencies
+
+                       none
+
+               Known Bugs
+
+                       Samples from the longer of the two frames are discarded.
+
 Consumers
 ---------
 
@@ -389,8 +599,11 @@ Consumers
                
                Known Bugs
 
+                       Does not work with any service that uses pipes!
+                       
                        If mlt crashes, you must reload the BlueDriver kernel module
                        due to unreleased DMA buffers.
+                       
                        Needs an argument or property for multi-card address.
                
        ffmpeg
index 16c42cc58fba45381f5df7640a2beca8fc6b7885..0477176507a5b7ac69f7e333b92a4c5774f5f90a 100644 (file)
@@ -24,8 +24,8 @@ Producers
                        int audio_channels - audio channels (default: 2)
                        int audio_track - audio track to use (default: 0)
                        int audio_loop - loop audio until video exhausted (default: 0)
-                       timecode in - in point
-                       timecode out - out point
+                       intint in - in point
+                       int out - out point
                        double fps - output frames per second (default: 25)
                        double aspect_ratio - aspect ratio of video
 
@@ -56,15 +56,15 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video]
-                       timecode length - duration of resource (in seconds)
+                       int length - duration of resource (in frames)
 
                Dependencies
 
@@ -86,15 +86,15 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video
-                       timecode length - duration of resource (in seconds)
+                       int length - duration of resource (in frames)
 
                Dependencies
 
@@ -118,13 +118,13 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Read Only Properties
 
                        string resource - file location
-                       double fps - output frames per second 
+                       double fps - output frames per second
                        double aspect_ratio - aspect ratio of video
 
                Dependencies
@@ -137,7 +137,7 @@ Producers
                        None.
 
        pango
-       
+
                Description
 
                        A title generator that uses the Pango international text layout
@@ -151,11 +151,11 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Mutable Properties
-               
+
                        int video_standard - enum mlt_video_standard from mlt_frame.h
                                             PAL = 0, NTSC = 1
                                             this determines proper pixel aspect ratio
@@ -212,8 +212,8 @@ Producers
 
                Initialisation Properties
 
-                       timecode in - in point
-                       timecode out - out point
+                       int in - in point
+                       int out - out point
 
                Mutable Properties
 
@@ -240,13 +240,32 @@ Producers
                        in/out settings are incorrectly handled.
 
        ppm
+       
                Description
+
+                       Reads a stream of contiguous PPM images.
+                       
                Constructor Argument
+
+                       command - a shell command to run something that produces ppm
+                                 streams on stdout.
+                       
                Initialisation Properties
+
+                       none
+                       
                Read Only Properties
+
+                       string resource - the command
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
 
+                       Since it uses pipes, it is not compatible with bluefish.
+
 
 Filters
 -------
@@ -254,48 +273,196 @@ Filters
        deinterlace
        
                Description
+
+                       Deinterlace a frame consisting of two fields by linearly blending.
+               
                Constructor Argument
+
+                       none
+               
                Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+               
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       Not a bug, but it only provides fair quality at a fair performance;
+                               i.e., it excels at neither.
                
        ffmpeg_dub
        
                Description
+
+                       Use ffmpeg executable to substitute audio stream.
+               
                Constructor Argument
+
+                       file - filename of a WAV, Ogg Vorbis (--enable-vorbis),
+                              MP3 (--enable-mp3lame), or AC-3 (--enable-a52) audio file.
+               
                Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+               
                Read Only Properties
+               
+                       string resource - file
+                       
                Dependencies
+
+                       ffmpeg plus for ffmpeg:
+                       libogg and libvorbis for Ogg Vorbis, libmp3lame for MP3, liba52 for AC-3.
+                       
                Known Bugs
 
+                       Uses pipes and is therefore not compatible with bluefish.
+
        gamma
        
                Description
+
+                       Adjust image luma using a non-linear power-law curve
+                       
                Constructor Argument
+
+                       gamma - a floating point value
+               
                Initialisation Properties
-               Read Only Properties
+               
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double gamma - the exponential factor of the power-law curve
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       none
        
        greyscale
        
                Description
+
+                       Convert color image to greyscale
+                       
                Constructor Argument
+
+                       none
+                       
                Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+                       
                Dependencies
+
+                       none
+                       
                Known Bugs
+
+                       none
                
        resize
        
                Description
+
+                       Image scaling and padding
+                       
                Constructor Argument
+
+                       scale - "affine" to use affine transform scaling, otherwise
+                                center and pad.
+                       
                Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
                Read Only Properties
+
+                       none
+                       
+               Dependencies
+
+                       none
+                       
+               Known Bugs
+
+                       none
+
+       volume
+
+               Description
+
+                       Adjust an audio stream's volume level
+                       
+               Constructor Argument
+
+                       volume - a floating point value of the factor
+                       
+               Initialisation Properties
+               
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double volume - the factor applied to each sample
+                       
+               Dependencies
+
+                       none
+                       
+               Known Bugs
+
+                       none
+
+       resample
+
+               Description
+
+                       Adjust an audio stream's sampling rate
+
+               Constructor Argument
+
+                       frequency - a numeric value for the new sample rate
+
+               Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       int frequency - the target sample rate
+
                Dependencies
+
+                       libresample
+
                Known Bugs
 
+                       none
+
 Transitions
 -----------
 
@@ -307,14 +474,20 @@ Transitions
                        
                Constructor Argument
 
-                       none
+                       mix - see below
+
+               Initialisation Properties
                        
+                       int in - in point
+                       int out - out point
+
                Mutable Properties
 
                        int x - the horizontal offset from the left edge of the frame
                        int y - the vertical offset from the top edge of the frame
                        double mix - the opacity factor to apply to the second frame
                                     (used in addition to alpha channel).
+                                  - any negative value causes an automatic dissolve
                
                Read Only Properties
 
@@ -342,7 +515,12 @@ Transitions
                Constructor Argument
 
                        string file - the luma map file name. If not supplied, a dissolve.
+
+               Initialisation Properties
                
+                       int in - in point
+                       int out - out point
+
                Mutable Properties
 
                        string filename - same as above
@@ -362,6 +540,38 @@ Transitions
 
                        The luma map must be the same size as the B frame.
 
+       mix
+
+               Description
+
+                       An two stream audio mixer.
+
+               Constructor Argument
+
+                       mix - see below
+
+               Initalisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       double mix - the mix level to apply to the second frame.
+                                  - any negative value causes an automatic crossfade.
+
+               Read Only Properties
+
+                       none
+
+               Dependencies
+
+                       none
+
+               Known Bugs
+
+                       Samples from the longer of the two frames are discarded.
+
 Consumers
 ---------
 
@@ -389,8 +599,11 @@ Consumers
                
                Known Bugs
 
+                       Does not work with any service that uses pipes!
+                       
                        If mlt crashes, you must reload the BlueDriver kernel module
                        due to unreleased DMA buffers.
+                       
                        Needs an argument or property for multi-card address.
                
        ffmpeg
index adfc54672f8203c17ba3160721dd622c10080aa4..f5f7e1a705af9bd91a024ba22d8e7845ae6cfaa9 100644 (file)
@@ -32,7 +32,7 @@ void miracle_log_init( enum log_output method, int new_threshold )
        log_output = method;
        threshold = new_threshold;
        if (method == log_syslog)
-               openlog( "dv1394d", LOG_CONS, LOG_DAEMON );
+               openlog( "miracle", LOG_CONS, LOG_DAEMON );
 
 }
 
index a1043df4ee1f20888eb0461e94d71a03139cdcc6..32ab8bec108884716f970210ebc92c2798f41540 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
+#include <limits.h>
 
 #include <sys/mman.h>
 
@@ -471,7 +472,7 @@ void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position
        else if ( clip >= mlt_playlist_count( playlist ) )
        {
                clip = mlt_playlist_count( playlist ) - 1;
-               position = 999999999999;
+               position = LONG_MAX;
        }
 
        if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 )
index 2179c42b42bc9e4c618110c8466829b0f492ed20..48274e0d771d2bfd4fa00dca5323bd3d812b2f13 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg inigo
+SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg inigo resample
 
 all clean depend install:
        list='$(SUBDIRS)'; \
index 9dd52cda02c685782288980794d56479e6291ffd..4c458d17548beb78c6d35e9dead06a97b7f4083f 100644 (file)
@@ -8,7 +8,9 @@ OBJS = factory.o \
           filter_gamma.o \
           filter_resize.o \
           transition_composite.o \
-          transition_luma.o
+          transition_luma.o \
+          transition_mix.o \
+          filter_volume.o
 
 CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
index 4b73ac861b659b53d1b3f4b51402ef4377783312..baedbae13818312132c724a088b47e5b0e4a9c97 100755 (executable)
@@ -12,11 +12,13 @@ deinterlace         libmltcore.so
 gamma                  libmltcore.so
 greyscale              libmltcore.so
 resize                 libmltcore.so
+volume                 libmltcore.so
 EOF
 
 cat << EOF >> ../transitions.dat
 composite              libmltcore.so
-luma           libmltcore.so
+luma                   libmltcore.so
+mix                            libmltcore.so
 EOF
 
 fi
index 78bdea75f9a1860dd4567c00f830a78032e8e97f..5353ac2110847f45435efa778ee7451ef42c38e3 100644 (file)
@@ -27,6 +27,8 @@
 #include "filter_gamma.h"
 #include "transition_composite.h"
 #include "transition_luma.h"
+#include "transition_mix.h"
+#include "filter_volume.h"
 
 void *mlt_create_producer( char *id, void *arg )
 {
@@ -45,6 +47,8 @@ void *mlt_create_filter( char *id, void *arg )
                return filter_greyscale_init( arg );
        if ( !strcmp( id, "resize" ) )
                return filter_resize_init( arg );
+       if ( !strcmp( id, "volume" ) )
+               return filter_volume_init( arg );
        return NULL;
 }
 
@@ -54,6 +58,8 @@ void *mlt_create_transition( char *id, void *arg )
                return transition_composite_init( arg );
        if ( !strcmp( id, "luma" ) )
                return transition_luma_init( arg );
+       if ( !strcmp( id, "mix" ) )
+               return transition_mix_init( arg );
        return NULL;
 }
 
diff --git a/mlt/src/modules/core/filter_volume.c b/mlt/src/modules/core/filter_volume.c
new file mode 100644 (file)
index 0000000..c0ad4dd
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * filter_volume.c -- adjust audio volume
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "filter_volume.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/** Get the audio.
+*/
+
+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 );
+       double volume = mlt_properties_get_double( properties, "volume" );
+
+       // 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 );
+
+       // Apply the volume
+       int i;
+       for ( i = 0; i < ( *channels * *samples ); i++ )
+               (*buffer)[i] *= volume;
+       
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_properties properties = mlt_frame_properties( frame );
+
+       // Propogate the level property
+       if ( mlt_properties_get( mlt_filter_properties( this ), "volume" ) != NULL )
+               mlt_properties_set_double( properties, "volume",
+                       mlt_properties_get_double( mlt_filter_properties( this ), "volume" ) );
+       
+       // 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;
+
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_volume_init( char *arg )
+{
+       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
+       {
+               this->process = filter_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_filter_properties( this ), "volume", atof( arg ) );
+       }
+       return this;
+}
+
diff --git a/mlt/src/modules/core/filter_volume.h b/mlt/src/modules/core/filter_volume.h
new file mode 100644 (file)
index 0000000..d5fb569
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_volume.h -- adjust audio volume
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FILTER_VOLUME_H_
+#define _FILTER_VOLUME_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_volume_init( char *arg );
+
+#endif
index ef896a9ff7b5678dd586a487ec1ff9222ceefb2d..7a32dd5020d69a3e483df7c5200a0219e0aab791 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-/** Composition class.
-*/
-
-typedef struct 
-{
-       struct mlt_transition_s parent;
-}
-transition_composite;
-
 /** Get the image.
 */
 
@@ -59,8 +50,8 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
                        x = mlt_properties_get_int( b_props, "x" );
                if ( mlt_properties_get( b_props, "y" ) != NULL )
                        y = mlt_properties_get_int( b_props, "y" );
-               if ( mlt_properties_get( b_props, "mix" ) != NULL )
-                       mix = mlt_properties_get_double( b_props, "mix" );
+               if ( mlt_properties_get( b_props, "image.mix" ) != NULL )
+                       mix = mlt_properties_get_double( b_props, "image.mix" );
 
                // Composite the b_frame on the a_frame
                mlt_frame_composite_yuv( this, b_frame, x, y, mix );
@@ -86,18 +77,34 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
 
 static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
 {
-       mlt_frame_push_get_image( a_frame, transition_get_image );
-       mlt_frame_push_frame( a_frame, b_frame );
-       
        // Propogate the transition properties to the b frame
        mlt_properties properties = mlt_transition_properties( this );
        mlt_properties b_props = mlt_frame_properties( b_frame );
+       
        if ( mlt_properties_get( properties, "x" ) != NULL )
                mlt_properties_set_int( b_props, "x", mlt_properties_get_int( properties, "x" ) );
        if ( mlt_properties_get( properties, "y" ) != NULL )
                mlt_properties_set_int( b_props, "y", mlt_properties_get_int( properties, "y" ) );
+
+       // Only if mix is specified, otherwise a producer may set the mix
        if ( mlt_properties_get( properties, "mix" ) != NULL )
-               mlt_properties_set_double( b_props, "mix",  mlt_properties_get_double( properties, "mix" ) );
+       {
+               // A negative means dissolve
+               if ( mlt_properties_get_double( properties, "mix" ) < 0 )
+               {
+                       // Determine the time position of this frame in the transition duration
+                       mlt_position in = mlt_transition_get_in( this );
+                       mlt_position out = mlt_transition_get_out( this );
+                       mlt_position time = mlt_frame_get_position( b_frame );
+                       double mix = ( double )( time - in ) / ( double )( out - in + 1 );
+                       mlt_properties_set_double( b_props, "image.mix", mix );
+               }
+               else
+                       mlt_properties_set_double( b_props, "image.mix", mlt_properties_get_double( properties, "mix" ) );
+       }
+       
+       mlt_frame_push_get_image( a_frame, transition_get_image );
+       mlt_frame_push_frame( a_frame, b_frame );
 
        return a_frame;
 }
@@ -105,16 +112,15 @@ static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_
 /** Constructor for the filter.
 */
 
-mlt_transition transition_composite_init( void *arg )
+mlt_transition transition_composite_init( char *arg )
 {
-       transition_composite *this = calloc( sizeof( transition_composite ), 1 );
-       if ( this != NULL )
+       mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 );
+       if ( this != NULL && mlt_transition_init( this, NULL ) == 0 )
        {
-               mlt_transition transition = &this->parent;
-               mlt_transition_init( transition, this );
-               transition->process = composite_process;
-               return &this->parent;
+               this->process = composite_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) );
        }
-       return NULL;
+       return this;
 }
 
index 73fcb300f17b6940efe9565eac03333f3ae9f69c..769ddfd9e20fee25ad58041e5b29dc4234e56dba 100644 (file)
@@ -23,6 +23,6 @@
 
 #include <framework/mlt_transition.h>
 
-extern mlt_transition transition_composite_init( void *arg );
+extern mlt_transition transition_composite_init( char *arg );
 
 #endif
index 5e0dd0fe90217741f961cbf7cd6a4c8f9a50ad22..633d8da96dcb7f72b3af69c0059f6ecdb66f0636 100644 (file)
@@ -141,8 +141,8 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
 
        // mix is the offset time value in the duration of the transition
        // - also used as the mixing level for a dissolve
-       if ( mlt_properties_get( b_props, "mix" ) != NULL )
-               mix = mlt_properties_get_double( b_props, "mix" );
+       if ( mlt_properties_get( b_props, "image.mix" ) != NULL )
+               mix = mlt_properties_get_double( b_props, "image.mix" );
 
        // (mix - previous_mix) is the animation delta, if backwards reset previous
        if ( mix < previous_mix )
@@ -181,32 +181,6 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
        return 0;
 }
 
-static int transition_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 a_props = mlt_frame_properties( frame );
-
-       // Get the b frame from the stack
-       mlt_frame b_frame = mlt_frame_pop_frame( frame );
-
-       // Get the properties of the b frame
-       mlt_properties b_props = mlt_frame_properties( b_frame );
-
-       // Restore the original get_audio
-       frame->get_audio = mlt_properties_get_data( a_props, "get_audio", NULL );
-       
-       double mix = 0;
-       if ( mlt_properties_get( b_props, "mix" ) != NULL )
-               mix = mlt_properties_get_double( b_props, "mix" );
-       mlt_frame_mix_audio( frame, b_frame, mix, buffer, format, frequency, channels, samples );
-
-       // Push the b_frame back on for get_image
-       mlt_frame_push_frame( frame, b_frame );
-
-       return 0;
-}
-
-
 /** Load the luma map from PGM stream.
 */
 
@@ -342,7 +316,7 @@ static mlt_frame transition_process( mlt_transition transition, mlt_frame a_fram
        double pos = ( double )( time - in ) / ( double )( out - in + 1 );
        
        // Set the b frame properties
-       mlt_properties_set_double( b_props, "mix", pos );
+       mlt_properties_set_double( b_props, "image.mix", pos );
        mlt_properties_set_int( b_props, "luma.width", this->width );
        mlt_properties_set_int( b_props, "luma.height", this->height );
        mlt_properties_set_data( b_props, "luma.bitmap", this->bitmap, 0, NULL, NULL );
@@ -352,14 +326,6 @@ static mlt_frame transition_process( mlt_transition transition, mlt_frame a_fram
        mlt_frame_push_get_image( a_frame, transition_get_image );
        mlt_frame_push_frame( a_frame, b_frame );
 
-/************************ AUDIO ***************************/
-#if 1
-       // Backup the original get_audio (it's still needed)
-       mlt_properties_set_data( mlt_frame_properties( a_frame ), "get_audio", a_frame->get_audio, 0, NULL, NULL );
-
-       // Override the get_audio method
-       a_frame->get_audio = transition_get_audio;
-#endif
        return a_frame;
 }
 
diff --git a/mlt/src/modules/core/transition_mix.c b/mlt/src/modules/core/transition_mix.c
new file mode 100644 (file)
index 0000000..4d32de7
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * transition_mix.c -- mix two audio streams
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "transition_mix.h"
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/** Get the audio.
+*/
+
+static int transition_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 a_props = mlt_frame_properties( frame );
+
+       // Get the b frame from the stack
+       mlt_frame b_frame = mlt_frame_pop_frame( frame );
+
+       // Get the properties of the b frame
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+
+       // Restore the original get_audio
+       frame->get_audio = mlt_properties_get_data( a_props, "mix.get_audio", NULL );
+
+       double mix = mlt_properties_get_double( b_props, "audio.mix" );
+       mlt_frame_mix_audio( frame, b_frame, mix, buffer, format, frequency, channels, samples );
+
+       // Push the b_frame back on for get_image
+       mlt_frame_push_frame( frame, b_frame );
+
+       return 0;
+}
+
+
+/** Mix transition processing.
+*/
+
+static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
+{
+       mlt_properties properties = mlt_transition_properties( this );
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+
+       // Only if mix is specified, otherwise a producer may set the mix
+       if ( mlt_properties_get( properties, "mix" ) != NULL )
+       {
+               // A negative means crossfade
+               if ( mlt_properties_get_double( properties, "mix" ) < 0 )
+               {
+                       // Determine the time position of this frame in the transition duration
+                       mlt_position in = mlt_transition_get_in( this );
+                       mlt_position out = mlt_transition_get_out( this );
+                       mlt_position time = mlt_frame_get_position( b_frame );
+                       double mix = ( double )( time - in ) / ( double )( out - in + 1 );
+                       mlt_properties_set_double( b_props, "audio.mix", mix );
+               }
+               else
+                       mlt_properties_set_double( b_props, "audio.mix", mlt_properties_get_double( properties, "mix" ) );
+       }
+                       
+       // Backup the original get_audio (it's still needed)
+       mlt_properties_set_data( mlt_frame_properties( a_frame ), "mix.get_audio", a_frame->get_audio, 0, NULL, NULL );
+
+       // Override the get_audio method
+       a_frame->get_audio = transition_get_audio;
+       
+       mlt_frame_push_frame( a_frame, b_frame );
+       
+       return a_frame;
+}
+
+/** Constructor for the transition.
+*/
+
+mlt_transition transition_mix_init( char *arg )
+{
+       mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 );
+       if ( this != NULL && mlt_transition_init( this, NULL ) == 0 )
+       {
+               this->process = transition_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) );
+       }
+       return this;
+}
+
diff --git a/mlt/src/modules/core/transition_mix.h b/mlt/src/modules/core/transition_mix.h
new file mode 100644 (file)
index 0000000..2ada6bc
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * transition_mix.h -- mix two audio streams
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _TRANSITION_MIX_H_
+#define _TRANSITION_MIX_H_
+
+#include <framework/mlt_transition.h>
+
+extern mlt_transition transition_mix_init( char *arg );
+
+#endif
index 2a8d99f45c05b8adf44e628c690ba96963fc5962..f1952dccc21bbf260e68df51df25e490c3d70a00 100644 (file)
@@ -326,7 +326,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                if ( mlt_properties_get( producer_props, "y" ) != NULL )
                        mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
                if ( mlt_properties_get( producer_props, "mix" ) != NULL )
-                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+                       mlt_properties_set_double( properties, "image.mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL );
index 04a9e64a66e768b3b4440b3612c9963c5de530af..8a1d3a3060756ddce4f6b30754e993d35ca97e96 100644 (file)
@@ -222,7 +222,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                if ( mlt_properties_get( producer_props, "y" ) != NULL )
                        mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
                if ( mlt_properties_get( producer_props, "mix" ) != NULL )
-                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+                       mlt_properties_set_double( properties, "image.mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, 0, NULL, NULL );
diff --git a/mlt/src/modules/resample/Makefile b/mlt/src/modules/resample/Makefile
new file mode 100644 (file)
index 0000000..b8b7542
--- /dev/null
@@ -0,0 +1,29 @@
+
+TARGET = ../libmltresample.so
+
+OBJS = factory.o \
+          filter_resample.o 
+
+CFLAGS = -I../../ -Wall -g
+
+LDFLAGS= -lsamplerate
+
+SRCS := $(OBJS:.o=.c)
+
+all:   $(TARGET)
+
+$(TARGET): $(OBJS)
+               $(CC) -shared -o $@ $(OBJS) $(LDFLAGS)
+
+depend:        $(SRCS)
+               $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+dist-clean:    clean
+               rm -f .depend
+
+clean: 
+               rm -f $(OBJS) $(TARGET)
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
diff --git a/mlt/src/modules/resample/configure b/mlt/src/modules/resample/configure
new file mode 100755 (executable)
index 0000000..7e0f23a
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+if [ "$help" != "1" ]
+then
+
+cat << EOF >> ../filters.dat
+resample               libmltresample.so
+EOF
+
+fi
+
diff --git a/mlt/src/modules/resample/factory.c b/mlt/src/modules/resample/factory.c
new file mode 100644 (file)
index 0000000..42385a7
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * factory.c -- the factory method interfaces
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+
+#include "filter_resample.h"
+
+void *mlt_create_producer( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_filter( char *id, void *arg )
+{
+       if ( !strcmp( id, "resample" ) )
+               return filter_resample_init( arg );
+       return NULL;
+}
+
+void *mlt_create_transition( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_consumer( char *id, void *arg )
+{
+       return NULL;
+}
+
diff --git a/mlt/src/modules/resample/filter_resample.c b/mlt/src/modules/resample/filter_resample.c
new file mode 100644 (file)
index 0000000..402a278
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * filter_resample.c -- adjust audio sample frequency
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "filter_resample.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <samplerate.h>
+#define __USE_ISOC99 1
+#include <math.h>
+
+#define BUFFER_LEN 20480
+#define RESAMPLE_TYPE SRC_SINC_FASTEST
+
+/** Get the audio.
+*/
+
+static int resample_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 );
+       int output_rate = mlt_properties_get_int( properties, "resample.frequency" );
+       SRC_STATE *state = mlt_properties_get_data( properties, "resample.state", NULL );
+       SRC_DATA data;
+       float *input_buffer = mlt_properties_get_data( properties, "resample.input_buffer", NULL );
+       float *output_buffer = mlt_properties_get_data( properties, "resample.output_buffer", NULL );
+       int i;
+
+       // Restore the original get_audio
+       frame->get_audio = mlt_properties_get_data( properties, "resample.get_audio", NULL );
+
+       // Get the producer's audio
+       mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
+
+       // Convert to floating point
+       for ( i = 0; i < *samples * *channels; ++i )
+               input_buffer[ i ] = ( float )( (*buffer)[ i ] ) / 32768;
+
+       // Resample
+       data.data_in = input_buffer;
+       data.data_out = output_buffer;
+       data.src_ratio = ( float ) output_rate / ( float ) *frequency;
+       data.input_frames = *samples;
+       data.output_frames = BUFFER_LEN / *channels;
+       data.end_of_input = 0;
+       i = src_process( state, &data );
+       if ( i == 0 )
+       {
+               if ( data.output_frames_gen > *samples )
+               {
+                       *buffer = (int16_t*) malloc( data.output_frames_gen * *channels * 2 );
+                       mlt_properties_set_data( properties, "audio", *buffer, *channels * data.output_frames_gen * 2, free, NULL );
+               }
+               *samples = data.output_frames_gen;
+               *frequency = output_rate;
+               
+               // Convert from floating back to signed 16bit
+               for ( i = 0; i < *samples * *channels; ++i )
+               {
+                       float sample = output_buffer[ i ];
+                       if ( sample > 1.0 )
+                               sample = 1.0;
+                       if ( sample < -1.0 )
+                               sample = -1.0;
+                       if ( sample >= 0 )
+                               (*buffer)[ i ] = lrint( 32767.0 * sample );
+                       else
+                               (*buffer)[ i ] = lrint( 32768.0 * sample );
+               }
+       }
+       else
+               fprintf( stderr, "resample_get_audio: %s\n", src_strerror( i ) );
+       
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_properties properties = mlt_filter_properties( this );
+       mlt_properties frame_props = mlt_frame_properties( frame );
+
+       // Propogate the frequency property if supplied
+       if ( mlt_properties_get( properties, "frequency" ) != NULL )
+               mlt_properties_set_int( frame_props, "resample.frequency", mlt_properties_get_int( properties, "frequency" ) );
+
+       // Propogate the other properties
+       mlt_properties_set_int( frame_props, "resample.channels", mlt_properties_get_int( properties, "channels" ) );
+       mlt_properties_set_data( frame_props, "resample.state", mlt_properties_get_data( properties, "state", NULL ), 0, NULL, NULL );
+       mlt_properties_set_data( frame_props, "resample.input_buffer", mlt_properties_get_data( properties, "input_buffer", NULL ), 0, NULL, NULL );
+       mlt_properties_set_data( frame_props, "resample.output_buffer", mlt_properties_get_data( properties, "output_buffer", NULL ), 0, NULL, NULL );
+       
+       // Backup the original get_audio (it's still needed)
+       mlt_properties_set_data( frame_props, "resample.get_audio", frame->get_audio, 0, NULL, NULL );
+
+       // Override the get_audio method
+       frame->get_audio = resample_get_audio;
+
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_resample_init( char *arg )
+{
+       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
+       {
+               int error;
+               SRC_STATE *state = src_new( RESAMPLE_TYPE, 2 /* channels */, &error );
+               if ( error == 0 )
+               {
+                       this->process = filter_process;
+                       if ( arg != NULL )
+                               mlt_properties_set_int( mlt_filter_properties( this ), "frequency", atoi( arg ) );
+                       mlt_properties_set_int( mlt_filter_properties( this ), "channels", 2 );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "state", state, 0, (mlt_destructor)src_delete, NULL );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "input_buffer",
+                               malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "output_buffer",
+                               malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL );
+               }
+               else
+               {
+                       fprintf( stderr, "filter_resample_init: %s\n", src_strerror( error ) );
+               }
+       }
+       return this;
+}
+
diff --git a/mlt/src/modules/resample/filter_resample.h b/mlt/src/modules/resample/filter_resample.h
new file mode 100644 (file)
index 0000000..6ce7eb4
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_resample.h -- adjust audio sample frequency
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FILTER_RESAMPLE_H_
+#define _FILTER_RESAMPLE_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_resample_init( char *arg );
+
+#endif
index 146ec76dc978fba47f47a7d7ca08a0eebb68b7e2..dabb878d7b6c57672771bc44e058500c0e463659 100644 (file)
@@ -25,7 +25,7 @@ int main( int argc, char **argv )
        }
 
        // Start the consumer...
-       mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" );
+       mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" );
 
        // Create the producer(s)
        mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 );
index eaf9758943afeb62bc4efc757a995102fac0addf..fb56113e5c1b3bfe386d053e86d482e36709cbe0 100644 (file)
@@ -23,7 +23,7 @@ int main( int argc, char **argv )
        }
 
        // Start the consumer...
-       mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" );
+       mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" );
 
        // Create the producer(s)
        mlt_playlist pl1 = mlt_playlist_init();
@@ -39,7 +39,7 @@ int main( int argc, char **argv )
        mlt_properties_set_int( mlt_producer_properties( title ), "bgcolor", 0x0000007f );
        mlt_properties_set_int( mlt_producer_properties( title ), "pad", 8 );
        mlt_properties_set_int( mlt_producer_properties( title ), "align", 1 );
-       mlt_properties_set_int( mlt_producer_properties( title ), "x", 20 );
+       mlt_properties_set_int( mlt_producer_properties( title ), "x", 200 );
        mlt_properties_set_int( mlt_producer_properties( title ), "y", 40 );
        mlt_properties_set_double( mlt_producer_properties( title ), "mix", 0.8 );
 
index adfc54672f8203c17ba3160721dd622c10080aa4..f5f7e1a705af9bd91a024ba22d8e7845ae6cfaa9 100644 (file)
@@ -32,7 +32,7 @@ void miracle_log_init( enum log_output method, int new_threshold )
        log_output = method;
        threshold = new_threshold;
        if (method == log_syslog)
-               openlog( "dv1394d", LOG_CONS, LOG_DAEMON );
+               openlog( "miracle", LOG_CONS, LOG_DAEMON );
 
 }
 
index a1043df4ee1f20888eb0461e94d71a03139cdcc6..32ab8bec108884716f970210ebc92c2798f41540 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
+#include <limits.h>
 
 #include <sys/mman.h>
 
@@ -471,7 +472,7 @@ void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position
        else if ( clip >= mlt_playlist_count( playlist ) )
        {
                clip = mlt_playlist_count( playlist ) - 1;
-               position = 999999999999;
+               position = LONG_MAX;
        }
 
        if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 )
index 2179c42b42bc9e4c618110c8466829b0f492ed20..48274e0d771d2bfd4fa00dca5323bd3d812b2f13 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg inigo
+SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg inigo resample
 
 all clean depend install:
        list='$(SUBDIRS)'; \
index 9dd52cda02c685782288980794d56479e6291ffd..4c458d17548beb78c6d35e9dead06a97b7f4083f 100644 (file)
@@ -8,7 +8,9 @@ OBJS = factory.o \
           filter_gamma.o \
           filter_resize.o \
           transition_composite.o \
-          transition_luma.o
+          transition_luma.o \
+          transition_mix.o \
+          filter_volume.o
 
 CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
index 4b73ac861b659b53d1b3f4b51402ef4377783312..baedbae13818312132c724a088b47e5b0e4a9c97 100755 (executable)
@@ -12,11 +12,13 @@ deinterlace         libmltcore.so
 gamma                  libmltcore.so
 greyscale              libmltcore.so
 resize                 libmltcore.so
+volume                 libmltcore.so
 EOF
 
 cat << EOF >> ../transitions.dat
 composite              libmltcore.so
-luma           libmltcore.so
+luma                   libmltcore.so
+mix                            libmltcore.so
 EOF
 
 fi
index 78bdea75f9a1860dd4567c00f830a78032e8e97f..5353ac2110847f45435efa778ee7451ef42c38e3 100644 (file)
@@ -27,6 +27,8 @@
 #include "filter_gamma.h"
 #include "transition_composite.h"
 #include "transition_luma.h"
+#include "transition_mix.h"
+#include "filter_volume.h"
 
 void *mlt_create_producer( char *id, void *arg )
 {
@@ -45,6 +47,8 @@ void *mlt_create_filter( char *id, void *arg )
                return filter_greyscale_init( arg );
        if ( !strcmp( id, "resize" ) )
                return filter_resize_init( arg );
+       if ( !strcmp( id, "volume" ) )
+               return filter_volume_init( arg );
        return NULL;
 }
 
@@ -54,6 +58,8 @@ void *mlt_create_transition( char *id, void *arg )
                return transition_composite_init( arg );
        if ( !strcmp( id, "luma" ) )
                return transition_luma_init( arg );
+       if ( !strcmp( id, "mix" ) )
+               return transition_mix_init( arg );
        return NULL;
 }
 
diff --git a/src/modules/core/filter_volume.c b/src/modules/core/filter_volume.c
new file mode 100644 (file)
index 0000000..c0ad4dd
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * filter_volume.c -- adjust audio volume
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "filter_volume.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/** Get the audio.
+*/
+
+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 );
+       double volume = mlt_properties_get_double( properties, "volume" );
+
+       // 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 );
+
+       // Apply the volume
+       int i;
+       for ( i = 0; i < ( *channels * *samples ); i++ )
+               (*buffer)[i] *= volume;
+       
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_properties properties = mlt_frame_properties( frame );
+
+       // Propogate the level property
+       if ( mlt_properties_get( mlt_filter_properties( this ), "volume" ) != NULL )
+               mlt_properties_set_double( properties, "volume",
+                       mlt_properties_get_double( mlt_filter_properties( this ), "volume" ) );
+       
+       // 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;
+
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_volume_init( char *arg )
+{
+       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
+       {
+               this->process = filter_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_filter_properties( this ), "volume", atof( arg ) );
+       }
+       return this;
+}
+
diff --git a/src/modules/core/filter_volume.h b/src/modules/core/filter_volume.h
new file mode 100644 (file)
index 0000000..d5fb569
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_volume.h -- adjust audio volume
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FILTER_VOLUME_H_
+#define _FILTER_VOLUME_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_volume_init( char *arg );
+
+#endif
index ef896a9ff7b5678dd586a487ec1ff9222ceefb2d..7a32dd5020d69a3e483df7c5200a0219e0aab791 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-/** Composition class.
-*/
-
-typedef struct 
-{
-       struct mlt_transition_s parent;
-}
-transition_composite;
-
 /** Get the image.
 */
 
@@ -59,8 +50,8 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
                        x = mlt_properties_get_int( b_props, "x" );
                if ( mlt_properties_get( b_props, "y" ) != NULL )
                        y = mlt_properties_get_int( b_props, "y" );
-               if ( mlt_properties_get( b_props, "mix" ) != NULL )
-                       mix = mlt_properties_get_double( b_props, "mix" );
+               if ( mlt_properties_get( b_props, "image.mix" ) != NULL )
+                       mix = mlt_properties_get_double( b_props, "image.mix" );
 
                // Composite the b_frame on the a_frame
                mlt_frame_composite_yuv( this, b_frame, x, y, mix );
@@ -86,18 +77,34 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
 
 static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
 {
-       mlt_frame_push_get_image( a_frame, transition_get_image );
-       mlt_frame_push_frame( a_frame, b_frame );
-       
        // Propogate the transition properties to the b frame
        mlt_properties properties = mlt_transition_properties( this );
        mlt_properties b_props = mlt_frame_properties( b_frame );
+       
        if ( mlt_properties_get( properties, "x" ) != NULL )
                mlt_properties_set_int( b_props, "x", mlt_properties_get_int( properties, "x" ) );
        if ( mlt_properties_get( properties, "y" ) != NULL )
                mlt_properties_set_int( b_props, "y", mlt_properties_get_int( properties, "y" ) );
+
+       // Only if mix is specified, otherwise a producer may set the mix
        if ( mlt_properties_get( properties, "mix" ) != NULL )
-               mlt_properties_set_double( b_props, "mix",  mlt_properties_get_double( properties, "mix" ) );
+       {
+               // A negative means dissolve
+               if ( mlt_properties_get_double( properties, "mix" ) < 0 )
+               {
+                       // Determine the time position of this frame in the transition duration
+                       mlt_position in = mlt_transition_get_in( this );
+                       mlt_position out = mlt_transition_get_out( this );
+                       mlt_position time = mlt_frame_get_position( b_frame );
+                       double mix = ( double )( time - in ) / ( double )( out - in + 1 );
+                       mlt_properties_set_double( b_props, "image.mix", mix );
+               }
+               else
+                       mlt_properties_set_double( b_props, "image.mix", mlt_properties_get_double( properties, "mix" ) );
+       }
+       
+       mlt_frame_push_get_image( a_frame, transition_get_image );
+       mlt_frame_push_frame( a_frame, b_frame );
 
        return a_frame;
 }
@@ -105,16 +112,15 @@ static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_
 /** Constructor for the filter.
 */
 
-mlt_transition transition_composite_init( void *arg )
+mlt_transition transition_composite_init( char *arg )
 {
-       transition_composite *this = calloc( sizeof( transition_composite ), 1 );
-       if ( this != NULL )
+       mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 );
+       if ( this != NULL && mlt_transition_init( this, NULL ) == 0 )
        {
-               mlt_transition transition = &this->parent;
-               mlt_transition_init( transition, this );
-               transition->process = composite_process;
-               return &this->parent;
+               this->process = composite_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) );
        }
-       return NULL;
+       return this;
 }
 
index 73fcb300f17b6940efe9565eac03333f3ae9f69c..769ddfd9e20fee25ad58041e5b29dc4234e56dba 100644 (file)
@@ -23,6 +23,6 @@
 
 #include <framework/mlt_transition.h>
 
-extern mlt_transition transition_composite_init( void *arg );
+extern mlt_transition transition_composite_init( char *arg );
 
 #endif
index 5e0dd0fe90217741f961cbf7cd6a4c8f9a50ad22..633d8da96dcb7f72b3af69c0059f6ecdb66f0636 100644 (file)
@@ -141,8 +141,8 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
 
        // mix is the offset time value in the duration of the transition
        // - also used as the mixing level for a dissolve
-       if ( mlt_properties_get( b_props, "mix" ) != NULL )
-               mix = mlt_properties_get_double( b_props, "mix" );
+       if ( mlt_properties_get( b_props, "image.mix" ) != NULL )
+               mix = mlt_properties_get_double( b_props, "image.mix" );
 
        // (mix - previous_mix) is the animation delta, if backwards reset previous
        if ( mix < previous_mix )
@@ -181,32 +181,6 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form
        return 0;
 }
 
-static int transition_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 a_props = mlt_frame_properties( frame );
-
-       // Get the b frame from the stack
-       mlt_frame b_frame = mlt_frame_pop_frame( frame );
-
-       // Get the properties of the b frame
-       mlt_properties b_props = mlt_frame_properties( b_frame );
-
-       // Restore the original get_audio
-       frame->get_audio = mlt_properties_get_data( a_props, "get_audio", NULL );
-       
-       double mix = 0;
-       if ( mlt_properties_get( b_props, "mix" ) != NULL )
-               mix = mlt_properties_get_double( b_props, "mix" );
-       mlt_frame_mix_audio( frame, b_frame, mix, buffer, format, frequency, channels, samples );
-
-       // Push the b_frame back on for get_image
-       mlt_frame_push_frame( frame, b_frame );
-
-       return 0;
-}
-
-
 /** Load the luma map from PGM stream.
 */
 
@@ -342,7 +316,7 @@ static mlt_frame transition_process( mlt_transition transition, mlt_frame a_fram
        double pos = ( double )( time - in ) / ( double )( out - in + 1 );
        
        // Set the b frame properties
-       mlt_properties_set_double( b_props, "mix", pos );
+       mlt_properties_set_double( b_props, "image.mix", pos );
        mlt_properties_set_int( b_props, "luma.width", this->width );
        mlt_properties_set_int( b_props, "luma.height", this->height );
        mlt_properties_set_data( b_props, "luma.bitmap", this->bitmap, 0, NULL, NULL );
@@ -352,14 +326,6 @@ static mlt_frame transition_process( mlt_transition transition, mlt_frame a_fram
        mlt_frame_push_get_image( a_frame, transition_get_image );
        mlt_frame_push_frame( a_frame, b_frame );
 
-/************************ AUDIO ***************************/
-#if 1
-       // Backup the original get_audio (it's still needed)
-       mlt_properties_set_data( mlt_frame_properties( a_frame ), "get_audio", a_frame->get_audio, 0, NULL, NULL );
-
-       // Override the get_audio method
-       a_frame->get_audio = transition_get_audio;
-#endif
        return a_frame;
 }
 
diff --git a/src/modules/core/transition_mix.c b/src/modules/core/transition_mix.c
new file mode 100644 (file)
index 0000000..4d32de7
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * transition_mix.c -- mix two audio streams
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "transition_mix.h"
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/** Get the audio.
+*/
+
+static int transition_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 a_props = mlt_frame_properties( frame );
+
+       // Get the b frame from the stack
+       mlt_frame b_frame = mlt_frame_pop_frame( frame );
+
+       // Get the properties of the b frame
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+
+       // Restore the original get_audio
+       frame->get_audio = mlt_properties_get_data( a_props, "mix.get_audio", NULL );
+
+       double mix = mlt_properties_get_double( b_props, "audio.mix" );
+       mlt_frame_mix_audio( frame, b_frame, mix, buffer, format, frequency, channels, samples );
+
+       // Push the b_frame back on for get_image
+       mlt_frame_push_frame( frame, b_frame );
+
+       return 0;
+}
+
+
+/** Mix transition processing.
+*/
+
+static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
+{
+       mlt_properties properties = mlt_transition_properties( this );
+       mlt_properties b_props = mlt_frame_properties( b_frame );
+
+       // Only if mix is specified, otherwise a producer may set the mix
+       if ( mlt_properties_get( properties, "mix" ) != NULL )
+       {
+               // A negative means crossfade
+               if ( mlt_properties_get_double( properties, "mix" ) < 0 )
+               {
+                       // Determine the time position of this frame in the transition duration
+                       mlt_position in = mlt_transition_get_in( this );
+                       mlt_position out = mlt_transition_get_out( this );
+                       mlt_position time = mlt_frame_get_position( b_frame );
+                       double mix = ( double )( time - in ) / ( double )( out - in + 1 );
+                       mlt_properties_set_double( b_props, "audio.mix", mix );
+               }
+               else
+                       mlt_properties_set_double( b_props, "audio.mix", mlt_properties_get_double( properties, "mix" ) );
+       }
+                       
+       // Backup the original get_audio (it's still needed)
+       mlt_properties_set_data( mlt_frame_properties( a_frame ), "mix.get_audio", a_frame->get_audio, 0, NULL, NULL );
+
+       // Override the get_audio method
+       a_frame->get_audio = transition_get_audio;
+       
+       mlt_frame_push_frame( a_frame, b_frame );
+       
+       return a_frame;
+}
+
+/** Constructor for the transition.
+*/
+
+mlt_transition transition_mix_init( char *arg )
+{
+       mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 );
+       if ( this != NULL && mlt_transition_init( this, NULL ) == 0 )
+       {
+               this->process = transition_process;
+               if ( arg != NULL )
+                       mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) );
+       }
+       return this;
+}
+
diff --git a/src/modules/core/transition_mix.h b/src/modules/core/transition_mix.h
new file mode 100644 (file)
index 0000000..2ada6bc
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * transition_mix.h -- mix two audio streams
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _TRANSITION_MIX_H_
+#define _TRANSITION_MIX_H_
+
+#include <framework/mlt_transition.h>
+
+extern mlt_transition transition_mix_init( char *arg );
+
+#endif
index 2a8d99f45c05b8adf44e628c690ba96963fc5962..f1952dccc21bbf260e68df51df25e490c3d70a00 100644 (file)
@@ -326,7 +326,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                if ( mlt_properties_get( producer_props, "y" ) != NULL )
                        mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
                if ( mlt_properties_get( producer_props, "mix" ) != NULL )
-                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+                       mlt_properties_set_double( properties, "image.mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL );
index 04a9e64a66e768b3b4440b3612c9963c5de530af..8a1d3a3060756ddce4f6b30754e993d35ca97e96 100644 (file)
@@ -222,7 +222,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                if ( mlt_properties_get( producer_props, "y" ) != NULL )
                        mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) );
                if ( mlt_properties_get( producer_props, "mix" ) != NULL )
-                       mlt_properties_set_double( properties, "mix",  mlt_properties_get_double( producer_props, "mix" ) );
+                       mlt_properties_set_double( properties, "image.mix",  mlt_properties_get_double( producer_props, "mix" ) );
 
                // if picture sequence pass the image and alpha data without destructor
                mlt_properties_set_data( properties, "image", this->image, 0, NULL, NULL );
diff --git a/src/modules/resample/Makefile b/src/modules/resample/Makefile
new file mode 100644 (file)
index 0000000..b8b7542
--- /dev/null
@@ -0,0 +1,29 @@
+
+TARGET = ../libmltresample.so
+
+OBJS = factory.o \
+          filter_resample.o 
+
+CFLAGS = -I../../ -Wall -g
+
+LDFLAGS= -lsamplerate
+
+SRCS := $(OBJS:.o=.c)
+
+all:   $(TARGET)
+
+$(TARGET): $(OBJS)
+               $(CC) -shared -o $@ $(OBJS) $(LDFLAGS)
+
+depend:        $(SRCS)
+               $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+dist-clean:    clean
+               rm -f .depend
+
+clean: 
+               rm -f $(OBJS) $(TARGET)
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
diff --git a/src/modules/resample/configure b/src/modules/resample/configure
new file mode 100755 (executable)
index 0000000..7e0f23a
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+if [ "$help" != "1" ]
+then
+
+cat << EOF >> ../filters.dat
+resample               libmltresample.so
+EOF
+
+fi
+
diff --git a/src/modules/resample/factory.c b/src/modules/resample/factory.c
new file mode 100644 (file)
index 0000000..42385a7
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * factory.c -- the factory method interfaces
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+
+#include "filter_resample.h"
+
+void *mlt_create_producer( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_filter( char *id, void *arg )
+{
+       if ( !strcmp( id, "resample" ) )
+               return filter_resample_init( arg );
+       return NULL;
+}
+
+void *mlt_create_transition( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_consumer( char *id, void *arg )
+{
+       return NULL;
+}
+
diff --git a/src/modules/resample/filter_resample.c b/src/modules/resample/filter_resample.c
new file mode 100644 (file)
index 0000000..402a278
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * filter_resample.c -- adjust audio sample frequency
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "filter_resample.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <samplerate.h>
+#define __USE_ISOC99 1
+#include <math.h>
+
+#define BUFFER_LEN 20480
+#define RESAMPLE_TYPE SRC_SINC_FASTEST
+
+/** Get the audio.
+*/
+
+static int resample_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 );
+       int output_rate = mlt_properties_get_int( properties, "resample.frequency" );
+       SRC_STATE *state = mlt_properties_get_data( properties, "resample.state", NULL );
+       SRC_DATA data;
+       float *input_buffer = mlt_properties_get_data( properties, "resample.input_buffer", NULL );
+       float *output_buffer = mlt_properties_get_data( properties, "resample.output_buffer", NULL );
+       int i;
+
+       // Restore the original get_audio
+       frame->get_audio = mlt_properties_get_data( properties, "resample.get_audio", NULL );
+
+       // Get the producer's audio
+       mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
+
+       // Convert to floating point
+       for ( i = 0; i < *samples * *channels; ++i )
+               input_buffer[ i ] = ( float )( (*buffer)[ i ] ) / 32768;
+
+       // Resample
+       data.data_in = input_buffer;
+       data.data_out = output_buffer;
+       data.src_ratio = ( float ) output_rate / ( float ) *frequency;
+       data.input_frames = *samples;
+       data.output_frames = BUFFER_LEN / *channels;
+       data.end_of_input = 0;
+       i = src_process( state, &data );
+       if ( i == 0 )
+       {
+               if ( data.output_frames_gen > *samples )
+               {
+                       *buffer = (int16_t*) malloc( data.output_frames_gen * *channels * 2 );
+                       mlt_properties_set_data( properties, "audio", *buffer, *channels * data.output_frames_gen * 2, free, NULL );
+               }
+               *samples = data.output_frames_gen;
+               *frequency = output_rate;
+               
+               // Convert from floating back to signed 16bit
+               for ( i = 0; i < *samples * *channels; ++i )
+               {
+                       float sample = output_buffer[ i ];
+                       if ( sample > 1.0 )
+                               sample = 1.0;
+                       if ( sample < -1.0 )
+                               sample = -1.0;
+                       if ( sample >= 0 )
+                               (*buffer)[ i ] = lrint( 32767.0 * sample );
+                       else
+                               (*buffer)[ i ] = lrint( 32768.0 * sample );
+               }
+       }
+       else
+               fprintf( stderr, "resample_get_audio: %s\n", src_strerror( i ) );
+       
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_properties properties = mlt_filter_properties( this );
+       mlt_properties frame_props = mlt_frame_properties( frame );
+
+       // Propogate the frequency property if supplied
+       if ( mlt_properties_get( properties, "frequency" ) != NULL )
+               mlt_properties_set_int( frame_props, "resample.frequency", mlt_properties_get_int( properties, "frequency" ) );
+
+       // Propogate the other properties
+       mlt_properties_set_int( frame_props, "resample.channels", mlt_properties_get_int( properties, "channels" ) );
+       mlt_properties_set_data( frame_props, "resample.state", mlt_properties_get_data( properties, "state", NULL ), 0, NULL, NULL );
+       mlt_properties_set_data( frame_props, "resample.input_buffer", mlt_properties_get_data( properties, "input_buffer", NULL ), 0, NULL, NULL );
+       mlt_properties_set_data( frame_props, "resample.output_buffer", mlt_properties_get_data( properties, "output_buffer", NULL ), 0, NULL, NULL );
+       
+       // Backup the original get_audio (it's still needed)
+       mlt_properties_set_data( frame_props, "resample.get_audio", frame->get_audio, 0, NULL, NULL );
+
+       // Override the get_audio method
+       frame->get_audio = resample_get_audio;
+
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_resample_init( char *arg )
+{
+       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
+       {
+               int error;
+               SRC_STATE *state = src_new( RESAMPLE_TYPE, 2 /* channels */, &error );
+               if ( error == 0 )
+               {
+                       this->process = filter_process;
+                       if ( arg != NULL )
+                               mlt_properties_set_int( mlt_filter_properties( this ), "frequency", atoi( arg ) );
+                       mlt_properties_set_int( mlt_filter_properties( this ), "channels", 2 );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "state", state, 0, (mlt_destructor)src_delete, NULL );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "input_buffer",
+                               malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL );
+                       mlt_properties_set_data( mlt_filter_properties( this ), "output_buffer",
+                               malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL );
+               }
+               else
+               {
+                       fprintf( stderr, "filter_resample_init: %s\n", src_strerror( error ) );
+               }
+       }
+       return this;
+}
+
diff --git a/src/modules/resample/filter_resample.h b/src/modules/resample/filter_resample.h
new file mode 100644 (file)
index 0000000..6ce7eb4
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_resample.h -- adjust audio sample frequency
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FILTER_RESAMPLE_H_
+#define _FILTER_RESAMPLE_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_resample_init( char *arg );
+
+#endif
index 146ec76dc978fba47f47a7d7ca08a0eebb68b7e2..dabb878d7b6c57672771bc44e058500c0e463659 100644 (file)
@@ -25,7 +25,7 @@ int main( int argc, char **argv )
        }
 
        // Start the consumer...
-       mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" );
+       mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" );
 
        // Create the producer(s)
        mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 );
index eaf9758943afeb62bc4efc757a995102fac0addf..fb56113e5c1b3bfe386d053e86d482e36709cbe0 100644 (file)
@@ -23,7 +23,7 @@ int main( int argc, char **argv )
        }
 
        // Start the consumer...
-       mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" );
+       mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" );
 
        // Create the producer(s)
        mlt_playlist pl1 = mlt_playlist_init();
@@ -39,7 +39,7 @@ int main( int argc, char **argv )
        mlt_properties_set_int( mlt_producer_properties( title ), "bgcolor", 0x0000007f );
        mlt_properties_set_int( mlt_producer_properties( title ), "pad", 8 );
        mlt_properties_set_int( mlt_producer_properties( title ), "align", 1 );
-       mlt_properties_set_int( mlt_producer_properties( title ), "x", 20 );
+       mlt_properties_set_int( mlt_producer_properties( title ), "x", 200 );
        mlt_properties_set_int( mlt_producer_properties( title ), "y", 40 );
        mlt_properties_set_double( mlt_producer_properties( title ), "mix", 0.8 );