diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-04-16 18:32:32 +0400 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-04-18 00:39:26 +0400 |
commit | 5229b78371643d33fc6a36f86f6342a85d304981 (patch) | |
tree | b8643488362dfbf3344700ffb1dd625aa2bd430d /libavfilter | |
parent | fe5ca6b91371cf938a4b84aa688598e45b4540c7 (diff) |
lavfi/aspect: extend verbose feedback, show old SAR and DAR values
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_aspect.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c index 2dadebd7e5..939c966834 100644 --- a/libavfilter/vf_aspect.c +++ b/libavfilter/vf_aspect.c @@ -79,12 +79,22 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) #define OFFSET(x) offsetof(AspectContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +static inline void compute_dar(AVRational *dar, AVRational sar, int w, int h) +{ + if (sar.num && sar.den) { + av_reduce(&dar->num, &dar->den, sar.num * w, sar.den * h, INT_MAX); + } else { + av_reduce(&dar->num, &dar->den, w, h, INT_MAX); + } +} + #if CONFIG_SETDAR_FILTER static int setdar_config_props(AVFilterLink *inlink) { AspectContext *aspect = inlink->dst->priv; - AVRational dar = aspect->aspect; + AVRational dar = aspect->aspect, old_dar; + AVRational old_sar = inlink->sample_aspect_ratio; if (aspect->aspect.num && aspect->aspect.den) { av_reduce(&aspect->aspect.num, &aspect->aspect.den, @@ -96,9 +106,10 @@ static int setdar_config_props(AVFilterLink *inlink) dar = (AVRational){ inlink->w, inlink->h }; } - av_log(inlink->dst, AV_LOG_VERBOSE, "w:%d h:%d -> dar:%d/%d sar:%d/%d\n", - inlink->w, inlink->h, dar.num, dar.den, - inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den); + compute_dar(&old_dar, old_sar, inlink->w, inlink->h); + av_log(inlink->dst, AV_LOG_VERBOSE, "w:%d h:%d dar:%d/%d sar:%d/%d -> dar:%d/%d sar:%d/%d\n", + inlink->w, inlink->h, old_dar.num, old_dar.den, old_sar.num, old_sar.den, + dar.den, dar.num, inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den); return 0; } @@ -152,13 +163,20 @@ AVFilter avfilter_vf_setdar = { #if CONFIG_SETSAR_FILTER - static int setsar_config_props(AVFilterLink *inlink) { AspectContext *aspect = inlink->dst->priv; + AVRational old_sar = inlink->sample_aspect_ratio; + AVRational old_dar, dar; inlink->sample_aspect_ratio = aspect->aspect; + compute_dar(&old_dar, old_sar, inlink->w, inlink->h); + compute_dar(&dar, aspect->aspect, inlink->w, inlink->h); + av_log(inlink->dst, AV_LOG_VERBOSE, "w:%d h:%d sar:%d/%d dar:%d/%d -> sar:%d/%d dar:%d/%d\n", + inlink->w, inlink->h, old_sar.num, old_sar.den, old_dar.num, old_dar.den, + inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den, dar.num, dar.den); + return 0; } |