Commit e3b809c1 authored by Maxim Bublis's avatar Maxim Bublis Committed by Jean-Baptiste Kempf

misc/image: fixed overwriting of correct visible dimensions

In some cases fmt_in already contains correct i_visible_width and i_visible_height values.
This patch fixes incorrect overwriting of valid values.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent a9712eb1
......@@ -707,34 +707,39 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
p_enc->p_module = NULL;
es_format_Init( &p_enc->fmt_in, VIDEO_ES, fmt_in->i_chroma );
p_enc->fmt_in.video = *fmt_in;
if( fmt_out->i_width > 0 && fmt_out->i_height > 0 )
{
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 )
if( p_enc->fmt_in.video.i_visible_width == 0 ||
p_enc->fmt_in.video.i_visible_height == 0 )
{
if( fmt_out->i_width > 0 && fmt_out->i_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;
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
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_den * fmt_in->i_sar_num )
{
p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
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_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;
}
}
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_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_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;
p_enc->fmt_in.video.i_frame_rate_base = 1;
......
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