Browse Source

Deprecate sws_getContext(), use sws_alloc_context() and

sws_init_context() instead.

Originally committed as revision 32401 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
tags/n0.8
Stefano Sabatini 14 years ago
parent
commit
0810a5846b
2 changed files with 26 additions and 3 deletions
  1. +11
    -0
      libswscale/swscale.h
  2. +15
    -3
      libswscale/utils.c

+ 11
- 0
libswscale/swscale.h View File

@@ -43,6 +43,14 @@


#define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION) #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. * Returns the LIBSWSCALE_VERSION_INT constant.
*/ */
@@ -164,6 +172,7 @@ int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFi
*/ */
void sws_freeContext(struct SwsContext *swsContext); void sws_freeContext(struct SwsContext *swsContext);


#if FF_API_SWS_GETCONTEXT
/** /**
* Allocates and returns a SwsContext. You need it to perform * Allocates and returns a SwsContext. You need it to perform
* scaling/conversion operations using sws_scale(). * scaling/conversion operations using sws_scale().
@@ -178,10 +187,12 @@ void sws_freeContext(struct SwsContext *swsContext);
* @return a pointer to an allocated context, or NULL in case of error * @return a pointer to an allocated context, or NULL in case of error
* @deprecated use sws_alloc_context() and sws_init_context() * @deprecated use sws_alloc_context() and sws_init_context()
*/ */
attribute_deprecated
struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int dstW, int dstH, enum PixelFormat dstFormat,
int flags, SwsFilter *srcFilter, int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, const double *param); SwsFilter *dstFilter, const double *param);
#endif


/** /**
* Scales the image slice in srcSlice and puts the resulting scaled * Scales the image slice in srcSlice and puts the resulting scaled


+ 15
- 3
libswscale/utils.c View File

@@ -1146,6 +1146,7 @@ fail: //FIXME replace things by appropriate error codes
return -1; return -1;
} }


#if FF_API_SWS_GETCONTEXT
SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags, int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param) SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
@@ -1181,6 +1182,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,


return c; return c;
} }
#endif


SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
float lumaSharpen, float chromaSharpen, float lumaSharpen, float chromaSharpen,
@@ -1564,9 +1566,19 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context,
} }


if (!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; return context;
} }


Loading…
Cancel
Save