Path: blob/master/3rdparty/libwebp/src/dsp/lossless_enc.c
16348 views
// Copyright 2015 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Image transform methods for lossless encoder.10//11// Authors: Vikas Arora ([email protected])12// Jyrki Alakuijala ([email protected])13// Urvang Joshi ([email protected])1415#include "src/dsp/dsp.h"1617#include <assert.h>18#include <math.h>19#include <stdlib.h>20#include "src/dec/vp8li_dec.h"21#include "src/utils/endian_inl_utils.h"22#include "src/dsp/lossless.h"23#include "src/dsp/lossless_common.h"24#include "src/dsp/yuv.h"2526// lookup table for small values of log2(int)27const float kLog2Table[LOG_LOOKUP_IDX_MAX] = {280.0000000000000000f, 0.0000000000000000f,291.0000000000000000f, 1.5849625007211560f,302.0000000000000000f, 2.3219280948873621f,312.5849625007211560f, 2.8073549220576041f,323.0000000000000000f, 3.1699250014423121f,333.3219280948873621f, 3.4594316186372973f,343.5849625007211560f, 3.7004397181410921f,353.8073549220576041f, 3.9068905956085187f,364.0000000000000000f, 4.0874628412503390f,374.1699250014423121f, 4.2479275134435852f,384.3219280948873626f, 4.3923174227787606f,394.4594316186372973f, 4.5235619560570130f,404.5849625007211560f, 4.6438561897747243f,414.7004397181410917f, 4.7548875021634682f,424.8073549220576037f, 4.8579809951275718f,434.9068905956085187f, 4.9541963103868749f,445.0000000000000000f, 5.0443941193584533f,455.0874628412503390f, 5.1292830169449663f,465.1699250014423121f, 5.2094533656289501f,475.2479275134435852f, 5.2854022188622487f,485.3219280948873626f, 5.3575520046180837f,495.3923174227787606f, 5.4262647547020979f,505.4594316186372973f, 5.4918530963296747f,515.5235619560570130f, 5.5545888516776376f,525.5849625007211560f, 5.6147098441152083f,535.6438561897747243f, 5.6724253419714951f,545.7004397181410917f, 5.7279204545631987f,555.7548875021634682f, 5.7813597135246599f,565.8073549220576037f, 5.8328900141647412f,575.8579809951275718f, 5.8826430493618415f,585.9068905956085187f, 5.9307373375628866f,595.9541963103868749f, 5.9772799234999167f,606.0000000000000000f, 6.0223678130284543f,616.0443941193584533f, 6.0660891904577720f,626.0874628412503390f, 6.1085244567781691f,636.1292830169449663f, 6.1497471195046822f,646.1699250014423121f, 6.1898245588800175f,656.2094533656289501f, 6.2288186904958804f,666.2479275134435852f, 6.2667865406949010f,676.2854022188622487f, 6.3037807481771030f,686.3219280948873626f, 6.3398500028846243f,696.3575520046180837f, 6.3750394313469245f,706.3923174227787606f, 6.4093909361377017f,716.4262647547020979f, 6.4429434958487279f,726.4594316186372973f, 6.4757334309663976f,736.4918530963296747f, 6.5077946401986963f,746.5235619560570130f, 6.5391588111080309f,756.5545888516776376f, 6.5698556083309478f,766.5849625007211560f, 6.5999128421871278f,776.6147098441152083f, 6.6293566200796094f,786.6438561897747243f, 6.6582114827517946f,796.6724253419714951f, 6.6865005271832185f,806.7004397181410917f, 6.7142455176661224f,816.7279204545631987f, 6.7414669864011464f,826.7548875021634682f, 6.7681843247769259f,836.7813597135246599f, 6.7944158663501061f,846.8073549220576037f, 6.8201789624151878f,856.8328900141647412f, 6.8454900509443747f,866.8579809951275718f, 6.8703647195834047f,876.8826430493618415f, 6.8948177633079437f,886.9068905956085187f, 6.9188632372745946f,896.9307373375628866f, 6.9425145053392398f,906.9541963103868749f, 6.9657842846620869f,916.9772799234999167f, 6.9886846867721654f,927.0000000000000000f, 7.0112272554232539f,937.0223678130284543f, 7.0334230015374501f,947.0443941193584533f, 7.0552824355011898f,957.0660891904577720f, 7.0768155970508308f,967.0874628412503390f, 7.0980320829605263f,977.1085244567781691f, 7.1189410727235076f,987.1292830169449663f, 7.1395513523987936f,997.1497471195046822f, 7.1598713367783890f,1007.1699250014423121f, 7.1799090900149344f,1017.1898245588800175f, 7.1996723448363644f,1027.2094533656289501f, 7.2191685204621611f,1037.2288186904958804f, 7.2384047393250785f,1047.2479275134435852f, 7.2573878426926521f,1057.2667865406949010f, 7.2761244052742375f,1067.2854022188622487f, 7.2946207488916270f,1077.3037807481771030f, 7.3128829552843557f,1087.3219280948873626f, 7.3309168781146167f,1097.3398500028846243f, 7.3487281542310771f,1107.3575520046180837f, 7.3663222142458160f,1117.3750394313469245f, 7.3837042924740519f,1127.3923174227787606f, 7.4008794362821843f,1137.4093909361377017f, 7.4178525148858982f,1147.4262647547020979f, 7.4346282276367245f,1157.4429434958487279f, 7.4512111118323289f,1167.4594316186372973f, 7.4676055500829976f,1177.4757334309663976f, 7.4838157772642563f,1187.4918530963296747f, 7.4998458870832056f,1197.5077946401986963f, 7.5156998382840427f,1207.5235619560570130f, 7.5313814605163118f,1217.5391588111080309f, 7.5468944598876364f,1227.5545888516776376f, 7.5622424242210728f,1237.5698556083309478f, 7.5774288280357486f,1247.5849625007211560f, 7.5924570372680806f,1257.5999128421871278f, 7.6073303137496104f,1267.6147098441152083f, 7.6220518194563764f,1277.6293566200796094f, 7.6366246205436487f,1287.6438561897747243f, 7.6510516911789281f,1297.6582114827517946f, 7.6653359171851764f,1307.6724253419714951f, 7.6794800995054464f,1317.6865005271832185f, 7.6934869574993252f,1327.7004397181410917f, 7.7073591320808825f,1337.7142455176661224f, 7.7210991887071855f,1347.7279204545631987f, 7.7347096202258383f,1357.7414669864011464f, 7.7481928495894605f,1367.7548875021634682f, 7.7615512324444795f,1377.7681843247769259f, 7.7747870596011736f,1387.7813597135246599f, 7.7879025593914317f,1397.7944158663501061f, 7.8008998999203047f,1407.8073549220576037f, 7.8137811912170374f,1417.8201789624151878f, 7.8265484872909150f,1427.8328900141647412f, 7.8392037880969436f,1437.8454900509443747f, 7.8517490414160571f,1447.8579809951275718f, 7.8641861446542797f,1457.8703647195834047f, 7.8765169465649993f,1467.8826430493618415f, 7.8887432488982591f,1477.8948177633079437f, 7.9008668079807486f,1487.9068905956085187f, 7.9128893362299619f,1497.9188632372745946f, 7.9248125036057812f,1507.9307373375628866f, 7.9366379390025709f,1517.9425145053392398f, 7.9483672315846778f,1527.9541963103868749f, 7.9600019320680805f,1537.9657842846620869f, 7.9715435539507719f,1547.9772799234999167f, 7.9829935746943103f,1557.9886846867721654f, 7.9943534368588577f156};157158const float kSLog2Table[LOG_LOOKUP_IDX_MAX] = {1590.00000000f, 0.00000000f, 2.00000000f, 4.75488750f,1608.00000000f, 11.60964047f, 15.50977500f, 19.65148445f,16124.00000000f, 28.52932501f, 33.21928095f, 38.05374781f,16243.01955001f, 48.10571634f, 53.30296891f, 58.60335893f,16364.00000000f, 69.48686830f, 75.05865003f, 80.71062276f,16486.43856190f, 92.23866588f, 98.10749561f, 104.04192499f,165110.03910002f, 116.09640474f, 122.21143267f, 128.38196256f,166134.60593782f, 140.88144886f, 147.20671787f, 153.58008562f,167160.00000000f, 166.46500594f, 172.97373660f, 179.52490559f,168186.11730005f, 192.74977453f, 199.42124551f, 206.13068654f,169212.87712380f, 219.65963219f, 226.47733176f, 233.32938445f,170240.21499122f, 247.13338933f, 254.08384998f, 261.06567603f,171268.07820003f, 275.12078236f, 282.19280949f, 289.29369244f,172296.42286534f, 303.57978409f, 310.76392512f, 317.97478424f,173325.21187564f, 332.47473081f, 339.76289772f, 347.07593991f,174354.41343574f, 361.77497759f, 369.16017124f, 376.56863518f,175384.00000000f, 391.45390785f, 398.93001188f, 406.42797576f,176413.94747321f, 421.48818752f, 429.04981119f, 436.63204548f,177444.23460010f, 451.85719280f, 459.49954906f, 467.16140179f,178474.84249102f, 482.54256363f, 490.26137307f, 497.99867911f,179505.75424759f, 513.52785023f, 521.31926438f, 529.12827280f,180536.95466351f, 544.79822957f, 552.65876890f, 560.53608414f,181568.42998244f, 576.34027536f, 584.26677867f, 592.20931226f,182600.16769996f, 608.14176943f, 616.13135206f, 624.13628279f,183632.15640007f, 640.19154569f, 648.24156472f, 656.30630539f,184664.38561898f, 672.47935976f, 680.58738488f, 688.70955430f,185696.84573069f, 704.99577935f, 713.15956818f, 721.33696754f,186729.52785023f, 737.73209140f, 745.94956849f, 754.18016116f,187762.42375127f, 770.68022275f, 778.94946161f, 787.23135586f,188795.52579543f, 803.83267219f, 812.15187982f, 820.48331383f,189828.82687147f, 837.18245171f, 845.54995518f, 853.92928416f,190862.32034249f, 870.72303558f, 879.13727036f, 887.56295522f,191896.00000000f, 904.44831595f, 912.90781569f, 921.37841320f,192929.86002376f, 938.35256392f, 946.85595152f, 955.37010560f,193963.89494641f, 972.43039537f, 980.97637504f, 989.53280911f,194998.09962237f, 1006.67674069f, 1015.26409097f, 1023.86160116f,1951032.46920021f, 1041.08681805f, 1049.71438560f, 1058.35183469f,1961066.99909811f, 1075.65610955f, 1084.32280357f, 1092.99911564f,1971101.68498204f, 1110.38033993f, 1119.08512727f, 1127.79928282f,1981136.52274614f, 1145.25545758f, 1153.99735821f, 1162.74838989f,1991171.50849518f, 1180.27761738f, 1189.05570047f, 1197.84268914f,2001206.63852876f, 1215.44316535f, 1224.25654560f, 1233.07861684f,2011241.90932703f, 1250.74862473f, 1259.59645914f, 1268.45278005f,2021277.31753781f, 1286.19068338f, 1295.07216828f, 1303.96194457f,2031312.85996488f, 1321.76618236f, 1330.68055071f, 1339.60302413f,2041348.53355734f, 1357.47210556f, 1366.41862452f, 1375.37307041f,2051384.33539991f, 1393.30557020f, 1402.28353887f, 1411.26926400f,2061420.26270412f, 1429.26381818f, 1438.27256558f, 1447.28890615f,2071456.31280014f, 1465.34420819f, 1474.38309138f, 1483.42941118f,2081492.48312945f, 1501.54420843f, 1510.61261078f, 1519.68829949f,2091528.77123795f, 1537.86138993f, 1546.95871952f, 1556.06319119f,2101565.17476976f, 1574.29342040f, 1583.41910860f, 1592.55180020f,2111601.69146137f, 1610.83805860f, 1619.99155871f, 1629.15192882f,2121638.31913637f, 1647.49314911f, 1656.67393509f, 1665.86146266f,2131675.05570047f, 1684.25661744f, 1693.46418280f, 1702.67836605f,2141711.89913698f, 1721.12646563f, 1730.36032233f, 1739.60067768f,2151748.84750254f, 1758.10076802f, 1767.36044551f, 1776.62650662f,2161785.89892323f, 1795.17766747f, 1804.46271172f, 1813.75402857f,2171823.05159087f, 1832.35537170f, 1841.66534438f, 1850.98148244f,2181860.30375965f, 1869.63214999f, 1878.96662767f, 1888.30716711f,2191897.65374295f, 1907.00633003f, 1916.36490342f, 1925.72943838f,2201935.09991037f, 1944.47629506f, 1953.85856831f, 1963.24670620f,2211972.64068498f, 1982.04048108f, 1991.44607117f, 2000.85743204f,2222010.27454072f, 2019.69737440f, 2029.12591044f, 2038.56012640f223};224225const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX] = {226{ 0, 0}, { 0, 0}, { 1, 0}, { 2, 0}, { 3, 0}, { 4, 1}, { 4, 1}, { 5, 1},227{ 5, 1}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 7, 2}, { 7, 2}, { 7, 2},228{ 7, 2}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3},229{ 8, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3},230{ 9, 3}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},231{10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},232{10, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},233{11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},234{11, 4}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},235{12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},236{12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},237{12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},238{12, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},239{13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},240{13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},241{13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},242{13, 5}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},243{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},244{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},245{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},246{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},247{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},248{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},249{14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},250{14, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},251{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},252{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},253{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},254{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},255{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},256{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},257{15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},258{15, 6}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},259{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},260{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},261{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},262{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},263{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},264{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},265{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},266{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},267{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},268{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},269{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},270{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},271{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},272{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},273{16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},274{16, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},275{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},276{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},277{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},278{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},279{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},280{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},281{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},282{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},283{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},284{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},285{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},286{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},287{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},288{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},289{17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},290};291292const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX] = {2930, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3,2940, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,2950, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,2960, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,2970, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,29816, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,2990, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,30016, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,3010, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,30216, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,30332, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,30448, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,3050, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,30616, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,30732, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,30848, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,3090, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,31016, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,31132, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,31248, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,31364, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,31480, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,31596, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,316112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,317127,3180, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,31916, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,32032, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,32148, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,32264, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,32380, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,32496, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,325112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126326};327328static float FastSLog2Slow_C(uint32_t v) {329assert(v >= LOG_LOOKUP_IDX_MAX);330if (v < APPROX_LOG_WITH_CORRECTION_MAX) {331int log_cnt = 0;332uint32_t y = 1;333int correction = 0;334const float v_f = (float)v;335const uint32_t orig_v = v;336do {337++log_cnt;338v = v >> 1;339y = y << 1;340} while (v >= LOG_LOOKUP_IDX_MAX);341// vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256342// Xf = floor(Xf) * (1 + (v % y) / v)343// log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)344// The correction factor: log(1 + d) ~ d; for very small d values, so345// log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v346// LOG_2_RECIPROCAL ~ 23/16347correction = (23 * (orig_v & (y - 1))) >> 4;348return v_f * (kLog2Table[v] + log_cnt) + correction;349} else {350return (float)(LOG_2_RECIPROCAL * v * log((double)v));351}352}353354static float FastLog2Slow_C(uint32_t v) {355assert(v >= LOG_LOOKUP_IDX_MAX);356if (v < APPROX_LOG_WITH_CORRECTION_MAX) {357int log_cnt = 0;358uint32_t y = 1;359const uint32_t orig_v = v;360double log_2;361do {362++log_cnt;363v = v >> 1;364y = y << 1;365} while (v >= LOG_LOOKUP_IDX_MAX);366log_2 = kLog2Table[v] + log_cnt;367if (orig_v >= APPROX_LOG_MAX) {368// Since the division is still expensive, add this correction factor only369// for large values of 'v'.370const int correction = (23 * (orig_v & (y - 1))) >> 4;371log_2 += (double)correction / orig_v;372}373return (float)log_2;374} else {375return (float)(LOG_2_RECIPROCAL * log((double)v));376}377}378379//------------------------------------------------------------------------------380// Methods to calculate Entropy (Shannon).381382// Compute the combined Shanon's entropy for distribution {X} and {X+Y}383static float CombinedShannonEntropy_C(const int X[256], const int Y[256]) {384int i;385double retval = 0.;386int sumX = 0, sumXY = 0;387for (i = 0; i < 256; ++i) {388const int x = X[i];389if (x != 0) {390const int xy = x + Y[i];391sumX += x;392retval -= VP8LFastSLog2(x);393sumXY += xy;394retval -= VP8LFastSLog2(xy);395} else if (Y[i] != 0) {396sumXY += Y[i];397retval -= VP8LFastSLog2(Y[i]);398}399}400retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY);401return (float)retval;402}403404void VP8LBitEntropyInit(VP8LBitEntropy* const entropy) {405entropy->entropy = 0.;406entropy->sum = 0;407entropy->nonzeros = 0;408entropy->max_val = 0;409entropy->nonzero_code = VP8L_NON_TRIVIAL_SYM;410}411412void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,413VP8LBitEntropy* const entropy) {414int i;415416VP8LBitEntropyInit(entropy);417418for (i = 0; i < n; ++i) {419if (array[i] != 0) {420entropy->sum += array[i];421entropy->nonzero_code = i;422++entropy->nonzeros;423entropy->entropy -= VP8LFastSLog2(array[i]);424if (entropy->max_val < array[i]) {425entropy->max_val = array[i];426}427}428}429entropy->entropy += VP8LFastSLog2(entropy->sum);430}431432static WEBP_INLINE void GetEntropyUnrefinedHelper(433uint32_t val, int i, uint32_t* const val_prev, int* const i_prev,434VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats) {435const int streak = i - *i_prev;436437// Gather info for the bit entropy.438if (*val_prev != 0) {439bit_entropy->sum += (*val_prev) * streak;440bit_entropy->nonzeros += streak;441bit_entropy->nonzero_code = *i_prev;442bit_entropy->entropy -= VP8LFastSLog2(*val_prev) * streak;443if (bit_entropy->max_val < *val_prev) {444bit_entropy->max_val = *val_prev;445}446}447448// Gather info for the Huffman cost.449stats->counts[*val_prev != 0] += (streak > 3);450stats->streaks[*val_prev != 0][(streak > 3)] += streak;451452*val_prev = val;453*i_prev = i;454}455456static void GetEntropyUnrefined_C(const uint32_t X[], int length,457VP8LBitEntropy* const bit_entropy,458VP8LStreaks* const stats) {459int i;460int i_prev = 0;461uint32_t x_prev = X[0];462463memset(stats, 0, sizeof(*stats));464VP8LBitEntropyInit(bit_entropy);465466for (i = 1; i < length; ++i) {467const uint32_t x = X[i];468if (x != x_prev) {469GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);470}471}472GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);473474bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);475}476477static void GetCombinedEntropyUnrefined_C(const uint32_t X[],478const uint32_t Y[],479int length,480VP8LBitEntropy* const bit_entropy,481VP8LStreaks* const stats) {482int i = 1;483int i_prev = 0;484uint32_t xy_prev = X[0] + Y[0];485486memset(stats, 0, sizeof(*stats));487VP8LBitEntropyInit(bit_entropy);488489for (i = 1; i < length; ++i) {490const uint32_t xy = X[i] + Y[i];491if (xy != xy_prev) {492GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);493}494}495GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);496497bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);498}499500//------------------------------------------------------------------------------501502void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels) {503int i;504for (i = 0; i < num_pixels; ++i) {505const int argb = argb_data[i];506const int green = (argb >> 8) & 0xff;507const uint32_t new_r = (((argb >> 16) & 0xff) - green) & 0xff;508const uint32_t new_b = (((argb >> 0) & 0xff) - green) & 0xff;509argb_data[i] = (argb & 0xff00ff00u) | (new_r << 16) | new_b;510}511}512513static WEBP_INLINE int ColorTransformDelta(int8_t color_pred, int8_t color) {514return ((int)color_pred * color) >> 5;515}516517void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,518int num_pixels) {519int i;520for (i = 0; i < num_pixels; ++i) {521const uint32_t argb = data[i];522const uint32_t green = argb >> 8;523const uint32_t red = argb >> 16;524int new_red = red & 0xff;525int new_blue = argb & 0xff;526new_red -= ColorTransformDelta(m->green_to_red_, green);527new_red &= 0xff;528new_blue -= ColorTransformDelta(m->green_to_blue_, green);529new_blue -= ColorTransformDelta(m->red_to_blue_, red);530new_blue &= 0xff;531data[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);532}533}534535static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,536uint32_t argb) {537const uint32_t green = argb >> 8;538int new_red = argb >> 16;539new_red -= ColorTransformDelta(green_to_red, green);540return (new_red & 0xff);541}542543static WEBP_INLINE uint8_t TransformColorBlue(uint8_t green_to_blue,544uint8_t red_to_blue,545uint32_t argb) {546const uint32_t green = argb >> 8;547const uint32_t red = argb >> 16;548uint8_t new_blue = argb;549new_blue -= ColorTransformDelta(green_to_blue, green);550new_blue -= ColorTransformDelta(red_to_blue, red);551return (new_blue & 0xff);552}553554void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride,555int tile_width, int tile_height,556int green_to_red, int histo[]) {557while (tile_height-- > 0) {558int x;559for (x = 0; x < tile_width; ++x) {560++histo[TransformColorRed(green_to_red, argb[x])];561}562argb += stride;563}564}565566void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,567int tile_width, int tile_height,568int green_to_blue, int red_to_blue,569int histo[]) {570while (tile_height-- > 0) {571int x;572for (x = 0; x < tile_width; ++x) {573++histo[TransformColorBlue(green_to_blue, red_to_blue, argb[x])];574}575argb += stride;576}577}578579//------------------------------------------------------------------------------580581static int VectorMismatch_C(const uint32_t* const array1,582const uint32_t* const array2, int length) {583int match_len = 0;584585while (match_len < length && array1[match_len] == array2[match_len]) {586++match_len;587}588return match_len;589}590591// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.592void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits,593uint32_t* dst) {594int x;595if (xbits > 0) {596const int bit_depth = 1 << (3 - xbits);597const int mask = (1 << xbits) - 1;598uint32_t code = 0xff000000;599for (x = 0; x < width; ++x) {600const int xsub = x & mask;601if (xsub == 0) {602code = 0xff000000;603}604code |= row[x] << (8 + bit_depth * xsub);605dst[x >> xbits] = code;606}607} else {608for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8);609}610}611612//------------------------------------------------------------------------------613614static double ExtraCost_C(const uint32_t* population, int length) {615int i;616double cost = 0.;617for (i = 2; i < length - 2; ++i) cost += (i >> 1) * population[i + 2];618return cost;619}620621static double ExtraCostCombined_C(const uint32_t* X, const uint32_t* Y,622int length) {623int i;624double cost = 0.;625for (i = 2; i < length - 2; ++i) {626const int xy = X[i + 2] + Y[i + 2];627cost += (i >> 1) * xy;628}629return cost;630}631632//------------------------------------------------------------------------------633634static void HistogramAdd_C(const VP8LHistogram* const a,635const VP8LHistogram* const b,636VP8LHistogram* const out) {637int i;638const int literal_size = VP8LHistogramNumCodes(a->palette_code_bits_);639assert(a->palette_code_bits_ == b->palette_code_bits_);640if (b != out) {641for (i = 0; i < literal_size; ++i) {642out->literal_[i] = a->literal_[i] + b->literal_[i];643}644for (i = 0; i < NUM_DISTANCE_CODES; ++i) {645out->distance_[i] = a->distance_[i] + b->distance_[i];646}647for (i = 0; i < NUM_LITERAL_CODES; ++i) {648out->red_[i] = a->red_[i] + b->red_[i];649out->blue_[i] = a->blue_[i] + b->blue_[i];650out->alpha_[i] = a->alpha_[i] + b->alpha_[i];651}652} else {653for (i = 0; i < literal_size; ++i) {654out->literal_[i] += a->literal_[i];655}656for (i = 0; i < NUM_DISTANCE_CODES; ++i) {657out->distance_[i] += a->distance_[i];658}659for (i = 0; i < NUM_LITERAL_CODES; ++i) {660out->red_[i] += a->red_[i];661out->blue_[i] += a->blue_[i];662out->alpha_[i] += a->alpha_[i];663}664}665}666667//------------------------------------------------------------------------------668// Image transforms.669670static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {671return (((a0 ^ a1) & 0xfefefefeu) >> 1) + (a0 & a1);672}673674static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {675return Average2(Average2(a0, a2), a1);676}677678static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,679uint32_t a2, uint32_t a3) {680return Average2(Average2(a0, a1), Average2(a2, a3));681}682683static WEBP_INLINE uint32_t Clip255(uint32_t a) {684if (a < 256) {685return a;686}687// return 0, when a is a negative integer.688// return 255, when a is positive.689return ~a >> 24;690}691692static WEBP_INLINE int AddSubtractComponentFull(int a, int b, int c) {693return Clip255(a + b - c);694}695696static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,697uint32_t c2) {698const int a = AddSubtractComponentFull(c0 >> 24, c1 >> 24, c2 >> 24);699const int r = AddSubtractComponentFull((c0 >> 16) & 0xff,700(c1 >> 16) & 0xff,701(c2 >> 16) & 0xff);702const int g = AddSubtractComponentFull((c0 >> 8) & 0xff,703(c1 >> 8) & 0xff,704(c2 >> 8) & 0xff);705const int b = AddSubtractComponentFull(c0 & 0xff, c1 & 0xff, c2 & 0xff);706return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;707}708709static WEBP_INLINE int AddSubtractComponentHalf(int a, int b) {710return Clip255(a + (a - b) / 2);711}712713static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,714uint32_t c2) {715const uint32_t ave = Average2(c0, c1);716const int a = AddSubtractComponentHalf(ave >> 24, c2 >> 24);717const int r = AddSubtractComponentHalf((ave >> 16) & 0xff, (c2 >> 16) & 0xff);718const int g = AddSubtractComponentHalf((ave >> 8) & 0xff, (c2 >> 8) & 0xff);719const int b = AddSubtractComponentHalf((ave >> 0) & 0xff, (c2 >> 0) & 0xff);720return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;721}722723// gcc-4.9 on ARM generates incorrect code in Select() when Sub3() is inlined.724#if defined(__arm__) && \725(LOCAL_GCC_VERSION == 0x409 || LOCAL_GCC_VERSION == 0x408)726# define LOCAL_INLINE __attribute__ ((noinline))727#else728# define LOCAL_INLINE WEBP_INLINE729#endif730731static LOCAL_INLINE int Sub3(int a, int b, int c) {732const int pb = b - c;733const int pa = a - c;734return abs(pb) - abs(pa);735}736737#undef LOCAL_INLINE738739static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {740const int pa_minus_pb =741Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +742Sub3((a >> 16) & 0xff, (b >> 16) & 0xff, (c >> 16) & 0xff) +743Sub3((a >> 8) & 0xff, (b >> 8) & 0xff, (c >> 8) & 0xff) +744Sub3((a ) & 0xff, (b ) & 0xff, (c ) & 0xff);745return (pa_minus_pb <= 0) ? a : b;746}747748//------------------------------------------------------------------------------749// Predictors750751static uint32_t Predictor2(uint32_t left, const uint32_t* const top) {752(void)left;753return top[0];754}755static uint32_t Predictor3(uint32_t left, const uint32_t* const top) {756(void)left;757return top[1];758}759static uint32_t Predictor4(uint32_t left, const uint32_t* const top) {760(void)left;761return top[-1];762}763static uint32_t Predictor5(uint32_t left, const uint32_t* const top) {764const uint32_t pred = Average3(left, top[0], top[1]);765return pred;766}767static uint32_t Predictor6(uint32_t left, const uint32_t* const top) {768const uint32_t pred = Average2(left, top[-1]);769return pred;770}771static uint32_t Predictor7(uint32_t left, const uint32_t* const top) {772const uint32_t pred = Average2(left, top[0]);773return pred;774}775static uint32_t Predictor8(uint32_t left, const uint32_t* const top) {776const uint32_t pred = Average2(top[-1], top[0]);777(void)left;778return pred;779}780static uint32_t Predictor9(uint32_t left, const uint32_t* const top) {781const uint32_t pred = Average2(top[0], top[1]);782(void)left;783return pred;784}785static uint32_t Predictor10(uint32_t left, const uint32_t* const top) {786const uint32_t pred = Average4(left, top[-1], top[0], top[1]);787return pred;788}789static uint32_t Predictor11(uint32_t left, const uint32_t* const top) {790const uint32_t pred = Select(top[0], left, top[-1]);791return pred;792}793static uint32_t Predictor12(uint32_t left, const uint32_t* const top) {794const uint32_t pred = ClampedAddSubtractFull(left, top[0], top[-1]);795return pred;796}797static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {798const uint32_t pred = ClampedAddSubtractHalf(left, top[0], top[-1]);799return pred;800}801802//------------------------------------------------------------------------------803804static void PredictorSub0_C(const uint32_t* in, const uint32_t* upper,805int num_pixels, uint32_t* out) {806int i;807for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], ARGB_BLACK);808(void)upper;809}810811static void PredictorSub1_C(const uint32_t* in, const uint32_t* upper,812int num_pixels, uint32_t* out) {813int i;814for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], in[i - 1]);815(void)upper;816}817818GENERATE_PREDICTOR_SUB(Predictor2, PredictorSub2_C)819GENERATE_PREDICTOR_SUB(Predictor3, PredictorSub3_C)820GENERATE_PREDICTOR_SUB(Predictor4, PredictorSub4_C)821GENERATE_PREDICTOR_SUB(Predictor5, PredictorSub5_C)822GENERATE_PREDICTOR_SUB(Predictor6, PredictorSub6_C)823GENERATE_PREDICTOR_SUB(Predictor7, PredictorSub7_C)824GENERATE_PREDICTOR_SUB(Predictor8, PredictorSub8_C)825GENERATE_PREDICTOR_SUB(Predictor9, PredictorSub9_C)826GENERATE_PREDICTOR_SUB(Predictor10, PredictorSub10_C)827GENERATE_PREDICTOR_SUB(Predictor11, PredictorSub11_C)828GENERATE_PREDICTOR_SUB(Predictor12, PredictorSub12_C)829GENERATE_PREDICTOR_SUB(Predictor13, PredictorSub13_C)830831//------------------------------------------------------------------------------832833VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;834835VP8LTransformColorFunc VP8LTransformColor;836837VP8LCollectColorBlueTransformsFunc VP8LCollectColorBlueTransforms;838VP8LCollectColorRedTransformsFunc VP8LCollectColorRedTransforms;839840VP8LFastLog2SlowFunc VP8LFastLog2Slow;841VP8LFastLog2SlowFunc VP8LFastSLog2Slow;842843VP8LCostFunc VP8LExtraCost;844VP8LCostCombinedFunc VP8LExtraCostCombined;845VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;846847VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;848VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;849850VP8LHistogramAddFunc VP8LHistogramAdd;851852VP8LVectorMismatchFunc VP8LVectorMismatch;853VP8LBundleColorMapFunc VP8LBundleColorMap;854855VP8LPredictorAddSubFunc VP8LPredictorsSub[16];856VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16];857858extern void VP8LEncDspInitSSE2(void);859extern void VP8LEncDspInitSSE41(void);860extern void VP8LEncDspInitNEON(void);861extern void VP8LEncDspInitMIPS32(void);862extern void VP8LEncDspInitMIPSdspR2(void);863extern void VP8LEncDspInitMSA(void);864865WEBP_DSP_INIT_FUNC(VP8LEncDspInit) {866VP8LDspInit();867868#if !WEBP_NEON_OMIT_C_CODE869VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;870871VP8LTransformColor = VP8LTransformColor_C;872#endif873874VP8LCollectColorBlueTransforms = VP8LCollectColorBlueTransforms_C;875VP8LCollectColorRedTransforms = VP8LCollectColorRedTransforms_C;876877VP8LFastLog2Slow = FastLog2Slow_C;878VP8LFastSLog2Slow = FastSLog2Slow_C;879880VP8LExtraCost = ExtraCost_C;881VP8LExtraCostCombined = ExtraCostCombined_C;882VP8LCombinedShannonEntropy = CombinedShannonEntropy_C;883884VP8LGetEntropyUnrefined = GetEntropyUnrefined_C;885VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined_C;886887VP8LHistogramAdd = HistogramAdd_C;888889VP8LVectorMismatch = VectorMismatch_C;890VP8LBundleColorMap = VP8LBundleColorMap_C;891892VP8LPredictorsSub[0] = PredictorSub0_C;893VP8LPredictorsSub[1] = PredictorSub1_C;894VP8LPredictorsSub[2] = PredictorSub2_C;895VP8LPredictorsSub[3] = PredictorSub3_C;896VP8LPredictorsSub[4] = PredictorSub4_C;897VP8LPredictorsSub[5] = PredictorSub5_C;898VP8LPredictorsSub[6] = PredictorSub6_C;899VP8LPredictorsSub[7] = PredictorSub7_C;900VP8LPredictorsSub[8] = PredictorSub8_C;901VP8LPredictorsSub[9] = PredictorSub9_C;902VP8LPredictorsSub[10] = PredictorSub10_C;903VP8LPredictorsSub[11] = PredictorSub11_C;904VP8LPredictorsSub[12] = PredictorSub12_C;905VP8LPredictorsSub[13] = PredictorSub13_C;906VP8LPredictorsSub[14] = PredictorSub0_C; // <- padding security sentinels907VP8LPredictorsSub[15] = PredictorSub0_C;908909VP8LPredictorsSub_C[0] = PredictorSub0_C;910VP8LPredictorsSub_C[1] = PredictorSub1_C;911VP8LPredictorsSub_C[2] = PredictorSub2_C;912VP8LPredictorsSub_C[3] = PredictorSub3_C;913VP8LPredictorsSub_C[4] = PredictorSub4_C;914VP8LPredictorsSub_C[5] = PredictorSub5_C;915VP8LPredictorsSub_C[6] = PredictorSub6_C;916VP8LPredictorsSub_C[7] = PredictorSub7_C;917VP8LPredictorsSub_C[8] = PredictorSub8_C;918VP8LPredictorsSub_C[9] = PredictorSub9_C;919VP8LPredictorsSub_C[10] = PredictorSub10_C;920VP8LPredictorsSub_C[11] = PredictorSub11_C;921VP8LPredictorsSub_C[12] = PredictorSub12_C;922VP8LPredictorsSub_C[13] = PredictorSub13_C;923VP8LPredictorsSub_C[14] = PredictorSub0_C; // <- padding security sentinels924VP8LPredictorsSub_C[15] = PredictorSub0_C;925926// If defined, use CPUInfo() to overwrite some pointers with faster versions.927if (VP8GetCPUInfo != NULL) {928#if defined(WEBP_USE_SSE2)929if (VP8GetCPUInfo(kSSE2)) {930VP8LEncDspInitSSE2();931#if defined(WEBP_USE_SSE41)932if (VP8GetCPUInfo(kSSE4_1)) {933VP8LEncDspInitSSE41();934}935#endif936}937#endif938#if defined(WEBP_USE_MIPS32)939if (VP8GetCPUInfo(kMIPS32)) {940VP8LEncDspInitMIPS32();941}942#endif943#if defined(WEBP_USE_MIPS_DSP_R2)944if (VP8GetCPUInfo(kMIPSdspR2)) {945VP8LEncDspInitMIPSdspR2();946}947#endif948#if defined(WEBP_USE_MSA)949if (VP8GetCPUInfo(kMSA)) {950VP8LEncDspInitMSA();951}952#endif953}954955#if defined(WEBP_USE_NEON)956if (WEBP_NEON_OMIT_C_CODE ||957(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {958VP8LEncDspInitNEON();959}960#endif961962assert(VP8LSubtractGreenFromBlueAndRed != NULL);963assert(VP8LTransformColor != NULL);964assert(VP8LCollectColorBlueTransforms != NULL);965assert(VP8LCollectColorRedTransforms != NULL);966assert(VP8LFastLog2Slow != NULL);967assert(VP8LFastSLog2Slow != NULL);968assert(VP8LExtraCost != NULL);969assert(VP8LExtraCostCombined != NULL);970assert(VP8LCombinedShannonEntropy != NULL);971assert(VP8LGetEntropyUnrefined != NULL);972assert(VP8LGetCombinedEntropyUnrefined != NULL);973assert(VP8LHistogramAdd != NULL);974assert(VP8LVectorMismatch != NULL);975assert(VP8LBundleColorMap != NULL);976assert(VP8LPredictorsSub[0] != NULL);977assert(VP8LPredictorsSub[1] != NULL);978assert(VP8LPredictorsSub[2] != NULL);979assert(VP8LPredictorsSub[3] != NULL);980assert(VP8LPredictorsSub[4] != NULL);981assert(VP8LPredictorsSub[5] != NULL);982assert(VP8LPredictorsSub[6] != NULL);983assert(VP8LPredictorsSub[7] != NULL);984assert(VP8LPredictorsSub[8] != NULL);985assert(VP8LPredictorsSub[9] != NULL);986assert(VP8LPredictorsSub[10] != NULL);987assert(VP8LPredictorsSub[11] != NULL);988assert(VP8LPredictorsSub[12] != NULL);989assert(VP8LPredictorsSub[13] != NULL);990assert(VP8LPredictorsSub[14] != NULL);991assert(VP8LPredictorsSub[15] != NULL);992assert(VP8LPredictorsSub_C[0] != NULL);993assert(VP8LPredictorsSub_C[1] != NULL);994assert(VP8LPredictorsSub_C[2] != NULL);995assert(VP8LPredictorsSub_C[3] != NULL);996assert(VP8LPredictorsSub_C[4] != NULL);997assert(VP8LPredictorsSub_C[5] != NULL);998assert(VP8LPredictorsSub_C[6] != NULL);999assert(VP8LPredictorsSub_C[7] != NULL);1000assert(VP8LPredictorsSub_C[8] != NULL);1001assert(VP8LPredictorsSub_C[9] != NULL);1002assert(VP8LPredictorsSub_C[10] != NULL);1003assert(VP8LPredictorsSub_C[11] != NULL);1004assert(VP8LPredictorsSub_C[12] != NULL);1005assert(VP8LPredictorsSub_C[13] != NULL);1006assert(VP8LPredictorsSub_C[14] != NULL);1007assert(VP8LPredictorsSub_C[15] != NULL);1008}10091010//------------------------------------------------------------------------------101110121013