]> git.sesse.net Git - mlt/commitdiff
profiles/dv_*, consumer_avformat.c, producer_avformat.c: bugfix (1912796) to override...
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 15 May 2008 02:47:37 +0000 (02:47 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 15 May 2008 02:47:37 +0000 (02:47 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1126 d19143bc-622f-0410-bfdd-b5b2a6649095

profiles/dv_ntsc
profiles/dv_ntsc_wide
profiles/dv_pal
profiles/dv_pal_wide
src/modules/avformat/consumer_avformat.c
src/modules/avformat/producer_avformat.c

index c5462ddd8433740038c8b478250b43ae0edf7fa9..ff1f24e6fc2c9fa7fdeb4d20736f25933fc69bb8 100644 (file)
@@ -4,7 +4,7 @@ frame_rate_den=1001
 width=720
 height=480
 progressive=0
-sample_aspect_num=10
-sample_aspect_den=11
+sample_aspect_num=8
+sample_aspect_den=9
 display_aspect_num=4
 display_aspect_den=3
index 6c98e4f8fb874c23c4b2e704d57d20be707f32fb..d512d6ce73449b9ba71c7074de4f9c77068a6090 100644 (file)
@@ -4,7 +4,7 @@ frame_rate_den=1001
 width=720
 height=480
 progressive=0
-sample_aspect_num=40
-sample_aspect_den=33
+sample_aspect_num=32
+sample_aspect_den=27
 display_aspect_num=16
 display_aspect_den=9
index 33e82bc2f8b05eb6d033aeefa75a8430d62053aa..d56914003a408d4a23e1866e32ce249db689b203 100644 (file)
@@ -4,7 +4,7 @@ frame_rate_den=1
 width=720
 height=576
 progressive=0
-sample_aspect_num=59
-sample_aspect_den=54
+sample_aspect_num=16
+sample_aspect_den=15
 display_aspect_num=4
 display_aspect_den=3
index a4b669c5b580257f834305e1e3ad6f85fa363f96..a52b9cff7b6da6fa5e5b2ff32cb093022085a7c6 100644 (file)
@@ -4,7 +4,7 @@ frame_rate_den=1
 width=720
 height=576
 progressive=0
-sample_aspect_num=118
-sample_aspect_den=81
+sample_aspect_num=64
+sample_aspect_den=45
 display_aspect_num=16
 display_aspect_den=9
index d2c6fe137f33ea32be1268c7454d92f9e6f69dfc..93b8652bad87b483904bf382899e690660cf9ebe 100644 (file)
@@ -429,7 +429,7 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c
        if ( st != NULL ) 
        {
                char *pix_fmt = mlt_properties_get( properties, "pix_fmt" );
-               double ar = mlt_properties_get_double( properties, "display_ratio" );
+               double ar = mlt_properties_get_double( properties, "aspect_ratio" );
                AVCodecContext *c = st->codec;
 
                // Establish defaults from AVOptions
@@ -451,11 +451,44 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c
                // Set options controlled by MLT
                c->width = mlt_properties_get_int( properties, "width" );
                c->height = mlt_properties_get_int( properties, "height" );
-               c->sample_aspect_ratio = av_d2q( ar * c->height / c->width , 255);
                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->pix_fmt = pix_fmt ? avcodec_get_pix_fmt( pix_fmt ) : PIX_FMT_YUV420P;
 
+               if ( codec_id == CODEC_ID_DVVIDEO )
+               {
+                       // Compensate for FFmpeg's notion of DV aspect ratios, which are
+                       // based upon a width of 704. Since we do not have a normaliser
+                       // that crops (nor is cropping 720 wide ITU-R 601 video always desirable)
+                       // we just coerce the values to facilitate a passive behaviour through
+                       // the rescale normaliser when using equivalent producers and consumers.
+                       // = display_aspect / (width * height)
+                       if ( ar == 8.0/9.0 )  // 4:3 NTSC
+                       {
+                               c->sample_aspect_ratio.num = 10;
+                               c->sample_aspect_ratio.den = 11;
+                       }
+                       else if ( ar == 16.0/15.0 ) // 4:3 PAL
+                       {
+                               c->sample_aspect_ratio.num = 159;
+                               c->sample_aspect_ratio.den = 54;
+                       }
+                       else if ( ar == 32.0/27.0 ) // 16:9 NTSC
+                       {
+                               c->sample_aspect_ratio.num = 40;
+                               c->sample_aspect_ratio.den = 33;
+                       }
+                       else // 16:9 PAL
+                       {
+                               c->sample_aspect_ratio.num = 118;
+                               c->sample_aspect_ratio.den = 81;
+                       }
+               }
+               else
+               {
+                       c->sample_aspect_ratio = av_d2q( ar * c->height / c->width , 255);
+               }
+
                if ( mlt_properties_get_double( properties, "qscale" ) > 0 )
                {
                        c->flags |= CODEC_FLAG_QSCALE;
index d42a307ee0f088c87386936bb7dda699703cae79..5103798108981b7d5df5082f929bbec7e8f1c831 100644 (file)
@@ -640,7 +640,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                        if ( got_picture )
                        {
                                mlt_properties_set_int( frame_properties, "progressive", !av_frame->interlaced_frame );
-                               mlt_properties_set_int( frame_properties, "top_field_first", av_frame->top_field_first );
                                mlt_properties_set_int( properties, "top_field_first", av_frame->top_field_first );
                                convert_image( av_frame, *buffer, codec_context->pix_fmt, *format, *width, *height );
                                mlt_properties_set_data( frame_properties, "image", *buffer, size, (mlt_destructor)mlt_pool_release, NULL );
@@ -729,6 +728,28 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame )
                        double force_aspect_ratio = mlt_properties_get_double( properties, "force_aspect_ratio" );
                        double aspect_ratio;
 
+                       if ( strcmp( codec_context->codec->name, "dvvideo" ) == 0 )
+                       {
+                               // Override FFmpeg's notion of DV aspect ratios, which are
+                               // based upon a width of 704. Since we do not have a normaliser
+                               // that crops (nor is cropping 720 wide ITU-R 601 video always desirable)
+                               // we just coerce the values to facilitate a passive behaviour through
+                               // the rescale normaliser when using equivalent producers and consumers.
+                               // = display_aspect / (width * height)
+                               if ( codec_context->sample_aspect_ratio.num == 10 &&
+                                       codec_context->sample_aspect_ratio.den == 11 )
+                                       force_aspect_ratio = 8.0/9.0; // 4:3 NTSC
+                               else if ( codec_context->sample_aspect_ratio.num == 59 &&
+                                       codec_context->sample_aspect_ratio.den == 54 )
+                                       force_aspect_ratio = 16.0/15.0; // 4:3 PAL
+                               else if ( codec_context->sample_aspect_ratio.num == 40 &&
+                                       codec_context->sample_aspect_ratio.den == 33 )
+                                       force_aspect_ratio = 32.0/27.0; // 16:9 NTSC
+                               else if ( codec_context->sample_aspect_ratio.num == 118 &&
+                                       codec_context->sample_aspect_ratio.den == 81 )
+                                       force_aspect_ratio = 64.0/45.0; // 16:9 PAL
+                       }
+
                        // XXX: We won't know the real aspect ratio until an image is decoded
                        // but we do need it now (to satisfy filter_resize) - take a guess based
                        // on pal/ntsc
@@ -742,8 +763,7 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame )
                        }
                        else
                        {
-                               int is_pal = mlt_producer_get_fps( this ) == 25.0;
-                               aspect_ratio = is_pal ? 59.0/54.0 : 10.0/11.0;
+                               aspect_ratio = 1.0;
                        }
 
                        // Determine the fps