[PATCH 2/2] Deprecate sws_getContext(), use sws_alloc_context() and sws_init_context() instead.
Stefano Sabatini
stefano.sabatini-lala
Tue Sep 28 18:27:48 CEST 2010
---
swscale.h | 11 +++++++++++
utils.c | 18 +++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/swscale.h b/swscale.h
index ddf3734..ce061e8 100644
--- a/swscale.h
+++ b/swscale.h
@@ -44,6 +44,14 @@
#define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION)
/**
+ * Those FF_API_* defines are not part of public API.
+ * They may change, break or disappear at any time.
+ */
+#ifndef FF_API_SWS_GETCONTEXT
+#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 1)
+#endif
+
+/**
* Returns the LIBSWSCALE_VERSION_INT constant.
*/
unsigned swscale_version(void);
@@ -163,6 +171,7 @@ int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFi
*/
void sws_freeContext(struct SwsContext *swsContext);
+#if FF_API_SWS_GETCONTEXT
/**
* Allocates and returns a SwsContext. You need it to perform
* scaling/conversion operations using sws_scale().
@@ -177,10 +186,12 @@ void sws_freeContext(struct SwsContext *swsContext);
* @return a pointer to an allocated context, or NULL in case of error
* @deprecated use sws_alloc_context() and sws_init_context()
*/
+attribute_deprecated
struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat,
int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, const double *param);
+#endif
/**
* Scales the image slice in srcSlice and puts the resulting scaled
diff --git a/utils.c b/utils.c
index c817a4d..23968b6 100644
--- a/utils.c
+++ b/utils.c
@@ -1146,6 +1146,7 @@ fail: //FIXME replace things by appropriate error codes
return -1;
}
+#if FF_API_SWS_GETCONTEXT
SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
@@ -1181,6 +1182,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
return c;
}
+#endif
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
float lumaSharpen, float chromaSharpen,
@@ -1564,9 +1566,19 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context,
}
if (!context) {
- return sws_getContext(srcW, srcH, srcFormat,
- dstW, dstH, dstFormat, flags,
- srcFilter, dstFilter, param);
+ if (!(context = sws_alloc_context()))
+ return NULL;
+ context->srcW = srcW;
+ context->srcH = srcH;
+ context->srcFormat = srcFormat;
+ context->dstFormat = dstFormat;
+ context->flags = flags;
+ context->param[0] = param[0];
+ context->param[1] = param[1];
+ if (sws_init_context(context, srcFilter, dstFilter) < 0) {
+ sws_freeContext(context);
+ return NULL;
+ }
}
return context;
}
--
1.7.1
--r5Pyd7+fXNt84Ff3--
More information about the ffmpeg-devel
mailing list