- /* center the video in the dedicated rectangle */
- p_region->i_y = p_sys->i_yoffset
- + i_row * ( p_sys->i_height / p_sys->i_rows )
- + ( i_row * p_sys->i_borderh ) / p_sys->i_rows
- + ( row_inner_height - fmt_out.i_height ) / 2;
+ if( fmt_out.i_width > col_inner_width ||
+ p_sys->b_ar || p_sys->b_keep )
+ {
+ /* we don't have to center the video since it takes the
+ whole rectangle area or it's larger than the rectangle */
+ p_region->i_x = p_sys->i_xoffset
+ + i_col * ( p_sys->i_width / p_sys->i_cols )
+ + ( i_col * p_sys->i_borderw ) / p_sys->i_cols;
+ }
+ else
+ {
+ /* center the video in the dedicated rectangle */
+ p_region->i_x = p_sys->i_xoffset
+ + i_col * ( p_sys->i_width / p_sys->i_cols )
+ + ( i_col * p_sys->i_borderw ) / p_sys->i_cols
+ + ( col_inner_width - fmt_out.i_width ) / 2;
+ }
+
+ if( fmt_out.i_height > row_inner_height
+ || p_sys->b_ar || p_sys->b_keep )
+ {
+ /* we don't have to center the video since it takes the
+ whole rectangle area or it's taller than the rectangle */
+ p_region->i_y = p_sys->i_yoffset
+ + i_row * ( p_sys->i_height / p_sys->i_rows )
+ + ( i_row * p_sys->i_borderh ) / p_sys->i_rows;
+ }
+ else
+ {
+ /* center the video in the dedicated rectangle */
+ p_region->i_y = p_sys->i_yoffset
+ + i_row * ( p_sys->i_height / p_sys->i_rows )
+ + ( i_row * p_sys->i_borderh ) / p_sys->i_rows
+ + ( row_inner_height - fmt_out.i_height ) / 2;
+ }