[FFmpeg-cvslog] vf_setdar: make config_props work properly when called multiple times.

Anton Khirnov git at videolan.org
Fri May 17 11:40:18 CEST 2013


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Mar 18 21:31:54 2013 +0100| [d5c66d9c561283b4c9e862ce185fead8f27f37ce] | committer: Anton Khirnov

vf_setdar: make config_props work properly when called multiple times.

Do not overwrite the variable set through AVOptions.

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

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

diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c
index 50b4a7f..11cd000 100644
--- a/libavfilter/vf_aspect.c
+++ b/libavfilter/vf_aspect.c
@@ -35,7 +35,8 @@
 
 typedef struct {
     const AVClass *class;
-    AVRational aspect;
+    AVRational dar;
+    AVRational sar;
 #if FF_API_OLD_FILTER_OPTS
     float aspect_num, aspect_den;
 #endif
@@ -49,7 +50,7 @@ static av_cold int init(AVFilterContext *ctx)
     if (s->aspect_num > 0 && s->aspect_den > 0) {
         av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use "
                "dar=<number> or dar=num/den.\n");
-        s->aspect = av_d2q(s->aspect_num / s->aspect_den, INT_MAX);
+        s->sar = s->dar = av_d2q(s->aspect_num / s->aspect_den, INT_MAX);
     }
 
     return 0;
@@ -60,7 +61,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
 {
     AspectContext *s = link->dst->priv;
 
-    frame->sample_aspect_ratio = s->aspect;
+    frame->sample_aspect_ratio = s->sar;
     return ff_filter_frame(link->dst->outputs[0], frame);
 }
 
@@ -72,13 +73,14 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
 static int setdar_config_props(AVFilterLink *inlink)
 {
     AspectContext *s = inlink->dst->priv;
-    AVRational dar = s->aspect;
-
-    if (s->aspect.num && s->aspect.den) {
-        av_reduce(&s->aspect.num, &s->aspect.den,
-                   s->aspect.num * inlink->h,
-                   s->aspect.den * inlink->w, 100);
-        inlink->sample_aspect_ratio = s->aspect;
+    AVRational dar;
+
+    if (s->dar.num && s->dar.den) {
+        av_reduce(&s->sar.num, &s->sar.den,
+                   s->dar.num * inlink->h,
+                   s->dar.den * inlink->w, 100);
+        inlink->sample_aspect_ratio = s->sar;
+        dar = s->dar;
     } else {
         inlink->sample_aspect_ratio = (AVRational){ 1, 1 };
         dar = (AVRational){ inlink->w, inlink->h };
@@ -96,7 +98,7 @@ static const AVOption setdar_options[] = {
     { "dar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
     { "dar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
 #endif
-    { "dar", "display aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
+    { "dar", "display aspect ratio", OFFSET(dar), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
     { NULL },
 };
 
@@ -149,7 +151,7 @@ static int setsar_config_props(AVFilterLink *inlink)
 {
     AspectContext *s = inlink->dst->priv;
 
-    inlink->sample_aspect_ratio = s->aspect;
+    inlink->sample_aspect_ratio = s->sar;
 
     return 0;
 }
@@ -159,7 +161,7 @@ static const AVOption setsar_options[] = {
     { "sar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
     { "sar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
 #endif
-    { "sar", "sample (pixel) aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, INT_MAX, FLAGS },
+    { "sar", "sample (pixel) aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, INT_MAX, FLAGS },
     { NULL },
 };
 



More information about the ffmpeg-cvslog mailing list