Ticket #8434: mpeg-scale.diff
File mpeg-scale.diff, 12.4 KB (added by , 19 years ago) |
---|
-
graphics/animation.cpp
diff -ur ScummVM-cvs20050604/graphics/animation.cpp ScummVM-cvs20050604+gui/graphics/animation.cpp
old new 30 30 31 31 namespace Graphics { 32 32 33 BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int width, int height) 33 BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int width, int height) 34 34 : _movieWidth(width), _movieHeight(height), _snd(snd), _sys(sys) { 35 35 #ifndef BACKEND_8BIT 36 const int screenW = _sys->getOverlayWidth(); 37 const int screenH = _sys->getOverlayHeight(); 38 39 _movieScale = MIN(screenW / _movieWidth, screenH / _movieHeight); 40 41 assert (_movieScale >= 1); 42 if (_movieScale > 3) 43 _movieScale = 3; 44 45 36 46 _colorTab = NULL; 37 47 _rgbToPix = NULL; 38 48 _bitFormat = 0; … … 115 125 _lutCalcNum = (BITDEPTH + _palettes[_palNum].end + 2) / (_palettes[_palNum].end + 2); 116 126 #else 117 127 buildLookup(); 118 _overlay = (OverlayColor*)calloc(_movie Width* _movieHeight, sizeof(OverlayColor));128 _overlay = (OverlayColor*)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor)); 119 129 _sys->showOverlay(); 120 130 #endif 121 131 … … 421 431 } 422 432 423 433 void BaseAnimationState::plotYUV(int width, int height, byte *const *dat) { 424 OverlayColor *ptr = _overlay + (_movieHeight - height) / 2 * _movieWidth + (_movieWidth - width) / 2; 434 switch (_movieScale) { 435 case 1: 436 plotYUV1x(width, height, dat); 437 break; 438 case 2: 439 plotYUV2x(width, height, dat); 440 break; 441 case 3: 442 plotYUV3x(width, height, dat); 443 break; 444 } 445 } 446 447 void BaseAnimationState::plotYUV1x(int width, int height, byte *const *dat) { 448 OverlayColor *ptr = _overlay + _movieWidth * (_movieHeight - height) / 2 + (_movieWidth - width) / 2; 425 449 426 450 byte *lum = dat[0]; 427 451 byte *cr = dat[2]; … … 439 463 int x, y; 440 464 441 465 for (y = 0; y < height; y += 2) { 466 OverlayColor *r1 = row1; 467 OverlayColor *r2 = row2; 468 469 for (x = 0; x < width; x += 2) { 470 register byte L; 471 472 cr_r = 0 * 768 + 256 + _colorTab[*cr + 0 * 256]; 473 crb_g = 1 * 768 + 256 + _colorTab[*cr + 1 * 256] + _colorTab[*cb + 2 * 256]; 474 cb_b = 2 * 768 + 256 + _colorTab[*cb + 3 * 256]; 475 ++cr; 476 ++cb; 477 478 L = *lum++; 479 *r1++ = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 480 481 L = *lum++; 482 *r1++ = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 483 484 // Now, do second row. 485 486 L = *lum2++; 487 *r2++ = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 488 489 L = *lum2++; 490 *r2++ = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 491 } 492 493 lum += width; 494 lum2 += width; 495 row1 += 2 * _movieWidth; 496 row2 += 2 * _movieWidth; 497 } 498 } 499 500 void BaseAnimationState::plotYUV2x(int width, int height, byte *const *dat) { 501 OverlayColor *ptr = _overlay + 2 * _movieWidth * (_movieHeight - height) + _movieWidth - width; 502 503 byte *lum = dat[0]; 504 byte *cr = dat[2]; 505 byte *cb = dat[1]; 506 507 byte *lum2 = lum + width; 508 509 int16 cr_r; 510 int16 crb_g; 511 int16 cb_b; 512 513 OverlayColor *row1 = ptr; 514 OverlayColor *row2 = ptr + 2 * 2 * _movieWidth; 515 516 int x, y; 517 518 for (y = 0; y < height; y += 2) { 519 OverlayColor *r1 = row1; 520 OverlayColor *r2 = row2; 521 442 522 for (x = 0; x < width; x += 2) { 443 523 register byte L; 524 register OverlayColor C; 444 525 445 526 cr_r = 0 * 768 + 256 + _colorTab[*cr + 0 * 256]; 446 527 crb_g = 1 * 768 + 256 + _colorTab[*cr + 1 * 256] + _colorTab[*cb + 2 * 256]; … … 449 530 ++cb; 450 531 451 532 L = *lum++; 452 *row1++ = (_rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]); 533 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 534 *r1++ = C; 535 *r1++ = C; 536 537 L = *lum++; 538 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 539 *r1++ = C; 540 *r1++ = C; 541 542 // Now, do second row. 543 544 L = *lum2++; 545 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 546 *r2++ = C; 547 *r2++ = C; 548 549 L = *lum2++; 550 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 551 *r2++ = C; 552 *r2++ = C; 553 } 554 555 memcpy(row1 + 2 * _movieWidth, row1, 2 * _movieWidth * sizeof(OverlayColor)); 556 memcpy(row2 + 2 * _movieWidth, row2, 2 * _movieWidth * sizeof(OverlayColor)); 557 558 lum += width; 559 lum2 += width; 560 row1 += 4 * 2 * _movieWidth; 561 row2 += 4 * 2 * _movieWidth; 562 } 563 } 564 565 void BaseAnimationState::plotYUV3x(int width, int height, byte *const *dat) { 566 OverlayColor *ptr = _overlay + (3 * (_movieHeight - height) / 2) * 3 * _movieWidth + 3 * (_movieWidth - width ) / 2; 567 568 byte *lum = dat[0]; 569 byte *cr = dat[2]; 570 byte *cb = dat[1]; 571 572 byte *lum2 = lum + width; 573 574 int16 cr_r; 575 int16 crb_g; 576 int16 cb_b; 577 578 OverlayColor *row1 = ptr; 579 OverlayColor *row2 = ptr + 3 * 3 * _movieWidth; 580 581 int x, y; 582 583 for (y = 0; y < height; y += 2) { 584 OverlayColor *r1 = row1; 585 OverlayColor *r2 = row2; 586 587 for (x = 0; x < width; x += 2) { 588 register byte L; 589 register OverlayColor C; 590 591 cr_r = 0 * 768 + 256 + _colorTab[*cr + 0 * 256]; 592 crb_g = 1 * 768 + 256 + _colorTab[*cr + 1 * 256] + _colorTab[*cb + 2 * 256]; 593 cb_b = 2 * 768 + 256 + _colorTab[*cb + 3 * 256]; 594 ++cr; 595 ++cb; 596 453 597 L = *lum++; 454 *row1++ = (_rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]); 598 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 599 *r1++ = C; 600 *r1++ = C; 601 *r1++ = C; 455 602 603 L = *lum++; 604 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 605 *r1++ = C; 606 *r1++ = C; 607 *r1++ = C; 608 456 609 // Now, do second row. 457 610 458 611 L = *lum2++; 459 *row2++ = (_rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]); 612 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 613 *r2++ = C; 614 *r2++ = C; 615 *r2++ = C; 616 460 617 L = *lum2++; 461 *row2++ = (_rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]); 618 C = _rgbToPix[L + cr_r] | _rgbToPix[L + crb_g] | _rgbToPix[L + cb_b]; 619 *r2++ = C; 620 *r2++ = C; 621 *r2++ = C; 462 622 } 463 623 464 // These values are at the start of the next line, (due 465 // to the ++'s above), but they need to be at the start 466 // of the line after that. 624 memcpy(row1 + 3 * _movieWidth, row1, 3 * _movieWidth * sizeof(OverlayColor)); 625 memcpy(row1 + 2 * 3 * _movieWidth, row1, 3 * _movieWidth * sizeof(OverlayColor)); 626 memcpy(row2 + 3 * _movieWidth, row2, 3 * _movieWidth * sizeof(OverlayColor)); 627 memcpy(row2 + 2 * 3 * _movieWidth, row2, 3 * _movieWidth * sizeof(OverlayColor)); 467 628 468 629 lum += width; 469 630 lum2 += width; 470 row1 += (2 * _movieWidth - width);471 row2 += (2 * _movieWidth - width);631 row1 += 6 * 3 * _movieWidth; 632 row2 += 6 * 3 * _movieWidth; 472 633 } 473 634 } 474 635 -
graphics/animation.h
diff -ur ScummVM-cvs20050604/graphics/animation.h ScummVM-cvs20050604+gui/graphics/animation.h
old new 73 73 protected: 74 74 const int _movieWidth; 75 75 const int _movieHeight; 76 77 #ifndef BACKEND_8BIT 78 int _movieScale; 79 #endif 76 80 77 81 Audio::Mixer *_snd; 78 82 OSystem *_sys; … … 137 141 virtual void setPalette(byte *pal) = 0; 138 142 #else 139 143 void plotYUV(int width, int height, byte *const *dat); 144 void plotYUV1x(int width, int height, byte *const *dat); 145 void plotYUV2x(int width, int height, byte *const *dat); 146 void plotYUV3x(int width, int height, byte *const *dat); 140 147 #endif 141 148 }; 142 149 -
sword1/animation.cpp
diff -ur ScummVM-cvs20050604/sword1/animation.cpp ScummVM-cvs20050604+gui/sword1/animation.cpp
old new 47 47 #endif 48 48 49 49 void AnimationState::drawYUV(int width, int height, byte *const *dat) { 50 _frameWidth = width; 51 _frameHeight = height; 52 50 53 #ifdef BACKEND_8BIT 51 54 _scr->plotYUV(_lut, width, height, dat); 52 55 #else … … 56 59 57 60 void AnimationState::updateScreen(void) { 58 61 #ifndef BACKEND_8BIT 59 _sys->copyRectToOverlay(_overlay, _movieWidth, 0, 40, _movieWidth, _movieHeight); 62 int width = _movieScale * _frameWidth; 63 int height = _movieScale * _frameHeight; 64 int pitch = _movieScale * _movieWidth; 65 int x = _movieScale * ((_movieWidth - _frameWidth) / 2); 66 int y = _movieScale * ((_movieHeight - _frameHeight) / 2); 67 68 _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y + _movieScale * 40, width, height); 60 69 #endif 61 70 _sys->updateScreen(); 62 71 } -
sword1/animation.h
diff -ur ScummVM-cvs20050604/sword1/animation.h ScummVM-cvs20050604+gui/sword1/animation.h
old new 60 60 private: 61 61 Screen *_scr; 62 62 63 int _frameWidth; 64 int _frameHeight; 65 63 66 public: 64 67 AnimationState(Screen *scr, Audio::Mixer *snd, OSystem *sys); 65 68 ~AnimationState(); -
sword2/driver/animation.cpp
void Dialog::registerWidget(Widget *widget) { diff -ur ScummVM-cvs20050604/sword2/driver/animation.cpp ScummVM-cvs20050604+gui/sword2/driver/animation.cpp
old new 51 51 #else 52 52 53 53 void AnimationState::drawTextObject(SpriteInfo *s, byte *src) { 54 OverlayColor *dst = _overlay + RENDERWIDE * s->y + s->x; 55 56 // FIXME: These aren't the "right" colours, but look good to me. 54 OverlayColor *dst = _overlay + _movieScale * _movieWidth * _movieScale * s->y + _movieScale * s->x; 57 55 58 56 OverlayColor pen = _sys->RGBToColor(255, 255, 255); 59 57 OverlayColor border = _sys->RGBToColor(0, 0, 0); 60 58 59 // TODO: Use the AdvMame scalers for the text? Pre-scale it? 60 61 61 for (int y = 0; y < s->h; y++) { 62 OverlayColor *ptr = dst; 63 62 64 for (int x = 0; x < s->w; x++) { 63 65 switch (src[x]) { 64 66 case 1: 65 dst[x] = border; 67 *ptr++ = border; 68 if (_movieScale > 1) { 69 *ptr++ = border; 70 if (_movieScale > 2) 71 *ptr++ = border; 72 } 66 73 break; 67 74 case 255: 68 dst[x] = pen; 75 *ptr++ = pen; 76 if (_movieScale > 1) { 77 *ptr++ = pen; 78 if (_movieScale > 2) 79 *ptr++ = pen; 80 } 69 81 break; 70 82 default: 83 ptr += _movieScale; 71 84 break; 72 85 } 73 86 } 74 dst += RENDERWIDE; 87 88 if (_movieScale > 1) { 89 memcpy(dst + _movieScale * _movieWidth, dst, _movieScale * s->w * sizeof(OverlayColor)); 90 if (_movieScale > 2) 91 memcpy(dst + 2 * _movieScale * _movieWidth, dst, _movieScale * s->w * sizeof(OverlayColor)); 92 } 93 94 dst += _movieScale * _movieScale * _movieWidth; 75 95 src += s->w; 76 96 } 77 97 } … … 79 99 #endif 80 100 81 101 void AnimationState::clearScreen() { 102 _frameWidth = _movieWidth; 103 _frameHeight = _movieHeight; 104 82 105 #ifdef BACKEND_8BIT 83 106 memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight); 84 107 #else 85 108 OverlayColor black = _sys->RGBToColor(0, 0, 0); 86 109 87 for (int i = 0; i < _movie Width* _movieHeight; i++)110 for (int i = 0; i < _movieScale * _movieWidth * _movieScale * _movieHeight; i++) 88 111 _overlay[i] = black; 89 112 #endif 90 113 } 91 114 92 115 void AnimationState::updateScreen() { 116 int x, y; 117 118 x = (_movieWidth - _frameWidth) / 2; 119 y = (_movieHeight - _frameHeight) / 2; 120 93 121 #ifdef BACKEND_8BIT 94 byte *buf = _vm->_screen->getScreen() + ((480 - _movieHeight) / 2) * RENDERWIDE + (640 - _movieWidth) / 2;122 byte *buf = _vm->_screen->getScreen() + y * RENDERWIDE + x; 95 123 96 124 _vm->_system->copyRectToScreen(buf, _movieWidth, (640 - _movieWidth) / 2, (480 - _movieHeight) / 2, _movieWidth, _movieHeight); 97 125 #else 98 _sys->copyRectToOverlay(_overlay, _movieWidth, 0, 0, _movieWidth, _movieHeight); 126 int width = _movieScale * _frameWidth; 127 int height = _movieScale * _frameHeight; 128 int pitch = _movieScale * _movieWidth; 129 130 x *= _movieScale; 131 y *= _movieScale; 132 133 _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y, width, height); 99 134 #endif 100 135 _vm->_system->updateScreen(); 101 136 } 102 137 103 138 void AnimationState::drawYUV(int width, int height, byte *const *dat) { 139 _frameWidth = width; 140 _frameHeight = height; 141 104 142 #ifdef BACKEND_8BIT 105 143 _vm->_screen->plotYUV(_lut, width, height, dat); 106 144 #else -
sword2/driver/animation.h
diff -ur ScummVM-cvs20050604/sword2/driver/animation.h ScummVM-cvs20050604+gui/sword2/driver/animation.h
old new 45 45 private: 46 46 Sword2Engine *_vm; 47 47 48 int _frameWidth; 49 int _frameHeight; 50 48 51 public: 49 52 AnimationState(Sword2Engine *vm); 50 53 ~AnimationState();