📄 cl_cin.c
字号:
ddst[0] = dsrc[0]; ddst[1] = dsrc[1];
dsrc += 2; ddst += dspl;
ddst[0] = dsrc[0]; ddst[1] = dsrc[1];
dsrc += 2; ddst += dspl;
ddst[0] = dsrc[0]; ddst[1] = dsrc[1];
dsrc += 2; ddst += dspl;
ddst[0] = dsrc[0]; ddst[1] = dsrc[1];
}
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static void blit2_32( byte *src, byte *dst, int spl )
{
double *dsrc, *ddst;
int dspl;
dsrc = (double *)src;
ddst = (double *)dst;
dspl = spl>>3;
ddst[0] = dsrc[0];
ddst[dspl] = dsrc[1];
}
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static void blitVQQuad32fs( byte **status, unsigned char *data )
{
unsigned short newd, celdata, code;
unsigned int index, i;
int spl;
newd = 0;
celdata = 0;
index = 0;
spl = cinTable[currentHandle].samplesPerLine;
do {
if (!newd) {
newd = 7;
celdata = data[0] + data[1]*256;
data += 2;
} else {
newd--;
}
code = (unsigned short)(celdata&0xc000);
celdata <<= 2;
switch (code) {
case 0x8000: // vq code
blit8_32( (byte *)&vq8[(*data)*128], status[index], spl );
data++;
index += 5;
break;
case 0xc000: // drop
index++; // skip 8x8
for(i=0;i<4;i++) {
if (!newd) {
newd = 7;
celdata = data[0] + data[1]*256;
data += 2;
} else {
newd--;
}
code = (unsigned short)(celdata&0xc000); celdata <<= 2;
switch (code) { // code in top two bits of code
case 0x8000: // 4x4 vq code
blit4_32( (byte *)&vq4[(*data)*32], status[index], spl );
data++;
break;
case 0xc000: // 2x2 vq code
blit2_32( (byte *)&vq2[(*data)*8], status[index], spl );
data++;
blit2_32( (byte *)&vq2[(*data)*8], status[index]+8, spl );
data++;
blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2, spl );
data++;
blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2+8, spl );
data++;
break;
case 0x4000: // motion compensation
move4_32( status[index] + cin.mcomp[(*data)], status[index], spl );
data++;
break;
}
index++;
}
break;
case 0x4000: // motion compensation
move8_32( status[index] + cin.mcomp[(*data)], status[index], spl );
data++;
index += 5;
break;
case 0x0000:
index += 5;
break;
}
} while ( status[index] != NULL );
}
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static void ROQ_GenYUVTables( void )
{
float t_ub,t_vr,t_ug,t_vg;
long i;
t_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f;
t_vr = (1.40200f/2.0f) * (float)(1<<6) + 0.5f;
t_ug = (0.34414f/2.0f) * (float)(1<<6) + 0.5f;
t_vg = (0.71414f/2.0f) * (float)(1<<6) + 0.5f;
for(i=0;i<256;i++) {
float x = (float)(2 * i - 255);
ROQ_UB_tab[i] = (long)( ( t_ub * x) + (1<<5));
ROQ_VR_tab[i] = (long)( ( t_vr * x) + (1<<5));
ROQ_UG_tab[i] = (long)( (-t_ug * x) );
ROQ_VG_tab[i] = (long)( (-t_vg * x) + (1<<5));
ROQ_YY_tab[i] = (long)( (i << 6) | (i >> 2) );
}
}
#define VQ2TO4(a,b,c,d) { \
*c++ = a[0]; \
*d++ = a[0]; \
*d++ = a[0]; \
*c++ = a[1]; \
*d++ = a[1]; \
*d++ = a[1]; \
*c++ = b[0]; \
*d++ = b[0]; \
*d++ = b[0]; \
*c++ = b[1]; \
*d++ = b[1]; \
*d++ = b[1]; \
*d++ = a[0]; \
*d++ = a[0]; \
*d++ = a[1]; \
*d++ = a[1]; \
*d++ = b[0]; \
*d++ = b[0]; \
*d++ = b[1]; \
*d++ = b[1]; \
a += 2; b += 2; }
#define VQ2TO2(a,b,c,d) { \
*c++ = *a; \
*d++ = *a; \
*d++ = *a; \
*c++ = *b; \
*d++ = *b; \
*d++ = *b; \
*d++ = *a; \
*d++ = *a; \
*d++ = *b; \
*d++ = *b; \
a++; b++; }
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static unsigned short yuv_to_rgb( long y, long u, long v )
{
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 9;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8;
b = (YY + ROQ_UB_tab[u]) >> 9;
if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;
if (r > 31) r = 31; if (g > 63) g = 63; if (b > 31) b = 31;
return (unsigned short)((r<<11)+(g<<5)+(b));
}
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
#if defined(MACOS_X)
static inline unsigned int yuv_to_rgb24( long y, long u, long v )
{
long r,g,b,YY;
YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 6;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;
b = (YY + ROQ_UB_tab[u]) >> 6;
if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;
if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;
return ((r<<24)|(g<<16)|(b<<8))|(255); //+(255<<24));
}
#else
static unsigned int yuv_to_rgb24( long y, long u, long v )
{
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 6;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;
b = (YY + ROQ_UB_tab[u]) >> 6;
if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;
if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;
return LittleLong ((r)|(g<<8)|(b<<16)|(255<<24));
}
#endif
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static void decodeCodeBook( byte *input, unsigned short roq_flags )
{
long i, j, two, four;
unsigned short *aptr, *bptr, *cptr, *dptr;
long y0,y1,y2,y3,cr,cb;
byte *bbptr, *baptr, *bcptr, *bdptr;
unsigned int *iaptr, *ibptr, *icptr, *idptr;
if (!roq_flags) {
two = four = 256;
} else {
two = roq_flags>>8;
if (!two) two = 256;
four = roq_flags&0xff;
}
four *= 2;
bptr = (unsigned short *)vq2;
if (!cinTable[currentHandle].half) {
if (!cinTable[currentHandle].smootheddouble) {
//
// normal height
//
if (cinTable[currentHandle].samplesPerPixel==2) {
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
y2 = (long)*input++;
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
*bptr++ = yuv_to_rgb( y0, cr, cb );
*bptr++ = yuv_to_rgb( y1, cr, cb );
*bptr++ = yuv_to_rgb( y2, cr, cb );
*bptr++ = yuv_to_rgb( y3, cr, cb );
}
cptr = (unsigned short *)vq4;
dptr = (unsigned short *)vq8;
for(i=0;i<four;i++) {
aptr = (unsigned short *)vq2 + (*input++)*4;
bptr = (unsigned short *)vq2 + (*input++)*4;
for(j=0;j<2;j++)
VQ2TO4(aptr,bptr,cptr,dptr);
}
} else if (cinTable[currentHandle].samplesPerPixel==4) {
ibptr = (unsigned int *)bptr;
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
y2 = (long)*input++;
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb );
*ibptr++ = yuv_to_rgb24( y3, cr, cb );
}
icptr = (unsigned int *)vq4;
idptr = (unsigned int *)vq8;
for(i=0;i<four;i++) {
iaptr = (unsigned int *)vq2 + (*input++)*4;
ibptr = (unsigned int *)vq2 + (*input++)*4;
for(j=0;j<2;j++)
VQ2TO4(iaptr, ibptr, icptr, idptr);
}
} else if (cinTable[currentHandle].samplesPerPixel==1) {
bbptr = (byte *)bptr;
for(i=0;i<two;i++) {
*bbptr++ = cinTable[currentHandle].gray[*input++];
*bbptr++ = cinTable[currentHandle].gray[*input++];
*bbptr++ = cinTable[currentHandle].gray[*input++];
*bbptr++ = cinTable[currentHandle].gray[*input]; input +=3;
}
bcptr = (byte *)vq4;
bdptr = (byte *)vq8;
for(i=0;i<four;i++) {
baptr = (byte *)vq2 + (*input++)*4;
bbptr = (byte *)vq2 + (*input++)*4;
for(j=0;j<2;j++)
VQ2TO4(baptr,bbptr,bcptr,bdptr);
}
}
} else {
//
// double height, smoothed
//
if (cinTable[currentHandle].samplesPerPixel==2) {
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
y2 = (long)*input++;
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
*bptr++ = yuv_to_rgb( y0, cr, cb );
*bptr++ = yuv_to_rgb( y1, cr, cb );
*bptr++ = yuv_to_rgb( ((y0*3)+y2)/4, cr, cb );
*bptr++ = yuv_to_rgb( ((y1*3)+y3)/4, cr, cb );
*bptr++ = yuv_to_rgb( (y0+(y2*3))/4, cr, cb );
*bptr++ = yuv_to_rgb( (y1+(y3*3))/4, cr, cb );
*bptr++ = yuv_to_rgb( y2, cr, cb );
*bptr++ = yuv_to_rgb( y3, cr, cb );
}
cptr = (unsigned short *)vq4;
dptr = (unsigned short *)vq8;
for(i=0;i<four;i++) {
aptr = (unsigned short *)vq2 + (*input++)*8;
bptr = (unsigned short *)vq2 + (*input++)*8;
for(j=0;j<2;j++) {
VQ2TO4(aptr,bptr,cptr,dptr);
VQ2TO4(aptr,bptr,cptr,dptr);
}
}
} else if (cinTable[currentHandle].samplesPerPixel==4) {
ibptr = (unsigned int *)bptr;
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
y2 = (long)*input++;
y3 = (long)*input++;
cr = (long)*input++;
cb = (long)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );
*ibptr++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb );
*ibptr++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb );
*ibptr++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb );
*ibptr++ = yuv_to_rgb24( y3, cr, cb );
}
icptr = (unsigned int *)vq4;
idptr = (unsigned int *)vq8;
for(i=0;i<four;i++) {
iaptr = (unsigned int *)vq2 + (*input++)*8;
ibptr = (unsigned int *)vq2 + (*input++)*8;
for(j=0;j<2;j++) {
VQ2TO4(iaptr, ibptr, icptr, idptr);
VQ2TO4(iaptr, ibptr, icptr, idptr);
}
}
} else if (cinTable[currentHandle].samplesPerPixel==1) {
bbptr = (byte *)bptr;
for(i=0;i<two;i++) {
y0 = (long)*input++;
y1 = (long)*input++;
y2 = (long)*input++;
y3 = (long)*input; input+= 3;
*bbptr++ = cinTable[currentHandle].gray[y0];
*bbptr++ = cinTable[currentHandle].gray[y1];
*bbptr++ = cinTable[currentHandle].gray[((y0*3)+y2)/4];
*bbptr++ = cinTable[currentHandle].gray[((y1*3)+y3)/4];
*bbptr++ = cinTable[currentHandle].gray[(y0+(y2*3))/4];
*bbptr++ = cinTable[currentHandle].gray[(y1+(y3*3))/4];
*bbptr++ = cinTable[currentHandle].gray[y2];
*bbptr++ = cinTable[currentHandle].gray[y3];
}
bcptr = (byte *)vq4;
bdptr = (byte *)vq8;
for(i=0;i<four;i++) {
baptr = (byte *)vq2 + (*input++)*8;
bbptr = (byte *)vq2 + (*input++)*8;
for(j=0;j<2;j++) {
VQ2TO4(baptr,bbptr,bcptr,bdptr);
VQ2TO4(baptr,bbptr,bcptr,bdptr);
}
}
}
}
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -