]> git.sesse.net Git - mlt/commitdiff
Minor optimisations, consumer avformat experimentation
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 30 Mar 2004 19:45:13 +0000 (19:45 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 30 Mar 2004 19:45:13 +0000 (19:45 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@262 d19143bc-622f-0410-bfdd-b5b2a6649095

26 files changed:
docs/services.txt
src/albino/Makefile
src/framework/Makefile
src/framework/mlt_consumer.c
src/framework/mlt_consumer.h
src/framework/mlt_frame.c
src/humperdink/Makefile
src/inigo/Makefile
src/miracle/Makefile
src/miracle/miracle_unit.c
src/modules/avformat/Makefile
src/modules/avformat/consumer_avformat.c
src/modules/avformat/producer_avformat.c
src/modules/core/Makefile
src/modules/dv/Makefile
src/modules/fezzik/Makefile
src/modules/ffmpeg/Makefile
src/modules/gtk2/Makefile
src/modules/inigo/Makefile
src/modules/resample/Makefile
src/modules/sdl/Makefile
src/modules/vorbis/Makefile
src/modules/westley/Makefile
src/modules/xine/Makefile
src/tests/Makefile
src/valerie/Makefile

index e932147722bb55bd1b203f714d7fba1bdc0b0ee0..7e6fcae3136314a822b1a6affe7c9ff6cd4ec60c 100644 (file)
@@ -1278,6 +1278,35 @@ Transitions
 Consumers
 ---------
 
+       avformat
+       
+           Description
+           
+               Multiformat transcoding consumer.
+
+           Constructor Argument
+
+               string target - the filename to write to, e.g. test.mpeg.
+
+           Initialisation Properties
+           
+               int buffer - the number of frames to buffer, minimum 1, default 25.
+               string rescale - a rescale method, see the Filters/rescale.
+               int progressive - indicates whether to use progressive or field-
+                                 based rendering, default 0 (off).
+               
+           Read Only Properties
+           
+               none
+               
+           Dependencies
+           
+               libavformat
+               
+           Known Bugs
+           
+               Plenty.
+
        bluefish (Proprietary)
        
            Description
index d30c7626abecf82af50e3eb6ff058911cd9e191a..4ad38e487c54c988ee2ebe1852955b14393fed26 100644 (file)
@@ -4,15 +4,10 @@ TARGET = albino
 
 OBJS = albino.o
 
-CFLAGS = -O3 -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
 
 LDFLAGS = -L ../valerie -L ../miracle -L ../framework -lmiracle -lmlt -lvalerie
 
-ifeq ($(MLT_GPROF),true)
-CFLAGS+=-p
-LDFLAGS+=-p
-endif
-
 SRCS := $(OBJS:.o=.c)
 
 all: $(TARGET)
index b9f2c7086732a52a5129ef374f201c5a0eac345d..00cc60509ed8caf3ba243030662d458ca9cbfb68 100644 (file)
@@ -21,7 +21,7 @@ OBJS = mlt_frame.o \
 
 SRCS := $(OBJS:.o=.c)
 
-CFLAGS = -g -O3 -Wall -D_FILE_OFFSET_BITS=64 -pthread -DPREFIX="\"$(prefix)\""
+CFLAGS = -g -O4 -pipe -ffast-math -fomit-frame-pointer -Wall -D_FILE_OFFSET_BITS=64 -pthread -DPREFIX="\"$(prefix)\""
 
 LDFLAGS = -lm -ldl -lpthread
 
index 2fb7dd33c597f09f3cfbc6800d6f247ea38e8373..829c3e83a79e43fec967f2783b19de93ce77780a 100644 (file)
@@ -165,6 +165,9 @@ int mlt_consumer_start( mlt_consumer this )
                mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL );
        }
 
+       // Set the real_time preference
+       this->real_time = mlt_properties_get_int( properties, "real_time" );
+
        // Start the service
        if ( this->start != NULL )
                return this->start( this );
@@ -172,7 +175,7 @@ int mlt_consumer_start( mlt_consumer this )
        return 0;
 }
 
-/** Protected method :-/ for consumer to get frames from connected service
+/** Protected method for consumer to get frames from connected service
 */
 
 mlt_frame mlt_consumer_get_frame( mlt_consumer this )
@@ -375,7 +378,7 @@ mlt_frame mlt_consumer_rt_frame( mlt_consumer this )
        mlt_properties properties = mlt_consumer_properties( this );
 
        // Check if the user has requested real time or not
-       if ( mlt_properties_get_int( properties, "real_time" ) )
+       if ( this->real_time )
        {
                int size = 1;
 
index 5376756294487283233b8b079ccc3ae8540675a8..e718912cafe01f047659fb6bd8a353c713afd9bb 100644 (file)
@@ -42,6 +42,7 @@ struct mlt_consumer_s
        void *private;
        void *child;
 
+       int real_time;
        int ahead;
        mlt_image_format format;
        mlt_deque queue;
index ce820b9a0e74c3df928c52153240c0bfafcd2c54..0924cbbc780e9e0ee155c2c90cd0bc33885aa98b 100644 (file)
@@ -494,6 +494,8 @@ void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input
 
        int active_width = 2 * iwidth;
        int inactive_width = out_x_range - in_x_range;
+       uint8_t *p = NULL;
+       uint8_t *end = NULL;
 
        // Loop for the entirety of our output height.
        while ( iheight -- )
@@ -510,8 +512,13 @@ void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input
                }
 
                // We're in the input range for this row.
-               memcpy( out_ptr, in_middle + in_line, active_width );
-               out_ptr += active_width;
+               p = in_middle + in_line;
+               end = out_ptr + active_width;
+               while ( out_ptr != end )
+               {
+                       *out_ptr ++ = *p ++;
+                       *out_ptr ++ = *p ++;
+               }
 
                // Fill the outer part with black
                elements = inactive_width;
index 7003d633ad27f8591ae3ee230b5c3b68d996b9f0..f974b0dbe6bab1eb6ed8bd1c48566daf93303e48 100644 (file)
@@ -6,7 +6,7 @@ OBJS = client.o \
        io.o \
           remote.o
 
-CFLAGS = -O3 -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
 
 LDFLAGS = -L ../valerie -lvalerie
 
index 0b67a319506d5212722ac9df5d143ff5d5471388..46f21f8b6a1fe4b785c986940c013c1515bc8b38 100644 (file)
@@ -5,7 +5,7 @@ TARGET = inigo
 OBJS = inigo.o \
           io.o
 
-CFLAGS = -O3 -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
 
 LDFLAGS = -L ../framework -lmlt 
 
index f8f4340f0d091fe8d05f977a23396a4f36b341c4..8cba00af71cc568bffc42a9c037833ccc4280a18 100644 (file)
@@ -14,7 +14,7 @@ LIB_OBJS = miracle_log.o \
 
 OBJS = $(APP_OBJS) $(LIB_OBJS)
 
-CFLAGS = -O3 -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
 
 LDFLAGS = -L ../valerie -lvalerie -L ../framework -lmlt
 
index ff6072317d4ab5ed35c382e56b4a3c1dde092a57..ce9dac819568ef620a72969c2fbea08d13463c80 100644 (file)
@@ -697,6 +697,7 @@ void miracle_unit_close( miracle_unit unit )
        if ( unit != NULL )
        {
                miracle_log( LOG_DEBUG, "closing unit..." );
+               miracle_unit_terminate( unit );
                if ( unit->old_producers != NULL )
                        mlt_properties_close( unit->old_producers );
                mlt_properties_close( unit->properties );
index 3d1e1cc06e4c71d842411be73a207590f7bcd587..390cef48441d6bbd8686d0013e5eba5790074622 100644 (file)
@@ -6,7 +6,7 @@ OBJS = factory.o \
           producer_avformat.o \
           consumer_avformat.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64
 
 LDFLAGS = -lavformat -lavcodec
 
index ce13c8841aa674bd7073a1eebfadb26cf4307b84..a841339e12efef526caddbe0017e62dd603a5cae 100644 (file)
@@ -10,7 +10,7 @@
  *
  * 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
+ * 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
@@ -117,10 +117,14 @@ mlt_consumer consumer_avformat_init( char *arg )
 
                // Set avformat defaults
                mlt_properties_set_int( properties, "audio_bit_rate", 128000 );
-               mlt_properties_set_int( properties, "video_bit_rate", 400000 );
+               mlt_properties_set_int( properties, "video_bit_rate", 200 * 1000 );
+               mlt_properties_set_int( properties, "video_bit_rate_tolerance", 4000 * 1000 );
+               mlt_properties_set_int( properties, "frame_rate_base", 1 );
                mlt_properties_set_int( properties, "gop_size", 12 );
                mlt_properties_set_int( properties, "max_b_frames", 0 );
                mlt_properties_set_int( properties, "mb_decision", 0 );
+               mlt_properties_set_double( properties, "qscale", 0 );
+               mlt_properties_set_int( properties, "me_method", ME_EPZS );
 
                // Ensure termination at end of the stream
                mlt_properties_set_int( properties, "terminate_on_pause", 1 );
@@ -161,7 +165,7 @@ static int consumer_start( mlt_consumer this )
                int height = mlt_properties_get_int( properties, "height" );
 
                // Obtain the size property
-               char *size =  mlt_properties_get( properties, "size" );
+               char *size = mlt_properties_get( properties, "size" );
 
                // Interpret it
                if ( size != NULL )
@@ -241,26 +245,26 @@ static AVStream *add_audio_stream( mlt_consumer this, AVFormatContext *oc, int c
        mlt_properties properties = mlt_consumer_properties( this );
 
        // Create a new stream
-    AVStream *st = av_new_stream( oc, 1 );
+       AVStream *st = av_new_stream( oc, 1 );
 
        // If created, then initialise from properties
-    if ( st != NULL ) 
+       if ( st != NULL ) 
        {
-       AVCodecContext *c = &st->codec;
-       c->codec_id = codec_id;
-       c->codec_type = CODEC_TYPE_AUDIO;
-
-       // Put sample parameters
-       c->bit_rate = mlt_properties_get_int( properties, "audio_bit_rate" );
-       c->sample_rate = mlt_properties_get_int( properties, "frequency" );
-       c->channels = mlt_properties_get_int( properties, "channels" );
+               AVCodecContext *c = &st->codec;
+               c->codec_id = codec_id;
+               c->codec_type = CODEC_TYPE_AUDIO;
+
+               // Put sample parameters
+               c->bit_rate = mlt_properties_get_int( properties, "audio_bit_rate" );
+               c->sample_rate = mlt_properties_get_int( properties, "frequency" );
+               c->channels = mlt_properties_get_int( properties, "channels" );
        }
        else
        {
-        fprintf( stderr, "Could not allocate a stream for audio\n" );
-    }
+               fprintf( stderr, "Could not allocate a stream for audio\n" );
+       }
 
-    return st;
+       return st;
 }
 
 static int open_audio( AVFormatContext *oc, AVStream *st, int audio_outbuf_size )
@@ -269,35 +273,41 @@ static int open_audio( AVFormatContext *oc, AVStream *st, int audio_outbuf_size
        int audio_input_frame_size = 0;
 
        // Get the context
-    AVCodecContext *c = &st->codec;
+       AVCodecContext *c = &st->codec;
 
        // Find the encoder
-    AVCodec *codec = avcodec_find_encoder( c->codec_id );
+       AVCodec *codec = avcodec_find_encoder( c->codec_id );
 
        // Continue if codec found and we can open it
        if ( codec != NULL && avcodec_open(c, codec) >= 0 )
        {
-       // ugly hack for PCM codecs (will be removed ASAP with new PCM
-       // support to compute the input frame size in samples
-       if ( c->frame_size <= 1 ) 
+               // ugly hack for PCM codecs (will be removed ASAP with new PCM
+               // support to compute the input frame size in samples
+               if ( c->frame_size <= 1 ) 
                {
-               audio_input_frame_size = audio_outbuf_size / c->channels;
-               switch(st->codec.codec_id) 
+                       audio_input_frame_size = audio_outbuf_size / c->channels;
+                       switch(st->codec.codec_id) 
                        {
-                       case CODEC_ID_PCM_S16LE:
-                       case CODEC_ID_PCM_S16BE:
-                       case CODEC_ID_PCM_U16LE:
-                       case CODEC_ID_PCM_U16BE:
-                       audio_input_frame_size >>= 1;
-                       break;
-                       default:
-                       break;
-               }
-       } 
+                               case CODEC_ID_PCM_S16LE:
+                               case CODEC_ID_PCM_S16BE:
+                               case CODEC_ID_PCM_U16LE:
+                               case CODEC_ID_PCM_U16BE:
+                                       audio_input_frame_size >>= 1;
+                                       break;
+                               default:
+                                       break;
+                       }
+               
                else 
                {
-               audio_input_frame_size = c->frame_size;
-       }
+                       audio_input_frame_size = c->frame_size;
+               }
+
+               // Some formats want stream headers to be seperate (hmm)
+               if( !strcmp( oc->oformat->name, "mp4" ) || 
+                       !strcmp( oc->oformat->name, "mov" ) || 
+                       !strcmp( oc->oformat->name, "3gp" ) )
+                       c->flags |= CODEC_FLAG_GLOBAL_HEADER;
        }
        else
        {
@@ -309,7 +319,7 @@ static int open_audio( AVFormatContext *oc, AVStream *st, int audio_outbuf_size
 
 static void close_audio( AVFormatContext *oc, AVStream *st )
 {
-    avcodec_close( &st->codec );
+       avcodec_close( &st->codec );
 }
 
 /** Add a video output stream 
@@ -317,77 +327,95 @@ static void close_audio( AVFormatContext *oc, AVStream *st )
 
 static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int codec_id )
 {
-       // Get the properties
+       // Get the properties
        mlt_properties properties = mlt_consumer_properties( this );
 
        // Create a new stream
-    AVStream *st = av_new_stream( oc, 0 );
+       AVStream *st = av_new_stream( oc, 0 );
 
-    if ( st != NULL ) 
+       if ( st != NULL ) 
        {
                AVCodecContext *c = &st->codec;
-       c->codec_id = codec_id;
-       c->codec_type = CODEC_TYPE_VIDEO;
-
-       // put sample parameters
-       c->bit_rate = mlt_properties_get_int( properties, "video_bit_rate" );
-       c->width = mlt_properties_get_int( properties, "width" );  
-       c->height = mlt_properties_get_int( properties, "height" );
-       c->frame_rate = mlt_properties_get_double( properties, "fps" );  
-       c->frame_rate_base = 1;
-       c->gop_size = mlt_properties_get_int( properties, "gop_size" );
-               c->max_b_frames = mlt_properties_get_int( properties, "max_b_frames" );
-               c->mb_decision = mlt_properties_get_int( properties, "mb_decision" );
-
-       // Some formats want stream headers to be seperate (hmm)
-       if( !strcmp( oc->oformat->name, "mp4" ) || 
+               c->codec_id = codec_id;
+               c->codec_type = CODEC_TYPE_VIDEO;
+
+               // put sample parameters
+               c->bit_rate = mlt_properties_get_int( properties, "video_bit_rate" );
+               c->bit_rate_tolerance = mlt_properties_get_int( properties, "video_bit_rate_tolerance" );
+               c->width = mlt_properties_get_int( properties, "width" );
+               c->height = mlt_properties_get_int( properties, "height" );
+               c->frame_rate = mlt_properties_get_double( properties, "fps" );
+               c->frame_rate_base = mlt_properties_get_double( properties, "frame_rate_base" );
+               c->frame_rate_base = 1;
+               c->gop_size = mlt_properties_get_int( properties, "gop_size" );
+               c->max_b_frames = mlt_properties_get_int( properties, "max_b_frames" );
+               if ( c->max_b_frames )
+               {
+                       c->b_frame_strategy = 0;
+                       c->b_quant_factor = 2.0;
+               }
+
+               c->mb_decision = mlt_properties_get_int( properties, "mb_decision" );
+               c->sample_aspect_ratio = av_d2q( mlt_properties_get_double( properties, "aspect_ratio" ), 255 );
+
+
+               if ( mlt_properties_get_double( properties, "qscale" ) > 0 )
+               {
+                       c->flags |= CODEC_FLAG_QSCALE;
+                       st->quality = FF_QP2LAMBDA * mlt_properties_get_double( properties, "qscale" );
+               }
+
+               // Some formats want stream headers to be seperate (hmm)
+               if( !strcmp( oc->oformat->name, "mp4" ) || 
                        !strcmp( oc->oformat->name, "mov" ) || 
                        !strcmp( oc->oformat->name, "3gp" ) )
-               c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+                       c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+
+               c->me_method = mlt_properties_get_int( properties, "me_method" );
        }
        else
        {
-        fprintf( stderr, "Could not allocate a stream for video\n" );
-    }
-   
-    return st;
+               fprintf( stderr, "Could not allocate a stream for video\n" );
+       }
+       return st;
 }
 
 static AVFrame *alloc_picture( int pix_fmt, int width, int height )
 {
        // Allocate a frame
-    AVFrame *picture = avcodec_alloc_frame();
+       AVFrame *picture = avcodec_alloc_frame();
 
        // Determine size of the 
-       int size = avpicture_get_size(pix_fmt, width, height);
+       int size = avpicture_get_size(pix_fmt, width, height);
 
        // Allocate the picture buf
-       uint8_t *picture_buf = av_malloc(size);
+       uint8_t *picture_buf = av_malloc(size);
 
        // If we have both, then fill the image
        if ( picture != NULL && picture_buf != NULL )
        {
                // Fill the frame with the allocated buffer
-       avpicture_fill((AVPicture *)picture, picture_buf, pix_fmt, width, height);
+               avpicture_fill( (AVPicture *)picture, picture_buf, pix_fmt, width, height);
        }
        else
        {
                // Something failed - clean up what we can
-               av_free(picture);
-               av_free(picture_buf);
-               picture = NULL;
+               av_free( picture );
+               av_free( picture_buf );
+               picture = NULL;
        }
 
-    return picture;
+       return picture;
 }
-    
+       
 static int open_video(AVFormatContext *oc, AVStream *st)
 {
        // Get the codec
-    AVCodecContext *c = &st->codec;
+       AVCodecContext *c = &st->codec;
 
-    // find the video encoder
-    AVCodec *codec = avcodec_find_encoder(c->codec_id);
+       // find the video encoder
+       AVCodec *codec = avcodec_find_encoder(c->codec_id);
 
        // Open the codec safely
        return codec != NULL && avcodec_open(c, codec) >= 0;
@@ -395,7 +423,7 @@ static int open_video(AVFormatContext *oc, AVStream *st)
 
 void close_video(AVFormatContext *oc, AVStream *st)
 {
-    avcodec_close(&st->codec);
+       avcodec_close(&st->codec);
 }
 
 /** The main thread - the argument is simply the consumer.
@@ -429,14 +457,14 @@ static void *consumer_thread( void *arg )
        int samples = 0;
 
        // AVFormat audio buffer and frame size
-       int audio_outbuf_size = 10000;
-       uint8_t *audio_outbuf = av_malloc( audio_outbuf_size );
+       int audio_outbuf_size = 2 * 128 * 1024;
+       uint8_t *audio_outbuf = av_malloc( audio_outbuf_size );
        int audio_input_frame_size = 0;
 
        // AVFormat video buffer and frame count
        int frame_count = 0;
-       int video_outbuf_size = 200000;
-       uint8_t *video_outbuf = av_malloc(video_outbuf_size);
+       int video_outbuf_size = ( 1024 * 1024 );
+       uint8_t *video_outbuf = av_malloc( video_outbuf_size );
 
        // Used for the frame properties
        mlt_frame frame = NULL;
@@ -459,24 +487,28 @@ static void *consumer_thread( void *arg )
        int count = 0;
 
        // Allocate the context
-    AVFormatContext *oc = av_alloc_format_context();
+       AVFormatContext *oc = av_alloc_format_context( );
 
        // Streams
-    AVStream *audio_st = NULL;
+       AVStream *audio_st = NULL;
        AVStream *video_st = NULL;
 
        // Time stamps
-    double audio_pts, video_pts;
+       double audio_pts, video_pts;
 
        // Loop variable
        int i;
 
        // Determine the format
-    AVOutputFormat *fmt = NULL;
+       AVOutputFormat *fmt = NULL;
        char *filename = mlt_properties_get( properties, "target" );
        char *format = mlt_properties_get( properties, "format" );
-       //char *vcodec = mlt_properties_get( properties, "vcodec" );
-       //char *acodec = mlt_properties_get( properties, "acodec" );
+       char *vcodec = mlt_properties_get( properties, "vcodec" );
+       char *acodec = mlt_properties_get( properties, "acodec" );
+
+       // Used to store and override codec ids
+       int audio_codec_id;
+       int video_codec_id;
 
        // Check for user selected format first
        if ( format != NULL )
@@ -494,43 +526,82 @@ static void *consumer_thread( void *arg )
        if ( filename == NULL )
                filename = "pipe:";
 
+       // Get the codec ids selected
+       audio_codec_id = fmt->audio_codec;
+       video_codec_id = fmt->video_codec;
+
+       // Check for audio codec overides
+       if ( acodec != NULL )
+       {
+               AVCodec *p = first_avcodec;
+               while( p != NULL ) 
+               {
+                       if ( !strcmp( p->name, acodec ) && p->type == CODEC_TYPE_AUDIO )
+                               break;
+                       p = p->next;
+               }
+               if ( p != NULL )
+                       audio_codec_id = p->id;
+               else
+                       fprintf( stderr, "consumer_avcodec: audio codec %s unrecognised - ignoring\n", acodec );
+       }
+
+       // Check for video codec overides
+       if ( vcodec != NULL )
+       {
+               AVCodec *p = first_avcodec;
+               while( p != NULL ) 
+               {
+                       if ( !strcmp( p->name, vcodec ) && p->type == CODEC_TYPE_VIDEO )
+                               break;
+                       p = p->next;
+               }
+               if ( p != NULL )
+                       video_codec_id = p->id;
+               else
+                       fprintf( stderr, "consumer_avcodec: video codec %s unrecognised - ignoring\n", vcodec );
+       }
+
        // Update the output context
        oc->oformat = fmt;
-    snprintf( oc->filename, sizeof(oc->filename), "%s", filename );
+       snprintf( oc->filename, sizeof(oc->filename), "%s", filename );
 
        // Add audio and video streams 
-    if ( fmt->video_codec != CODEC_ID_NONE )
-        video_st = add_video_stream( this, oc, fmt->video_codec );
-    if ( fmt->audio_codec != CODEC_ID_NONE )
-        audio_st = add_audio_stream( this, oc, fmt->audio_codec );
+       if ( fmt->video_codec != CODEC_ID_NONE )
+               video_st = add_video_stream( this, oc, video_codec_id );
+       if ( fmt->audio_codec != CODEC_ID_NONE )
+               audio_st = add_audio_stream( this, oc, audio_codec_id );
 
        // Set the parameters (even though we have none...)
-    if ( av_set_parameters(oc, NULL) >= 0 ) 
+       if ( av_set_parameters(oc, NULL) >= 0 ) 
        {
-           if ( video_st && !open_video( oc, video_st ) )
+               if ( video_st && !open_video( oc, video_st ) )
                        video_st = NULL;
-       if ( audio_st )
-               audio_input_frame_size = open_audio( oc, audio_st, audio_outbuf_size );
+               if ( audio_st )
+                       audio_input_frame_size = open_audio( oc, audio_st, audio_outbuf_size );
 
-       // Open the output file, if needed
-       if ( !( fmt->flags & AVFMT_NOFILE ) ) 
+               // Open the output file, if needed
+               if ( !( fmt->flags & AVFMT_NOFILE ) ) 
                {
-               if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) 
+                       if (url_fopen(&oc->pb, filename, URL_RDWR) < 0) 
                        {
-               fprintf(stderr, "Could not open '%s'\n", filename);
+                               fprintf(stderr, "Could not open '%s'\n", filename);
                                mlt_properties_set_int( properties, "running", 0 );
-               }
-       }
-    
-       // Write the stream header, if any
+                       }
+               }
+       
+               if ( url_is_streamed( &oc->pb ) )
+                       fprintf( stderr, "FUCK!\n" );
+
+               // Write the stream header, if any
                if ( mlt_properties_get_int( properties, "running" ) )
-               av_write_header( oc );
+                       av_write_header( oc );
        }
        else
        {
-        fprintf(stderr, "Invalid output format parameters\n");
+               fprintf(stderr, "Invalid output format parameters\n");
                mlt_properties_set_int( properties, "running", 0 );
-    }
+       }
 
        // Last check - need at least one stream
        if ( audio_st == NULL && video_st == NULL )
@@ -565,47 +636,47 @@ static void *consumer_thread( void *arg )
                        // While we have stuff to process, process...
                        while ( 1 )
                        {
-                               // Compute current audio and video time
-                               if (audio_st)
-                               audio_pts = (double)audio_st->pts.val * oc->pts_num / oc->pts_den;
-                               else
-                               audio_pts = 0.0;
-       
-                               if (video_st)
-                               video_pts = (double)video_st->pts.val * oc->pts_num / oc->pts_den;
-                               else
-                               video_pts = 0.0;
-
-                               // Write interleaved audio and video frames
-                               if ( !video_st || ( video_st && audio_st && audio_pts < video_pts ) )
+                               // Compute current audio and video time
+                               if (audio_st)
+                                       audio_pts = (double)audio_st->pts.val * oc->pts_num / oc->pts_den;
+                               else
+                                       audio_pts = 0.0;
+        
+                               if (video_st)
+                                       video_pts = (double)video_st->pts.val * oc->pts_num / oc->pts_den;
+                               else
+                                       video_pts = 0.0;
+
+                               // Write interleaved audio and video frames
+                               if ( !video_st || ( video_st && audio_st && audio_pts < video_pts ) )
                                {
                                        if ( channels * audio_input_frame_size < sample_fifo_used( fifo ) )
                                        {
-                               int out_size;
-                                               AVCodecContext *c;
+                                               int out_size;
+                                               AVCodecContext *c;
 
-                                               c = &audio_st->codec;
+                                               c = &audio_st->codec;
 
                                                sample_fifo_fetch( fifo, buffer, channels * audio_input_frame_size );
 
-                                               out_size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
+                                               out_size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
 
-                                               // Write the compressed frame in the media file
-                                               if (av_write_frame(oc, audio_st->index, audio_outbuf, out_size) != 0) 
-                                                       fprintf(stderr, "Error while writing audio frame\n");
+                                               // Write the compressed frame in the media file
+                                               if (av_write_frame(oc, audio_st->index, audio_outbuf, out_size) != 0) 
+                                                       fprintf(stderr, "Error while writing audio frame\n");
                                        }
                                        else
                                        {
                                                break;
                                        }
                                }
-                               else if ( video_st )
+                               else if ( video_st )
                                {
                                        if ( mlt_deque_count( queue ) )
                                        {
-                                               int out_size, ret;
-                                               AVCodecContext *c;
-   
+                                               int out_size, ret;
+                                               AVCodecContext *c;
                                                frame = mlt_deque_pop_front( queue );
                                                frame_properties = mlt_frame_properties( frame );
 
@@ -615,8 +686,8 @@ static void *consumer_thread( void *arg )
                                                        break;
                                                }
 
-                                               c = &video_st->codec;
-                                               
+                                               c = &video_st->codec;
+                                               
                                                if ( mlt_properties_get_int( frame_properties, "rendered" ) )
                                                {
                                                        int i = 0;
@@ -641,26 +712,26 @@ static void *consumer_thread( void *arg )
 
                                                        img_convert( ( AVPicture * )output, PIX_FMT_YUV420P, ( AVPicture * )input, PIX_FMT_YUV422, width, height );
                                                }
-   
-                                               if (oc->oformat->flags & AVFMT_RAWPICTURE) 
+                                               if (oc->oformat->flags & AVFMT_RAWPICTURE) 
                                                {
-                                                       // raw video case. The API will change slightly in the near future for that
-                                                       ret = av_write_frame(oc, video_st->index, (uint8_t *)output, sizeof(AVPicture));
-                                               } 
+                                                       // raw video case. The API will change slightly in the near future for that
+                                                       ret = av_write_frame(oc, video_st->index, (uint8_t *)output, sizeof(AVPicture));
+                                               } 
                                                else 
                                                {
-                                                       // Encode the image
-                                                       out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, output );
+                                                       // Encode the image
+                                                       out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, output );
 
-                                                       // If zero size, it means the image was buffered
-                                                       if (out_size != 0) 
+                                                       // If zero size, it means the image was buffered
+                                                       if (out_size != 0) 
                                                        {
-                                                       // write the compressed frame in the media file
-                                                       // XXX: in case of B frames, the pts is not yet valid
-                                                       ret = av_write_frame( oc, video_st->index, video_outbuf, out_size );
-                                                       } 
-                                               }
-                                               frame_count++;
+                                                               // write the compressed frame in the media file
+                                                               // XXX: in case of B frames, the pts is not yet valid
+                                                               ret = av_write_frame( oc, video_st->index, video_outbuf, out_size );
+                                                       } 
+                                               }
+                                               frame_count++;
                                                mlt_frame_close( frame );
                                        }
                                        else
@@ -672,32 +743,32 @@ static void *consumer_thread( void *arg )
                }
        }
 
-    // close each codec 
-    if (video_st)
-        close_video(oc, video_st);
-    if (audio_st)
-        close_audio(oc, audio_st);
+       // close each codec 
+       if (video_st)
+               close_video(oc, video_st);
+       if (audio_st)
+               close_audio(oc, audio_st);
+
+       // Write the trailer, if any
+       av_write_trailer(oc);
 
-    // Write the trailer, if any
-    av_write_trailer(oc);
-    
-    // Free the streams
-    for(i = 0; i < oc->nb_streams; i++)
-        av_freep(&oc->streams[i]);
+       // Free the streams
+       for(i = 0; i < oc->nb_streams; i++)
+               av_freep(&oc->streams[i]);
 
        // Close the output file
-    if (!(fmt->flags & AVFMT_NOFILE))
-        url_fclose(&oc->pb);
+       if (!(fmt->flags & AVFMT_NOFILE))
+               url_fclose(&oc->pb);
 
        // Clean up input and output frames
-    av_free( output->data[0] );
-    av_free( output );
-    av_free( input->data[0] );
-    av_free( input );
-    av_free( video_outbuf );
-
-    // Free the stream
-    av_free(oc);
+       av_free( output->data[0] );
+       av_free( output );
+       av_free( input->data[0] );
+       av_free( input );
+       av_free( video_outbuf );
+
+       // Free the stream
+       av_free(oc);
 
        return NULL;
 }
index 582171ea7d13d4072c3e11d5b752d031b1c9cb30..f4cb38b6eed95e6cfc92e56c1f3631cbaf0dac26 100644 (file)
@@ -469,7 +469,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                                                current_time = real_timecode;
 
                                        // Handle ignore
-                                       if ( current_time < real_timecode )
+                                       if ( ( int )( current_time * 100 ) < ( int )( real_timecode * 100 ) - 7 )
                                        {
                                                ignore = 0;
                                                got_picture = 0;
index 12e2d6189b4c63de2b9abd2167350d633cc66fbf..a906252b7bdaf3e02bae8fd8a0285a7d7f9beff3 100644 (file)
@@ -24,7 +24,7 @@ OBJS = factory.o \
 
 ASM_OBJS = composite_line_yuv_mmx.o
 
-CFLAGS = -O3 -DUSE_MMX -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -DUSE_MMX -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 SRCS := $(OBJS:.o=.c)
 
index 493d2ac4cb99148a5ccb89bf6e49508db149a6c4..576d4f4735bd2978c7ab0c5a6affd61b4315dcbc 100644 (file)
@@ -6,7 +6,7 @@ OBJS = factory.o \
           producer_libdv.o \
           consumer_libdv.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 LDFLAGS=-ldv -lpthread
 
index 1cb292e107d928cf3aafc88cd44578656f7e4558..137c9c2b9076293d3528dde4eb3bc1aac1e0c35f 100644 (file)
@@ -6,7 +6,7 @@ OBJS = factory.o \
           producer_fezzik.o \
           producer_hold.o 
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 SRCS := $(OBJS:.o=.c)
 
index 8e0e3ad35176eda23b5387854c1765a3e486cad9..0585571111759a28c210ac960d6f8d2702f80fb6 100644 (file)
@@ -7,7 +7,7 @@ OBJS = factory.o \
           filter_ffmpeg_dub.o \
           consumer_ffmpeg.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 SRCS := $(OBJS:.o=.c)
 
index 77c47658f93af26c106a33b0dbb0e94b386d2570..a37c1842f667c9e4055367f898b097399172dd94 100644 (file)
@@ -11,7 +11,7 @@ OBJS = factory.o \
 ASM_OBJS = have_mmx.o \
                   scale_line_22_yuv_mmx.o
 
-CFLAGS = -O3 -DUSE_MMX `pkg-config gdk-pixbuf-2.0 --cflags` `pkg-config pangoft2 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -DUSE_MMX `pkg-config gdk-pixbuf-2.0 --cflags` `pkg-config pangoft2 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 LDFLAGS = `pkg-config gdk-pixbuf-2.0 --libs` `pkg-config pangoft2 --libs`
 
index 31c4955e694d9eb38bdc18fdb5fd90ea3ec93a58..8ea9c243f22ab432e7cff76a737a60ea0e1012f4 100644 (file)
@@ -5,7 +5,7 @@ TARGET = ../libmltinigo.so
 OBJS = factory.o \
           producer_inigo.o 
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 SRCS := $(OBJS:.o=.c)
 
index 83ffb3d94135b53ccbb476263a97d0289491ac39..7811050600728bb169bb0aea4a21caa6a1636b19 100644 (file)
@@ -5,7 +5,7 @@ TARGET = ../libmltresample.so
 OBJS = factory.o \
           filter_resample.o 
 
-CFLAGS = -O3 -I../../ -Wall -g
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g
 
 LDFLAGS= -lsamplerate
 
index 1571a297f0ba1b201c8dd3a4702ade35eb97e2d6..19ef216c1e2a5dda144491b09b5b218e2ff8fb76 100644 (file)
@@ -5,7 +5,7 @@ TARGET = ../libmltsdl.so
 OBJS = factory.o \
           consumer_sdl.o 
 
-CFLAGS = -O3 -I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 LDFLAGS= `sdl-config --libs`
 
index fabf4d7b5e57ef136cd2615106ab7a68a71a91ad..3d19024101f88eea8fdbe96ab97f195b609a0816 100644 (file)
@@ -5,7 +5,7 @@ TARGET = ../libmltvorbis.so
 OBJS = factory.o \
           producer_vorbis.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64
 
 LDFLAGS = -lvorbisfile -lvorbis
 
index a5d5d184bb64c03ad12d397055f0598a429ad783..160181b647eb2d9914b913940558d1e7131ede60 100644 (file)
@@ -6,7 +6,7 @@ OBJS = factory.o \
           consumer_westley.o \
           producer_westley.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread `xml2-config --cflags`
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread `xml2-config --cflags`
 
 LDFLAGS = `xml2-config --libs`
 
index 9a965929285c732ed26d66affb6261694403c50d..2f82a13fc672fecd7f69cdc42a93f56e5ec4d8ae 100644 (file)
@@ -7,7 +7,7 @@ OBJS = factory.o \
           cpu_accel.o \
           filter_deinterlace.o
 
-CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -DARCH_X86
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -DARCH_X86
 
 SRCS := $(OBJS:.o=.c)
 
index 92ef0eb9fd21fb2c0490ab9ba4659cca92ee2502..0dd5bb8e7a60dadb4f068a85074801512ee529f2 100644 (file)
@@ -2,7 +2,7 @@ include ../../config.mak
 
 TARGET = dan charlie pango pixbuf dissolve luma
 
-CFLAGS = -O3 -I .. -Wall -rdynamic -pthread
+CFLAGS = -O4 -pipe -ffast-math -fomit-frame-pointer -I .. -Wall -rdynamic -pthread
 
 LDFLAGS = -L ../framework -L ../modules -lmlt -lmltdv -lmltsdl
 
index d7ff25cc5aad7e319ad410e0fa14801b6e8a1150..12b835fbd7a230c7dca36a75c6f82fb33530c3cf 100644 (file)
@@ -14,7 +14,7 @@ OBJS = valerie.o \
 
 SRCS := $(OBJS:.o=.c)
 
-CFLAGS=-O3 -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS=-O4 -pipe -ffast-math -fomit-frame-pointer -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
 LDFLAGS=-ldv -lpthread