From 35a62a5e6025c6807e1bdf86dd9abbc6fea74808 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 19 Mar 2013 00:15:17 +0100 Subject: Don't overwrite user-defined aspect ratio settings ass_set_storage_size() overwrote the user-defined aspect ratio set with ass_set_aspect_ratio(). Change it so that if ass_set_aspect_ratio() is used, the ass_set_storage_size() parameters are not used for any aspect ratio calculations. (The storage size is still used for calculating the blur scale.) This simplifies the code as well, because the aspect ratio is now centrally calculated in ass_start_frame(). Update the doxygen. Make it clear that ass_set_storage_size() will be used for aspect ratio calculation, unless ass_set_aspect_ratio() is used. Also mention what libass actually does with the dar and sar parameters: it uses them to calculate a pixel aspect ratio, nothing else. Explicitly allow resetting the storage size with w=h=0. Document that it's allowed to remove the user defined aspect ratio by setting a pixel aspedct ratio of 0. See issue 6. --- libass/ass_render.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index de27641..67ecb9c 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -2264,8 +2264,19 @@ ass_start_frame(ASS_Renderer *render_priv, ASS_Track *track, ass_shaper_set_level(render_priv->shaper, render_priv->settings.shaper); // PAR correction - render_priv->font_scale_x = render_priv->settings.aspect / - render_priv->settings.storage_aspect; + double par = render_priv->settings.par; + if (par == 0.) { + if (settings_priv->frame_width && settings_priv->frame_height && + settings_priv->storage_width && settings_priv->storage_height) { + double dar = ((double) settings_priv->frame_width) / + settings_priv->frame_height; + double sar = ((double) settings_priv->storage_width) / + settings_priv->storage_height; + par = sar / dar; + } else + par = 1.0; + } + render_priv->font_scale_x = par; render_priv->prev_images_root = render_priv->images_root; render_priv->images_root = 0; -- cgit v1.2.3