]> git.sesse.net Git - mlt/commitdiff
src/framework/mlt_consumer.c src/framework/mlt_consumer.h
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 21 Jun 2005 20:59:39 +0000 (20:59 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 21 Jun 2005 20:59:39 +0000 (20:59 +0000)
+ Added a general profile handling for size, aspect ratio and display ratio

src/framework/mlt_producer.c
+ Correction to aspect ratio properties

src/inigo/inigo.c
+ Minimalist support for sdl_preview (still not very good)

src/modules/avformat/consumer_avformat.c
+ Takes consumer profile into account

src/modules/core/filter_resize.c
+ Corrections for synthesised producers and aspect ratio (inherits from consumer)

src/modules/core/producer_colour.c
src/modules/core/producer_noise.c
src/modules/gtk2/producer_pango.c
+ Ensures that resize picks up consumer aspect ratio

src/modules/dv/consumer_libdv.c
+ Honour wide screen output

src/modules/gtk2/producer_pixbuf.c
+ Correction for 1:1 aspect ratio

src/modules/kino/Makefile
src/modules/kino/avi.cc
src/modules/kino/avi.h
src/modules/kino/configure
src/modules/kino/filehandler.cc
+ Attempt to allow mov dv files to provide audio

src/modules/sdl/consumer_sdl.c
src/modules/sdl/consumer_sdl_preview.c
src/modules/sdl/consumer_sdl_still.c
+ Takes consumer profile into account

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@736 d19143bc-622f-0410-bfdd-b5b2a6649095

19 files changed:
src/framework/mlt_consumer.c
src/framework/mlt_consumer.h
src/framework/mlt_producer.c
src/inigo/inigo.c
src/modules/avformat/consumer_avformat.c
src/modules/core/filter_resize.c
src/modules/core/producer_colour.c
src/modules/core/producer_noise.c
src/modules/dv/consumer_libdv.c
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pixbuf.c
src/modules/kino/Makefile
src/modules/kino/avi.cc
src/modules/kino/avi.h
src/modules/kino/configure
src/modules/kino/filehandler.cc
src/modules/sdl/consumer_sdl.c
src/modules/sdl/consumer_sdl_preview.c
src/modules/sdl/consumer_sdl_still.c

index 8f99db4dce52086ca24c6b8d73e35bb658af1279..5b48e6d330c4593bf5606c0f934a44dbd1a99555 100644 (file)
@@ -53,23 +53,33 @@ int mlt_consumer_init( mlt_consumer this, void *child )
                {
                        mlt_properties_set( properties, "normalisation", "PAL" );
                        mlt_properties_set_double( properties, "fps", 25.0 );
-                       mlt_properties_set_int( properties, "frame_rate_den", 25 );
-                       mlt_properties_set_int( properties, "frame_rate_num", 1 );
+                       mlt_properties_set_int( properties, "frame_rate_num", 25 );
+                       mlt_properties_set_int( properties, "frame_rate_den", 1 );
                        mlt_properties_set_int( properties, "width", 720 );
                        mlt_properties_set_int( properties, "height", 576 );
                        mlt_properties_set_int( properties, "progressive", 0 );
                        mlt_properties_set_double( properties, "aspect_ratio", 59.0 / 54.0 );
+                       mlt_properties_set_int( properties, "aspect_ratio_num", 59 );
+                       mlt_properties_set_int( properties, "aspect_ratio_den", 54 );
+                       mlt_properties_set_double( properties, "display_ratio", 4.0 / 3.0 );
+                       mlt_properties_set_int( properties, "display_ratio_num", 4 );
+                       mlt_properties_set_int( properties, "display_ratio_den", 3 );
                }
                else
                {
                        mlt_properties_set( properties, "normalisation", "NTSC" );
                        mlt_properties_set_double( properties, "fps", 30000.0 / 1001.0 );
-                       mlt_properties_set_int( properties, "frame_rate_den", 30000 );
-                       mlt_properties_set_int( properties, "frame_rate_num", 1001 );
+                       mlt_properties_set_int( properties, "frame_rate_num", 30000 );
+                       mlt_properties_set_int( properties, "frame_rate_den", 1001 );
                        mlt_properties_set_int( properties, "width", 720 );
                        mlt_properties_set_int( properties, "height", 480 );
                        mlt_properties_set_int( properties, "progressive", 0 );
                        mlt_properties_set_double( properties, "aspect_ratio", 10.0 / 11.0 );
+                       mlt_properties_set_int( properties, "aspect_ratio_num", 10 );
+                       mlt_properties_set_int( properties, "aspect_ratio_den", 11 );
+                       mlt_properties_set_double( properties, "display_ratio", 4.0 / 3.0 );
+                       mlt_properties_set_int( properties, "display_ratio_num", 4 );
+                       mlt_properties_set_int( properties, "display_ratio_den", 3 );
                }
 
                // Default rescaler for all consumers
@@ -166,6 +176,16 @@ int mlt_consumer_start( mlt_consumer this )
        // Determine if there's a test card producer
        char *test_card = mlt_properties_get( properties, "test_card" );
 
+       // Handle profiles
+       char *profile = mlt_properties_get( properties, "profile" );
+       int profile_ok = mlt_consumer_profile( properties, profile );
+
+       // Check that everything is OK
+       if ( !profile_ok )
+               fprintf( stderr, "Unrecognised profile %s - continuing with defaults.\n", mlt_properties_get( properties, "profile" ) );
+       else if ( profile_ok < 0 )
+               fprintf( stderr, "Recognised profile %s with warnings - trying to continue with some defaults.\n", mlt_properties_get( properties, "profile" ) );
+
        // Just to make sure nothing is hanging around...
        mlt_frame_close( this->put );
        this->put = NULL;
@@ -327,6 +347,168 @@ static inline long time_difference( struct timeval *time1 )
        return time1->tv_sec * 1000000 + time1->tv_usec - time2.tv_sec * 1000000 - time2.tv_usec;
 }
 
+int mlt_consumer_profile( mlt_properties properties, char *profile )
+{
+       double fps = mlt_properties_get_double( properties, "fps" );
+       int recognised = 1;
+       double display_num = 0;
+       double display_den = 0;
+       double pixel_num = 0;
+       double pixel_den = 0;
+       int width = 0;
+       int height = 0;
+
+       if ( fps == 25.0 && profile != NULL )
+       {
+               width = 720;
+               height = 576;
+               display_num = 4;
+               display_den = 3;
+               pixel_num = 59;
+               pixel_den = 54;
+
+               if ( !strcmp( profile, "dv_wide" ) )
+               {
+                       display_num = 16;
+                       display_den = 9;
+                       pixel_num = 118;
+                       pixel_den = 81;
+               }
+               else if ( !strncmp( profile, "square_wide", 11 ) )
+               {
+                       display_num = 16;
+                       display_den = 9;
+                       pixel_num = 1;
+                       pixel_den = 1;
+                       width = 1024;
+                       height = 576;
+               }
+               else if ( !strncmp( profile, "square", 6 ) )
+               {
+                       pixel_num = 1;
+                       pixel_den = 1;
+                       width = 768;
+                       height = 576;
+               }
+               else if ( !strncmp( profile, "vcd", 3 ) )
+               {
+                       width = 352;
+                       height = 288;
+               }
+               else if ( !strncmp( profile, "cvd", 3 ) )
+               {
+                       width = 352;
+                       height = 576;
+                       pixel_num = 59;
+                       pixel_den = 27;
+               }
+               else if ( !strncmp( profile, "svcd_wide", 9 ) )
+               {
+                       width = 480;
+                       height = 576;
+                       pixel_num = 59;
+                       pixel_den = 27;
+                       display_num = 16;
+                       display_den = 9;
+               }
+               else if ( !strncmp( profile, "svcd", 4 ) )
+               {
+                       width = 480;
+                       height = 576;
+                       pixel_num = 59;
+                       pixel_den = 36;
+               }
+               else if ( strncmp( profile, "frame", 5 ) && strcmp( profile, "dv" ) )
+               {
+                       recognised = 0;
+               }
+       }
+       else if ( profile != NULL )
+       {
+               width = 720;
+               height = 480;
+               display_num = 4;
+               display_den = 3;
+               pixel_num = 10;
+               pixel_den = 11;
+
+               if ( !strcmp( profile, "dv_wide" ) )
+               {
+                       display_num = 16;
+                       display_den = 9;
+                       pixel_num = 40;
+                       pixel_den = 33;
+               }
+               else if ( !strncmp( profile, "square_wide", 11 ) )
+               {
+                       display_num = 16;
+                       display_den = 9;
+                       pixel_num = 1;
+                       pixel_den = 1;
+                       width = 854;
+                       height = 480;
+               }
+               else if ( !strncmp( profile, "square", 6 ) )
+               {
+                       pixel_num = 1;
+                       pixel_den = 1;
+                       width = 640;
+                       height = 480;
+               }
+               else if ( !strncmp( profile, "vcd", 3 ) )
+               {
+                       width = 352;
+                       height = 240;
+               }
+               else if ( !strncmp( profile, "cvd", 3 ) )
+               {
+                       width = 352;
+                       height = 480;
+                       pixel_num = 20;
+                       pixel_den = 11;
+               }
+               else if ( !strncmp( profile, "svcd_wide", 9 ) )
+               {
+                       width = 480;
+                       height = 480;
+                       pixel_num = 20;
+                       pixel_den = 11;
+                       display_num = 16;
+                       display_den = 9;
+               }
+               else if ( !strncmp( profile, "svcd", 4 ) )
+               {
+                       width = 480;
+                       height = 480;
+                       pixel_num = 15;
+                       pixel_den = 11;
+               }
+               else if ( strncmp( profile, "frame", 5 ) && strcmp( profile, "dv" ) )
+               {
+                       recognised = 0;
+               }
+       }
+
+       // If width (or any of the above are 0), we use defaults otherwise we switch to recognised
+       if ( width != 0 && recognised )
+       {
+               if ( recognised && strchr( profile, ':' ) )
+                       if ( sscanf( strchr( profile, ':' ) + 1, "%dx%d", &width, &height ) != 2 )
+                               recognised = -1;
+
+               mlt_properties_set_int( properties, "width", width );
+               mlt_properties_set_int( properties, "height", height );
+               mlt_properties_set_double( properties, "aspect_ratio", pixel_num / pixel_den );
+               mlt_properties_set_int( properties, "aspect_ratio_num", pixel_num );
+               mlt_properties_set_int( properties, "aspect_ratio_den", pixel_den );
+               mlt_properties_set_double( properties, "display_ratio", display_num / display_den );
+               mlt_properties_set_int( properties, "display_ratio_num", display_num );
+               mlt_properties_set_int( properties, "display_ratio_den", display_den );
+       }
+
+       return recognised;
+}
+
 static void *consumer_read_ahead_thread( void *arg )
 {
        // The argument is the consumer
@@ -407,6 +589,10 @@ static void *consumer_read_ahead_thread( void *arg )
        // Continue to read ahead
        while ( this->ahead )
        {
+               // Fetch width/height again
+               width = mlt_properties_get_int( properties, "width" );
+               height = mlt_properties_get_int( properties, "height" );
+
                // Put the current frame into the queue
                pthread_mutex_lock( &this->mutex );
                while( this->ahead && mlt_deque_count( this->queue ) >= buffer )
index 873f42165efb68dbf213c348f9d7dc3b5a905170..82a08b42ce08e7b2805eb55340465272a13ceb7d 100644 (file)
@@ -75,5 +75,6 @@ extern int mlt_consumer_stop( mlt_consumer self );
 extern int mlt_consumer_is_stopped( mlt_consumer self );
 extern void mlt_consumer_stopped( mlt_consumer self );
 extern void mlt_consumer_close( mlt_consumer );
+extern int mlt_consumer_profile( mlt_properties properties, char *profile );
 
 #endif
index 4963baa22ae9e584c99d85bf8079f7c278ae27c2..f3233f92087b8f21fecf36ca7905440276a26399 100644 (file)
@@ -89,15 +89,15 @@ int mlt_producer_init( mlt_producer this, void *child )
                        if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
                        {
                                mlt_properties_set_double( properties, "fps", 25.0 );
-                               mlt_properties_set_int( properties, "frame_rate_den", 25 );
-                               mlt_properties_set_int( properties, "frame_rate_num", 1 );
+                               mlt_properties_set_int( properties, "frame_rate_num", 25 );
+                               mlt_properties_set_int( properties, "frame_rate_den", 1 );
                                mlt_properties_set_double( properties, "aspect_ratio", 59.0 / 54.0 );
                        }
                        else
                        {
                                mlt_properties_set_double( properties, "fps", 30000.0 / 1001.0 );
-                               mlt_properties_set_int( properties, "frame_rate_den", 30000 );
-                               mlt_properties_set_int( properties, "frame_rate_num", 1001 );
+                               mlt_properties_set_int( properties, "frame_rate_num", 30000 );
+                               mlt_properties_set_int( properties, "frame_rate_den", 1001 );
                                mlt_properties_set_double( properties, "aspect_ratio", 10.0 / 11.0 );
                        }
                        mlt_properties_set_double( properties, "_speed", 1.0 );
index f7ffffc26be16a6bbf04757ca4bca1c23715ad5c..5c8e9b88982eff5d4fa20bafd43a6625b72b9ac9 100644 (file)
@@ -11,6 +11,7 @@ static void transport_action( mlt_producer producer, char *value )
 {
        mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
        mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
+       mlt_consumer consumer = mlt_properties_get_data( properties, "transport_consumer", NULL );
 
        mlt_properties_set_int( properties, "stats_off", 0 );
 
@@ -122,6 +123,8 @@ static void transport_action( mlt_producer producer, char *value )
                                }
                                break;
                }
+
+               mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
        }
 
        mlt_properties_set_int( properties, "stats_off", 0 );
@@ -138,6 +141,7 @@ static mlt_consumer create_consumer( char *id, mlt_producer producer )
                mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
                mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL );
                mlt_properties_set_data( properties, "transport_producer", producer, 0, NULL, NULL );
+               mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( producer ), "transport_consumer", consumer, 0, NULL, NULL );
        }
        return consumer;
 }
index febd134741dc87a02bacf4ac1c485f06f93ead2a..fbb978eea73e52569c253ad633dd5b122ede76e1 100644 (file)
@@ -158,7 +158,6 @@ mlt_consumer consumer_avformat_init( char *arg )
                mlt_properties_set_int( properties, "audio_bit_rate", 128000 );
                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, "b_frames", 0 );
                mlt_properties_set_int( properties, "mb_decision", FF_MB_DECISION_SIMPLE );
@@ -331,6 +330,17 @@ static AVStream *add_audio_stream( mlt_consumer this, AVFormatContext *oc, int c
                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" );
+
+               // Allow the user to override the audio fourcc
+               if ( mlt_properties_get( properties, "afourcc" ) )
+               {
+                       char *tail = NULL;
+                       char *arg = mlt_properties_get( properties, "afourcc" );
+               int tag = strtol( arg, &tail, 0);
+               if( !tail || *tail )
+                       tag = arg[ 0 ] + ( arg[ 1 ] << 8 ) + ( arg[ 2 ] << 16 ) + ( arg[ 3 ] << 24 );
+                       c->codec_tag = tag;
+               }
        }
        else
        {
@@ -417,8 +427,8 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c
                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->time_base.den = mlt_properties_get_int( properties, "frame_rate_den" );
-               c->time_base.num = mlt_properties_get_int( properties, "frame_rate_num" );
+               c->time_base.num = mlt_properties_get_int( properties, "frame_rate_den" );
+               c->time_base.den = mlt_properties_get_int( properties, "frame_rate_num" );
                c->gop_size = mlt_properties_get_int( properties, "gop_size" );
                c->pix_fmt = PIX_FMT_YUV420P;
 
@@ -430,7 +440,7 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c
                }
 
                c->mb_decision = mlt_properties_get_int( properties, "mb_decision" );
-               c->sample_aspect_ratio = av_d2q( mlt_properties_get_double( properties, "aspect_ratio" ), 255 );
+               c->sample_aspect_ratio = av_d2q( mlt_properties_get_double( properties, "display_ratio" ) * c->height / c->width, 255 );
                c->mb_cmp = mlt_properties_get_int( properties, "mb_cmp" );
                c->ildct_cmp = mlt_properties_get_int( properties, "ildct_cmp" );
                c->me_sub_cmp = mlt_properties_get_int( properties, "sub_cmp" );
@@ -459,10 +469,19 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c
                        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" ) )
+               // Allow the user to override the video fourcc
+               if ( mlt_properties_get( properties, "vfourcc" ) )
+               {
+                       char *tail = NULL;
+                       const char *arg = mlt_properties_get( properties, "vfourcc" );
+               int tag = strtol( arg, &tail, 0);
+               if( !tail || *tail )
+                       tag = arg[ 0 ] + ( arg[ 1 ] << 8 ) + ( arg[ 2 ] << 16 ) + ( arg[ 3 ] << 24 );
+                       c->codec_tag = tag;
+               }
+
+               // Some formats want stream headers to be seperate
+               if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) 
                        c->flags |= CODEC_FLAG_GLOBAL_HEADER;
 
                c->rc_max_rate = mlt_properties_get_int( properties, "video_rc_max_rate" );
@@ -538,7 +557,7 @@ static int open_video(AVFormatContext *oc, AVStream *st)
        if( codec && codec->supported_framerates )
        {
                const AVRational *p = codec->supported_framerates;
-               AVRational req = ( AVRational ){ video_enc->time_base.den, video_enc->time_base.num };
+               AVRational req = ( AVRational ){ video_enc->time_base.num, video_enc->time_base.den };
                const AVRational *best = NULL;
                AVRational best_error = (AVRational){ INT_MAX, 1 };
                for( ; p->den!=0; p++ )
@@ -552,8 +571,8 @@ static int open_video(AVFormatContext *oc, AVStream *st)
                                best = p;
                        }
                }
-               video_enc->time_base.den = best->num;
-               video_enc->time_base.num = best->den;
+               video_enc->time_base.num = best->num;
+               video_enc->time_base.den = best->den;
        }
  
        if( codec && codec->pix_fmts )
index d245ed0d409b4f915f315f7446c5a82f1e74c27a..c9884e8b59135e8a8f111130179e5fd5705f5fd8 100644 (file)
@@ -43,6 +43,10 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        int owidth = *width;
        int oheight = *height;
 
+       // Check for the special case - no aspect ratio means no problem :-)
+       if ( mlt_frame_get_aspect_ratio( this ) == 0 )
+               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) );
+
        // Hmmm...
        char *rescale = mlt_properties_get( properties, "rescale.interp" );
        if ( rescale != NULL && !strcmp( rescale, "none" ) )
@@ -61,6 +65,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        real_height = mlt_properties_get_int( properties, "height" );
                double input_ar = mlt_frame_get_aspect_ratio( this ) * real_width / real_height;
                double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight;
+
                
                //fprintf( stderr, "normalised %dx%d output %dx%d %f %f\n", normalised_width, normalised_height, owidth, oheight, ( float )output_ar, ( float )mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight );
 
@@ -74,7 +79,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        scaled_width = normalised_width;
                        scaled_height = output_ar / input_ar * normalised_height + 0.5;
                }
-       
+
                // Now calculate the actual image size that we want
                owidth = scaled_width * owidth / normalised_width;
                oheight = scaled_height * oheight / normalised_height;
index c1fa1681e3d558814e2f944b5540194a93711ccf..c2f645bcd0b236a73fd2f37ce655fe8e2b39ece1 100644 (file)
@@ -199,9 +199,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                // Obtain properties of producer
                mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
 
-               // Determine if we're producing PAL or NTSC
-               int is_pal = mlt_properties_get_double( producer_props, "fps" ) == 25.0;
-
                // Set the producer on the frame properties
                mlt_properties_set_data( properties, "producer_colour", producer, 0, NULL, NULL );
 
@@ -210,7 +207,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 );
+               mlt_properties_set_double( properties, "aspect_ratio", 0 );
 
                // colour is an alias for resource
                if ( mlt_properties_get( producer_props, "colour" ) != NULL )
index 8bc21c30e6ed422669bb4107234033fde857b2b5..1b71cda49638c967fb1d07712447c872107e812c 100644 (file)
@@ -151,14 +151,8 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index
                // Obtain properties of frame
                mlt_properties properties = MLT_FRAME_PROPERTIES( *frame );
 
-               // Obtain properties of producer
-               mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( this );
-
-               // Determine if we're producing PAL or NTSC
-               int is_pal = mlt_properties_get_double( producer_props, "fps" ) == 25.0;
-
-               // Aspect ratio is 1?
-               mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 );
+               // Aspect ratio is whatever it needs to be
+               mlt_properties_set_double( properties, "aspect_ratio", 0 );
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
index c8f58bd2081e5e391e6651485fddba5ab6d34fa3..dbb817e2ed5bbdf91bedaf19e825d9f0e5eee1bc 100644 (file)
@@ -280,7 +280,7 @@ static void consumer_encode_audio( mlt_consumer this, uint8_t *dv_frame, mlt_fra
                time_t start = time( NULL );
                int height = mlt_properties_get_int( this_properties, "height" );
                int is_pal = height == 576;
-               int is_wide = mlt_properties_get_double( frame_properties, "fps" ) == ( ( double ) 16.0 / 9.0 );
+               int is_wide = mlt_properties_get_int( this_properties, "display_ratio_num" ) == 16;
 
                // Temporary - audio buffer allocation
                int16_t *audio_buffers[ 4 ];
index 37b1abb2c086939ab15d500ce5477ef7f03b24f5..84082dbef78916ae07377c2d45b48f5142b103e4 100644 (file)
@@ -493,7 +493,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
        // Set producer-specific frame properties
        mlt_properties_set_int( properties, "progressive", 1 );
-       mlt_properties_set_double( properties, "aspect_ratio", 1 );
+       mlt_properties_set_double( properties, "aspect_ratio", 0 );
 
        // Set alpha call back
        ( *frame )->get_alpha_mask = producer_get_alpha_mask;
index e007ccd6df92ff770f30d95524414d46eda36ffa..df23189cf086fd0482e298a9c49054f6ba60a4de 100644 (file)
@@ -383,9 +383,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                // Obtain properties of frame and producer
                mlt_properties properties = MLT_FRAME_PROPERTIES( *frame );
 
-               // Determine if we're rendering for PAL or NTSC
-               int is_pal = mlt_properties_get_int( properties, "normalised_height" ) == 576;
-
                // Set the producer on the frame properties
                mlt_properties_set_data( properties, "producer_pixbuf", this, 0, NULL, NULL );
 
@@ -400,7 +397,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 );
+               mlt_properties_set_double( properties, "aspect_ratio", 1 );
 
                // Set alpha call back
                ( *frame )->get_alpha_mask = producer_get_alpha_mask;
index dd51d4b0784e67ca28526edd9ca3f185dcd350d4..a0dc3276676f4603ed72a322f7bfa44280cdf0f0 100644 (file)
@@ -14,6 +14,12 @@ CXXFLAGS+=`lqt-config --cflags`
 LDFLAGS+=`lqt-config --libs`
 endif
 
+ifdef HAVE_LIBDV
+CFLAGS += `pkg-config --cflags libdv`
+LDFLAGS += `pkg-config --libs libdv`
+endif
+
+
 SRCS := $(OBJS:.o=.c) $(CPPOBJS:.o=.cc)
 
 all:   $(TARGET)
index 1ed29ad18c2ddf6b740ac20e510d47ceaa0a2504..2ee0c99d9757a32da8f1122e71f573395560fa95 100644 (file)
 * Change log:
 * 
 * $Log$
+* Revision 1.2  2005/06/21 20:59:39  lilo_booter
+* src/framework/mlt_consumer.c src/framework/mlt_consumer.h
+* + Added a general profile handling for size, aspect ratio and display ratio
+*
+* src/framework/mlt_producer.c
+* + Correction to aspect ratio properties
+*
+* src/inigo/inigo.c
+* + Minimalist support for sdl_preview (still not very good)
+*
+* src/modules/avformat/consumer_avformat.c
+* + Takes consumer profile into account
+*
+* src/modules/core/filter_resize.c
+* + Corrections for synthesised producers and aspect ratio (inherits from consumer)
+*
+* src/modules/core/producer_colour.c
+* src/modules/core/producer_noise.c
+* src/modules/gtk2/producer_pango.c
+* + Ensures that resize picks up consumer aspect ratio
+*
+* src/modules/dv/consumer_libdv.c
+* + Honour wide screen output
+*
+* src/modules/gtk2/producer_pixbuf.c
+* + Correction for 1:1 aspect ratio
+*
+* src/modules/kino/Makefile
+* src/modules/kino/avi.cc
+* src/modules/kino/avi.h
+* src/modules/kino/configure
+* src/modules/kino/filehandler.cc
+* + Attempt to allow mov dv files to provide audio
+*
+* src/modules/sdl/consumer_sdl.c
+* src/modules/sdl/consumer_sdl_preview.c
+* src/modules/sdl/consumer_sdl_still.c
+* + Takes consumer profile into account
+*
 * Revision 1.1  2005/04/15 14:28:26  lilo_booter
 * Initial version
 *
@@ -376,7 +415,7 @@ void AVIFile::Init( int format, int sampleFrequency, int indexType )
        {
                indx[ i ] ->wLongsPerEntry = 4;
                indx[ i ] ->bIndexSubType = 0;
-               indx[ i ] ->bIndexType = AVI_INDEX_OF_INDEXES;
+               indx[ i ] ->bIndexType = KINO_AVI_INDEX_OF_INDEXES;
                indx[ i ] ->nEntriesInUse = 0;
                indx[ i ] ->dwReserved[ 0 ] = 0;
                indx[ i ] ->dwReserved[ 1 ] = 0;
@@ -983,7 +1022,7 @@ void AVIFile::FlushIndx( int stream )
 
        ix[ stream ] ->wLongsPerEntry = 2;
        ix[ stream ] ->bIndexSubType = 0;
-       ix[ stream ] ->bIndexType = AVI_INDEX_OF_CHUNKS;
+       ix[ stream ] ->bIndexType = KINO_AVI_INDEX_OF_CHUNKS;
        ix[ stream ] ->nEntriesInUse = 0;
        ix[ stream ] ->dwChunkId = indx[ stream ] ->dwChunkId;
        ix[ stream ] ->qwBaseOffset = offset + length;
index e7ce66cf83c4b6b8c8a613bdc211d54ca11815a1..68f2ea4ffad671398d3c94ca57e4c769bc312a1d 100644 (file)
 * Change log:
 * 
 * $Log$
+* Revision 1.3  2005/06/21 20:59:39  lilo_booter
+* src/framework/mlt_consumer.c src/framework/mlt_consumer.h
+* + Added a general profile handling for size, aspect ratio and display ratio
+*
+* src/framework/mlt_producer.c
+* + Correction to aspect ratio properties
+*
+* src/inigo/inigo.c
+* + Minimalist support for sdl_preview (still not very good)
+*
+* src/modules/avformat/consumer_avformat.c
+* + Takes consumer profile into account
+*
+* src/modules/core/filter_resize.c
+* + Corrections for synthesised producers and aspect ratio (inherits from consumer)
+*
+* src/modules/core/producer_colour.c
+* src/modules/core/producer_noise.c
+* src/modules/gtk2/producer_pango.c
+* + Ensures that resize picks up consumer aspect ratio
+*
+* src/modules/dv/consumer_libdv.c
+* + Honour wide screen output
+*
+* src/modules/gtk2/producer_pixbuf.c
+* + Correction for 1:1 aspect ratio
+*
+* src/modules/kino/Makefile
+* src/modules/kino/avi.cc
+* src/modules/kino/avi.h
+* src/modules/kino/configure
+* src/modules/kino/filehandler.cc
+* + Attempt to allow mov dv files to provide audio
+*
+* src/modules/sdl/consumer_sdl.c
+* src/modules/sdl/consumer_sdl_preview.c
+* src/modules/sdl/consumer_sdl_still.c
+* + Takes consumer profile into account
+*
 * Revision 1.2  2005/04/15 14:37:03  lilo_booter
 * Minor correction
 *
 
 #define AVI_SMALL_INDEX (0x01)
 #define AVI_LARGE_INDEX (0x02)
-#define AVI_INDEX_OF_INDEXES (0x00)
-#define AVI_INDEX_OF_CHUNKS (0x01)
+#define KINO_AVI_INDEX_OF_INDEXES (0x00)
+#define KINO_AVI_INDEX_OF_CHUNKS (0x01)
 #define AVI_INDEX_2FIELD (0x01)
 
 enum { AVI_PAL, AVI_NTSC, AVI_AUDIO_48KHZ, AVI_AUDIO_44KHZ, AVI_AUDIO_32KHZ };
index 7c57d91ab5a51e4e87789096a4fbd038ba8c9384..17c00f3e694dd0610a2e3bdb09f6789a35029e4f 100755 (executable)
@@ -6,12 +6,18 @@ then
        lqt-config --prefix > /dev/null 2>&1
        lqt_disabled=$?
 
+       pkg-config libdv 2> /dev/null
+       libdv_disabled=$?
+
        echo > config.h
        [ "$lqt_disabled" = "0" ] && echo "#define HAVE_LIBQUICKTIME" >> config.h
+       [ "$libdv_disabled" = "0" ] && echo "#define HAVE_LIBDV" >> config.h
        echo > config.mak
        [ "$lqt_disabled" = "0" ] && echo "HAVE_LIBQUICKTIME=1" >> config.mak
+       [ "$libdv_disabled" = "0" ] && echo "HAVE_LIBDV=1" >> config.mak
 
        [ "$lqt_disabled" != "0" ] && echo "- libquicktime not found: only enabling dv avi support"
+       [ "$libdv_disabled" != 0 -a "$lqt_disabled" = "0" ] && echo "- libdv not found: mov dv may not have audio"
 
        echo "kino                      libmltkino$LIBSUF" >> ../producers.dat
 fi
index 5c4de5249202a335e44265fa90dd11d82c3683e6..67412fda8cbdab34deecc949293d6a1200801934 100644 (file)
@@ -38,6 +38,11 @@ using std::setfill;
 #include <time.h>
 #include <sys/time.h>
 
+// libdv header files
+#ifdef HAVE_LIBDV
+#include <libdv/dv.h>
+#endif
+
 #include "filehandler.h"
 #include "error.h"
 #include "riff.h"
@@ -884,30 +889,24 @@ int QtHandler::GetFrame( uint8_t *data, int frameNum )
        quicktime_set_video_position( fd, frameNum, 0 );
        quicktime_read_frame( fd, data, 0 );
 
-#if 0
+#ifdef HAVE_LIBDV
        if ( quicktime_has_audio( fd ) )
        {
-               AudioInfo info;
-               double samples;
-
                if ( ! isFullyInitialized )
-               {
-                       cerr << ">>> using audio from separarate Quicktime audio track" << endl;
                        AllocateAudioBuffers();
-               }
 
-               info.channels = channels;
-               info.frequency = quicktime_sample_rate( fd, 0 );
-               samples = info.frequency / quicktime_frame_rate( fd, 0 );
-               info.samples = (int) samples;
+               int frequency = quicktime_sample_rate( fd, 0 );
+               int samples = ( int )( frequency / quicktime_frame_rate( fd, 0 ) );
                for ( int i = 0; i < channels; i++ )
                {
                        quicktime_set_audio_position( fd, ( int64_t )( frameNum * samples ), 0 );
                        quicktime_decode_audio( fd, audioChannelBuffer[ i ], NULL, (long) samples, i );
                }
-               frame.EncodeAudio( info, audioChannelBuffer );
+               dv_encoder_t *encoder = dv_encoder_new( 0, 0, 0 );
+               encoder->samples_this_frame = samples;
+               dv_encode_full_audio( encoder, audioChannelBuffer, channels, frequency, data );
+               dv_encoder_free( encoder );
        }
-       frame.ExtractHeader();
 #endif
 
        return 0;
index 91925c91c6b2670ed1526ab72c6787352a7079b8..62d33e78f576e8bb1100ac87d78295605853e0ea 100644 (file)
@@ -57,9 +57,8 @@ struct consumer_sdl_s
        pthread_cond_t video_cond;
        int window_width;
        int window_height;
-       float aspect_ratio;
-       float display_aspect;
-       double last_frame_aspect;
+       int previous_width;
+       int previous_height;
        int width;
        int height;
        int playing;
@@ -117,6 +116,9 @@ mlt_consumer consumer_sdl_init( char *arg )
                mlt_service service = MLT_CONSUMER_SERVICE( parent );
                this->properties = MLT_SERVICE_PROPERTIES( service );
 
+               // Default display aspect ratio
+               double display_ratio = mlt_properties_get_double( this->properties, "display_ratio" );
+               
                // Set the default volume
                mlt_properties_set_double( this->properties, "volume", 1.0 );
 
@@ -138,15 +140,9 @@ mlt_consumer consumer_sdl_init( char *arg )
                // Default audio buffer
                mlt_properties_set_int( this->properties, "audio_buffer", 512 );
 
-               // Get sample aspect ratio
-               this->aspect_ratio = mlt_properties_get_double( this->properties, "aspect_ratio" );
-
                // Ensure we don't join on a non-running object
                this->joined = 1;
                
-               // Default display aspect ratio
-               this->display_aspect = 4.0 / 3.0;
-               
                // process actual param
                if ( arg == NULL || sscanf( arg, "%dx%d", &this->width, &this->height ) != 2 )
                {
@@ -155,7 +151,7 @@ mlt_consumer consumer_sdl_init( char *arg )
                }
 
                // Default window size
-               this->window_width = ( float )this->height * this->display_aspect;
+               this->window_width = ( float )this->height * display_ratio;
                this->window_height = this->height;
 
                // Set the sdl flags
@@ -203,6 +199,11 @@ int consumer_start( mlt_consumer parent )
                        mlt_properties_set_int( this->properties, "width", this->width );
                        mlt_properties_set_int( this->properties, "height", this->height );
                }
+               else
+               {
+                       this->width = mlt_properties_get_int( this->properties, "width" );
+                       this->height = mlt_properties_get_int( this->properties, "height" );
+               }
 
                pthread_create( &this->thread, NULL, consumer_thread, this );
        }
@@ -461,8 +462,13 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        // Determine window's new display aspect ratio
                        float this_aspect = ( float )this->window_width / this->window_height;
 
+                       // Get the display aspect ratio
+                       double display_ratio = mlt_properties_get_double( properties, "display_ratio" );
+
                        // Determine frame's display aspect ratio
                        float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height;
+
+                       // Store the width and height received
                        this->width = width;
                        this->height = height;
 
@@ -470,42 +476,31 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        if ( mlt_properties_get( properties, "rescale" ) != NULL &&
                                !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) )
                        {
-                               // Special case optimisation to negate odd effect of sample aspect ratio
-                               // not corresponding exactly with image resolution.
-                               if ( ( (int)( this_aspect * 1000 ) == (int)( this->display_aspect * 1000 ) ) && 
-                                        ( (int)( mlt_frame_get_aspect_ratio( frame ) * 1000 ) == (int)( this->aspect_ratio * 1000 ) ) )
+                               // Use hardware scaler to normalise display aspect ratio
+                               this->rect.w = frame_aspect / this_aspect * this->window_width;
+                               this->rect.h = this->window_height;
+                               if ( this->rect.w > this->window_width )
                                {
                                        this->rect.w = this->window_width;
-                                       this->rect.h = this->window_height;
-                               }
-                               else
-                               {
-                                       // Use hardware scaler to normalise display aspect ratio
-                                       this->rect.w = frame_aspect / this_aspect * this->window_width;
-                                       this->rect.h = this->window_height;
-                                       if ( this->rect.w > this->window_width )
-                                       {
-                                               this->rect.w = this->window_width;
-                                               this->rect.h = this_aspect / frame_aspect * this->window_height;
-                                       }
+                                       this->rect.h = this_aspect / frame_aspect * this->window_height;
                                }
                        }
                        // Special case optimisation to negate odd effect of sample aspect ratio
                        // not corresponding exactly with image resolution.
-                       else if ( (int)( this_aspect * 1000 ) == (int)( this->display_aspect * 1000 ) ) 
+                       else if ( (int)( this_aspect * 1000 ) == (int)( display_ratio * 1000 ) ) 
                        {
                                this->rect.w = this->window_width;
                                this->rect.h = this->window_height;
                        }
                        // Use hardware scaler to normalise sample aspect ratio
-                       else if ( this->window_height * this->display_aspect > this->window_width )
+                       else if ( this->window_height * display_ratio > this->window_width )
                        {
                                this->rect.w = this->window_width;
-                               this->rect.h = this->window_width / this->display_aspect;
+                               this->rect.h = this->window_width / display_ratio;
                        }
                        else
                        {
-                               this->rect.w = this->window_height * this->display_aspect;
+                               this->rect.w = this->window_height * display_ratio;
                                this->rect.h = this->window_height;
                        }
                        
@@ -525,7 +520,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        SDL_SetClipRect( this->sdl_screen, &this->rect );
                        SDL_Flip( this->sdl_screen );
                        sdl_lock_display();
-                       this->sdl_overlay = SDL_CreateYUVOverlay( this->width, this->height, SDL_YUY2_OVERLAY, this->sdl_screen );
+                       this->sdl_overlay = SDL_CreateYUVOverlay( width, height, SDL_YUY2_OVERLAY, this->sdl_screen );
                        sdl_unlock_display();
                }
 
index 4e55bd6f99f7c382c116eee3e2558433834c01aa..eaaac2eb769636cdce631e569c4e7d597c9ed720 100644 (file)
@@ -232,6 +232,10 @@ static void *consumer_thread( void *arg )
        mlt_properties_set_int( still, "width", mlt_properties_get_int( properties, "width" ) );
        mlt_properties_set_int( play, "height", mlt_properties_get_int( properties, "height" ) );
        mlt_properties_set_int( still, "height", mlt_properties_get_int( properties, "height" ) );
+       mlt_properties_set_double( play, "aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) );
+       mlt_properties_set_double( still, "aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) );
+       mlt_properties_set_double( play, "display_ratio", mlt_properties_get_double( properties, "display_ratio" ) );
+       mlt_properties_set_double( still, "display_ratio", mlt_properties_get_double( properties, "display_ratio" ) );
 
        mlt_properties_set_int( play, "progressive", progressive );
        mlt_properties_set_int( still, "progressive", progressive );
index c76740a379bfbaca5701736e69f2643b1b645557..c0848dbec4e0b46c77bc699b6615f862df358e74 100644 (file)
@@ -45,9 +45,6 @@ struct consumer_sdl_s
        int running;
        int window_width;
        int window_height;
-       float aspect_ratio;
-       float display_aspect;
-       double last_frame_aspect;
        int width;
        int height;
        int playing;
@@ -86,13 +83,16 @@ mlt_consumer consumer_sdl_still_init( char *arg )
                // Get the parent consumer object
                mlt_consumer parent = &this->parent;
 
-               // We have stuff to clean up, so override the close method
-               parent->close = consumer_close;
-
                // get a handle on properties
                mlt_service service = MLT_CONSUMER_SERVICE( parent );
                this->properties = MLT_SERVICE_PROPERTIES( service );
 
+               // Get the default display ratio
+               double display_ratio = mlt_properties_get_double( this->properties, "display_ratio" );
+
+               // We have stuff to clean up, so override the close method
+               parent->close = consumer_close;
+
                // Default scaler (for now we'll use nearest)
                mlt_properties_set( this->properties, "rescale", "nearest" );
 
@@ -102,15 +102,9 @@ mlt_consumer consumer_sdl_still_init( char *arg )
                // Default progressive true
                mlt_properties_set_int( this->properties, "progressive", 1 );
 
-               // Get sample aspect ratio
-               this->aspect_ratio = mlt_properties_get_double( this->properties, "aspect_ratio" );
-
                // Ensure we don't join on a non-running object
                this->joined = 1;
                
-               // Default display aspect ratio
-               this->display_aspect = 4.0 / 3.0;
-               
                // process actual param
                if ( arg == NULL || sscanf( arg, "%dx%d", &this->width, &this->height ) != 2 )
                {
@@ -119,7 +113,7 @@ mlt_consumer consumer_sdl_still_init( char *arg )
                }
 
                // Default window size
-               this->window_width = ( float )this->height * this->display_aspect;
+               this->window_width = ( float )this->height * display_ratio;
                this->window_height = this->height;
 
                // Set the sdl flags
@@ -181,8 +175,6 @@ static int consumer_start( mlt_consumer parent )
                        mlt_properties_set_int( this->properties, "height", this->height );
                }
 
-               //this->width = this->height * this->display_aspect;
-
                pthread_create( &this->thread, NULL, consumer_thread, this );
        }
 
@@ -355,6 +347,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        int width = this->width;
        uint8_t *image = NULL;
        int changed = 0;
+       double display_ratio = mlt_properties_get_double( this->properties, "display_ratio" );
 
        void ( *lock )( void ) = mlt_properties_get_data( properties, "app_lock", NULL );
        void ( *unlock )( void ) = mlt_properties_get_data( properties, "app_unlock", NULL );
@@ -431,27 +424,15 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        this->last_producer = mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame ), "_producer", NULL );
 
        // Get the image, width and height
-       if ( image == NULL )
-       {
-               mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
-
-               // I would like to provide upstream scaling here, but this is incorrect
-               // Something? (or everything?) is too sensitive to aspect ratio
-               //width = this->rect.w;
-               //height = this->rect.h;
-               //mlt_properties_set( MLT_FRAME_PROPERTIES( frame ), "distort", "true" );
-               //mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "normalised_width", width );
-               //mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "normalised_height", height );
-
-               mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
-       }
+       mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
+       mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
 
        if ( image != NULL )
        {
                char *rescale = mlt_properties_get( properties, "rescale" );
                if ( rescale != NULL && strcmp( rescale, "none" ) )
                {
-                       float this_aspect = this->display_aspect / ( ( float )this->window_width / ( float )this->window_height );
+                       float this_aspect = display_ratio / ( ( float )this->window_width / ( float )this->window_height );
                        this->rect.w = this_aspect * this->window_width;
                        this->rect.h = this->window_height;
                        if ( this->rect.w > this->window_width )