Commit 71963689 authored by michael's avatar michael

general convolution filtering of the source picture

dynamic memory allocation for the buffers (needed for the filter stuff)


git-svn-id: file:///var/local/repositories/mplayer/trunk/postproc@4291 b3059339-0415-0410-9bf9-f77b7e298cf2
parent a97a12a5
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define SWS_FULL_UV_IPOL 0x100 #define SWS_FULL_UV_IPOL 0x100
#define SWS_PRINT_INFO 0x1000 #define SWS_PRINT_INFO 0x1000
#define SWS_MAX_SIZE 2000 #define SWS_MAX_REDUCE_CUTOFF 0.002
/* this struct should be aligned on at least 32-byte boundary */ /* this struct should be aligned on at least 32-byte boundary */
typedef struct{ typedef struct{
...@@ -16,20 +16,21 @@ typedef struct{ ...@@ -16,20 +16,21 @@ typedef struct{
int lumXInc, chrXInc; int lumXInc, chrXInc;
int lumYInc, chrYInc; int lumYInc, chrYInc;
int dstFormat, srcFormat; int dstFormat, srcFormat;
int16_t __attribute__((aligned(8))) *lumPixBuf[SWS_MAX_SIZE];
int16_t __attribute__((aligned(8))) *chrPixBuf[SWS_MAX_SIZE]; int16_t **lumPixBuf;
int16_t __attribute__((aligned(8))) hLumFilter[SWS_MAX_SIZE*5]; int16_t **chrPixBuf;
int16_t __attribute__((aligned(8))) hLumFilterPos[SWS_MAX_SIZE]; int16_t *hLumFilter;
int16_t __attribute__((aligned(8))) hChrFilter[SWS_MAX_SIZE*5]; int16_t *hLumFilterPos;
int16_t __attribute__((aligned(8))) hChrFilterPos[SWS_MAX_SIZE]; int16_t *hChrFilter;
int16_t __attribute__((aligned(8))) vLumFilter[SWS_MAX_SIZE*5]; int16_t *hChrFilterPos;
int16_t __attribute__((aligned(8))) vLumFilterPos[SWS_MAX_SIZE]; int16_t *vLumFilter;
int16_t __attribute__((aligned(8))) vChrFilter[SWS_MAX_SIZE*5]; int16_t *vLumFilterPos;
int16_t __attribute__((aligned(8))) vChrFilterPos[SWS_MAX_SIZE]; int16_t *vChrFilter;
int16_t *vChrFilterPos;
// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx // Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
int16_t __attribute__((aligned(8))) lumMmxFilter[SWS_MAX_SIZE*20]; int16_t *lumMmxFilter;
int16_t __attribute__((aligned(8))) chrMmxFilter[SWS_MAX_SIZE*20]; int16_t *chrMmxFilter;
int hLumFilterSize; int hLumFilterSize;
int hChrFilterSize; int hChrFilterSize;
...@@ -52,12 +53,19 @@ typedef struct{ ...@@ -52,12 +53,19 @@ typedef struct{
} SwsContext; } SwsContext;
//FIXME check init (where 0) //FIXME check init (where 0)
// when used for filters they must have an odd number of elements
// coeffs cannot be shared between vectors
typedef struct { typedef struct {
double *lumH; double *coeff;
double *lumV;
double *chrH;
double *chrV;
int length; int length;
} SwsVector;
// vectors can be shared
typedef struct {
SwsVector *lumH;
SwsVector *lumV;
SwsVector *chrH;
SwsVector *chrV;
} SwsFilter; } SwsFilter;
...@@ -74,7 +82,7 @@ void SwScale_Init(); ...@@ -74,7 +82,7 @@ void SwScale_Init();
void freeSwsContext(SwsContext swsContext); void freeSwsContext(SwsContext *swsContext);
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter); SwsFilter *srcFilter, SwsFilter *dstFilter);
...@@ -82,9 +90,15 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, ...@@ -82,9 +90,15 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH,
extern void (*swScale)(SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, extern void (*swScale)(SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]); int srcSliceH, uint8_t* dst[], int dstStride[]);
double *getGaussian(double variance, double quality); SwsVector *getGaussianVec(double variance, double quality);
SwsVector *getIdentityVec(void);
void normalize(double *coeff, int length, double height); void scaleVec(SwsVector *a, double scalar);
void normalizeVec(SwsVector *a, double height);
double *conv(double *a, int aLength, double *b, int bLength); SwsVector *convVec(SwsVector *a, SwsVector *b);
SwsVector *sumVec(SwsVector *a, SwsVector *b);
SwsVector *diffVec(SwsVector *a, SwsVector *b);
SwsVector *shiftVec(SwsVector *a, int shift);
void printVec(SwsVector *a);
void freeVec(SwsVector *a);
...@@ -1935,13 +1935,10 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int ...@@ -1935,13 +1935,10 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int
const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
if(flags&SWS_FAST_BILINEAR) //handle holes (FAST_BILINEAR & weird filters)
{ if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
//handle holes if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize);
if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
}
ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1) ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
...@@ -1953,6 +1950,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int ...@@ -1953,6 +1950,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int
{ {
uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
lumBufIndex++; lumBufIndex++;
// printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY);
ASSERT(lumBufIndex < 2*vLumBufSize) ASSERT(lumBufIndex < 2*vLumBufSize)
ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
......
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