Commit 3013997d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

video_format_TransformBy: fix and preserve video offsets

In general, the picture buffer contains, in memory order:
- cropped top scan lines,
- visible scan lines,
- cropped bottom scan lines,
- extra codec lines,
- padding lines.

This order needs to be preserved when flipping vertically or rotating
180 degrees, since filters and displays rely on this. In particular,
the picture plane structure so far has no provisions for non-zero
offsets, so filters expect visible pixels at the top left of each
pixels plane. Effectively, non-zero offsets only work for cropping
after filtering. Lets assume that the number of cropped lines are
identical at the top and bottom, and keep the X and Y offsets as are.

This fixes green lines at the bottom on R180 and VFLIP.

If support for non-centered cropping is ever required, I believe
offsets will need to be added to plane_t. This would break many video
filters though.
parent 7782614f
......@@ -339,52 +339,18 @@ void video_format_TransformBy( video_format_t *fmt, video_transform_t transform
}
/* Apply transform */
if( ORIENT_IS_SWAP( fmt->orientation ) != ORIENT_IS_SWAP( dst_orient ) )
{
video_format_t scratch = *fmt;
if( ORIENT_IS_SWAP( fmt->orientation ) != ORIENT_IS_SWAP( dst_orient )) {
fmt->i_width = scratch.i_height;
fmt->i_visible_width = scratch.i_visible_height;
fmt->i_height = scratch.i_width;
fmt->i_visible_height = scratch.i_visible_width;
fmt->i_sar_num = scratch.i_sar_den;
fmt->i_sar_den = scratch.i_sar_num;
}
unsigned int delta_y = scratch.i_height - scratch.i_visible_height - scratch.i_y_offset;
unsigned int delta_x = scratch.i_width - scratch.i_visible_width - scratch.i_x_offset;
switch ( transform )
{
case TRANSFORM_IDENTITY:
break;
case TRANSFORM_R90:
fmt->i_x_offset = delta_y;
fmt->i_y_offset = scratch.i_x_offset;
break;
case TRANSFORM_R180:
fmt->i_x_offset = delta_x;
fmt->i_y_offset = delta_y;
break;
case TRANSFORM_R270:
fmt->i_x_offset = scratch.i_y_offset;
fmt->i_y_offset = delta_x;
break;
case TRANSFORM_HFLIP:
fmt->i_x_offset = delta_x;
break;
case TRANSFORM_VFLIP:
fmt->i_y_offset = delta_y;
break;
case TRANSFORM_TRANSPOSE:
fmt->i_x_offset = scratch.i_y_offset;
fmt->i_y_offset = scratch.i_x_offset;
break;
case TRANSFORM_ANTI_TRANSPOSE:
fmt->i_x_offset = delta_y;
fmt->i_y_offset = delta_x;
break;
fmt->i_sar_num = scratch.i_sar_den;
fmt->i_sar_den = scratch.i_sar_num;
}
fmt->orientation = dst_orient;
......
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