summaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale-example.c8
-rw-r--r--libswscale/swscale.c31
-rw-r--r--libswscale/swscale.h69
-rw-r--r--libswscale/swscale_internal.h12
-rw-r--r--libswscale/yuv2rgb.c14
-rw-r--r--libswscale/yuv2rgb_altivec.c4
-rw-r--r--libswscale/yuv2rgb_mlib.c2
-rw-r--r--libswscale/yuv2rgb_vis.c2
8 files changed, 87 insertions, 55 deletions
diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c
index 90c3ce39ab..87b9ba027d 100644
--- a/libswscale/swscale-example.c
+++ b/libswscale/swscale-example.c
@@ -118,10 +118,6 @@ static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
-#if ARCH_X86
- __asm__ volatile ("emms\n\t");
-#endif
-
ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
@@ -208,10 +204,6 @@ int main(int argc, char **argv){
}
sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
-#if ARCH_X86
- __asm__ volatile ("emms\n\t");
-#endif
-
selfTest(src, stride, W, H);
return 123;
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 88ac39757e..586715eacd 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -174,7 +174,7 @@ unsigned swscale_version(void)
#define RV ( (int)(0.500*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define RU (-(int)(0.169*224/255*(1<<RGB2YUV_SHIFT)+0.5))
-extern const int32_t Inverse_Table_6_9[8][4];
+extern const int32_t ff_yuv2rgb_coeffs[8][4];
static const double rgb2yuv_table[8][9]={
{0.7152, 0.0722, 0.2126, -0.386, 0.5, -0.115, -0.454, -0.046, 0.5},
@@ -2076,7 +2076,7 @@ static uint16_t roundToInt16(int64_t f){
}
/**
- * @param inv_table the yuv2rgb coefficients, normally Inverse_Table_6_9[x]
+ * @param inv_table the yuv2rgb coefficients, normally ff_yuv2rgb_coeffs[x]
* @param fullRange if 1 then the luma range is 0..255 if 0 it is 16..235
* @return -1 if not supported
*/
@@ -2133,12 +2133,12 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);
c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);
- yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);
+ sws_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);
//FIXME factorize
#ifdef COMPILE_ALTIVEC
if (c->flags & SWS_CPU_CAPS_ALTIVEC)
- yuv2rgb_altivec_init_tables (c, inv_table, brightness, contrast, saturation);
+ sws_yuv2rgb_altivec_init_tables (c, inv_table, brightness, contrast, saturation);
#endif
return 0;
}
@@ -2321,7 +2321,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
- sws_setColorspaceDetails(c, Inverse_Table_6_9[SWS_CS_DEFAULT], srcRange, Inverse_Table_6_9[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
+ sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
/* unscaled special cases */
if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isBGR(dstFormat) || isRGB(dstFormat)))
@@ -2336,7 +2336,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat))
&& !(flags & SWS_ACCURATE_RND) && !(dstH&1))
{
- c->swScale= yuv2rgb_get_func_ptr(c);
+ c->swScale= sws_yuv2rgb_get_func_ptr(c);
}
#endif
@@ -2820,13 +2820,12 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
}
}
-/**
- * swscale wrapper, so we don't need to export the SwsContext.
- */
+#if LIBSWSCALE_VERSION_MAJOR < 1
int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
}
+#endif
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
float lumaSharpen, float chromaSharpen,
@@ -2886,10 +2885,6 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
return filter;
}
-/**
- * Returns a normalized Gaussian curve used to filter stuff
- * quality=3 is high quality, lower is lower quality.
- */
SwsVector *sws_getGaussianVec(double variance, double quality){
const int length= (int)(variance*quality + 0.5) | 1;
int i;
@@ -3166,16 +3161,6 @@ void sws_freeContext(SwsContext *c){
av_free(c);
}
-/**
- * Checks if context is valid or reallocs a new one instead.
- * If context is NULL, just calls sws_getContext() to get a new one.
- * Otherwise, checks if the parameters are the ones already saved in context.
- * If that is the case, returns the current context.
- * Otherwise, frees context and gets a new one.
- *
- * Be warned that srcFilter, dstFilter are not checked, they are
- * asumed to remain valid.
- */
struct SwsContext *sws_getCachedContext(struct SwsContext *context,
int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags,
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index cee394f8a5..35db84cdef 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -31,7 +31,7 @@
#define LIBSWSCALE_VERSION_MAJOR 0
#define LIBSWSCALE_VERSION_MINOR 6
-#define LIBSWSCALE_VERSION_MICRO 1
+#define LIBSWSCALE_VERSION_MICRO 2
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \
@@ -98,8 +98,8 @@ unsigned swscale_version(void);
// when used for filters they must have an odd number of elements
// coeffs cannot be shared between vectors
typedef struct {
- double *coeff;
- int length;
+ double *coeff; ///< pointer to the list of coefficients
+ int length; ///< number of coefficients in the vector
} SwsVector;
// vectors can be shared
@@ -114,39 +114,94 @@ struct SwsContext;
void sws_freeContext(struct SwsContext *swsContext);
-struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
+/**
+ * Allocates and returns a SwsContext. You need it to perform
+ * scaling/conversion operations using sws_scale().
+ *
+ * @param srcW the width of the source image
+ * @param srcH the height of the source image
+ * @param srcFormat the source image format
+ * @param dstW the width of the destination image
+ * @param dstH the height of the destination image
+ * @param dstFormat the destination image format
+ * @param flags specify which algorithm and options to use for rescaling
+ * @return a pointer to an allocated context, or NULL in case of error
+ */
+struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, double *param);
int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
+#if LIBSWSCALE_VERSION_MAJOR < 1
+/**
+ * @deprecated Use sws_scale() instead.
+ */
int sws_scale_ordered(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]) attribute_deprecated;
+#endif
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation);
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation);
+
+/**
+ * Returns a normalized Gaussian curve used to filter stuff
+ * quality=3 is high quality, lower is lower quality.
+ */
SwsVector *sws_getGaussianVec(double variance, double quality);
+
+/**
+ * Allocates and returns a vector with \p length coefficients, all
+ * with the same value \p c.
+ */
SwsVector *sws_getConstVec(double c, int length);
+
+/**
+ * Allocates and returns a vector with just one coefficient, with
+ * value 1.0.
+ */
SwsVector *sws_getIdentityVec(void);
+
+/**
+ * Scales all the coefficients of \p a by the \p scalar value.
+ */
void sws_scaleVec(SwsVector *a, double scalar);
void sws_normalizeVec(SwsVector *a, double height);
void sws_convVec(SwsVector *a, SwsVector *b);
void sws_addVec(SwsVector *a, SwsVector *b);
void sws_subVec(SwsVector *a, SwsVector *b);
void sws_shiftVec(SwsVector *a, int shift);
+
+/**
+ * Allocates and returns a clone of the vector \p a, that is a vector
+ * with the same coefficients as \p a.
+ */
SwsVector *sws_cloneVec(SwsVector *a);
void sws_printVec(SwsVector *a);
void sws_freeVec(SwsVector *a);
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
- float lumaSarpen, float chromaSharpen,
+ float lumaSharpen, float chromaSharpen,
float chromaHShift, float chromaVShift,
int verbose);
void sws_freeFilter(SwsFilter *filter);
+/**
+ * Checks if \p context can be reused, otherwise reallocates a new
+ * one.
+ *
+ * If \p context is NULL, just calls sws_getContext() to get a new
+ * context. Otherwise, checks if the parameters are the ones already
+ * saved in \p context. If that is the case, returns the current
+ * context. Otherwise, frees \p context and gets a new context with
+ * the new parameters.
+ *
+ * Be warned that \p srcFilter and \p dstFilter are not checked, they
+ * are assumed to remain the same.
+ */
struct SwsContext *sws_getCachedContext(struct SwsContext *context,
- int srcW, int srcH, int srcFormat,
- int dstW, int dstH, int dstFormat, int flags,
+ int srcW, int srcH, enum PixelFormat srcFormat,
+ int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, double *param);
#endif /* SWSCALE_SWSCALE_H */
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 38db01023a..cf157428b3 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -212,11 +212,11 @@ typedef struct SwsContext{
} SwsContext;
//FIXME check init (where 0)
-SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
-int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
+SwsFunc sws_yuv2rgb_get_func_ptr (SwsContext *c);
+int sws_yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
-void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation);
-SwsFunc yuv2rgb_init_altivec (SwsContext *c);
+void sws_yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation);
+SwsFunc sws_yuv2rgb_init_altivec (SwsContext *c);
void altivec_yuv2packedX (SwsContext *c,
int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
@@ -309,8 +309,8 @@ static inline int fmt_depth(int fmt)
}
}
-extern const DECLARE_ALIGNED(8, uint64_t, ff_dither4[2]);
-extern const DECLARE_ALIGNED(8, uint64_t, ff_dither8[2]);
+extern const uint64_t ff_dither4[2];
+extern const uint64_t ff_dither8[2];
extern const AVClass sws_context_class;
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 5aaa5728ea..fe90a04f22 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -1,5 +1,5 @@
/*
- * yuv2rgb.c, Software YUV to RGB converter
+ * software YUV to RGB converter
*
* Copyright (C) 1999, Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
@@ -70,7 +70,7 @@ DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
#endif /* HAVE_MMX */
-const int32_t Inverse_Table_6_9[8][4] = {
+const int32_t ff_yuv2rgb_coeffs[8][4] = {
{117504, 138453, 13954, 34903}, /* no sequence_display_extension */
{117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
{104597, 132201, 25675, 53279}, /* unspecified */
@@ -481,7 +481,7 @@ PROLOG(yuv2rgb_c_1_ordered_dither, uint8_t)
dst_2[0]= out_2;
EPILOG(1)
-SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
+SwsFunc sws_yuv2rgb_get_func_ptr (SwsContext *c)
{
#if HAVE_MMX2 || HAVE_MMX
if (c->flags & SWS_CPU_CAPS_MMX2){
@@ -503,20 +503,20 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
#endif
#if HAVE_VIS
{
- SwsFunc t= yuv2rgb_init_vis(c);
+ SwsFunc t= sws_yuv2rgb_init_vis(c);
if (t) return t;
}
#endif
#if CONFIG_MLIB
{
- SwsFunc t= yuv2rgb_init_mlib(c);
+ SwsFunc t= sws_yuv2rgb_init_mlib(c);
if (t) return t;
}
#endif
#if HAVE_ALTIVEC
if (c->flags & SWS_CPU_CAPS_ALTIVEC)
{
- SwsFunc t = yuv2rgb_init_altivec(c);
+ SwsFunc t = sws_yuv2rgb_init_altivec(c);
if (t) return t;
}
#endif
@@ -563,7 +563,7 @@ static int div_round (int dividend, int divisor)
return -((-dividend + (divisor>>1)) / divisor);
}
-int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
+int sws_yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
{
const int isRgb = c->dstFormat==PIX_FMT_RGB32
|| c->dstFormat==PIX_FMT_RGB32_1
diff --git a/libswscale/yuv2rgb_altivec.c b/libswscale/yuv2rgb_altivec.c
index baffbc80a6..a4cdcf898f 100644
--- a/libswscale/yuv2rgb_altivec.c
+++ b/libswscale/yuv2rgb_altivec.c
@@ -690,7 +690,7 @@ static int altivec_uyvy_rgb32 (SwsContext *c,
So we just fall back to the C codes for this.
*/
-SwsFunc yuv2rgb_init_altivec (SwsContext *c)
+SwsFunc sws_yuv2rgb_init_altivec (SwsContext *c)
{
if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))
return NULL;
@@ -750,7 +750,7 @@ SwsFunc yuv2rgb_init_altivec (SwsContext *c)
return NULL;
}
-void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
+void sws_yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
{
union {
signed short tmp[8] __attribute__ ((aligned(16)));
diff --git a/libswscale/yuv2rgb_mlib.c b/libswscale/yuv2rgb_mlib.c
index ff2e50a2b0..68247914e7 100644
--- a/libswscale/yuv2rgb_mlib.c
+++ b/libswscale/yuv2rgb_mlib.c
@@ -73,7 +73,7 @@ static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], in
}
-SwsFunc yuv2rgb_init_mlib(SwsContext *c)
+SwsFunc sws_yuv2rgb_init_mlib(SwsContext *c)
{
switch(c->dstFormat){
case PIX_FMT_RGB24: return mlib_YUV2RGB420_24;
diff --git a/libswscale/yuv2rgb_vis.c b/libswscale/yuv2rgb_vis.c
index 42a0094f68..5c9698510d 100644
--- a/libswscale/yuv2rgb_vis.c
+++ b/libswscale/yuv2rgb_vis.c
@@ -182,7 +182,7 @@ static int vis_422P_ARGB32(SwsContext *c, uint8_t* src[], int srcStride[], int s
return srcSliceH;
}
-SwsFunc yuv2rgb_init_vis(SwsContext *c) {
+SwsFunc sws_yuv2rgb_init_vis(SwsContext *c) {
c->sparc_coeffs[5]=c->yCoeff;
c->sparc_coeffs[6]=c->vgCoeff;
c->sparc_coeffs[7]=c->vrCoeff;