wall.c: handle some rounding error causing a integer overflow. more window

size constrain fixes
parent 75dd79c4
...@@ -246,31 +246,37 @@ static int Init( vout_thread_t *p_vout ) ...@@ -246,31 +246,37 @@ static int Init( vout_thread_t *p_vout )
var_Create( p_vout, "align", VLC_VAR_INTEGER ); var_Create( p_vout, "align", VLC_VAR_INTEGER );
w1 = p_vout->output.i_width / p_vout->p_sys->i_col; w1 = p_vout->output.i_width / p_vout->p_sys->i_col;
h1 = w1 * VOUT_ASPECT_FACTOR / i_aspect; w1 &= ~1;
w1 &= ~1; h1 &= ~1; h1 = w1 * VOUT_ASPECT_FACTOR / i_aspect&~1;
h1 &= ~1;
h2 = p_vout->output.i_height / p_vout->p_sys->i_row; h2 = p_vout->output.i_height / p_vout->p_sys->i_row&~1;
w2 = h2 * i_aspect / VOUT_ASPECT_FACTOR; h2 &= ~1;
w2 &= ~1; h2 &= ~1; w2 = h2 * i_aspect / VOUT_ASPECT_FACTOR&~1;
w2 &= ~1;
if ( h1 * p_vout->p_sys->i_row < p_vout->output.i_height ) if ( h1 * p_vout->p_sys->i_row < p_vout->output.i_height )
{ {
int i_tmp;
i_target_width = w2; i_target_width = w2;
i_target_height = h2; i_target_height = h2;
i_vstart = 0; i_vstart = 0;
i_vend = p_vout->output.i_height; i_vend = p_vout->output.i_height;
i_hstart = ( i_target_width * p_vout->p_sys->i_col i_tmp = i_target_width * p_vout->p_sys->i_col;
- p_vout->output.i_width ) / 2; while( i_tmp < p_vout->output.i_width ) i_tmp += p_vout->p_sys->i_col;
i_hstart = (( i_tmp - p_vout->output.i_width ) / 2)&~1;
i_hend = i_hstart + p_vout->output.i_width; i_hend = i_hstart + p_vout->output.i_width;
} }
else else
{ {
int i_tmp;
i_target_height = h1; i_target_height = h1;
i_target_width = w1; i_target_width = w1;
i_hstart = 0; i_hstart = 0;
i_hend = p_vout->output.i_width; i_hend = p_vout->output.i_width;
i_vstart = ( i_target_height * p_vout->p_sys->i_row i_tmp = i_target_height * p_vout->p_sys->i_row;
- p_vout->output.i_height ) / 2; while( i_tmp < p_vout->output.i_height ) i_tmp += p_vout->p_sys->i_row;
i_vstart = ( ( i_tmp - p_vout->output.i_height ) / 2 ) & ~1;
i_vend = i_vstart + p_vout->output.i_height; i_vend = i_vstart + p_vout->output.i_height;
} }
msg_Dbg( p_vout, "target resolution %dx%d", i_target_width, i_target_height ); msg_Dbg( p_vout, "target resolution %dx%d", i_target_width, i_target_height );
......
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