- i_dst_width = 2 * (int)( p_sys->i_crop_width * f_scale_width / 2 + 0.5 );
- i_dst_height = 2 *
- (int)( p_sys->i_crop_height * f_scale_height / 2 + 0.5 );
-
- p_sys->i_nopadd_width = i_dst_width;
- p_sys->i_nopadd_height = i_dst_height;
- p_sys->i_dst_x_offset = 0;
- p_sys->i_dst_y_offset = 0;
-
- /* Handle canvas and padding */
- if( p_sys->i_canvas_width <= 0 )
- {
- /* No canvas width set, add explicit padding border */
- i_dst_width = p_sys->i_nopadd_width + ( p_sys->i_padd_left & ~1 ) +
- ( p_sys->i_padd_right & ~1 );
- p_sys->i_dst_x_offset = ( p_sys->i_padd_left & ~1 );
- }
- else
- {
- /* Canvas set, check if we have to padd or crop */
- if( p_sys->i_canvas_width < p_sys->i_nopadd_width )
- {
- /* need to crop more, but keep same scaling */
- int i_crop = 2 * (int)( ( p_sys->i_canvas_width & ~1 ) /
- f_scale_width / 2 + 0.5 );
-
- p_sys->i_src_x_offset += ( ( p_sys->i_crop_width - i_crop ) / 2 )
- & ~1;
- p_sys->i_crop_width = i_crop;
- i_dst_width = p_sys->i_canvas_width & ~1;
- p_sys->i_nopadd_width = i_dst_width;
- }
- else if( p_sys->i_canvas_width > p_sys->i_nopadd_width )
- {
- /* need to padd */
- i_dst_width = p_sys->i_canvas_width & ~1;
- p_sys->i_dst_x_offset = ( i_dst_width - p_sys->i_nopadd_width )/2;
- p_sys->i_dst_x_offset = p_sys->i_dst_x_offset & ~1;
- }
- }
-
- if( p_sys->i_canvas_height <= 0 )
- {
- /* No canvas set, add padding border */
- i_dst_height = p_sys->i_nopadd_height + ( p_sys->i_padd_top & ~1 ) +
- ( p_sys->i_padd_bottom & ~1 );
- p_sys->i_dst_y_offset = ( p_sys->i_padd_top & ~1 );
- }
- else
- {
- /* Canvas set, check if we have to padd or crop */
- if( p_sys->i_canvas_height < p_sys->i_nopadd_height )
- {
- /* need to crop more, but keep same scaling */
- int i_crop = 2 * (int)( ( p_sys->i_canvas_height & ~1 ) /
- f_scale_height / 2 + 0.5 );
-
- p_sys->i_src_y_offset += ( ( p_sys->i_crop_height - i_crop ) / 2 )
- & ~1;
- p_sys->i_crop_height = i_crop;
- i_dst_height = p_sys->i_canvas_height & ~1;
- p_sys->i_nopadd_height = i_dst_height;
- }
- else if( p_sys->i_canvas_height > p_sys->i_nopadd_height )
- {
- /* need to padd */
- i_dst_height = p_sys->i_canvas_height & ~1;
- p_sys->i_dst_y_offset = ( i_dst_height - p_sys->i_nopadd_height )
- /2;
- p_sys->i_dst_y_offset = p_sys->i_dst_y_offset & ~1;
- }
- }