Showing the changes to codec/decoder/core/src/decode_mb_aux.cpp (1 of 308 files). Show all
Unified · Split
| @@ -0,0 +1,134 @@ | |||
| 1 | /*! | ||
| 2 | * \copy | ||
| 3 | * Copyright (c) 2013, Cisco Systems | ||
| 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 | ||
| 8 | * are met: | ||
| 9 | * | ||
| 10 | * * Redistributions of source code must retain the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer. | ||
| 12 | * | ||
| 13 | * * Redistributions in binary form must reproduce the above copyright | ||
| 14 | * notice, this list of conditions and the following disclaimer in | ||
| 15 | * the documentation and/or other materials provided with the | ||
| 16 | * distribution. | ||
| 17 | * | ||
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 22 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| 28 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 29 | * POSSIBILITY OF SUCH DAMAGE. | ||
| 30 | * | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include <string.h> | ||
| 34 | |||
| 35 | #include "decode_mb_aux.h" | ||
| 36 | #include "wels_common_basis.h" | ||
| 37 | |||
| 38 | namespace WelsDec { | ||
| 39 | |||
| 40 | #define MAX_NEG_CROP 1024 | ||
| 41 | uint8_t g_ClipTable[256 + 2 * MAX_NEG_CROP]; //the front 1024 is 0, the back 1024 is 255, the middle 256 elements is 0-255 | ||
| 42 | |||
| 43 | |||
| 44 | /* init pClip table to pClip the final dct data */ | ||
| 45 | void_t InitDctClipTable(void_t) | ||
| 46 | { | ||
| 47 | uint8_t *p = &g_ClipTable[0]; | ||
| 48 | const int32_t kiLength = MAX_NEG_CROP * sizeof(uint8_t); | ||
| 49 | int32_t i = 0; | ||
| 50 | |||
| 51 | do | ||
| 52 | { | ||
| 53 | const int32_t kiIdx = MAX_NEG_CROP + i; | ||
| 54 | |||
| 55 | p[kiIdx] = i; | ||
| 56 | p[1+kiIdx] = 1+i; | ||
| 57 | p[2+kiIdx] = 2+i; | ||
| 58 | p[3+kiIdx] = 3+i; | ||
| 59 | |||
| 60 | i += 4; | ||
| 61 | } while(i < 256); | ||
| 62 | |||
| 63 | memset( p, 0, kiLength); | ||
| 64 | memset( p + MAX_NEG_CROP + 256, 0xFF, kiLength); | ||
| 65 | } | ||
| 66 | |||
| 67 | //NOTE::: p_RS should NOT be modified and it will lead to mismatch with JSVM. | ||
| 68 | // so should allocate kA array to store the temporary value (idct). | ||
| 69 | void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs) | ||
| 70 | { | ||
| 71 | int16_t iSrc[16]; | ||
| 72 | |||
| 73 | uint8_t *pDst = pPred; | ||
| 74 | const int32_t kiStride2 = kiStride<<1; | ||
| 75 | const int32_t kiStride3 = kiStride + kiStride2; | ||
| 76 | uint8_t *pClip = &g_ClipTable[MAX_NEG_CROP]; | ||
| 77 | int32_t i; | ||
| 78 | |||
| 79 | for(i=0; i<4; i++) | ||
| 80 | { | ||
| 81 | const int32_t kiY = i<<2; | ||
| 82 | const int32_t kiT0 = pRs[kiY] + pRs[kiY+2]; | ||
| 83 | const int32_t kiT1 = pRs[kiY] - pRs[kiY+2]; | ||
| 84 | const int32_t kiT2 = (pRs[kiY+1]>>1) - pRs[kiY+3]; | ||
| 85 | const int32_t kiT3 = pRs[kiY+1] + (pRs[kiY+3]>>1); | ||
| 86 | |||
| 87 | iSrc[kiY] = kiT0 + kiT3; | ||
| 88 | iSrc[kiY+1] = kiT1 + kiT2; | ||
| 89 | iSrc[kiY+2] = kiT1 - kiT2; | ||
| 90 | iSrc[kiY+3] = kiT0 - kiT3; | ||
| 91 | } | ||
| 92 | |||
| 93 | for(i=0; i<4; i++) | ||
| 94 | { | ||
| 95 | int32_t kT1 = iSrc[i] + iSrc[i+8]; | ||
| 96 | int32_t kT2 = iSrc[i+4] + (iSrc[i+12]>>1); | ||
| 97 | int32_t kT3 = (32 + kT1 + kT2) >> 6; | ||
| 98 | int32_t kT4 = (32 + kT1 - kT2) >> 6; | ||
| 99 | |||
| 100 | pDst[i] = pClip[ kT3 + pPred[i] ]; | ||
| 101 | pDst[i+kiStride3] = pClip[ kT4 + pPred[i+kiStride3] ]; | ||
| 102 | |||
| 103 | kT1 = iSrc[i] - iSrc[i+8]; | ||
| 104 | kT2 = (iSrc[i+4]>>1) - iSrc[i+12]; | ||
| 105 | pDst[i+kiStride] = pClip[ ((32 + kT1 + kT2) >> 6) + pDst[i+kiStride] ]; | ||
| 106 | pDst[i+kiStride2] = pClip[ ((32 + kT1 - kT2) >> 6) + pDst[i+kiStride2] ]; | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | void_t GetI4LumaIChromaAddrTable(int32_t *pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) | ||
| 111 | { | ||
| 112 | int32_t *pOffset = pBlockOffset; | ||
| 113 | int32_t i; | ||
| 114 | const uint8_t kuiScan0 = g_kuiScan8[0]; | ||
| 115 | |||
| 116 | for(i=0; i<16; i++) | ||
| 117 | { | ||
| 118 | const uint32_t kuiA = g_kuiScan8[i] - kuiScan0; | ||
| 119 | const uint32_t kuiX = kuiA & 0x07; | ||
| 120 | const uint32_t kuiY = kuiA >> 3; | ||
| 121 | |||
| 122 | pOffset[i]= (kuiX + kiYStride* kuiY) << 2; | ||
| 123 | } | ||
| 124 | |||
| 125 | for(i=0; i<4; i++) | ||
| 126 | { | ||
| 127 | const uint32_t kuiA = g_kuiScan8[i] - kuiScan0; | ||
| 128 | |||
| 129 | pOffset[16+i]= | ||
| 130 | pOffset[20+i]= ((kuiA & 0x07) + (kiUVStride/*>>1*/) * (kuiA >> 3)) << 2; | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | } // namespace WelsDec | ||