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 // exp_data.c 34 // export date cross various modules (.c) 35 #include "md.h" 36 #include "vlc_encoder.h" 37 namespace WelsEnc { 38 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 40 // extern at mb_cache.h 41 const uint8_t g_kuiSmb4AddrIn256[16] = { 42 0, 4, 16 * 4, 16 * 4 + 4, 43 8, 12, 16 * 4 + 8, 16 * 4 + 12, 44 16 * 8, 16 * 8 + 4, 16 * 12, 16 * 12 + 4, 45 16 * 8 + 8, 16 * 8 + 12, 16 * 12 + 8, 16 * 12 + 12 46 }; 47 48 49 const uint8_t g_kuiCache12_8x8RefIdx[4] = { //mv or uiRefIndex cache scan index, 4*4 block as basic unit 50 5, 6, 51 9, 10 52 }; 53 54 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 55 56 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 57 58 // extern at md.h 59 const int32_t g_kiQpCostTable[52] = { 60 1, 1, 1, 1, 1, 1, 1, 1, /* 0-7 */ 61 1, 1, 1, 1, /* 8-11 */ 62 1, 1, 1, 1, 2, 2, 2, 2, /* 12-19 */ 63 3, 3, 3, 4, 4, 4, 5, 6, /* 20-27 */ 64 6, 7, 8, 9, 10, 11, 13, 14, /* 28-35 */ 65 16, 18, 20, 23, 25, 29, 32, 36, /* 36-43 */ 66 40, 45, 51, 57, 64, 72, 81, 91 /* 44-51 */ 67 }; 68 const int8_t g_kiMapModeI16x16[7] = { 69 0, 1, 2, 3, 2, 2, 2 70 };//{I16_PRED_V, I16_PRED_H, I16_PRED_DC, I16_PRED_P, I16_PRED_DC, I16_PRED_DC, I16_PRED_DC}; 71 72 const int8_t g_kiMapModeIntraChroma[7] = { 73 0, 1, 2, 3, 0, 0, 0 74 };//{C_PRED_DC, C_PRED_H, C_PRED_V, C_PRED_P, C_PRED_DC_L, C_PRED_DC_T, C_PRED_DC_128}; 75 76 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 77 78 79 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 80 81 // extern at vlc_encoder.h 82 83 //g_kuiVlcCoeffToken[nc][total-coeff][trailing-ones][0--value, 1--bit count] 84 const uint8_t g_kuiVlcCoeffToken[5][17][4][2] = { 85 { 86 //0<=nc<2 87 { { 1, 1}, { 0, 0}, { 0, 0}, { 0, 0} },//0 88 { { 5, 6}, { 1, 2}, { 0, 0}, { 0, 0} },//1 89 { { 7, 8}, { 4, 6}, { 1, 3}, { 0, 0} },//2 90 { { 7, 9}, { 6, 8}, { 5, 7}, { 3, 5} },//3 91 { { 7, 10}, { 6, 9}, { 5, 8}, { 3, 6} },//4 92 { { 7, 11}, { 6, 10}, { 5, 9}, { 4, 7} },//5 93 { {15, 13}, { 6, 11}, { 5, 10}, { 4, 8} },//6 94 { {11, 13}, {14, 13}, { 5, 11}, { 4, 9} },//7 95 { { 8, 13}, {10, 13}, {13, 13}, { 4, 10} },//8 96 { {15, 14}, {14, 14}, { 9, 13}, { 4, 11} },//9 97 { {11, 14}, {10, 14}, {13, 14}, {12, 13} },//10 98 { {15, 15}, {14, 15}, { 9, 14}, {12, 14} },//11 99 { {11, 15}, {10, 15}, {13, 15}, { 8, 14} },//12 100 { {15, 16}, { 1, 15}, { 9, 15}, {12, 15} },//13 101 { {11, 16}, {14, 16}, {13, 16}, { 8, 15} },//14 102 { { 7, 16}, {10, 16}, { 9, 16}, {12, 16} },//15 103 { { 4, 16}, { 6, 16}, { 5, 16}, { 8, 16} } //16 104 }, 105 106 { 107 //2<=nc<4 108 { { 3, 2}, { 0, 0}, { 0, 0}, { 0, 0} },//0 109 { {11, 6}, { 2, 2}, { 0, 0}, { 0, 0} },//1 110 { { 7, 6}, { 7, 5}, { 3, 3}, { 0, 0} },//2 111 { { 7, 7}, {10, 6}, { 9, 6}, { 5, 4} },//3 112 { { 7, 8}, { 6, 6}, { 5, 6}, { 4, 4} },//4 113 { { 4, 8}, { 6, 7}, { 5, 7}, { 6, 5} },//5 114 { { 7, 9}, { 6, 8}, { 5, 8}, { 8, 6} },//6 115 { {15, 11}, { 6, 9}, { 5, 9}, { 4, 6} },//7 116 { {11, 11}, {14, 11}, {13, 11}, { 4, 7} },//8 117 { {15, 12}, {10, 11}, { 9, 11}, { 4, 9} },//9 118 { {11, 12}, {14, 12}, {13, 12}, {12, 11} },//10 119 { { 8, 12}, {10, 12}, { 9, 12}, { 8, 11} },//11 120 { {15, 13}, {14, 13}, {13, 13}, {12, 12} },//12 121 { {11, 13}, {10, 13}, { 9, 13}, {12, 13} },//13 122 { { 7, 13}, {11, 14}, { 6, 13}, { 8, 13} },//14 123 { { 9, 14}, { 8, 14}, {10, 14}, { 1, 13} },//15 124 { { 7, 14}, { 6, 14}, { 5, 14}, { 4, 14} } //16 125 }, 126 127 { 128 //4<=nc<8 129 { {15, 4}, { 0, 0}, { 0, 0}, { 0, 0} },//0 130 { {15, 6}, {14, 4}, { 0, 0}, { 0, 0} },//1 131 { {11, 6}, {15, 5}, {13, 4}, { 0, 0} },//2 132 { { 8, 6}, {12, 5}, {14, 5}, {12, 4} },//3 133 { {15, 7}, {10, 5}, {11, 5}, {11, 4} },//4 134 { {11, 7}, { 8, 5}, { 9, 5}, {10, 4} },//5 135 { { 9, 7}, {14, 6}, {13, 6}, { 9, 4} },//6 136 { { 8, 7}, {10, 6}, { 9, 6}, { 8, 4} },//7 137 { {15, 8}, {14, 7}, {13, 7}, {13, 5} },//8 138 { {11, 8}, {14, 8}, {10, 7}, {12, 6} },//9 139 { {15, 9}, {10, 8}, {13, 8}, {12, 7} },//10 140 { {11, 9}, {14, 9}, { 9, 8}, {12, 8} },//11 141 { { 8, 9}, {10, 9}, {13, 9}, { 8, 8} },//12 142 { {13, 10}, { 7, 9}, { 9, 9}, {12, 9} },//13 143 { { 9, 10}, {12, 10}, {11, 10}, {10, 10} },//14 144 { { 5, 10}, { 8, 10}, { 7, 10}, { 6, 10} },//15 145 { { 1, 10}, { 4, 10}, { 3, 10}, { 2, 10} } //16 146 }, 147 148 { 149 //8<=nc 150 { { 3, 6}, { 0, 0}, { 0, 0}, { 0, 0} },//0 151 { { 0, 6}, { 1, 6}, { 0, 0}, { 0, 0} },//1 152 { { 4, 6}, { 5, 6}, { 6, 6}, { 0, 0} },//2 153 { { 8, 6}, { 9, 6}, {10, 6}, {11, 6} },//3 154 { {12, 6}, {13, 6}, {14, 6}, {15, 6} },//4 155 { {16, 6}, {17, 6}, {18, 6}, {19, 6} },//5 156 { {20, 6}, {21, 6}, {22, 6}, {23, 6} },//6 157 { {24, 6}, {25, 6}, {26, 6}, {27, 6} },//7 158 { {28, 6}, {29, 6}, {30, 6}, {31, 6} },//8 159 { {32, 6}, {33, 6}, {34, 6}, {35, 6} },//9 160 { {36, 6}, {37, 6}, {38, 6}, {39, 6} },//10 161 { {40, 6}, {41, 6}, {42, 6}, {43, 6} },//11 162 { {44, 6}, {45, 6}, {46, 6}, {47, 6} },//12 163 { {48, 6}, {49, 6}, {50, 6}, {51, 6} },//13 164 { {52, 6}, {53, 6}, {54, 6}, {55, 6} },//14 165 { {56, 6}, {57, 6}, {58, 6}, {59, 6} },//15 166 { {60, 6}, {61, 6}, {62, 6}, {63, 6} } //16 167 }, 168 169 { 170 //nc == -1 171 { { 1, 2}, { 0, 0}, { 0, 0}, { 0, 0} },//0 172 { { 7, 6}, { 1, 1}, { 0, 0}, { 0, 0} },//1 173 { { 4, 6}, { 6, 6}, { 1, 3}, { 0, 0} },//2 174 { { 3, 6}, { 3, 7}, { 2, 7}, { 5, 6} },//3 175 { { 2, 6}, { 3, 8}, { 2, 8}, { 0, 7} },//4 176 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//5 177 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//6 178 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//7 179 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//8 180 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//9 181 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//10 182 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//11 183 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//12 184 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//13 185 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//14 186 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} },//15 187 { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} } //16 188 } 189 }; 190 191 //const uint8_t g_kuiVlcLevelPrefix[15][2] = 192 //{ 193 // {1, 1}, {1, 2} 194 //}; 195 196 //g_kuiVlcTotalZeros[tzVlcIndex][total_zeros][0--value, 1--bit count] 197 const uint8_t g_kuiVlcTotalZeros[16][16][2] = { 198 { 199 //0 not available 200 {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 201 }, 202 { 203 //1 204 {1, 1}, {3, 3}, {2, 3}, {3, 4}, {2, 4}, {3, 5}, {2, 5}, {3, 6}, {2, 6}, {3, 7}, {2, 7}, {3, 8}, {2, 8}, {3, 9}, {2, 9}, {1, 9} 205 }, 206 { 207 //2 208 {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {5, 4}, {4, 4}, {3, 4}, {2, 4}, {3, 5}, {2, 5}, {3, 6}, {2, 6}, {1, 6}, {0, 6}, {0, 0} 209 }, 210 { 211 //3 212 {5, 4}, {7, 3}, {6, 3}, {5, 3}, {4, 4}, {3, 4}, {4, 3}, {3, 3}, {2, 4}, {3, 5}, {2, 5}, {1, 6}, {1, 5}, {0, 6}, {0, 0}, {0, 0} 213 }, 214 { 215 //4 216 {3, 5}, {7, 3}, {5, 4}, {4, 4}, {6, 3}, {5, 3}, {4, 3}, {3, 4}, {3, 3}, {2, 4}, {2, 5}, {1, 5}, {0, 5}, {0, 0}, {0, 0}, {0, 0} 217 }, 218 { 219 //5 220 {5, 4}, {4, 4}, {3, 4}, {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 4}, {1, 5}, {1, 4}, {0, 5}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 221 }, 222 { 223 //6 224 {1, 6}, {1, 5}, {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 4}, {1, 3}, {0, 6}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 225 }, 226 { 227 //7 228 {1, 6}, {1, 5}, {5, 3}, {4, 3}, {3, 3}, {3, 2}, {2, 3}, {1, 4}, {1, 3}, {0, 6}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 229 }, 230 { 231 //8 232 {1, 6}, {1, 4}, {1, 5}, {3, 3}, {3, 2}, {2, 2}, {2, 3}, {1, 3}, {0, 6}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 233 }, 234 { 235 //9 236 {1, 6}, {0, 6}, {1, 4}, {3, 2}, {2, 2}, {1, 3}, {1, 2}, {1, 5}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 237 }, 238 { 239 //10 240 {1, 5}, {0, 5}, {1, 3}, {3, 2}, {2, 2}, {1, 2}, {1, 4}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 241 }, 242 { 243 //11 244 {0, 4}, {1, 4}, {1, 3}, {2, 3}, {1, 1}, {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 245 }, 246 { 247 //12 248 {0, 4}, {1, 4}, {1, 2}, {1, 1}, {1, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 249 }, 250 { 251 //13 252 {0, 3}, {1, 3}, {1, 1}, {1, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 253 }, 254 { 255 //14 256 {0, 2}, {1, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 257 }, 258 { 259 //15 260 {0, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 261 } 262 }; 263 264 const uint8_t g_kuiVlcTotalZerosChromaDc[4][4][2] = { 265 { 266 {0, 0}, {0, 0}, {0, 0}, {0, 0} 267 }, 268 { 269 {1, 1}, {1, 2}, {1, 3}, {0, 3} 270 }, 271 { 272 {1, 1}, {1, 2}, {0, 2}, {0, 0} 273 }, 274 { 275 {1, 1}, {0, 1}, {0, 0}, {0, 0} 276 } 277 }; 278 // 279 280 //g_kuiVlcRunBefore[zeros-left][run-before][0--value, 1--bit count] 281 const uint8_t g_kuiVlcRunBefore[8][15][2] = { 282 { 283 //0 not available 284 {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 285 }, 286 { 287 //1 288 {1, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 289 }, 290 { 291 //2 292 {1, 1}, {1, 2}, {0, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 293 }, 294 { 295 //3 296 {3, 2}, {2, 2}, {1, 2}, {0, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 297 }, 298 { 299 //4 300 {3, 2}, {2, 2}, {1, 2}, {1, 3}, {0, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 301 }, 302 { 303 //5 304 {3, 2}, {2, 2}, {3, 3}, {2, 3}, {1, 3}, {0, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 305 }, 306 { 307 //6 308 {3, 2}, {0, 3}, {1, 3}, {3, 3}, {2, 3}, {5, 3}, {4, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} 309 }, 310 { 311 //>6 312 {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11} 313 } 314 }; 315 316 const ALIGNED_DECLARE (uint8_t, g_kuiEncNcMapTable[18], 16) = { 317 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 318 }; 319 320 321 322 const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE + 1] = { 323 { 324 0, 0, 0, 0, 0, 0, 0, 0, 325 0 326 }, // uiGopSize = 1 327 { 328 0, 1, 0, 0, 0, 0, 0, 0, 329 0 330 }, // uiGopSize = 2 331 { 332 0, 2, 1, 2, 0, 0, 0, 0, 333 0 334 }, // uiGopSize = 4 335 { 336 0, 3, 2, 3, 1, 3, 2, 3, 337 0 338 } //uiGopSize = 8 339 }; 340 341 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 342 343 // extern at svc_encode_slice.h 344 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 345 } 346