Ticket #8611: 32bit_try02.patch
File 32bit_try02.patch, 57.3 KB (added by , 17 years ago) |
---|
-
backends/platform/sdl/graphics.cpp
145 145 bool OSystem_SDL::setGraphicsMode(int mode) { 146 146 Common::StackLock lock(_graphicsMutex); 147 147 148 bool needHotSwap = false; 148 149 int newScaleFactor = 1; 149 150 ScalerProc *newScalerProc; 150 151 … … 211 212 _transactionDetails.normal1xScaler = (mode == GFX_NORMAL); 212 213 213 214 _mode = mode; 215 216 #ifndef DISABLE_HQ_SCALERS 217 // Hotswapping (to change the color depth) when switching to and from 218 // HQ-scalers. They use lookup-tables for color conversion and therefore 219 // won't work for 32 bit graphics 220 if (_scalerProc != newScalerProc) { 221 if (((newScalerProc == HQ2x) || (newScalerProc == HQ3x)) && 222 (_curBytesPerPixel == 4)) 223 needHotSwap = true; 224 if (((_scalerProc == HQ2x) || (_scalerProc == HQ3x)) && 225 (_bytesPerPixel > 2)) 226 needHotSwap = true; 227 } 228 #endif 229 214 230 _scalerProc = newScalerProc; 215 231 216 232 if (_transactionMode == kTransactionActive) { … … 230 246 // NOTE: This should not be executed at transaction commit 231 247 // Otherwise there is some unsolicited setGraphicsMode() call 232 248 // which should be properly removed 233 if ( newScaleFactor != _scaleFactor) {249 if ((newScaleFactor != _scaleFactor) || needHotSwap) { 234 250 assert(_transactionMode != kTransactionCommit); 235 251 236 252 _scaleFactor = newScaleFactor; … … 337 353 error("allocating _screen failed"); 338 354 339 355 // 340 // C reate the surface that contains the scaled graphics in 16 bit mode356 // Check whether to use 32 or 16 bit colors 341 357 // 342 358 343 _hwscreen = SDL_SetVideoMode(hwW, hwH, 16, 359 // If a color depth of more than 16 bit is supported by the system, 360 // use 32 bit. Don't, if a HQ-scaler is in use, though, because these 361 // scalers use lookup-tables (RGBtoYUV and LUT16to32) for color conversion. 362 if ((_bytesPerPixel > 2) && (_scalerProc != HQ2x) && (_scalerProc != HQ3x)) 363 _curBytesPerPixel = 4; 364 else 365 _curBytesPerPixel = 2; 366 367 // 368 // Create the surface that contains the scaled graphics in 32/16 bit mode 369 // 370 371 _hwscreen = SDL_SetVideoMode(hwW, hwH, _curBytesPerPixel * 8, 344 372 _fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 345 373 ); 346 374 if (_hwscreen == NULL) { … … 368 396 // Create the surface used for the graphics in 16 bit before scaling, and also the overlay 369 397 // 370 398 371 // Distinguish 555 and 565 mode 372 if (_hwscreen->format->Rmask == 0x7C00) 373 InitScalers(555); 374 else 375 InitScalers(565); 399 // 400 if (_curBytesPerPixel == 2) { 401 _Rmask = _hwscreen->format->Rmask; 402 _Gmask = _hwscreen->format->Gmask; 403 _Bmask = _hwscreen->format->Bmask; 404 _Amask = _hwscreen->format->Amask; 405 // Distinguish 555 and 565 mode 406 if (_Rmask == 0x7C00) 407 InitScalers(555); 408 else 409 InitScalers(565); 410 } else { 411 // Use 565 format for 16 bit surfaces when using a 32 bit _hwscreen 412 _Rmask = 0xF800; 413 _Gmask = 0x07E0; 414 _Bmask = 0x001F; 415 _Amask = 0x0000; 416 InitScalers(8888); 417 } 376 418 377 419 // Need some extra bytes around when using 2xSaI 378 420 _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 379 16,421 _curBytesPerPixel * 8, 380 422 _hwscreen->format->Rmask, 381 423 _hwscreen->format->Gmask, 382 424 _hwscreen->format->Bmask, … … 386 428 error("allocating _tmpscreen failed"); 387 429 388 430 _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 389 16, 390 _hwscreen->format->Rmask, 391 _hwscreen->format->Gmask, 392 _hwscreen->format->Bmask, 393 _hwscreen->format->Amask); 431 16, _Rmask, _Gmask, _Bmask, _Amask); 394 432 395 433 if (_overlayscreen == NULL) 396 434 error("allocating _overlayscreen failed"); 397 435 398 436 _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 399 16, 437 16, _Rmask, _Gmask, _Bmask, _Amask); 438 439 if (_tmpscreen2 == NULL) 440 error("allocating _tmpscreen2 failed"); 441 442 _tmpscreen3 = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 443 16, _Rmask, _Gmask, _Bmask, _Amask); 444 445 if (_tmpscreen3 == NULL) 446 error("allocating _tmpscreen3 failed"); 447 448 _tmpscreen4 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 449 _curBytesPerPixel * 8, 400 450 _hwscreen->format->Rmask, 401 451 _hwscreen->format->Gmask, 402 452 _hwscreen->format->Bmask, 403 453 _hwscreen->format->Amask); 404 454 405 if (_tmpscreen 2== NULL)406 error("allocating _tmpscreen 2failed");455 if (_tmpscreen4 == NULL) 456 error("allocating _tmpscreen4 failed"); 407 457 408 458 #ifdef USE_OSD 409 459 _osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 410 460 _hwscreen->w, 411 461 _hwscreen->h, 412 16, 413 _hwscreen->format->Rmask, 414 _hwscreen->format->Gmask, 415 _hwscreen->format->Bmask, 416 _hwscreen->format->Amask); 462 16, _Rmask, _Gmask, _Bmask, _Amask); 417 463 if (_osdSurface == NULL) 418 464 error("allocating _osdSurface failed"); 419 465 SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey); … … 447 493 _tmpscreen2 = NULL; 448 494 } 449 495 496 if (_tmpscreen3) { 497 SDL_FreeSurface(_tmpscreen3); 498 _tmpscreen3 = NULL; 499 } 500 501 if (_tmpscreen4) { 502 SDL_FreeSurface(_tmpscreen4); 503 _tmpscreen4 = NULL; 504 } 505 450 506 if (_overlayscreen) { 451 507 SDL_FreeSurface(_overlayscreen); 452 508 _overlayscreen = NULL; … … 474 530 475 531 SDL_FreeSurface(_tmpscreen); 476 532 SDL_FreeSurface(_tmpscreen2); 533 SDL_FreeSurface(_tmpscreen3); 534 SDL_FreeSurface(_tmpscreen4); 477 535 478 536 #ifdef USE_OSD 479 537 // Release the OSD surface … … 578 636 scale1 = _scaleFactor; 579 637 } else { 580 638 origSurf = _overlayscreen; 581 srcSurf = _tmpscreen 2;639 srcSurf = _tmpscreen4; 582 640 width = _overlayWidth; 583 641 height = _overlayHeight; 584 642 scalerProc = Normal1x; … … 646 704 dst_y = real2Aspect(dst_y); 647 705 648 706 assert(scalerProc != NULL); 649 scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, 650 (byte *)_hwscreen->pixels + rx1 * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); 707 scalerProc((byte *)srcSurf->pixels + 708 (r->x * _curBytesPerPixel + _bytesPerPixel) + 709 (r->y + 1) * srcPitch, srcPitch, 710 (byte *)_hwscreen->pixels + 711 rx1 * _curBytesPerPixel + 712 dst_y * dstPitch, dstPitch, 713 r->w, dst_h, _curBytesPerPixel); 651 714 } 652 715 653 716 r->x = rx1; … … 657 720 658 721 #ifndef DISABLE_SCALERS 659 722 if (_adjustAspectRatio && orig_dst_y < height && !_overlayVisible) 660 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1 );723 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1, _curBytesPerPixel); 661 724 #endif 662 725 } 663 726 SDL_UnlockSurface(srcSurf); … … 1157 1220 dst.x = dst.y = 1; 1158 1221 src.w = dst.w = _screenWidth; 1159 1222 src.h = dst.h = _screenHeight; 1160 if (SDL_BlitSurface(_screen, &src, _tmpscreen , &dst) != 0)1223 if (SDL_BlitSurface(_screen, &src, _tmpscreen3, &dst) != 0) 1161 1224 error("SDL_BlitSurface failed: %s", SDL_GetError()); 1162 1225 1163 SDL_LockSurface(_tmpscreen );1226 SDL_LockSurface(_tmpscreen3); 1164 1227 SDL_LockSurface(_overlayscreen); 1165 _scalerProc((byte *)(_tmpscreen ->pixels) + _tmpscreen->pitch + 2, _tmpscreen->pitch,1228 _scalerProc((byte *)(_tmpscreen3->pixels) + _tmpscreen3->pitch + 2, _tmpscreen3->pitch, 1166 1229 (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight); 1167 1230 1168 1231 #ifndef DISABLE_SCALERS 1169 1232 if (_adjustAspectRatio) 1170 1233 stretch200To240((uint8 *)_overlayscreen->pixels, _overlayscreen->pitch, 1171 _overlayWidth, _screenHeight * _scaleFactor, 0, 0, 0 );1234 _overlayWidth, _screenHeight * _scaleFactor, 0, 0, 0, 2); 1172 1235 #endif 1173 SDL_UnlockSurface(_tmpscreen );1236 SDL_UnlockSurface(_tmpscreen3); 1174 1237 SDL_UnlockSurface(_overlayscreen); 1175 1238 1176 1239 _forceFull = true; … … 1317 1380 _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 1318 1381 _mouseCurState.w + 2, 1319 1382 _mouseCurState.h + 2, 1320 16, 1321 _hwscreen->format->Rmask, 1322 _hwscreen->format->Gmask, 1323 _hwscreen->format->Bmask, 1324 _hwscreen->format->Amask); 1383 16, _Rmask, _Gmask, _Bmask, _Amask); 1325 1384 1326 1385 if (_mouseOrigSurface == NULL) 1327 1386 error("allocating _mouseOrigSurface failed"); … … 1438 1497 _mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 1439 1498 _mouseCurState.rW, 1440 1499 _mouseCurState.rH, 1441 16, 1442 _hwscreen->format->Rmask, 1443 _hwscreen->format->Gmask, 1444 _hwscreen->format->Bmask, 1445 _hwscreen->format->Amask); 1500 16, _Rmask, _Gmask, _Bmask, _Amask); 1446 1501 1447 1502 if (_mouseSurface == NULL) 1448 1503 error("allocating _mouseSurface failed"); -
backends/platform/sdl/sdl.cpp
142 142 error("Could not initialize SDL: %s", SDL_GetError()); 143 143 } 144 144 145 _bytesPerPixel = SDL_GetVideoInfo()->vfmt->BytesPerPixel; 145 146 _graphicsMutex = createMutex(); 146 147 147 148 SDL_ShowCursor(SDL_DISABLE); -
backends/platform/sdl/sdl-common.h
221 221 // temporary screen (for scalers) 222 222 SDL_Surface *_tmpscreen; 223 223 SDL_Surface *_tmpscreen2; 224 SDL_Surface *_tmpscreen3; 225 SDL_Surface *_tmpscreen4; 224 226 225 227 // overlay 226 228 SDL_Surface *_overlayscreen; 227 229 int _overlayWidth, _overlayHeight; 228 230 bool _overlayVisible; 229 231 232 // color depth 233 uint8 _bytesPerPixel; 234 uint8 _curBytesPerPixel; 235 uint32 _Rmask; 236 uint32 _Gmask; 237 uint32 _Bmask; 238 uint32 _Amask; 239 230 240 // Audio 231 241 int _samplesPerSec; 232 242 -
graphics/scaler.cpp
107 107 InitLUT<ColorMasks<555> >(); 108 108 if (gBitFormat == 565) 109 109 InitLUT<ColorMasks<565> >(); 110 // Use 565-format for 16 bit surfaces in 32 bit mode 111 if (gBitFormat == 8888) 112 InitLUT<ColorMasks<565> >(); 110 113 #endif 111 114 } 112 115 … … 116 119 * source to the destionation. 117 120 */ 118 121 void Normal1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 119 int width, int height ) {122 int width, int height, uint8 bytesPerPixel) { 120 123 while (height--) { 121 memcpy(dstPtr, srcPtr, 2* width);124 memcpy(dstPtr, srcPtr, bytesPerPixel * width); 122 125 srcPtr += srcPitch; 123 126 dstPtr += dstPitch; 124 127 } … … 129 132 * Trivial nearest-neighbour 2x scaler. 130 133 */ 131 134 void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 132 int width, int height ) {135 int width, int height, uint8 bytesPerPixel) { 133 136 uint8 *r; 137 const uint8 *s; 134 138 135 139 assert(((long)dstPtr & 3) == 0); 140 width *= bytesPerPixel; 136 141 while (height--) { 137 142 r = dstPtr; 138 for (int i = 0; i < width; ++i, r += 4) { 139 uint32 color = *(((const uint16 *)srcPtr) + i); 140 141 color |= color << 16; 142 143 *(uint32 *)(r) = color; 144 *(uint32 *)(r + dstPitch) = color; 143 for (int i = 0; i < width; i += bytesPerPixel, r += (bytesPerPixel * 2)) { 144 s = srcPtr + i; 145 memcpy(r, s, bytesPerPixel); 146 memcpy(r + bytesPerPixel, s, bytesPerPixel); 147 memcpy(r + dstPitch, s, bytesPerPixel); 148 memcpy(r + dstPitch + bytesPerPixel, s, bytesPerPixel); 145 149 } 146 150 srcPtr += srcPitch; 147 151 dstPtr += dstPitch << 1; … … 152 156 * Trivial nearest-neighbour 3x scaler. 153 157 */ 154 158 void Normal3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 155 int width, int height ) {159 int width, int height, uint8 bytesPerPixel) { 156 160 uint8 *r; 161 const uint8 *s; 157 162 const uint32 dstPitch2 = dstPitch * 2; 158 163 const uint32 dstPitch3 = dstPitch * 3; 159 164 160 165 assert(((long)dstPtr & 1) == 0); 166 width *= bytesPerPixel; 161 167 while (height--) { 162 168 r = dstPtr; 163 for (int i = 0; i < width; ++i, r += 6) { 164 uint16 color = *(((const uint16 *)srcPtr) + i); 165 166 *(uint16 *)(r + 0) = color; 167 *(uint16 *)(r + 2) = color; 168 *(uint16 *)(r + 4) = color; 169 *(uint16 *)(r + 0 + dstPitch) = color; 170 *(uint16 *)(r + 2 + dstPitch) = color; 171 *(uint16 *)(r + 4 + dstPitch) = color; 172 *(uint16 *)(r + 0 + dstPitch2) = color; 173 *(uint16 *)(r + 2 + dstPitch2) = color; 174 *(uint16 *)(r + 4 + dstPitch2) = color; 169 for (int i = 0; i < width; i += bytesPerPixel, r += (bytesPerPixel * 3)) { 170 s = srcPtr + i; 171 memcpy(r, s, bytesPerPixel); 172 memcpy(r + bytesPerPixel, s, bytesPerPixel); 173 memcpy(r + bytesPerPixel * 2, s, bytesPerPixel); 174 memcpy(r + dstPitch, s, bytesPerPixel); 175 memcpy(r + dstPitch + bytesPerPixel, s, bytesPerPixel); 176 memcpy(r + dstPitch + bytesPerPixel * 2, s, bytesPerPixel); 177 memcpy(r + dstPitch2, s, bytesPerPixel); 178 memcpy(r + dstPitch2 + bytesPerPixel, s, bytesPerPixel); 179 memcpy(r + dstPitch2 + bytesPerPixel * 2, s, bytesPerPixel); 175 180 } 176 181 srcPtr += srcPitch; 177 182 dstPtr += dstPitch3; 178 183 } 179 184 } 180 185 181 #define interpolate 32_1_1 interpolate32_1_1<bitFormat>182 #define interpolate 32_1_1_1_1 interpolate32_1_1_1_1<bitFormat>186 #define interpolate_1_1 interpolate_1_1<bitFormat> 187 #define interpolate_1_1_1_1 interpolate_1_1_1_1<bitFormat> 183 188 184 189 /** 185 190 * Trivial nearest-neighbour 1.5x scaler. 186 191 */ 187 template<int bitFormat >188 void Normal1o5xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8*dstPtr, uint32 dstPitch,192 template<int bitFormat, typename T> 193 void Normal1o5xTemplate(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, 189 194 int width, int height) { 190 uint8 *r; 195 dstPitch /= sizeof(T); 196 srcPitch /= sizeof(T); 197 198 T *r; 191 199 const uint32 dstPitch2 = dstPitch * 2; 192 200 const uint32 dstPitch3 = dstPitch * 3; 193 201 const uint32 srcPitch2 = srcPitch * 2; … … 195 203 assert(((long)dstPtr & 1) == 0); 196 204 while (height > 0) { 197 205 r = dstPtr; 198 for (int i = 0; i < width; i += 2, r += 6) {199 uint16 color0 = *(((const uint16 *)srcPtr)+ i);200 uint16 color1 = *(((const uint16 *)srcPtr)+ i + 1);201 uint16 color2 = *(((const uint16 *)(srcPtr + srcPitch))+ i);202 uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch))+ i + 1);206 for (int i = 0; i < width; i += 2, r += 3) { 207 T color0 = *(srcPtr + i); 208 T color1 = *(srcPtr + i + 1); 209 T color2 = *(srcPtr + srcPitch + i); 210 T color3 = *(srcPtr + srcPitch + i + 1); 203 211 204 *( uint16 *)(r + 0) = color0;205 *( uint16 *)(r + 2) = interpolate32_1_1(color0, color1);206 *( uint16 *)(r + 4) = color1;207 *( uint16 *)(r + 0 + dstPitch) = interpolate32_1_1(color0, color2);208 *( uint16 *)(r + 2 + dstPitch) = interpolate32_1_1_1_1(color0, color1, color2, color3);209 *( uint16 *)(r + 4 + dstPitch) = interpolate32_1_1(color1, color3);210 *( uint16 *)(r + 0 + dstPitch2) = color2;211 *( uint16 *)(r + 2 + dstPitch2) = interpolate32_1_1(color2, color3);212 *( uint16 *)(r + 4+ dstPitch2) = color3;212 *(r + 0) = color0; 213 *(r + 1) = interpolate_1_1(color0, color1); 214 *(r + 2) = color1; 215 *(r + 0 + dstPitch) = interpolate_1_1(color0, color2); 216 *(r + 1 + dstPitch) = interpolate_1_1_1_1(color0, color1, color2, color3); 217 *(r + 2 + dstPitch) = interpolate_1_1(color1, color3); 218 *(r + 0 + dstPitch2) = color2; 219 *(r + 1 + dstPitch2) = interpolate_1_1(color2, color3); 220 *(r + 2 + dstPitch2) = color3; 213 221 } 214 222 srcPtr += srcPitch2; 215 223 dstPtr += dstPitch3; … … 223 231 * See also http://scale2x.sourceforge.net 224 232 */ 225 233 void AdvMame2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 226 int width, int height ) {227 scale(2, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, 2, width, height);234 int width, int height, uint8 bytesPerPixel) { 235 scale(2, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, bytesPerPixel, width, height); 228 236 } 229 237 230 238 /** … … 232 240 * See also http://scale2x.sourceforge.net 233 241 */ 234 242 void AdvMame3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 235 int width, int height ) {236 scale(3, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, 2, width, height);243 int width, int height, uint8 bytesPerPixel) { 244 scale(3, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, bytesPerPixel, width, height); 237 245 } 238 246 239 template<int bitFormat >240 void TV2xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8*dstPtr, uint32 dstPitch,247 template<int bitFormat, typename T> 248 void TV2xTemplate(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, 241 249 int width, int height) { 242 const uint32 nextlineSrc = srcPitch / sizeof(uint16);243 const uint16 *p = (const uint16 *)srcPtr;250 dstPitch /= sizeof(T); 251 srcPitch /= sizeof(T); 244 252 245 const uint32 nextlineDst = dstPitch / sizeof(uint16);246 uint16 *q = (uint16 *)dstPtr;247 248 253 while (height--) { 249 254 for (int i = 0, j = 0; i < width; ++i, j += 2) { 250 uint16 p1 = *(p+ i);255 T p1 = *(srcPtr + i); 251 256 uint32 pi; 252 257 253 258 pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; 254 259 pi |= (((p1 & greenMask) * 7) >> 3) & greenMask; 255 260 256 *( q+ j) = p1;257 *( q+ j + 1) = p1;258 *( q + j + nextlineDst) = (uint16)pi;259 *( q + j + nextlineDst + 1) = (uint16)pi;261 *(dstPtr + j) = p1; 262 *(dstPtr + j + 1) = p1; 263 *(dstPtr + j + dstPitch) = (T)pi; 264 *(dstPtr + j + dstPitch + 1) = (T)pi; 260 265 } 261 p += nextlineSrc;262 q += nextlineDst<< 1;266 srcPtr += srcPitch; 267 dstPtr += dstPitch << 1; 263 268 } 264 269 } 265 270 MAKE_WRAPPER(TV2x) … … 277 282 0x1CE7, 0x0000, 0x1CE7, 0x0000 278 283 }; 279 284 280 static inline uint16 DOT_16(const uint16 *dotmatrix, uint16 c, int j, int i) { 285 static const uint32 dotmatrix_8888[16] = { 286 0x00003F00, 0x0000003F, 0x001F0000, 0x00000000, 287 0x001F3F3F, 0x00000000, 0x001F3F3F, 0x00000000, 288 0x001F0000, 0x00000000, 0x00003F00, 0x0000003F, 289 0x001F3F3F, 0x00000000, 0x001F3F3F, 0x00000000 290 }; 291 292 template<typename T> 293 static inline T DOT(const T *dotmatrix, T c, int j, int i) { 281 294 return c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3))); 282 295 } 283 296 … … 287 300 // a way that also works together with aspect-ratio correction is left as an 288 301 // exercise for the reader.) 289 302 303 template<typename T> 304 void DotMatrix(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, 305 int width, int height, const T *dotmatrix) { 306 dstPitch /= sizeof(T); 307 srcPitch /= sizeof(T); 308 309 for (int j = 0, jj = 0; j < height; ++j, jj += 2) { 310 for (int i = 0, ii = 0; i < width; ++i, ii += 2) { 311 T c = *(srcPtr + i); 312 *(dstPtr + ii) = DOT(dotmatrix, c, jj, ii); 313 *(dstPtr + ii + 1) = DOT(dotmatrix, c, jj, ii + 1); 314 *(dstPtr + ii + dstPitch) = DOT(dotmatrix, c, jj + 1, ii); 315 *(dstPtr + ii + dstPitch + 1) = DOT(dotmatrix, c, jj + 1, ii + 1); 316 } 317 srcPtr += srcPitch; 318 dstPtr += dstPitch << 1; 319 } 320 } 321 290 322 void DotMatrix(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 291 int width, int height) { 292 293 const uint16 *dotmatrix; 323 int width, int height, uint8 bytesPerPixel) { 294 324 if (gBitFormat == 565) { 295 dotmatrix = dotmatrix_565;325 DotMatrix((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height, dotmatrix_565); 296 326 } else if (gBitFormat == 555) { 297 dotmatrix = dotmatrix_555; 327 DotMatrix((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height, dotmatrix_555); 328 } else if (gBitFormat == 8888) { 329 if (bytesPerPixel == 4) 330 DotMatrix((uint32*) srcPtr, srcPitch, (uint32*) dstPtr, dstPitch, width, height, dotmatrix_8888); 331 else 332 DotMatrix((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height, dotmatrix_565); 298 333 } else { 299 334 error("Unknown bit format %d", gBitFormat); 300 335 } 301 302 const uint32 nextlineSrc = srcPitch / sizeof(uint16);303 const uint16 *p = (const uint16 *)srcPtr;304 305 const uint32 nextlineDst = dstPitch / sizeof(uint16);306 uint16 *q = (uint16 *)dstPtr;307 308 for (int j = 0, jj = 0; j < height; ++j, jj += 2) {309 for (int i = 0, ii = 0; i < width; ++i, ii += 2) {310 uint16 c = *(p + i);311 *(q + ii) = DOT_16(dotmatrix, c, jj, ii);312 *(q + ii + 1) = DOT_16(dotmatrix, c, jj, ii + 1);313 *(q + ii + nextlineDst) = DOT_16(dotmatrix, c, jj + 1, ii);314 *(q + ii + nextlineDst + 1) = DOT_16(dotmatrix, c, jj + 1, ii + 1);315 }316 p += nextlineSrc;317 q += nextlineDst << 1;318 }319 336 } 320 337 321 338 #endif -
graphics/scaler.h
29 29 extern void InitScalers(uint32 BitFormat); 30 30 31 31 typedef void ScalerProc(const uint8 *srcPtr, uint32 srcPitch, 32 uint8 *dstPtr, uint32 dstPitch, int width, int height );32 uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel = 2); 33 33 34 34 #define DECLARE_SCALER(x) \ 35 35 extern void x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, \ 36 uint32 dstPitch, int width, int height )36 uint32 dstPitch, int width, int height, uint8 bytesPerPixel = 2) 37 37 38 38 DECLARE_SCALER(_2xSaI); 39 39 DECLARE_SCALER(Super2xSaI); … … 62 62 63 63 extern void makeRectStretchable(int &x, int &y, int &w, int &h); 64 64 65 extern int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY );65 extern int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY, uint8 bytesPerPixel = 2); 66 66 67 67 // creates a 160x100 thumbnail for 320x200 games 68 68 // and 160x120 thumbnail for 320x240 and 640x480 games -
graphics/colormasks.h
63 63 template<> 64 64 struct ColorMasks<565> { 65 65 enum { 66 highBits = 0xF7DEF7DE, 67 lowBits = 0x08210821, 68 qhighBits = 0xE79CE79C, 69 qlowBits = 0x18631863, 66 highBits = 0xF7DE, 67 lowBits = 0x0821, 68 qhighBits = 0xE79C, 69 qlowBits = 0x1863, 70 phighBits = 0xF7DEF7DE, 71 plowBits = 0x08210821, 72 pqhighBits = 0xE79CE79C, 73 pqlowBits = 0x18631863, 70 74 71 75 72 76 kBytesPerPixel = 2, … … 94 98 template<> 95 99 struct ColorMasks<555> { 96 100 enum { 97 highBits = 0x7BDE7BDE, 98 lowBits = 0x04210421, 99 qhighBits = 0x739C739C, 100 qlowBits = 0x0C630C63, 101 highBits = 0x7BDE, 102 lowBits = 0x0421, 103 qhighBits = 0x739C, 104 qlowBits = 0x0C63, 105 phighBits = 0x7BDE7BDE, 106 plowBits = 0x04210421, 107 pqhighBits = 0x739C739C, 108 pqlowBits = 0x0C630C63, 101 109 102 110 103 111 kBytesPerPixel = 2, … … 172 180 template<> 173 181 struct ColorMasks<888> { 174 182 enum { 183 highBits = 0x00FEFEFE, 184 lowBits = 0x00010101, 185 qhighBits = 0x00FCFCFC, 186 qlowBits = 0x00030303, 175 187 kBytesPerPixel = 4, 176 188 177 189 kAlphaBits = 0, … … 196 208 template<> 197 209 struct ColorMasks<8888> { 198 210 enum { 211 highBits = 0xFEFEFEFE, 212 lowBits = 0x01010101, 213 qhighBits = 0xFCFCFCFC, 214 qlowBits = 0x03030303, 199 215 kBytesPerPixel = 4, 200 216 201 217 kAlphaBits = 8, -
graphics/scaler/intern.h
29 29 #include "graphics/colormasks.h" 30 30 31 31 32 #define highBits ColorMasks<bitFormat>::highBits 33 #define lowBits ColorMasks<bitFormat>::lowBits 34 #define qhighBits ColorMasks<bitFormat>::qhighBits 35 #define qlowBits ColorMasks<bitFormat>::qlowBits 36 #define redblueMask ColorMasks<bitFormat>::kRedBlueMask 37 #define greenMask ColorMasks<bitFormat>::kGreenMask 32 #define highBits ColorMasks<bitFormat>::highBits 33 #define lowBits ColorMasks<bitFormat>::lowBits 34 #define qhighBits ColorMasks<bitFormat>::qhighBits 35 #define qlowBits ColorMasks<bitFormat>::qlowBits 36 #define phighBits ColorMasks<bitFormat>::phighBits 37 #define plowBits ColorMasks<bitFormat>::plowBits 38 #define pqhighBits ColorMasks<bitFormat>::pqhighBits 39 #define pqlowBits ColorMasks<bitFormat>::pqlowBits 40 #define redblueMask ColorMasks<bitFormat>::kRedBlueMask 41 #define greenMask ColorMasks<bitFormat>::kGreenMask 38 42 39 40 43 /** 41 * Interpolate two 16 bit pixel *pairs* at once with equal weights 1. 42 * In particular, A and B can contain two pixels/each in the upper 43 * and lower halves. 44 * Interpolate two pixels with equal weights 1. 44 45 */ 45 46 template<int bitFormat> 46 static inline uint32 interpolate 32_1_1(uint32 A, uint32 B) {47 static inline uint32 interpolate_1_1(uint32 A, uint32 B) { 47 48 return (((A & highBits) >> 1) + ((B & highBits) >> 1) + (A & B & lowBits)); 48 49 } 49 50 50 51 /** 51 * Interpolate two 16 bit pixel *pairs* at once with weights 3 resp. 1. 52 * In particular, A and B can contain two pixels/each in the upper 53 * and lower halves. 52 * Interpolate two 16 bit pixels *pairs* with equal weights 1. 54 53 */ 55 54 template<int bitFormat> 56 static inline uint32 interpolate32_3_1(uint32 A, uint32 B) { 55 static inline uint32 interpolate16p_1_1(uint32 A, uint32 B) { 56 return (((A & phighBits) >> 1) + ((B & phighBits) >> 1) + (A & B & plowBits)); 57 } 58 59 60 /** 61 * Interpolate two pixels with weights 3 resp. 1. 62 */ 63 template<int bitFormat> 64 static inline uint32 interpolate_3_1(uint32 A, uint32 B) { 57 65 register uint32 x = ((A & qhighBits) >> 2) * 3 + ((B & qhighBits) >> 2); 58 66 register uint32 y = ((A & qlowBits) * 3 + (B & qlowBits)) >> 2; 59 67 … … 62 70 } 63 71 64 72 /** 65 * Interpolate four 16 bit pixel pairs at once with equal weights 1. 66 * In particular, A and B can contain two pixels/each in the upper 67 * and lower halves. 73 * Interpolate two 16 bit pixels *pairs* with weights 3 resp. 1. 68 74 */ 69 75 template<int bitFormat> 70 static inline uint32 interpolate32_1_1_1_1(uint32 A, uint32 B, uint32 C, uint32 D) { 76 static inline uint32 interpolate16p_3_1(uint32 A, uint32 B) { 77 register uint32 x = ((A & pqhighBits) >> 2) * 3 + ((B & pqhighBits) >> 2); 78 register uint32 y = ((A & pqlowBits) * 3 + (B & pqlowBits)) >> 2; 79 80 y &= pqlowBits; 81 return x + y; 82 } 83 84 /** 85 * Interpolate four pixels with equal weights 1. 86 */ 87 template<int bitFormat> 88 static inline uint32 interpolate_1_1_1_1(uint32 A, uint32 B, uint32 C, uint32 D) { 71 89 register uint32 x = ((A & qhighBits) >> 2) + ((B & qhighBits) >> 2) + ((C & qhighBits) >> 2) + ((D & qhighBits) >> 2); 72 90 register uint32 y = ((A & qlowBits) + (B & qlowBits) + (C & qlowBits) + (D & qlowBits)) >> 2; 73 91 … … 77 95 78 96 79 97 /** 80 * Interpolate two 16 bitpixels with the weights specified in the template98 * Interpolate two pixels with the weights specified in the template 81 99 * parameters. Used by the hq scaler family. 82 100 * @note w1 and w2 must sum up to 2, 4, 8 or 16. 83 101 */ 84 102 template<int bitFormat, int w1, int w2> 85 static inline uint 16 interpolate16_2(uint16 p1, uint16p2) {103 static inline uint32 interpolate_2(uint32 p1, uint32 p2) { 86 104 return ((((p1 & redblueMask) * w1 + (p2 & redblueMask) * w2) / (w1 + w2)) & redblueMask) | 87 105 ((((p1 & greenMask) * w1 + (p2 & greenMask) * w2) / (w1 + w2)) & greenMask); 88 106 } 89 107 108 90 109 /** 91 * Interpolate three 16 bitpixels with the weights specified in the template110 * Interpolate three pixels with the weights specified in the template 92 111 * parameters. Used by the hq scaler family. 93 112 * @note w1, w2 and w3 must sum up to 2, 4, 8 or 16. 94 113 */ 95 114 template<int bitFormat, int w1, int w2, int w3> 96 static inline uint 16 interpolate16_3(uint16 p1, uint16 p2, uint16p3) {115 static inline uint32 interpolate_3(uint32 p1, uint32 p2, uint32 p3) { 97 116 return ((((p1 & redblueMask) * w1 + (p2 & redblueMask) * w2 + (p3 & redblueMask) * w3) / (w1 + w2 + w3)) & redblueMask) | 98 117 ((((p1 & greenMask) * w1 + (p2 & greenMask) * w2 + (p3 & greenMask) * w3) / (w1 + w2 + w3)) & greenMask); 99 118 } … … 146 165 147 166 /** Auxiliary macro to simplify creating those template function wrappers. */ 148 167 #define MAKE_WRAPPER(FUNC) \ 149 void FUNC(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { \ 150 if (gBitFormat == 565) \ 151 FUNC ## Template<565>(srcPtr, srcPitch, dstPtr, dstPitch, width, height); \ 168 void FUNC(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel) { \ 169 if (gBitFormat == 8888) { \ 170 if (bytesPerPixel == 4) \ 171 FUNC ## Template<8888>((uint32*) srcPtr, srcPitch, (uint32*) dstPtr, dstPitch, width, height); \ 172 else \ 173 FUNC ## Template<565>((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height); \ 174 } \ 175 else if (gBitFormat == 565) \ 176 FUNC ## Template<565>((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height); \ 152 177 else \ 153 FUNC ## Template<555>( srcPtr, srcPitch,dstPtr, dstPitch, width, height); \178 FUNC ## Template<555>((uint16*) srcPtr, srcPitch, (uint16*) dstPtr, dstPitch, width, height); \ 154 179 } 155 180 156 /** Specifies the currently active 16bit pixel format, 555 or 565. */ 181 182 /** Specifies the currently active pixel format, 555, 565 or 8888. */ 157 183 extern int gBitFormat; 158 184 159 185 #endif -
graphics/scaler/aspect.cpp
24 24 #include "graphics/scaler/intern.h" 25 25 #include "graphics/scaler.h" 26 26 27 #define highBits ColorMasks<bitFormat>::highBits 28 #define lowBits ColorMasks<bitFormat>::lowBits 29 #define qhighBits ColorMasks<bitFormat>::qhighBits 30 #define qlowBits ColorMasks<bitFormat>::qlowBits 31 #define interpolate_1_1 interpolate_1_1<bitFormat> 32 #define interpolate_3_1 interpolate_3_1<bitFormat> 33 #define interpolate16p_1_1 interpolate16p_1_1<bitFormat> 34 #define interpolate16p_3_1 interpolate16p_3_1<bitFormat> 27 35 28 #define kVeryFastAndUglyAspectMode 0 // No interpolation at all, but super-fast29 #define kFastAndNiceAspectMode 1 // Quite good quality with good speed30 #define kSlowAndPerfectAspectMode 2 // Accurate but slow code31 32 #define ASPECT_MODE kFastAndNiceAspectMode33 34 35 #if ASPECT_MODE == kSlowAndPerfectAspectMode36 37 36 template<int bitFormat, int scale> 38 static inline uint16 interpolate5(uint16 A, uint16 B) {39 uint16 r = (uint16)(((A & redblueMask & 0xFF00) * scale + (B & redblueMask & 0xFF00) * (5 - scale)) / 5);40 uint16 g = (uint16)(((A & greenMask) * scale + (B & greenMask) * (5 - scale)) / 5);41 uint16 b = (uint16)(((A & redblueMask & 0x00FF) * scale + (B & redblueMask & 0x00FF) * (5 - scale)) / 5);42 43 return (uint16)((r & redblueMask & 0xFF00) | (g & greenMask) | (b & redblueMask & 0x00FF));44 }45 46 47 template<int bitFormat, int scale>48 37 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) { 49 // Accurate but slightly slower code50 while (width--) {51 *dst++ = interpolate5<bitFormat, scale>(*srcA++, *srcB++);52 }53 }54 #endif55 56 #if ASPECT_MODE == kFastAndNiceAspectMode57 58 template<int bitFormat, int scale>59 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {60 38 // For efficiency reasons we blit two pixels at a time, so it is important 61 39 // that makeRectStretchable() guarantees that the width is even and that 62 40 // the rect starts on a well-aligned address. (Even where unaligned memory … … 70 48 //assert(((int)srcB & 3) == 0); 71 49 //assert((width & 1) == 0); 72 50 73 width /= 2;74 51 const uint32 *sA = (const uint32 *)srcA; 75 52 const uint32 *sB = (const uint32 *)srcB; 76 53 uint32 *d = (uint32 *)dst; 54 55 width /= 2; 77 56 if (scale == 1) { 78 while (width--) { 79 *d++ = interpolate32_3_1<bitFormat>(*sB++, *sA++); 80 } 57 while (width--) 58 *d++ = interpolate16p_3_1(*sB++, *sA++); 81 59 } else { 82 while (width--) { 83 *d++ = interpolate32_1_1<bitFormat>(*sB++, *sA++); 84 } 60 while (width--) 61 *d++ = interpolate16p_1_1(*sB++, *sA++); 85 62 } 86 63 } 87 #endif 64 template<int bitFormat, int scale> 65 static inline void interpolate5Line(uint32 *dst, const uint32 *srcA, const uint32 *srcB, int width) { 66 if (scale == 1) 67 while (width--) 68 *dst++ = interpolate_3_1(*srcB++, *srcA++); 69 else 70 while (width--) 71 *dst++ = interpolate_1_1(*srcB++, *srcA++); 72 } 88 73 89 74 void makeRectStretchable(int &x, int &y, int &w, int &h) { 90 #if ASPECT_MODE != kVeryFastAndUglyAspectMode91 75 int m = real2Aspect(y) % 6; 92 76 93 77 // Ensure that the rect will start on a line that won't have its … … 97 81 h += m; 98 82 } 99 83 100 #if ASPECT_MODE == kFastAndNiceAspectMode101 84 // Force x to be even, to ensure aligned memory access (this assumes 102 85 // that each line starts at an even memory location, but that should 103 86 // be the case on every target anyway). … … 111 94 // this should actually be faster than having the check for the 112 95 if (w & 1) 113 96 w++; 114 #endif115 #endif116 97 } 117 98 118 99 /** … … 131 112 * srcY + height - 1, and it should be stretched to Y coordinates srcY 132 113 * through real2Aspect(srcY + height - 1). 133 114 */ 134 template<int bitFormat> 135 int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 115 template<int bitFormat, typename T> 116 int stretch200To240(T *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 117 pitch /= sizeof(T); 118 136 119 int maxDstY = real2Aspect(origSrcY + height - 1); 137 120 int y; 138 const uint8 *startSrcPtr = buf + srcX * 2+ (srcY - origSrcY) * pitch;139 uint8 *dstPtr = buf + srcX * 2+ maxDstY * pitch;121 const T *startSrcPtr = buf + srcX + (srcY - origSrcY) * pitch; 122 T *dstPtr = buf + srcX + maxDstY * pitch; 140 123 141 124 for (y = maxDstY; y >= srcY; y--) { 142 const uint8*srcPtr = startSrcPtr + aspect2Real(y) * pitch;125 const T *srcPtr = startSrcPtr + aspect2Real(y) * pitch; 143 126 144 #if ASPECT_MODE == kVeryFastAndUglyAspectMode145 if (srcPtr == dstPtr)146 break;147 memcpy(dstPtr, srcPtr, width * 2);148 #else149 127 // Bilinear filter 150 128 switch (y % 6) { 151 129 case 0: 152 130 case 5: 153 131 if (srcPtr != dstPtr) 154 memcpy(dstPtr, srcPtr, width * 2);132 memcpy(dstPtr, srcPtr, width * sizeof(T)); 155 133 break; 156 134 case 1: 157 interpolate5Line<bitFormat, 1>( (uint16 *)dstPtr, (const uint16 *)(srcPtr - pitch), (const uint16 *)srcPtr, width);135 interpolate5Line<bitFormat, 1>(dstPtr, srcPtr - pitch, srcPtr, width); 158 136 break; 159 137 case 2: 160 interpolate5Line<bitFormat, 2>( (uint16 *)dstPtr, (const uint16 *)(srcPtr - pitch), (const uint16 *)srcPtr, width);138 interpolate5Line<bitFormat, 2>(dstPtr, srcPtr - pitch, srcPtr, width); 161 139 break; 162 140 case 3: 163 interpolate5Line<bitFormat, 2>( (uint16 *)dstPtr, (const uint16 *)srcPtr, (const uint16 *)(srcPtr - pitch), width);141 interpolate5Line<bitFormat, 2>(dstPtr, srcPtr, srcPtr - pitch, width); 164 142 break; 165 143 case 4: 166 interpolate5Line<bitFormat, 1>( (uint16 *)dstPtr, (const uint16 *)srcPtr, (const uint16 *)(srcPtr - pitch), width);144 interpolate5Line<bitFormat, 1>(dstPtr, srcPtr, srcPtr - pitch, width); 167 145 break; 168 146 } 169 #endif170 147 dstPtr -= pitch; 171 148 } 172 149 173 150 return 1 + maxDstY - srcY; 174 151 } 175 152 176 int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 177 if (gBitFormat == 565) 178 return stretch200To240<565>(buf, pitch, width, height, srcX, srcY, origSrcY); 153 int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY, uint8 bytesPerPixel) { 154 if (gBitFormat == 8888) { 155 if (bytesPerPixel == 4) 156 return stretch200To240<8888>((uint32*) buf, pitch, width, height, srcX, srcY, origSrcY); 157 else 158 return stretch200To240<565>((uint16*) buf, pitch, width, height, srcX, srcY, origSrcY); 159 } 160 else if (gBitFormat == 565) 161 return stretch200To240<565>((uint16*) buf, pitch, width, height, srcX, srcY, origSrcY); 179 162 else // gBitFormat == 555 180 return stretch200To240<555>( buf, pitch, width, height, srcX, srcY, origSrcY);163 return stretch200To240<555>((uint16*) buf, pitch, width, height, srcX, srcY, origSrcY); 181 164 } 182 -
graphics/scaler/hq2x.cpp
36 36 37 37 } 38 38 39 void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height ) {39 void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel) { 40 40 hq2x_16(srcPtr, dstPtr, width, height, srcPitch, dstPitch); 41 41 } 42 42 43 43 #else 44 44 45 45 #define PIXEL00_0 *(q) = w5; 46 #define PIXEL00_10 *(q) = interpolate 16_2<bitFormat,3,1>(w5, w1);47 #define PIXEL00_11 *(q) = interpolate 16_2<bitFormat,3,1>(w5, w4);48 #define PIXEL00_12 *(q) = interpolate 16_2<bitFormat,3,1>(w5, w2);49 #define PIXEL00_20 *(q) = interpolate 16_3<bitFormat,2,1,1>(w5, w4, w2);50 #define PIXEL00_21 *(q) = interpolate 16_3<bitFormat,2,1,1>(w5, w1, w2);51 #define PIXEL00_22 *(q) = interpolate 16_3<bitFormat,2,1,1>(w5, w1, w4);52 #define PIXEL00_60 *(q) = interpolate 16_3<bitFormat,5,2,1>(w5, w2, w4);53 #define PIXEL00_61 *(q) = interpolate 16_3<bitFormat,5,2,1>(w5, w4, w2);54 #define PIXEL00_70 *(q) = interpolate 16_3<bitFormat,6,1,1>(w5, w4, w2);55 #define PIXEL00_90 *(q) = interpolate 16_3<bitFormat,2,3,3>(w5, w4, w2);56 #define PIXEL00_100 *(q) = interpolate 16_3<bitFormat,14,1,1>(w5, w4, w2);46 #define PIXEL00_10 *(q) = interpolate_2<bitFormat,3,1>(w5, w1); 47 #define PIXEL00_11 *(q) = interpolate_2<bitFormat,3,1>(w5, w4); 48 #define PIXEL00_12 *(q) = interpolate_2<bitFormat,3,1>(w5, w2); 49 #define PIXEL00_20 *(q) = interpolate_3<bitFormat,2,1,1>(w5, w4, w2); 50 #define PIXEL00_21 *(q) = interpolate_3<bitFormat,2,1,1>(w5, w1, w2); 51 #define PIXEL00_22 *(q) = interpolate_3<bitFormat,2,1,1>(w5, w1, w4); 52 #define PIXEL00_60 *(q) = interpolate_3<bitFormat,5,2,1>(w5, w2, w4); 53 #define PIXEL00_61 *(q) = interpolate_3<bitFormat,5,2,1>(w5, w4, w2); 54 #define PIXEL00_70 *(q) = interpolate_3<bitFormat,6,1,1>(w5, w4, w2); 55 #define PIXEL00_90 *(q) = interpolate_3<bitFormat,2,3,3>(w5, w4, w2); 56 #define PIXEL00_100 *(q) = interpolate_3<bitFormat,14,1,1>(w5, w4, w2); 57 57 58 58 #define PIXEL01_0 *(q+1) = w5; 59 #define PIXEL01_10 *(q+1) = interpolate 16_2<bitFormat,3,1>(w5, w3);60 #define PIXEL01_11 *(q+1) = interpolate 16_2<bitFormat,3,1>(w5, w2);61 #define PIXEL01_12 *(q+1) = interpolate 16_2<bitFormat,3,1>(w5, w6);62 #define PIXEL01_20 *(q+1) = interpolate 16_3<bitFormat,2,1,1>(w5, w2, w6);63 #define PIXEL01_21 *(q+1) = interpolate 16_3<bitFormat,2,1,1>(w5, w3, w6);64 #define PIXEL01_22 *(q+1) = interpolate 16_3<bitFormat,2,1,1>(w5, w3, w2);65 #define PIXEL01_60 *(q+1) = interpolate 16_3<bitFormat,5,2,1>(w5, w6, w2);66 #define PIXEL01_61 *(q+1) = interpolate 16_3<bitFormat,5,2,1>(w5, w2, w6);67 #define PIXEL01_70 *(q+1) = interpolate 16_3<bitFormat,6,1,1>(w5, w2, w6);68 #define PIXEL01_90 *(q+1) = interpolate 16_3<bitFormat,2,3,3>(w5, w2, w6);69 #define PIXEL01_100 *(q+1) = interpolate 16_3<bitFormat,14,1,1>(w5, w2, w6);59 #define PIXEL01_10 *(q+1) = interpolate_2<bitFormat,3,1>(w5, w3); 60 #define PIXEL01_11 *(q+1) = interpolate_2<bitFormat,3,1>(w5, w2); 61 #define PIXEL01_12 *(q+1) = interpolate_2<bitFormat,3,1>(w5, w6); 62 #define PIXEL01_20 *(q+1) = interpolate_3<bitFormat,2,1,1>(w5, w2, w6); 63 #define PIXEL01_21 *(q+1) = interpolate_3<bitFormat,2,1,1>(w5, w3, w6); 64 #define PIXEL01_22 *(q+1) = interpolate_3<bitFormat,2,1,1>(w5, w3, w2); 65 #define PIXEL01_60 *(q+1) = interpolate_3<bitFormat,5,2,1>(w5, w6, w2); 66 #define PIXEL01_61 *(q+1) = interpolate_3<bitFormat,5,2,1>(w5, w2, w6); 67 #define PIXEL01_70 *(q+1) = interpolate_3<bitFormat,6,1,1>(w5, w2, w6); 68 #define PIXEL01_90 *(q+1) = interpolate_3<bitFormat,2,3,3>(w5, w2, w6); 69 #define PIXEL01_100 *(q+1) = interpolate_3<bitFormat,14,1,1>(w5, w2, w6); 70 70 71 71 #define PIXEL10_0 *(q+nextlineDst) = w5; 72 #define PIXEL10_10 *(q+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w7);73 #define PIXEL10_11 *(q+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w8);74 #define PIXEL10_12 *(q+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w4);75 #define PIXEL10_20 *(q+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w8, w4);76 #define PIXEL10_21 *(q+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w7, w4);77 #define PIXEL10_22 *(q+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w7, w8);78 #define PIXEL10_60 *(q+nextlineDst) = interpolate 16_3<bitFormat,5,2,1>(w5, w4, w8);79 #define PIXEL10_61 *(q+nextlineDst) = interpolate 16_3<bitFormat,5,2,1>(w5, w8, w4);80 #define PIXEL10_70 *(q+nextlineDst) = interpolate 16_3<bitFormat,6,1,1>(w5, w8, w4);81 #define PIXEL10_90 *(q+nextlineDst) = interpolate 16_3<bitFormat,2,3,3>(w5, w8, w4);82 #define PIXEL10_100 *(q+nextlineDst) = interpolate 16_3<bitFormat,14,1,1>(w5, w8, w4);72 #define PIXEL10_10 *(q+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w7); 73 #define PIXEL10_11 *(q+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w8); 74 #define PIXEL10_12 *(q+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w4); 75 #define PIXEL10_20 *(q+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w8, w4); 76 #define PIXEL10_21 *(q+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w7, w4); 77 #define PIXEL10_22 *(q+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w7, w8); 78 #define PIXEL10_60 *(q+nextlineDst) = interpolate_3<bitFormat,5,2,1>(w5, w4, w8); 79 #define PIXEL10_61 *(q+nextlineDst) = interpolate_3<bitFormat,5,2,1>(w5, w8, w4); 80 #define PIXEL10_70 *(q+nextlineDst) = interpolate_3<bitFormat,6,1,1>(w5, w8, w4); 81 #define PIXEL10_90 *(q+nextlineDst) = interpolate_3<bitFormat,2,3,3>(w5, w8, w4); 82 #define PIXEL10_100 *(q+nextlineDst) = interpolate_3<bitFormat,14,1,1>(w5, w8, w4); 83 83 84 84 #define PIXEL11_0 *(q+1+nextlineDst) = w5; 85 #define PIXEL11_10 *(q+1+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w9);86 #define PIXEL11_11 *(q+1+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w6);87 #define PIXEL11_12 *(q+1+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w8);88 #define PIXEL11_20 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w6, w8);89 #define PIXEL11_21 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w9, w8);90 #define PIXEL11_22 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,2,1,1>(w5, w9, w6);91 #define PIXEL11_60 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,5,2,1>(w5, w8, w6);92 #define PIXEL11_61 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,5,2,1>(w5, w6, w8);93 #define PIXEL11_70 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,6,1,1>(w5, w6, w8);94 #define PIXEL11_90 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,2,3,3>(w5, w6, w8);95 #define PIXEL11_100 *(q+1+nextlineDst) = interpolate 16_3<bitFormat,14,1,1>(w5, w6, w8);85 #define PIXEL11_10 *(q+1+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w9); 86 #define PIXEL11_11 *(q+1+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w6); 87 #define PIXEL11_12 *(q+1+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w8); 88 #define PIXEL11_20 *(q+1+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w6, w8); 89 #define PIXEL11_21 *(q+1+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w9, w8); 90 #define PIXEL11_22 *(q+1+nextlineDst) = interpolate_3<bitFormat,2,1,1>(w5, w9, w6); 91 #define PIXEL11_60 *(q+1+nextlineDst) = interpolate_3<bitFormat,5,2,1>(w5, w8, w6); 92 #define PIXEL11_61 *(q+1+nextlineDst) = interpolate_3<bitFormat,5,2,1>(w5, w6, w8); 93 #define PIXEL11_70 *(q+1+nextlineDst) = interpolate_3<bitFormat,6,1,1>(w5, w6, w8); 94 #define PIXEL11_90 *(q+1+nextlineDst) = interpolate_3<bitFormat,2,3,3>(w5, w6, w8); 95 #define PIXEL11_100 *(q+1+nextlineDst) = interpolate_3<bitFormat,14,1,1>(w5, w6, w8); 96 96 97 97 #define YUV(x) RGBtoYUV[w ## x] 98 98 … … 110 110 #undef bitFormat 111 111 112 112 113 void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height ) {113 void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel) { 114 114 if (gBitFormat == 565) 115 115 HQ2x_565(srcPtr, srcPitch, dstPtr, dstPitch, width, height); 116 116 else -
graphics/scaler/hq3x.cpp
37 37 38 38 } 39 39 40 void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height ) {40 void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel) { 41 41 hq3x_16(srcPtr, dstPtr, width, height, srcPitch, dstPitch); 42 42 } 43 43 44 44 #else 45 45 46 #define PIXEL00_1M *(q) = interpolate 16_2<bitFormat,3,1>(w5, w1);47 #define PIXEL00_1U *(q) = interpolate 16_2<bitFormat,3,1>(w5, w2);48 #define PIXEL00_1L *(q) = interpolate 16_2<bitFormat,3,1>(w5, w4);49 #define PIXEL00_2 *(q) = interpolate 16_3<bitFormat,2,1,1>(w5, w4, w2);50 #define PIXEL00_4 *(q) = interpolate 16_3<bitFormat,2,7,7>(w5, w4, w2);51 #define PIXEL00_5 *(q) = interpolate 16_2<bitFormat,1,1>(w4, w2);46 #define PIXEL00_1M *(q) = interpolate_2<bitFormat,3,1>(w5, w1); 47 #define PIXEL00_1U *(q) = interpolate_2<bitFormat,3,1>(w5, w2); 48 #define PIXEL00_1L *(q) = interpolate_2<bitFormat,3,1>(w5, w4); 49 #define PIXEL00_2 *(q) = interpolate_3<bitFormat,2,1,1>(w5, w4, w2); 50 #define PIXEL00_4 *(q) = interpolate_3<bitFormat,2,7,7>(w5, w4, w2); 51 #define PIXEL00_5 *(q) = interpolate_2<bitFormat,1,1>(w4, w2); 52 52 #define PIXEL00_C *(q) = w5; 53 53 54 #define PIXEL01_1 *(q+1) = interpolate 16_2<bitFormat,3,1>(w5, w2);55 #define PIXEL01_3 *(q+1) = interpolate 16_2<bitFormat,7,1>(w5, w2);56 #define PIXEL01_6 *(q+1) = interpolate 16_2<bitFormat,3,1>(w2, w5);54 #define PIXEL01_1 *(q+1) = interpolate_2<bitFormat,3,1>(w5, w2); 55 #define PIXEL01_3 *(q+1) = interpolate_2<bitFormat,7,1>(w5, w2); 56 #define PIXEL01_6 *(q+1) = interpolate_2<bitFormat,3,1>(w2, w5); 57 57 #define PIXEL01_C *(q+1) = w5; 58 58 59 #define PIXEL02_1M *(q+2) = interpolate 16_2<bitFormat,3,1>(w5, w3);60 #define PIXEL02_1U *(q+2) = interpolate 16_2<bitFormat,3,1>(w5, w2);61 #define PIXEL02_1R *(q+2) = interpolate 16_2<bitFormat,3,1>(w5, w6);62 #define PIXEL02_2 *(q+2) = interpolate 16_3<bitFormat,2,1,1>(w5, w2, w6);63 #define PIXEL02_4 *(q+2) = interpolate 16_3<bitFormat,2,7,7>(w5, w2, w6);64 #define PIXEL02_5 *(q+2) = interpolate 16_2<bitFormat,1,1>(w2, w6);59 #define PIXEL02_1M *(q+2) = interpolate_2<bitFormat,3,1>(w5, w3); 60 #define PIXEL02_1U *(q+2) = interpolate_2<bitFormat,3,1>(w5, w2); 61 #define PIXEL02_1R *(q+2) = interpolate_2<bitFormat,3,1>(w5, w6); 62 #define PIXEL02_2 *(q+2) = interpolate_3<bitFormat,2,1,1>(w5, w2, w6); 63 #define PIXEL02_4 *(q+2) = interpolate_3<bitFormat,2,7,7>(w5, w2, w6); 64 #define PIXEL02_5 *(q+2) = interpolate_2<bitFormat,1,1>(w2, w6); 65 65 #define PIXEL02_C *(q+2) = w5; 66 66 67 #define PIXEL10_1 *(q+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w4);68 #define PIXEL10_3 *(q+nextlineDst) = interpolate 16_2<bitFormat,7,1>(w5, w4);69 #define PIXEL10_6 *(q+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w4, w5);67 #define PIXEL10_1 *(q+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w4); 68 #define PIXEL10_3 *(q+nextlineDst) = interpolate_2<bitFormat,7,1>(w5, w4); 69 #define PIXEL10_6 *(q+nextlineDst) = interpolate_2<bitFormat,3,1>(w4, w5); 70 70 #define PIXEL10_C *(q+nextlineDst) = w5; 71 71 72 72 #define PIXEL11 *(q+1+nextlineDst) = w5; 73 73 74 #define PIXEL12_1 *(q+2+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w5, w6);75 #define PIXEL12_3 *(q+2+nextlineDst) = interpolate 16_2<bitFormat,7,1>(w5, w6);76 #define PIXEL12_6 *(q+2+nextlineDst) = interpolate 16_2<bitFormat,3,1>(w6, w5);74 #define PIXEL12_1 *(q+2+nextlineDst) = interpolate_2<bitFormat,3,1>(w5, w6); 75 #define PIXEL12_3 *(q+2+nextlineDst) = interpolate_2<bitFormat,7,1>(w5, w6); 76 #define PIXEL12_6 *(q+2+nextlineDst) = interpolate_2<bitFormat,3,1>(w6, w5); 77 77 #define PIXEL12_C *(q+2+nextlineDst) = w5; 78 78 79 #define PIXEL20_1M *(q+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w7);80 #define PIXEL20_1D *(q+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w8);81 #define PIXEL20_1L *(q+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w4);82 #define PIXEL20_2 *(q+nextlineDst2) = interpolate 16_3<bitFormat,2,1,1>(w5, w8, w4);83 #define PIXEL20_4 *(q+nextlineDst2) = interpolate 16_3<bitFormat,2,7,7>(w5, w8, w4);84 #define PIXEL20_5 *(q+nextlineDst2) = interpolate 16_2<bitFormat,1,1>(w8, w4);79 #define PIXEL20_1M *(q+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w7); 80 #define PIXEL20_1D *(q+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w8); 81 #define PIXEL20_1L *(q+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w4); 82 #define PIXEL20_2 *(q+nextlineDst2) = interpolate_3<bitFormat,2,1,1>(w5, w8, w4); 83 #define PIXEL20_4 *(q+nextlineDst2) = interpolate_3<bitFormat,2,7,7>(w5, w8, w4); 84 #define PIXEL20_5 *(q+nextlineDst2) = interpolate_2<bitFormat,1,1>(w8, w4); 85 85 #define PIXEL20_C *(q+nextlineDst2) = w5; 86 86 87 #define PIXEL21_1 *(q+1+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w8);88 #define PIXEL21_3 *(q+1+nextlineDst2) = interpolate 16_2<bitFormat,7,1>(w5, w8);89 #define PIXEL21_6 *(q+1+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w8, w5);87 #define PIXEL21_1 *(q+1+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w8); 88 #define PIXEL21_3 *(q+1+nextlineDst2) = interpolate_2<bitFormat,7,1>(w5, w8); 89 #define PIXEL21_6 *(q+1+nextlineDst2) = interpolate_2<bitFormat,3,1>(w8, w5); 90 90 #define PIXEL21_C *(q+1+nextlineDst2) = w5; 91 91 92 #define PIXEL22_1M *(q+2+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w9);93 #define PIXEL22_1D *(q+2+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w8);94 #define PIXEL22_1R *(q+2+nextlineDst2) = interpolate 16_2<bitFormat,3,1>(w5, w6);95 #define PIXEL22_2 *(q+2+nextlineDst2) = interpolate 16_3<bitFormat,2,1,1>(w5, w6, w8);96 #define PIXEL22_4 *(q+2+nextlineDst2) = interpolate 16_3<bitFormat,2,7,7>(w5, w6, w8);97 #define PIXEL22_5 *(q+2+nextlineDst2) = interpolate 16_2<bitFormat,1,1>(w6, w8);92 #define PIXEL22_1M *(q+2+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w9); 93 #define PIXEL22_1D *(q+2+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w8); 94 #define PIXEL22_1R *(q+2+nextlineDst2) = interpolate_2<bitFormat,3,1>(w5, w6); 95 #define PIXEL22_2 *(q+2+nextlineDst2) = interpolate_3<bitFormat,2,1,1>(w5, w6, w8); 96 #define PIXEL22_4 *(q+2+nextlineDst2) = interpolate_3<bitFormat,2,7,7>(w5, w6, w8); 97 #define PIXEL22_5 *(q+2+nextlineDst2) = interpolate_2<bitFormat,1,1>(w6, w8); 98 98 #define PIXEL22_C *(q+2+nextlineDst2) = w5; 99 99 100 100 #define YUV(x) RGBtoYUV[w ## x] … … 113 113 #undef bitFormat 114 114 115 115 116 void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height ) {116 void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, uint8 bytesPerPixel) { 117 117 if (gBitFormat == 565) 118 118 HQ3x_565(srcPtr, srcPitch, dstPtr, dstPitch, width, height); 119 119 else -
graphics/scaler/thumbnail.cpp
36 36 uint16 colorx1y2 = *(((const uint16*)(src + srcPitch))); 37 37 uint16 colorx2y2 = *(((const uint16*)(src + srcPitch)) + 1); 38 38 39 return interpolate 32_1_1_1_1<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);39 return interpolate_1_1_1_1<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2); 40 40 } 41 41 42 42 template<int bitFormat> … … 63 63 uint16 downleft = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * x, srcPitch); 64 64 uint16 downright = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * (x + 2), srcPitch); 65 65 66 *((uint16*)dstPtr) = interpolate 32_1_1_1_1<bitFormat>(upleft, upright, downleft, downright);66 *((uint16*)dstPtr) = interpolate_1_1_1_1<bitFormat>(upleft, upright, downleft, downright); 67 67 } 68 68 dstPtr += (dstPitch - 2 * width / 4); 69 69 src += 4 * srcPitch; -
graphics/scaler/2xsai.cpp
44 44 return rmap[y][x]; 45 45 } 46 46 47 #define interpolate_1_1 interpolate 16_2<bitFormat, 1, 1>48 #define interpolate_3_1 interpolate 16_2<bitFormat, 3, 1>49 #define interpolate_6_1_1 interpolate 16_3<bitFormat, 6, 1, 1>50 #define interpolate_1_1_1_1 interpolate 32_1_1_1_1<bitFormat>47 #define interpolate_1_1 interpolate_2<bitFormat, 1, 1> 48 #define interpolate_3_1 interpolate_2<bitFormat, 3, 1> 49 #define interpolate_6_1_1 interpolate_3<bitFormat, 6, 1, 1> 50 #define interpolate_1_1_1_1 interpolate_1_1_1_1<bitFormat> 51 51 52 template<int bitFormat> 53 void Super2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { 54 const uint16 *bP; 55 uint16 *dP; 56 const uint32 nextlineSrc = srcPitch >> 1; 52 template<int bitFormat, typename T> 53 void Super2xSaITemplate(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, int width, int height) { 54 const T *bP; 55 T *dP; 57 56 57 dstPitch /= sizeof(T); 58 srcPitch /= sizeof(T); 59 58 60 while (height--) { 59 bP = (const uint16*)srcPtr;60 dP = ( uint16*)dstPtr;61 bP = (const T *)srcPtr; 62 dP = (T *)dstPtr; 61 63 62 64 for (int i = 0; i < width; ++i) { 63 65 uint32 color4, color5, color6; … … 72 74 // 1 2 3 S1 73 75 // A1 A2 74 76 75 colorB0 = *(bP - nextlineSrc- 1);76 colorB1 = *(bP - nextlineSrc);77 colorB2 = *(bP - nextlineSrc+ 1);78 colorB3 = *(bP - nextlineSrc+ 2);77 colorB0 = *(bP - srcPitch - 1); 78 colorB1 = *(bP - srcPitch); 79 colorB2 = *(bP - srcPitch + 1); 80 colorB3 = *(bP - srcPitch + 2); 79 81 80 82 color4 = *(bP - 1); 81 83 color5 = *(bP); 82 84 color6 = *(bP + 1); 83 85 colorS2 = *(bP + 2); 84 86 85 color1 = *(bP + nextlineSrc- 1);86 color2 = *(bP + nextlineSrc);87 color3 = *(bP + nextlineSrc+ 1);88 colorS1 = *(bP + nextlineSrc+ 2);87 color1 = *(bP + srcPitch - 1); 88 color2 = *(bP + srcPitch); 89 color3 = *(bP + srcPitch + 1); 90 colorS1 = *(bP + srcPitch + 2); 89 91 90 colorA0 = *(bP + 2 * nextlineSrc- 1);91 colorA1 = *(bP + 2 * nextlineSrc);92 colorA2 = *(bP + 2 * nextlineSrc+ 1);93 colorA3 = *(bP + 2 * nextlineSrc+ 2);92 colorA0 = *(bP + 2 * srcPitch - 1); 93 colorA1 = *(bP + 2 * srcPitch); 94 colorA2 = *(bP + 2 * srcPitch + 1); 95 colorA3 = *(bP + 2 * srcPitch + 2); 94 96 95 97 //-------------------------------------- 96 98 if (color2 == color6 && color5 != color3) { … … 142 144 else 143 145 product1a = color5; 144 146 145 *(dP + 0) = ( uint16) product1a;146 *(dP + 1) = ( uint16) product1b;147 *(dP + dstPitch /2 + 0) = (uint16) product2a;148 *(dP + dstPitch /2 + 1) = (uint16) product2b;147 *(dP + 0) = (T) product1a; 148 *(dP + 1) = (T) product1b; 149 *(dP + dstPitch + 0) = (T) product2a; 150 *(dP + dstPitch + 1) = (T) product2b; 149 151 150 152 bP += 1; 151 153 dP += 2; … … 158 160 159 161 MAKE_WRAPPER(Super2xSaI) 160 162 161 template<int bitFormat> 162 void SuperEagleTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { 163 const uint16 *bP; 164 uint16 *dP; 165 const uint32 nextlineSrc = srcPitch >> 1; 163 template<int bitFormat, typename T> 164 void SuperEagleTemplate(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, int width, int height) { 165 const T *bP; 166 T *dP; 166 167 168 dstPitch /= sizeof(T); 169 srcPitch /= sizeof(T); 170 167 171 while (height--) { 168 bP = (const uint16*)srcPtr;169 dP = ( uint16*)dstPtr;172 bP = (const T *)srcPtr; 173 dP = (T *)dstPtr; 170 174 for (int i = 0; i < width; ++i) { 171 175 uint32 color4, color5, color6; 172 176 uint32 color1, color2, color3; 173 177 uint32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; 174 178 uint32 product1a, product1b, product2a, product2b; 175 179 176 colorB1 = *(bP - nextlineSrc);177 colorB2 = *(bP - nextlineSrc+ 1);180 colorB1 = *(bP - srcPitch); 181 colorB2 = *(bP - srcPitch + 1); 178 182 179 183 color4 = *(bP - 1); 180 184 color5 = *(bP); 181 185 color6 = *(bP + 1); 182 186 colorS2 = *(bP + 2); 183 187 184 color1 = *(bP + nextlineSrc- 1);185 color2 = *(bP + nextlineSrc);186 color3 = *(bP + nextlineSrc+ 1);187 colorS1 = *(bP + nextlineSrc+ 2);188 color1 = *(bP + srcPitch - 1); 189 color2 = *(bP + srcPitch); 190 color3 = *(bP + srcPitch + 1); 191 colorS1 = *(bP + srcPitch + 2); 188 192 189 colorA1 = *(bP + 2 * nextlineSrc);190 colorA2 = *(bP + 2 * nextlineSrc+ 1);193 colorA1 = *(bP + 2 * srcPitch); 194 colorA2 = *(bP + 2 * srcPitch + 1); 191 195 192 196 // -------------------------------------- 193 197 if (color5 != color3) { … … 247 251 } 248 252 } 249 253 250 *(dP + 0) = ( uint16) product1a;251 *(dP + 1) = ( uint16) product1b;252 *(dP + dstPitch /2 + 0) = (uint16) product2a;253 *(dP + dstPitch /2 + 1) = (uint16) product2b;254 *(dP + 0) = (T) product1a; 255 *(dP + 1) = (T) product1b; 256 *(dP + dstPitch + 0) = (T) product2a; 257 *(dP + dstPitch + 1) = (T) product2b; 254 258 255 259 bP += 1; 256 260 dP += 2; … … 263 267 264 268 MAKE_WRAPPER(SuperEagle) 265 269 266 template<int bitFormat> 267 void _2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { 268 const uint16 *bP; 269 uint16 *dP; 270 const uint32 nextlineSrc = srcPitch >> 1; 270 template<int bitFormat, typename T> 271 void _2xSaITemplate(const T *srcPtr, uint32 srcPitch, T *dstPtr, uint32 dstPitch, int width, int height) { 272 const T *bP; 273 T *dP; 271 274 275 dstPitch /= sizeof(T); 276 srcPitch /= sizeof(T); 277 272 278 while (height--) { 273 bP = (const uint16*)srcPtr;274 dP = ( uint16*)dstPtr;279 bP = (const T *)srcPtr; 280 dP = (T *)dstPtr; 275 281 276 282 for (int i = 0; i < width; ++i) { 277 283 … … 285 291 // G|A B|K 286 292 // H|C D|L 287 293 // M|N O|P 288 colorI = *(bP - nextlineSrc- 1);289 colorE = *(bP - nextlineSrc);290 colorF = *(bP - nextlineSrc+ 1);291 colorJ = *(bP - nextlineSrc+ 2);294 colorI = *(bP - srcPitch - 1); 295 colorE = *(bP - srcPitch); 296 colorF = *(bP - srcPitch + 1); 297 colorJ = *(bP - srcPitch + 2); 292 298 293 299 colorG = *(bP - 1); 294 300 colorA = *(bP); 295 301 colorB = *(bP + 1); 296 302 colorK = *(bP + 2); 297 303 298 colorH = *(bP + nextlineSrc- 1);299 colorC = *(bP + nextlineSrc);300 colorD = *(bP + nextlineSrc+ 1);301 colorL = *(bP + nextlineSrc+ 2);304 colorH = *(bP + srcPitch - 1); 305 colorC = *(bP + srcPitch); 306 colorD = *(bP + srcPitch + 1); 307 colorL = *(bP + srcPitch + 2); 302 308 303 colorM = *(bP + 2 * nextlineSrc- 1);304 colorN = *(bP + 2 * nextlineSrc);305 colorO = *(bP + 2 * nextlineSrc+ 1);306 colorP = *(bP + 2 * nextlineSrc+ 2);309 colorM = *(bP + 2 * srcPitch - 1); 310 colorN = *(bP + 2 * srcPitch); 311 colorO = *(bP + 2 * srcPitch + 1); 312 colorP = *(bP + 2 * srcPitch + 2); 307 313 308 314 if ((colorA == colorD) && (colorB != colorC)) { 309 315 if (((colorA == colorE) && (colorB == colorL)) || … … 383 389 } 384 390 } 385 391 386 *(dP + 0) = ( uint16) colorA;387 *(dP + 1) = ( uint16) product;388 *(dP + dstPitch /2 + 0) = (uint16) product1;389 *(dP + dstPitch /2 + 1) = (uint16) product2;392 *(dP + 0) = (T) colorA; 393 *(dP + 1) = (T) product; 394 *(dP + dstPitch + 0) = (T) product1; 395 *(dP + dstPitch + 1) = (T) product2; 390 396 391 397 bP += 1; 392 398 dP += 2;