Commit 6e788757 authored by Sam Hocevar's avatar Sam Hocevar

* modules/demux/mkv.cpp: fix an issue with DAR vs. Canvas size with matroska

    files, backported from [16424].
parent a09c0325
...@@ -4309,6 +4309,8 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m ) ...@@ -4309,6 +4309,8 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
{ {
EbmlMaster *tkv = static_cast<EbmlMaster*>(l); EbmlMaster *tkv = static_cast<EbmlMaster*>(l);
unsigned int j; unsigned int j;
unsigned int i_crop_right = 0, i_crop_left = 0, i_crop_top = 0, i_crop_bottom = 0;
unsigned int i_display_unit = 0, i_display_width = 0, i_display_height = 0;
msg_Dbg( &sys.demuxer, "| | | + Track Video" ); msg_Dbg( &sys.demuxer, "| | | + Track Video" );
tk->f_fps = 0.0; tk->f_fps = 0.0;
...@@ -4350,44 +4352,42 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m ) ...@@ -4350,44 +4352,42 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
{ {
KaxVideoDisplayWidth &vwidth = *(KaxVideoDisplayWidth*)l; KaxVideoDisplayWidth &vwidth = *(KaxVideoDisplayWidth*)l;
tk->fmt.video.i_visible_width = uint16( vwidth ); i_display_width = uint16( vwidth );
msg_Dbg( &sys.demuxer, "| | | | + display width=%d", uint16( vwidth ) ); msg_Dbg( &sys.demuxer, "| | | | + display width=%d", uint16( vwidth ) );
} }
else if( MKV_IS_ID( l, KaxVideoDisplayHeight ) ) else if( MKV_IS_ID( l, KaxVideoDisplayHeight ) )
{ {
KaxVideoDisplayWidth &vheight = *(KaxVideoDisplayWidth*)l; KaxVideoDisplayWidth &vheight = *(KaxVideoDisplayWidth*)l;
tk->fmt.video.i_visible_height = uint16( vheight ); i_display_height = uint16( vheight );
msg_Dbg( &sys.demuxer, "| | | | + display height=%d", uint16( vheight ) ); msg_Dbg( &sys.demuxer, "| | | | + display height=%d", uint16( vheight ) );
} }
else if( MKV_IS_ID( l, KaxVideoPixelCropBottom ) ) else if( MKV_IS_ID( l, KaxVideoPixelCropBottom ) )
{ {
KaxVideoPixelCropBottom &cropval = *(KaxVideoPixelCropBottom*)l; KaxVideoPixelCropBottom &cropval = *(KaxVideoPixelCropBottom*)l;
tk->fmt.video.i_height -= uint16( cropval ); i_crop_bottom = uint16( cropval );
msg_Dbg( &sys.demuxer, "| | | | + crop pixel bottom=%d", uint16( cropval ) ); msg_Dbg( &sys.demuxer, "| | | | + crop pixel bottom=%d", uint16( cropval ) );
} }
else if( MKV_IS_ID( l, KaxVideoPixelCropTop ) ) else if( MKV_IS_ID( l, KaxVideoPixelCropTop ) )
{ {
KaxVideoPixelCropTop &cropval = *(KaxVideoPixelCropTop*)l; KaxVideoPixelCropTop &cropval = *(KaxVideoPixelCropTop*)l;
tk->fmt.video.i_height -= uint16( cropval ); i_crop_top = uint16( cropval );
tk->fmt.video.i_y_offset += uint16( cropval );
msg_Dbg( &sys.demuxer, "| | | | + crop pixel top=%d", uint16( cropval ) ); msg_Dbg( &sys.demuxer, "| | | | + crop pixel top=%d", uint16( cropval ) );
} }
else if( MKV_IS_ID( l, KaxVideoPixelCropRight ) ) else if( MKV_IS_ID( l, KaxVideoPixelCropRight ) )
{ {
KaxVideoPixelCropRight &cropval = *(KaxVideoPixelCropRight*)l; KaxVideoPixelCropRight &cropval = *(KaxVideoPixelCropRight*)l;
tk->fmt.video.i_width -= uint16( cropval ); i_crop_right = uint16( cropval );
msg_Dbg( &sys.demuxer, "| | | | + crop pixel right=%d", uint16( cropval ) ); msg_Dbg( &sys.demuxer, "| | | | + crop pixel right=%d", uint16( cropval ) );
} }
else if( MKV_IS_ID( l, KaxVideoPixelCropLeft ) ) else if( MKV_IS_ID( l, KaxVideoPixelCropLeft ) )
{ {
KaxVideoPixelCropLeft &cropval = *(KaxVideoPixelCropLeft*)l; KaxVideoPixelCropLeft &cropval = *(KaxVideoPixelCropLeft*)l;
tk->fmt.video.i_width -= uint16( cropval ); i_crop_left = uint16( cropval );
tk->fmt.video.i_x_offset += uint16( cropval );
msg_Dbg( &sys.demuxer, "| | | | + crop pixel left=%d", uint16( cropval ) ); msg_Dbg( &sys.demuxer, "| | | | + crop pixel left=%d", uint16( cropval ) );
} }
else if( MKV_IS_ID( l, KaxVideoFrameRate ) ) else if( MKV_IS_ID( l, KaxVideoFrameRate ) )
...@@ -4397,13 +4397,14 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m ) ...@@ -4397,13 +4397,14 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
tk->f_fps = float( vfps ); tk->f_fps = float( vfps );
msg_Dbg( &sys.demuxer, " | | | + fps=%f", float( vfps ) ); msg_Dbg( &sys.demuxer, " | | | + fps=%f", float( vfps ) );
} }
// else if( EbmlId( *l ) == KaxVideoDisplayUnit::ClassInfos.GlobalId ) else if( EbmlId( *l ) == KaxVideoDisplayUnit::ClassInfos.GlobalId )
// { {
// KaxVideoDisplayUnit &vdmode = *(KaxVideoDisplayUnit*)l; KaxVideoDisplayUnit &vdmode = *(KaxVideoDisplayUnit*)l;
// msg_Dbg( &sys.demuxer, "| | | | + Track Video Display Unit=%s", i_display_unit = uint8( vdmode );
// uint8( vdmode ) == 0 ? "pixels" : ( uint8( vdmode ) == 1 ? "centimeters": "inches" ) ); msg_Dbg( &sys.demuxer, "| | | | + Track Video Display Unit=%s",
// } uint8( vdmode ) == 0 ? "pixels" : ( uint8( vdmode ) == 1 ? "centimeters": "inches" ) );
}
// else if( EbmlId( *l ) == KaxVideoAspectRatio::ClassInfos.GlobalId ) // else if( EbmlId( *l ) == KaxVideoAspectRatio::ClassInfos.GlobalId )
// { // {
// KaxVideoAspectRatio &ratio = *(KaxVideoAspectRatio*)l; // KaxVideoAspectRatio &ratio = *(KaxVideoAspectRatio*)l;
...@@ -4414,15 +4415,26 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m ) ...@@ -4414,15 +4415,26 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
// { // {
// KaxVideoGamma &gamma = *(KaxVideoGamma*)l; // KaxVideoGamma &gamma = *(KaxVideoGamma*)l;
// msg_Dbg( &sys.demuxer, " | | | + fps=%f", float( gamma ) ); // msg_Dbg( &sys.demuxer, " | | | + gamma=%f", float( gamma ) );
// } // }
else else
{ {
msg_Dbg( &sys.demuxer, "| | | | + Unknown (%s)", typeid(*l).name() ); msg_Dbg( &sys.demuxer, "| | | | + Unknown (%s)", typeid(*l).name() );
} }
} }
if ( tk->fmt.video.i_visible_height && tk->fmt.video.i_visible_width ) if( i_display_height && i_display_width )
tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * tk->fmt.video.i_visible_width / tk->fmt.video.i_visible_height; tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * i_display_width / i_display_height;
if( i_crop_left || i_crop_right || i_crop_top || i_crop_bottom )
{
tk->fmt.video.i_visible_width = tk->fmt.video.i_width;
tk->fmt.video.i_visible_height = tk->fmt.video.i_height;
tk->fmt.video.i_x_offset = i_crop_left;
tk->fmt.video.i_y_offset = i_crop_top;
tk->fmt.video.i_visible_width -= i_crop_left + i_crop_right;
tk->fmt.video.i_visible_height -= i_crop_top + i_crop_bottom;
}
/* FIXME: i_display_* allows you to not only set DAR, but also a zoom factor.
we do not support this atm */
} }
else if( MKV_IS_ID( l, KaxTrackAudio ) ) else if( MKV_IS_ID( l, KaxTrackAudio ) )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment