//*@@@+++@@@@******************************************************************1//2// Copyright © Microsoft Corp.3// All rights reserved.4//5// Redistribution and use in source and binary forms, with or without6// modification, are permitted provided that the following conditions are met:7//8// • Redistributions of source code must retain the above copyright notice,9// this list of conditions and the following disclaimer.10// • Redistributions in binary form must reproduce the above copyright notice,11// this list of conditions and the following disclaimer in the documentation12// and/or other materials provided with the distribution.13//14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"15// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE18// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR19// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF20// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS21// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN22// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)23// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE24// POSSIBILITY OF SUCH DAMAGE.25//26//*@@@---@@@@******************************************************************2728#include "strTransform.h"2930/** need to swap b and c **/31/** rounding behavior: [0 0 0 0] <-> [+ - - -]32[+ + + +] <-> [+3/4 - - -]33[- - - -] <-> [- - - -] **/34Void strDCT2x2dn(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)35{36PixelI a, b, c, d, C, t;37a = *pa;38b = *pb;39C = *pc;40d = *pd;4142a += d;43b -= C;44t = ((a - b) >> 1);45c = t - d;46d = t - C;47a -= d;48b += c;4950*pa = a;51*pb = b;52*pc = c;53*pd = d;54}5556Void strDCT2x2up(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)57{58PixelI a, b, c, d, C, t;59a = *pa;60b = *pb;61C = *pc;62d = *pd;6364a += d;65b -= C;66t = ((a - b + 1) >> 1);67c = t - d;68d = t - C;69a -= d;70b += c;7172*pa = a;73*pb = b;74*pc = c;75*pd = d;76}7778Void FOURBUTTERFLY_HARDCODED1(PixelI *p)79{80strDCT2x2dn(&p[0], &p[4], &p[8], &p[12]);81strDCT2x2dn(&p[1], &p[5], &p[9], &p[13]);82strDCT2x2dn(&p[2], &p[6], &p[10], &p[14]);83strDCT2x2dn(&p[3], &p[7], &p[11], &p[15]);84}858687