Commit 9cf0b9d4 authored by Laurent Aimar's avatar Laurent Aimar

Added video_format_ScaleCropAr().

It computes correct crop/ar settings when scaling a video format.
parent 351139f5
......@@ -177,6 +177,11 @@ VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma,
*/
VLC_EXPORT( void, video_format_CopyCrop, ( video_format_t *, const video_format_t * ) );
/**
* It will compute the crop/ar properties when scaling.
*/
VLC_EXPORT( void, video_format_ScaleCropAr, ( video_format_t *, const video_format_t * ) );
/**
* This function will check if the first video format is similar
* to the second one.
......
......@@ -486,6 +486,7 @@ var_Type
var_Inherit
var_InheritURational
video_format_CopyCrop
video_format_ScaleCropAr
video_format_FixRgb
video_format_IsSimilar
video_format_Setup
......
......@@ -215,6 +215,24 @@ void video_format_CopyCrop( video_format_t *p_dst, const video_format_t *p_src )
p_dst->i_visible_height = p_src->i_visible_height;
}
void video_format_ScaleCropAr( video_format_t *p_dst, const video_format_t *p_src )
{
p_dst->i_x_offset = (uint64_t)p_src->i_x_offset * p_dst->i_width / p_src->i_width;
p_dst->i_y_offset = (uint64_t)p_src->i_y_offset * p_dst->i_height / p_src->i_height;
p_dst->i_visible_width = (uint64_t)p_src->i_visible_width * p_dst->i_width / p_src->i_width;
p_dst->i_visible_height = (uint64_t)p_src->i_visible_height * p_dst->i_height / p_src->i_height;
p_dst->i_sar_num *= p_src->i_width;
p_dst->i_sar_den *= p_dst->i_width;
vlc_ureduce(&p_dst->i_sar_num, &p_dst->i_sar_den,
p_dst->i_sar_num, p_dst->i_sar_den, 65536);
p_dst->i_sar_num *= p_dst->i_height;
p_dst->i_sar_den *= p_src->i_height;
vlc_ureduce(&p_dst->i_sar_num, &p_dst->i_sar_den,
p_dst->i_sar_num, p_dst->i_sar_den, 65536);
}
bool video_format_IsSimilar( const video_format_t *p_fmt1, const video_format_t *p_fmt2 )
{
video_format_t v1 = *p_fmt1;
......
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