diff options
Diffstat (limited to 'postproc')
-rw-r--r-- | postproc/swscale.c | 175 | ||||
-rw-r--r-- | postproc/swscale.h | 65 | ||||
-rw-r--r-- | postproc/swscale_internal.h | 8 | ||||
-rw-r--r-- | postproc/swscale_template.c | 7 | ||||
-rw-r--r-- | postproc/yuv2rgb.c | 3 | ||||
-rw-r--r-- | postproc/yuv2rgb_mlib.c | 9 | ||||
-rw-r--r-- | postproc/yuv2rgb_template.c | 13 |
7 files changed, 159 insertions, 121 deletions
diff --git a/postproc/swscale.c b/postproc/swscale.c index dbbf072..da4a4de 100644 --- a/postproc/swscale.c +++ b/postproc/swscale.c @@ -226,11 +226,11 @@ float sws_lum_sharpen= 0.0; (if there is no support for something compiled in it wont appear here) */ static CpuCaps cpuCaps; -void (*swScale)(SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, +int (*swScale)(SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[])=NULL; -static SwsVector *getConvVec(SwsVector *a, SwsVector *b); - +static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b); + extern const uint8_t dither_2x2_4[2][8]; extern const uint8_t dither_2x2_8[2][8]; extern const uint8_t dither_8x8_32[8][8]; @@ -306,9 +306,9 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma out[i]= malloc(refStride[i]*h); } - srcContext= getSwsContext(w, h, IMGFMT_YV12, srcW, srcH, srcFormat, flags, NULL, NULL); - dstContext= getSwsContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL); - outContext= getSwsContext(dstW, dstH, dstFormat, w, h, IMGFMT_YV12, flags, NULL, NULL); + srcContext= sws_getContext(w, h, IMGFMT_YV12, srcW, srcH, srcFormat, flags, NULL, NULL); + dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL); + outContext= sws_getContext(dstW, dstH, dstFormat, w, h, IMGFMT_YV12, flags, NULL, NULL); if(srcContext==NULL ||dstContext==NULL ||outContext==NULL){ printf("Failed allocating swsContext\n"); goto end; @@ -340,9 +340,9 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma end: - freeSwsContext(srcContext); - freeSwsContext(dstContext); - freeSwsContext(outContext); + sws_freeContext(srcContext); + sws_freeContext(dstContext); + sws_freeContext(outContext); for(i=0; i<3; i++){ free(src[i]); @@ -918,12 +918,12 @@ void SwScale_YV12slice(unsigned char* src[], int srcStride[], int srcSliceY , default: return; } - if(!context) context=getSwsContextFromCmdLine(srcW, srcH, IMGFMT_YV12, dstW, dstH, dstFormat); + if(!context) context=sws_getContextFromCmdLine(srcW, srcH, IMGFMT_YV12, dstW, dstH, dstFormat); context->swScale(context, src, srcStride, srcSliceY, srcSliceH, dst, dstStride3); } -void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam) +void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam) { static int firstTime=1; *flags=0; @@ -939,62 +939,62 @@ void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, Sws } else if(verbose>1) *flags= SWS_PRINT_INFO; - if(src_filter.lumH) freeVec(src_filter.lumH); - if(src_filter.lumV) freeVec(src_filter.lumV); - if(src_filter.chrH) freeVec(src_filter.chrH); - if(src_filter.chrV) freeVec(src_filter.chrV); + if(src_filter.lumH) sws_freeVec(src_filter.lumH); + if(src_filter.lumV) sws_freeVec(src_filter.lumV); + if(src_filter.chrH) sws_freeVec(src_filter.chrH); + if(src_filter.chrV) sws_freeVec(src_filter.chrV); if(sws_lum_gblur!=0.0){ - src_filter.lumH= getGaussianVec(sws_lum_gblur, 3.0); - src_filter.lumV= getGaussianVec(sws_lum_gblur, 3.0); + src_filter.lumH= sws_getGaussianVec(sws_lum_gblur, 3.0); + src_filter.lumV= sws_getGaussianVec(sws_lum_gblur, 3.0); }else{ - src_filter.lumH= getIdentityVec(); - src_filter.lumV= getIdentityVec(); + src_filter.lumH= sws_getIdentityVec(); + src_filter.lumV= sws_getIdentityVec(); } if(sws_chr_gblur!=0.0){ - src_filter.chrH= getGaussianVec(sws_chr_gblur, 3.0); - src_filter.chrV= getGaussianVec(sws_chr_gblur, 3.0); + src_filter.chrH= sws_getGaussianVec(sws_chr_gblur, 3.0); + src_filter.chrV= sws_getGaussianVec(sws_chr_gblur, 3.0); }else{ - src_filter.chrH= getIdentityVec(); - src_filter.chrV= getIdentityVec(); + src_filter.chrH= sws_getIdentityVec(); + src_filter.chrV= sws_getIdentityVec(); } if(sws_chr_sharpen!=0.0){ - SwsVector *g= getConstVec(-1.0, 3); - SwsVector *id= getConstVec(10.0/sws_chr_sharpen, 1); + SwsVector *g= sws_getConstVec(-1.0, 3); + SwsVector *id= sws_getConstVec(10.0/sws_chr_sharpen, 1); g->coeff[1]=2.0; - addVec(id, g); - convVec(src_filter.chrH, id); - convVec(src_filter.chrV, id); - freeVec(g); - freeVec(id); + sws_addVec(id, g); + sws_convVec(src_filter.chrH, id); + sws_convVec(src_filter.chrV, id); + sws_freeVec(g); + sws_freeVec(id); } if(sws_lum_sharpen!=0.0){ - SwsVector *g= getConstVec(-1.0, 3); - SwsVector *id= getConstVec(10.0/sws_lum_sharpen, 1); + SwsVector *g= sws_getConstVec(-1.0, 3); + SwsVector *id= sws_getConstVec(10.0/sws_lum_sharpen, 1); g->coeff[1]=2.0; - addVec(id, g); - convVec(src_filter.lumH, id); - convVec(src_filter.lumV, id); - freeVec(g); - freeVec(id); + sws_addVec(id, g); + sws_convVec(src_filter.lumH, id); + sws_convVec(src_filter.lumV, id); + sws_freeVec(g); + sws_freeVec(id); } if(sws_chr_hshift) - shiftVec(src_filter.chrH, sws_chr_hshift); + sws_shiftVec(src_filter.chrH, sws_chr_hshift); if(sws_chr_vshift) - shiftVec(src_filter.chrV, sws_chr_vshift); + sws_shiftVec(src_filter.chrV, sws_chr_vshift); - normalizeVec(src_filter.chrH, 1.0); - normalizeVec(src_filter.chrV, 1.0); - normalizeVec(src_filter.lumH, 1.0); - normalizeVec(src_filter.lumV, 1.0); + sws_normalizeVec(src_filter.chrH, 1.0); + sws_normalizeVec(src_filter.chrV, 1.0); + sws_normalizeVec(src_filter.lumH, 1.0); + sws_normalizeVec(src_filter.lumV, 1.0); - if(verbose > 1) printVec(src_filter.chrH); - if(verbose > 1) printVec(src_filter.lumH); + if(verbose > 1) sws_printVec(src_filter.chrH); + if(verbose > 1) sws_printVec(src_filter.lumH); switch(sws_flags) { @@ -1017,13 +1017,13 @@ void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, Sws } // will use sws_flags & src_filter (from cmd line) -SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat) +SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat) { int flags; SwsFilter *dstFilterParam, *srcFilterParam; - swsGetFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam); + sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam); - return getSwsContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, srcFilterParam, dstFilterParam); + return sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, srcFilterParam, dstFilterParam); } static double getSplineCoeff(double a, double b, double c, double d, double dist) @@ -1245,7 +1245,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out scaleFilter.coeff= filter + i*filterSize; scaleFilter.length= filterSize; - if(srcFilter) outVec= getConvVec(srcFilter, &scaleFilter); + if(srcFilter) outVec= sws_getConvVec(srcFilter, &scaleFilter); else outVec= &scaleFilter; ASSERT(outVec->length == filter2Size) @@ -1258,7 +1258,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out (*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2; - if(outVec != &scaleFilter) freeVec(outVec); + if(outVec != &scaleFilter) sws_freeVec(outVec); } free(filter); filter=NULL; @@ -1607,7 +1607,7 @@ cpuCaps= gCpuCaps; #endif //!RUNTIME_CPUDETECT } -static void PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dstParam[], int dstStride[]){ uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; /* Copy Y plane */ @@ -1630,9 +1630,10 @@ static void PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], interleaveBytes( src[1],src[2],dst,c->srcW,srcSliceH,srcStride[1],srcStride[2],dstStride[0] ); else /* I420 & IYUV */ interleaveBytes( src[2],src[1],dst,c->srcW,srcSliceH,srcStride[2],srcStride[1],dstStride[0] ); + return srcSliceH; } -static void PlanarToYuy2Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +static int PlanarToYuy2Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dstParam[], int dstStride[]){ uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; @@ -1640,10 +1641,11 @@ static void PlanarToYuy2Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); else /* I420 & IYUV */ yv12toyuy2( src[0],src[2],src[1],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); + return srcSliceH; } /* {RGB,BGR}{15,16,24,32} -> {RGB,BGR}{15,16,24,32} */ -static void rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ const int srcFormat= c->srcFormat; const int dstFormat= c->dstFormat; @@ -1714,9 +1716,10 @@ static void rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int s dstPtr+= dstStride[0]; } } + return srcSliceH; } -static void bgr24toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +static int bgr24toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ rgb24toyv12( @@ -1726,9 +1729,10 @@ static void bgr24toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i dst[2]+(srcSliceY>>1)*dstStride[2], c->srcW, srcSliceH, dstStride[0], dstStride[1], srcStride[0]); + return srcSliceH; } -static void yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int i; @@ -1754,6 +1758,7 @@ static void yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], in planar2x(src[1], dst[2], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[2]); planar2x(src[2], dst[1], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[1]); } + return srcSliceH; } /** @@ -1792,7 +1797,7 @@ inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], ui } /* unscaled copy like stuff (assumes nearly identical formats) */ -static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static int simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){ int srcStride[3]; @@ -1860,6 +1865,7 @@ static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], } } } + return srcSliceH; } static int remove_dup_fourcc(int fourcc) @@ -1985,7 +1991,7 @@ int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int return 0; } -SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, +SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter){ SwsContext *c; @@ -2374,11 +2380,20 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, } /** + * swscale warper, so we dont need to export the SwsContext + */ +int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dst[], int dstStride[]){ + return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride); +} +//FIXME order YV12/I420 here + +/** * returns a normalized gaussian curve used to filter stuff * quality=3 is high quality, lowwer is lowwer quality */ -SwsVector *getGaussianVec(double variance, double quality){ +SwsVector *sws_getGaussianVec(double variance, double quality){ const int length= (int)(variance*quality + 0.5) | 1; int i; double *coeff= memalign(sizeof(double), length*sizeof(double)); @@ -2394,12 +2409,12 @@ SwsVector *getGaussianVec(double variance, double quality){ coeff[i]= exp( -dist*dist/(2*variance*variance) ) / sqrt(2*variance*PI); } - normalizeVec(vec, 1.0); + sws_normalizeVec(vec, 1.0); return vec; } -SwsVector *getConstVec(double c, int length){ +SwsVector *sws_getConstVec(double c, int length){ int i; double *coeff= memalign(sizeof(double), length*sizeof(double)); SwsVector *vec= malloc(sizeof(SwsVector)); @@ -2414,7 +2429,7 @@ SwsVector *getConstVec(double c, int length){ } -SwsVector *getIdentityVec(void){ +SwsVector *sws_getIdentityVec(void){ double *coeff= memalign(sizeof(double), sizeof(double)); SwsVector *vec= malloc(sizeof(SwsVector)); coeff[0]= 1.0; @@ -2425,7 +2440,7 @@ SwsVector *getIdentityVec(void){ return vec; } -void normalizeVec(SwsVector *a, double height){ +void sws_normalizeVec(SwsVector *a, double height){ int i; double sum=0; double inv; @@ -2439,14 +2454,14 @@ void normalizeVec(SwsVector *a, double height){ a->coeff[i]*= inv; } -void scaleVec(SwsVector *a, double scalar){ +void sws_scaleVec(SwsVector *a, double scalar){ int i; for(i=0; i<a->length; i++) a->coeff[i]*= scalar; } -static SwsVector *getConvVec(SwsVector *a, SwsVector *b){ +static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){ int length= a->length + b->length - 1; double *coeff= memalign(sizeof(double), length*sizeof(double)); int i, j; @@ -2468,7 +2483,7 @@ static SwsVector *getConvVec(SwsVector *a, SwsVector *b){ return vec; } -static SwsVector *sumVec(SwsVector *a, SwsVector *b){ +static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){ int length= MAX(a->length, b->length); double *coeff= memalign(sizeof(double), length*sizeof(double)); int i; @@ -2485,7 +2500,7 @@ static SwsVector *sumVec(SwsVector *a, SwsVector *b){ return vec; } -static SwsVector *diffVec(SwsVector *a, SwsVector *b){ +static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){ int length= MAX(a->length, b->length); double *coeff= memalign(sizeof(double), length*sizeof(double)); int i; @@ -2503,7 +2518,7 @@ static SwsVector *diffVec(SwsVector *a, SwsVector *b){ } /* shift left / or right if "shift" is negative */ -static SwsVector *getShiftedVec(SwsVector *a, int shift){ +static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){ int length= a->length + ABS(shift)*2; double *coeff= memalign(sizeof(double), length*sizeof(double)); int i; @@ -2522,39 +2537,39 @@ static SwsVector *getShiftedVec(SwsVector *a, int shift){ return vec; } -void shiftVec(SwsVector *a, int shift){ - SwsVector *shifted= getShiftedVec(a, shift); +void sws_shiftVec(SwsVector *a, int shift){ + SwsVector *shifted= sws_getShiftedVec(a, shift); free(a->coeff); a->coeff= shifted->coeff; a->length= shifted->length; free(shifted); } -void addVec(SwsVector *a, SwsVector *b){ - SwsVector *sum= sumVec(a, b); +void sws_addVec(SwsVector *a, SwsVector *b){ + SwsVector *sum= sws_sumVec(a, b); free(a->coeff); a->coeff= sum->coeff; a->length= sum->length; free(sum); } -void subVec(SwsVector *a, SwsVector *b){ - SwsVector *diff= diffVec(a, b); +void sws_subVec(SwsVector *a, SwsVector *b){ + SwsVector *diff= sws_diffVec(a, b); free(a->coeff); a->coeff= diff->coeff; a->length= diff->length; free(diff); } -void convVec(SwsVector *a, SwsVector *b){ - SwsVector *conv= getConvVec(a, b); - free(a->coeff); +void sws_convVec(SwsVector *a, SwsVector *b){ + SwsVector *conv= sws_getConvVec(a, b); + free(a->coeff); a->coeff= conv->coeff; a->length= conv->length; free(conv); } -SwsVector *cloneVec(SwsVector *a){ +SwsVector *sws_cloneVec(SwsVector *a){ double *coeff= memalign(sizeof(double), a->length*sizeof(double)); int i; SwsVector *vec= malloc(sizeof(SwsVector)); @@ -2567,7 +2582,7 @@ SwsVector *cloneVec(SwsVector *a){ return vec; } -void printVec(SwsVector *a){ +void sws_printVec(SwsVector *a){ int i; double max=0; double min=0; @@ -2590,7 +2605,7 @@ void printVec(SwsVector *a){ } } -void freeVec(SwsVector *a){ +void sws_freeVec(SwsVector *a){ if(!a) return; if(a->coeff) free(a->coeff); a->coeff=NULL; @@ -2598,7 +2613,7 @@ void freeVec(SwsVector *a){ free(a); } -void freeSwsContext(SwsContext *c){ +void sws_freeContext(SwsContext *c){ int i; if(!c) return; diff --git a/postproc/swscale.h b/postproc/swscale.h index 0471d6a..22ffba8 100644 --- a/postproc/swscale.h +++ b/postproc/swscale.h @@ -19,7 +19,15 @@ #ifndef SWSCALE_H #define SWSCALE_H -#include "swscale_internal.h" //FIXME HACK REMOVE +/** + * @file swscale.h + * @brief + * external api for the swscale stuff + */ + +#ifdef __cplusplus +extern "C" { +#endif /* values for the flags, the stuff on the command line is different */ #define SWS_FAST_BILINEAR 1 @@ -76,42 +84,47 @@ typedef struct { SwsVector *chrV; } SwsFilter; +struct SwsContext; +//typedef struct SwsContext; // *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices: // *** Note: it's called multiple times while decoding a frame, first time y==0 // dstbpp == 12 -> yv12 output // will use sws_flags +// deprecated, will be removed void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp, int srcW, int srcH, int dstW, int dstH); -// Obsolete, will be removed soon -void SwScale_Init(); - +void sws_freeContext(struct SwsContext *swsContext); -void freeSwsContext(SwsContext *swsContext); - -SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat); -SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, +struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat); +struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter); -void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); - -int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation); -int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation); - -SwsVector *getGaussianVec(double variance, double quality); -SwsVector *getConstVec(double c, int length); -SwsVector *getIdentityVec(void); -void scaleVec(SwsVector *a, double scalar); -void normalizeVec(SwsVector *a, double height); -void convVec(SwsVector *a, SwsVector *b); -void addVec(SwsVector *a, SwsVector *b); -void subVec(SwsVector *a, SwsVector *b); -void shiftVec(SwsVector *a, int shift); -SwsVector *cloneVec(SwsVector *a); - -void printVec(SwsVector *a); -void freeVec(SwsVector *a); +int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dst[], int dstStride[]); + +void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); //FIXME try to seperate this + +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); +SwsVector *sws_getGaussianVec(double variance, double quality); +SwsVector *sws_getConstVec(double c, int length); +SwsVector *sws_getIdentityVec(void); +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); +SwsVector *sws_cloneVec(SwsVector *a); + +void sws_printVec(SwsVector *a); +void sws_freeVec(SwsVector *a); + +#ifdef __cplusplus +} +#endif #endif diff --git a/postproc/swscale_internal.h b/postproc/swscale_internal.h index 0697d97..fe7da66 100644 --- a/postproc/swscale_internal.h +++ b/postproc/swscale_internal.h @@ -21,13 +21,12 @@ #define MAX_FILTER_SIZE 256 -struct SwsContext; - -typedef void (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, +typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); /* this struct should be aligned on at least 32-byte boundary */ typedef struct SwsContext{ + SwsFunc swScale; int srcW, srcH, dstH; int chrSrcW, chrSrcH, chrDstW, chrDstH; int lumXInc, chrXInc; @@ -85,8 +84,6 @@ typedef struct SwsContext{ int dstColorspaceTable[4]; int srcRange, dstRange; - SwsFunc swScale; - #define RED_DITHER "0*8" #define GREEN_DITHER "1*8" #define BLUE_DITHER "2*8" @@ -121,7 +118,6 @@ typedef struct SwsContext{ int esp; } SwsContext; //FIXME check init (where 0) -//FIXME split private & public inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]); SwsFunc yuv2rgb_get_func_ptr (SwsContext *c); diff --git a/postproc/swscale_template.c b/postproc/swscale_template.c index 4166e50..fed7a48 100644 --- a/postproc/swscale_template.c +++ b/postproc/swscale_template.c @@ -2502,7 +2502,7 @@ FUNNY_UV_CODE } } -static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static int RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){ /* load a few things into local vars to make the code more readable? and faster */ @@ -2540,6 +2540,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar uint8_t *formatConvBuffer= c->formatConvBuffer; const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); + int lastDstY; /* vars whch will change and which we need to storw back in the context */ int dstY= c->dstY; @@ -2603,6 +2604,8 @@ i--; lastInChrBuf= -1; } + lastDstY= dstY; + for(;dstY < dstH; dstY++){ unsigned char *dest =dst[0]+dstStride[0]*dstY; const int chrDstY= dstY>>c->chrDstVSubSample; @@ -2810,4 +2813,6 @@ i--; c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; + + return dstY - lastDstY; } diff --git a/postproc/yuv2rgb.c b/postproc/yuv2rgb.c index e920d50..0df8534 100644 --- a/postproc/yuv2rgb.c +++ b/postproc/yuv2rgb.c @@ -262,7 +262,7 @@ const int32_t Inverse_Table_6_9[8][4] = { dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y]; #define PROLOG(func_name, dst_type) \ -static void func_name(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, \ +static int func_name(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, \ int srcSliceH, uint8_t* dst[], int dstStride[]){\ uint8_t *src[3];\ int srcStride[3];\ @@ -294,6 +294,7 @@ static void func_name(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], dst_2 += dst_delta;\ }\ }\ + return srcSliceH;\ } PROLOG(yuv2rgb_c_32, uint32_t) diff --git a/postproc/yuv2rgb_mlib.c b/postproc/yuv2rgb_mlib.c index 142aa1d..25d256e 100644 --- a/postproc/yuv2rgb_mlib.c +++ b/postproc/yuv2rgb_mlib.c @@ -33,7 +33,7 @@ #include "../libvo/img_format.h" //FIXME try to reduce dependency of such stuff #include "swscale.h" -static void mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ uint8_t *src[3]; int srcStride[3]; @@ -48,9 +48,10 @@ static void mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* srcParam[], int srcStrid mlib_VideoColorYUV2ARGB420(dst[0], src[0], src[1], src[2], c->dstW, c->dstH, dstStride[0], srcStride[0], srcStride[1]); + return srcSliceH; } -static void mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ uint8_t *src[3]; int srcStride[3]; @@ -65,9 +66,10 @@ static void mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* srcParam[], int srcStrid mlib_VideoColorYUV2ABGR420(dst[0], src[0], src[1], src[2], c->dstW, c->dstH, dstStride[0], srcStride[0], srcStride[1]); + return srcSliceH; } -static void mlib_YUV2RGB420_24(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ uint8_t *src[3]; int srcStride[3]; @@ -82,6 +84,7 @@ static void mlib_YUV2RGB420_24(SwsContext *c, uint8_t* srcParam[], int srcStride mlib_VideoColorYUV2RGB420(dst[0], src[0], src[1], src[2], c->dstW, c->dstH, dstStride[0], srcStride[0], srcStride[1]); + return srcSliceH; } diff --git a/postproc/yuv2rgb_template.c b/postproc/yuv2rgb_template.c index 7b4abf6..57f2797 100644 --- a/postproc/yuv2rgb_template.c +++ b/postproc/yuv2rgb_template.c @@ -123,7 +123,7 @@ "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */\ -static inline void RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcStride[3]; uint8_t *src[3]; @@ -217,9 +217,11 @@ YUV2RGB } __asm__ __volatile__ (EMMS); + + return srcSliceH; } -static inline void RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcStride[3]; uint8_t *src[3]; @@ -308,9 +310,10 @@ YUV2RGB } __asm__ __volatile__ (EMMS); + return srcSliceH; } -static inline void RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcStride[3]; uint8_t *src[3]; @@ -456,9 +459,10 @@ YUV2RGB } __asm__ __volatile__ (EMMS); + return srcSliceH; } -static inline void RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, +static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcStride[3]; uint8_t *src[3]; @@ -544,4 +548,5 @@ YUV2RGB } __asm__ __volatile__ (EMMS); + return srcSliceH; } |