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
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
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
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
None.
pango
-
+
Description
A title generator that uses the Pango international text layout
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
Initialisation Properties
- timecode in - in point
- timecode out - out point
+ int in - in point
+ int out - out point
Mutable Properties
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
-------
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
-----------
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
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
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
---------
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
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
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
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
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
None.
pango
-
+
Description
A title generator that uses the Pango international text layout
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
Initialisation Properties
- timecode in - in point
- timecode out - out point
+ int in - in point
+ int out - out point
Mutable Properties
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
-------
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
-----------
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
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
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
---------
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
log_output = method;
threshold = new_threshold;
if (method == log_syslog)
- openlog( "dv1394d", LOG_CONS, LOG_DAEMON );
+ openlog( "miracle", LOG_CONS, LOG_DAEMON );
}
#include <string.h>
#include <errno.h>
#include <signal.h>
+#include <limits.h>
#include <sys/mman.h>
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 )
-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)'; \
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
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
#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 )
{
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;
}
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;
}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
#include <stdio.h>
#include <stdlib.h>
-/** Composition class.
-*/
-
-typedef struct
-{
- struct mlt_transition_s parent;
-}
-transition_composite;
-
/** Get the image.
*/
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 );
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;
}
/** 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;
}
#include <framework/mlt_transition.h>
-extern mlt_transition transition_composite_init( void *arg );
+extern mlt_transition transition_composite_init( char *arg );
#endif
// 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 )
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.
*/
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 );
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;
}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
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 );
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 );
--- /dev/null
+
+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
--- /dev/null
+#!/bin/bash
+
+if [ "$help" != "1" ]
+then
+
+cat << EOF >> ../filters.dat
+resample libmltresample.so
+EOF
+
+fi
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
}
// 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 );
}
// 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();
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 );
log_output = method;
threshold = new_threshold;
if (method == log_syslog)
- openlog( "dv1394d", LOG_CONS, LOG_DAEMON );
+ openlog( "miracle", LOG_CONS, LOG_DAEMON );
}
#include <string.h>
#include <errno.h>
#include <signal.h>
+#include <limits.h>
#include <sys/mman.h>
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 )
-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)'; \
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
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
#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 )
{
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;
}
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;
}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
#include <stdio.h>
#include <stdlib.h>
-/** Composition class.
-*/
-
-typedef struct
-{
- struct mlt_transition_s parent;
-}
-transition_composite;
-
/** Get the image.
*/
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 );
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;
}
/** 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;
}
#include <framework/mlt_transition.h>
-extern mlt_transition transition_composite_init( void *arg );
+extern mlt_transition transition_composite_init( char *arg );
#endif
// 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 )
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.
*/
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 );
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;
}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
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 );
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 );
--- /dev/null
+
+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
--- /dev/null
+#!/bin/bash
+
+if [ "$help" != "1" ]
+then
+
+cat << EOF >> ../filters.dat
+resample libmltresample.so
+EOF
+
+fi
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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
}
// 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 );
}
// 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();
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 );