And mark it as such
---
 cmdutils.c                |  4 ++--
 doc/examples/output.c     | 21 ++++++++++-----------
 libavcodec/avcodec.h      |  1 +
 libswscale/swscale-test.c | 19 ++++++++++---------
 libswscale/swscale.h      |  1 +
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index a1e5116..931055a 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -63,8 +63,8 @@ static const int this_year = 2014;
 void init_opts(void)
 {
 #if CONFIG_SWSCALE
-    sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
-                              NULL, NULL, NULL);
+    sws_opts = sws_getCachedContext(NULL, 16, 16, 0, 16, 16, 0, SWS_BICUBIC,
+                                    NULL, NULL, NULL);
 #endif
 }
 
diff --git a/doc/examples/output.c b/doc/examples/output.c
index dd0e6a2..06912a2 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -309,7 +309,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream 
*st)
 {
     int ret;
     AVCodecContext *c;
-    static struct SwsContext *img_convert_ctx;
+    static struct SwsContext *img_convert_ctx = NULL;
 
     c = st->codec;
 
@@ -321,17 +321,16 @@ static void write_video_frame(AVFormatContext *oc, 
AVStream *st)
         if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
             /* as we only generate a YUV420P picture, we must convert it
              * to the codec pixel format if needed */
+            img_convert_ctx = sws_getCachedContext(img_convert_ctx,
+                                                   c->width, c->height,
+                                                   AV_PIX_FMT_YUV420P,
+                                                   c->width, c->height,
+                                                   c->pix_fmt, sws_flags,
+                                                   NULL, NULL, NULL);
             if (img_convert_ctx == NULL) {
-                img_convert_ctx = sws_getContext(c->width, c->height,
-                                                 AV_PIX_FMT_YUV420P,
-                                                 c->width, c->height,
-                                                 c->pix_fmt,
-                                                 sws_flags, NULL, NULL, NULL);
-                if (img_convert_ctx == NULL) {
-                    fprintf(stderr,
-                            "Cannot initialize the conversion context\n");
-                    exit(1);
-                }
+                fprintf(stderr,
+                        "Cannot initialize the conversion context\n");
+                exit(1);
             }
             fill_yuv_image(tmp_picture, frame_count, c->width, c->height);
             sws_scale(img_convert_ctx, tmp_picture->data, 
tmp_picture->linesize,
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 707abe5..c72f51a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2716,6 +2716,7 @@ typedef struct AVCodec {
 #endif
     const AVClass *priv_class;              ///< AVClass for the private 
context
     const AVProfile *profiles;              ///< array of recognized profiles, 
or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+    const enum AVColorRange *color_range;    ///< array of supported color 
ranges of pix_fmts, or NULL if unknown, array is terminated by -1
 
     /*****************************************************************
      * No fields below this line are part of the public API. They
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c
index 12fa9ed..5569a25 100644
--- a/libswscale/swscale-test.c
+++ b/libswscale/swscale-test.c
@@ -114,8 +114,9 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, 
int h,
                 goto end;
             }
         }
-        srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
-                                    srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
+        srcContext = sws_getCachedContext(NULL, w, h, AV_PIX_FMT_YUVA420P,
+                                          srcW, srcH, srcFormat, SWS_BILINEAR,
+                                          NULL, NULL, NULL);
         if (!srcContext) {
             fprintf(stderr, "Failed to get %s ---> %s\n",
                     desc_yuva420p->name,
@@ -149,8 +150,8 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, 
int h,
         }
     }
 
-    dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
-                                flags, NULL, NULL, NULL);
+    dstContext = sws_getCachedContext(NULL, srcW, srcH, srcFormat, dstW, dstH,
+                                      dstFormat, flags, NULL, NULL, NULL);
     if (!dstContext) {
         fprintf(stderr, "Failed to get %s ---> %s\n",
                 desc_src->name, desc_dst->name);
@@ -185,9 +186,9 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, 
int h,
                 goto end;
             }
         }
-        outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
-                                    AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
-                                    NULL, NULL, NULL);
+        outContext = sws_getCachedContext(NULL, dstW, dstH, dstFormat, w, h,
+                                          AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
+                                          NULL, NULL, NULL);
         if (!outContext) {
             fprintf(stderr, "Failed to get %s ---> %s\n",
                     desc_dst->name,
@@ -356,8 +357,8 @@ int main(int argc, char **argv)
     if (!rgb_data || !data)
         return -1;
 
-    sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
-                         AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL);
+    sws = sws_getCachedContext(NULL, W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
+                               AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, 
NULL);
 
     av_lfg_init(&rand, 1);
 
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 8fe27df..4d03ef8 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -189,6 +189,7 @@ void sws_freeContext(struct SwsContext *swsContext);
  *       written
  * @deprecated Use sws_getCachedContext() instead.
  */
+attribute_deprecated
 struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat 
srcFormat,
                                   int dstW, int dstH, enum AVPixelFormat 
dstFormat,
                                   int flags, SwsFilter *srcFilter,
-- 
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