[FFmpeg-cvslog] lavfi/aspect: extend verbose feedback, show old SAR and DAR values

Stefano Sabatini git at videolan.org
Wed Apr 17 23:07:24 CEST 2013


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Apr 16 16:32:32 2013 +0200| [5229b78371643d33fc6a36f86f6342a85d304981] | committer: Stefano Sabatini

lavfi/aspect: extend verbose feedback, show old SAR and DAR values

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5229b78371643d33fc6a36f86f6342a85d304981
---

 libavfilter/vf_aspect.c |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c
index 2dadebd..939c966 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;
 }
 



More information about the ffmpeg-cvslog mailing list