mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 06:03:45 +01:00
sws_ prefix, more seperation between internal & external swscaler API
sws_scale() returns the number of outputed lines git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9495 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
4bd87c35eb
commit
41b847f6a8
@ -43,7 +43,7 @@ typedef struct FilterParam{
|
||||
float preFilterRadius;
|
||||
float strength;
|
||||
float quality;
|
||||
SwsContext *preFilterContext;
|
||||
struct SwsContext *preFilterContext;
|
||||
uint8_t *preFilterBuf;
|
||||
int preFilterStride;
|
||||
int distWidth;
|
||||
@ -95,14 +95,14 @@ static int allocStuff(FilterParam *f, int width, int height){
|
||||
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 @@ static int allocStuff(FilterParam *f, int width, int height){
|
||||
|
||||
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 @@ static int allocStuff(FilterParam *f, int width, int height){
|
||||
// printf("%6d ", f->distCoeff[x + y*f->distStride]);
|
||||
}
|
||||
}
|
||||
freeVec(vec);
|
||||
sws_freeVec(vec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -147,7 +147,7 @@ static int config(struct vf_instance_s* vf,
|
||||
}
|
||||
|
||||
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 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
|
||||
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++){
|
||||
|
@ -18,7 +18,7 @@ struct vf_priv_s {
|
||||
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 @@ static int config(struct vf_instance_s* vf,
|
||||
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 @@ static void draw_slice(struct vf_instance_s* vf,
|
||||
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 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ typedef struct FilterParam{
|
||||
float strength;
|
||||
int threshold;
|
||||
float quality;
|
||||
SwsContext *filterContext;
|
||||
struct SwsContext *filterContext;
|
||||
}FilterParam;
|
||||
|
||||
struct vf_priv_s {
|
||||
@ -88,15 +88,15 @@ static int allocStuff(FilterParam *f, int width, int height){
|
||||
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 int config(struct vf_instance_s* vf,
|
||||
}
|
||||
|
||||
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 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
|
||||
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++){
|
||||
|
@ -95,7 +95,7 @@ static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL;
|
||||
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 @@ static void vesa_term( void )
|
||||
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 @@ static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int
|
||||
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 @@ static uint32_t draw_frame(uint8_t *src[])
|
||||
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 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
|
||||
#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");
|
||||
|
@ -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 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t
|
||||
if ( myximage )
|
||||
{
|
||||
freeMyXImage();
|
||||
freeSwsContext(swsContext);
|
||||
sws_freeContext(swsContext);
|
||||
}
|
||||
getMyXImage();
|
||||
|
||||
@ -397,7 +398,7 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t
|
||||
}
|
||||
|
||||
/* 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 @@ static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y
|
||||
|
||||
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 @@ static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y
|
||||
|
||||
freeMyXImage();
|
||||
getMyXImage();
|
||||
freeSwsContext(oldContext);
|
||||
sws_freeContext(oldContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -507,13 +508,13 @@ static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y
|
||||
{
|
||||
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 @@ static void uninit(void)
|
||||
zoomFlag=0;
|
||||
vo_x11_uninit();
|
||||
|
||||
freeSwsContext(swsContext);
|
||||
sws_freeContext(swsContext);
|
||||
}
|
||||
|
||||
static uint32_t preinit(const char *arg)
|
||||
|
@ -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;
|
||||
@ -2373,12 +2379,21 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH,
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
@ -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_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
|
||||
int srcSliceH, uint8_t* dst[], int dstStride[]);
|
||||
|
||||
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);
|
||||
void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); //FIXME try to seperate this
|
||||
|
||||
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);
|
||||
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 printVec(SwsVector *a);
|
||||
void freeVec(SwsVector *a);
|
||||
void sws_printVec(SwsVector *a);
|
||||
void sws_freeVec(SwsVector *a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
16
spudec.c
16
spudec.c
@ -724,27 +724,27 @@ static void scale_image(int x, int y, scale_pixel* table_x, scale_pixel* table_y
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user