vlc | branch: master | Laurent Aimar <[email protected]> | Sat Nov 13 20:40:42 2010 +0100| [9cf0b9d4e10fb6b2ec65de48a18fd2c6a4b1275d] | committer: Laurent Aimar
Added video_format_ScaleCropAr(). It computes correct crop/ar settings when scaling a video format. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9cf0b9d4e10fb6b2ec65de48a18fd2c6a4b1275d --- include/vlc_es.h | 5 +++++ src/libvlccore.sym | 1 + src/misc/es_format.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/include/vlc_es.h b/include/vlc_es.h index 3c80d57..0b41015 100644 --- a/include/vlc_es.h +++ b/include/vlc_es.h @@ -178,6 +178,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. */ diff --git a/src/libvlccore.sym b/src/libvlccore.sym index aec8a36..393c461 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -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 diff --git a/src/misc/es_format.c b/src/misc/es_format.c index e55ee2b..7830289 100644 --- a/src/misc/es_format.c +++ b/src/misc/es_format.c @@ -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; _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
