Mercurial > mplayer.hg
changeset 9494:543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
sws_scale() returns the number of outputed lines
author | michael |
---|---|
date | Sun, 23 Feb 2003 22:05:55 +0000 |
parents | d1f82707ad78 |
children | 2837f8da12c4 |
files | libmpcodecs/vf_sab.c libmpcodecs/vf_scale.c libmpcodecs/vf_smartblur.c libvo/vo_vesa.c libvo/vo_x11.c postproc/swscale.c postproc/swscale.h postproc/swscale_internal.h postproc/swscale_template.c postproc/yuv2rgb.c postproc/yuv2rgb_mlib.c postproc/yuv2rgb_template.c spudec.c |
diffstat | 13 files changed, 201 insertions(+), 161 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vf_sab.c Sun Feb 23 20:48:13 2003 +0000 +++ b/libmpcodecs/vf_sab.c Sun Feb 23 22:05:55 2003 +0000 @@ -43,7 +43,7 @@ float preFilterRadius; float strength; float quality; - SwsContext *preFilterContext; + struct SwsContext *preFilterContext; uint8_t *preFilterBuf; int preFilterStride; int distWidth; @@ -95,14 +95,14 @@ f->preFilterBuf= (uint8_t*)memalign(8, stride*height); f->preFilterStride= stride; - vec = getGaussianVec(f->preFilterRadius, f->quality); + vec = sws_getGaussianVec(f->preFilterRadius, f->quality); swsF.lumH= swsF.lumV= vec; swsF.chrH= swsF.chrV= NULL; - f->preFilterContext= getSwsContext( + f->preFilterContext= sws_getContext( width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, 0, &swsF, NULL); - freeVec(vec); - vec = getGaussianVec(f->strength, 5.0); + sws_freeVec(vec); + vec = sws_getGaussianVec(f->strength, 5.0); for(i=0; i<512; i++){ double d; int index= i-256 + vec->length/2; @@ -112,8 +112,8 @@ f->colorDiffCoeff[i]= (int)(d/vec->coeff[vec->length/2]*(1<<12) + 0.5); } - freeVec(vec); - vec = getGaussianVec(f->radius, f->quality); + sws_freeVec(vec); + vec = sws_getGaussianVec(f->radius, f->quality); f->distWidth= vec->length; f->distStride= (vec->length+7)&~7; f->distCoeff= (int32_t*)memalign(8, f->distWidth*f->distStride*sizeof(int32_t)); @@ -127,7 +127,7 @@ // printf("%6d ", f->distCoeff[x + y*f->distStride]); } } - freeVec(vec); + sws_freeVec(vec); return 0; } @@ -147,7 +147,7 @@ } static void freeBuffers(FilterParam *f){ - if(f->preFilterContext) freeSwsContext(f->preFilterContext); + if(f->preFilterContext) sws_freeContext(f->preFilterContext); f->preFilterContext=NULL; if(f->preFilterBuf) free(f->preFilterBuf); @@ -176,7 +176,8 @@ int srcStrideArray[3]= {srcStride, 0, 0}; int dstStrideArray[3]= {f.preFilterStride, 0, 0}; - f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); +// f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); + sws_scale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); for(y=0; y<h; y++){ for(x=0; x<w; x++){
--- a/libmpcodecs/vf_scale.c Sun Feb 23 20:48:13 2003 +0000 +++ b/libmpcodecs/vf_scale.c Sun Feb 23 22:05:55 2003 +0000 @@ -18,7 +18,7 @@ int v_chr_drop; int param; unsigned int fmt; - SwsContext *ctx; + struct SwsContext *ctx; unsigned char* palette; mp_image_t *dmpi; }; @@ -148,13 +148,13 @@ vf->priv->w,vf->priv->h,vo_format_name(best)); // free old ctx: - if(vf->priv->ctx) freeSwsContext(vf->priv->ctx); + if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); // new swscaler: - swsGetFlagsAndFilterFromCmdLine(&int_sws_flags, &srcFilter, &dstFilter); + sws_getFlagsAndFilterFromCmdLine(&int_sws_flags, &srcFilter, &dstFilter); int_sws_flags|= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT; int_sws_flags|= vf->priv->param << SWS_PARAM_SHIFT; - vf->priv->ctx=getSwsContext(width,height, + vf->priv->ctx=sws_getContext(width,height, (outfmt==IMGFMT_I420 || outfmt==IMGFMT_IYUV)?IMGFMT_YV12:outfmt, vf->priv->w,vf->priv->h, (best==IMGFMT_I420 || best==IMGFMT_IYUV)?IMGFMT_YV12:best, @@ -218,7 +218,7 @@ return; } // printf("vf_scale::draw_slice() y=%d h=%d\n",y,h); - vf->priv->ctx->swScale(vf->priv->ctx,src,stride,y,h,dmpi->planes,dmpi->stride); + sws_scale(vf->priv->ctx,src,stride,y,h,dmpi->planes,dmpi->stride); } static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ @@ -233,7 +233,7 @@ dmpi=vf_get_image(vf->next,vf->priv->fmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, vf->priv->w, vf->priv->h); - vf->priv->ctx->swScale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride); + sws_scale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride); }
--- a/libmpcodecs/vf_smartblur.c Sun Feb 23 20:48:13 2003 +0000 +++ b/libmpcodecs/vf_smartblur.c Sun Feb 23 22:05:55 2003 +0000 @@ -46,7 +46,7 @@ float strength; int threshold; float quality; - SwsContext *filterContext; + struct SwsContext *filterContext; }FilterParam; struct vf_priv_s { @@ -88,15 +88,15 @@ SwsVector *vec; SwsFilter swsF; - vec = getGaussianVec(f->radius, f->quality); - scaleVec(vec, f->strength); + vec = sws_getGaussianVec(f->radius, f->quality); + sws_scaleVec(vec, f->strength); vec->coeff[vec->length/2]+= 1.0 - f->strength; swsF.lumH= swsF.lumV= vec; swsF.chrH= swsF.chrV= NULL; - f->filterContext= getSwsContext( + f->filterContext= sws_getContext( width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, 0, &swsF, NULL); - freeVec(vec); + sws_freeVec(vec); return 0; } @@ -116,7 +116,7 @@ } static void freeBuffers(FilterParam *f){ - if(f->filterContext) freeSwsContext(f->filterContext); + if(f->filterContext) sws_freeContext(f->filterContext); f->filterContext=NULL; } @@ -138,7 +138,7 @@ int srcStrideArray[3]= {srcStride, 0, 0}; int dstStrideArray[3]= {dstStride, 0, 0}; - f.filterContext->swScale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); + sws_scale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); if(f.threshold > 0){ for(y=0; y<h; y++){
--- a/libvo/vo_vesa.c Sun Feb 23 20:48:13 2003 +0000 +++ b/libvo/vo_vesa.c Sun Feb 23 22:05:55 2003 +0000 @@ -95,7 +95,7 @@ static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */ static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */ -static SwsContext * sws = NULL; +static struct SwsContext * sws = NULL; static int32_t x_offset,y_offset; /* to center image on screen */ static unsigned init_mode=0; /* mode before run of mplayer */ @@ -161,7 +161,7 @@ if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); if(dga_buffer && !HAS_DGA()) free(dga_buffer); vbeDestroy(); - if(sws) freeSwsContext(sws); + if(sws) sws_freeContext(sws); sws=NULL; } @@ -278,7 +278,7 @@ dstStride[1]= dstStride[2]=dstStride[0]>>1; if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); - sws->swScale(sws,image,stride,y,h,dst,dstStride); + sws_scale(sws,image,stride,y,h,dst,dstStride); flip_trigger = 1; return 0; } @@ -423,7 +423,7 @@ else srcStride[0] = srcW*2; if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); - sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride); + sws_scale(sws,src,srcStride,0,srcH,dst,dstStride); flip_trigger=1; } return 0; @@ -800,7 +800,7 @@ #endif ) { - sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); + sws = sws_getContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); if(!sws) { printf("vo_vesa: Can't initialize SwScaler\n");
--- a/libvo/vo_x11.c Sun Feb 23 20:48:13 2003 +0000 +++ b/libvo/vo_x11.c Sun Feb 23 22:05:55 2003 +0000 @@ -23,6 +23,7 @@ #include "sub.h" #include "../postproc/swscale.h" +#include "../postproc/swscale_internal.h" //FIXME #include "../postproc/rgb2rgb.h" #include "../mp_msg.h" @@ -371,7 +372,7 @@ if ( myximage ) { freeMyXImage(); - freeSwsContext(swsContext); + sws_freeContext(swsContext); } getMyXImage(); @@ -397,7 +398,7 @@ } /* always allocate swsContext as size could change between frames */ - swsContext= getSwsContextFromCmdLine(width, height, in_format, width, height, out_format ); + swsContext= sws_getContextFromCmdLine(width, height, in_format, width, height, out_format ); //printf( "X11 bpp: %d color mask: R:%lX G:%lX B:%lX\n",bpp,myximage->red_mask,myximage->green_mask,myximage->blue_mask ); @@ -482,7 +483,7 @@ if(sws_flags==0) newW&= (~31); // not needed but, if the user wants the FAST_BILINEAR SCALER, then its needed - swsContext= getSwsContextFromCmdLine(srcW, srcH, in_format, + swsContext= sws_getContextFromCmdLine(srcW, srcH, in_format, newW, newH, out_format); if(swsContext) { @@ -491,7 +492,7 @@ freeMyXImage(); getMyXImage(); - freeSwsContext(oldContext); + sws_freeContext(oldContext); } else { @@ -507,13 +508,13 @@ { dstStride[0]= -image_width*((bpp+7)/8); dst[0]=ImageData - dstStride[0]*(image_height-1); - swsContext->swScale(swsContext,src,stride,y,h,dst, dstStride); + sws_scale(swsContext,src,stride,y,h,dst, dstStride); } else { dstStride[0]=image_width*((bpp+7)/8); dst[0]=ImageData; - swsContext->swScale(swsContext,src,stride,y,h,dst, dstStride); + sws_scale(swsContext,src,stride,y,h,dst, dstStride); } return 0; } @@ -609,7 +610,7 @@ zoomFlag=0; vo_x11_uninit(); - freeSwsContext(swsContext); + sws_freeContext(swsContext); } static uint32_t preinit(const char *arg)
--- a/postproc/swscale.c Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/swscale.c Sun Feb 23 22:05:55 2003 +0000 @@ -226,11 +226,11 @@ (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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } // 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 @@ 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 @@ (*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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ } } } + return srcSliceH; } static int remove_dup_fourcc(int fourcc) @@ -1985,7 +1991,7 @@ 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 @@ } /** + * 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 @@ 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 *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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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 @@ return vec; } -void printVec(SwsVector *a){ +void sws_printVec(SwsVector *a){ int i; double max=0; double min=0; @@ -2590,7 +2605,7 @@ } } -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 @@ free(a); } -void freeSwsContext(SwsContext *c){ +void sws_freeContext(SwsContext *c){ int i; if(!c) return;
--- a/postproc/swscale.h Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/swscale.h Sun Feb 23 22:05:55 2003 +0000 @@ -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 @@ 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); +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); +int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dst[], int dstStride[]); -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, - SwsFilter *srcFilter, SwsFilter *dstFilter); -void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); +void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); //FIXME try to seperate this -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); +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); -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 sws_printVec(SwsVector *a); +void sws_freeVec(SwsVector *a); -void printVec(SwsVector *a); -void freeVec(SwsVector *a); +#ifdef __cplusplus +} +#endif #endif
--- a/postproc/swscale_internal.h Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/swscale_internal.h Sun Feb 23 22:05:55 2003 +0000 @@ -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 @@ 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 @@ 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);
--- a/postproc/swscale_template.c Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/swscale_template.c Sun Feb 23 22:05:55 2003 +0000 @@ -2502,7 +2502,7 @@ } } -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 @@ 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 @@ 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 @@ c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; + + return dstY - lastDstY; }
--- a/postproc/yuv2rgb.c Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/yuv2rgb.c Sun Feb 23 22:05:55 2003 +0000 @@ -262,7 +262,7 @@ 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 @@ dst_2 += dst_delta;\ }\ }\ + return srcSliceH;\ } PROLOG(yuv2rgb_c_32, uint32_t)
--- a/postproc/yuv2rgb_mlib.c Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/yuv2rgb_mlib.c Sun Feb 23 22:05:55 2003 +0000 @@ -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 @@ 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 @@ 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 @@ mlib_VideoColorYUV2RGB420(dst[0], src[0], src[1], src[2], c->dstW, c->dstH, dstStride[0], srcStride[0], srcStride[1]); + return srcSliceH; }
--- a/postproc/yuv2rgb_template.c Sun Feb 23 20:48:13 2003 +0000 +++ b/postproc/yuv2rgb_template.c Sun Feb 23 22:05:55 2003 +0000 @@ -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 @@ } __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 @@ } __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 @@ } __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 @@ } __asm__ __volatile__ (EMMS); + return srcSliceH; }
--- a/spudec.c Sun Feb 23 20:48:13 2003 +0000 +++ b/spudec.c Sun Feb 23 22:05:55 2003 +0000 @@ -724,27 +724,27 @@ void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, int ds, unsigned char *s1, unsigned char *s2, int sw, int sh, int ss) { - SwsContext *ctx; + struct SwsContext *ctx; static SwsFilter filter; static int firsttime = 1; static float oldvar; int i; - if (!firsttime && oldvar != spu_gaussvar) freeVec(filter.lumH); + if (!firsttime && oldvar != spu_gaussvar) sws_freeVec(filter.lumH); if (firsttime) { filter.lumH = filter.lumV = - filter.chrH = filter.chrV = getGaussianVec(spu_gaussvar, 3.0); - normalizeVec(filter.lumH, 1.0); + filter.chrH = filter.chrV = sws_getGaussianVec(spu_gaussvar, 3.0); + sws_normalizeVec(filter.lumH, 1.0); firsttime = 0; oldvar = spu_gaussvar; } - ctx=getSwsContext(sw, sh, IMGFMT_Y800, dw, dh, IMGFMT_Y800, SWS_GAUSS, &filter, NULL); - ctx->swScale(ctx,&s1,&ss,0,sh,&d1,&ds); + ctx=sws_getContext(sw, sh, IMGFMT_Y800, dw, dh, IMGFMT_Y800, SWS_GAUSS, &filter, NULL); + sws_scale(ctx,&s1,&ss,0,sh,&d1,&ds); for (i=ss*sh-1; i>=0; i--) if (!s2[i]) s2[i] = 255; //else s2[i] = 1; - ctx->swScale(ctx,&s2,&ss,0,sh,&d2,&ds); + sws_scale(ctx,&s2,&ss,0,sh,&d2,&ds); for (i=ds*dh-1; i>=0; i--) if (d2[i]==0) d2[i] = 1; else if (d2[i]==255) d2[i] = 0; - freeSwsContext(ctx); + sws_freeContext(ctx); } void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))