Commit 49f85e90 authored by Erwan Tulou's avatar Erwan Tulou Committed by Jean-Baptiste Kempf

snapshot core : correct aspect ratio issue (trac #2705)

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent cb9e93bf
......@@ -1213,6 +1213,9 @@ static void* RunThread( void *p_this )
picture_Copy( p_pic, p_directbuffer );
p_pic->format.i_sar_num = p_vout->fmt_out.i_sar_num;
p_pic->format.i_sar_den = p_vout->fmt_out.i_sar_den;
p_pic->p_next = p_vout->p->snapshot.p_picture;
p_vout->p->snapshot.p_picture = p_pic;
p_vout->p->snapshot.i_request--;
......
......@@ -1114,30 +1114,37 @@ int picture_Export( vlc_object_t *p_obj,
fmt_out.i_sar_num =
fmt_out.i_sar_den = 1;
fmt_out.i_chroma = i_format;
fmt_out.i_width = i_override_width;
fmt_out.i_height = i_override_height;
if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
/* compute original width/height */
unsigned int i_original_width;
unsigned int i_original_height;
if( fmt_in.i_sar_num >= fmt_in.i_sar_den )
{
fmt_out.i_height = fmt_in.i_height * fmt_out.i_width / fmt_in.i_width;
const int i_height = fmt_out.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
if( i_height > 0 )
fmt_out.i_height = i_height;
i_original_width = fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
i_original_height = fmt_in.i_height;
}
else
{
if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
{
fmt_out.i_width = fmt_in.i_width * fmt_out.i_height / fmt_in.i_height;
i_original_width = fmt_in.i_width;
i_original_height = fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
}
else
/* */
fmt_out.i_width = ( i_override_width < 0 ) ?
i_original_width : i_override_width;
fmt_out.i_height = ( i_override_height < 0 ) ?
i_original_height : i_override_height;
/* scale if only one direction is provided */
if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
{
fmt_out.i_width = fmt_in.i_width;
fmt_out.i_height = fmt_in.i_height;
fmt_out.i_height = fmt_in.i_height * fmt_out.i_width
* fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num;
}
const int i_width = fmt_out.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
if( i_width > 0 )
fmt_out.i_width = i_width;
else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
{
fmt_out.i_width = fmt_in.i_width * fmt_out.i_height
* fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den;
}
image_handler_t *p_image = image_HandlerCreate( p_obj );
......
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