---
 libavfilter/vf_scale.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index c47c6f3..7c817a5 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -103,6 +103,7 @@ static av_cold int init(AVFilterContext *ctx)
             return ret;
     }
 
+    scale->sws = NULL;
     return 0;
 }
 
@@ -224,19 +225,12 @@ static int config_props(AVFilterLink *outlink)
     scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL ||
                           desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL;
 
-    if (scale->sws)
-        sws_freeContext(scale->sws);
-    if (inlink->w == outlink->w && inlink->h == outlink->h &&
-        inlink->format == outlink->format)
-        scale->sws = NULL;
-    else {
-        scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format,
-                                    outlink->w, outlink->h, outlink->format,
-                                    scale->flags, NULL, NULL, NULL);
-        if (!scale->sws)
-            return AVERROR(EINVAL);
-    }
-
+    scale->sws = sws_getCachedContext(scale->sws, inlink ->w, inlink ->h,
+                                      inlink ->format, outlink->w, outlink->h,
+                                      outlink->format, scale->flags,
+                                      NULL, NULL, NULL);
+    if (!scale->sws)
+        return AVERROR(EINVAL);
 
     if (inlink->sample_aspect_ratio.num)
         outlink->sample_aspect_ratio = 
av_mul_q((AVRational){outlink->h*inlink->w,
-- 
1.8.3.4 (Apple Git-47)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to