strTransform.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //*@@@+++@@@@******************************************************************
  2. //
  3. // Copyright © Microsoft Corp.
  4. // All rights reserved.
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions are met:
  8. //
  9. // • Redistributions of source code must retain the above copyright notice,
  10. // this list of conditions and the following disclaimer.
  11. // • Redistributions in binary form must reproduce the above copyright notice,
  12. // this list of conditions and the following disclaimer in the documentation
  13. // and/or other materials provided with the distribution.
  14. //
  15. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. // POSSIBILITY OF SUCH DAMAGE.
  26. //
  27. //*@@@---@@@@******************************************************************
  28. #include "strTransform.h"
  29. /** need to swap b and c **/
  30. /** rounding behavior: [0 0 0 0] <-> [+ - - -]
  31. [+ + + +] <-> [+3/4 - - -]
  32. [- - - -] <-> [- - - -] **/
  33. Void strDCT2x2dn(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  34. {
  35. PixelI a, b, c, d, C, t;
  36. a = *pa;
  37. b = *pb;
  38. C = *pc;
  39. d = *pd;
  40. a += d;
  41. b -= C;
  42. t = ((a - b) >> 1);
  43. c = t - d;
  44. d = t - C;
  45. a -= d;
  46. b += c;
  47. *pa = a;
  48. *pb = b;
  49. *pc = c;
  50. *pd = d;
  51. }
  52. Void strDCT2x2up(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  53. {
  54. PixelI a, b, c, d, C, t;
  55. a = *pa;
  56. b = *pb;
  57. C = *pc;
  58. d = *pd;
  59. a += d;
  60. b -= C;
  61. t = ((a - b + 1) >> 1);
  62. c = t - d;
  63. d = t - C;
  64. a -= d;
  65. b += c;
  66. *pa = a;
  67. *pb = b;
  68. *pc = c;
  69. *pd = d;
  70. }
  71. Void FOURBUTTERFLY_HARDCODED1(PixelI *p)
  72. {
  73. strDCT2x2dn(&p[0], &p[4], &p[8], &p[12]);
  74. strDCT2x2dn(&p[1], &p[5], &p[9], &p[13]);
  75. strDCT2x2dn(&p[2], &p[6], &p[10], &p[14]);
  76. strDCT2x2dn(&p[3], &p[7], &p[11], &p[15]);
  77. }