PageRenderTime 25ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Avc/paint_2.js

http://github.com/mbebenita/Broadway
JavaScript | 35 lines | 32 code | 3 blank | 0 comment | 2 complexity | db035fd75c5ac3b29fc6f35feedb884c MD5 | raw file
Possible License(s): BSD-3-Clause
  1. function _paint($luma, $cb, $cr, w, h) {
  2. for (var y1,y2,u,v,ruv,guv,buv,j,w_2=w>>1,W=w*4, surface=SDL.surfaces[SDL.screen], d=surface.image.data, r=0; h-=2;) {
  3. for (j=w_2; j--;) {
  4. u = HEAPU8[$cr++];
  5. v = HEAPU8[$cb++];
  6. ruv = 409*u-56992;
  7. guv = 34784-208*u-100*v;
  8. buv = 516*v-70688;
  9. y2 = HEAPU8[$luma+w]*298;
  10. y1 = HEAPU8[$luma++]*298;
  11. d[r+W] = y2+ruv>>8;
  12. d[r++] = y1+ruv>>8;
  13. d[r+W] = y2+guv>>8;
  14. d[r++] = y1+guv>>8;
  15. d[r+W] = y2+buv>>8;
  16. d[r++] = y1+buv>>8;
  17. r++;
  18. y2 = HEAPU8[$luma+w]*298;
  19. y1 = HEAPU8[$luma++]*298;
  20. d[r+W] = y2+ruv>>8;
  21. d[r++] = y1+ruv>>8;
  22. d[r+W] = y2+guv>>8;
  23. d[r++] = y1+guv>>8;
  24. d[r+W] = y2+buv>>8;
  25. d[r++] = y1+buv>>8;
  26. r++;
  27. }
  28. r+=W;
  29. $luma+=w;
  30. }
  31. surface.ctx.putImageData(surface.image, 0, 0 );
  32. }