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
// 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;
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 );
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
}
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