---
cmdutils.c | 4 ++--
doc/examples/output.c | 10 +++++-----
libavfilter/vf_scale.c | 7 ++++---
libswscale/swscale-test.c | 21 ++++++++++++---------
4 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/cmdutils.c b/cmdutils.c
index 69a11bd..5c1eae5 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(sws_opts, 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 0534554..1af2ed5 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -459,11 +459,11 @@ static AVFrame *get_video_frame(OutputStream *ost)
/* as we only generate a YUV420P picture, we must convert it
* to the codec pixel format if needed */
if (!ost->sws_ctx) {
- ost->sws_ctx = sws_getContext(c->width, c->height,
- AV_PIX_FMT_YUV420P,
- c->width, c->height,
- c->pix_fmt,
- SCALE_FLAGS, NULL, NULL, NULL);
+ ost->sws_ctx = sws_getCachedContext(ost->sws_ctx,
+ c->width, c->height,
+ AV_PIX_FMT_YUV420P,
+ c->width, c->height,
c->pix_fmt,
+ SCALE_FLAGS, NULL, NULL, NULL);
if (!ost->sws_ctx) {
fprintf(stderr,
"Cannot initialize the conversion context\n");
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 73ea9d2..9bf0f9d 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -236,9 +236,10 @@ static int config_props(AVFilterLink *outlink)
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);
+ 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);
}
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c
index 12fa9ed..aba62ee 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(srcContext, 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,9 @@ 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(dstContext, 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 +187,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(outContext, 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 +358,9 @@ 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(sws, W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
+ AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
+ NULL, NULL, NULL);
av_lfg_init(&rand, 1);
--
1.8.3.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel