int ScaleImage(void *p_src, int src_width, int src_height, int src_fmt,
int src_offset1, int src_offset2, int src_offset3, void *p_dest, int dest_width, int dest_height,
int dest_offset1, int dest_offset2, int dest_offset3)
{
if(p_src==0) return -1;
if(p_dest==0) return -2;
Cache_inv(p_src, 6*(src_offset3-src_offset2), Cache_Type_ALL, TRUE);
unsigned int x,y;
long srcx_16,srcy_16;
char *ySrcline,*uSrcline,*vSrcline;
char *yDstline,*uDstline,*vDstline;
long xrIntFloat_16=(src_width<<16)/dest_width+1; //16.16格式定点数
long yrIntFloat_16=(src_height<<16)/dest_height+1; //16.16格式定点数
if((src_width{
yDstline=p_dest+dest_offset1+(dest_height-1)*dest_width;
srcy_16=yrIntFloat_16*(src_width-1);
for (y=dest_height-1;y>=0;--y)
{
ySrcline= p_src+src_offset1+(srcy_16>>16);
long srcx_16=xrIntFloat_16*(src_width-1);
for (x=dest_width-1;x>=0;--x)
{
yDstline[x]=ySrcline[srcx_16>>16];
srcx_16-=xrIntFloat_16;
}
srcy_16-=yrIntFloat_16;
yDstline-=dest_width;
}
dest_width=dest_width>>1;
dest_height=dest_height>>1;
src_width=src_width>>1;
src_height=src_height>>1;
uDstline=p_dest+dest_offset2+(dest_height-1)*dest_width;
vDstline=p_dest+dest_offset3+(dest_height-1)*dest_width;
srcy_16=yrIntFloat_16*(src_width-1);
for ( y=dest_height-1;y>=0;--y)
{
uSrcline= p_src+src_offset2+(srcy_16>>16);
vSrcline= p_src+src_offset3+(srcy_16>>16);
srcx_16=xrIntFloat_16*(src_width-1);
for (x=dest_width-1;x>=0;--x)
{
uDstline[x]=uSrcline[srcx_16>>16];
vDstline[x]=vSrcline[srcx_16>>16];
srcx_16-=xrIntFloat_16;
}
srcy_16-=yrIntFloat_16;
uDstline-=dest_width;
vDstline-=dest_width;
}
}
else
{
yDstline=p_dest+dest_offset1;
srcy_16=0;
for (y=0;y{
ySrcline=p_src+src_offset1+(srcy_16>>16);
srcx_16=0;
for (x=0;x{
yDstline[x]=ySrcline[srcx_16>>16];
srcx_16+=xrIntFloat_16;
}
srcy_16+=yrIntFloat_16;
yDstline+=dest_width;
}
dest_width=dest_width>>1;
dest_height=dest_height>>1;
src_width=src_width>>1;
src_height=src_height>>1;
uDstline=p_dest+dest_offset2;
vDstline=p_dest+dest_offset3;
srcy_16=0;
for (y=0;y{
uSrcline=p_src+src_offset2+(srcy_16>>16);
vSrcline=p_src+src_offset3+(srcy_16>>16);
srcx_16=0;
for (x=0;x{
uDstline[x]=uSrcline[srcx_16>>16];
vDstline[x]=vSrcline[srcx_16>>16];
srcx_16+=xrIntFloat_16;
}
srcy_16+=yrIntFloat_16;
uDstline+=dest_width;
vDstline+=dest_width;
}
}
Cache_wb(p_src, 6*(src_offset3-src_offset2), Cache_Type_ALL, TRUE);
return 0;
}