Commit d0fb2441 authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/image.c, src/video_output/vout_intf.c: handle aspect ratio changes...

* src/misc/image.c, src/video_output/vout_intf.c: handle aspect ratio changes in image_Convert() as well.
* modules/video_output/picture.c: set all the fields of fmt_in for image_Convert().
parent 23f94423
......@@ -2,7 +2,7 @@
* picture.c:
*****************************************************************************
* Copyright (C) 2004-2005 VideoLAN
* $Id: picture.c 10081 2005-03-01 15:33:51Z dionoea $
* $Id$
*
* Authors: Antoine Cellerier <dionoea@videolan.org>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -426,9 +426,7 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
picture_t *p_new_pic2;
#endif
fmt_in.i_chroma = p_vout->render.i_chroma;
fmt_in.i_width = p_vout->render.i_width;
fmt_in.i_height = p_vout->render.i_height;
fmt_in = p_vout->fmt_in;
#ifdef IMAGE_2PASSES
fmt_middle.i_chroma = p_vout->render.i_chroma;
......
......@@ -356,9 +356,28 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
void (*pf_release)( picture_t * );
picture_t *p_pif;
if( !p_fmt_out->i_width && !p_fmt_out->i_height &&
p_fmt_out->i_sar_num && p_fmt_out->i_sar_den &&
p_fmt_out->i_sar_num * p_fmt_in->i_sar_den !=
p_fmt_out->i_sar_den * p_fmt_in->i_sar_num )
{
p_fmt_out->i_width =
p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
p_fmt_in->i_width / p_fmt_in->i_sar_den / p_fmt_out->i_sar_num;
p_fmt_out->i_visible_width =
p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
p_fmt_in->i_visible_width / p_fmt_in->i_sar_den /
p_fmt_out->i_sar_num;
}
if( !p_fmt_out->i_chroma ) p_fmt_out->i_chroma = p_fmt_in->i_chroma;
if( !p_fmt_out->i_width ) p_fmt_out->i_width = p_fmt_in->i_width;
if( !p_fmt_out->i_height ) p_fmt_out->i_height = p_fmt_in->i_height;
if( !p_fmt_out->i_width )
p_fmt_out->i_width = p_fmt_out->i_visible_width = p_fmt_in->i_width;
if( !p_fmt_out->i_height )
p_fmt_out->i_height = p_fmt_out->i_visible_height = p_fmt_in->i_height;
if( !p_fmt_out->i_sar_num ) p_fmt_out->i_sar_num = p_fmt_in->i_sar_num;
if( !p_fmt_out->i_sar_den ) p_fmt_out->i_sar_den = p_fmt_in->i_sar_den;
if( !p_fmt_out->i_aspect ) p_fmt_out->i_aspect = p_fmt_in->i_aspect;
if( p_image->p_filter )
if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
......@@ -580,14 +599,29 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
{
p_enc->fmt_in.video.i_width = fmt_out->i_width;
p_enc->fmt_in.video.i_height = fmt_out->i_height;
if( fmt_out->i_visible_width > 0 &&
fmt_out->i_visible_height > 0 )
{
p_enc->fmt_in.video.i_visible_width = fmt_out->i_visible_width;
p_enc->fmt_in.video.i_visible_height = fmt_out->i_visible_height;
}
else
{
p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
}
}
else if( fmt_out->i_sar_num && fmt_out->i_sar_den &&
fmt_out->i_sar_num * fmt_in->i_sar_den !=
fmt_out->i_sar_num * fmt_in->i_sar_den !=
fmt_out->i_sar_den * fmt_in->i_sar_num )
{
p_enc->fmt_in.video.i_width =
fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
fmt_in->i_sar_den / fmt_out->i_sar_num;
p_enc->fmt_in.video.i_visible_width =
fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den *
fmt_in->i_visible_width / fmt_in->i_sar_den / fmt_out->i_sar_num;
}
p_enc->fmt_in.video.i_frame_rate = 25;
......
......@@ -361,11 +361,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
free( format.psz_string );
/* Save the snapshot */
fmt_in.i_chroma = p_vout->render.i_chroma;
fmt_in.i_width = p_vout->render.i_width;
fmt_in.i_height = p_vout->render.i_height;
fmt_in.i_sar_num = p_vout->fmt_render.i_sar_num;
fmt_in.i_sar_den = p_vout->fmt_render.i_sar_den;
fmt_in = p_vout->fmt_in;
fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
i_ret = image_WriteUrl( p_image, p_pic, &fmt_in, &fmt_out, psz_filename );
if( i_ret != VLC_SUCCESS )
......@@ -380,10 +376,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
free( psz_filename );
/* Inject a subpicture with the snapshot */
memset( &fmt_out, 0, sizeof(fmt_out) );
fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
fmt_out.i_width = fmt_out.i_visible_width = p_vout->render.i_width;
fmt_out.i_height = fmt_out.i_visible_height = p_vout->render.i_height;
fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
p_pif = image_Convert( p_image, p_pic, &fmt_in, &fmt_out );
image_HandlerDelete( p_image );
if( !p_pif ) return VLC_EGENERIC;
......
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