patch_idct.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "llmath.h"
00035 //#include "vmath.h"
00036 #include "v3math.h"
00037 #include "patch_dct.h"
00038 
00039 LLGroupHeader   *gGOPP;
00040 
00041 void set_group_of_patch_header(LLGroupHeader *gopp)
00042 {
00043         gGOPP = gopp;
00044 }
00045 
00046 F32 gPatchDequantizeTable[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
00047 void build_patch_dequantize_table(S32 size)
00048 {
00049         S32 i, j;
00050         for (j = 0; j < size; j++)
00051         {
00052                 for (i = 0; i < size; i++)
00053                 {
00054                         gPatchDequantizeTable[j*size + i] = (1.f + 2.f*(i+j));
00055                 }
00056         }
00057 }
00058 
00059 S32     gCurrentDeSize = 0;
00060 
00061 F32     gPatchICosines[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
00062 
00063 void setup_patch_icosines(S32 size)
00064 {
00065         S32 n, u;
00066         F32 oosob = F_PI*0.5f/size;
00067 
00068         for (u = 0; u < size; u++)
00069         {
00070                 for (n = 0; n < size; n++)
00071                 {
00072                         gPatchICosines[u*size+n] = cosf((2.f*n+1.f)*u*oosob);
00073                 }
00074         }
00075 }
00076 
00077 S32     gDeCopyMatrix[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
00078 
00079 void build_decopy_matrix(S32 size)
00080 {
00081         S32 i, j, count;
00082         BOOL    b_diag = FALSE;
00083         BOOL    b_right = TRUE;
00084 
00085         i = 0;
00086         j = 0;
00087         count = 0;
00088 
00089         while (  (i < size)
00090                    &&(j < size))
00091         {
00092                 gDeCopyMatrix[j*size + i] = count;
00093 
00094                 count++;
00095 
00096                 if (!b_diag)
00097                 {
00098                         if (b_right)
00099                         {
00100                                 if (i < size - 1)
00101                                         i++;
00102                                 else
00103                                         j++;
00104                                 b_right = FALSE;
00105                                 b_diag = TRUE;
00106                         }
00107                         else
00108                         {
00109                                 if (j < size - 1)
00110                                         j++;
00111                                 else
00112                                         i++;
00113                                 b_right = TRUE;
00114                                 b_diag = TRUE;
00115                         }
00116                 }
00117                 else
00118                 {
00119                         if (b_right)
00120                         {
00121                                 i++;
00122                                 j--;
00123                                 if (  (i == size - 1)
00124                                         ||(j == 0))
00125                                 {
00126                                         b_diag = FALSE;
00127                                 }
00128                         }
00129                         else
00130                         {
00131                                 i--;
00132                                 j++;
00133                                 if (  (i == 0)
00134                                         ||(j == size - 1))
00135                                 {
00136                                         b_diag = FALSE;
00137                                 }
00138                         }
00139                 }
00140         }
00141 }
00142 
00143 void init_patch_decompressor(S32 size)
00144 {
00145         if (size != gCurrentDeSize)
00146         {
00147                 gCurrentDeSize = size;
00148                 build_patch_dequantize_table(size);
00149                 setup_patch_icosines(size);
00150                 build_decopy_matrix(size);
00151         }
00152 }
00153 
00154 inline void idct_line(F32 *linein, F32 *lineout, S32 line)
00155 {
00156         S32 n;
00157         F32 total;
00158         F32 *pcp = gPatchICosines;
00159 
00160 #ifdef _PATCH_SIZE_16_AND_32_ONLY
00161         F32 oosob = 2.f/16.f;
00162         S32     line_size = line*NORMAL_PATCH_SIZE;
00163         F32 *tlinein, *tpcp;
00164 
00165 
00166         for (n = 0; n < NORMAL_PATCH_SIZE; n++)
00167         {
00168                 tpcp = pcp + n;
00169                 tlinein = linein + line_size;
00170         
00171                 total = OO_SQRT2*(*(tlinein++));
00172                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00173                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00174                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00175 
00176                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00177                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00178                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00179                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00180 
00181                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00182                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00183                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00184                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00185 
00186                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00187                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00188                 total += *(tlinein++)*(*(tpcp += NORMAL_PATCH_SIZE));
00189                 total += *(tlinein)*(*(tpcp += NORMAL_PATCH_SIZE));
00190 
00191                 *(lineout + line_size + n) = total*oosob;
00192         }
00193 #else
00194         F32 oosob = 2.f/size;
00195         S32     size = gGOPP->patch_size;
00196         S32     line_size = line*size;
00197         S32 u;
00198         for (n = 0; n < size; n++)
00199         {
00200                 total = OO_SQRT2*linein[line_size];
00201                 for (u = 1; u < size; u++)
00202                 {
00203                         total += linein[line_size + u]*pcp[u*size+n];
00204                 }
00205                 lineout[line_size + n] = total*oosob;
00206         }
00207 #endif
00208 }
00209 
00210 inline void idct_line_large_slow(F32 *linein, F32 *lineout, S32 line)
00211 {
00212         S32 n;
00213         F32 total;
00214         F32 *pcp = gPatchICosines;
00215 
00216         F32 oosob = 2.f/32.f;
00217         S32     line_size = line*LARGE_PATCH_SIZE;
00218         F32 *tlinein, *tpcp;
00219 
00220 
00221         for (n = 0; n < LARGE_PATCH_SIZE; n++)
00222         {
00223                 tpcp = pcp + n;
00224                 tlinein = linein + line_size;
00225         
00226                 total = OO_SQRT2*(*(tlinein++));
00227                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00228                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00229                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00230 
00231                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00232                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00233                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00234                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00235 
00236                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00237                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00238                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00239                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00240 
00241                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00242                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00243                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00244                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00245 
00246                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00247                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00248                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00249                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00250 
00251                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00252                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00253                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00254                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00255 
00256                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00257                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00258                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00259                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00260 
00261                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00262                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00263                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00264                 total += *(tlinein)*(*(tpcp += LARGE_PATCH_SIZE));
00265 
00266                 *(lineout + line_size + n) = total*oosob;
00267         }
00268 }
00269 
00270 // Nota Bene: assumes that coefficients beyond 128 are 0!
00271 
00272 void idct_line_large(F32 *linein, F32 *lineout, S32 line)
00273 {
00274         S32 n;
00275         F32 total;
00276         F32 *pcp = gPatchICosines;
00277 
00278         F32 oosob = 2.f/32.f;
00279         S32     line_size = line*LARGE_PATCH_SIZE;
00280         F32 *tlinein, *tpcp;
00281         F32 *baselinein = linein + line_size;
00282         F32 *baselineout = lineout + line_size;
00283 
00284 
00285         for (n = 0; n < LARGE_PATCH_SIZE; n++)
00286         {
00287                 tpcp = pcp++;
00288                 tlinein = baselinein;
00289         
00290                 total = OO_SQRT2*(*(tlinein++));
00291                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00292                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00293                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00294 
00295                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00296                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00297                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00298                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00299 
00300                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00301                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00302                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00303                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00304 
00305                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00306                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00307                 total += *(tlinein++)*(*(tpcp += LARGE_PATCH_SIZE));
00308                 total += *(tlinein)*(*(tpcp));
00309 
00310                 *baselineout++ = total*oosob;
00311         }
00312 }
00313 
00314 inline void idct_column(F32 *linein, F32 *lineout, S32 column)
00315 {
00316         S32 n;
00317         F32 total;
00318         F32 *pcp = gPatchICosines;
00319 
00320 #ifdef _PATCH_SIZE_16_AND_32_ONLY
00321         F32 *tlinein, *tpcp;
00322 
00323         for (n = 0; n < NORMAL_PATCH_SIZE; n++)
00324         {
00325                 tpcp = pcp + n;
00326                 tlinein = linein + column;
00327 
00328                 total = OO_SQRT2*(*tlinein);
00329                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00330                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00331                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00332 
00333                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00334                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00335                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00336                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00337 
00338                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00339                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00340                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00341                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00342 
00343                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00344                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00345                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00346                 total += *(tlinein += NORMAL_PATCH_SIZE)*(*(tpcp += NORMAL_PATCH_SIZE));
00347 
00348                 *(lineout + (n<<4) + column) = total;
00349         }
00350 
00351 #else
00352         S32     size = gGOPP->patch_size;
00353         S32 u;
00354         S32 u_size;
00355 
00356         for (n = 0; n < size; n++)
00357         {
00358                 total = OO_SQRT2*linein[column];
00359                 for (u = 1; u < size; u++)
00360                 {
00361                         u_size = u*size;
00362                         total += linein[u_size + column]*pcp[u_size+n];
00363                 }
00364                 lineout[size*n + column] = total;
00365         }
00366 #endif
00367 }
00368 
00369 inline void idct_column_large_slow(F32 *linein, F32 *lineout, S32 column)
00370 {
00371         S32 n;
00372         F32 total;
00373         F32 *pcp = gPatchICosines;
00374 
00375         F32 *tlinein, *tpcp;
00376 
00377         for (n = 0; n < LARGE_PATCH_SIZE; n++)
00378         {
00379                 tpcp = pcp + n;
00380                 tlinein = linein + column;
00381 
00382                 total = OO_SQRT2*(*tlinein);
00383                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00384                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00385                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00386 
00387                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00388                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00389                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00390                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00391 
00392                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00393                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00394                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00395                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00396 
00397                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00398                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00399                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00400                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00401 
00402                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00403                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00404                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00405                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00406 
00407                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00408                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00409                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00410                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00411 
00412                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00413                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00414                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00415                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00416 
00417                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00418                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00419                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00420                 total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00421 
00422                 *(lineout + (n<<5) + column) = total;
00423         }
00424 }
00425 
00426 // Nota Bene: assumes that coefficients beyond 128 are 0!
00427 
00428 void idct_column_large(F32 *linein, F32 *lineout, S32 column)
00429 {
00430         S32 n, m;
00431         F32 total;
00432         F32 *pcp = gPatchICosines;
00433 
00434         F32 *tlinein, *tpcp;
00435         F32 *baselinein = linein + column;
00436         F32 *baselineout = lineout + column;
00437 
00438         for (n = 0; n < LARGE_PATCH_SIZE; n++)
00439         {
00440                 tpcp = pcp++;
00441                 tlinein = baselinein;
00442 
00443                 total = OO_SQRT2*(*tlinein);
00444                 for (m = 1; m < NORMAL_PATCH_SIZE; m++)
00445                         total += *(tlinein += LARGE_PATCH_SIZE)*(*(tpcp += LARGE_PATCH_SIZE));
00446 
00447                 *(baselineout + (n<<5)) = total;
00448         }
00449 }
00450 
00451 inline void idct_patch(F32 *block)
00452 {
00453         F32 temp[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
00454 
00455 #ifdef _PATCH_SIZE_16_AND_32_ONLY
00456         idct_column(block, temp, 0);    
00457         idct_column(block, temp, 1);    
00458         idct_column(block, temp, 2);    
00459         idct_column(block, temp, 3);    
00460 
00461         idct_column(block, temp, 4);    
00462         idct_column(block, temp, 5);    
00463         idct_column(block, temp, 6);    
00464         idct_column(block, temp, 7);    
00465 
00466         idct_column(block, temp, 8);    
00467         idct_column(block, temp, 9);    
00468         idct_column(block, temp, 10);   
00469         idct_column(block, temp, 11);   
00470 
00471         idct_column(block, temp, 12);   
00472         idct_column(block, temp, 13);   
00473         idct_column(block, temp, 14);   
00474         idct_column(block, temp, 15);   
00475 
00476         idct_line(temp, block, 0);      
00477         idct_line(temp, block, 1);      
00478         idct_line(temp, block, 2);      
00479         idct_line(temp, block, 3);      
00480 
00481         idct_line(temp, block, 4);      
00482         idct_line(temp, block, 5);      
00483         idct_line(temp, block, 6);      
00484         idct_line(temp, block, 7);      
00485 
00486         idct_line(temp, block, 8);      
00487         idct_line(temp, block, 9);      
00488         idct_line(temp, block, 10);     
00489         idct_line(temp, block, 11);     
00490 
00491         idct_line(temp, block, 12);     
00492         idct_line(temp, block, 13);     
00493         idct_line(temp, block, 14);     
00494         idct_line(temp, block, 15);     
00495 #else
00496         S32 i;
00497         S32     size = gGOPP->patch_size;
00498         for (i = 0; i < size; i++)
00499         {
00500                 idct_column(block, temp, i);    
00501         }
00502         for (i = 0; i < size; i++)
00503         {
00504                 idct_line(temp, block, i);      
00505         }
00506 #endif
00507 }
00508 
00509 inline void idct_patch_large(F32 *block)
00510 {
00511         F32 temp[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
00512 
00513         idct_column_large_slow(block, temp, 0); 
00514         idct_column_large_slow(block, temp, 1); 
00515         idct_column_large_slow(block, temp, 2); 
00516         idct_column_large_slow(block, temp, 3); 
00517 
00518         idct_column_large_slow(block, temp, 4); 
00519         idct_column_large_slow(block, temp, 5); 
00520         idct_column_large_slow(block, temp, 6); 
00521         idct_column_large_slow(block, temp, 7); 
00522 
00523         idct_column_large_slow(block, temp, 8); 
00524         idct_column_large_slow(block, temp, 9); 
00525         idct_column_large_slow(block, temp, 10);        
00526         idct_column_large_slow(block, temp, 11);        
00527 
00528         idct_column_large_slow(block, temp, 12);        
00529         idct_column_large_slow(block, temp, 13);        
00530         idct_column_large_slow(block, temp, 14);        
00531         idct_column_large_slow(block, temp, 15);        
00532 
00533         idct_column_large_slow(block, temp, 16);        
00534         idct_column_large_slow(block, temp, 17);        
00535         idct_column_large_slow(block, temp, 18);        
00536         idct_column_large_slow(block, temp, 19);        
00537 
00538         idct_column_large_slow(block, temp, 20);        
00539         idct_column_large_slow(block, temp, 21);        
00540         idct_column_large_slow(block, temp, 22);        
00541         idct_column_large_slow(block, temp, 23);        
00542 
00543         idct_column_large_slow(block, temp, 24);        
00544         idct_column_large_slow(block, temp, 25);        
00545         idct_column_large_slow(block, temp, 26);        
00546         idct_column_large_slow(block, temp, 27);        
00547 
00548         idct_column_large_slow(block, temp, 28);        
00549         idct_column_large_slow(block, temp, 29);        
00550         idct_column_large_slow(block, temp, 30);        
00551         idct_column_large_slow(block, temp, 31);        
00552 
00553         idct_line_large_slow(temp, block, 0);   
00554         idct_line_large_slow(temp, block, 1);   
00555         idct_line_large_slow(temp, block, 2);   
00556         idct_line_large_slow(temp, block, 3);   
00557 
00558         idct_line_large_slow(temp, block, 4);   
00559         idct_line_large_slow(temp, block, 5);   
00560         idct_line_large_slow(temp, block, 6);   
00561         idct_line_large_slow(temp, block, 7);   
00562 
00563         idct_line_large_slow(temp, block, 8);   
00564         idct_line_large_slow(temp, block, 9);   
00565         idct_line_large_slow(temp, block, 10);  
00566         idct_line_large_slow(temp, block, 11);  
00567 
00568         idct_line_large_slow(temp, block, 12);  
00569         idct_line_large_slow(temp, block, 13);  
00570         idct_line_large_slow(temp, block, 14);  
00571         idct_line_large_slow(temp, block, 15);  
00572 
00573         idct_line_large_slow(temp, block, 16);  
00574         idct_line_large_slow(temp, block, 17);  
00575         idct_line_large_slow(temp, block, 18);  
00576         idct_line_large_slow(temp, block, 19);  
00577 
00578         idct_line_large_slow(temp, block, 20);  
00579         idct_line_large_slow(temp, block, 21);  
00580         idct_line_large_slow(temp, block, 22);  
00581         idct_line_large_slow(temp, block, 23);  
00582 
00583         idct_line_large_slow(temp, block, 24);  
00584         idct_line_large_slow(temp, block, 25);  
00585         idct_line_large_slow(temp, block, 26);  
00586         idct_line_large_slow(temp, block, 27);  
00587 
00588         idct_line_large_slow(temp, block, 28);  
00589         idct_line_large_slow(temp, block, 29);  
00590         idct_line_large_slow(temp, block, 30);  
00591         idct_line_large_slow(temp, block, 31);  
00592 }
00593 
00594 S32     gDitherNoise = 128;
00595 
00596 void decompress_patch(F32 *patch, S32 *cpatch, LLPatchHeader *ph)
00597 {
00598         S32             i, j;
00599 
00600         F32             block[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE], *tblock = block;
00601         F32             *tpatch;
00602 
00603         LLGroupHeader   *gopp = gGOPP;
00604         S32             size = gopp->patch_size;
00605         F32             range = ph->range;
00606         S32             prequant = (ph->quant_wbits >> 4) + 2;
00607         S32             quantize = 1<<prequant;
00608         F32             hmin = ph->dc_offset;
00609         S32             stride = gopp->stride;
00610 
00611         F32             ooq = 1.f/(F32)quantize;
00612         F32     *dq = gPatchDequantizeTable;
00613         S32             *decopy_matrix = gDeCopyMatrix;
00614 
00615         F32             mult = ooq*range;
00616         F32             addval = mult*(F32)(1<<(prequant - 1))+hmin;
00617 
00618         for (i = 0; i < size*size; i++)
00619         {
00620                 *(tblock++) = *(cpatch + *(decopy_matrix++))*(*dq++);
00621         }
00622 
00623         if (size == 16)
00624         {
00625                 idct_patch(block);
00626         }
00627         else
00628         {
00629                 idct_patch_large(block);
00630         }
00631 
00632         for (j = 0; j < size; j++)
00633         {
00634                 tpatch = patch + j*stride;
00635                 tblock = block + j*size;
00636                 for (i = 0; i < size; i++)
00637                 {
00638                         *(tpatch++) = *(tblock++)*mult+addval;
00639                 }
00640         }
00641 }
00642 
00643 
00644 void decompress_patchv(LLVector3 *v, S32 *cpatch, LLPatchHeader *ph)
00645 {
00646         S32             i, j;
00647 
00648         F32                     block[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE], *tblock = block;
00649         LLVector3       *tvec;
00650 
00651         LLGroupHeader   *gopp = gGOPP;
00652         S32             size = gopp->patch_size;
00653         F32             range = ph->range;
00654         S32             prequant = (ph->quant_wbits >> 4) + 2;
00655         S32             quantize = 1<<prequant;
00656         F32             hmin = ph->dc_offset;
00657         S32             stride = gopp->stride;
00658 
00659         F32             ooq = 1.f/(F32)quantize;
00660         F32     *dq = gPatchDequantizeTable;
00661         S32             *decopy_matrix = gDeCopyMatrix;
00662 
00663         F32             mult = ooq*range;
00664         F32             addval = mult*(F32)(1<<(prequant - 1))+hmin;
00665 
00666 //      BOOL    b_diag = FALSE;
00667 //      BOOL    b_right = TRUE;
00668 
00669         for (i = 0; i < size*size; i++)
00670         {
00671                 *(tblock++) = *(cpatch + *(decopy_matrix++))*(*dq++);
00672         }
00673 
00674         if (size == 16)
00675                 idct_patch(block);
00676         else
00677                 idct_patch_large(block);
00678 
00679         for (j = 0; j < size; j++)
00680         {
00681                 tvec = v + j*stride;
00682                 tblock = block + j*size;
00683                 for (i = 0; i < size; i++)
00684                 {
00685                         (*tvec++).mV[VZ] = *(tblock++)*mult+addval;
00686                 }
00687         }
00688 }
00689 

Generated on Thu Jul 1 06:09:57 2010 for Second Life Viewer by  doxygen 1.4.7