Commit 94c4def2 authored by Luca Abeni's avatar Luca Abeni

Use libavutil in libswscale, and allow it to be built out of the mplayer tree

Originally committed as revision 19148 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent 918a4591
...@@ -11,10 +11,12 @@ ...@@ -11,10 +11,12 @@
#include "config.h" #include "config.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "swscale.h" #include "swscale.h"
#include "cpudetect.h" #include "swscale_internal.h"
#include "mangle.h" #include "x86_cpu.h"
#include "bswap.h" #include "bswap.h"
#ifdef USE_FASTMEMCPY
#include "libvo/fastmemcpy.h" #include "libvo/fastmemcpy.h"
#endif
#define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit
......
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdarg.h> #include <stdarg.h>
#include "config.h"
#include "swscale.h" #include "swscale.h"
#include "libvo/img_format.h" #include "img_format.h"
static int testFormat[]={ static int testFormat[]={
IMGFMT_YVU9, IMGFMT_YVU9,
...@@ -120,8 +118,8 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma ...@@ -120,8 +118,8 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
if(ssdY>100 || ssdU>100 || ssdV>100){ if(ssdY>100 || ssdU>100 || ssdV>100){
printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n", printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n",
vo_format_name(srcFormat), srcW, srcH, sws_format_name(srcFormat), srcW, srcH,
vo_format_name(dstFormat), dstW, dstH, sws_format_name(dstFormat), dstW, dstH,
flags, flags,
ssdY, ssdU, ssdV); ssdY, ssdU, ssdV);
} }
...@@ -163,8 +161,8 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){ ...@@ -163,8 +161,8 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){
if(!dstFormat) break; if(!dstFormat) break;
// if(!isSupportedOut(dstFormat)) continue; // if(!isSupportedOut(dstFormat)) continue;
printf("%s -> %s\n", printf("%s -> %s\n",
vo_format_name(srcFormat), sws_format_name(srcFormat),
vo_format_name(dstFormat)); sws_format_name(dstFormat));
srcW= w; srcW= w;
srcH= h; srcH= h;
......
...@@ -55,7 +55,6 @@ untested special converters ...@@ -55,7 +55,6 @@ untested special converters
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "config.h" #include "config.h"
#include "mangle.h"
#include <assert.h> #include <assert.h>
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOC_H
#include <malloc.h> #include <malloc.h>
...@@ -70,11 +69,13 @@ untested special converters ...@@ -70,11 +69,13 @@ untested special converters
#endif #endif
#include "swscale.h" #include "swscale.h"
#include "swscale_internal.h" #include "swscale_internal.h"
#include "cpudetect.h" #include "x86_cpu.h"
#include "bswap.h" #include "bswap.h"
#include "libvo/img_format.h" #include "img_format.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#ifdef USE_FASTMEMCPY
#include "libvo/fastmemcpy.h" #include "libvo/fastmemcpy.h"
#endif
#undef MOVNTQ #undef MOVNTQ
#undef PAVGB #undef PAVGB
...@@ -150,7 +151,6 @@ add BGR4 output support ...@@ -150,7 +151,6 @@ add BGR4 output support
write special BGR->BGR scaler write special BGR->BGR scaler
*/ */
#define ABS(a) ((a) > 0 ? (a) : (-(a)))
#define MIN(a,b) ((a) > (b) ? (b) : (a)) #define MIN(a,b) ((a) > (b) ? (b) : (a))
#define MAX(a,b) ((a) < (b) ? (b) : (a)) #define MAX(a,b) ((a) < (b) ? (b) : (a))
...@@ -213,6 +213,22 @@ extern const uint8_t dither_8x8_32[8][8]; ...@@ -213,6 +213,22 @@ extern const uint8_t dither_8x8_32[8][8];
extern const uint8_t dither_8x8_73[8][8]; extern const uint8_t dither_8x8_73[8][8];
extern const uint8_t dither_8x8_220[8][8]; extern const uint8_t dither_8x8_220[8][8];
char *sws_format_name(int format)
{
static char fmt_name[64];
char *res;
static int buffer;
res = fmt_name + buffer * 32;
buffer = 1 - buffer;
snprintf(res, 32, "0x%x (%c%c%c%c)", format,
format >> 24, (format >> 16) & 0xFF,
(format >> 8) & 0xFF,
format & 0xFF);
return res;
}
#if defined(ARCH_X86) || defined(ARCH_X86_64) #if defined(ARCH_X86) || defined(ARCH_X86_64)
void in_asm_used_var_warning_killer() void in_asm_used_var_warning_killer()
{ {
...@@ -1021,7 +1037,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1021,7 +1037,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
} }
/* apply src & dst Filter to filter -> filter2 /* apply src & dst Filter to filter -> filter2
free(filter); av_free(filter);
*/ */
ASSERT(filterSize>0) ASSERT(filterSize>0)
filter2Size= filterSize; filter2Size= filterSize;
...@@ -1054,7 +1070,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1054,7 +1070,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
if(outVec != &scaleFilter) sws_freeVec(outVec); if(outVec != &scaleFilter) sws_freeVec(outVec);
} }
free(filter); filter=NULL; av_free(filter); filter=NULL;
/* try to reduce the filter-size (step1 find size and shift left) */ /* try to reduce the filter-size (step1 find size and shift left) */
// Assume its near normalized (*0.5 or *2.0 is ok but * 0.001 is not) // Assume its near normalized (*0.5 or *2.0 is ok but * 0.001 is not)
...@@ -1130,7 +1146,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1130,7 +1146,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
else filter[i*filterSize + j]= filter2[i*filter2Size + j]; else filter[i*filterSize + j]= filter2[i*filter2Size + j];
} }
} }
free(filter2); filter2=NULL; av_free(filter2); filter2=NULL;
//FIXME try to align filterpos if possible //FIXME try to align filterpos if possible
...@@ -1199,7 +1215,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1199,7 +1215,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
(*outFilter)[j + i]= (*outFilter)[j + i - (*outFilterSize)]; (*outFilter)[j + i]= (*outFilter)[j + i - (*outFilterSize)];
} }
free(filter); av_free(filter);
} }
#if defined(ARCH_X86) || defined(ARCH_X86_64) #if defined(ARCH_X86) || defined(ARCH_X86_64)
...@@ -1495,7 +1511,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr ...@@ -1495,7 +1511,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
case 0x84: conv= rgb16to32; break; case 0x84: conv= rgb16to32; break;
case 0x86: conv= rgb24to32; break; case 0x86: conv= rgb24to32; break;
default: MSG_ERR("swScaler: internal error %s -> %s converter\n", default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
vo_format_name(srcFormat), vo_format_name(dstFormat)); break; sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
} }
}else if( (isBGR(srcFormat) && isRGB(dstFormat)) }else if( (isBGR(srcFormat) && isRGB(dstFormat))
|| (isRGB(srcFormat) && isBGR(dstFormat))){ || (isRGB(srcFormat) && isBGR(dstFormat))){
...@@ -1517,11 +1533,11 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr ...@@ -1517,11 +1533,11 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
case 0x86: conv= rgb24tobgr32; break; case 0x86: conv= rgb24tobgr32; break;
case 0x88: conv= rgb32tobgr32; break; case 0x88: conv= rgb32tobgr32; break;
default: MSG_ERR("swScaler: internal error %s -> %s converter\n", default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
vo_format_name(srcFormat), vo_format_name(dstFormat)); break; sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
} }
}else{ }else{
MSG_ERR("swScaler: internal error %s -> %s converter\n", MSG_ERR("swScaler: internal error %s -> %s converter\n",
vo_format_name(srcFormat), vo_format_name(dstFormat)); sws_format_name(srcFormat), sws_format_name(dstFormat));
} }
if(dstStride[0]*srcBpp == srcStride[0]*dstBpp) if(dstStride[0]*srcBpp == srcStride[0]*dstBpp)
...@@ -1861,12 +1877,12 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -1861,12 +1877,12 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
if(!isSupportedIn(srcFormat)) if(!isSupportedIn(srcFormat))
{ {
MSG_ERR("swScaler: %s is not supported as input format\n", vo_format_name(srcFormat)); MSG_ERR("swScaler: %s is not supported as input format\n", sws_format_name(srcFormat));
return NULL; return NULL;
} }
if(!isSupportedOut(dstFormat)) if(!isSupportedOut(dstFormat))
{ {
MSG_ERR("swScaler: %s is not supported as output format\n", vo_format_name(dstFormat)); MSG_ERR("swScaler: %s is not supported as output format\n", sws_format_name(dstFormat));
return NULL; return NULL;
} }
...@@ -2012,7 +2028,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2012,7 +2028,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
if(c->swScale){ if(c->swScale){
if(flags&SWS_PRINT_INFO) if(flags&SWS_PRINT_INFO)
MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n", MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
vo_format_name(srcFormat), vo_format_name(dstFormat)); sws_format_name(srcFormat), sws_format_name(dstFormat));
return c; return c;
} }
} }
...@@ -2198,10 +2214,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2198,10 +2214,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16) if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16)
MSG_INFO("from %s to%s %s ", MSG_INFO("from %s to%s %s ",
vo_format_name(srcFormat), dither, vo_format_name(dstFormat)); sws_format_name(srcFormat), dither, sws_format_name(dstFormat));
else else
MSG_INFO("from %s to %s ", MSG_INFO("from %s to %s ",
vo_format_name(srcFormat), vo_format_name(dstFormat)); sws_format_name(srcFormat), sws_format_name(dstFormat));
if(flags & SWS_CPU_CAPS_MMX2) if(flags & SWS_CPU_CAPS_MMX2)
MSG_INFO("using MMX2\n"); MSG_INFO("using MMX2\n");
...@@ -2348,7 +2364,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, ...@@ -2348,7 +2364,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
float chromaHShift, float chromaVShift, float chromaHShift, float chromaVShift,
int verbose) int verbose)
{ {
SwsFilter *filter= malloc(sizeof(SwsFilter)); SwsFilter *filter= av_malloc(sizeof(SwsFilter));
if(lumaGBlur!=0.0){ if(lumaGBlur!=0.0){
filter->lumH= sws_getGaussianVec(lumaGBlur, 3.0); filter->lumH= sws_getGaussianVec(lumaGBlur, 3.0);
...@@ -2410,7 +2426,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality){ ...@@ -2410,7 +2426,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality){
int i; int i;
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
double middle= (length-1)*0.5; double middle= (length-1)*0.5;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2429,7 +2445,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality){ ...@@ -2429,7 +2445,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality){
SwsVector *sws_getConstVec(double c, int length){ SwsVector *sws_getConstVec(double c, int length){
int i; int i;
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2470,7 +2486,7 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){ ...@@ -2470,7 +2486,7 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){
int length= a->length + b->length - 1; int length= a->length + b->length - 1;
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
int i, j; int i, j;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2492,7 +2508,7 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){ ...@@ -2492,7 +2508,7 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){
int length= MAX(a->length, b->length); int length= MAX(a->length, b->length);
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
int i; int i;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2509,7 +2525,7 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){ ...@@ -2509,7 +2525,7 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){
int length= MAX(a->length, b->length); int length= MAX(a->length, b->length);
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
int i; int i;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2527,7 +2543,7 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){ ...@@ -2527,7 +2543,7 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){
int length= a->length + ABS(shift)*2; int length= a->length + ABS(shift)*2;
double *coeff= memalign(sizeof(double), length*sizeof(double)); double *coeff= memalign(sizeof(double), length*sizeof(double));
int i; int i;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= length; vec->length= length;
...@@ -2544,40 +2560,40 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){ ...@@ -2544,40 +2560,40 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){
void sws_shiftVec(SwsVector *a, int shift){ void sws_shiftVec(SwsVector *a, int shift){
SwsVector *shifted= sws_getShiftedVec(a, shift); SwsVector *shifted= sws_getShiftedVec(a, shift);
free(a->coeff); av_free(a->coeff);
a->coeff= shifted->coeff; a->coeff= shifted->coeff;
a->length= shifted->length; a->length= shifted->length;
free(shifted); av_free(shifted);
} }
void sws_addVec(SwsVector *a, SwsVector *b){ void sws_addVec(SwsVector *a, SwsVector *b){
SwsVector *sum= sws_sumVec(a, b); SwsVector *sum= sws_sumVec(a, b);
free(a->coeff); av_free(a->coeff);
a->coeff= sum->coeff; a->coeff= sum->coeff;
a->length= sum->length; a->length= sum->length;
free(sum); av_free(sum);
} }
void sws_subVec(SwsVector *a, SwsVector *b){ void sws_subVec(SwsVector *a, SwsVector *b){
SwsVector *diff= sws_diffVec(a, b); SwsVector *diff= sws_diffVec(a, b);
free(a->coeff); av_free(a->coeff);
a->coeff= diff->coeff; a->coeff= diff->coeff;
a->length= diff->length; a->length= diff->length;
free(diff); av_free(diff);
} }
void sws_convVec(SwsVector *a, SwsVector *b){ void sws_convVec(SwsVector *a, SwsVector *b){
SwsVector *conv= sws_getConvVec(a, b); SwsVector *conv= sws_getConvVec(a, b);
free(a->coeff); av_free(a->coeff);
a->coeff= conv->coeff; a->coeff= conv->coeff;
a->length= conv->length; a->length= conv->length;
free(conv); av_free(conv);
} }
SwsVector *sws_cloneVec(SwsVector *a){ SwsVector *sws_cloneVec(SwsVector *a){
double *coeff= memalign(sizeof(double), a->length*sizeof(double)); double *coeff= memalign(sizeof(double), a->length*sizeof(double));
int i; int i;
SwsVector *vec= malloc(sizeof(SwsVector)); SwsVector *vec= av_malloc(sizeof(SwsVector));
vec->coeff= coeff; vec->coeff= coeff;
vec->length= a->length; vec->length= a->length;
...@@ -2612,10 +2628,10 @@ void sws_printVec(SwsVector *a){ ...@@ -2612,10 +2628,10 @@ void sws_printVec(SwsVector *a){
void sws_freeVec(SwsVector *a){ void sws_freeVec(SwsVector *a){
if(!a) return; if(!a) return;
if(a->coeff) free(a->coeff); av_free(a->coeff);
a->coeff=NULL; a->coeff=NULL;
a->length=0; a->length=0;
free(a); av_free(a);
} }
void sws_freeFilter(SwsFilter *filter){ void sws_freeFilter(SwsFilter *filter){
...@@ -2625,7 +2641,7 @@ void sws_freeFilter(SwsFilter *filter){ ...@@ -2625,7 +2641,7 @@ void sws_freeFilter(SwsFilter *filter){
if(filter->lumV) sws_freeVec(filter->lumV); if(filter->lumV) sws_freeVec(filter->lumV);
if(filter->chrH) sws_freeVec(filter->chrH); if(filter->chrH) sws_freeVec(filter->chrH);
if(filter->chrV) sws_freeVec(filter->chrV); if(filter->chrV) sws_freeVec(filter->chrV);
free(filter); av_free(filter);
} }
...@@ -2637,10 +2653,10 @@ void sws_freeContext(SwsContext *c){ ...@@ -2637,10 +2653,10 @@ void sws_freeContext(SwsContext *c){
{ {
for(i=0; i<c->vLumBufSize; i++) for(i=0; i<c->vLumBufSize; i++)
{ {
if(c->lumPixBuf[i]) free(c->lumPixBuf[i]); av_free(c->lumPixBuf[i]);
c->lumPixBuf[i]=NULL; c->lumPixBuf[i]=NULL;
} }
free(c->lumPixBuf); av_free(c->lumPixBuf);
c->lumPixBuf=NULL; c->lumPixBuf=NULL;
} }
...@@ -2648,35 +2664,35 @@ void sws_freeContext(SwsContext *c){ ...@@ -2648,35 +2664,35 @@ void sws_freeContext(SwsContext *c){
{ {
for(i=0; i<c->vChrBufSize; i++) for(i=0; i<c->vChrBufSize; i++)
{ {
if(c->chrPixBuf[i]) free(c->chrPixBuf[i]); av_free(c->chrPixBuf[i]);
c->chrPixBuf[i]=NULL; c->chrPixBuf[i]=NULL;
} }
free(c->chrPixBuf); av_free(c->chrPixBuf);
c->chrPixBuf=NULL; c->chrPixBuf=NULL;
} }
if(c->vLumFilter) free(c->vLumFilter); av_free(c->vLumFilter);
c->vLumFilter = NULL; c->vLumFilter = NULL;
if(c->vChrFilter) free(c->vChrFilter); av_free(c->vChrFilter);
c->vChrFilter = NULL; c->vChrFilter = NULL;
if(c->hLumFilter) free(c->hLumFilter); av_free(c->hLumFilter);
c->hLumFilter = NULL; c->hLumFilter = NULL;
if(c->hChrFilter) free(c->hChrFilter); av_free(c->hChrFilter);
c->hChrFilter = NULL; c->hChrFilter = NULL;
#ifdef HAVE_ALTIVEC #ifdef HAVE_ALTIVEC
if(c->vYCoeffsBank) free(c->vYCoeffsBank); av_free(c->vYCoeffsBank);
c->vYCoeffsBank = NULL; c->vYCoeffsBank = NULL;
if(c->vCCoeffsBank) free(c->vCCoeffsBank); av_free(c->vCCoeffsBank);
c->vCCoeffsBank = NULL; c->vCCoeffsBank = NULL;
#endif #endif
if(c->vLumFilterPos) free(c->vLumFilterPos); av_free(c->vLumFilterPos);
c->vLumFilterPos = NULL; c->vLumFilterPos = NULL;
if(c->vChrFilterPos) free(c->vChrFilterPos); av_free(c->vChrFilterPos);
c->vChrFilterPos = NULL; c->vChrFilterPos = NULL;
if(c->hLumFilterPos) free(c->hLumFilterPos); av_free(c->hLumFilterPos);
c->hLumFilterPos = NULL; c->hLumFilterPos = NULL;
if(c->hChrFilterPos) free(c->hChrFilterPos); av_free(c->hChrFilterPos);
c->hChrFilterPos = NULL; c->hChrFilterPos = NULL;
#if defined(ARCH_X86) || defined(ARCH_X86_64) #if defined(ARCH_X86) || defined(ARCH_X86_64)
...@@ -2684,24 +2700,24 @@ void sws_freeContext(SwsContext *c){ ...@@ -2684,24 +2700,24 @@ void sws_freeContext(SwsContext *c){
if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE); if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE); if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
#else #else
if(c->funnyYCode) free(c->funnyYCode); av_free(c->funnyYCode);
if(c->funnyUVCode) free(c->funnyUVCode); av_free(c->funnyUVCode);
#endif #endif
c->funnyYCode=NULL; c->funnyYCode=NULL;
c->funnyUVCode=NULL; c->funnyUVCode=NULL;
#endif #endif
if(c->lumMmx2Filter) free(c->lumMmx2Filter); av_free(c->lumMmx2Filter);
c->lumMmx2Filter=NULL; c->lumMmx2Filter=NULL;
if(c->chrMmx2Filter) free(c->chrMmx2Filter); av_free(c->chrMmx2Filter);
c->chrMmx2Filter=NULL; c->chrMmx2Filter=NULL;
if(c->lumMmx2FilterPos) free(c->lumMmx2FilterPos); av_free(c->lumMmx2FilterPos);
c->lumMmx2FilterPos=NULL; c->lumMmx2FilterPos=NULL;
if(c->chrMmx2FilterPos) free(c->chrMmx2FilterPos); av_free(c->chrMmx2FilterPos);
c->chrMmx2FilterPos=NULL; c->chrMmx2FilterPos=NULL;
if(c->yuvTable) free(c->yuvTable); av_free(c->yuvTable);
c->yuvTable=NULL; c->yuvTable=NULL;
free(c); av_free(c);
} }
...@@ -29,6 +29,15 @@ ...@@ -29,6 +29,15 @@
extern "C" { extern "C" {
#endif #endif
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
#define LIBSWSCALE_VERSION_INT ((0<<16)+(5<<8)+0)
#define LIBSWSCALE_VERSION 0.5.0
#define LIBSWSCALE_BUILD LIBSWSCALE_VERSION_INT
#define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION)
/* values for the flags, the stuff on the command line is different */ /* values for the flags, the stuff on the command line is different */
#define SWS_FAST_BILINEAR 1 #define SWS_FAST_BILINEAR 1
#define SWS_BILINEAR 2 #define SWS_BILINEAR 2
......
...@@ -23,20 +23,20 @@ ...@@ -23,20 +23,20 @@
#include <altivec.h> #include <altivec.h>
#endif #endif
#include "avutil.h"
#ifdef CONFIG_DARWIN #ifdef CONFIG_DARWIN
#define AVV(x...) (x) #define AVV(x...) (x)
#else #else
#define AVV(x...) {x} #define AVV(x...) {x}
#endif #endif
#include "mp_msg.h" #define MSG_WARN(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
#define MSG_FATAL(args...) av_log(NULL, AV_LOG_ERROR, ##args )
#define MSG_WARN(args...) mp_msg(MSGT_SWS,MSGL_WARN, ##args ) #define MSG_ERR(args...) av_log(NULL, AV_LOG_ERROR, ##args )
#define MSG_FATAL(args...) mp_msg(MSGT_SWS,MSGL_FATAL, ##args ) #define MSG_V(args...) av_log(NULL, AV_LOG_INFO, ##args )
#define MSG_ERR(args...) mp_msg(MSGT_SWS,MSGL_ERR, ##args ) #define MSG_DBG2(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
#define MSG_V(args...) mp_msg(MSGT_SWS,MSGL_V, ##args ) #define MSG_INFO(args...) av_log(NULL, AV_LOG_INFO, ##args )
#define MSG_DBG2(args...) mp_msg(MSGT_SWS,MSGL_DBG2, ##args )
#define MSG_INFO(args...) mp_msg(MSGT_SWS,MSGL_INFO, ##args )
#define MAX_FILTER_SIZE 256 #define MAX_FILTER_SIZE 256
...@@ -164,4 +164,6 @@ typedef struct SwsContext{ ...@@ -164,4 +164,6 @@ typedef struct SwsContext{
SwsFunc yuv2rgb_get_func_ptr (SwsContext *c); 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); int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
char *sws_format_name(int format);
#endif #endif
...@@ -36,12 +36,10 @@ ...@@ -36,12 +36,10 @@
#include <assert.h> #include <assert.h>
#include "config.h" #include "config.h"
//#include "video_out.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "swscale.h" #include "swscale.h"
#include "swscale_internal.h" #include "swscale_internal.h"
#include "mangle.h" #include "img_format.h" //FIXME try to reduce dependency of such stuff
#include "libvo/img_format.h" //FIXME try to reduce dependency of such stuff
#ifdef HAVE_MLIB #ifdef HAVE_MLIB
#include "yuv2rgb_mlib.c" #include "yuv2rgb_mlib.c"
...@@ -692,7 +690,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -692,7 +690,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
switch (bpp) { switch (bpp) {
case 32: case 32:
table_start= table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
entry_size = sizeof (uint32_t); entry_size = sizeof (uint32_t);
table_r = table_32 + 197; table_r = table_32 + 197;
...@@ -708,7 +706,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -708,7 +706,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
break; break;
case 24: case 24:
table_start= table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t));
entry_size = sizeof (uint8_t); entry_size = sizeof (uint8_t);
table_r = table_g = table_b = table_8 + 232; table_r = table_g = table_b = table_8 + 232;
...@@ -719,7 +717,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -719,7 +717,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
case 15: case 15:
case 16: case 16:
table_start= table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); table_start= table_16 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
entry_size = sizeof (uint16_t); entry_size = sizeof (uint16_t);
table_r = table_16 + 197; table_r = table_16 + 197;
...@@ -750,7 +748,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -750,7 +748,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
break; break;
case 8: case 8:
table_start= table_332 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); table_start= table_332 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
entry_size = sizeof (uint8_t); entry_size = sizeof (uint8_t);
table_r = table_332 + 197; table_r = table_332 + 197;
...@@ -784,7 +782,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -784,7 +782,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
break; break;
case 4: case 4:
case 4|128: case 4|128:
table_start= table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); table_start= table_121 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
entry_size = sizeof (uint8_t); entry_size = sizeof (uint8_t);
table_r = table_121 + 197; table_r = table_121 + 197;
...@@ -815,7 +813,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -815,7 +813,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
break; break;
case 1: case 1:
table_start= table_1 = malloc (256*2 * sizeof (uint8_t)); table_start= table_1 = av_malloc (256*2 * sizeof (uint8_t));
entry_size = sizeof (uint8_t); entry_size = sizeof (uint8_t);
table_g = table_1; table_g = table_1;
...@@ -842,7 +840,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -842,7 +840,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
c->table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309); c->table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309);
} }
if(c->yuvTable) free(c->yuvTable); av_free(c->yuvTable);
c->yuvTable= table_start; c->yuvTable= table_start;
return 0; return 0;
} }
...@@ -74,8 +74,7 @@ ...@@ -74,8 +74,7 @@
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "swscale.h" #include "swscale.h"
#include "swscale_internal.h" #include "swscale_internal.h"
#include "mangle.h" #include "img_format.h" //FIXME try to reduce dependency of such stuff
#include "libvo/img_format.h" //FIXME try to reduce dependency of such stuff
#undef PROFILE_THE_BEAST #undef PROFILE_THE_BEAST
#undef INC_SCALING #undef INC_SCALING
...@@ -868,7 +867,7 @@ altivec_yuv2packedX (SwsContext *c, ...@@ -868,7 +867,7 @@ altivec_yuv2packedX (SwsContext *c,
static int printed_error_message; static int printed_error_message;
if(!printed_error_message) { if(!printed_error_message) {
MSG_ERR("altivec_yuv2packedX doesn't support %s output\n", MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
vo_format_name(c->dstFormat)); sws_format_name(c->dstFormat));
printed_error_message=1; printed_error_message=1;
} }
return; return;
...@@ -943,7 +942,7 @@ altivec_yuv2packedX (SwsContext *c, ...@@ -943,7 +942,7 @@ altivec_yuv2packedX (SwsContext *c,
default: default:
/* Unreachable, I think. */ /* Unreachable, I think. */
MSG_ERR("altivec_yuv2packedX doesn't support %s output\n", MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
vo_format_name(c->dstFormat)); sws_format_name(c->dstFormat));
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment