go-libwebp

Experimental translation from libwebp to Go source.
Log | Files | Refs | README | LICENSE

libwebp_darwin_amd64.go (2234970B)


      1 // Code generated for darwin/amd64 by 'ccgo --goos=darwin --goarch=amd64 --package-name=webp -ignore-asm-errors -nostdinc -isystem /tmp/claude-1000/-home-jfm-Source-Personal-go-libwebp/63cfa3bd-5955-40ba-bf85-20c89d375570/scratchpad/zig-x86_64-linux-0.15.2/lib/include -isystem /tmp/claude-1000/-home-jfm-Source-Personal-go-libwebp/63cfa3bd-5955-40ba-bf85-20c89d375570/scratchpad/zig-x86_64-linux-0.15.2/lib/libc/include/any-macos-any -o /home/jfm/Source/Personal/go-libwebp/tools/../lib/transpiled/webp/libwebp_darwin_amd64.go -DNDEBUG -DHAVE_CONFIG_H -I/tmp/tmp.jLmqxibQOP -I. src/dec/alpha_dec.c src/dec/buffer_dec.c src/dec/frame_dec.c src/dec/idec_dec.c src/dec/io_dec.c src/dec/quant_dec.c src/dec/tree_dec.c src/dec/vp8_dec.c src/dec/vp8l_dec.c src/dec/webp_dec.c src/enc/alpha_enc.c src/enc/analysis_enc.c src/enc/backward_references_cost_enc.c src/enc/backward_references_enc.c src/enc/config_enc.c src/enc/cost_enc.c src/enc/filter_enc.c src/enc/frame_enc.c src/enc/histogram_enc.c src/enc/iterator_enc.c src/enc/near_lossless_enc.c src/enc/picture_csp_enc.c src/enc/picture_enc.c src/enc/picture_psnr_enc.c src/enc/picture_rescale_enc.c src/enc/picture_tools_enc.c src/enc/predictor_enc.c src/enc/quant_enc.c src/enc/syntax_enc.c src/enc/token_enc.c src/enc/tree_enc.c src/enc/vp8l_enc.c src/enc/webp_enc.c src/utils/bit_reader_utils.c src/utils/bit_writer_utils.c src/utils/color_cache_utils.c src/utils/filters_utils.c src/utils/huffman_encode_utils.c src/utils/huffman_utils.c src/utils/palette.c src/utils/quant_levels_dec_utils.c src/utils/quant_levels_utils.c src/utils/random_utils.c src/utils/rescaler_utils.c src/utils/thread_utils.c src/utils/utils.c src/dsp/alpha_processing.c src/dsp/alpha_processing_mips_dsp_r2.c src/dsp/alpha_processing_neon.c src/dsp/alpha_processing_sse2.c src/dsp/alpha_processing_sse41.c src/dsp/cost.c src/dsp/cost_mips32.c src/dsp/cost_mips_dsp_r2.c src/dsp/cost_neon.c src/dsp/cost_sse2.c src/dsp/cpu.c src/dsp/dec.c src/dsp/dec_clip_tables.c src/dsp/dec_mips32.c src/dsp/dec_mips_dsp_r2.c src/dsp/dec_msa.c src/dsp/dec_neon.c src/dsp/dec_sse2.c src/dsp/dec_sse41.c src/dsp/enc.c src/dsp/enc_mips32.c src/dsp/enc_mips_dsp_r2.c src/dsp/enc_msa.c src/dsp/enc_neon.c src/dsp/enc_sse2.c src/dsp/enc_sse41.c src/dsp/filters.c src/dsp/filters_mips_dsp_r2.c src/dsp/filters_msa.c src/dsp/filters_neon.c src/dsp/filters_sse2.c src/dsp/lossless_avx2.c src/dsp/lossless.c src/dsp/lossless_enc_avx2.c src/dsp/lossless_enc.c src/dsp/lossless_enc_mips32.c src/dsp/lossless_enc_mips_dsp_r2.c src/dsp/lossless_enc_msa.c src/dsp/lossless_enc_neon.c src/dsp/lossless_enc_sse2.c src/dsp/lossless_enc_sse41.c src/dsp/lossless_mips_dsp_r2.c src/dsp/lossless_msa.c src/dsp/lossless_neon.c src/dsp/lossless_sse2.c src/dsp/lossless_sse41.c src/dsp/rescaler.c src/dsp/rescaler_mips32.c src/dsp/rescaler_mips_dsp_r2.c src/dsp/rescaler_msa.c src/dsp/rescaler_neon.c src/dsp/rescaler_sse2.c src/dsp/ssim.c src/dsp/ssim_sse2.c src/dsp/upsampling.c src/dsp/upsampling_mips_dsp_r2.c src/dsp/upsampling_msa.c src/dsp/upsampling_neon.c src/dsp/upsampling_sse2.c src/dsp/upsampling_sse41.c src/dsp/yuv.c src/dsp/yuv_mips32.c src/dsp/yuv_mips_dsp_r2.c src/dsp/yuv_neon.c src/dsp/yuv_sse2.c src/dsp/yuv_sse41.c /home/jfm/Source/Personal/go-libwebp/tools/sharpyuv_stub.c', DO NOT EDIT.
      2 
      3 //go:build darwin && amd64
      4 
      5 package webp
      6 
      7 import (
      8 	"math"
      9 	"reflect"
     10 	"unsafe"
     11 
     12 	"modernc.org/libc"
     13 )
     14 
     15 var _ = math.Pi
     16 var _ reflect.Type
     17 var _ unsafe.Pointer
     18 
     19 const ALPHA_HEADER_LEN = 1
     20 const ALPHA_LOSSLESS_COMPRESSION = 1
     21 const ALPHA_NO_COMPRESSION = 0
     22 const ALPHA_PREPROCESSED_LEVELS = 1
     23 const ANIM_CHUNK_SIZE = 6
     24 const ANMF_CHUNK_SIZE = 16
     25 const ARGB_BLACK = 0xff000000
     26 const BADSIG = "SIG_ERR"
     27 const BIG_ENDIAN = "__DARWIN_BIG_ENDIAN"
     28 const BITS = 56
     29 const BITTRACE = 0
     30 const BPS = 32
     31 const BUS_ADRALN = 1
     32 const BUS_ADRERR = 2
     33 const BUS_NOOP = 0
     34 const BUS_OBJERR = 3
     35 const BYTE_ORDER = "__DARWIN_BYTE_ORDER"
     36 const CHUNK_HEADER_SIZE = 8
     37 const CHUNK_SIZE_BYTES = 4
     38 const CLD_CONTINUED = 6
     39 const CLD_DUMPED = 3
     40 const CLD_EXITED = 1
     41 const CLD_KILLED = 2
     42 const CLD_NOOP = 0
     43 const CLD_STOPPED = 5
     44 const CLD_TRAPPED = 4
     45 const CODE_LENGTH_CODES = 19
     46 const CPUMON_MAKE_FATAL = 0x1000
     47 const DEC_MAJ_VERSION = 1
     48 const DEC_MIN_VERSION = 6
     49 const DEC_REV_VERSION = 0
     50 const DEFAULT_CODE_LENGTH = 8
     51 const EXIT_FAILURE = 1
     52 const EXIT_SUCCESS = 0
     53 const FOOTPRINT_INTERVAL_RESET = 0x1
     54 const FPE_FLTDIV = 1
     55 const FPE_FLTINV = 5
     56 const FPE_FLTOVF = 2
     57 const FPE_FLTRES = 4
     58 const FPE_FLTSUB = 6
     59 const FPE_FLTUND = 3
     60 const FPE_INTDIV = 7
     61 const FPE_INTOVF = 8
     62 const FPE_NOOP = 0
     63 const FP_CHOP = 3
     64 const FP_PREC_24B = 0
     65 const FP_PREC_53B = 2
     66 const FP_PREC_64B = 3
     67 const FP_RND_DOWN = 1
     68 const FP_RND_NEAR = 0
     69 const FP_RND_UP = 2
     70 const FP_STATE_BYTES = 512
     71 const HAVE_BUILTIN_BSWAP16 = 1
     72 const HAVE_BUILTIN_BSWAP32 = 1
     73 const HAVE_BUILTIN_BSWAP64 = 1
     74 const HAVE_CONFIG_H = 1
     75 const HUFFMAN_CODES_PER_META_CODE = 5
     76 const HUFFMAN_PACKED_BITS = 6
     77 const HUFFMAN_TABLE_BITS = 8
     78 const ILL_BADSTK = 8
     79 const ILL_COPROC = 7
     80 const ILL_ILLADR = 5
     81 const ILL_ILLOPC = 1
     82 const ILL_ILLOPN = 4
     83 const ILL_ILLTRP = 2
     84 const ILL_NOOP = 0
     85 const ILL_PRVOPC = 3
     86 const ILL_PRVREG = 6
     87 const INT16_MAX = 32767
     88 const INT32_MAX = 2147483647
     89 const INT64_MAX = 9223372036854775807
     90 const INT8_MAX = 127
     91 const INTPTR_MAX = 9223372036854775807
     92 const INT_FAST16_MAX = "INT16_MAX"
     93 const INT_FAST16_MIN = "INT16_MIN"
     94 const INT_FAST32_MAX = "INT32_MAX"
     95 const INT_FAST32_MIN = "INT32_MIN"
     96 const INT_FAST64_MAX = "INT64_MAX"
     97 const INT_FAST64_MIN = "INT64_MIN"
     98 const INT_FAST8_MAX = "INT8_MAX"
     99 const INT_FAST8_MIN = "INT8_MIN"
    100 const INT_LEAST16_MAX = "INT16_MAX"
    101 const INT_LEAST16_MIN = "INT16_MIN"
    102 const INT_LEAST32_MAX = "INT32_MAX"
    103 const INT_LEAST32_MIN = "INT32_MIN"
    104 const INT_LEAST64_MAX = "INT64_MAX"
    105 const INT_LEAST64_MIN = "INT64_MIN"
    106 const INT_LEAST8_MAX = "INT8_MAX"
    107 const INT_LEAST8_MIN = "INT8_MIN"
    108 const IOPOL_APPLICATION = "IOPOL_STANDARD"
    109 const IOPOL_ATIME_UPDATES_DEFAULT = 0
    110 const IOPOL_ATIME_UPDATES_OFF = 1
    111 const IOPOL_DEFAULT = 0
    112 const IOPOL_IMPORTANT = 1
    113 const IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0
    114 const IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1
    115 const IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2
    116 const IOPOL_NORMAL = "IOPOL_IMPORTANT"
    117 const IOPOL_PASSIVE = 2
    118 const IOPOL_SCOPE_DARWIN_BG = 2
    119 const IOPOL_SCOPE_PROCESS = 0
    120 const IOPOL_SCOPE_THREAD = 1
    121 const IOPOL_STANDARD = 5
    122 const IOPOL_THROTTLE = 3
    123 const IOPOL_TYPE_DISK = 0
    124 const IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES = 9
    125 const IOPOL_TYPE_VFS_ATIME_UPDATES = 2
    126 const IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY = 10
    127 const IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION = 6
    128 const IOPOL_TYPE_VFS_IGNORE_PERMISSIONS = 7
    129 const IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3
    130 const IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE = 8
    131 const IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4
    132 const IOPOL_TYPE_VFS_TRIGGER_RESOLVE = 5
    133 const IOPOL_UTILITY = 4
    134 const IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF = 0
    135 const IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON = 1
    136 const IOPOL_VFS_CONTENT_PROTECTION_DEFAULT = 0
    137 const IOPOL_VFS_CONTENT_PROTECTION_IGNORE = 1
    138 const IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT = 0
    139 const IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON = 1
    140 const IOPOL_VFS_IGNORE_PERMISSIONS_OFF = 0
    141 const IOPOL_VFS_IGNORE_PERMISSIONS_ON = 1
    142 const IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT = 0
    143 const IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON = 1
    144 const IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE = 2
    145 const IOPOL_VFS_SKIP_MTIME_UPDATE_OFF = 0
    146 const IOPOL_VFS_SKIP_MTIME_UPDATE_ON = 1
    147 const IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1
    148 const IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0
    149 const IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT = 0
    150 const IOPOL_VFS_TRIGGER_RESOLVE_OFF = 1
    151 const LENGTHS_TABLE_BITS = 7
    152 const LITTLE_ENDIAN = "__DARWIN_LITTLE_ENDIAN"
    153 const LOCAL_CLANG_VERSION = 0
    154 const MAC_OS_VERSION_11_0 = "__MAC_11_0"
    155 const MAC_OS_VERSION_11_1 = "__MAC_11_1"
    156 const MAC_OS_VERSION_11_3 = "__MAC_11_3"
    157 const MAC_OS_VERSION_11_4 = "__MAC_11_4"
    158 const MAC_OS_VERSION_11_5 = "__MAC_11_5"
    159 const MAC_OS_VERSION_11_6 = "__MAC_11_6"
    160 const MAC_OS_VERSION_12_0 = "__MAC_12_0"
    161 const MAC_OS_VERSION_12_1 = "__MAC_12_1"
    162 const MAC_OS_VERSION_12_2 = "__MAC_12_2"
    163 const MAC_OS_VERSION_12_3 = "__MAC_12_3"
    164 const MAC_OS_VERSION_12_4 = "__MAC_12_4"
    165 const MAC_OS_VERSION_12_5 = "__MAC_12_5"
    166 const MAC_OS_VERSION_12_6 = "__MAC_12_6"
    167 const MAC_OS_VERSION_12_7 = "__MAC_12_7"
    168 const MAC_OS_VERSION_13_0 = "__MAC_13_0"
    169 const MAC_OS_VERSION_13_1 = "__MAC_13_1"
    170 const MAC_OS_VERSION_13_2 = "__MAC_13_2"
    171 const MAC_OS_VERSION_13_3 = "__MAC_13_3"
    172 const MAC_OS_VERSION_13_4 = "__MAC_13_4"
    173 const MAC_OS_VERSION_13_5 = "__MAC_13_5"
    174 const MAC_OS_VERSION_13_6 = "__MAC_13_6"
    175 const MAC_OS_VERSION_13_7 = "__MAC_13_7"
    176 const MAC_OS_VERSION_14_0 = "__MAC_14_0"
    177 const MAC_OS_VERSION_14_1 = "__MAC_14_1"
    178 const MAC_OS_VERSION_14_2 = "__MAC_14_2"
    179 const MAC_OS_VERSION_14_3 = "__MAC_14_3"
    180 const MAC_OS_VERSION_14_4 = "__MAC_14_4"
    181 const MAC_OS_VERSION_14_5 = "__MAC_14_5"
    182 const MAC_OS_VERSION_14_6 = "__MAC_14_6"
    183 const MAC_OS_VERSION_14_7 = "__MAC_14_7"
    184 const MAC_OS_VERSION_15_0 = "__MAC_15_0"
    185 const MAC_OS_VERSION_15_1 = "__MAC_15_1"
    186 const MAC_OS_VERSION_15_2 = "__MAC_15_2"
    187 const MAC_OS_VERSION_15_3 = "__MAC_15_3"
    188 const MAC_OS_VERSION_15_4 = "__MAC_15_4"
    189 const MAC_OS_VERSION_15_5 = "__MAC_15_5"
    190 const MAC_OS_X_VERSION_10_0 = "__MAC_10_0"
    191 const MAC_OS_X_VERSION_10_1 = "__MAC_10_1"
    192 const MAC_OS_X_VERSION_10_10 = "__MAC_10_10"
    193 const MAC_OS_X_VERSION_10_10_2 = "__MAC_10_10_2"
    194 const MAC_OS_X_VERSION_10_10_3 = "__MAC_10_10_3"
    195 const MAC_OS_X_VERSION_10_11 = "__MAC_10_11"
    196 const MAC_OS_X_VERSION_10_11_2 = "__MAC_10_11_2"
    197 const MAC_OS_X_VERSION_10_11_3 = "__MAC_10_11_3"
    198 const MAC_OS_X_VERSION_10_11_4 = "__MAC_10_11_4"
    199 const MAC_OS_X_VERSION_10_12 = "__MAC_10_12"
    200 const MAC_OS_X_VERSION_10_12_1 = "__MAC_10_12_1"
    201 const MAC_OS_X_VERSION_10_12_2 = "__MAC_10_12_2"
    202 const MAC_OS_X_VERSION_10_12_4 = "__MAC_10_12_4"
    203 const MAC_OS_X_VERSION_10_13 = "__MAC_10_13"
    204 const MAC_OS_X_VERSION_10_13_1 = "__MAC_10_13_1"
    205 const MAC_OS_X_VERSION_10_13_2 = "__MAC_10_13_2"
    206 const MAC_OS_X_VERSION_10_13_4 = "__MAC_10_13_4"
    207 const MAC_OS_X_VERSION_10_14 = "__MAC_10_14"
    208 const MAC_OS_X_VERSION_10_14_1 = "__MAC_10_14_1"
    209 const MAC_OS_X_VERSION_10_14_4 = "__MAC_10_14_4"
    210 const MAC_OS_X_VERSION_10_14_5 = "__MAC_10_14_5"
    211 const MAC_OS_X_VERSION_10_14_6 = "__MAC_10_14_6"
    212 const MAC_OS_X_VERSION_10_15 = "__MAC_10_15"
    213 const MAC_OS_X_VERSION_10_15_1 = "__MAC_10_15_1"
    214 const MAC_OS_X_VERSION_10_15_4 = "__MAC_10_15_4"
    215 const MAC_OS_X_VERSION_10_16 = "__MAC_10_16"
    216 const MAC_OS_X_VERSION_10_2 = "__MAC_10_2"
    217 const MAC_OS_X_VERSION_10_3 = "__MAC_10_3"
    218 const MAC_OS_X_VERSION_10_4 = "__MAC_10_4"
    219 const MAC_OS_X_VERSION_10_5 = "__MAC_10_5"
    220 const MAC_OS_X_VERSION_10_6 = "__MAC_10_6"
    221 const MAC_OS_X_VERSION_10_7 = "__MAC_10_7"
    222 const MAC_OS_X_VERSION_10_8 = "__MAC_10_8"
    223 const MAC_OS_X_VERSION_10_9 = "__MAC_10_9"
    224 const MAX_ALLOWED_CODE_LENGTH = 15
    225 const MAX_CACHE_BITS = 11
    226 const MAX_COEFF_THRESH = 31
    227 const MAX_PALETTE_SIZE = 256
    228 const MB_CUR_MAX = "__mb_cur_max"
    229 const MINSIGSTKSZ = 32768
    230 const MIN_HUFFMAN_BITS = 2
    231 const MIN_TRANSFORM_BITS = 2
    232 const MIN_WIDTH_FOR_THREADS = 512
    233 const NDEBUG = 1
    234 const NSIG = "__DARWIN_NSIG"
    235 const NUM_DISTANCE_CODES = 40
    236 const NUM_HUFFMAN_BITS = 3
    237 const NUM_LENGTH_CODES = 24
    238 const NUM_LITERAL_CODES = 256
    239 const NUM_TRANSFORMS = 4
    240 const NUM_TRANSFORM_BITS = 3
    241 const PDP_ENDIAN = "__DARWIN_PDP_ENDIAN"
    242 const POLL_ERR = 4
    243 const POLL_HUP = 6
    244 const POLL_IN = 1
    245 const POLL_MSG = 3
    246 const POLL_OUT = 2
    247 const POLL_PRI = 5
    248 const PRIO_DARWIN_BG = 0x1000
    249 const PRIO_DARWIN_NONUI = 0x1001
    250 const PRIO_DARWIN_PROCESS = 4
    251 const PRIO_DARWIN_THREAD = 3
    252 const PRIO_MAX = 20
    253 const PRIO_PGRP = 1
    254 const PRIO_PROCESS = 0
    255 const PRIO_USER = 2
    256 const PRIX16 = "hX"
    257 const PRIX32 = "X"
    258 const PRIXFAST16 = "PRIX16"
    259 const PRIXFAST32 = "PRIX32"
    260 const PRIXFAST64 = "PRIX64"
    261 const PRIXFAST8 = "PRIX8"
    262 const PRIXLEAST16 = "PRIX16"
    263 const PRIXLEAST32 = "PRIX32"
    264 const PRIXLEAST64 = "PRIX64"
    265 const PRIXLEAST8 = "PRIX8"
    266 const PRIXPTR = "lX"
    267 const PRId16 = "hd"
    268 const PRId32 = "d"
    269 const PRIdFAST16 = "PRId16"
    270 const PRIdFAST32 = "PRId32"
    271 const PRIdFAST64 = "PRId64"
    272 const PRIdFAST8 = "PRId8"
    273 const PRIdLEAST16 = "PRId16"
    274 const PRIdLEAST32 = "PRId32"
    275 const PRIdLEAST64 = "PRId64"
    276 const PRIdLEAST8 = "PRId8"
    277 const PRIdPTR = "ld"
    278 const PRIi16 = "hi"
    279 const PRIi32 = "i"
    280 const PRIiFAST16 = "PRIi16"
    281 const PRIiFAST32 = "PRIi32"
    282 const PRIiFAST64 = "PRIi64"
    283 const PRIiFAST8 = "PRIi8"
    284 const PRIiLEAST16 = "PRIi16"
    285 const PRIiLEAST32 = "PRIi32"
    286 const PRIiLEAST64 = "PRIi64"
    287 const PRIiLEAST8 = "PRIi8"
    288 const PRIiPTR = "li"
    289 const PRIo16 = "ho"
    290 const PRIo32 = "o"
    291 const PRIoFAST16 = "PRIo16"
    292 const PRIoFAST32 = "PRIo32"
    293 const PRIoFAST64 = "PRIo64"
    294 const PRIoFAST8 = "PRIo8"
    295 const PRIoLEAST16 = "PRIo16"
    296 const PRIoLEAST32 = "PRIo32"
    297 const PRIoLEAST64 = "PRIo64"
    298 const PRIoLEAST8 = "PRIo8"
    299 const PRIoPTR = "lo"
    300 const PRIu16 = "hu"
    301 const PRIu32 = "u"
    302 const PRIuFAST16 = "PRIu16"
    303 const PRIuFAST32 = "PRIu32"
    304 const PRIuFAST64 = "PRIu64"
    305 const PRIuFAST8 = "PRIu8"
    306 const PRIuLEAST16 = "PRIu16"
    307 const PRIuLEAST32 = "PRIu32"
    308 const PRIuLEAST64 = "PRIu64"
    309 const PRIuLEAST8 = "PRIu8"
    310 const PRIuPTR = "lu"
    311 const PRIx16 = "hx"
    312 const PRIx32 = "x"
    313 const PRIxFAST16 = "PRIx16"
    314 const PRIxFAST32 = "PRIx32"
    315 const PRIxFAST64 = "PRIx64"
    316 const PRIxFAST8 = "PRIx8"
    317 const PRIxLEAST16 = "PRIx16"
    318 const PRIxLEAST32 = "PRIx32"
    319 const PRIxLEAST64 = "PRIx64"
    320 const PRIxLEAST8 = "PRIx8"
    321 const PRIxPTR = "lx"
    322 const PTRDIFF_MAX = "INTMAX_MAX"
    323 const PTRDIFF_MIN = "INTMAX_MIN"
    324 const RAND_MAX = 0x7fffffff
    325 const RIFF_HEADER_SIZE = 12
    326 const RLIMIT_AS = 5
    327 const RLIMIT_CORE = 4
    328 const RLIMIT_CPU = 0
    329 const RLIMIT_CPU_USAGE_MONITOR = 0x2
    330 const RLIMIT_DATA = 2
    331 const RLIMIT_FOOTPRINT_INTERVAL = 0x4
    332 const RLIMIT_FSIZE = 1
    333 const RLIMIT_MEMLOCK = 6
    334 const RLIMIT_NOFILE = 8
    335 const RLIMIT_NPROC = 7
    336 const RLIMIT_RSS = "RLIMIT_AS"
    337 const RLIMIT_STACK = 3
    338 const RLIMIT_THREAD_CPULIMITS = 0x3
    339 const RLIMIT_WAKEUPS_MONITOR = 0x1
    340 const RLIM_NLIMITS = 9
    341 const RLIM_SAVED_CUR = "RLIM_INFINITY"
    342 const RLIM_SAVED_MAX = "RLIM_INFINITY"
    343 const RUSAGE_INFO_CURRENT = "RUSAGE_INFO_V6"
    344 const RUSAGE_INFO_V0 = 0
    345 const RUSAGE_INFO_V1 = 1
    346 const RUSAGE_INFO_V2 = 2
    347 const RUSAGE_INFO_V3 = 3
    348 const RUSAGE_INFO_V4 = 4
    349 const RUSAGE_INFO_V5 = 5
    350 const RUSAGE_INFO_V6 = 6
    351 const RUSAGE_SELF = 0
    352 const RU_PROC_RUNS_RESLIDE = 0x00000001
    353 const SA_64REGSET = 0x0200
    354 const SA_NOCLDSTOP = 0x0008
    355 const SA_NOCLDWAIT = 0x0020
    356 const SA_NODEFER = 0x0010
    357 const SA_ONSTACK = 0x0001
    358 const SA_RESETHAND = 0x0004
    359 const SA_RESTART = 0x0002
    360 const SA_SIGINFO = 0x0040
    361 const SA_USERTRAMP = 0x0100
    362 const SCNd16 = "hd"
    363 const SCNd32 = "d"
    364 const SCNdFAST16 = "SCNd16"
    365 const SCNdFAST32 = "SCNd32"
    366 const SCNdFAST64 = "SCNd64"
    367 const SCNdFAST8 = "SCNd8"
    368 const SCNdLEAST16 = "SCNd16"
    369 const SCNdLEAST32 = "SCNd32"
    370 const SCNdLEAST64 = "SCNd64"
    371 const SCNdLEAST8 = "SCNd8"
    372 const SCNdPTR = "ld"
    373 const SCNi16 = "hi"
    374 const SCNi32 = "i"
    375 const SCNiFAST16 = "SCNi16"
    376 const SCNiFAST32 = "SCNi32"
    377 const SCNiFAST64 = "SCNi64"
    378 const SCNiFAST8 = "SCNi8"
    379 const SCNiLEAST16 = "SCNi16"
    380 const SCNiLEAST32 = "SCNi32"
    381 const SCNiLEAST64 = "SCNi64"
    382 const SCNiLEAST8 = "SCNi8"
    383 const SCNiPTR = "li"
    384 const SCNo16 = "ho"
    385 const SCNo32 = "o"
    386 const SCNoFAST16 = "SCNo16"
    387 const SCNoFAST32 = "SCNo32"
    388 const SCNoFAST64 = "SCNo64"
    389 const SCNoFAST8 = "SCNo8"
    390 const SCNoLEAST16 = "SCNo16"
    391 const SCNoLEAST32 = "SCNo32"
    392 const SCNoLEAST64 = "SCNo64"
    393 const SCNoLEAST8 = "SCNo8"
    394 const SCNoPTR = "lo"
    395 const SCNu16 = "hu"
    396 const SCNu32 = "u"
    397 const SCNuFAST16 = "SCNu16"
    398 const SCNuFAST32 = "SCNu32"
    399 const SCNuFAST64 = "SCNu64"
    400 const SCNuFAST8 = "SCNu8"
    401 const SCNuLEAST16 = "SCNu16"
    402 const SCNuLEAST32 = "SCNu32"
    403 const SCNuLEAST64 = "SCNu64"
    404 const SCNuLEAST8 = "SCNu8"
    405 const SCNuPTR = "lu"
    406 const SCNx16 = "hx"
    407 const SCNx32 = "x"
    408 const SCNxFAST16 = "SCNx16"
    409 const SCNxFAST32 = "SCNx32"
    410 const SCNxFAST64 = "SCNx64"
    411 const SCNxFAST8 = "SCNx8"
    412 const SCNxLEAST16 = "SCNx16"
    413 const SCNxLEAST32 = "SCNx32"
    414 const SCNxLEAST64 = "SCNx64"
    415 const SCNxLEAST8 = "SCNx8"
    416 const SCNxPTR = "lx"
    417 const SEGV_ACCERR = 2
    418 const SEGV_MAPERR = 1
    419 const SEGV_NOOP = 0
    420 const SIGABRT = 6
    421 const SIGALRM = 14
    422 const SIGBUS = 10
    423 const SIGCHLD = 20
    424 const SIGCONT = 19
    425 const SIGEMT = 7
    426 const SIGEV_NONE = 0
    427 const SIGEV_SIGNAL = 1
    428 const SIGEV_THREAD = 3
    429 const SIGFPE = 8
    430 const SIGHUP = 1
    431 const SIGILL = 4
    432 const SIGINFO = 29
    433 const SIGINT = 2
    434 const SIGIO = 23
    435 const SIGIOT = "SIGABRT"
    436 const SIGKILL = 9
    437 const SIGPIPE = 13
    438 const SIGPROF = 27
    439 const SIGQUIT = 3
    440 const SIGSEGV = 11
    441 const SIGSTKSZ = 131072
    442 const SIGSTOP = 17
    443 const SIGSYS = 12
    444 const SIGTERM = 15
    445 const SIGTRAP = 5
    446 const SIGTSTP = 18
    447 const SIGTTIN = 21
    448 const SIGTTOU = 22
    449 const SIGURG = 16
    450 const SIGUSR1 = 30
    451 const SIGUSR2 = 31
    452 const SIGVTALRM = 26
    453 const SIGWINCH = 28
    454 const SIGXCPU = 24
    455 const SIGXFSZ = 25
    456 const SIG_ATOMIC_MAX = "INT32_MAX"
    457 const SIG_ATOMIC_MIN = "INT32_MIN"
    458 const SIG_BLOCK = 1
    459 const SIG_SETMASK = 3
    460 const SIG_UNBLOCK = 2
    461 const SIZE_MAX = "UINTPTR_MAX"
    462 const SI_ASYNCIO = 0x10004
    463 const SI_MESGQ = 0x10005
    464 const SI_QUEUE = 0x10002
    465 const SI_TIMER = 0x10003
    466 const SI_USER = 0x10001
    467 const SS_DISABLE = 0x0004
    468 const SS_ONSTACK = 0x0001
    469 const SV_INTERRUPT = "SA_RESTART"
    470 const SV_NOCLDSTOP = "SA_NOCLDSTOP"
    471 const SV_NODEFER = "SA_NODEFER"
    472 const SV_ONSTACK = "SA_ONSTACK"
    473 const SV_RESETHAND = "SA_RESETHAND"
    474 const SV_SIGINFO = "SA_SIGINFO"
    475 const TAG_SIZE = 4
    476 const TRANSFORM_PRESENT = 1
    477 const TRAP_BRKPT = 1
    478 const TRAP_TRACE = 2
    479 const UINT16_MAX = 65535
    480 const UINT32_MAX = 4294967295
    481 const UINT64_MAX = "18446744073709551615U"
    482 const UINT8_MAX = 255
    483 const UINTPTR_MAX = 18446744073709551615
    484 const UINT_FAST16_MAX = "UINT16_MAX"
    485 const UINT_FAST32_MAX = "UINT32_MAX"
    486 const UINT_FAST64_MAX = "UINT64_MAX"
    487 const UINT_FAST8_MAX = "UINT8_MAX"
    488 const UINT_LEAST16_MAX = "UINT16_MAX"
    489 const UINT_LEAST32_MAX = "UINT32_MAX"
    490 const UINT_LEAST64_MAX = "UINT64_MAX"
    491 const UINT_LEAST8_MAX = "UINT8_MAX"
    492 const VP8L_FRAME_HEADER_SIZE = 5
    493 const VP8L_IMAGE_SIZE_BITS = 14
    494 const VP8L_LBITS = 64
    495 const VP8L_MAGIC_BYTE = 0x2f
    496 const VP8L_MAX_NUM_BIT_READ = 24
    497 const VP8L_SIGNATURE_SIZE = 1
    498 const VP8L_VERSION = 0
    499 const VP8L_VERSION_BITS = 3
    500 const VP8L_WBITS = 32
    501 const VP8X_CHUNK_SIZE = 10
    502 const VP8_DITHER_AMP_BITS = 7
    503 const VP8_DITHER_DESCALE = 4
    504 const VP8_FRAME_HEADER_SIZE = 10
    505 const VP8_RANDOM_DITHER_FIX = 8
    506 const VP8_RANDOM_TABLE_SIZE = 55
    507 const VP8_SIGNATURE = 0x9d012a
    508 const VP8_SSIM_KERNEL = 3
    509 const WAIT_MYPGRP = 0
    510 const WAKEMON_DISABLE = 0x02
    511 const WAKEMON_ENABLE = 0x01
    512 const WAKEMON_GET_PARAMS = 0x04
    513 const WAKEMON_MAKE_FATAL = 0x10
    514 const WAKEMON_SET_DEFAULTS = 0x08
    515 const WCHAR_MAX = "__WCHAR_MAX__"
    516 const WCONTINUED = 0x00000010
    517 const WCOREFLAG = 0200
    518 const WEBP_AARCH64 = 0
    519 const WEBP_ALIGN_CST = 31
    520 const WEBP_DECODER_ABI_VERSION = 528
    521 const WEBP_DSP_OMIT_C_CODE = 1
    522 const WEBP_INLINE = "inline"
    523 const WEBP_NEON_OMIT_C_CODE = 0
    524 const WEBP_NEON_WORK_AROUND_GCC = 0
    525 const WEBP_RESCALER_RFIX = 32
    526 const WEBP_RESTRICT = "__restrict__"
    527 const WEBP_SWAP_16BIT_CSP = 0
    528 const WEBP_TRANSFORM_AC3_C1 = 20091
    529 const WEBP_TRANSFORM_AC3_C2 = 35468
    530 const WEXITED = 0x00000004
    531 const WINT_MAX = "INT32_MAX"
    532 const WINT_MIN = "INT32_MIN"
    533 const WNOHANG = 0x00000001
    534 const WNOWAIT = 0x00000020
    535 const WSTOPPED = 0x00000008
    536 const WUNTRACED = 0x00000002
    537 const _DARWIN_FEATURE_64_BIT_INODE = 1
    538 const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1
    539 const _DARWIN_FEATURE_UNIX_CONFORMANCE = 3
    540 const _FORTIFY_SOURCE = 2
    541 const _I386_SIGNAL_H_ = 1
    542 const _LIBC_COUNT__MB_LEN_MAX = "_LIBC_UNSAFE_INDEXABLE"
    543 const _LIBC_COUNT__PATH_MAX = "_LIBC_UNSAFE_INDEXABLE"
    544 const _LP64 = 1
    545 const _QUAD_HIGHWORD = 1
    546 const _QUAD_LOWWORD = 0
    547 const _RLIMIT_POSIX_FLAG = 0x1000
    548 const _STRUCT_MCONTEXT = "_STRUCT_MCONTEXT64"
    549 const _WSTOPPED = 0177
    550 const _X86_INSTRUCTION_STATE_CACHELINE_SIZE = 64
    551 const __API_TO_BE_DEPRECATED = 100000
    552 const __API_TO_BE_DEPRECATED_DRIVERKIT = 100000
    553 const __API_TO_BE_DEPRECATED_IOS = 100000
    554 const __API_TO_BE_DEPRECATED_IOSAPPLICATIONEXTENSION = 100000
    555 const __API_TO_BE_DEPRECATED_KERNELKIT = 100000
    556 const __API_TO_BE_DEPRECATED_MACCATALYST = 100000
    557 const __API_TO_BE_DEPRECATED_MACCATALYSTAPPLICATIONEXTENSION = 100000
    558 const __API_TO_BE_DEPRECATED_MACOS = 100000
    559 const __API_TO_BE_DEPRECATED_MACOSAPPLICATIONEXTENSION = 100000
    560 const __API_TO_BE_DEPRECATED_TVOS = 100000
    561 const __API_TO_BE_DEPRECATED_TVOSAPPLICATIONEXTENSION = 100000
    562 const __API_TO_BE_DEPRECATED_VISIONOS = 100000
    563 const __API_TO_BE_DEPRECATED_VISIONOSAPPLICATIONEXTENSION = 100000
    564 const __API_TO_BE_DEPRECATED_WATCHOS = 100000
    565 const __API_TO_BE_DEPRECATED_WATCHOSAPPLICATIONEXTENSION = 100000
    566 const __ATOMIC_ACQUIRE = 2
    567 const __ATOMIC_ACQ_REL = 4
    568 const __ATOMIC_CONSUME = 1
    569 const __ATOMIC_HLE_ACQUIRE = 65536
    570 const __ATOMIC_HLE_RELEASE = 131072
    571 const __ATOMIC_RELAXED = 0
    572 const __ATOMIC_RELEASE = 3
    573 const __ATOMIC_SEQ_CST = 5
    574 const __AVAILABILITY_FILE = "AvailabilityVersions.h"
    575 const __AVAILABILITY_VERSIONS_VERSION_HASH = 93585900
    576 const __AVAILABILITY_VERSIONS_VERSION_STRING = "Local"
    577 const __BFLT16_DECIMAL_DIG__ = 4
    578 const __BFLT16_DENORM_MIN__ = "9.18354961579912115600575419704879436e-41B"
    579 const __BFLT16_DIG__ = 2
    580 const __BFLT16_EPSILON__ = "7.81250000000000000000000000000000000e-3B"
    581 const __BFLT16_HAS_DENORM__ = 1
    582 const __BFLT16_HAS_INFINITY__ = 1
    583 const __BFLT16_HAS_QUIET_NAN__ = 1
    584 const __BFLT16_IS_IEC_60559__ = 0
    585 const __BFLT16_MANT_DIG__ = 8
    586 const __BFLT16_MAX_10_EXP__ = 38
    587 const __BFLT16_MAX_EXP__ = 128
    588 const __BFLT16_MAX__ = "3.38953138925153547590470800371487867e+38B"
    589 const __BFLT16_MIN__ = "1.17549435082228750796873653722224568e-38B"
    590 const __BFLT16_NORM_MAX__ = "3.38953138925153547590470800371487867e+38B"
    591 const __BIGGEST_ALIGNMENT__ = 16
    592 const __BITINT_MAXWIDTH__ = 65535
    593 const __BRIDGEOS_2_0 = 20000
    594 const __BRIDGEOS_3_0 = 30000
    595 const __BRIDGEOS_3_1 = 30100
    596 const __BRIDGEOS_3_4 = 30400
    597 const __BRIDGEOS_4_0 = 40000
    598 const __BRIDGEOS_4_1 = 40100
    599 const __BRIDGEOS_5_0 = 50000
    600 const __BRIDGEOS_5_1 = 50100
    601 const __BRIDGEOS_5_3 = 50300
    602 const __BRIDGEOS_6_0 = 60000
    603 const __BRIDGEOS_6_2 = 60200
    604 const __BRIDGEOS_6_4 = 60400
    605 const __BRIDGEOS_6_5 = 60500
    606 const __BRIDGEOS_6_6 = 60600
    607 const __BRIDGEOS_7_0 = 70000
    608 const __BRIDGEOS_7_1 = 70100
    609 const __BRIDGEOS_7_2 = 70200
    610 const __BRIDGEOS_7_3 = 70300
    611 const __BRIDGEOS_7_4 = 70400
    612 const __BRIDGEOS_7_6 = 70600
    613 const __BRIDGEOS_8_0 = 80000
    614 const __BRIDGEOS_8_1 = 80100
    615 const __BRIDGEOS_8_2 = 80200
    616 const __BRIDGEOS_8_3 = 80300
    617 const __BRIDGEOS_8_4 = 80400
    618 const __BRIDGEOS_8_5 = 80500
    619 const __BRIDGEOS_8_6 = 80600
    620 const __BRIDGEOS_9_0 = 90000
    621 const __BRIDGEOS_9_1 = 90100
    622 const __BRIDGEOS_9_2 = 90200
    623 const __BRIDGEOS_9_3 = 90300
    624 const __BRIDGEOS_9_4 = 90400
    625 const __BRIDGEOS_9_5 = 90500
    626 const __BYTE_ORDER__ = "__ORDER_LITTLE_ENDIAN__"
    627 const __CCGO__ = 1
    628 const __CHAR_BIT__ = 8
    629 const __DARWIN_64_BIT_INO_T = 1
    630 const __DARWIN_BIG_ENDIAN = 4321
    631 const __DARWIN_BYTE_ORDER = "__DARWIN_LITTLE_ENDIAN"
    632 const __DARWIN_C_ANSI = 010000
    633 const __DARWIN_C_FULL = 900000
    634 const __DARWIN_C_LEVEL = "__DARWIN_C_FULL"
    635 const __DARWIN_LITTLE_ENDIAN = 1234
    636 const __DARWIN_NON_CANCELABLE = 0
    637 const __DARWIN_NO_LONG_LONG = 0
    638 const __DARWIN_NSIG = 32
    639 const __DARWIN_ONLY_64_BIT_INO_T = 0
    640 const __DARWIN_ONLY_UNIX_CONFORMANCE = 1
    641 const __DARWIN_ONLY_VERS_1050 = 0
    642 const __DARWIN_PDP_ENDIAN = 3412
    643 const __DARWIN_SUF_1050 = "$1050"
    644 const __DARWIN_SUF_64_BIT_INO_T = "$INODE64"
    645 const __DARWIN_SUF_EXTSN = "$DARWIN_EXTSN"
    646 const __DARWIN_UNIX03 = 1
    647 const __DARWIN_VERS_1050 = 1
    648 const __DARWIN_WCHAR_MAX = "__WCHAR_MAX__"
    649 const __DBL_DECIMAL_DIG__ = 17
    650 const __DBL_DIG__ = 15
    651 const __DBL_HAS_DENORM__ = 1
    652 const __DBL_HAS_INFINITY__ = 1
    653 const __DBL_HAS_QUIET_NAN__ = 1
    654 const __DBL_IS_IEC_60559__ = 1
    655 const __DBL_MANT_DIG__ = 53
    656 const __DBL_MAX_10_EXP__ = 308
    657 const __DBL_MAX_EXP__ = 1024
    658 const __DEC128_EPSILON__ = 1e-33
    659 const __DEC128_MANT_DIG__ = 34
    660 const __DEC128_MAX_EXP__ = 6145
    661 const __DEC128_MAX__ = "9.999999999999999999999999999999999E6144"
    662 const __DEC128_MIN__ = 1e-6143
    663 const __DEC128_SUBNORMAL_MIN__ = 0.000000000000000000000000000000001e-6143
    664 const __DEC32_EPSILON__ = 1e-6
    665 const __DEC32_MANT_DIG__ = 7
    666 const __DEC32_MAX_EXP__ = 97
    667 const __DEC32_MAX__ = 9.999999e96
    668 const __DEC32_MIN__ = 1e-95
    669 const __DEC32_SUBNORMAL_MIN__ = 0.000001e-95
    670 const __DEC64X_EPSILON__ = "1E-33D64x"
    671 const __DEC64X_MANT_DIG__ = 34
    672 const __DEC64X_MAX_EXP__ = 6145
    673 const __DEC64X_MAX__ = "9.999999999999999999999999999999999E6144D64x"
    674 const __DEC64X_MIN__ = "1E-6143D64x"
    675 const __DEC64X_SUBNORMAL_MIN__ = "0.000000000000000000000000000000001E-6143D64x"
    676 const __DEC64_EPSILON__ = 1e-15
    677 const __DEC64_MANT_DIG__ = 16
    678 const __DEC64_MAX_EXP__ = 385
    679 const __DEC64_MAX__ = "9.999999999999999E384"
    680 const __DEC64_MIN__ = 1e-383
    681 const __DEC64_SUBNORMAL_MIN__ = 0.000000000000001e-383
    682 const __DECIMAL_BID_FORMAT__ = 1
    683 const __DECIMAL_DIG__ = 17
    684 const __DEC_EVAL_METHOD__ = 2
    685 const __DRIVERKIT_19_0 = 190000
    686 const __DRIVERKIT_20_0 = 200000
    687 const __DRIVERKIT_21_0 = 210000
    688 const __DRIVERKIT_22_0 = 220000
    689 const __DRIVERKIT_22_4 = 220400
    690 const __DRIVERKIT_22_5 = 220500
    691 const __DRIVERKIT_22_6 = 220600
    692 const __DRIVERKIT_23_0 = 230000
    693 const __DRIVERKIT_23_1 = 230100
    694 const __DRIVERKIT_23_2 = 230200
    695 const __DRIVERKIT_23_3 = 230300
    696 const __DRIVERKIT_23_4 = 230400
    697 const __DRIVERKIT_23_5 = 230500
    698 const __DRIVERKIT_23_6 = 230600
    699 const __DRIVERKIT_24_0 = 240000
    700 const __DRIVERKIT_24_1 = 240100
    701 const __DRIVERKIT_24_2 = 240200
    702 const __DRIVERKIT_24_3 = 240300
    703 const __DRIVERKIT_24_4 = 240400
    704 const __DRIVERKIT_24_5 = 240500
    705 const __ELF__ = 1
    706 const __FINITE_MATH_ONLY__ = 0
    707 const __FLOAT_WORD_ORDER__ = "__ORDER_LITTLE_ENDIAN__"
    708 const __FLT128_DECIMAL_DIG__ = 36
    709 const __FLT128_DENORM_MIN__ = 6.47517511943802511092443895822764655e-4966
    710 const __FLT128_DIG__ = 33
    711 const __FLT128_EPSILON__ = 1.92592994438723585305597794258492732e-34
    712 const __FLT128_HAS_DENORM__ = 1
    713 const __FLT128_HAS_INFINITY__ = 1
    714 const __FLT128_HAS_QUIET_NAN__ = 1
    715 const __FLT128_IS_IEC_60559__ = 1
    716 const __FLT128_MANT_DIG__ = 113
    717 const __FLT128_MAX_10_EXP__ = 4932
    718 const __FLT128_MAX_EXP__ = 16384
    719 const __FLT128_MAX__ = "1.18973149535723176508575932662800702e+4932"
    720 const __FLT128_MIN__ = 3.36210314311209350626267781732175260e-4932
    721 const __FLT128_NORM_MAX__ = "1.18973149535723176508575932662800702e+4932"
    722 const __FLT16_DECIMAL_DIG__ = 5
    723 const __FLT16_DENORM_MIN__ = 5.96046447753906250000000000000000000e-8
    724 const __FLT16_DIG__ = 3
    725 const __FLT16_EPSILON__ = 9.76562500000000000000000000000000000e-4
    726 const __FLT16_HAS_DENORM__ = 1
    727 const __FLT16_HAS_INFINITY__ = 1
    728 const __FLT16_HAS_QUIET_NAN__ = 1
    729 const __FLT16_IS_IEC_60559__ = 1
    730 const __FLT16_MANT_DIG__ = 11
    731 const __FLT16_MAX_10_EXP__ = 4
    732 const __FLT16_MAX_EXP__ = 16
    733 const __FLT16_MAX__ = 6.55040000000000000000000000000000000e+4
    734 const __FLT16_MIN__ = 6.10351562500000000000000000000000000e-5
    735 const __FLT16_NORM_MAX__ = 6.55040000000000000000000000000000000e+4
    736 const __FLT32X_DECIMAL_DIG__ = 17
    737 const __FLT32X_DENORM_MIN__ = 4.94065645841246544176568792868221372e-324
    738 const __FLT32X_DIG__ = 15
    739 const __FLT32X_EPSILON__ = 2.22044604925031308084726333618164062e-16
    740 const __FLT32X_HAS_DENORM__ = 1
    741 const __FLT32X_HAS_INFINITY__ = 1
    742 const __FLT32X_HAS_QUIET_NAN__ = 1
    743 const __FLT32X_IS_IEC_60559__ = 1
    744 const __FLT32X_MANT_DIG__ = 53
    745 const __FLT32X_MAX_10_EXP__ = 308
    746 const __FLT32X_MAX_EXP__ = 1024
    747 const __FLT32X_MAX__ = 1.79769313486231570814527423731704357e+308
    748 const __FLT32X_MIN__ = 2.22507385850720138309023271733240406e-308
    749 const __FLT32X_NORM_MAX__ = 1.79769313486231570814527423731704357e+308
    750 const __FLT32_DECIMAL_DIG__ = 9
    751 const __FLT32_DENORM_MIN__ = 1.40129846432481707092372958328991613e-45
    752 const __FLT32_DIG__ = 6
    753 const __FLT32_EPSILON__ = 1.19209289550781250000000000000000000e-7
    754 const __FLT32_HAS_DENORM__ = 1
    755 const __FLT32_HAS_INFINITY__ = 1
    756 const __FLT32_HAS_QUIET_NAN__ = 1
    757 const __FLT32_IS_IEC_60559__ = 1
    758 const __FLT32_MANT_DIG__ = 24
    759 const __FLT32_MAX_10_EXP__ = 38
    760 const __FLT32_MAX_EXP__ = 128
    761 const __FLT32_MAX__ = 3.40282346638528859811704183484516925e+38
    762 const __FLT32_MIN__ = 1.17549435082228750796873653722224568e-38
    763 const __FLT32_NORM_MAX__ = 3.40282346638528859811704183484516925e+38
    764 const __FLT64X_DECIMAL_DIG__ = 36
    765 const __FLT64X_DENORM_MIN__ = 6.47517511943802511092443895822764655e-4966
    766 const __FLT64X_DIG__ = 33
    767 const __FLT64X_EPSILON__ = 1.92592994438723585305597794258492732e-34
    768 const __FLT64X_HAS_DENORM__ = 1
    769 const __FLT64X_HAS_INFINITY__ = 1
    770 const __FLT64X_HAS_QUIET_NAN__ = 1
    771 const __FLT64X_IS_IEC_60559__ = 1
    772 const __FLT64X_MANT_DIG__ = 113
    773 const __FLT64X_MAX_10_EXP__ = 4932
    774 const __FLT64X_MAX_EXP__ = 16384
    775 const __FLT64X_MAX__ = "1.18973149535723176508575932662800702e+4932"
    776 const __FLT64X_MIN__ = 3.36210314311209350626267781732175260e-4932
    777 const __FLT64X_NORM_MAX__ = "1.18973149535723176508575932662800702e+4932"
    778 const __FLT64_DECIMAL_DIG__ = 17
    779 const __FLT64_DENORM_MIN__ = 4.94065645841246544176568792868221372e-324
    780 const __FLT64_DIG__ = 15
    781 const __FLT64_EPSILON__ = 2.22044604925031308084726333618164062e-16
    782 const __FLT64_HAS_DENORM__ = 1
    783 const __FLT64_HAS_INFINITY__ = 1
    784 const __FLT64_HAS_QUIET_NAN__ = 1
    785 const __FLT64_IS_IEC_60559__ = 1
    786 const __FLT64_MANT_DIG__ = 53
    787 const __FLT64_MAX_10_EXP__ = 308
    788 const __FLT64_MAX_EXP__ = 1024
    789 const __FLT64_MAX__ = 1.79769313486231570814527423731704357e+308
    790 const __FLT64_MIN__ = 2.22507385850720138309023271733240406e-308
    791 const __FLT64_NORM_MAX__ = 1.79769313486231570814527423731704357e+308
    792 const __FLT_DECIMAL_DIG__ = 9
    793 const __FLT_DENORM_MIN__ = 1.40129846432481707092372958328991613e-45
    794 const __FLT_DIG__ = 6
    795 const __FLT_EPSILON__ = 1.19209289550781250000000000000000000e-7
    796 const __FLT_EVAL_METHOD_TS_18661_3__ = 0
    797 const __FLT_EVAL_METHOD__ = 0
    798 const __FLT_HAS_DENORM__ = 1
    799 const __FLT_HAS_INFINITY__ = 1
    800 const __FLT_HAS_QUIET_NAN__ = 1
    801 const __FLT_IS_IEC_60559__ = 1
    802 const __FLT_MANT_DIG__ = 24
    803 const __FLT_MAX_10_EXP__ = 38
    804 const __FLT_MAX_EXP__ = 128
    805 const __FLT_MAX__ = 3.40282346638528859811704183484516925e+38
    806 const __FLT_MIN__ = 1.17549435082228750796873653722224568e-38
    807 const __FLT_NORM_MAX__ = 3.40282346638528859811704183484516925e+38
    808 const __FLT_RADIX__ = 2
    809 const __FUNCTION__ = "__func__"
    810 const __FXSR__ = 1
    811 const __GCC_ASM_FLAG_OUTPUTS__ = 1
    812 const __GCC_ATOMIC_BOOL_LOCK_FREE = 2
    813 const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = 2
    814 const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = 2
    815 const __GCC_ATOMIC_CHAR8_T_LOCK_FREE = 2
    816 const __GCC_ATOMIC_CHAR_LOCK_FREE = 2
    817 const __GCC_ATOMIC_INT_LOCK_FREE = 2
    818 const __GCC_ATOMIC_LLONG_LOCK_FREE = 2
    819 const __GCC_ATOMIC_LONG_LOCK_FREE = 2
    820 const __GCC_ATOMIC_POINTER_LOCK_FREE = 2
    821 const __GCC_ATOMIC_SHORT_LOCK_FREE = 2
    822 const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = 1
    823 const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = 2
    824 const __GCC_CONSTRUCTIVE_SIZE = 64
    825 const __GCC_DESTRUCTIVE_SIZE = 64
    826 const __GCC_HAVE_DWARF2_CFI_ASM = 1
    827 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = 1
    828 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = 1
    829 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = 1
    830 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = 1
    831 const __GCC_IEC_559 = 2
    832 const __GCC_IEC_559_COMPLEX = 2
    833 const __GNUC_EXECUTION_CHARSET_NAME = "UTF-8"
    834 const __GNUC_MINOR__ = 2
    835 const __GNUC_PATCHLEVEL__ = 1
    836 const __GNUC_STDC_INLINE__ = 1
    837 const __GNUC_WIDE_EXECUTION_CHARSET_NAME = "UTF-32LE"
    838 const __GNUC__ = 16
    839 const __GXX_ABI_VERSION = 1021
    840 const __HAVE_SPECULATION_SAFE_VALUE = 1
    841 const __INT16_MAX__ = 0x7fff
    842 const __INT32_MAX__ = 0x7fffffff
    843 const __INT32_TYPE__ = "int"
    844 const __INT64_MAX__ = 0x7fffffffffffffff
    845 const __INT8_MAX__ = 0x7f
    846 const __INTMAX_MAX__ = 0x7fffffffffffffff
    847 const __INTMAX_WIDTH__ = 64
    848 const __INTPTR_MAX__ = 0x7fffffffffffffff
    849 const __INTPTR_WIDTH__ = 64
    850 const __INT_FAST16_MAX__ = 0x7fffffffffffffff
    851 const __INT_FAST16_WIDTH__ = 64
    852 const __INT_FAST32_MAX__ = 0x7fffffffffffffff
    853 const __INT_FAST32_WIDTH__ = 64
    854 const __INT_FAST64_MAX__ = 0x7fffffffffffffff
    855 const __INT_FAST64_WIDTH__ = 64
    856 const __INT_FAST8_MAX__ = 0x7f
    857 const __INT_FAST8_WIDTH__ = 8
    858 const __INT_LEAST16_MAX__ = 0x7fff
    859 const __INT_LEAST16_WIDTH__ = 16
    860 const __INT_LEAST32_MAX__ = 0x7fffffff
    861 const __INT_LEAST32_TYPE__ = "int"
    862 const __INT_LEAST32_WIDTH__ = 32
    863 const __INT_LEAST64_MAX__ = 0x7fffffffffffffff
    864 const __INT_LEAST64_WIDTH__ = 64
    865 const __INT_LEAST8_MAX__ = 0x7f
    866 const __INT_LEAST8_WIDTH__ = 8
    867 const __INT_MAX__ = 0x7fffffff
    868 const __INT_WIDTH__ = 32
    869 const __IPHONE_10_0 = 100000
    870 const __IPHONE_10_1 = 100100
    871 const __IPHONE_10_2 = 100200
    872 const __IPHONE_10_3 = 100300
    873 const __IPHONE_11_0 = 110000
    874 const __IPHONE_11_1 = 110100
    875 const __IPHONE_11_2 = 110200
    876 const __IPHONE_11_3 = 110300
    877 const __IPHONE_11_4 = 110400
    878 const __IPHONE_12_0 = 120000
    879 const __IPHONE_12_1 = 120100
    880 const __IPHONE_12_2 = 120200
    881 const __IPHONE_12_3 = 120300
    882 const __IPHONE_12_4 = 120400
    883 const __IPHONE_13_0 = 130000
    884 const __IPHONE_13_1 = 130100
    885 const __IPHONE_13_2 = 130200
    886 const __IPHONE_13_3 = 130300
    887 const __IPHONE_13_4 = 130400
    888 const __IPHONE_13_5 = 130500
    889 const __IPHONE_13_6 = 130600
    890 const __IPHONE_13_7 = 130700
    891 const __IPHONE_14_0 = 140000
    892 const __IPHONE_14_1 = 140100
    893 const __IPHONE_14_2 = 140200
    894 const __IPHONE_14_3 = 140300
    895 const __IPHONE_14_4 = 140400
    896 const __IPHONE_14_5 = 140500
    897 const __IPHONE_14_6 = 140600
    898 const __IPHONE_14_7 = 140700
    899 const __IPHONE_14_8 = 140800
    900 const __IPHONE_15_0 = 150000
    901 const __IPHONE_15_1 = 150100
    902 const __IPHONE_15_2 = 150200
    903 const __IPHONE_15_3 = 150300
    904 const __IPHONE_15_4 = 150400
    905 const __IPHONE_15_5 = 150500
    906 const __IPHONE_15_6 = 150600
    907 const __IPHONE_15_7 = 150700
    908 const __IPHONE_15_8 = 150800
    909 const __IPHONE_16_0 = 160000
    910 const __IPHONE_16_1 = 160100
    911 const __IPHONE_16_2 = 160200
    912 const __IPHONE_16_3 = 160300
    913 const __IPHONE_16_4 = 160400
    914 const __IPHONE_16_5 = 160500
    915 const __IPHONE_16_6 = 160600
    916 const __IPHONE_16_7 = 160700
    917 const __IPHONE_17_0 = 170000
    918 const __IPHONE_17_1 = 170100
    919 const __IPHONE_17_2 = 170200
    920 const __IPHONE_17_3 = 170300
    921 const __IPHONE_17_4 = 170400
    922 const __IPHONE_17_5 = 170500
    923 const __IPHONE_17_6 = 170600
    924 const __IPHONE_17_7 = 170700
    925 const __IPHONE_18_0 = 180000
    926 const __IPHONE_18_1 = 180100
    927 const __IPHONE_18_2 = 180200
    928 const __IPHONE_18_3 = 180300
    929 const __IPHONE_18_4 = 180400
    930 const __IPHONE_18_5 = 180500
    931 const __IPHONE_2_0 = 20000
    932 const __IPHONE_2_1 = 20100
    933 const __IPHONE_2_2 = 20200
    934 const __IPHONE_3_0 = 30000
    935 const __IPHONE_3_1 = 30100
    936 const __IPHONE_3_2 = 30200
    937 const __IPHONE_4_0 = 40000
    938 const __IPHONE_4_1 = 40100
    939 const __IPHONE_4_2 = 40200
    940 const __IPHONE_4_3 = 40300
    941 const __IPHONE_5_0 = 50000
    942 const __IPHONE_5_1 = 50100
    943 const __IPHONE_6_0 = 60000
    944 const __IPHONE_6_1 = 60100
    945 const __IPHONE_7_0 = 70000
    946 const __IPHONE_7_1 = 70100
    947 const __IPHONE_8_0 = 80000
    948 const __IPHONE_8_1 = 80100
    949 const __IPHONE_8_2 = 80200
    950 const __IPHONE_8_3 = 80300
    951 const __IPHONE_8_4 = 80400
    952 const __IPHONE_9_0 = 90000
    953 const __IPHONE_9_1 = 90100
    954 const __IPHONE_9_2 = 90200
    955 const __IPHONE_9_3 = 90300
    956 const __LASTBRANCH_MAX = 32
    957 const __LDBL_DECIMAL_DIG__ = 17
    958 const __LDBL_DENORM_MIN__ = 4.94065645841246544176568792868221372e-324
    959 const __LDBL_DIG__ = 15
    960 const __LDBL_EPSILON__ = 2.22044604925031308084726333618164062e-16
    961 const __LDBL_HAS_DENORM__ = 1
    962 const __LDBL_HAS_INFINITY__ = 1
    963 const __LDBL_HAS_QUIET_NAN__ = 1
    964 const __LDBL_IS_IEC_60559__ = 1
    965 const __LDBL_MANT_DIG__ = 53
    966 const __LDBL_MAX_10_EXP__ = 308
    967 const __LDBL_MAX_EXP__ = 1024
    968 const __LDBL_MAX__ = 1.79769313486231570814527423731704357e+308
    969 const __LDBL_MIN__ = 2.22507385850720138309023271733240406e-308
    970 const __LDBL_NORM_MAX__ = 1.79769313486231570814527423731704357e+308
    971 const __LONG_DOUBLE_64__ = 1
    972 const __LONG_LONG_MAX__ = 0x7fffffffffffffff
    973 const __LONG_LONG_WIDTH__ = 64
    974 const __LONG_MAX__ = 0x7fffffffffffffff
    975 const __LONG_WIDTH__ = 64
    976 const __LP64__ = 1
    977 const __MAC_10_0 = 1000
    978 const __MAC_10_1 = 1010
    979 const __MAC_10_10 = 101000
    980 const __MAC_10_10_2 = 101002
    981 const __MAC_10_10_3 = 101003
    982 const __MAC_10_11 = 101100
    983 const __MAC_10_11_2 = 101102
    984 const __MAC_10_11_3 = 101103
    985 const __MAC_10_11_4 = 101104
    986 const __MAC_10_12 = 101200
    987 const __MAC_10_12_1 = 101201
    988 const __MAC_10_12_2 = 101202
    989 const __MAC_10_12_4 = 101204
    990 const __MAC_10_13 = 101300
    991 const __MAC_10_13_1 = 101301
    992 const __MAC_10_13_2 = 101302
    993 const __MAC_10_13_4 = 101304
    994 const __MAC_10_14 = 101400
    995 const __MAC_10_14_1 = 101401
    996 const __MAC_10_14_4 = 101404
    997 const __MAC_10_14_5 = 101405
    998 const __MAC_10_14_6 = 101406
    999 const __MAC_10_15 = 101500
   1000 const __MAC_10_15_1 = 101501
   1001 const __MAC_10_15_4 = 101504
   1002 const __MAC_10_16 = 101600
   1003 const __MAC_10_2 = 1020
   1004 const __MAC_10_3 = 1030
   1005 const __MAC_10_4 = 1040
   1006 const __MAC_10_5 = 1050
   1007 const __MAC_10_6 = 1060
   1008 const __MAC_10_7 = 1070
   1009 const __MAC_10_8 = 1080
   1010 const __MAC_10_9 = 1090
   1011 const __MAC_11_0 = 110000
   1012 const __MAC_11_1 = 110100
   1013 const __MAC_11_3 = 110300
   1014 const __MAC_11_4 = 110400
   1015 const __MAC_11_5 = 110500
   1016 const __MAC_11_6 = 110600
   1017 const __MAC_12_0 = 120000
   1018 const __MAC_12_1 = 120100
   1019 const __MAC_12_2 = 120200
   1020 const __MAC_12_3 = 120300
   1021 const __MAC_12_4 = 120400
   1022 const __MAC_12_5 = 120500
   1023 const __MAC_12_6 = 120600
   1024 const __MAC_12_7 = 120700
   1025 const __MAC_13_0 = 130000
   1026 const __MAC_13_1 = 130100
   1027 const __MAC_13_2 = 130200
   1028 const __MAC_13_3 = 130300
   1029 const __MAC_13_4 = 130400
   1030 const __MAC_13_5 = 130500
   1031 const __MAC_13_6 = 130600
   1032 const __MAC_13_7 = 130700
   1033 const __MAC_14_0 = 140000
   1034 const __MAC_14_1 = 140100
   1035 const __MAC_14_2 = 140200
   1036 const __MAC_14_3 = 140300
   1037 const __MAC_14_4 = 140400
   1038 const __MAC_14_5 = 140500
   1039 const __MAC_14_6 = 140600
   1040 const __MAC_14_7 = 140700
   1041 const __MAC_15_0 = 150000
   1042 const __MAC_15_1 = 150100
   1043 const __MAC_15_2 = 150200
   1044 const __MAC_15_3 = 150300
   1045 const __MAC_15_4 = 150400
   1046 const __MAC_15_5 = 150500
   1047 const __MMX_WITH_SSE__ = 1
   1048 const __MMX__ = 1
   1049 const __NO_INLINE__ = 1
   1050 const __ORDER_BIG_ENDIAN__ = 4321
   1051 const __ORDER_LITTLE_ENDIAN__ = 1234
   1052 const __ORDER_PDP_ENDIAN__ = 3412
   1053 const __PIC__ = 2
   1054 const __PIE__ = 2
   1055 const __PRAGMA_REDEFINE_EXTNAME = 1
   1056 const __PRETTY_FUNCTION__ = "__func__"
   1057 const __PRI_64_LENGTH_MODIFIER__ = "ll"
   1058 const __PRI_8_LENGTH_MODIFIER__ = "hh"
   1059 const __PRI_MAX_LENGTH_MODIFIER__ = "j"
   1060 const __PTHREAD_ATTR_SIZE__ = 56
   1061 const __PTHREAD_CONDATTR_SIZE__ = 8
   1062 const __PTHREAD_COND_SIZE__ = 40
   1063 const __PTHREAD_MUTEXATTR_SIZE__ = 8
   1064 const __PTHREAD_MUTEX_SIZE__ = 56
   1065 const __PTHREAD_ONCE_SIZE__ = 8
   1066 const __PTHREAD_RWLOCKATTR_SIZE__ = 16
   1067 const __PTHREAD_RWLOCK_SIZE__ = 192
   1068 const __PTHREAD_SIZE__ = 8176
   1069 const __PTRDIFF_MAX__ = 0x7fffffffffffffff
   1070 const __PTRDIFF_WIDTH__ = 64
   1071 const __SCHAR_MAX__ = 0x7f
   1072 const __SCHAR_WIDTH__ = 8
   1073 const __SCN_64_LENGTH_MODIFIER__ = "ll"
   1074 const __SCN_MAX_LENGTH_MODIFIER__ = "j"
   1075 const __SEG_FS = 1
   1076 const __SEG_GS = 1
   1077 const __SHRT_MAX__ = 0x7fff
   1078 const __SHRT_WIDTH__ = 16
   1079 const __SIG_ATOMIC_MAX__ = 0x7fffffff
   1080 const __SIG_ATOMIC_TYPE__ = "int"
   1081 const __SIG_ATOMIC_WIDTH__ = 32
   1082 const __SIZEOF_DOUBLE__ = 8
   1083 const __SIZEOF_FLOAT128__ = 16
   1084 const __SIZEOF_FLOAT80__ = 16
   1085 const __SIZEOF_FLOAT__ = 4
   1086 const __SIZEOF_INT128__ = 16
   1087 const __SIZEOF_INT__ = 4
   1088 const __SIZEOF_LONG_DOUBLE__ = 8
   1089 const __SIZEOF_LONG_LONG__ = 8
   1090 const __SIZEOF_LONG__ = 8
   1091 const __SIZEOF_POINTER__ = 8
   1092 const __SIZEOF_PTRDIFF_T__ = 8
   1093 const __SIZEOF_SHORT__ = 2
   1094 const __SIZEOF_SIZE_T__ = 8
   1095 const __SIZEOF_WCHAR_T__ = 4
   1096 const __SIZEOF_WINT_T__ = 4
   1097 const __SIZE_MAX__ = 0xffffffffffffffff
   1098 const __SIZE_WIDTH__ = 64
   1099 const __SSE2_MATH__ = 1
   1100 const __SSE2__ = 1
   1101 const __SSE_MATH__ = 1
   1102 const __SSE__ = 1
   1103 const __SSP_STRONG__ = 3
   1104 const __STDC_EMBED_EMPTY__ = 2
   1105 const __STDC_EMBED_FOUND__ = 1
   1106 const __STDC_EMBED_NOT_FOUND__ = 0
   1107 const __STDC_HOSTED__ = 1
   1108 const __STDC_UTF_16__ = 1
   1109 const __STDC_UTF_32__ = 1
   1110 const __STDC_VERSION__ = 202311
   1111 const __STDC_WANT_LIB_EXT1__ = 1
   1112 const __STDC__ = 1
   1113 const __TVOS_10_0 = 100000
   1114 const __TVOS_10_0_1 = 100001
   1115 const __TVOS_10_1 = 100100
   1116 const __TVOS_10_2 = 100200
   1117 const __TVOS_11_0 = 110000
   1118 const __TVOS_11_1 = 110100
   1119 const __TVOS_11_2 = 110200
   1120 const __TVOS_11_3 = 110300
   1121 const __TVOS_11_4 = 110400
   1122 const __TVOS_12_0 = 120000
   1123 const __TVOS_12_1 = 120100
   1124 const __TVOS_12_2 = 120200
   1125 const __TVOS_12_3 = 120300
   1126 const __TVOS_12_4 = 120400
   1127 const __TVOS_13_0 = 130000
   1128 const __TVOS_13_2 = 130200
   1129 const __TVOS_13_3 = 130300
   1130 const __TVOS_13_4 = 130400
   1131 const __TVOS_14_0 = 140000
   1132 const __TVOS_14_1 = 140100
   1133 const __TVOS_14_2 = 140200
   1134 const __TVOS_14_3 = 140300
   1135 const __TVOS_14_5 = 140500
   1136 const __TVOS_14_6 = 140600
   1137 const __TVOS_14_7 = 140700
   1138 const __TVOS_15_0 = 150000
   1139 const __TVOS_15_1 = 150100
   1140 const __TVOS_15_2 = 150200
   1141 const __TVOS_15_3 = 150300
   1142 const __TVOS_15_4 = 150400
   1143 const __TVOS_15_5 = 150500
   1144 const __TVOS_15_6 = 150600
   1145 const __TVOS_16_0 = 160000
   1146 const __TVOS_16_1 = 160100
   1147 const __TVOS_16_2 = 160200
   1148 const __TVOS_16_3 = 160300
   1149 const __TVOS_16_4 = 160400
   1150 const __TVOS_16_5 = 160500
   1151 const __TVOS_16_6 = 160600
   1152 const __TVOS_17_0 = 170000
   1153 const __TVOS_17_1 = 170100
   1154 const __TVOS_17_2 = 170200
   1155 const __TVOS_17_3 = 170300
   1156 const __TVOS_17_4 = 170400
   1157 const __TVOS_17_5 = 170500
   1158 const __TVOS_17_6 = 170600
   1159 const __TVOS_18_0 = 180000
   1160 const __TVOS_18_1 = 180100
   1161 const __TVOS_18_2 = 180200
   1162 const __TVOS_18_3 = 180300
   1163 const __TVOS_18_4 = 180400
   1164 const __TVOS_18_5 = 180500
   1165 const __TVOS_9_0 = 90000
   1166 const __TVOS_9_1 = 90100
   1167 const __TVOS_9_2 = 90200
   1168 const __UINT16_MAX__ = 0xffff
   1169 const __UINT32_MAX__ = 0xffffffff
   1170 const __UINT64_MAX__ = 0xffffffffffffffff
   1171 const __UINT8_MAX__ = 0xff
   1172 const __UINTMAX_MAX__ = 0xffffffffffffffff
   1173 const __UINTPTR_MAX__ = 0xffffffffffffffff
   1174 const __UINT_FAST16_MAX__ = 0xffffffffffffffff
   1175 const __UINT_FAST32_MAX__ = 0xffffffffffffffff
   1176 const __UINT_FAST64_MAX__ = 0xffffffffffffffff
   1177 const __UINT_FAST8_MAX__ = 0xff
   1178 const __UINT_LEAST16_MAX__ = 0xffff
   1179 const __UINT_LEAST32_MAX__ = 0xffffffff
   1180 const __UINT_LEAST64_MAX__ = 0xffffffffffffffff
   1181 const __UINT_LEAST8_MAX__ = 0xff
   1182 const __VERSION__ = "16.2.1 20260810"
   1183 const __VISIONOS_1_0 = 10000
   1184 const __VISIONOS_1_1 = 10100
   1185 const __VISIONOS_1_2 = 10200
   1186 const __VISIONOS_1_3 = 10300
   1187 const __VISIONOS_2_0 = 20000
   1188 const __VISIONOS_2_1 = 20100
   1189 const __VISIONOS_2_2 = 20200
   1190 const __VISIONOS_2_3 = 20300
   1191 const __VISIONOS_2_4 = 20400
   1192 const __VISIONOS_2_5 = 20500
   1193 const __WATCHOS_10_0 = 100000
   1194 const __WATCHOS_10_1 = 100100
   1195 const __WATCHOS_10_2 = 100200
   1196 const __WATCHOS_10_3 = 100300
   1197 const __WATCHOS_10_4 = 100400
   1198 const __WATCHOS_10_5 = 100500
   1199 const __WATCHOS_10_6 = 100600
   1200 const __WATCHOS_10_7 = 100700
   1201 const __WATCHOS_11_0 = 110000
   1202 const __WATCHOS_11_1 = 110100
   1203 const __WATCHOS_11_2 = 110200
   1204 const __WATCHOS_11_3 = 110300
   1205 const __WATCHOS_11_4 = 110400
   1206 const __WATCHOS_11_5 = 110500
   1207 const __WATCHOS_1_0 = 10000
   1208 const __WATCHOS_2_0 = 20000
   1209 const __WATCHOS_2_1 = 20100
   1210 const __WATCHOS_2_2 = 20200
   1211 const __WATCHOS_3_0 = 30000
   1212 const __WATCHOS_3_1 = 30100
   1213 const __WATCHOS_3_1_1 = 30101
   1214 const __WATCHOS_3_2 = 30200
   1215 const __WATCHOS_4_0 = 40000
   1216 const __WATCHOS_4_1 = 40100
   1217 const __WATCHOS_4_2 = 40200
   1218 const __WATCHOS_4_3 = 40300
   1219 const __WATCHOS_5_0 = 50000
   1220 const __WATCHOS_5_1 = 50100
   1221 const __WATCHOS_5_2 = 50200
   1222 const __WATCHOS_5_3 = 50300
   1223 const __WATCHOS_6_0 = 60000
   1224 const __WATCHOS_6_1 = 60100
   1225 const __WATCHOS_6_2 = 60200
   1226 const __WATCHOS_7_0 = 70000
   1227 const __WATCHOS_7_1 = 70100
   1228 const __WATCHOS_7_2 = 70200
   1229 const __WATCHOS_7_3 = 70300
   1230 const __WATCHOS_7_4 = 70400
   1231 const __WATCHOS_7_5 = 70500
   1232 const __WATCHOS_7_6 = 70600
   1233 const __WATCHOS_8_0 = 80000
   1234 const __WATCHOS_8_1 = 80100
   1235 const __WATCHOS_8_3 = 80300
   1236 const __WATCHOS_8_4 = 80400
   1237 const __WATCHOS_8_5 = 80500
   1238 const __WATCHOS_8_6 = 80600
   1239 const __WATCHOS_8_7 = 80700
   1240 const __WATCHOS_8_8 = 80800
   1241 const __WATCHOS_9_0 = 90000
   1242 const __WATCHOS_9_1 = 90100
   1243 const __WATCHOS_9_2 = 90200
   1244 const __WATCHOS_9_3 = 90300
   1245 const __WATCHOS_9_4 = 90400
   1246 const __WATCHOS_9_5 = 90500
   1247 const __WATCHOS_9_6 = 90600
   1248 const __WCHAR_MAX__ = 0x7fffffff
   1249 const __WCHAR_TYPE__ = "int"
   1250 const __WCHAR_WIDTH__ = 32
   1251 const __WINT_MAX__ = 0xffffffff
   1252 const __WINT_MIN__ = 0
   1253 const __WINT_WIDTH__ = 32
   1254 const __WORDSIZE = 64
   1255 const __amd64 = 1
   1256 const __amd64__ = 1
   1257 const __code_model_small__ = 1
   1258 const __const = "const"
   1259 const __gnu_linux__ = 1
   1260 const __has_ptrcheck = 0
   1261 const __has_safe_buffers = 0
   1262 const __k8 = 1
   1263 const __k8__ = 1
   1264 const __linux = 1
   1265 const __linux__ = 1
   1266 const __pic__ = 2
   1267 const __pie__ = 2
   1268 const __restrict = "restrict"
   1269 const __restrict_arr = "restrict"
   1270 const __signed = "signed"
   1271 const __unix = 1
   1272 const __unix__ = 1
   1273 const __volatile = "volatile"
   1274 const __x86_64 = 1
   1275 const __x86_64__ = 1
   1276 const false1 = 0
   1277 const linux = 1
   1278 const ru_first = "ru_ixrss"
   1279 const ru_last = "ru_nivcsw"
   1280 const static_assert = "_Static_assert"
   1281 const sv_onstack = "sv_flags"
   1282 const true1 = 1
   1283 const unix = 1
   1284 
   1285 /* C23 keywords, no longer defined as macros by <stdbool.h> and <stddef.h>. */
   1286 
   1287 type __builtin_va_list = uintptr
   1288 
   1289 type __predefined_size_t = uint64
   1290 
   1291 type __predefined_wchar_t = int32
   1292 
   1293 type __predefined_ptrdiff_t = int64
   1294 
   1295 type __int8_t = int8
   1296 
   1297 type __uint8_t = uint8
   1298 
   1299 type __int16_t = int16
   1300 
   1301 type __uint16_t = uint16
   1302 
   1303 type __int32_t = int32
   1304 
   1305 type __uint32_t = uint32
   1306 
   1307 type __int64_t = int64
   1308 
   1309 type __uint64_t = uint64
   1310 
   1311 type __darwin_intptr_t = int64
   1312 
   1313 type __darwin_natural_t = uint32
   1314 
   1315 type __darwin_ct_rune_t = int32
   1316 
   1317 type __mbstate_t = struct {
   1318 	F_mbstateL  [0]int64
   1319 	F__mbstate8 [128]int8
   1320 }
   1321 
   1322 type __darwin_mbstate_t = struct {
   1323 	F_mbstateL  [0]int64
   1324 	F__mbstate8 [128]int8
   1325 }
   1326 
   1327 type __darwin_ptrdiff_t = int64
   1328 
   1329 type __darwin_size_t = uint64
   1330 
   1331 type __darwin_va_list = uintptr
   1332 
   1333 type __darwin_wchar_t = int32
   1334 
   1335 type __darwin_rune_t = int32
   1336 
   1337 type __darwin_wint_t = uint32
   1338 
   1339 type __darwin_clock_t = uint64
   1340 
   1341 type __darwin_socklen_t = uint32
   1342 
   1343 type __darwin_ssize_t = int64
   1344 
   1345 type __darwin_time_t = int64
   1346 
   1347 type __darwin_blkcnt_t = int64
   1348 
   1349 type __darwin_blksize_t = int32
   1350 
   1351 type __darwin_dev_t = int32
   1352 
   1353 type __darwin_fsblkcnt_t = uint32
   1354 
   1355 type __darwin_fsfilcnt_t = uint32
   1356 
   1357 type __darwin_gid_t = uint32
   1358 
   1359 type __darwin_id_t = uint32
   1360 
   1361 type __darwin_ino64_t = uint64
   1362 
   1363 type __darwin_ino_t = uint64
   1364 
   1365 type __darwin_mach_port_name_t = uint32
   1366 
   1367 type __darwin_mach_port_t = uint32
   1368 
   1369 type __darwin_mode_t = uint16
   1370 
   1371 type __darwin_off_t = int64
   1372 
   1373 type __darwin_pid_t = int32
   1374 
   1375 type __darwin_sigset_t = uint32
   1376 
   1377 type __darwin_suseconds_t = int32
   1378 
   1379 type __darwin_uid_t = uint32
   1380 
   1381 type __darwin_useconds_t = uint32
   1382 
   1383 type __darwin_uuid_t = [16]uint8
   1384 
   1385 type __darwin_uuid_string_t = [37]int8
   1386 
   1387 type __darwin_pthread_handler_rec = struct {
   1388 	F__routine uintptr
   1389 	F__arg     uintptr
   1390 	F__next    uintptr
   1391 }
   1392 
   1393 type _opaque_pthread_attr_t = struct {
   1394 	F__sig    int64
   1395 	F__opaque [56]int8
   1396 }
   1397 
   1398 type _opaque_pthread_cond_t = struct {
   1399 	F__sig    int64
   1400 	F__opaque [40]int8
   1401 }
   1402 
   1403 type _opaque_pthread_condattr_t = struct {
   1404 	F__sig    int64
   1405 	F__opaque [8]int8
   1406 }
   1407 
   1408 type _opaque_pthread_mutex_t = struct {
   1409 	F__sig    int64
   1410 	F__opaque [56]int8
   1411 }
   1412 
   1413 type _opaque_pthread_mutexattr_t = struct {
   1414 	F__sig    int64
   1415 	F__opaque [8]int8
   1416 }
   1417 
   1418 type _opaque_pthread_once_t = struct {
   1419 	F__sig    int64
   1420 	F__opaque [8]int8
   1421 }
   1422 
   1423 type _opaque_pthread_rwlock_t = struct {
   1424 	F__sig    int64
   1425 	F__opaque [192]int8
   1426 }
   1427 
   1428 type _opaque_pthread_rwlockattr_t = struct {
   1429 	F__sig    int64
   1430 	F__opaque [16]int8
   1431 }
   1432 
   1433 type _opaque_pthread_t = struct {
   1434 	F__sig           int64
   1435 	F__cleanup_stack uintptr
   1436 	F__opaque        [8176]int8
   1437 }
   1438 
   1439 type __darwin_pthread_attr_t = struct {
   1440 	F__sig    int64
   1441 	F__opaque [56]int8
   1442 }
   1443 
   1444 type __darwin_pthread_cond_t = struct {
   1445 	F__sig    int64
   1446 	F__opaque [40]int8
   1447 }
   1448 
   1449 type __darwin_pthread_condattr_t = struct {
   1450 	F__sig    int64
   1451 	F__opaque [8]int8
   1452 }
   1453 
   1454 type __darwin_pthread_key_t = uint64
   1455 
   1456 type __darwin_pthread_mutex_t = struct {
   1457 	F__sig    int64
   1458 	F__opaque [56]int8
   1459 }
   1460 
   1461 type __darwin_pthread_mutexattr_t = struct {
   1462 	F__sig    int64
   1463 	F__opaque [8]int8
   1464 }
   1465 
   1466 type __darwin_pthread_once_t = struct {
   1467 	F__sig    int64
   1468 	F__opaque [8]int8
   1469 }
   1470 
   1471 type __darwin_pthread_rwlock_t = struct {
   1472 	F__sig    int64
   1473 	F__opaque [192]int8
   1474 }
   1475 
   1476 type __darwin_pthread_rwlockattr_t = struct {
   1477 	F__sig    int64
   1478 	F__opaque [16]int8
   1479 }
   1480 
   1481 type __darwin_pthread_t = uintptr
   1482 
   1483 type __darwin_nl_item = int32
   1484 
   1485 type __darwin_wctrans_t = int32
   1486 
   1487 type __darwin_wctype_t = uint32
   1488 
   1489 type idtype_t = int32
   1490 
   1491 const P_ALL = 0
   1492 const P_PID = 1
   1493 const P_PGID = 2
   1494 
   1495 type pid_t = int32
   1496 
   1497 type id_t = uint32
   1498 
   1499 type sig_atomic_t = int32
   1500 
   1501 type int8_t = int8
   1502 
   1503 type int16_t = int16
   1504 
   1505 type int32_t = int32
   1506 
   1507 type int64_t = int64
   1508 
   1509 type u_int8_t = uint8
   1510 
   1511 type u_int16_t = uint16
   1512 
   1513 type u_int32_t = uint32
   1514 
   1515 type u_int64_t = uint64
   1516 
   1517 type register_t = int64
   1518 
   1519 type intptr_t = int64
   1520 
   1521 type uintptr_t = uint64
   1522 
   1523 type user_addr_t = uint64
   1524 
   1525 type user_size_t = uint64
   1526 
   1527 type user_ssize_t = int64
   1528 
   1529 type user_long_t = int64
   1530 
   1531 type user_ulong_t = uint64
   1532 
   1533 type user_time_t = int64
   1534 
   1535 type user_off_t = int64
   1536 
   1537 type syscall_arg_t = uint64
   1538 
   1539 type __darwin_i386_thread_state = struct {
   1540 	F__eax    uint32
   1541 	F__ebx    uint32
   1542 	F__ecx    uint32
   1543 	F__edx    uint32
   1544 	F__edi    uint32
   1545 	F__esi    uint32
   1546 	F__ebp    uint32
   1547 	F__esp    uint32
   1548 	F__ss     uint32
   1549 	F__eflags uint32
   1550 	F__eip    uint32
   1551 	F__cs     uint32
   1552 	F__ds     uint32
   1553 	F__es     uint32
   1554 	F__fs     uint32
   1555 	F__gs     uint32
   1556 }
   1557 
   1558 type __darwin_fp_control = struct {
   1559 	F__ccgo0 uint16
   1560 }
   1561 
   1562 type __darwin_fp_control_t = struct {
   1563 	F__ccgo0 uint16
   1564 }
   1565 
   1566 type __darwin_fp_status = struct {
   1567 	F__ccgo0 uint16
   1568 }
   1569 
   1570 type __darwin_fp_status_t = struct {
   1571 	F__ccgo0 uint16
   1572 }
   1573 
   1574 type __darwin_mmst_reg = struct {
   1575 	F__mmst_reg  [10]int8
   1576 	F__mmst_rsrv [6]int8
   1577 }
   1578 
   1579 type __darwin_xmm_reg = struct {
   1580 	F__xmm_reg [16]int8
   1581 }
   1582 
   1583 type __darwin_ymm_reg = struct {
   1584 	F__ymm_reg [32]int8
   1585 }
   1586 
   1587 type __darwin_zmm_reg = struct {
   1588 	F__zmm_reg [64]int8
   1589 }
   1590 
   1591 type __darwin_opmask_reg = struct {
   1592 	F__opmask_reg [8]int8
   1593 }
   1594 
   1595 type __darwin_i386_float_state = struct {
   1596 	F__fpu_reserved  [2]int32
   1597 	F__fpu_fcw       __darwin_fp_control
   1598 	F__fpu_fsw       __darwin_fp_status
   1599 	F__fpu_ftw       __uint8_t
   1600 	F__fpu_rsrv1     __uint8_t
   1601 	F__fpu_fop       __uint16_t
   1602 	F__fpu_ip        __uint32_t
   1603 	F__fpu_cs        __uint16_t
   1604 	F__fpu_rsrv2     __uint16_t
   1605 	F__fpu_dp        __uint32_t
   1606 	F__fpu_ds        __uint16_t
   1607 	F__fpu_rsrv3     __uint16_t
   1608 	F__fpu_mxcsr     __uint32_t
   1609 	F__fpu_mxcsrmask __uint32_t
   1610 	F__fpu_stmm0     __darwin_mmst_reg
   1611 	F__fpu_stmm1     __darwin_mmst_reg
   1612 	F__fpu_stmm2     __darwin_mmst_reg
   1613 	F__fpu_stmm3     __darwin_mmst_reg
   1614 	F__fpu_stmm4     __darwin_mmst_reg
   1615 	F__fpu_stmm5     __darwin_mmst_reg
   1616 	F__fpu_stmm6     __darwin_mmst_reg
   1617 	F__fpu_stmm7     __darwin_mmst_reg
   1618 	F__fpu_xmm0      __darwin_xmm_reg
   1619 	F__fpu_xmm1      __darwin_xmm_reg
   1620 	F__fpu_xmm2      __darwin_xmm_reg
   1621 	F__fpu_xmm3      __darwin_xmm_reg
   1622 	F__fpu_xmm4      __darwin_xmm_reg
   1623 	F__fpu_xmm5      __darwin_xmm_reg
   1624 	F__fpu_xmm6      __darwin_xmm_reg
   1625 	F__fpu_xmm7      __darwin_xmm_reg
   1626 	F__fpu_rsrv4     [224]int8
   1627 	F__fpu_reserved1 int32
   1628 }
   1629 
   1630 type __darwin_i386_avx_state = struct {
   1631 	F__fpu_reserved  [2]int32
   1632 	F__fpu_fcw       __darwin_fp_control
   1633 	F__fpu_fsw       __darwin_fp_status
   1634 	F__fpu_ftw       __uint8_t
   1635 	F__fpu_rsrv1     __uint8_t
   1636 	F__fpu_fop       __uint16_t
   1637 	F__fpu_ip        __uint32_t
   1638 	F__fpu_cs        __uint16_t
   1639 	F__fpu_rsrv2     __uint16_t
   1640 	F__fpu_dp        __uint32_t
   1641 	F__fpu_ds        __uint16_t
   1642 	F__fpu_rsrv3     __uint16_t
   1643 	F__fpu_mxcsr     __uint32_t
   1644 	F__fpu_mxcsrmask __uint32_t
   1645 	F__fpu_stmm0     __darwin_mmst_reg
   1646 	F__fpu_stmm1     __darwin_mmst_reg
   1647 	F__fpu_stmm2     __darwin_mmst_reg
   1648 	F__fpu_stmm3     __darwin_mmst_reg
   1649 	F__fpu_stmm4     __darwin_mmst_reg
   1650 	F__fpu_stmm5     __darwin_mmst_reg
   1651 	F__fpu_stmm6     __darwin_mmst_reg
   1652 	F__fpu_stmm7     __darwin_mmst_reg
   1653 	F__fpu_xmm0      __darwin_xmm_reg
   1654 	F__fpu_xmm1      __darwin_xmm_reg
   1655 	F__fpu_xmm2      __darwin_xmm_reg
   1656 	F__fpu_xmm3      __darwin_xmm_reg
   1657 	F__fpu_xmm4      __darwin_xmm_reg
   1658 	F__fpu_xmm5      __darwin_xmm_reg
   1659 	F__fpu_xmm6      __darwin_xmm_reg
   1660 	F__fpu_xmm7      __darwin_xmm_reg
   1661 	F__fpu_rsrv4     [224]int8
   1662 	F__fpu_reserved1 int32
   1663 	F__avx_reserved1 [64]int8
   1664 	F__fpu_ymmh0     __darwin_xmm_reg
   1665 	F__fpu_ymmh1     __darwin_xmm_reg
   1666 	F__fpu_ymmh2     __darwin_xmm_reg
   1667 	F__fpu_ymmh3     __darwin_xmm_reg
   1668 	F__fpu_ymmh4     __darwin_xmm_reg
   1669 	F__fpu_ymmh5     __darwin_xmm_reg
   1670 	F__fpu_ymmh6     __darwin_xmm_reg
   1671 	F__fpu_ymmh7     __darwin_xmm_reg
   1672 }
   1673 
   1674 type __darwin_i386_avx512_state = struct {
   1675 	F__fpu_reserved  [2]int32
   1676 	F__fpu_fcw       __darwin_fp_control
   1677 	F__fpu_fsw       __darwin_fp_status
   1678 	F__fpu_ftw       __uint8_t
   1679 	F__fpu_rsrv1     __uint8_t
   1680 	F__fpu_fop       __uint16_t
   1681 	F__fpu_ip        __uint32_t
   1682 	F__fpu_cs        __uint16_t
   1683 	F__fpu_rsrv2     __uint16_t
   1684 	F__fpu_dp        __uint32_t
   1685 	F__fpu_ds        __uint16_t
   1686 	F__fpu_rsrv3     __uint16_t
   1687 	F__fpu_mxcsr     __uint32_t
   1688 	F__fpu_mxcsrmask __uint32_t
   1689 	F__fpu_stmm0     __darwin_mmst_reg
   1690 	F__fpu_stmm1     __darwin_mmst_reg
   1691 	F__fpu_stmm2     __darwin_mmst_reg
   1692 	F__fpu_stmm3     __darwin_mmst_reg
   1693 	F__fpu_stmm4     __darwin_mmst_reg
   1694 	F__fpu_stmm5     __darwin_mmst_reg
   1695 	F__fpu_stmm6     __darwin_mmst_reg
   1696 	F__fpu_stmm7     __darwin_mmst_reg
   1697 	F__fpu_xmm0      __darwin_xmm_reg
   1698 	F__fpu_xmm1      __darwin_xmm_reg
   1699 	F__fpu_xmm2      __darwin_xmm_reg
   1700 	F__fpu_xmm3      __darwin_xmm_reg
   1701 	F__fpu_xmm4      __darwin_xmm_reg
   1702 	F__fpu_xmm5      __darwin_xmm_reg
   1703 	F__fpu_xmm6      __darwin_xmm_reg
   1704 	F__fpu_xmm7      __darwin_xmm_reg
   1705 	F__fpu_rsrv4     [224]int8
   1706 	F__fpu_reserved1 int32
   1707 	F__avx_reserved1 [64]int8
   1708 	F__fpu_ymmh0     __darwin_xmm_reg
   1709 	F__fpu_ymmh1     __darwin_xmm_reg
   1710 	F__fpu_ymmh2     __darwin_xmm_reg
   1711 	F__fpu_ymmh3     __darwin_xmm_reg
   1712 	F__fpu_ymmh4     __darwin_xmm_reg
   1713 	F__fpu_ymmh5     __darwin_xmm_reg
   1714 	F__fpu_ymmh6     __darwin_xmm_reg
   1715 	F__fpu_ymmh7     __darwin_xmm_reg
   1716 	F__fpu_k0        __darwin_opmask_reg
   1717 	F__fpu_k1        __darwin_opmask_reg
   1718 	F__fpu_k2        __darwin_opmask_reg
   1719 	F__fpu_k3        __darwin_opmask_reg
   1720 	F__fpu_k4        __darwin_opmask_reg
   1721 	F__fpu_k5        __darwin_opmask_reg
   1722 	F__fpu_k6        __darwin_opmask_reg
   1723 	F__fpu_k7        __darwin_opmask_reg
   1724 	F__fpu_zmmh0     __darwin_ymm_reg
   1725 	F__fpu_zmmh1     __darwin_ymm_reg
   1726 	F__fpu_zmmh2     __darwin_ymm_reg
   1727 	F__fpu_zmmh3     __darwin_ymm_reg
   1728 	F__fpu_zmmh4     __darwin_ymm_reg
   1729 	F__fpu_zmmh5     __darwin_ymm_reg
   1730 	F__fpu_zmmh6     __darwin_ymm_reg
   1731 	F__fpu_zmmh7     __darwin_ymm_reg
   1732 }
   1733 
   1734 type __darwin_i386_exception_state = struct {
   1735 	F__trapno     __uint16_t
   1736 	F__cpu        __uint16_t
   1737 	F__err        __uint32_t
   1738 	F__faultvaddr __uint32_t
   1739 }
   1740 
   1741 type __darwin_x86_debug_state32 = struct {
   1742 	F__dr0 uint32
   1743 	F__dr1 uint32
   1744 	F__dr2 uint32
   1745 	F__dr3 uint32
   1746 	F__dr4 uint32
   1747 	F__dr5 uint32
   1748 	F__dr6 uint32
   1749 	F__dr7 uint32
   1750 }
   1751 
   1752 type __x86_instruction_state = struct {
   1753 	F__insn_stream_valid_bytes int32
   1754 	F__insn_offset             int32
   1755 	F__out_of_synch            int32
   1756 	F__insn_bytes              [2380]__uint8_t
   1757 	F__insn_cacheline          [64]__uint8_t
   1758 }
   1759 
   1760 type __last_branch_record = struct {
   1761 	F__from_ip __uint64_t
   1762 	F__to_ip   __uint64_t
   1763 	F__ccgo16  uint32
   1764 }
   1765 
   1766 type __last_branch_state = struct {
   1767 	F__lbr_count int32
   1768 	F__ccgo4     uint32
   1769 	F__lbrs      [32]__last_branch_record
   1770 }
   1771 
   1772 type __x86_pagein_state = struct {
   1773 	F__pagein_error int32
   1774 }
   1775 
   1776 type __darwin_x86_thread_state64 = struct {
   1777 	F__rax    __uint64_t
   1778 	F__rbx    __uint64_t
   1779 	F__rcx    __uint64_t
   1780 	F__rdx    __uint64_t
   1781 	F__rdi    __uint64_t
   1782 	F__rsi    __uint64_t
   1783 	F__rbp    __uint64_t
   1784 	F__rsp    __uint64_t
   1785 	F__r8     __uint64_t
   1786 	F__r9     __uint64_t
   1787 	F__r10    __uint64_t
   1788 	F__r11    __uint64_t
   1789 	F__r12    __uint64_t
   1790 	F__r13    __uint64_t
   1791 	F__r14    __uint64_t
   1792 	F__r15    __uint64_t
   1793 	F__rip    __uint64_t
   1794 	F__rflags __uint64_t
   1795 	F__cs     __uint64_t
   1796 	F__fs     __uint64_t
   1797 	F__gs     __uint64_t
   1798 }
   1799 
   1800 type __darwin_x86_thread_full_state64 = struct {
   1801 	F__ss64   __darwin_x86_thread_state64
   1802 	F__ds     __uint64_t
   1803 	F__es     __uint64_t
   1804 	F__ss     __uint64_t
   1805 	F__gsbase __uint64_t
   1806 }
   1807 
   1808 type __darwin_x86_float_state64 = struct {
   1809 	F__fpu_reserved  [2]int32
   1810 	F__fpu_fcw       __darwin_fp_control
   1811 	F__fpu_fsw       __darwin_fp_status
   1812 	F__fpu_ftw       __uint8_t
   1813 	F__fpu_rsrv1     __uint8_t
   1814 	F__fpu_fop       __uint16_t
   1815 	F__fpu_ip        __uint32_t
   1816 	F__fpu_cs        __uint16_t
   1817 	F__fpu_rsrv2     __uint16_t
   1818 	F__fpu_dp        __uint32_t
   1819 	F__fpu_ds        __uint16_t
   1820 	F__fpu_rsrv3     __uint16_t
   1821 	F__fpu_mxcsr     __uint32_t
   1822 	F__fpu_mxcsrmask __uint32_t
   1823 	F__fpu_stmm0     __darwin_mmst_reg
   1824 	F__fpu_stmm1     __darwin_mmst_reg
   1825 	F__fpu_stmm2     __darwin_mmst_reg
   1826 	F__fpu_stmm3     __darwin_mmst_reg
   1827 	F__fpu_stmm4     __darwin_mmst_reg
   1828 	F__fpu_stmm5     __darwin_mmst_reg
   1829 	F__fpu_stmm6     __darwin_mmst_reg
   1830 	F__fpu_stmm7     __darwin_mmst_reg
   1831 	F__fpu_xmm0      __darwin_xmm_reg
   1832 	F__fpu_xmm1      __darwin_xmm_reg
   1833 	F__fpu_xmm2      __darwin_xmm_reg
   1834 	F__fpu_xmm3      __darwin_xmm_reg
   1835 	F__fpu_xmm4      __darwin_xmm_reg
   1836 	F__fpu_xmm5      __darwin_xmm_reg
   1837 	F__fpu_xmm6      __darwin_xmm_reg
   1838 	F__fpu_xmm7      __darwin_xmm_reg
   1839 	F__fpu_xmm8      __darwin_xmm_reg
   1840 	F__fpu_xmm9      __darwin_xmm_reg
   1841 	F__fpu_xmm10     __darwin_xmm_reg
   1842 	F__fpu_xmm11     __darwin_xmm_reg
   1843 	F__fpu_xmm12     __darwin_xmm_reg
   1844 	F__fpu_xmm13     __darwin_xmm_reg
   1845 	F__fpu_xmm14     __darwin_xmm_reg
   1846 	F__fpu_xmm15     __darwin_xmm_reg
   1847 	F__fpu_rsrv4     [96]int8
   1848 	F__fpu_reserved1 int32
   1849 }
   1850 
   1851 type __darwin_x86_avx_state64 = struct {
   1852 	F__fpu_reserved  [2]int32
   1853 	F__fpu_fcw       __darwin_fp_control
   1854 	F__fpu_fsw       __darwin_fp_status
   1855 	F__fpu_ftw       __uint8_t
   1856 	F__fpu_rsrv1     __uint8_t
   1857 	F__fpu_fop       __uint16_t
   1858 	F__fpu_ip        __uint32_t
   1859 	F__fpu_cs        __uint16_t
   1860 	F__fpu_rsrv2     __uint16_t
   1861 	F__fpu_dp        __uint32_t
   1862 	F__fpu_ds        __uint16_t
   1863 	F__fpu_rsrv3     __uint16_t
   1864 	F__fpu_mxcsr     __uint32_t
   1865 	F__fpu_mxcsrmask __uint32_t
   1866 	F__fpu_stmm0     __darwin_mmst_reg
   1867 	F__fpu_stmm1     __darwin_mmst_reg
   1868 	F__fpu_stmm2     __darwin_mmst_reg
   1869 	F__fpu_stmm3     __darwin_mmst_reg
   1870 	F__fpu_stmm4     __darwin_mmst_reg
   1871 	F__fpu_stmm5     __darwin_mmst_reg
   1872 	F__fpu_stmm6     __darwin_mmst_reg
   1873 	F__fpu_stmm7     __darwin_mmst_reg
   1874 	F__fpu_xmm0      __darwin_xmm_reg
   1875 	F__fpu_xmm1      __darwin_xmm_reg
   1876 	F__fpu_xmm2      __darwin_xmm_reg
   1877 	F__fpu_xmm3      __darwin_xmm_reg
   1878 	F__fpu_xmm4      __darwin_xmm_reg
   1879 	F__fpu_xmm5      __darwin_xmm_reg
   1880 	F__fpu_xmm6      __darwin_xmm_reg
   1881 	F__fpu_xmm7      __darwin_xmm_reg
   1882 	F__fpu_xmm8      __darwin_xmm_reg
   1883 	F__fpu_xmm9      __darwin_xmm_reg
   1884 	F__fpu_xmm10     __darwin_xmm_reg
   1885 	F__fpu_xmm11     __darwin_xmm_reg
   1886 	F__fpu_xmm12     __darwin_xmm_reg
   1887 	F__fpu_xmm13     __darwin_xmm_reg
   1888 	F__fpu_xmm14     __darwin_xmm_reg
   1889 	F__fpu_xmm15     __darwin_xmm_reg
   1890 	F__fpu_rsrv4     [96]int8
   1891 	F__fpu_reserved1 int32
   1892 	F__avx_reserved1 [64]int8
   1893 	F__fpu_ymmh0     __darwin_xmm_reg
   1894 	F__fpu_ymmh1     __darwin_xmm_reg
   1895 	F__fpu_ymmh2     __darwin_xmm_reg
   1896 	F__fpu_ymmh3     __darwin_xmm_reg
   1897 	F__fpu_ymmh4     __darwin_xmm_reg
   1898 	F__fpu_ymmh5     __darwin_xmm_reg
   1899 	F__fpu_ymmh6     __darwin_xmm_reg
   1900 	F__fpu_ymmh7     __darwin_xmm_reg
   1901 	F__fpu_ymmh8     __darwin_xmm_reg
   1902 	F__fpu_ymmh9     __darwin_xmm_reg
   1903 	F__fpu_ymmh10    __darwin_xmm_reg
   1904 	F__fpu_ymmh11    __darwin_xmm_reg
   1905 	F__fpu_ymmh12    __darwin_xmm_reg
   1906 	F__fpu_ymmh13    __darwin_xmm_reg
   1907 	F__fpu_ymmh14    __darwin_xmm_reg
   1908 	F__fpu_ymmh15    __darwin_xmm_reg
   1909 }
   1910 
   1911 type __darwin_x86_avx512_state64 = struct {
   1912 	F__fpu_reserved  [2]int32
   1913 	F__fpu_fcw       __darwin_fp_control
   1914 	F__fpu_fsw       __darwin_fp_status
   1915 	F__fpu_ftw       __uint8_t
   1916 	F__fpu_rsrv1     __uint8_t
   1917 	F__fpu_fop       __uint16_t
   1918 	F__fpu_ip        __uint32_t
   1919 	F__fpu_cs        __uint16_t
   1920 	F__fpu_rsrv2     __uint16_t
   1921 	F__fpu_dp        __uint32_t
   1922 	F__fpu_ds        __uint16_t
   1923 	F__fpu_rsrv3     __uint16_t
   1924 	F__fpu_mxcsr     __uint32_t
   1925 	F__fpu_mxcsrmask __uint32_t
   1926 	F__fpu_stmm0     __darwin_mmst_reg
   1927 	F__fpu_stmm1     __darwin_mmst_reg
   1928 	F__fpu_stmm2     __darwin_mmst_reg
   1929 	F__fpu_stmm3     __darwin_mmst_reg
   1930 	F__fpu_stmm4     __darwin_mmst_reg
   1931 	F__fpu_stmm5     __darwin_mmst_reg
   1932 	F__fpu_stmm6     __darwin_mmst_reg
   1933 	F__fpu_stmm7     __darwin_mmst_reg
   1934 	F__fpu_xmm0      __darwin_xmm_reg
   1935 	F__fpu_xmm1      __darwin_xmm_reg
   1936 	F__fpu_xmm2      __darwin_xmm_reg
   1937 	F__fpu_xmm3      __darwin_xmm_reg
   1938 	F__fpu_xmm4      __darwin_xmm_reg
   1939 	F__fpu_xmm5      __darwin_xmm_reg
   1940 	F__fpu_xmm6      __darwin_xmm_reg
   1941 	F__fpu_xmm7      __darwin_xmm_reg
   1942 	F__fpu_xmm8      __darwin_xmm_reg
   1943 	F__fpu_xmm9      __darwin_xmm_reg
   1944 	F__fpu_xmm10     __darwin_xmm_reg
   1945 	F__fpu_xmm11     __darwin_xmm_reg
   1946 	F__fpu_xmm12     __darwin_xmm_reg
   1947 	F__fpu_xmm13     __darwin_xmm_reg
   1948 	F__fpu_xmm14     __darwin_xmm_reg
   1949 	F__fpu_xmm15     __darwin_xmm_reg
   1950 	F__fpu_rsrv4     [96]int8
   1951 	F__fpu_reserved1 int32
   1952 	F__avx_reserved1 [64]int8
   1953 	F__fpu_ymmh0     __darwin_xmm_reg
   1954 	F__fpu_ymmh1     __darwin_xmm_reg
   1955 	F__fpu_ymmh2     __darwin_xmm_reg
   1956 	F__fpu_ymmh3     __darwin_xmm_reg
   1957 	F__fpu_ymmh4     __darwin_xmm_reg
   1958 	F__fpu_ymmh5     __darwin_xmm_reg
   1959 	F__fpu_ymmh6     __darwin_xmm_reg
   1960 	F__fpu_ymmh7     __darwin_xmm_reg
   1961 	F__fpu_ymmh8     __darwin_xmm_reg
   1962 	F__fpu_ymmh9     __darwin_xmm_reg
   1963 	F__fpu_ymmh10    __darwin_xmm_reg
   1964 	F__fpu_ymmh11    __darwin_xmm_reg
   1965 	F__fpu_ymmh12    __darwin_xmm_reg
   1966 	F__fpu_ymmh13    __darwin_xmm_reg
   1967 	F__fpu_ymmh14    __darwin_xmm_reg
   1968 	F__fpu_ymmh15    __darwin_xmm_reg
   1969 	F__fpu_k0        __darwin_opmask_reg
   1970 	F__fpu_k1        __darwin_opmask_reg
   1971 	F__fpu_k2        __darwin_opmask_reg
   1972 	F__fpu_k3        __darwin_opmask_reg
   1973 	F__fpu_k4        __darwin_opmask_reg
   1974 	F__fpu_k5        __darwin_opmask_reg
   1975 	F__fpu_k6        __darwin_opmask_reg
   1976 	F__fpu_k7        __darwin_opmask_reg
   1977 	F__fpu_zmmh0     __darwin_ymm_reg
   1978 	F__fpu_zmmh1     __darwin_ymm_reg
   1979 	F__fpu_zmmh2     __darwin_ymm_reg
   1980 	F__fpu_zmmh3     __darwin_ymm_reg
   1981 	F__fpu_zmmh4     __darwin_ymm_reg
   1982 	F__fpu_zmmh5     __darwin_ymm_reg
   1983 	F__fpu_zmmh6     __darwin_ymm_reg
   1984 	F__fpu_zmmh7     __darwin_ymm_reg
   1985 	F__fpu_zmmh8     __darwin_ymm_reg
   1986 	F__fpu_zmmh9     __darwin_ymm_reg
   1987 	F__fpu_zmmh10    __darwin_ymm_reg
   1988 	F__fpu_zmmh11    __darwin_ymm_reg
   1989 	F__fpu_zmmh12    __darwin_ymm_reg
   1990 	F__fpu_zmmh13    __darwin_ymm_reg
   1991 	F__fpu_zmmh14    __darwin_ymm_reg
   1992 	F__fpu_zmmh15    __darwin_ymm_reg
   1993 	F__fpu_zmm16     __darwin_zmm_reg
   1994 	F__fpu_zmm17     __darwin_zmm_reg
   1995 	F__fpu_zmm18     __darwin_zmm_reg
   1996 	F__fpu_zmm19     __darwin_zmm_reg
   1997 	F__fpu_zmm20     __darwin_zmm_reg
   1998 	F__fpu_zmm21     __darwin_zmm_reg
   1999 	F__fpu_zmm22     __darwin_zmm_reg
   2000 	F__fpu_zmm23     __darwin_zmm_reg
   2001 	F__fpu_zmm24     __darwin_zmm_reg
   2002 	F__fpu_zmm25     __darwin_zmm_reg
   2003 	F__fpu_zmm26     __darwin_zmm_reg
   2004 	F__fpu_zmm27     __darwin_zmm_reg
   2005 	F__fpu_zmm28     __darwin_zmm_reg
   2006 	F__fpu_zmm29     __darwin_zmm_reg
   2007 	F__fpu_zmm30     __darwin_zmm_reg
   2008 	F__fpu_zmm31     __darwin_zmm_reg
   2009 }
   2010 
   2011 type __darwin_x86_exception_state64 = struct {
   2012 	F__trapno     __uint16_t
   2013 	F__cpu        __uint16_t
   2014 	F__err        __uint32_t
   2015 	F__faultvaddr __uint64_t
   2016 }
   2017 
   2018 type __darwin_x86_debug_state64 = struct {
   2019 	F__dr0 __uint64_t
   2020 	F__dr1 __uint64_t
   2021 	F__dr2 __uint64_t
   2022 	F__dr3 __uint64_t
   2023 	F__dr4 __uint64_t
   2024 	F__dr5 __uint64_t
   2025 	F__dr6 __uint64_t
   2026 	F__dr7 __uint64_t
   2027 }
   2028 
   2029 type __darwin_x86_cpmu_state64 = struct {
   2030 	F__ctrs [16]__uint64_t
   2031 }
   2032 
   2033 type __darwin_mcontext32 = struct {
   2034 	F__es __darwin_i386_exception_state
   2035 	F__ss __darwin_i386_thread_state
   2036 	F__fs __darwin_i386_float_state
   2037 }
   2038 
   2039 type __darwin_mcontext_avx32 = struct {
   2040 	F__es __darwin_i386_exception_state
   2041 	F__ss __darwin_i386_thread_state
   2042 	F__fs __darwin_i386_avx_state
   2043 }
   2044 
   2045 type __darwin_mcontext_avx512_32 = struct {
   2046 	F__es __darwin_i386_exception_state
   2047 	F__ss __darwin_i386_thread_state
   2048 	F__fs __darwin_i386_avx512_state
   2049 }
   2050 
   2051 type __darwin_mcontext64 = struct {
   2052 	F__es __darwin_x86_exception_state64
   2053 	F__ss __darwin_x86_thread_state64
   2054 	F__fs __darwin_x86_float_state64
   2055 }
   2056 
   2057 type __darwin_mcontext64_full = struct {
   2058 	F__es __darwin_x86_exception_state64
   2059 	F__ss __darwin_x86_thread_full_state64
   2060 	F__fs __darwin_x86_float_state64
   2061 }
   2062 
   2063 type __darwin_mcontext_avx64 = struct {
   2064 	F__es __darwin_x86_exception_state64
   2065 	F__ss __darwin_x86_thread_state64
   2066 	F__fs __darwin_x86_avx_state64
   2067 }
   2068 
   2069 type __darwin_mcontext_avx64_full = struct {
   2070 	F__es __darwin_x86_exception_state64
   2071 	F__ss __darwin_x86_thread_full_state64
   2072 	F__fs __darwin_x86_avx_state64
   2073 }
   2074 
   2075 type __darwin_mcontext_avx512_64 = struct {
   2076 	F__es __darwin_x86_exception_state64
   2077 	F__ss __darwin_x86_thread_state64
   2078 	F__fs __darwin_x86_avx512_state64
   2079 }
   2080 
   2081 type __darwin_mcontext_avx512_64_full = struct {
   2082 	F__es __darwin_x86_exception_state64
   2083 	F__ss __darwin_x86_thread_full_state64
   2084 	F__fs __darwin_x86_avx512_state64
   2085 }
   2086 
   2087 type mcontext_t = uintptr
   2088 
   2089 type pthread_attr_t = struct {
   2090 	F__sig    int64
   2091 	F__opaque [56]int8
   2092 }
   2093 
   2094 type __darwin_sigaltstack = struct {
   2095 	Fss_sp    uintptr
   2096 	Fss_size  __darwin_size_t
   2097 	Fss_flags int32
   2098 }
   2099 
   2100 type stack_t = struct {
   2101 	Fss_sp    uintptr
   2102 	Fss_size  __darwin_size_t
   2103 	Fss_flags int32
   2104 }
   2105 
   2106 type __darwin_ucontext = struct {
   2107 	Fuc_onstack  int32
   2108 	Fuc_sigmask  __darwin_sigset_t
   2109 	Fuc_stack    __darwin_sigaltstack
   2110 	Fuc_link     uintptr
   2111 	Fuc_mcsize   __darwin_size_t
   2112 	Fuc_mcontext uintptr
   2113 }
   2114 
   2115 type ucontext_t = struct {
   2116 	Fuc_onstack  int32
   2117 	Fuc_sigmask  __darwin_sigset_t
   2118 	Fuc_stack    __darwin_sigaltstack
   2119 	Fuc_link     uintptr
   2120 	Fuc_mcsize   __darwin_size_t
   2121 	Fuc_mcontext uintptr
   2122 }
   2123 
   2124 type sigset_t = uint32
   2125 
   2126 type size_t = uint64
   2127 
   2128 type uid_t = uint32
   2129 
   2130 type sigval = struct {
   2131 	Fsival_ptr   [0]uintptr
   2132 	Fsival_int   int32
   2133 	F__ccgo_pad2 [4]byte
   2134 }
   2135 
   2136 type sigevent = struct {
   2137 	Fsigev_notify            int32
   2138 	Fsigev_signo             int32
   2139 	Fsigev_value             sigval
   2140 	Fsigev_notify_function   uintptr
   2141 	Fsigev_notify_attributes uintptr
   2142 }
   2143 
   2144 type siginfo_t = struct {
   2145 	Fsi_signo  int32
   2146 	Fsi_errno  int32
   2147 	Fsi_code   int32
   2148 	Fsi_pid    pid_t
   2149 	Fsi_uid    uid_t
   2150 	Fsi_status int32
   2151 	Fsi_addr   uintptr
   2152 	Fsi_value  sigval
   2153 	Fsi_band   int64
   2154 	F__pad     [7]uint64
   2155 }
   2156 
   2157 type __siginfo = siginfo_t
   2158 
   2159 type __sigaction_u = struct {
   2160 	F__sa_sigaction [0]uintptr
   2161 	F__sa_handler   uintptr
   2162 }
   2163 
   2164 type __sigaction = struct {
   2165 	F__sigaction_u __sigaction_u
   2166 	Fsa_tramp      uintptr
   2167 	Fsa_mask       sigset_t
   2168 	Fsa_flags      int32
   2169 }
   2170 
   2171 type sigaction1 = struct {
   2172 	F__sigaction_u __sigaction_u
   2173 	Fsa_mask       sigset_t
   2174 	Fsa_flags      int32
   2175 }
   2176 
   2177 type sig_t = uintptr
   2178 
   2179 type sigvec = struct {
   2180 	Fsv_handler uintptr
   2181 	Fsv_mask    int32
   2182 	Fsv_flags   int32
   2183 }
   2184 
   2185 type sigstack = struct {
   2186 	Fss_sp      uintptr
   2187 	Fss_onstack int32
   2188 }
   2189 
   2190 type uint8_t = uint8
   2191 
   2192 type uint16_t = uint16
   2193 
   2194 type uint32_t = uint32
   2195 
   2196 type uint64_t = uint64
   2197 
   2198 type int_least8_t = int8
   2199 
   2200 type int_least16_t = int16
   2201 
   2202 type int_least32_t = int32
   2203 
   2204 type int_least64_t = int64
   2205 
   2206 type uint_least8_t = uint8
   2207 
   2208 type uint_least16_t = uint16
   2209 
   2210 type uint_least32_t = uint32
   2211 
   2212 type uint_least64_t = uint64
   2213 
   2214 type int_fast8_t = int8
   2215 
   2216 type int_fast16_t = int16
   2217 
   2218 type int_fast32_t = int32
   2219 
   2220 type int_fast64_t = int64
   2221 
   2222 type uint_fast8_t = uint8
   2223 
   2224 type uint_fast16_t = uint16
   2225 
   2226 type uint_fast32_t = uint32
   2227 
   2228 type uint_fast64_t = uint64
   2229 
   2230 type intmax_t = int64
   2231 
   2232 type uintmax_t = uint64
   2233 
   2234 type timeval = struct {
   2235 	Ftv_sec  __darwin_time_t
   2236 	Ftv_usec __darwin_suseconds_t
   2237 }
   2238 
   2239 type rlim_t = uint64
   2240 
   2241 type rusage = struct {
   2242 	Fru_utime    timeval
   2243 	Fru_stime    timeval
   2244 	Fru_maxrss   int64
   2245 	Fru_ixrss    int64
   2246 	Fru_idrss    int64
   2247 	Fru_isrss    int64
   2248 	Fru_minflt   int64
   2249 	Fru_majflt   int64
   2250 	Fru_nswap    int64
   2251 	Fru_inblock  int64
   2252 	Fru_oublock  int64
   2253 	Fru_msgsnd   int64
   2254 	Fru_msgrcv   int64
   2255 	Fru_nsignals int64
   2256 	Fru_nvcsw    int64
   2257 	Fru_nivcsw   int64
   2258 }
   2259 
   2260 type rusage_info_t = uintptr
   2261 
   2262 type rusage_info_v0 = struct {
   2263 	Fri_uuid               [16]uint8_t
   2264 	Fri_user_time          uint64_t
   2265 	Fri_system_time        uint64_t
   2266 	Fri_pkg_idle_wkups     uint64_t
   2267 	Fri_interrupt_wkups    uint64_t
   2268 	Fri_pageins            uint64_t
   2269 	Fri_wired_size         uint64_t
   2270 	Fri_resident_size      uint64_t
   2271 	Fri_phys_footprint     uint64_t
   2272 	Fri_proc_start_abstime uint64_t
   2273 	Fri_proc_exit_abstime  uint64_t
   2274 }
   2275 
   2276 type rusage_info_v1 = struct {
   2277 	Fri_uuid                  [16]uint8_t
   2278 	Fri_user_time             uint64_t
   2279 	Fri_system_time           uint64_t
   2280 	Fri_pkg_idle_wkups        uint64_t
   2281 	Fri_interrupt_wkups       uint64_t
   2282 	Fri_pageins               uint64_t
   2283 	Fri_wired_size            uint64_t
   2284 	Fri_resident_size         uint64_t
   2285 	Fri_phys_footprint        uint64_t
   2286 	Fri_proc_start_abstime    uint64_t
   2287 	Fri_proc_exit_abstime     uint64_t
   2288 	Fri_child_user_time       uint64_t
   2289 	Fri_child_system_time     uint64_t
   2290 	Fri_child_pkg_idle_wkups  uint64_t
   2291 	Fri_child_interrupt_wkups uint64_t
   2292 	Fri_child_pageins         uint64_t
   2293 	Fri_child_elapsed_abstime uint64_t
   2294 }
   2295 
   2296 type rusage_info_v2 = struct {
   2297 	Fri_uuid                  [16]uint8_t
   2298 	Fri_user_time             uint64_t
   2299 	Fri_system_time           uint64_t
   2300 	Fri_pkg_idle_wkups        uint64_t
   2301 	Fri_interrupt_wkups       uint64_t
   2302 	Fri_pageins               uint64_t
   2303 	Fri_wired_size            uint64_t
   2304 	Fri_resident_size         uint64_t
   2305 	Fri_phys_footprint        uint64_t
   2306 	Fri_proc_start_abstime    uint64_t
   2307 	Fri_proc_exit_abstime     uint64_t
   2308 	Fri_child_user_time       uint64_t
   2309 	Fri_child_system_time     uint64_t
   2310 	Fri_child_pkg_idle_wkups  uint64_t
   2311 	Fri_child_interrupt_wkups uint64_t
   2312 	Fri_child_pageins         uint64_t
   2313 	Fri_child_elapsed_abstime uint64_t
   2314 	Fri_diskio_bytesread      uint64_t
   2315 	Fri_diskio_byteswritten   uint64_t
   2316 }
   2317 
   2318 type rusage_info_v3 = struct {
   2319 	Fri_uuid                          [16]uint8_t
   2320 	Fri_user_time                     uint64_t
   2321 	Fri_system_time                   uint64_t
   2322 	Fri_pkg_idle_wkups                uint64_t
   2323 	Fri_interrupt_wkups               uint64_t
   2324 	Fri_pageins                       uint64_t
   2325 	Fri_wired_size                    uint64_t
   2326 	Fri_resident_size                 uint64_t
   2327 	Fri_phys_footprint                uint64_t
   2328 	Fri_proc_start_abstime            uint64_t
   2329 	Fri_proc_exit_abstime             uint64_t
   2330 	Fri_child_user_time               uint64_t
   2331 	Fri_child_system_time             uint64_t
   2332 	Fri_child_pkg_idle_wkups          uint64_t
   2333 	Fri_child_interrupt_wkups         uint64_t
   2334 	Fri_child_pageins                 uint64_t
   2335 	Fri_child_elapsed_abstime         uint64_t
   2336 	Fri_diskio_bytesread              uint64_t
   2337 	Fri_diskio_byteswritten           uint64_t
   2338 	Fri_cpu_time_qos_default          uint64_t
   2339 	Fri_cpu_time_qos_maintenance      uint64_t
   2340 	Fri_cpu_time_qos_background       uint64_t
   2341 	Fri_cpu_time_qos_utility          uint64_t
   2342 	Fri_cpu_time_qos_legacy           uint64_t
   2343 	Fri_cpu_time_qos_user_initiated   uint64_t
   2344 	Fri_cpu_time_qos_user_interactive uint64_t
   2345 	Fri_billed_system_time            uint64_t
   2346 	Fri_serviced_system_time          uint64_t
   2347 }
   2348 
   2349 type rusage_info_v4 = struct {
   2350 	Fri_uuid                          [16]uint8_t
   2351 	Fri_user_time                     uint64_t
   2352 	Fri_system_time                   uint64_t
   2353 	Fri_pkg_idle_wkups                uint64_t
   2354 	Fri_interrupt_wkups               uint64_t
   2355 	Fri_pageins                       uint64_t
   2356 	Fri_wired_size                    uint64_t
   2357 	Fri_resident_size                 uint64_t
   2358 	Fri_phys_footprint                uint64_t
   2359 	Fri_proc_start_abstime            uint64_t
   2360 	Fri_proc_exit_abstime             uint64_t
   2361 	Fri_child_user_time               uint64_t
   2362 	Fri_child_system_time             uint64_t
   2363 	Fri_child_pkg_idle_wkups          uint64_t
   2364 	Fri_child_interrupt_wkups         uint64_t
   2365 	Fri_child_pageins                 uint64_t
   2366 	Fri_child_elapsed_abstime         uint64_t
   2367 	Fri_diskio_bytesread              uint64_t
   2368 	Fri_diskio_byteswritten           uint64_t
   2369 	Fri_cpu_time_qos_default          uint64_t
   2370 	Fri_cpu_time_qos_maintenance      uint64_t
   2371 	Fri_cpu_time_qos_background       uint64_t
   2372 	Fri_cpu_time_qos_utility          uint64_t
   2373 	Fri_cpu_time_qos_legacy           uint64_t
   2374 	Fri_cpu_time_qos_user_initiated   uint64_t
   2375 	Fri_cpu_time_qos_user_interactive uint64_t
   2376 	Fri_billed_system_time            uint64_t
   2377 	Fri_serviced_system_time          uint64_t
   2378 	Fri_logical_writes                uint64_t
   2379 	Fri_lifetime_max_phys_footprint   uint64_t
   2380 	Fri_instructions                  uint64_t
   2381 	Fri_cycles                        uint64_t
   2382 	Fri_billed_energy                 uint64_t
   2383 	Fri_serviced_energy               uint64_t
   2384 	Fri_interval_max_phys_footprint   uint64_t
   2385 	Fri_runnable_time                 uint64_t
   2386 }
   2387 
   2388 type rusage_info_v5 = struct {
   2389 	Fri_uuid                          [16]uint8_t
   2390 	Fri_user_time                     uint64_t
   2391 	Fri_system_time                   uint64_t
   2392 	Fri_pkg_idle_wkups                uint64_t
   2393 	Fri_interrupt_wkups               uint64_t
   2394 	Fri_pageins                       uint64_t
   2395 	Fri_wired_size                    uint64_t
   2396 	Fri_resident_size                 uint64_t
   2397 	Fri_phys_footprint                uint64_t
   2398 	Fri_proc_start_abstime            uint64_t
   2399 	Fri_proc_exit_abstime             uint64_t
   2400 	Fri_child_user_time               uint64_t
   2401 	Fri_child_system_time             uint64_t
   2402 	Fri_child_pkg_idle_wkups          uint64_t
   2403 	Fri_child_interrupt_wkups         uint64_t
   2404 	Fri_child_pageins                 uint64_t
   2405 	Fri_child_elapsed_abstime         uint64_t
   2406 	Fri_diskio_bytesread              uint64_t
   2407 	Fri_diskio_byteswritten           uint64_t
   2408 	Fri_cpu_time_qos_default          uint64_t
   2409 	Fri_cpu_time_qos_maintenance      uint64_t
   2410 	Fri_cpu_time_qos_background       uint64_t
   2411 	Fri_cpu_time_qos_utility          uint64_t
   2412 	Fri_cpu_time_qos_legacy           uint64_t
   2413 	Fri_cpu_time_qos_user_initiated   uint64_t
   2414 	Fri_cpu_time_qos_user_interactive uint64_t
   2415 	Fri_billed_system_time            uint64_t
   2416 	Fri_serviced_system_time          uint64_t
   2417 	Fri_logical_writes                uint64_t
   2418 	Fri_lifetime_max_phys_footprint   uint64_t
   2419 	Fri_instructions                  uint64_t
   2420 	Fri_cycles                        uint64_t
   2421 	Fri_billed_energy                 uint64_t
   2422 	Fri_serviced_energy               uint64_t
   2423 	Fri_interval_max_phys_footprint   uint64_t
   2424 	Fri_runnable_time                 uint64_t
   2425 	Fri_flags                         uint64_t
   2426 }
   2427 
   2428 type rusage_info_v6 = struct {
   2429 	Fri_uuid                          [16]uint8_t
   2430 	Fri_user_time                     uint64_t
   2431 	Fri_system_time                   uint64_t
   2432 	Fri_pkg_idle_wkups                uint64_t
   2433 	Fri_interrupt_wkups               uint64_t
   2434 	Fri_pageins                       uint64_t
   2435 	Fri_wired_size                    uint64_t
   2436 	Fri_resident_size                 uint64_t
   2437 	Fri_phys_footprint                uint64_t
   2438 	Fri_proc_start_abstime            uint64_t
   2439 	Fri_proc_exit_abstime             uint64_t
   2440 	Fri_child_user_time               uint64_t
   2441 	Fri_child_system_time             uint64_t
   2442 	Fri_child_pkg_idle_wkups          uint64_t
   2443 	Fri_child_interrupt_wkups         uint64_t
   2444 	Fri_child_pageins                 uint64_t
   2445 	Fri_child_elapsed_abstime         uint64_t
   2446 	Fri_diskio_bytesread              uint64_t
   2447 	Fri_diskio_byteswritten           uint64_t
   2448 	Fri_cpu_time_qos_default          uint64_t
   2449 	Fri_cpu_time_qos_maintenance      uint64_t
   2450 	Fri_cpu_time_qos_background       uint64_t
   2451 	Fri_cpu_time_qos_utility          uint64_t
   2452 	Fri_cpu_time_qos_legacy           uint64_t
   2453 	Fri_cpu_time_qos_user_initiated   uint64_t
   2454 	Fri_cpu_time_qos_user_interactive uint64_t
   2455 	Fri_billed_system_time            uint64_t
   2456 	Fri_serviced_system_time          uint64_t
   2457 	Fri_logical_writes                uint64_t
   2458 	Fri_lifetime_max_phys_footprint   uint64_t
   2459 	Fri_instructions                  uint64_t
   2460 	Fri_cycles                        uint64_t
   2461 	Fri_billed_energy                 uint64_t
   2462 	Fri_serviced_energy               uint64_t
   2463 	Fri_interval_max_phys_footprint   uint64_t
   2464 	Fri_runnable_time                 uint64_t
   2465 	Fri_flags                         uint64_t
   2466 	Fri_user_ptime                    uint64_t
   2467 	Fri_system_ptime                  uint64_t
   2468 	Fri_pinstructions                 uint64_t
   2469 	Fri_pcycles                       uint64_t
   2470 	Fri_energy_nj                     uint64_t
   2471 	Fri_penergy_nj                    uint64_t
   2472 	Fri_secure_time_in_system         uint64_t
   2473 	Fri_secure_ptime_in_system        uint64_t
   2474 	Fri_neural_footprint              uint64_t
   2475 	Fri_lifetime_max_neural_footprint uint64_t
   2476 	Fri_interval_max_neural_footprint uint64_t
   2477 	Fri_reserved                      [9]uint64_t
   2478 }
   2479 
   2480 type rusage_info_current = struct {
   2481 	Fri_uuid                          [16]uint8_t
   2482 	Fri_user_time                     uint64_t
   2483 	Fri_system_time                   uint64_t
   2484 	Fri_pkg_idle_wkups                uint64_t
   2485 	Fri_interrupt_wkups               uint64_t
   2486 	Fri_pageins                       uint64_t
   2487 	Fri_wired_size                    uint64_t
   2488 	Fri_resident_size                 uint64_t
   2489 	Fri_phys_footprint                uint64_t
   2490 	Fri_proc_start_abstime            uint64_t
   2491 	Fri_proc_exit_abstime             uint64_t
   2492 	Fri_child_user_time               uint64_t
   2493 	Fri_child_system_time             uint64_t
   2494 	Fri_child_pkg_idle_wkups          uint64_t
   2495 	Fri_child_interrupt_wkups         uint64_t
   2496 	Fri_child_pageins                 uint64_t
   2497 	Fri_child_elapsed_abstime         uint64_t
   2498 	Fri_diskio_bytesread              uint64_t
   2499 	Fri_diskio_byteswritten           uint64_t
   2500 	Fri_cpu_time_qos_default          uint64_t
   2501 	Fri_cpu_time_qos_maintenance      uint64_t
   2502 	Fri_cpu_time_qos_background       uint64_t
   2503 	Fri_cpu_time_qos_utility          uint64_t
   2504 	Fri_cpu_time_qos_legacy           uint64_t
   2505 	Fri_cpu_time_qos_user_initiated   uint64_t
   2506 	Fri_cpu_time_qos_user_interactive uint64_t
   2507 	Fri_billed_system_time            uint64_t
   2508 	Fri_serviced_system_time          uint64_t
   2509 	Fri_logical_writes                uint64_t
   2510 	Fri_lifetime_max_phys_footprint   uint64_t
   2511 	Fri_instructions                  uint64_t
   2512 	Fri_cycles                        uint64_t
   2513 	Fri_billed_energy                 uint64_t
   2514 	Fri_serviced_energy               uint64_t
   2515 	Fri_interval_max_phys_footprint   uint64_t
   2516 	Fri_runnable_time                 uint64_t
   2517 	Fri_flags                         uint64_t
   2518 	Fri_user_ptime                    uint64_t
   2519 	Fri_system_ptime                  uint64_t
   2520 	Fri_pinstructions                 uint64_t
   2521 	Fri_pcycles                       uint64_t
   2522 	Fri_energy_nj                     uint64_t
   2523 	Fri_penergy_nj                    uint64_t
   2524 	Fri_secure_time_in_system         uint64_t
   2525 	Fri_secure_ptime_in_system        uint64_t
   2526 	Fri_neural_footprint              uint64_t
   2527 	Fri_lifetime_max_neural_footprint uint64_t
   2528 	Fri_interval_max_neural_footprint uint64_t
   2529 	Fri_reserved                      [9]uint64_t
   2530 }
   2531 
   2532 type rlimit = struct {
   2533 	Frlim_cur rlim_t
   2534 	Frlim_max rlim_t
   2535 }
   2536 
   2537 type proc_rlimit_control_wakeupmon = struct {
   2538 	Fwm_flags uint32_t
   2539 	Fwm_rate  int32_t
   2540 }
   2541 
   2542 type wait = struct {
   2543 	Fw_T [0]struct {
   2544 		F__ccgo0 uint32
   2545 	}
   2546 	Fw_S [0]struct {
   2547 		F__ccgo0 uint32
   2548 	}
   2549 	Fw_status int32
   2550 }
   2551 
   2552 type ct_rune_t = int32
   2553 
   2554 type rune_t = int32
   2555 
   2556 type wchar_t = int32
   2557 
   2558 type div_t = struct {
   2559 	Fquot int32
   2560 	Frem  int32
   2561 }
   2562 
   2563 type ldiv_t = struct {
   2564 	Fquot int64
   2565 	Frem  int64
   2566 }
   2567 
   2568 type lldiv_t = struct {
   2569 	Fquot int64
   2570 	Frem  int64
   2571 }
   2572 
   2573 type malloc_type_id_t = uint64
   2574 
   2575 type dev_t = int32
   2576 
   2577 type mode_t = uint16
   2578 
   2579 type ptrdiff_t = int64
   2580 
   2581 type rsize_t = uint64
   2582 
   2583 type nullptr_t = uintptr
   2584 
   2585 type max_align_t = struct {
   2586 	F__clang_max_align_nonce1 int64
   2587 	F__clang_max_align_nonce2 float64
   2588 }
   2589 
   2590 type imaxdiv_t = struct {
   2591 	Fquot intmax_t
   2592 	Frem  intmax_t
   2593 }
   2594 
   2595 type WebPRGBABuffer = struct {
   2596 	Frgba   uintptr
   2597 	Fstride int32
   2598 	Fsize   size_t
   2599 }
   2600 
   2601 type WebPYUVABuffer = struct {
   2602 	Fy        uintptr
   2603 	Fu        uintptr
   2604 	Fv        uintptr
   2605 	Fa        uintptr
   2606 	Fy_stride int32
   2607 	Fu_stride int32
   2608 	Fv_stride int32
   2609 	Fa_stride int32
   2610 	Fy_size   size_t
   2611 	Fu_size   size_t
   2612 	Fv_size   size_t
   2613 	Fa_size   size_t
   2614 }
   2615 
   2616 type WebPDecBuffer = struct {
   2617 	Fcolorspace         WEBP_CSP_MODE1
   2618 	Fwidth              int32
   2619 	Fheight             int32
   2620 	Fis_external_memory int32
   2621 	Fu                  struct {
   2622 		FYUVA        [0]WebPYUVABuffer
   2623 		FRGBA        WebPRGBABuffer
   2624 		F__ccgo_pad2 [56]byte
   2625 	}
   2626 	Fpad            [4]uint32_t
   2627 	Fprivate_memory uintptr
   2628 }
   2629 
   2630 type WEBP_CSP_MODE = int32
   2631 
   2632 const MODE_RGB = 0
   2633 const MODE_RGBA = 1
   2634 const MODE_BGR = 2
   2635 const MODE_BGRA = 3
   2636 const MODE_ARGB = 4
   2637 const MODE_RGBA_4444 = 5
   2638 const MODE_RGB_565 = 6
   2639 const MODE_rgbA = 7
   2640 const MODE_bgrA = 8
   2641 const MODE_Argb = 9
   2642 const MODE_rgbA_4444 = 10
   2643 const MODE_YUV = 11
   2644 const MODE_YUVA = 12
   2645 const MODE_LAST = 13
   2646 
   2647 type WebPBitstreamFeatures = struct {
   2648 	Fwidth         int32
   2649 	Fheight        int32
   2650 	Fhas_alpha     int32
   2651 	Fhas_animation int32
   2652 	Fformat        int32
   2653 	Fpad           [5]uint32_t
   2654 }
   2655 
   2656 type WebPDecoderOptions = struct {
   2657 	Fbypass_filtering         int32
   2658 	Fno_fancy_upsampling      int32
   2659 	Fuse_cropping             int32
   2660 	Fcrop_left                int32
   2661 	Fcrop_top                 int32
   2662 	Fcrop_width               int32
   2663 	Fcrop_height              int32
   2664 	Fuse_scaling              int32
   2665 	Fscaled_width             int32
   2666 	Fscaled_height            int32
   2667 	Fuse_threads              int32
   2668 	Fdithering_strength       int32
   2669 	Fflip                     int32
   2670 	Falpha_dithering_strength int32
   2671 	Fpad                      [5]uint32_t
   2672 }
   2673 
   2674 type WebPDecoderConfig = struct {
   2675 	Finput   WebPBitstreamFeatures
   2676 	Foutput  WebPDecBuffer
   2677 	Foptions WebPDecoderOptions
   2678 }
   2679 
   2680 type WEBP_CSP_MODE1 = int32
   2681 
   2682 type VP8StatusCode1 = int32
   2683 
   2684 type VP8StatusCode = int32
   2685 
   2686 const VP8_STATUS_OK = 0
   2687 const VP8_STATUS_OUT_OF_MEMORY = 1
   2688 const VP8_STATUS_INVALID_PARAM = 2
   2689 const VP8_STATUS_BITSTREAM_ERROR = 3
   2690 const VP8_STATUS_UNSUPPORTED_FEATURE = 4
   2691 const VP8_STATUS_SUSPENDED = 5
   2692 const VP8_STATUS_USER_ABORT = 6
   2693 const VP8_STATUS_NOT_ENOUGH_DATA = 7
   2694 
   2695 type VP8Io = struct {
   2696 	Fwidth            int32
   2697 	Fheight           int32
   2698 	Fmb_y             int32
   2699 	Fmb_w             int32
   2700 	Fmb_h             int32
   2701 	Fy                uintptr
   2702 	Fu                uintptr
   2703 	Fv                uintptr
   2704 	Fy_stride         int32
   2705 	Fuv_stride        int32
   2706 	Fopaque           uintptr
   2707 	Fput              VP8IoPutHook
   2708 	Fsetup            VP8IoSetupHook
   2709 	Fteardown         VP8IoTeardownHook
   2710 	Ffancy_upsampling int32
   2711 	Fdata_size        size_t
   2712 	Fdata             uintptr
   2713 	Fbypass_filtering int32
   2714 	Fuse_cropping     int32
   2715 	Fcrop_left        int32
   2716 	Fcrop_right       int32
   2717 	Fcrop_top         int32
   2718 	Fcrop_bottom      int32
   2719 	Fuse_scaling      int32
   2720 	Fscaled_width     int32
   2721 	Fscaled_height    int32
   2722 	Fa                uintptr
   2723 }
   2724 
   2725 type VP8IoPutHook = uintptr
   2726 
   2727 type VP8IoSetupHook = uintptr
   2728 
   2729 type VP8IoTeardownHook = uintptr
   2730 
   2731 type VP8Decoder = struct {
   2732 	Fstatus              VP8StatusCode1
   2733 	Fready               int32
   2734 	Ferror_msg           uintptr
   2735 	Fbr                  VP8BitReader
   2736 	Fincremental         int32
   2737 	Ffrm_hdr             VP8FrameHeader
   2738 	Fpic_hdr             VP8PictureHeader
   2739 	Ffilter_hdr          VP8FilterHeader
   2740 	Fsegment_hdr         VP8SegmentHeader
   2741 	Fworker              WebPWorker
   2742 	Fmt_method           int32
   2743 	Fcache_id            int32
   2744 	Fnum_caches          int32
   2745 	Fthread_ctx          VP8ThreadContext
   2746 	Fmb_w                int32
   2747 	Fmb_h                int32
   2748 	Ftl_mb_x             int32
   2749 	Ftl_mb_y             int32
   2750 	Fbr_mb_x             int32
   2751 	Fbr_mb_y             int32
   2752 	Fnum_parts_minus_one uint32_t
   2753 	Fparts               [8]VP8BitReader
   2754 	Fdither              int32
   2755 	Fdithering_rg        VP8Random
   2756 	Fdqm                 [4]VP8QuantMatrix
   2757 	Fproba               VP8Proba
   2758 	Fuse_skip_proba      int32
   2759 	Fskip_p              uint8_t
   2760 	Fintra_t             uintptr
   2761 	Fintra_l             [4]uint8_t
   2762 	Fyuv_t               uintptr
   2763 	Fmb_info             uintptr
   2764 	Ff_info              uintptr
   2765 	Fyuv_b               uintptr
   2766 	Fcache_y             uintptr
   2767 	Fcache_u             uintptr
   2768 	Fcache_v             uintptr
   2769 	Fcache_y_stride      int32
   2770 	Fcache_uv_stride     int32
   2771 	Fmem                 uintptr
   2772 	Fmem_size            size_t
   2773 	Fmb_x                int32
   2774 	Fmb_y                int32
   2775 	Fmb_data             uintptr
   2776 	Ffilter_type         int32
   2777 	Ffstrengths          [4][2]VP8FInfo
   2778 	Falph_dec            uintptr
   2779 	Falpha_data          uintptr
   2780 	Falpha_data_size     size_t
   2781 	Fis_alpha_decoded    int32
   2782 	Falpha_plane_mem     uintptr
   2783 	Falpha_plane         uintptr
   2784 	Falpha_prev_line     uintptr
   2785 	Falpha_dithering     int32
   2786 }
   2787 
   2788 type rescaler_t = uint32
   2789 
   2790 type WebPRescaler = struct {
   2791 	Fx_expand     int32
   2792 	Fy_expand     int32
   2793 	Fnum_channels int32
   2794 	Ffx_scale     uint32_t
   2795 	Ffy_scale     uint32_t
   2796 	Ffxy_scale    uint32_t
   2797 	Fy_accum      int32
   2798 	Fy_add        int32
   2799 	Fy_sub        int32
   2800 	Fx_add        int32
   2801 	Fx_sub        int32
   2802 	Fsrc_width    int32
   2803 	Fsrc_height   int32
   2804 	Fdst_width    int32
   2805 	Fdst_height   int32
   2806 	Fsrc_y        int32
   2807 	Fdst_y        int32
   2808 	Fdst          uintptr
   2809 	Fdst_stride   int32
   2810 	Firow         uintptr
   2811 	Ffrow         uintptr
   2812 }
   2813 
   2814 type WebPDecParams = struct {
   2815 	Foutput         uintptr
   2816 	Ftmp_y          uintptr
   2817 	Ftmp_u          uintptr
   2818 	Ftmp_v          uintptr
   2819 	Flast_y         int32
   2820 	Foptions        uintptr
   2821 	Fscaler_y       uintptr
   2822 	Fscaler_u       uintptr
   2823 	Fscaler_v       uintptr
   2824 	Fscaler_a       uintptr
   2825 	Fmemory         uintptr
   2826 	Femit           OutputFunc
   2827 	Femit_alpha     OutputAlphaFunc
   2828 	Femit_alpha_row OutputRowFunc
   2829 }
   2830 
   2831 type OutputFunc = uintptr
   2832 
   2833 type OutputAlphaFunc = uintptr
   2834 
   2835 type OutputRowFunc = uintptr
   2836 
   2837 type WebPHeaderStructure = struct {
   2838 	Fdata            uintptr
   2839 	Fdata_size       size_t
   2840 	Fhave_all_data   int32
   2841 	Foffset          size_t
   2842 	Falpha_data      uintptr
   2843 	Falpha_data_size size_t
   2844 	Fcompressed_size size_t
   2845 	Friff_size       size_t
   2846 	Fis_lossless     int32
   2847 }
   2848 
   2849 type CPUFeature = int32
   2850 
   2851 const kSSE2 = 0
   2852 const kSSE3 = 1
   2853 const kSlowSSSE3 = 2
   2854 const kSSE4_1 = 3
   2855 const kAVX = 4
   2856 const kAVX2 = 5
   2857 const kNEON = 6
   2858 const kMIPS32 = 7
   2859 const kMIPSdspR2 = 8
   2860 const kMSA = 9
   2861 
   2862 type VP8CPUInfo = uintptr
   2863 
   2864 type VP8Idct = uintptr
   2865 
   2866 type VP8Fdct = uintptr
   2867 
   2868 type VP8WHT = uintptr
   2869 
   2870 type VP8IntraPreds = uintptr
   2871 
   2872 type VP8Intra4Preds = uintptr
   2873 
   2874 type VP8Metric = uintptr
   2875 
   2876 type VP8WMetric = uintptr
   2877 
   2878 type VP8MeanMetric = uintptr
   2879 
   2880 type VP8BlockCopy = uintptr
   2881 
   2882 type VP8QuantizeBlock = uintptr
   2883 
   2884 type VP8Quantize2Blocks = uintptr
   2885 
   2886 type VP8QuantizeBlockWHT = uintptr
   2887 
   2888 type VP8Histogram = struct {
   2889 	Fmax_value     int32
   2890 	Flast_non_zero int32
   2891 }
   2892 
   2893 type VP8CHisto = uintptr
   2894 
   2895 type VP8SetResidualCoeffsFunc = uintptr
   2896 
   2897 type VP8GetResidualCostFunc = uintptr
   2898 
   2899 type VP8DistoStats = struct {
   2900 	Fw   uint32_t
   2901 	Fxm  uint32_t
   2902 	Fym  uint32_t
   2903 	Fxxm uint32_t
   2904 	Fxym uint32_t
   2905 	Fyym uint32_t
   2906 }
   2907 
   2908 type VP8SSIMGetClippedFunc = uintptr
   2909 
   2910 type VP8SSIMGetFunc = uintptr
   2911 
   2912 type VP8AccumulateSSEFunc = uintptr
   2913 
   2914 type VP8DecIdct = uintptr
   2915 
   2916 type VP8DecIdct2 = uintptr
   2917 
   2918 type VP8PredFunc = uintptr
   2919 
   2920 type VP8SimpleFilterFunc = uintptr
   2921 
   2922 type VP8LumaFilterFunc = uintptr
   2923 
   2924 type VP8ChromaFilterFunc = uintptr
   2925 
   2926 type WebPUpsampleLinePairFunc = uintptr
   2927 
   2928 type WebPSamplerRowFunc = uintptr
   2929 
   2930 type WebPYUV444Converter = uintptr
   2931 
   2932 type WebPRescalerImportRowFunc = uintptr
   2933 
   2934 type WebPRescalerExportRowFunc = uintptr
   2935 
   2936 type WEBP_FILTER_TYPE = int32
   2937 
   2938 const WEBP_FILTER_NONE = 0
   2939 const WEBP_FILTER_HORIZONTAL = 1
   2940 const WEBP_FILTER_VERTICAL = 2
   2941 const WEBP_FILTER_GRADIENT = 3
   2942 const WEBP_FILTER_LAST = 4
   2943 const WEBP_FILTER_BEST = 5
   2944 const WEBP_FILTER_FAST = 6
   2945 
   2946 type WebPFilterFunc = uintptr
   2947 
   2948 type WebPUnfilterFunc = uintptr
   2949 
   2950 type VP8LDecoder = struct {
   2951 	Fstatus           VP8StatusCode1
   2952 	Fstate            VP8LDecodeState
   2953 	Fio               uintptr
   2954 	Foutput           uintptr
   2955 	Fpixels           uintptr
   2956 	Fargb_cache       uintptr
   2957 	Fbr               VP8LBitReader
   2958 	Fincremental      int32
   2959 	Fsaved_br         VP8LBitReader
   2960 	Fsaved_last_pixel int32
   2961 	Fwidth            int32
   2962 	Fheight           int32
   2963 	Flast_row         int32
   2964 	Flast_pixel       int32
   2965 	Flast_out_row     int32
   2966 	Fhdr              VP8LMetadata
   2967 	Fnext_transform   int32
   2968 	Ftransforms       [4]VP8LTransform
   2969 	Ftransforms_seen  uint32_t
   2970 	Frescaler_memory  uintptr
   2971 	Frescaler         uintptr
   2972 }
   2973 
   2974 const READ_DATA = 0
   2975 const READ_HDR = 1
   2976 const READ_DIM = 2
   2977 
   2978 type ALPHDecoder = struct {
   2979 	Fwidth          int32
   2980 	Fheight         int32
   2981 	Fmethod         int32
   2982 	Ffilter         WEBP_FILTER_TYPE
   2983 	Fpre_processing int32
   2984 	Fvp8l_dec       uintptr
   2985 	Fio             VP8Io
   2986 	Fuse_8b_decode  int32
   2987 	Foutput         uintptr
   2988 	Fprev_line      uintptr
   2989 }
   2990 
   2991 type errno_t = int32
   2992 
   2993 type ssize_t = int64
   2994 
   2995 const B_DC_PRED = 0
   2996 const B_TM_PRED = 1
   2997 const B_VE_PRED = 2
   2998 const B_HE_PRED = 3
   2999 const B_RD_PRED = 4
   3000 const B_VR_PRED = 5
   3001 const B_LD_PRED = 6
   3002 const B_VL_PRED = 7
   3003 const B_HD_PRED = 8
   3004 const B_HU_PRED = 9
   3005 const NUM_BMODES = 10
   3006 const DC_PRED = 0
   3007 const V_PRED = 2
   3008 const H_PRED = 3
   3009 const TM_PRED = 1
   3010 const B_PRED = 10
   3011 const NUM_PRED_MODES = 4
   3012 const B_DC_PRED_NOTOP = 4
   3013 const B_DC_PRED_NOLEFT = 5
   3014 const B_DC_PRED_NOTOPLEFT = 6
   3015 const NUM_B_DC_MODES = 7
   3016 const MB_FEATURE_TREE_PROBS = 3
   3017 const NUM_MB_SEGMENTS = 4
   3018 const NUM_REF_LF_DELTAS = 4
   3019 const NUM_MODE_LF_DELTAS = 4
   3020 const MAX_NUM_PARTITIONS = 8
   3021 const NUM_TYPES = 4
   3022 const NUM_BANDS = 8
   3023 const NUM_CTX = 3
   3024 const NUM_PROBAS = 11
   3025 
   3026 type bit_t = uint64
   3027 
   3028 type range_t = uint32
   3029 
   3030 type VP8BitReader = struct {
   3031 	Fvalue   bit_t
   3032 	Frange1  range_t
   3033 	Fbits    int32
   3034 	Fbuf     uintptr
   3035 	Fbuf_end uintptr
   3036 	Fbuf_max uintptr
   3037 	Feof     int32
   3038 }
   3039 
   3040 type vp8l_val_t = uint64
   3041 
   3042 type VP8LBitReader = struct {
   3043 	Fval     vp8l_val_t
   3044 	Fbuf     uintptr
   3045 	Flen1    size_t
   3046 	Fpos     size_t
   3047 	Fbit_pos int32
   3048 	Feos     int32
   3049 }
   3050 
   3051 type VP8LColorCache = struct {
   3052 	Fcolors     uintptr
   3053 	Fhash_shift int32
   3054 	Fhash_bits  int32
   3055 }
   3056 
   3057 var kHashMul = uint32(0x1e35a7bd)
   3058 
   3059 type VP8LImageTransformType = int32
   3060 
   3061 const PREDICTOR_TRANSFORM = 0
   3062 const CROSS_COLOR_TRANSFORM = 1
   3063 const SUBTRACT_GREEN_TRANSFORM = 2
   3064 const COLOR_INDEXING_TRANSFORM = 3
   3065 
   3066 type HuffmanCode = struct {
   3067 	Fbits  uint8_t
   3068 	Fvalue uint16_t
   3069 }
   3070 
   3071 type HuffmanCode32 = struct {
   3072 	Fbits  int32
   3073 	Fvalue uint32_t
   3074 }
   3075 
   3076 type HuffmanTablesSegment = struct {
   3077 	Fstart      uintptr
   3078 	Fcurr_table uintptr
   3079 	Fnext       uintptr
   3080 	Fsize       int32
   3081 }
   3082 
   3083 type HuffmanTables = struct {
   3084 	Froot         HuffmanTablesSegment
   3085 	Fcurr_segment uintptr
   3086 }
   3087 
   3088 type HTreeGroup = struct {
   3089 	Fhtrees             [5]uintptr
   3090 	Fis_trivial_literal int32
   3091 	Fliteral_arb        uint32_t
   3092 	Fis_trivial_code    int32
   3093 	Fuse_packed_table   int32
   3094 	Fpacked_table       [64]HuffmanCode32
   3095 }
   3096 
   3097 type VP8LDecodeState = int32
   3098 
   3099 type VP8LTransform = struct {
   3100 	Ftype1 VP8LImageTransformType
   3101 	Fbits  int32
   3102 	Fxsize int32
   3103 	Fysize int32
   3104 	Fdata  uintptr
   3105 }
   3106 
   3107 type VP8LMetadata = struct {
   3108 	Fcolor_cache_size       int32
   3109 	Fcolor_cache            VP8LColorCache
   3110 	Fsaved_color_cache      VP8LColorCache
   3111 	Fhuffman_mask           int32
   3112 	Fhuffman_subsample_bits int32
   3113 	Fhuffman_xsize          int32
   3114 	Fhuffman_image          uintptr
   3115 	Fnum_htree_groups       int32
   3116 	Fhtree_groups           uintptr
   3117 	Fhuffman_tables         HuffmanTables
   3118 }
   3119 
   3120 type VP8Random = struct {
   3121 	Findex1 int32
   3122 	Findex2 int32
   3123 	Ftab    [55]uint32_t
   3124 	Famp    int32
   3125 }
   3126 
   3127 type WebPWorkerStatus = int32
   3128 
   3129 const NOT_OK = 0
   3130 const OK = 1
   3131 const WORK = 2
   3132 
   3133 type WebPWorkerHook = uintptr
   3134 
   3135 type WebPWorker = struct {
   3136 	Fimpl      uintptr
   3137 	Fstatus    WebPWorkerStatus
   3138 	Fhook      WebPWorkerHook
   3139 	Fdata1     uintptr
   3140 	Fdata2     uintptr
   3141 	Fhad_error int32
   3142 }
   3143 
   3144 type WebPWorkerInterface = struct {
   3145 	FInit    uintptr
   3146 	FReset   uintptr
   3147 	FSync    uintptr
   3148 	FLaunch  uintptr
   3149 	FExecute uintptr
   3150 	FEnd     uintptr
   3151 }
   3152 
   3153 type VP8FrameHeader = struct {
   3154 	Fkey_frame        uint8_t
   3155 	Fprofile          uint8_t
   3156 	Fshow             uint8_t
   3157 	Fpartition_length uint32_t
   3158 }
   3159 
   3160 type VP8PictureHeader = struct {
   3161 	Fwidth      uint16_t
   3162 	Fheight     uint16_t
   3163 	Fxscale     uint8_t
   3164 	Fyscale     uint8_t
   3165 	Fcolorspace uint8_t
   3166 	Fclamp_type uint8_t
   3167 }
   3168 
   3169 type VP8SegmentHeader = struct {
   3170 	Fuse_segment     int32
   3171 	Fupdate_map      int32
   3172 	Fabsolute_delta  int32
   3173 	Fquantizer       [4]int8_t
   3174 	Ffilter_strength [4]int8_t
   3175 }
   3176 
   3177 type VP8ProbaArray = [11]uint8_t
   3178 
   3179 type VP8BandProbas = struct {
   3180 	Fprobas [3]VP8ProbaArray
   3181 }
   3182 
   3183 type VP8Proba = struct {
   3184 	Fsegments  [3]uint8_t
   3185 	Fbands     [4][8]VP8BandProbas
   3186 	Fbands_ptr [4][17]uintptr
   3187 }
   3188 
   3189 type VP8FilterHeader = struct {
   3190 	Fsimple        int32
   3191 	Flevel         int32
   3192 	Fsharpness     int32
   3193 	Fuse_lf_delta  int32
   3194 	Fref_lf_delta  [4]int32
   3195 	Fmode_lf_delta [4]int32
   3196 }
   3197 
   3198 type VP8FInfo = struct {
   3199 	Ff_limit    uint8_t
   3200 	Ff_ilevel   uint8_t
   3201 	Ff_inner    uint8_t
   3202 	Fhev_thresh uint8_t
   3203 }
   3204 
   3205 type VP8MB = struct {
   3206 	Fnz    uint8_t
   3207 	Fnz_dc uint8_t
   3208 }
   3209 
   3210 type quant_t = [2]int32
   3211 
   3212 type VP8QuantMatrix = struct {
   3213 	Fy1_mat   quant_t
   3214 	Fy2_mat   quant_t
   3215 	Fuv_mat   quant_t
   3216 	Fuv_quant int32
   3217 	Fdither   int32
   3218 }
   3219 
   3220 type VP8MBData = struct {
   3221 	Fcoeffs      [384]int16_t
   3222 	Fis_i4x4     uint8_t
   3223 	Fimodes      [16]uint8_t
   3224 	Fuvmode      uint8_t
   3225 	Fnon_zero_y  uint32_t
   3226 	Fnon_zero_uv uint32_t
   3227 	Fdither      uint8_t
   3228 	Fskip        uint8_t
   3229 	Fsegment     uint8_t
   3230 }
   3231 
   3232 type VP8ThreadContext = struct {
   3233 	Fid         int32
   3234 	Fmb_y       int32
   3235 	Ffilter_row int32
   3236 	Ff_info     uintptr
   3237 	Fmb_data    uintptr
   3238 	Fio         VP8Io
   3239 }
   3240 
   3241 type VP8TopSamples = struct {
   3242 	Fy [16]uint8_t
   3243 	Fu [8]uint8_t
   3244 	Fv [8]uint8_t
   3245 }
   3246 
   3247 //------------------------------------------------------------------------------
   3248 
   3249 // Copyright 2010 Google Inc. All Rights Reserved.
   3250 //
   3251 // Use of this source code is governed by a BSD-style license
   3252 // that can be found in the COPYING file in the root of the source
   3253 // tree. An additional intellectual property rights grant can be found
   3254 // in the file PATENTS. All contributing project authors may
   3255 // be found in the AUTHORS file in the root of the source tree.
   3256 // -----------------------------------------------------------------------------
   3257 //
   3258 //  Main decoding functions for WebP images.
   3259 //
   3260 // Author: Skal (pascal.massimino@gmail.com)
   3261 
   3262 // Copyright 2012 Google Inc. All Rights Reserved.
   3263 //
   3264 // Use of this source code is governed by a BSD-style license
   3265 // that can be found in the COPYING file in the root of the source
   3266 // tree. An additional intellectual property rights grant can be found
   3267 // in the file PATENTS. All contributing project authors may
   3268 // be found in the AUTHORS file in the root of the source tree.
   3269 // -----------------------------------------------------------------------------
   3270 //
   3271 //  Internal header for constants related to WebP file format.
   3272 //
   3273 // Author: Urvang (urvang@google.com)
   3274 
   3275 // Copyright 2010 Google Inc. All Rights Reserved.
   3276 //
   3277 // Use of this source code is governed by a BSD-style license
   3278 // that can be found in the COPYING file in the root of the source
   3279 // tree. An additional intellectual property rights grant can be found
   3280 // in the file PATENTS. All contributing project authors may
   3281 // be found in the AUTHORS file in the root of the source tree.
   3282 // -----------------------------------------------------------------------------
   3283 //
   3284 //  Common types + memory wrappers
   3285 //
   3286 // Author: Skal (pascal.massimino@gmail.com)
   3287 
   3288 //------------------------------------------------------------------------------
   3289 // ALPHDecoder object.
   3290 
   3291 // C documentation
   3292 //
   3293 //	// Allocates a new alpha decoder instance.
   3294 func ALPHNew(tls *libc.TLS) (r uintptr) {
   3295 	var dec uintptr
   3296 	_ = dec
   3297 	dec = WebPSafeCalloc(tls, uint64(1), uint64(216))
   3298 	return dec
   3299 }
   3300 
   3301 // C documentation
   3302 //
   3303 //	// Clears and deallocates an alpha decoder instance.
   3304 func ALPHDelete(tls *libc.TLS, dec uintptr) {
   3305 	if dec != libc.UintptrFromInt32(0) {
   3306 		VP8LDelete(tls, (*ALPHDecoder)(unsafe.Pointer(dec)).Fvp8l_dec)
   3307 		(*ALPHDecoder)(unsafe.Pointer(dec)).Fvp8l_dec = libc.UintptrFromInt32(0)
   3308 		WebPSafeFree(tls, dec)
   3309 	}
   3310 }
   3311 
   3312 //------------------------------------------------------------------------------
   3313 // Decoding.
   3314 
   3315 // C documentation
   3316 //
   3317 //	// Initialize alpha decoding by parsing the alpha header and decoding the image
   3318 //	// header for alpha data stored using lossless compression.
   3319 //	// Returns false in case of error in alpha header (data too short, invalid
   3320 //	// compression method or filter, error in lossless header data etc).
   3321 func ALPHInit(tls *libc.TLS, dec uintptr, data uintptr, data_size size_t, src_io uintptr, output uintptr) (r int32) {
   3322 	var alpha_data, io1 uintptr
   3323 	var alpha_data_size, alpha_decoded_size size_t
   3324 	var ok, rsrv, v1 int32
   3325 	_, _, _, _, _, _, _ = alpha_data, alpha_data_size, alpha_decoded_size, io1, ok, rsrv, v1
   3326 	ok = 0
   3327 	alpha_data = data + uintptr(ALPHA_HEADER_LEN)
   3328 	alpha_data_size = data_size - uint64(ALPHA_HEADER_LEN)
   3329 	io1 = dec + 32
   3330 	VP8FiltersInit(tls)
   3331 	(*ALPHDecoder)(unsafe.Pointer(dec)).Foutput = output
   3332 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fwidth = (*VP8Io)(unsafe.Pointer(src_io)).Fwidth
   3333 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fheight = (*VP8Io)(unsafe.Pointer(src_io)).Fheight
   3334 	if data_size <= uint64(ALPHA_HEADER_LEN) {
   3335 		return 0
   3336 	}
   3337 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> 0 & int32(0x03)
   3338 	(*ALPHDecoder)(unsafe.Pointer(dec)).Ffilter = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> libc.Int32FromInt32(2) & libc.Int32FromInt32(0x03)
   3339 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fpre_processing = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> int32(4) & int32(0x03)
   3340 	rsrv = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> int32(6) & int32(0x03)
   3341 	if (*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod < ALPHA_NO_COMPRESSION || (*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod > int32(ALPHA_LOSSLESS_COMPRESSION) || (*ALPHDecoder)(unsafe.Pointer(dec)).Ffilter >= int32(WEBP_FILTER_LAST) || (*ALPHDecoder)(unsafe.Pointer(dec)).Fpre_processing > int32(ALPHA_PREPROCESSED_LEVELS) || rsrv != 0 {
   3342 		return 0
   3343 	}
   3344 	// Copy the necessary parameters from src_io to io
   3345 	v1 = VP8InitIoInternal(tls, io1, int32(WEBP_DECODER_ABI_VERSION))
   3346 	goto _2
   3347 _2:
   3348 	if !(v1 != 0) {
   3349 		return 0
   3350 	}
   3351 	WebPInitCustomIo(tls, libc.UintptrFromInt32(0), io1)
   3352 	(*VP8Io)(unsafe.Pointer(io1)).Fopaque = dec
   3353 	(*VP8Io)(unsafe.Pointer(io1)).Fwidth = (*VP8Io)(unsafe.Pointer(src_io)).Fwidth
   3354 	(*VP8Io)(unsafe.Pointer(io1)).Fheight = (*VP8Io)(unsafe.Pointer(src_io)).Fheight
   3355 	(*VP8Io)(unsafe.Pointer(io1)).Fuse_cropping = (*VP8Io)(unsafe.Pointer(src_io)).Fuse_cropping
   3356 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_left = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_left
   3357 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_right = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_right
   3358 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_top = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_top
   3359 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_bottom = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_bottom
   3360 	// No need to copy the scaling parameters.
   3361 	if (*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod == ALPHA_NO_COMPRESSION {
   3362 		alpha_decoded_size = libc.Uint64FromInt32((*ALPHDecoder)(unsafe.Pointer(dec)).Fwidth * (*ALPHDecoder)(unsafe.Pointer(dec)).Fheight)
   3363 		ok = libc.BoolInt32(alpha_data_size >= alpha_decoded_size)
   3364 	} else {
   3365 		ok = VP8LDecodeAlphaHeader(tls, dec, alpha_data, alpha_data_size)
   3366 	}
   3367 	return ok
   3368 }
   3369 
   3370 // C documentation
   3371 //
   3372 //	// Decodes, unfilters and dequantizes *at least* 'num_rows' rows of alpha
   3373 //	// starting from row number 'row'. It assumes that rows up to (row - 1) have
   3374 //	// already been decoded.
   3375 //	// Returns false in case of bitstream error.
   3376 func ALPHDecode(tls *libc.TLS, dec uintptr, row int32, num_rows int32) (r int32) {
   3377 	var alph_dec, deltas, dst, prev_line uintptr
   3378 	var height, width, y int32
   3379 	_, _, _, _, _, _, _ = alph_dec, deltas, dst, height, prev_line, width, y
   3380 	alph_dec = (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec
   3381 	width = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
   3382 	height = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fio.Fcrop_bottom
   3383 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fmethod == ALPHA_NO_COMPRESSION {
   3384 		prev_line = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line
   3385 		deltas = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data + uintptr(ALPHA_HEADER_LEN) + uintptr(row*width)
   3386 		dst = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr(row*width)
   3387 		y = 0
   3388 		for {
   3389 			if !(y < num_rows) {
   3390 				break
   3391 			}
   3392 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPUnfilters[(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter]})))(tls, prev_line, deltas, dst, width)
   3393 			prev_line = dst
   3394 			dst = dst + uintptr(width)
   3395 			deltas = deltas + uintptr(width)
   3396 			goto _1
   3397 		_1:
   3398 			;
   3399 			y = y + 1
   3400 		}
   3401 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line = prev_line
   3402 	} else { // alph_dec->method == ALPHA_LOSSLESS_COMPRESSION
   3403 		if !(VP8LDecodeAlphaImageStream(tls, alph_dec, row+num_rows) != 0) {
   3404 			return 0
   3405 		}
   3406 	}
   3407 	if row+num_rows >= height {
   3408 		(*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded = int32(1)
   3409 	}
   3410 	return int32(1)
   3411 }
   3412 
   3413 func AllocateAlphaPlane(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   3414 	var alpha_size uint64_t
   3415 	var height, stride int32
   3416 	_, _, _ = alpha_size, height, stride
   3417 	stride = (*VP8Io)(unsafe.Pointer(io)).Fwidth
   3418 	height = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom
   3419 	alpha_size = libc.Uint64FromInt32(stride) * libc.Uint64FromInt32(height)
   3420 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem = WebPSafeMalloc(tls, alpha_size, uint64(1))
   3421 	if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem == libc.UintptrFromInt32(0) {
   3422 		return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts)
   3423 	}
   3424 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem
   3425 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line = libc.UintptrFromInt32(0)
   3426 	return int32(1)
   3427 }
   3428 
   3429 func WebPDeallocateAlphaMemory(tls *libc.TLS, dec uintptr) {
   3430 	WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem)
   3431 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem = libc.UintptrFromInt32(0)
   3432 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = libc.UintptrFromInt32(0)
   3433 	ALPHDelete(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)
   3434 	(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = libc.UintptrFromInt32(0)
   3435 }
   3436 
   3437 // ------------------------------------------------------------------------------
   3438 // Main entry point.
   3439 func VP8DecompressAlphaRows(tls *libc.TLS, dec uintptr, io uintptr, row int32, num_rows int32) (r uintptr) {
   3440 	var alpha, vp8l_dec uintptr
   3441 	var height, width, v1 int32
   3442 	_, _, _, _, _ = alpha, height, vp8l_dec, width, v1
   3443 	width = (*VP8Io)(unsafe.Pointer(io)).Fwidth
   3444 	height = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom
   3445 	if row < 0 || num_rows <= 0 || row+num_rows > height {
   3446 		return libc.UintptrFromInt32(0)
   3447 	}
   3448 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0) {
   3449 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec == libc.UintptrFromInt32(0) { // Initialize decoder.
   3450 			(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = ALPHNew(tls)
   3451 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec == libc.UintptrFromInt32(0) {
   3452 				VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts)
   3453 				return libc.UintptrFromInt32(0)
   3454 			}
   3455 			if !(AllocateAlphaPlane(tls, dec, io) != 0) {
   3456 				goto Error
   3457 			}
   3458 			if !(ALPHInit(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size, io, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane) != 0) {
   3459 				vp8l_dec = (*ALPHDecoder)(unsafe.Pointer((*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)).Fvp8l_dec
   3460 				if vp8l_dec == libc.UintptrFromInt32(0) {
   3461 					v1 = int32(VP8_STATUS_OUT_OF_MEMORY)
   3462 				} else {
   3463 					v1 = (*VP8LDecoder)(unsafe.Pointer(vp8l_dec)).Fstatus
   3464 				}
   3465 				VP8SetError(tls, dec, v1, __ccgo_ts)
   3466 				goto Error
   3467 			}
   3468 			// if we allowed use of alpha dithering, check whether it's needed at all
   3469 			if (*ALPHDecoder)(unsafe.Pointer((*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)).Fpre_processing != int32(ALPHA_PREPROCESSED_LEVELS) {
   3470 				(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = 0 // disable dithering
   3471 			} else {
   3472 				num_rows = height - row // decode everything in one pass
   3473 			}
   3474 		}
   3475 		if !(ALPHDecode(tls, dec, row, num_rows) != 0) {
   3476 			goto Error
   3477 		}
   3478 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0 { // finished?
   3479 			ALPHDelete(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)
   3480 			(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = libc.UintptrFromInt32(0)
   3481 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering > 0 {
   3482 				alpha = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_top*width) + uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   3483 				if !(WebPDequantizeLevels(tls, alpha, (*VP8Io)(unsafe.Pointer(io)).Fcrop_right-(*VP8Io)(unsafe.Pointer(io)).Fcrop_left, (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom-(*VP8Io)(unsafe.Pointer(io)).Fcrop_top, width, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering) != 0) {
   3484 					goto Error
   3485 				}
   3486 			}
   3487 		}
   3488 	}
   3489 	// Return a pointer to the current decoded row.
   3490 	return (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr(row*width)
   3491 	goto Error
   3492 Error:
   3493 	;
   3494 	WebPDeallocateAlphaMemory(tls, dec)
   3495 	return libc.UintptrFromInt32(0)
   3496 }
   3497 
   3498 var kHashMul1 = uint32(0x1e35a7bd)
   3499 
   3500 //------------------------------------------------------------------------------
   3501 
   3502 // Copyright 2010 Google Inc. All Rights Reserved.
   3503 //
   3504 // Use of this source code is governed by a BSD-style license
   3505 // that can be found in the COPYING file in the root of the source
   3506 // tree. An additional intellectual property rights grant can be found
   3507 // in the file PATENTS. All contributing project authors may
   3508 // be found in the AUTHORS file in the root of the source tree.
   3509 // -----------------------------------------------------------------------------
   3510 //
   3511 //  Main decoding functions for WebP images.
   3512 //
   3513 // Author: Skal (pascal.massimino@gmail.com)
   3514 
   3515 // Copyright 2010 Google Inc. All Rights Reserved.
   3516 //
   3517 // Use of this source code is governed by a BSD-style license
   3518 // that can be found in the COPYING file in the root of the source
   3519 // tree. An additional intellectual property rights grant can be found
   3520 // in the file PATENTS. All contributing project authors may
   3521 // be found in the AUTHORS file in the root of the source tree.
   3522 // -----------------------------------------------------------------------------
   3523 //
   3524 //  Common types + memory wrappers
   3525 //
   3526 // Author: Skal (pascal.massimino@gmail.com)
   3527 
   3528 //------------------------------------------------------------------------------
   3529 // WebPDecBuffer
   3530 
   3531 // C documentation
   3532 //
   3533 //	// Number of bytes per pixel for the different color-spaces.
   3534 var kModeBpp = [13]uint8_t{
   3535 	0:  uint8(3),
   3536 	1:  uint8(4),
   3537 	2:  uint8(3),
   3538 	3:  uint8(4),
   3539 	4:  uint8(4),
   3540 	5:  uint8(2),
   3541 	6:  uint8(2),
   3542 	7:  uint8(4),
   3543 	8:  uint8(4),
   3544 	9:  uint8(4),
   3545 	10: uint8(2),
   3546 	11: uint8(1),
   3547 	12: uint8(1),
   3548 }
   3549 
   3550 // C documentation
   3551 //
   3552 //	// Convert to an integer to handle both the unsigned/signed enum cases
   3553 //	// without the need for casting to remove type limit warnings.
   3554 func IsValidColorspace(tls *libc.TLS, webp_csp_mode int32) (r int32) {
   3555 	return libc.BoolInt32(webp_csp_mode >= int32(MODE_RGB) && webp_csp_mode < int32(MODE_LAST))
   3556 }
   3557 
   3558 // strictly speaking, the very last (or first, if flipped) row
   3559 // doesn't require padding.
   3560 
   3561 func CheckDecBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3562 	var a_size, size, u_size, v_size, y_size uint64_t
   3563 	var a_stride, height, ok, stride, u_stride, uv_height, uv_width, v_stride, width, y_stride, v1 int32
   3564 	var buf, buf1 uintptr
   3565 	var mode1 WEBP_CSP_MODE1
   3566 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_size, a_stride, buf, buf1, height, mode1, ok, size, stride, u_size, u_stride, uv_height, uv_width, v_size, v_stride, width, y_size, y_stride, v1
   3567 	ok = int32(1)
   3568 	mode1 = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace
   3569 	width = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth
   3570 	height = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight
   3571 	if !(IsValidColorspace(tls, mode1) != 0) {
   3572 		ok = 0
   3573 	} else {
   3574 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3575 		goto _2
   3576 	_2:
   3577 		if !(v1 != 0) { // YUV checks
   3578 			buf = buffer + 16
   3579 			uv_width = (width + int32(1)) / int32(2)
   3580 			uv_height = (height + int32(1)) / int32(2)
   3581 			y_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride)
   3582 			u_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride)
   3583 			v_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride)
   3584 			a_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   3585 			y_size = libc.Uint64FromInt32(y_stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)
   3586 			u_size = libc.Uint64FromInt32(u_stride)*libc.Uint64FromInt32(uv_height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(uv_width)
   3587 			v_size = libc.Uint64FromInt32(v_stride)*libc.Uint64FromInt32(uv_height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(uv_width)
   3588 			a_size = libc.Uint64FromInt32(a_stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)
   3589 			ok = ok & libc.BoolInt32(y_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_size)
   3590 			ok = ok & libc.BoolInt32(u_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_size)
   3591 			ok = ok & libc.BoolInt32(v_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_size)
   3592 			ok = ok & libc.BoolInt32(y_stride >= width)
   3593 			ok = ok & libc.BoolInt32(u_stride >= uv_width)
   3594 			ok = ok & libc.BoolInt32(v_stride >= uv_width)
   3595 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy != libc.UintptrFromInt32(0))
   3596 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu != libc.UintptrFromInt32(0))
   3597 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv != libc.UintptrFromInt32(0))
   3598 			if mode1 == int32(MODE_YUVA) {
   3599 				ok = ok & libc.BoolInt32(a_stride >= width)
   3600 				ok = ok & libc.BoolInt32(a_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_size)
   3601 				ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0))
   3602 			}
   3603 		} else { // RGB checks
   3604 			buf1 = buffer + 16
   3605 			stride = libc.Xabs(tls, (*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fstride)
   3606 			size = libc.Uint64FromInt32(stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)*uint64(kModeBpp[mode1])
   3607 			ok = ok & libc.BoolInt32(size <= (*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fsize)
   3608 			ok = ok & libc.BoolInt32(stride >= width*libc.Int32FromUint8(kModeBpp[mode1]))
   3609 			ok = ok & libc.BoolInt32((*WebPRGBABuffer)(unsafe.Pointer(buf1)).Frgba != libc.UintptrFromInt32(0))
   3610 		}
   3611 	}
   3612 	if ok != 0 {
   3613 		v1 = int32(VP8_STATUS_OK)
   3614 	} else {
   3615 		v1 = int32(VP8_STATUS_INVALID_PARAM)
   3616 	}
   3617 	return v1
   3618 }
   3619 
   3620 func AllocateBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3621 	var a_size, size, total_size, uv_size uint64_t
   3622 	var a_stride, h, stride, uv_stride, w, v1 int32
   3623 	var buf, buf1, output uintptr
   3624 	var mode1 WEBP_CSP_MODE1
   3625 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_size, a_stride, buf, buf1, h, mode1, output, size, stride, total_size, uv_size, uv_stride, w, v1
   3626 	w = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth
   3627 	h = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight
   3628 	mode1 = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace
   3629 	if w <= 0 || h <= 0 || !(IsValidColorspace(tls, mode1) != 0) {
   3630 		return int32(VP8_STATUS_INVALID_PARAM)
   3631 	}
   3632 	if (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fis_external_memory <= 0 && (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory == libc.UintptrFromInt32(0) {
   3633 		uv_stride = 0
   3634 		a_stride = 0
   3635 		uv_size = uint64(0)
   3636 		a_size = uint64(0)
   3637 		if libc.Uint64FromInt32(w)*uint64(kModeBpp[mode1]) >= libc.Uint64FromUint64(1)<<libc.Int32FromInt32(31) {
   3638 			return int32(VP8_STATUS_INVALID_PARAM)
   3639 		}
   3640 		stride = w * libc.Int32FromUint8(kModeBpp[mode1])
   3641 		size = libc.Uint64FromInt32(stride) * libc.Uint64FromInt32(h)
   3642 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3643 		goto _2
   3644 	_2:
   3645 		if !(v1 != 0) {
   3646 			uv_stride = (w + int32(1)) / int32(2)
   3647 			uv_size = libc.Uint64FromInt32(uv_stride) * libc.Uint64FromInt32((h+libc.Int32FromInt32(1))/libc.Int32FromInt32(2))
   3648 			if mode1 == int32(MODE_YUVA) {
   3649 				a_stride = w
   3650 				a_size = libc.Uint64FromInt32(a_stride) * libc.Uint64FromInt32(h)
   3651 			}
   3652 		}
   3653 		total_size = size + uint64(2)*uv_size + a_size
   3654 		output = WebPSafeMalloc(tls, total_size, uint64(1))
   3655 		if output == libc.UintptrFromInt32(0) {
   3656 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   3657 		}
   3658 		(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory = output
   3659 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3660 		goto _4
   3661 	_4:
   3662 		if !(v1 != 0) { // YUVA initialization
   3663 			buf = buffer + 16
   3664 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy = output
   3665 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride = stride
   3666 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_size = size
   3667 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu = output + uintptr(size)
   3668 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride = uv_stride
   3669 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_size = uv_size
   3670 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv = output + uintptr(size) + uintptr(uv_size)
   3671 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride = uv_stride
   3672 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_size = uv_size
   3673 			if mode1 == int32(MODE_YUVA) {
   3674 				(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa = output + uintptr(size) + uintptr(uint64(2)*uv_size)
   3675 			}
   3676 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_size = a_size
   3677 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride = a_stride
   3678 		} else { // RGBA initialization
   3679 			buf1 = buffer + 16
   3680 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Frgba = output
   3681 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fstride = stride
   3682 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fsize = size
   3683 		}
   3684 	}
   3685 	return CheckDecBuffer(tls, buffer)
   3686 }
   3687 
   3688 func WebPFlipBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3689 	var H int64_t
   3690 	var buf, buf1 uintptr
   3691 	var v1 int32
   3692 	_, _, _, _ = H, buf, buf1, v1
   3693 	if buffer == libc.UintptrFromInt32(0) {
   3694 		return int32(VP8_STATUS_INVALID_PARAM)
   3695 	}
   3696 	v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace < int32(MODE_YUV))
   3697 	goto _2
   3698 _2:
   3699 	if v1 != 0 {
   3700 		buf = buffer + 16
   3701 		**(**uintptr)(__ccgo_up(buf)) += uintptr(int64((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight-libc.Int32FromInt32(1)) * int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   3702 		(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride = -(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride
   3703 	} else {
   3704 		buf1 = buffer + 16
   3705 		H = int64((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight)
   3706 		**(**uintptr)(__ccgo_up(buf1)) += uintptr((H - int64(1)) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride))
   3707 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride
   3708 		**(**uintptr)(__ccgo_up(buf1 + 8)) += uintptr((H - int64(1)) >> int32(1) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride))
   3709 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride
   3710 		**(**uintptr)(__ccgo_up(buf1 + 16)) += uintptr((H - int64(1)) >> int32(1) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride))
   3711 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride
   3712 		if (*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa != libc.UintptrFromInt32(0) {
   3713 			**(**uintptr)(__ccgo_up(buf1 + 24)) += uintptr((H - int64(1)) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride))
   3714 			(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride
   3715 		}
   3716 	}
   3717 	return int32(VP8_STATUS_OK)
   3718 }
   3719 
   3720 func WebPAllocateDecBuffer(tls *libc.TLS, width int32, height int32, options uintptr, buffer uintptr) (r VP8StatusCode1) {
   3721 	bp := tls.Alloc(16)
   3722 	defer tls.Free(16)
   3723 	var ch, cw, x, y int32
   3724 	var status VP8StatusCode1
   3725 	var _ /* scaled_height at bp+4 */ int32
   3726 	var _ /* scaled_width at bp+0 */ int32
   3727 	_, _, _, _, _ = ch, cw, status, x, y
   3728 	if buffer == libc.UintptrFromInt32(0) || width <= 0 || height <= 0 {
   3729 		return int32(VP8_STATUS_INVALID_PARAM)
   3730 	}
   3731 	if options != libc.UintptrFromInt32(0) { // First, apply options if there is any.
   3732 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0 {
   3733 			cw = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width
   3734 			ch = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height
   3735 			x = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left & ^libc.Int32FromInt32(1)
   3736 			y = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top & ^libc.Int32FromInt32(1)
   3737 			if !(WebPCheckCropDimensions(tls, width, height, x, y, cw, ch) != 0) {
   3738 				return int32(VP8_STATUS_INVALID_PARAM) // out of frame boundary.
   3739 			}
   3740 			width = cw
   3741 			height = ch
   3742 		}
   3743 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0 {
   3744 			**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
   3745 			**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
   3746 			if !(WebPRescalerGetScaledDimensions(tls, width, height, bp, bp+4) != 0) {
   3747 				return int32(VP8_STATUS_INVALID_PARAM)
   3748 			}
   3749 			width = **(**int32)(__ccgo_up(bp))
   3750 			height = **(**int32)(__ccgo_up(bp + 4))
   3751 		}
   3752 	}
   3753 	(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth = width
   3754 	(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight = height
   3755 	// Then, allocate buffer for real.
   3756 	status = AllocateBuffer(tls, buffer)
   3757 	if status != int32(VP8_STATUS_OK) {
   3758 		return status
   3759 	}
   3760 	// Use the stride trick if vertical flip is needed.
   3761 	if options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fflip != 0 {
   3762 		status = WebPFlipBuffer(tls, buffer)
   3763 	}
   3764 	return status
   3765 }
   3766 
   3767 //------------------------------------------------------------------------------
   3768 // constructors / destructors
   3769 
   3770 func WebPInitDecBufferInternal(tls *libc.TLS, buffer uintptr, version int32) (r int32) {
   3771 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
   3772 		return 0 // version mismatch
   3773 	}
   3774 	if buffer == libc.UintptrFromInt32(0) {
   3775 		return 0
   3776 	}
   3777 	libc.X__builtin___memset_chk(tls, buffer, 0, uint64(120), ^__predefined_size_t(0))
   3778 	return int32(1)
   3779 }
   3780 
   3781 func WebPFreeDecBuffer(tls *libc.TLS, buffer uintptr) {
   3782 	if buffer != libc.UintptrFromInt32(0) {
   3783 		if (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fis_external_memory <= 0 {
   3784 			WebPSafeFree(tls, (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory)
   3785 		}
   3786 		(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory = libc.UintptrFromInt32(0)
   3787 	}
   3788 }
   3789 
   3790 func WebPCopyDecBuffer(tls *libc.TLS, src uintptr, dst uintptr) {
   3791 	if src != libc.UintptrFromInt32(0) && dst != libc.UintptrFromInt32(0) {
   3792 		**(**WebPDecBuffer)(__ccgo_up(dst)) = **(**WebPDecBuffer)(__ccgo_up(src))
   3793 		if (*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory != libc.UintptrFromInt32(0) {
   3794 			(*WebPDecBuffer)(unsafe.Pointer(dst)).Fis_external_memory = int32(1) // dst buffer doesn't own the memory.
   3795 			(*WebPDecBuffer)(unsafe.Pointer(dst)).Fprivate_memory = libc.UintptrFromInt32(0)
   3796 		}
   3797 	}
   3798 }
   3799 
   3800 // C documentation
   3801 //
   3802 //	// Copy and transfer ownership from src to dst (beware of parameter order!)
   3803 func WebPGrabDecBuffer(tls *libc.TLS, src uintptr, dst uintptr) {
   3804 	if src != libc.UintptrFromInt32(0) && dst != libc.UintptrFromInt32(0) {
   3805 		**(**WebPDecBuffer)(__ccgo_up(dst)) = **(**WebPDecBuffer)(__ccgo_up(src))
   3806 		if (*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory != libc.UintptrFromInt32(0) {
   3807 			(*WebPDecBuffer)(unsafe.Pointer(src)).Fis_external_memory = int32(1) // src relinquishes ownership
   3808 			(*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory = libc.UintptrFromInt32(0)
   3809 		}
   3810 	}
   3811 }
   3812 
   3813 func WebPCopyDecBufferPixels(tls *libc.TLS, src_buf uintptr, dst_buf uintptr) (r VP8StatusCode1) {
   3814 	var dst, dst1, src, src1 uintptr
   3815 	var v1, v4 int32
   3816 	var v3, v6 WEBP_CSP_MODE1
   3817 	var v9 bool
   3818 	_, _, _, _, _, _, _, _, _ = dst, dst1, src, src1, v1, v3, v4, v6, v9
   3819 	(*WebPDecBuffer)(unsafe.Pointer(dst_buf)).Fwidth = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth
   3820 	(*WebPDecBuffer)(unsafe.Pointer(dst_buf)).Fheight = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight
   3821 	if CheckDecBuffer(tls, dst_buf) != int32(VP8_STATUS_OK) {
   3822 		return int32(VP8_STATUS_INVALID_PARAM)
   3823 	}
   3824 	v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fcolorspace < int32(MODE_YUV))
   3825 	goto _2
   3826 _2:
   3827 	if v1 != 0 {
   3828 		src = src_buf + 16
   3829 		dst = dst_buf + 16
   3830 		WebPCopyPlane(tls, (*WebPRGBABuffer)(unsafe.Pointer(src)).Frgba, (*WebPRGBABuffer)(unsafe.Pointer(src)).Fstride, (*WebPRGBABuffer)(unsafe.Pointer(dst)).Frgba, (*WebPRGBABuffer)(unsafe.Pointer(dst)).Fstride, (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth*libc.Int32FromUint8(kModeBpp[(*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fcolorspace]), (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight)
   3831 	} else {
   3832 		src1 = src_buf + 16
   3833 		dst1 = dst_buf + 16
   3834 		WebPCopyPlane(tls, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fy, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fy_stride, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fy, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fy_stride, (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth, (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight)
   3835 		WebPCopyPlane(tls, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fu, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fu_stride, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fu, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fu_stride, ((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth+int32(1))/int32(2), ((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight+int32(1))/int32(2))
   3836 		WebPCopyPlane(tls, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fv, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fv_stride, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fv, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fv_stride, ((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth+int32(1))/int32(2), ((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight+int32(1))/int32(2))
   3837 		v3 = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fcolorspace
   3838 		if v9 = v3 == int32(MODE_RGBA) || v3 == int32(MODE_BGRA) || v3 == int32(MODE_ARGB) || v3 == int32(MODE_RGBA_4444) || v3 == int32(MODE_YUVA); !v9 {
   3839 			v6 = v3
   3840 			v4 = libc.BoolInt32(v6 == int32(MODE_rgbA) || v6 == int32(MODE_bgrA) || v6 == int32(MODE_Argb) || v6 == int32(MODE_rgbA_4444))
   3841 			goto _8
   3842 		_8:
   3843 		}
   3844 		v1 = libc.BoolInt32(v9 || v4 != 0)
   3845 		goto _5
   3846 	_5:
   3847 		if v1 != 0 {
   3848 			WebPCopyPlane(tls, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fa, (*WebPYUVABuffer)(unsafe.Pointer(src1)).Fa_stride, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fa, (*WebPYUVABuffer)(unsafe.Pointer(dst1)).Fa_stride, (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth, (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight)
   3849 		}
   3850 	}
   3851 	return int32(VP8_STATUS_OK)
   3852 }
   3853 
   3854 func WebPAvoidSlowMemory(tls *libc.TLS, output uintptr, features uintptr) (r int32) {
   3855 	var v1 WEBP_CSP_MODE1
   3856 	var v2 int32
   3857 	var v4 bool
   3858 	_, _, _ = v1, v2, v4
   3859 	if v4 = (*WebPDecBuffer)(unsafe.Pointer(output)).Fis_external_memory >= int32(2); v4 {
   3860 		v1 = (*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace
   3861 		v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
   3862 		goto _3
   3863 	_3:
   3864 	}
   3865 	return libc.BoolInt32(v4 && v2 != 0 && (features != libc.UintptrFromInt32(0) && (*WebPBitstreamFeatures)(unsafe.Pointer(features)).Fhas_alpha != 0))
   3866 }
   3867 
   3868 const DITHER_AMP_TAB_SIZE = 12
   3869 const MIN_DITHER_AMP = 4
   3870 
   3871 var kHashMul2 = uint32(0x1e35a7bd)
   3872 
   3873 //------------------------------------------------------------------------------
   3874 
   3875 // Copyright 2010 Google Inc. All Rights Reserved.
   3876 //
   3877 // Use of this source code is governed by a BSD-style license
   3878 // that can be found in the COPYING file in the root of the source
   3879 // tree. An additional intellectual property rights grant can be found
   3880 // in the file PATENTS. All contributing project authors may
   3881 // be found in the AUTHORS file in the root of the source tree.
   3882 // -----------------------------------------------------------------------------
   3883 //
   3884 //  Main decoding functions for WebP images.
   3885 //
   3886 // Author: Skal (pascal.massimino@gmail.com)
   3887 
   3888 // Copyright 2010 Google Inc. All Rights Reserved.
   3889 //
   3890 // Use of this source code is governed by a BSD-style license
   3891 // that can be found in the COPYING file in the root of the source
   3892 // tree. An additional intellectual property rights grant can be found
   3893 // in the file PATENTS. All contributing project authors may
   3894 // be found in the AUTHORS file in the root of the source tree.
   3895 // -----------------------------------------------------------------------------
   3896 //
   3897 //  Common types + memory wrappers
   3898 //
   3899 // Author: Skal (pascal.massimino@gmail.com)
   3900 
   3901 //------------------------------------------------------------------------------
   3902 // Main reconstruction function.
   3903 
   3904 var kScan = [16]uint16_t{
   3905 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3906 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3907 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3908 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3909 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3910 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3911 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3912 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3913 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3914 	10: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3915 	11: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3916 	12: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3917 	13: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3918 	14: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3919 	15: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3920 }
   3921 
   3922 func CheckMode(tls *libc.TLS, mb_x int32, mb_y int32, mode int32) (r int32) {
   3923 	var v1 int32
   3924 	_ = v1
   3925 	if mode == int32(B_DC_PRED) {
   3926 		if mb_x == 0 {
   3927 			if mb_y == 0 {
   3928 				v1 = int32(B_DC_PRED_NOTOPLEFT)
   3929 			} else {
   3930 				v1 = int32(B_DC_PRED_NOLEFT)
   3931 			}
   3932 			return v1
   3933 		} else {
   3934 			if mb_y == 0 {
   3935 				v1 = int32(B_DC_PRED_NOTOP)
   3936 			} else {
   3937 				v1 = int32(B_DC_PRED)
   3938 			}
   3939 			return v1
   3940 		}
   3941 	}
   3942 	return mode
   3943 }
   3944 
   3945 func Copy32b(tls *libc.TLS, dst uintptr, src uintptr) {
   3946 	libc.X__builtin___memcpy_chk(tls, dst, src, uint64(4), ^__predefined_size_t(0))
   3947 }
   3948 
   3949 func DoTransform(tls *libc.TLS, bits uint32_t, src uintptr, dst uintptr) {
   3950 	switch bits >> libc.Int32FromInt32(30) {
   3951 	case uint32(3):
   3952 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8Transform})))(tls, src, dst, 0)
   3953 	case uint32(2):
   3954 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformAC3})))(tls, src, dst)
   3955 	case uint32(1):
   3956 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, src, dst)
   3957 	default:
   3958 		break
   3959 	}
   3960 }
   3961 
   3962 func DoUVTransform(tls *libc.TLS, bits uint32_t, src uintptr, dst uintptr) {
   3963 	if bits&uint32(0xff) != 0 { // any non-zero coeff at all?
   3964 		if bits&uint32(0xaa) != 0 { // any non-zero AC coefficient?
   3965 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformUV})))(tls, src, dst) // note we don't use the AC3 variant for U/V
   3966 		} else {
   3967 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDCUV})))(tls, src, dst)
   3968 		}
   3969 	}
   3970 }
   3971 
   3972 func ReconstructRow(tls *libc.TLS, dec uintptr, ctx uintptr) {
   3973 	var bits, bits_uv, v8, v9 uint32_t
   3974 	var block, coeffs, dst, top_right, top_yuv, u_dst, u_out, v_dst, v_out, y_dst, y_out uintptr
   3975 	var cache_id, j, mb_x, mb_y, n, pred_func, pred_func1, uv_offset, y_offset int32
   3976 	var v3, v4 uint8_t
   3977 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bits, bits_uv, block, cache_id, coeffs, dst, j, mb_x, mb_y, n, pred_func, pred_func1, top_right, top_yuv, u_dst, u_out, uv_offset, v_dst, v_out, y_dst, y_offset, y_out, v3, v4, v8, v9
   3978 	mb_y = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y
   3979 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   3980 	y_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(1)+libc.Int32FromInt32(8))
   3981 	u_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(1)+libc.Int32FromInt32(8)+libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16)+libc.Int32FromInt32(BPS))
   3982 	v_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(1)+libc.Int32FromInt32(8)+libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16)+libc.Int32FromInt32(BPS)+libc.Int32FromInt32(16))
   3983 	// Initialize left-most block.
   3984 	j = 0
   3985 	for {
   3986 		if !(j < int32(16)) {
   3987 			break
   3988 		}
   3989 		**(**uint8_t)(__ccgo_up(y_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   3990 		goto _1
   3991 	_1:
   3992 		;
   3993 		j = j + 1
   3994 	}
   3995 	j = 0
   3996 	for {
   3997 		if !(j < int32(8)) {
   3998 			break
   3999 		}
   4000 		**(**uint8_t)(__ccgo_up(u_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   4001 		**(**uint8_t)(__ccgo_up(v_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   4002 		goto _2
   4003 	_2:
   4004 		;
   4005 		j = j + 1
   4006 	}
   4007 	// Init top-left sample on left column too.
   4008 	if mb_y > 0 {
   4009 		v4 = libc.Uint8FromInt32(129)
   4010 		**(**uint8_t)(__ccgo_up(v_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v4
   4011 		v3 = v4
   4012 		**(**uint8_t)(__ccgo_up(u_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v3
   4013 		**(**uint8_t)(__ccgo_up(y_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v3
   4014 	} else {
   4015 		// we only need to do this init once at block (0,0).
   4016 		// Afterward, it remains valid for the whole topmost row.
   4017 		libc.X__builtin___memset_chk(tls, y_dst-uintptr(BPS)-uintptr(1), int32(127), libc.Uint64FromInt32(libc.Int32FromInt32(16)+libc.Int32FromInt32(4)+libc.Int32FromInt32(1)), ^__predefined_size_t(0))
   4018 		libc.X__builtin___memset_chk(tls, u_dst-uintptr(BPS)-uintptr(1), int32(127), libc.Uint64FromInt32(libc.Int32FromInt32(8)+libc.Int32FromInt32(1)), ^__predefined_size_t(0))
   4019 		libc.X__builtin___memset_chk(tls, v_dst-uintptr(BPS)-uintptr(1), int32(127), libc.Uint64FromInt32(libc.Int32FromInt32(8)+libc.Int32FromInt32(1)), ^__predefined_size_t(0))
   4020 	}
   4021 	// Reconstruct one row.
   4022 	mb_x = 0
   4023 	for {
   4024 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
   4025 			break
   4026 		}
   4027 		block = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data + uintptr(mb_x)*800
   4028 		// Rotate in the left samples from previously decoded block. We move four
   4029 		// pixels at a time for alignment reason, and because of in-loop filter.
   4030 		if mb_x > 0 {
   4031 			j = -int32(1)
   4032 			for {
   4033 				if !(j < int32(16)) {
   4034 					break
   4035 				}
   4036 				Copy32b(tls, y_dst+uintptr(j*int32(BPS)-int32(4)), y_dst+uintptr(j*int32(BPS)+int32(12)))
   4037 				goto _6
   4038 			_6:
   4039 				;
   4040 				j = j + 1
   4041 			}
   4042 			j = -int32(1)
   4043 			for {
   4044 				if !(j < int32(8)) {
   4045 					break
   4046 				}
   4047 				Copy32b(tls, u_dst+uintptr(j*int32(BPS)-int32(4)), u_dst+uintptr(j*int32(BPS)+int32(4)))
   4048 				Copy32b(tls, v_dst+uintptr(j*int32(BPS)-int32(4)), v_dst+uintptr(j*int32(BPS)+int32(4)))
   4049 				goto _7
   4050 			_7:
   4051 				;
   4052 				j = j + 1
   4053 			}
   4054 		}
   4055 		// bring top samples into the cache
   4056 		top_yuv = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_t + uintptr(mb_x)*32
   4057 		coeffs = block
   4058 		bits = (*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y
   4059 		if mb_y > 0 {
   4060 			libc.X__builtin___memcpy_chk(tls, y_dst-uintptr(BPS), top_yuv, uint64(16), ^__predefined_size_t(0))
   4061 			libc.X__builtin___memcpy_chk(tls, u_dst-uintptr(BPS), top_yuv+16, uint64(8), ^__predefined_size_t(0))
   4062 			libc.X__builtin___memcpy_chk(tls, v_dst-uintptr(BPS), top_yuv+24, uint64(8), ^__predefined_size_t(0))
   4063 		}
   4064 		// predict and add residuals
   4065 		if (*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0 { // 4x4
   4066 			top_right = y_dst - libc.UintptrFromInt32(BPS) + libc.UintptrFromInt32(16)
   4067 			if mb_y > 0 {
   4068 				if mb_x >= (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w-int32(1) { // on rightmost border
   4069 					libc.X__builtin___memset_chk(tls, top_right, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_yuv + 15))), uint64(4), ^__predefined_size_t(0))
   4070 				} else {
   4071 					libc.X__builtin___memcpy_chk(tls, top_right, top_yuv+1*32, uint64(4), ^__predefined_size_t(0))
   4072 				}
   4073 			}
   4074 			// replicate the top-right pixels below
   4075 			v9 = **(**uint32_t)(__ccgo_up(top_right))
   4076 			**(**uint32_t)(__ccgo_up(top_right + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))*4)) = v9
   4077 			v8 = v9
   4078 			**(**uint32_t)(__ccgo_up(top_right + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))*4)) = v8
   4079 			**(**uint32_t)(__ccgo_up(top_right + 32*4)) = v8
   4080 			// predict and add residuals for all 4x4 blocks in turn.
   4081 			n = 0
   4082 			for {
   4083 				if !(n < int32(16)) {
   4084 					break
   4085 				}
   4086 				dst = y_dst + uintptr(kScan[n])
   4087 				(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredLuma4[**(**uint8_t)(__ccgo_up(block + 769 + uintptr(n)))]})))(tls, dst)
   4088 				DoTransform(tls, bits, coeffs+uintptr(n*int32(16))*2, dst)
   4089 				goto _10
   4090 			_10:
   4091 				;
   4092 				n = n + 1
   4093 				bits = bits << uint32(2)
   4094 			}
   4095 		} else { // 16x16
   4096 			pred_func = CheckMode(tls, mb_x, mb_y, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(block + 769))))
   4097 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredLuma16[pred_func]})))(tls, y_dst)
   4098 			if bits != uint32(0) {
   4099 				n = 0
   4100 				for {
   4101 					if !(n < int32(16)) {
   4102 						break
   4103 					}
   4104 					DoTransform(tls, bits, coeffs+uintptr(n*int32(16))*2, y_dst+uintptr(kScan[n]))
   4105 					goto _11
   4106 				_11:
   4107 					;
   4108 					n = n + 1
   4109 					bits = bits << uint32(2)
   4110 				}
   4111 			}
   4112 		}
   4113 		// Chroma
   4114 		bits_uv = (*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv
   4115 		pred_func1 = CheckMode(tls, mb_x, mb_y, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(block)).Fuvmode))
   4116 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredChroma8[pred_func1]})))(tls, u_dst)
   4117 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredChroma8[pred_func1]})))(tls, v_dst)
   4118 		DoUVTransform(tls, bits_uv>>0, coeffs+uintptr(libc.Int32FromInt32(16)*libc.Int32FromInt32(16))*2, u_dst)
   4119 		DoUVTransform(tls, bits_uv>>int32(8), coeffs+uintptr(libc.Int32FromInt32(20)*libc.Int32FromInt32(16))*2, v_dst)
   4120 		// stash away top samples for next block
   4121 		if mb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h-int32(1) {
   4122 			libc.X__builtin___memcpy_chk(tls, top_yuv, y_dst+uintptr(libc.Int32FromInt32(15)*libc.Int32FromInt32(BPS)), uint64(16), ^__predefined_size_t(0))
   4123 			libc.X__builtin___memcpy_chk(tls, top_yuv+16, u_dst+uintptr(libc.Int32FromInt32(7)*libc.Int32FromInt32(BPS)), uint64(8), ^__predefined_size_t(0))
   4124 			libc.X__builtin___memcpy_chk(tls, top_yuv+24, v_dst+uintptr(libc.Int32FromInt32(7)*libc.Int32FromInt32(BPS)), uint64(8), ^__predefined_size_t(0))
   4125 		}
   4126 		// Transfer reconstructed samples from yuv_b cache to final destination.
   4127 		y_offset = cache_id * int32(16) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4128 		uv_offset = cache_id * int32(8) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4129 		y_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(mb_x*int32(16)) + uintptr(y_offset)
   4130 		u_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(mb_x*int32(8)) + uintptr(uv_offset)
   4131 		v_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(mb_x*int32(8)) + uintptr(uv_offset)
   4132 		j = 0
   4133 		for {
   4134 			if !(j < int32(16)) {
   4135 				break
   4136 			}
   4137 			libc.X__builtin___memcpy_chk(tls, y_out+uintptr(j*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride), y_dst+uintptr(j*int32(BPS)), uint64(16), ^__predefined_size_t(0))
   4138 			goto _12
   4139 		_12:
   4140 			;
   4141 			j = j + 1
   4142 		}
   4143 		j = 0
   4144 		for {
   4145 			if !(j < int32(8)) {
   4146 				break
   4147 			}
   4148 			libc.X__builtin___memcpy_chk(tls, u_out+uintptr(j*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride), u_dst+uintptr(j*int32(BPS)), uint64(8), ^__predefined_size_t(0))
   4149 			libc.X__builtin___memcpy_chk(tls, v_out+uintptr(j*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride), v_dst+uintptr(j*int32(BPS)), uint64(8), ^__predefined_size_t(0))
   4150 			goto _13
   4151 		_13:
   4152 			;
   4153 			j = j + 1
   4154 		}
   4155 		goto _5
   4156 	_5:
   4157 		;
   4158 		mb_x = mb_x + 1
   4159 	}
   4160 }
   4161 
   4162 //------------------------------------------------------------------------------
   4163 // Filtering
   4164 
   4165 // C documentation
   4166 //
   4167 //	// kFilterExtraRows[] = How many extra lines are needed on the MB boundary
   4168 //	// for caching, given a filtering level.
   4169 //	// Simple filter:  up to 2 luma samples are read and 1 is written.
   4170 //	// Complex filter: up to 4 luma samples are read and 3 are written. Same for
   4171 //	//                 U/V, so it's 8 samples total (because of the 2x upsampling).
   4172 var kFilterExtraRows = [3]uint8_t{
   4173 	1: uint8(2),
   4174 	2: uint8(8),
   4175 }
   4176 
   4177 func DoFilter(tls *libc.TLS, dec uintptr, mb_x int32, mb_y int32) {
   4178 	var cache_id, hev_thresh, ilevel, limit, uv_bps, y_bps int32
   4179 	var ctx, f_info, u_dst, v_dst, y_dst uintptr
   4180 	_, _, _, _, _, _, _, _, _, _, _ = cache_id, ctx, f_info, hev_thresh, ilevel, limit, u_dst, uv_bps, v_dst, y_bps, y_dst
   4181 	ctx = dec + 216
   4182 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4183 	y_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4184 	f_info = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info + uintptr(mb_x)*4
   4185 	y_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(cache_id*int32(16)*y_bps) + uintptr(mb_x*int32(16))
   4186 	ilevel = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Ff_ilevel)
   4187 	limit = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Ff_limit)
   4188 	if limit == 0 {
   4189 		return
   4190 	}
   4191 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type == int32(1) { // simple
   4192 		if mb_x > 0 {
   4193 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16})))(tls, y_dst, y_bps, limit+int32(4))
   4194 		}
   4195 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4196 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16i})))(tls, y_dst, y_bps, limit)
   4197 		}
   4198 		if mb_y > 0 {
   4199 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16})))(tls, y_dst, y_bps, limit+int32(4))
   4200 		}
   4201 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4202 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16i})))(tls, y_dst, y_bps, limit)
   4203 		}
   4204 	} else { // complex
   4205 		uv_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4206 		u_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4207 		v_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4208 		hev_thresh = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Fhev_thresh)
   4209 		if mb_x > 0 {
   4210 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16})))(tls, y_dst, y_bps, limit+int32(4), ilevel, hev_thresh)
   4211 			(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter8})))(tls, u_dst, v_dst, uv_bps, limit+int32(4), ilevel, hev_thresh)
   4212 		}
   4213 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4214 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16i})))(tls, y_dst, y_bps, limit, ilevel, hev_thresh)
   4215 			(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter8i})))(tls, u_dst, v_dst, uv_bps, limit, ilevel, hev_thresh)
   4216 		}
   4217 		if mb_y > 0 {
   4218 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16})))(tls, y_dst, y_bps, limit+int32(4), ilevel, hev_thresh)
   4219 			(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter8})))(tls, u_dst, v_dst, uv_bps, limit+int32(4), ilevel, hev_thresh)
   4220 		}
   4221 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4222 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16i})))(tls, y_dst, y_bps, limit, ilevel, hev_thresh)
   4223 			(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter8i})))(tls, u_dst, v_dst, uv_bps, limit, ilevel, hev_thresh)
   4224 		}
   4225 	}
   4226 }
   4227 
   4228 // C documentation
   4229 //
   4230 //	// Filter the decoded macroblock row (if needed)
   4231 func FilterRow(tls *libc.TLS, dec uintptr) {
   4232 	var mb_x, mb_y int32
   4233 	_, _ = mb_x, mb_y
   4234 	mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_y
   4235 	mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x
   4236 	for {
   4237 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x) {
   4238 			break
   4239 		}
   4240 		DoFilter(tls, dec, mb_x, mb_y)
   4241 		goto _1
   4242 	_1:
   4243 		;
   4244 		mb_x = mb_x + 1
   4245 	}
   4246 }
   4247 
   4248 //------------------------------------------------------------------------------
   4249 // Precompute the filtering strength for each segment and each i4x4/i16x16 mode.
   4250 
   4251 func PrecomputeFilterStrengths(tls *libc.TLS, dec uintptr) {
   4252 	var base_level, i4x4, ilevel, level, s, v3, v4 int32
   4253 	var hdr, info uintptr
   4254 	_, _, _, _, _, _, _, _, _ = base_level, hdr, i4x4, ilevel, info, level, s, v3, v4
   4255 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4256 		hdr = dec + 84
   4257 		s = 0
   4258 		for {
   4259 			if !(s < int32(NUM_MB_SEGMENTS)) {
   4260 				break
   4261 			}
   4262 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fuse_segment != 0 {
   4263 				base_level = int32(**(**int8_t)(__ccgo_up(dec + 132 + 16 + uintptr(s))))
   4264 				if !((*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fabsolute_delta != 0) {
   4265 					base_level = base_level + (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel
   4266 				}
   4267 			} else {
   4268 				base_level = (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel
   4269 			}
   4270 			i4x4 = 0
   4271 			for {
   4272 				if !(i4x4 <= int32(1)) {
   4273 					break
   4274 				}
   4275 				info = dec + 2924 + uintptr(s)*8 + uintptr(i4x4)*4
   4276 				level = base_level
   4277 				if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta != 0 {
   4278 					level = level + **(**int32)(__ccgo_up(hdr + 16))
   4279 					if i4x4 != 0 {
   4280 						level = level + **(**int32)(__ccgo_up(hdr + 32))
   4281 					}
   4282 				}
   4283 				if level < 0 {
   4284 					v3 = 0
   4285 				} else {
   4286 					if level > int32(63) {
   4287 						v4 = int32(63)
   4288 					} else {
   4289 						v4 = level
   4290 					}
   4291 					v3 = v4
   4292 				}
   4293 				level = v3
   4294 				if level > 0 {
   4295 					ilevel = level
   4296 					if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness > 0 {
   4297 						if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness > int32(4) {
   4298 							ilevel = ilevel >> int32(2)
   4299 						} else {
   4300 							ilevel = ilevel >> int32(1)
   4301 						}
   4302 						if ilevel > int32(9)-(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness {
   4303 							ilevel = int32(9) - (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness
   4304 						}
   4305 					}
   4306 					if ilevel < int32(1) {
   4307 						ilevel = int32(1)
   4308 					}
   4309 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_ilevel = libc.Uint8FromInt32(ilevel)
   4310 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_limit = libc.Uint8FromInt32(int32(2)*level + ilevel)
   4311 					if level >= int32(40) {
   4312 						v3 = int32(2)
   4313 					} else {
   4314 						if level >= int32(15) {
   4315 							v4 = int32(1)
   4316 						} else {
   4317 							v4 = 0
   4318 						}
   4319 						v3 = v4
   4320 					}
   4321 					(*VP8FInfo)(unsafe.Pointer(info)).Fhev_thresh = libc.Uint8FromInt32(v3)
   4322 				} else {
   4323 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_limit = uint8(0) // no filtering
   4324 				}
   4325 				(*VP8FInfo)(unsafe.Pointer(info)).Ff_inner = libc.Uint8FromInt32(i4x4)
   4326 				goto _2
   4327 			_2:
   4328 				;
   4329 				i4x4 = i4x4 + 1
   4330 			}
   4331 			goto _1
   4332 		_1:
   4333 			;
   4334 			s = s + 1
   4335 		}
   4336 	}
   4337 }
   4338 
   4339 //------------------------------------------------------------------------------
   4340 // Dithering
   4341 
   4342 // minimal amp that will provide a non-zero dithering effect
   4343 
   4344 var kQuantToDitherAmp = [12]uint8_t{
   4345 	0:  uint8(8),
   4346 	1:  uint8(7),
   4347 	2:  uint8(6),
   4348 	3:  uint8(4),
   4349 	4:  uint8(4),
   4350 	5:  uint8(2),
   4351 	6:  uint8(2),
   4352 	7:  uint8(2),
   4353 	8:  uint8(1),
   4354 	9:  uint8(1),
   4355 	10: uint8(1),
   4356 	11: uint8(1),
   4357 }
   4358 
   4359 func VP8InitDithering(tls *libc.TLS, options uintptr, dec uintptr) {
   4360 	var all_amp, d, f, idx, max_amp, s, v1, v2, v4 int32
   4361 	var dqm uintptr
   4362 	_, _, _, _, _, _, _, _, _, _ = all_amp, d, dqm, f, idx, max_amp, s, v1, v2, v4
   4363 	if options != libc.UintptrFromInt32(0) {
   4364 		d = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fdithering_strength
   4365 		max_amp = libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX) - libc.Int32FromInt32(1)
   4366 		if d < 0 {
   4367 			v1 = 0
   4368 		} else {
   4369 			if d > int32(100) {
   4370 				v2 = max_amp
   4371 			} else {
   4372 				v2 = d * max_amp / int32(100)
   4373 			}
   4374 			v1 = v2
   4375 		}
   4376 		f = v1
   4377 		if f > 0 {
   4378 			all_amp = 0
   4379 			s = 0
   4380 			for {
   4381 				if !(s < int32(NUM_MB_SEGMENTS)) {
   4382 					break
   4383 				}
   4384 				dqm = dec + 1060 + uintptr(s)*32
   4385 				if (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant < int32(DITHER_AMP_TAB_SIZE) {
   4386 					if (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant < 0 {
   4387 						v4 = 0
   4388 					} else {
   4389 						v4 = (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant
   4390 					}
   4391 					idx = v4
   4392 					(*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fdither = f * libc.Int32FromUint8(kQuantToDitherAmp[idx]) >> int32(3)
   4393 				}
   4394 				all_amp = all_amp | (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fdither
   4395 				goto _3
   4396 			_3:
   4397 				;
   4398 				s = s + 1
   4399 			}
   4400 			if all_amp != 0 {
   4401 				VP8InitRandom(tls, dec+828, libc.Float32FromFloat32(1))
   4402 				(*VP8Decoder)(unsafe.Pointer(dec)).Fdither = int32(1)
   4403 			}
   4404 		}
   4405 		// potentially allow alpha dithering
   4406 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = (*WebPDecoderOptions)(unsafe.Pointer(options)).Falpha_dithering_strength
   4407 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering > int32(100) {
   4408 			(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = int32(100)
   4409 		} else {
   4410 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering < 0 {
   4411 				(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = 0
   4412 			}
   4413 		}
   4414 	}
   4415 }
   4416 
   4417 // C documentation
   4418 //
   4419 //	// Convert to range: [-2,2] for dither=50, [-4,4] for dither=100
   4420 func Dither8x8(tls *libc.TLS, rg1 uintptr, dst uintptr, bps int32, amp1 int32) {
   4421 	bp := tls.Alloc(64)
   4422 	defer tls.Free(64)
   4423 	var diff, i, v3, v4, v6, v8 int32
   4424 	var v2, v5, v7 uintptr
   4425 	var _ /* dither at bp+0 */ [64]uint8_t
   4426 	_, _, _, _, _, _, _, _, _ = diff, i, v2, v3, v4, v5, v6, v7, v8
   4427 	i = 0
   4428 	for {
   4429 		if !(i < libc.Int32FromInt32(8)*libc.Int32FromInt32(8)) {
   4430 			break
   4431 		}
   4432 		v2 = rg1
   4433 		v3 = libc.Int32FromInt32(VP8_DITHER_AMP_BITS) + libc.Int32FromInt32(1)
   4434 		diff = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(v2 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v2)).Findex1)*4)) - **(**uint32_t)(__ccgo_up(v2 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v2)).Findex2)*4)))
   4435 		if diff < libc.Int32FromInt32(0) {
   4436 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
   4437 		}
   4438 		**(**uint32_t)(__ccgo_up(v2 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v2)).Findex1)*4)) = libc.Uint32FromInt32(diff)
   4439 		v5 = v2
   4440 		*(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1
   4441 		v4 = *(*int32)(unsafe.Pointer(v5))
   4442 		if v4 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
   4443 			(*VP8Random)(unsafe.Pointer(v2)).Findex1 = 0
   4444 		}
   4445 		v7 = v2 + 4
   4446 		*(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1
   4447 		v6 = *(*int32)(unsafe.Pointer(v7))
   4448 		if v6 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
   4449 			(*VP8Random)(unsafe.Pointer(v2)).Findex2 = 0
   4450 		}
   4451 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v3)
   4452 		diff = diff * amp1 >> int32(VP8_RANDOM_DITHER_FIX)
   4453 		diff = diff + int32(1)<<(v3-int32(1))
   4454 		v8 = diff
   4455 		goto _9
   4456 	_9:
   4457 		(**(**[64]uint8_t)(__ccgo_up(bp)))[i] = libc.Uint8FromInt32(v8)
   4458 		goto _1
   4459 	_1:
   4460 		;
   4461 		i = i + 1
   4462 	}
   4463 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8DitherCombine8x8})))(tls, bp, dst, bps)
   4464 }
   4465 
   4466 func DitherRow(tls *libc.TLS, dec uintptr) {
   4467 	var cache_id, mb_x, uv_bps int32
   4468 	var ctx, data, u_dst, v_dst uintptr
   4469 	_, _, _, _, _, _, _ = cache_id, ctx, data, mb_x, u_dst, uv_bps, v_dst
   4470 	mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x
   4471 	for {
   4472 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x) {
   4473 			break
   4474 		}
   4475 		ctx = dec + 216
   4476 		data = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data + uintptr(mb_x)*800
   4477 		cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4478 		uv_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4479 		if libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither) >= int32(MIN_DITHER_AMP) {
   4480 			u_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4481 			v_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4482 			Dither8x8(tls, dec+828, u_dst, uv_bps, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither))
   4483 			Dither8x8(tls, dec+828, v_dst, uv_bps, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither))
   4484 		}
   4485 		goto _1
   4486 	_1:
   4487 		;
   4488 		mb_x = mb_x + 1
   4489 	}
   4490 }
   4491 
   4492 //------------------------------------------------------------------------------
   4493 // This function is called after a row of macroblocks is finished decoding.
   4494 // It also takes into account the following restrictions:
   4495 //  * In case of in-loop filtering, we must hold off sending some of the bottom
   4496 //    pixels as they are yet unfiltered. They will be when the next macroblock
   4497 //    row is decoded. Meanwhile, we must preserve them by rotating them in the
   4498 //    cache area. This doesn't hold for the very bottom row of the uncropped
   4499 //    picture of course.
   4500 //  * we must clip the remaining pixels against the cropping area. The VP8Io
   4501 //    struct must have the following fields set correctly before calling put():
   4502 
   4503 // C documentation
   4504 //
   4505 //	// Finalize and transmit a complete row. Return false in case of user-abort.
   4506 func FinishRow(tls *libc.TLS, arg1 uintptr, arg2 uintptr) (r int32) {
   4507 	var cache_id, delta_y, extra_y_rows, is_first_row, is_last_row, mb_y, ok, uv_offset, uvsize, y_end, y_offset, y_start, ysize int32
   4508 	var ctx, dec, io, udst, vdst, ydst uintptr
   4509 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cache_id, ctx, dec, delta_y, extra_y_rows, io, is_first_row, is_last_row, mb_y, ok, udst, uv_offset, uvsize, vdst, y_end, y_offset, y_start, ydst, ysize
   4510 	dec = arg1
   4511 	io = arg2
   4512 	ok = int32(1)
   4513 	ctx = dec + 216
   4514 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4515 	extra_y_rows = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4516 	ysize = extra_y_rows * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4517 	uvsize = extra_y_rows / int32(2) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4518 	y_offset = cache_id * int32(16) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4519 	uv_offset = cache_id * int32(8) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4520 	ydst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y - uintptr(ysize) + uintptr(y_offset)
   4521 	udst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u - uintptr(uvsize) + uintptr(uv_offset)
   4522 	vdst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v - uintptr(uvsize) + uintptr(uv_offset)
   4523 	mb_y = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y
   4524 	is_first_row = libc.BoolInt32(mb_y == libc.Int32FromInt32(0))
   4525 	is_last_row = libc.BoolInt32(mb_y >= (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y-libc.Int32FromInt32(1))
   4526 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4527 		ReconstructRow(tls, dec, ctx)
   4528 	}
   4529 	if (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row != 0 {
   4530 		FilterRow(tls, dec)
   4531 	}
   4532 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fdither != 0 {
   4533 		DitherRow(tls, dec)
   4534 	}
   4535 	if (*VP8Io)(unsafe.Pointer(io)).Fput != libc.UintptrFromInt32(0) {
   4536 		y_start = mb_y * int32(16)
   4537 		y_end = (mb_y + int32(1)) * int32(16)
   4538 		if !(is_first_row != 0) {
   4539 			y_start = y_start - extra_y_rows
   4540 			(*VP8Io)(unsafe.Pointer(io)).Fy = ydst
   4541 			(*VP8Io)(unsafe.Pointer(io)).Fu = udst
   4542 			(*VP8Io)(unsafe.Pointer(io)).Fv = vdst
   4543 		} else {
   4544 			(*VP8Io)(unsafe.Pointer(io)).Fy = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(y_offset)
   4545 			(*VP8Io)(unsafe.Pointer(io)).Fu = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(uv_offset)
   4546 			(*VP8Io)(unsafe.Pointer(io)).Fv = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(uv_offset)
   4547 		}
   4548 		if !(is_last_row != 0) {
   4549 			y_end = y_end - extra_y_rows
   4550 		}
   4551 		if y_end > (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
   4552 			y_end = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom // make sure we don't overflow on last row.
   4553 		}
   4554 		// If dec->alpha_data is not NULL, we have some alpha plane present.
   4555 		(*VP8Io)(unsafe.Pointer(io)).Fa = libc.UintptrFromInt32(0)
   4556 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) && y_start < y_end {
   4557 			(*VP8Io)(unsafe.Pointer(io)).Fa = VP8DecompressAlphaRows(tls, dec, io, y_start, y_end-y_start)
   4558 			if (*VP8Io)(unsafe.Pointer(io)).Fa == libc.UintptrFromInt32(0) {
   4559 				return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+37)
   4560 			}
   4561 		}
   4562 		if y_start < (*VP8Io)(unsafe.Pointer(io)).Fcrop_top {
   4563 			delta_y = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - y_start
   4564 			y_start = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
   4565 			**(**uintptr)(__ccgo_up(io + 24)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride * delta_y)
   4566 			**(**uintptr)(__ccgo_up(io + 32)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride * (delta_y >> libc.Int32FromInt32(1)))
   4567 			**(**uintptr)(__ccgo_up(io + 40)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride * (delta_y >> libc.Int32FromInt32(1)))
   4568 			if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   4569 				**(**uintptr)(__ccgo_up(io + 152)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth * delta_y)
   4570 			}
   4571 		}
   4572 		if y_start < y_end {
   4573 			**(**uintptr)(__ccgo_up(io + 24)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   4574 			**(**uintptr)(__ccgo_up(io + 32)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left >> int32(1))
   4575 			**(**uintptr)(__ccgo_up(io + 40)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left >> int32(1))
   4576 			if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   4577 				**(**uintptr)(__ccgo_up(io + 152)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   4578 			}
   4579 			(*VP8Io)(unsafe.Pointer(io)).Fmb_y = y_start - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
   4580 			(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fcrop_right - (*VP8Io)(unsafe.Pointer(io)).Fcrop_left
   4581 			(*VP8Io)(unsafe.Pointer(io)).Fmb_h = y_end - y_start
   4582 			ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*VP8Io)(unsafe.Pointer(io)).Fput})))(tls, io)
   4583 		}
   4584 	}
   4585 	// rotate top samples if needed
   4586 	if cache_id+int32(1) == (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches {
   4587 		if !(is_last_row != 0) {
   4588 			libc.X__builtin___memcpy_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y-uintptr(ysize), ydst+uintptr(int32(16)*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride), libc.Uint64FromInt32(ysize), ^__predefined_size_t(0))
   4589 			libc.X__builtin___memcpy_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u-uintptr(uvsize), udst+uintptr(int32(8)*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride), libc.Uint64FromInt32(uvsize), ^__predefined_size_t(0))
   4590 			libc.X__builtin___memcpy_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v-uintptr(uvsize), vdst+uintptr(int32(8)*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride), libc.Uint64FromInt32(uvsize), ^__predefined_size_t(0))
   4591 		}
   4592 	}
   4593 	return ok
   4594 }
   4595 
   4596 //------------------------------------------------------------------------------
   4597 
   4598 func VP8ProcessRow(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4599 	var ctx, tmp, tmp1, worker, v2 uintptr
   4600 	var filter_row, ok, v1 int32
   4601 	_, _, _, _, _, _, _, _ = ctx, filter_row, ok, tmp, tmp1, worker, v1, v2
   4602 	ok = int32(1)
   4603 	ctx = dec + 216
   4604 	filter_row = libc.BoolInt32((*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 && (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y >= (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y && (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y <= (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y)
   4605 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == 0 {
   4606 		// ctx->id and ctx->f_info are already set
   4607 		(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   4608 		(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row = filter_row
   4609 		ReconstructRow(tls, dec, ctx)
   4610 		ok = FinishRow(tls, dec, io)
   4611 	} else {
   4612 		worker = dec + 152
   4613 		// Finish previous job *before* updating context
   4614 		ok = ok & (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker)
   4615 		if ok != 0 { // spawn a new deblocking/output job
   4616 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fio = **(**VP8Io)(__ccgo_up(io))
   4617 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id
   4618 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   4619 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row = filter_row
   4620 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) { // swap macroblock data
   4621 				tmp = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data
   4622 				(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data
   4623 				(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data = tmp
   4624 			} else {
   4625 				// perform reconstruction directly in main thread
   4626 				ReconstructRow(tls, dec, ctx)
   4627 			}
   4628 			if filter_row != 0 { // swap filter info
   4629 				tmp1 = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info
   4630 				(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info
   4631 				(*VP8Decoder)(unsafe.Pointer(dec)).Ff_info = tmp1
   4632 			}
   4633 			// (reconstruct)+filter in parallel
   4634 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FLaunch})))(tls, worker)
   4635 			v2 = dec + 204
   4636 			*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
   4637 			v1 = *(*int32)(unsafe.Pointer(v2))
   4638 			if v1 == (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches {
   4639 				(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4640 			}
   4641 		}
   4642 	}
   4643 	return ok
   4644 }
   4645 
   4646 //------------------------------------------------------------------------------
   4647 // Finish setting up the decoding parameter once user's setup() is called.
   4648 
   4649 func VP8EnterCritical(tls *libc.TLS, dec uintptr, io uintptr) (r VP8StatusCode1) {
   4650 	var extra_pixels int32
   4651 	_ = extra_pixels
   4652 	// Call setup() first. This may trigger additional decoding features on 'io'.
   4653 	// Note: Afterward, we must call teardown() no matter what.
   4654 	if (*VP8Io)(unsafe.Pointer(io)).Fsetup != libc.UintptrFromInt32(0) && !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*VP8Io)(unsafe.Pointer(io)).Fsetup})))(tls, io) != 0) {
   4655 		VP8SetError(tls, dec, int32(VP8_STATUS_USER_ABORT), __ccgo_ts+66)
   4656 		return (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
   4657 	}
   4658 	// Disable filtering per user request
   4659 	if (*VP8Io)(unsafe.Pointer(io)).Fbypass_filtering != 0 {
   4660 		(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type = 0
   4661 	}
   4662 	// Define the area where we can skip in-loop filtering, in case of cropping.
   4663 	//
   4664 	// 'Simple' filter reads two luma samples outside of the macroblock
   4665 	// and filters one. It doesn't filter the chroma samples. Hence, we can
   4666 	// avoid doing the in-loop filtering before crop_top/crop_left position.
   4667 	// For the 'Complex' filter, 3 samples are read and up to 3 are filtered.
   4668 	// Means: there's a dependency chain that goes all the way up to the
   4669 	// top-left corner of the picture (MB #0). We must filter all the previous
   4670 	// macroblocks.
   4671 	extra_pixels = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4672 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type == int32(2) {
   4673 		// For complex filter, we need to preserve the dependency chain.
   4674 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = 0
   4675 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = 0
   4676 	} else {
   4677 		// For simple filter, we can filter only the cropped region.
   4678 		// We include 'extra_pixels' on the other side of the boundary, since
   4679 		// vertical or horizontal filtering of the previous macroblock can
   4680 		// modify some abutting pixels.
   4681 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_left - extra_pixels) >> int32(4)
   4682 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_top - extra_pixels) >> int32(4)
   4683 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x < 0 {
   4684 			(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = 0
   4685 		}
   4686 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y < 0 {
   4687 			(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = 0
   4688 		}
   4689 	}
   4690 	// We need some 'extra' pixels on the right/bottom.
   4691 	(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom + int32(15) + extra_pixels) >> int32(4)
   4692 	(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_right + int32(15) + extra_pixels) >> int32(4)
   4693 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x > (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w {
   4694 		(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w
   4695 	}
   4696 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y > (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h {
   4697 		(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h
   4698 	}
   4699 	PrecomputeFilterStrengths(tls, dec)
   4700 	return int32(VP8_STATUS_OK)
   4701 }
   4702 
   4703 func VP8ExitCritical(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4704 	var ok int32
   4705 	_ = ok
   4706 	ok = int32(1)
   4707 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4708 		ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152)
   4709 	}
   4710 	if (*VP8Io)(unsafe.Pointer(io)).Fteardown != libc.UintptrFromInt32(0) {
   4711 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*VP8Io)(unsafe.Pointer(io)).Fteardown})))(tls, io)
   4712 	}
   4713 	return ok
   4714 }
   4715 
   4716 //------------------------------------------------------------------------------
   4717 // For multi-threaded decoding we need to use 3 rows of 16 pixels as delay line.
   4718 //
   4719 // Reason is: the deblocking filter cannot deblock the bottom horizontal edges
   4720 // immediately, and needs to wait for first few rows of the next macroblock to
   4721 // be decoded. Hence, deblocking is lagging behind by 4 or 8 pixels (depending
   4722 // on strength).
   4723 // With two threads, the vertical positions of the rows being decoded are:
   4724 // Decode:  [ 0..15][16..31][32..47][48..63][64..79][...
   4725 // Deblock:         [ 0..11][12..27][28..43][44..59][...
   4726 // If we use two threads and two caches of 16 pixels, the sequence would be:
   4727 // Decode:  [ 0..15][16..31][ 0..15!!][16..31][ 0..15][...
   4728 // Deblock:         [ 0..11][12..27!!][-4..11][12..27][...
   4729 // The problem occurs during row [12..15!!] that both the decoding and
   4730 // deblocking threads are writing simultaneously.
   4731 // With 3 cache lines, one get a safe write pattern:
   4732 // Decode:  [ 0..15][16..31][32..47][ 0..15][16..31][32..47][0..
   4733 // Deblock:         [ 0..11][12..27][28..43][-4..11][12..27][28...
   4734 // Note that multi-threaded output _without_ deblocking can make use of two
   4735 // cache lines of 16 pixels only, since there's no lagging behind. The decoding
   4736 // and output process have non-concurrent writing:
   4737 // Decode:  [ 0..15][16..31][ 0..15][16..31][...
   4738 // io->put:         [ 0..15][16..31][ 0..15][...
   4739 
   4740 // C documentation
   4741 //
   4742 //	// Initialize multi/single-thread worker
   4743 func InitThreadContext(tls *libc.TLS, dec uintptr) (r int32) {
   4744 	var worker uintptr
   4745 	var v1 int32
   4746 	_, _ = worker, v1
   4747 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4748 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4749 		worker = dec + 152
   4750 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FReset})))(tls, worker) != 0) {
   4751 			return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts+85)
   4752 		}
   4753 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = dec
   4754 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = dec + 216 + 32
   4755 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(FinishRow)
   4756 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4757 			v1 = int32(3)
   4758 		} else {
   4759 			v1 = libc.Int32FromInt32(3) - libc.Int32FromInt32(1)
   4760 		}
   4761 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches = v1
   4762 	} else {
   4763 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches = int32(1)
   4764 	}
   4765 	return int32(1)
   4766 }
   4767 
   4768 func VP8GetThreadMethod(tls *libc.TLS, options uintptr, headers uintptr, width int32, height int32) (r int32) {
   4769 	if options == libc.UintptrFromInt32(0) || (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_threads == 0 {
   4770 		return 0
   4771 	}
   4772 	_ = headers
   4773 	_ = width
   4774 	_ = height
   4775 	return 0
   4776 }
   4777 
   4778 //------------------------------------------------------------------------------
   4779 // Memory setup
   4780 
   4781 func AllocateMemory(tls *libc.TLS, dec uintptr) (r int32) {
   4782 	var alpha_size, needed, v5 uint64_t
   4783 	var cache_height, cache_size, f_info_size, intra_pred_mode_size, mb_data_size, mb_info_size, top_size, yuv_size size_t
   4784 	var extra_rows, extra_uv, extra_y, mb_w, num_caches, v2, v3, v6 int32
   4785 	var mem, v8 uintptr
   4786 	var v1, v4 uint64
   4787 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_size, cache_height, cache_size, extra_rows, extra_uv, extra_y, f_info_size, intra_pred_mode_size, mb_data_size, mb_info_size, mb_w, mem, needed, num_caches, top_size, yuv_size, v1, v2, v3, v4, v5, v6, v8
   4788 	num_caches = (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches
   4789 	mb_w = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w
   4790 	// Note: we use 'size_t' when there's no overflow risk, uint64_t otherwise.
   4791 	intra_pred_mode_size = libc.Uint64FromInt32(int32(4)*mb_w) * uint64(1)
   4792 	top_size = uint64(32) * libc.Uint64FromInt32(mb_w)
   4793 	mb_info_size = libc.Uint64FromInt32(mb_w+libc.Int32FromInt32(1)) * uint64(2)
   4794 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4795 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4796 			v2 = int32(2)
   4797 		} else {
   4798 			v2 = int32(1)
   4799 		}
   4800 		v1 = libc.Uint64FromInt32(mb_w*v2) * uint64(4)
   4801 	} else {
   4802 		v1 = uint64(0)
   4803 	}
   4804 	f_info_size = v1
   4805 	yuv_size = libc.Uint64FromInt32(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(17)+libc.Int32FromInt32(BPS)*libc.Int32FromInt32(9)) * libc.Uint64FromInt64(1)
   4806 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4807 		v3 = int32(2)
   4808 	} else {
   4809 		v3 = int32(1)
   4810 	}
   4811 	mb_data_size = libc.Uint64FromInt32(v3*mb_w) * uint64(800)
   4812 	cache_height = libc.Uint64FromInt32((int32(16)*num_caches + libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])) * int32(3) / int32(2))
   4813 	cache_size = top_size * cache_height
   4814 	if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) {
   4815 		v4 = uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fpic_hdr.Fwidth) * uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fpic_hdr.Fheight)
   4816 	} else {
   4817 		v4 = 0
   4818 	}
   4819 	// alpha_size is the only one that scales as width x height.
   4820 	alpha_size = v4
   4821 	needed = intra_pred_mode_size + top_size + mb_info_size + f_info_size + yuv_size + mb_data_size + cache_size + alpha_size + uint64(WEBP_ALIGN_CST)
   4822 	v5 = needed
   4823 	v6 = libc.BoolInt32(v5 == v5)
   4824 	goto _7
   4825 _7:
   4826 	if !(v6 != 0) {
   4827 		return 0
   4828 	} // check for overflow
   4829 	if needed > (*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size {
   4830 		WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmem)
   4831 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = uint64(0)
   4832 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem = WebPSafeMalloc(tls, needed, uint64(1))
   4833 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fmem == libc.UintptrFromInt32(0) {
   4834 			return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts+115)
   4835 		}
   4836 		// down-cast is ok, thanks to WebPSafeMalloc() above.
   4837 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = needed
   4838 	}
   4839 	mem = (*VP8Decoder)(unsafe.Pointer(dec)).Fmem
   4840 	(*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t = mem
   4841 	mem = mem + uintptr(intra_pred_mode_size)
   4842 	(*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_t = mem
   4843 	mem = mem + uintptr(top_size)
   4844 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info = mem + uintptr(1)*2
   4845 	mem = mem + uintptr(mb_info_size)
   4846 	if f_info_size != 0 {
   4847 		v8 = mem
   4848 	} else {
   4849 		v8 = libc.UintptrFromInt32(0)
   4850 	}
   4851 	(*VP8Decoder)(unsafe.Pointer(dec)).Ff_info = v8
   4852 	mem = mem + uintptr(f_info_size)
   4853 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fid = 0
   4854 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Ff_info = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info
   4855 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 && (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4856 		// secondary cache line. The deblocking process need to make use of the
   4857 		// filtering strength from previous macroblock row, while the new ones
   4858 		// are being decoded in parallel. We'll just swap the pointers.
   4859 		(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Ff_info += uintptr(mb_w) * 4
   4860 	}
   4861 	mem = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   4862 	(*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b = mem
   4863 	mem = mem + uintptr(yuv_size)
   4864 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data = mem
   4865 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_data = mem
   4866 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4867 		(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_data += uintptr(mb_w) * 800
   4868 	}
   4869 	mem = mem + uintptr(mb_data_size)
   4870 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride = int32(16) * mb_w
   4871 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride = int32(8) * mb_w
   4872 	extra_rows = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4873 	extra_y = extra_rows * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4874 	extra_uv = extra_rows / int32(2) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4875 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y = mem + uintptr(extra_y)
   4876 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(int32(16)*num_caches*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride) + uintptr(extra_uv)
   4877 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(int32(8)*num_caches*(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride) + uintptr(extra_uv)
   4878 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4879 	mem = mem + uintptr(cache_size)
   4880 	// alpha plane
   4881 	if alpha_size != 0 {
   4882 		v8 = mem
   4883 	} else {
   4884 		v8 = libc.UintptrFromInt32(0)
   4885 	}
   4886 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = v8
   4887 	mem = mem + uintptr(alpha_size)
   4888 	// note: left/top-info is initialized once for all.
   4889 	libc.X__builtin___memset_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info-uintptr(1)*2, 0, mb_info_size, ^__predefined_size_t(0))
   4890 	VP8InitScanline(tls, dec) // initialize left too.
   4891 	// initialize top
   4892 	libc.X__builtin___memset_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t, int32(B_DC_PRED), intra_pred_mode_size, ^__predefined_size_t(0))
   4893 	return int32(1)
   4894 }
   4895 
   4896 func InitIo(tls *libc.TLS, dec uintptr, io uintptr) {
   4897 	// prepare 'io'
   4898 	(*VP8Io)(unsafe.Pointer(io)).Fmb_y = 0
   4899 	(*VP8Io)(unsafe.Pointer(io)).Fy = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y
   4900 	(*VP8Io)(unsafe.Pointer(io)).Fu = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u
   4901 	(*VP8Io)(unsafe.Pointer(io)).Fv = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v
   4902 	(*VP8Io)(unsafe.Pointer(io)).Fy_stride = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4903 	(*VP8Io)(unsafe.Pointer(io)).Fuv_stride = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4904 	(*VP8Io)(unsafe.Pointer(io)).Fa = libc.UintptrFromInt32(0)
   4905 }
   4906 
   4907 func VP8InitFrame(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4908 	if !(InitThreadContext(tls, dec) != 0) {
   4909 		return 0
   4910 	} // call first. Sets dec->num_caches.
   4911 	if !(AllocateMemory(tls, dec) != 0) {
   4912 		return 0
   4913 	}
   4914 	InitIo(tls, dec, io)
   4915 	VP8DspInit(tls) // Init critical function pointers and look-up tables.
   4916 	return int32(1)
   4917 }
   4918 
   4919 const CHUNK_SIZE = 4096
   4920 const MAX_MB_SIZE = 4096
   4921 
   4922 type WebPIDecoder = struct {
   4923 	Fstate        DecState
   4924 	Fparams       WebPDecParams
   4925 	Fis_lossless  int32
   4926 	Fdec          uintptr
   4927 	Fio           VP8Io
   4928 	Fmem          MemBuffer
   4929 	Foutput       WebPDecBuffer
   4930 	Ffinal_output uintptr
   4931 	Fchunk_size   size_t
   4932 	Flast_mb_y    int32
   4933 }
   4934 
   4935 const STATE_WEBP_HEADER = 0
   4936 const // All the data before that of the VP8/VP8L chunk.
   4937 STATE_VP8_HEADER = 1
   4938 const // The VP8 Frame header (within the VP8 chunk).
   4939 STATE_VP8_PARTS0 = 2
   4940 const STATE_VP8_DATA = 3
   4941 const STATE_VP8L_HEADER = 4
   4942 const STATE_VP8L_DATA = 5
   4943 const STATE_DONE = 6
   4944 const STATE_ERROR = 7
   4945 
   4946 var kHashMul3 = uint32(0x1e35a7bd)
   4947 
   4948 //------------------------------------------------------------------------------
   4949 
   4950 // Copyright 2010 Google Inc. All Rights Reserved.
   4951 //
   4952 // Use of this source code is governed by a BSD-style license
   4953 // that can be found in the COPYING file in the root of the source
   4954 // tree. An additional intellectual property rights grant can be found
   4955 // in the file PATENTS. All contributing project authors may
   4956 // be found in the AUTHORS file in the root of the source tree.
   4957 // -----------------------------------------------------------------------------
   4958 //
   4959 //  Main decoding functions for WebP images.
   4960 //
   4961 // Author: Skal (pascal.massimino@gmail.com)
   4962 
   4963 // Copyright 2012 Google Inc. All Rights Reserved.
   4964 //
   4965 // Use of this source code is governed by a BSD-style license
   4966 // that can be found in the COPYING file in the root of the source
   4967 // tree. An additional intellectual property rights grant can be found
   4968 // in the file PATENTS. All contributing project authors may
   4969 // be found in the AUTHORS file in the root of the source tree.
   4970 // -----------------------------------------------------------------------------
   4971 //
   4972 //  Internal header for constants related to WebP file format.
   4973 //
   4974 // Author: Urvang (urvang@google.com)
   4975 
   4976 // Copyright 2010 Google Inc. All Rights Reserved.
   4977 //
   4978 // Use of this source code is governed by a BSD-style license
   4979 // that can be found in the COPYING file in the root of the source
   4980 // tree. An additional intellectual property rights grant can be found
   4981 // in the file PATENTS. All contributing project authors may
   4982 // be found in the AUTHORS file in the root of the source tree.
   4983 // -----------------------------------------------------------------------------
   4984 //
   4985 //  Common types + memory wrappers
   4986 //
   4987 // Author: Skal (pascal.massimino@gmail.com)
   4988 
   4989 // In append mode, buffer allocations increase as multiples of this value.
   4990 // Needs to be a power of 2.
   4991 
   4992 //------------------------------------------------------------------------------
   4993 // Data structures for memory and states
   4994 
   4995 // C documentation
   4996 //
   4997 //	// Decoding states. State normally flows as:
   4998 //	// WEBP_HEADER->VP8_HEADER->VP8_PARTS0->VP8_DATA->DONE for a lossy image, and
   4999 //	// WEBP_HEADER->VP8L_HEADER->VP8L_DATA->DONE for a lossless image.
   5000 //	// If there is any error the decoder goes into state ERROR.
   5001 type DecState = int32
   5002 
   5003 // C documentation
   5004 //
   5005 //	// Operating state for the MemBuffer
   5006 type MemBufferMode = int32
   5007 
   5008 const MEM_MODE_NONE = 0
   5009 const MEM_MODE_APPEND = 1
   5010 const MEM_MODE_MAP = 2
   5011 
   5012 // C documentation
   5013 //
   5014 //	// storage for partition #0 and partial data (in a rolling fashion)
   5015 type MemBuffer = struct {
   5016 	Fmode       MemBufferMode
   5017 	Fstart      size_t
   5018 	Fend        size_t
   5019 	Fbuf_size   size_t
   5020 	Fbuf        uintptr
   5021 	Fpart0_size size_t
   5022 	Fpart0_buf  uintptr
   5023 }
   5024 
   5025 // C documentation
   5026 //
   5027 //	// MB context to restore in case VP8DecodeMB() fails
   5028 type MBContext = struct {
   5029 	Fleft     VP8MB
   5030 	Finfo     VP8MB
   5031 	Ftoken_br VP8BitReader
   5032 }
   5033 
   5034 //------------------------------------------------------------------------------
   5035 // MemBuffer: incoming data handling
   5036 
   5037 func MemDataSize(tls *libc.TLS, mem uintptr) (r size_t) {
   5038 	return (*MemBuffer)(unsafe.Pointer(mem)).Fend - (*MemBuffer)(unsafe.Pointer(mem)).Fstart
   5039 }
   5040 
   5041 // C documentation
   5042 //
   5043 //	// Check if we need to preserve the compressed alpha data, as it may not have
   5044 //	// been decoded yet.
   5045 func NeedCompressedAlpha(tls *libc.TLS, idec uintptr) (r int32) {
   5046 	var dec uintptr
   5047 	_ = dec
   5048 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_WEBP_HEADER) {
   5049 		// We haven't parsed the headers yet, so we don't know whether the image is
   5050 		// lossy or lossless. This also means that we haven't parsed the ALPH chunk.
   5051 		return 0
   5052 	}
   5053 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0 {
   5054 		return 0 // ALPH chunk is not present for lossless images.
   5055 	} else {
   5056 		dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5057 		// Must be true as idec->state != STATE_WEBP_HEADER.
   5058 		return libc.BoolInt32((*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) && !((*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0))
   5059 	}
   5060 	return r
   5061 }
   5062 
   5063 func DoRemap(tls *libc.TLS, idec uintptr, offset ptrdiff_t) {
   5064 	var alph_dec, alph_vp8l_dec, dec, dec1, last_start, mem, new_base uintptr
   5065 	var last_part, p uint32_t
   5066 	_, _, _, _, _, _, _, _, _ = alph_dec, alph_vp8l_dec, dec, dec1, last_part, last_start, mem, new_base, p
   5067 	mem = idec + 296
   5068 	new_base = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5069 	// note: for VP8, setting up idec->io is only really needed at the beginning
   5070 	// of the decoding, till partition #0 is complete.
   5071 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = new_base
   5072 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = MemDataSize(tls, mem)
   5073 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec != libc.UintptrFromInt32(0) {
   5074 		if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5075 			dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5076 			last_part = (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one
   5077 			if offset != 0 {
   5078 				p = uint32(0)
   5079 				for {
   5080 					if !(p <= last_part) {
   5081 						break
   5082 					}
   5083 					VP8RemapBitReader(tls, dec+440+uintptr(p)*48, offset)
   5084 					goto _1
   5085 				_1:
   5086 					;
   5087 					p = p + 1
   5088 				}
   5089 				// Remap partition #0 data pointer to new offset, but only in MAP
   5090 				// mode (in APPEND mode, partition #0 is copied into a fixed memory).
   5091 				if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_MAP) {
   5092 					VP8RemapBitReader(tls, dec+16, offset)
   5093 				}
   5094 			}
   5095 			last_start = (**(**VP8BitReader)(__ccgo_up(dec + 440 + uintptr(last_part)*48))).Fbuf
   5096 			// 'last_start' will be NULL when 'idec->state' is < STATE_VP8_PARTS0
   5097 			// and through a portion of that state (when there isn't enough data to
   5098 			// parse the partitions). The bitreader is only used meaningfully when
   5099 			// there is enough data to begin parsing partition 0.
   5100 			if last_start != libc.UintptrFromInt32(0) {
   5101 				VP8BitReaderSetBuffer(tls, dec+440+uintptr(last_part)*48, last_start, libc.Uint64FromInt64(int64((*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fend))-int64(last_start)))
   5102 			}
   5103 			if NeedCompressedAlpha(tls, idec) != 0 {
   5104 				alph_dec = (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec
   5105 				**(**uintptr)(__ccgo_up(dec + 2968)) += uintptr(offset)
   5106 				if alph_dec != libc.UintptrFromInt32(0) && (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec != libc.UintptrFromInt32(0) {
   5107 					if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fmethod == int32(ALPHA_LOSSLESS_COMPRESSION) {
   5108 						alph_vp8l_dec = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec
   5109 						VP8LBitReaderSetBuffer(tls, alph_vp8l_dec+40, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data+uintptr(ALPHA_HEADER_LEN), (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size-uint64(ALPHA_HEADER_LEN))
   5110 					} else { // alph_dec->method == ALPHA_NO_COMPRESSION
   5111 						// Nothing special to do in this case.
   5112 					}
   5113 				}
   5114 			}
   5115 		} else { // Resize lossless bitreader
   5116 			dec1 = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5117 			VP8LBitReaderSetBuffer(tls, dec1+40, new_base, MemDataSize(tls, mem))
   5118 		}
   5119 	}
   5120 }
   5121 
   5122 // C documentation
   5123 //
   5124 //	// Appends data to the end of MemBuffer->buf. It expands the allocated memory
   5125 //	// size if required and also updates VP8BitReader's if new memory is allocated.
   5126 func AppendToMemBuffer(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r int32) {
   5127 	var current_size, new_mem_start size_t
   5128 	var dec, mem, new_buf, old_base, old_start, v1, v2 uintptr
   5129 	var extra_size, new_size uint64_t
   5130 	var need_compressed_alpha int32
   5131 	_, _, _, _, _, _, _, _, _, _, _, _ = current_size, dec, extra_size, mem, need_compressed_alpha, new_buf, new_mem_start, new_size, old_base, old_start, v1, v2
   5132 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5133 	mem = idec + 296
   5134 	need_compressed_alpha = NeedCompressedAlpha(tls, idec)
   5135 	if (*MemBuffer)(unsafe.Pointer(mem)).Fbuf == libc.UintptrFromInt32(0) {
   5136 		v1 = libc.UintptrFromInt32(0)
   5137 	} else {
   5138 		v1 = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5139 	}
   5140 	old_start = v1
   5141 	if need_compressed_alpha != 0 {
   5142 		v2 = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data
   5143 	} else {
   5144 		v2 = old_start
   5145 	}
   5146 	old_base = v2
   5147 	if data_size > uint64(^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1)) {
   5148 		// security safeguard: trying to allocate more than what the format
   5149 		// allows for a chunk should be considered a smoke smell.
   5150 		return 0
   5151 	}
   5152 	if (*MemBuffer)(unsafe.Pointer(mem)).Fend+data_size > (*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size { // Need some free memory
   5153 		new_mem_start = libc.Uint64FromInt64(int64(old_start) - int64(old_base))
   5154 		current_size = MemDataSize(tls, mem) + new_mem_start
   5155 		new_size = current_size + data_size
   5156 		extra_size = (new_size + uint64(CHUNK_SIZE) - uint64(1)) & libc.Uint64FromInt32(^(libc.Int32FromInt32(CHUNK_SIZE) - libc.Int32FromInt32(1)))
   5157 		new_buf = WebPSafeMalloc(tls, extra_size, uint64(1))
   5158 		if new_buf == libc.UintptrFromInt32(0) {
   5159 			return 0
   5160 		}
   5161 		if old_base != libc.UintptrFromInt32(0) {
   5162 			libc.X__builtin___memcpy_chk(tls, new_buf, old_base, current_size, ^__predefined_size_t(0))
   5163 		}
   5164 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf)
   5165 		(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = new_buf
   5166 		(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = extra_size
   5167 		(*MemBuffer)(unsafe.Pointer(mem)).Fstart = new_mem_start
   5168 		(*MemBuffer)(unsafe.Pointer(mem)).Fend = current_size
   5169 	}
   5170 	libc.X__builtin___memcpy_chk(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fend), data, data_size, ^__predefined_size_t(0))
   5171 	**(**size_t)(__ccgo_up(mem + 16)) += data_size
   5172 	DoRemap(tls, idec, int64((*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart))-int64(old_start))
   5173 	return int32(1)
   5174 }
   5175 
   5176 func RemapMemBuffer(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r int32) {
   5177 	var mem, old_buf, old_start, v1 uintptr
   5178 	var v2 size_t
   5179 	_, _, _, _, _ = mem, old_buf, old_start, v1, v2
   5180 	mem = idec + 296
   5181 	old_buf = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf
   5182 	if old_buf == libc.UintptrFromInt32(0) {
   5183 		v1 = libc.UintptrFromInt32(0)
   5184 	} else {
   5185 		v1 = old_buf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5186 	}
   5187 	old_start = v1
   5188 	if data_size < (*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size {
   5189 		return 0
   5190 	} // can't remap to a shorter buffer!
   5191 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = data
   5192 	v2 = data_size
   5193 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = v2
   5194 	(*MemBuffer)(unsafe.Pointer(mem)).Fend = v2
   5195 	DoRemap(tls, idec, int64((*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart))-int64(old_start))
   5196 	return int32(1)
   5197 }
   5198 
   5199 func InitMemBuffer(tls *libc.TLS, mem uintptr) {
   5200 	(*MemBuffer)(unsafe.Pointer(mem)).Fmode = int32(MEM_MODE_NONE)
   5201 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = libc.UintptrFromInt32(0)
   5202 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = uint64(0)
   5203 	(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf = libc.UintptrFromInt32(0)
   5204 	(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_size = uint64(0)
   5205 }
   5206 
   5207 func ClearMemBuffer(tls *libc.TLS, mem uintptr) {
   5208 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_APPEND) {
   5209 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf)
   5210 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf)
   5211 	}
   5212 }
   5213 
   5214 func CheckMemBufferMode(tls *libc.TLS, mem uintptr, expected MemBufferMode) (r int32) {
   5215 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_NONE) {
   5216 		(*MemBuffer)(unsafe.Pointer(mem)).Fmode = expected // switch to the expected mode
   5217 	} else {
   5218 		if (*MemBuffer)(unsafe.Pointer(mem)).Fmode != expected {
   5219 			return 0 // we mixed the modes => error
   5220 		}
   5221 	}
   5222 	// mode is ok
   5223 	return int32(1)
   5224 }
   5225 
   5226 // C documentation
   5227 //
   5228 //	// To be called last.
   5229 func FinishDecoding(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5230 	var options, output uintptr
   5231 	var status, status1 VP8StatusCode1
   5232 	_, _, _, _ = options, output, status, status1
   5233 	options = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foptions
   5234 	output = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput
   5235 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_DONE)
   5236 	if options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fflip != 0 {
   5237 		status = WebPFlipBuffer(tls, output)
   5238 		if status != int32(VP8_STATUS_OK) {
   5239 			return status
   5240 		}
   5241 	}
   5242 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output != libc.UintptrFromInt32(0) {
   5243 		status1 = WebPCopyDecBufferPixels(tls, output, (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output) // do the slow-copy
   5244 		WebPFreeDecBuffer(tls, idec+352)
   5245 		if status1 != int32(VP8_STATUS_OK) {
   5246 			return status1
   5247 		}
   5248 		**(**WebPDecBuffer)(__ccgo_up(output)) = **(**WebPDecBuffer)(__ccgo_up((*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output))
   5249 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = libc.UintptrFromInt32(0)
   5250 	}
   5251 	return int32(VP8_STATUS_OK)
   5252 }
   5253 
   5254 //------------------------------------------------------------------------------
   5255 // Macroblock-decoding contexts
   5256 
   5257 func SaveContext(tls *libc.TLS, dec uintptr, token_br uintptr, context uintptr) {
   5258 	(*MBContext)(unsafe.Pointer(context)).Fleft = **(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr(-libc.Int32FromInt32(1))*2))
   5259 	(*MBContext)(unsafe.Pointer(context)).Finfo = **(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2))
   5260 	(*MBContext)(unsafe.Pointer(context)).Ftoken_br = **(**VP8BitReader)(__ccgo_up(token_br))
   5261 }
   5262 
   5263 func RestoreContext(tls *libc.TLS, context uintptr, dec uintptr, token_br uintptr) {
   5264 	**(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr(-libc.Int32FromInt32(1))*2)) = (*MBContext)(unsafe.Pointer(context)).Fleft
   5265 	**(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2)) = (*MBContext)(unsafe.Pointer(context)).Finfo
   5266 	**(**VP8BitReader)(__ccgo_up(token_br)) = (*MBContext)(unsafe.Pointer(context)).Ftoken_br
   5267 }
   5268 
   5269 //------------------------------------------------------------------------------
   5270 
   5271 func IDecError(tls *libc.TLS, idec uintptr, error1 VP8StatusCode1) (r VP8StatusCode1) {
   5272 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5273 		// Synchronize the thread, clean-up and check for errors.
   5274 		VP8ExitCritical(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec, idec+136)
   5275 	}
   5276 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_ERROR)
   5277 	return error1
   5278 }
   5279 
   5280 func ChangeState(tls *libc.TLS, idec uintptr, new_state DecState, consumed_bytes size_t) {
   5281 	var mem uintptr
   5282 	_ = mem
   5283 	mem = idec + 296
   5284 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = new_state
   5285 	**(**size_t)(__ccgo_up(mem + 8)) += consumed_bytes
   5286 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5287 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = MemDataSize(tls, mem)
   5288 }
   5289 
   5290 // C documentation
   5291 //
   5292 //	// Headers
   5293 func DecodeWebPHeaders(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5294 	bp := tls.Alloc(80)
   5295 	defer tls.Free(80)
   5296 	var curr_size size_t
   5297 	var data, dec, dec1, mem uintptr
   5298 	var status VP8StatusCode1
   5299 	var _ /* headers at bp+0 */ WebPHeaderStructure
   5300 	_, _, _, _, _, _ = curr_size, data, dec, dec1, mem, status
   5301 	mem = idec + 296
   5302 	data = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5303 	curr_size = MemDataSize(tls, mem)
   5304 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fdata = data
   5305 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fdata_size = curr_size
   5306 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fhave_all_data = 0
   5307 	status = WebPParseHeaders(tls, bp)
   5308 	if status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5309 		return int32(VP8_STATUS_SUSPENDED) // We haven't found a VP8 chunk yet.
   5310 	} else {
   5311 		if status != int32(VP8_STATUS_OK) {
   5312 			return IDecError(tls, idec, status)
   5313 		}
   5314 	}
   5315 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Fcompressed_size
   5316 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Fis_lossless
   5317 	if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5318 		dec = VP8New(tls)
   5319 		if dec == libc.UintptrFromInt32(0) {
   5320 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5321 		}
   5322 		(*VP8Decoder)(unsafe.Pointer(dec)).Fincremental = int32(1)
   5323 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fdec = dec
   5324 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Falpha_data
   5325 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Falpha_data_size
   5326 		ChangeState(tls, idec, int32(STATE_VP8_HEADER), (**(**WebPHeaderStructure)(__ccgo_up(bp))).Foffset)
   5327 	} else {
   5328 		dec1 = VP8LNew(tls)
   5329 		if dec1 == libc.UintptrFromInt32(0) {
   5330 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5331 		}
   5332 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fdec = dec1
   5333 		ChangeState(tls, idec, int32(STATE_VP8L_HEADER), (**(**WebPHeaderStructure)(__ccgo_up(bp))).Foffset)
   5334 	}
   5335 	return int32(VP8_STATUS_OK)
   5336 }
   5337 
   5338 func DecodeVP8FrameHeader(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5339 	bp := tls.Alloc(16)
   5340 	defer tls.Free(16)
   5341 	var bits uint32_t
   5342 	var curr_size size_t
   5343 	var data uintptr
   5344 	var _ /* height at bp+4 */ int32
   5345 	var _ /* width at bp+0 */ int32
   5346 	_, _, _ = bits, curr_size, data
   5347 	data = (*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fbuf + uintptr((*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fstart)
   5348 	curr_size = MemDataSize(tls, idec+296)
   5349 	if curr_size < uint64(VP8_FRAME_HEADER_SIZE) {
   5350 		// Not enough data bytes to extract VP8 Frame Header.
   5351 		return int32(VP8_STATUS_SUSPENDED)
   5352 	}
   5353 	if !(VP8GetInfo(tls, data, curr_size, (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size, bp, bp+4) != 0) {
   5354 		return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5355 	}
   5356 	bits = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 1)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 2)))<<int32(16))
   5357 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fpart0_size = uint64(bits>>libc.Int32FromInt32(5) + uint32(VP8_FRAME_HEADER_SIZE))
   5358 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = data
   5359 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = curr_size
   5360 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8_PARTS0)
   5361 	return int32(VP8_STATUS_OK)
   5362 }
   5363 
   5364 // C documentation
   5365 //
   5366 //	// Partition #0
   5367 func CopyParts0Data(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5368 	var br, dec, mem, part0_buf uintptr
   5369 	var part_size size_t
   5370 	_, _, _, _, _ = br, dec, mem, part0_buf, part_size
   5371 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5372 	br = dec + 16
   5373 	part_size = libc.Uint64FromInt64(int64((*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end) - int64((*VP8BitReader)(unsafe.Pointer(br)).Fbuf))
   5374 	mem = idec + 296
   5375 	// the following is a format limitation, no need for runtime check:
   5376 	if part_size == uint64(0) { // can't have zero-size partition #0
   5377 		return int32(VP8_STATUS_BITSTREAM_ERROR)
   5378 	}
   5379 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_APPEND) {
   5380 		// We copy and grab ownership of the partition #0 data.
   5381 		part0_buf = WebPSafeMalloc(tls, uint64(1), part_size)
   5382 		if part0_buf == libc.UintptrFromInt32(0) {
   5383 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5384 		}
   5385 		libc.X__builtin___memcpy_chk(tls, part0_buf, (*VP8BitReader)(unsafe.Pointer(br)).Fbuf, part_size, ^__predefined_size_t(0))
   5386 		(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf = part0_buf
   5387 		VP8BitReaderSetBuffer(tls, br, part0_buf, part_size)
   5388 	} else {
   5389 		// Else: just keep pointers to the partition #0's data in dec->br.
   5390 	}
   5391 	**(**size_t)(__ccgo_up(mem + 8)) += part_size
   5392 	return int32(VP8_STATUS_OK)
   5393 }
   5394 
   5395 func DecodePartition0(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5396 	var dec, io, output, params uintptr
   5397 	var status VP8StatusCode1
   5398 	_, _, _, _, _ = dec, io, output, params, status
   5399 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5400 	io = idec + 136
   5401 	params = idec + 8
   5402 	output = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
   5403 	// Wait till we have enough data for the whole partition #0
   5404 	if MemDataSize(tls, idec+296) < (*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fpart0_size {
   5405 		return int32(VP8_STATUS_SUSPENDED)
   5406 	}
   5407 	if !(VP8GetHeaders(tls, dec, io) != 0) {
   5408 		status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
   5409 		if status == int32(VP8_STATUS_SUSPENDED) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5410 			// treating NOT_ENOUGH_DATA as SUSPENDED state
   5411 			return int32(VP8_STATUS_SUSPENDED)
   5412 		}
   5413 		return IDecError(tls, idec, status)
   5414 	}
   5415 	// Allocate/Verify output buffer now
   5416 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = WebPAllocateDecBuffer(tls, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, output)
   5417 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5418 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5419 	}
   5420 	// This change must be done before calling VP8InitFrame()
   5421 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method = VP8GetThreadMethod(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, libc.UintptrFromInt32(0), (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fheight)
   5422 	VP8InitDithering(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, dec)
   5423 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = CopyParts0Data(tls, idec)
   5424 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5425 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5426 	}
   5427 	// Finish setting up the decoding parameters. Will call io->setup().
   5428 	if VP8EnterCritical(tls, dec, io) != int32(VP8_STATUS_OK) {
   5429 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5430 	}
   5431 	// Note: past this point, teardown() must always be called
   5432 	// in case of error.
   5433 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8_DATA)
   5434 	// Allocate memory and prepare everything.
   5435 	if !(VP8InitFrame(tls, dec, io) != 0) {
   5436 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5437 	}
   5438 	return int32(VP8_STATUS_OK)
   5439 }
   5440 
   5441 // C documentation
   5442 //
   5443 //	// Remaining partitions
   5444 func DecodeRemaining(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5445 	bp := tls.Alloc(64)
   5446 	defer tls.Free(64)
   5447 	var dec, io, token_br uintptr
   5448 	var _ /* context at bp+0 */ MBContext
   5449 	_, _, _ = dec, io, token_br
   5450 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5451 	io = idec + 136
   5452 	// Make sure partition #0 has been read before, to set dec to ready.
   5453 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fready != 0) {
   5454 		return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5455 	}
   5456 	for {
   5457 		if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h) {
   5458 			break
   5459 		}
   5460 		if (*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y != (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y {
   5461 			if !(VP8ParseIntraModeRow(tls, dec+16, dec) != 0) {
   5462 				// note: normally, error shouldn't occur since we already have the whole
   5463 				// partition0 available here in DecodeRemaining(). Reaching EOF while
   5464 				// reading intra modes really means a BITSTREAM_ERROR.
   5465 				return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5466 			}
   5467 			(*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   5468 		}
   5469 		for {
   5470 			if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
   5471 				break
   5472 			}
   5473 			token_br = dec + 440 + uintptr(libc.Uint32FromInt32((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y)&(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)*48
   5474 			SaveContext(tls, dec, token_br, bp)
   5475 			if !(VP8DecodeMB(tls, dec, token_br) != 0) {
   5476 				// We shouldn't fail when MAX_MB data was available
   5477 				if (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one == uint32(0) && MemDataSize(tls, idec+296) > uint64(MAX_MB_SIZE) {
   5478 					return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5479 				}
   5480 				// Synchronize the threads.
   5481 				if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   5482 					if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152) != 0) {
   5483 						return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5484 					}
   5485 				}
   5486 				RestoreContext(tls, bp, dec, token_br)
   5487 				return int32(VP8_STATUS_SUSPENDED)
   5488 			}
   5489 			// Release buffer only if there is only one partition
   5490 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one == uint32(0) {
   5491 				(*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fstart = libc.Uint64FromInt64(int64((*VP8BitReader)(unsafe.Pointer(token_br)).Fbuf) - int64((*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fbuf))
   5492 			}
   5493 			goto _2
   5494 		_2:
   5495 			;
   5496 			(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x + 1
   5497 		}
   5498 		VP8InitScanline(tls, dec) // Prepare for next scanline
   5499 		// Reconstruct, filter and emit the row.
   5500 		if !(VP8ProcessRow(tls, dec, io) != 0) {
   5501 			return IDecError(tls, idec, int32(VP8_STATUS_USER_ABORT))
   5502 		}
   5503 		goto _1
   5504 	_1:
   5505 		;
   5506 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y + 1
   5507 	}
   5508 	// Synchronize the thread and check for errors.
   5509 	if !(VP8ExitCritical(tls, dec, io) != 0) {
   5510 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_ERROR) // prevent re-entry in IDecError
   5511 		return IDecError(tls, idec, int32(VP8_STATUS_USER_ABORT))
   5512 	}
   5513 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
   5514 	return FinishDecoding(tls, idec)
   5515 }
   5516 
   5517 func ErrorStatusLossless(tls *libc.TLS, idec uintptr, status VP8StatusCode1) (r VP8StatusCode1) {
   5518 	if status == int32(VP8_STATUS_SUSPENDED) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5519 		return int32(VP8_STATUS_SUSPENDED)
   5520 	}
   5521 	return IDecError(tls, idec, status)
   5522 }
   5523 
   5524 func DecodeVP8LHeader(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5525 	var curr_size size_t
   5526 	var dec, io, output, params uintptr
   5527 	_, _, _, _, _ = curr_size, dec, io, output, params
   5528 	io = idec + 136
   5529 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5530 	params = idec + 8
   5531 	output = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
   5532 	curr_size = MemDataSize(tls, idec+296)
   5533 	// Wait until there's enough data for decoding header.
   5534 	if curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size>>libc.Int32FromInt32(3) {
   5535 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
   5536 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5537 	}
   5538 	if !(VP8LDecodeHeader(tls, dec, io) != 0) {
   5539 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_BITSTREAM_ERROR) && curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size {
   5540 			(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
   5541 		}
   5542 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5543 	}
   5544 	// Allocate/verify output buffer now.
   5545 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = WebPAllocateDecBuffer(tls, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, output)
   5546 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5547 		return IDecError(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5548 	}
   5549 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8L_DATA)
   5550 	return int32(VP8_STATUS_OK)
   5551 }
   5552 
   5553 func DecodeVP8LData(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5554 	var curr_size size_t
   5555 	var dec uintptr
   5556 	var v1 int32
   5557 	_, _, _ = curr_size, dec, v1
   5558 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5559 	curr_size = MemDataSize(tls, idec+296)
   5560 	// Switch to incremental decoding if we don't have all the bytes available.
   5561 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental = libc.BoolInt32(curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size)
   5562 	if !(VP8LDecodeImage(tls, dec) != 0) {
   5563 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5564 	}
   5565 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_SUSPENDED) {
   5566 		v1 = (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus
   5567 	} else {
   5568 		v1 = FinishDecoding(tls, idec)
   5569 	}
   5570 	return v1
   5571 }
   5572 
   5573 // C documentation
   5574 //
   5575 //	// Main decoding loop
   5576 func IDecode(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5577 	var dec uintptr
   5578 	var status VP8StatusCode1
   5579 	_, _ = dec, status
   5580 	status = int32(VP8_STATUS_SUSPENDED)
   5581 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_WEBP_HEADER) {
   5582 		status = DecodeWebPHeaders(tls, idec)
   5583 	} else {
   5584 		if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec == libc.UintptrFromInt32(0) {
   5585 			return int32(VP8_STATUS_SUSPENDED) // can't continue if we have no decoder.
   5586 		}
   5587 	}
   5588 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_HEADER) {
   5589 		status = DecodeVP8FrameHeader(tls, idec)
   5590 	}
   5591 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_PARTS0) {
   5592 		status = DecodePartition0(tls, idec)
   5593 	}
   5594 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5595 		dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5596 		if dec == libc.UintptrFromInt32(0) {
   5597 			return int32(VP8_STATUS_SUSPENDED) // can't continue if we have no decoder.
   5598 		}
   5599 		status = DecodeRemaining(tls, idec)
   5600 	}
   5601 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8L_HEADER) {
   5602 		status = DecodeVP8LHeader(tls, idec)
   5603 	}
   5604 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8L_DATA) {
   5605 		status = DecodeVP8LData(tls, idec)
   5606 	}
   5607 	return status
   5608 }
   5609 
   5610 // ------------------------------------------------------------------------------
   5611 // Internal constructor
   5612 func NewDecoder(tls *libc.TLS, output_buffer uintptr, features uintptr) (r uintptr) {
   5613 	var idec uintptr
   5614 	var v1, v3 int32
   5615 	var v5 bool
   5616 	_, _, _, _ = idec, v1, v3, v5
   5617 	idec = WebPSafeCalloc(tls, uint64(1), uint64(496))
   5618 	if idec == libc.UintptrFromInt32(0) {
   5619 		return libc.UintptrFromInt32(0)
   5620 	}
   5621 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_WEBP_HEADER)
   5622 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size = uint64(0)
   5623 	(*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y = -int32(1)
   5624 	InitMemBuffer(tls, idec+296)
   5625 	v1 = WebPInitDecBufferInternal(tls, idec+352, int32(WEBP_DECODER_ABI_VERSION))
   5626 	goto _2
   5627 _2:
   5628 	;
   5629 	if v5 = !(v1 != 0); !v5 {
   5630 		v3 = VP8InitIoInternal(tls, idec+136, int32(WEBP_DECODER_ABI_VERSION))
   5631 		goto _4
   5632 	_4:
   5633 	}
   5634 	if v5 || !(v3 != 0) {
   5635 		WebPSafeFree(tls, idec)
   5636 		return libc.UintptrFromInt32(0)
   5637 	}
   5638 	WebPResetDecParams(tls, idec+8)
   5639 	if output_buffer == libc.UintptrFromInt32(0) || WebPAvoidSlowMemory(tls, output_buffer, features) != 0 {
   5640 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput = idec + 352
   5641 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = output_buffer
   5642 		if output_buffer != libc.UintptrFromInt32(0) {
   5643 			(*WebPDecBuffer)(unsafe.Pointer((*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput)).Fcolorspace = (*WebPDecBuffer)(unsafe.Pointer(output_buffer)).Fcolorspace
   5644 		}
   5645 	} else {
   5646 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput = output_buffer
   5647 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = libc.UintptrFromInt32(0)
   5648 	}
   5649 	WebPInitCustomIo(tls, idec+8, idec+136) // Plug the I/O functions.
   5650 	return idec
   5651 }
   5652 
   5653 //------------------------------------------------------------------------------
   5654 // Public functions
   5655 
   5656 func WebPINewDecoder(tls *libc.TLS, output_buffer uintptr) (r uintptr) {
   5657 	return NewDecoder(tls, output_buffer, libc.UintptrFromInt32(0))
   5658 }
   5659 
   5660 func WebPIDecode(tls *libc.TLS, data1 uintptr, data_size1 size_t, config uintptr) (r uintptr) {
   5661 	bp := tls.Alloc(48)
   5662 	defer tls.Free(48)
   5663 	var features1, idec, v1 uintptr
   5664 	var v2 VP8StatusCode1
   5665 	var _ /* tmp_features at bp+0 */ WebPBitstreamFeatures
   5666 	_, _, _, _ = features1, idec, v1, v2
   5667 	if config == libc.UintptrFromInt32(0) {
   5668 		v1 = bp
   5669 	} else {
   5670 		v1 = config
   5671 	}
   5672 	features1 = v1
   5673 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(40), ^__predefined_size_t(0))
   5674 	// Parse the bitstream's features, if requested:
   5675 	if data1 != libc.UintptrFromInt32(0) && data_size1 > uint64(0) {
   5676 		v2 = WebPGetFeaturesInternal(tls, data1, data_size1, features1, int32(WEBP_DECODER_ABI_VERSION))
   5677 		goto _3
   5678 	_3:
   5679 		if v2 != int32(VP8_STATUS_OK) {
   5680 			return libc.UintptrFromInt32(0)
   5681 		}
   5682 	}
   5683 	// Create an instance of the incremental decoder
   5684 	if config != libc.UintptrFromInt32(0) {
   5685 		v1 = NewDecoder(tls, config+40, features1)
   5686 	} else {
   5687 		v1 = NewDecoder(tls, libc.UintptrFromInt32(0), features1)
   5688 	}
   5689 	idec = v1
   5690 	if idec == libc.UintptrFromInt32(0) {
   5691 		return libc.UintptrFromInt32(0)
   5692 	}
   5693 	// Finish initialization
   5694 	if config != libc.UintptrFromInt32(0) {
   5695 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foptions = config + 160
   5696 	}
   5697 	return idec
   5698 }
   5699 
   5700 func WebPIDelete(tls *libc.TLS, idec uintptr) {
   5701 	if idec == libc.UintptrFromInt32(0) {
   5702 		return
   5703 	}
   5704 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec != libc.UintptrFromInt32(0) {
   5705 		if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5706 			if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5707 				// Synchronize the thread, clean-up and check for errors.
   5708 				// TODO(vrabaud) do we care about the return result?
   5709 				VP8ExitCritical(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec, idec+136)
   5710 			}
   5711 			VP8Delete(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec)
   5712 		} else {
   5713 			VP8LDelete(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec)
   5714 		}
   5715 	}
   5716 	ClearMemBuffer(tls, idec+296)
   5717 	WebPFreeDecBuffer(tls, idec+352)
   5718 	WebPSafeFree(tls, idec)
   5719 }
   5720 
   5721 //------------------------------------------------------------------------------
   5722 // Wrapper toward WebPINewDecoder
   5723 
   5724 func WebPINewRGB(tls *libc.TLS, csp WEBP_CSP_MODE1, output_buffer uintptr, output_buffer_size size_t, output_stride int32) (r uintptr) {
   5725 	var idec uintptr
   5726 	var is_external_memory, v1 int32
   5727 	_, _, _ = idec, is_external_memory, v1
   5728 	if output_buffer != libc.UintptrFromInt32(0) {
   5729 		v1 = int32(1)
   5730 	} else {
   5731 		v1 = 0
   5732 	}
   5733 	is_external_memory = v1
   5734 	if csp >= int32(MODE_YUV) {
   5735 		return libc.UintptrFromInt32(0)
   5736 	}
   5737 	if is_external_memory == 0 { // Overwrite parameters to sane values.
   5738 		output_buffer_size = uint64(0)
   5739 		output_stride = 0
   5740 	} else { // A buffer was passed. Validate the other params.
   5741 		if output_stride == 0 || output_buffer_size == uint64(0) {
   5742 			return libc.UintptrFromInt32(0) // invalid parameter.
   5743 		}
   5744 	}
   5745 	idec = WebPINewDecoder(tls, libc.UintptrFromInt32(0))
   5746 	if idec == libc.UintptrFromInt32(0) {
   5747 		return libc.UintptrFromInt32(0)
   5748 	}
   5749 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fcolorspace = csp
   5750 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fis_external_memory = is_external_memory
   5751 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16)) = output_buffer
   5752 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 8)) = output_stride
   5753 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 16)) = output_buffer_size
   5754 	return idec
   5755 }
   5756 
   5757 func WebPINewYUVA(tls *libc.TLS, luma uintptr, luma_size size_t, luma_stride int32, u uintptr, u_size size_t, u_stride int32, v uintptr, v_size size_t, v_stride int32, a uintptr, a_size size_t, a_stride int32) (r uintptr) {
   5758 	var colorspace WEBP_CSP_MODE1
   5759 	var idec, v8, v9 uintptr
   5760 	var is_external_memory, v1, v5, v6 int32
   5761 	var v2, v3, v4 size_t
   5762 	_, _, _, _, _, _, _, _, _, _, _ = colorspace, idec, is_external_memory, v1, v2, v3, v4, v5, v6, v8, v9
   5763 	if luma != libc.UintptrFromInt32(0) {
   5764 		v1 = int32(1)
   5765 	} else {
   5766 		v1 = 0
   5767 	}
   5768 	is_external_memory = v1
   5769 	if is_external_memory == 0 { // Overwrite parameters to sane values.
   5770 		v4 = libc.Uint64FromInt32(0)
   5771 		a_size = v4
   5772 		v3 = v4
   5773 		v_size = v3
   5774 		v2 = v3
   5775 		u_size = v2
   5776 		luma_size = v2
   5777 		v6 = libc.Int32FromInt32(0)
   5778 		a_stride = v6
   5779 		v5 = v6
   5780 		v_stride = v5
   5781 		v1 = v5
   5782 		u_stride = v1
   5783 		luma_stride = v1
   5784 		v9 = libc.UintptrFromInt32(0)
   5785 		a = v9
   5786 		v8 = v9
   5787 		v = v8
   5788 		u = v8
   5789 		colorspace = int32(MODE_YUVA)
   5790 	} else { // A luma buffer was passed. Validate the other parameters.
   5791 		if u == libc.UintptrFromInt32(0) || v == libc.UintptrFromInt32(0) {
   5792 			return libc.UintptrFromInt32(0)
   5793 		}
   5794 		if luma_size == uint64(0) || u_size == uint64(0) || v_size == uint64(0) {
   5795 			return libc.UintptrFromInt32(0)
   5796 		}
   5797 		if luma_stride == 0 || u_stride == 0 || v_stride == 0 {
   5798 			return libc.UintptrFromInt32(0)
   5799 		}
   5800 		if a != libc.UintptrFromInt32(0) {
   5801 			if a_size == uint64(0) || a_stride == 0 {
   5802 				return libc.UintptrFromInt32(0)
   5803 			}
   5804 		}
   5805 		if a == libc.UintptrFromInt32(0) {
   5806 			v1 = int32(MODE_YUV)
   5807 		} else {
   5808 			v1 = int32(MODE_YUVA)
   5809 		}
   5810 		colorspace = v1
   5811 	}
   5812 	idec = WebPINewDecoder(tls, libc.UintptrFromInt32(0))
   5813 	if idec == libc.UintptrFromInt32(0) {
   5814 		return libc.UintptrFromInt32(0)
   5815 	}
   5816 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fcolorspace = colorspace
   5817 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fis_external_memory = is_external_memory
   5818 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16)) = luma
   5819 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 32)) = luma_stride
   5820 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 48)) = luma_size
   5821 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 8)) = u
   5822 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 36)) = u_stride
   5823 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 56)) = u_size
   5824 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 16)) = v
   5825 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 40)) = v_stride
   5826 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 64)) = v_size
   5827 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 24)) = a
   5828 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 44)) = a_stride
   5829 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 72)) = a_size
   5830 	return idec
   5831 }
   5832 
   5833 func WebPINewYUV(tls *libc.TLS, luma uintptr, luma_size size_t, luma_stride int32, u uintptr, u_size size_t, u_stride int32, v uintptr, v_size size_t, v_stride int32) (r uintptr) {
   5834 	return WebPINewYUVA(tls, luma, luma_size, luma_stride, u, u_size, u_stride, v, v_size, v_stride, libc.UintptrFromInt32(0), uint64(0), 0)
   5835 }
   5836 
   5837 //------------------------------------------------------------------------------
   5838 
   5839 func IDecCheckStatus(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5840 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_ERROR) {
   5841 		return int32(VP8_STATUS_BITSTREAM_ERROR)
   5842 	}
   5843 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_DONE) {
   5844 		return int32(VP8_STATUS_OK)
   5845 	}
   5846 	return int32(VP8_STATUS_SUSPENDED)
   5847 }
   5848 
   5849 func WebPIAppend(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r VP8StatusCode1) {
   5850 	var status VP8StatusCode1
   5851 	_ = status
   5852 	if idec == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
   5853 		return int32(VP8_STATUS_INVALID_PARAM)
   5854 	}
   5855 	status = IDecCheckStatus(tls, idec)
   5856 	if status != int32(VP8_STATUS_SUSPENDED) {
   5857 		return status
   5858 	}
   5859 	// Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
   5860 	if !(CheckMemBufferMode(tls, idec+296, int32(MEM_MODE_APPEND)) != 0) {
   5861 		return int32(VP8_STATUS_INVALID_PARAM)
   5862 	}
   5863 	// Append data to memory buffer
   5864 	if !(AppendToMemBuffer(tls, idec, data, data_size) != 0) {
   5865 		return int32(VP8_STATUS_OUT_OF_MEMORY)
   5866 	}
   5867 	return IDecode(tls, idec)
   5868 }
   5869 
   5870 func WebPIUpdate(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r VP8StatusCode1) {
   5871 	var status VP8StatusCode1
   5872 	_ = status
   5873 	if idec == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
   5874 		return int32(VP8_STATUS_INVALID_PARAM)
   5875 	}
   5876 	status = IDecCheckStatus(tls, idec)
   5877 	if status != int32(VP8_STATUS_SUSPENDED) {
   5878 		return status
   5879 	}
   5880 	// Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
   5881 	if !(CheckMemBufferMode(tls, idec+296, int32(MEM_MODE_MAP)) != 0) {
   5882 		return int32(VP8_STATUS_INVALID_PARAM)
   5883 	}
   5884 	// Make the memory buffer point to the new buffer
   5885 	if !(RemapMemBuffer(tls, idec, data, data_size) != 0) {
   5886 		return int32(VP8_STATUS_INVALID_PARAM)
   5887 	}
   5888 	return IDecode(tls, idec)
   5889 }
   5890 
   5891 //------------------------------------------------------------------------------
   5892 
   5893 func GetOutputBuffer(tls *libc.TLS, idec uintptr) (r uintptr) {
   5894 	if idec == libc.UintptrFromInt32(0) || (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec == libc.UintptrFromInt32(0) {
   5895 		return libc.UintptrFromInt32(0)
   5896 	}
   5897 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate <= int32(STATE_VP8_PARTS0) {
   5898 		return libc.UintptrFromInt32(0)
   5899 	}
   5900 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output != libc.UintptrFromInt32(0) {
   5901 		return libc.UintptrFromInt32(0) // not yet slow-copied
   5902 	}
   5903 	return (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput
   5904 }
   5905 
   5906 func WebPIDecodedArea(tls *libc.TLS, idec uintptr, left uintptr, top uintptr, width uintptr, height uintptr) (r uintptr) {
   5907 	var src uintptr
   5908 	_ = src
   5909 	src = GetOutputBuffer(tls, idec)
   5910 	if left != libc.UintptrFromInt32(0) {
   5911 		**(**int32)(__ccgo_up(left)) = 0
   5912 	}
   5913 	if top != libc.UintptrFromInt32(0) {
   5914 		**(**int32)(__ccgo_up(top)) = 0
   5915 	}
   5916 	if src != libc.UintptrFromInt32(0) {
   5917 		if width != libc.UintptrFromInt32(0) {
   5918 			**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5919 		}
   5920 		if height != libc.UintptrFromInt32(0) {
   5921 			**(**int32)(__ccgo_up(height)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5922 		}
   5923 	} else {
   5924 		if width != libc.UintptrFromInt32(0) {
   5925 			**(**int32)(__ccgo_up(width)) = 0
   5926 		}
   5927 		if height != libc.UintptrFromInt32(0) {
   5928 			**(**int32)(__ccgo_up(height)) = 0
   5929 		}
   5930 	}
   5931 	return src
   5932 }
   5933 
   5934 func WebPIDecGetRGB(tls *libc.TLS, idec uintptr, last_y uintptr, width uintptr, height uintptr, stride uintptr) (r uintptr) {
   5935 	var src uintptr
   5936 	_ = src
   5937 	src = GetOutputBuffer(tls, idec)
   5938 	if src == libc.UintptrFromInt32(0) {
   5939 		return libc.UintptrFromInt32(0)
   5940 	}
   5941 	if (*WebPDecBuffer)(unsafe.Pointer(src)).Fcolorspace >= int32(MODE_YUV) {
   5942 		return libc.UintptrFromInt32(0)
   5943 	}
   5944 	if last_y != libc.UintptrFromInt32(0) {
   5945 		**(**int32)(__ccgo_up(last_y)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5946 	}
   5947 	if width != libc.UintptrFromInt32(0) {
   5948 		**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5949 	}
   5950 	if height != libc.UintptrFromInt32(0) {
   5951 		**(**int32)(__ccgo_up(height)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fheight
   5952 	}
   5953 	if stride != libc.UintptrFromInt32(0) {
   5954 		**(**int32)(__ccgo_up(stride)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fu.FRGBA.Fstride
   5955 	}
   5956 	return (*WebPDecBuffer)(unsafe.Pointer(src)).Fu.FRGBA.Frgba
   5957 }
   5958 
   5959 func WebPIDecGetYUVA(tls *libc.TLS, idec uintptr, last_y uintptr, u uintptr, v uintptr, a uintptr, width uintptr, height uintptr, stride uintptr, uv_stride uintptr, a_stride uintptr) (r uintptr) {
   5960 	var src uintptr
   5961 	_ = src
   5962 	src = GetOutputBuffer(tls, idec)
   5963 	if src == libc.UintptrFromInt32(0) {
   5964 		return libc.UintptrFromInt32(0)
   5965 	}
   5966 	if (*WebPDecBuffer)(unsafe.Pointer(src)).Fcolorspace < int32(MODE_YUV) {
   5967 		return libc.UintptrFromInt32(0)
   5968 	}
   5969 	if last_y != libc.UintptrFromInt32(0) {
   5970 		**(**int32)(__ccgo_up(last_y)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5971 	}
   5972 	if u != libc.UintptrFromInt32(0) {
   5973 		**(**uintptr)(__ccgo_up(u)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fu
   5974 	}
   5975 	if v != libc.UintptrFromInt32(0) {
   5976 		**(**uintptr)(__ccgo_up(v)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fv
   5977 	}
   5978 	if a != libc.UintptrFromInt32(0) {
   5979 		**(**uintptr)(__ccgo_up(a)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fa
   5980 	}
   5981 	if width != libc.UintptrFromInt32(0) {
   5982 		**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5983 	}
   5984 	if height != libc.UintptrFromInt32(0) {
   5985 		**(**int32)(__ccgo_up(height)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fheight
   5986 	}
   5987 	if stride != libc.UintptrFromInt32(0) {
   5988 		**(**int32)(__ccgo_up(stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fy_stride
   5989 	}
   5990 	if uv_stride != libc.UintptrFromInt32(0) {
   5991 		**(**int32)(__ccgo_up(uv_stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fu_stride
   5992 	}
   5993 	if a_stride != libc.UintptrFromInt32(0) {
   5994 		**(**int32)(__ccgo_up(a_stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fa_stride
   5995 	}
   5996 	return (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fy
   5997 }
   5998 
   5999 type __ccgo_fp__XWebPISetIOHooks_1 = func(*libc.TLS, uintptr) int32
   6000 
   6001 type __ccgo_fp__XWebPISetIOHooks_2 = func(*libc.TLS, uintptr) int32
   6002 
   6003 type __ccgo_fp__XWebPISetIOHooks_3 = func(*libc.TLS, uintptr)
   6004 
   6005 func WebPISetIOHooks(tls *libc.TLS, idec uintptr, __ccgo_fp_put VP8IoPutHook, __ccgo_fp_setup VP8IoSetupHook, __ccgo_fp_teardown VP8IoTeardownHook, user_data uintptr) (r int32) {
   6006 	if idec == libc.UintptrFromInt32(0) || (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate > int32(STATE_WEBP_HEADER) {
   6007 		return 0
   6008 	}
   6009 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fput = __ccgo_fp_put
   6010 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fsetup = __ccgo_fp_setup
   6011 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fteardown = __ccgo_fp_teardown
   6012 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fopaque = user_data
   6013 	return int32(1)
   6014 }
   6015 
   6016 var kHashMul4 = uint32(0x1e35a7bd)
   6017 
   6018 const YUV_FIX = 16
   6019 const YUV_HALF = 32768
   6020 const YUV_FIX2 = 6
   6021 const YUV_MASK2 = 16383
   6022 
   6023 //------------------------------------------------------------------------------
   6024 
   6025 // Copyright 2010 Google Inc. All Rights Reserved.
   6026 //
   6027 // Use of this source code is governed by a BSD-style license
   6028 // that can be found in the COPYING file in the root of the source
   6029 // tree. An additional intellectual property rights grant can be found
   6030 // in the file PATENTS. All contributing project authors may
   6031 // be found in the AUTHORS file in the root of the source tree.
   6032 // -----------------------------------------------------------------------------
   6033 //
   6034 //  Main decoding functions for WebP images.
   6035 //
   6036 // Author: Skal (pascal.massimino@gmail.com)
   6037 
   6038 //------------------------------------------------------------------------------
   6039 // Main YUV<->RGB conversion functions
   6040 
   6041 func EmitYUV(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6042 	var buf, output, u_dst, v_dst, y_dst uintptr
   6043 	var mb_h, mb_w, uv_h, uv_w int32
   6044 	_, _, _, _, _, _, _, _, _ = buf, mb_h, mb_w, output, u_dst, uv_h, uv_w, v_dst, y_dst
   6045 	output = (*WebPDecParams)(unsafe.Pointer(p)).Foutput
   6046 	buf = output + 16
   6047 	y_dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride))
   6048 	u_dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y>>libc.Int32FromInt32(1))*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride))
   6049 	v_dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y>>libc.Int32FromInt32(1))*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride))
   6050 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6051 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6052 	uv_w = (mb_w + int32(1)) / int32(2)
   6053 	uv_h = (mb_h + int32(1)) / int32(2)
   6054 	WebPCopyPlane(tls, (*VP8Io)(unsafe.Pointer(io)).Fy, (*VP8Io)(unsafe.Pointer(io)).Fy_stride, y_dst, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride, mb_w, mb_h)
   6055 	WebPCopyPlane(tls, (*VP8Io)(unsafe.Pointer(io)).Fu, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, u_dst, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride, uv_w, uv_h)
   6056 	WebPCopyPlane(tls, (*VP8Io)(unsafe.Pointer(io)).Fv, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, v_dst, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride, uv_w, uv_h)
   6057 	return (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6058 }
   6059 
   6060 // C documentation
   6061 //
   6062 //	// Point-sampling U/V sampler.
   6063 func EmitSampledRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6064 	var buf, dst, output uintptr
   6065 	_, _, _ = buf, dst, output
   6066 	output = (*WebPDecParams)(unsafe.Pointer(p)).Foutput
   6067 	buf = output + 16
   6068 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6069 	WebPSamplerProcessPlane(tls, (*VP8Io)(unsafe.Pointer(io)).Fy, (*VP8Io)(unsafe.Pointer(io)).Fy_stride, (*VP8Io)(unsafe.Pointer(io)).Fu, (*VP8Io)(unsafe.Pointer(io)).Fv, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, dst, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, WebPSamplers[(*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace])
   6070 	return (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6071 }
   6072 
   6073 //------------------------------------------------------------------------------
   6074 // Fancy upsampling
   6075 
   6076 func EmitFancyRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6077 	var buf, cur_u, cur_v, cur_y, dst, top_u, top_v uintptr
   6078 	var mb_w, num_lines_out, uv_w, y, y_end int32
   6079 	var upsample WebPUpsampleLinePairFunc
   6080 	_, _, _, _, _, _, _, _, _, _, _, _, _ = buf, cur_u, cur_v, cur_y, dst, mb_w, num_lines_out, top_u, top_v, upsample, uv_w, y, y_end
   6081 	num_lines_out = (*VP8Io)(unsafe.Pointer(io)).Fmb_h // a priori guess
   6082 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6083 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6084 	upsample = WebPUpsamplers[(*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace]
   6085 	cur_y = (*VP8Io)(unsafe.Pointer(io)).Fy
   6086 	cur_u = (*VP8Io)(unsafe.Pointer(io)).Fu
   6087 	cur_v = (*VP8Io)(unsafe.Pointer(io)).Fv
   6088 	top_u = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u
   6089 	top_v = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v
   6090 	y = (*VP8Io)(unsafe.Pointer(io)).Fmb_y
   6091 	y_end = (*VP8Io)(unsafe.Pointer(io)).Fmb_y + (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6092 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6093 	uv_w = (mb_w + int32(1)) / int32(2)
   6094 	if y == 0 {
   6095 		// First line is special cased. We mirror the u/v samples at boundary.
   6096 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y, libc.UintptrFromInt32(0), cur_u, cur_v, cur_u, cur_v, dst, libc.UintptrFromInt32(0), mb_w)
   6097 	} else {
   6098 		// We can finish the left-over line from previous call.
   6099 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y, cur_y, top_u, top_v, cur_u, cur_v, dst-uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride), dst, mb_w)
   6100 		num_lines_out = num_lines_out + 1
   6101 	}
   6102 	// Loop over each output pairs of row.
   6103 	for {
   6104 		if !(y+int32(2) < y_end) {
   6105 			break
   6106 		}
   6107 		top_u = cur_u
   6108 		top_v = cur_v
   6109 		cur_u = cur_u + uintptr((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6110 		cur_v = cur_v + uintptr((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6111 		dst = dst + uintptr(int32(2)*(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6112 		cur_y = cur_y + uintptr(int32(2)*(*VP8Io)(unsafe.Pointer(io)).Fy_stride)
   6113 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y-uintptr((*VP8Io)(unsafe.Pointer(io)).Fy_stride), cur_y, top_u, top_v, cur_u, cur_v, dst-uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride), dst, mb_w)
   6114 		goto _1
   6115 	_1:
   6116 		;
   6117 		y = y + int32(2)
   6118 	}
   6119 	// move to last row
   6120 	cur_y = cur_y + uintptr((*VP8Io)(unsafe.Pointer(io)).Fy_stride)
   6121 	if (*VP8Io)(unsafe.Pointer(io)).Fcrop_top+y_end < (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
   6122 		// Save the unfinished samples for next call (as we're not done yet).
   6123 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y, cur_y, libc.Uint64FromInt32(mb_w)*uint64(1), ^__predefined_size_t(0))
   6124 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u, cur_u, libc.Uint64FromInt32(uv_w)*uint64(1), ^__predefined_size_t(0))
   6125 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v, cur_v, libc.Uint64FromInt32(uv_w)*uint64(1), ^__predefined_size_t(0))
   6126 		// The fancy upsampler leaves a row unfinished behind
   6127 		// (except for the very last row)
   6128 		num_lines_out = num_lines_out - 1
   6129 	} else {
   6130 		// Process the very last row of even-sized picture
   6131 		if !(y_end&libc.Int32FromInt32(1) != 0) {
   6132 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y, libc.UintptrFromInt32(0), cur_u, cur_v, cur_u, cur_v, dst+uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride), libc.UintptrFromInt32(0), mb_w)
   6133 		}
   6134 	}
   6135 	return num_lines_out
   6136 }
   6137 
   6138 //------------------------------------------------------------------------------
   6139 
   6140 func FillAlphaPlane(tls *libc.TLS, dst uintptr, w int32, h int32, stride int32) {
   6141 	var j int32
   6142 	_ = j
   6143 	j = 0
   6144 	for {
   6145 		if !(j < h) {
   6146 			break
   6147 		}
   6148 		libc.X__builtin___memset_chk(tls, dst, int32(0xff), libc.Uint64FromInt32(w)*uint64(1), ^__predefined_size_t(0))
   6149 		dst = dst + uintptr(stride)
   6150 		goto _1
   6151 	_1:
   6152 		;
   6153 		j = j + 1
   6154 	}
   6155 }
   6156 
   6157 func EmitAlphaYUV(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6158 	var alpha, buf, dst uintptr
   6159 	var j, mb_h, mb_w int32
   6160 	_, _, _, _, _, _ = alpha, buf, dst, j, mb_h, mb_w
   6161 	alpha = (*VP8Io)(unsafe.Pointer(io)).Fa
   6162 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6163 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6164 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6165 	dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride))
   6166 	_ = expected_num_lines_out
   6167 	if alpha != libc.UintptrFromInt32(0) {
   6168 		j = 0
   6169 		for {
   6170 			if !(j < mb_h) {
   6171 				break
   6172 			}
   6173 			libc.X__builtin___memcpy_chk(tls, dst, alpha, libc.Uint64FromInt32(mb_w)*uint64(1), ^__predefined_size_t(0))
   6174 			alpha = alpha + uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6175 			dst = dst + uintptr((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6176 			goto _1
   6177 		_1:
   6178 			;
   6179 			j = j + 1
   6180 		}
   6181 	} else {
   6182 		if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
   6183 			// the user requested alpha, but there is none, set it to opaque.
   6184 			FillAlphaPlane(tls, dst, mb_w, mb_h, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6185 		}
   6186 	}
   6187 	return 0
   6188 }
   6189 
   6190 func GetAlphaSourceRow(tls *libc.TLS, io uintptr, alpha uintptr, num_rows uintptr) (r int32) {
   6191 	var start_y int32
   6192 	_ = start_y
   6193 	start_y = (*VP8Io)(unsafe.Pointer(io)).Fmb_y
   6194 	**(**int32)(__ccgo_up(num_rows)) = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6195 	// Compensate for the 1-line delay of the fancy upscaler.
   6196 	// This is similar to EmitFancyRGB().
   6197 	if (*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling != 0 {
   6198 		if start_y == 0 {
   6199 			// We don't process the last row yet. It'll be done during the next call.
   6200 			**(**int32)(__ccgo_up(num_rows)) = **(**int32)(__ccgo_up(num_rows)) - 1
   6201 		} else {
   6202 			start_y = start_y - 1
   6203 			// Fortunately, *alpha data is persistent, so we can go back
   6204 			// one row and finish alpha blending, now that the fancy upscaler
   6205 			// completed the YUV->RGB interpolation.
   6206 			**(**uintptr)(__ccgo_up(alpha)) -= uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6207 		}
   6208 		if (*VP8Io)(unsafe.Pointer(io)).Fcrop_top+(*VP8Io)(unsafe.Pointer(io)).Fmb_y+(*VP8Io)(unsafe.Pointer(io)).Fmb_h == (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
   6209 			// If it's the very last call, we process all the remaining rows!
   6210 			**(**int32)(__ccgo_up(num_rows)) = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - start_y
   6211 		}
   6212 	}
   6213 	return start_y
   6214 }
   6215 
   6216 func EmitAlphaRGB(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6217 	bp := tls.Alloc(16)
   6218 	defer tls.Free(16)
   6219 	var alpha_first, has_alpha, mb_w, start_y, v1 int32
   6220 	var base_rgba, buf, dst uintptr
   6221 	var colorspace, v2 WEBP_CSP_MODE1
   6222 	var v5 bool
   6223 	var _ /* alpha at bp+0 */ uintptr
   6224 	var _ /* num_rows at bp+8 */ int32
   6225 	_, _, _, _, _, _, _, _, _, _, _ = alpha_first, base_rgba, buf, colorspace, dst, has_alpha, mb_w, start_y, v1, v2, v5
   6226 	**(**uintptr)(__ccgo_up(bp)) = (*VP8Io)(unsafe.Pointer(io)).Fa
   6227 	if **(**uintptr)(__ccgo_up(bp)) != libc.UintptrFromInt32(0) {
   6228 		mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6229 		colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6230 		alpha_first = libc.BoolInt32(colorspace == int32(MODE_ARGB) || colorspace == int32(MODE_Argb))
   6231 		buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6232 		start_y = GetAlphaSourceRow(tls, io, bp, bp+8)
   6233 		base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(start_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6234 		if alpha_first != 0 {
   6235 			v1 = 0
   6236 		} else {
   6237 			v1 = int32(3)
   6238 		}
   6239 		dst = base_rgba + uintptr(v1)
   6240 		has_alpha = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPDispatchAlpha})))(tls, **(**uintptr)(__ccgo_up(bp)), (*VP8Io)(unsafe.Pointer(io)).Fwidth, mb_w, **(**int32)(__ccgo_up(bp + 8)), dst, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6241 		_ = expected_num_lines_out
   6242 		// has_alpha is true if there's non-trivial alpha to premultiply with.
   6243 		if v5 = has_alpha != 0; v5 {
   6244 			v2 = colorspace
   6245 			v1 = libc.BoolInt32(v2 == int32(MODE_rgbA) || v2 == int32(MODE_bgrA) || v2 == int32(MODE_Argb) || v2 == int32(MODE_rgbA_4444))
   6246 			goto _4
   6247 		_4:
   6248 		}
   6249 		if v5 && v1 != 0 {
   6250 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, base_rgba, alpha_first, mb_w, **(**int32)(__ccgo_up(bp + 8)), (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6251 		}
   6252 	}
   6253 	return 0
   6254 }
   6255 
   6256 func EmitAlphaRGBA4444(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6257 	bp := tls.Alloc(16)
   6258 	defer tls.Free(16)
   6259 	var alpha_dst, base_rgba, buf uintptr
   6260 	var alpha_mask, alpha_value uint32_t
   6261 	var colorspace, v3 WEBP_CSP_MODE1
   6262 	var i, j, mb_w, start_y, v4 int32
   6263 	var v6 bool
   6264 	var _ /* alpha at bp+0 */ uintptr
   6265 	var _ /* num_rows at bp+8 */ int32
   6266 	_, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_dst, alpha_mask, alpha_value, base_rgba, buf, colorspace, i, j, mb_w, start_y, v3, v4, v6
   6267 	**(**uintptr)(__ccgo_up(bp)) = (*VP8Io)(unsafe.Pointer(io)).Fa
   6268 	if **(**uintptr)(__ccgo_up(bp)) != libc.UintptrFromInt32(0) {
   6269 		mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6270 		colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6271 		buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6272 		start_y = GetAlphaSourceRow(tls, io, bp, bp+8)
   6273 		base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(start_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6274 		alpha_dst = base_rgba + uintptr(1)
   6275 		alpha_mask = uint32(0x0f)
   6276 		j = 0
   6277 		for {
   6278 			if !(j < **(**int32)(__ccgo_up(bp + 8))) {
   6279 				break
   6280 			}
   6281 			i = 0
   6282 			for {
   6283 				if !(i < mb_w) {
   6284 					break
   6285 				}
   6286 				// Fill in the alpha value (converted to 4 bits).
   6287 				alpha_value = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)))) >> int32(4))
   6288 				**(**uint8_t)(__ccgo_up(alpha_dst + uintptr(int32(2)*i))) = uint8(libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_dst + uintptr(int32(2)*i))))&libc.Int32FromInt32(0xf0)) | alpha_value)
   6289 				alpha_mask = alpha_mask & alpha_value
   6290 				goto _2
   6291 			_2:
   6292 				;
   6293 				i = i + 1
   6294 			}
   6295 			**(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6296 			alpha_dst = alpha_dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6297 			goto _1
   6298 		_1:
   6299 			;
   6300 			j = j + 1
   6301 		}
   6302 		_ = expected_num_lines_out
   6303 		if v6 = alpha_mask != uint32(0x0f); v6 {
   6304 			v3 = colorspace
   6305 			v4 = libc.BoolInt32(v3 == int32(MODE_rgbA) || v3 == int32(MODE_bgrA) || v3 == int32(MODE_Argb) || v3 == int32(MODE_rgbA_4444))
   6306 			goto _5
   6307 		_5:
   6308 		}
   6309 		if v6 && v4 != 0 {
   6310 			(*(*func(*libc.TLS, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply4444})))(tls, base_rgba, mb_w, **(**int32)(__ccgo_up(bp + 8)), (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6311 		}
   6312 	}
   6313 	return 0
   6314 }
   6315 
   6316 //------------------------------------------------------------------------------
   6317 // YUV rescaling (no final RGB conversion needed)
   6318 
   6319 func Rescale(tls *libc.TLS, src uintptr, src_stride int32, new_lines int32, wrk uintptr) (r int32) {
   6320 	var lines_in, num_lines_out int32
   6321 	_, _ = lines_in, num_lines_out
   6322 	num_lines_out = 0
   6323 	for new_lines > 0 { // import new contributions of source rows.
   6324 		lines_in = WebPRescalerImport(tls, wrk, new_lines, src, src_stride)
   6325 		src = src + uintptr(lines_in*src_stride)
   6326 		new_lines = new_lines - lines_in
   6327 		num_lines_out = num_lines_out + WebPRescalerExport(tls, wrk) // emit output row(s)
   6328 	}
   6329 	return num_lines_out
   6330 }
   6331 
   6332 func EmitRescaledYUV(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6333 	var mb_h, num_lines_out, uv_mb_h, v2, v5 int32
   6334 	var scaler uintptr
   6335 	var v1, v4 WEBP_CSP_MODE1
   6336 	var v7 bool
   6337 	_, _, _, _, _, _, _, _, _ = mb_h, num_lines_out, scaler, uv_mb_h, v1, v2, v4, v5, v7
   6338 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6339 	uv_mb_h = (mb_h + int32(1)) >> int32(1)
   6340 	scaler = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y
   6341 	num_lines_out = 0
   6342 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6343 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6344 		v4 = v1
   6345 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6346 		goto _6
   6347 	_6:
   6348 	}
   6349 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6350 	goto _3
   6351 _3:
   6352 	;
   6353 	if v2 != 0 && (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6354 		// Before rescaling, we premultiply the luma directly into the io->y
   6355 		// internal buffer. This is OK since these samples are not used for
   6356 		// intra-prediction (the top samples are saved in cache_y/u/v).
   6357 		// But we need to cast the const away, though.
   6358 		WebPMultRows(tls, (*VP8Io)(unsafe.Pointer(io)).Fy, (*VP8Io)(unsafe.Pointer(io)).Fy_stride, (*VP8Io)(unsafe.Pointer(io)).Fa, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, mb_h, 0)
   6359 	}
   6360 	num_lines_out = Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fy, (*VP8Io)(unsafe.Pointer(io)).Fy_stride, mb_h, scaler)
   6361 	Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fu, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, uv_mb_h, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u)
   6362 	Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fv, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, uv_mb_h, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v)
   6363 	return num_lines_out
   6364 }
   6365 
   6366 func EmitRescaledAlphaYUV(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6367 	var buf, dst_a, dst_y uintptr
   6368 	var num_lines_out int32
   6369 	_, _, _, _ = buf, dst_a, dst_y, num_lines_out
   6370 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6371 	dst_a = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(int64((*WebPDecParams)(unsafe.Pointer(p)).Flast_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride))
   6372 	if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6373 		dst_y = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy + uintptr(int64((*WebPDecParams)(unsafe.Pointer(p)).Flast_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride))
   6374 		num_lines_out = Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fa, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)
   6375 		if num_lines_out > 0 { // unmultiply the Y
   6376 			WebPMultRows(tls, dst_y, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride, dst_a, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst_width, num_lines_out, int32(1))
   6377 		}
   6378 	} else {
   6379 		if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
   6380 			// the user requested alpha, but there is none, set it to opaque.
   6381 			FillAlphaPlane(tls, dst_a, (*VP8Io)(unsafe.Pointer(io)).Fscaled_width, expected_num_lines_out, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6382 		}
   6383 	}
   6384 	return 0
   6385 }
   6386 
   6387 func InitYUVRescaler(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6388 	var buf, scalers, work, v12 uintptr
   6389 	var has_alpha, num_rescalers, out_height, out_width, uv_in_height, uv_in_width, uv_out_height, uv_out_width, v2, v5, v8 int32
   6390 	var rescaler_size, uv_work_size, work_size size_t
   6391 	var total_size, v9 uint64_t
   6392 	var v1, v4 WEBP_CSP_MODE1
   6393 	var v7 bool
   6394 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = buf, has_alpha, num_rescalers, out_height, out_width, rescaler_size, scalers, total_size, uv_in_height, uv_in_width, uv_out_height, uv_out_width, uv_work_size, work, work_size, v1, v12, v2, v4, v5, v7, v8, v9
   6395 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6396 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6397 		v4 = v1
   6398 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6399 		goto _6
   6400 	_6:
   6401 	}
   6402 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6403 	goto _3
   6404 _3:
   6405 	has_alpha = v2
   6406 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6407 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
   6408 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
   6409 	uv_out_width = (out_width + int32(1)) >> int32(1)
   6410 	uv_out_height = (out_height + int32(1)) >> int32(1)
   6411 	uv_in_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6412 	uv_in_height = ((*VP8Io)(unsafe.Pointer(io)).Fmb_h + int32(1)) >> int32(1)
   6413 	// scratch memory for luma rescaler
   6414 	work_size = uint64(2) * libc.Uint64FromInt32(out_width)
   6415 	uv_work_size = libc.Uint64FromInt32(int32(2) * uv_out_width)
   6416 	if has_alpha != 0 {
   6417 		v8 = int32(4)
   6418 	} else {
   6419 		v8 = int32(3)
   6420 	}
   6421 	num_rescalers = v8
   6422 	total_size = (work_size + uint64(2)*uv_work_size) * uint64(4)
   6423 	if has_alpha != 0 {
   6424 		total_size = total_size + work_size*uint64(4)
   6425 	}
   6426 	rescaler_size = libc.Uint64FromInt32(num_rescalers)*uint64(104) + uint64(WEBP_ALIGN_CST)
   6427 	total_size = total_size + rescaler_size
   6428 	v9 = total_size
   6429 	v2 = libc.BoolInt32(v9 == v9)
   6430 	goto _11
   6431 _11:
   6432 	if !(v2 != 0) {
   6433 		return 0
   6434 	}
   6435 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), total_size)
   6436 	if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6437 		return 0 // memory error
   6438 	}
   6439 	work = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6440 	scalers = uintptr((uint64(work+uintptr(total_size)-uintptr(rescaler_size)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   6441 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y = scalers
   6442 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u = scalers + 1*104
   6443 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v = scalers + 2*104
   6444 	if has_alpha != 0 {
   6445 		v12 = scalers + 3*104
   6446 	} else {
   6447 		v12 = libc.UintptrFromInt32(0)
   6448 	}
   6449 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a = v12
   6450 	if !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy, out_width, out_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride, int32(1), work) != 0) || !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u, uv_in_width, uv_in_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu, uv_out_width, uv_out_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride, int32(1), work+uintptr(work_size)*4) != 0) || !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v, uv_in_width, uv_in_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv, uv_out_width, uv_out_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride, int32(1), work+uintptr(work_size)*4+uintptr(uv_work_size)*4) != 0) {
   6451 		return 0
   6452 	}
   6453 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitRescaledYUV)
   6454 	if has_alpha != 0 {
   6455 		if !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa, out_width, out_height, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride, int32(1), work+uintptr(work_size)*4+uintptr(uint64(2)*uv_work_size)*4) != 0) {
   6456 			return 0
   6457 		}
   6458 		(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = __ccgo_fp(EmitRescaledAlphaYUV)
   6459 		WebPInitAlphaProcessing(tls)
   6460 	}
   6461 	return int32(1)
   6462 }
   6463 
   6464 //------------------------------------------------------------------------------
   6465 // RGBA rescaling
   6466 
   6467 func ExportRGB(tls *libc.TLS, p uintptr, y_pos int32) (r int32) {
   6468 	var buf, dst, v1, v10, v4, v7 uintptr
   6469 	var convert WebPYUV444Converter
   6470 	var num_lines_out, v11, v2, v5, v8 int32
   6471 	var v13 bool
   6472 	_, _, _, _, _, _, _, _, _, _, _, _, _ = buf, convert, dst, num_lines_out, v1, v10, v11, v13, v2, v4, v5, v7, v8
   6473 	convert = WebPYUV444Converters[(*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace]
   6474 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6475 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6476 	num_lines_out = 0
   6477 	// For RGB rescaling, because of the YUV420, current scan position
   6478 	// U/V can be +1/-1 line from the Y one.  Hence the double test.
   6479 	for {
   6480 		v1 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y
   6481 		v4 = v1
   6482 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
   6483 		goto _6
   6484 	_6:
   6485 		;
   6486 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
   6487 		goto _3
   6488 	_3:
   6489 		;
   6490 		if v13 = v2 != 0; v13 {
   6491 			v7 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u
   6492 			v10 = v7
   6493 			v11 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v10)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v10)).Fdst_height)
   6494 			goto _12
   6495 		_12:
   6496 			;
   6497 			v8 = libc.BoolInt32(!(v11 != 0) && (*WebPRescaler)(unsafe.Pointer(v7)).Fy_accum <= 0)
   6498 			goto _9
   6499 		_9:
   6500 		}
   6501 		if !(v13 && v8 != 0) {
   6502 			break
   6503 		}
   6504 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y)
   6505 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u)
   6506 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v)
   6507 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{convert})))(tls, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y)).Fdst, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u)).Fdst, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v)).Fdst, dst, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y)).Fdst_width)
   6508 		dst = dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6509 		num_lines_out = num_lines_out + 1
   6510 	}
   6511 	return num_lines_out
   6512 }
   6513 
   6514 func EmitRescaledRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6515 	var j, mb_h, num_lines_out, u_lines_in, uv_j, uv_mb_h, v_lines_in, y_lines_in int32
   6516 	_, _, _, _, _, _, _, _ = j, mb_h, num_lines_out, u_lines_in, uv_j, uv_mb_h, v_lines_in, y_lines_in
   6517 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6518 	uv_mb_h = (mb_h + int32(1)) >> int32(1)
   6519 	j = 0
   6520 	uv_j = 0
   6521 	num_lines_out = 0
   6522 	for j < mb_h {
   6523 		y_lines_in = WebPRescalerImport(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y, mb_h-j, (*VP8Io)(unsafe.Pointer(io)).Fy+uintptr(int64(j)*int64((*VP8Io)(unsafe.Pointer(io)).Fy_stride)), (*VP8Io)(unsafe.Pointer(io)).Fy_stride)
   6524 		j = j + y_lines_in
   6525 		if WebPRescaleNeededLines(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u, uv_mb_h-uv_j) != 0 {
   6526 			u_lines_in = WebPRescalerImport(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u, uv_mb_h-uv_j, (*VP8Io)(unsafe.Pointer(io)).Fu+uintptr(int64(uv_j)*int64((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)), (*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6527 			v_lines_in = WebPRescalerImport(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v, uv_mb_h-uv_j, (*VP8Io)(unsafe.Pointer(io)).Fv+uintptr(int64(uv_j)*int64((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)), (*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6528 			_ = v_lines_in // remove a gcc warning
   6529 			uv_j = uv_j + u_lines_in
   6530 		}
   6531 		num_lines_out = num_lines_out + ExportRGB(tls, p, (*WebPDecParams)(unsafe.Pointer(p)).Flast_y+num_lines_out)
   6532 	}
   6533 	return num_lines_out
   6534 }
   6535 
   6536 func ExportAlpha(tls *libc.TLS, p uintptr, y_pos int32, max_lines_out int32) (r int32) {
   6537 	var alpha_first, is_premult_alpha, num_lines_out, width, v1, v3, v6, v9 int32
   6538 	var base_rgba, buf, dst, v5, v8 uintptr
   6539 	var colorspace, v2 WEBP_CSP_MODE1
   6540 	var non_opaque uint32_t
   6541 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_first, base_rgba, buf, colorspace, dst, is_premult_alpha, non_opaque, num_lines_out, width, v1, v2, v3, v5, v6, v8, v9
   6542 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6543 	base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6544 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6545 	alpha_first = libc.BoolInt32(colorspace == int32(MODE_ARGB) || colorspace == int32(MODE_Argb))
   6546 	if alpha_first != 0 {
   6547 		v1 = 0
   6548 	} else {
   6549 		v1 = int32(3)
   6550 	}
   6551 	dst = base_rgba + uintptr(v1)
   6552 	num_lines_out = 0
   6553 	v2 = colorspace
   6554 	v3 = libc.BoolInt32(v2 == int32(MODE_rgbA) || v2 == int32(MODE_bgrA) || v2 == int32(MODE_Argb) || v2 == int32(MODE_rgbA_4444))
   6555 	goto _4
   6556 _4:
   6557 	is_premult_alpha = v3
   6558 	non_opaque = uint32(0)
   6559 	width = (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst_width
   6560 	for {
   6561 		v5 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6562 		v8 = v5
   6563 		v9 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v8)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v8)).Fdst_height)
   6564 		goto _10
   6565 	_10:
   6566 		;
   6567 		v6 = libc.BoolInt32(!(v9 != 0) && (*WebPRescaler)(unsafe.Pointer(v5)).Fy_accum <= 0)
   6568 		goto _7
   6569 	_7:
   6570 		;
   6571 		if !(v6 != 0 && num_lines_out < max_lines_out) {
   6572 			break
   6573 		}
   6574 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)
   6575 		non_opaque = non_opaque | libc.Uint32FromInt32((*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPDispatchAlpha})))(tls, (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst, 0, width, int32(1), dst, 0))
   6576 		dst = dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6577 		num_lines_out = num_lines_out + 1
   6578 	}
   6579 	if is_premult_alpha != 0 && non_opaque != 0 {
   6580 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, base_rgba, alpha_first, width, num_lines_out, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6581 	}
   6582 	return num_lines_out
   6583 }
   6584 
   6585 func ExportAlphaRGBA4444(tls *libc.TLS, p uintptr, y_pos int32, max_lines_out int32) (r int32) {
   6586 	var alpha_dst, base_rgba, buf, v4, v7 uintptr
   6587 	var alpha_mask, alpha_value uint32_t
   6588 	var colorspace, v1 WEBP_CSP_MODE1
   6589 	var i, is_premult_alpha, num_lines_out, width, v2, v5, v8 int32
   6590 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_dst, alpha_mask, alpha_value, base_rgba, buf, colorspace, i, is_premult_alpha, num_lines_out, width, v1, v2, v4, v5, v7, v8
   6591 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6592 	base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6593 	alpha_dst = base_rgba + uintptr(1)
   6594 	num_lines_out = 0
   6595 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6596 	width = (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst_width
   6597 	v1 = colorspace
   6598 	v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
   6599 	goto _3
   6600 _3:
   6601 	is_premult_alpha = v2
   6602 	alpha_mask = uint32(0x0f)
   6603 	for {
   6604 		v4 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6605 		v7 = v4
   6606 		v8 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v7)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v7)).Fdst_height)
   6607 		goto _9
   6608 	_9:
   6609 		;
   6610 		v5 = libc.BoolInt32(!(v8 != 0) && (*WebPRescaler)(unsafe.Pointer(v4)).Fy_accum <= 0)
   6611 		goto _6
   6612 	_6:
   6613 		;
   6614 		if !(v5 != 0 && num_lines_out < max_lines_out) {
   6615 			break
   6616 		}
   6617 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)
   6618 		i = 0
   6619 		for {
   6620 			if !(i < width) {
   6621 				break
   6622 			}
   6623 			// Fill in the alpha value (converted to 4 bits).
   6624 			alpha_value = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst + uintptr(i)))) >> int32(4))
   6625 			**(**uint8_t)(__ccgo_up(alpha_dst + uintptr(int32(2)*i))) = uint8(libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_dst + uintptr(int32(2)*i))))&libc.Int32FromInt32(0xf0)) | alpha_value)
   6626 			alpha_mask = alpha_mask & alpha_value
   6627 			goto _10
   6628 		_10:
   6629 			;
   6630 			i = i + 1
   6631 		}
   6632 		alpha_dst = alpha_dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6633 		num_lines_out = num_lines_out + 1
   6634 	}
   6635 	if is_premult_alpha != 0 && alpha_mask != uint32(0x0f) {
   6636 		(*(*func(*libc.TLS, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply4444})))(tls, base_rgba, width, num_lines_out, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6637 	}
   6638 	return num_lines_out
   6639 }
   6640 
   6641 func EmitRescaledAlphaRGB(tls *libc.TLS, io uintptr, p uintptr, expected_num_out_lines int32) (r int32) {
   6642 	var lines_left, y_end int32
   6643 	var row_offset int64_t
   6644 	var scaler uintptr
   6645 	_, _, _, _ = lines_left, row_offset, scaler, y_end
   6646 	if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6647 		scaler = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6648 		lines_left = expected_num_out_lines
   6649 		y_end = (*WebPDecParams)(unsafe.Pointer(p)).Flast_y + lines_left
   6650 		for lines_left > 0 {
   6651 			row_offset = int64((*WebPRescaler)(unsafe.Pointer(scaler)).Fsrc_y) - int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)
   6652 			WebPRescalerImport(tls, scaler, (*VP8Io)(unsafe.Pointer(io)).Fmb_h+(*VP8Io)(unsafe.Pointer(io)).Fmb_y-(*WebPRescaler)(unsafe.Pointer(scaler)).Fsrc_y, (*VP8Io)(unsafe.Pointer(io)).Fa+uintptr(row_offset*int64((*VP8Io)(unsafe.Pointer(io)).Fwidth)), (*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6653 			lines_left = lines_left - (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row})))(tls, p, y_end-lines_left, lines_left)
   6654 		}
   6655 	}
   6656 	return 0
   6657 }
   6658 
   6659 func InitRGBRescaler(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6660 	var has_alpha, num_rescalers, out_height, out_width, uv_in_height, uv_in_width, v2, v5, v8 int32
   6661 	var rescaler_size, work_size size_t
   6662 	var scalers, tmp, work, v12 uintptr
   6663 	var tmp_size1, tmp_size2, total_size, v9 uint64_t
   6664 	var v1, v4 WEBP_CSP_MODE1
   6665 	var v7 bool
   6666 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = has_alpha, num_rescalers, out_height, out_width, rescaler_size, scalers, tmp, tmp_size1, tmp_size2, total_size, uv_in_height, uv_in_width, work, work_size, v1, v12, v2, v4, v5, v7, v8, v9
   6667 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6668 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6669 		v4 = v1
   6670 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6671 		goto _6
   6672 	_6:
   6673 	}
   6674 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6675 	goto _3
   6676 _3:
   6677 	has_alpha = v2
   6678 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
   6679 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
   6680 	uv_in_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6681 	uv_in_height = ((*VP8Io)(unsafe.Pointer(io)).Fmb_h + int32(1)) >> int32(1)
   6682 	// scratch memory for one rescaler
   6683 	work_size = uint64(2) * libc.Uint64FromInt32(out_width)
   6684 	if has_alpha != 0 {
   6685 		v8 = int32(4)
   6686 	} else {
   6687 		v8 = int32(3)
   6688 	}
   6689 	num_rescalers = v8
   6690 	tmp_size1 = libc.Uint64FromInt32(num_rescalers) * work_size
   6691 	tmp_size2 = libc.Uint64FromInt32(num_rescalers) * libc.Uint64FromInt32(out_width)
   6692 	total_size = tmp_size1*uint64(4) + tmp_size2*uint64(1)
   6693 	rescaler_size = libc.Uint64FromInt32(num_rescalers)*uint64(104) + uint64(WEBP_ALIGN_CST)
   6694 	total_size = total_size + rescaler_size
   6695 	v9 = total_size
   6696 	v2 = libc.BoolInt32(v9 == v9)
   6697 	goto _11
   6698 _11:
   6699 	if !(v2 != 0) {
   6700 		return 0
   6701 	}
   6702 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), total_size)
   6703 	if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6704 		return 0 // memory error
   6705 	}
   6706 	work = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6707 	tmp = work + uintptr(tmp_size1)*4
   6708 	scalers = uintptr((uint64(work+uintptr(total_size)-uintptr(rescaler_size)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   6709 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y = scalers
   6710 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u = scalers + 1*104
   6711 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v = scalers + 2*104
   6712 	if has_alpha != 0 {
   6713 		v12 = scalers + 3*104
   6714 	} else {
   6715 		v12 = libc.UintptrFromInt32(0)
   6716 	}
   6717 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a = v12
   6718 	if !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, tmp+uintptr(0*out_width), out_width, out_height, 0, int32(1), work+uintptr(uint64(0)*work_size)*4) != 0) || !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u, uv_in_width, uv_in_height, tmp+uintptr(int32(1)*out_width), out_width, out_height, 0, int32(1), work+uintptr(uint64(1)*work_size)*4) != 0) || !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v, uv_in_width, uv_in_height, tmp+uintptr(int32(2)*out_width), out_width, out_height, 0, int32(1), work+uintptr(uint64(2)*work_size)*4) != 0) {
   6719 		return 0
   6720 	}
   6721 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitRescaledRGB)
   6722 	WebPInitYUV444Converters(tls)
   6723 	if has_alpha != 0 {
   6724 		if !(WebPRescalerInit(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, tmp+uintptr(int32(3)*out_width), out_width, out_height, 0, int32(1), work+uintptr(uint64(3)*work_size)*4) != 0) {
   6725 			return 0
   6726 		}
   6727 		(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = __ccgo_fp(EmitRescaledAlphaRGB)
   6728 		if (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace == int32(MODE_RGBA_4444) || (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace == int32(MODE_rgbA_4444) {
   6729 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = __ccgo_fp(ExportAlphaRGBA4444)
   6730 		} else {
   6731 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = __ccgo_fp(ExportAlpha)
   6732 		}
   6733 		WebPInitAlphaProcessing(tls)
   6734 	}
   6735 	return int32(1)
   6736 }
   6737 
   6738 //------------------------------------------------------------------------------
   6739 // Default custom functions
   6740 
   6741 func CustomSetup(tls *libc.TLS, io uintptr) (r int32) {
   6742 	var colorspace, v3, v6 WEBP_CSP_MODE1
   6743 	var is_alpha, is_rgb, ok, uv_width, v1, v4, v7 int32
   6744 	var p, v16, v17 uintptr
   6745 	var v9 bool
   6746 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = colorspace, is_alpha, is_rgb, ok, p, uv_width, v1, v16, v17, v3, v4, v6, v7, v9
   6747 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6748 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6749 	v1 = libc.BoolInt32(colorspace < int32(MODE_YUV))
   6750 	goto _2
   6751 _2:
   6752 	is_rgb = v1
   6753 	v3 = colorspace
   6754 	if v9 = v3 == int32(MODE_RGBA) || v3 == int32(MODE_BGRA) || v3 == int32(MODE_ARGB) || v3 == int32(MODE_RGBA_4444) || v3 == int32(MODE_YUVA); !v9 {
   6755 		v6 = v3
   6756 		v7 = libc.BoolInt32(v6 == int32(MODE_rgbA) || v6 == int32(MODE_bgrA) || v6 == int32(MODE_Argb) || v6 == int32(MODE_rgbA_4444))
   6757 		goto _8
   6758 	_8:
   6759 	}
   6760 	v4 = libc.BoolInt32(v9 || v7 != 0)
   6761 	goto _5
   6762 _5:
   6763 	is_alpha = v4
   6764 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = libc.UintptrFromInt32(0)
   6765 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = libc.UintptrFromInt32(0)
   6766 	(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = libc.UintptrFromInt32(0)
   6767 	(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = libc.UintptrFromInt32(0)
   6768 	if is_alpha != 0 {
   6769 		v1 = int32(MODE_YUV)
   6770 	} else {
   6771 		v1 = int32(MODE_YUVA)
   6772 	}
   6773 	if !(WebPIoInitFromOptions(tls, (*WebPDecParams)(unsafe.Pointer(p)).Foptions, io, v1) != 0) {
   6774 		return 0
   6775 	}
   6776 	if v9 = is_alpha != 0; v9 {
   6777 		v3 = colorspace
   6778 		v1 = libc.BoolInt32(v3 == int32(MODE_rgbA) || v3 == int32(MODE_bgrA) || v3 == int32(MODE_Argb) || v3 == int32(MODE_rgbA_4444))
   6779 		goto _13
   6780 	_13:
   6781 	}
   6782 	if v9 && v1 != 0 {
   6783 		WebPInitUpsamplers(tls)
   6784 	}
   6785 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
   6786 		if is_rgb != 0 {
   6787 			v1 = InitRGBRescaler(tls, io, p)
   6788 		} else {
   6789 			v1 = InitYUVRescaler(tls, io, p)
   6790 		}
   6791 		ok = v1
   6792 		if !(ok != 0) {
   6793 			return 0 // memory error
   6794 		}
   6795 	} else {
   6796 		if is_rgb != 0 {
   6797 			WebPInitSamplers(tls)
   6798 			(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitSampledRGB) // default
   6799 			if (*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling != 0 {
   6800 				uv_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6801 				(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fmb_w+libc.Int32FromInt32(2)*uv_width))
   6802 				if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6803 					return 0 // memory error.
   6804 				}
   6805 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6806 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y + uintptr((*VP8Io)(unsafe.Pointer(io)).Fmb_w)
   6807 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u + uintptr(uv_width)
   6808 				(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitFancyRGB)
   6809 				WebPInitUpsamplers(tls)
   6810 			}
   6811 		} else {
   6812 			(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitYUV)
   6813 		}
   6814 		if is_alpha != 0 { // need transparency output
   6815 			if colorspace == int32(MODE_RGBA_4444) || colorspace == int32(MODE_rgbA_4444) {
   6816 				v16 = __ccgo_fp(EmitAlphaRGBA4444)
   6817 			} else {
   6818 				if is_rgb != 0 {
   6819 					v17 = __ccgo_fp(EmitAlphaRGB)
   6820 				} else {
   6821 					v17 = __ccgo_fp(EmitAlphaYUV)
   6822 				}
   6823 				v16 = v17
   6824 			}
   6825 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = v16
   6826 			if is_rgb != 0 {
   6827 				WebPInitAlphaProcessing(tls)
   6828 			}
   6829 		}
   6830 	}
   6831 	return int32(1)
   6832 }
   6833 
   6834 //------------------------------------------------------------------------------
   6835 
   6836 func CustomPut(tls *libc.TLS, io uintptr) (r int32) {
   6837 	var mb_h, mb_w, num_lines_out int32
   6838 	var p uintptr
   6839 	_, _, _, _ = mb_h, mb_w, num_lines_out, p
   6840 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6841 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6842 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6843 	if mb_w <= 0 || mb_h <= 0 {
   6844 		return 0
   6845 	}
   6846 	num_lines_out = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPDecParams)(unsafe.Pointer(p)).Femit})))(tls, io, p)
   6847 	if (*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha != libc.UintptrFromInt32(0) {
   6848 		(*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha})))(tls, io, p, num_lines_out)
   6849 	}
   6850 	**(**int32)(__ccgo_up(p + 32)) += num_lines_out
   6851 	return int32(1)
   6852 }
   6853 
   6854 //------------------------------------------------------------------------------
   6855 
   6856 func CustomTeardown(tls *libc.TLS, io uintptr) {
   6857 	var p uintptr
   6858 	_ = p
   6859 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6860 	WebPSafeFree(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fmemory)
   6861 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = libc.UintptrFromInt32(0)
   6862 }
   6863 
   6864 //------------------------------------------------------------------------------
   6865 // Main entry point
   6866 
   6867 func WebPInitCustomIo(tls *libc.TLS, params uintptr, io uintptr) {
   6868 	(*VP8Io)(unsafe.Pointer(io)).Fput = __ccgo_fp(CustomPut)
   6869 	(*VP8Io)(unsafe.Pointer(io)).Fsetup = __ccgo_fp(CustomSetup)
   6870 	(*VP8Io)(unsafe.Pointer(io)).Fteardown = __ccgo_fp(CustomTeardown)
   6871 	(*VP8Io)(unsafe.Pointer(io)).Fopaque = params
   6872 }
   6873 
   6874 var kHashMul5 = uint32(0x1e35a7bd)
   6875 
   6876 //------------------------------------------------------------------------------
   6877 
   6878 // Copyright 2010 Google Inc. All Rights Reserved.
   6879 //
   6880 // Use of this source code is governed by a BSD-style license
   6881 // that can be found in the COPYING file in the root of the source
   6882 // tree. An additional intellectual property rights grant can be found
   6883 // in the file PATENTS. All contributing project authors may
   6884 // be found in the AUTHORS file in the root of the source tree.
   6885 // -----------------------------------------------------------------------------
   6886 //
   6887 // Boolean decoder
   6888 //
   6889 // Author: Skal (pascal.massimino@gmail.com)
   6890 //         Vikas Arora (vikaas.arora@gmail.com)
   6891 
   6892 // Copyright 2010 Google Inc. All Rights Reserved.
   6893 //
   6894 // Use of this source code is governed by a BSD-style license
   6895 // that can be found in the COPYING file in the root of the source
   6896 // tree. An additional intellectual property rights grant can be found
   6897 // in the file PATENTS. All contributing project authors may
   6898 // be found in the AUTHORS file in the root of the source tree.
   6899 // -----------------------------------------------------------------------------
   6900 //
   6901 //  Common types + memory wrappers
   6902 //
   6903 // Author: Skal (pascal.massimino@gmail.com)
   6904 
   6905 func clip(tls *libc.TLS, v int32, M int32) (r int32) {
   6906 	var v1, v2 int32
   6907 	_, _ = v1, v2
   6908 	if v < 0 {
   6909 		v1 = 0
   6910 	} else {
   6911 		if v > M {
   6912 			v2 = M
   6913 		} else {
   6914 			v2 = v
   6915 		}
   6916 		v1 = v2
   6917 	}
   6918 	return v1
   6919 }
   6920 
   6921 // C documentation
   6922 //
   6923 //	// Paragraph 14.1
   6924 var kDcTable = [128]uint8_t{
   6925 	0:   uint8(4),
   6926 	1:   uint8(5),
   6927 	2:   uint8(6),
   6928 	3:   uint8(7),
   6929 	4:   uint8(8),
   6930 	5:   uint8(9),
   6931 	6:   uint8(10),
   6932 	7:   uint8(10),
   6933 	8:   uint8(11),
   6934 	9:   uint8(12),
   6935 	10:  uint8(13),
   6936 	11:  uint8(14),
   6937 	12:  uint8(15),
   6938 	13:  uint8(16),
   6939 	14:  uint8(17),
   6940 	15:  uint8(17),
   6941 	16:  uint8(18),
   6942 	17:  uint8(19),
   6943 	18:  uint8(20),
   6944 	19:  uint8(20),
   6945 	20:  uint8(21),
   6946 	21:  uint8(21),
   6947 	22:  uint8(22),
   6948 	23:  uint8(22),
   6949 	24:  uint8(23),
   6950 	25:  uint8(23),
   6951 	26:  uint8(24),
   6952 	27:  uint8(25),
   6953 	28:  uint8(25),
   6954 	29:  uint8(26),
   6955 	30:  uint8(27),
   6956 	31:  uint8(28),
   6957 	32:  uint8(29),
   6958 	33:  uint8(30),
   6959 	34:  uint8(31),
   6960 	35:  uint8(32),
   6961 	36:  uint8(33),
   6962 	37:  uint8(34),
   6963 	38:  uint8(35),
   6964 	39:  uint8(36),
   6965 	40:  uint8(37),
   6966 	41:  uint8(37),
   6967 	42:  uint8(38),
   6968 	43:  uint8(39),
   6969 	44:  uint8(40),
   6970 	45:  uint8(41),
   6971 	46:  uint8(42),
   6972 	47:  uint8(43),
   6973 	48:  uint8(44),
   6974 	49:  uint8(45),
   6975 	50:  uint8(46),
   6976 	51:  uint8(46),
   6977 	52:  uint8(47),
   6978 	53:  uint8(48),
   6979 	54:  uint8(49),
   6980 	55:  uint8(50),
   6981 	56:  uint8(51),
   6982 	57:  uint8(52),
   6983 	58:  uint8(53),
   6984 	59:  uint8(54),
   6985 	60:  uint8(55),
   6986 	61:  uint8(56),
   6987 	62:  uint8(57),
   6988 	63:  uint8(58),
   6989 	64:  uint8(59),
   6990 	65:  uint8(60),
   6991 	66:  uint8(61),
   6992 	67:  uint8(62),
   6993 	68:  uint8(63),
   6994 	69:  uint8(64),
   6995 	70:  uint8(65),
   6996 	71:  uint8(66),
   6997 	72:  uint8(67),
   6998 	73:  uint8(68),
   6999 	74:  uint8(69),
   7000 	75:  uint8(70),
   7001 	76:  uint8(71),
   7002 	77:  uint8(72),
   7003 	78:  uint8(73),
   7004 	79:  uint8(74),
   7005 	80:  uint8(75),
   7006 	81:  uint8(76),
   7007 	82:  uint8(76),
   7008 	83:  uint8(77),
   7009 	84:  uint8(78),
   7010 	85:  uint8(79),
   7011 	86:  uint8(80),
   7012 	87:  uint8(81),
   7013 	88:  uint8(82),
   7014 	89:  uint8(83),
   7015 	90:  uint8(84),
   7016 	91:  uint8(85),
   7017 	92:  uint8(86),
   7018 	93:  uint8(87),
   7019 	94:  uint8(88),
   7020 	95:  uint8(89),
   7021 	96:  uint8(91),
   7022 	97:  uint8(93),
   7023 	98:  uint8(95),
   7024 	99:  uint8(96),
   7025 	100: uint8(98),
   7026 	101: uint8(100),
   7027 	102: uint8(101),
   7028 	103: uint8(102),
   7029 	104: uint8(104),
   7030 	105: uint8(106),
   7031 	106: uint8(108),
   7032 	107: uint8(110),
   7033 	108: uint8(112),
   7034 	109: uint8(114),
   7035 	110: uint8(116),
   7036 	111: uint8(118),
   7037 	112: uint8(122),
   7038 	113: uint8(124),
   7039 	114: uint8(126),
   7040 	115: uint8(128),
   7041 	116: uint8(130),
   7042 	117: uint8(132),
   7043 	118: uint8(134),
   7044 	119: uint8(136),
   7045 	120: uint8(138),
   7046 	121: uint8(140),
   7047 	122: uint8(143),
   7048 	123: uint8(145),
   7049 	124: uint8(148),
   7050 	125: uint8(151),
   7051 	126: uint8(154),
   7052 	127: uint8(157),
   7053 }
   7054 
   7055 var kAcTable = [128]uint16_t{
   7056 	0:   uint16(4),
   7057 	1:   uint16(5),
   7058 	2:   uint16(6),
   7059 	3:   uint16(7),
   7060 	4:   uint16(8),
   7061 	5:   uint16(9),
   7062 	6:   uint16(10),
   7063 	7:   uint16(11),
   7064 	8:   uint16(12),
   7065 	9:   uint16(13),
   7066 	10:  uint16(14),
   7067 	11:  uint16(15),
   7068 	12:  uint16(16),
   7069 	13:  uint16(17),
   7070 	14:  uint16(18),
   7071 	15:  uint16(19),
   7072 	16:  uint16(20),
   7073 	17:  uint16(21),
   7074 	18:  uint16(22),
   7075 	19:  uint16(23),
   7076 	20:  uint16(24),
   7077 	21:  uint16(25),
   7078 	22:  uint16(26),
   7079 	23:  uint16(27),
   7080 	24:  uint16(28),
   7081 	25:  uint16(29),
   7082 	26:  uint16(30),
   7083 	27:  uint16(31),
   7084 	28:  uint16(32),
   7085 	29:  uint16(33),
   7086 	30:  uint16(34),
   7087 	31:  uint16(35),
   7088 	32:  uint16(36),
   7089 	33:  uint16(37),
   7090 	34:  uint16(38),
   7091 	35:  uint16(39),
   7092 	36:  uint16(40),
   7093 	37:  uint16(41),
   7094 	38:  uint16(42),
   7095 	39:  uint16(43),
   7096 	40:  uint16(44),
   7097 	41:  uint16(45),
   7098 	42:  uint16(46),
   7099 	43:  uint16(47),
   7100 	44:  uint16(48),
   7101 	45:  uint16(49),
   7102 	46:  uint16(50),
   7103 	47:  uint16(51),
   7104 	48:  uint16(52),
   7105 	49:  uint16(53),
   7106 	50:  uint16(54),
   7107 	51:  uint16(55),
   7108 	52:  uint16(56),
   7109 	53:  uint16(57),
   7110 	54:  uint16(58),
   7111 	55:  uint16(60),
   7112 	56:  uint16(62),
   7113 	57:  uint16(64),
   7114 	58:  uint16(66),
   7115 	59:  uint16(68),
   7116 	60:  uint16(70),
   7117 	61:  uint16(72),
   7118 	62:  uint16(74),
   7119 	63:  uint16(76),
   7120 	64:  uint16(78),
   7121 	65:  uint16(80),
   7122 	66:  uint16(82),
   7123 	67:  uint16(84),
   7124 	68:  uint16(86),
   7125 	69:  uint16(88),
   7126 	70:  uint16(90),
   7127 	71:  uint16(92),
   7128 	72:  uint16(94),
   7129 	73:  uint16(96),
   7130 	74:  uint16(98),
   7131 	75:  uint16(100),
   7132 	76:  uint16(102),
   7133 	77:  uint16(104),
   7134 	78:  uint16(106),
   7135 	79:  uint16(108),
   7136 	80:  uint16(110),
   7137 	81:  uint16(112),
   7138 	82:  uint16(114),
   7139 	83:  uint16(116),
   7140 	84:  uint16(119),
   7141 	85:  uint16(122),
   7142 	86:  uint16(125),
   7143 	87:  uint16(128),
   7144 	88:  uint16(131),
   7145 	89:  uint16(134),
   7146 	90:  uint16(137),
   7147 	91:  uint16(140),
   7148 	92:  uint16(143),
   7149 	93:  uint16(146),
   7150 	94:  uint16(149),
   7151 	95:  uint16(152),
   7152 	96:  uint16(155),
   7153 	97:  uint16(158),
   7154 	98:  uint16(161),
   7155 	99:  uint16(164),
   7156 	100: uint16(167),
   7157 	101: uint16(170),
   7158 	102: uint16(173),
   7159 	103: uint16(177),
   7160 	104: uint16(181),
   7161 	105: uint16(185),
   7162 	106: uint16(189),
   7163 	107: uint16(193),
   7164 	108: uint16(197),
   7165 	109: uint16(201),
   7166 	110: uint16(205),
   7167 	111: uint16(209),
   7168 	112: uint16(213),
   7169 	113: uint16(217),
   7170 	114: uint16(221),
   7171 	115: uint16(225),
   7172 	116: uint16(229),
   7173 	117: uint16(234),
   7174 	118: uint16(239),
   7175 	119: uint16(245),
   7176 	120: uint16(249),
   7177 	121: uint16(254),
   7178 	122: uint16(259),
   7179 	123: uint16(264),
   7180 	124: uint16(269),
   7181 	125: uint16(274),
   7182 	126: uint16(279),
   7183 	127: uint16(284),
   7184 }
   7185 
   7186 //------------------------------------------------------------------------------
   7187 // Paragraph 9.6
   7188 
   7189 func VP8ParseQuant(tls *libc.TLS, dec uintptr) {
   7190 	var base_q0, dquv_ac, dquv_dc, dqy1_dc, dqy2_ac, dqy2_dc, i, q, v1, v2, v3, v4, v5 int32
   7191 	var br, hdr, m uintptr
   7192 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base_q0, br, dquv_ac, dquv_dc, dqy1_dc, dqy2_ac, dqy2_dc, hdr, i, m, q, v1, v2, v3, v4, v5
   7193 	br = dec + 16
   7194 	base_q0 = libc.Int32FromUint32(VP8GetValue(tls, br, int32(7)))
   7195 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7196 		v1 = VP8GetSignedValue(tls, br, int32(4))
   7197 	} else {
   7198 		v1 = 0
   7199 	}
   7200 	dqy1_dc = v1
   7201 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7202 		v2 = VP8GetSignedValue(tls, br, int32(4))
   7203 	} else {
   7204 		v2 = 0
   7205 	}
   7206 	dqy2_dc = v2
   7207 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7208 		v3 = VP8GetSignedValue(tls, br, int32(4))
   7209 	} else {
   7210 		v3 = 0
   7211 	}
   7212 	dqy2_ac = v3
   7213 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7214 		v4 = VP8GetSignedValue(tls, br, int32(4))
   7215 	} else {
   7216 		v4 = 0
   7217 	}
   7218 	dquv_dc = v4
   7219 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7220 		v5 = VP8GetSignedValue(tls, br, int32(4))
   7221 	} else {
   7222 		v5 = 0
   7223 	}
   7224 	dquv_ac = v5
   7225 	hdr = dec + 132
   7226 	i = 0
   7227 	for {
   7228 		if !(i < int32(NUM_MB_SEGMENTS)) {
   7229 			break
   7230 		}
   7231 		if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment != 0 {
   7232 			q = int32(**(**int8_t)(__ccgo_up(hdr + 12 + uintptr(i))))
   7233 			if !((*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta != 0) {
   7234 				q = q + base_q0
   7235 			}
   7236 		} else {
   7237 			if i > 0 {
   7238 				**(**VP8QuantMatrix)(__ccgo_up(dec + 1060 + uintptr(i)*32)) = **(**VP8QuantMatrix)(__ccgo_up(dec + 1060))
   7239 				goto _6
   7240 			} else {
   7241 				q = base_q0
   7242 			}
   7243 		}
   7244 		m = dec + 1060 + uintptr(i)*32
   7245 		**(**int32)(__ccgo_up(m)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dqy1_dc, int32(127))])
   7246 		**(**int32)(__ccgo_up(m + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+0, int32(127))])
   7247 		**(**int32)(__ccgo_up(m + 8)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dqy2_dc, int32(127))]) * int32(2)
   7248 		// For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
   7249 		// The smallest precision for that is '(x*6349) >> 12' but 16 is a good
   7250 		// word size.
   7251 		**(**int32)(__ccgo_up(m + 8 + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+dqy2_ac, int32(127))]) * int32(101581) >> int32(16)
   7252 		if **(**int32)(__ccgo_up(m + 8 + 1*4)) < int32(8) {
   7253 			**(**int32)(__ccgo_up(m + 8 + 1*4)) = int32(8)
   7254 		}
   7255 		**(**int32)(__ccgo_up(m + 16)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dquv_dc, int32(117))])
   7256 		**(**int32)(__ccgo_up(m + 16 + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+dquv_ac, int32(127))])
   7257 		(*VP8QuantMatrix)(unsafe.Pointer(m)).Fuv_quant = q + dquv_ac // for dithering strength evaluation
   7258 		goto _6
   7259 	_6:
   7260 		;
   7261 		i = i + 1
   7262 	}
   7263 }
   7264 
   7265 const USE_GENERIC_TREE = 1
   7266 
   7267 var kHashMul6 = uint32(0x1e35a7bd)
   7268 
   7269 type lbit_t = uint64
   7270 
   7271 // Copyright 2010 Google Inc. All Rights Reserved.
   7272 //
   7273 // Use of this source code is governed by a BSD-style license
   7274 // that can be found in the COPYING file in the root of the source
   7275 // tree. An additional intellectual property rights grant can be found
   7276 // in the file PATENTS. All contributing project authors may
   7277 // be found in the AUTHORS file in the root of the source tree.
   7278 // -----------------------------------------------------------------------------
   7279 //
   7280 // Boolean decoder
   7281 //
   7282 // Author: Skal (pascal.massimino@gmail.com)
   7283 //         Vikas Arora (vikaas.arora@gmail.com)
   7284 
   7285 // using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
   7286 
   7287 var kYModesIntra4 = [18]int8_t{
   7288 	1:  int8(1),
   7289 	2:  int8(-int32(B_TM_PRED)),
   7290 	3:  int8(2),
   7291 	4:  int8(-int32(B_VE_PRED)),
   7292 	5:  int8(3),
   7293 	6:  int8(4),
   7294 	7:  int8(6),
   7295 	8:  int8(-int32(B_HE_PRED)),
   7296 	9:  int8(5),
   7297 	10: int8(-int32(B_RD_PRED)),
   7298 	11: int8(-int32(B_VR_PRED)),
   7299 	12: int8(-int32(B_LD_PRED)),
   7300 	13: int8(7),
   7301 	14: int8(-int32(B_VL_PRED)),
   7302 	15: int8(8),
   7303 	16: int8(-int32(B_HD_PRED)),
   7304 	17: int8(-int32(B_HU_PRED)),
   7305 }
   7306 
   7307 //------------------------------------------------------------------------------
   7308 // Default probabilities
   7309 
   7310 // C documentation
   7311 //
   7312 //	// Paragraph 13.5
   7313 
   7314 var CoeffsProba0 = [4][8][3][11]uint8_t{
   7315 	0: {
   7316 		0: {
   7317 			0: {
   7318 				0:  uint8(128),
   7319 				1:  uint8(128),
   7320 				2:  uint8(128),
   7321 				3:  uint8(128),
   7322 				4:  uint8(128),
   7323 				5:  uint8(128),
   7324 				6:  uint8(128),
   7325 				7:  uint8(128),
   7326 				8:  uint8(128),
   7327 				9:  uint8(128),
   7328 				10: uint8(128),
   7329 			},
   7330 			1: {
   7331 				0:  uint8(128),
   7332 				1:  uint8(128),
   7333 				2:  uint8(128),
   7334 				3:  uint8(128),
   7335 				4:  uint8(128),
   7336 				5:  uint8(128),
   7337 				6:  uint8(128),
   7338 				7:  uint8(128),
   7339 				8:  uint8(128),
   7340 				9:  uint8(128),
   7341 				10: uint8(128),
   7342 			},
   7343 			2: {
   7344 				0:  uint8(128),
   7345 				1:  uint8(128),
   7346 				2:  uint8(128),
   7347 				3:  uint8(128),
   7348 				4:  uint8(128),
   7349 				5:  uint8(128),
   7350 				6:  uint8(128),
   7351 				7:  uint8(128),
   7352 				8:  uint8(128),
   7353 				9:  uint8(128),
   7354 				10: uint8(128),
   7355 			},
   7356 		},
   7357 		1: {
   7358 			0: {
   7359 				0:  uint8(253),
   7360 				1:  uint8(136),
   7361 				2:  uint8(254),
   7362 				3:  uint8(255),
   7363 				4:  uint8(228),
   7364 				5:  uint8(219),
   7365 				6:  uint8(128),
   7366 				7:  uint8(128),
   7367 				8:  uint8(128),
   7368 				9:  uint8(128),
   7369 				10: uint8(128),
   7370 			},
   7371 			1: {
   7372 				0:  uint8(189),
   7373 				1:  uint8(129),
   7374 				2:  uint8(242),
   7375 				3:  uint8(255),
   7376 				4:  uint8(227),
   7377 				5:  uint8(213),
   7378 				6:  uint8(255),
   7379 				7:  uint8(219),
   7380 				8:  uint8(128),
   7381 				9:  uint8(128),
   7382 				10: uint8(128),
   7383 			},
   7384 			2: {
   7385 				0:  uint8(106),
   7386 				1:  uint8(126),
   7387 				2:  uint8(227),
   7388 				3:  uint8(252),
   7389 				4:  uint8(214),
   7390 				5:  uint8(209),
   7391 				6:  uint8(255),
   7392 				7:  uint8(255),
   7393 				8:  uint8(128),
   7394 				9:  uint8(128),
   7395 				10: uint8(128),
   7396 			},
   7397 		},
   7398 		2: {
   7399 			0: {
   7400 				0:  uint8(1),
   7401 				1:  uint8(98),
   7402 				2:  uint8(248),
   7403 				3:  uint8(255),
   7404 				4:  uint8(236),
   7405 				5:  uint8(226),
   7406 				6:  uint8(255),
   7407 				7:  uint8(255),
   7408 				8:  uint8(128),
   7409 				9:  uint8(128),
   7410 				10: uint8(128),
   7411 			},
   7412 			1: {
   7413 				0:  uint8(181),
   7414 				1:  uint8(133),
   7415 				2:  uint8(238),
   7416 				3:  uint8(254),
   7417 				4:  uint8(221),
   7418 				5:  uint8(234),
   7419 				6:  uint8(255),
   7420 				7:  uint8(154),
   7421 				8:  uint8(128),
   7422 				9:  uint8(128),
   7423 				10: uint8(128),
   7424 			},
   7425 			2: {
   7426 				0:  uint8(78),
   7427 				1:  uint8(134),
   7428 				2:  uint8(202),
   7429 				3:  uint8(247),
   7430 				4:  uint8(198),
   7431 				5:  uint8(180),
   7432 				6:  uint8(255),
   7433 				7:  uint8(219),
   7434 				8:  uint8(128),
   7435 				9:  uint8(128),
   7436 				10: uint8(128),
   7437 			},
   7438 		},
   7439 		3: {
   7440 			0: {
   7441 				0:  uint8(1),
   7442 				1:  uint8(185),
   7443 				2:  uint8(249),
   7444 				3:  uint8(255),
   7445 				4:  uint8(243),
   7446 				5:  uint8(255),
   7447 				6:  uint8(128),
   7448 				7:  uint8(128),
   7449 				8:  uint8(128),
   7450 				9:  uint8(128),
   7451 				10: uint8(128),
   7452 			},
   7453 			1: {
   7454 				0:  uint8(184),
   7455 				1:  uint8(150),
   7456 				2:  uint8(247),
   7457 				3:  uint8(255),
   7458 				4:  uint8(236),
   7459 				5:  uint8(224),
   7460 				6:  uint8(128),
   7461 				7:  uint8(128),
   7462 				8:  uint8(128),
   7463 				9:  uint8(128),
   7464 				10: uint8(128),
   7465 			},
   7466 			2: {
   7467 				0:  uint8(77),
   7468 				1:  uint8(110),
   7469 				2:  uint8(216),
   7470 				3:  uint8(255),
   7471 				4:  uint8(236),
   7472 				5:  uint8(230),
   7473 				6:  uint8(128),
   7474 				7:  uint8(128),
   7475 				8:  uint8(128),
   7476 				9:  uint8(128),
   7477 				10: uint8(128),
   7478 			},
   7479 		},
   7480 		4: {
   7481 			0: {
   7482 				0:  uint8(1),
   7483 				1:  uint8(101),
   7484 				2:  uint8(251),
   7485 				3:  uint8(255),
   7486 				4:  uint8(241),
   7487 				5:  uint8(255),
   7488 				6:  uint8(128),
   7489 				7:  uint8(128),
   7490 				8:  uint8(128),
   7491 				9:  uint8(128),
   7492 				10: uint8(128),
   7493 			},
   7494 			1: {
   7495 				0:  uint8(170),
   7496 				1:  uint8(139),
   7497 				2:  uint8(241),
   7498 				3:  uint8(252),
   7499 				4:  uint8(236),
   7500 				5:  uint8(209),
   7501 				6:  uint8(255),
   7502 				7:  uint8(255),
   7503 				8:  uint8(128),
   7504 				9:  uint8(128),
   7505 				10: uint8(128),
   7506 			},
   7507 			2: {
   7508 				0:  uint8(37),
   7509 				1:  uint8(116),
   7510 				2:  uint8(196),
   7511 				3:  uint8(243),
   7512 				4:  uint8(228),
   7513 				5:  uint8(255),
   7514 				6:  uint8(255),
   7515 				7:  uint8(255),
   7516 				8:  uint8(128),
   7517 				9:  uint8(128),
   7518 				10: uint8(128),
   7519 			},
   7520 		},
   7521 		5: {
   7522 			0: {
   7523 				0:  uint8(1),
   7524 				1:  uint8(204),
   7525 				2:  uint8(254),
   7526 				3:  uint8(255),
   7527 				4:  uint8(245),
   7528 				5:  uint8(255),
   7529 				6:  uint8(128),
   7530 				7:  uint8(128),
   7531 				8:  uint8(128),
   7532 				9:  uint8(128),
   7533 				10: uint8(128),
   7534 			},
   7535 			1: {
   7536 				0:  uint8(207),
   7537 				1:  uint8(160),
   7538 				2:  uint8(250),
   7539 				3:  uint8(255),
   7540 				4:  uint8(238),
   7541 				5:  uint8(128),
   7542 				6:  uint8(128),
   7543 				7:  uint8(128),
   7544 				8:  uint8(128),
   7545 				9:  uint8(128),
   7546 				10: uint8(128),
   7547 			},
   7548 			2: {
   7549 				0:  uint8(102),
   7550 				1:  uint8(103),
   7551 				2:  uint8(231),
   7552 				3:  uint8(255),
   7553 				4:  uint8(211),
   7554 				5:  uint8(171),
   7555 				6:  uint8(128),
   7556 				7:  uint8(128),
   7557 				8:  uint8(128),
   7558 				9:  uint8(128),
   7559 				10: uint8(128),
   7560 			},
   7561 		},
   7562 		6: {
   7563 			0: {
   7564 				0:  uint8(1),
   7565 				1:  uint8(152),
   7566 				2:  uint8(252),
   7567 				3:  uint8(255),
   7568 				4:  uint8(240),
   7569 				5:  uint8(255),
   7570 				6:  uint8(128),
   7571 				7:  uint8(128),
   7572 				8:  uint8(128),
   7573 				9:  uint8(128),
   7574 				10: uint8(128),
   7575 			},
   7576 			1: {
   7577 				0:  uint8(177),
   7578 				1:  uint8(135),
   7579 				2:  uint8(243),
   7580 				3:  uint8(255),
   7581 				4:  uint8(234),
   7582 				5:  uint8(225),
   7583 				6:  uint8(128),
   7584 				7:  uint8(128),
   7585 				8:  uint8(128),
   7586 				9:  uint8(128),
   7587 				10: uint8(128),
   7588 			},
   7589 			2: {
   7590 				0:  uint8(80),
   7591 				1:  uint8(129),
   7592 				2:  uint8(211),
   7593 				3:  uint8(255),
   7594 				4:  uint8(194),
   7595 				5:  uint8(224),
   7596 				6:  uint8(128),
   7597 				7:  uint8(128),
   7598 				8:  uint8(128),
   7599 				9:  uint8(128),
   7600 				10: uint8(128),
   7601 			},
   7602 		},
   7603 		7: {
   7604 			0: {
   7605 				0:  uint8(1),
   7606 				1:  uint8(1),
   7607 				2:  uint8(255),
   7608 				3:  uint8(128),
   7609 				4:  uint8(128),
   7610 				5:  uint8(128),
   7611 				6:  uint8(128),
   7612 				7:  uint8(128),
   7613 				8:  uint8(128),
   7614 				9:  uint8(128),
   7615 				10: uint8(128),
   7616 			},
   7617 			1: {
   7618 				0:  uint8(246),
   7619 				1:  uint8(1),
   7620 				2:  uint8(255),
   7621 				3:  uint8(128),
   7622 				4:  uint8(128),
   7623 				5:  uint8(128),
   7624 				6:  uint8(128),
   7625 				7:  uint8(128),
   7626 				8:  uint8(128),
   7627 				9:  uint8(128),
   7628 				10: uint8(128),
   7629 			},
   7630 			2: {
   7631 				0:  uint8(255),
   7632 				1:  uint8(128),
   7633 				2:  uint8(128),
   7634 				3:  uint8(128),
   7635 				4:  uint8(128),
   7636 				5:  uint8(128),
   7637 				6:  uint8(128),
   7638 				7:  uint8(128),
   7639 				8:  uint8(128),
   7640 				9:  uint8(128),
   7641 				10: uint8(128),
   7642 			},
   7643 		},
   7644 	},
   7645 	1: {
   7646 		0: {
   7647 			0: {
   7648 				0:  uint8(198),
   7649 				1:  uint8(35),
   7650 				2:  uint8(237),
   7651 				3:  uint8(223),
   7652 				4:  uint8(193),
   7653 				5:  uint8(187),
   7654 				6:  uint8(162),
   7655 				7:  uint8(160),
   7656 				8:  uint8(145),
   7657 				9:  uint8(155),
   7658 				10: uint8(62),
   7659 			},
   7660 			1: {
   7661 				0:  uint8(131),
   7662 				1:  uint8(45),
   7663 				2:  uint8(198),
   7664 				3:  uint8(221),
   7665 				4:  uint8(172),
   7666 				5:  uint8(176),
   7667 				6:  uint8(220),
   7668 				7:  uint8(157),
   7669 				8:  uint8(252),
   7670 				9:  uint8(221),
   7671 				10: uint8(1),
   7672 			},
   7673 			2: {
   7674 				0:  uint8(68),
   7675 				1:  uint8(47),
   7676 				2:  uint8(146),
   7677 				3:  uint8(208),
   7678 				4:  uint8(149),
   7679 				5:  uint8(167),
   7680 				6:  uint8(221),
   7681 				7:  uint8(162),
   7682 				8:  uint8(255),
   7683 				9:  uint8(223),
   7684 				10: uint8(128),
   7685 			},
   7686 		},
   7687 		1: {
   7688 			0: {
   7689 				0:  uint8(1),
   7690 				1:  uint8(149),
   7691 				2:  uint8(241),
   7692 				3:  uint8(255),
   7693 				4:  uint8(221),
   7694 				5:  uint8(224),
   7695 				6:  uint8(255),
   7696 				7:  uint8(255),
   7697 				8:  uint8(128),
   7698 				9:  uint8(128),
   7699 				10: uint8(128),
   7700 			},
   7701 			1: {
   7702 				0:  uint8(184),
   7703 				1:  uint8(141),
   7704 				2:  uint8(234),
   7705 				3:  uint8(253),
   7706 				4:  uint8(222),
   7707 				5:  uint8(220),
   7708 				6:  uint8(255),
   7709 				7:  uint8(199),
   7710 				8:  uint8(128),
   7711 				9:  uint8(128),
   7712 				10: uint8(128),
   7713 			},
   7714 			2: {
   7715 				0:  uint8(81),
   7716 				1:  uint8(99),
   7717 				2:  uint8(181),
   7718 				3:  uint8(242),
   7719 				4:  uint8(176),
   7720 				5:  uint8(190),
   7721 				6:  uint8(249),
   7722 				7:  uint8(202),
   7723 				8:  uint8(255),
   7724 				9:  uint8(255),
   7725 				10: uint8(128),
   7726 			},
   7727 		},
   7728 		2: {
   7729 			0: {
   7730 				0:  uint8(1),
   7731 				1:  uint8(129),
   7732 				2:  uint8(232),
   7733 				3:  uint8(253),
   7734 				4:  uint8(214),
   7735 				5:  uint8(197),
   7736 				6:  uint8(242),
   7737 				7:  uint8(196),
   7738 				8:  uint8(255),
   7739 				9:  uint8(255),
   7740 				10: uint8(128),
   7741 			},
   7742 			1: {
   7743 				0:  uint8(99),
   7744 				1:  uint8(121),
   7745 				2:  uint8(210),
   7746 				3:  uint8(250),
   7747 				4:  uint8(201),
   7748 				5:  uint8(198),
   7749 				6:  uint8(255),
   7750 				7:  uint8(202),
   7751 				8:  uint8(128),
   7752 				9:  uint8(128),
   7753 				10: uint8(128),
   7754 			},
   7755 			2: {
   7756 				0:  uint8(23),
   7757 				1:  uint8(91),
   7758 				2:  uint8(163),
   7759 				3:  uint8(242),
   7760 				4:  uint8(170),
   7761 				5:  uint8(187),
   7762 				6:  uint8(247),
   7763 				7:  uint8(210),
   7764 				8:  uint8(255),
   7765 				9:  uint8(255),
   7766 				10: uint8(128),
   7767 			},
   7768 		},
   7769 		3: {
   7770 			0: {
   7771 				0:  uint8(1),
   7772 				1:  uint8(200),
   7773 				2:  uint8(246),
   7774 				3:  uint8(255),
   7775 				4:  uint8(234),
   7776 				5:  uint8(255),
   7777 				6:  uint8(128),
   7778 				7:  uint8(128),
   7779 				8:  uint8(128),
   7780 				9:  uint8(128),
   7781 				10: uint8(128),
   7782 			},
   7783 			1: {
   7784 				0:  uint8(109),
   7785 				1:  uint8(178),
   7786 				2:  uint8(241),
   7787 				3:  uint8(255),
   7788 				4:  uint8(231),
   7789 				5:  uint8(245),
   7790 				6:  uint8(255),
   7791 				7:  uint8(255),
   7792 				8:  uint8(128),
   7793 				9:  uint8(128),
   7794 				10: uint8(128),
   7795 			},
   7796 			2: {
   7797 				0:  uint8(44),
   7798 				1:  uint8(130),
   7799 				2:  uint8(201),
   7800 				3:  uint8(253),
   7801 				4:  uint8(205),
   7802 				5:  uint8(192),
   7803 				6:  uint8(255),
   7804 				7:  uint8(255),
   7805 				8:  uint8(128),
   7806 				9:  uint8(128),
   7807 				10: uint8(128),
   7808 			},
   7809 		},
   7810 		4: {
   7811 			0: {
   7812 				0:  uint8(1),
   7813 				1:  uint8(132),
   7814 				2:  uint8(239),
   7815 				3:  uint8(251),
   7816 				4:  uint8(219),
   7817 				5:  uint8(209),
   7818 				6:  uint8(255),
   7819 				7:  uint8(165),
   7820 				8:  uint8(128),
   7821 				9:  uint8(128),
   7822 				10: uint8(128),
   7823 			},
   7824 			1: {
   7825 				0:  uint8(94),
   7826 				1:  uint8(136),
   7827 				2:  uint8(225),
   7828 				3:  uint8(251),
   7829 				4:  uint8(218),
   7830 				5:  uint8(190),
   7831 				6:  uint8(255),
   7832 				7:  uint8(255),
   7833 				8:  uint8(128),
   7834 				9:  uint8(128),
   7835 				10: uint8(128),
   7836 			},
   7837 			2: {
   7838 				0:  uint8(22),
   7839 				1:  uint8(100),
   7840 				2:  uint8(174),
   7841 				3:  uint8(245),
   7842 				4:  uint8(186),
   7843 				5:  uint8(161),
   7844 				6:  uint8(255),
   7845 				7:  uint8(199),
   7846 				8:  uint8(128),
   7847 				9:  uint8(128),
   7848 				10: uint8(128),
   7849 			},
   7850 		},
   7851 		5: {
   7852 			0: {
   7853 				0:  uint8(1),
   7854 				1:  uint8(182),
   7855 				2:  uint8(249),
   7856 				3:  uint8(255),
   7857 				4:  uint8(232),
   7858 				5:  uint8(235),
   7859 				6:  uint8(128),
   7860 				7:  uint8(128),
   7861 				8:  uint8(128),
   7862 				9:  uint8(128),
   7863 				10: uint8(128),
   7864 			},
   7865 			1: {
   7866 				0:  uint8(124),
   7867 				1:  uint8(143),
   7868 				2:  uint8(241),
   7869 				3:  uint8(255),
   7870 				4:  uint8(227),
   7871 				5:  uint8(234),
   7872 				6:  uint8(128),
   7873 				7:  uint8(128),
   7874 				8:  uint8(128),
   7875 				9:  uint8(128),
   7876 				10: uint8(128),
   7877 			},
   7878 			2: {
   7879 				0:  uint8(35),
   7880 				1:  uint8(77),
   7881 				2:  uint8(181),
   7882 				3:  uint8(251),
   7883 				4:  uint8(193),
   7884 				5:  uint8(211),
   7885 				6:  uint8(255),
   7886 				7:  uint8(205),
   7887 				8:  uint8(128),
   7888 				9:  uint8(128),
   7889 				10: uint8(128),
   7890 			},
   7891 		},
   7892 		6: {
   7893 			0: {
   7894 				0:  uint8(1),
   7895 				1:  uint8(157),
   7896 				2:  uint8(247),
   7897 				3:  uint8(255),
   7898 				4:  uint8(236),
   7899 				5:  uint8(231),
   7900 				6:  uint8(255),
   7901 				7:  uint8(255),
   7902 				8:  uint8(128),
   7903 				9:  uint8(128),
   7904 				10: uint8(128),
   7905 			},
   7906 			1: {
   7907 				0:  uint8(121),
   7908 				1:  uint8(141),
   7909 				2:  uint8(235),
   7910 				3:  uint8(255),
   7911 				4:  uint8(225),
   7912 				5:  uint8(227),
   7913 				6:  uint8(255),
   7914 				7:  uint8(255),
   7915 				8:  uint8(128),
   7916 				9:  uint8(128),
   7917 				10: uint8(128),
   7918 			},
   7919 			2: {
   7920 				0:  uint8(45),
   7921 				1:  uint8(99),
   7922 				2:  uint8(188),
   7923 				3:  uint8(251),
   7924 				4:  uint8(195),
   7925 				5:  uint8(217),
   7926 				6:  uint8(255),
   7927 				7:  uint8(224),
   7928 				8:  uint8(128),
   7929 				9:  uint8(128),
   7930 				10: uint8(128),
   7931 			},
   7932 		},
   7933 		7: {
   7934 			0: {
   7935 				0:  uint8(1),
   7936 				1:  uint8(1),
   7937 				2:  uint8(251),
   7938 				3:  uint8(255),
   7939 				4:  uint8(213),
   7940 				5:  uint8(255),
   7941 				6:  uint8(128),
   7942 				7:  uint8(128),
   7943 				8:  uint8(128),
   7944 				9:  uint8(128),
   7945 				10: uint8(128),
   7946 			},
   7947 			1: {
   7948 				0:  uint8(203),
   7949 				1:  uint8(1),
   7950 				2:  uint8(248),
   7951 				3:  uint8(255),
   7952 				4:  uint8(255),
   7953 				5:  uint8(128),
   7954 				6:  uint8(128),
   7955 				7:  uint8(128),
   7956 				8:  uint8(128),
   7957 				9:  uint8(128),
   7958 				10: uint8(128),
   7959 			},
   7960 			2: {
   7961 				0:  uint8(137),
   7962 				1:  uint8(1),
   7963 				2:  uint8(177),
   7964 				3:  uint8(255),
   7965 				4:  uint8(224),
   7966 				5:  uint8(255),
   7967 				6:  uint8(128),
   7968 				7:  uint8(128),
   7969 				8:  uint8(128),
   7970 				9:  uint8(128),
   7971 				10: uint8(128),
   7972 			},
   7973 		},
   7974 	},
   7975 	2: {
   7976 		0: {
   7977 			0: {
   7978 				0:  uint8(253),
   7979 				1:  uint8(9),
   7980 				2:  uint8(248),
   7981 				3:  uint8(251),
   7982 				4:  uint8(207),
   7983 				5:  uint8(208),
   7984 				6:  uint8(255),
   7985 				7:  uint8(192),
   7986 				8:  uint8(128),
   7987 				9:  uint8(128),
   7988 				10: uint8(128),
   7989 			},
   7990 			1: {
   7991 				0:  uint8(175),
   7992 				1:  uint8(13),
   7993 				2:  uint8(224),
   7994 				3:  uint8(243),
   7995 				4:  uint8(193),
   7996 				5:  uint8(185),
   7997 				6:  uint8(249),
   7998 				7:  uint8(198),
   7999 				8:  uint8(255),
   8000 				9:  uint8(255),
   8001 				10: uint8(128),
   8002 			},
   8003 			2: {
   8004 				0:  uint8(73),
   8005 				1:  uint8(17),
   8006 				2:  uint8(171),
   8007 				3:  uint8(221),
   8008 				4:  uint8(161),
   8009 				5:  uint8(179),
   8010 				6:  uint8(236),
   8011 				7:  uint8(167),
   8012 				8:  uint8(255),
   8013 				9:  uint8(234),
   8014 				10: uint8(128),
   8015 			},
   8016 		},
   8017 		1: {
   8018 			0: {
   8019 				0:  uint8(1),
   8020 				1:  uint8(95),
   8021 				2:  uint8(247),
   8022 				3:  uint8(253),
   8023 				4:  uint8(212),
   8024 				5:  uint8(183),
   8025 				6:  uint8(255),
   8026 				7:  uint8(255),
   8027 				8:  uint8(128),
   8028 				9:  uint8(128),
   8029 				10: uint8(128),
   8030 			},
   8031 			1: {
   8032 				0:  uint8(239),
   8033 				1:  uint8(90),
   8034 				2:  uint8(244),
   8035 				3:  uint8(250),
   8036 				4:  uint8(211),
   8037 				5:  uint8(209),
   8038 				6:  uint8(255),
   8039 				7:  uint8(255),
   8040 				8:  uint8(128),
   8041 				9:  uint8(128),
   8042 				10: uint8(128),
   8043 			},
   8044 			2: {
   8045 				0:  uint8(155),
   8046 				1:  uint8(77),
   8047 				2:  uint8(195),
   8048 				3:  uint8(248),
   8049 				4:  uint8(188),
   8050 				5:  uint8(195),
   8051 				6:  uint8(255),
   8052 				7:  uint8(255),
   8053 				8:  uint8(128),
   8054 				9:  uint8(128),
   8055 				10: uint8(128),
   8056 			},
   8057 		},
   8058 		2: {
   8059 			0: {
   8060 				0:  uint8(1),
   8061 				1:  uint8(24),
   8062 				2:  uint8(239),
   8063 				3:  uint8(251),
   8064 				4:  uint8(218),
   8065 				5:  uint8(219),
   8066 				6:  uint8(255),
   8067 				7:  uint8(205),
   8068 				8:  uint8(128),
   8069 				9:  uint8(128),
   8070 				10: uint8(128),
   8071 			},
   8072 			1: {
   8073 				0:  uint8(201),
   8074 				1:  uint8(51),
   8075 				2:  uint8(219),
   8076 				3:  uint8(255),
   8077 				4:  uint8(196),
   8078 				5:  uint8(186),
   8079 				6:  uint8(128),
   8080 				7:  uint8(128),
   8081 				8:  uint8(128),
   8082 				9:  uint8(128),
   8083 				10: uint8(128),
   8084 			},
   8085 			2: {
   8086 				0:  uint8(69),
   8087 				1:  uint8(46),
   8088 				2:  uint8(190),
   8089 				3:  uint8(239),
   8090 				4:  uint8(201),
   8091 				5:  uint8(218),
   8092 				6:  uint8(255),
   8093 				7:  uint8(228),
   8094 				8:  uint8(128),
   8095 				9:  uint8(128),
   8096 				10: uint8(128),
   8097 			},
   8098 		},
   8099 		3: {
   8100 			0: {
   8101 				0:  uint8(1),
   8102 				1:  uint8(191),
   8103 				2:  uint8(251),
   8104 				3:  uint8(255),
   8105 				4:  uint8(255),
   8106 				5:  uint8(128),
   8107 				6:  uint8(128),
   8108 				7:  uint8(128),
   8109 				8:  uint8(128),
   8110 				9:  uint8(128),
   8111 				10: uint8(128),
   8112 			},
   8113 			1: {
   8114 				0:  uint8(223),
   8115 				1:  uint8(165),
   8116 				2:  uint8(249),
   8117 				3:  uint8(255),
   8118 				4:  uint8(213),
   8119 				5:  uint8(255),
   8120 				6:  uint8(128),
   8121 				7:  uint8(128),
   8122 				8:  uint8(128),
   8123 				9:  uint8(128),
   8124 				10: uint8(128),
   8125 			},
   8126 			2: {
   8127 				0:  uint8(141),
   8128 				1:  uint8(124),
   8129 				2:  uint8(248),
   8130 				3:  uint8(255),
   8131 				4:  uint8(255),
   8132 				5:  uint8(128),
   8133 				6:  uint8(128),
   8134 				7:  uint8(128),
   8135 				8:  uint8(128),
   8136 				9:  uint8(128),
   8137 				10: uint8(128),
   8138 			},
   8139 		},
   8140 		4: {
   8141 			0: {
   8142 				0:  uint8(1),
   8143 				1:  uint8(16),
   8144 				2:  uint8(248),
   8145 				3:  uint8(255),
   8146 				4:  uint8(255),
   8147 				5:  uint8(128),
   8148 				6:  uint8(128),
   8149 				7:  uint8(128),
   8150 				8:  uint8(128),
   8151 				9:  uint8(128),
   8152 				10: uint8(128),
   8153 			},
   8154 			1: {
   8155 				0:  uint8(190),
   8156 				1:  uint8(36),
   8157 				2:  uint8(230),
   8158 				3:  uint8(255),
   8159 				4:  uint8(236),
   8160 				5:  uint8(255),
   8161 				6:  uint8(128),
   8162 				7:  uint8(128),
   8163 				8:  uint8(128),
   8164 				9:  uint8(128),
   8165 				10: uint8(128),
   8166 			},
   8167 			2: {
   8168 				0:  uint8(149),
   8169 				1:  uint8(1),
   8170 				2:  uint8(255),
   8171 				3:  uint8(128),
   8172 				4:  uint8(128),
   8173 				5:  uint8(128),
   8174 				6:  uint8(128),
   8175 				7:  uint8(128),
   8176 				8:  uint8(128),
   8177 				9:  uint8(128),
   8178 				10: uint8(128),
   8179 			},
   8180 		},
   8181 		5: {
   8182 			0: {
   8183 				0:  uint8(1),
   8184 				1:  uint8(226),
   8185 				2:  uint8(255),
   8186 				3:  uint8(128),
   8187 				4:  uint8(128),
   8188 				5:  uint8(128),
   8189 				6:  uint8(128),
   8190 				7:  uint8(128),
   8191 				8:  uint8(128),
   8192 				9:  uint8(128),
   8193 				10: uint8(128),
   8194 			},
   8195 			1: {
   8196 				0:  uint8(247),
   8197 				1:  uint8(192),
   8198 				2:  uint8(255),
   8199 				3:  uint8(128),
   8200 				4:  uint8(128),
   8201 				5:  uint8(128),
   8202 				6:  uint8(128),
   8203 				7:  uint8(128),
   8204 				8:  uint8(128),
   8205 				9:  uint8(128),
   8206 				10: uint8(128),
   8207 			},
   8208 			2: {
   8209 				0:  uint8(240),
   8210 				1:  uint8(128),
   8211 				2:  uint8(255),
   8212 				3:  uint8(128),
   8213 				4:  uint8(128),
   8214 				5:  uint8(128),
   8215 				6:  uint8(128),
   8216 				7:  uint8(128),
   8217 				8:  uint8(128),
   8218 				9:  uint8(128),
   8219 				10: uint8(128),
   8220 			},
   8221 		},
   8222 		6: {
   8223 			0: {
   8224 				0:  uint8(1),
   8225 				1:  uint8(134),
   8226 				2:  uint8(252),
   8227 				3:  uint8(255),
   8228 				4:  uint8(255),
   8229 				5:  uint8(128),
   8230 				6:  uint8(128),
   8231 				7:  uint8(128),
   8232 				8:  uint8(128),
   8233 				9:  uint8(128),
   8234 				10: uint8(128),
   8235 			},
   8236 			1: {
   8237 				0:  uint8(213),
   8238 				1:  uint8(62),
   8239 				2:  uint8(250),
   8240 				3:  uint8(255),
   8241 				4:  uint8(255),
   8242 				5:  uint8(128),
   8243 				6:  uint8(128),
   8244 				7:  uint8(128),
   8245 				8:  uint8(128),
   8246 				9:  uint8(128),
   8247 				10: uint8(128),
   8248 			},
   8249 			2: {
   8250 				0:  uint8(55),
   8251 				1:  uint8(93),
   8252 				2:  uint8(255),
   8253 				3:  uint8(128),
   8254 				4:  uint8(128),
   8255 				5:  uint8(128),
   8256 				6:  uint8(128),
   8257 				7:  uint8(128),
   8258 				8:  uint8(128),
   8259 				9:  uint8(128),
   8260 				10: uint8(128),
   8261 			},
   8262 		},
   8263 		7: {
   8264 			0: {
   8265 				0:  uint8(128),
   8266 				1:  uint8(128),
   8267 				2:  uint8(128),
   8268 				3:  uint8(128),
   8269 				4:  uint8(128),
   8270 				5:  uint8(128),
   8271 				6:  uint8(128),
   8272 				7:  uint8(128),
   8273 				8:  uint8(128),
   8274 				9:  uint8(128),
   8275 				10: uint8(128),
   8276 			},
   8277 			1: {
   8278 				0:  uint8(128),
   8279 				1:  uint8(128),
   8280 				2:  uint8(128),
   8281 				3:  uint8(128),
   8282 				4:  uint8(128),
   8283 				5:  uint8(128),
   8284 				6:  uint8(128),
   8285 				7:  uint8(128),
   8286 				8:  uint8(128),
   8287 				9:  uint8(128),
   8288 				10: uint8(128),
   8289 			},
   8290 			2: {
   8291 				0:  uint8(128),
   8292 				1:  uint8(128),
   8293 				2:  uint8(128),
   8294 				3:  uint8(128),
   8295 				4:  uint8(128),
   8296 				5:  uint8(128),
   8297 				6:  uint8(128),
   8298 				7:  uint8(128),
   8299 				8:  uint8(128),
   8300 				9:  uint8(128),
   8301 				10: uint8(128),
   8302 			},
   8303 		},
   8304 	},
   8305 	3: {
   8306 		0: {
   8307 			0: {
   8308 				0:  uint8(202),
   8309 				1:  uint8(24),
   8310 				2:  uint8(213),
   8311 				3:  uint8(235),
   8312 				4:  uint8(186),
   8313 				5:  uint8(191),
   8314 				6:  uint8(220),
   8315 				7:  uint8(160),
   8316 				8:  uint8(240),
   8317 				9:  uint8(175),
   8318 				10: uint8(255),
   8319 			},
   8320 			1: {
   8321 				0:  uint8(126),
   8322 				1:  uint8(38),
   8323 				2:  uint8(182),
   8324 				3:  uint8(232),
   8325 				4:  uint8(169),
   8326 				5:  uint8(184),
   8327 				6:  uint8(228),
   8328 				7:  uint8(174),
   8329 				8:  uint8(255),
   8330 				9:  uint8(187),
   8331 				10: uint8(128),
   8332 			},
   8333 			2: {
   8334 				0:  uint8(61),
   8335 				1:  uint8(46),
   8336 				2:  uint8(138),
   8337 				3:  uint8(219),
   8338 				4:  uint8(151),
   8339 				5:  uint8(178),
   8340 				6:  uint8(240),
   8341 				7:  uint8(170),
   8342 				8:  uint8(255),
   8343 				9:  uint8(216),
   8344 				10: uint8(128),
   8345 			},
   8346 		},
   8347 		1: {
   8348 			0: {
   8349 				0:  uint8(1),
   8350 				1:  uint8(112),
   8351 				2:  uint8(230),
   8352 				3:  uint8(250),
   8353 				4:  uint8(199),
   8354 				5:  uint8(191),
   8355 				6:  uint8(247),
   8356 				7:  uint8(159),
   8357 				8:  uint8(255),
   8358 				9:  uint8(255),
   8359 				10: uint8(128),
   8360 			},
   8361 			1: {
   8362 				0:  uint8(166),
   8363 				1:  uint8(109),
   8364 				2:  uint8(228),
   8365 				3:  uint8(252),
   8366 				4:  uint8(211),
   8367 				5:  uint8(215),
   8368 				6:  uint8(255),
   8369 				7:  uint8(174),
   8370 				8:  uint8(128),
   8371 				9:  uint8(128),
   8372 				10: uint8(128),
   8373 			},
   8374 			2: {
   8375 				0:  uint8(39),
   8376 				1:  uint8(77),
   8377 				2:  uint8(162),
   8378 				3:  uint8(232),
   8379 				4:  uint8(172),
   8380 				5:  uint8(180),
   8381 				6:  uint8(245),
   8382 				7:  uint8(178),
   8383 				8:  uint8(255),
   8384 				9:  uint8(255),
   8385 				10: uint8(128),
   8386 			},
   8387 		},
   8388 		2: {
   8389 			0: {
   8390 				0:  uint8(1),
   8391 				1:  uint8(52),
   8392 				2:  uint8(220),
   8393 				3:  uint8(246),
   8394 				4:  uint8(198),
   8395 				5:  uint8(199),
   8396 				6:  uint8(249),
   8397 				7:  uint8(220),
   8398 				8:  uint8(255),
   8399 				9:  uint8(255),
   8400 				10: uint8(128),
   8401 			},
   8402 			1: {
   8403 				0:  uint8(124),
   8404 				1:  uint8(74),
   8405 				2:  uint8(191),
   8406 				3:  uint8(243),
   8407 				4:  uint8(183),
   8408 				5:  uint8(193),
   8409 				6:  uint8(250),
   8410 				7:  uint8(221),
   8411 				8:  uint8(255),
   8412 				9:  uint8(255),
   8413 				10: uint8(128),
   8414 			},
   8415 			2: {
   8416 				0:  uint8(24),
   8417 				1:  uint8(71),
   8418 				2:  uint8(130),
   8419 				3:  uint8(219),
   8420 				4:  uint8(154),
   8421 				5:  uint8(170),
   8422 				6:  uint8(243),
   8423 				7:  uint8(182),
   8424 				8:  uint8(255),
   8425 				9:  uint8(255),
   8426 				10: uint8(128),
   8427 			},
   8428 		},
   8429 		3: {
   8430 			0: {
   8431 				0:  uint8(1),
   8432 				1:  uint8(182),
   8433 				2:  uint8(225),
   8434 				3:  uint8(249),
   8435 				4:  uint8(219),
   8436 				5:  uint8(240),
   8437 				6:  uint8(255),
   8438 				7:  uint8(224),
   8439 				8:  uint8(128),
   8440 				9:  uint8(128),
   8441 				10: uint8(128),
   8442 			},
   8443 			1: {
   8444 				0:  uint8(149),
   8445 				1:  uint8(150),
   8446 				2:  uint8(226),
   8447 				3:  uint8(252),
   8448 				4:  uint8(216),
   8449 				5:  uint8(205),
   8450 				6:  uint8(255),
   8451 				7:  uint8(171),
   8452 				8:  uint8(128),
   8453 				9:  uint8(128),
   8454 				10: uint8(128),
   8455 			},
   8456 			2: {
   8457 				0:  uint8(28),
   8458 				1:  uint8(108),
   8459 				2:  uint8(170),
   8460 				3:  uint8(242),
   8461 				4:  uint8(183),
   8462 				5:  uint8(194),
   8463 				6:  uint8(254),
   8464 				7:  uint8(223),
   8465 				8:  uint8(255),
   8466 				9:  uint8(255),
   8467 				10: uint8(128),
   8468 			},
   8469 		},
   8470 		4: {
   8471 			0: {
   8472 				0:  uint8(1),
   8473 				1:  uint8(81),
   8474 				2:  uint8(230),
   8475 				3:  uint8(252),
   8476 				4:  uint8(204),
   8477 				5:  uint8(203),
   8478 				6:  uint8(255),
   8479 				7:  uint8(192),
   8480 				8:  uint8(128),
   8481 				9:  uint8(128),
   8482 				10: uint8(128),
   8483 			},
   8484 			1: {
   8485 				0:  uint8(123),
   8486 				1:  uint8(102),
   8487 				2:  uint8(209),
   8488 				3:  uint8(247),
   8489 				4:  uint8(188),
   8490 				5:  uint8(196),
   8491 				6:  uint8(255),
   8492 				7:  uint8(233),
   8493 				8:  uint8(128),
   8494 				9:  uint8(128),
   8495 				10: uint8(128),
   8496 			},
   8497 			2: {
   8498 				0:  uint8(20),
   8499 				1:  uint8(95),
   8500 				2:  uint8(153),
   8501 				3:  uint8(243),
   8502 				4:  uint8(164),
   8503 				5:  uint8(173),
   8504 				6:  uint8(255),
   8505 				7:  uint8(203),
   8506 				8:  uint8(128),
   8507 				9:  uint8(128),
   8508 				10: uint8(128),
   8509 			},
   8510 		},
   8511 		5: {
   8512 			0: {
   8513 				0:  uint8(1),
   8514 				1:  uint8(222),
   8515 				2:  uint8(248),
   8516 				3:  uint8(255),
   8517 				4:  uint8(216),
   8518 				5:  uint8(213),
   8519 				6:  uint8(128),
   8520 				7:  uint8(128),
   8521 				8:  uint8(128),
   8522 				9:  uint8(128),
   8523 				10: uint8(128),
   8524 			},
   8525 			1: {
   8526 				0:  uint8(168),
   8527 				1:  uint8(175),
   8528 				2:  uint8(246),
   8529 				3:  uint8(252),
   8530 				4:  uint8(235),
   8531 				5:  uint8(205),
   8532 				6:  uint8(255),
   8533 				7:  uint8(255),
   8534 				8:  uint8(128),
   8535 				9:  uint8(128),
   8536 				10: uint8(128),
   8537 			},
   8538 			2: {
   8539 				0:  uint8(47),
   8540 				1:  uint8(116),
   8541 				2:  uint8(215),
   8542 				3:  uint8(255),
   8543 				4:  uint8(211),
   8544 				5:  uint8(212),
   8545 				6:  uint8(255),
   8546 				7:  uint8(255),
   8547 				8:  uint8(128),
   8548 				9:  uint8(128),
   8549 				10: uint8(128),
   8550 			},
   8551 		},
   8552 		6: {
   8553 			0: {
   8554 				0:  uint8(1),
   8555 				1:  uint8(121),
   8556 				2:  uint8(236),
   8557 				3:  uint8(253),
   8558 				4:  uint8(212),
   8559 				5:  uint8(214),
   8560 				6:  uint8(255),
   8561 				7:  uint8(255),
   8562 				8:  uint8(128),
   8563 				9:  uint8(128),
   8564 				10: uint8(128),
   8565 			},
   8566 			1: {
   8567 				0:  uint8(141),
   8568 				1:  uint8(84),
   8569 				2:  uint8(213),
   8570 				3:  uint8(252),
   8571 				4:  uint8(201),
   8572 				5:  uint8(202),
   8573 				6:  uint8(255),
   8574 				7:  uint8(219),
   8575 				8:  uint8(128),
   8576 				9:  uint8(128),
   8577 				10: uint8(128),
   8578 			},
   8579 			2: {
   8580 				0:  uint8(42),
   8581 				1:  uint8(80),
   8582 				2:  uint8(160),
   8583 				3:  uint8(240),
   8584 				4:  uint8(162),
   8585 				5:  uint8(185),
   8586 				6:  uint8(255),
   8587 				7:  uint8(205),
   8588 				8:  uint8(128),
   8589 				9:  uint8(128),
   8590 				10: uint8(128),
   8591 			},
   8592 		},
   8593 		7: {
   8594 			0: {
   8595 				0:  uint8(1),
   8596 				1:  uint8(1),
   8597 				2:  uint8(255),
   8598 				3:  uint8(128),
   8599 				4:  uint8(128),
   8600 				5:  uint8(128),
   8601 				6:  uint8(128),
   8602 				7:  uint8(128),
   8603 				8:  uint8(128),
   8604 				9:  uint8(128),
   8605 				10: uint8(128),
   8606 			},
   8607 			1: {
   8608 				0:  uint8(244),
   8609 				1:  uint8(1),
   8610 				2:  uint8(255),
   8611 				3:  uint8(128),
   8612 				4:  uint8(128),
   8613 				5:  uint8(128),
   8614 				6:  uint8(128),
   8615 				7:  uint8(128),
   8616 				8:  uint8(128),
   8617 				9:  uint8(128),
   8618 				10: uint8(128),
   8619 			},
   8620 			2: {
   8621 				0:  uint8(238),
   8622 				1:  uint8(1),
   8623 				2:  uint8(255),
   8624 				3:  uint8(128),
   8625 				4:  uint8(128),
   8626 				5:  uint8(128),
   8627 				6:  uint8(128),
   8628 				7:  uint8(128),
   8629 				8:  uint8(128),
   8630 				9:  uint8(128),
   8631 				10: uint8(128),
   8632 			},
   8633 		},
   8634 	},
   8635 }
   8636 
   8637 // C documentation
   8638 //
   8639 //	// Paragraph 11.5
   8640 var kBModesProba = [10][10][9]uint8_t{
   8641 	0: {
   8642 		0: {
   8643 			0: uint8(231),
   8644 			1: uint8(120),
   8645 			2: uint8(48),
   8646 			3: uint8(89),
   8647 			4: uint8(115),
   8648 			5: uint8(113),
   8649 			6: uint8(120),
   8650 			7: uint8(152),
   8651 			8: uint8(112),
   8652 		},
   8653 		1: {
   8654 			0: uint8(152),
   8655 			1: uint8(179),
   8656 			2: uint8(64),
   8657 			3: uint8(126),
   8658 			4: uint8(170),
   8659 			5: uint8(118),
   8660 			6: uint8(46),
   8661 			7: uint8(70),
   8662 			8: uint8(95),
   8663 		},
   8664 		2: {
   8665 			0: uint8(175),
   8666 			1: uint8(69),
   8667 			2: uint8(143),
   8668 			3: uint8(80),
   8669 			4: uint8(85),
   8670 			5: uint8(82),
   8671 			6: uint8(72),
   8672 			7: uint8(155),
   8673 			8: uint8(103),
   8674 		},
   8675 		3: {
   8676 			0: uint8(56),
   8677 			1: uint8(58),
   8678 			2: uint8(10),
   8679 			3: uint8(171),
   8680 			4: uint8(218),
   8681 			5: uint8(189),
   8682 			6: uint8(17),
   8683 			7: uint8(13),
   8684 			8: uint8(152),
   8685 		},
   8686 		4: {
   8687 			0: uint8(114),
   8688 			1: uint8(26),
   8689 			2: uint8(17),
   8690 			3: uint8(163),
   8691 			4: uint8(44),
   8692 			5: uint8(195),
   8693 			6: uint8(21),
   8694 			7: uint8(10),
   8695 			8: uint8(173),
   8696 		},
   8697 		5: {
   8698 			0: uint8(121),
   8699 			1: uint8(24),
   8700 			2: uint8(80),
   8701 			3: uint8(195),
   8702 			4: uint8(26),
   8703 			5: uint8(62),
   8704 			6: uint8(44),
   8705 			7: uint8(64),
   8706 			8: uint8(85),
   8707 		},
   8708 		6: {
   8709 			0: uint8(144),
   8710 			1: uint8(71),
   8711 			2: uint8(10),
   8712 			3: uint8(38),
   8713 			4: uint8(171),
   8714 			5: uint8(213),
   8715 			6: uint8(144),
   8716 			7: uint8(34),
   8717 			8: uint8(26),
   8718 		},
   8719 		7: {
   8720 			0: uint8(170),
   8721 			1: uint8(46),
   8722 			2: uint8(55),
   8723 			3: uint8(19),
   8724 			4: uint8(136),
   8725 			5: uint8(160),
   8726 			6: uint8(33),
   8727 			7: uint8(206),
   8728 			8: uint8(71),
   8729 		},
   8730 		8: {
   8731 			0: uint8(63),
   8732 			1: uint8(20),
   8733 			2: uint8(8),
   8734 			3: uint8(114),
   8735 			4: uint8(114),
   8736 			5: uint8(208),
   8737 			6: uint8(12),
   8738 			7: uint8(9),
   8739 			8: uint8(226),
   8740 		},
   8741 		9: {
   8742 			0: uint8(81),
   8743 			1: uint8(40),
   8744 			2: uint8(11),
   8745 			3: uint8(96),
   8746 			4: uint8(182),
   8747 			5: uint8(84),
   8748 			6: uint8(29),
   8749 			7: uint8(16),
   8750 			8: uint8(36),
   8751 		},
   8752 	},
   8753 	1: {
   8754 		0: {
   8755 			0: uint8(134),
   8756 			1: uint8(183),
   8757 			2: uint8(89),
   8758 			3: uint8(137),
   8759 			4: uint8(98),
   8760 			5: uint8(101),
   8761 			6: uint8(106),
   8762 			7: uint8(165),
   8763 			8: uint8(148),
   8764 		},
   8765 		1: {
   8766 			0: uint8(72),
   8767 			1: uint8(187),
   8768 			2: uint8(100),
   8769 			3: uint8(130),
   8770 			4: uint8(157),
   8771 			5: uint8(111),
   8772 			6: uint8(32),
   8773 			7: uint8(75),
   8774 			8: uint8(80),
   8775 		},
   8776 		2: {
   8777 			0: uint8(66),
   8778 			1: uint8(102),
   8779 			2: uint8(167),
   8780 			3: uint8(99),
   8781 			4: uint8(74),
   8782 			5: uint8(62),
   8783 			6: uint8(40),
   8784 			7: uint8(234),
   8785 			8: uint8(128),
   8786 		},
   8787 		3: {
   8788 			0: uint8(41),
   8789 			1: uint8(53),
   8790 			2: uint8(9),
   8791 			3: uint8(178),
   8792 			4: uint8(241),
   8793 			5: uint8(141),
   8794 			6: uint8(26),
   8795 			7: uint8(8),
   8796 			8: uint8(107),
   8797 		},
   8798 		4: {
   8799 			0: uint8(74),
   8800 			1: uint8(43),
   8801 			2: uint8(26),
   8802 			3: uint8(146),
   8803 			4: uint8(73),
   8804 			5: uint8(166),
   8805 			6: uint8(49),
   8806 			7: uint8(23),
   8807 			8: uint8(157),
   8808 		},
   8809 		5: {
   8810 			0: uint8(65),
   8811 			1: uint8(38),
   8812 			2: uint8(105),
   8813 			3: uint8(160),
   8814 			4: uint8(51),
   8815 			5: uint8(52),
   8816 			6: uint8(31),
   8817 			7: uint8(115),
   8818 			8: uint8(128),
   8819 		},
   8820 		6: {
   8821 			0: uint8(104),
   8822 			1: uint8(79),
   8823 			2: uint8(12),
   8824 			3: uint8(27),
   8825 			4: uint8(217),
   8826 			5: uint8(255),
   8827 			6: uint8(87),
   8828 			7: uint8(17),
   8829 			8: uint8(7),
   8830 		},
   8831 		7: {
   8832 			0: uint8(87),
   8833 			1: uint8(68),
   8834 			2: uint8(71),
   8835 			3: uint8(44),
   8836 			4: uint8(114),
   8837 			5: uint8(51),
   8838 			6: uint8(15),
   8839 			7: uint8(186),
   8840 			8: uint8(23),
   8841 		},
   8842 		8: {
   8843 			0: uint8(47),
   8844 			1: uint8(41),
   8845 			2: uint8(14),
   8846 			3: uint8(110),
   8847 			4: uint8(182),
   8848 			5: uint8(183),
   8849 			6: uint8(21),
   8850 			7: uint8(17),
   8851 			8: uint8(194),
   8852 		},
   8853 		9: {
   8854 			0: uint8(66),
   8855 			1: uint8(45),
   8856 			2: uint8(25),
   8857 			3: uint8(102),
   8858 			4: uint8(197),
   8859 			5: uint8(189),
   8860 			6: uint8(23),
   8861 			7: uint8(18),
   8862 			8: uint8(22),
   8863 		},
   8864 	},
   8865 	2: {
   8866 		0: {
   8867 			0: uint8(88),
   8868 			1: uint8(88),
   8869 			2: uint8(147),
   8870 			3: uint8(150),
   8871 			4: uint8(42),
   8872 			5: uint8(46),
   8873 			6: uint8(45),
   8874 			7: uint8(196),
   8875 			8: uint8(205),
   8876 		},
   8877 		1: {
   8878 			0: uint8(43),
   8879 			1: uint8(97),
   8880 			2: uint8(183),
   8881 			3: uint8(117),
   8882 			4: uint8(85),
   8883 			5: uint8(38),
   8884 			6: uint8(35),
   8885 			7: uint8(179),
   8886 			8: uint8(61),
   8887 		},
   8888 		2: {
   8889 			0: uint8(39),
   8890 			1: uint8(53),
   8891 			2: uint8(200),
   8892 			3: uint8(87),
   8893 			4: uint8(26),
   8894 			5: uint8(21),
   8895 			6: uint8(43),
   8896 			7: uint8(232),
   8897 			8: uint8(171),
   8898 		},
   8899 		3: {
   8900 			0: uint8(56),
   8901 			1: uint8(34),
   8902 			2: uint8(51),
   8903 			3: uint8(104),
   8904 			4: uint8(114),
   8905 			5: uint8(102),
   8906 			6: uint8(29),
   8907 			7: uint8(93),
   8908 			8: uint8(77),
   8909 		},
   8910 		4: {
   8911 			0: uint8(39),
   8912 			1: uint8(28),
   8913 			2: uint8(85),
   8914 			3: uint8(171),
   8915 			4: uint8(58),
   8916 			5: uint8(165),
   8917 			6: uint8(90),
   8918 			7: uint8(98),
   8919 			8: uint8(64),
   8920 		},
   8921 		5: {
   8922 			0: uint8(34),
   8923 			1: uint8(22),
   8924 			2: uint8(116),
   8925 			3: uint8(206),
   8926 			4: uint8(23),
   8927 			5: uint8(34),
   8928 			6: uint8(43),
   8929 			7: uint8(166),
   8930 			8: uint8(73),
   8931 		},
   8932 		6: {
   8933 			0: uint8(107),
   8934 			1: uint8(54),
   8935 			2: uint8(32),
   8936 			3: uint8(26),
   8937 			4: uint8(51),
   8938 			5: uint8(1),
   8939 			6: uint8(81),
   8940 			7: uint8(43),
   8941 			8: uint8(31),
   8942 		},
   8943 		7: {
   8944 			0: uint8(68),
   8945 			1: uint8(25),
   8946 			2: uint8(106),
   8947 			3: uint8(22),
   8948 			4: uint8(64),
   8949 			5: uint8(171),
   8950 			6: uint8(36),
   8951 			7: uint8(225),
   8952 			8: uint8(114),
   8953 		},
   8954 		8: {
   8955 			0: uint8(34),
   8956 			1: uint8(19),
   8957 			2: uint8(21),
   8958 			3: uint8(102),
   8959 			4: uint8(132),
   8960 			5: uint8(188),
   8961 			6: uint8(16),
   8962 			7: uint8(76),
   8963 			8: uint8(124),
   8964 		},
   8965 		9: {
   8966 			0: uint8(62),
   8967 			1: uint8(18),
   8968 			2: uint8(78),
   8969 			3: uint8(95),
   8970 			4: uint8(85),
   8971 			5: uint8(57),
   8972 			6: uint8(50),
   8973 			7: uint8(48),
   8974 			8: uint8(51),
   8975 		},
   8976 	},
   8977 	3: {
   8978 		0: {
   8979 			0: uint8(193),
   8980 			1: uint8(101),
   8981 			2: uint8(35),
   8982 			3: uint8(159),
   8983 			4: uint8(215),
   8984 			5: uint8(111),
   8985 			6: uint8(89),
   8986 			7: uint8(46),
   8987 			8: uint8(111),
   8988 		},
   8989 		1: {
   8990 			0: uint8(60),
   8991 			1: uint8(148),
   8992 			2: uint8(31),
   8993 			3: uint8(172),
   8994 			4: uint8(219),
   8995 			5: uint8(228),
   8996 			6: uint8(21),
   8997 			7: uint8(18),
   8998 			8: uint8(111),
   8999 		},
   9000 		2: {
   9001 			0: uint8(112),
   9002 			1: uint8(113),
   9003 			2: uint8(77),
   9004 			3: uint8(85),
   9005 			4: uint8(179),
   9006 			5: uint8(255),
   9007 			6: uint8(38),
   9008 			7: uint8(120),
   9009 			8: uint8(114),
   9010 		},
   9011 		3: {
   9012 			0: uint8(40),
   9013 			1: uint8(42),
   9014 			2: uint8(1),
   9015 			3: uint8(196),
   9016 			4: uint8(245),
   9017 			5: uint8(209),
   9018 			6: uint8(10),
   9019 			7: uint8(25),
   9020 			8: uint8(109),
   9021 		},
   9022 		4: {
   9023 			0: uint8(88),
   9024 			1: uint8(43),
   9025 			2: uint8(29),
   9026 			3: uint8(140),
   9027 			4: uint8(166),
   9028 			5: uint8(213),
   9029 			6: uint8(37),
   9030 			7: uint8(43),
   9031 			8: uint8(154),
   9032 		},
   9033 		5: {
   9034 			0: uint8(61),
   9035 			1: uint8(63),
   9036 			2: uint8(30),
   9037 			3: uint8(155),
   9038 			4: uint8(67),
   9039 			5: uint8(45),
   9040 			6: uint8(68),
   9041 			7: uint8(1),
   9042 			8: uint8(209),
   9043 		},
   9044 		6: {
   9045 			0: uint8(100),
   9046 			1: uint8(80),
   9047 			2: uint8(8),
   9048 			3: uint8(43),
   9049 			4: uint8(154),
   9050 			5: uint8(1),
   9051 			6: uint8(51),
   9052 			7: uint8(26),
   9053 			8: uint8(71),
   9054 		},
   9055 		7: {
   9056 			0: uint8(142),
   9057 			1: uint8(78),
   9058 			2: uint8(78),
   9059 			3: uint8(16),
   9060 			4: uint8(255),
   9061 			5: uint8(128),
   9062 			6: uint8(34),
   9063 			7: uint8(197),
   9064 			8: uint8(171),
   9065 		},
   9066 		8: {
   9067 			0: uint8(41),
   9068 			1: uint8(40),
   9069 			2: uint8(5),
   9070 			3: uint8(102),
   9071 			4: uint8(211),
   9072 			5: uint8(183),
   9073 			6: uint8(4),
   9074 			7: uint8(1),
   9075 			8: uint8(221),
   9076 		},
   9077 		9: {
   9078 			0: uint8(51),
   9079 			1: uint8(50),
   9080 			2: uint8(17),
   9081 			3: uint8(168),
   9082 			4: uint8(209),
   9083 			5: uint8(192),
   9084 			6: uint8(23),
   9085 			7: uint8(25),
   9086 			8: uint8(82),
   9087 		},
   9088 	},
   9089 	4: {
   9090 		0: {
   9091 			0: uint8(138),
   9092 			1: uint8(31),
   9093 			2: uint8(36),
   9094 			3: uint8(171),
   9095 			4: uint8(27),
   9096 			5: uint8(166),
   9097 			6: uint8(38),
   9098 			7: uint8(44),
   9099 			8: uint8(229),
   9100 		},
   9101 		1: {
   9102 			0: uint8(67),
   9103 			1: uint8(87),
   9104 			2: uint8(58),
   9105 			3: uint8(169),
   9106 			4: uint8(82),
   9107 			5: uint8(115),
   9108 			6: uint8(26),
   9109 			7: uint8(59),
   9110 			8: uint8(179),
   9111 		},
   9112 		2: {
   9113 			0: uint8(63),
   9114 			1: uint8(59),
   9115 			2: uint8(90),
   9116 			3: uint8(180),
   9117 			4: uint8(59),
   9118 			5: uint8(166),
   9119 			6: uint8(93),
   9120 			7: uint8(73),
   9121 			8: uint8(154),
   9122 		},
   9123 		3: {
   9124 			0: uint8(40),
   9125 			1: uint8(40),
   9126 			2: uint8(21),
   9127 			3: uint8(116),
   9128 			4: uint8(143),
   9129 			5: uint8(209),
   9130 			6: uint8(34),
   9131 			7: uint8(39),
   9132 			8: uint8(175),
   9133 		},
   9134 		4: {
   9135 			0: uint8(47),
   9136 			1: uint8(15),
   9137 			2: uint8(16),
   9138 			3: uint8(183),
   9139 			4: uint8(34),
   9140 			5: uint8(223),
   9141 			6: uint8(49),
   9142 			7: uint8(45),
   9143 			8: uint8(183),
   9144 		},
   9145 		5: {
   9146 			0: uint8(46),
   9147 			1: uint8(17),
   9148 			2: uint8(33),
   9149 			3: uint8(183),
   9150 			4: uint8(6),
   9151 			5: uint8(98),
   9152 			6: uint8(15),
   9153 			7: uint8(32),
   9154 			8: uint8(183),
   9155 		},
   9156 		6: {
   9157 			0: uint8(57),
   9158 			1: uint8(46),
   9159 			2: uint8(22),
   9160 			3: uint8(24),
   9161 			4: uint8(128),
   9162 			5: uint8(1),
   9163 			6: uint8(54),
   9164 			7: uint8(17),
   9165 			8: uint8(37),
   9166 		},
   9167 		7: {
   9168 			0: uint8(65),
   9169 			1: uint8(32),
   9170 			2: uint8(73),
   9171 			3: uint8(115),
   9172 			4: uint8(28),
   9173 			5: uint8(128),
   9174 			6: uint8(23),
   9175 			7: uint8(128),
   9176 			8: uint8(205),
   9177 		},
   9178 		8: {
   9179 			0: uint8(40),
   9180 			1: uint8(3),
   9181 			2: uint8(9),
   9182 			3: uint8(115),
   9183 			4: uint8(51),
   9184 			5: uint8(192),
   9185 			6: uint8(18),
   9186 			7: uint8(6),
   9187 			8: uint8(223),
   9188 		},
   9189 		9: {
   9190 			0: uint8(87),
   9191 			1: uint8(37),
   9192 			2: uint8(9),
   9193 			3: uint8(115),
   9194 			4: uint8(59),
   9195 			5: uint8(77),
   9196 			6: uint8(64),
   9197 			7: uint8(21),
   9198 			8: uint8(47),
   9199 		},
   9200 	},
   9201 	5: {
   9202 		0: {
   9203 			0: uint8(104),
   9204 			1: uint8(55),
   9205 			2: uint8(44),
   9206 			3: uint8(218),
   9207 			4: uint8(9),
   9208 			5: uint8(54),
   9209 			6: uint8(53),
   9210 			7: uint8(130),
   9211 			8: uint8(226),
   9212 		},
   9213 		1: {
   9214 			0: uint8(64),
   9215 			1: uint8(90),
   9216 			2: uint8(70),
   9217 			3: uint8(205),
   9218 			4: uint8(40),
   9219 			5: uint8(41),
   9220 			6: uint8(23),
   9221 			7: uint8(26),
   9222 			8: uint8(57),
   9223 		},
   9224 		2: {
   9225 			0: uint8(54),
   9226 			1: uint8(57),
   9227 			2: uint8(112),
   9228 			3: uint8(184),
   9229 			4: uint8(5),
   9230 			5: uint8(41),
   9231 			6: uint8(38),
   9232 			7: uint8(166),
   9233 			8: uint8(213),
   9234 		},
   9235 		3: {
   9236 			0: uint8(30),
   9237 			1: uint8(34),
   9238 			2: uint8(26),
   9239 			3: uint8(133),
   9240 			4: uint8(152),
   9241 			5: uint8(116),
   9242 			6: uint8(10),
   9243 			7: uint8(32),
   9244 			8: uint8(134),
   9245 		},
   9246 		4: {
   9247 			0: uint8(39),
   9248 			1: uint8(19),
   9249 			2: uint8(53),
   9250 			3: uint8(221),
   9251 			4: uint8(26),
   9252 			5: uint8(114),
   9253 			6: uint8(32),
   9254 			7: uint8(73),
   9255 			8: uint8(255),
   9256 		},
   9257 		5: {
   9258 			0: uint8(31),
   9259 			1: uint8(9),
   9260 			2: uint8(65),
   9261 			3: uint8(234),
   9262 			4: uint8(2),
   9263 			5: uint8(15),
   9264 			6: uint8(1),
   9265 			7: uint8(118),
   9266 			8: uint8(73),
   9267 		},
   9268 		6: {
   9269 			0: uint8(75),
   9270 			1: uint8(32),
   9271 			2: uint8(12),
   9272 			3: uint8(51),
   9273 			4: uint8(192),
   9274 			5: uint8(255),
   9275 			6: uint8(160),
   9276 			7: uint8(43),
   9277 			8: uint8(51),
   9278 		},
   9279 		7: {
   9280 			0: uint8(88),
   9281 			1: uint8(31),
   9282 			2: uint8(35),
   9283 			3: uint8(67),
   9284 			4: uint8(102),
   9285 			5: uint8(85),
   9286 			6: uint8(55),
   9287 			7: uint8(186),
   9288 			8: uint8(85),
   9289 		},
   9290 		8: {
   9291 			0: uint8(56),
   9292 			1: uint8(21),
   9293 			2: uint8(23),
   9294 			3: uint8(111),
   9295 			4: uint8(59),
   9296 			5: uint8(205),
   9297 			6: uint8(45),
   9298 			7: uint8(37),
   9299 			8: uint8(192),
   9300 		},
   9301 		9: {
   9302 			0: uint8(55),
   9303 			1: uint8(38),
   9304 			2: uint8(70),
   9305 			3: uint8(124),
   9306 			4: uint8(73),
   9307 			5: uint8(102),
   9308 			6: uint8(1),
   9309 			7: uint8(34),
   9310 			8: uint8(98),
   9311 		},
   9312 	},
   9313 	6: {
   9314 		0: {
   9315 			0: uint8(125),
   9316 			1: uint8(98),
   9317 			2: uint8(42),
   9318 			3: uint8(88),
   9319 			4: uint8(104),
   9320 			5: uint8(85),
   9321 			6: uint8(117),
   9322 			7: uint8(175),
   9323 			8: uint8(82),
   9324 		},
   9325 		1: {
   9326 			0: uint8(95),
   9327 			1: uint8(84),
   9328 			2: uint8(53),
   9329 			3: uint8(89),
   9330 			4: uint8(128),
   9331 			5: uint8(100),
   9332 			6: uint8(113),
   9333 			7: uint8(101),
   9334 			8: uint8(45),
   9335 		},
   9336 		2: {
   9337 			0: uint8(75),
   9338 			1: uint8(79),
   9339 			2: uint8(123),
   9340 			3: uint8(47),
   9341 			4: uint8(51),
   9342 			5: uint8(128),
   9343 			6: uint8(81),
   9344 			7: uint8(171),
   9345 			8: uint8(1),
   9346 		},
   9347 		3: {
   9348 			0: uint8(57),
   9349 			1: uint8(17),
   9350 			2: uint8(5),
   9351 			3: uint8(71),
   9352 			4: uint8(102),
   9353 			5: uint8(57),
   9354 			6: uint8(53),
   9355 			7: uint8(41),
   9356 			8: uint8(49),
   9357 		},
   9358 		4: {
   9359 			0: uint8(38),
   9360 			1: uint8(33),
   9361 			2: uint8(13),
   9362 			3: uint8(121),
   9363 			4: uint8(57),
   9364 			5: uint8(73),
   9365 			6: uint8(26),
   9366 			7: uint8(1),
   9367 			8: uint8(85),
   9368 		},
   9369 		5: {
   9370 			0: uint8(41),
   9371 			1: uint8(10),
   9372 			2: uint8(67),
   9373 			3: uint8(138),
   9374 			4: uint8(77),
   9375 			5: uint8(110),
   9376 			6: uint8(90),
   9377 			7: uint8(47),
   9378 			8: uint8(114),
   9379 		},
   9380 		6: {
   9381 			0: uint8(115),
   9382 			1: uint8(21),
   9383 			2: uint8(2),
   9384 			3: uint8(10),
   9385 			4: uint8(102),
   9386 			5: uint8(255),
   9387 			6: uint8(166),
   9388 			7: uint8(23),
   9389 			8: uint8(6),
   9390 		},
   9391 		7: {
   9392 			0: uint8(101),
   9393 			1: uint8(29),
   9394 			2: uint8(16),
   9395 			3: uint8(10),
   9396 			4: uint8(85),
   9397 			5: uint8(128),
   9398 			6: uint8(101),
   9399 			7: uint8(196),
   9400 			8: uint8(26),
   9401 		},
   9402 		8: {
   9403 			0: uint8(57),
   9404 			1: uint8(18),
   9405 			2: uint8(10),
   9406 			3: uint8(102),
   9407 			4: uint8(102),
   9408 			5: uint8(213),
   9409 			6: uint8(34),
   9410 			7: uint8(20),
   9411 			8: uint8(43),
   9412 		},
   9413 		9: {
   9414 			0: uint8(117),
   9415 			1: uint8(20),
   9416 			2: uint8(15),
   9417 			3: uint8(36),
   9418 			4: uint8(163),
   9419 			5: uint8(128),
   9420 			6: uint8(68),
   9421 			7: uint8(1),
   9422 			8: uint8(26),
   9423 		},
   9424 	},
   9425 	7: {
   9426 		0: {
   9427 			0: uint8(102),
   9428 			1: uint8(61),
   9429 			2: uint8(71),
   9430 			3: uint8(37),
   9431 			4: uint8(34),
   9432 			5: uint8(53),
   9433 			6: uint8(31),
   9434 			7: uint8(243),
   9435 			8: uint8(192),
   9436 		},
   9437 		1: {
   9438 			0: uint8(69),
   9439 			1: uint8(60),
   9440 			2: uint8(71),
   9441 			3: uint8(38),
   9442 			4: uint8(73),
   9443 			5: uint8(119),
   9444 			6: uint8(28),
   9445 			7: uint8(222),
   9446 			8: uint8(37),
   9447 		},
   9448 		2: {
   9449 			0: uint8(68),
   9450 			1: uint8(45),
   9451 			2: uint8(128),
   9452 			3: uint8(34),
   9453 			4: uint8(1),
   9454 			5: uint8(47),
   9455 			6: uint8(11),
   9456 			7: uint8(245),
   9457 			8: uint8(171),
   9458 		},
   9459 		3: {
   9460 			0: uint8(62),
   9461 			1: uint8(17),
   9462 			2: uint8(19),
   9463 			3: uint8(70),
   9464 			4: uint8(146),
   9465 			5: uint8(85),
   9466 			6: uint8(55),
   9467 			7: uint8(62),
   9468 			8: uint8(70),
   9469 		},
   9470 		4: {
   9471 			0: uint8(37),
   9472 			1: uint8(43),
   9473 			2: uint8(37),
   9474 			3: uint8(154),
   9475 			4: uint8(100),
   9476 			5: uint8(163),
   9477 			6: uint8(85),
   9478 			7: uint8(160),
   9479 			8: uint8(1),
   9480 		},
   9481 		5: {
   9482 			0: uint8(63),
   9483 			1: uint8(9),
   9484 			2: uint8(92),
   9485 			3: uint8(136),
   9486 			4: uint8(28),
   9487 			5: uint8(64),
   9488 			6: uint8(32),
   9489 			7: uint8(201),
   9490 			8: uint8(85),
   9491 		},
   9492 		6: {
   9493 			0: uint8(75),
   9494 			1: uint8(15),
   9495 			2: uint8(9),
   9496 			3: uint8(9),
   9497 			4: uint8(64),
   9498 			5: uint8(255),
   9499 			6: uint8(184),
   9500 			7: uint8(119),
   9501 			8: uint8(16),
   9502 		},
   9503 		7: {
   9504 			0: uint8(86),
   9505 			1: uint8(6),
   9506 			2: uint8(28),
   9507 			3: uint8(5),
   9508 			4: uint8(64),
   9509 			5: uint8(255),
   9510 			6: uint8(25),
   9511 			7: uint8(248),
   9512 			8: uint8(1),
   9513 		},
   9514 		8: {
   9515 			0: uint8(56),
   9516 			1: uint8(8),
   9517 			2: uint8(17),
   9518 			3: uint8(132),
   9519 			4: uint8(137),
   9520 			5: uint8(255),
   9521 			6: uint8(55),
   9522 			7: uint8(116),
   9523 			8: uint8(128),
   9524 		},
   9525 		9: {
   9526 			0: uint8(58),
   9527 			1: uint8(15),
   9528 			2: uint8(20),
   9529 			3: uint8(82),
   9530 			4: uint8(135),
   9531 			5: uint8(57),
   9532 			6: uint8(26),
   9533 			7: uint8(121),
   9534 			8: uint8(40),
   9535 		},
   9536 	},
   9537 	8: {
   9538 		0: {
   9539 			0: uint8(164),
   9540 			1: uint8(50),
   9541 			2: uint8(31),
   9542 			3: uint8(137),
   9543 			4: uint8(154),
   9544 			5: uint8(133),
   9545 			6: uint8(25),
   9546 			7: uint8(35),
   9547 			8: uint8(218),
   9548 		},
   9549 		1: {
   9550 			0: uint8(51),
   9551 			1: uint8(103),
   9552 			2: uint8(44),
   9553 			3: uint8(131),
   9554 			4: uint8(131),
   9555 			5: uint8(123),
   9556 			6: uint8(31),
   9557 			7: uint8(6),
   9558 			8: uint8(158),
   9559 		},
   9560 		2: {
   9561 			0: uint8(86),
   9562 			1: uint8(40),
   9563 			2: uint8(64),
   9564 			3: uint8(135),
   9565 			4: uint8(148),
   9566 			5: uint8(224),
   9567 			6: uint8(45),
   9568 			7: uint8(183),
   9569 			8: uint8(128),
   9570 		},
   9571 		3: {
   9572 			0: uint8(22),
   9573 			1: uint8(26),
   9574 			2: uint8(17),
   9575 			3: uint8(131),
   9576 			4: uint8(240),
   9577 			5: uint8(154),
   9578 			6: uint8(14),
   9579 			7: uint8(1),
   9580 			8: uint8(209),
   9581 		},
   9582 		4: {
   9583 			0: uint8(45),
   9584 			1: uint8(16),
   9585 			2: uint8(21),
   9586 			3: uint8(91),
   9587 			4: uint8(64),
   9588 			5: uint8(222),
   9589 			6: uint8(7),
   9590 			7: uint8(1),
   9591 			8: uint8(197),
   9592 		},
   9593 		5: {
   9594 			0: uint8(56),
   9595 			1: uint8(21),
   9596 			2: uint8(39),
   9597 			3: uint8(155),
   9598 			4: uint8(60),
   9599 			5: uint8(138),
   9600 			6: uint8(23),
   9601 			7: uint8(102),
   9602 			8: uint8(213),
   9603 		},
   9604 		6: {
   9605 			0: uint8(83),
   9606 			1: uint8(12),
   9607 			2: uint8(13),
   9608 			3: uint8(54),
   9609 			4: uint8(192),
   9610 			5: uint8(255),
   9611 			6: uint8(68),
   9612 			7: uint8(47),
   9613 			8: uint8(28),
   9614 		},
   9615 		7: {
   9616 			0: uint8(85),
   9617 			1: uint8(26),
   9618 			2: uint8(85),
   9619 			3: uint8(85),
   9620 			4: uint8(128),
   9621 			5: uint8(128),
   9622 			6: uint8(32),
   9623 			7: uint8(146),
   9624 			8: uint8(171),
   9625 		},
   9626 		8: {
   9627 			0: uint8(18),
   9628 			1: uint8(11),
   9629 			2: uint8(7),
   9630 			3: uint8(63),
   9631 			4: uint8(144),
   9632 			5: uint8(171),
   9633 			6: uint8(4),
   9634 			7: uint8(4),
   9635 			8: uint8(246),
   9636 		},
   9637 		9: {
   9638 			0: uint8(35),
   9639 			1: uint8(27),
   9640 			2: uint8(10),
   9641 			3: uint8(146),
   9642 			4: uint8(174),
   9643 			5: uint8(171),
   9644 			6: uint8(12),
   9645 			7: uint8(26),
   9646 			8: uint8(128),
   9647 		},
   9648 	},
   9649 	9: {
   9650 		0: {
   9651 			0: uint8(190),
   9652 			1: uint8(80),
   9653 			2: uint8(35),
   9654 			3: uint8(99),
   9655 			4: uint8(180),
   9656 			5: uint8(80),
   9657 			6: uint8(126),
   9658 			7: uint8(54),
   9659 			8: uint8(45),
   9660 		},
   9661 		1: {
   9662 			0: uint8(85),
   9663 			1: uint8(126),
   9664 			2: uint8(47),
   9665 			3: uint8(87),
   9666 			4: uint8(176),
   9667 			5: uint8(51),
   9668 			6: uint8(41),
   9669 			7: uint8(20),
   9670 			8: uint8(32),
   9671 		},
   9672 		2: {
   9673 			0: uint8(101),
   9674 			1: uint8(75),
   9675 			2: uint8(128),
   9676 			3: uint8(139),
   9677 			4: uint8(118),
   9678 			5: uint8(146),
   9679 			6: uint8(116),
   9680 			7: uint8(128),
   9681 			8: uint8(85),
   9682 		},
   9683 		3: {
   9684 			0: uint8(56),
   9685 			1: uint8(41),
   9686 			2: uint8(15),
   9687 			3: uint8(176),
   9688 			4: uint8(236),
   9689 			5: uint8(85),
   9690 			6: uint8(37),
   9691 			7: uint8(9),
   9692 			8: uint8(62),
   9693 		},
   9694 		4: {
   9695 			0: uint8(71),
   9696 			1: uint8(30),
   9697 			2: uint8(17),
   9698 			3: uint8(119),
   9699 			4: uint8(118),
   9700 			5: uint8(255),
   9701 			6: uint8(17),
   9702 			7: uint8(18),
   9703 			8: uint8(138),
   9704 		},
   9705 		5: {
   9706 			0: uint8(101),
   9707 			1: uint8(38),
   9708 			2: uint8(60),
   9709 			3: uint8(138),
   9710 			4: uint8(55),
   9711 			5: uint8(70),
   9712 			6: uint8(43),
   9713 			7: uint8(26),
   9714 			8: uint8(142),
   9715 		},
   9716 		6: {
   9717 			0: uint8(146),
   9718 			1: uint8(36),
   9719 			2: uint8(19),
   9720 			3: uint8(30),
   9721 			4: uint8(171),
   9722 			5: uint8(255),
   9723 			6: uint8(97),
   9724 			7: uint8(27),
   9725 			8: uint8(20),
   9726 		},
   9727 		7: {
   9728 			0: uint8(138),
   9729 			1: uint8(45),
   9730 			2: uint8(61),
   9731 			3: uint8(62),
   9732 			4: uint8(219),
   9733 			5: uint8(1),
   9734 			6: uint8(81),
   9735 			7: uint8(188),
   9736 			8: uint8(64),
   9737 		},
   9738 		8: {
   9739 			0: uint8(32),
   9740 			1: uint8(41),
   9741 			2: uint8(20),
   9742 			3: uint8(117),
   9743 			4: uint8(151),
   9744 			5: uint8(142),
   9745 			6: uint8(20),
   9746 			7: uint8(21),
   9747 			8: uint8(163),
   9748 		},
   9749 		9: {
   9750 			0: uint8(112),
   9751 			1: uint8(19),
   9752 			2: uint8(12),
   9753 			3: uint8(61),
   9754 			4: uint8(195),
   9755 			5: uint8(128),
   9756 			6: uint8(48),
   9757 			7: uint8(4),
   9758 			8: uint8(24),
   9759 		},
   9760 	},
   9761 }
   9762 
   9763 func VP8ResetProba(tls *libc.TLS, proba uintptr) {
   9764 	libc.X__builtin___memset_chk(tls, proba, libc.Int32FromUint32(255), uint64(3), ^__predefined_size_t(0))
   9765 	// proba->bands[][] is initialized later
   9766 }
   9767 
   9768 func ParseIntraMode(tls *libc.TLS, br2 uintptr, dec uintptr, mb_x int32) {
   9769 	bp := tls.Alloc(16)
   9770 	defer tls.Free(16)
   9771 	var bit, i, pos, shift, x1, y, ymode, ymode1, v1, v14, v16, v22, v24, v30, v32, v6, v8 int32
   9772 	var bits bit_t
   9773 	var block, left, modes, prob1, top, v10, v11, v18, v19, v2, v3 uintptr
   9774 	var range1, split, value range_t
   9775 	var v12, v20, v4 uint64_t
   9776 	var _ /* in_bits at bp+0 */ lbit_t
   9777 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, block, i, left, modes, pos, prob1, range1, shift, split, top, value, x1, y, ymode, ymode1, v1, v10, v11, v12, v14, v16, v18, v19, v2, v20, v22, v24, v3, v30, v32, v4, v6, v8
   9778 	top = (*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t + uintptr(int32(4)*mb_x)
   9779 	left = dec + 2816
   9780 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr(mb_x)*800
   9781 	// Note: we don't save segment map (yet), as we don't expect
   9782 	// to decode more than 1 keyframe.
   9783 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fupdate_map != 0 {
   9784 		// Hardcoded tree parsing
   9785 		v2 = br2
   9786 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9787 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9788 			v3 = v2
   9789 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9790 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9791 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9792 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9793 				goto _5
   9794 			_5:
   9795 				bits = v4
   9796 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9797 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9798 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9799 			} else {
   9800 				VP8LoadFinalBytes(tls, v3)
   9801 			}
   9802 		}
   9803 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9804 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192)))) >> int32(8)
   9805 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9806 		bit = libc.BoolInt32(value > split)
   9807 		if bit != 0 {
   9808 			range1 = range1 - split
   9809 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9810 		} else {
   9811 			range1 = split + uint32(1)
   9812 		}
   9813 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9814 		goto _7
   9815 	_7:
   9816 		shift = int32(7) ^ v6
   9817 		range1 = range1 << libc.Uint32FromInt32(shift)
   9818 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9819 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9820 		v8 = bit
   9821 		goto _9
   9822 	_9:
   9823 		if !(v8 != 0) {
   9824 			v10 = br2
   9825 			range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
   9826 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
   9827 				v11 = v10
   9828 				if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
   9829 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9830 					**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9831 					v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9832 					goto _13
   9833 				_13:
   9834 					bits = v12
   9835 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9836 					(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
   9837 					**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
   9838 				} else {
   9839 					VP8LoadFinalBytes(tls, v11)
   9840 				}
   9841 			}
   9842 			pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
   9843 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192 + 1)))) >> int32(8)
   9844 			value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
   9845 			bit = libc.BoolInt32(value > split)
   9846 			if bit != 0 {
   9847 				range1 = range1 - split
   9848 				**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9849 			} else {
   9850 				range1 = split + uint32(1)
   9851 			}
   9852 			v14 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9853 			goto _15
   9854 		_15:
   9855 			shift = int32(7) ^ v14
   9856 			range1 = range1 << libc.Uint32FromInt32(shift)
   9857 			**(**int32)(__ccgo_up(v10 + 12)) -= shift
   9858 			(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
   9859 			v16 = bit
   9860 			goto _17
   9861 		_17:
   9862 			v1 = v16
   9863 		} else {
   9864 			v18 = br2
   9865 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
   9866 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
   9867 				v19 = v18
   9868 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
   9869 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9870 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9871 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9872 					goto _21
   9873 				_21:
   9874 					bits = v20
   9875 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9876 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
   9877 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
   9878 				} else {
   9879 					VP8LoadFinalBytes(tls, v19)
   9880 				}
   9881 			}
   9882 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
   9883 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192 + 2)))) >> int32(8)
   9884 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
   9885 			bit = libc.BoolInt32(value > split)
   9886 			if bit != 0 {
   9887 				range1 = range1 - split
   9888 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9889 			} else {
   9890 				range1 = split + uint32(1)
   9891 			}
   9892 			v22 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9893 			goto _23
   9894 		_23:
   9895 			shift = int32(7) ^ v22
   9896 			range1 = range1 << libc.Uint32FromInt32(shift)
   9897 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
   9898 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
   9899 			v24 = bit
   9900 			goto _25
   9901 		_25:
   9902 			v1 = v24 + int32(2)
   9903 		}
   9904 		(*VP8MBData)(unsafe.Pointer(block)).Fsegment = libc.Uint8FromInt32(v1)
   9905 	} else {
   9906 		(*VP8MBData)(unsafe.Pointer(block)).Fsegment = uint8(0) // default for intra
   9907 	}
   9908 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
   9909 		v2 = br2
   9910 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9911 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9912 			v3 = v2
   9913 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9914 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9915 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9916 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9917 				goto _29
   9918 			_29:
   9919 				bits = v4
   9920 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9921 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9922 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9923 			} else {
   9924 				VP8LoadFinalBytes(tls, v3)
   9925 			}
   9926 		}
   9927 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9928 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8((*VP8Decoder)(unsafe.Pointer(dec)).Fskip_p)) >> int32(8)
   9929 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9930 		bit = libc.BoolInt32(value > split)
   9931 		if bit != 0 {
   9932 			range1 = range1 - split
   9933 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9934 		} else {
   9935 			range1 = split + uint32(1)
   9936 		}
   9937 		v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9938 		goto _31
   9939 	_31:
   9940 		shift = int32(7) ^ v1
   9941 		range1 = range1 << libc.Uint32FromInt32(shift)
   9942 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9943 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9944 		v6 = bit
   9945 		goto _33
   9946 	_33:
   9947 		(*VP8MBData)(unsafe.Pointer(block)).Fskip = libc.Uint8FromInt32(v6)
   9948 	}
   9949 	v2 = br2
   9950 	range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9951 	if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9952 		v3 = v2
   9953 		if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9954 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9955 			**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9956 			v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9957 			goto _37
   9958 		_37:
   9959 			bits = v4
   9960 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9961 			(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9962 			**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9963 		} else {
   9964 			VP8LoadFinalBytes(tls, v3)
   9965 		}
   9966 	}
   9967 	pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9968 	split = range1 * libc.Uint32FromInt32(int32(145)) >> int32(8)
   9969 	value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9970 	bit = libc.BoolInt32(value > split)
   9971 	if bit != 0 {
   9972 		range1 = range1 - split
   9973 		**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9974 	} else {
   9975 		range1 = split + uint32(1)
   9976 	}
   9977 	v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9978 	goto _39
   9979 _39:
   9980 	shift = int32(7) ^ v1
   9981 	range1 = range1 << libc.Uint32FromInt32(shift)
   9982 	**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9983 	(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9984 	v6 = bit
   9985 	goto _41
   9986 _41:
   9987 	(*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 = libc.BoolUint8(!(v6 != 0))
   9988 	if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) {
   9989 		v2 = br2
   9990 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9991 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9992 			v3 = v2
   9993 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9994 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9995 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9996 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9997 				goto _46
   9998 			_46:
   9999 				bits = v4
  10000 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10001 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10002 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10003 			} else {
  10004 				VP8LoadFinalBytes(tls, v3)
  10005 			}
  10006 		}
  10007 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10008 		split = range1 * libc.Uint32FromInt32(int32(156)) >> int32(8)
  10009 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10010 		bit = libc.BoolInt32(value > split)
  10011 		if bit != 0 {
  10012 			range1 = range1 - split
  10013 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10014 		} else {
  10015 			range1 = split + uint32(1)
  10016 		}
  10017 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10018 		goto _48
  10019 	_48:
  10020 		shift = int32(7) ^ v6
  10021 		range1 = range1 << libc.Uint32FromInt32(shift)
  10022 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10023 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10024 		v8 = bit
  10025 		goto _50
  10026 	_50:
  10027 		if v8 != 0 {
  10028 			v10 = br2
  10029 			range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10030 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10031 				v11 = v10
  10032 				if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10033 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10034 					**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10035 					v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10036 					goto _55
  10037 				_55:
  10038 					bits = v12
  10039 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10040 					(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10041 					**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10042 				} else {
  10043 					VP8LoadFinalBytes(tls, v11)
  10044 				}
  10045 			}
  10046 			pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10047 			split = range1 * libc.Uint32FromInt32(int32(128)) >> int32(8)
  10048 			value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10049 			bit = libc.BoolInt32(value > split)
  10050 			if bit != 0 {
  10051 				range1 = range1 - split
  10052 				**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10053 			} else {
  10054 				range1 = split + uint32(1)
  10055 			}
  10056 			v16 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10057 			goto _57
  10058 		_57:
  10059 			shift = int32(7) ^ v16
  10060 			range1 = range1 << libc.Uint32FromInt32(shift)
  10061 			**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10062 			(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10063 			v22 = bit
  10064 			goto _59
  10065 		_59:
  10066 			if v22 != 0 {
  10067 				v14 = int32(TM_PRED)
  10068 			} else {
  10069 				v14 = int32(H_PRED)
  10070 			}
  10071 			v1 = v14
  10072 		} else {
  10073 			v18 = br2
  10074 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
  10075 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
  10076 				v19 = v18
  10077 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
  10078 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10079 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10080 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10081 					goto _64
  10082 				_64:
  10083 					bits = v20
  10084 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10085 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
  10086 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
  10087 				} else {
  10088 					VP8LoadFinalBytes(tls, v19)
  10089 				}
  10090 			}
  10091 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
  10092 			split = range1 * libc.Uint32FromInt32(int32(163)) >> int32(8)
  10093 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
  10094 			bit = libc.BoolInt32(value > split)
  10095 			if bit != 0 {
  10096 				range1 = range1 - split
  10097 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10098 			} else {
  10099 				range1 = split + uint32(1)
  10100 			}
  10101 			v30 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10102 			goto _66
  10103 		_66:
  10104 			shift = int32(7) ^ v30
  10105 			range1 = range1 << libc.Uint32FromInt32(shift)
  10106 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
  10107 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
  10108 			v32 = bit
  10109 			goto _68
  10110 		_68:
  10111 			if v32 != 0 {
  10112 				v24 = int32(V_PRED)
  10113 			} else {
  10114 				v24 = int32(DC_PRED)
  10115 			}
  10116 			v1 = v24
  10117 		}
  10118 		// Hardcoded 16x16 intra-mode decision tree.
  10119 		ymode = v1
  10120 		**(**uint8_t)(__ccgo_up(block + 769)) = libc.Uint8FromInt32(ymode)
  10121 		libc.X__builtin___memset_chk(tls, top, ymode, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10122 		libc.X__builtin___memset_chk(tls, left, ymode, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10123 	} else {
  10124 		modes = block + 769
  10125 		y = 0
  10126 		for {
  10127 			if !(y < int32(4)) {
  10128 				break
  10129 			}
  10130 			ymode1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(y))))
  10131 			x1 = 0
  10132 			for {
  10133 				if !(x1 < int32(4)) {
  10134 					break
  10135 				}
  10136 				prob1 = uintptr(unsafe.Pointer(&kBModesProba)) + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x1))))*90 + uintptr(ymode1)*9
  10137 				v2 = br2
  10138 				range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  10139 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  10140 					v3 = v2
  10141 					if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  10142 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10143 						**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10144 						v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10145 						goto _74
  10146 					_74:
  10147 						bits = v4
  10148 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10149 						(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10150 						**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10151 					} else {
  10152 						VP8LoadFinalBytes(tls, v3)
  10153 					}
  10154 				}
  10155 				pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10156 				split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob1)))) >> int32(8)
  10157 				value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10158 				bit = libc.BoolInt32(value > split)
  10159 				if bit != 0 {
  10160 					range1 = range1 - split
  10161 					**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10162 				} else {
  10163 					range1 = split + uint32(1)
  10164 				}
  10165 				v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10166 				goto _76
  10167 			_76:
  10168 				shift = int32(7) ^ v1
  10169 				range1 = range1 << libc.Uint32FromInt32(shift)
  10170 				**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10171 				(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10172 				v6 = bit
  10173 				goto _78
  10174 			_78:
  10175 				// Generic tree-parsing
  10176 				i = int32(kYModesIntra4[v6])
  10177 				for i > 0 {
  10178 					v10 = br2
  10179 					range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10180 					if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10181 						v11 = v10
  10182 						if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10183 							libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10184 							**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10185 							v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10186 							goto _82
  10187 						_82:
  10188 							bits = v12
  10189 							bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10190 							(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10191 							**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10192 						} else {
  10193 							VP8LoadFinalBytes(tls, v11)
  10194 						}
  10195 					}
  10196 					pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10197 					split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob1 + uintptr(i))))) >> int32(8)
  10198 					value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10199 					bit = libc.BoolInt32(value > split)
  10200 					if bit != 0 {
  10201 						range1 = range1 - split
  10202 						**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10203 					} else {
  10204 						range1 = split + uint32(1)
  10205 					}
  10206 					v8 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10207 					goto _84
  10208 				_84:
  10209 					shift = int32(7) ^ v8
  10210 					range1 = range1 << libc.Uint32FromInt32(shift)
  10211 					**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10212 					(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10213 					v14 = bit
  10214 					goto _86
  10215 				_86:
  10216 					i = int32(kYModesIntra4[int32(2)*i+v14])
  10217 				}
  10218 				ymode1 = -i
  10219 				**(**uint8_t)(__ccgo_up(top + uintptr(x1))) = libc.Uint8FromInt32(ymode1)
  10220 				goto _70
  10221 			_70:
  10222 				;
  10223 				x1 = x1 + 1
  10224 			}
  10225 			libc.X__builtin___memcpy_chk(tls, modes, top, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10226 			modes = modes + uintptr(4)
  10227 			**(**uint8_t)(__ccgo_up(left + uintptr(y))) = libc.Uint8FromInt32(ymode1)
  10228 			goto _69
  10229 		_69:
  10230 			;
  10231 			y = y + 1
  10232 		}
  10233 	}
  10234 	// Hardcoded UVMode decision tree
  10235 	v2 = br2
  10236 	range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  10237 	if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  10238 		v3 = v2
  10239 		if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  10240 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10241 			**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10242 			v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10243 			goto _91
  10244 		_91:
  10245 			bits = v4
  10246 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10247 			(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10248 			**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10249 		} else {
  10250 			VP8LoadFinalBytes(tls, v3)
  10251 		}
  10252 	}
  10253 	pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10254 	split = range1 * libc.Uint32FromInt32(int32(142)) >> int32(8)
  10255 	value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10256 	bit = libc.BoolInt32(value > split)
  10257 	if bit != 0 {
  10258 		range1 = range1 - split
  10259 		**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10260 	} else {
  10261 		range1 = split + uint32(1)
  10262 	}
  10263 	v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10264 	goto _93
  10265 _93:
  10266 	shift = int32(7) ^ v6
  10267 	range1 = range1 << libc.Uint32FromInt32(shift)
  10268 	**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10269 	(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10270 	v8 = bit
  10271 	goto _95
  10272 _95:
  10273 	if !(v8 != 0) {
  10274 		v1 = int32(DC_PRED)
  10275 	} else {
  10276 		v10 = br2
  10277 		range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10278 		if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10279 			v11 = v10
  10280 			if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10281 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10282 				**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10283 				v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10284 				goto _100
  10285 			_100:
  10286 				bits = v12
  10287 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10288 				(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10289 				**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10290 			} else {
  10291 				VP8LoadFinalBytes(tls, v11)
  10292 			}
  10293 		}
  10294 		pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10295 		split = range1 * libc.Uint32FromInt32(int32(114)) >> int32(8)
  10296 		value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10297 		bit = libc.BoolInt32(value > split)
  10298 		if bit != 0 {
  10299 			range1 = range1 - split
  10300 			**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10301 		} else {
  10302 			range1 = split + uint32(1)
  10303 		}
  10304 		v16 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10305 		goto _102
  10306 	_102:
  10307 		shift = int32(7) ^ v16
  10308 		range1 = range1 << libc.Uint32FromInt32(shift)
  10309 		**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10310 		(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10311 		v22 = bit
  10312 		goto _104
  10313 	_104:
  10314 		if !(v22 != 0) {
  10315 			v14 = int32(V_PRED)
  10316 		} else {
  10317 			v18 = br2
  10318 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
  10319 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
  10320 				v19 = v18
  10321 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
  10322 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10323 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10324 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10325 					goto _109
  10326 				_109:
  10327 					bits = v20
  10328 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10329 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
  10330 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
  10331 				} else {
  10332 					VP8LoadFinalBytes(tls, v19)
  10333 				}
  10334 			}
  10335 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
  10336 			split = range1 * libc.Uint32FromInt32(int32(183)) >> int32(8)
  10337 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
  10338 			bit = libc.BoolInt32(value > split)
  10339 			if bit != 0 {
  10340 				range1 = range1 - split
  10341 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10342 			} else {
  10343 				range1 = split + uint32(1)
  10344 			}
  10345 			v30 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10346 			goto _111
  10347 		_111:
  10348 			shift = int32(7) ^ v30
  10349 			range1 = range1 << libc.Uint32FromInt32(shift)
  10350 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
  10351 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
  10352 			v32 = bit
  10353 			goto _113
  10354 		_113:
  10355 			if v32 != 0 {
  10356 				v24 = int32(TM_PRED)
  10357 			} else {
  10358 				v24 = int32(H_PRED)
  10359 			}
  10360 			v14 = v24
  10361 		}
  10362 		v1 = v14
  10363 	}
  10364 	(*VP8MBData)(unsafe.Pointer(block)).Fuvmode = libc.Uint8FromInt32(v1)
  10365 }
  10366 
  10367 func VP8ParseIntraModeRow(tls *libc.TLS, br uintptr, dec uintptr) (r int32) {
  10368 	var mb_x int32
  10369 	_ = mb_x
  10370 	mb_x = 0
  10371 	for {
  10372 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
  10373 			break
  10374 		}
  10375 		ParseIntraMode(tls, br, dec, mb_x)
  10376 		goto _1
  10377 	_1:
  10378 		;
  10379 		mb_x = mb_x + 1
  10380 	}
  10381 	return libc.BoolInt32(!((*VP8Decoder)(unsafe.Pointer(dec)).Fbr.Feof != 0))
  10382 }
  10383 
  10384 //------------------------------------------------------------------------------
  10385 // Paragraph 13
  10386 
  10387 var CoeffsUpdateProba = [4][8][3][11]uint8_t{
  10388 	0: {
  10389 		0: {
  10390 			0: {
  10391 				0:  uint8(255),
  10392 				1:  uint8(255),
  10393 				2:  uint8(255),
  10394 				3:  uint8(255),
  10395 				4:  uint8(255),
  10396 				5:  uint8(255),
  10397 				6:  uint8(255),
  10398 				7:  uint8(255),
  10399 				8:  uint8(255),
  10400 				9:  uint8(255),
  10401 				10: uint8(255),
  10402 			},
  10403 			1: {
  10404 				0:  uint8(255),
  10405 				1:  uint8(255),
  10406 				2:  uint8(255),
  10407 				3:  uint8(255),
  10408 				4:  uint8(255),
  10409 				5:  uint8(255),
  10410 				6:  uint8(255),
  10411 				7:  uint8(255),
  10412 				8:  uint8(255),
  10413 				9:  uint8(255),
  10414 				10: uint8(255),
  10415 			},
  10416 			2: {
  10417 				0:  uint8(255),
  10418 				1:  uint8(255),
  10419 				2:  uint8(255),
  10420 				3:  uint8(255),
  10421 				4:  uint8(255),
  10422 				5:  uint8(255),
  10423 				6:  uint8(255),
  10424 				7:  uint8(255),
  10425 				8:  uint8(255),
  10426 				9:  uint8(255),
  10427 				10: uint8(255),
  10428 			},
  10429 		},
  10430 		1: {
  10431 			0: {
  10432 				0:  uint8(176),
  10433 				1:  uint8(246),
  10434 				2:  uint8(255),
  10435 				3:  uint8(255),
  10436 				4:  uint8(255),
  10437 				5:  uint8(255),
  10438 				6:  uint8(255),
  10439 				7:  uint8(255),
  10440 				8:  uint8(255),
  10441 				9:  uint8(255),
  10442 				10: uint8(255),
  10443 			},
  10444 			1: {
  10445 				0:  uint8(223),
  10446 				1:  uint8(241),
  10447 				2:  uint8(252),
  10448 				3:  uint8(255),
  10449 				4:  uint8(255),
  10450 				5:  uint8(255),
  10451 				6:  uint8(255),
  10452 				7:  uint8(255),
  10453 				8:  uint8(255),
  10454 				9:  uint8(255),
  10455 				10: uint8(255),
  10456 			},
  10457 			2: {
  10458 				0:  uint8(249),
  10459 				1:  uint8(253),
  10460 				2:  uint8(253),
  10461 				3:  uint8(255),
  10462 				4:  uint8(255),
  10463 				5:  uint8(255),
  10464 				6:  uint8(255),
  10465 				7:  uint8(255),
  10466 				8:  uint8(255),
  10467 				9:  uint8(255),
  10468 				10: uint8(255),
  10469 			},
  10470 		},
  10471 		2: {
  10472 			0: {
  10473 				0:  uint8(255),
  10474 				1:  uint8(244),
  10475 				2:  uint8(252),
  10476 				3:  uint8(255),
  10477 				4:  uint8(255),
  10478 				5:  uint8(255),
  10479 				6:  uint8(255),
  10480 				7:  uint8(255),
  10481 				8:  uint8(255),
  10482 				9:  uint8(255),
  10483 				10: uint8(255),
  10484 			},
  10485 			1: {
  10486 				0:  uint8(234),
  10487 				1:  uint8(254),
  10488 				2:  uint8(254),
  10489 				3:  uint8(255),
  10490 				4:  uint8(255),
  10491 				5:  uint8(255),
  10492 				6:  uint8(255),
  10493 				7:  uint8(255),
  10494 				8:  uint8(255),
  10495 				9:  uint8(255),
  10496 				10: uint8(255),
  10497 			},
  10498 			2: {
  10499 				0:  uint8(253),
  10500 				1:  uint8(255),
  10501 				2:  uint8(255),
  10502 				3:  uint8(255),
  10503 				4:  uint8(255),
  10504 				5:  uint8(255),
  10505 				6:  uint8(255),
  10506 				7:  uint8(255),
  10507 				8:  uint8(255),
  10508 				9:  uint8(255),
  10509 				10: uint8(255),
  10510 			},
  10511 		},
  10512 		3: {
  10513 			0: {
  10514 				0:  uint8(255),
  10515 				1:  uint8(246),
  10516 				2:  uint8(254),
  10517 				3:  uint8(255),
  10518 				4:  uint8(255),
  10519 				5:  uint8(255),
  10520 				6:  uint8(255),
  10521 				7:  uint8(255),
  10522 				8:  uint8(255),
  10523 				9:  uint8(255),
  10524 				10: uint8(255),
  10525 			},
  10526 			1: {
  10527 				0:  uint8(239),
  10528 				1:  uint8(253),
  10529 				2:  uint8(254),
  10530 				3:  uint8(255),
  10531 				4:  uint8(255),
  10532 				5:  uint8(255),
  10533 				6:  uint8(255),
  10534 				7:  uint8(255),
  10535 				8:  uint8(255),
  10536 				9:  uint8(255),
  10537 				10: uint8(255),
  10538 			},
  10539 			2: {
  10540 				0:  uint8(254),
  10541 				1:  uint8(255),
  10542 				2:  uint8(254),
  10543 				3:  uint8(255),
  10544 				4:  uint8(255),
  10545 				5:  uint8(255),
  10546 				6:  uint8(255),
  10547 				7:  uint8(255),
  10548 				8:  uint8(255),
  10549 				9:  uint8(255),
  10550 				10: uint8(255),
  10551 			},
  10552 		},
  10553 		4: {
  10554 			0: {
  10555 				0:  uint8(255),
  10556 				1:  uint8(248),
  10557 				2:  uint8(254),
  10558 				3:  uint8(255),
  10559 				4:  uint8(255),
  10560 				5:  uint8(255),
  10561 				6:  uint8(255),
  10562 				7:  uint8(255),
  10563 				8:  uint8(255),
  10564 				9:  uint8(255),
  10565 				10: uint8(255),
  10566 			},
  10567 			1: {
  10568 				0:  uint8(251),
  10569 				1:  uint8(255),
  10570 				2:  uint8(254),
  10571 				3:  uint8(255),
  10572 				4:  uint8(255),
  10573 				5:  uint8(255),
  10574 				6:  uint8(255),
  10575 				7:  uint8(255),
  10576 				8:  uint8(255),
  10577 				9:  uint8(255),
  10578 				10: uint8(255),
  10579 			},
  10580 			2: {
  10581 				0:  uint8(255),
  10582 				1:  uint8(255),
  10583 				2:  uint8(255),
  10584 				3:  uint8(255),
  10585 				4:  uint8(255),
  10586 				5:  uint8(255),
  10587 				6:  uint8(255),
  10588 				7:  uint8(255),
  10589 				8:  uint8(255),
  10590 				9:  uint8(255),
  10591 				10: uint8(255),
  10592 			},
  10593 		},
  10594 		5: {
  10595 			0: {
  10596 				0:  uint8(255),
  10597 				1:  uint8(253),
  10598 				2:  uint8(254),
  10599 				3:  uint8(255),
  10600 				4:  uint8(255),
  10601 				5:  uint8(255),
  10602 				6:  uint8(255),
  10603 				7:  uint8(255),
  10604 				8:  uint8(255),
  10605 				9:  uint8(255),
  10606 				10: uint8(255),
  10607 			},
  10608 			1: {
  10609 				0:  uint8(251),
  10610 				1:  uint8(254),
  10611 				2:  uint8(254),
  10612 				3:  uint8(255),
  10613 				4:  uint8(255),
  10614 				5:  uint8(255),
  10615 				6:  uint8(255),
  10616 				7:  uint8(255),
  10617 				8:  uint8(255),
  10618 				9:  uint8(255),
  10619 				10: uint8(255),
  10620 			},
  10621 			2: {
  10622 				0:  uint8(254),
  10623 				1:  uint8(255),
  10624 				2:  uint8(254),
  10625 				3:  uint8(255),
  10626 				4:  uint8(255),
  10627 				5:  uint8(255),
  10628 				6:  uint8(255),
  10629 				7:  uint8(255),
  10630 				8:  uint8(255),
  10631 				9:  uint8(255),
  10632 				10: uint8(255),
  10633 			},
  10634 		},
  10635 		6: {
  10636 			0: {
  10637 				0:  uint8(255),
  10638 				1:  uint8(254),
  10639 				2:  uint8(253),
  10640 				3:  uint8(255),
  10641 				4:  uint8(254),
  10642 				5:  uint8(255),
  10643 				6:  uint8(255),
  10644 				7:  uint8(255),
  10645 				8:  uint8(255),
  10646 				9:  uint8(255),
  10647 				10: uint8(255),
  10648 			},
  10649 			1: {
  10650 				0:  uint8(250),
  10651 				1:  uint8(255),
  10652 				2:  uint8(254),
  10653 				3:  uint8(255),
  10654 				4:  uint8(254),
  10655 				5:  uint8(255),
  10656 				6:  uint8(255),
  10657 				7:  uint8(255),
  10658 				8:  uint8(255),
  10659 				9:  uint8(255),
  10660 				10: uint8(255),
  10661 			},
  10662 			2: {
  10663 				0:  uint8(254),
  10664 				1:  uint8(255),
  10665 				2:  uint8(255),
  10666 				3:  uint8(255),
  10667 				4:  uint8(255),
  10668 				5:  uint8(255),
  10669 				6:  uint8(255),
  10670 				7:  uint8(255),
  10671 				8:  uint8(255),
  10672 				9:  uint8(255),
  10673 				10: uint8(255),
  10674 			},
  10675 		},
  10676 		7: {
  10677 			0: {
  10678 				0:  uint8(255),
  10679 				1:  uint8(255),
  10680 				2:  uint8(255),
  10681 				3:  uint8(255),
  10682 				4:  uint8(255),
  10683 				5:  uint8(255),
  10684 				6:  uint8(255),
  10685 				7:  uint8(255),
  10686 				8:  uint8(255),
  10687 				9:  uint8(255),
  10688 				10: uint8(255),
  10689 			},
  10690 			1: {
  10691 				0:  uint8(255),
  10692 				1:  uint8(255),
  10693 				2:  uint8(255),
  10694 				3:  uint8(255),
  10695 				4:  uint8(255),
  10696 				5:  uint8(255),
  10697 				6:  uint8(255),
  10698 				7:  uint8(255),
  10699 				8:  uint8(255),
  10700 				9:  uint8(255),
  10701 				10: uint8(255),
  10702 			},
  10703 			2: {
  10704 				0:  uint8(255),
  10705 				1:  uint8(255),
  10706 				2:  uint8(255),
  10707 				3:  uint8(255),
  10708 				4:  uint8(255),
  10709 				5:  uint8(255),
  10710 				6:  uint8(255),
  10711 				7:  uint8(255),
  10712 				8:  uint8(255),
  10713 				9:  uint8(255),
  10714 				10: uint8(255),
  10715 			},
  10716 		},
  10717 	},
  10718 	1: {
  10719 		0: {
  10720 			0: {
  10721 				0:  uint8(217),
  10722 				1:  uint8(255),
  10723 				2:  uint8(255),
  10724 				3:  uint8(255),
  10725 				4:  uint8(255),
  10726 				5:  uint8(255),
  10727 				6:  uint8(255),
  10728 				7:  uint8(255),
  10729 				8:  uint8(255),
  10730 				9:  uint8(255),
  10731 				10: uint8(255),
  10732 			},
  10733 			1: {
  10734 				0:  uint8(225),
  10735 				1:  uint8(252),
  10736 				2:  uint8(241),
  10737 				3:  uint8(253),
  10738 				4:  uint8(255),
  10739 				5:  uint8(255),
  10740 				6:  uint8(254),
  10741 				7:  uint8(255),
  10742 				8:  uint8(255),
  10743 				9:  uint8(255),
  10744 				10: uint8(255),
  10745 			},
  10746 			2: {
  10747 				0:  uint8(234),
  10748 				1:  uint8(250),
  10749 				2:  uint8(241),
  10750 				3:  uint8(250),
  10751 				4:  uint8(253),
  10752 				5:  uint8(255),
  10753 				6:  uint8(253),
  10754 				7:  uint8(254),
  10755 				8:  uint8(255),
  10756 				9:  uint8(255),
  10757 				10: uint8(255),
  10758 			},
  10759 		},
  10760 		1: {
  10761 			0: {
  10762 				0:  uint8(255),
  10763 				1:  uint8(254),
  10764 				2:  uint8(255),
  10765 				3:  uint8(255),
  10766 				4:  uint8(255),
  10767 				5:  uint8(255),
  10768 				6:  uint8(255),
  10769 				7:  uint8(255),
  10770 				8:  uint8(255),
  10771 				9:  uint8(255),
  10772 				10: uint8(255),
  10773 			},
  10774 			1: {
  10775 				0:  uint8(223),
  10776 				1:  uint8(254),
  10777 				2:  uint8(254),
  10778 				3:  uint8(255),
  10779 				4:  uint8(255),
  10780 				5:  uint8(255),
  10781 				6:  uint8(255),
  10782 				7:  uint8(255),
  10783 				8:  uint8(255),
  10784 				9:  uint8(255),
  10785 				10: uint8(255),
  10786 			},
  10787 			2: {
  10788 				0:  uint8(238),
  10789 				1:  uint8(253),
  10790 				2:  uint8(254),
  10791 				3:  uint8(254),
  10792 				4:  uint8(255),
  10793 				5:  uint8(255),
  10794 				6:  uint8(255),
  10795 				7:  uint8(255),
  10796 				8:  uint8(255),
  10797 				9:  uint8(255),
  10798 				10: uint8(255),
  10799 			},
  10800 		},
  10801 		2: {
  10802 			0: {
  10803 				0:  uint8(255),
  10804 				1:  uint8(248),
  10805 				2:  uint8(254),
  10806 				3:  uint8(255),
  10807 				4:  uint8(255),
  10808 				5:  uint8(255),
  10809 				6:  uint8(255),
  10810 				7:  uint8(255),
  10811 				8:  uint8(255),
  10812 				9:  uint8(255),
  10813 				10: uint8(255),
  10814 			},
  10815 			1: {
  10816 				0:  uint8(249),
  10817 				1:  uint8(254),
  10818 				2:  uint8(255),
  10819 				3:  uint8(255),
  10820 				4:  uint8(255),
  10821 				5:  uint8(255),
  10822 				6:  uint8(255),
  10823 				7:  uint8(255),
  10824 				8:  uint8(255),
  10825 				9:  uint8(255),
  10826 				10: uint8(255),
  10827 			},
  10828 			2: {
  10829 				0:  uint8(255),
  10830 				1:  uint8(255),
  10831 				2:  uint8(255),
  10832 				3:  uint8(255),
  10833 				4:  uint8(255),
  10834 				5:  uint8(255),
  10835 				6:  uint8(255),
  10836 				7:  uint8(255),
  10837 				8:  uint8(255),
  10838 				9:  uint8(255),
  10839 				10: uint8(255),
  10840 			},
  10841 		},
  10842 		3: {
  10843 			0: {
  10844 				0:  uint8(255),
  10845 				1:  uint8(253),
  10846 				2:  uint8(255),
  10847 				3:  uint8(255),
  10848 				4:  uint8(255),
  10849 				5:  uint8(255),
  10850 				6:  uint8(255),
  10851 				7:  uint8(255),
  10852 				8:  uint8(255),
  10853 				9:  uint8(255),
  10854 				10: uint8(255),
  10855 			},
  10856 			1: {
  10857 				0:  uint8(247),
  10858 				1:  uint8(254),
  10859 				2:  uint8(255),
  10860 				3:  uint8(255),
  10861 				4:  uint8(255),
  10862 				5:  uint8(255),
  10863 				6:  uint8(255),
  10864 				7:  uint8(255),
  10865 				8:  uint8(255),
  10866 				9:  uint8(255),
  10867 				10: uint8(255),
  10868 			},
  10869 			2: {
  10870 				0:  uint8(255),
  10871 				1:  uint8(255),
  10872 				2:  uint8(255),
  10873 				3:  uint8(255),
  10874 				4:  uint8(255),
  10875 				5:  uint8(255),
  10876 				6:  uint8(255),
  10877 				7:  uint8(255),
  10878 				8:  uint8(255),
  10879 				9:  uint8(255),
  10880 				10: uint8(255),
  10881 			},
  10882 		},
  10883 		4: {
  10884 			0: {
  10885 				0:  uint8(255),
  10886 				1:  uint8(253),
  10887 				2:  uint8(254),
  10888 				3:  uint8(255),
  10889 				4:  uint8(255),
  10890 				5:  uint8(255),
  10891 				6:  uint8(255),
  10892 				7:  uint8(255),
  10893 				8:  uint8(255),
  10894 				9:  uint8(255),
  10895 				10: uint8(255),
  10896 			},
  10897 			1: {
  10898 				0:  uint8(252),
  10899 				1:  uint8(255),
  10900 				2:  uint8(255),
  10901 				3:  uint8(255),
  10902 				4:  uint8(255),
  10903 				5:  uint8(255),
  10904 				6:  uint8(255),
  10905 				7:  uint8(255),
  10906 				8:  uint8(255),
  10907 				9:  uint8(255),
  10908 				10: uint8(255),
  10909 			},
  10910 			2: {
  10911 				0:  uint8(255),
  10912 				1:  uint8(255),
  10913 				2:  uint8(255),
  10914 				3:  uint8(255),
  10915 				4:  uint8(255),
  10916 				5:  uint8(255),
  10917 				6:  uint8(255),
  10918 				7:  uint8(255),
  10919 				8:  uint8(255),
  10920 				9:  uint8(255),
  10921 				10: uint8(255),
  10922 			},
  10923 		},
  10924 		5: {
  10925 			0: {
  10926 				0:  uint8(255),
  10927 				1:  uint8(254),
  10928 				2:  uint8(254),
  10929 				3:  uint8(255),
  10930 				4:  uint8(255),
  10931 				5:  uint8(255),
  10932 				6:  uint8(255),
  10933 				7:  uint8(255),
  10934 				8:  uint8(255),
  10935 				9:  uint8(255),
  10936 				10: uint8(255),
  10937 			},
  10938 			1: {
  10939 				0:  uint8(253),
  10940 				1:  uint8(255),
  10941 				2:  uint8(255),
  10942 				3:  uint8(255),
  10943 				4:  uint8(255),
  10944 				5:  uint8(255),
  10945 				6:  uint8(255),
  10946 				7:  uint8(255),
  10947 				8:  uint8(255),
  10948 				9:  uint8(255),
  10949 				10: uint8(255),
  10950 			},
  10951 			2: {
  10952 				0:  uint8(255),
  10953 				1:  uint8(255),
  10954 				2:  uint8(255),
  10955 				3:  uint8(255),
  10956 				4:  uint8(255),
  10957 				5:  uint8(255),
  10958 				6:  uint8(255),
  10959 				7:  uint8(255),
  10960 				8:  uint8(255),
  10961 				9:  uint8(255),
  10962 				10: uint8(255),
  10963 			},
  10964 		},
  10965 		6: {
  10966 			0: {
  10967 				0:  uint8(255),
  10968 				1:  uint8(254),
  10969 				2:  uint8(253),
  10970 				3:  uint8(255),
  10971 				4:  uint8(255),
  10972 				5:  uint8(255),
  10973 				6:  uint8(255),
  10974 				7:  uint8(255),
  10975 				8:  uint8(255),
  10976 				9:  uint8(255),
  10977 				10: uint8(255),
  10978 			},
  10979 			1: {
  10980 				0:  uint8(250),
  10981 				1:  uint8(255),
  10982 				2:  uint8(255),
  10983 				3:  uint8(255),
  10984 				4:  uint8(255),
  10985 				5:  uint8(255),
  10986 				6:  uint8(255),
  10987 				7:  uint8(255),
  10988 				8:  uint8(255),
  10989 				9:  uint8(255),
  10990 				10: uint8(255),
  10991 			},
  10992 			2: {
  10993 				0:  uint8(254),
  10994 				1:  uint8(255),
  10995 				2:  uint8(255),
  10996 				3:  uint8(255),
  10997 				4:  uint8(255),
  10998 				5:  uint8(255),
  10999 				6:  uint8(255),
  11000 				7:  uint8(255),
  11001 				8:  uint8(255),
  11002 				9:  uint8(255),
  11003 				10: uint8(255),
  11004 			},
  11005 		},
  11006 		7: {
  11007 			0: {
  11008 				0:  uint8(255),
  11009 				1:  uint8(255),
  11010 				2:  uint8(255),
  11011 				3:  uint8(255),
  11012 				4:  uint8(255),
  11013 				5:  uint8(255),
  11014 				6:  uint8(255),
  11015 				7:  uint8(255),
  11016 				8:  uint8(255),
  11017 				9:  uint8(255),
  11018 				10: uint8(255),
  11019 			},
  11020 			1: {
  11021 				0:  uint8(255),
  11022 				1:  uint8(255),
  11023 				2:  uint8(255),
  11024 				3:  uint8(255),
  11025 				4:  uint8(255),
  11026 				5:  uint8(255),
  11027 				6:  uint8(255),
  11028 				7:  uint8(255),
  11029 				8:  uint8(255),
  11030 				9:  uint8(255),
  11031 				10: uint8(255),
  11032 			},
  11033 			2: {
  11034 				0:  uint8(255),
  11035 				1:  uint8(255),
  11036 				2:  uint8(255),
  11037 				3:  uint8(255),
  11038 				4:  uint8(255),
  11039 				5:  uint8(255),
  11040 				6:  uint8(255),
  11041 				7:  uint8(255),
  11042 				8:  uint8(255),
  11043 				9:  uint8(255),
  11044 				10: uint8(255),
  11045 			},
  11046 		},
  11047 	},
  11048 	2: {
  11049 		0: {
  11050 			0: {
  11051 				0:  uint8(186),
  11052 				1:  uint8(251),
  11053 				2:  uint8(250),
  11054 				3:  uint8(255),
  11055 				4:  uint8(255),
  11056 				5:  uint8(255),
  11057 				6:  uint8(255),
  11058 				7:  uint8(255),
  11059 				8:  uint8(255),
  11060 				9:  uint8(255),
  11061 				10: uint8(255),
  11062 			},
  11063 			1: {
  11064 				0:  uint8(234),
  11065 				1:  uint8(251),
  11066 				2:  uint8(244),
  11067 				3:  uint8(254),
  11068 				4:  uint8(255),
  11069 				5:  uint8(255),
  11070 				6:  uint8(255),
  11071 				7:  uint8(255),
  11072 				8:  uint8(255),
  11073 				9:  uint8(255),
  11074 				10: uint8(255),
  11075 			},
  11076 			2: {
  11077 				0:  uint8(251),
  11078 				1:  uint8(251),
  11079 				2:  uint8(243),
  11080 				3:  uint8(253),
  11081 				4:  uint8(254),
  11082 				5:  uint8(255),
  11083 				6:  uint8(254),
  11084 				7:  uint8(255),
  11085 				8:  uint8(255),
  11086 				9:  uint8(255),
  11087 				10: uint8(255),
  11088 			},
  11089 		},
  11090 		1: {
  11091 			0: {
  11092 				0:  uint8(255),
  11093 				1:  uint8(253),
  11094 				2:  uint8(254),
  11095 				3:  uint8(255),
  11096 				4:  uint8(255),
  11097 				5:  uint8(255),
  11098 				6:  uint8(255),
  11099 				7:  uint8(255),
  11100 				8:  uint8(255),
  11101 				9:  uint8(255),
  11102 				10: uint8(255),
  11103 			},
  11104 			1: {
  11105 				0:  uint8(236),
  11106 				1:  uint8(253),
  11107 				2:  uint8(254),
  11108 				3:  uint8(255),
  11109 				4:  uint8(255),
  11110 				5:  uint8(255),
  11111 				6:  uint8(255),
  11112 				7:  uint8(255),
  11113 				8:  uint8(255),
  11114 				9:  uint8(255),
  11115 				10: uint8(255),
  11116 			},
  11117 			2: {
  11118 				0:  uint8(251),
  11119 				1:  uint8(253),
  11120 				2:  uint8(253),
  11121 				3:  uint8(254),
  11122 				4:  uint8(254),
  11123 				5:  uint8(255),
  11124 				6:  uint8(255),
  11125 				7:  uint8(255),
  11126 				8:  uint8(255),
  11127 				9:  uint8(255),
  11128 				10: uint8(255),
  11129 			},
  11130 		},
  11131 		2: {
  11132 			0: {
  11133 				0:  uint8(255),
  11134 				1:  uint8(254),
  11135 				2:  uint8(254),
  11136 				3:  uint8(255),
  11137 				4:  uint8(255),
  11138 				5:  uint8(255),
  11139 				6:  uint8(255),
  11140 				7:  uint8(255),
  11141 				8:  uint8(255),
  11142 				9:  uint8(255),
  11143 				10: uint8(255),
  11144 			},
  11145 			1: {
  11146 				0:  uint8(254),
  11147 				1:  uint8(254),
  11148 				2:  uint8(254),
  11149 				3:  uint8(255),
  11150 				4:  uint8(255),
  11151 				5:  uint8(255),
  11152 				6:  uint8(255),
  11153 				7:  uint8(255),
  11154 				8:  uint8(255),
  11155 				9:  uint8(255),
  11156 				10: uint8(255),
  11157 			},
  11158 			2: {
  11159 				0:  uint8(255),
  11160 				1:  uint8(255),
  11161 				2:  uint8(255),
  11162 				3:  uint8(255),
  11163 				4:  uint8(255),
  11164 				5:  uint8(255),
  11165 				6:  uint8(255),
  11166 				7:  uint8(255),
  11167 				8:  uint8(255),
  11168 				9:  uint8(255),
  11169 				10: uint8(255),
  11170 			},
  11171 		},
  11172 		3: {
  11173 			0: {
  11174 				0:  uint8(255),
  11175 				1:  uint8(254),
  11176 				2:  uint8(255),
  11177 				3:  uint8(255),
  11178 				4:  uint8(255),
  11179 				5:  uint8(255),
  11180 				6:  uint8(255),
  11181 				7:  uint8(255),
  11182 				8:  uint8(255),
  11183 				9:  uint8(255),
  11184 				10: uint8(255),
  11185 			},
  11186 			1: {
  11187 				0:  uint8(254),
  11188 				1:  uint8(254),
  11189 				2:  uint8(255),
  11190 				3:  uint8(255),
  11191 				4:  uint8(255),
  11192 				5:  uint8(255),
  11193 				6:  uint8(255),
  11194 				7:  uint8(255),
  11195 				8:  uint8(255),
  11196 				9:  uint8(255),
  11197 				10: uint8(255),
  11198 			},
  11199 			2: {
  11200 				0:  uint8(254),
  11201 				1:  uint8(255),
  11202 				2:  uint8(255),
  11203 				3:  uint8(255),
  11204 				4:  uint8(255),
  11205 				5:  uint8(255),
  11206 				6:  uint8(255),
  11207 				7:  uint8(255),
  11208 				8:  uint8(255),
  11209 				9:  uint8(255),
  11210 				10: uint8(255),
  11211 			},
  11212 		},
  11213 		4: {
  11214 			0: {
  11215 				0:  uint8(255),
  11216 				1:  uint8(255),
  11217 				2:  uint8(255),
  11218 				3:  uint8(255),
  11219 				4:  uint8(255),
  11220 				5:  uint8(255),
  11221 				6:  uint8(255),
  11222 				7:  uint8(255),
  11223 				8:  uint8(255),
  11224 				9:  uint8(255),
  11225 				10: uint8(255),
  11226 			},
  11227 			1: {
  11228 				0:  uint8(254),
  11229 				1:  uint8(255),
  11230 				2:  uint8(255),
  11231 				3:  uint8(255),
  11232 				4:  uint8(255),
  11233 				5:  uint8(255),
  11234 				6:  uint8(255),
  11235 				7:  uint8(255),
  11236 				8:  uint8(255),
  11237 				9:  uint8(255),
  11238 				10: uint8(255),
  11239 			},
  11240 			2: {
  11241 				0:  uint8(255),
  11242 				1:  uint8(255),
  11243 				2:  uint8(255),
  11244 				3:  uint8(255),
  11245 				4:  uint8(255),
  11246 				5:  uint8(255),
  11247 				6:  uint8(255),
  11248 				7:  uint8(255),
  11249 				8:  uint8(255),
  11250 				9:  uint8(255),
  11251 				10: uint8(255),
  11252 			},
  11253 		},
  11254 		5: {
  11255 			0: {
  11256 				0:  uint8(255),
  11257 				1:  uint8(255),
  11258 				2:  uint8(255),
  11259 				3:  uint8(255),
  11260 				4:  uint8(255),
  11261 				5:  uint8(255),
  11262 				6:  uint8(255),
  11263 				7:  uint8(255),
  11264 				8:  uint8(255),
  11265 				9:  uint8(255),
  11266 				10: uint8(255),
  11267 			},
  11268 			1: {
  11269 				0:  uint8(255),
  11270 				1:  uint8(255),
  11271 				2:  uint8(255),
  11272 				3:  uint8(255),
  11273 				4:  uint8(255),
  11274 				5:  uint8(255),
  11275 				6:  uint8(255),
  11276 				7:  uint8(255),
  11277 				8:  uint8(255),
  11278 				9:  uint8(255),
  11279 				10: uint8(255),
  11280 			},
  11281 			2: {
  11282 				0:  uint8(255),
  11283 				1:  uint8(255),
  11284 				2:  uint8(255),
  11285 				3:  uint8(255),
  11286 				4:  uint8(255),
  11287 				5:  uint8(255),
  11288 				6:  uint8(255),
  11289 				7:  uint8(255),
  11290 				8:  uint8(255),
  11291 				9:  uint8(255),
  11292 				10: uint8(255),
  11293 			},
  11294 		},
  11295 		6: {
  11296 			0: {
  11297 				0:  uint8(255),
  11298 				1:  uint8(255),
  11299 				2:  uint8(255),
  11300 				3:  uint8(255),
  11301 				4:  uint8(255),
  11302 				5:  uint8(255),
  11303 				6:  uint8(255),
  11304 				7:  uint8(255),
  11305 				8:  uint8(255),
  11306 				9:  uint8(255),
  11307 				10: uint8(255),
  11308 			},
  11309 			1: {
  11310 				0:  uint8(255),
  11311 				1:  uint8(255),
  11312 				2:  uint8(255),
  11313 				3:  uint8(255),
  11314 				4:  uint8(255),
  11315 				5:  uint8(255),
  11316 				6:  uint8(255),
  11317 				7:  uint8(255),
  11318 				8:  uint8(255),
  11319 				9:  uint8(255),
  11320 				10: uint8(255),
  11321 			},
  11322 			2: {
  11323 				0:  uint8(255),
  11324 				1:  uint8(255),
  11325 				2:  uint8(255),
  11326 				3:  uint8(255),
  11327 				4:  uint8(255),
  11328 				5:  uint8(255),
  11329 				6:  uint8(255),
  11330 				7:  uint8(255),
  11331 				8:  uint8(255),
  11332 				9:  uint8(255),
  11333 				10: uint8(255),
  11334 			},
  11335 		},
  11336 		7: {
  11337 			0: {
  11338 				0:  uint8(255),
  11339 				1:  uint8(255),
  11340 				2:  uint8(255),
  11341 				3:  uint8(255),
  11342 				4:  uint8(255),
  11343 				5:  uint8(255),
  11344 				6:  uint8(255),
  11345 				7:  uint8(255),
  11346 				8:  uint8(255),
  11347 				9:  uint8(255),
  11348 				10: uint8(255),
  11349 			},
  11350 			1: {
  11351 				0:  uint8(255),
  11352 				1:  uint8(255),
  11353 				2:  uint8(255),
  11354 				3:  uint8(255),
  11355 				4:  uint8(255),
  11356 				5:  uint8(255),
  11357 				6:  uint8(255),
  11358 				7:  uint8(255),
  11359 				8:  uint8(255),
  11360 				9:  uint8(255),
  11361 				10: uint8(255),
  11362 			},
  11363 			2: {
  11364 				0:  uint8(255),
  11365 				1:  uint8(255),
  11366 				2:  uint8(255),
  11367 				3:  uint8(255),
  11368 				4:  uint8(255),
  11369 				5:  uint8(255),
  11370 				6:  uint8(255),
  11371 				7:  uint8(255),
  11372 				8:  uint8(255),
  11373 				9:  uint8(255),
  11374 				10: uint8(255),
  11375 			},
  11376 		},
  11377 	},
  11378 	3: {
  11379 		0: {
  11380 			0: {
  11381 				0:  uint8(248),
  11382 				1:  uint8(255),
  11383 				2:  uint8(255),
  11384 				3:  uint8(255),
  11385 				4:  uint8(255),
  11386 				5:  uint8(255),
  11387 				6:  uint8(255),
  11388 				7:  uint8(255),
  11389 				8:  uint8(255),
  11390 				9:  uint8(255),
  11391 				10: uint8(255),
  11392 			},
  11393 			1: {
  11394 				0:  uint8(250),
  11395 				1:  uint8(254),
  11396 				2:  uint8(252),
  11397 				3:  uint8(254),
  11398 				4:  uint8(255),
  11399 				5:  uint8(255),
  11400 				6:  uint8(255),
  11401 				7:  uint8(255),
  11402 				8:  uint8(255),
  11403 				9:  uint8(255),
  11404 				10: uint8(255),
  11405 			},
  11406 			2: {
  11407 				0:  uint8(248),
  11408 				1:  uint8(254),
  11409 				2:  uint8(249),
  11410 				3:  uint8(253),
  11411 				4:  uint8(255),
  11412 				5:  uint8(255),
  11413 				6:  uint8(255),
  11414 				7:  uint8(255),
  11415 				8:  uint8(255),
  11416 				9:  uint8(255),
  11417 				10: uint8(255),
  11418 			},
  11419 		},
  11420 		1: {
  11421 			0: {
  11422 				0:  uint8(255),
  11423 				1:  uint8(253),
  11424 				2:  uint8(253),
  11425 				3:  uint8(255),
  11426 				4:  uint8(255),
  11427 				5:  uint8(255),
  11428 				6:  uint8(255),
  11429 				7:  uint8(255),
  11430 				8:  uint8(255),
  11431 				9:  uint8(255),
  11432 				10: uint8(255),
  11433 			},
  11434 			1: {
  11435 				0:  uint8(246),
  11436 				1:  uint8(253),
  11437 				2:  uint8(253),
  11438 				3:  uint8(255),
  11439 				4:  uint8(255),
  11440 				5:  uint8(255),
  11441 				6:  uint8(255),
  11442 				7:  uint8(255),
  11443 				8:  uint8(255),
  11444 				9:  uint8(255),
  11445 				10: uint8(255),
  11446 			},
  11447 			2: {
  11448 				0:  uint8(252),
  11449 				1:  uint8(254),
  11450 				2:  uint8(251),
  11451 				3:  uint8(254),
  11452 				4:  uint8(254),
  11453 				5:  uint8(255),
  11454 				6:  uint8(255),
  11455 				7:  uint8(255),
  11456 				8:  uint8(255),
  11457 				9:  uint8(255),
  11458 				10: uint8(255),
  11459 			},
  11460 		},
  11461 		2: {
  11462 			0: {
  11463 				0:  uint8(255),
  11464 				1:  uint8(254),
  11465 				2:  uint8(252),
  11466 				3:  uint8(255),
  11467 				4:  uint8(255),
  11468 				5:  uint8(255),
  11469 				6:  uint8(255),
  11470 				7:  uint8(255),
  11471 				8:  uint8(255),
  11472 				9:  uint8(255),
  11473 				10: uint8(255),
  11474 			},
  11475 			1: {
  11476 				0:  uint8(248),
  11477 				1:  uint8(254),
  11478 				2:  uint8(253),
  11479 				3:  uint8(255),
  11480 				4:  uint8(255),
  11481 				5:  uint8(255),
  11482 				6:  uint8(255),
  11483 				7:  uint8(255),
  11484 				8:  uint8(255),
  11485 				9:  uint8(255),
  11486 				10: uint8(255),
  11487 			},
  11488 			2: {
  11489 				0:  uint8(253),
  11490 				1:  uint8(255),
  11491 				2:  uint8(254),
  11492 				3:  uint8(254),
  11493 				4:  uint8(255),
  11494 				5:  uint8(255),
  11495 				6:  uint8(255),
  11496 				7:  uint8(255),
  11497 				8:  uint8(255),
  11498 				9:  uint8(255),
  11499 				10: uint8(255),
  11500 			},
  11501 		},
  11502 		3: {
  11503 			0: {
  11504 				0:  uint8(255),
  11505 				1:  uint8(251),
  11506 				2:  uint8(254),
  11507 				3:  uint8(255),
  11508 				4:  uint8(255),
  11509 				5:  uint8(255),
  11510 				6:  uint8(255),
  11511 				7:  uint8(255),
  11512 				8:  uint8(255),
  11513 				9:  uint8(255),
  11514 				10: uint8(255),
  11515 			},
  11516 			1: {
  11517 				0:  uint8(245),
  11518 				1:  uint8(251),
  11519 				2:  uint8(254),
  11520 				3:  uint8(255),
  11521 				4:  uint8(255),
  11522 				5:  uint8(255),
  11523 				6:  uint8(255),
  11524 				7:  uint8(255),
  11525 				8:  uint8(255),
  11526 				9:  uint8(255),
  11527 				10: uint8(255),
  11528 			},
  11529 			2: {
  11530 				0:  uint8(253),
  11531 				1:  uint8(253),
  11532 				2:  uint8(254),
  11533 				3:  uint8(255),
  11534 				4:  uint8(255),
  11535 				5:  uint8(255),
  11536 				6:  uint8(255),
  11537 				7:  uint8(255),
  11538 				8:  uint8(255),
  11539 				9:  uint8(255),
  11540 				10: uint8(255),
  11541 			},
  11542 		},
  11543 		4: {
  11544 			0: {
  11545 				0:  uint8(255),
  11546 				1:  uint8(251),
  11547 				2:  uint8(253),
  11548 				3:  uint8(255),
  11549 				4:  uint8(255),
  11550 				5:  uint8(255),
  11551 				6:  uint8(255),
  11552 				7:  uint8(255),
  11553 				8:  uint8(255),
  11554 				9:  uint8(255),
  11555 				10: uint8(255),
  11556 			},
  11557 			1: {
  11558 				0:  uint8(252),
  11559 				1:  uint8(253),
  11560 				2:  uint8(254),
  11561 				3:  uint8(255),
  11562 				4:  uint8(255),
  11563 				5:  uint8(255),
  11564 				6:  uint8(255),
  11565 				7:  uint8(255),
  11566 				8:  uint8(255),
  11567 				9:  uint8(255),
  11568 				10: uint8(255),
  11569 			},
  11570 			2: {
  11571 				0:  uint8(255),
  11572 				1:  uint8(254),
  11573 				2:  uint8(255),
  11574 				3:  uint8(255),
  11575 				4:  uint8(255),
  11576 				5:  uint8(255),
  11577 				6:  uint8(255),
  11578 				7:  uint8(255),
  11579 				8:  uint8(255),
  11580 				9:  uint8(255),
  11581 				10: uint8(255),
  11582 			},
  11583 		},
  11584 		5: {
  11585 			0: {
  11586 				0:  uint8(255),
  11587 				1:  uint8(252),
  11588 				2:  uint8(255),
  11589 				3:  uint8(255),
  11590 				4:  uint8(255),
  11591 				5:  uint8(255),
  11592 				6:  uint8(255),
  11593 				7:  uint8(255),
  11594 				8:  uint8(255),
  11595 				9:  uint8(255),
  11596 				10: uint8(255),
  11597 			},
  11598 			1: {
  11599 				0:  uint8(249),
  11600 				1:  uint8(255),
  11601 				2:  uint8(254),
  11602 				3:  uint8(255),
  11603 				4:  uint8(255),
  11604 				5:  uint8(255),
  11605 				6:  uint8(255),
  11606 				7:  uint8(255),
  11607 				8:  uint8(255),
  11608 				9:  uint8(255),
  11609 				10: uint8(255),
  11610 			},
  11611 			2: {
  11612 				0:  uint8(255),
  11613 				1:  uint8(255),
  11614 				2:  uint8(254),
  11615 				3:  uint8(255),
  11616 				4:  uint8(255),
  11617 				5:  uint8(255),
  11618 				6:  uint8(255),
  11619 				7:  uint8(255),
  11620 				8:  uint8(255),
  11621 				9:  uint8(255),
  11622 				10: uint8(255),
  11623 			},
  11624 		},
  11625 		6: {
  11626 			0: {
  11627 				0:  uint8(255),
  11628 				1:  uint8(255),
  11629 				2:  uint8(253),
  11630 				3:  uint8(255),
  11631 				4:  uint8(255),
  11632 				5:  uint8(255),
  11633 				6:  uint8(255),
  11634 				7:  uint8(255),
  11635 				8:  uint8(255),
  11636 				9:  uint8(255),
  11637 				10: uint8(255),
  11638 			},
  11639 			1: {
  11640 				0:  uint8(250),
  11641 				1:  uint8(255),
  11642 				2:  uint8(255),
  11643 				3:  uint8(255),
  11644 				4:  uint8(255),
  11645 				5:  uint8(255),
  11646 				6:  uint8(255),
  11647 				7:  uint8(255),
  11648 				8:  uint8(255),
  11649 				9:  uint8(255),
  11650 				10: uint8(255),
  11651 			},
  11652 			2: {
  11653 				0:  uint8(255),
  11654 				1:  uint8(255),
  11655 				2:  uint8(255),
  11656 				3:  uint8(255),
  11657 				4:  uint8(255),
  11658 				5:  uint8(255),
  11659 				6:  uint8(255),
  11660 				7:  uint8(255),
  11661 				8:  uint8(255),
  11662 				9:  uint8(255),
  11663 				10: uint8(255),
  11664 			},
  11665 		},
  11666 		7: {
  11667 			0: {
  11668 				0:  uint8(255),
  11669 				1:  uint8(255),
  11670 				2:  uint8(255),
  11671 				3:  uint8(255),
  11672 				4:  uint8(255),
  11673 				5:  uint8(255),
  11674 				6:  uint8(255),
  11675 				7:  uint8(255),
  11676 				8:  uint8(255),
  11677 				9:  uint8(255),
  11678 				10: uint8(255),
  11679 			},
  11680 			1: {
  11681 				0:  uint8(254),
  11682 				1:  uint8(255),
  11683 				2:  uint8(255),
  11684 				3:  uint8(255),
  11685 				4:  uint8(255),
  11686 				5:  uint8(255),
  11687 				6:  uint8(255),
  11688 				7:  uint8(255),
  11689 				8:  uint8(255),
  11690 				9:  uint8(255),
  11691 				10: uint8(255),
  11692 			},
  11693 			2: {
  11694 				0:  uint8(255),
  11695 				1:  uint8(255),
  11696 				2:  uint8(255),
  11697 				3:  uint8(255),
  11698 				4:  uint8(255),
  11699 				5:  uint8(255),
  11700 				6:  uint8(255),
  11701 				7:  uint8(255),
  11702 				8:  uint8(255),
  11703 				9:  uint8(255),
  11704 				10: uint8(255),
  11705 			},
  11706 		},
  11707 	},
  11708 }
  11709 
  11710 // Paragraph 9.9
  11711 
  11712 var kBands = [17]uint8_t{
  11713 	1:  uint8(1),
  11714 	2:  uint8(2),
  11715 	3:  uint8(3),
  11716 	4:  uint8(6),
  11717 	5:  uint8(4),
  11718 	6:  uint8(5),
  11719 	7:  uint8(6),
  11720 	8:  uint8(6),
  11721 	9:  uint8(6),
  11722 	10: uint8(6),
  11723 	11: uint8(6),
  11724 	12: uint8(6),
  11725 	13: uint8(6),
  11726 	14: uint8(6),
  11727 	15: uint8(7),
  11728 }
  11729 
  11730 func VP8ParseProba(tls *libc.TLS, br2 uintptr, dec uintptr) {
  11731 	bp := tls.Alloc(16)
  11732 	defer tls.Free(16)
  11733 	var b, bit, c, p, pos, shift, t, v, v10, v12 int32
  11734 	var bits bit_t
  11735 	var proba, v6, v7 uintptr
  11736 	var range1, split, value range_t
  11737 	var v5 uint32
  11738 	var v8 uint64_t
  11739 	var _ /* in_bits at bp+0 */ lbit_t
  11740 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, bit, bits, c, p, pos, proba, range1, shift, split, t, v, value, v10, v12, v5, v6, v7, v8
  11741 	proba = dec + 1192
  11742 	t = 0
  11743 	for {
  11744 		if !(t < int32(NUM_TYPES)) {
  11745 			break
  11746 		}
  11747 		b = 0
  11748 		for {
  11749 			if !(b < int32(NUM_BANDS)) {
  11750 				break
  11751 			}
  11752 			c = 0
  11753 			for {
  11754 				if !(c < int32(NUM_CTX)) {
  11755 					break
  11756 				}
  11757 				p = 0
  11758 				for {
  11759 					if !(p < int32(NUM_PROBAS)) {
  11760 						break
  11761 					}
  11762 					v6 = br2
  11763 					range1 = (*VP8BitReader)(unsafe.Pointer(v6)).Frange1
  11764 					if (*VP8BitReader)(unsafe.Pointer(v6)).Fbits < libc.Int32FromInt32(0) {
  11765 						v7 = v6
  11766 						if (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf_max {
  11767 							libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf, uint64(8), ^__predefined_size_t(0))
  11768 							**(**uintptr)(__ccgo_up(v7 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  11769 							v8 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  11770 							goto _9
  11771 						_9:
  11772 							bits = v8
  11773 							bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  11774 							(*VP8BitReader)(unsafe.Pointer(v7)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v7)).Fvalue<<libc.Int32FromInt32(BITS)
  11775 							**(**int32)(__ccgo_up(v7 + 12)) += int32(BITS)
  11776 						} else {
  11777 							VP8LoadFinalBytes(tls, v7)
  11778 						}
  11779 					}
  11780 					pos = (*VP8BitReader)(unsafe.Pointer(v6)).Fbits
  11781 					split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&CoeffsUpdateProba)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))) >> int32(8)
  11782 					value = uint32((*VP8BitReader)(unsafe.Pointer(v6)).Fvalue >> pos)
  11783 					bit = libc.BoolInt32(value > split)
  11784 					if bit != 0 {
  11785 						range1 = range1 - split
  11786 						**(**bit_t)(__ccgo_up(v6)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  11787 					} else {
  11788 						range1 = split + uint32(1)
  11789 					}
  11790 					v10 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  11791 					goto _11
  11792 				_11:
  11793 					shift = int32(7) ^ v10
  11794 					range1 = range1 << libc.Uint32FromInt32(shift)
  11795 					**(**int32)(__ccgo_up(v6 + 12)) -= shift
  11796 					(*VP8BitReader)(unsafe.Pointer(v6)).Frange1 = range1 - uint32(1)
  11797 					v12 = bit
  11798 					goto _13
  11799 				_13:
  11800 					if v12 != 0 {
  11801 						v5 = VP8GetValue(tls, br2, int32(8))
  11802 					} else {
  11803 						v5 = uint32(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&CoeffsProba0)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  11804 					}
  11805 					v = libc.Int32FromUint32(v5)
  11806 					**(**uint8_t)(__ccgo_up(proba + 3 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(v)
  11807 					goto _4
  11808 				_4:
  11809 					;
  11810 					p = p + 1
  11811 				}
  11812 				goto _3
  11813 			_3:
  11814 				;
  11815 				c = c + 1
  11816 			}
  11817 			goto _2
  11818 		_2:
  11819 			;
  11820 			b = b + 1
  11821 		}
  11822 		b = 0
  11823 		for {
  11824 			if !(b < libc.Int32FromInt32(16)+libc.Int32FromInt32(1)) {
  11825 				break
  11826 			}
  11827 			**(**uintptr)(__ccgo_up(proba + 1064 + uintptr(t)*136 + uintptr(b)*8)) = proba + 3 + uintptr(t)*264 + uintptr(kBands[b])*33
  11828 			goto _14
  11829 		_14:
  11830 			;
  11831 			b = b + 1
  11832 		}
  11833 		goto _1
  11834 	_1:
  11835 		;
  11836 		t = t + 1
  11837 	}
  11838 	(*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba = libc.Int32FromUint32(VP8GetValue(tls, br2, int32(1)))
  11839 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
  11840 		(*VP8Decoder)(unsafe.Pointer(dec)).Fskip_p = uint8(VP8GetValue(tls, br2, int32(8)))
  11841 	}
  11842 }
  11843 
  11844 var kHashMul7 = uint32(0x1e35a7bd)
  11845 
  11846 // Copyright 2010 Google Inc. All Rights Reserved.
  11847 //
  11848 // Use of this source code is governed by a BSD-style license
  11849 // that can be found in the COPYING file in the root of the source
  11850 // tree. An additional intellectual property rights grant can be found
  11851 // in the file PATENTS. All contributing project authors may
  11852 // be found in the AUTHORS file in the root of the source tree.
  11853 // -----------------------------------------------------------------------------
  11854 //
  11855 // Boolean decoder
  11856 //
  11857 // Author: Skal (pascal.massimino@gmail.com)
  11858 //         Vikas Arora (vikaas.arora@gmail.com)
  11859 
  11860 // Copyright 2011 Google Inc. All Rights Reserved.
  11861 //
  11862 // Use of this source code is governed by a BSD-style license
  11863 // that can be found in the COPYING file in the root of the source
  11864 // tree. An additional intellectual property rights grant can be found
  11865 // in the file PATENTS. All contributing project authors may
  11866 // be found in the AUTHORS file in the root of the source tree.
  11867 // -----------------------------------------------------------------------------
  11868 //
  11869 // Multi-threaded worker
  11870 //
  11871 // Author: Skal (pascal.massimino@gmail.com)
  11872 
  11873 // Copyright 2012 Google Inc. All Rights Reserved.
  11874 //
  11875 // Use of this source code is governed by a BSD-style license
  11876 // that can be found in the COPYING file in the root of the source
  11877 // tree. An additional intellectual property rights grant can be found
  11878 // in the file PATENTS. All contributing project authors may
  11879 // be found in the AUTHORS file in the root of the source tree.
  11880 // -----------------------------------------------------------------------------
  11881 //
  11882 // Misc. common utility functions
  11883 //
  11884 // Authors: Skal (pascal.massimino@gmail.com)
  11885 //          Urvang (urvang@google.com)
  11886 
  11887 // Copyright 2010 Google Inc. All Rights Reserved.
  11888 //
  11889 // Use of this source code is governed by a BSD-style license
  11890 // that can be found in the COPYING file in the root of the source
  11891 // tree. An additional intellectual property rights grant can be found
  11892 // in the file PATENTS. All contributing project authors may
  11893 // be found in the AUTHORS file in the root of the source tree.
  11894 // -----------------------------------------------------------------------------
  11895 //
  11896 //  Main decoding functions for WebP images.
  11897 //
  11898 // Author: Skal (pascal.massimino@gmail.com)
  11899 
  11900 // Copyright 2012 Google Inc. All Rights Reserved.
  11901 //
  11902 // Use of this source code is governed by a BSD-style license
  11903 // that can be found in the COPYING file in the root of the source
  11904 // tree. An additional intellectual property rights grant can be found
  11905 // in the file PATENTS. All contributing project authors may
  11906 // be found in the AUTHORS file in the root of the source tree.
  11907 // -----------------------------------------------------------------------------
  11908 //
  11909 //  Internal header for constants related to WebP file format.
  11910 //
  11911 // Author: Urvang (urvang@google.com)
  11912 
  11913 // Copyright 2010 Google Inc. All Rights Reserved.
  11914 //
  11915 // Use of this source code is governed by a BSD-style license
  11916 // that can be found in the COPYING file in the root of the source
  11917 // tree. An additional intellectual property rights grant can be found
  11918 // in the file PATENTS. All contributing project authors may
  11919 // be found in the AUTHORS file in the root of the source tree.
  11920 // -----------------------------------------------------------------------------
  11921 //
  11922 //  Common types + memory wrappers
  11923 //
  11924 // Author: Skal (pascal.massimino@gmail.com)
  11925 
  11926 //------------------------------------------------------------------------------
  11927 
  11928 func WebPGetDecoderVersion(tls *libc.TLS) (r int32) {
  11929 	return libc.Int32FromInt32(DEC_MAJ_VERSION)<<libc.Int32FromInt32(16) | libc.Int32FromInt32(DEC_MIN_VERSION)<<libc.Int32FromInt32(8) | libc.Int32FromInt32(DEC_REV_VERSION)
  11930 }
  11931 
  11932 //------------------------------------------------------------------------------
  11933 // Signature and pointer-to-function for GetCoeffs() variants below.
  11934 
  11935 type GetCoeffsFunc = uintptr
  11936 
  11937 var GetCoeffs = uintptr(0)
  11938 
  11939 func init() {
  11940 	p := unsafe.Pointer(&GetCoeffs)
  11941 	*(*uintptr)(unsafe.Add(p, 0)) = libc.UintptrFromInt32(0)
  11942 }
  11943 
  11944 //------------------------------------------------------------------------------
  11945 // VP8Decoder
  11946 
  11947 func SetOk(tls *libc.TLS, dec uintptr) {
  11948 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  11949 	(*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg = __ccgo_ts + 154
  11950 }
  11951 
  11952 func VP8InitIoInternal(tls *libc.TLS, io uintptr, version int32) (r int32) {
  11953 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  11954 		return 0 // mismatch error
  11955 	}
  11956 	if io != libc.UintptrFromInt32(0) {
  11957 		libc.X__builtin___memset_chk(tls, io, 0, uint64(160), ^__predefined_size_t(0))
  11958 	}
  11959 	return int32(1)
  11960 }
  11961 
  11962 func VP8New(tls *libc.TLS) (r uintptr) {
  11963 	var dec uintptr
  11964 	_ = dec
  11965 	dec = WebPSafeCalloc(tls, uint64(1), uint64(3024))
  11966 	if dec != libc.UintptrFromInt32(0) {
  11967 		SetOk(tls, dec)
  11968 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, dec+152)
  11969 		(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  11970 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one = uint32(0)
  11971 		InitGetCoeffs(tls)
  11972 	}
  11973 	return dec
  11974 }
  11975 
  11976 func VP8Status(tls *libc.TLS, dec uintptr) (r VP8StatusCode1) {
  11977 	if !(dec != 0) {
  11978 		return int32(VP8_STATUS_INVALID_PARAM)
  11979 	}
  11980 	return (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
  11981 }
  11982 
  11983 func VP8StatusMessage(tls *libc.TLS, dec uintptr) (r uintptr) {
  11984 	if dec == libc.UintptrFromInt32(0) {
  11985 		return __ccgo_ts + 157
  11986 	}
  11987 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg != 0) {
  11988 		return __ccgo_ts + 154
  11989 	}
  11990 	return (*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg
  11991 }
  11992 
  11993 func VP8Delete(tls *libc.TLS, dec uintptr) {
  11994 	if dec != libc.UintptrFromInt32(0) {
  11995 		VP8Clear(tls, dec)
  11996 		WebPSafeFree(tls, dec)
  11997 	}
  11998 }
  11999 
  12000 func VP8SetError(tls *libc.TLS, dec uintptr, error1 VP8StatusCode1, msg uintptr) (r int32) {
  12001 	// VP8_STATUS_SUSPENDED is only meaningful in incremental decoding.
  12002 	// The oldest error reported takes precedence over the new one.
  12003 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_OK) {
  12004 		(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = error1
  12005 		(*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg = msg
  12006 		(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  12007 	}
  12008 	return 0
  12009 }
  12010 
  12011 //------------------------------------------------------------------------------
  12012 
  12013 func VP8CheckSignature(tls *libc.TLS, data uintptr, data_size size_t) (r int32) {
  12014 	return libc.BoolInt32(data_size >= uint64(3) && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) == int32(0x9d) && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 1))) == int32(0x01) && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 2))) == int32(0x2a))
  12015 }
  12016 
  12017 func VP8GetInfo(tls *libc.TLS, data uintptr, data_size size_t, chunk_size size_t, width uintptr, height uintptr) (r int32) {
  12018 	var bits uint32_t
  12019 	var h, key_frame, w int32
  12020 	_, _, _, _ = bits, h, key_frame, w
  12021 	if data == libc.UintptrFromInt32(0) || data_size < uint64(VP8_FRAME_HEADER_SIZE) {
  12022 		return 0 // not enough data
  12023 	}
  12024 	// check signature
  12025 	if !(VP8CheckSignature(tls, data+uintptr(3), data_size-uint64(3)) != 0) {
  12026 		return 0 // Wrong signature.
  12027 	} else {
  12028 		bits = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 1)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 2)))<<int32(16))
  12029 		key_frame = libc.BoolInt32(!(bits&libc.Uint32FromInt32(1) != 0))
  12030 		w = (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 7)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 6)))) & int32(0x3fff)
  12031 		h = (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 9)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 8)))) & int32(0x3fff)
  12032 		if !(key_frame != 0) { // Not a keyframe.
  12033 			return 0
  12034 		}
  12035 		if bits>>libc.Int32FromInt32(1)&uint32(7) > uint32(3) {
  12036 			return 0 // unknown profile
  12037 		}
  12038 		if !(bits>>libc.Int32FromInt32(4)&libc.Uint32FromInt32(1) != 0) {
  12039 			return 0 // first frame is invisible!
  12040 		}
  12041 		if uint64(bits>>libc.Int32FromInt32(5)) >= chunk_size { // partition_length
  12042 			return 0 // inconsistent size information.
  12043 		}
  12044 		if w == 0 || h == 0 {
  12045 			return 0 // We don't support both width and height to be zero.
  12046 		}
  12047 		if width != 0 {
  12048 			**(**int32)(__ccgo_up(width)) = w
  12049 		}
  12050 		if height != 0 {
  12051 			**(**int32)(__ccgo_up(height)) = h
  12052 		}
  12053 		return int32(1)
  12054 	}
  12055 	return r
  12056 }
  12057 
  12058 //------------------------------------------------------------------------------
  12059 // Header parsing
  12060 
  12061 func ResetSegmentHeader(tls *libc.TLS, hdr uintptr) {
  12062 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment = 0
  12063 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = 0
  12064 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta = int32(1)
  12065 	libc.X__builtin___memset_chk(tls, hdr+12, 0, uint64(4), ^__predefined_size_t(0))
  12066 	libc.X__builtin___memset_chk(tls, hdr+16, 0, uint64(4), ^__predefined_size_t(0))
  12067 }
  12068 
  12069 // C documentation
  12070 //
  12071 //	// Paragraph 9.3
  12072 func ParseSegmentHeader(tls *libc.TLS, br uintptr, hdr uintptr, proba uintptr) (r int32) {
  12073 	var s, s1, v2 int32
  12074 	var v6 uint32
  12075 	_, _, _, _ = s, s1, v2, v6
  12076 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12077 	if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment != 0 {
  12078 		(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12079 		if VP8GetValue(tls, br, int32(1)) != 0 {
  12080 			(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12081 			s = 0
  12082 			for {
  12083 				if !(s < int32(NUM_MB_SEGMENTS)) {
  12084 					break
  12085 				}
  12086 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12087 					v2 = VP8GetSignedValue(tls, br, int32(7))
  12088 				} else {
  12089 					v2 = 0
  12090 				}
  12091 				**(**int8_t)(__ccgo_up(hdr + 12 + uintptr(s))) = int8(v2)
  12092 				goto _1
  12093 			_1:
  12094 				;
  12095 				s = s + 1
  12096 			}
  12097 			s = 0
  12098 			for {
  12099 				if !(s < int32(NUM_MB_SEGMENTS)) {
  12100 					break
  12101 				}
  12102 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12103 					v2 = VP8GetSignedValue(tls, br, int32(6))
  12104 				} else {
  12105 					v2 = 0
  12106 				}
  12107 				**(**int8_t)(__ccgo_up(hdr + 16 + uintptr(s))) = int8(v2)
  12108 				goto _3
  12109 			_3:
  12110 				;
  12111 				s = s + 1
  12112 			}
  12113 		}
  12114 		if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map != 0 {
  12115 			s1 = 0
  12116 			for {
  12117 				if !(s1 < int32(MB_FEATURE_TREE_PROBS)) {
  12118 					break
  12119 				}
  12120 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12121 					v6 = VP8GetValue(tls, br, int32(8))
  12122 				} else {
  12123 					v6 = uint32(255)
  12124 				}
  12125 				**(**uint8_t)(__ccgo_up(proba + uintptr(s1))) = uint8(v6)
  12126 				goto _5
  12127 			_5:
  12128 				;
  12129 				s1 = s1 + 1
  12130 			}
  12131 		}
  12132 	} else {
  12133 		(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = 0
  12134 	}
  12135 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0))
  12136 }
  12137 
  12138 // C documentation
  12139 //
  12140 //	// Paragraph 9.5
  12141 //	// If we don't have all the necessary data in 'buf', this function returns
  12142 //	// VP8_STATUS_SUSPENDED in incremental decoding, VP8_STATUS_NOT_ENOUGH_DATA
  12143 //	// otherwise.
  12144 //	// In incremental decoding, this case is not necessarily an error. Still, no
  12145 //	// bitreader is ever initialized to make it possible to read unavailable memory.
  12146 //	// If we don't even have the partitions' sizes, then VP8_STATUS_NOT_ENOUGH_DATA
  12147 //	// is returned, and this is an unrecoverable error.
  12148 //	// If the partitions were positioned ok, VP8_STATUS_OK is returned.
  12149 func ParsePartitions(tls *libc.TLS, dec uintptr, buf uintptr, size size_t) (r VP8StatusCode1) {
  12150 	var br, buf_end, part_start, sz uintptr
  12151 	var last_part, p, psize, size_left size_t
  12152 	var v2 int32
  12153 	_, _, _, _, _, _, _, _, _ = br, buf_end, last_part, p, part_start, psize, size_left, sz, v2
  12154 	br = dec + 16
  12155 	sz = buf
  12156 	buf_end = buf + uintptr(size)
  12157 	size_left = size
  12158 	(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one = libc.Uint32FromInt32(int32(1)<<VP8GetValue(tls, br, int32(2)) - int32(1))
  12159 	last_part = uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)
  12160 	if size < uint64(3)*last_part {
  12161 		// we can't even read the sizes with sz[]! That's a failure.
  12162 		return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  12163 	}
  12164 	part_start = buf + uintptr(last_part*uint64(3))
  12165 	size_left = size_left - last_part*uint64(3)
  12166 	p = uint64(0)
  12167 	for {
  12168 		if !(p < last_part) {
  12169 			break
  12170 		}
  12171 		psize = libc.Uint64FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(sz))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(sz + 1)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(sz + 2)))<<int32(16))
  12172 		if psize > size_left {
  12173 			psize = size_left
  12174 		}
  12175 		VP8InitBitReader(tls, dec+440+uintptr(p)*48, part_start, psize)
  12176 		part_start = part_start + uintptr(psize)
  12177 		size_left = size_left - psize
  12178 		sz = sz + uintptr(3)
  12179 		goto _1
  12180 	_1:
  12181 		;
  12182 		p = p + 1
  12183 	}
  12184 	VP8InitBitReader(tls, dec+440+uintptr(last_part)*48, part_start, size_left)
  12185 	if part_start < buf_end {
  12186 		return int32(VP8_STATUS_OK)
  12187 	}
  12188 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  12189 		v2 = int32(VP8_STATUS_SUSPENDED)
  12190 	} else {
  12191 		v2 = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  12192 	}
  12193 	return v2
  12194 }
  12195 
  12196 // C documentation
  12197 //
  12198 //	// Paragraph 9.4
  12199 func ParseFilterHeader(tls *libc.TLS, br uintptr, dec uintptr) (r int32) {
  12200 	var hdr uintptr
  12201 	var i, v3, v4 int32
  12202 	_, _, _, _ = hdr, i, v3, v4
  12203 	hdr = dec + 84
  12204 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsimple = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12205 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel = libc.Int32FromUint32(VP8GetValue(tls, br, int32(6)))
  12206 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness = libc.Int32FromUint32(VP8GetValue(tls, br, int32(3)))
  12207 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12208 	if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta != 0 {
  12209 		if VP8GetValue(tls, br, int32(1)) != 0 {
  12210 			i = 0
  12211 			for {
  12212 				if !(i < int32(NUM_REF_LF_DELTAS)) {
  12213 					break
  12214 				}
  12215 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12216 					**(**int32)(__ccgo_up(hdr + 16 + uintptr(i)*4)) = VP8GetSignedValue(tls, br, int32(6))
  12217 				}
  12218 				goto _1
  12219 			_1:
  12220 				;
  12221 				i = i + 1
  12222 			}
  12223 			i = 0
  12224 			for {
  12225 				if !(i < int32(NUM_MODE_LF_DELTAS)) {
  12226 					break
  12227 				}
  12228 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12229 					**(**int32)(__ccgo_up(hdr + 32 + uintptr(i)*4)) = VP8GetSignedValue(tls, br, int32(6))
  12230 				}
  12231 				goto _2
  12232 			_2:
  12233 				;
  12234 				i = i + 1
  12235 			}
  12236 		}
  12237 	}
  12238 	if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel == 0 {
  12239 		v3 = 0
  12240 	} else {
  12241 		if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsimple != 0 {
  12242 			v4 = int32(1)
  12243 		} else {
  12244 			v4 = int32(2)
  12245 		}
  12246 		v3 = v4
  12247 	}
  12248 	(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type = v3
  12249 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0))
  12250 }
  12251 
  12252 // C documentation
  12253 //
  12254 //	// Topmost call
  12255 func VP8GetHeaders(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  12256 	var bits uint32_t
  12257 	var br, buf, frm_hdr, pic_hdr uintptr
  12258 	var buf_size size_t
  12259 	var status VP8StatusCode1
  12260 	_, _, _, _, _, _, _ = bits, br, buf, buf_size, frm_hdr, pic_hdr, status
  12261 	if dec == libc.UintptrFromInt32(0) {
  12262 		return 0
  12263 	}
  12264 	SetOk(tls, dec)
  12265 	if io == libc.UintptrFromInt32(0) {
  12266 		return VP8SetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM), __ccgo_ts+167)
  12267 	}
  12268 	buf = (*VP8Io)(unsafe.Pointer(io)).Fdata
  12269 	buf_size = (*VP8Io)(unsafe.Pointer(io)).Fdata_size
  12270 	if buf_size < uint64(4) {
  12271 		return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+204)
  12272 	}
  12273 	// Paragraph 9.1
  12274 	bits = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 1)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 2)))<<int32(16))
  12275 	frm_hdr = dec + 68
  12276 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame = libc.BoolUint8(!(bits&libc.Uint32FromInt32(1) != 0))
  12277 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fprofile = uint8(bits >> libc.Int32FromInt32(1) & uint32(7))
  12278 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fshow = uint8(bits >> libc.Int32FromInt32(4) & uint32(1))
  12279 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length = bits >> libc.Int32FromInt32(5)
  12280 	if libc.Int32FromUint8((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fprofile) > int32(3) {
  12281 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+222)
  12282 	}
  12283 	if !((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fshow != 0) {
  12284 		return VP8SetError(tls, dec, int32(VP8_STATUS_UNSUPPORTED_FEATURE), __ccgo_ts+253)
  12285 	}
  12286 	buf = buf + uintptr(3)
  12287 	buf_size = buf_size - uint64(3)
  12288 	pic_hdr = dec + 76
  12289 	if (*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0 {
  12290 		// Paragraph 9.2
  12291 		if buf_size < uint64(7) {
  12292 			return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+276)
  12293 		}
  12294 		if !(VP8CheckSignature(tls, buf, buf_size) != 0) {
  12295 			return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+304)
  12296 		}
  12297 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fwidth = libc.Uint16FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 4)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 3)))) & int32(0x3fff))
  12298 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fxscale = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 4))) >> int32(6)) // ratio: 1, 5/4 5/3 or 2
  12299 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fheight = libc.Uint16FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 6)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 5)))) & int32(0x3fff))
  12300 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fyscale = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 6))) >> int32(6))
  12301 		buf = buf + uintptr(7)
  12302 		buf_size = buf_size - uint64(7)
  12303 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w = (libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fwidth) + int32(15)) >> int32(4)
  12304 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h = (libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fheight) + int32(15)) >> int32(4)
  12305 		// Setup default output area (can be later modified during io->setup())
  12306 		(*VP8Io)(unsafe.Pointer(io)).Fwidth = libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fwidth)
  12307 		(*VP8Io)(unsafe.Pointer(io)).Fheight = libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fheight)
  12308 		// IMPORTANT! use some sane dimensions in crop* and scaled* fields.
  12309 		// So they can be used interchangeably without always testing for
  12310 		// 'use_cropping'.
  12311 		(*VP8Io)(unsafe.Pointer(io)).Fuse_cropping = 0
  12312 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_top = 0
  12313 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_left = 0
  12314 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_right = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  12315 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom = (*VP8Io)(unsafe.Pointer(io)).Fheight
  12316 		(*VP8Io)(unsafe.Pointer(io)).Fuse_scaling = 0
  12317 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_width = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  12318 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_height = (*VP8Io)(unsafe.Pointer(io)).Fheight
  12319 		(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fwidth  // for soundness
  12320 		(*VP8Io)(unsafe.Pointer(io)).Fmb_h = (*VP8Io)(unsafe.Pointer(io)).Fheight // ditto
  12321 		VP8ResetProba(tls, dec+1192)
  12322 		ResetSegmentHeader(tls, dec+132)
  12323 	}
  12324 	// Check if we have all the partition #0 available, and initialize dec->br
  12325 	// to read this partition (and this partition only).
  12326 	if uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length) > buf_size {
  12327 		return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+318)
  12328 	}
  12329 	br = dec + 16
  12330 	VP8InitBitReader(tls, br, buf, uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length))
  12331 	buf = buf + uintptr((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length)
  12332 	buf_size = buf_size - uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length)
  12333 	if (*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0 {
  12334 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fcolorspace = uint8(VP8GetValue(tls, br, int32(1)))
  12335 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fclamp_type = uint8(VP8GetValue(tls, br, int32(1)))
  12336 	}
  12337 	if !(ParseSegmentHeader(tls, br, dec+132, dec+1192) != 0) {
  12338 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+339)
  12339 	}
  12340 	// Filter specs
  12341 	if !(ParseFilterHeader(tls, br, dec) != 0) {
  12342 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+367)
  12343 	}
  12344 	status = ParsePartitions(tls, dec, buf, buf_size)
  12345 	if status != int32(VP8_STATUS_OK) {
  12346 		return VP8SetError(tls, dec, status, __ccgo_ts+394)
  12347 	}
  12348 	// quantizer change
  12349 	VP8ParseQuant(tls, dec)
  12350 	// Frame buffer marking
  12351 	if !((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0) {
  12352 		return VP8SetError(tls, dec, int32(VP8_STATUS_UNSUPPORTED_FEATURE), __ccgo_ts+418)
  12353 	}
  12354 	VP8GetValue(tls, br, int32(1)) // ignore the value of 'update_proba'
  12355 	VP8ParseProba(tls, br, dec)
  12356 	// sanitized state
  12357 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = int32(1)
  12358 	return int32(1)
  12359 }
  12360 
  12361 //------------------------------------------------------------------------------
  12362 // Residual decoding (Paragraph 13.2 / 13.3)
  12363 
  12364 var kCat3 = [4]uint8_t{
  12365 	0: uint8(173),
  12366 	1: uint8(148),
  12367 	2: uint8(140),
  12368 }
  12369 var kCat4 = [5]uint8_t{
  12370 	0: uint8(176),
  12371 	1: uint8(155),
  12372 	2: uint8(140),
  12373 	3: uint8(135),
  12374 }
  12375 var kCat5 = [6]uint8_t{
  12376 	0: uint8(180),
  12377 	1: uint8(157),
  12378 	2: uint8(141),
  12379 	3: uint8(134),
  12380 	4: uint8(130),
  12381 }
  12382 var kCat6 = [12]uint8_t{
  12383 	0:  uint8(254),
  12384 	1:  uint8(254),
  12385 	2:  uint8(243),
  12386 	3:  uint8(230),
  12387 	4:  uint8(196),
  12388 	5:  uint8(177),
  12389 	6:  uint8(153),
  12390 	7:  uint8(140),
  12391 	8:  uint8(133),
  12392 	9:  uint8(130),
  12393 	10: uint8(129),
  12394 }
  12395 var kCat3456 = [4]uintptr{
  12396 	0: uintptr(unsafe.Pointer(&kCat3)),
  12397 	1: uintptr(unsafe.Pointer(&kCat4)),
  12398 	2: uintptr(unsafe.Pointer(&kCat5)),
  12399 	3: uintptr(unsafe.Pointer(&kCat6)),
  12400 }
  12401 var kZigzag = [16]uint8_t{
  12402 	1:  uint8(1),
  12403 	2:  uint8(4),
  12404 	3:  uint8(8),
  12405 	4:  uint8(5),
  12406 	5:  uint8(2),
  12407 	6:  uint8(3),
  12408 	7:  uint8(6),
  12409 	8:  uint8(9),
  12410 	9:  uint8(12),
  12411 	10: uint8(13),
  12412 	11: uint8(10),
  12413 	12: uint8(7),
  12414 	13: uint8(11),
  12415 	14: uint8(14),
  12416 	15: uint8(15),
  12417 }
  12418 
  12419 // C documentation
  12420 //
  12421 //	// See section 13-2: https://datatracker.ietf.org/doc/html/rfc6386#section-13.2
  12422 func GetLargeValue(tls *libc.TLS, br2 uintptr, p uintptr) (r int32) {
  12423 	bp := tls.Alloc(16)
  12424 	defer tls.Free(16)
  12425 	var bit, bit0, bit1, cat, pos, shift, v, v13, v15, v21, v23, v5, v7 int32
  12426 	var bits bit_t
  12427 	var range1, split, value range_t
  12428 	var tab, v1, v10, v17, v18, v2, v9 uintptr
  12429 	var v11, v19, v3 uint64_t
  12430 	var _ /* in_bits at bp+0 */ lbit_t
  12431 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bit0, bit1, bits, cat, pos, range1, shift, split, tab, v, value, v1, v10, v11, v13, v15, v17, v18, v19, v2, v21, v23, v3, v5, v7, v9
  12432 	v1 = br2
  12433 	range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12434 	if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12435 		v2 = v1
  12436 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12437 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12438 			**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12439 			v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12440 			goto _4
  12441 		_4:
  12442 			bits = v3
  12443 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12444 			(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12445 			**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12446 		} else {
  12447 			VP8LoadFinalBytes(tls, v2)
  12448 		}
  12449 	}
  12450 	pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12451 	split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 3)))) >> int32(8)
  12452 	value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12453 	bit = libc.BoolInt32(value > split)
  12454 	if bit != 0 {
  12455 		range1 = range1 - split
  12456 		**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12457 	} else {
  12458 		range1 = split + uint32(1)
  12459 	}
  12460 	v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12461 	goto _6
  12462 _6:
  12463 	shift = int32(7) ^ v5
  12464 	range1 = range1 << libc.Uint32FromInt32(shift)
  12465 	**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12466 	(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12467 	v7 = bit
  12468 	goto _8
  12469 _8:
  12470 	if !(v7 != 0) {
  12471 		v9 = br2
  12472 		range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12473 		if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12474 			v10 = v9
  12475 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12476 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12477 				**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12478 				v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12479 				goto _12
  12480 			_12:
  12481 				bits = v11
  12482 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12483 				(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12484 				**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12485 			} else {
  12486 				VP8LoadFinalBytes(tls, v10)
  12487 			}
  12488 		}
  12489 		pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12490 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 4)))) >> int32(8)
  12491 		value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12492 		bit = libc.BoolInt32(value > split)
  12493 		if bit != 0 {
  12494 			range1 = range1 - split
  12495 			**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12496 		} else {
  12497 			range1 = split + uint32(1)
  12498 		}
  12499 		v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12500 		goto _14
  12501 	_14:
  12502 		shift = int32(7) ^ v13
  12503 		range1 = range1 << libc.Uint32FromInt32(shift)
  12504 		**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12505 		(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12506 		v15 = bit
  12507 		goto _16
  12508 	_16:
  12509 		if !(v15 != 0) {
  12510 			v = int32(2)
  12511 		} else {
  12512 			v1 = br2
  12513 			range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12514 			if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12515 				v2 = v1
  12516 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12517 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12518 					**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12519 					v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12520 					goto _20
  12521 				_20:
  12522 					bits = v3
  12523 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12524 					(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12525 					**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12526 				} else {
  12527 					VP8LoadFinalBytes(tls, v2)
  12528 				}
  12529 			}
  12530 			pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12531 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 5)))) >> int32(8)
  12532 			value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12533 			bit = libc.BoolInt32(value > split)
  12534 			if bit != 0 {
  12535 				range1 = range1 - split
  12536 				**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12537 			} else {
  12538 				range1 = split + uint32(1)
  12539 			}
  12540 			v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12541 			goto _22
  12542 		_22:
  12543 			shift = int32(7) ^ v5
  12544 			range1 = range1 << libc.Uint32FromInt32(shift)
  12545 			**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12546 			(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12547 			v7 = bit
  12548 			goto _24
  12549 		_24:
  12550 			v = int32(3) + v7
  12551 		}
  12552 	} else {
  12553 		v1 = br2
  12554 		range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12555 		if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12556 			v2 = v1
  12557 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12558 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12559 				**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12560 				v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12561 				goto _28
  12562 			_28:
  12563 				bits = v3
  12564 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12565 				(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12566 				**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12567 			} else {
  12568 				VP8LoadFinalBytes(tls, v2)
  12569 			}
  12570 		}
  12571 		pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12572 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 6)))) >> int32(8)
  12573 		value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12574 		bit = libc.BoolInt32(value > split)
  12575 		if bit != 0 {
  12576 			range1 = range1 - split
  12577 			**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12578 		} else {
  12579 			range1 = split + uint32(1)
  12580 		}
  12581 		v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12582 		goto _30
  12583 	_30:
  12584 		shift = int32(7) ^ v5
  12585 		range1 = range1 << libc.Uint32FromInt32(shift)
  12586 		**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12587 		(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12588 		v7 = bit
  12589 		goto _32
  12590 	_32:
  12591 		if !(v7 != 0) {
  12592 			v9 = br2
  12593 			range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12594 			if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12595 				v10 = v9
  12596 				if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12597 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12598 					**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12599 					v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12600 					goto _36
  12601 				_36:
  12602 					bits = v11
  12603 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12604 					(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12605 					**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12606 				} else {
  12607 					VP8LoadFinalBytes(tls, v10)
  12608 				}
  12609 			}
  12610 			pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12611 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 7)))) >> int32(8)
  12612 			value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12613 			bit = libc.BoolInt32(value > split)
  12614 			if bit != 0 {
  12615 				range1 = range1 - split
  12616 				**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12617 			} else {
  12618 				range1 = split + uint32(1)
  12619 			}
  12620 			v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12621 			goto _38
  12622 		_38:
  12623 			shift = int32(7) ^ v13
  12624 			range1 = range1 << libc.Uint32FromInt32(shift)
  12625 			**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12626 			(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12627 			v15 = bit
  12628 			goto _40
  12629 		_40:
  12630 			if !(v15 != 0) {
  12631 				v17 = br2
  12632 				range1 = (*VP8BitReader)(unsafe.Pointer(v17)).Frange1
  12633 				if (*VP8BitReader)(unsafe.Pointer(v17)).Fbits < libc.Int32FromInt32(0) {
  12634 					v18 = v17
  12635 					if (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf_max {
  12636 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12637 						**(**uintptr)(__ccgo_up(v18 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12638 						v19 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12639 						goto _44
  12640 					_44:
  12641 						bits = v19
  12642 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12643 						(*VP8BitReader)(unsafe.Pointer(v18)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v18)).Fvalue<<libc.Int32FromInt32(BITS)
  12644 						**(**int32)(__ccgo_up(v18 + 12)) += int32(BITS)
  12645 					} else {
  12646 						VP8LoadFinalBytes(tls, v18)
  12647 					}
  12648 				}
  12649 				pos = (*VP8BitReader)(unsafe.Pointer(v17)).Fbits
  12650 				split = range1 * libc.Uint32FromInt32(int32(159)) >> int32(8)
  12651 				value = uint32((*VP8BitReader)(unsafe.Pointer(v17)).Fvalue >> pos)
  12652 				bit = libc.BoolInt32(value > split)
  12653 				if bit != 0 {
  12654 					range1 = range1 - split
  12655 					**(**bit_t)(__ccgo_up(v17)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12656 				} else {
  12657 					range1 = split + uint32(1)
  12658 				}
  12659 				v21 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12660 				goto _46
  12661 			_46:
  12662 				shift = int32(7) ^ v21
  12663 				range1 = range1 << libc.Uint32FromInt32(shift)
  12664 				**(**int32)(__ccgo_up(v17 + 12)) -= shift
  12665 				(*VP8BitReader)(unsafe.Pointer(v17)).Frange1 = range1 - uint32(1)
  12666 				v23 = bit
  12667 				goto _48
  12668 			_48:
  12669 				v = int32(5) + v23
  12670 			} else {
  12671 				v1 = br2
  12672 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12673 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12674 					v2 = v1
  12675 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12676 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12677 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12678 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12679 						goto _52
  12680 					_52:
  12681 						bits = v3
  12682 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12683 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12684 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12685 					} else {
  12686 						VP8LoadFinalBytes(tls, v2)
  12687 					}
  12688 				}
  12689 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12690 				split = range1 * libc.Uint32FromInt32(int32(165)) >> int32(8)
  12691 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12692 				bit = libc.BoolInt32(value > split)
  12693 				if bit != 0 {
  12694 					range1 = range1 - split
  12695 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12696 				} else {
  12697 					range1 = split + uint32(1)
  12698 				}
  12699 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12700 				goto _54
  12701 			_54:
  12702 				shift = int32(7) ^ v5
  12703 				range1 = range1 << libc.Uint32FromInt32(shift)
  12704 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12705 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12706 				v7 = bit
  12707 				goto _56
  12708 			_56:
  12709 				v = int32(7) + int32(2)*v7
  12710 				v1 = br2
  12711 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12712 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12713 					v2 = v1
  12714 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12715 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12716 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12717 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12718 						goto _60
  12719 					_60:
  12720 						bits = v3
  12721 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12722 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12723 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12724 					} else {
  12725 						VP8LoadFinalBytes(tls, v2)
  12726 					}
  12727 				}
  12728 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12729 				split = range1 * libc.Uint32FromInt32(int32(145)) >> int32(8)
  12730 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12731 				bit = libc.BoolInt32(value > split)
  12732 				if bit != 0 {
  12733 					range1 = range1 - split
  12734 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12735 				} else {
  12736 					range1 = split + uint32(1)
  12737 				}
  12738 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12739 				goto _62
  12740 			_62:
  12741 				shift = int32(7) ^ v5
  12742 				range1 = range1 << libc.Uint32FromInt32(shift)
  12743 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12744 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12745 				v7 = bit
  12746 				goto _64
  12747 			_64:
  12748 				v = v + v7
  12749 			}
  12750 		} else {
  12751 			v1 = br2
  12752 			range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12753 			if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12754 				v2 = v1
  12755 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12756 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12757 					**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12758 					v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12759 					goto _68
  12760 				_68:
  12761 					bits = v3
  12762 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12763 					(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12764 					**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12765 				} else {
  12766 					VP8LoadFinalBytes(tls, v2)
  12767 				}
  12768 			}
  12769 			pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12770 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8)))) >> int32(8)
  12771 			value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12772 			bit = libc.BoolInt32(value > split)
  12773 			if bit != 0 {
  12774 				range1 = range1 - split
  12775 				**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12776 			} else {
  12777 				range1 = split + uint32(1)
  12778 			}
  12779 			v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12780 			goto _70
  12781 		_70:
  12782 			shift = int32(7) ^ v5
  12783 			range1 = range1 << libc.Uint32FromInt32(shift)
  12784 			**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12785 			(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12786 			v7 = bit
  12787 			goto _72
  12788 		_72:
  12789 			bit1 = v7
  12790 			v9 = br2
  12791 			range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12792 			if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12793 				v10 = v9
  12794 				if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12795 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12796 					**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12797 					v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12798 					goto _76
  12799 				_76:
  12800 					bits = v11
  12801 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12802 					(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12803 					**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12804 				} else {
  12805 					VP8LoadFinalBytes(tls, v10)
  12806 				}
  12807 			}
  12808 			pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12809 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(9)+bit1))))) >> int32(8)
  12810 			value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12811 			bit = libc.BoolInt32(value > split)
  12812 			if bit != 0 {
  12813 				range1 = range1 - split
  12814 				**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12815 			} else {
  12816 				range1 = split + uint32(1)
  12817 			}
  12818 			v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12819 			goto _78
  12820 		_78:
  12821 			shift = int32(7) ^ v13
  12822 			range1 = range1 << libc.Uint32FromInt32(shift)
  12823 			**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12824 			(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12825 			v15 = bit
  12826 			goto _80
  12827 		_80:
  12828 			bit0 = v15
  12829 			cat = int32(2)*bit1 + bit0
  12830 			v = 0
  12831 			tab = kCat3456[cat]
  12832 			for {
  12833 				if !(**(**uint8_t)(__ccgo_up(tab)) != 0) {
  12834 					break
  12835 				}
  12836 				v1 = br2
  12837 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12838 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12839 					v2 = v1
  12840 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12841 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12842 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12843 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12844 						goto _85
  12845 					_85:
  12846 						bits = v3
  12847 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12848 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12849 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12850 					} else {
  12851 						VP8LoadFinalBytes(tls, v2)
  12852 					}
  12853 				}
  12854 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12855 				split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(tab)))) >> int32(8)
  12856 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12857 				bit = libc.BoolInt32(value > split)
  12858 				if bit != 0 {
  12859 					range1 = range1 - split
  12860 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12861 				} else {
  12862 					range1 = split + uint32(1)
  12863 				}
  12864 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12865 				goto _87
  12866 			_87:
  12867 				shift = int32(7) ^ v5
  12868 				range1 = range1 << libc.Uint32FromInt32(shift)
  12869 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12870 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12871 				v7 = bit
  12872 				goto _89
  12873 			_89:
  12874 				v = v + (v + v7)
  12875 				goto _81
  12876 			_81:
  12877 				;
  12878 				tab = tab + 1
  12879 			}
  12880 			v = v + (int32(3) + int32(8)<<cat)
  12881 		}
  12882 	}
  12883 	return v
  12884 }
  12885 
  12886 // C documentation
  12887 //
  12888 //	// Returns the position of the last non-zero coeff plus one
  12889 func GetCoeffsFast(tls *libc.TLS, br3 uintptr, prob1 uintptr, ctx int32, dq uintptr, n1 int32, out uintptr) (r int32) {
  12890 	bp := tls.Alloc(16)
  12891 	defer tls.Free(16)
  12892 	var bit, pos, pos1, shift, v1, v14, v6, v8 int32
  12893 	var bits bit_t
  12894 	var mask int32_t
  12895 	var p, p_ctx, v2, v3 uintptr
  12896 	var range1, split, split1, value, value1 range_t
  12897 	var v4 uint64_t
  12898 	var _ /* in_bits at bp+0 */ lbit_t
  12899 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, mask, p, p_ctx, pos, pos1, range1, shift, split, split1, v1, value, value1, v14, v2, v3, v4, v6, v8
  12900 	p = **(**uintptr)(__ccgo_up(prob1 + uintptr(n1)*8)) + uintptr(ctx)*11
  12901 	for {
  12902 		if !(n1 < int32(16)) {
  12903 			break
  12904 		}
  12905 		v2 = br3
  12906 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12907 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  12908 			v3 = v2
  12909 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  12910 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12911 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12912 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12913 				goto _5
  12914 			_5:
  12915 				bits = v4
  12916 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12917 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  12918 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  12919 			} else {
  12920 				VP8LoadFinalBytes(tls, v3)
  12921 			}
  12922 		}
  12923 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  12924 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) >> int32(8)
  12925 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  12926 		bit = libc.BoolInt32(value > split)
  12927 		if bit != 0 {
  12928 			range1 = range1 - split
  12929 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12930 		} else {
  12931 			range1 = split + uint32(1)
  12932 		}
  12933 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12934 		goto _7
  12935 	_7:
  12936 		shift = int32(7) ^ v6
  12937 		range1 = range1 << libc.Uint32FromInt32(shift)
  12938 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  12939 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  12940 		v8 = bit
  12941 		goto _9
  12942 	_9:
  12943 		if !(v8 != 0) {
  12944 			return n1 // previous coeff was last non-zero coeff
  12945 		}
  12946 		for {
  12947 			v2 = br3
  12948 			range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12949 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  12950 				v3 = v2
  12951 				if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  12952 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12953 					**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12954 					v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12955 					goto _13
  12956 				_13:
  12957 					bits = v4
  12958 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12959 					(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  12960 					**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  12961 				} else {
  12962 					VP8LoadFinalBytes(tls, v3)
  12963 				}
  12964 			}
  12965 			pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  12966 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) >> int32(8)
  12967 			value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  12968 			bit = libc.BoolInt32(value > split)
  12969 			if bit != 0 {
  12970 				range1 = range1 - split
  12971 				**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12972 			} else {
  12973 				range1 = split + uint32(1)
  12974 			}
  12975 			v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12976 			goto _15
  12977 		_15:
  12978 			shift = int32(7) ^ v6
  12979 			range1 = range1 << libc.Uint32FromInt32(shift)
  12980 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  12981 			(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  12982 			v8 = bit
  12983 			goto _17
  12984 		_17:
  12985 			if !!(v8 != 0) {
  12986 				break
  12987 			} // sequence of zero coeffs
  12988 			n1 = n1 + 1
  12989 			v14 = n1
  12990 			p = **(**uintptr)(__ccgo_up(prob1 + uintptr(v14)*8))
  12991 			if n1 == int32(16) {
  12992 				return int32(16)
  12993 			}
  12994 		}
  12995 		// non zero coeff
  12996 		p_ctx = **(**uintptr)(__ccgo_up(prob1 + uintptr(n1+int32(1))*8))
  12997 		v2 = br3
  12998 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12999 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13000 			v3 = v2
  13001 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13002 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13003 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13004 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13005 				goto _22
  13006 			_22:
  13007 				bits = v4
  13008 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13009 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13010 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13011 			} else {
  13012 				VP8LoadFinalBytes(tls, v3)
  13013 			}
  13014 		}
  13015 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13016 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) >> int32(8)
  13017 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  13018 		bit = libc.BoolInt32(value > split)
  13019 		if bit != 0 {
  13020 			range1 = range1 - split
  13021 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  13022 		} else {
  13023 			range1 = split + uint32(1)
  13024 		}
  13025 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  13026 		goto _24
  13027 	_24:
  13028 		shift = int32(7) ^ v6
  13029 		range1 = range1 << libc.Uint32FromInt32(shift)
  13030 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13031 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  13032 		v8 = bit
  13033 		goto _26
  13034 	_26:
  13035 		if !(v8 != 0) {
  13036 			v1 = int32(1)
  13037 			p = p_ctx + 1*11
  13038 		} else {
  13039 			v1 = GetLargeValue(tls, br3, p)
  13040 			p = p_ctx + 2*11
  13041 		}
  13042 		v2 = br3
  13043 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13044 			v3 = v2
  13045 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13046 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13047 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13048 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13049 				goto _30
  13050 			_30:
  13051 				bits = v4
  13052 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13053 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13054 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13055 			} else {
  13056 				VP8LoadFinalBytes(tls, v3)
  13057 			}
  13058 		}
  13059 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13060 		split1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1 >> int32(1)
  13061 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13062 		mask = libc.Int32FromUint32(split1-value1) >> int32(31)
  13063 		**(**int32)(__ccgo_up(v2 + 12)) -= int32(1)
  13064 		**(**range_t)(__ccgo_up(v2 + 8)) += libc.Uint32FromInt32(mask)
  13065 		**(**range_t)(__ccgo_up(v2 + 8)) |= uint32(1)
  13066 		**(**bit_t)(__ccgo_up(v2)) -= uint64((split1+libc.Uint32FromInt32(1))&libc.Uint32FromInt32(mask)) << pos1
  13067 		v6 = v1 ^ mask - mask
  13068 		goto _32
  13069 	_32:
  13070 		**(**int16_t)(__ccgo_up(out + uintptr(kZigzag[n1])*2)) = int16(v6 * **(**int32)(__ccgo_up(dq + libc.BoolUintptr(n1 > 0)*4)))
  13071 		goto _1
  13072 	_1:
  13073 		;
  13074 		n1 = n1 + 1
  13075 	}
  13076 	return int32(16)
  13077 }
  13078 
  13079 // C documentation
  13080 //
  13081 //	// This version of GetCoeffs() uses VP8GetBitAlt() which is an alternate version
  13082 //	// of VP8GetBitAlt() targeting specific platforms.
  13083 func GetCoeffsAlt(tls *libc.TLS, br3 uintptr, prob1 uintptr, ctx int32, dq uintptr, n int32, out uintptr) (r int32) {
  13084 	bp := tls.Alloc(16)
  13085 	defer tls.Free(16)
  13086 	var bit, pos, pos1, shift, v1, v12, v6 int32
  13087 	var bits bit_t
  13088 	var mask int32_t
  13089 	var p, p_ctx, v2, v3 uintptr
  13090 	var range1, split, split1, value, value1 range_t
  13091 	var v4 uint64_t
  13092 	var _ /* in_bits at bp+0 */ lbit_t
  13093 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, mask, p, p_ctx, pos, pos1, range1, shift, split, split1, v1, value, value1, v12, v2, v3, v4, v6
  13094 	p = **(**uintptr)(__ccgo_up(prob1 + uintptr(n)*8)) + uintptr(ctx)*11
  13095 	for {
  13096 		if !(n < int32(16)) {
  13097 			break
  13098 		}
  13099 		v2 = br3
  13100 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13101 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13102 			v3 = v2
  13103 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13104 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13105 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13106 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13107 				goto _5
  13108 			_5:
  13109 				bits = v4
  13110 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13111 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13112 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13113 			} else {
  13114 				VP8LoadFinalBytes(tls, v3)
  13115 			}
  13116 		}
  13117 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13118 		split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) >> int32(8)
  13119 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13120 		if value1 > split1 {
  13121 			range1 = range1 - (split1 + uint32(1))
  13122 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13123 			bit = int32(1)
  13124 		} else {
  13125 			range1 = split1
  13126 			bit = 0
  13127 		}
  13128 		if range1 <= libc.Uint32FromInt32(0x7e) {
  13129 			shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13130 			range1 = uint32(kVP8NewRange[range1])
  13131 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13132 		}
  13133 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13134 		v6 = bit
  13135 		goto _7
  13136 	_7:
  13137 		if !(v6 != 0) {
  13138 			return n // previous coeff was last non-zero coeff
  13139 		}
  13140 		for {
  13141 			v2 = br3
  13142 			range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13143 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13144 				v3 = v2
  13145 				if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13146 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13147 					**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13148 					v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13149 					goto _11
  13150 				_11:
  13151 					bits = v4
  13152 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13153 					(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13154 					**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13155 				} else {
  13156 					VP8LoadFinalBytes(tls, v3)
  13157 				}
  13158 			}
  13159 			pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13160 			split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) >> int32(8)
  13161 			value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13162 			if value1 > split1 {
  13163 				range1 = range1 - (split1 + uint32(1))
  13164 				**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13165 				bit = int32(1)
  13166 			} else {
  13167 				range1 = split1
  13168 				bit = 0
  13169 			}
  13170 			if range1 <= libc.Uint32FromInt32(0x7e) {
  13171 				shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13172 				range1 = uint32(kVP8NewRange[range1])
  13173 				**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13174 			}
  13175 			(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13176 			v6 = bit
  13177 			goto _13
  13178 		_13:
  13179 			if !!(v6 != 0) {
  13180 				break
  13181 			} // sequence of zero coeffs
  13182 			n = n + 1
  13183 			v12 = n
  13184 			p = **(**uintptr)(__ccgo_up(prob1 + uintptr(v12)*8))
  13185 			if n == int32(16) {
  13186 				return int32(16)
  13187 			}
  13188 		}
  13189 		// non zero coeff
  13190 		p_ctx = **(**uintptr)(__ccgo_up(prob1 + uintptr(n+int32(1))*8))
  13191 		v2 = br3
  13192 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13193 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13194 			v3 = v2
  13195 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13196 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13197 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13198 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13199 				goto _18
  13200 			_18:
  13201 				bits = v4
  13202 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13203 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13204 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13205 			} else {
  13206 				VP8LoadFinalBytes(tls, v3)
  13207 			}
  13208 		}
  13209 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13210 		split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) >> int32(8)
  13211 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13212 		if value1 > split1 {
  13213 			range1 = range1 - (split1 + uint32(1))
  13214 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13215 			bit = int32(1)
  13216 		} else {
  13217 			range1 = split1
  13218 			bit = 0
  13219 		}
  13220 		if range1 <= libc.Uint32FromInt32(0x7e) {
  13221 			shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13222 			range1 = uint32(kVP8NewRange[range1])
  13223 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13224 		}
  13225 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13226 		v6 = bit
  13227 		goto _20
  13228 	_20:
  13229 		if !(v6 != 0) {
  13230 			v1 = int32(1)
  13231 			p = p_ctx + 1*11
  13232 		} else {
  13233 			v1 = GetLargeValue(tls, br3, p)
  13234 			p = p_ctx + 2*11
  13235 		}
  13236 		v2 = br3
  13237 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13238 			v3 = v2
  13239 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13240 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13241 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13242 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13243 				goto _24
  13244 			_24:
  13245 				bits = v4
  13246 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13247 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13248 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13249 			} else {
  13250 				VP8LoadFinalBytes(tls, v3)
  13251 			}
  13252 		}
  13253 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13254 		split = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1 >> int32(1)
  13255 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  13256 		mask = libc.Int32FromUint32(split-value) >> int32(31)
  13257 		**(**int32)(__ccgo_up(v2 + 12)) -= int32(1)
  13258 		**(**range_t)(__ccgo_up(v2 + 8)) += libc.Uint32FromInt32(mask)
  13259 		**(**range_t)(__ccgo_up(v2 + 8)) |= uint32(1)
  13260 		**(**bit_t)(__ccgo_up(v2)) -= uint64((split+libc.Uint32FromInt32(1))&libc.Uint32FromInt32(mask)) << pos
  13261 		v6 = v1 ^ mask - mask
  13262 		goto _26
  13263 	_26:
  13264 		**(**int16_t)(__ccgo_up(out + uintptr(kZigzag[n])*2)) = int16(v6 * **(**int32)(__ccgo_up(dq + libc.BoolUintptr(n > 0)*4)))
  13265 		goto _1
  13266 	_1:
  13267 		;
  13268 		n = n + 1
  13269 	}
  13270 	return int32(16)
  13271 }
  13272 
  13273 func InitGetCoeffs(tls *libc.TLS) {
  13274 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  13275 		goto _1
  13276 	}
  13277 	InitGetCoeffs_body(tls)
  13278 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used)), VP8GetCPUInfo)
  13279 	goto _2
  13280 _2:
  13281 	;
  13282 	goto _1
  13283 _1: /**/ //
  13284 }
  13285 
  13286 var InitGetCoeffs_body_last_cpuinfo_used = uintptr(0)
  13287 
  13288 func init() {
  13289 	p := unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used)
  13290 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used))
  13291 }
  13292 
  13293 func InitGetCoeffs_body(tls *libc.TLS) {
  13294 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) && (*(*func(*libc.TLS, CPUFeature) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetCPUInfo})))(tls, int32(kSlowSSSE3)) != 0 {
  13295 		GetCoeffs = __ccgo_fp(GetCoeffsAlt)
  13296 	} else {
  13297 		GetCoeffs = __ccgo_fp(GetCoeffsFast)
  13298 	}
  13299 }
  13300 
  13301 func NzCodeBits(tls *libc.TLS, nz_coeffs uint32_t, nz int32, dc_nz int32) (r uint32_t) {
  13302 	var v1, v2 int32
  13303 	_, _ = v1, v2
  13304 	nz_coeffs = nz_coeffs << uint32(2)
  13305 	if nz > int32(3) {
  13306 		v1 = int32(3)
  13307 	} else {
  13308 		if nz > int32(1) {
  13309 			v2 = int32(2)
  13310 		} else {
  13311 			v2 = dc_nz
  13312 		}
  13313 		v1 = v2
  13314 	}
  13315 	nz_coeffs = nz_coeffs | libc.Uint32FromInt32(v1)
  13316 	return nz_coeffs
  13317 }
  13318 
  13319 func ParseResiduals(tls *libc.TLS, dec uintptr, mb uintptr, token_br uintptr) (r int32) {
  13320 	bp := tls.Alloc(32)
  13321 	defer tls.Free(32)
  13322 	var ac_proba, bands, block, dst, left_mb, q uintptr
  13323 	var ch, ctx, ctx1, ctx2, dc0, first, i, l, l1, nz, nz1, nz2, x, y, v8 int32
  13324 	var lnz, tnz, v1 uint8_t
  13325 	var non_zero_uv, non_zero_y, nz_coeffs, nz_coeffs1, out_l_nz, out_t_nz uint32_t
  13326 	var _ /* dc at bp+0 */ [16]int16_t
  13327 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ac_proba, bands, block, ch, ctx, ctx1, ctx2, dc0, dst, first, i, l, l1, left_mb, lnz, non_zero_uv, non_zero_y, nz, nz1, nz2, nz_coeffs, nz_coeffs1, out_l_nz, out_t_nz, q, tnz, x, y, v1, v8
  13328 	bands = dec + 1192 + 1064
  13329 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*800
  13330 	q = dec + 1060 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fsegment)*32
  13331 	dst = block
  13332 	left_mb = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13333 	non_zero_y = uint32(0)
  13334 	non_zero_uv = uint32(0)
  13335 	libc.X__builtin___memset_chk(tls, dst, 0, libc.Uint64FromInt32(384)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  13336 	if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) { // parse DC
  13337 		**(**[16]int16_t)(__ccgo_up(bp)) = [16]int16_t{}
  13338 		ctx = libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz_dc) + libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz_dc)
  13339 		nz = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{GetCoeffs})))(tls, token_br, bands+1*136, ctx, q+8, 0, bp)
  13340 		v1 = libc.BoolUint8(nz > libc.Int32FromInt32(0))
  13341 		(*VP8MB)(unsafe.Pointer(left_mb)).Fnz_dc = v1
  13342 		(*VP8MB)(unsafe.Pointer(mb)).Fnz_dc = v1
  13343 		if nz > int32(1) { // more than just the DC -> perform the full transform
  13344 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformWHT})))(tls, bp, dst)
  13345 		} else {
  13346 			dc0 = (int32((**(**[16]int16_t)(__ccgo_up(bp)))[0]) + int32(3)) >> int32(3)
  13347 			i = 0
  13348 			for {
  13349 				if !(i < libc.Int32FromInt32(16)*libc.Int32FromInt32(16)) {
  13350 					break
  13351 				}
  13352 				**(**int16_t)(__ccgo_up(dst + uintptr(i)*2)) = int16(dc0)
  13353 				goto _2
  13354 			_2:
  13355 				;
  13356 				i = i + int32(16)
  13357 			}
  13358 		}
  13359 		first = int32(1)
  13360 		ac_proba = bands
  13361 	} else {
  13362 		first = 0
  13363 		ac_proba = bands + 3*136
  13364 	}
  13365 	tnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz) & int32(0x0f))
  13366 	lnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz) & int32(0x0f))
  13367 	y = 0
  13368 	for {
  13369 		if !(y < int32(4)) {
  13370 			break
  13371 		}
  13372 		l = libc.Int32FromUint8(lnz) & int32(1)
  13373 		nz_coeffs = uint32(0)
  13374 		x = 0
  13375 		for {
  13376 			if !(x < int32(4)) {
  13377 				break
  13378 			}
  13379 			ctx1 = l + libc.Int32FromUint8(tnz)&int32(1)
  13380 			nz1 = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{GetCoeffs})))(tls, token_br, ac_proba, ctx1, q, first, dst)
  13381 			l = libc.BoolInt32(nz1 > first)
  13382 			tnz = libc.Uint8FromInt32(libc.Int32FromUint8(tnz)>>int32(1) | l<<int32(7))
  13383 			nz_coeffs = NzCodeBits(tls, nz_coeffs, nz1, libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(dst))) != 0))
  13384 			dst = dst + uintptr(16)*2
  13385 			goto _4
  13386 		_4:
  13387 			;
  13388 			x = x + 1
  13389 		}
  13390 		tnz = libc.Uint8FromInt32(int32(tnz) >> libc.Int32FromInt32(4))
  13391 		lnz = libc.Uint8FromInt32(libc.Int32FromUint8(lnz)>>int32(1) | l<<int32(7))
  13392 		non_zero_y = non_zero_y<<libc.Int32FromInt32(8) | nz_coeffs
  13393 		goto _3
  13394 	_3:
  13395 		;
  13396 		y = y + 1
  13397 	}
  13398 	out_t_nz = uint32(tnz)
  13399 	out_l_nz = libc.Uint32FromInt32(libc.Int32FromUint8(lnz) >> int32(4))
  13400 	ch = 0
  13401 	for {
  13402 		if !(ch < int32(4)) {
  13403 			break
  13404 		}
  13405 		nz_coeffs1 = uint32(0)
  13406 		tnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz) >> (int32(4) + ch))
  13407 		lnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz) >> (int32(4) + ch))
  13408 		y = 0
  13409 		for {
  13410 			if !(y < int32(2)) {
  13411 				break
  13412 			}
  13413 			l1 = libc.Int32FromUint8(lnz) & int32(1)
  13414 			x = 0
  13415 			for {
  13416 				if !(x < int32(2)) {
  13417 					break
  13418 				}
  13419 				ctx2 = l1 + libc.Int32FromUint8(tnz)&int32(1)
  13420 				nz2 = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{GetCoeffs})))(tls, token_br, bands+2*136, ctx2, q+16, 0, dst)
  13421 				l1 = libc.BoolInt32(nz2 > 0)
  13422 				tnz = libc.Uint8FromInt32(libc.Int32FromUint8(tnz)>>int32(1) | l1<<int32(3))
  13423 				nz_coeffs1 = NzCodeBits(tls, nz_coeffs1, nz2, libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(dst))) != 0))
  13424 				dst = dst + uintptr(16)*2
  13425 				goto _7
  13426 			_7:
  13427 				;
  13428 				x = x + 1
  13429 			}
  13430 			tnz = libc.Uint8FromInt32(int32(tnz) >> libc.Int32FromInt32(2))
  13431 			lnz = libc.Uint8FromInt32(libc.Int32FromUint8(lnz)>>int32(1) | l1<<int32(5))
  13432 			goto _6
  13433 		_6:
  13434 			;
  13435 			y = y + 1
  13436 		}
  13437 		// Note: we don't really need the per-4x4 details for U/V blocks.
  13438 		non_zero_uv = non_zero_uv | nz_coeffs1<<(int32(4)*ch)
  13439 		out_t_nz = out_t_nz | libc.Uint32FromInt32(libc.Int32FromUint8(tnz)<<int32(4)<<ch)
  13440 		out_l_nz = out_l_nz | libc.Uint32FromInt32(libc.Int32FromUint8(lnz)&int32(0xf0)<<ch)
  13441 		goto _5
  13442 	_5:
  13443 		;
  13444 		ch = ch + int32(2)
  13445 	}
  13446 	(*VP8MB)(unsafe.Pointer(mb)).Fnz = uint8(out_t_nz)
  13447 	(*VP8MB)(unsafe.Pointer(left_mb)).Fnz = uint8(out_l_nz)
  13448 	(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y = non_zero_y
  13449 	(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv = non_zero_uv
  13450 	// We look at the mode-code of each block and check if some blocks have less
  13451 	// than three non-zero coeffs (code < 2). This is to avoid dithering flat and
  13452 	// empty blocks.
  13453 	if non_zero_uv&uint32(0xaaaa) != 0 {
  13454 		v8 = 0
  13455 	} else {
  13456 		v8 = (*VP8QuantMatrix)(unsafe.Pointer(q)).Fdither
  13457 	}
  13458 	(*VP8MBData)(unsafe.Pointer(block)).Fdither = libc.Uint8FromInt32(v8)
  13459 	return libc.BoolInt32(!(non_zero_y|non_zero_uv != 0)) // will be used for further optimization
  13460 }
  13461 
  13462 //------------------------------------------------------------------------------
  13463 // Main loop
  13464 
  13465 func VP8DecodeMB(tls *libc.TLS, dec uintptr, token_br uintptr) (r int32) {
  13466 	var block, finfo, left, mb, v4 uintptr
  13467 	var skip, v1 int32
  13468 	var v2 uint8_t
  13469 	_, _, _, _, _, _, _, _ = block, finfo, left, mb, skip, v1, v2, v4
  13470 	left = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13471 	mb = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2
  13472 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*800
  13473 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
  13474 		v1 = libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(block)).Fskip)
  13475 	} else {
  13476 		v1 = 0
  13477 	}
  13478 	skip = v1
  13479 	if !(skip != 0) {
  13480 		skip = ParseResiduals(tls, dec, mb, token_br)
  13481 	} else {
  13482 		v2 = libc.Uint8FromInt32(0)
  13483 		(*VP8MB)(unsafe.Pointer(mb)).Fnz = v2
  13484 		(*VP8MB)(unsafe.Pointer(left)).Fnz = v2
  13485 		if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) {
  13486 			v2 = libc.Uint8FromInt32(0)
  13487 			(*VP8MB)(unsafe.Pointer(mb)).Fnz_dc = v2
  13488 			(*VP8MB)(unsafe.Pointer(left)).Fnz_dc = v2
  13489 		}
  13490 		(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y = uint32(0)
  13491 		(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv = uint32(0)
  13492 		(*VP8MBData)(unsafe.Pointer(block)).Fdither = uint8(0)
  13493 	}
  13494 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 { // store filter info
  13495 		finfo = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*4
  13496 		**(**VP8FInfo)(__ccgo_up(finfo)) = **(**VP8FInfo)(__ccgo_up(dec + 2924 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fsegment)*8 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4)*4))
  13497 		v4 = finfo + 2
  13498 		*(*uint8_t)(unsafe.Pointer(v4)) = uint8_t(int32(*(*uint8_t)(unsafe.Pointer(v4))) | libc.BoolInt32(!(skip != 0)))
  13499 	}
  13500 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(token_br)).Feof != 0))
  13501 }
  13502 
  13503 func VP8InitScanline(tls *libc.TLS, dec uintptr) {
  13504 	var left uintptr
  13505 	_ = left
  13506 	left = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13507 	(*VP8MB)(unsafe.Pointer(left)).Fnz = uint8(0)
  13508 	(*VP8MB)(unsafe.Pointer(left)).Fnz_dc = uint8(0)
  13509 	libc.X__builtin___memset_chk(tls, dec+2816, int32(B_DC_PRED), uint64(4), ^__predefined_size_t(0))
  13510 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = 0
  13511 }
  13512 
  13513 func ParseFrame(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  13514 	var token_br uintptr
  13515 	_ = token_br
  13516 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = 0
  13517 	for {
  13518 		if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y) {
  13519 			break
  13520 		}
  13521 		// Parse bitstream for this row.
  13522 		token_br = dec + 440 + uintptr(libc.Uint32FromInt32((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y)&(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)*48
  13523 		if !(VP8ParseIntraModeRow(tls, dec+16, dec) != 0) {
  13524 			return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+435)
  13525 		}
  13526 		for {
  13527 			if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
  13528 				break
  13529 			}
  13530 			if !(VP8DecodeMB(tls, dec, token_br) != 0) {
  13531 				return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+476)
  13532 			}
  13533 			goto _2
  13534 		_2:
  13535 			;
  13536 			(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x + 1
  13537 		}
  13538 		VP8InitScanline(tls, dec) // Prepare for next scanline
  13539 		// Reconstruct, filter and emit the row.
  13540 		if !(VP8ProcessRow(tls, dec, io) != 0) {
  13541 			return VP8SetError(tls, dec, int32(VP8_STATUS_USER_ABORT), __ccgo_ts+511)
  13542 		}
  13543 		goto _1
  13544 	_1:
  13545 		;
  13546 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y + 1
  13547 	}
  13548 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
  13549 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152) != 0) {
  13550 			return 0
  13551 		}
  13552 	}
  13553 	return int32(1)
  13554 }
  13555 
  13556 // C documentation
  13557 //
  13558 //	// Main entry point
  13559 func VP8Decode(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  13560 	var ok int32
  13561 	_ = ok
  13562 	ok = 0
  13563 	if dec == libc.UintptrFromInt32(0) {
  13564 		return 0
  13565 	}
  13566 	if io == libc.UintptrFromInt32(0) {
  13567 		return VP8SetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM), __ccgo_ts+527)
  13568 	}
  13569 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fready != 0) {
  13570 		if !(VP8GetHeaders(tls, dec, io) != 0) {
  13571 			return 0
  13572 		}
  13573 	}
  13574 	// Finish setting up the decoding parameter. Will call io->setup().
  13575 	ok = libc.BoolInt32(VP8EnterCritical(tls, dec, io) == int32(VP8_STATUS_OK))
  13576 	if ok != 0 { // good to go.
  13577 		// Will allocate memory and prepare everything.
  13578 		if ok != 0 {
  13579 			ok = VP8InitFrame(tls, dec, io)
  13580 		}
  13581 		// Main decoding loop
  13582 		if ok != 0 {
  13583 			ok = ParseFrame(tls, dec, io)
  13584 		}
  13585 		// Exit.
  13586 		ok = ok & VP8ExitCritical(tls, dec, io)
  13587 	}
  13588 	if !(ok != 0) {
  13589 		VP8Clear(tls, dec)
  13590 		return 0
  13591 	}
  13592 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  13593 	return ok
  13594 }
  13595 
  13596 func VP8Clear(tls *libc.TLS, dec uintptr) {
  13597 	if dec == libc.UintptrFromInt32(0) {
  13598 		return
  13599 	}
  13600 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FEnd})))(tls, dec+152)
  13601 	WebPDeallocateAlphaMemory(tls, dec)
  13602 	WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmem)
  13603 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmem = libc.UintptrFromInt32(0)
  13604 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = uint64(0)
  13605 	libc.X__builtin___memset_chk(tls, dec+16, 0, uint64(48), ^__predefined_size_t(0))
  13606 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  13607 }
  13608 
  13609 const APPROX_LOG_MAX = 4096
  13610 const APPROX_LOG_WITH_CORRECTION_MAX = 65536
  13611 const BITS_SPECIAL_MARKER = 256
  13612 const CODE_TO_PLANE_CODES = 120
  13613 const LOG_2_PRECISION_BITS = 23
  13614 const LOG_2_RECIPROCAL = 1.44269504088896338700465094007086
  13615 const LOG_2_RECIPROCAL_FIXED_DOUBLE = 12102203.161561485379934310913085937500
  13616 const LOG_LOOKUP_IDX_MAX = 256
  13617 const NUM_ARGB_CACHE_ROWS = 16
  13618 const NUM_CODE_LENGTH_CODES = 19
  13619 const PACKED_NON_LITERAL_CODE = 0
  13620 const PREFIX_LOOKUP_IDX_MAX = 512
  13621 const SYNC_EVERY_N_ROWS = 8
  13622 const VP8L_MAGIC_BYTE1 = 47
  13623 
  13624 var kHashMul8 = uint32(0x1e35a7bd)
  13625 
  13626 type VP8LPredictorFunc = uintptr
  13627 
  13628 type VP8LPredictorAddSubFunc = uintptr
  13629 
  13630 type VP8LProcessDecBlueAndRedFunc = uintptr
  13631 
  13632 type VP8LMultipliers = struct {
  13633 	Fgreen_to_red  uint8_t
  13634 	Fgreen_to_blue uint8_t
  13635 	Fred_to_blue   uint8_t
  13636 }
  13637 
  13638 type VP8LTransformColorInverseFunc = uintptr
  13639 
  13640 type VP8LConvertFunc = uintptr
  13641 
  13642 type VP8LMapARGBFunc = uintptr
  13643 
  13644 type VP8LMapAlphaFunc = uintptr
  13645 
  13646 type VP8LProcessEncBlueAndRedFunc = uintptr
  13647 
  13648 type VP8LTransformColorFunc = uintptr
  13649 
  13650 type VP8LCollectColorBlueTransformsFunc = uintptr
  13651 
  13652 type VP8LCollectColorRedTransformsFunc = uintptr
  13653 
  13654 type VP8LCostFunc = uintptr
  13655 
  13656 type VP8LCombinedShannonEntropyFunc = uintptr
  13657 
  13658 type VP8LShannonEntropyFunc = uintptr
  13659 
  13660 type VP8LStreaks = struct {
  13661 	Fcounts  [2]int32
  13662 	Fstreaks [2][2]int32
  13663 }
  13664 
  13665 type VP8LBitEntropy = struct {
  13666 	Fentropy      uint64_t
  13667 	Fsum          uint32_t
  13668 	Fnonzeros     int32
  13669 	Fmax_val      uint32_t
  13670 	Fnonzero_code uint32_t
  13671 }
  13672 
  13673 type VP8LGetCombinedEntropyUnrefinedFunc = uintptr
  13674 
  13675 type VP8LGetEntropyUnrefinedFunc = uintptr
  13676 
  13677 type VP8LAddVectorFunc = uintptr
  13678 
  13679 type VP8LAddVectorEqFunc = uintptr
  13680 
  13681 type VP8LVectorMismatchFunc = uintptr
  13682 
  13683 type VP8LBundleColorMapFunc = uintptr
  13684 
  13685 type VP8LFastLog2SlowFunc = uintptr
  13686 
  13687 type VP8LFastSLog2SlowFunc = uintptr
  13688 
  13689 type VP8LPrefixCode = struct {
  13690 	Fcode       int8_t
  13691 	Fextra_bits int8_t
  13692 }
  13693 
  13694 //------------------------------------------------------------------------------
  13695 // Transform-related functions used in both encoding and decoding.
  13696 
  13697 // Macros used to create a batch predictor that iteratively uses a
  13698 // one-pixel predictor.
  13699 
  13700 // The predictor is added to the output pixel (which
  13701 // is therefore considered as a residual) to get the final prediction.
  13702 
  13703 // Copyright 2010 Google Inc. All Rights Reserved.
  13704 //
  13705 // Use of this source code is governed by a BSD-style license
  13706 // that can be found in the COPYING file in the root of the source
  13707 // tree. An additional intellectual property rights grant can be found
  13708 // in the file PATENTS. All contributing project authors may
  13709 // be found in the AUTHORS file in the root of the source tree.
  13710 // -----------------------------------------------------------------------------
  13711 //
  13712 // Boolean decoder
  13713 //
  13714 // Author: Skal (pascal.massimino@gmail.com)
  13715 //         Vikas Arora (vikaas.arora@gmail.com)
  13716 
  13717 // Copyright 2012 Google Inc. All Rights Reserved.
  13718 //
  13719 // Use of this source code is governed by a BSD-style license
  13720 // that can be found in the COPYING file in the root of the source
  13721 // tree. An additional intellectual property rights grant can be found
  13722 // in the file PATENTS. All contributing project authors may
  13723 // be found in the AUTHORS file in the root of the source tree.
  13724 // -----------------------------------------------------------------------------
  13725 //
  13726 // Color Cache for WebP Lossless
  13727 //
  13728 // Authors: Jyrki Alakuijala (jyrki@google.com)
  13729 //          Urvang Joshi (urvang@google.com)
  13730 
  13731 // Copyright 2012 Google Inc. All Rights Reserved.
  13732 //
  13733 // Use of this source code is governed by a BSD-style license
  13734 // that can be found in the COPYING file in the root of the source
  13735 // tree. An additional intellectual property rights grant can be found
  13736 // in the file PATENTS. All contributing project authors may
  13737 // be found in the AUTHORS file in the root of the source tree.
  13738 // -----------------------------------------------------------------------------
  13739 //
  13740 // Utilities for building and looking up Huffman trees.
  13741 //
  13742 // Author: Urvang Joshi (urvang@google.com)
  13743 
  13744 // Copyright 2012 Google Inc. All Rights Reserved.
  13745 //
  13746 // Use of this source code is governed by a BSD-style license
  13747 // that can be found in the COPYING file in the root of the source
  13748 // tree. An additional intellectual property rights grant can be found
  13749 // in the file PATENTS. All contributing project authors may
  13750 // be found in the AUTHORS file in the root of the source tree.
  13751 // -----------------------------------------------------------------------------
  13752 //
  13753 // Rescaling functions
  13754 //
  13755 // Author: Skal (pascal.massimino@gmail.com)
  13756 
  13757 // Copyright 2012 Google Inc. All Rights Reserved.
  13758 //
  13759 // Use of this source code is governed by a BSD-style license
  13760 // that can be found in the COPYING file in the root of the source
  13761 // tree. An additional intellectual property rights grant can be found
  13762 // in the file PATENTS. All contributing project authors may
  13763 // be found in the AUTHORS file in the root of the source tree.
  13764 // -----------------------------------------------------------------------------
  13765 //
  13766 // Misc. common utility functions
  13767 //
  13768 // Authors: Skal (pascal.massimino@gmail.com)
  13769 //          Urvang (urvang@google.com)
  13770 
  13771 // Copyright 2010 Google Inc. All Rights Reserved.
  13772 //
  13773 // Use of this source code is governed by a BSD-style license
  13774 // that can be found in the COPYING file in the root of the source
  13775 // tree. An additional intellectual property rights grant can be found
  13776 // in the file PATENTS. All contributing project authors may
  13777 // be found in the AUTHORS file in the root of the source tree.
  13778 // -----------------------------------------------------------------------------
  13779 //
  13780 //  Main decoding functions for WebP images.
  13781 //
  13782 // Author: Skal (pascal.massimino@gmail.com)
  13783 
  13784 // Copyright 2012 Google Inc. All Rights Reserved.
  13785 //
  13786 // Use of this source code is governed by a BSD-style license
  13787 // that can be found in the COPYING file in the root of the source
  13788 // tree. An additional intellectual property rights grant can be found
  13789 // in the file PATENTS. All contributing project authors may
  13790 // be found in the AUTHORS file in the root of the source tree.
  13791 // -----------------------------------------------------------------------------
  13792 //
  13793 //  Internal header for constants related to WebP file format.
  13794 //
  13795 // Author: Urvang (urvang@google.com)
  13796 
  13797 // Copyright 2010 Google Inc. All Rights Reserved.
  13798 //
  13799 // Use of this source code is governed by a BSD-style license
  13800 // that can be found in the COPYING file in the root of the source
  13801 // tree. An additional intellectual property rights grant can be found
  13802 // in the file PATENTS. All contributing project authors may
  13803 // be found in the AUTHORS file in the root of the source tree.
  13804 // -----------------------------------------------------------------------------
  13805 //
  13806 //  Common types + memory wrappers
  13807 //
  13808 // Author: Skal (pascal.massimino@gmail.com)
  13809 
  13810 var kCodeLengthLiterals = int32(16)
  13811 var kCodeLengthRepeatCode = int32(16)
  13812 var kCodeLengthExtraBits = [3]uint8_t{
  13813 	0: uint8(2),
  13814 	1: uint8(3),
  13815 	2: uint8(7),
  13816 }
  13817 var kCodeLengthRepeatOffsets = [3]uint8_t{
  13818 	0: uint8(3),
  13819 	1: uint8(3),
  13820 	2: uint8(11),
  13821 }
  13822 
  13823 // C documentation
  13824 //
  13825 //	// -----------------------------------------------------------------------------
  13826 //	//  Five Huffman codes are used at each meta code:
  13827 //	//  1. green + length prefix codes + color cache codes,
  13828 //	//  2. alpha,
  13829 //	//  3. red,
  13830 //	//  4. blue, and,
  13831 //	//  5. distance prefix codes.
  13832 type HuffIndex = int32
  13833 
  13834 const GREEN = 0
  13835 const RED = 1
  13836 const BLUE = 2
  13837 const ALPHA = 3
  13838 const DIST = 4
  13839 
  13840 var kAlphabetSize = [5]uint16_t{
  13841 	0: libc.Uint16FromInt32(libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)),
  13842 	1: uint16(NUM_LITERAL_CODES),
  13843 	2: uint16(NUM_LITERAL_CODES),
  13844 	3: uint16(NUM_LITERAL_CODES),
  13845 	4: uint16(NUM_DISTANCE_CODES),
  13846 }
  13847 
  13848 var kLiteralMap = [5]uint8_t{
  13849 	1: uint8(1),
  13850 	2: uint8(1),
  13851 	3: uint8(1),
  13852 }
  13853 
  13854 var kCodeLengthCodeOrder = [19]uint8_t{
  13855 	0:  uint8(17),
  13856 	1:  uint8(18),
  13857 	3:  uint8(1),
  13858 	4:  uint8(2),
  13859 	5:  uint8(3),
  13860 	6:  uint8(4),
  13861 	7:  uint8(5),
  13862 	8:  uint8(16),
  13863 	9:  uint8(6),
  13864 	10: uint8(7),
  13865 	11: uint8(8),
  13866 	12: uint8(9),
  13867 	13: uint8(10),
  13868 	14: uint8(11),
  13869 	15: uint8(12),
  13870 	16: uint8(13),
  13871 	17: uint8(14),
  13872 	18: uint8(15),
  13873 }
  13874 
  13875 var kCodeToPlane = [120]uint8_t{
  13876 	0:   uint8(0x18),
  13877 	1:   uint8(0x07),
  13878 	2:   uint8(0x17),
  13879 	3:   uint8(0x19),
  13880 	4:   uint8(0x28),
  13881 	5:   uint8(0x06),
  13882 	6:   uint8(0x27),
  13883 	7:   uint8(0x29),
  13884 	8:   uint8(0x16),
  13885 	9:   uint8(0x1a),
  13886 	10:  uint8(0x26),
  13887 	11:  uint8(0x2a),
  13888 	12:  uint8(0x38),
  13889 	13:  uint8(0x05),
  13890 	14:  uint8(0x37),
  13891 	15:  uint8(0x39),
  13892 	16:  uint8(0x15),
  13893 	17:  uint8(0x1b),
  13894 	18:  uint8(0x36),
  13895 	19:  uint8(0x3a),
  13896 	20:  uint8(0x25),
  13897 	21:  uint8(0x2b),
  13898 	22:  uint8(0x48),
  13899 	23:  uint8(0x04),
  13900 	24:  uint8(0x47),
  13901 	25:  uint8(0x49),
  13902 	26:  uint8(0x14),
  13903 	27:  uint8(0x1c),
  13904 	28:  uint8(0x35),
  13905 	29:  uint8(0x3b),
  13906 	30:  uint8(0x46),
  13907 	31:  uint8(0x4a),
  13908 	32:  uint8(0x24),
  13909 	33:  uint8(0x2c),
  13910 	34:  uint8(0x58),
  13911 	35:  uint8(0x45),
  13912 	36:  uint8(0x4b),
  13913 	37:  uint8(0x34),
  13914 	38:  uint8(0x3c),
  13915 	39:  uint8(0x03),
  13916 	40:  uint8(0x57),
  13917 	41:  uint8(0x59),
  13918 	42:  uint8(0x13),
  13919 	43:  uint8(0x1d),
  13920 	44:  uint8(0x56),
  13921 	45:  uint8(0x5a),
  13922 	46:  uint8(0x23),
  13923 	47:  uint8(0x2d),
  13924 	48:  uint8(0x44),
  13925 	49:  uint8(0x4c),
  13926 	50:  uint8(0x55),
  13927 	51:  uint8(0x5b),
  13928 	52:  uint8(0x33),
  13929 	53:  uint8(0x3d),
  13930 	54:  uint8(0x68),
  13931 	55:  uint8(0x02),
  13932 	56:  uint8(0x67),
  13933 	57:  uint8(0x69),
  13934 	58:  uint8(0x12),
  13935 	59:  uint8(0x1e),
  13936 	60:  uint8(0x66),
  13937 	61:  uint8(0x6a),
  13938 	62:  uint8(0x22),
  13939 	63:  uint8(0x2e),
  13940 	64:  uint8(0x54),
  13941 	65:  uint8(0x5c),
  13942 	66:  uint8(0x43),
  13943 	67:  uint8(0x4d),
  13944 	68:  uint8(0x65),
  13945 	69:  uint8(0x6b),
  13946 	70:  uint8(0x32),
  13947 	71:  uint8(0x3e),
  13948 	72:  uint8(0x78),
  13949 	73:  uint8(0x01),
  13950 	74:  uint8(0x77),
  13951 	75:  uint8(0x79),
  13952 	76:  uint8(0x53),
  13953 	77:  uint8(0x5d),
  13954 	78:  uint8(0x11),
  13955 	79:  uint8(0x1f),
  13956 	80:  uint8(0x64),
  13957 	81:  uint8(0x6c),
  13958 	82:  uint8(0x42),
  13959 	83:  uint8(0x4e),
  13960 	84:  uint8(0x76),
  13961 	85:  uint8(0x7a),
  13962 	86:  uint8(0x21),
  13963 	87:  uint8(0x2f),
  13964 	88:  uint8(0x75),
  13965 	89:  uint8(0x7b),
  13966 	90:  uint8(0x31),
  13967 	91:  uint8(0x3f),
  13968 	92:  uint8(0x63),
  13969 	93:  uint8(0x6d),
  13970 	94:  uint8(0x52),
  13971 	95:  uint8(0x5e),
  13972 	97:  uint8(0x74),
  13973 	98:  uint8(0x7c),
  13974 	99:  uint8(0x41),
  13975 	100: uint8(0x4f),
  13976 	101: uint8(0x10),
  13977 	102: uint8(0x20),
  13978 	103: uint8(0x62),
  13979 	104: uint8(0x6e),
  13980 	105: uint8(0x30),
  13981 	106: uint8(0x73),
  13982 	107: uint8(0x7d),
  13983 	108: uint8(0x51),
  13984 	109: uint8(0x5f),
  13985 	110: uint8(0x40),
  13986 	111: uint8(0x72),
  13987 	112: uint8(0x7e),
  13988 	113: uint8(0x61),
  13989 	114: uint8(0x6f),
  13990 	115: uint8(0x50),
  13991 	116: uint8(0x71),
  13992 	117: uint8(0x7f),
  13993 	118: uint8(0x60),
  13994 	119: uint8(0x70),
  13995 }
  13996 
  13997 // C documentation
  13998 //
  13999 //	// Memory needed for lookup tables of one Huffman tree group. Red, blue, alpha
  14000 //	// and distance alphabets are constant (256 for red, blue and alpha, 40 for
  14001 //	// distance) and lookup table sizes for them in worst case are 630 and 410
  14002 //	// respectively. Size of green alphabet depends on color cache size and is equal
  14003 //	// to 256 (green component values) + 24 (length prefix values)
  14004 //	// + color_cache_size (between 0 and 2048).
  14005 //	// All values computed for 8-bit first level lookup with Mark Adler's tool:
  14006 //	// https://github.com/madler/zlib/blob/v1.2.5/examples/enough.c
  14007 var kTableSize = [12]uint16_t{
  14008 	0:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(654)),
  14009 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(656)),
  14010 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(658)),
  14011 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(662)),
  14012 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(670)),
  14013 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(686)),
  14014 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(718)),
  14015 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(782)),
  14016 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(912)),
  14017 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(1168)),
  14018 	10: libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(1680)),
  14019 	11: libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(2704)),
  14020 }
  14021 
  14022 func VP8LSetError(tls *libc.TLS, dec uintptr, error1 VP8StatusCode1) (r int32) {
  14023 	// The oldest error reported takes precedence over the new one.
  14024 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_OK) || (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_SUSPENDED) {
  14025 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = error1
  14026 	}
  14027 	return 0
  14028 }
  14029 
  14030 //------------------------------------------------------------------------------
  14031 
  14032 func VP8LCheckSignature(tls *libc.TLS, data uintptr, size size_t) (r int32) {
  14033 	return libc.BoolInt32(size >= uint64(VP8L_FRAME_HEADER_SIZE) && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) == int32(VP8L_MAGIC_BYTE1) && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 4)))>>int32(5) == 0) // version
  14034 }
  14035 
  14036 func ReadImageInfo(tls *libc.TLS, br uintptr, width uintptr, height uintptr, has_alpha uintptr) (r int32) {
  14037 	if VP8LReadBits(tls, br, int32(8)) != uint32(VP8L_MAGIC_BYTE1) {
  14038 		return 0
  14039 	}
  14040 	**(**int32)(__ccgo_up(width)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(VP8L_IMAGE_SIZE_BITS)) + uint32(1))
  14041 	**(**int32)(__ccgo_up(height)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(VP8L_IMAGE_SIZE_BITS)) + uint32(1))
  14042 	**(**int32)(__ccgo_up(has_alpha)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14043 	if VP8LReadBits(tls, br, int32(VP8L_VERSION_BITS)) != uint32(0) {
  14044 		return 0
  14045 	}
  14046 	return libc.BoolInt32(!((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  14047 }
  14048 
  14049 func VP8LGetInfo(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr, has_alpha uintptr) (r int32) {
  14050 	bp := tls.Alloc(64)
  14051 	defer tls.Free(64)
  14052 	var _ /* a at bp+8 */ int32
  14053 	var _ /* br at bp+16 */ VP8LBitReader
  14054 	var _ /* h at bp+4 */ int32
  14055 	var _ /* w at bp+0 */ int32
  14056 	if data == libc.UintptrFromInt32(0) || data_size < uint64(VP8L_FRAME_HEADER_SIZE) {
  14057 		return 0 // not enough data
  14058 	} else {
  14059 		if !(VP8LCheckSignature(tls, data, data_size) != 0) {
  14060 			return 0 // bad signature
  14061 		} else {
  14062 			VP8LInitBitReader(tls, bp+16, data, data_size)
  14063 			if !(ReadImageInfo(tls, bp+16, bp, bp+4, bp+8) != 0) {
  14064 				return 0
  14065 			}
  14066 			if width != libc.UintptrFromInt32(0) {
  14067 				**(**int32)(__ccgo_up(width)) = **(**int32)(__ccgo_up(bp))
  14068 			}
  14069 			if height != libc.UintptrFromInt32(0) {
  14070 				**(**int32)(__ccgo_up(height)) = **(**int32)(__ccgo_up(bp + 4))
  14071 			}
  14072 			if has_alpha != libc.UintptrFromInt32(0) {
  14073 				**(**int32)(__ccgo_up(has_alpha)) = **(**int32)(__ccgo_up(bp + 8))
  14074 			}
  14075 			return int32(1)
  14076 		}
  14077 	}
  14078 	return r
  14079 }
  14080 
  14081 //------------------------------------------------------------------------------
  14082 
  14083 func GetCopyDistance(tls *libc.TLS, distance_symbol int32, br uintptr) (r int32) {
  14084 	var extra_bits, offset int32
  14085 	_, _ = extra_bits, offset
  14086 	if distance_symbol < int32(4) {
  14087 		return distance_symbol + int32(1)
  14088 	}
  14089 	extra_bits = (distance_symbol - int32(2)) >> int32(1)
  14090 	offset = (int32(2) + distance_symbol&int32(1)) << extra_bits
  14091 	return libc.Int32FromUint32(libc.Uint32FromInt32(offset) + VP8LReadBits(tls, br, extra_bits) + uint32(1))
  14092 }
  14093 
  14094 func GetCopyLength(tls *libc.TLS, length_symbol int32, br uintptr) (r int32) {
  14095 	// Length and distance prefixes are encoded the same way.
  14096 	return GetCopyDistance(tls, length_symbol, br)
  14097 }
  14098 
  14099 func PlaneCodeToDistance(tls *libc.TLS, xsize int32, plane_code int32) (r int32) {
  14100 	var dist, dist_code, xoffset, yoffset, v1 int32
  14101 	_, _, _, _, _ = dist, dist_code, xoffset, yoffset, v1
  14102 	if plane_code > int32(CODE_TO_PLANE_CODES) {
  14103 		return plane_code - int32(CODE_TO_PLANE_CODES)
  14104 	} else {
  14105 		dist_code = libc.Int32FromUint8(kCodeToPlane[plane_code-int32(1)])
  14106 		yoffset = dist_code >> int32(4)
  14107 		xoffset = int32(8) - dist_code&int32(0xf)
  14108 		dist = yoffset*xsize + xoffset
  14109 		if dist >= int32(1) {
  14110 			v1 = dist
  14111 		} else {
  14112 			v1 = int32(1)
  14113 		}
  14114 		return v1 // dist<1 can happen if xsize is very small
  14115 	}
  14116 	return r
  14117 }
  14118 
  14119 // C documentation
  14120 //
  14121 //	//------------------------------------------------------------------------------
  14122 //	// Decodes the next Huffman code from bit-stream.
  14123 //	// VP8LFillBitWindow(br) needs to be called at minimum every second call
  14124 //	// to ReadSymbol, in order to pre-fetch enough bits.
  14125 func ReadSymbol(tls *libc.TLS, table uintptr, br2 uintptr) (r int32) {
  14126 	var nbits int32
  14127 	var val1, v2 uint32_t
  14128 	var v1 uintptr
  14129 	_, _, _, _ = nbits, val1, v1, v2
  14130 	v1 = br2
  14131 	v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14132 	goto _3
  14133 _3:
  14134 	val1 = v2
  14135 	table = table + uintptr(val1&libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(HUFFMAN_TABLE_BITS)-libc.Int32FromInt32(1)))*4
  14136 	nbits = libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(table)).Fbits) - int32(HUFFMAN_TABLE_BITS)
  14137 	if nbits > 0 {
  14138 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + int32(HUFFMAN_TABLE_BITS)
  14139 		v1 = br2
  14140 		v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14141 		goto _6
  14142 	_6:
  14143 		val1 = v2
  14144 		table = table + uintptr((*HuffmanCode)(unsafe.Pointer(table)).Fvalue)*4
  14145 		table = table + uintptr(val1&libc.Uint32FromInt32(libc.Int32FromInt32(1)<<nbits-libc.Int32FromInt32(1)))*4
  14146 	}
  14147 	(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(table)).Fbits)
  14148 	return libc.Int32FromUint16((*HuffmanCode)(unsafe.Pointer(table)).Fvalue)
  14149 }
  14150 
  14151 // C documentation
  14152 //
  14153 //	// Reads packed symbol depending on GREEN channel
  14154 func ReadPackedSymbols(tls *libc.TLS, group uintptr, br2 uintptr, dst uintptr) (r int32) {
  14155 	var code HuffmanCode32
  14156 	var val1, v2 uint32_t
  14157 	var v1 uintptr
  14158 	_, _, _, _ = code, val1, v1, v2
  14159 	v1 = br2
  14160 	v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14161 	goto _3
  14162 _3:
  14163 	val1 = v2 & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(HUFFMAN_PACKED_BITS) - libc.Uint32FromInt32(1))
  14164 	code = **(**HuffmanCode32)(__ccgo_up(group + 56 + uintptr(val1)*8))
  14165 	if code.Fbits < int32(BITS_SPECIAL_MARKER) {
  14166 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + code.Fbits
  14167 		**(**uint32_t)(__ccgo_up(dst)) = code.Fvalue
  14168 		return PACKED_NON_LITERAL_CODE
  14169 	} else {
  14170 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + code.Fbits - int32(BITS_SPECIAL_MARKER)
  14171 		return libc.Int32FromUint32(code.Fvalue)
  14172 	}
  14173 	return r
  14174 }
  14175 
  14176 func AccumulateHCode(tls *libc.TLS, hcode HuffmanCode, shift int32, huff uintptr) (r int32) {
  14177 	**(**int32)(__ccgo_up(huff)) += libc.Int32FromUint8(hcode.Fbits)
  14178 	**(**uint32_t)(__ccgo_up(huff + 4)) |= uint32(hcode.Fvalue) << shift
  14179 	return libc.Int32FromUint8(hcode.Fbits)
  14180 }
  14181 
  14182 func BuildPackedTable(tls *libc.TLS, htree_group uintptr) {
  14183 	var bits, code uint32_t
  14184 	var hcode HuffmanCode
  14185 	var huff uintptr
  14186 	_, _, _, _ = bits, code, hcode, huff
  14187 	code = uint32(0)
  14188 	for {
  14189 		if !(code < libc.Uint32FromUint32(1)<<libc.Int32FromInt32(HUFFMAN_PACKED_BITS)) {
  14190 			break
  14191 		}
  14192 		bits = code
  14193 		huff = htree_group + 56 + uintptr(bits)*8
  14194 		hcode = **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)) + uintptr(bits)*4))
  14195 		if libc.Int32FromUint16(hcode.Fvalue) >= int32(NUM_LITERAL_CODES) {
  14196 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fbits = libc.Int32FromUint8(hcode.Fbits) + int32(BITS_SPECIAL_MARKER)
  14197 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fvalue = uint32(hcode.Fvalue)
  14198 		} else {
  14199 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fbits = 0
  14200 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fvalue = uint32(0)
  14201 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, hcode, int32(8), huff))
  14202 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(RED)*8)) + uintptr(bits)*4)), int32(16), huff))
  14203 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(BLUE)*8)) + uintptr(bits)*4)), 0, huff))
  14204 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(ALPHA)*8)) + uintptr(bits)*4)), int32(24), huff))
  14205 			_ = bits
  14206 		}
  14207 		goto _1
  14208 	_1:
  14209 		;
  14210 		code = code + 1
  14211 	}
  14212 }
  14213 
  14214 func ReadHuffmanCodeLengths(tls *libc.TLS, dec uintptr, code_length_code_lengths uintptr, num_symbols int32, code_lengths uintptr) (r int32) {
  14215 	bp := tls.Alloc(48)
  14216 	defer tls.Free(48)
  14217 	var br3, p, v2 uintptr
  14218 	var code_len, extra_bits, length, length_nbits, max_symbol, ok, prev_code_len, repeat, repeat_offset, slot, symbol, use_prev, v1, v6, v7 int32
  14219 	var v4 uint32_t
  14220 	var _ /* tables at bp+0 */ HuffmanTables
  14221 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = br3, code_len, extra_bits, length, length_nbits, max_symbol, ok, p, prev_code_len, repeat, repeat_offset, slot, symbol, use_prev, v1, v2, v4, v6, v7
  14222 	ok = 0
  14223 	br3 = dec + 40
  14224 	prev_code_len = int32(DEFAULT_CODE_LENGTH)
  14225 	if !(VP8LHuffmanTablesAllocate(tls, libc.Int32FromInt32(1)<<libc.Int32FromInt32(LENGTHS_TABLE_BITS), bp) != 0) || !(VP8LBuildHuffmanTable(tls, bp, int32(LENGTHS_TABLE_BITS), code_length_code_lengths, int32(NUM_CODE_LENGTH_CODES)) != 0) {
  14226 		goto End
  14227 	}
  14228 	if VP8LReadBits(tls, br3, int32(1)) != 0 { // use length
  14229 		length_nbits = libc.Int32FromUint32(uint32(2) + uint32(2)*VP8LReadBits(tls, br3, int32(3)))
  14230 		max_symbol = libc.Int32FromUint32(uint32(2) + VP8LReadBits(tls, br3, length_nbits))
  14231 		if max_symbol > num_symbols {
  14232 			goto End
  14233 		}
  14234 	} else {
  14235 		max_symbol = num_symbols
  14236 	}
  14237 	symbol = 0
  14238 	for symbol < num_symbols {
  14239 		v1 = max_symbol
  14240 		max_symbol = max_symbol - 1
  14241 		if v1 == 0 {
  14242 			break
  14243 		}
  14244 		v2 = br3
  14245 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  14246 			VP8LDoFillBitWindow(tls, v2)
  14247 		}
  14248 		v2 = br3
  14249 		v4 = uint32((*VP8LBitReader)(unsafe.Pointer(v2)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14250 		goto _5
  14251 	_5:
  14252 		p = (*HuffmanTablesSegment)(unsafe.Pointer((**(**HuffmanTables)(__ccgo_up(bp))).Fcurr_segment)).Fstart + uintptr(v4&libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(LENGTHS_TABLE_BITS)-libc.Int32FromInt32(1)))*4
  14253 		(*VP8LBitReader)(unsafe.Pointer(br3)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br3)).Fbit_pos + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(p)).Fbits)
  14254 		code_len = libc.Int32FromUint16((*HuffmanCode)(unsafe.Pointer(p)).Fvalue)
  14255 		if code_len < kCodeLengthLiterals {
  14256 			v1 = symbol
  14257 			symbol = symbol + 1
  14258 			**(**int32)(__ccgo_up(code_lengths + uintptr(v1)*4)) = code_len
  14259 			if code_len != 0 {
  14260 				prev_code_len = code_len
  14261 			}
  14262 		} else {
  14263 			use_prev = libc.BoolInt32(code_len == kCodeLengthRepeatCode)
  14264 			slot = code_len - kCodeLengthLiterals
  14265 			extra_bits = libc.Int32FromUint8(kCodeLengthExtraBits[slot])
  14266 			repeat_offset = libc.Int32FromUint8(kCodeLengthRepeatOffsets[slot])
  14267 			repeat = libc.Int32FromUint32(VP8LReadBits(tls, br3, extra_bits) + libc.Uint32FromInt32(repeat_offset))
  14268 			if symbol+repeat > num_symbols {
  14269 				goto End
  14270 			} else {
  14271 				if use_prev != 0 {
  14272 					v1 = prev_code_len
  14273 				} else {
  14274 					v1 = 0
  14275 				}
  14276 				length = v1
  14277 				for {
  14278 					v6 = repeat
  14279 					repeat = repeat - 1
  14280 					if !(v6 > 0) {
  14281 						break
  14282 					}
  14283 					v7 = symbol
  14284 					symbol = symbol + 1
  14285 					**(**int32)(__ccgo_up(code_lengths + uintptr(v7)*4)) = length
  14286 				}
  14287 			}
  14288 		}
  14289 	}
  14290 	ok = int32(1)
  14291 	goto End
  14292 End:
  14293 	;
  14294 	VP8LHuffmanTablesDeallocate(tls, bp)
  14295 	if !(ok != 0) {
  14296 		return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  14297 	}
  14298 	return ok
  14299 }
  14300 
  14301 // C documentation
  14302 //
  14303 //	// 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman
  14304 //	// tree.
  14305 func ReadHuffmanCode(tls *libc.TLS, alphabet_size int32, dec uintptr, code_lengths uintptr, table uintptr) (r int32) {
  14306 	bp := tls.Alloc(80)
  14307 	defer tls.Free(80)
  14308 	var br uintptr
  14309 	var first_symbol_len_code, i, num_codes, num_symbols, ok, simple_code, size, symbol, v1 int32
  14310 	var _ /* code_length_code_lengths at bp+0 */ [19]int32
  14311 	_, _, _, _, _, _, _, _, _, _ = br, first_symbol_len_code, i, num_codes, num_symbols, ok, simple_code, size, symbol, v1
  14312 	ok = 0
  14313 	size = 0
  14314 	br = dec + 40
  14315 	simple_code = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14316 	libc.X__builtin___memset_chk(tls, code_lengths, 0, libc.Uint64FromInt32(alphabet_size)*uint64(4), ^__predefined_size_t(0))
  14317 	if simple_code != 0 { // Read symbols, codes & code lengths directly.
  14318 		num_symbols = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)) + uint32(1))
  14319 		first_symbol_len_code = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14320 		if first_symbol_len_code == 0 {
  14321 			v1 = int32(1)
  14322 		} else {
  14323 			v1 = int32(8)
  14324 		}
  14325 		// The first code is either 1 bit or 8 bit code.
  14326 		symbol = libc.Int32FromUint32(VP8LReadBits(tls, br, v1))
  14327 		**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) = int32(1)
  14328 		// The second code (if present), is always 8 bits long.
  14329 		if num_symbols == int32(2) {
  14330 			symbol = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(8)))
  14331 			**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) = int32(1)
  14332 		}
  14333 		ok = int32(1)
  14334 	} else {
  14335 		**(**[19]int32)(__ccgo_up(bp)) = [19]int32{}
  14336 		num_codes = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(4)) + uint32(4))
  14337 		i = 0
  14338 		for {
  14339 			if !(i < num_codes) {
  14340 				break
  14341 			}
  14342 			(**(**[19]int32)(__ccgo_up(bp)))[kCodeLengthCodeOrder[i]] = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(3)))
  14343 			goto _2
  14344 		_2:
  14345 			;
  14346 			i = i + 1
  14347 		}
  14348 		ok = ReadHuffmanCodeLengths(tls, dec, bp, alphabet_size, code_lengths)
  14349 	}
  14350 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  14351 	if ok != 0 {
  14352 		size = VP8LBuildHuffmanTable(tls, table, int32(HUFFMAN_TABLE_BITS), code_lengths, alphabet_size)
  14353 	}
  14354 	if !(ok != 0) || size == 0 {
  14355 		return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  14356 	}
  14357 	return size
  14358 }
  14359 
  14360 func ReadHuffmanCodes(tls *libc.TLS, dec uintptr, xsize int32, ysize int32, color_cache_bits int32, allow_recursion int32) (r int32) {
  14361 	bp := tls.Alloc(16)
  14362 	defer tls.Free(16)
  14363 	var br, hdr, huffman_tables, mapped_group, mapping uintptr
  14364 	var group, huffman_pixs, huffman_precision, huffman_xsize, huffman_ysize, i, num_htree_groups, num_htree_groups_max, ok, v9 int32
  14365 	var v1, v2, v4, v5 uint32_t
  14366 	var _ /* htree_groups at bp+8 */ uintptr
  14367 	var _ /* huffman_image at bp+0 */ uintptr
  14368 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = br, group, hdr, huffman_pixs, huffman_precision, huffman_tables, huffman_xsize, huffman_ysize, i, mapped_group, mapping, num_htree_groups, num_htree_groups_max, ok, v1, v2, v4, v5, v9
  14369 	br = dec + 40
  14370 	hdr = dec + 152
  14371 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  14372 	**(**uintptr)(__ccgo_up(bp + 8)) = libc.UintptrFromInt32(0)
  14373 	huffman_tables = hdr + 80
  14374 	num_htree_groups = int32(1)
  14375 	num_htree_groups_max = int32(1)
  14376 	mapping = libc.UintptrFromInt32(0)
  14377 	ok = 0
  14378 	// Check the table has been 0 initialized (through InitMetadata).
  14379 	if allow_recursion != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  14380 		// use meta Huffman codes.
  14381 		huffman_precision = libc.Int32FromUint32(uint32(MIN_HUFFMAN_BITS) + VP8LReadBits(tls, br, int32(NUM_HUFFMAN_BITS)))
  14382 		v1 = libc.Uint32FromInt32(huffman_precision)
  14383 		v2 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  14384 		goto _3
  14385 	_3:
  14386 		huffman_xsize = libc.Int32FromUint32(v2)
  14387 		v4 = libc.Uint32FromInt32(huffman_precision)
  14388 		v5 = (libc.Uint32FromInt32(ysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  14389 		goto _6
  14390 	_6:
  14391 		huffman_ysize = libc.Int32FromUint32(v5)
  14392 		huffman_pixs = huffman_xsize * huffman_ysize
  14393 		if !(DecodeImageStream(tls, huffman_xsize, huffman_ysize, 0, dec, bp) != 0) {
  14394 			goto Error
  14395 		}
  14396 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_subsample_bits = huffman_precision
  14397 		i = 0
  14398 		for {
  14399 			if !(i < huffman_pixs) {
  14400 				break
  14401 			}
  14402 			// The huffman data is stored in red and green bytes.
  14403 			group = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) >> libc.Int32FromInt32(8) & uint32(0xffff))
  14404 			**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) = libc.Uint32FromInt32(group)
  14405 			if group >= num_htree_groups_max {
  14406 				num_htree_groups_max = group + int32(1)
  14407 			}
  14408 			goto _7
  14409 		_7:
  14410 			;
  14411 			i = i + 1
  14412 		}
  14413 		// Check the validity of num_htree_groups_max. If it seems too big, use a
  14414 		// smaller value for later. This will prevent big memory allocations to end
  14415 		// up with a bad bitstream anyway.
  14416 		// The value of 1000 is totally arbitrary. We know that num_htree_groups_max
  14417 		// is smaller than (1 << 16) and should be smaller than the number of pixels
  14418 		// (though the format allows it to be bigger).
  14419 		if num_htree_groups_max > int32(1000) || num_htree_groups_max > xsize*ysize {
  14420 			// Create a mapping from the used indices to the minimal set of used
  14421 			// values [0, num_htree_groups)
  14422 			mapping = WebPSafeMalloc(tls, libc.Uint64FromInt32(num_htree_groups_max), uint64(4))
  14423 			if mapping == libc.UintptrFromInt32(0) {
  14424 				VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14425 				goto Error
  14426 			}
  14427 			// -1 means a value is unmapped, and therefore unused in the Huffman
  14428 			// image.
  14429 			libc.X__builtin___memset_chk(tls, mapping, int32(0xff), libc.Uint64FromInt32(num_htree_groups_max)*uint64(4), ^__predefined_size_t(0))
  14430 			num_htree_groups = 0
  14431 			i = libc.Int32FromInt32(0)
  14432 			for {
  14433 				if !(i < huffman_pixs) {
  14434 					break
  14435 				}
  14436 				// Get the current mapping for the group and remap the Huffman image.
  14437 				mapped_group = mapping + uintptr(**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)))*4
  14438 				if **(**int32)(__ccgo_up(mapped_group)) == -int32(1) {
  14439 					v9 = num_htree_groups
  14440 					num_htree_groups = num_htree_groups + 1
  14441 					**(**int32)(__ccgo_up(mapped_group)) = v9
  14442 				}
  14443 				**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) = libc.Uint32FromInt32(**(**int32)(__ccgo_up(mapped_group)))
  14444 				goto _8
  14445 			_8:
  14446 				;
  14447 				i = i + 1
  14448 			}
  14449 		} else {
  14450 			num_htree_groups = num_htree_groups_max
  14451 		}
  14452 	}
  14453 	if (*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0 {
  14454 		goto Error
  14455 	}
  14456 	if !(ReadHuffmanCodesHelper(tls, color_cache_bits, num_htree_groups, num_htree_groups_max, mapping, dec, huffman_tables, bp+8) != 0) {
  14457 		goto Error
  14458 	}
  14459 	ok = int32(1)
  14460 	// All OK. Finalize pointers.
  14461 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_image = **(**uintptr)(__ccgo_up(bp))
  14462 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fnum_htree_groups = num_htree_groups
  14463 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups = **(**uintptr)(__ccgo_up(bp + 8))
  14464 	goto Error
  14465 Error:
  14466 	;
  14467 	WebPSafeFree(tls, mapping)
  14468 	if !(ok != 0) {
  14469 		WebPSafeFree(tls, **(**uintptr)(__ccgo_up(bp)))
  14470 		VP8LHuffmanTablesDeallocate(tls, huffman_tables)
  14471 		VP8LHtreeGroupsFree(tls, **(**uintptr)(__ccgo_up(bp + 8)))
  14472 	}
  14473 	return ok
  14474 }
  14475 
  14476 func ReadHuffmanCodesHelper(tls *libc.TLS, color_cache_bits int32, num_htree_groups int32, num_htree_groups_max int32, mapping uintptr, dec uintptr, huffman_tables uintptr, htree_groups uintptr) (r int32) {
  14477 	var alpha, alphabet_size, alphabet_size1, blue, i, is_trivial_literal, j, k, local_max_bits, max_alphabet_size, max_bits, ok, red, size, table_size, total_size, v1 int32
  14478 	var code_lengths, htree_group, htrees uintptr
  14479 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha, alphabet_size, alphabet_size1, blue, code_lengths, htree_group, htrees, i, is_trivial_literal, j, k, local_max_bits, max_alphabet_size, max_bits, ok, red, size, table_size, total_size, v1
  14480 	ok = 0
  14481 	if color_cache_bits > 0 {
  14482 		v1 = int32(1) << color_cache_bits
  14483 	} else {
  14484 		v1 = 0
  14485 	}
  14486 	max_alphabet_size = libc.Int32FromUint16(kAlphabetSize[0]) + v1
  14487 	table_size = libc.Int32FromUint16(kTableSize[color_cache_bits])
  14488 	code_lengths = libc.UintptrFromInt32(0)
  14489 	if mapping == libc.UintptrFromInt32(0) && num_htree_groups != num_htree_groups_max || num_htree_groups > num_htree_groups_max {
  14490 		goto Error
  14491 	}
  14492 	code_lengths = WebPSafeCalloc(tls, libc.Uint64FromInt32(max_alphabet_size), uint64(4))
  14493 	**(**uintptr)(__ccgo_up(htree_groups)) = VP8LHtreeGroupsNew(tls, num_htree_groups)
  14494 	if **(**uintptr)(__ccgo_up(htree_groups)) == libc.UintptrFromInt32(0) || code_lengths == libc.UintptrFromInt32(0) || !(VP8LHuffmanTablesAllocate(tls, num_htree_groups*table_size, huffman_tables) != 0) {
  14495 		VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14496 		goto Error
  14497 	}
  14498 	i = 0
  14499 	for {
  14500 		if !(i < num_htree_groups_max) {
  14501 			break
  14502 		}
  14503 		// If the index "i" is unused in the Huffman image, just make sure the
  14504 		// coefficients are valid but do not store them.
  14505 		if mapping != libc.UintptrFromInt32(0) && **(**int32)(__ccgo_up(mapping + uintptr(i)*4)) == -int32(1) {
  14506 			j = 0
  14507 			for {
  14508 				if !(j < int32(HUFFMAN_CODES_PER_META_CODE)) {
  14509 					break
  14510 				}
  14511 				alphabet_size = libc.Int32FromUint16(kAlphabetSize[j])
  14512 				if j == 0 && color_cache_bits > 0 {
  14513 					alphabet_size = alphabet_size + int32(1)<<color_cache_bits
  14514 				}
  14515 				// Passing in NULL so that nothing gets filled.
  14516 				if !(ReadHuffmanCode(tls, alphabet_size, dec, code_lengths, libc.UintptrFromInt32(0)) != 0) {
  14517 					goto Error
  14518 				}
  14519 				goto _3
  14520 			_3:
  14521 				;
  14522 				j = j + 1
  14523 			}
  14524 		} else {
  14525 			if mapping == libc.UintptrFromInt32(0) {
  14526 				v1 = i
  14527 			} else {
  14528 				v1 = **(**int32)(__ccgo_up(mapping + uintptr(i)*4))
  14529 			}
  14530 			htree_group = **(**uintptr)(__ccgo_up(htree_groups)) + uintptr(v1)*568
  14531 			htrees = htree_group
  14532 			total_size = 0
  14533 			is_trivial_literal = int32(1)
  14534 			max_bits = 0
  14535 			j = 0
  14536 			for {
  14537 				if !(j < int32(HUFFMAN_CODES_PER_META_CODE)) {
  14538 					break
  14539 				}
  14540 				alphabet_size1 = libc.Int32FromUint16(kAlphabetSize[j])
  14541 				if j == 0 && color_cache_bits > 0 {
  14542 					alphabet_size1 = alphabet_size1 + int32(1)<<color_cache_bits
  14543 				}
  14544 				size = ReadHuffmanCode(tls, alphabet_size1, dec, code_lengths, huffman_tables)
  14545 				**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)) = (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment)).Fcurr_table
  14546 				if size == 0 {
  14547 					goto Error
  14548 				}
  14549 				if is_trivial_literal != 0 && libc.Int32FromUint8(kLiteralMap[j]) == int32(1) {
  14550 					is_trivial_literal = libc.BoolInt32(libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)))).Fbits) == 0)
  14551 				}
  14552 				total_size = total_size + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)))).Fbits)
  14553 				**(**uintptr)(__ccgo_up((*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment + 8)) += uintptr(size) * 4
  14554 				if j <= int32(ALPHA) {
  14555 					local_max_bits = **(**int32)(__ccgo_up(code_lengths))
  14556 					k = int32(1)
  14557 					for {
  14558 						if !(k < alphabet_size1) {
  14559 							break
  14560 						}
  14561 						if **(**int32)(__ccgo_up(code_lengths + uintptr(k)*4)) > local_max_bits {
  14562 							local_max_bits = **(**int32)(__ccgo_up(code_lengths + uintptr(k)*4))
  14563 						}
  14564 						goto _6
  14565 					_6:
  14566 						;
  14567 						k = k + 1
  14568 					}
  14569 					max_bits = max_bits + local_max_bits
  14570 				}
  14571 				goto _5
  14572 			_5:
  14573 				;
  14574 				j = j + 1
  14575 			}
  14576 			(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_literal = is_trivial_literal
  14577 			(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code = 0
  14578 			if is_trivial_literal != 0 {
  14579 				red = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(RED)*8))))).Fvalue)
  14580 				blue = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(BLUE)*8))))).Fvalue)
  14581 				alpha = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(ALPHA)*8))))).Fvalue)
  14582 				(*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb = libc.Uint32FromInt32(alpha)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(blue)
  14583 				if total_size == 0 && libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(GREEN)*8))))).Fvalue) < int32(NUM_LITERAL_CODES) {
  14584 					(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code = int32(1)
  14585 					**(**uint32_t)(__ccgo_up(htree_group + 44)) |= libc.Uint32FromInt32(libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(GREEN)*8))))).Fvalue) << int32(8))
  14586 				}
  14587 			}
  14588 			(*HTreeGroup)(unsafe.Pointer(htree_group)).Fuse_packed_table = libc.BoolInt32(!((*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code != 0) && max_bits < int32(HUFFMAN_PACKED_BITS))
  14589 			if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fuse_packed_table != 0 {
  14590 				BuildPackedTable(tls, htree_group)
  14591 			}
  14592 		}
  14593 		goto _2
  14594 	_2:
  14595 		;
  14596 		i = i + 1
  14597 	}
  14598 	ok = int32(1)
  14599 	goto Error
  14600 Error:
  14601 	;
  14602 	WebPSafeFree(tls, code_lengths)
  14603 	if !(ok != 0) {
  14604 		VP8LHuffmanTablesDeallocate(tls, huffman_tables)
  14605 		VP8LHtreeGroupsFree(tls, **(**uintptr)(__ccgo_up(htree_groups)))
  14606 		**(**uintptr)(__ccgo_up(htree_groups)) = libc.UintptrFromInt32(0)
  14607 	}
  14608 	return ok
  14609 }
  14610 
  14611 //------------------------------------------------------------------------------
  14612 // Scaling.
  14613 
  14614 func AllocateAndInitRescaler(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  14615 	var in_height, in_width, num_channels, out_height, out_width int32
  14616 	var memory, scaled_data, work uintptr
  14617 	var memory_size, scaled_data_size, work_size uint64_t
  14618 	_, _, _, _, _, _, _, _, _, _, _ = in_height, in_width, memory, memory_size, num_channels, out_height, out_width, scaled_data, scaled_data_size, work, work_size
  14619 	num_channels = int32(4)
  14620 	in_width = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
  14621 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
  14622 	in_height = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
  14623 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
  14624 	work_size = libc.Uint64FromInt32(int32(2)*num_channels) * libc.Uint64FromInt32(out_width) // Rescaler work area.
  14625 	scaled_data_size = libc.Uint64FromInt32(out_width)                                        // Temporary storage for scaled BGRA data.
  14626 	memory_size = uint64(104) + work_size*uint64(4) + scaled_data_size*uint64(4)
  14627 	memory = WebPSafeMalloc(tls, memory_size, uint64(1))
  14628 	if memory == libc.UintptrFromInt32(0) {
  14629 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14630 	}
  14631 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory = memory
  14632 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler = memory
  14633 	memory = memory + uintptr(104)
  14634 	work = memory
  14635 	memory = memory + uintptr(work_size*uint64(4))
  14636 	scaled_data = memory
  14637 	if !(WebPRescalerInit(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, in_width, in_height, scaled_data, out_width, out_height, 0, num_channels, work) != 0) {
  14638 		return 0
  14639 	}
  14640 	return int32(1)
  14641 }
  14642 
  14643 //------------------------------------------------------------------------------
  14644 // Export to ARGB
  14645 
  14646 // C documentation
  14647 //
  14648 //	// We have special "export" function since we need to convert from BGRA
  14649 func Export(tls *libc.TLS, rescaler2 uintptr, colorspace WEBP_CSP_MODE1, rgba_stride int32, rgba uintptr) (r int32) {
  14650 	var dst, src, v1, v4 uintptr
  14651 	var dst_width, num_lines_out, v2, v5 int32
  14652 	_, _, _, _, _, _, _, _ = dst, dst_width, num_lines_out, src, v1, v2, v4, v5
  14653 	src = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst
  14654 	dst = rgba
  14655 	dst_width = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width
  14656 	num_lines_out = 0
  14657 	for {
  14658 		v1 = rescaler2
  14659 		v4 = v1
  14660 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  14661 		goto _6
  14662 	_6:
  14663 		;
  14664 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  14665 		goto _3
  14666 	_3:
  14667 		if !(v2 != 0) {
  14668 			break
  14669 		}
  14670 		WebPRescalerExportRow(tls, rescaler2)
  14671 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, src, dst_width, int32(1))
  14672 		VP8LConvertFromBGRA(tls, src, dst_width, colorspace, dst)
  14673 		dst = dst + uintptr(rgba_stride)
  14674 		num_lines_out = num_lines_out + 1
  14675 	}
  14676 	return num_lines_out
  14677 }
  14678 
  14679 // C documentation
  14680 //
  14681 //	// Emit scaled rows.
  14682 func EmitRescaledRowsRGBA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_h int32, out uintptr, out_stride int32) (r int32) {
  14683 	var colorspace WEBP_CSP_MODE1
  14684 	var lines_imported, lines_left, needed_lines, num_lines_in, num_lines_out int32
  14685 	var row_in, row_out uintptr
  14686 	_, _, _, _, _, _, _, _ = colorspace, lines_imported, lines_left, needed_lines, num_lines_in, num_lines_out, row_in, row_out
  14687 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace
  14688 	num_lines_in = 0
  14689 	num_lines_out = 0
  14690 	for num_lines_in < mb_h {
  14691 		row_in = in + uintptr(int64(num_lines_in)*int64(in_stride))
  14692 		row_out = out + uintptr(int64(num_lines_out)*int64(out_stride))
  14693 		lines_left = mb_h - num_lines_in
  14694 		needed_lines = WebPRescaleNeededLines(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left)
  14695 		WebPMultARGBRows(tls, row_in, in_stride, (*WebPRescaler)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler)).Fsrc_width, needed_lines, 0)
  14696 		lines_imported = WebPRescalerImport(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left, row_in, in_stride)
  14697 		num_lines_in = num_lines_in + lines_imported
  14698 		num_lines_out = num_lines_out + Export(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, colorspace, out_stride, row_out)
  14699 	}
  14700 	return num_lines_out
  14701 }
  14702 
  14703 // C documentation
  14704 //
  14705 //	// Emit rows without any scaling.
  14706 func EmitRows(tls *libc.TLS, colorspace WEBP_CSP_MODE1, row_in uintptr, in_stride int32, mb_w int32, mb_h int32, out uintptr, out_stride int32) (r int32) {
  14707 	var lines, v1 int32
  14708 	var row_out uintptr
  14709 	_, _, _ = lines, row_out, v1
  14710 	lines = mb_h
  14711 	row_out = out
  14712 	for {
  14713 		v1 = lines
  14714 		lines = lines - 1
  14715 		if !(v1 > 0) {
  14716 			break
  14717 		}
  14718 		VP8LConvertFromBGRA(tls, row_in, mb_w, colorspace, row_out)
  14719 		row_in = row_in + uintptr(in_stride)
  14720 		row_out = row_out + uintptr(out_stride)
  14721 	}
  14722 	return mb_h // Num rows out == num rows in.
  14723 }
  14724 
  14725 //------------------------------------------------------------------------------
  14726 // Export to YUVA
  14727 
  14728 func ConvertToYUVA(tls *libc.TLS, src uintptr, width int32, y_pos int32, output uintptr) {
  14729 	var a, buf, u, v uintptr
  14730 	_, _, _, _ = a, buf, u, v
  14731 	buf = output + 16
  14732 	// first, the luma plane
  14733 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertARGBToY})))(tls, src, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy+uintptr(y_pos*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride), width)
  14734 	// then U/V planes
  14735 	u = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu + uintptr(y_pos>>int32(1)*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride)
  14736 	v = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv + uintptr(y_pos>>int32(1)*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride)
  14737 	// even lines: store values
  14738 	// odd lines: average with previous values
  14739 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertARGBToUV})))(tls, src, u, v, width, libc.BoolInt32(!(y_pos&libc.Int32FromInt32(1) != 0)))
  14740 	// Lastly, store alpha if needed.
  14741 	if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
  14742 		a = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(y_pos*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
  14743 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPExtractAlpha})))(tls, src+uintptr(3), 0, width, int32(1), a, 0)
  14744 	}
  14745 }
  14746 
  14747 func ExportYUVA(tls *libc.TLS, dec uintptr, y_pos int32) (r int32) {
  14748 	var dst_width, num_lines_out, v2, v5 int32
  14749 	var rescaler2, src, v1, v4 uintptr
  14750 	_, _, _, _, _, _, _, _ = dst_width, num_lines_out, rescaler2, src, v1, v2, v4, v5
  14751 	rescaler2 = (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler
  14752 	src = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst
  14753 	dst_width = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width
  14754 	num_lines_out = 0
  14755 	for {
  14756 		v1 = rescaler2
  14757 		v4 = v1
  14758 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  14759 		goto _6
  14760 	_6:
  14761 		;
  14762 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  14763 		goto _3
  14764 	_3:
  14765 		if !(v2 != 0) {
  14766 			break
  14767 		}
  14768 		WebPRescalerExportRow(tls, rescaler2)
  14769 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, src, dst_width, int32(1))
  14770 		ConvertToYUVA(tls, src, dst_width, y_pos, (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)
  14771 		y_pos = y_pos + 1
  14772 		num_lines_out = num_lines_out + 1
  14773 	}
  14774 	return num_lines_out
  14775 }
  14776 
  14777 func EmitRescaledRowsYUVA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_h int32) (r int32) {
  14778 	var lines_imported, lines_left, needed_lines, num_lines_in, y_pos int32
  14779 	_, _, _, _, _ = lines_imported, lines_left, needed_lines, num_lines_in, y_pos
  14780 	num_lines_in = 0
  14781 	y_pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  14782 	for num_lines_in < mb_h {
  14783 		lines_left = mb_h - num_lines_in
  14784 		needed_lines = WebPRescaleNeededLines(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left)
  14785 		WebPMultARGBRows(tls, in, in_stride, (*WebPRescaler)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler)).Fsrc_width, needed_lines, 0)
  14786 		lines_imported = WebPRescalerImport(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left, in, in_stride)
  14787 		num_lines_in = num_lines_in + lines_imported
  14788 		in = in + uintptr(needed_lines*in_stride)
  14789 		y_pos = y_pos + ExportYUVA(tls, dec, y_pos)
  14790 	}
  14791 	return y_pos
  14792 }
  14793 
  14794 func EmitRowsYUVA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_w int32, num_rows int32) (r int32) {
  14795 	var y_pos, v1 int32
  14796 	_, _ = y_pos, v1
  14797 	y_pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  14798 	for {
  14799 		v1 = num_rows
  14800 		num_rows = num_rows - 1
  14801 		if !(v1 > 0) {
  14802 			break
  14803 		}
  14804 		ConvertToYUVA(tls, in, mb_w, y_pos, (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)
  14805 		in = in + uintptr(in_stride)
  14806 		y_pos = y_pos + 1
  14807 	}
  14808 	return y_pos
  14809 }
  14810 
  14811 //------------------------------------------------------------------------------
  14812 // Cropping.
  14813 
  14814 // C documentation
  14815 //
  14816 //	// Sets io->mb_y, io->mb_h & io->mb_w according to start row, end row and
  14817 //	// crop options. Also updates the input data pointer, so that it points to the
  14818 //	// start of the cropped window. Note that pixels are in ARGB format even if
  14819 //	// 'in_data' is uint8_t*.
  14820 //	// Returns true if the crop window is not empty.
  14821 func SetCropWindow(tls *libc.TLS, io uintptr, y_start int32, y_end int32, in_data uintptr, pixel_stride int32) (r int32) {
  14822 	var delta int32
  14823 	_ = delta
  14824 	if y_end > (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
  14825 		y_end = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom // make sure we don't overflow on last row.
  14826 	}
  14827 	if y_start < (*VP8Io)(unsafe.Pointer(io)).Fcrop_top {
  14828 		delta = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - y_start
  14829 		y_start = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
  14830 		**(**uintptr)(__ccgo_up(in_data)) += uintptr(delta * pixel_stride)
  14831 	}
  14832 	if y_start >= y_end {
  14833 		return 0
  14834 	} // Crop window is empty.
  14835 	**(**uintptr)(__ccgo_up(in_data)) += uintptr(libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fcrop_left) * uint64(4))
  14836 	(*VP8Io)(unsafe.Pointer(io)).Fmb_y = y_start - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
  14837 	(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fcrop_right - (*VP8Io)(unsafe.Pointer(io)).Fcrop_left
  14838 	(*VP8Io)(unsafe.Pointer(io)).Fmb_h = y_end - y_start
  14839 	return int32(1) // Non-empty crop window.
  14840 }
  14841 
  14842 //------------------------------------------------------------------------------
  14843 
  14844 func GetMetaIndex(tls *libc.TLS, image uintptr, xsize int32, bits int32, x int32, y int32) (r int32) {
  14845 	if bits == 0 {
  14846 		return 0
  14847 	}
  14848 	return libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(image + uintptr(xsize*(y>>bits)+x>>bits)*4)))
  14849 }
  14850 
  14851 func GetHtreeGroupForPos(tls *libc.TLS, hdr uintptr, x int32, y int32) (r uintptr) {
  14852 	var meta_index int32
  14853 	_ = meta_index
  14854 	meta_index = GetMetaIndex(tls, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_image, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_xsize, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_subsample_bits, x, y)
  14855 	return (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups + uintptr(meta_index)*568
  14856 }
  14857 
  14858 //------------------------------------------------------------------------------
  14859 // Main loop, with custom row-processing function
  14860 
  14861 type ProcessRowsFunc = uintptr
  14862 
  14863 func ApplyInverseTransforms(tls *libc.TLS, dec uintptr, start_row int32, num_rows int32, rows uintptr) {
  14864 	var cache_pixs, end_row, n, v1 int32
  14865 	var rows_in, rows_out, transform uintptr
  14866 	_, _, _, _, _, _, _ = cache_pixs, end_row, n, rows_in, rows_out, transform, v1
  14867 	n = (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform
  14868 	cache_pixs = (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth * num_rows
  14869 	end_row = start_row + num_rows
  14870 	rows_in = rows
  14871 	rows_out = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  14872 	// Inverse transforms.
  14873 	for {
  14874 		v1 = n
  14875 		n = n - 1
  14876 		if !(v1 > 0) {
  14877 			break
  14878 		}
  14879 		transform = dec + 280 + uintptr(n)*24
  14880 		VP8LInverseTransform(tls, transform, start_row, end_row, rows_in, rows_out)
  14881 		rows_in = rows_out
  14882 	}
  14883 	if rows_in != rows_out {
  14884 		// No transform called, hence just copy.
  14885 		libc.X__builtin___memcpy_chk(tls, rows_out, rows_in, libc.Uint64FromInt32(cache_pixs)*uint64(4), ^__predefined_size_t(0))
  14886 	}
  14887 }
  14888 
  14889 // C documentation
  14890 //
  14891 //	// Processes (transforms, scales & color-converts) the rows decoded after the
  14892 //	// last call.
  14893 func ProcessRows(tls *libc.TLS, dec uintptr, row int32) {
  14894 	bp := tls.Alloc(16)
  14895 	defer tls.Free(16)
  14896 	var buf, io, output, rgba, rows uintptr
  14897 	var in_stride, num_rows, num_rows_out, v1, v3 int32
  14898 	var _ /* rows_data at bp+0 */ uintptr
  14899 	_, _, _, _, _, _, _, _, _, _ = buf, in_stride, io, num_rows, num_rows_out, output, rgba, rows, v1, v3
  14900 	rows = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row)*4
  14901 	num_rows = row - (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  14902 	// We can't process more than NUM_ARGB_CACHE_ROWS at a time (that's the size
  14903 	// of argb_cache), but we currently don't need more than that.
  14904 	if num_rows > 0 { // Emit output.
  14905 		io = (*VP8LDecoder)(unsafe.Pointer(dec)).Fio
  14906 		**(**uintptr)(__ccgo_up(bp)) = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  14907 		in_stride = libc.Int32FromUint64(libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fwidth) * uint64(4)) // in unit of RGBA
  14908 		ApplyInverseTransforms(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row, num_rows, rows)
  14909 		if !(SetCropWindow(tls, io, (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row, row, bp, in_stride) != 0) {
  14910 			// Nothing to output (this time).
  14911 		} else {
  14912 			output = (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput
  14913 			v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace < int32(MODE_YUV))
  14914 			goto _2
  14915 		_2:
  14916 			if v1 != 0 { // convert to RGBA
  14917 				buf = output + 16
  14918 				rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
  14919 				if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  14920 					v3 = EmitRescaledRowsRGBA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, rgba, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
  14921 				} else {
  14922 					v3 = EmitRows(tls, (*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, rgba, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
  14923 				}
  14924 				num_rows_out = v3
  14925 				// Update 'last_out_row'.
  14926 				**(**int32)(__ccgo_up(dec + 148)) += num_rows_out
  14927 			} else { // convert to YUVA
  14928 				if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  14929 					v1 = EmitRescaledRowsYUVA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_h)
  14930 				} else {
  14931 					v1 = EmitRowsYUVA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h)
  14932 				}
  14933 				(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  14934 			}
  14935 		}
  14936 	}
  14937 	// Update 'last_row'.
  14938 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = row
  14939 }
  14940 
  14941 // C documentation
  14942 //
  14943 //	// Row-processing for the special case when alpha data contains only one
  14944 //	// transform (color indexing), and trivial non-green literals.
  14945 func Is8bOptimizable(tls *libc.TLS, hdr uintptr) (r int32) {
  14946 	var htrees uintptr
  14947 	var i int32
  14948 	_, _ = htrees, i
  14949 	if (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size > 0 {
  14950 		return 0
  14951 	}
  14952 	// When the Huffman tree contains only one symbol, we can skip the
  14953 	// call to ReadSymbol() for red/blue/alpha channels.
  14954 	i = 0
  14955 	for {
  14956 		if !(i < (*VP8LMetadata)(unsafe.Pointer(hdr)).Fnum_htree_groups) {
  14957 			break
  14958 		}
  14959 		htrees = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups + uintptr(i)*568
  14960 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(RED)*8))))).Fbits) > 0 {
  14961 			return 0
  14962 		}
  14963 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(BLUE)*8))))).Fbits) > 0 {
  14964 			return 0
  14965 		}
  14966 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(ALPHA)*8))))).Fbits) > 0 {
  14967 			return 0
  14968 		}
  14969 		goto _1
  14970 	_1:
  14971 		;
  14972 		i = i + 1
  14973 	}
  14974 	return int32(1)
  14975 }
  14976 
  14977 func AlphaApplyFilter(tls *libc.TLS, alph_dec uintptr, first_row int32, last_row int32, out uintptr, stride int32) {
  14978 	var prev_line uintptr
  14979 	var y int32
  14980 	_, _ = prev_line, y
  14981 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter != int32(WEBP_FILTER_NONE) {
  14982 		prev_line = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fprev_line
  14983 		y = first_row
  14984 		for {
  14985 			if !(y < last_row) {
  14986 				break
  14987 			}
  14988 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPUnfilters[(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter]})))(tls, prev_line, out, out, stride)
  14989 			prev_line = out
  14990 			out = out + uintptr(stride)
  14991 			goto _1
  14992 		_1:
  14993 			;
  14994 			y = y + 1
  14995 		}
  14996 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fprev_line = prev_line
  14997 	}
  14998 }
  14999 
  15000 func ExtractPalettedAlphaRows(tls *libc.TLS, dec uintptr, last_row int32) {
  15001 	var alph_dec, in, out, transform uintptr
  15002 	var first_row, top_row, width, v1, v2 int32
  15003 	_, _, _, _, _, _, _, _, _ = alph_dec, first_row, in, out, top_row, transform, width, v1, v2
  15004 	// For vertical and gradient filtering, we need to decode the part above the
  15005 	// crop_top row, in order to have the correct spatial predictors.
  15006 	alph_dec = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque
  15007 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter == int32(WEBP_FILTER_NONE) || (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter == int32(WEBP_FILTER_HORIZONTAL) {
  15008 		v1 = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fcrop_top
  15009 	} else {
  15010 		v1 = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15011 	}
  15012 	top_row = v1
  15013 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row < top_row {
  15014 		v2 = top_row
  15015 	} else {
  15016 		v2 = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15017 	}
  15018 	first_row = v2
  15019 	if last_row > first_row {
  15020 		// Special method for paletted alpha data. We only process the cropped area.
  15021 		width = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth
  15022 		out = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Foutput + uintptr(width*first_row)
  15023 		in = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*first_row)
  15024 		transform = dec + 280
  15025 		VP8LColorIndexInverseTransformAlpha(tls, transform, first_row, last_row, in, out)
  15026 		AlphaApplyFilter(tls, alph_dec, first_row, last_row, out, width)
  15027 	}
  15028 	v1 = last_row
  15029 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  15030 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = v1
  15031 }
  15032 
  15033 //------------------------------------------------------------------------------
  15034 // Helper functions for fast pattern copy (8b and 32b)
  15035 
  15036 // C documentation
  15037 //
  15038 //	// cyclic rotation of pattern word
  15039 func Rotate8b(tls *libc.TLS, V uint32_t) (r uint32_t) {
  15040 	return V&uint32(0xff)<<int32(24) | V>>libc.Int32FromInt32(8)
  15041 }
  15042 
  15043 // C documentation
  15044 //
  15045 //	// copy 1, 2 or 4-bytes pattern
  15046 func CopySmallPattern8b(tls *libc.TLS, src uintptr, dst uintptr, length int32, pattern uint32_t) {
  15047 	var i int32
  15048 	var v1, v2 uintptr
  15049 	_, _, _ = i, v1, v2
  15050 	// align 'dst' to 4-bytes boundary. Adjust the pattern along the way.
  15051 	for uint64(dst)&uint64(3) != 0 {
  15052 		v1 = dst
  15053 		dst = dst + 1
  15054 		v2 = src
  15055 		src = src + 1
  15056 		**(**uint8_t)(__ccgo_up(v1)) = **(**uint8_t)(__ccgo_up(v2))
  15057 		pattern = Rotate8b(tls, pattern)
  15058 		length = length - 1
  15059 	}
  15060 	// Copy the pattern 4 bytes at a time.
  15061 	i = 0
  15062 	for {
  15063 		if !(i < length>>int32(2)) {
  15064 			break
  15065 		}
  15066 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = pattern
  15067 		goto _3
  15068 	_3:
  15069 		;
  15070 		i = i + 1
  15071 	}
  15072 	// Finish with left-overs. 'pattern' is still correctly positioned,
  15073 	// so no Rotate8b() call is needed.
  15074 	i = i << int32(2)
  15075 	for {
  15076 		if !(i < length) {
  15077 			break
  15078 		}
  15079 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src + uintptr(i)))
  15080 		goto _4
  15081 	_4:
  15082 		;
  15083 		i = i + 1
  15084 	}
  15085 }
  15086 
  15087 func CopyBlock8b(tls *libc.TLS, dst uintptr, dist int32, length int32) {
  15088 	bp := tls.Alloc(16)
  15089 	defer tls.Free(16)
  15090 	var i int32
  15091 	var src uintptr
  15092 	var _ /* pattern at bp+0 */ uint32_t
  15093 	_, _ = i, src
  15094 	src = dst - uintptr(dist)
  15095 	if length >= int32(8) {
  15096 		**(**uint32_t)(__ccgo_up(bp)) = uint32(0)
  15097 		switch dist {
  15098 		case int32(1):
  15099 			**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(src)))
  15100 			**(**uint32_t)(__ccgo_up(bp)) = uint32(0x01010101) * **(**uint32_t)(__ccgo_up(bp))
  15101 		case int32(2):
  15102 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(2), ^__predefined_size_t(0))
  15103 			**(**uint32_t)(__ccgo_up(bp)) = uint32(0x00010001) * **(**uint32_t)(__ccgo_up(bp))
  15104 		case int32(4):
  15105 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(4), ^__predefined_size_t(0))
  15106 		default:
  15107 			goto Copy
  15108 		}
  15109 		CopySmallPattern8b(tls, src, dst, length, **(**uint32_t)(__ccgo_up(bp)))
  15110 		return
  15111 	}
  15112 	goto Copy
  15113 Copy:
  15114 	;
  15115 	if dist >= length { // no overlap -> use memcpy()
  15116 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(length)*uint64(1), ^__predefined_size_t(0))
  15117 	} else {
  15118 		i = 0
  15119 		for {
  15120 			if !(i < length) {
  15121 				break
  15122 			}
  15123 			**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src + uintptr(i)))
  15124 			goto _1
  15125 		_1:
  15126 			;
  15127 			i = i + 1
  15128 		}
  15129 	}
  15130 }
  15131 
  15132 // C documentation
  15133 //
  15134 //	// copy pattern of 1 or 2 uint32_t's
  15135 func CopySmallPattern32b(tls *libc.TLS, src uintptr, dst uintptr, length int32, pattern uint64_t) {
  15136 	var i int32
  15137 	var v1, v2 uintptr
  15138 	_, _, _ = i, v1, v2
  15139 	if uint64(dst)&uint64(4) != 0 { // Align 'dst' to 8-bytes boundary.
  15140 		v1 = dst
  15141 		dst += 4
  15142 		v2 = src
  15143 		src += 4
  15144 		**(**uint32_t)(__ccgo_up(v1)) = **(**uint32_t)(__ccgo_up(v2))
  15145 		pattern = pattern>>libc.Int32FromInt32(32) | pattern<<libc.Int32FromInt32(32)
  15146 		length = length - 1
  15147 	}
  15148 	i = 0
  15149 	for {
  15150 		if !(i < length>>int32(1)) {
  15151 			break
  15152 		}
  15153 		**(**uint64_t)(__ccgo_up(dst + uintptr(i)*8)) = pattern // Copy the pattern 8 bytes at a time.
  15154 		goto _3
  15155 	_3:
  15156 		;
  15157 		i = i + 1
  15158 	}
  15159 	if length&int32(1) != 0 { // Finish with left-over.
  15160 		**(**uint32_t)(__ccgo_up(dst + uintptr(i<<int32(1))*4)) = **(**uint32_t)(__ccgo_up(src + uintptr(i<<int32(1))*4))
  15161 	}
  15162 }
  15163 
  15164 func CopyBlock32b(tls *libc.TLS, dst uintptr, dist int32, length int32) {
  15165 	bp := tls.Alloc(16)
  15166 	defer tls.Free(16)
  15167 	var i int32
  15168 	var src uintptr
  15169 	var _ /* pattern at bp+0 */ uint64_t
  15170 	_, _ = i, src
  15171 	src = dst - uintptr(dist)*4
  15172 	if dist <= int32(2) && length >= int32(4) && uint64(dst)&uint64(3) == uint64(0) {
  15173 		if dist == int32(1) {
  15174 			**(**uint64_t)(__ccgo_up(bp)) = uint64(**(**uint32_t)(__ccgo_up(src)))
  15175 			**(**uint64_t)(__ccgo_up(bp)) = **(**uint64_t)(__ccgo_up(bp)) | **(**uint64_t)(__ccgo_up(bp))<<int32(32)
  15176 		} else {
  15177 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(8), ^__predefined_size_t(0))
  15178 		}
  15179 		CopySmallPattern32b(tls, src, dst, length, **(**uint64_t)(__ccgo_up(bp)))
  15180 	} else {
  15181 		if dist >= length { // no overlap
  15182 			libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(length)*uint64(4), ^__predefined_size_t(0))
  15183 		} else {
  15184 			i = 0
  15185 			for {
  15186 				if !(i < length) {
  15187 					break
  15188 				}
  15189 				**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  15190 				goto _1
  15191 			_1:
  15192 				;
  15193 				i = i + 1
  15194 			}
  15195 		}
  15196 	}
  15197 }
  15198 
  15199 //------------------------------------------------------------------------------
  15200 
  15201 func DecodeAlphaData(tls *libc.TLS, dec uintptr, data uintptr, width int32, height int32, last_row int32) (r int32) {
  15202 	var br2, hdr, htree_group, v1 uintptr
  15203 	var code, col, dist, dist_code, dist_symbol, end, last, len_code_limit, length, length_sym, mask, ok, pos, row, v5 int32
  15204 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = br2, code, col, dist, dist_code, dist_symbol, end, hdr, htree_group, last, len_code_limit, length, length_sym, mask, ok, pos, row, v1, v5
  15205 	ok = int32(1)
  15206 	row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel / width
  15207 	col = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel % width
  15208 	br2 = dec + 40
  15209 	hdr = dec + 152
  15210 	pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel // current position
  15211 	end = width * height                                  // End of data
  15212 	last = width * last_row                               // Last pixel to decode
  15213 	len_code_limit = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)
  15214 	mask = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask
  15215 	if pos < last {
  15216 		v1 = GetHtreeGroupForPos(tls, hdr, col, row)
  15217 	} else {
  15218 		v1 = libc.UintptrFromInt32(0)
  15219 	}
  15220 	htree_group = v1
  15221 	for !((*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0) && pos < last {
  15222 		// Only update when changing tile.
  15223 		if col&mask == 0 {
  15224 			htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15225 		}
  15226 		v1 = br2
  15227 		if (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15228 			VP8LDoFillBitWindow(tls, v1)
  15229 		}
  15230 		code = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)), br2)
  15231 		if code < int32(NUM_LITERAL_CODES) { // Literal
  15232 			**(**uint8_t)(__ccgo_up(data + uintptr(pos))) = libc.Uint8FromInt32(code)
  15233 			pos = pos + 1
  15234 			col = col + 1
  15235 			if col >= width {
  15236 				col = 0
  15237 				row = row + 1
  15238 				if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15239 					ExtractPalettedAlphaRows(tls, dec, row)
  15240 				}
  15241 			}
  15242 		} else {
  15243 			if code < len_code_limit {
  15244 				length_sym = code - int32(NUM_LITERAL_CODES)
  15245 				length = GetCopyLength(tls, length_sym, br2)
  15246 				dist_symbol = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(DIST)*8)), br2)
  15247 				v1 = br2
  15248 				if (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15249 					VP8LDoFillBitWindow(tls, v1)
  15250 				}
  15251 				dist_code = GetCopyDistance(tls, dist_symbol, br2)
  15252 				dist = PlaneCodeToDistance(tls, width, dist_code)
  15253 				if pos >= dist && end-pos >= length {
  15254 					CopyBlock8b(tls, data+uintptr(pos), dist, length)
  15255 				} else {
  15256 					ok = 0
  15257 					goto End
  15258 				}
  15259 				pos = pos + length
  15260 				col = col + length
  15261 				for col >= width {
  15262 					col = col - width
  15263 					row = row + 1
  15264 					if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15265 						ExtractPalettedAlphaRows(tls, dec, row)
  15266 					}
  15267 				}
  15268 				if pos < last && col&mask != 0 {
  15269 					htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15270 				}
  15271 			} else { // Not reached
  15272 				ok = 0
  15273 				goto End
  15274 			}
  15275 		}
  15276 		v1 = br2
  15277 		v5 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v1)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v1)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v1)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos > int32(VP8L_LBITS))
  15278 		goto _6
  15279 	_6:
  15280 		(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v5
  15281 	}
  15282 	// Process the remaining rows corresponding to last row-block.
  15283 	if row > last_row {
  15284 		v5 = last_row
  15285 	} else {
  15286 		v5 = row
  15287 	}
  15288 	ExtractPalettedAlphaRows(tls, dec, v5)
  15289 	goto End
  15290 End:
  15291 	;
  15292 	v1 = br2
  15293 	v5 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v1)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v1)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v1)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos > int32(VP8L_LBITS))
  15294 	goto _10
  15295 _10:
  15296 	(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v5
  15297 	if !(ok != 0) || (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 && pos < end {
  15298 		if (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 {
  15299 			v5 = int32(VP8_STATUS_SUSPENDED)
  15300 		} else {
  15301 			v5 = int32(VP8_STATUS_BITSTREAM_ERROR)
  15302 		}
  15303 		return VP8LSetError(tls, dec, v5)
  15304 	}
  15305 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = pos
  15306 	return ok
  15307 }
  15308 
  15309 func SaveState(tls *libc.TLS, dec uintptr, last_pixel int32) {
  15310 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_br = (*VP8LDecoder)(unsafe.Pointer(dec)).Fbr
  15311 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_last_pixel = last_pixel
  15312 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 {
  15313 		VP8LColorCacheCopy(tls, dec+152+8, dec+152+24)
  15314 	}
  15315 }
  15316 
  15317 func RestoreState(tls *libc.TLS, dec uintptr) {
  15318 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
  15319 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fbr = (*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_br
  15320 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = (*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_last_pixel
  15321 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 {
  15322 		VP8LColorCacheCopy(tls, dec+152+24, dec+152+8)
  15323 	}
  15324 }
  15325 
  15326 func DecodeImageData(tls *libc.TLS, dec uintptr, data uintptr, width int32, height int32, last_row int32, __ccgo_fp_process_func ProcessRowsFunc) (r int32) {
  15327 	var alpha, blue, code, col, color_cache_limit, dist, dist_code, dist_symbol, key1, key2, len_code_limit, length, length_sym, mask, next_sync_row, red, row, v1 int32
  15328 	var br2, color_cache, hdr, htree_group, last_cached, src, src_end, src_last, v2, v3 uintptr
  15329 	var v21 uint32_t
  15330 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha, blue, br2, code, col, color_cache, color_cache_limit, dist, dist_code, dist_symbol, hdr, htree_group, key1, key2, last_cached, len_code_limit, length, length_sym, mask, next_sync_row, red, row, src, src_end, src_last, v1, v2, v21, v3
  15331 	row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel / width
  15332 	col = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel % width
  15333 	br2 = dec + 40
  15334 	hdr = dec + 152
  15335 	src = data + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel)*4
  15336 	last_cached = src
  15337 	src_end = data + uintptr(width*height)*4    // End of data
  15338 	src_last = data + uintptr(width*last_row)*4 // Last pixel to decode
  15339 	len_code_limit = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)
  15340 	color_cache_limit = len_code_limit + (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size
  15341 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  15342 		v1 = row
  15343 	} else {
  15344 		v1 = libc.Int32FromInt32(1) << libc.Int32FromInt32(24)
  15345 	}
  15346 	next_sync_row = v1
  15347 	if (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size > 0 {
  15348 		v2 = hdr + 8
  15349 	} else {
  15350 		v2 = libc.UintptrFromInt32(0)
  15351 	}
  15352 	color_cache = v2
  15353 	mask = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask
  15354 	if src < src_last {
  15355 		v3 = GetHtreeGroupForPos(tls, hdr, col, row)
  15356 	} else {
  15357 		v3 = libc.UintptrFromInt32(0)
  15358 	}
  15359 	htree_group = v3
  15360 _5:
  15361 	;
  15362 	if !(src < src_last) {
  15363 		goto _4
  15364 	}
  15365 	if row >= next_sync_row {
  15366 		SaveState(tls, dec, int32((int64(src)-int64(data))/4))
  15367 		next_sync_row = row + int32(SYNC_EVERY_N_ROWS)
  15368 	}
  15369 	// Only update when changing tile. Note we could use this test:
  15370 	// if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed
  15371 	// but that's actually slower and needs storing the previous col/row.
  15372 	if col&mask == 0 {
  15373 		htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15374 	}
  15375 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code != 0 {
  15376 		**(**uint32_t)(__ccgo_up(src)) = (*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb
  15377 		goto AdvanceByOne
  15378 	}
  15379 	v2 = br2
  15380 	if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15381 		VP8LDoFillBitWindow(tls, v2)
  15382 	}
  15383 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fuse_packed_table != 0 {
  15384 		code = ReadPackedSymbols(tls, htree_group, br2, src)
  15385 		v2 = br2
  15386 		v1 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v2)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v2)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v2)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos > int32(VP8L_LBITS))
  15387 		goto _9
  15388 	_9:
  15389 		if v1 != 0 {
  15390 			goto _4
  15391 		}
  15392 		if code == PACKED_NON_LITERAL_CODE {
  15393 			goto AdvanceByOne
  15394 		}
  15395 	} else {
  15396 		code = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)), br2)
  15397 	}
  15398 	v2 = br2
  15399 	v1 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v2)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v2)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v2)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos > int32(VP8L_LBITS))
  15400 	goto _12
  15401 _12:
  15402 	if v1 != 0 {
  15403 		goto _4
  15404 	}
  15405 	if !(code < int32(NUM_LITERAL_CODES)) {
  15406 		goto _13
  15407 	} // Literal
  15408 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_literal != 0 {
  15409 		**(**uint32_t)(__ccgo_up(src)) = (*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb | libc.Uint32FromInt32(code<<libc.Int32FromInt32(8))
  15410 	} else {
  15411 		red = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(RED)*8)), br2)
  15412 		v2 = br2
  15413 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15414 			VP8LDoFillBitWindow(tls, v2)
  15415 		}
  15416 		blue = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(BLUE)*8)), br2)
  15417 		alpha = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(ALPHA)*8)), br2)
  15418 		v2 = br2
  15419 		v1 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v2)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v2)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v2)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos > int32(VP8L_LBITS))
  15420 		goto _18
  15421 	_18:
  15422 		if v1 != 0 {
  15423 			goto _4
  15424 		}
  15425 		**(**uint32_t)(__ccgo_up(src)) = libc.Uint32FromInt32(alpha)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(code<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(blue)
  15426 	}
  15427 	goto AdvanceByOne
  15428 AdvanceByOne:
  15429 	;
  15430 	src += 4
  15431 	col = col + 1
  15432 	if col >= width {
  15433 		col = 0
  15434 		row = row + 1
  15435 		if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15436 			if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15437 				(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, row)
  15438 			}
  15439 		}
  15440 		if color_cache != libc.UintptrFromInt32(0) {
  15441 			for last_cached < src {
  15442 				v2 = last_cached
  15443 				last_cached += 4
  15444 				v3 = color_cache
  15445 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15446 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15447 				goto _23
  15448 			_23:
  15449 				key1 = v1
  15450 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15451 			}
  15452 		}
  15453 	}
  15454 	goto _14
  15455 _13:
  15456 	;
  15457 	if code < len_code_limit {
  15458 		length_sym = code - int32(NUM_LITERAL_CODES)
  15459 		length = GetCopyLength(tls, length_sym, br2)
  15460 		dist_symbol = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(DIST)*8)), br2)
  15461 		v2 = br2
  15462 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15463 			VP8LDoFillBitWindow(tls, v2)
  15464 		}
  15465 		dist_code = GetCopyDistance(tls, dist_symbol, br2)
  15466 		dist = PlaneCodeToDistance(tls, width, dist_code)
  15467 		v2 = br2
  15468 		v1 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v2)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v2)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v2)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos > int32(VP8L_LBITS))
  15469 		goto _27
  15470 	_27:
  15471 		if v1 != 0 {
  15472 			goto _4
  15473 		}
  15474 		if (int64(src)-int64(data))/4 < int64(dist) || (int64(src_end)-int64(src))/4 < int64(length) {
  15475 			goto Error
  15476 		} else {
  15477 			CopyBlock32b(tls, src, dist, length)
  15478 		}
  15479 		src = src + uintptr(length)*4
  15480 		col = col + length
  15481 		for col >= width {
  15482 			col = col - width
  15483 			row = row + 1
  15484 			if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15485 				if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15486 					(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, row)
  15487 				}
  15488 			}
  15489 		}
  15490 		// Because of the check done above (before 'src' was incremented by
  15491 		// 'length'), the following holds true.
  15492 		if col&mask != 0 {
  15493 			htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15494 		}
  15495 		if color_cache != libc.UintptrFromInt32(0) {
  15496 			for last_cached < src {
  15497 				v2 = last_cached
  15498 				last_cached += 4
  15499 				v3 = color_cache
  15500 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15501 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15502 				goto _32
  15503 			_32:
  15504 				key1 = v1
  15505 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15506 			}
  15507 		}
  15508 	} else {
  15509 		if code < color_cache_limit { // Color cache
  15510 			key2 = code - len_code_limit
  15511 			for last_cached < src {
  15512 				v2 = last_cached
  15513 				last_cached += 4
  15514 				v3 = color_cache
  15515 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15516 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15517 				goto _37
  15518 			_37:
  15519 				key1 = v1
  15520 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15521 			}
  15522 			v21 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4))
  15523 			goto _39
  15524 		_39:
  15525 			**(**uint32_t)(__ccgo_up(src)) = v21
  15526 			goto AdvanceByOne
  15527 		} else { // Not reached
  15528 			goto Error
  15529 		}
  15530 	}
  15531 _14:
  15532 	;
  15533 	goto _5
  15534 _4:
  15535 	;
  15536 	v2 = br2
  15537 	v1 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v2)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v2)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v2)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos > int32(VP8L_LBITS))
  15538 	goto _42
  15539 _42:
  15540 	(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v1
  15541 	// In incremental decoding:
  15542 	// br->eos && src < src_last: if 'br' reached the end of the buffer and
  15543 	// 'src_last' has not been reached yet, there is not enough data. 'dec' has to
  15544 	// be reset until there is more data.
  15545 	// !br->eos && src < src_last: this cannot happen as either the buffer is
  15546 	// fully read, either enough has been read to reach 'src_last'.
  15547 	// src >= src_last: 'src_last' is reached, all is fine. 'src' can actually go
  15548 	// beyond 'src_last' in case the image is cropped and an LZ77 goes further.
  15549 	// The buffer might have been enough or there is some left. 'br->eos' does
  15550 	// not matter.
  15551 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 && (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 && src < src_last {
  15552 		RestoreState(tls, dec)
  15553 	} else {
  15554 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 && src >= src_last || !((*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0) {
  15555 			// Process the remaining rows corresponding to last row-block.
  15556 			if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15557 				if row > last_row {
  15558 					v1 = last_row
  15559 				} else {
  15560 					v1 = row
  15561 				}
  15562 				(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, v1)
  15563 			}
  15564 			(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15565 			(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = int32((int64(src) - int64(data)) / 4) // end-of-scan marker
  15566 		} else {
  15567 			// if not incremental, and we are past the end of buffer (eos=1), then this
  15568 			// is a real bitstream error.
  15569 			goto Error
  15570 		}
  15571 	}
  15572 	return int32(1)
  15573 	goto Error
  15574 Error:
  15575 	;
  15576 	return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15577 	return r
  15578 }
  15579 
  15580 // -----------------------------------------------------------------------------
  15581 // VP8LTransform
  15582 
  15583 func ClearTransform(tls *libc.TLS, transform uintptr) {
  15584 	WebPSafeFree(tls, (*VP8LTransform)(unsafe.Pointer(transform)).Fdata)
  15585 	(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = libc.UintptrFromInt32(0)
  15586 }
  15587 
  15588 // C documentation
  15589 //
  15590 //	// For security reason, we need to remap the color map to span
  15591 //	// the total possible bundled values, and not just the num_colors.
  15592 func ExpandColorMap(tls *libc.TLS, num_colors int32, transform uintptr) (r int32) {
  15593 	var data, new_color_map, new_data uintptr
  15594 	var final_num_colors, i int32
  15595 	_, _, _, _, _ = data, final_num_colors, i, new_color_map, new_data
  15596 	final_num_colors = int32(1) << (int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15597 	new_color_map = WebPSafeMalloc(tls, libc.Uint64FromInt32(final_num_colors), uint64(4))
  15598 	if new_color_map == libc.UintptrFromInt32(0) {
  15599 		return 0
  15600 	} else {
  15601 		data = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  15602 		new_data = new_color_map
  15603 		**(**uint32_t)(__ccgo_up(new_color_map)) = **(**uint32_t)(__ccgo_up((*VP8LTransform)(unsafe.Pointer(transform)).Fdata))
  15604 		i = int32(4)
  15605 		for {
  15606 			if !(i < int32(4)*num_colors) {
  15607 				break
  15608 			}
  15609 			// Equivalent to VP8LAddPixels(), on a byte-basis.
  15610 			**(**uint8_t)(__ccgo_up(new_data + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(i)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(new_data + uintptr(i-int32(4)))))) & int32(0xff))
  15611 			goto _1
  15612 		_1:
  15613 			;
  15614 			i = i + 1
  15615 		}
  15616 		for {
  15617 			if !(i < int32(4)*final_num_colors) {
  15618 				break
  15619 			}
  15620 			**(**uint8_t)(__ccgo_up(new_data + uintptr(i))) = uint8(0) // black tail.
  15621 			goto _2
  15622 		_2:
  15623 			;
  15624 			i = i + 1
  15625 		}
  15626 		WebPSafeFree(tls, (*VP8LTransform)(unsafe.Pointer(transform)).Fdata)
  15627 		(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = new_color_map
  15628 	}
  15629 	return int32(1)
  15630 }
  15631 
  15632 func ReadTransform(tls *libc.TLS, xsize uintptr, ysize uintptr, dec uintptr) (r int32) {
  15633 	var bits, num_colors, ok, v7, v8, v9 int32
  15634 	var br, transform uintptr
  15635 	var type1 VP8LImageTransformType
  15636 	var v1, v2, v4, v5 uint32_t
  15637 	_, _, _, _, _, _, _, _, _, _, _, _, _ = bits, br, num_colors, ok, transform, type1, v1, v2, v4, v5, v7, v8, v9
  15638 	ok = int32(1)
  15639 	br = dec + 40
  15640 	transform = dec + 280 + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform)*24
  15641 	type1 = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(2)))
  15642 	// Each transform type can only be present once in the stream.
  15643 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Ftransforms_seen&(uint32(1)<<type1) != 0 {
  15644 		return 0 // Already there, let's not accept the second same transform.
  15645 	}
  15646 	**(**uint32_t)(__ccgo_up(dec + 376)) |= uint32(1) << type1
  15647 	(*VP8LTransform)(unsafe.Pointer(transform)).Ftype1 = type1
  15648 	(*VP8LTransform)(unsafe.Pointer(transform)).Fxsize = **(**int32)(__ccgo_up(xsize))
  15649 	(*VP8LTransform)(unsafe.Pointer(transform)).Fysize = **(**int32)(__ccgo_up(ysize))
  15650 	(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = libc.UintptrFromInt32(0)
  15651 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform = (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform + 1
  15652 	switch type1 {
  15653 	case int32(PREDICTOR_TRANSFORM):
  15654 		fallthrough
  15655 	case int32(CROSS_COLOR_TRANSFORM):
  15656 		(*VP8LTransform)(unsafe.Pointer(transform)).Fbits = libc.Int32FromUint32(uint32(MIN_TRANSFORM_BITS) + VP8LReadBits(tls, br, int32(NUM_TRANSFORM_BITS)))
  15657 		v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15658 		v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15659 		goto _3
  15660 	_3:
  15661 		v4 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15662 		v5 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  15663 		goto _6
  15664 	_6:
  15665 		ok = DecodeImageStream(tls, libc.Int32FromUint32(v2), libc.Int32FromUint32(v5), 0, dec, transform+16)
  15666 	case int32(COLOR_INDEXING_TRANSFORM):
  15667 		num_colors = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(8)) + uint32(1))
  15668 		if num_colors > int32(16) {
  15669 			v7 = 0
  15670 		} else {
  15671 			if num_colors > int32(4) {
  15672 				v8 = int32(1)
  15673 			} else {
  15674 				if num_colors > int32(2) {
  15675 					v9 = int32(2)
  15676 				} else {
  15677 					v9 = int32(3)
  15678 				}
  15679 				v8 = v9
  15680 			}
  15681 			v7 = v8
  15682 		}
  15683 		bits = v7
  15684 		v1 = libc.Uint32FromInt32(bits)
  15685 		v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15686 		goto _12
  15687 	_12:
  15688 		**(**int32)(__ccgo_up(xsize)) = libc.Int32FromUint32(v2)
  15689 		(*VP8LTransform)(unsafe.Pointer(transform)).Fbits = bits
  15690 		ok = DecodeImageStream(tls, num_colors, int32(1), 0, dec, transform+16)
  15691 		if ok != 0 && !(ExpandColorMap(tls, num_colors, transform) != 0) {
  15692 			return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15693 		}
  15694 	case int32(SUBTRACT_GREEN_TRANSFORM):
  15695 	default:
  15696 		// can't happen
  15697 		break
  15698 	}
  15699 	return ok
  15700 }
  15701 
  15702 // -----------------------------------------------------------------------------
  15703 // VP8LMetadata
  15704 
  15705 func InitMetadata(tls *libc.TLS, hdr uintptr) {
  15706 	libc.X__builtin___memset_chk(tls, hdr, 0, uint64(120), ^__predefined_size_t(0))
  15707 }
  15708 
  15709 func ClearMetadata(tls *libc.TLS, hdr uintptr) {
  15710 	WebPSafeFree(tls, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_image)
  15711 	VP8LHuffmanTablesDeallocate(tls, hdr+80)
  15712 	VP8LHtreeGroupsFree(tls, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups)
  15713 	VP8LColorCacheClear(tls, hdr+8)
  15714 	VP8LColorCacheClear(tls, hdr+24)
  15715 	InitMetadata(tls, hdr)
  15716 }
  15717 
  15718 // -----------------------------------------------------------------------------
  15719 // VP8LDecoder
  15720 
  15721 func VP8LNew(tls *libc.TLS) (r uintptr) {
  15722 	var dec uintptr
  15723 	_ = dec
  15724 	dec = WebPSafeCalloc(tls, uint64(1), uint64(400))
  15725 	if dec == libc.UintptrFromInt32(0) {
  15726 		return libc.UintptrFromInt32(0)
  15727 	}
  15728 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15729 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DIM)
  15730 	VP8LDspInit(tls) // Init critical function pointers.
  15731 	return dec
  15732 }
  15733 
  15734 // C documentation
  15735 //
  15736 //	// Resets the decoder in its initial state, reclaiming memory.
  15737 //	// Preserves the dec->status value.
  15738 func VP8LClear(tls *libc.TLS, dec uintptr) {
  15739 	var i int32
  15740 	_ = i
  15741 	if dec == libc.UintptrFromInt32(0) {
  15742 		return
  15743 	}
  15744 	ClearMetadata(tls, dec+152)
  15745 	WebPSafeFree(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels)
  15746 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = libc.UintptrFromInt32(0)
  15747 	i = 0
  15748 	for {
  15749 		if !(i < (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform) {
  15750 			break
  15751 		}
  15752 		ClearTransform(tls, dec+280+uintptr(i)*24)
  15753 		goto _1
  15754 	_1:
  15755 		;
  15756 		i = i + 1
  15757 	}
  15758 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform = 0
  15759 	(*VP8LDecoder)(unsafe.Pointer(dec)).Ftransforms_seen = uint32(0)
  15760 	WebPSafeFree(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory)
  15761 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory = libc.UintptrFromInt32(0)
  15762 	(*VP8LDecoder)(unsafe.Pointer(dec)).Foutput = libc.UintptrFromInt32(0) // leave no trace behind
  15763 }
  15764 
  15765 func VP8LDelete(tls *libc.TLS, dec uintptr) {
  15766 	if dec != libc.UintptrFromInt32(0) {
  15767 		VP8LClear(tls, dec)
  15768 		WebPSafeFree(tls, dec)
  15769 	}
  15770 }
  15771 
  15772 func UpdateDecoder(tls *libc.TLS, dec uintptr, width int32, height int32) {
  15773 	var hdr uintptr
  15774 	var num_bits, v4 int32
  15775 	var v1, v2 uint32_t
  15776 	_, _, _, _, _ = hdr, num_bits, v1, v2, v4
  15777 	hdr = dec + 152
  15778 	num_bits = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_subsample_bits
  15779 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth = width
  15780 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fheight = height
  15781 	v1 = libc.Uint32FromInt32(num_bits)
  15782 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15783 	goto _3
  15784 _3:
  15785 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_xsize = libc.Int32FromUint32(v2)
  15786 	if num_bits == 0 {
  15787 		v4 = ^libc.Int32FromInt32(0)
  15788 	} else {
  15789 		v4 = int32(1)<<num_bits - int32(1)
  15790 	}
  15791 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask = v4
  15792 }
  15793 
  15794 func DecodeImageStream(tls *libc.TLS, xsize int32, ysize int32, is_level0 int32, dec uintptr, decoded_data uintptr) (r int32) {
  15795 	bp := tls.Alloc(16)
  15796 	defer tls.Free(16)
  15797 	var br, data, hdr uintptr
  15798 	var color_cache_bits, ok int32
  15799 	var total_size uint64_t
  15800 	var _ /* transform_xsize at bp+0 */ int32
  15801 	var _ /* transform_ysize at bp+4 */ int32
  15802 	_, _, _, _, _, _ = br, color_cache_bits, data, hdr, ok, total_size
  15803 	ok = int32(1)
  15804 	**(**int32)(__ccgo_up(bp)) = xsize
  15805 	**(**int32)(__ccgo_up(bp + 4)) = ysize
  15806 	br = dec + 40
  15807 	hdr = dec + 152
  15808 	data = libc.UintptrFromInt32(0)
  15809 	color_cache_bits = 0
  15810 	// Read the transforms (may recurse).
  15811 	if is_level0 != 0 {
  15812 		for ok != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  15813 			ok = ReadTransform(tls, bp, bp+4, dec)
  15814 		}
  15815 	}
  15816 	// Color cache
  15817 	if ok != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  15818 		color_cache_bits = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(4)))
  15819 		ok = libc.BoolInt32(color_cache_bits >= int32(1) && color_cache_bits <= int32(MAX_CACHE_BITS))
  15820 		if !(ok != 0) {
  15821 			VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15822 			goto End
  15823 		}
  15824 	}
  15825 	// Read the Huffman codes (may recurse).
  15826 	ok = libc.BoolInt32(ok != 0 && ReadHuffmanCodes(tls, dec, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), color_cache_bits, is_level0) != 0)
  15827 	if !(ok != 0) {
  15828 		VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15829 		goto End
  15830 	}
  15831 	// Finish setting up the color-cache
  15832 	if color_cache_bits > 0 {
  15833 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size = int32(1) << color_cache_bits
  15834 		if !(VP8LColorCacheInit(tls, hdr+8, color_cache_bits) != 0) {
  15835 			ok = VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15836 			goto End
  15837 		}
  15838 	} else {
  15839 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size = 0
  15840 	}
  15841 	UpdateDecoder(tls, dec, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)))
  15842 	if is_level0 != 0 { // level 0 complete
  15843 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_HDR)
  15844 		goto End
  15845 	}
  15846 	total_size = libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))) * libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))
  15847 	data = WebPSafeMalloc(tls, total_size, uint64(4))
  15848 	if data == libc.UintptrFromInt32(0) {
  15849 		ok = VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15850 		goto End
  15851 	}
  15852 	// Use the Huffman trees to decode the LZ77 encoded data.
  15853 	ok = DecodeImageData(tls, dec, data, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), **(**int32)(__ccgo_up(bp + 4)), libc.UintptrFromInt32(0))
  15854 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  15855 	goto End
  15856 End:
  15857 	;
  15858 	if !(ok != 0) {
  15859 		WebPSafeFree(tls, data)
  15860 		ClearMetadata(tls, hdr)
  15861 	} else {
  15862 		if decoded_data != libc.UintptrFromInt32(0) {
  15863 			**(**uintptr)(__ccgo_up(decoded_data)) = data
  15864 		} else {
  15865 			// We allocate image data in this function only for transforms. At level 0
  15866 			// (that is: not the transforms), we shouldn't have allocated anything.
  15867 		}
  15868 		(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = 0 // Reset for future DECODE_DATA_FUNC() calls.
  15869 		if !(is_level0 != 0) {
  15870 			ClearMetadata(tls, hdr)
  15871 		} // Clean up temporary data behind.
  15872 	}
  15873 	return ok
  15874 }
  15875 
  15876 // C documentation
  15877 //
  15878 //	//------------------------------------------------------------------------------
  15879 //	// Allocate internal buffers dec->pixels and dec->argb_cache.
  15880 func AllocateInternalBuffers32b(tls *libc.TLS, dec uintptr, final_width int32) (r int32) {
  15881 	var cache_pixels, cache_top_pixels, num_pixels, total_num_pixels uint64_t
  15882 	_, _, _, _ = cache_pixels, cache_top_pixels, num_pixels, total_num_pixels
  15883 	num_pixels = libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth) * libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fheight)
  15884 	// Scratch buffer corresponding to top-prediction row for transforming the
  15885 	// first row in the row-blocks. Not needed for paletted alpha.
  15886 	cache_top_pixels = uint64(libc.Uint16FromInt32(final_width))
  15887 	// Scratch buffer for temporary BGRA storage. Not needed for paletted alpha.
  15888 	cache_pixels = libc.Uint64FromInt32(final_width) * uint64(NUM_ARGB_CACHE_ROWS)
  15889 	total_num_pixels = num_pixels + cache_top_pixels + cache_pixels
  15890 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = WebPSafeMalloc(tls, total_num_pixels, uint64(4))
  15891 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels == libc.UintptrFromInt32(0) {
  15892 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = libc.UintptrFromInt32(0) // for soundness
  15893 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15894 	}
  15895 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr(num_pixels)*4 + uintptr(cache_top_pixels)*4
  15896 	return int32(1)
  15897 }
  15898 
  15899 func AllocateInternalBuffers8b(tls *libc.TLS, dec uintptr) (r int32) {
  15900 	var total_num_pixels uint64_t
  15901 	_ = total_num_pixels
  15902 	total_num_pixels = libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth) * libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fheight)
  15903 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = libc.UintptrFromInt32(0) // for soundness
  15904 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = WebPSafeMalloc(tls, total_num_pixels, uint64(1))
  15905 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels == libc.UintptrFromInt32(0) {
  15906 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15907 	}
  15908 	return int32(1)
  15909 }
  15910 
  15911 //------------------------------------------------------------------------------
  15912 
  15913 // C documentation
  15914 //
  15915 //	// Special row-processing that only stores the alpha data.
  15916 func ExtractAlphaRows(tls *libc.TLS, dec uintptr, last_row int32) {
  15917 	var alph_dec, dst, in, output, src uintptr
  15918 	var cache_pixs, cur_row, num_rows, num_rows_to_process, width, v1 int32
  15919 	_, _, _, _, _, _, _, _, _, _, _ = alph_dec, cache_pixs, cur_row, dst, in, num_rows, num_rows_to_process, output, src, width, v1
  15920 	cur_row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15921 	num_rows = last_row - cur_row
  15922 	in = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*cur_row)*4
  15923 	for num_rows > 0 {
  15924 		if num_rows > int32(NUM_ARGB_CACHE_ROWS) {
  15925 			v1 = int32(NUM_ARGB_CACHE_ROWS)
  15926 		} else {
  15927 			v1 = num_rows
  15928 		}
  15929 		num_rows_to_process = v1
  15930 		// Extract alpha (which is stored in the green plane).
  15931 		alph_dec = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque
  15932 		output = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Foutput
  15933 		width = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth // the final width (!= dec->width)
  15934 		cache_pixs = width * num_rows_to_process
  15935 		dst = output + uintptr(width*cur_row)
  15936 		src = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  15937 		ApplyInverseTransforms(tls, dec, cur_row, num_rows_to_process, in)
  15938 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPExtractGreen})))(tls, src, dst, cache_pixs)
  15939 		AlphaApplyFilter(tls, alph_dec, cur_row, cur_row+num_rows_to_process, dst, width)
  15940 		num_rows = num_rows - num_rows_to_process
  15941 		in = in + uintptr(num_rows_to_process*(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth)*4
  15942 		cur_row = cur_row + num_rows_to_process
  15943 	}
  15944 	v1 = last_row
  15945 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  15946 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = v1
  15947 }
  15948 
  15949 func VP8LDecodeAlphaHeader(tls *libc.TLS, alph_dec uintptr, data uintptr, data_size size_t) (r int32) {
  15950 	var dec uintptr
  15951 	var ok int32
  15952 	_, _ = dec, ok
  15953 	ok = 0
  15954 	dec = VP8LNew(tls)
  15955 	if dec == libc.UintptrFromInt32(0) {
  15956 		return 0
  15957 	}
  15958 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
  15959 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fheight = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight
  15960 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fio = alph_dec + 32
  15961 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque = alph_dec
  15962 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
  15963 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fheight = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight
  15964 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15965 	VP8LInitBitReader(tls, dec+40, data, data_size)
  15966 	if !(DecodeImageStream(tls, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight, int32(1), dec, libc.UintptrFromInt32(0)) != 0) {
  15967 		goto Err
  15968 	}
  15969 	// Special case: if alpha data uses only the color indexing transform and
  15970 	// doesn't use color cache (a frequent case), we will use DecodeAlphaData()
  15971 	// method that only needs allocation of 1 byte per pixel (alpha channel).
  15972 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform == int32(1) && (**(**VP8LTransform)(__ccgo_up(dec + 280))).Ftype1 == int32(COLOR_INDEXING_TRANSFORM) && Is8bOptimizable(tls, dec+152) != 0 {
  15973 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode = int32(1)
  15974 		ok = AllocateInternalBuffers8b(tls, dec)
  15975 	} else {
  15976 		// Allocate internal buffers (note that dec->width may have changed here).
  15977 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode = 0
  15978 		ok = AllocateInternalBuffers32b(tls, dec, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth)
  15979 	}
  15980 	if !(ok != 0) {
  15981 		goto Err
  15982 	}
  15983 	// Only set here, once we are sure it is valid (to avoid thread races).
  15984 	(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec = dec
  15985 	return int32(1)
  15986 	goto Err
  15987 Err:
  15988 	;
  15989 	VP8LDelete(tls, dec)
  15990 	return 0
  15991 }
  15992 
  15993 func VP8LDecodeAlphaImageStream(tls *libc.TLS, alph_dec uintptr, last_row int32) (r int32) {
  15994 	var dec uintptr
  15995 	var v1 int32
  15996 	_, _ = dec, v1
  15997 	dec = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec
  15998 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row >= last_row {
  15999 		return int32(1) // done
  16000 	}
  16001 	if !((*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode != 0) {
  16002 		WebPInitAlphaProcessing(tls)
  16003 	}
  16004 	// Decode (with special row processing).
  16005 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode != 0 {
  16006 		v1 = DecodeAlphaData(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels, (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth, (*VP8LDecoder)(unsafe.Pointer(dec)).Fheight, last_row)
  16007 	} else {
  16008 		v1 = DecodeImageData(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels, (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth, (*VP8LDecoder)(unsafe.Pointer(dec)).Fheight, last_row, __ccgo_fp(ExtractAlphaRows))
  16009 	}
  16010 	return v1
  16011 }
  16012 
  16013 //------------------------------------------------------------------------------
  16014 
  16015 func VP8LDecodeHeader(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  16016 	bp := tls.Alloc(16)
  16017 	defer tls.Free(16)
  16018 	var _ /* has_alpha at bp+8 */ int32
  16019 	var _ /* height at bp+4 */ int32
  16020 	var _ /* width at bp+0 */ int32
  16021 	if dec == libc.UintptrFromInt32(0) {
  16022 		return 0
  16023 	}
  16024 	if io == libc.UintptrFromInt32(0) {
  16025 		return VP8LSetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM))
  16026 	}
  16027 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fio = io
  16028 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  16029 	VP8LInitBitReader(tls, dec+40, (*VP8Io)(unsafe.Pointer(io)).Fdata, (*VP8Io)(unsafe.Pointer(io)).Fdata_size)
  16030 	if !(ReadImageInfo(tls, dec+40, bp, bp+4, bp+8) != 0) {
  16031 		VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  16032 		goto Error
  16033 	}
  16034 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DIM)
  16035 	(*VP8Io)(unsafe.Pointer(io)).Fwidth = **(**int32)(__ccgo_up(bp))
  16036 	(*VP8Io)(unsafe.Pointer(io)).Fheight = **(**int32)(__ccgo_up(bp + 4))
  16037 	if !(DecodeImageStream(tls, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), int32(1), dec, libc.UintptrFromInt32(0)) != 0) {
  16038 		goto Error
  16039 	}
  16040 	return int32(1)
  16041 	goto Error
  16042 Error:
  16043 	;
  16044 	VP8LClear(tls, dec)
  16045 	return 0
  16046 }
  16047 
  16048 func VP8LDecodeImage(tls *libc.TLS, dec uintptr) (r int32) {
  16049 	var io, params uintptr
  16050 	var v1 WEBP_CSP_MODE1
  16051 	var v2 int32
  16052 	var v4 bool
  16053 	_, _, _, _, _ = io, params, v1, v2, v4
  16054 	io = libc.UintptrFromInt32(0)
  16055 	params = libc.UintptrFromInt32(0)
  16056 	if dec == libc.UintptrFromInt32(0) {
  16057 		return 0
  16058 	}
  16059 	io = (*VP8LDecoder)(unsafe.Pointer(dec)).Fio
  16060 	params = (*VP8Io)(unsafe.Pointer(io)).Fopaque
  16061 	// Initialization.
  16062 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstate != int32(READ_DATA) {
  16063 		(*VP8LDecoder)(unsafe.Pointer(dec)).Foutput = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
  16064 		if !(WebPIoInitFromOptions(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, io, int32(MODE_BGRA)) != 0) {
  16065 			VP8LSetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM))
  16066 			goto Err
  16067 		}
  16068 		if !(AllocateInternalBuffers32b(tls, dec, (*VP8Io)(unsafe.Pointer(io)).Fwidth) != 0) {
  16069 			goto Err
  16070 		}
  16071 		if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 && !(AllocateAndInitRescaler(tls, dec, io) != 0) {
  16072 			goto Err
  16073 		}
  16074 		if v4 = (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0; !v4 {
  16075 			v1 = (*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace
  16076 			v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
  16077 			goto _3
  16078 		_3:
  16079 		}
  16080 		if v4 || v2 != 0 {
  16081 			// need the alpha-multiply functions for premultiplied output or rescaling
  16082 			WebPInitAlphaProcessing(tls)
  16083 		}
  16084 		v2 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace < int32(MODE_YUV))
  16085 		goto _6
  16086 	_6:
  16087 		if !(v2 != 0) {
  16088 			WebPInitConvertARGBToYUV(tls)
  16089 			if (*(*WebPYUVABuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput + 16))).Fa != libc.UintptrFromInt32(0) {
  16090 				WebPInitAlphaProcessing(tls)
  16091 			}
  16092 		}
  16093 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  16094 			if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 && (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fsaved_color_cache.Fcolors == libc.UintptrFromInt32(0) {
  16095 				if !(VP8LColorCacheInit(tls, dec+152+24, (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache.Fhash_bits) != 0) {
  16096 					VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  16097 					goto Err
  16098 				}
  16099 			}
  16100 		}
  16101 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DATA)
  16102 	}
  16103 	// Decode.
  16104 	if !(DecodeImageData(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels, (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth, (*VP8LDecoder)(unsafe.Pointer(dec)).Fheight, (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom, __ccgo_fp(ProcessRows)) != 0) {
  16105 		goto Err
  16106 	}
  16107 	(*WebPDecParams)(unsafe.Pointer(params)).Flast_y = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  16108 	return int32(1)
  16109 	goto Err
  16110 Err:
  16111 	;
  16112 	VP8LClear(tls, dec)
  16113 	return 0
  16114 }
  16115 
  16116 const VP8L_MAGIC_BYTE2 = 0x2f
  16117 
  16118 var kHashMul9 = uint32(0x1e35a7bd)
  16119 
  16120 type WebPData = struct {
  16121 	Fbytes uintptr
  16122 	Fsize  size_t
  16123 }
  16124 
  16125 type WebPFeatureFlags1 = int32
  16126 
  16127 type WebPFeatureFlags = int32
  16128 
  16129 const ANIMATION_FLAG = 2
  16130 const XMP_FLAG = 4
  16131 const EXIF_FLAG = 8
  16132 const ALPHA_FLAG = 16
  16133 const ICCP_FLAG = 32
  16134 const ALL_VALID_FLAGS = 62
  16135 
  16136 type WebPMuxAnimDispose1 = int32
  16137 
  16138 type WebPMuxAnimDispose = int32
  16139 
  16140 const WEBP_MUX_DISPOSE_NONE = 0
  16141 const WEBP_MUX_DISPOSE_BACKGROUND = 1
  16142 
  16143 type WebPMuxAnimBlend1 = int32
  16144 
  16145 type WebPMuxAnimBlend = int32
  16146 
  16147 const WEBP_MUX_BLEND = 0
  16148 const WEBP_MUX_NO_BLEND = 1
  16149 
  16150 // Copyright 2010 Google Inc. All Rights Reserved.
  16151 //
  16152 // Use of this source code is governed by a BSD-style license
  16153 // that can be found in the COPYING file in the root of the source
  16154 // tree. An additional intellectual property rights grant can be found
  16155 // in the file PATENTS. All contributing project authors may
  16156 // be found in the AUTHORS file in the root of the source tree.
  16157 // -----------------------------------------------------------------------------
  16158 //
  16159 //  Common types + memory wrappers
  16160 //
  16161 // Author: Skal (pascal.massimino@gmail.com)
  16162 
  16163 //------------------------------------------------------------------------------
  16164 // RIFF layout is:
  16165 //   Offset  tag
  16166 //   0...3   "RIFF" 4-byte tag
  16167 //   4...7   size of image data (including metadata) starting at offset 8
  16168 //   8...11  "WEBP"   our form-type signature
  16169 // The RIFF container (12 bytes) is followed by appropriate chunks:
  16170 //   12..15  "VP8 ": 4-bytes tags, signaling the use of VP8 video format
  16171 //   16..19  size of the raw VP8 image data, starting at offset 20
  16172 //   20....  the VP8 bytes
  16173 // Or,
  16174 //   12..15  "VP8L": 4-bytes tags, signaling the use of VP8L lossless format
  16175 //   16..19  size of the raw VP8L image data, starting at offset 20
  16176 //   20....  the VP8L bytes
  16177 // Or,
  16178 //   12..15  "VP8X": 4-bytes tags, describing the extended-VP8 chunk.
  16179 //   16..19  size of the VP8X chunk starting at offset 20.
  16180 //   20..23  VP8X flags bit-map corresponding to the chunk-types present.
  16181 //   24..26  Width of the Canvas Image.
  16182 //   27..29  Height of the Canvas Image.
  16183 // There can be extra chunks after the "VP8X" chunk (ICCP, ANMF, VP8, VP8L,
  16184 // XMP, EXIF  ...)
  16185 // All sizes are in little-endian order.
  16186 // Note: chunk data size must be padded to multiple of 2 when written.
  16187 
  16188 // C documentation
  16189 //
  16190 //	// Validates the RIFF container (if detected) and skips over it.
  16191 //	// If a RIFF container is detected, returns:
  16192 //	//     VP8_STATUS_BITSTREAM_ERROR for invalid header,
  16193 //	//     VP8_STATUS_NOT_ENOUGH_DATA for truncated data if have_all_data is true,
  16194 //	// and VP8_STATUS_OK otherwise.
  16195 //	// In case there are not enough bytes (partial RIFF container), return 0 for
  16196 //	// *riff_size. Else return the RIFF size extracted from the header.
  16197 func ParseRIFF(tls *libc.TLS, data2 uintptr, data_size uintptr, have_all_data int32, riff_size uintptr) (r VP8StatusCode1) {
  16198 	var size, v2 uint32_t
  16199 	var v1, v4, v7 uintptr
  16200 	var v5, v8 int32
  16201 	_, _, _, _, _, _, _ = size, v1, v2, v4, v5, v7, v8
  16202 	**(**size_t)(__ccgo_up(riff_size)) = uint64(0) // Default: no RIFF present.
  16203 	if **(**size_t)(__ccgo_up(data_size)) >= uint64(RIFF_HEADER_SIZE) && !(libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(data2)), __ccgo_ts+564, uint64(TAG_SIZE)) != 0) {
  16204 		if libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(data2))+uintptr(8), __ccgo_ts+569, uint64(TAG_SIZE)) != 0 {
  16205 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Wrong image file signature.
  16206 		} else {
  16207 			v1 = **(**uintptr)(__ccgo_up(data2)) + uintptr(TAG_SIZE)
  16208 			v4 = v1
  16209 			v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16210 			goto _6
  16211 		_6:
  16212 			v7 = v1 + uintptr(2)
  16213 			v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16214 			goto _9
  16215 		_9:
  16216 			v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16217 			goto _3
  16218 		_3:
  16219 			size = v2
  16220 			// Check that we have at least one chunk (i.e "WEBP" + "VP8?nnnn").
  16221 			if size < libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) {
  16222 				return int32(VP8_STATUS_BITSTREAM_ERROR)
  16223 			}
  16224 			if size > ^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1) {
  16225 				return int32(VP8_STATUS_BITSTREAM_ERROR)
  16226 			}
  16227 			if have_all_data != 0 && uint64(size) > **(**size_t)(__ccgo_up(data_size))-uint64(CHUNK_HEADER_SIZE) {
  16228 				return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Truncated bitstream.
  16229 			}
  16230 			// We have a RIFF container. Skip it.
  16231 			**(**size_t)(__ccgo_up(riff_size)) = uint64(size)
  16232 			**(**uintptr)(__ccgo_up(data2)) += uintptr(RIFF_HEADER_SIZE)
  16233 			**(**size_t)(__ccgo_up(data_size)) -= uint64(RIFF_HEADER_SIZE)
  16234 		}
  16235 	}
  16236 	return int32(VP8_STATUS_OK)
  16237 }
  16238 
  16239 // C documentation
  16240 //
  16241 //	// Validates the VP8X header and skips over it.
  16242 //	// Returns VP8_STATUS_BITSTREAM_ERROR for invalid VP8X header,
  16243 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16244 //	//         VP8_STATUS_OK otherwise.
  16245 //	// If a VP8X chunk is found, found_vp8x is set to true and *width_ptr,
  16246 //	// *height_ptr and *flags_ptr are set to the corresponding values extracted
  16247 //	// from the VP8X chunk.
  16248 func ParseVP8X(tls *libc.TLS, data3 uintptr, data_size uintptr, found_vp8x uintptr, width_ptr uintptr, height_ptr uintptr, flags_ptr uintptr) (r VP8StatusCode1) {
  16249 	var chunk_size, flags, vp8x_size, v2 uint32_t
  16250 	var height, width, v5, v8 int32
  16251 	var v1, v4, v7 uintptr
  16252 	_, _, _, _, _, _, _, _, _, _, _ = chunk_size, flags, height, vp8x_size, width, v1, v2, v4, v5, v7, v8
  16253 	vp8x_size = libc.Uint32FromInt32(libc.Int32FromInt32(CHUNK_HEADER_SIZE) + libc.Int32FromInt32(VP8X_CHUNK_SIZE))
  16254 	**(**int32)(__ccgo_up(found_vp8x)) = 0
  16255 	if **(**size_t)(__ccgo_up(data_size)) < uint64(CHUNK_HEADER_SIZE) {
  16256 		return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16257 	}
  16258 	if !(libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(data3)), __ccgo_ts+574, uint64(TAG_SIZE)) != 0) {
  16259 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(TAG_SIZE)
  16260 		v4 = v1
  16261 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16262 		goto _6
  16263 	_6:
  16264 		v7 = v1 + uintptr(2)
  16265 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16266 		goto _9
  16267 	_9:
  16268 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16269 		goto _3
  16270 	_3:
  16271 		chunk_size = v2
  16272 		if chunk_size != uint32(VP8X_CHUNK_SIZE) {
  16273 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Wrong chunk size.
  16274 		}
  16275 		// Verify if enough data is available to validate the VP8X chunk.
  16276 		if **(**size_t)(__ccgo_up(data_size)) < uint64(vp8x_size) {
  16277 			return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16278 		}
  16279 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(8)
  16280 		v4 = v1
  16281 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16282 		goto _15
  16283 	_15:
  16284 		v7 = v1 + uintptr(2)
  16285 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16286 		goto _18
  16287 	_18:
  16288 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16289 		goto _12
  16290 	_12:
  16291 		flags = v2
  16292 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(12)
  16293 		v4 = v1
  16294 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16295 		goto _24
  16296 	_24:
  16297 		v5 = v8 | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + 2)))<<int32(16)
  16298 		goto _21
  16299 	_21:
  16300 		width = int32(1) + v5
  16301 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(15)
  16302 		v4 = v1
  16303 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16304 		goto _30
  16305 	_30:
  16306 		v5 = v8 | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + 2)))<<int32(16)
  16307 		goto _27
  16308 	_27:
  16309 		height = int32(1) + v5
  16310 		if libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height) >= libc.Uint64FromUint64(1)<<libc.Int32FromInt32(32) {
  16311 			return int32(VP8_STATUS_BITSTREAM_ERROR) // image is too large
  16312 		}
  16313 		if flags_ptr != libc.UintptrFromInt32(0) {
  16314 			**(**uint32_t)(__ccgo_up(flags_ptr)) = flags
  16315 		}
  16316 		if width_ptr != libc.UintptrFromInt32(0) {
  16317 			**(**int32)(__ccgo_up(width_ptr)) = width
  16318 		}
  16319 		if height_ptr != libc.UintptrFromInt32(0) {
  16320 			**(**int32)(__ccgo_up(height_ptr)) = height
  16321 		}
  16322 		// Skip over VP8X header bytes.
  16323 		**(**uintptr)(__ccgo_up(data3)) += uintptr(vp8x_size)
  16324 		**(**size_t)(__ccgo_up(data_size)) -= uint64(vp8x_size)
  16325 		**(**int32)(__ccgo_up(found_vp8x)) = int32(1)
  16326 	}
  16327 	return int32(VP8_STATUS_OK)
  16328 }
  16329 
  16330 // C documentation
  16331 //
  16332 //	// Skips to the next VP8/VP8L chunk header in the data given the size of the
  16333 //	// RIFF chunk 'riff_size'.
  16334 //	// Returns VP8_STATUS_BITSTREAM_ERROR if any invalid chunk size is encountered,
  16335 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16336 //	//         VP8_STATUS_OK otherwise.
  16337 //	// If an alpha chunk is found, *alpha_data and *alpha_size are set
  16338 //	// appropriately.
  16339 func ParseOptionalChunks(tls *libc.TLS, data2 uintptr, data_size uintptr, riff_size size_t, alpha_data uintptr, alpha_size uintptr) (r VP8StatusCode1) {
  16340 	var buf, v1, v4, v7 uintptr
  16341 	var buf_size size_t
  16342 	var chunk_size, disk_chunk_size, total_size, v2 uint32_t
  16343 	var v5, v8 int32
  16344 	_, _, _, _, _, _, _, _, _, _, _ = buf, buf_size, chunk_size, disk_chunk_size, total_size, v1, v2, v4, v5, v7, v8
  16345 	total_size = libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE) + libc.Int32FromInt32(CHUNK_HEADER_SIZE) + libc.Int32FromInt32(VP8X_CHUNK_SIZE)) // data.
  16346 	buf = **(**uintptr)(__ccgo_up(data2))
  16347 	buf_size = **(**size_t)(__ccgo_up(data_size))
  16348 	**(**uintptr)(__ccgo_up(alpha_data)) = libc.UintptrFromInt32(0)
  16349 	**(**size_t)(__ccgo_up(alpha_size)) = uint64(0)
  16350 	for int32(1) != 0 { // chunk_size with padding
  16351 		**(**uintptr)(__ccgo_up(data2)) = buf
  16352 		**(**size_t)(__ccgo_up(data_size)) = buf_size
  16353 		if buf_size < uint64(CHUNK_HEADER_SIZE) { // Insufficient data.
  16354 			return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16355 		}
  16356 		v1 = buf + uintptr(TAG_SIZE)
  16357 		v4 = v1
  16358 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16359 		goto _6
  16360 	_6:
  16361 		v7 = v1 + uintptr(2)
  16362 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16363 		goto _9
  16364 	_9:
  16365 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16366 		goto _3
  16367 	_3:
  16368 		chunk_size = v2
  16369 		if chunk_size > ^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1) {
  16370 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not a valid chunk size.
  16371 		}
  16372 		// For odd-sized chunk-payload, there's one byte padding at the end.
  16373 		disk_chunk_size = (uint32(CHUNK_HEADER_SIZE) + chunk_size + uint32(1)) & ^libc.Uint32FromUint32(1)
  16374 		total_size = total_size + disk_chunk_size
  16375 		// Check that total bytes skipped so far does not exceed riff_size.
  16376 		if riff_size > uint64(0) && uint64(total_size) > riff_size {
  16377 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not a valid chunk size.
  16378 		}
  16379 		// Start of a (possibly incomplete) VP8/VP8L chunk implies that we have
  16380 		// parsed all the optional chunks.
  16381 		// Note: This check must occur before the check 'buf_size < disk_chunk_size'
  16382 		// below to allow incomplete VP8/VP8L chunks.
  16383 		if !(libc.Xmemcmp(tls, buf, __ccgo_ts+579, uint64(TAG_SIZE)) != 0) || !(libc.Xmemcmp(tls, buf, __ccgo_ts+584, uint64(TAG_SIZE)) != 0) {
  16384 			return int32(VP8_STATUS_OK)
  16385 		}
  16386 		if buf_size < uint64(disk_chunk_size) { // Insufficient data.
  16387 			return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16388 		}
  16389 		if !(libc.Xmemcmp(tls, buf, __ccgo_ts+589, uint64(TAG_SIZE)) != 0) { // A valid ALPH header.
  16390 			**(**uintptr)(__ccgo_up(alpha_data)) = buf + uintptr(CHUNK_HEADER_SIZE)
  16391 			**(**size_t)(__ccgo_up(alpha_size)) = uint64(chunk_size)
  16392 		}
  16393 		// We have a full and valid chunk; skip it.
  16394 		buf = buf + uintptr(disk_chunk_size)
  16395 		buf_size = buf_size - uint64(disk_chunk_size)
  16396 	}
  16397 	return r
  16398 }
  16399 
  16400 // C documentation
  16401 //
  16402 //	// Validates the VP8/VP8L Header ("VP8 nnnn" or "VP8L nnnn") and skips over it.
  16403 //	// Returns VP8_STATUS_BITSTREAM_ERROR for invalid (chunk larger than
  16404 //	//         riff_size) VP8/VP8L header,
  16405 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16406 //	//         VP8_STATUS_OK otherwise.
  16407 //	// If a VP8/VP8L chunk is found, *chunk_size is set to the total number of bytes
  16408 //	// extracted from the VP8/VP8L chunk header.
  16409 //	// The flag '*is_lossless' is set to 1 in case of VP8L chunk / raw VP8L data.
  16410 func ParseVP8Header(tls *libc.TLS, data_ptr uintptr, data_size uintptr, have_all_data int32, riff_size size_t, chunk_size uintptr, is_lossless uintptr) (r VP8StatusCode1) {
  16411 	var data2, v1, v4, v7 uintptr
  16412 	var is_vp8, is_vp8l, v5, v8 int32
  16413 	var minimal_size, size, v2 uint32_t
  16414 	_, _, _, _, _, _, _, _, _, _, _ = data2, is_vp8, is_vp8l, minimal_size, size, v1, v2, v4, v5, v7, v8
  16415 	data2 = **(**uintptr)(__ccgo_up(data_ptr))
  16416 	is_vp8 = libc.BoolInt32(!(libc.Xmemcmp(tls, data2, __ccgo_ts+579, uint64(TAG_SIZE)) != 0))
  16417 	is_vp8l = libc.BoolInt32(!(libc.Xmemcmp(tls, data2, __ccgo_ts+584, uint64(TAG_SIZE)) != 0))
  16418 	minimal_size = libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE) + libc.Int32FromInt32(CHUNK_HEADER_SIZE)) // "WEBP" + "VP8 nnnn" OR
  16419 	// "WEBP" + "VP8Lnnnn"
  16420 	if **(**size_t)(__ccgo_up(data_size)) < uint64(CHUNK_HEADER_SIZE) {
  16421 		return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16422 	}
  16423 	if is_vp8 != 0 || is_vp8l != 0 {
  16424 		v1 = data2 + uintptr(TAG_SIZE)
  16425 		v4 = v1
  16426 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16427 		goto _6
  16428 	_6:
  16429 		v7 = v1 + uintptr(2)
  16430 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16431 		goto _9
  16432 	_9:
  16433 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16434 		goto _3
  16435 	_3:
  16436 		// Bitstream contains VP8/VP8L header.
  16437 		size = v2
  16438 		if riff_size >= uint64(minimal_size) && uint64(size) > riff_size-uint64(minimal_size) {
  16439 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Inconsistent size information.
  16440 		}
  16441 		if have_all_data != 0 && uint64(size) > **(**size_t)(__ccgo_up(data_size))-uint64(CHUNK_HEADER_SIZE) {
  16442 			return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Truncated bitstream.
  16443 		}
  16444 		// Skip over CHUNK_HEADER_SIZE bytes from VP8/VP8L Header.
  16445 		**(**size_t)(__ccgo_up(chunk_size)) = uint64(size)
  16446 		**(**uintptr)(__ccgo_up(data_ptr)) += uintptr(CHUNK_HEADER_SIZE)
  16447 		**(**size_t)(__ccgo_up(data_size)) -= uint64(CHUNK_HEADER_SIZE)
  16448 		**(**int32)(__ccgo_up(is_lossless)) = is_vp8l
  16449 	} else {
  16450 		// Raw VP8/VP8L bitstream (no header).
  16451 		**(**int32)(__ccgo_up(is_lossless)) = VP8LCheckSignature(tls, data2, **(**size_t)(__ccgo_up(data_size)))
  16452 		**(**size_t)(__ccgo_up(chunk_size)) = **(**size_t)(__ccgo_up(data_size))
  16453 	}
  16454 	return int32(VP8_STATUS_OK)
  16455 }
  16456 
  16457 //------------------------------------------------------------------------------
  16458 
  16459 // C documentation
  16460 //
  16461 //	// Fetch '*width', '*height', '*has_alpha' and fill out 'headers' based on
  16462 //	// 'data'. All the output parameters may be NULL. If 'headers' is NULL only the
  16463 //	// minimal amount will be read to fetch the remaining parameters.
  16464 //	// If 'headers' is non-NULL this function will attempt to locate both alpha
  16465 //	// data (with or without a VP8X chunk) and the bitstream chunk (VP8/VP8L).
  16466 //	// Note: The following chunk sequences (before the raw VP8/VP8L data) are
  16467 //	// considered valid by this function:
  16468 //	// RIFF + VP8(L)
  16469 //	// RIFF + VP8X + (optional chunks) + VP8(L)
  16470 //	// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
  16471 //	// VP8(L)     <-- Not a valid WebP format: only allowed for internal purpose.
  16472 func ParseHeadersInternal(tls *libc.TLS, _data uintptr, _data_size size_t, width uintptr, height uintptr, has_alpha uintptr, has_animation uintptr, format uintptr, headers uintptr) (r VP8StatusCode1) {
  16473 	bp := tls.Alloc(128)
  16474 	defer tls.Free(128)
  16475 	*(*uintptr)(unsafe.Pointer(bp)) = _data
  16476 	*(*size_t)(unsafe.Pointer(bp + 8)) = _data_size
  16477 	var animation_present, found_riff, have_all_data, v1 int32
  16478 	var status VP8StatusCode1
  16479 	var _ /* canvas_height at bp+20 */ int32
  16480 	var _ /* canvas_width at bp+16 */ int32
  16481 	var _ /* flags at bp+112 */ uint32_t
  16482 	var _ /* found_vp8x at bp+32 */ int32
  16483 	var _ /* hdrs at bp+40 */ WebPHeaderStructure
  16484 	var _ /* image_height at bp+28 */ int32
  16485 	var _ /* image_width at bp+24 */ int32
  16486 	_, _, _, _, _ = animation_present, found_riff, have_all_data, status, v1
  16487 	**(**int32)(__ccgo_up(bp + 16)) = 0
  16488 	**(**int32)(__ccgo_up(bp + 20)) = 0
  16489 	**(**int32)(__ccgo_up(bp + 24)) = 0
  16490 	**(**int32)(__ccgo_up(bp + 28)) = 0
  16491 	found_riff = 0
  16492 	**(**int32)(__ccgo_up(bp + 32)) = 0
  16493 	animation_present = 0
  16494 	if headers != libc.UintptrFromInt32(0) {
  16495 		v1 = (*WebPHeaderStructure)(unsafe.Pointer(headers)).Fhave_all_data
  16496 	} else {
  16497 		v1 = 0
  16498 	}
  16499 	have_all_data = v1
  16500 	if **(**uintptr)(__ccgo_up(bp)) == libc.UintptrFromInt32(0) || **(**size_t)(__ccgo_up(bp + 8)) < uint64(RIFF_HEADER_SIZE) {
  16501 		return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16502 	}
  16503 	libc.X__builtin___memset_chk(tls, bp+40, 0, uint64(72), ^__predefined_size_t(0))
  16504 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fdata = **(**uintptr)(__ccgo_up(bp))
  16505 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fdata_size = **(**size_t)(__ccgo_up(bp + 8))
  16506 	// Skip over RIFF header.
  16507 	status = ParseRIFF(tls, bp, bp+8, have_all_data, bp+40+56)
  16508 	if status != int32(VP8_STATUS_OK) {
  16509 		return status // Wrong RIFF header / insufficient data.
  16510 	}
  16511 	found_riff = libc.BoolInt32((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size > uint64(0))
  16512 	// Skip over VP8X.
  16513 	**(**uint32_t)(__ccgo_up(bp + 112)) = uint32(0)
  16514 	status = ParseVP8X(tls, bp, bp+8, bp+32, bp+16, bp+20, bp+112)
  16515 	if status != int32(VP8_STATUS_OK) {
  16516 		return status // Wrong VP8X / insufficient data.
  16517 	}
  16518 	animation_present = libc.BoolInt32(!!(**(**uint32_t)(__ccgo_up(bp + 112))&uint32(ANIMATION_FLAG) != 0))
  16519 	if !(found_riff != 0) && **(**int32)(__ccgo_up(bp + 32)) != 0 {
  16520 		// Note: This restriction may be removed in the future, if it becomes
  16521 		// necessary to send VP8X chunk to the decoder.
  16522 		return int32(VP8_STATUS_BITSTREAM_ERROR)
  16523 	}
  16524 	if has_alpha != libc.UintptrFromInt32(0) {
  16525 		**(**int32)(__ccgo_up(has_alpha)) = libc.BoolInt32(!!(**(**uint32_t)(__ccgo_up(bp + 112))&uint32(ALPHA_FLAG) != 0))
  16526 	}
  16527 	if has_animation != libc.UintptrFromInt32(0) {
  16528 		**(**int32)(__ccgo_up(has_animation)) = animation_present
  16529 	}
  16530 	if format != libc.UintptrFromInt32(0) {
  16531 		**(**int32)(__ccgo_up(format)) = 0
  16532 	} // default = undefined
  16533 	**(**int32)(__ccgo_up(bp + 24)) = **(**int32)(__ccgo_up(bp + 16))
  16534 	**(**int32)(__ccgo_up(bp + 28)) = **(**int32)(__ccgo_up(bp + 20))
  16535 	if **(**int32)(__ccgo_up(bp + 32)) != 0 && animation_present != 0 && headers == libc.UintptrFromInt32(0) {
  16536 		status = int32(VP8_STATUS_OK)
  16537 		goto ReturnWidthHeight // Just return features from VP8X header.
  16538 	}
  16539 	if **(**size_t)(__ccgo_up(bp + 8)) < uint64(TAG_SIZE) {
  16540 		status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16541 		goto ReturnWidthHeight
  16542 	}
  16543 	// Skip over optional chunks if data started with "RIFF + VP8X" or "ALPH".
  16544 	if found_riff != 0 && **(**int32)(__ccgo_up(bp + 32)) != 0 || !(found_riff != 0) && !(**(**int32)(__ccgo_up(bp + 32)) != 0) && !(libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+589, uint64(TAG_SIZE)) != 0) {
  16545 		status = ParseOptionalChunks(tls, bp, bp+8, (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size, bp+40+32, bp+40+40)
  16546 		if status != int32(VP8_STATUS_OK) {
  16547 			goto ReturnWidthHeight // Invalid chunk size / insufficient data.
  16548 		}
  16549 	}
  16550 	// Skip over VP8/VP8L header.
  16551 	status = ParseVP8Header(tls, bp, bp+8, have_all_data, (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size, bp+40+48, bp+40+64)
  16552 	if status != int32(VP8_STATUS_OK) {
  16553 		goto ReturnWidthHeight // Wrong VP8/VP8L chunk-header / insufficient data.
  16554 	}
  16555 	if (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fcompressed_size > uint64(^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1)) {
  16556 		return int32(VP8_STATUS_BITSTREAM_ERROR)
  16557 	}
  16558 	if format != libc.UintptrFromInt32(0) && !(animation_present != 0) {
  16559 		if (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fis_lossless != 0 {
  16560 			v1 = int32(2)
  16561 		} else {
  16562 			v1 = int32(1)
  16563 		}
  16564 		**(**int32)(__ccgo_up(format)) = v1
  16565 	}
  16566 	if !((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fis_lossless != 0) {
  16567 		if **(**size_t)(__ccgo_up(bp + 8)) < uint64(VP8_FRAME_HEADER_SIZE) {
  16568 			status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16569 			goto ReturnWidthHeight
  16570 		}
  16571 		// Validates raw VP8 data.
  16572 		if !(VP8GetInfo(tls, **(**uintptr)(__ccgo_up(bp)), **(**size_t)(__ccgo_up(bp + 8)), uint64(uint32((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fcompressed_size)), bp+24, bp+28) != 0) {
  16573 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16574 		}
  16575 	} else {
  16576 		if **(**size_t)(__ccgo_up(bp + 8)) < uint64(VP8L_FRAME_HEADER_SIZE) {
  16577 			status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16578 			goto ReturnWidthHeight
  16579 		}
  16580 		// Validates raw VP8L data.
  16581 		if !(VP8LGetInfo(tls, **(**uintptr)(__ccgo_up(bp)), **(**size_t)(__ccgo_up(bp + 8)), bp+24, bp+28, has_alpha) != 0) {
  16582 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16583 		}
  16584 	}
  16585 	// Validates image size coherency.
  16586 	if **(**int32)(__ccgo_up(bp + 32)) != 0 {
  16587 		if **(**int32)(__ccgo_up(bp + 16)) != **(**int32)(__ccgo_up(bp + 24)) || **(**int32)(__ccgo_up(bp + 20)) != **(**int32)(__ccgo_up(bp + 28)) {
  16588 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16589 		}
  16590 	}
  16591 	if headers != libc.UintptrFromInt32(0) {
  16592 		**(**WebPHeaderStructure)(__ccgo_up(headers)) = **(**WebPHeaderStructure)(__ccgo_up(bp + 40))
  16593 		(*WebPHeaderStructure)(unsafe.Pointer(headers)).Foffset = libc.Uint64FromInt64(int64(**(**uintptr)(__ccgo_up(bp))) - int64((*WebPHeaderStructure)(unsafe.Pointer(headers)).Fdata))
  16594 	}
  16595 	goto ReturnWidthHeight
  16596 ReturnWidthHeight:
  16597 	;
  16598 	if status == int32(VP8_STATUS_OK) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) && **(**int32)(__ccgo_up(bp + 32)) != 0 && headers == libc.UintptrFromInt32(0) {
  16599 		if has_alpha != libc.UintptrFromInt32(0) {
  16600 			// If the data did not contain a VP8X/VP8L chunk the only definitive way
  16601 			// to set this is by looking for alpha data (from an ALPH chunk).
  16602 			**(**int32)(__ccgo_up(has_alpha)) |= libc.BoolInt32((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Falpha_data != libc.UintptrFromInt32(0))
  16603 		}
  16604 		if width != libc.UintptrFromInt32(0) {
  16605 			**(**int32)(__ccgo_up(width)) = **(**int32)(__ccgo_up(bp + 24))
  16606 		}
  16607 		if height != libc.UintptrFromInt32(0) {
  16608 			**(**int32)(__ccgo_up(height)) = **(**int32)(__ccgo_up(bp + 28))
  16609 		}
  16610 		return int32(VP8_STATUS_OK)
  16611 	} else {
  16612 		return status
  16613 	}
  16614 	return r
  16615 }
  16616 
  16617 func WebPParseHeaders(tls *libc.TLS, headers uintptr) (r VP8StatusCode1) {
  16618 	bp := tls.Alloc(16)
  16619 	defer tls.Free(16)
  16620 	var status VP8StatusCode1
  16621 	var _ /* has_animation at bp+0 */ int32
  16622 	_ = status
  16623 	**(**int32)(__ccgo_up(bp)) = 0
  16624 	// fill out headers, ignore width/height/has_alpha.
  16625 	status = ParseHeadersInternal(tls, (*WebPHeaderStructure)(unsafe.Pointer(headers)).Fdata, (*WebPHeaderStructure)(unsafe.Pointer(headers)).Fdata_size, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), bp, libc.UintptrFromInt32(0), headers)
  16626 	if status == int32(VP8_STATUS_OK) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
  16627 		// The WebPDemux API + libwebp can be used to decode individual
  16628 		// uncomposited frames or the WebPAnimDecoder can be used to fully
  16629 		// reconstruct them (see webp/demux.h).
  16630 		if **(**int32)(__ccgo_up(bp)) != 0 {
  16631 			status = int32(VP8_STATUS_UNSUPPORTED_FEATURE)
  16632 		}
  16633 	}
  16634 	return status
  16635 }
  16636 
  16637 //------------------------------------------------------------------------------
  16638 // WebPDecParams
  16639 
  16640 func WebPResetDecParams(tls *libc.TLS, params uintptr) {
  16641 	if params != libc.UintptrFromInt32(0) {
  16642 		libc.X__builtin___memset_chk(tls, params, 0, uint64(112), ^__predefined_size_t(0))
  16643 	}
  16644 }
  16645 
  16646 //------------------------------------------------------------------------------
  16647 // "Into" decoding variants
  16648 
  16649 // C documentation
  16650 //
  16651 //	// Main flow
  16652 func DecodeInto(tls *libc.TLS, data uintptr, data_size size_t, params uintptr) (r VP8StatusCode1) {
  16653 	bp := tls.Alloc(240)
  16654 	defer tls.Free(240)
  16655 	var dec, dec1 uintptr
  16656 	var status VP8StatusCode1
  16657 	var v1 int32
  16658 	var _ /* headers at bp+160 */ WebPHeaderStructure
  16659 	var _ /* io at bp+0 */ VP8Io
  16660 	_, _, _, _ = dec, dec1, status, v1
  16661 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata = data
  16662 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata_size = data_size
  16663 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fhave_all_data = int32(1)
  16664 	status = WebPParseHeaders(tls, bp+160) // Process Pre-VP8 chunks.
  16665 	if status != int32(VP8_STATUS_OK) {
  16666 		return status
  16667 	}
  16668 	v1 = VP8InitIoInternal(tls, bp, int32(WEBP_DECODER_ABI_VERSION))
  16669 	goto _2
  16670 _2:
  16671 	if !(v1 != 0) {
  16672 		return int32(VP8_STATUS_INVALID_PARAM)
  16673 	}
  16674 	(**(**VP8Io)(__ccgo_up(bp))).Fdata = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata + uintptr((**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Foffset)
  16675 	(**(**VP8Io)(__ccgo_up(bp))).Fdata_size = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata_size - (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Foffset
  16676 	WebPInitCustomIo(tls, params, bp) // Plug the I/O functions.
  16677 	if !((**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fis_lossless != 0) {
  16678 		dec = VP8New(tls)
  16679 		if dec == libc.UintptrFromInt32(0) {
  16680 			return int32(VP8_STATUS_OUT_OF_MEMORY)
  16681 		}
  16682 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Falpha_data
  16683 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Falpha_data_size
  16684 		// Decode bitstream header, update io->width/io->height.
  16685 		if !(VP8GetHeaders(tls, dec, bp) != 0) {
  16686 			status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus // An error occurred. Grab error status.
  16687 		} else {
  16688 			// Allocate/check output buffers.
  16689 			status = WebPAllocateDecBuffer(tls, (**(**VP8Io)(__ccgo_up(bp))).Fwidth, (**(**VP8Io)(__ccgo_up(bp))).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16690 			if status == int32(VP8_STATUS_OK) { // Decode
  16691 				// This change must be done before calling VP8Decode()
  16692 				(*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method = VP8GetThreadMethod(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, bp+160, (**(**VP8Io)(__ccgo_up(bp))).Fwidth, (**(**VP8Io)(__ccgo_up(bp))).Fheight)
  16693 				VP8InitDithering(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, dec)
  16694 				if !(VP8Decode(tls, dec, bp) != 0) {
  16695 					status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
  16696 				}
  16697 			}
  16698 		}
  16699 		VP8Delete(tls, dec)
  16700 	} else {
  16701 		dec1 = VP8LNew(tls)
  16702 		if dec1 == libc.UintptrFromInt32(0) {
  16703 			return int32(VP8_STATUS_OUT_OF_MEMORY)
  16704 		}
  16705 		if !(VP8LDecodeHeader(tls, dec1, bp) != 0) {
  16706 			status = (*VP8LDecoder)(unsafe.Pointer(dec1)).Fstatus // An error occurred. Grab error status.
  16707 		} else {
  16708 			// Allocate/check output buffers.
  16709 			status = WebPAllocateDecBuffer(tls, (**(**VP8Io)(__ccgo_up(bp))).Fwidth, (**(**VP8Io)(__ccgo_up(bp))).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16710 			if status == int32(VP8_STATUS_OK) { // Decode
  16711 				if !(VP8LDecodeImage(tls, dec1) != 0) {
  16712 					status = (*VP8LDecoder)(unsafe.Pointer(dec1)).Fstatus
  16713 				}
  16714 			}
  16715 		}
  16716 		VP8LDelete(tls, dec1)
  16717 	}
  16718 	if status != int32(VP8_STATUS_OK) {
  16719 		WebPFreeDecBuffer(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16720 	} else {
  16721 		if (*WebPDecParams)(unsafe.Pointer(params)).Foptions != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(params)).Foptions)).Fflip != 0 {
  16722 			// This restores the original stride values if options->flip was used
  16723 			// during the call to WebPAllocateDecBuffer above.
  16724 			status = WebPFlipBuffer(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16725 		}
  16726 	}
  16727 	return status
  16728 }
  16729 
  16730 // C documentation
  16731 //
  16732 //	// Helpers
  16733 func DecodeIntoRGBABuffer(tls *libc.TLS, colorspace WEBP_CSP_MODE1, data uintptr, data_size size_t, rgba uintptr, stride int32, size size_t) (r uintptr) {
  16734 	bp := tls.Alloc(240)
  16735 	defer tls.Free(240)
  16736 	var v1 int32
  16737 	var v3 bool
  16738 	var _ /* buf at bp+112 */ WebPDecBuffer
  16739 	var _ /* params at bp+0 */ WebPDecParams
  16740 	_, _ = v1, v3
  16741 	if v3 = rgba == libc.UintptrFromInt32(0); !v3 {
  16742 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16743 		goto _2
  16744 	_2:
  16745 	}
  16746 	if v3 || !(v1 != 0) {
  16747 		return libc.UintptrFromInt32(0)
  16748 	}
  16749 	WebPResetDecParams(tls, bp)
  16750 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16751 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = colorspace
  16752 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = rgba
  16753 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 8)) = stride
  16754 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 16)) = size
  16755 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fis_external_memory = int32(1)
  16756 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16757 		return libc.UintptrFromInt32(0)
  16758 	}
  16759 	return rgba
  16760 }
  16761 
  16762 func WebPDecodeRGBInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16763 	return DecodeIntoRGBABuffer(tls, int32(MODE_RGB), data, data_size, output, stride, size)
  16764 }
  16765 
  16766 func WebPDecodeRGBAInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16767 	return DecodeIntoRGBABuffer(tls, int32(MODE_RGBA), data, data_size, output, stride, size)
  16768 }
  16769 
  16770 func WebPDecodeARGBInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16771 	return DecodeIntoRGBABuffer(tls, int32(MODE_ARGB), data, data_size, output, stride, size)
  16772 }
  16773 
  16774 func WebPDecodeBGRInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16775 	return DecodeIntoRGBABuffer(tls, int32(MODE_BGR), data, data_size, output, stride, size)
  16776 }
  16777 
  16778 func WebPDecodeBGRAInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16779 	return DecodeIntoRGBABuffer(tls, int32(MODE_BGRA), data, data_size, output, stride, size)
  16780 }
  16781 
  16782 func WebPDecodeYUVInto(tls *libc.TLS, data uintptr, data_size size_t, luma uintptr, luma_size size_t, luma_stride int32, u uintptr, u_size size_t, u_stride int32, v uintptr, v_size size_t, v_stride int32) (r uintptr) {
  16783 	bp := tls.Alloc(240)
  16784 	defer tls.Free(240)
  16785 	var v1 int32
  16786 	var v3 bool
  16787 	var _ /* output at bp+112 */ WebPDecBuffer
  16788 	var _ /* params at bp+0 */ WebPDecParams
  16789 	_, _ = v1, v3
  16790 	if v3 = luma == libc.UintptrFromInt32(0); !v3 {
  16791 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16792 		goto _2
  16793 	_2:
  16794 	}
  16795 	if v3 || !(v1 != 0) {
  16796 		return libc.UintptrFromInt32(0)
  16797 	}
  16798 	WebPResetDecParams(tls, bp)
  16799 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16800 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = int32(MODE_YUV)
  16801 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = luma
  16802 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 32)) = luma_stride
  16803 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 48)) = luma_size
  16804 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16 + 8)) = u
  16805 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 36)) = u_stride
  16806 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 56)) = u_size
  16807 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16 + 16)) = v
  16808 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 40)) = v_stride
  16809 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 64)) = v_size
  16810 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fis_external_memory = int32(1)
  16811 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16812 		return libc.UintptrFromInt32(0)
  16813 	}
  16814 	return luma
  16815 }
  16816 
  16817 // ------------------------------------------------------------------------------
  16818 func Decode(tls *libc.TLS, mode1 WEBP_CSP_MODE1, data uintptr, data_size size_t, width uintptr, height uintptr, keep_info uintptr) (r uintptr) {
  16819 	bp := tls.Alloc(240)
  16820 	defer tls.Free(240)
  16821 	var v1 int32
  16822 	var v3 uintptr
  16823 	var _ /* output at bp+112 */ WebPDecBuffer
  16824 	var _ /* params at bp+0 */ WebPDecParams
  16825 	_, _ = v1, v3
  16826 	v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16827 	goto _2
  16828 _2:
  16829 	if !(v1 != 0) {
  16830 		return libc.UintptrFromInt32(0)
  16831 	}
  16832 	WebPResetDecParams(tls, bp)
  16833 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16834 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = mode1
  16835 	// Retrieve (and report back) the required dimensions from bitstream.
  16836 	if !(WebPGetInfo(tls, data, data_size, bp+112+4, bp+112+8) != 0) {
  16837 		return libc.UintptrFromInt32(0)
  16838 	}
  16839 	if width != libc.UintptrFromInt32(0) {
  16840 		**(**int32)(__ccgo_up(width)) = (**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fwidth
  16841 	}
  16842 	if height != libc.UintptrFromInt32(0) {
  16843 		**(**int32)(__ccgo_up(height)) = (**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fheight
  16844 	}
  16845 	// Decode
  16846 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16847 		return libc.UintptrFromInt32(0)
  16848 	}
  16849 	if keep_info != libc.UintptrFromInt32(0) { // keep track of the side-info
  16850 		WebPCopyDecBuffer(tls, bp+112, keep_info)
  16851 	}
  16852 	// return decoded samples (don't clear 'output'!)
  16853 	v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
  16854 	goto _5
  16855 _5:
  16856 	if v1 != 0 {
  16857 		v3 = *(*uintptr)(unsafe.Pointer(bp + 112 + 16))
  16858 	} else {
  16859 		v3 = *(*uintptr)(unsafe.Pointer(bp + 112 + 16))
  16860 	}
  16861 	return v3
  16862 }
  16863 
  16864 func WebPDecodeRGB(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16865 	return Decode(tls, int32(MODE_RGB), data, data_size, width, height, libc.UintptrFromInt32(0))
  16866 }
  16867 
  16868 func WebPDecodeRGBA(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16869 	return Decode(tls, int32(MODE_RGBA), data, data_size, width, height, libc.UintptrFromInt32(0))
  16870 }
  16871 
  16872 func WebPDecodeARGB(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16873 	return Decode(tls, int32(MODE_ARGB), data, data_size, width, height, libc.UintptrFromInt32(0))
  16874 }
  16875 
  16876 func WebPDecodeBGR(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16877 	return Decode(tls, int32(MODE_BGR), data, data_size, width, height, libc.UintptrFromInt32(0))
  16878 }
  16879 
  16880 func WebPDecodeBGRA(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16881 	return Decode(tls, int32(MODE_BGRA), data, data_size, width, height, libc.UintptrFromInt32(0))
  16882 }
  16883 
  16884 func WebPDecodeYUV(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr, u uintptr, v uintptr, stride uintptr, uv_stride uintptr) (r uintptr) {
  16885 	bp := tls.Alloc(128)
  16886 	defer tls.Free(128)
  16887 	var buf, out uintptr
  16888 	var _ /* output at bp+0 */ WebPDecBuffer
  16889 	_, _ = buf, out
  16890 	// data, width and height are checked by Decode().
  16891 	if u == libc.UintptrFromInt32(0) || v == libc.UintptrFromInt32(0) || stride == libc.UintptrFromInt32(0) || uv_stride == libc.UintptrFromInt32(0) {
  16892 		return libc.UintptrFromInt32(0)
  16893 	}
  16894 	// only to preserve the side-infos
  16895 	out = Decode(tls, int32(MODE_YUV), data, data_size, width, height, bp)
  16896 	if out != libc.UintptrFromInt32(0) {
  16897 		buf = bp + 16
  16898 		**(**uintptr)(__ccgo_up(u)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu
  16899 		**(**uintptr)(__ccgo_up(v)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv
  16900 		**(**int32)(__ccgo_up(stride)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride
  16901 		**(**int32)(__ccgo_up(uv_stride)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride
  16902 	}
  16903 	return out
  16904 	return r
  16905 }
  16906 
  16907 func DefaultFeatures(tls *libc.TLS, features uintptr) {
  16908 	libc.X__builtin___memset_chk(tls, features, 0, uint64(40), ^__predefined_size_t(0))
  16909 }
  16910 
  16911 func GetFeatures(tls *libc.TLS, data uintptr, data_size size_t, features uintptr) (r VP8StatusCode1) {
  16912 	if features == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
  16913 		return int32(VP8_STATUS_INVALID_PARAM)
  16914 	}
  16915 	DefaultFeatures(tls, features)
  16916 	// Only parse enough of the data to retrieve the features.
  16917 	return ParseHeadersInternal(tls, data, data_size, features, features+4, features+8, features+12, features+16, libc.UintptrFromInt32(0))
  16918 }
  16919 
  16920 //------------------------------------------------------------------------------
  16921 // WebPGetInfo()
  16922 
  16923 func WebPGetInfo(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r int32) {
  16924 	bp := tls.Alloc(48)
  16925 	defer tls.Free(48)
  16926 	var _ /* features at bp+0 */ WebPBitstreamFeatures
  16927 	if GetFeatures(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16928 		return 0
  16929 	}
  16930 	if width != libc.UintptrFromInt32(0) {
  16931 		**(**int32)(__ccgo_up(width)) = (**(**WebPBitstreamFeatures)(__ccgo_up(bp))).Fwidth
  16932 	}
  16933 	if height != libc.UintptrFromInt32(0) {
  16934 		**(**int32)(__ccgo_up(height)) = (**(**WebPBitstreamFeatures)(__ccgo_up(bp))).Fheight
  16935 	}
  16936 	return int32(1)
  16937 }
  16938 
  16939 //------------------------------------------------------------------------------
  16940 // Advance decoding API
  16941 
  16942 func WebPInitDecoderConfigInternal(tls *libc.TLS, config uintptr, version int32) (r int32) {
  16943 	var v1 int32
  16944 	_ = v1
  16945 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  16946 		return 0 // version mismatch
  16947 	}
  16948 	if config == libc.UintptrFromInt32(0) {
  16949 		return 0
  16950 	}
  16951 	libc.X__builtin___memset_chk(tls, config, 0, uint64(240), ^__predefined_size_t(0))
  16952 	DefaultFeatures(tls, config)
  16953 	v1 = WebPInitDecBufferInternal(tls, config+40, int32(WEBP_DECODER_ABI_VERSION))
  16954 	goto _2
  16955 _2:
  16956 	if !(v1 != 0) {
  16957 		return 0
  16958 	}
  16959 	return int32(1)
  16960 }
  16961 
  16962 func WebPCheckCropDimensionsBasic(tls *libc.TLS, x int32, y int32, w int32, h int32) (r int32) {
  16963 	return libc.BoolInt32(!(x < 0 || y < 0 || w <= 0 || h <= 0))
  16964 }
  16965 
  16966 func WebPValidateDecoderConfig(tls *libc.TLS, config uintptr) (r int32) {
  16967 	bp := tls.Alloc(16)
  16968 	defer tls.Free(16)
  16969 	var options uintptr
  16970 	var _ /* scaled_height at bp+4 */ int32
  16971 	var _ /* scaled_width at bp+0 */ int32
  16972 	_ = options
  16973 	if config == libc.UintptrFromInt32(0) {
  16974 		return 0
  16975 	}
  16976 	if !(IsValidColorspace(tls, (*WebPDecoderConfig)(unsafe.Pointer(config)).Foutput.Fcolorspace) != 0) {
  16977 		return 0
  16978 	}
  16979 	options = config + 160
  16980 	// bypass_filtering, no_fancy_upsampling, use_cropping, use_scaling,
  16981 	// use_threads, flip can be any integer and are interpreted as boolean.
  16982 	// Check for cropping.
  16983 	if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0 && !(WebPCheckCropDimensionsBasic(tls, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height) != 0) {
  16984 		return 0
  16985 	}
  16986 	// Check for scaling.
  16987 	if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0 && ((*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width < 0 || (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height < 0 || (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width == 0 && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height == 0) {
  16988 		return 0
  16989 	}
  16990 	// In case the WebPBitstreamFeatures has been filled in, check further.
  16991 	if (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth > 0 || (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight > 0 {
  16992 		**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
  16993 		**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
  16994 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0 && !(WebPCheckCropDimensions(tls, (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth, (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width, (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height) != 0) {
  16995 			return 0
  16996 		}
  16997 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0 && !(WebPRescalerGetScaledDimensions(tls, (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth, (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight, bp, bp+4) != 0) {
  16998 			return 0
  16999 		}
  17000 	}
  17001 	// Check for dithering.
  17002 	if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fdithering_strength < 0 || (*WebPDecoderOptions)(unsafe.Pointer(options)).Fdithering_strength > int32(100) || (*WebPDecoderOptions)(unsafe.Pointer(options)).Falpha_dithering_strength < 0 || (*WebPDecoderOptions)(unsafe.Pointer(options)).Falpha_dithering_strength > int32(100) {
  17003 		return 0
  17004 	}
  17005 	return int32(1)
  17006 }
  17007 
  17008 func WebPGetFeaturesInternal(tls *libc.TLS, data uintptr, data_size size_t, features uintptr, version int32) (r VP8StatusCode1) {
  17009 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  17010 		return int32(VP8_STATUS_INVALID_PARAM) // version mismatch
  17011 	}
  17012 	if features == libc.UintptrFromInt32(0) {
  17013 		return int32(VP8_STATUS_INVALID_PARAM)
  17014 	}
  17015 	return GetFeatures(tls, data, data_size, features)
  17016 }
  17017 
  17018 func WebPDecode(tls *libc.TLS, data uintptr, data_size size_t, config uintptr) (r VP8StatusCode1) {
  17019 	bp := tls.Alloc(240)
  17020 	defer tls.Free(240)
  17021 	var status VP8StatusCode1
  17022 	var v1 int32
  17023 	var _ /* in_mem_buffer at bp+112 */ WebPDecBuffer
  17024 	var _ /* params at bp+0 */ WebPDecParams
  17025 	_, _ = status, v1
  17026 	if config == libc.UintptrFromInt32(0) {
  17027 		return int32(VP8_STATUS_INVALID_PARAM)
  17028 	}
  17029 	status = GetFeatures(tls, data, data_size, config)
  17030 	if status != int32(VP8_STATUS_OK) {
  17031 		if status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
  17032 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not-enough-data treated as error.
  17033 		}
  17034 		return status
  17035 	}
  17036 	WebPResetDecParams(tls, bp)
  17037 	(**(**WebPDecParams)(__ccgo_up(bp))).Foptions = config + 160
  17038 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = config + 40
  17039 	if WebPAvoidSlowMemory(tls, (**(**WebPDecParams)(__ccgo_up(bp))).Foutput, config) != 0 {
  17040 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  17041 		goto _2
  17042 	_2:
  17043 		if !(v1 != 0) {
  17044 			return int32(VP8_STATUS_INVALID_PARAM)
  17045 		}
  17046 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = (*WebPDecoderConfig)(unsafe.Pointer(config)).Foutput.Fcolorspace
  17047 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fwidth = (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth
  17048 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fheight = (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight
  17049 		(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  17050 		status = DecodeInto(tls, data, data_size, bp)
  17051 		if status == int32(VP8_STATUS_OK) { // do the slow-copy
  17052 			status = WebPCopyDecBufferPixels(tls, bp+112, config+40)
  17053 		}
  17054 		WebPFreeDecBuffer(tls, bp+112)
  17055 	} else {
  17056 		status = DecodeInto(tls, data, data_size, bp)
  17057 	}
  17058 	return status
  17059 }
  17060 
  17061 //------------------------------------------------------------------------------
  17062 // Cropping and rescaling.
  17063 
  17064 func WebPCheckCropDimensions(tls *libc.TLS, image_width int32, image_height int32, x int32, y int32, w int32, h int32) (r int32) {
  17065 	return libc.BoolInt32(WebPCheckCropDimensionsBasic(tls, x, y, w, h) != 0 && !(x >= image_width || w > image_width || w > image_width-x || y >= image_height || h > image_height || h > image_height-y))
  17066 }
  17067 
  17068 func WebPIoInitFromOptions(tls *libc.TLS, options uintptr, io uintptr, src_colorspace WEBP_CSP_MODE1) (r int32) {
  17069 	bp := tls.Alloc(16)
  17070 	defer tls.Free(16)
  17071 	var H, W, h, w, x, y, v1 int32
  17072 	var _ /* scaled_height at bp+4 */ int32
  17073 	var _ /* scaled_width at bp+0 */ int32
  17074 	_, _, _, _, _, _, _ = H, W, h, w, x, y, v1
  17075 	W = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  17076 	H = (*VP8Io)(unsafe.Pointer(io)).Fheight
  17077 	x = 0
  17078 	y = 0
  17079 	w = W
  17080 	h = H
  17081 	// Cropping
  17082 	(*VP8Io)(unsafe.Pointer(io)).Fuse_cropping = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0)
  17083 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_cropping != 0 {
  17084 		w = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width
  17085 		h = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height
  17086 		x = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left
  17087 		y = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top
  17088 		v1 = libc.BoolInt32(src_colorspace < int32(MODE_YUV))
  17089 		goto _2
  17090 	_2:
  17091 		if !(v1 != 0) { // only snap for YUV420
  17092 			x = x & ^libc.Int32FromInt32(1)
  17093 			y = y & ^libc.Int32FromInt32(1)
  17094 		}
  17095 		if !(WebPCheckCropDimensions(tls, W, H, x, y, w, h) != 0) {
  17096 			return 0 // out of frame boundary error
  17097 		}
  17098 	}
  17099 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_left = x
  17100 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_top = y
  17101 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_right = x + w
  17102 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom = y + h
  17103 	(*VP8Io)(unsafe.Pointer(io)).Fmb_w = w
  17104 	(*VP8Io)(unsafe.Pointer(io)).Fmb_h = h
  17105 	// Scaling
  17106 	(*VP8Io)(unsafe.Pointer(io)).Fuse_scaling = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0)
  17107 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  17108 		**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
  17109 		**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
  17110 		if !(WebPRescalerGetScaledDimensions(tls, w, h, bp, bp+4) != 0) {
  17111 			return 0
  17112 		}
  17113 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_width = **(**int32)(__ccgo_up(bp))
  17114 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_height = **(**int32)(__ccgo_up(bp + 4))
  17115 	}
  17116 	// Filter
  17117 	(*VP8Io)(unsafe.Pointer(io)).Fbypass_filtering = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fbypass_filtering != 0)
  17118 	// Fancy upsampler
  17119 	(*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling = libc.BoolInt32(options == libc.UintptrFromInt32(0) || !((*WebPDecoderOptions)(unsafe.Pointer(options)).Fno_fancy_upsampling != 0))
  17120 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  17121 		// disable filter (only for large downscaling ratio).
  17122 		**(**int32)(__ccgo_up(io + 112)) |= libc.BoolInt32((*VP8Io)(unsafe.Pointer(io)).Fscaled_width < W*int32(3)/int32(4) && (*VP8Io)(unsafe.Pointer(io)).Fscaled_height < H*int32(3)/int32(4))
  17123 		(*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling = 0
  17124 	}
  17125 	return int32(1)
  17126 }
  17127 
  17128 const ENC_MAJ_VERSION = 1
  17129 const ENC_MIN_VERSION = 6
  17130 const ENC_REV_VERSION = 0
  17131 const ERROR_DIFFUSION_QUALITY = 98
  17132 const HASH_BITS = 18
  17133 const MAX_COLOR_CACHE_BITS = 10
  17134 const MAX_LENGTH_BITS = 12
  17135 const MAX_REFS_BLOCK_PER_IMAGE = 16
  17136 const QFIX = 17
  17137 const U_OFF_ENC = 16
  17138 const VP8L_WRITER_BITS = 32
  17139 const VP8L_WRITER_BYTES = 4
  17140 const VP8L_WRITER_MAX_BITS = 64
  17141 const WEBP_ENCODER_ABI_VERSION = 528
  17142 const WEBP_MAX_DIMENSION = 16383
  17143 const WEBP_NEAR_LOSSLESS = 1
  17144 const WINDOW_SIZE_BITS = 20
  17145 const WSWAP = "HToLE32"
  17146 const Y_OFF_ENC = 0
  17147 
  17148 type VP8Matrix = struct {
  17149 	Fq       [16]uint16_t
  17150 	Fiq      [16]uint16_t
  17151 	Fbias    [16]uint32_t
  17152 	Fzthresh [16]uint32_t
  17153 	Fsharpen [16]uint16_t
  17154 }
  17155 
  17156 type VP8BitWriter = struct {
  17157 	Frange1  int32_t
  17158 	Fvalue   int32_t
  17159 	Frun     int32
  17160 	Fnb_bits int32
  17161 	Fbuf     uintptr
  17162 	Fpos     size_t
  17163 	Fmax_pos size_t
  17164 	Ferror1  int32
  17165 }
  17166 
  17167 type vp8l_atype_t = uint64
  17168 
  17169 type vp8l_wtype_t = uint32
  17170 
  17171 type VP8LBitWriter = struct {
  17172 	Fbits   vp8l_atype_t
  17173 	Fused   int32
  17174 	Fbuf    uintptr
  17175 	Fcur    uintptr
  17176 	Fend    uintptr
  17177 	Ferror1 int32
  17178 }
  17179 
  17180 type WebPPicture = struct {
  17181 	Fuse_argb        int32
  17182 	Fcolorspace      WebPEncCSP1
  17183 	Fwidth           int32
  17184 	Fheight          int32
  17185 	Fy               uintptr
  17186 	Fu               uintptr
  17187 	Fv               uintptr
  17188 	Fy_stride        int32
  17189 	Fuv_stride       int32
  17190 	Fa               uintptr
  17191 	Fa_stride        int32
  17192 	Fpad1            [2]uint32_t
  17193 	Fargb            uintptr
  17194 	Fargb_stride     int32
  17195 	Fpad2            [3]uint32_t
  17196 	Fwriter          WebPWriterFunction
  17197 	Fcustom_ptr      uintptr
  17198 	Fextra_info_type int32
  17199 	Fextra_info      uintptr
  17200 	Fstats           uintptr
  17201 	Ferror_code      WebPEncodingError1
  17202 	Fprogress_hook   WebPProgressHook
  17203 	Fuser_data       uintptr
  17204 	Fpad3            [3]uint32_t
  17205 	Fpad4            uintptr
  17206 	Fpad5            uintptr
  17207 	Fpad6            [8]uint32_t
  17208 	Fmemory_         uintptr
  17209 	Fmemory_argb_    uintptr
  17210 	Fpad7            [2]uintptr
  17211 }
  17212 
  17213 type WebPEncCSP = int32
  17214 
  17215 const WEBP_YUV420 = 0
  17216 const WEBP_YUV420A = 4
  17217 const WEBP_CSP_UV_MASK = 3
  17218 const WEBP_CSP_ALPHA_BIT = 4
  17219 
  17220 type WebPEncodingError = int32
  17221 
  17222 const VP8_ENC_OK = 0
  17223 const VP8_ENC_ERROR_OUT_OF_MEMORY = 1
  17224 const VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY = 2
  17225 const VP8_ENC_ERROR_NULL_PARAMETER = 3
  17226 const VP8_ENC_ERROR_INVALID_CONFIGURATION = 4
  17227 const VP8_ENC_ERROR_BAD_DIMENSION = 5
  17228 const VP8_ENC_ERROR_PARTITION0_OVERFLOW = 6
  17229 const VP8_ENC_ERROR_PARTITION_OVERFLOW = 7
  17230 const VP8_ENC_ERROR_BAD_WRITE = 8
  17231 const VP8_ENC_ERROR_FILE_TOO_BIG = 9
  17232 const VP8_ENC_ERROR_USER_ABORT = 10
  17233 const VP8_ENC_ERROR_LAST = 11
  17234 
  17235 type WebPConfig = struct {
  17236 	Flossless          int32
  17237 	Fquality           float32
  17238 	Fmethod            int32
  17239 	Fimage_hint        WebPImageHint1
  17240 	Ftarget_size       int32
  17241 	Ftarget_PSNR       float32
  17242 	Fsegments          int32
  17243 	Fsns_strength      int32
  17244 	Ffilter_strength   int32
  17245 	Ffilter_sharpness  int32
  17246 	Ffilter_type       int32
  17247 	Fautofilter        int32
  17248 	Falpha_compression int32
  17249 	Falpha_filtering   int32
  17250 	Falpha_quality     int32
  17251 	Fpass              int32
  17252 	Fshow_compressed   int32
  17253 	Fpreprocessing     int32
  17254 	Fpartitions        int32
  17255 	Fpartition_limit   int32
  17256 	Femulate_jpeg_size int32
  17257 	Fthread_level      int32
  17258 	Flow_memory        int32
  17259 	Fnear_lossless     int32
  17260 	Fexact             int32
  17261 	Fuse_delta_palette int32
  17262 	Fuse_sharp_yuv     int32
  17263 	Fqmin              int32
  17264 	Fqmax              int32
  17265 }
  17266 
  17267 type WebPImageHint = int32
  17268 
  17269 const WEBP_HINT_DEFAULT = 0
  17270 const WEBP_HINT_PICTURE = 1
  17271 const WEBP_HINT_PHOTO = 2
  17272 const WEBP_HINT_GRAPH = 3
  17273 const WEBP_HINT_LAST = 4
  17274 
  17275 type WebPAuxStats = struct {
  17276 	Fcoded_size                 int32
  17277 	FPSNR                       [5]float32
  17278 	Fblock_count                [3]int32
  17279 	Fheader_bytes               [2]int32
  17280 	Fresidual_bytes             [3][4]int32
  17281 	Fsegment_size               [4]int32
  17282 	Fsegment_quant              [4]int32
  17283 	Fsegment_level              [4]int32
  17284 	Falpha_data_size            int32
  17285 	Flayer_data_size            int32
  17286 	Flossless_features          uint32_t
  17287 	Fhistogram_bits             int32
  17288 	Ftransform_bits             int32
  17289 	Fcache_bits                 int32
  17290 	Fpalette_size               int32
  17291 	Flossless_size              int32
  17292 	Flossless_hdr_size          int32
  17293 	Flossless_data_size         int32
  17294 	Fcross_color_transform_bits int32
  17295 	Fpad                        [1]uint32_t
  17296 }
  17297 
  17298 type WebPMemoryWriter = struct {
  17299 	Fmem      uintptr
  17300 	Fsize     size_t
  17301 	Fmax_size size_t
  17302 	Fpad      [1]uint32_t
  17303 }
  17304 
  17305 type WebPImageHint1 = int32
  17306 
  17307 type WebPPreset1 = int32
  17308 
  17309 type WebPPreset = int32
  17310 
  17311 const WEBP_PRESET_DEFAULT = 0
  17312 const WEBP_PRESET_PICTURE = 1
  17313 const WEBP_PRESET_PHOTO = 2
  17314 const WEBP_PRESET_DRAWING = 3
  17315 const WEBP_PRESET_ICON = 4
  17316 const WEBP_PRESET_TEXT = 5
  17317 
  17318 type WebPWriterFunction = uintptr
  17319 
  17320 type WebPProgressHook = uintptr
  17321 
  17322 type WebPEncCSP1 = int32
  17323 
  17324 type WebPEncodingError1 = int32
  17325 
  17326 const MAX_LF_LEVELS = 64
  17327 const MAX_VARIABLE_LEVEL = 67
  17328 const MAX_LEVEL = 2047
  17329 
  17330 type VP8RDLevel = int32
  17331 
  17332 const RD_OPT_NONE = 0
  17333 const RD_OPT_BASIC = 1
  17334 const RD_OPT_TRELLIS = 2
  17335 const RD_OPT_TRELLIS_ALL = 3
  17336 
  17337 type score_t = int64
  17338 
  17339 type proba_t = uint32
  17340 
  17341 type ProbaArray = [3][11]uint8_t
  17342 
  17343 type StatsArray = [3][11]proba_t
  17344 
  17345 type CostArray = [3][68]uint16_t
  17346 
  17347 type CostArrayPtr = uintptr
  17348 
  17349 type CostArrayMap = [16][3]uintptr
  17350 
  17351 type LFStats = [4][64]float64
  17352 
  17353 type VP8Encoder = struct {
  17354 	Fconfig             uintptr
  17355 	Fpic                uintptr
  17356 	Ffilter_hdr         VP8EncFilterHeader
  17357 	Fsegment_hdr        VP8EncSegmentHeader
  17358 	Fprofile            int32
  17359 	Fmb_w               int32
  17360 	Fmb_h               int32
  17361 	Fpreds_w            int32
  17362 	Fnum_parts          int32
  17363 	Fbw                 VP8BitWriter
  17364 	Fparts              [8]VP8BitWriter
  17365 	Ftokens             VP8TBuffer
  17366 	Fpercent            int32
  17367 	Fhas_alpha          int32
  17368 	Falpha_data         uintptr
  17369 	Falpha_data_size    uint32_t
  17370 	Falpha_worker       WebPWorker
  17371 	Fdqm                [4]VP8SegmentInfo
  17372 	Fbase_quant         int32
  17373 	Falpha              int32
  17374 	Fuv_alpha           int32
  17375 	Fdq_y1_dc           int32
  17376 	Fdq_y2_dc           int32
  17377 	Fdq_y2_ac           int32
  17378 	Fdq_uv_dc           int32
  17379 	Fdq_uv_ac           int32
  17380 	Fproba              VP8EncProba
  17381 	Fsse                [4]uint64_t
  17382 	Fsse_count          uint64_t
  17383 	Fcoded_size         int32
  17384 	Fresidual_bytes     [3][4]int32
  17385 	Fblock_count        [3]int32
  17386 	Fmethod             int32
  17387 	Frd_opt_level       VP8RDLevel
  17388 	Fmax_i4_header_bits int32
  17389 	Fmb_header_limit    int32
  17390 	Fthread_level       int32
  17391 	Fdo_search          int32
  17392 	Fuse_tokens         int32
  17393 	Fmb_info            uintptr
  17394 	Fpreds              uintptr
  17395 	Fnz                 uintptr
  17396 	Fy_top              uintptr
  17397 	Fuv_top             uintptr
  17398 	Flf_stats           uintptr
  17399 	Ftop_derr           uintptr
  17400 }
  17401 
  17402 type VP8EncSegmentHeader = struct {
  17403 	Fnum_segments int32
  17404 	Fupdate_map   int32
  17405 	Fsize         int32
  17406 }
  17407 
  17408 type VP8EncProba = struct {
  17409 	Fsegments       [3]uint8_t
  17410 	Fskip_proba     uint8_t
  17411 	Fcoeffs         [4][8]ProbaArray
  17412 	Fstats          [4][8]StatsArray
  17413 	Flevel_cost     [4][8]CostArray
  17414 	Fremapped_costs [4]CostArrayMap
  17415 	Fdirty          int32
  17416 	Fuse_skip_proba int32
  17417 	Fnb_skip        int32
  17418 }
  17419 
  17420 type VP8EncFilterHeader = struct {
  17421 	Fsimple        int32
  17422 	Flevel         int32
  17423 	Fsharpness     int32
  17424 	Fi4x4_lf_delta int32
  17425 }
  17426 
  17427 type VP8MBInfo = struct {
  17428 	F__ccgo_align [0]uint32
  17429 	F__ccgo0      uint8
  17430 	Falpha        uint8_t
  17431 }
  17432 
  17433 type VP8SegmentInfo = struct {
  17434 	Fy1                 VP8Matrix
  17435 	Fy2                 VP8Matrix
  17436 	Fuv                 VP8Matrix
  17437 	Falpha              int32
  17438 	Fbeta               int32
  17439 	Fquant              int32
  17440 	Ffstrength          int32
  17441 	Fmax_edge           int32
  17442 	Fmin_disto          int32
  17443 	Flambda_i16         int32
  17444 	Flambda_i4          int32
  17445 	Flambda_uv          int32
  17446 	Flambda_mode        int32
  17447 	Flambda_trellis     int32
  17448 	Ftlambda            int32
  17449 	Flambda_trellis_i16 int32
  17450 	Flambda_trellis_i4  int32
  17451 	Flambda_trellis_uv  int32
  17452 	Fi4_penalty         score_t
  17453 }
  17454 
  17455 type DError = [2][2]int8_t
  17456 
  17457 type VP8ModeScore = struct {
  17458 	FD           score_t
  17459 	FSD          score_t
  17460 	FH           score_t
  17461 	FR           score_t
  17462 	Fscore       score_t
  17463 	Fy_dc_levels [16]int16_t
  17464 	Fy_ac_levels [16][16]int16_t
  17465 	Fuv_levels   [8][16]int16_t
  17466 	Fmode_i16    int32
  17467 	Fmodes_i4    [16]uint8_t
  17468 	Fmode_uv     int32
  17469 	Fnz          uint32_t
  17470 	Fderr        [2][3]int8_t
  17471 }
  17472 
  17473 type VP8EncIterator = struct {
  17474 	Fx            int32
  17475 	Fy            int32
  17476 	Fyuv_in       uintptr
  17477 	Fyuv_out      uintptr
  17478 	Fyuv_out2     uintptr
  17479 	Fyuv_p        uintptr
  17480 	Fenc          uintptr
  17481 	Fmb           uintptr
  17482 	Fbw           uintptr
  17483 	Fpreds        uintptr
  17484 	Fnz           uintptr
  17485 	Fi4_boundary  [37]uint8_t
  17486 	Fi4_top       uintptr
  17487 	Fi4           int32
  17488 	Ftop_nz       [9]int32
  17489 	Fleft_nz      [9]int32
  17490 	Fbit_count    [4][3]uint64_t
  17491 	Fluma_bits    uint64_t
  17492 	Fuv_bits      uint64_t
  17493 	Flf_stats     uintptr
  17494 	Fdo_trellis   int32
  17495 	Fcount_down   int32
  17496 	Fcount_down0  int32
  17497 	Fpercent0     int32
  17498 	Fleft_derr    DError
  17499 	Ftop_derr     uintptr
  17500 	Fy_left       uintptr
  17501 	Fu_left       uintptr
  17502 	Fv_left       uintptr
  17503 	Fy_top        uintptr
  17504 	Fuv_top       uintptr
  17505 	Fyuv_left_mem [88]uint8_t
  17506 	Fyuv_mem      [3359]uint8_t
  17507 }
  17508 
  17509 type VP8TBuffer = struct {
  17510 	Fpages     uintptr
  17511 	Flast_page uintptr
  17512 	Ftokens    uintptr
  17513 	Fleft      int32
  17514 	Fpage_size int32
  17515 	Ferror1    int32
  17516 }
  17517 
  17518 type Mode = int32
  17519 
  17520 const kLiteral = 0
  17521 const kCacheIdx = 1
  17522 const kCopy = 2
  17523 const kNone = 3
  17524 
  17525 type PixOrCopy = struct {
  17526 	Fmode             uint8_t
  17527 	Flen1             uint16_t
  17528 	Fargb_or_distance uint32_t
  17529 }
  17530 
  17531 type VP8LHashChain = struct {
  17532 	Foffset_length uintptr
  17533 	Fsize          int32
  17534 }
  17535 
  17536 type VP8LBackwardRefs = struct {
  17537 	Fblock_size  int32
  17538 	Ferror1      int32
  17539 	Frefs        uintptr
  17540 	Ftail        uintptr
  17541 	Ffree_blocks uintptr
  17542 	Flast_block  uintptr
  17543 }
  17544 
  17545 type VP8LRefsCursor = struct {
  17546 	Fcur_pos   uintptr
  17547 	Fcur_block uintptr
  17548 	Flast_pos  uintptr
  17549 }
  17550 
  17551 type VP8LLZ77Type = int32
  17552 
  17553 const kLZ77Standard = 1
  17554 const kLZ77RLE = 2
  17555 const kLZ77Box = 4
  17556 
  17557 type VP8LHistogram = struct {
  17558 	Fliteral           uintptr
  17559 	Fred               [256]uint32_t
  17560 	Fblue              [256]uint32_t
  17561 	Falpha             [256]uint32_t
  17562 	Fdistance          [40]uint32_t
  17563 	Fpalette_code_bits int32
  17564 	Ftrivial_symbol    [5]uint16_t
  17565 	Fbit_cost          uint64_t
  17566 	Fcosts             [5]uint64_t
  17567 	Fis_used           [5]uint8_t
  17568 	Fbin_id            uint16_t
  17569 }
  17570 
  17571 type VP8LHistogramSet = struct {
  17572 	Fsize       int32
  17573 	Fmax_size   int32
  17574 	Fhistograms uintptr
  17575 }
  17576 
  17577 type VP8LEncoderARGBContent = int32
  17578 
  17579 const kEncoderNone = 0
  17580 const kEncoderARGB = 1
  17581 const kEncoderNearLossless = 2
  17582 const kEncoderPalette = 3
  17583 
  17584 type VP8LEncoder = struct {
  17585 	Fconfig                     uintptr
  17586 	Fpic                        uintptr
  17587 	Fargb                       uintptr
  17588 	Fargb_content               VP8LEncoderARGBContent
  17589 	Fargb_scratch               uintptr
  17590 	Ftransform_data             uintptr
  17591 	Ftransform_mem              uintptr
  17592 	Ftransform_mem_size         size_t
  17593 	Fcurrent_width              int32
  17594 	Fhisto_bits                 int32
  17595 	Fpredictor_transform_bits   int32
  17596 	Fcross_color_transform_bits int32
  17597 	Fcache_bits                 int32
  17598 	Fuse_cross_color            int32
  17599 	Fuse_subtract_green         int32
  17600 	Fuse_predict                int32
  17601 	Fuse_palette                int32
  17602 	Fpalette_size               int32
  17603 	Fpalette                    [256]uint32_t
  17604 	Fpalette_sorted             [256]uint32_t
  17605 	Frefs                       [4]VP8LBackwardRefs
  17606 	Fhash_chain                 VP8LHashChain
  17607 }
  17608 
  17609 //------------------------------------------------------------------------------
  17610 
  17611 func EncodeLossless(tls *libc.TLS, data uintptr, width int32, height int32, effort_level int32, use_quality_100 int32, bw uintptr, stats uintptr) (r int32) {
  17612 	bp := tls.Alloc(384)
  17613 	defer tls.Free(384)
  17614 	var ok, v1 int32
  17615 	var v5 float32
  17616 	var _ /* config at bp+0 */ WebPConfig
  17617 	var _ /* picture at bp+120 */ WebPPicture
  17618 	_, _, _ = ok, v1, v5
  17619 	ok = 0
  17620 	v1 = WebPPictureInitInternal(tls, bp+120, int32(WEBP_ENCODER_ABI_VERSION))
  17621 	goto _2
  17622 _2:
  17623 	if !(v1 != 0) {
  17624 		return 0
  17625 	}
  17626 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fwidth = width
  17627 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fheight = height
  17628 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fuse_argb = int32(1)
  17629 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fstats = stats
  17630 	if !(WebPPictureAlloc(tls, bp+120) != 0) {
  17631 		return 0
  17632 	}
  17633 	// Transfer the alpha values to the green channel.
  17634 	(*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPDispatchAlphaToGreen})))(tls, data, width, (**(**WebPPicture)(__ccgo_up(bp + 120))).Fwidth, (**(**WebPPicture)(__ccgo_up(bp + 120))).Fheight, (**(**WebPPicture)(__ccgo_up(bp + 120))).Fargb, (**(**WebPPicture)(__ccgo_up(bp + 120))).Fargb_stride)
  17635 	v1 = WebPConfigInitInternal(tls, bp, int32(WEBP_PRESET_DEFAULT), libc.Float32FromFloat32(75), int32(WEBP_ENCODER_ABI_VERSION))
  17636 	goto _4
  17637 _4:
  17638 	if !(v1 != 0) {
  17639 		return 0
  17640 	}
  17641 	(**(**WebPConfig)(__ccgo_up(bp))).Flossless = int32(1)
  17642 	// Enable exact, or it would alter RGB values of transparent alpha, which is
  17643 	// normally OK but not here since we are not encoding the input image but  an
  17644 	// internal encoding-related image containing necessary exact information in
  17645 	// RGB channels.
  17646 	(**(**WebPConfig)(__ccgo_up(bp))).Fexact = int32(1)
  17647 	(**(**WebPConfig)(__ccgo_up(bp))).Fmethod = effort_level // impact is very small
  17648 	// Set a low default quality for encoding alpha. Ensure that Alpha quality at
  17649 	// lower methods (3 and below) is less than the threshold for triggering
  17650 	// costly 'BackwardReferencesTraceBackwards'.
  17651 	// If the alpha quality is set to 100 and the method to 6, allow for a high
  17652 	// lossless quality to trigger the cruncher.
  17653 	if use_quality_100 != 0 && effort_level == int32(6) {
  17654 		v5 = libc.Float32FromInt32(100)
  17655 	} else {
  17656 		v5 = float32(libc.Float32FromFloat32(8) * float32(effort_level))
  17657 	}
  17658 	(**(**WebPConfig)(__ccgo_up(bp))).Fquality = v5
  17659 	ok = VP8LEncodeStream(tls, bp, bp+120, bw)
  17660 	WebPPictureFree(tls, bp+120)
  17661 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 != 0))
  17662 	if !(ok != 0) {
  17663 		VP8LBitWriterWipeOut(tls, bw)
  17664 		return 0
  17665 	}
  17666 	return int32(1)
  17667 }
  17668 
  17669 // -----------------------------------------------------------------------------
  17670 
  17671 // C documentation
  17672 //
  17673 //	// Small struct to hold the result of a filter mode compression attempt.
  17674 type FilterTrial = struct {
  17675 	Fscore size_t
  17676 	Fbw    VP8BitWriter
  17677 	Fstats WebPAuxStats
  17678 }
  17679 
  17680 // C documentation
  17681 //
  17682 //	// This function always returns an initialized 'bw' object, even upon error.
  17683 func EncodeAlphaInternal(tls *libc.TLS, data uintptr, width int32, height int32, method int32, filter int32, reduce_levels int32, effort_level int32, tmp_alpha uintptr, result uintptr) (r int32) {
  17684 	bp := tls.Alloc(64)
  17685 	defer tls.Free(64)
  17686 	var alpha_src, output, v1 uintptr
  17687 	var data_size, output_size, v2 size_t
  17688 	var filter_func WebPFilterFunc
  17689 	var ok int32
  17690 	var _ /* header at bp+0 */ uint8_t
  17691 	var _ /* tmp_bw at bp+8 */ VP8LBitWriter
  17692 	_, _, _, _, _, _, _, _ = alpha_src, data_size, filter_func, ok, output, output_size, v1, v2
  17693 	ok = 0
  17694 	data_size = libc.Uint64FromInt32(width * height)
  17695 	output = libc.UintptrFromInt32(0)
  17696 	output_size = uint64(0)
  17697 	// as per spec
  17698 	filter_func = WebPFilters[filter]
  17699 	if filter_func != libc.UintptrFromInt32(0) {
  17700 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{filter_func})))(tls, data, width, height, width, tmp_alpha)
  17701 		alpha_src = tmp_alpha
  17702 	} else {
  17703 		alpha_src = data
  17704 	}
  17705 	if method != ALPHA_NO_COMPRESSION {
  17706 		ok = VP8LBitWriterInit(tls, bp+8, data_size>>int32(3))
  17707 		ok = libc.BoolInt32(ok != 0 && EncodeLossless(tls, alpha_src, width, height, effort_level, libc.BoolInt32(!(reduce_levels != 0)), bp+8, result+56) != 0)
  17708 		if ok != 0 {
  17709 			output = VP8LBitWriterFinish(tls, bp+8)
  17710 			if (**(**VP8LBitWriter)(__ccgo_up(bp + 8))).Ferror1 != 0 {
  17711 				VP8LBitWriterWipeOut(tls, bp+8)
  17712 				libc.X__builtin___memset_chk(tls, result+8, 0, uint64(48), ^__predefined_size_t(0))
  17713 				return 0
  17714 			}
  17715 			v1 = bp + 8
  17716 			v2 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v1)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  17717 			goto _3
  17718 		_3:
  17719 			output_size = v2
  17720 			if output_size > data_size {
  17721 				// compressed size is larger than source! Revert to uncompressed mode.
  17722 				method = ALPHA_NO_COMPRESSION
  17723 				VP8LBitWriterWipeOut(tls, bp+8)
  17724 			}
  17725 		} else {
  17726 			VP8LBitWriterWipeOut(tls, bp+8)
  17727 			libc.X__builtin___memset_chk(tls, result+8, 0, uint64(48), ^__predefined_size_t(0))
  17728 			return 0
  17729 		}
  17730 	}
  17731 	if method == ALPHA_NO_COMPRESSION {
  17732 		output = alpha_src
  17733 		output_size = data_size
  17734 		ok = int32(1)
  17735 	}
  17736 	// Emit final result.
  17737 	**(**uint8_t)(__ccgo_up(bp)) = libc.Uint8FromInt32(method | filter<<int32(2))
  17738 	if reduce_levels != 0 {
  17739 		**(**uint8_t)(__ccgo_up(bp)) = libc.Uint8FromInt32(int32(**(**uint8_t)(__ccgo_up(bp))) | libc.Int32FromInt32(ALPHA_PREPROCESSED_LEVELS)<<libc.Int32FromInt32(4))
  17740 	}
  17741 	if !(VP8BitWriterInit(tls, result+8, uint64(ALPHA_HEADER_LEN)+output_size) != 0) {
  17742 		ok = 0
  17743 	}
  17744 	ok = libc.BoolInt32(ok != 0 && VP8BitWriterAppend(tls, result+8, bp, uint64(ALPHA_HEADER_LEN)) != 0)
  17745 	ok = libc.BoolInt32(ok != 0 && VP8BitWriterAppend(tls, result+8, output, output_size) != 0)
  17746 	if method != ALPHA_NO_COMPRESSION {
  17747 		VP8LBitWriterWipeOut(tls, bp+8)
  17748 	}
  17749 	ok = libc.BoolInt32(ok != 0 && !((*FilterTrial)(unsafe.Pointer(result)).Fbw.Ferror1 != 0))
  17750 	v2 = (*VP8BitWriter)(unsafe.Pointer(result + 8)).Fpos
  17751 	goto _5
  17752 _5:
  17753 	(*FilterTrial)(unsafe.Pointer(result)).Fscore = v2
  17754 	return ok
  17755 }
  17756 
  17757 // -----------------------------------------------------------------------------
  17758 
  17759 func GetNumColors(tls *libc.TLS, data uintptr, width int32, height int32, stride int32) (r int32) {
  17760 	var color [256]uint8_t
  17761 	var colors, i, j int32
  17762 	var p uintptr
  17763 	_, _, _, _, _ = color, colors, i, j, p
  17764 	colors = 0
  17765 	color = [256]uint8_t{}
  17766 	j = 0
  17767 	for {
  17768 		if !(j < height) {
  17769 			break
  17770 		}
  17771 		p = data + uintptr(j*stride)
  17772 		i = 0
  17773 		for {
  17774 			if !(i < width) {
  17775 				break
  17776 			}
  17777 			color[**(**uint8_t)(__ccgo_up(p + uintptr(i)))] = uint8(1)
  17778 			goto _2
  17779 		_2:
  17780 			;
  17781 			i = i + 1
  17782 		}
  17783 		goto _1
  17784 	_1:
  17785 		;
  17786 		j = j + 1
  17787 	}
  17788 	j = 0
  17789 	for {
  17790 		if !(j < int32(256)) {
  17791 			break
  17792 		}
  17793 		if libc.Int32FromUint8(color[j]) > 0 {
  17794 			colors = colors + 1
  17795 		}
  17796 		goto _3
  17797 	_3:
  17798 		;
  17799 		j = j + 1
  17800 	}
  17801 	return colors
  17802 }
  17803 
  17804 // C documentation
  17805 //
  17806 //	// Given the input 'filter' option, return an OR'd bit-set of filters to try.
  17807 func GetFilterMap(tls *libc.TLS, alpha uintptr, width int32, height int32, filter int32, effort_level int32) (r uint32_t) {
  17808 	var bit_map uint32_t
  17809 	var kMaxColorsForFilterNone, kMinColorsForFilterNone, num_colors, try_filter_none, v1 int32
  17810 	_, _, _, _, _, _ = bit_map, kMaxColorsForFilterNone, kMinColorsForFilterNone, num_colors, try_filter_none, v1
  17811 	bit_map = 0
  17812 	if filter == int32(WEBP_FILTER_FAST) {
  17813 		// Quick estimate of the best candidate.
  17814 		try_filter_none = libc.BoolInt32(effort_level > int32(3))
  17815 		kMinColorsForFilterNone = int32(16)
  17816 		kMaxColorsForFilterNone = int32(192)
  17817 		num_colors = GetNumColors(tls, alpha, width, height, width)
  17818 		// For low number of colors, NONE yields better compression.
  17819 		if num_colors <= kMinColorsForFilterNone {
  17820 			v1 = int32(WEBP_FILTER_NONE)
  17821 		} else {
  17822 			v1 = WebPEstimateBestFilter(tls, alpha, width, height, width)
  17823 		}
  17824 		filter = v1
  17825 		bit_map = bit_map | libc.Uint32FromInt32(int32(1)<<filter)
  17826 		// For large number of colors, try FILTER_NONE in addition to the best
  17827 		// filter as well.
  17828 		if try_filter_none != 0 || num_colors > kMaxColorsForFilterNone {
  17829 			bit_map = bit_map | libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_NONE))
  17830 		}
  17831 	} else {
  17832 		if filter == int32(WEBP_FILTER_NONE) {
  17833 			bit_map = libc.Uint32FromInt32(libc.Int32FromInt32(1) << int32(WEBP_FILTER_NONE))
  17834 		} else { // WEBP_FILTER_BEST -> try all
  17835 			bit_map = libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_LAST) - libc.Int32FromInt32(1))
  17836 		}
  17837 	}
  17838 	return bit_map
  17839 }
  17840 
  17841 func InitFilterTrial(tls *libc.TLS, score uintptr) {
  17842 	(*FilterTrial)(unsafe.Pointer(score)).Fscore = uint64(^libc.Uint32FromUint32(0))
  17843 	VP8BitWriterInit(tls, score+8, uint64(0))
  17844 }
  17845 
  17846 func ApplyFiltersAndEncode(tls *libc.TLS, alpha uintptr, width int32, height int32, data_size size_t, method int32, filter int32, reduce_levels int32, effort_level int32, output uintptr, output_size uintptr, stats uintptr) (r int32) {
  17847 	bp := tls.Alloc(496)
  17848 	defer tls.Free(496)
  17849 	var filtered_alpha, v4 uintptr
  17850 	var ok int32
  17851 	var try_map uint32_t
  17852 	var v2 size_t
  17853 	var _ /* best at bp+0 */ FilterTrial
  17854 	var _ /* trial at bp+248 */ FilterTrial
  17855 	_, _, _, _, _ = filtered_alpha, ok, try_map, v2, v4
  17856 	ok = int32(1)
  17857 	try_map = GetFilterMap(tls, alpha, width, height, filter, effort_level)
  17858 	InitFilterTrial(tls, bp)
  17859 	if try_map != libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_NONE)) {
  17860 		filtered_alpha = WebPSafeMalloc(tls, uint64(1), data_size)
  17861 		if filtered_alpha == libc.UintptrFromInt32(0) {
  17862 			return 0
  17863 		}
  17864 		filter = int32(WEBP_FILTER_NONE)
  17865 		for {
  17866 			if !(ok != 0 && try_map != 0) {
  17867 				break
  17868 			}
  17869 			if try_map&uint32(1) != 0 {
  17870 				ok = EncodeAlphaInternal(tls, alpha, width, height, method, filter, reduce_levels, effort_level, filtered_alpha, bp+248)
  17871 				if ok != 0 && (**(**FilterTrial)(__ccgo_up(bp + 248))).Fscore < (**(**FilterTrial)(__ccgo_up(bp))).Fscore {
  17872 					VP8BitWriterWipeOut(tls, bp+8)
  17873 					**(**FilterTrial)(__ccgo_up(bp)) = **(**FilterTrial)(__ccgo_up(bp + 248))
  17874 				} else {
  17875 					VP8BitWriterWipeOut(tls, bp+248+8)
  17876 				}
  17877 			}
  17878 			goto _1
  17879 		_1:
  17880 			;
  17881 			filter = filter + 1
  17882 			try_map = try_map >> uint32(1)
  17883 		}
  17884 		WebPSafeFree(tls, filtered_alpha)
  17885 	} else {
  17886 		ok = EncodeAlphaInternal(tls, alpha, width, height, method, int32(WEBP_FILTER_NONE), reduce_levels, effort_level, libc.UintptrFromInt32(0), bp)
  17887 	}
  17888 	if ok != 0 {
  17889 		if stats != libc.UintptrFromInt32(0) {
  17890 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_features = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_features
  17891 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fhistogram_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fhistogram_bits
  17892 			(*WebPAuxStats)(unsafe.Pointer(stats)).Ftransform_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Ftransform_bits
  17893 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fcross_color_transform_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fcross_color_transform_bits
  17894 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fcache_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fcache_bits
  17895 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fpalette_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fpalette_size
  17896 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_size
  17897 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_hdr_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_hdr_size
  17898 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_data_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_data_size
  17899 		}
  17900 		v2 = (*VP8BitWriter)(unsafe.Pointer(bp + 8)).Fpos
  17901 		goto _3
  17902 	_3:
  17903 		**(**size_t)(__ccgo_up(output_size)) = v2
  17904 		v4 = (*VP8BitWriter)(unsafe.Pointer(bp + 8)).Fbuf
  17905 		goto _5
  17906 	_5:
  17907 		**(**uintptr)(__ccgo_up(output)) = v4
  17908 	} else {
  17909 		VP8BitWriterWipeOut(tls, bp+8)
  17910 	}
  17911 	return ok
  17912 }
  17913 
  17914 func EncodeAlpha(tls *libc.TLS, enc uintptr, quality int32, method int32, filter int32, effort_level int32, output uintptr, output_size uintptr) (r int32) {
  17915 	bp := tls.Alloc(16)
  17916 	defer tls.Free(16)
  17917 	var alpha_levels, height, ok, reduce_levels, width, v1 int32
  17918 	var data_size size_t
  17919 	var pic, quant_alpha uintptr
  17920 	var _ /* sse at bp+0 */ uint64_t
  17921 	_, _, _, _, _, _, _, _, _ = alpha_levels, data_size, height, ok, pic, quant_alpha, reduce_levels, width, v1
  17922 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  17923 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  17924 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  17925 	quant_alpha = libc.UintptrFromInt32(0)
  17926 	data_size = libc.Uint64FromInt32(width * height)
  17927 	**(**uint64_t)(__ccgo_up(bp)) = uint64(0)
  17928 	ok = int32(1)
  17929 	reduce_levels = libc.BoolInt32(quality < libc.Int32FromInt32(100))
  17930 	// quick correctness checks
  17931 	// as per spec
  17932 	if quality < 0 || quality > int32(100) {
  17933 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  17934 	}
  17935 	if method < ALPHA_NO_COMPRESSION || method > int32(ALPHA_LOSSLESS_COMPRESSION) {
  17936 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  17937 	}
  17938 	if method == ALPHA_NO_COMPRESSION {
  17939 		// Don't filter, as filtering will make no impact on compressed size.
  17940 		filter = int32(WEBP_FILTER_NONE)
  17941 	}
  17942 	quant_alpha = WebPSafeMalloc(tls, uint64(1), data_size)
  17943 	if quant_alpha == libc.UintptrFromInt32(0) {
  17944 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  17945 	}
  17946 	// Extract alpha data (width x height) from raw_data (stride x height).
  17947 	WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fa, (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride, quant_alpha, width, width, height)
  17948 	if reduce_levels != 0 {
  17949 		if quality <= int32(70) {
  17950 			v1 = int32(2) + quality/int32(5)
  17951 		} else {
  17952 			v1 = int32(16) + (quality-int32(70))*int32(8)
  17953 		} // No Quantization required for 'quality = 100'.
  17954 		// 16 alpha levels gives quite a low MSE w.r.t original alpha plane hence
  17955 		// mapped to moderate quality 70. Hence Quality:[0, 70] -> Levels:[2, 16]
  17956 		// and Quality:]70, 100] -> Levels:]16, 256].
  17957 		alpha_levels = v1
  17958 		ok = QuantizeLevels(tls, quant_alpha, width, height, alpha_levels, bp)
  17959 	}
  17960 	if ok != 0 {
  17961 		VP8FiltersInit(tls)
  17962 		ok = ApplyFiltersAndEncode(tls, quant_alpha, width, height, data_size, method, filter, reduce_levels, effort_level, output, output_size, (*WebPPicture)(unsafe.Pointer(pic)).Fstats)
  17963 		if !(ok != 0) {
  17964 			WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY)) // imprecise
  17965 		}
  17966 		if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) { // need stats?
  17967 			**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer(pic)).Fstats)) += libc.Int32FromUint64(**(**size_t)(__ccgo_up(output_size)))
  17968 			**(**uint64_t)(__ccgo_up(enc + 23512 + 3*8)) = **(**uint64_t)(__ccgo_up(bp))
  17969 		}
  17970 	}
  17971 	WebPSafeFree(tls, quant_alpha)
  17972 	return ok
  17973 }
  17974 
  17975 //------------------------------------------------------------------------------
  17976 // Main calls
  17977 
  17978 func CompressAlphaJob(tls *libc.TLS, arg1 uintptr, unused uintptr) (r int32) {
  17979 	bp := tls.Alloc(16)
  17980 	defer tls.Free(16)
  17981 	var config, enc uintptr
  17982 	var effort_level, v1, v2 int32
  17983 	var filter WEBP_FILTER_TYPE
  17984 	var _ /* alpha_data at bp+0 */ uintptr
  17985 	var _ /* alpha_size at bp+8 */ size_t
  17986 	_, _, _, _, _, _ = config, effort_level, enc, filter, v1, v2
  17987 	enc = arg1
  17988 	config = (*VP8Encoder)(unsafe.Pointer(enc)).Fconfig
  17989 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  17990 	**(**size_t)(__ccgo_up(bp + 8)) = uint64(0)
  17991 	effort_level = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  17992 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering == 0 {
  17993 		v1 = int32(WEBP_FILTER_NONE)
  17994 	} else {
  17995 		if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering == int32(1) {
  17996 			v2 = int32(WEBP_FILTER_FAST)
  17997 		} else {
  17998 			v2 = int32(WEBP_FILTER_BEST)
  17999 		}
  18000 		v1 = v2
  18001 	} // maps to [0..6]
  18002 	filter = v1
  18003 	if !(EncodeAlpha(tls, enc, (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality, (*WebPConfig)(unsafe.Pointer(config)).Falpha_compression, filter, effort_level, bp, bp+8) != 0) {
  18004 		return 0
  18005 	}
  18006 	if **(**size_t)(__ccgo_up(bp + 8)) != uint64(uint32(**(**size_t)(__ccgo_up(bp + 8)))) { // Soundness check.
  18007 		WebPSafeFree(tls, **(**uintptr)(__ccgo_up(bp)))
  18008 		return 0
  18009 	}
  18010 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(**(**size_t)(__ccgo_up(bp + 8)))
  18011 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = **(**uintptr)(__ccgo_up(bp))
  18012 	_ = unused
  18013 	return int32(1)
  18014 }
  18015 
  18016 func VP8EncInitAlpha(tls *libc.TLS, enc uintptr) {
  18017 	var worker uintptr
  18018 	_ = worker
  18019 	WebPInitAlphaProcessing(tls)
  18020 	(*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha = WebPPictureHasTransparency(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic)
  18021 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = libc.UintptrFromInt32(0)
  18022 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(0)
  18023 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18024 		worker = enc + 560
  18025 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, worker)
  18026 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = enc
  18027 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = libc.UintptrFromInt32(0)
  18028 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(CompressAlphaJob)
  18029 	}
  18030 }
  18031 
  18032 func VP8EncStartAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18033 	var worker uintptr
  18034 	_ = worker
  18035 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  18036 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18037 			worker = enc + 560
  18038 			// Makes sure worker is good to go.
  18039 			if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FReset})))(tls, worker) != 0) {
  18040 				return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  18041 			}
  18042 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FLaunch})))(tls, worker)
  18043 			return int32(1)
  18044 		} else {
  18045 			return CompressAlphaJob(tls, enc, libc.UintptrFromInt32(0)) // just do the job right away
  18046 		}
  18047 	}
  18048 	return int32(1)
  18049 }
  18050 
  18051 func VP8EncFinishAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18052 	var worker uintptr
  18053 	_ = worker
  18054 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  18055 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18056 			worker = enc + 560
  18057 			if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker) != 0) {
  18058 				return 0
  18059 			} // error
  18060 		}
  18061 	}
  18062 	return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+int32(20), enc+536)
  18063 }
  18064 
  18065 func VP8EncDeleteAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18066 	var ok int32
  18067 	var worker uintptr
  18068 	_, _ = ok, worker
  18069 	ok = int32(1)
  18070 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18071 		worker = enc + 560
  18072 		// finish anything left in flight
  18073 		ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker)
  18074 		// still need to end the worker, even if !ok
  18075 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FEnd})))(tls, worker)
  18076 	}
  18077 	WebPSafeFree(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data)
  18078 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = libc.UintptrFromInt32(0)
  18079 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(0)
  18080 	(*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha = 0
  18081 	return ok
  18082 }
  18083 
  18084 const MAX_ALPHA = 255
  18085 const MAX_INTRA16_MODE = 2
  18086 const MAX_INTRA4_MODE = 2
  18087 const MAX_ITERS_K_MEANS = 6
  18088 const MAX_UV_MODE = 2
  18089 
  18090 //------------------------------------------------------------------------------
  18091 
  18092 // Copyright 2011 Google Inc. All Rights Reserved.
  18093 //
  18094 // Use of this source code is governed by a BSD-style license
  18095 // that can be found in the COPYING file in the root of the source
  18096 // tree. An additional intellectual property rights grant can be found
  18097 // in the file PATENTS. All contributing project authors may
  18098 // be found in the AUTHORS file in the root of the source tree.
  18099 // -----------------------------------------------------------------------------
  18100 //
  18101 // Multi-threaded worker
  18102 //
  18103 // Author: Skal (pascal.massimino@gmail.com)
  18104 
  18105 // Copyright 2012 Google Inc. All Rights Reserved.
  18106 //
  18107 // Use of this source code is governed by a BSD-style license
  18108 // that can be found in the COPYING file in the root of the source
  18109 // tree. An additional intellectual property rights grant can be found
  18110 // in the file PATENTS. All contributing project authors may
  18111 // be found in the AUTHORS file in the root of the source tree.
  18112 // -----------------------------------------------------------------------------
  18113 //
  18114 // Misc. common utility functions
  18115 //
  18116 // Authors: Skal (pascal.massimino@gmail.com)
  18117 //          Urvang (urvang@google.com)
  18118 
  18119 // Copyright 2011 Google Inc. All Rights Reserved.
  18120 //
  18121 // Use of this source code is governed by a BSD-style license
  18122 // that can be found in the COPYING file in the root of the source
  18123 // tree. An additional intellectual property rights grant can be found
  18124 // in the file PATENTS. All contributing project authors may
  18125 // be found in the AUTHORS file in the root of the source tree.
  18126 // -----------------------------------------------------------------------------
  18127 //
  18128 //   WebP encoder: main interface
  18129 //
  18130 // Author: Skal (pascal.massimino@gmail.com)
  18131 
  18132 // Copyright 2010 Google Inc. All Rights Reserved.
  18133 //
  18134 // Use of this source code is governed by a BSD-style license
  18135 // that can be found in the COPYING file in the root of the source
  18136 // tree. An additional intellectual property rights grant can be found
  18137 // in the file PATENTS. All contributing project authors may
  18138 // be found in the AUTHORS file in the root of the source tree.
  18139 // -----------------------------------------------------------------------------
  18140 //
  18141 //  Common types + memory wrappers
  18142 //
  18143 // Author: Skal (pascal.massimino@gmail.com)
  18144 
  18145 //------------------------------------------------------------------------------
  18146 // Smooth the segment map by replacing isolated block by the majority of its
  18147 // neighbours.
  18148 
  18149 func SmoothSegmentMap(tls *libc.TLS, enc uintptr) {
  18150 	var cnt [4]int32
  18151 	var h, majority_cnt_3_x_3_grid, majority_seg, n, w, x, y int32
  18152 	var mb, mb1, tmp uintptr
  18153 	_, _, _, _, _, _, _, _, _, _, _ = cnt, h, majority_cnt_3_x_3_grid, majority_seg, mb, mb1, n, tmp, w, x, y
  18154 	w = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w
  18155 	h = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  18156 	majority_cnt_3_x_3_grid = int32(5)
  18157 	tmp = WebPSafeMalloc(tls, libc.Uint64FromInt32(w*h), uint64(1))
  18158 	// no overflow, as per spec
  18159 	if tmp == libc.UintptrFromInt32(0) {
  18160 		return
  18161 	}
  18162 	y = int32(1)
  18163 	for {
  18164 		if !(y < h-int32(1)) {
  18165 			break
  18166 		}
  18167 		x = int32(1)
  18168 		for {
  18169 			if !(x < w-int32(1)) {
  18170 				break
  18171 			}
  18172 			cnt = [4]int32{}
  18173 			mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(x+w*y)*4
  18174 			majority_seg = int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x60 >> 5))
  18175 			// Check the 8 neighbouring segment values.
  18176 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w-int32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w-int32(1))*4 + 0))&0x60>>5))] + 1                         // top-left
  18177 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w+0)*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w+0)*4 + 0))&0x60>>5))] + 1                                       // top
  18178 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w+int32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-w+int32(1))*4 + 0))&0x60>>5))] + 1                         // top-right
  18179 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-libc.Int32FromInt32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(-libc.Int32FromInt32(1))*4 + 0))&0x60>>5))] + 1 // left
  18180 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(+libc.Int32FromInt32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(+libc.Int32FromInt32(1))*4 + 0))&0x60>>5))] + 1 // right
  18181 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w-int32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w-int32(1))*4 + 0))&0x60>>5))] + 1                           // bottom-left
  18182 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w+0)*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w+0)*4 + 0))&0x60>>5))] + 1                                         // bottom
  18183 			cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w+int32(1))*4 + 0))&0x60>>5))] = cnt[int32(uint32(*(*uint8)(unsafe.Pointer(mb + uintptr(w+int32(1))*4 + 0))&0x60>>5))] + 1                           // bottom-right
  18184 			n = 0
  18185 			for {
  18186 				if !(n < int32(NUM_MB_SEGMENTS)) {
  18187 					break
  18188 				}
  18189 				if cnt[n] >= majority_cnt_3_x_3_grid {
  18190 					majority_seg = n
  18191 					break
  18192 				}
  18193 				goto _3
  18194 			_3:
  18195 				;
  18196 				n = n + 1
  18197 			}
  18198 			**(**uint8_t)(__ccgo_up(tmp + uintptr(x+y*w))) = libc.Uint8FromInt32(majority_seg)
  18199 			goto _2
  18200 		_2:
  18201 			;
  18202 			x = x + 1
  18203 		}
  18204 		goto _1
  18205 	_1:
  18206 		;
  18207 		y = y + 1
  18208 	}
  18209 	y = int32(1)
  18210 	for {
  18211 		if !(y < h-int32(1)) {
  18212 			break
  18213 		}
  18214 		x = int32(1)
  18215 		for {
  18216 			if !(x < w-int32(1)) {
  18217 				break
  18218 			}
  18219 			mb1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(x+w*y)*4
  18220 			libc.SetBitFieldPtr8Uint32(mb1+0, uint32(**(**uint8_t)(__ccgo_up(tmp + uintptr(x+y*w)))), 5, 0x60)
  18221 			goto _5
  18222 		_5:
  18223 			;
  18224 			x = x + 1
  18225 		}
  18226 		goto _4
  18227 	_4:
  18228 		;
  18229 		y = y + 1
  18230 	}
  18231 	WebPSafeFree(tls, tmp)
  18232 }
  18233 
  18234 //------------------------------------------------------------------------------
  18235 // set segment susceptibility 'alpha' / 'beta'
  18236 
  18237 func clip1(tls *libc.TLS, v int32, m int32, M int32) (r int32) {
  18238 	var v1, v2 int32
  18239 	_, _ = v1, v2
  18240 	if v < m {
  18241 		v1 = m
  18242 	} else {
  18243 		if v > M {
  18244 			v2 = M
  18245 		} else {
  18246 			v2 = v
  18247 		}
  18248 		v1 = v2
  18249 	}
  18250 	return v1
  18251 }
  18252 
  18253 func SetSegmentAlphas(tls *libc.TLS, enc uintptr, centers uintptr, mid int32) {
  18254 	var alpha, beta, max, min, n, nb int32
  18255 	_, _, _, _, _, _ = alpha, beta, max, min, n, nb
  18256 	nb = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  18257 	min = **(**int32)(__ccgo_up(centers))
  18258 	max = **(**int32)(__ccgo_up(centers))
  18259 	if nb > int32(1) {
  18260 		n = 0
  18261 		for {
  18262 			if !(n < nb) {
  18263 				break
  18264 			}
  18265 			if min > **(**int32)(__ccgo_up(centers + uintptr(n)*4)) {
  18266 				min = **(**int32)(__ccgo_up(centers + uintptr(n)*4))
  18267 			}
  18268 			if max < **(**int32)(__ccgo_up(centers + uintptr(n)*4)) {
  18269 				max = **(**int32)(__ccgo_up(centers + uintptr(n)*4))
  18270 			}
  18271 			goto _1
  18272 		_1:
  18273 			;
  18274 			n = n + 1
  18275 		}
  18276 	}
  18277 	if max == min {
  18278 		max = min + int32(1)
  18279 	}
  18280 	n = 0
  18281 	for {
  18282 		if !(n < nb) {
  18283 			break
  18284 		}
  18285 		alpha = int32(255) * (**(**int32)(__ccgo_up(centers + uintptr(n)*4)) - mid) / (max - min)
  18286 		beta = int32(255) * (**(**int32)(__ccgo_up(centers + uintptr(n)*4)) - min) / (max - min)
  18287 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(n)*744))).Falpha = clip1(tls, alpha, -int32(127), int32(127))
  18288 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(n)*744))).Fbeta = clip1(tls, beta, 0, int32(255))
  18289 		goto _2
  18290 	_2:
  18291 		;
  18292 		n = n + 1
  18293 	}
  18294 }
  18295 
  18296 //------------------------------------------------------------------------------
  18297 // Compute susceptibility based on DCT-coeff histograms:
  18298 // the higher, the "easier" the macroblock is to compress.
  18299 
  18300 func FinalAlphaValue(tls *libc.TLS, alpha int32) (r int32) {
  18301 	alpha = int32(MAX_ALPHA) - alpha
  18302 	return clip1(tls, alpha, 0, int32(MAX_ALPHA))
  18303 }
  18304 
  18305 func GetAlpha(tls *libc.TLS, histo uintptr) (r int32) {
  18306 	var alpha, last_non_zero, max_value, v1 int32
  18307 	_, _, _, _ = alpha, last_non_zero, max_value, v1
  18308 	// 'alpha' will later be clipped to [0..MAX_ALPHA] range, clamping outer
  18309 	// values which happen to be mostly noise. This leaves the maximum precision
  18310 	// for handling the useful small values which contribute most.
  18311 	max_value = (*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value
  18312 	last_non_zero = (*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero
  18313 	if max_value > int32(1) {
  18314 		v1 = libc.Int32FromInt32(2) * libc.Int32FromInt32(MAX_ALPHA) * last_non_zero / max_value
  18315 	} else {
  18316 		v1 = 0
  18317 	}
  18318 	alpha = v1
  18319 	return alpha
  18320 }
  18321 
  18322 func InitHistogram(tls *libc.TLS, histo uintptr) {
  18323 	(*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value = 0
  18324 	(*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero = int32(1)
  18325 }
  18326 
  18327 //------------------------------------------------------------------------------
  18328 // Simplified k-Means, to assign Nb segments based on alpha-histogram
  18329 
  18330 func AssignSegments(tls *libc.TLS, enc uintptr, alphas uintptr) {
  18331 	bp := tls.Alloc(48)
  18332 	defer tls.Free(48)
  18333 	var a, alpha, displaced, k, max_a, min_a, n, nb, new_center, range_a, smooth, total_weight, weighted_average, v1 int32
  18334 	var map1 [256]int32
  18335 	var mb uintptr
  18336 	var _ /* accum at bp+16 */ [4]int32
  18337 	var _ /* centers at bp+0 */ [4]int32
  18338 	var _ /* dist_accum at bp+32 */ [4]int32
  18339 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, alpha, displaced, k, map1, max_a, mb, min_a, n, nb, new_center, range_a, smooth, total_weight, weighted_average, v1
  18340 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments < int32(NUM_MB_SEGMENTS) {
  18341 		v1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  18342 	} else {
  18343 		v1 = int32(NUM_MB_SEGMENTS)
  18344 	}
  18345 	// 'num_segments' is previously validated and <= NUM_MB_SEGMENTS, but an
  18346 	// explicit check is needed to avoid spurious warning about 'n + 1' exceeding
  18347 	// array bounds of 'centers' with some compilers (noticed with gcc-4.9).
  18348 	nb = v1
  18349 	weighted_average = 0
  18350 	min_a = 0
  18351 	max_a = int32(MAX_ALPHA)
  18352 	// bracket the input
  18353 	n = 0
  18354 	for {
  18355 		if !(n <= int32(MAX_ALPHA) && **(**int32)(__ccgo_up(alphas + uintptr(n)*4)) == 0) {
  18356 			break
  18357 		}
  18358 		goto _2
  18359 	_2:
  18360 		;
  18361 		n = n + 1
  18362 	}
  18363 	min_a = n
  18364 	n = int32(MAX_ALPHA)
  18365 	for {
  18366 		if !(n > min_a && **(**int32)(__ccgo_up(alphas + uintptr(n)*4)) == 0) {
  18367 			break
  18368 		}
  18369 		goto _3
  18370 	_3:
  18371 		;
  18372 		n = n - 1
  18373 	}
  18374 	max_a = n
  18375 	range_a = max_a - min_a
  18376 	// Spread initial centers evenly
  18377 	k = 0
  18378 	n = libc.Int32FromInt32(1)
  18379 	for {
  18380 		if !(k < nb) {
  18381 			break
  18382 		}
  18383 		(**(**[4]int32)(__ccgo_up(bp)))[k] = min_a + n*range_a/(int32(2)*nb)
  18384 		goto _4
  18385 	_4:
  18386 		;
  18387 		k = k + 1
  18388 		n = n + int32(2)
  18389 	}
  18390 	k = 0
  18391 	for {
  18392 		if !(k < int32(MAX_ITERS_K_MEANS)) {
  18393 			break
  18394 		}
  18395 		// Reset stats
  18396 		n = 0
  18397 		for {
  18398 			if !(n < nb) {
  18399 				break
  18400 			}
  18401 			(**(**[4]int32)(__ccgo_up(bp + 16)))[n] = 0
  18402 			(**(**[4]int32)(__ccgo_up(bp + 32)))[n] = 0
  18403 			goto _6
  18404 		_6:
  18405 			;
  18406 			n = n + 1
  18407 		}
  18408 		// Assign nearest center for each 'a'
  18409 		n = 0 // track the nearest center for current 'a'
  18410 		a = min_a
  18411 		for {
  18412 			if !(a <= max_a) {
  18413 				break
  18414 			}
  18415 			if **(**int32)(__ccgo_up(alphas + uintptr(a)*4)) != 0 {
  18416 				for n+int32(1) < nb && libc.Xabs(tls, a-(**(**[4]int32)(__ccgo_up(bp)))[n+int32(1)]) < libc.Xabs(tls, a-(**(**[4]int32)(__ccgo_up(bp)))[n]) {
  18417 					n = n + 1
  18418 				}
  18419 				map1[a] = n
  18420 				// accumulate contribution into best centroid
  18421 				**(**int32)(__ccgo_up(bp + 32 + uintptr(n)*4)) += a * **(**int32)(__ccgo_up(alphas + uintptr(a)*4))
  18422 				**(**int32)(__ccgo_up(bp + 16 + uintptr(n)*4)) += **(**int32)(__ccgo_up(alphas + uintptr(a)*4))
  18423 			}
  18424 			goto _7
  18425 		_7:
  18426 			;
  18427 			a = a + 1
  18428 		}
  18429 		// All point are classified. Move the centroids to the
  18430 		// center of their respective cloud.
  18431 		displaced = 0
  18432 		weighted_average = 0
  18433 		total_weight = 0
  18434 		n = 0
  18435 		for {
  18436 			if !(n < nb) {
  18437 				break
  18438 			}
  18439 			if (**(**[4]int32)(__ccgo_up(bp + 16)))[n] != 0 {
  18440 				new_center = ((**(**[4]int32)(__ccgo_up(bp + 32)))[n] + (**(**[4]int32)(__ccgo_up(bp + 16)))[n]/int32(2)) / (**(**[4]int32)(__ccgo_up(bp + 16)))[n]
  18441 				displaced = displaced + libc.Xabs(tls, (**(**[4]int32)(__ccgo_up(bp)))[n]-new_center)
  18442 				(**(**[4]int32)(__ccgo_up(bp)))[n] = new_center
  18443 				weighted_average = weighted_average + new_center*(**(**[4]int32)(__ccgo_up(bp + 16)))[n]
  18444 				total_weight = total_weight + (**(**[4]int32)(__ccgo_up(bp + 16)))[n]
  18445 			}
  18446 			goto _8
  18447 		_8:
  18448 			;
  18449 			n = n + 1
  18450 		}
  18451 		weighted_average = (weighted_average + total_weight/int32(2)) / total_weight
  18452 		if displaced < int32(5) {
  18453 			break
  18454 		} // no need to keep on looping...
  18455 		goto _5
  18456 	_5:
  18457 		;
  18458 		k = k + 1
  18459 	}
  18460 	// Map each original value to the closest centroid
  18461 	n = 0
  18462 	for {
  18463 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  18464 			break
  18465 		}
  18466 		mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(n)*4
  18467 		alpha = libc.Int32FromUint8((*VP8MBInfo)(unsafe.Pointer(mb)).Falpha)
  18468 		libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(map1[alpha]), 5, 0x60)
  18469 		(*VP8MBInfo)(unsafe.Pointer(mb)).Falpha = libc.Uint8FromInt32((**(**[4]int32)(__ccgo_up(bp)))[map1[alpha]]) // for the record.
  18470 		goto _9
  18471 	_9:
  18472 		;
  18473 		n = n + 1
  18474 	}
  18475 	if nb > int32(1) {
  18476 		smooth = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpreprocessing & libc.Int32FromInt32(1)
  18477 		if smooth != 0 {
  18478 			SmoothSegmentMap(tls, enc)
  18479 		}
  18480 	}
  18481 	SetSegmentAlphas(tls, enc, bp, weighted_average) // pick some alphas.
  18482 }
  18483 
  18484 //------------------------------------------------------------------------------
  18485 // Macroblock analysis: collect histogram for each mode, deduce the maximal
  18486 // susceptibility and set best modes for this macroblock.
  18487 // Segment assignment is done later.
  18488 
  18489 // Number of modes to inspect for 'alpha' evaluation. We don't need to test all
  18490 // the possible modes during the analysis phase: we risk falling into a local
  18491 // optimum, or be subject to boundary effect
  18492 
  18493 func MBAnalyzeBestIntra16Mode(tls *libc.TLS, it uintptr) (r int32) {
  18494 	bp := tls.Alloc(16)
  18495 	defer tls.Free(16)
  18496 	var alpha, best_alpha, best_mode, max_mode, mode int32
  18497 	var _ /* histo at bp+0 */ VP8Histogram
  18498 	_, _, _, _, _ = alpha, best_alpha, best_mode, max_mode, mode
  18499 	max_mode = int32(MAX_INTRA16_MODE)
  18500 	best_alpha = -int32(1)
  18501 	best_mode = 0
  18502 	VP8MakeLuma16Preds(tls, it)
  18503 	mode = 0
  18504 	for {
  18505 		if !(mode < max_mode) {
  18506 			break
  18507 		}
  18508 		InitHistogram(tls, bp)
  18509 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8CollectHistogram})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p+uintptr(VP8I16ModeOffsets[mode]), 0, int32(16), bp)
  18510 		alpha = GetAlpha(tls, bp)
  18511 		if alpha > best_alpha {
  18512 			best_alpha = alpha
  18513 			best_mode = mode
  18514 		}
  18515 		goto _1
  18516 	_1:
  18517 		;
  18518 		mode = mode + 1
  18519 	}
  18520 	VP8SetIntra16Mode(tls, it, best_mode)
  18521 	return best_alpha
  18522 }
  18523 
  18524 func FastMBAnalyze(tls *libc.TLS, it uintptr) (r int32) {
  18525 	bp := tls.Alloc(80)
  18526 	defer tls.Free(80)
  18527 	var k, q int32
  18528 	var kThreshold, m, m2 uint32_t
  18529 	var _ /* dc at bp+0 */ [16]uint32_t
  18530 	var _ /* modes at bp+64 */ [16]uint8_t
  18531 	_, _, _, _, _ = k, kThreshold, m, m2, q
  18532 	// Empirical cut-off value, should be around 16 (~=block size). We use the
  18533 	// [8-17] range and favor intra4 at high quality, intra16 for low quality.
  18534 	q = int32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fconfig)).Fquality)
  18535 	kThreshold = libc.Uint32FromInt32(int32(8) + (libc.Int32FromInt32(17)-libc.Int32FromInt32(8))*q/int32(100))
  18536 	k = 0
  18537 	for {
  18538 		if !(k < int32(16)) {
  18539 			break
  18540 		}
  18541 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8Mean16x4})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(Y_OFF_ENC))+uintptr(k*int32(BPS)), bp+uintptr(k)*4)
  18542 		goto _1
  18543 	_1:
  18544 		;
  18545 		k = k + int32(4)
  18546 	}
  18547 	m = uint32(0)
  18548 	m2 = uint32(0)
  18549 	k = libc.Int32FromInt32(0)
  18550 	for {
  18551 		if !(k < int32(16)) {
  18552 			break
  18553 		}
  18554 		m = m + (**(**[16]uint32_t)(__ccgo_up(bp)))[k]
  18555 		m2 = m2 + (**(**[16]uint32_t)(__ccgo_up(bp)))[k]*(**(**[16]uint32_t)(__ccgo_up(bp)))[k]
  18556 		goto _2
  18557 	_2:
  18558 		;
  18559 		k = k + 1
  18560 	}
  18561 	if kThreshold*m2 < m*m {
  18562 		VP8SetIntra16Mode(tls, it, 0) // DC16
  18563 	} else {
  18564 		**(**[16]uint8_t)(__ccgo_up(bp + 64)) = [16]uint8_t{} // DC4
  18565 		VP8SetIntra4Mode(tls, it, bp+64)
  18566 	}
  18567 	return 0
  18568 }
  18569 
  18570 func MBAnalyzeBestUVMode(tls *libc.TLS, it uintptr) (r int32) {
  18571 	bp := tls.Alloc(16)
  18572 	defer tls.Free(16)
  18573 	var alpha, best_alpha, best_mode, max_mode, mode, smallest_alpha int32
  18574 	var _ /* histo at bp+0 */ VP8Histogram
  18575 	_, _, _, _, _, _ = alpha, best_alpha, best_mode, max_mode, mode, smallest_alpha
  18576 	best_alpha = -int32(1)
  18577 	smallest_alpha = 0
  18578 	best_mode = 0
  18579 	max_mode = int32(MAX_UV_MODE)
  18580 	VP8MakeChroma8Preds(tls, it)
  18581 	mode = 0
  18582 	for {
  18583 		if !(mode < max_mode) {
  18584 			break
  18585 		}
  18586 		InitHistogram(tls, bp)
  18587 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8CollectHistogram})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(U_OFF_ENC)), (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p+uintptr(VP8UVModeOffsets[mode]), int32(16), libc.Int32FromInt32(16)+libc.Int32FromInt32(4)+libc.Int32FromInt32(4), bp)
  18588 		alpha = GetAlpha(tls, bp)
  18589 		if alpha > best_alpha {
  18590 			best_alpha = alpha
  18591 		}
  18592 		// The best prediction mode tends to be the one with the smallest alpha.
  18593 		if mode == 0 || alpha < smallest_alpha {
  18594 			smallest_alpha = alpha
  18595 			best_mode = mode
  18596 		}
  18597 		goto _1
  18598 	_1:
  18599 		;
  18600 		mode = mode + 1
  18601 	}
  18602 	VP8SetIntraUVMode(tls, it, best_mode)
  18603 	return best_alpha
  18604 }
  18605 
  18606 func MBAnalyze(tls *libc.TLS, it uintptr, alphas uintptr, alpha uintptr, uv_alpha uintptr) {
  18607 	var best_alpha, best_uv_alpha int32
  18608 	var enc uintptr
  18609 	_, _, _ = best_alpha, best_uv_alpha, enc
  18610 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  18611 	VP8SetIntra16Mode(tls, it, 0) // default: Intra16, DC_PRED
  18612 	VP8SetSkip(tls, it, 0)        // not skipped
  18613 	VP8SetSegment(tls, it, 0)     // default segment, spec-wise.
  18614 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod <= int32(1) {
  18615 		best_alpha = FastMBAnalyze(tls, it)
  18616 	} else {
  18617 		best_alpha = MBAnalyzeBestIntra16Mode(tls, it)
  18618 	}
  18619 	best_uv_alpha = MBAnalyzeBestUVMode(tls, it)
  18620 	// Final susceptibility mix
  18621 	best_alpha = (int32(3)*best_alpha + best_uv_alpha + int32(2)) >> int32(2)
  18622 	best_alpha = FinalAlphaValue(tls, best_alpha)
  18623 	**(**int32)(__ccgo_up(alphas + uintptr(best_alpha)*4)) = **(**int32)(__ccgo_up(alphas + uintptr(best_alpha)*4)) + 1
  18624 	(*VP8MBInfo)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb)).Falpha = libc.Uint8FromInt32(best_alpha) // for later remapping.
  18625 	// Accumulate for later complexity analysis.
  18626 	**(**int32)(__ccgo_up(alpha)) += best_alpha // mixed susceptibility (not just luma)
  18627 	**(**int32)(__ccgo_up(uv_alpha)) += best_uv_alpha
  18628 }
  18629 
  18630 func DefaultMBInfo(tls *libc.TLS, mb uintptr) {
  18631 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(1), 0, 0x3) // I16x16
  18632 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 2, 0xc)
  18633 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 4, 0x10) // not skipped
  18634 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 5, 0x60) // default segment
  18635 	(*VP8MBInfo)(unsafe.Pointer(mb)).Falpha = uint8(0)
  18636 }
  18637 
  18638 //------------------------------------------------------------------------------
  18639 // Main analysis loop:
  18640 // Collect all susceptibilities for each macroblock and record their
  18641 // distribution in alphas[]. Segments is assigned a-posteriori, based on
  18642 // this histogram.
  18643 // We also pick an intra16 prediction mode, which shouldn't be considered
  18644 // final except for fast-encode settings. We can also pick some intra4 modes
  18645 // and decide intra4/intra16, but that's usually almost always a bad choice at
  18646 // this stage.
  18647 
  18648 func ResetAllMBInfo(tls *libc.TLS, enc uintptr) {
  18649 	var n int32
  18650 	_ = n
  18651 	n = 0
  18652 	for {
  18653 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  18654 			break
  18655 		}
  18656 		DefaultMBInfo(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info+uintptr(n)*4)
  18657 		goto _1
  18658 	_1:
  18659 		;
  18660 		n = n + 1
  18661 	}
  18662 	// Default susceptibilities.
  18663 	(**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Falpha = 0
  18664 	(**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Fbeta = 0
  18665 	// Note: we can't compute this 'alpha' / 'uv_alpha' -> set to default value.
  18666 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha = 0
  18667 	(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_alpha = 0
  18668 	WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+int32(20), enc+536)
  18669 }
  18670 
  18671 // C documentation
  18672 //
  18673 //	// struct used to collect job result
  18674 type SegmentJob = struct {
  18675 	Fworker         WebPWorker
  18676 	Falphas         [256]int32
  18677 	Falpha          int32
  18678 	Fuv_alpha       int32
  18679 	Fit             VP8EncIterator
  18680 	Fdelta_progress int32
  18681 }
  18682 
  18683 // C documentation
  18684 //
  18685 //	// main work call
  18686 func DoSegmentsJob(tls *libc.TLS, arg1 uintptr, arg2 uintptr) (r int32) {
  18687 	bp := tls.Alloc(64)
  18688 	defer tls.Free(64)
  18689 	var it, job, scratch uintptr
  18690 	var ok int32
  18691 	var _ /* tmp at bp+0 */ [63]uint8_t
  18692 	_, _, _, _ = it, job, ok, scratch
  18693 	job = arg1
  18694 	it = arg2
  18695 	ok = int32(1)
  18696 	if !(VP8IteratorIsDone(tls, it) != 0) {
  18697 		scratch = uintptr((uintptr_t(bp) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  18698 		for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, it) != 0 {
  18699 			// Let's pretend we have perfect lossless reconstruction.
  18700 			VP8IteratorImport(tls, it, scratch)
  18701 			MBAnalyze(tls, it, job+48, job+1072, job+1076)
  18702 			ok = VP8IteratorProgress(tls, it, (*SegmentJob)(unsafe.Pointer(job)).Fdelta_progress)
  18703 		}
  18704 	}
  18705 	return ok
  18706 }
  18707 
  18708 // C documentation
  18709 //
  18710 //	// initialize the job struct with some tasks to perform
  18711 func InitSegmentJob(tls *libc.TLS, enc uintptr, job uintptr, start_row int32, end_row int32) {
  18712 	var v1 int32
  18713 	_ = v1
  18714 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, job)
  18715 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fdata1 = job
  18716 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fdata2 = job + 1080
  18717 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fhook = __ccgo_fp(DoSegmentsJob)
  18718 	VP8IteratorInit(tls, enc, job+1080)
  18719 	VP8IteratorSetRow(tls, job+1080, start_row)
  18720 	VP8IteratorSetCountDown(tls, job+1080, (end_row-start_row)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)
  18721 	libc.X__builtin___memset_chk(tls, job+48, 0, uint64(1024), ^__predefined_size_t(0))
  18722 	(*SegmentJob)(unsafe.Pointer(job)).Falpha = 0
  18723 	(*SegmentJob)(unsafe.Pointer(job)).Fuv_alpha = 0
  18724 	// only one of both jobs can record the progress, since we don't
  18725 	// expect the user's hook to be multi-thread safe
  18726 	if start_row == 0 {
  18727 		v1 = int32(20)
  18728 	} else {
  18729 		v1 = 0
  18730 	}
  18731 	(*SegmentJob)(unsafe.Pointer(job)).Fdelta_progress = v1
  18732 }
  18733 
  18734 // C documentation
  18735 //
  18736 //	// main entry point
  18737 func VP8EncAnalyze(tls *libc.TLS, enc uintptr) (r int32) {
  18738 	bp := tls.Alloc(4944)
  18739 	defer tls.Free(4944)
  18740 	var do_mt, do_segments, last_row, ok, total_mb int32
  18741 	var worker_interface uintptr
  18742 	var _ /* main_job at bp+0 */ SegmentJob
  18743 	_, _, _, _, _, _ = do_mt, do_segments, last_row, ok, total_mb, worker_interface
  18744 	ok = int32(1)
  18745 	do_segments = libc.BoolInt32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Femulate_jpeg_size != 0 || (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments > int32(1) || (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod <= int32(1)) // for method 0 - 1, we need preds[] to be filled.
  18746 	if do_segments != 0 {
  18747 		last_row = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  18748 		total_mb = last_row * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w
  18749 		do_mt = 0
  18750 		worker_interface = WebPGetWorkerInterface(tls)
  18751 		if do_mt != 0 {
  18752 		} else {
  18753 			// Even for single-thread case, we use the generic Worker tools.
  18754 			InitSegmentJob(tls, enc, bp, 0, last_row)
  18755 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FExecute})))(tls, bp)
  18756 			ok = ok & (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp)
  18757 		}
  18758 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp)
  18759 		if ok != 0 {
  18760 			(*VP8Encoder)(unsafe.Pointer(enc)).Falpha = (**(**SegmentJob)(__ccgo_up(bp))).Falpha / total_mb
  18761 			(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_alpha = (**(**SegmentJob)(__ccgo_up(bp))).Fuv_alpha / total_mb
  18762 			AssignSegments(tls, enc, bp+48)
  18763 		}
  18764 	} else { // Use only one default segment.
  18765 		ResetAllMBInfo(tls, enc)
  18766 	}
  18767 	if !(ok != 0) {
  18768 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY)) // imprecise
  18769 	}
  18770 	return ok
  18771 }
  18772 
  18773 const COST_CACHE_INTERVAL_SIZE_MAX = 500
  18774 const COST_MANAGER_MAX_FREE_LIST = 10
  18775 const VALUES_IN_BYTE = 256
  18776 
  18777 var kHashMul10 = uint32(0x1e35a7bd)
  18778 
  18779 type CostModel = struct {
  18780 	Falpha    [256]uint32_t
  18781 	Fred      [256]uint32_t
  18782 	Fblue     [256]uint32_t
  18783 	Fdistance [40]uint32_t
  18784 	Fliteral  uintptr
  18785 }
  18786 
  18787 func ConvertPopulationCountTableToBitEstimates(tls *libc.TLS, num_symbols int32, population_counts uintptr, output uintptr) {
  18788 	var i, nonzeros int32
  18789 	var logsum, sum, v2, v3, v7, v8 uint32_t
  18790 	var v10, v5 uint32
  18791 	_, _, _, _, _, _, _, _, _, _ = i, logsum, nonzeros, sum, v10, v2, v3, v5, v7, v8
  18792 	sum = uint32(0)
  18793 	nonzeros = 0
  18794 	i = 0
  18795 	for {
  18796 		if !(i < num_symbols) {
  18797 			break
  18798 		}
  18799 		sum = sum + **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4))
  18800 		if **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4)) > uint32(0) {
  18801 			nonzeros = nonzeros + 1
  18802 		}
  18803 		goto _1
  18804 	_1:
  18805 		;
  18806 		i = i + 1
  18807 	}
  18808 	if nonzeros <= int32(1) {
  18809 		libc.X__builtin___memset_chk(tls, output, 0, libc.Uint64FromInt32(num_symbols)*uint64(4), ^__predefined_size_t(0))
  18810 	} else {
  18811 		v2 = sum
  18812 		if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  18813 			v5 = kLog2Table[v2]
  18814 		} else {
  18815 			v5 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v2)
  18816 		}
  18817 		v3 = v5
  18818 		goto _4
  18819 	_4:
  18820 		logsum = v3
  18821 		i = 0
  18822 		for {
  18823 			if !(i < num_symbols) {
  18824 				break
  18825 			}
  18826 			v7 = **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4))
  18827 			if v7 < uint32(LOG_LOOKUP_IDX_MAX) {
  18828 				v10 = kLog2Table[v7]
  18829 			} else {
  18830 				v10 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v7)
  18831 			}
  18832 			v8 = v10
  18833 			goto _9
  18834 		_9:
  18835 			**(**uint32_t)(__ccgo_up(output + uintptr(i)*4)) = logsum - v8
  18836 			goto _6
  18837 		_6:
  18838 			;
  18839 			i = i + 1
  18840 		}
  18841 	}
  18842 }
  18843 
  18844 func CostModelBuild(tls *libc.TLS, m uintptr, xsize int32, cache_bits int32, refs uintptr) (r int32) {
  18845 	var histo uintptr
  18846 	var ok, v1, v2, v4 int32
  18847 	_, _, _, _, _ = histo, ok, v1, v2, v4
  18848 	ok = 0
  18849 	histo = VP8LAllocateHistogram(tls, cache_bits)
  18850 	if histo == libc.UintptrFromInt32(0) {
  18851 		goto Error
  18852 	}
  18853 	// The following code is similar to VP8LHistogramCreate but converts the
  18854 	// distance to plane code.
  18855 	VP8LHistogramInit(tls, histo, cache_bits, int32(1))
  18856 	VP8LHistogramStoreRefs(tls, refs, __ccgo_fp(VP8LDistanceToPlaneCode), xsize, histo)
  18857 	v1 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  18858 	if v1 > 0 {
  18859 		v4 = int32(1) << v1
  18860 	} else {
  18861 		v4 = 0
  18862 	}
  18863 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  18864 	goto _3
  18865 _3:
  18866 	ConvertPopulationCountTableToBitEstimates(tls, v2, (*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral, (*CostModel)(unsafe.Pointer(m)).Fliteral)
  18867 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+8, m+1024)
  18868 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+1032, m+2048)
  18869 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+2056, m)
  18870 	ConvertPopulationCountTableToBitEstimates(tls, int32(NUM_DISTANCE_CODES), histo+3080, m+3072)
  18871 	ok = int32(1)
  18872 	goto Error
  18873 Error:
  18874 	;
  18875 	VP8LFreeHistogram(tls, histo)
  18876 	return ok
  18877 }
  18878 
  18879 func GetLiteralCost(tls *libc.TLS, m uintptr, v uint32_t) (r int64_t) {
  18880 	return libc.Int64FromUint32(**(**uint32_t)(__ccgo_up(m + uintptr(v>>int32(24))*4))) + libc.Int64FromUint32(**(**uint32_t)(__ccgo_up(m + 1024 + uintptr(v>>libc.Int32FromInt32(16)&uint32(0xff))*4))) + libc.Int64FromUint32(**(**uint32_t)(__ccgo_up((*CostModel)(unsafe.Pointer(m)).Fliteral + uintptr(v>>libc.Int32FromInt32(8)&uint32(0xff))*4))) + libc.Int64FromUint32(**(**uint32_t)(__ccgo_up(m + 2048 + uintptr(v&uint32(0xff))*4)))
  18881 }
  18882 
  18883 func GetCacheCost(tls *libc.TLS, m uintptr, idx uint32_t) (r int64_t) {
  18884 	var literal_idx int32
  18885 	_ = literal_idx
  18886 	literal_idx = libc.Int32FromUint32(libc.Uint32FromInt32(libc.Int32FromInt32(VALUES_IN_BYTE)+libc.Int32FromInt32(NUM_LENGTH_CODES)) + idx)
  18887 	return libc.Int64FromUint32(**(**uint32_t)(__ccgo_up((*CostModel)(unsafe.Pointer(m)).Fliteral + uintptr(literal_idx)*4)))
  18888 }
  18889 
  18890 func GetLengthCost(tls *libc.TLS, m uintptr, length uint32_t) (r int64_t) {
  18891 	bp := tls.Alloc(16)
  18892 	defer tls.Free(16)
  18893 	var highest_bit, second_highest_bit, v1, v4, v5, v6 int32
  18894 	var prefix_code VP8LPrefixCode
  18895 	var v2, v3 uintptr
  18896 	var _ /* code at bp+0 */ int32
  18897 	var _ /* extra_bits at bp+4 */ int32
  18898 	_, _, _, _, _, _, _, _, _ = highest_bit, prefix_code, second_highest_bit, v1, v2, v3, v4, v5, v6
  18899 	v1 = libc.Int32FromUint32(length)
  18900 	v2 = bp
  18901 	v3 = bp + 4
  18902 	if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  18903 		prefix_code = kPrefixEncodeCode[v1]
  18904 		**(**int32)(__ccgo_up(v2)) = int32(prefix_code.Fcode)
  18905 		**(**int32)(__ccgo_up(v3)) = int32(prefix_code.Fextra_bits)
  18906 	} else {
  18907 		v4 = v1
  18908 		v4 = v4 - 1
  18909 		v5 = v4
  18910 		v6 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  18911 		goto _7
  18912 	_7:
  18913 		highest_bit = v6
  18914 		second_highest_bit = v4 >> (highest_bit - int32(1)) & int32(1)
  18915 		**(**int32)(__ccgo_up(v3)) = highest_bit - int32(1)
  18916 		**(**int32)(__ccgo_up(v2)) = int32(2)*highest_bit + second_highest_bit
  18917 	}
  18918 	return libc.Int64FromUint32(**(**uint32_t)(__ccgo_up((*CostModel)(unsafe.Pointer(m)).Fliteral + uintptr(int32(VALUES_IN_BYTE)+**(**int32)(__ccgo_up(bp)))*4))) + int64(**(**int32)(__ccgo_up(bp + 4)))<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  18919 }
  18920 
  18921 func GetDistanceCost(tls *libc.TLS, m uintptr, distance2 uint32_t) (r int64_t) {
  18922 	bp := tls.Alloc(16)
  18923 	defer tls.Free(16)
  18924 	var highest_bit, second_highest_bit, v1, v4, v5, v6 int32
  18925 	var prefix_code VP8LPrefixCode
  18926 	var v2, v3 uintptr
  18927 	var _ /* code at bp+0 */ int32
  18928 	var _ /* extra_bits at bp+4 */ int32
  18929 	_, _, _, _, _, _, _, _, _ = highest_bit, prefix_code, second_highest_bit, v1, v2, v3, v4, v5, v6
  18930 	v1 = libc.Int32FromUint32(distance2)
  18931 	v2 = bp
  18932 	v3 = bp + 4
  18933 	if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  18934 		prefix_code = kPrefixEncodeCode[v1]
  18935 		**(**int32)(__ccgo_up(v2)) = int32(prefix_code.Fcode)
  18936 		**(**int32)(__ccgo_up(v3)) = int32(prefix_code.Fextra_bits)
  18937 	} else {
  18938 		v4 = v1
  18939 		v4 = v4 - 1
  18940 		v5 = v4
  18941 		v6 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  18942 		goto _7
  18943 	_7:
  18944 		highest_bit = v6
  18945 		second_highest_bit = v4 >> (highest_bit - int32(1)) & int32(1)
  18946 		**(**int32)(__ccgo_up(v3)) = highest_bit - int32(1)
  18947 		**(**int32)(__ccgo_up(v2)) = int32(2)*highest_bit + second_highest_bit
  18948 	}
  18949 	return libc.Int64FromUint32(**(**uint32_t)(__ccgo_up(m + 3072 + uintptr(**(**int32)(__ccgo_up(bp)))*4))) + int64(**(**int32)(__ccgo_up(bp + 4)))<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  18950 }
  18951 
  18952 func AddSingleLiteralWithCostModel(tls *libc.TLS, argb3 uintptr, hashers uintptr, cost_model uintptr, idx int32, use_color_cache int32, prev_cost int64_t, cost uintptr, dist_array uintptr) {
  18953 	var color, v3 uint32_t
  18954 	var cost_val, v10, v11, v9 int64_t
  18955 	var ix, key, key1, v1, v4, v6, v8 int32
  18956 	var v13 int64
  18957 	var v2 uintptr
  18958 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = color, cost_val, ix, key, key1, v1, v10, v11, v13, v2, v3, v4, v6, v8, v9
  18959 	cost_val = prev_cost
  18960 	color = **(**uint32_t)(__ccgo_up(argb3 + uintptr(idx)*4))
  18961 	if use_color_cache != 0 {
  18962 		v2 = hashers
  18963 		v3 = color
  18964 		v4 = libc.Int32FromUint32(v3 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  18965 		goto _5
  18966 	_5:
  18967 		key1 = v4
  18968 		if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key1)*4)) == v3 {
  18969 			v8 = key1
  18970 		} else {
  18971 			v8 = -int32(1)
  18972 		}
  18973 		v6 = v8
  18974 		goto _7
  18975 	_7:
  18976 		v1 = v6
  18977 	} else {
  18978 		v1 = -int32(1)
  18979 	}
  18980 	ix = v1
  18981 	if ix >= 0 {
  18982 		// use_color_cache is true and hashers contains color
  18983 		v9 = GetCacheCost(tls, cost_model, libc.Uint32FromInt32(ix)) * int64(68)
  18984 		v10 = int64(100)
  18985 		if libc.BoolInt32(v9 < 0) == libc.BoolInt32(v10 < 0) {
  18986 			v13 = (v9 + v10/int64(2)) / v10
  18987 		} else {
  18988 			v13 = (v9 - v10/int64(2)) / v10
  18989 		}
  18990 		v11 = v13
  18991 		goto _12
  18992 	_12:
  18993 		cost_val = cost_val + v11
  18994 	} else {
  18995 		if use_color_cache != 0 {
  18996 			v2 = hashers
  18997 			v3 = color
  18998 			v1 = libc.Int32FromUint32(v3 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  18999 			goto _17
  19000 		_17:
  19001 			key = v1
  19002 			**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key)*4)) = v3
  19003 		}
  19004 		v9 = GetLiteralCost(tls, cost_model, color) * int64(82)
  19005 		v10 = int64(100)
  19006 		if libc.BoolInt32(v9 < 0) == libc.BoolInt32(v10 < 0) {
  19007 			v13 = (v9 + v10/int64(2)) / v10
  19008 		} else {
  19009 			v13 = (v9 - v10/int64(2)) / v10
  19010 		}
  19011 		v11 = v13
  19012 		goto _21
  19013 	_21:
  19014 		cost_val = cost_val + v11
  19015 	}
  19016 	if **(**int64_t)(__ccgo_up(cost + uintptr(idx)*8)) > cost_val {
  19017 		**(**int64_t)(__ccgo_up(cost + uintptr(idx)*8)) = cost_val
  19018 		**(**uint16_t)(__ccgo_up(dist_array + uintptr(idx)*2)) = uint16(1) // only one is inserted.
  19019 	}
  19020 }
  19021 
  19022 // -----------------------------------------------------------------------------
  19023 // CostManager and interval handling
  19024 
  19025 // Empirical value to avoid high memory consumption but good for performance.
  19026 
  19027 // C documentation
  19028 //
  19029 //	// To perform backward reference every pixel at index 'index' is considered and
  19030 //	// the cost for the MAX_LENGTH following pixels computed. Those following pixels
  19031 //	// at index 'index' + k (k from 0 to MAX_LENGTH) have a cost of:
  19032 //	//     cost = distance cost at index + GetLengthCost(cost_model, k)
  19033 //	// and the minimum value is kept. GetLengthCost(cost_model, k) is cached in an
  19034 //	// array of size MAX_LENGTH.
  19035 //	// Instead of performing MAX_LENGTH comparisons per pixel, we keep track of the
  19036 //	// minimal values using intervals of constant cost.
  19037 //	// An interval is defined by the 'index' of the pixel that generated it and
  19038 //	// is only useful in a range of indices from 'start' to 'end' (exclusive), i.e.
  19039 //	// it contains the minimum value for pixels between start and end.
  19040 //	// Intervals are stored in a linked list and ordered by 'start'. When a new
  19041 //	// interval has a better value, old intervals are split or removed. There are
  19042 //	// therefore no overlapping intervals.
  19043 type CostInterval = struct {
  19044 	Fcost     int64_t
  19045 	Fstart    int32
  19046 	Fend      int32
  19047 	Findex    int32
  19048 	Fprevious uintptr
  19049 	Fnext     uintptr
  19050 }
  19051 
  19052 // C documentation
  19053 //
  19054 //	// The GetLengthCost(cost_model, k) are cached in a CostCacheInterval.
  19055 type CostCacheInterval = struct {
  19056 	Fcost  int64_t
  19057 	Fstart int32
  19058 	Fend   int32
  19059 }
  19060 
  19061 // C documentation
  19062 //
  19063 //	// This structure is in charge of managing intervals and costs.
  19064 //	// It caches the different CostCacheInterval, caches the different
  19065 //	// GetLengthCost(cost_model, k) in cost_cache and the CostInterval's (whose
  19066 //	// 'count' is limited by COST_CACHE_INTERVAL_SIZE_MAX).
  19067 type CostManager = struct {
  19068 	Fhead                 uintptr
  19069 	Fcount                int32
  19070 	Fcache_intervals      uintptr
  19071 	Fcache_intervals_size size_t
  19072 	Fcost_cache           [4095]int64_t
  19073 	Fcosts                uintptr
  19074 	Fdist_array           uintptr
  19075 	Fintervals            [10]CostInterval
  19076 	Ffree_intervals       uintptr
  19077 	Frecycled_intervals   uintptr
  19078 }
  19079 
  19080 func CostIntervalAddToFreeList(tls *libc.TLS, manager uintptr, interval uintptr) {
  19081 	(*CostInterval)(unsafe.Pointer(interval)).Fnext = (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals
  19082 	(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = interval
  19083 }
  19084 
  19085 func CostIntervalIsInFreeList(tls *libc.TLS, manager uintptr, interval uintptr) (r int32) {
  19086 	return libc.BoolInt32(interval >= manager+32808 && interval <= manager+32808+uintptr(libc.Int32FromInt32(COST_MANAGER_MAX_FREE_LIST)-libc.Int32FromInt32(1))*40)
  19087 }
  19088 
  19089 func CostManagerInitFreeList(tls *libc.TLS, manager uintptr) {
  19090 	var i int32
  19091 	_ = i
  19092 	(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = libc.UintptrFromInt32(0)
  19093 	i = 0
  19094 	for {
  19095 		if !(i < int32(COST_MANAGER_MAX_FREE_LIST)) {
  19096 			break
  19097 		}
  19098 		CostIntervalAddToFreeList(tls, manager, manager+32808+uintptr(i)*40)
  19099 		goto _1
  19100 	_1:
  19101 		;
  19102 		i = i + 1
  19103 	}
  19104 }
  19105 
  19106 func DeleteIntervalList(tls *libc.TLS, manager uintptr, interval uintptr) {
  19107 	var next uintptr
  19108 	_ = next
  19109 	for interval != libc.UintptrFromInt32(0) {
  19110 		next = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19111 		if !(CostIntervalIsInFreeList(tls, manager, interval) != 0) {
  19112 			WebPSafeFree(tls, interval)
  19113 		} // else: do nothing
  19114 		interval = next
  19115 	}
  19116 }
  19117 
  19118 func CostManagerClear(tls *libc.TLS, manager uintptr) {
  19119 	if manager == libc.UintptrFromInt32(0) {
  19120 		return
  19121 	}
  19122 	WebPSafeFree(tls, (*CostManager)(unsafe.Pointer(manager)).Fcosts)
  19123 	WebPSafeFree(tls, (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals)
  19124 	// Clear the interval lists.
  19125 	DeleteIntervalList(tls, manager, (*CostManager)(unsafe.Pointer(manager)).Fhead)
  19126 	(*CostManager)(unsafe.Pointer(manager)).Fhead = libc.UintptrFromInt32(0)
  19127 	DeleteIntervalList(tls, manager, (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals)
  19128 	(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = libc.UintptrFromInt32(0)
  19129 	// Reset pointers, 'count' and 'cache_intervals_size'.
  19130 	libc.X__builtin___memset_chk(tls, manager, 0, uint64(33224), ^__predefined_size_t(0))
  19131 	CostManagerInitFreeList(tls, manager)
  19132 }
  19133 
  19134 func CostManagerInit(tls *libc.TLS, manager uintptr, dist_array uintptr, pix_count int32, cost_model uintptr) (r int32) {
  19135 	var cost_cache_size, i, v1 int32
  19136 	var cost_val int64_t
  19137 	var cur uintptr
  19138 	_, _, _, _, _ = cost_cache_size, cost_val, cur, i, v1
  19139 	if pix_count > libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  19140 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  19141 	} else {
  19142 		v1 = pix_count
  19143 	}
  19144 	cost_cache_size = v1
  19145 	(*CostManager)(unsafe.Pointer(manager)).Fcosts = libc.UintptrFromInt32(0)
  19146 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals = libc.UintptrFromInt32(0)
  19147 	(*CostManager)(unsafe.Pointer(manager)).Fhead = libc.UintptrFromInt32(0)
  19148 	(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = libc.UintptrFromInt32(0)
  19149 	(*CostManager)(unsafe.Pointer(manager)).Fcount = 0
  19150 	(*CostManager)(unsafe.Pointer(manager)).Fdist_array = dist_array
  19151 	CostManagerInitFreeList(tls, manager)
  19152 	// Fill in the 'cost_cache'.
  19153 	// Has to be done in two passes due to a GCC bug on i686
  19154 	// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
  19155 	i = 0
  19156 	for {
  19157 		if !(i < cost_cache_size) {
  19158 			break
  19159 		}
  19160 		**(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8)) = GetLengthCost(tls, cost_model, libc.Uint32FromInt32(i))
  19161 		goto _2
  19162 	_2:
  19163 		;
  19164 		i = i + 1
  19165 	}
  19166 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size = uint64(1)
  19167 	i = int32(1)
  19168 	for {
  19169 		if !(i < cost_cache_size) {
  19170 			break
  19171 		}
  19172 		// Get the number of bound intervals.
  19173 		if **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8)) != **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i-int32(1))*8)) {
  19174 			(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size + 1
  19175 		}
  19176 		goto _3
  19177 	_3:
  19178 		;
  19179 		i = i + 1
  19180 	}
  19181 	// With the current cost model, we usually have below 20 intervals.
  19182 	// The worst case scenario with a cost model would be if every length has a
  19183 	// different cost, hence MAX_LENGTH but that is impossible with the current
  19184 	// implementation that spirals around a pixel.
  19185 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals = WebPSafeMalloc(tls, (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size, uint64(16))
  19186 	if (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals == libc.UintptrFromInt32(0) {
  19187 		CostManagerClear(tls, manager)
  19188 		return 0
  19189 	}
  19190 	// Fill in the 'cache_intervals'.
  19191 	cur = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals
  19192 	// Consecutive values in 'cost_cache' are compared and if a big enough
  19193 	// difference is found, a new interval is created and bounded.
  19194 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fstart = 0
  19195 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fend = int32(1)
  19196 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fcost = **(**int64_t)(__ccgo_up(manager + 32))
  19197 	i = int32(1)
  19198 	for {
  19199 		if !(i < cost_cache_size) {
  19200 			break
  19201 		}
  19202 		cost_val = **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8))
  19203 		if cost_val != (*CostCacheInterval)(unsafe.Pointer(cur)).Fcost {
  19204 			cur += 16
  19205 			// Initialize an interval.
  19206 			(*CostCacheInterval)(unsafe.Pointer(cur)).Fstart = i
  19207 			(*CostCacheInterval)(unsafe.Pointer(cur)).Fcost = cost_val
  19208 		}
  19209 		(*CostCacheInterval)(unsafe.Pointer(cur)).Fend = i + int32(1)
  19210 		goto _4
  19211 	_4:
  19212 		;
  19213 		i = i + 1
  19214 	}
  19215 	(*CostManager)(unsafe.Pointer(manager)).Fcosts = WebPSafeMalloc(tls, libc.Uint64FromInt32(pix_count), uint64(8))
  19216 	if (*CostManager)(unsafe.Pointer(manager)).Fcosts == libc.UintptrFromInt32(0) {
  19217 		CostManagerClear(tls, manager)
  19218 		return 0
  19219 	}
  19220 	// Set the initial 'costs' to INT64_MAX for every pixel as we will keep the
  19221 	// minimum.
  19222 	i = 0
  19223 	for {
  19224 		if !(i < pix_count) {
  19225 			break
  19226 		}
  19227 		**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  19228 		goto _5
  19229 	_5:
  19230 		;
  19231 		i = i + 1
  19232 	}
  19233 	return int32(1)
  19234 }
  19235 
  19236 // C documentation
  19237 //
  19238 //	// Given the cost and the position that define an interval, update the cost at
  19239 //	// pixel 'i' if it is smaller than the previously computed value.
  19240 func UpdateCost(tls *libc.TLS, manager uintptr, i int32, position int32, cost int64_t) {
  19241 	var k int32
  19242 	_ = k
  19243 	k = i - position
  19244 	if **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) > cost {
  19245 		**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) = cost
  19246 		**(**uint16_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fdist_array + uintptr(i)*2)) = libc.Uint16FromInt32(k + int32(1))
  19247 	}
  19248 }
  19249 
  19250 // C documentation
  19251 //
  19252 //	// Given the cost and the position that define an interval, update the cost for
  19253 //	// all the pixels between 'start' and 'end' excluded.
  19254 func UpdateCostPerInterval(tls *libc.TLS, manager uintptr, start int32, end int32, position int32, cost int64_t) {
  19255 	var i int32
  19256 	_ = i
  19257 	i = start
  19258 	for {
  19259 		if !(i < end) {
  19260 			break
  19261 		}
  19262 		UpdateCost(tls, manager, i, position, cost)
  19263 		goto _1
  19264 	_1:
  19265 		;
  19266 		i = i + 1
  19267 	}
  19268 }
  19269 
  19270 // C documentation
  19271 //
  19272 //	// Given two intervals, make 'prev' be the previous one of 'next' in 'manager'.
  19273 func ConnectIntervals(tls *libc.TLS, manager uintptr, prev uintptr, next uintptr) {
  19274 	if prev != libc.UintptrFromInt32(0) {
  19275 		(*CostInterval)(unsafe.Pointer(prev)).Fnext = next
  19276 	} else {
  19277 		(*CostManager)(unsafe.Pointer(manager)).Fhead = next
  19278 	}
  19279 	if next != libc.UintptrFromInt32(0) {
  19280 		(*CostInterval)(unsafe.Pointer(next)).Fprevious = prev
  19281 	}
  19282 }
  19283 
  19284 // C documentation
  19285 //
  19286 //	// Pop an interval in the manager.
  19287 func PopInterval(tls *libc.TLS, manager uintptr, interval uintptr) {
  19288 	if interval == libc.UintptrFromInt32(0) {
  19289 		return
  19290 	}
  19291 	ConnectIntervals(tls, manager, (*CostInterval)(unsafe.Pointer(interval)).Fprevious, (*CostInterval)(unsafe.Pointer(interval)).Fnext)
  19292 	if CostIntervalIsInFreeList(tls, manager, interval) != 0 {
  19293 		CostIntervalAddToFreeList(tls, manager, interval)
  19294 	} else { // recycle regularly malloc'd intervals too
  19295 		(*CostInterval)(unsafe.Pointer(interval)).Fnext = (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals
  19296 		(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = interval
  19297 	}
  19298 	(*CostManager)(unsafe.Pointer(manager)).Fcount = (*CostManager)(unsafe.Pointer(manager)).Fcount - 1
  19299 }
  19300 
  19301 // C documentation
  19302 //
  19303 //	// Update the cost at index i by going over all the stored intervals that
  19304 //	// overlap with i.
  19305 //	// If 'do_clean_intervals' is set to something different than 0, intervals that
  19306 //	// end before 'i' will be popped.
  19307 func UpdateCostAtIndex(tls *libc.TLS, manager uintptr, i int32, do_clean_intervals int32) {
  19308 	var current, next uintptr
  19309 	_, _ = current, next
  19310 	current = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19311 	for current != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(current)).Fstart <= i {
  19312 		next = (*CostInterval)(unsafe.Pointer(current)).Fnext
  19313 		if (*CostInterval)(unsafe.Pointer(current)).Fend <= i {
  19314 			if do_clean_intervals != 0 {
  19315 				// We have an outdated interval, remove it.
  19316 				PopInterval(tls, manager, current)
  19317 			}
  19318 		} else {
  19319 			UpdateCost(tls, manager, i, (*CostInterval)(unsafe.Pointer(current)).Findex, (*CostInterval)(unsafe.Pointer(current)).Fcost)
  19320 		}
  19321 		current = next
  19322 	}
  19323 }
  19324 
  19325 // C documentation
  19326 //
  19327 //	// Given a current orphan interval and its previous interval, before
  19328 //	// it was orphaned (which can be NULL), set it at the right place in the list
  19329 //	// of intervals using the 'start' ordering and the previous interval as a hint.
  19330 func PositionOrphanInterval(tls *libc.TLS, manager uintptr, current uintptr, previous uintptr) {
  19331 	if previous == libc.UintptrFromInt32(0) {
  19332 		previous = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19333 	}
  19334 	for previous != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(current)).Fstart < (*CostInterval)(unsafe.Pointer(previous)).Fstart {
  19335 		previous = (*CostInterval)(unsafe.Pointer(previous)).Fprevious
  19336 	}
  19337 	for previous != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(previous)).Fnext != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer((*CostInterval)(unsafe.Pointer(previous)).Fnext)).Fstart < (*CostInterval)(unsafe.Pointer(current)).Fstart {
  19338 		previous = (*CostInterval)(unsafe.Pointer(previous)).Fnext
  19339 	}
  19340 	if previous != libc.UintptrFromInt32(0) {
  19341 		ConnectIntervals(tls, manager, current, (*CostInterval)(unsafe.Pointer(previous)).Fnext)
  19342 	} else {
  19343 		ConnectIntervals(tls, manager, current, (*CostManager)(unsafe.Pointer(manager)).Fhead)
  19344 	}
  19345 	ConnectIntervals(tls, manager, previous, current)
  19346 }
  19347 
  19348 // C documentation
  19349 //
  19350 //	// Insert an interval in the list contained in the manager by starting at
  19351 //	// 'interval_in' as a hint. The intervals are sorted by 'start' value.
  19352 func InsertInterval(tls *libc.TLS, manager uintptr, interval_in uintptr, cost int64_t, position int32, start int32, end int32) {
  19353 	var interval_new uintptr
  19354 	_ = interval_new
  19355 	if start >= end {
  19356 		return
  19357 	}
  19358 	if (*CostManager)(unsafe.Pointer(manager)).Fcount >= int32(COST_CACHE_INTERVAL_SIZE_MAX) {
  19359 		// Serialize the interval if we cannot store it.
  19360 		UpdateCostPerInterval(tls, manager, start, end, position, cost)
  19361 		return
  19362 	}
  19363 	if (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals != libc.UintptrFromInt32(0) {
  19364 		interval_new = (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals
  19365 		(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = (*CostInterval)(unsafe.Pointer(interval_new)).Fnext
  19366 	} else {
  19367 		if (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals != libc.UintptrFromInt32(0) {
  19368 			interval_new = (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals
  19369 			(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = (*CostInterval)(unsafe.Pointer(interval_new)).Fnext
  19370 		} else { // malloc for good
  19371 			interval_new = WebPSafeMalloc(tls, uint64(1), uint64(40))
  19372 			if interval_new == libc.UintptrFromInt32(0) {
  19373 				// Write down the interval if we cannot create it.
  19374 				UpdateCostPerInterval(tls, manager, start, end, position, cost)
  19375 				return
  19376 			}
  19377 		}
  19378 	}
  19379 	(*CostInterval)(unsafe.Pointer(interval_new)).Fcost = cost
  19380 	(*CostInterval)(unsafe.Pointer(interval_new)).Findex = position
  19381 	(*CostInterval)(unsafe.Pointer(interval_new)).Fstart = start
  19382 	(*CostInterval)(unsafe.Pointer(interval_new)).Fend = end
  19383 	PositionOrphanInterval(tls, manager, interval_new, interval_in)
  19384 	(*CostManager)(unsafe.Pointer(manager)).Fcount = (*CostManager)(unsafe.Pointer(manager)).Fcount + 1
  19385 }
  19386 
  19387 // C documentation
  19388 //
  19389 //	// Given a new cost interval defined by its start at position, its length value
  19390 //	// and distance_cost, add its contributions to the previous intervals and costs.
  19391 //	// If handling the interval or one of its subintervals becomes to heavy, its
  19392 //	// contribution is added to the costs right away.
  19393 func PushInterval(tls *libc.TLS, manager uintptr, distance_cost int64_t, position int32, len1 int32) {
  19394 	var cost, cost_tmp int64_t
  19395 	var cost_cache_intervals, interval, interval_next uintptr
  19396 	var end, end_original, j, k, kSkipDistance, start, start_new, v3 int32
  19397 	var i size_t
  19398 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = cost, cost_cache_intervals, cost_tmp, end, end_original, i, interval, interval_next, j, k, kSkipDistance, start, start_new, v3
  19399 	interval = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19400 	cost_cache_intervals = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals
  19401 	// If the interval is small enough, no need to deal with the heavy
  19402 	// interval logic, just serialize it right away. This constant is empirical.
  19403 	kSkipDistance = int32(10)
  19404 	if len1 < kSkipDistance {
  19405 		j = position
  19406 		for {
  19407 			if !(j < position+len1) {
  19408 				break
  19409 			}
  19410 			k = j - position
  19411 			cost_tmp = distance_cost + **(**int64_t)(__ccgo_up(manager + 32 + uintptr(k)*8))
  19412 			if **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(j)*8)) > cost_tmp {
  19413 				**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(j)*8)) = cost_tmp
  19414 				**(**uint16_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fdist_array + uintptr(j)*2)) = libc.Uint16FromInt32(k + int32(1))
  19415 			}
  19416 			goto _1
  19417 		_1:
  19418 			;
  19419 			j = j + 1
  19420 		}
  19421 		return
  19422 	}
  19423 	i = uint64(0)
  19424 	for {
  19425 		if !(i < (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size && (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fstart < len1) {
  19426 			break
  19427 		}
  19428 		// Define the intersection of the ith interval with the new one.
  19429 		start = position + (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fstart
  19430 		if (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fend > len1 {
  19431 			v3 = len1
  19432 		} else {
  19433 			v3 = (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fend
  19434 		}
  19435 		end = position + v3
  19436 		cost = distance_cost + (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fcost
  19437 		for {
  19438 			if !(interval != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(interval)).Fstart < end) {
  19439 				break
  19440 			}
  19441 			interval_next = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19442 			// Make sure we have some overlap
  19443 			if start >= (*CostInterval)(unsafe.Pointer(interval)).Fend {
  19444 				goto _4
  19445 			}
  19446 			if cost >= (*CostInterval)(unsafe.Pointer(interval)).Fcost {
  19447 				// When intervals are represented, the lower, the better.
  19448 				// [**********************************************************[
  19449 				// start                                                    end
  19450 				//                   [----------------------------------[
  19451 				//                   interval->start        interval->end
  19452 				// If we are worse than what we already have, add whatever we have so
  19453 				// far up to interval.
  19454 				start_new = (*CostInterval)(unsafe.Pointer(interval)).Fend
  19455 				InsertInterval(tls, manager, interval, cost, position, start, (*CostInterval)(unsafe.Pointer(interval)).Fstart)
  19456 				start = start_new
  19457 				if start >= end {
  19458 					break
  19459 				}
  19460 				goto _4
  19461 			}
  19462 			if start <= (*CostInterval)(unsafe.Pointer(interval)).Fstart {
  19463 				if (*CostInterval)(unsafe.Pointer(interval)).Fend <= end {
  19464 					//                   [----------------------------------[
  19465 					//                   interval->start        interval->end
  19466 					// [**************************************************************[
  19467 					// start                                                        end
  19468 					// We can safely remove the old interval as it is fully included.
  19469 					PopInterval(tls, manager, interval)
  19470 				} else {
  19471 					//              [------------------------------------[
  19472 					//              interval->start          interval->end
  19473 					// [*****************************[
  19474 					// start                       end
  19475 					(*CostInterval)(unsafe.Pointer(interval)).Fstart = end
  19476 					break
  19477 				}
  19478 			} else {
  19479 				if end < (*CostInterval)(unsafe.Pointer(interval)).Fend {
  19480 					// [--------------------------------------------------------------[
  19481 					// interval->start                                    interval->end
  19482 					//                     [*****************************[
  19483 					//                     start                       end
  19484 					// We have to split the old interval as it fully contains the new one.
  19485 					end_original = (*CostInterval)(unsafe.Pointer(interval)).Fend
  19486 					(*CostInterval)(unsafe.Pointer(interval)).Fend = start
  19487 					InsertInterval(tls, manager, interval, (*CostInterval)(unsafe.Pointer(interval)).Fcost, (*CostInterval)(unsafe.Pointer(interval)).Findex, end, end_original)
  19488 					interval = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19489 					break
  19490 				} else {
  19491 					// [------------------------------------[
  19492 					// interval->start          interval->end
  19493 					//                     [*****************************[
  19494 					//                     start                       end
  19495 					(*CostInterval)(unsafe.Pointer(interval)).Fend = start
  19496 				}
  19497 			}
  19498 			goto _4
  19499 		_4:
  19500 			;
  19501 			interval = interval_next
  19502 		}
  19503 		// Insert the remaining interval from start to end.
  19504 		InsertInterval(tls, manager, interval, cost, position, start, end)
  19505 		goto _2
  19506 	_2:
  19507 		;
  19508 		i = i + 1
  19509 	}
  19510 }
  19511 
  19512 func BackwardReferencesHashChainDistanceOnly(tls *libc.TLS, xsize int32, ysize int32, argb uintptr, cache_bits int32, hash_chain uintptr, refs uintptr, dist_array uintptr) (r int32) {
  19513 	bp := tls.Alloc(32)
  19514 	defer tls.Free(32)
  19515 	var cc_init, code, first_offset_is_constant, i, j, len_prev, offset_prev, ok, pix_count, reach, use_color_cache, v1, v2, v4 int32
  19516 	var cost_manager, cost_model, v6 uintptr
  19517 	var cost_model_size, literal_array_size size_t
  19518 	var offset_cost, prev_cost int64_t
  19519 	var _ /* hashers at bp+0 */ VP8LColorCache
  19520 	var _ /* len at bp+20 */ int32
  19521 	var _ /* len_j at bp+28 */ int32
  19522 	var _ /* offset at bp+16 */ int32
  19523 	var _ /* offset_j at bp+24 */ int32
  19524 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cc_init, code, cost_manager, cost_model, cost_model_size, first_offset_is_constant, i, j, len_prev, literal_array_size, offset_cost, offset_prev, ok, pix_count, prev_cost, reach, use_color_cache, v1, v2, v4, v6
  19525 	ok = 0
  19526 	cc_init = 0
  19527 	pix_count = xsize * ysize
  19528 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  19529 	v1 = cache_bits
  19530 	if v1 > 0 {
  19531 		v4 = int32(1) << v1
  19532 	} else {
  19533 		v4 = 0
  19534 	}
  19535 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  19536 	goto _3
  19537 _3:
  19538 	literal_array_size = uint64(4) * libc.Uint64FromInt32(v2)
  19539 	cost_model_size = uint64(3240) + literal_array_size
  19540 	cost_model = WebPSafeCalloc(tls, uint64(1), cost_model_size)
  19541 	cost_manager = WebPSafeCalloc(tls, uint64(1), uint64(33224))
  19542 	offset_prev = -int32(1)
  19543 	len_prev = -int32(1)
  19544 	offset_cost = int64(-int32(1))
  19545 	first_offset_is_constant = -int32(1) // initialized with 'impossible' value
  19546 	reach = 0
  19547 	if cost_model == libc.UintptrFromInt32(0) || cost_manager == libc.UintptrFromInt32(0) {
  19548 		goto Error
  19549 	}
  19550 	(*CostModel)(unsafe.Pointer(cost_model)).Fliteral = cost_model + libc.UintptrFromInt32(1)*3240
  19551 	if use_color_cache != 0 {
  19552 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  19553 		if !(cc_init != 0) {
  19554 			goto Error
  19555 		}
  19556 	}
  19557 	if !(CostModelBuild(tls, cost_model, xsize, cache_bits, refs) != 0) {
  19558 		goto Error
  19559 	}
  19560 	if !(CostManagerInit(tls, cost_manager, dist_array, pix_count, cost_model) != 0) {
  19561 		goto Error
  19562 	}
  19563 	// We loop one pixel at a time, but store all currently best points to
  19564 	// non-processed locations from this point.
  19565 	**(**uint16_t)(__ccgo_up(dist_array)) = uint16(0)
  19566 	// Add first pixel as literal.
  19567 	AddSingleLiteralWithCostModel(tls, argb, bp, cost_model, 0, use_color_cache, 0, (*CostManager)(unsafe.Pointer(cost_manager)).Fcosts, dist_array)
  19568 	i = int32(1)
  19569 	for {
  19570 		if !(i < pix_count) {
  19571 			break
  19572 		}
  19573 		prev_cost = **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(cost_manager)).Fcosts + uintptr(i-int32(1))*8))
  19574 		v6 = hash_chain
  19575 		v1 = i
  19576 		v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19577 		goto _9
  19578 	_9:
  19579 		**(**int32)(__ccgo_up(bp + 16)) = v2
  19580 		v4 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  19581 		goto _11
  19582 	_11:
  19583 		**(**int32)(__ccgo_up(bp + 20)) = v4
  19584 		// Try adding the pixel as a literal.
  19585 		AddSingleLiteralWithCostModel(tls, argb, bp, cost_model, i, use_color_cache, prev_cost, (*CostManager)(unsafe.Pointer(cost_manager)).Fcosts, dist_array)
  19586 		// If we are dealing with a non-literal.
  19587 		if **(**int32)(__ccgo_up(bp + 20)) >= int32(2) {
  19588 			if **(**int32)(__ccgo_up(bp + 16)) != offset_prev {
  19589 				code = VP8LDistanceToPlaneCode(tls, xsize, **(**int32)(__ccgo_up(bp + 16)))
  19590 				offset_cost = GetDistanceCost(tls, cost_model, libc.Uint32FromInt32(code))
  19591 				first_offset_is_constant = int32(1)
  19592 				PushInterval(tls, cost_manager, prev_cost+offset_cost, i, **(**int32)(__ccgo_up(bp + 20)))
  19593 			} else {
  19594 				// Instead of considering all contributions from a pixel i by calling:
  19595 				//         PushInterval(cost_manager, prev_cost + offset_cost, i, len);
  19596 				// we optimize these contributions in case offset_cost stays the same
  19597 				// for consecutive pixels. This describes a set of pixels similar to a
  19598 				// previous set (e.g. constant color regions).
  19599 				if first_offset_is_constant != 0 {
  19600 					reach = i - int32(1) + len_prev - int32(1)
  19601 					first_offset_is_constant = 0
  19602 				}
  19603 				if i+**(**int32)(__ccgo_up(bp + 20))-int32(1) > reach {
  19604 					**(**int32)(__ccgo_up(bp + 28)) = 0
  19605 					// Figure out the last consecutive pixel within [i, reach + 1] with
  19606 					// the same offset.
  19607 					j = i
  19608 					for {
  19609 						if !(j <= reach) {
  19610 							break
  19611 						}
  19612 						v6 = hash_chain
  19613 						v1 = j + int32(1)
  19614 						v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19615 						goto _16
  19616 					_16:
  19617 						**(**int32)(__ccgo_up(bp + 24)) = v2
  19618 						v4 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  19619 						goto _18
  19620 					_18:
  19621 						**(**int32)(__ccgo_up(bp + 28)) = v4
  19622 						if **(**int32)(__ccgo_up(bp + 24)) != **(**int32)(__ccgo_up(bp + 16)) {
  19623 							v6 = hash_chain
  19624 							v1 = j
  19625 							v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19626 							goto _22
  19627 						_22:
  19628 							**(**int32)(__ccgo_up(bp + 24)) = v2
  19629 							v4 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  19630 							goto _24
  19631 						_24:
  19632 							**(**int32)(__ccgo_up(bp + 28)) = v4
  19633 							break
  19634 						}
  19635 						goto _12
  19636 					_12:
  19637 						;
  19638 						j = j + 1
  19639 					}
  19640 					// Update the cost at j - 1 and j.
  19641 					UpdateCostAtIndex(tls, cost_manager, j-int32(1), 0)
  19642 					UpdateCostAtIndex(tls, cost_manager, j, 0)
  19643 					PushInterval(tls, cost_manager, **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(cost_manager)).Fcosts + uintptr(j-int32(1))*8))+offset_cost, j, **(**int32)(__ccgo_up(bp + 28)))
  19644 					reach = j + **(**int32)(__ccgo_up(bp + 28)) - int32(1)
  19645 				}
  19646 			}
  19647 		}
  19648 		UpdateCostAtIndex(tls, cost_manager, i, int32(1))
  19649 		offset_prev = **(**int32)(__ccgo_up(bp + 16))
  19650 		len_prev = **(**int32)(__ccgo_up(bp + 20))
  19651 		goto _5
  19652 	_5:
  19653 		;
  19654 		i = i + 1
  19655 	}
  19656 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  19657 	goto Error
  19658 Error:
  19659 	;
  19660 	if cc_init != 0 {
  19661 		VP8LColorCacheClear(tls, bp)
  19662 	}
  19663 	CostManagerClear(tls, cost_manager)
  19664 	WebPSafeFree(tls, cost_model)
  19665 	WebPSafeFree(tls, cost_manager)
  19666 	return ok
  19667 }
  19668 
  19669 // C documentation
  19670 //
  19671 //	// We pack the path at the end of *dist_array and return
  19672 //	// a pointer to this part of the array. Example:
  19673 //	// dist_array = [1x2xx3x2] => packed [1x2x1232], chosen_path = [1232]
  19674 func TraceBackwards(tls *libc.TLS, dist_array uintptr, dist_array_size int32, chosen_path uintptr, chosen_path_size uintptr) {
  19675 	var cur, path uintptr
  19676 	var k int32
  19677 	_, _, _ = cur, k, path
  19678 	path = dist_array + uintptr(dist_array_size)*2
  19679 	cur = dist_array + uintptr(dist_array_size)*2 - uintptr(1)*2
  19680 	for cur >= dist_array {
  19681 		k = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(cur)))
  19682 		path -= 2
  19683 		**(**uint16_t)(__ccgo_up(path)) = libc.Uint16FromInt32(k)
  19684 		cur = cur - uintptr(k)*2
  19685 	}
  19686 	**(**uintptr)(__ccgo_up(chosen_path)) = path
  19687 	**(**int32)(__ccgo_up(chosen_path_size)) = int32((int64(dist_array+uintptr(dist_array_size)*2) - int64(path)) / 2)
  19688 }
  19689 
  19690 func BackwardReferencesHashChainFollowChosenPath(tls *libc.TLS, argb4 uintptr, cache_bits int32, chosen_path uintptr, chosen_path_size int32, hash_chain uintptr, refs uintptr) (r int32) {
  19691 	bp := tls.Alloc(16)
  19692 	defer tls.Free(16)
  19693 	var cc_init, i, idx1, ix, k, key, key1, len1, offset, ok, use_color_cache, v11, v14, v2, v9 int32
  19694 	var retval, retval1, retval2, v, v4 PixOrCopy
  19695 	var v7 uintptr
  19696 	var v8 uint32_t
  19697 	var _ /* hashers at bp+0 */ VP8LColorCache
  19698 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cc_init, i, idx1, ix, k, key, key1, len1, offset, ok, retval, retval1, retval2, use_color_cache, v, v11, v14, v2, v4, v7, v8, v9
  19699 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  19700 	i = 0
  19701 	ok = 0
  19702 	cc_init = 0
  19703 	if use_color_cache != 0 {
  19704 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  19705 		if !(cc_init != 0) {
  19706 			goto Error
  19707 		}
  19708 	}
  19709 	VP8LClearBackwardRefs(tls, refs)
  19710 	ix = 0
  19711 	for {
  19712 		if !(ix < chosen_path_size) {
  19713 			break
  19714 		}
  19715 		len1 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(chosen_path + uintptr(ix)*2)))
  19716 		if len1 != int32(1) {
  19717 			v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(i)*4)) >> int32(MAX_LENGTH_BITS))
  19718 			goto _3
  19719 		_3:
  19720 			offset = v2
  19721 			retval.Fmode = uint8(kCopy)
  19722 			retval.Fargb_or_distance = libc.Uint32FromInt32(offset)
  19723 			retval.Flen1 = libc.Uint16FromInt32(len1)
  19724 			v4 = retval
  19725 			goto _5
  19726 		_5:
  19727 			VP8LBackwardRefsCursorAdd(tls, refs, v4)
  19728 			if use_color_cache != 0 {
  19729 				k = 0
  19730 				for {
  19731 					if !(k < len1) {
  19732 						break
  19733 					}
  19734 					v7 = bp
  19735 					v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i+k)*4))
  19736 					v2 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19737 					goto _10
  19738 				_10:
  19739 					key = v2
  19740 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  19741 					goto _6
  19742 				_6:
  19743 					;
  19744 					k = k + 1
  19745 				}
  19746 			}
  19747 			i = i + len1
  19748 		} else {
  19749 			if use_color_cache != 0 {
  19750 				v7 = bp
  19751 				v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19752 				v9 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19753 				goto _15
  19754 			_15:
  19755 				key1 = v9
  19756 				if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key1)*4)) == v8 {
  19757 					v14 = key1
  19758 				} else {
  19759 					v14 = -int32(1)
  19760 				}
  19761 				v11 = v14
  19762 				goto _17
  19763 			_17:
  19764 				v2 = v11
  19765 			} else {
  19766 				v2 = -int32(1)
  19767 			}
  19768 			idx1 = v2
  19769 			if idx1 >= 0 {
  19770 				// use_color_cache is true and hashers contains argb[i]
  19771 				// push pixel as a color cache index
  19772 				retval1.Fmode = uint8(kCacheIdx)
  19773 				retval1.Fargb_or_distance = libc.Uint32FromInt32(idx1)
  19774 				retval1.Flen1 = uint16(1)
  19775 				v4 = retval1
  19776 				goto _20
  19777 			_20:
  19778 				v = v4
  19779 			} else {
  19780 				if use_color_cache != 0 {
  19781 					v7 = bp
  19782 					v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19783 					v2 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19784 					goto _24
  19785 				_24:
  19786 					key = v2
  19787 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  19788 				}
  19789 				retval2.Fmode = uint8(kLiteral)
  19790 				retval2.Fargb_or_distance = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19791 				retval2.Flen1 = uint16(1)
  19792 				v4 = retval2
  19793 				goto _26
  19794 			_26:
  19795 				v = v4
  19796 			}
  19797 			VP8LBackwardRefsCursorAdd(tls, refs, v)
  19798 			i = i + 1
  19799 		}
  19800 		goto _1
  19801 	_1:
  19802 		;
  19803 		ix = ix + 1
  19804 	}
  19805 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  19806 	goto Error
  19807 Error:
  19808 	;
  19809 	if cc_init != 0 {
  19810 		VP8LColorCacheClear(tls, bp)
  19811 	}
  19812 	return ok
  19813 }
  19814 
  19815 func VP8LBackwardReferencesTraceBackwards(tls *libc.TLS, xsize int32, ysize int32, argb uintptr, cache_bits int32, hash_chain uintptr, refs_src uintptr, refs_dst uintptr) (r int32) {
  19816 	bp := tls.Alloc(16)
  19817 	defer tls.Free(16)
  19818 	var dist_array uintptr
  19819 	var dist_array_size, ok int32
  19820 	var _ /* chosen_path at bp+0 */ uintptr
  19821 	var _ /* chosen_path_size at bp+8 */ int32
  19822 	_, _, _ = dist_array, dist_array_size, ok
  19823 	ok = 0
  19824 	dist_array_size = xsize * ysize
  19825 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  19826 	**(**int32)(__ccgo_up(bp + 8)) = 0
  19827 	dist_array = WebPSafeMalloc(tls, libc.Uint64FromInt32(dist_array_size), uint64(2))
  19828 	if dist_array == libc.UintptrFromInt32(0) {
  19829 		goto Error
  19830 	}
  19831 	if !(BackwardReferencesHashChainDistanceOnly(tls, xsize, ysize, argb, cache_bits, hash_chain, refs_src, dist_array) != 0) {
  19832 		goto Error
  19833 	}
  19834 	TraceBackwards(tls, dist_array, dist_array_size, bp, bp+8)
  19835 	if !(BackwardReferencesHashChainFollowChosenPath(tls, argb, cache_bits, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), hash_chain, refs_dst) != 0) {
  19836 		goto Error
  19837 	}
  19838 	ok = int32(1)
  19839 	goto Error
  19840 Error:
  19841 	;
  19842 	WebPSafeFree(tls, dist_array)
  19843 	return ok
  19844 }
  19845 
  19846 const MIN_BLOCK_SIZE = 256
  19847 const MIN_LENGTH = 4
  19848 const WINDOW_OFFSETS_SIZE_MAX = 32
  19849 
  19850 type PixOrCopyBlock = struct {
  19851 	Fnext  uintptr
  19852 	Fstart uintptr
  19853 	Fsize  int32
  19854 }
  19855 
  19856 var kHashMul11 = uint32(0x1e35a7bd)
  19857 
  19858 //------------------------------------------------------------------------------
  19859 
  19860 // Copyright 2012 Google Inc. All Rights Reserved.
  19861 //
  19862 // Use of this source code is governed by a BSD-style license
  19863 // that can be found in the COPYING file in the root of the source
  19864 // tree. An additional intellectual property rights grant can be found
  19865 // in the file PATENTS. All contributing project authors may
  19866 // be found in the AUTHORS file in the root of the source tree.
  19867 // -----------------------------------------------------------------------------
  19868 //
  19869 // Misc. common utility functions
  19870 //
  19871 // Authors: Skal (pascal.massimino@gmail.com)
  19872 //          Urvang (urvang@google.com)
  19873 
  19874 // Copyright 2011 Google Inc. All Rights Reserved.
  19875 //
  19876 // Use of this source code is governed by a BSD-style license
  19877 // that can be found in the COPYING file in the root of the source
  19878 // tree. An additional intellectual property rights grant can be found
  19879 // in the file PATENTS. All contributing project authors may
  19880 // be found in the AUTHORS file in the root of the source tree.
  19881 // -----------------------------------------------------------------------------
  19882 //
  19883 //   WebP encoder: main interface
  19884 //
  19885 // Author: Skal (pascal.massimino@gmail.com)
  19886 
  19887 // Copyright 2012 Google Inc. All Rights Reserved.
  19888 //
  19889 // Use of this source code is governed by a BSD-style license
  19890 // that can be found in the COPYING file in the root of the source
  19891 // tree. An additional intellectual property rights grant can be found
  19892 // in the file PATENTS. All contributing project authors may
  19893 // be found in the AUTHORS file in the root of the source tree.
  19894 // -----------------------------------------------------------------------------
  19895 //
  19896 //  Internal header for constants related to WebP file format.
  19897 //
  19898 // Author: Urvang (urvang@google.com)
  19899 
  19900 // Copyright 2010 Google Inc. All Rights Reserved.
  19901 //
  19902 // Use of this source code is governed by a BSD-style license
  19903 // that can be found in the COPYING file in the root of the source
  19904 // tree. An additional intellectual property rights grant can be found
  19905 // in the file PATENTS. All contributing project authors may
  19906 // be found in the AUTHORS file in the root of the source tree.
  19907 // -----------------------------------------------------------------------------
  19908 //
  19909 //  Common types + memory wrappers
  19910 //
  19911 // Author: Skal (pascal.massimino@gmail.com)
  19912 
  19913 // 1M window (4M bytes) minus 120 special codes for short distances.
  19914 
  19915 // Minimum number of pixels for which it is cheaper to encode a
  19916 // distance + length instead of each pixel as a literal.
  19917 
  19918 // -----------------------------------------------------------------------------
  19919 
  19920 var plane_to_code_lut = [128]uint8_t{
  19921 	0:   uint8(96),
  19922 	1:   uint8(73),
  19923 	2:   uint8(55),
  19924 	3:   uint8(39),
  19925 	4:   uint8(23),
  19926 	5:   uint8(13),
  19927 	6:   uint8(5),
  19928 	7:   uint8(1),
  19929 	8:   uint8(255),
  19930 	9:   uint8(255),
  19931 	10:  uint8(255),
  19932 	11:  uint8(255),
  19933 	12:  uint8(255),
  19934 	13:  uint8(255),
  19935 	14:  uint8(255),
  19936 	15:  uint8(255),
  19937 	16:  uint8(101),
  19938 	17:  uint8(78),
  19939 	18:  uint8(58),
  19940 	19:  uint8(42),
  19941 	20:  uint8(26),
  19942 	21:  uint8(16),
  19943 	22:  uint8(8),
  19944 	23:  uint8(2),
  19945 	25:  uint8(3),
  19946 	26:  uint8(9),
  19947 	27:  uint8(17),
  19948 	28:  uint8(27),
  19949 	29:  uint8(43),
  19950 	30:  uint8(59),
  19951 	31:  uint8(79),
  19952 	32:  uint8(102),
  19953 	33:  uint8(86),
  19954 	34:  uint8(62),
  19955 	35:  uint8(46),
  19956 	36:  uint8(32),
  19957 	37:  uint8(20),
  19958 	38:  uint8(10),
  19959 	39:  uint8(6),
  19960 	40:  uint8(4),
  19961 	41:  uint8(7),
  19962 	42:  uint8(11),
  19963 	43:  uint8(21),
  19964 	44:  uint8(33),
  19965 	45:  uint8(47),
  19966 	46:  uint8(63),
  19967 	47:  uint8(87),
  19968 	48:  uint8(105),
  19969 	49:  uint8(90),
  19970 	50:  uint8(70),
  19971 	51:  uint8(52),
  19972 	52:  uint8(37),
  19973 	53:  uint8(28),
  19974 	54:  uint8(18),
  19975 	55:  uint8(14),
  19976 	56:  uint8(12),
  19977 	57:  uint8(15),
  19978 	58:  uint8(19),
  19979 	59:  uint8(29),
  19980 	60:  uint8(38),
  19981 	61:  uint8(53),
  19982 	62:  uint8(71),
  19983 	63:  uint8(91),
  19984 	64:  uint8(110),
  19985 	65:  uint8(99),
  19986 	66:  uint8(82),
  19987 	67:  uint8(66),
  19988 	68:  uint8(48),
  19989 	69:  uint8(35),
  19990 	70:  uint8(30),
  19991 	71:  uint8(24),
  19992 	72:  uint8(22),
  19993 	73:  uint8(25),
  19994 	74:  uint8(31),
  19995 	75:  uint8(36),
  19996 	76:  uint8(49),
  19997 	77:  uint8(67),
  19998 	78:  uint8(83),
  19999 	79:  uint8(100),
  20000 	80:  uint8(115),
  20001 	81:  uint8(108),
  20002 	82:  uint8(94),
  20003 	83:  uint8(76),
  20004 	84:  uint8(64),
  20005 	85:  uint8(50),
  20006 	86:  uint8(44),
  20007 	87:  uint8(40),
  20008 	88:  uint8(34),
  20009 	89:  uint8(41),
  20010 	90:  uint8(45),
  20011 	91:  uint8(51),
  20012 	92:  uint8(65),
  20013 	93:  uint8(77),
  20014 	94:  uint8(95),
  20015 	95:  uint8(109),
  20016 	96:  uint8(118),
  20017 	97:  uint8(113),
  20018 	98:  uint8(103),
  20019 	99:  uint8(92),
  20020 	100: uint8(80),
  20021 	101: uint8(68),
  20022 	102: uint8(60),
  20023 	103: uint8(56),
  20024 	104: uint8(54),
  20025 	105: uint8(57),
  20026 	106: uint8(61),
  20027 	107: uint8(69),
  20028 	108: uint8(81),
  20029 	109: uint8(93),
  20030 	110: uint8(104),
  20031 	111: uint8(114),
  20032 	112: uint8(119),
  20033 	113: uint8(116),
  20034 	114: uint8(111),
  20035 	115: uint8(106),
  20036 	116: uint8(97),
  20037 	117: uint8(88),
  20038 	118: uint8(84),
  20039 	119: uint8(74),
  20040 	120: uint8(72),
  20041 	121: uint8(75),
  20042 	122: uint8(85),
  20043 	123: uint8(89),
  20044 	124: uint8(98),
  20045 	125: uint8(107),
  20046 	126: uint8(112),
  20047 	127: uint8(117),
  20048 }
  20049 
  20050 func VP8LDistanceToPlaneCode(tls *libc.TLS, xsize int32, dist int32) (r int32) {
  20051 	var xoffset, yoffset int32
  20052 	_, _ = xoffset, yoffset
  20053 	yoffset = dist / xsize
  20054 	xoffset = dist - yoffset*xsize
  20055 	if xoffset <= int32(8) && yoffset < int32(8) {
  20056 		return libc.Int32FromUint8(plane_to_code_lut[yoffset*int32(16)+int32(8)-xoffset]) + int32(1)
  20057 	} else {
  20058 		if xoffset > xsize-int32(8) && yoffset < int32(7) {
  20059 			return libc.Int32FromUint8(plane_to_code_lut[(yoffset+int32(1))*int32(16)+int32(8)+(xsize-xoffset)]) + int32(1)
  20060 		}
  20061 	}
  20062 	return dist + int32(120)
  20063 }
  20064 
  20065 // C documentation
  20066 //
  20067 //	// Returns the exact index where array1 and array2 are different. For an index
  20068 //	// inferior or equal to best_len_match, the return value just has to be strictly
  20069 //	// inferior to best_len_match. The current behavior is to return 0 if this index
  20070 //	// is best_len_match, and the index itself otherwise.
  20071 //	// If no two elements are the same, it returns max_limit.
  20072 func FindMatchLength(tls *libc.TLS, array1 uintptr, array2 uintptr, best_len_match int32, max_limit int32) (r int32) {
  20073 	// Before 'expensive' linear match, check if the two arrays match at the
  20074 	// current best length index.
  20075 	if **(**uint32_t)(__ccgo_up(array1 + uintptr(best_len_match)*4)) != **(**uint32_t)(__ccgo_up(array2 + uintptr(best_len_match)*4)) {
  20076 		return 0
  20077 	}
  20078 	return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{VP8LVectorMismatch})))(tls, array1, array2, max_limit)
  20079 }
  20080 
  20081 func VP8LClearBackwardRefs(tls *libc.TLS, refs uintptr) {
  20082 	if (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail != libc.UintptrFromInt32(0) {
  20083 		**(**uintptr)(__ccgo_up((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail)) = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks // recycle all blocks at once
  20084 	}
  20085 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs
  20086 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = refs + 8
  20087 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block = libc.UintptrFromInt32(0)
  20088 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs = libc.UintptrFromInt32(0)
  20089 }
  20090 
  20091 func VP8LBackwardRefsClear(tls *libc.TLS, refs uintptr) {
  20092 	var next uintptr
  20093 	_ = next
  20094 	VP8LClearBackwardRefs(tls, refs)
  20095 	for (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks != libc.UintptrFromInt32(0) {
  20096 		next = (*PixOrCopyBlock)(unsafe.Pointer((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks)).Fnext
  20097 		WebPSafeFree(tls, (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks)
  20098 		(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = next
  20099 	}
  20100 }
  20101 
  20102 // C documentation
  20103 //
  20104 //	// Swaps the content of two VP8LBackwardRefs.
  20105 func BackwardRefsSwap(tls *libc.TLS, refs1 uintptr, refs2 uintptr) {
  20106 	var point_to_refs1, point_to_refs2 int32
  20107 	var tmp VP8LBackwardRefs
  20108 	_, _, _ = point_to_refs1, point_to_refs2, tmp
  20109 	point_to_refs1 = libc.BoolInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail != libc.UintptrFromInt32(0) && (*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail == refs1+8)
  20110 	point_to_refs2 = libc.BoolInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail != libc.UintptrFromInt32(0) && (*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail == refs2+8)
  20111 	tmp = **(**VP8LBackwardRefs)(__ccgo_up(refs1))
  20112 	**(**VP8LBackwardRefs)(__ccgo_up(refs1)) = **(**VP8LBackwardRefs)(__ccgo_up(refs2))
  20113 	**(**VP8LBackwardRefs)(__ccgo_up(refs2)) = tmp
  20114 	if point_to_refs2 != 0 {
  20115 		(*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail = refs1 + 8
  20116 	}
  20117 	if point_to_refs1 != 0 {
  20118 		(*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail = refs2 + 8
  20119 	}
  20120 }
  20121 
  20122 func VP8LBackwardRefsInit(tls *libc.TLS, refs uintptr, block_size int32) {
  20123 	var v1 int32
  20124 	_ = v1
  20125 	libc.X__builtin___memset_chk(tls, refs, 0, uint64(40), ^__predefined_size_t(0))
  20126 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = refs + 8
  20127 	if block_size < int32(MIN_BLOCK_SIZE) {
  20128 		v1 = int32(MIN_BLOCK_SIZE)
  20129 	} else {
  20130 		v1 = block_size
  20131 	}
  20132 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size = v1
  20133 }
  20134 
  20135 func VP8LRefsCursorInit(tls *libc.TLS, refs uintptr) (r VP8LRefsCursor) {
  20136 	var c VP8LRefsCursor
  20137 	_ = c
  20138 	c.Fcur_block = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs
  20139 	if (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs != libc.UintptrFromInt32(0) {
  20140 		c.Fcur_pos = (*PixOrCopyBlock)(unsafe.Pointer(c.Fcur_block)).Fstart
  20141 		c.Flast_pos = c.Fcur_pos + uintptr((*PixOrCopyBlock)(unsafe.Pointer(c.Fcur_block)).Fsize)*8
  20142 	} else {
  20143 		c.Fcur_pos = libc.UintptrFromInt32(0)
  20144 		c.Flast_pos = libc.UintptrFromInt32(0)
  20145 	}
  20146 	return c
  20147 }
  20148 
  20149 func VP8LRefsCursorNextBlock(tls *libc.TLS, c uintptr) {
  20150 	var b, v1 uintptr
  20151 	_, _ = b, v1
  20152 	b = (*PixOrCopyBlock)(unsafe.Pointer((*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_block)).Fnext
  20153 	if b == libc.UintptrFromInt32(0) {
  20154 		v1 = libc.UintptrFromInt32(0)
  20155 	} else {
  20156 		v1 = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart
  20157 	}
  20158 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_pos = v1
  20159 	if b == libc.UintptrFromInt32(0) {
  20160 		v1 = libc.UintptrFromInt32(0)
  20161 	} else {
  20162 		v1 = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart + uintptr((*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize)*8
  20163 	}
  20164 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Flast_pos = v1
  20165 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_block = b
  20166 }
  20167 
  20168 // C documentation
  20169 //
  20170 //	// Create a new block, either from the free list or allocated
  20171 func BackwardRefsNewBlock(tls *libc.TLS, refs uintptr) (r uintptr) {
  20172 	var b uintptr
  20173 	var total_size size_t
  20174 	_, _ = b, total_size
  20175 	b = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks
  20176 	if b == libc.UintptrFromInt32(0) { // allocate new memory chunk
  20177 		total_size = uint64(24) + libc.Uint64FromInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size)*uint64(8)
  20178 		b = WebPSafeMalloc(tls, uint64(1), total_size)
  20179 		if b == libc.UintptrFromInt32(0) {
  20180 			**(**int32)(__ccgo_up(refs + 4)) |= int32(1)
  20181 			return libc.UintptrFromInt32(0)
  20182 		}
  20183 		(*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart = b + libc.UintptrFromInt64(24) // not always aligned
  20184 	} else { // recycle from free-list
  20185 		(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fnext
  20186 	}
  20187 	**(**uintptr)(__ccgo_up((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail)) = b
  20188 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = b
  20189 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block = b
  20190 	(*PixOrCopyBlock)(unsafe.Pointer(b)).Fnext = libc.UintptrFromInt32(0)
  20191 	(*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize = 0
  20192 	return b
  20193 }
  20194 
  20195 // C documentation
  20196 //
  20197 //	// Return 1 on success, 0 on error.
  20198 func BackwardRefsClone(tls *libc.TLS, from uintptr, to uintptr) (r int32) {
  20199 	var block_from, block_to uintptr
  20200 	_, _ = block_from, block_to
  20201 	block_from = (*VP8LBackwardRefs)(unsafe.Pointer(from)).Frefs
  20202 	VP8LClearBackwardRefs(tls, to)
  20203 	for block_from != libc.UintptrFromInt32(0) {
  20204 		block_to = BackwardRefsNewBlock(tls, to)
  20205 		if block_to == libc.UintptrFromInt32(0) {
  20206 			return 0
  20207 		}
  20208 		libc.X__builtin___memcpy_chk(tls, (*PixOrCopyBlock)(unsafe.Pointer(block_to)).Fstart, (*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fstart, libc.Uint64FromInt32((*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fsize)*uint64(8), ^__predefined_size_t(0))
  20209 		(*PixOrCopyBlock)(unsafe.Pointer(block_to)).Fsize = (*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fsize
  20210 		block_from = (*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fnext
  20211 	}
  20212 	return int32(1)
  20213 }
  20214 
  20215 func VP8LBackwardRefsCursorAdd(tls *libc.TLS, refs uintptr, v PixOrCopy) {
  20216 	var b, v2 uintptr
  20217 	var v1 int32
  20218 	_, _, _ = b, v1, v2
  20219 	b = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block
  20220 	if b == libc.UintptrFromInt32(0) || (*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize == (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size {
  20221 		b = BackwardRefsNewBlock(tls, refs)
  20222 		if b == libc.UintptrFromInt32(0) {
  20223 			return
  20224 		} // refs->error is set
  20225 	}
  20226 	v2 = b + 16
  20227 	v1 = *(*int32)(unsafe.Pointer(v2))
  20228 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  20229 	**(**PixOrCopy)(__ccgo_up((*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart + uintptr(v1)*8)) = v
  20230 }
  20231 
  20232 // -----------------------------------------------------------------------------
  20233 // Hash chains
  20234 
  20235 func VP8LHashChainInit(tls *libc.TLS, p uintptr, size int32) (r int32) {
  20236 	(*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length = WebPSafeMalloc(tls, libc.Uint64FromInt32(size), uint64(4))
  20237 	if (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length == libc.UintptrFromInt32(0) {
  20238 		return 0
  20239 	}
  20240 	(*VP8LHashChain)(unsafe.Pointer(p)).Fsize = size
  20241 	return int32(1)
  20242 }
  20243 
  20244 func VP8LHashChainClear(tls *libc.TLS, p uintptr) {
  20245 	WebPSafeFree(tls, (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)
  20246 	(*VP8LHashChain)(unsafe.Pointer(p)).Fsize = 0
  20247 	(*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length = libc.UintptrFromInt32(0)
  20248 }
  20249 
  20250 // -----------------------------------------------------------------------------
  20251 
  20252 var kHashMultiplierHi = uint32(0xc6a4a793)
  20253 var kHashMultiplierLo = uint32(0x5bd1e996)
  20254 
  20255 func GetPixPairHash64(tls *libc.TLS, argb uintptr) (r uint32_t) {
  20256 	var key uint32_t
  20257 	_ = key
  20258 	key = **(**uint32_t)(__ccgo_up(argb + 1*4)) * kHashMultiplierHi
  20259 	key = key + **(**uint32_t)(__ccgo_up(argb))*kHashMultiplierLo
  20260 	key = key >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(HASH_BITS))
  20261 	return key
  20262 }
  20263 
  20264 // C documentation
  20265 //
  20266 //	// Returns the maximum number of hash chain lookups to do for a
  20267 //	// given compression quality. Return value in range [8, 86].
  20268 func GetMaxItersForQuality(tls *libc.TLS, quality int32) (r int32) {
  20269 	return int32(8) + quality*quality/int32(128)
  20270 }
  20271 
  20272 func GetWindowSizeForHashChain(tls *libc.TLS, quality int32, xsize int32) (r int32) {
  20273 	var max_window_size, v1, v2, v3 int32
  20274 	_, _, _, _ = max_window_size, v1, v2, v3
  20275 	if quality > int32(75) {
  20276 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS) - libc.Int32FromInt32(120)
  20277 	} else {
  20278 		if quality > int32(50) {
  20279 			v2 = xsize << int32(8)
  20280 		} else {
  20281 			if quality > int32(25) {
  20282 				v3 = xsize << int32(6)
  20283 			} else {
  20284 				v3 = xsize << int32(4)
  20285 			}
  20286 			v2 = v3
  20287 		}
  20288 		v1 = v2
  20289 	}
  20290 	max_window_size = v1
  20291 	if max_window_size > libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS)-libc.Int32FromInt32(120) {
  20292 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS) - libc.Int32FromInt32(120)
  20293 	} else {
  20294 		v1 = max_window_size
  20295 	}
  20296 	return v1
  20297 }
  20298 
  20299 func MaxFindCopyLength(tls *libc.TLS, len1 int32) (r int32) {
  20300 	var v1 int32
  20301 	_ = v1
  20302 	if len1 < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20303 		v1 = len1
  20304 	} else {
  20305 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  20306 	}
  20307 	return v1
  20308 }
  20309 
  20310 func VP8LHashChainFill(tls *libc.TLS, p uintptr, quality int32, argb uintptr, xsize int32, ysize int32, low_effort int32, pic uintptr, percent_range int32, percent uintptr) (r int32) {
  20311 	bp := tls.Alloc(16)
  20312 	defer tls.Free(16)
  20313 	var argb_comp, argb_comp_next, best_length, curr_length, curr_length1, iter, iter_max, length_max, max_len, min_pos, percent_start, pos, remaining_percent, size, v4 int32
  20314 	var argb_start, chain, hash_to_first_index uintptr
  20315 	var base_position, best_argb, best_distance, hash_code, len1, max_base_position, window_size, v1 uint32_t
  20316 	var v12 bool
  20317 	var v8 uint32
  20318 	var _ /* tmp at bp+0 */ [2]uint32_t
  20319 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = argb_comp, argb_comp_next, argb_start, base_position, best_argb, best_distance, best_length, chain, curr_length, curr_length1, hash_code, hash_to_first_index, iter, iter_max, len1, length_max, max_base_position, max_len, min_pos, percent_start, pos, remaining_percent, size, window_size, v1, v12, v4, v8
  20320 	size = xsize * ysize
  20321 	iter_max = GetMaxItersForQuality(tls, quality)
  20322 	window_size = libc.Uint32FromInt32(GetWindowSizeForHashChain(tls, quality, xsize))
  20323 	remaining_percent = percent_range
  20324 	percent_start = **(**int32)(__ccgo_up(percent))
  20325 	// Temporarily use the p->offset_length as a hash chain.
  20326 	chain = (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length
  20327 	if size <= int32(2) {
  20328 		v1 = libc.Uint32FromInt32(0)
  20329 		**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length + uintptr(size-int32(1))*4)) = v1
  20330 		**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)) = v1
  20331 		return int32(1)
  20332 	}
  20333 	hash_to_first_index = WebPSafeMalloc(tls, libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(HASH_BITS)), uint64(4))
  20334 	if hash_to_first_index == libc.UintptrFromInt32(0) {
  20335 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  20336 	}
  20337 	percent_range = remaining_percent / int32(2)
  20338 	remaining_percent = remaining_percent - percent_range
  20339 	// Set the int32_t array to -1.
  20340 	libc.X__builtin___memset_chk(tls, hash_to_first_index, int32(0xff), libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(HASH_BITS))*libc.Uint64FromInt64(4), ^__predefined_size_t(0))
  20341 	// Fill the chain linking pixels with the same hash.
  20342 	argb_comp = libc.BoolInt32(**(**uint32_t)(__ccgo_up(argb)) == **(**uint32_t)(__ccgo_up(argb + 1*4)))
  20343 	pos = 0
  20344 	for {
  20345 		if !(pos < size-int32(2)) {
  20346 			break
  20347 		}
  20348 		argb_comp_next = libc.BoolInt32(**(**uint32_t)(__ccgo_up(argb + uintptr(pos+int32(1))*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(pos+int32(2))*4)))
  20349 		if argb_comp != 0 && argb_comp_next != 0 {
  20350 			len1 = uint32(1)
  20351 			(**(**[2]uint32_t)(__ccgo_up(bp)))[0] = **(**uint32_t)(__ccgo_up(argb + uintptr(pos)*4))
  20352 			// Figure out how far the pixels are the same.
  20353 			// The last pixel has a different 64 bit hash, as its next pixel does
  20354 			// not have the same color, so we just need to get to the last pixel equal
  20355 			// to its follower.
  20356 			for pos+libc.Int32FromUint32(len1)+int32(2) < size && **(**uint32_t)(__ccgo_up(argb + uintptr(libc.Uint32FromInt32(pos)+len1+uint32(2))*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(pos)*4)) {
  20357 				len1 = len1 + 1
  20358 			}
  20359 			if len1 > libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1)) {
  20360 				// Skip the pixels that match for distance=1 and length>MAX_LENGTH
  20361 				// because they are linked to their predecessor and we automatically
  20362 				// check that in the main for loop below. Skipping means setting no
  20363 				// predecessor in the chain, hence -1.
  20364 				libc.X__builtin___memset_chk(tls, chain+uintptr(pos)*4, int32(0xff), uint64(len1-libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1)))*uint64(4), ^__predefined_size_t(0))
  20365 				pos = libc.Int32FromUint32(uint32(pos) + (len1 - libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1))))
  20366 				len1 = libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1))
  20367 			}
  20368 			// Process the rest of the hash chain.
  20369 			for len1 != 0 {
  20370 				v1 = len1
  20371 				len1 = len1 - 1
  20372 				(**(**[2]uint32_t)(__ccgo_up(bp)))[int32(1)] = v1
  20373 				hash_code = GetPixPairHash64(tls, bp)
  20374 				**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4))
  20375 				v4 = pos
  20376 				pos = pos + 1
  20377 				**(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4)) = v4
  20378 			}
  20379 			argb_comp = 0
  20380 		} else {
  20381 			// Just move one pixel forward.
  20382 			hash_code = GetPixPairHash64(tls, argb+uintptr(pos)*4)
  20383 			**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4))
  20384 			v4 = pos
  20385 			pos = pos + 1
  20386 			**(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4)) = v4
  20387 			argb_comp = argb_comp_next
  20388 		}
  20389 		if !(WebPReportProgress(tls, pic, percent_start+percent_range*pos/(size-int32(2)), percent) != 0) {
  20390 			WebPSafeFree(tls, hash_to_first_index)
  20391 			return 0
  20392 		}
  20393 		goto _2
  20394 	_2:
  20395 	}
  20396 	// Process the penultimate pixel.
  20397 	**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(GetPixPairHash64(tls, argb+uintptr(pos)*4))*4))
  20398 	WebPSafeFree(tls, hash_to_first_index)
  20399 	percent_start = percent_start + percent_range
  20400 	if !(WebPReportProgress(tls, pic, percent_start, percent) != 0) {
  20401 		return 0
  20402 	}
  20403 	percent_range = remaining_percent
  20404 	// Find the best match interval at each pixel, defined by an offset to the
  20405 	// pixel and a length. The right-most pixel cannot match anything to the right
  20406 	// (hence a best length of 0) and the left-most pixel nothing to the left
  20407 	// (hence an offset of 0).
  20408 	v1 = libc.Uint32FromInt32(0)
  20409 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length + uintptr(size-int32(1))*4)) = v1
  20410 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)) = v1
  20411 	base_position = libc.Uint32FromInt32(size - int32(2))
  20412 	for {
  20413 		if !(base_position > uint32(0)) {
  20414 			break
  20415 		}
  20416 		max_len = MaxFindCopyLength(tls, libc.Int32FromUint32(libc.Uint32FromInt32(size-int32(1))-base_position))
  20417 		argb_start = argb + uintptr(base_position)*4
  20418 		iter = iter_max
  20419 		best_length = 0
  20420 		best_distance = uint32(0)
  20421 		if base_position > window_size {
  20422 			v8 = base_position - window_size
  20423 		} else {
  20424 			v8 = uint32(0)
  20425 		}
  20426 		min_pos = libc.Int32FromUint32(v8)
  20427 		if max_len < int32(256) {
  20428 			v4 = max_len
  20429 		} else {
  20430 			v4 = int32(256)
  20431 		}
  20432 		length_max = v4
  20433 		pos = **(**int32_t)(__ccgo_up(chain + uintptr(base_position)*4))
  20434 		if !(low_effort != 0) {
  20435 			// Heuristic: use the comparison with the above line as an initialization.
  20436 			if base_position >= libc.Uint32FromInt32(xsize) {
  20437 				curr_length = FindMatchLength(tls, argb_start-uintptr(xsize)*4, argb_start, best_length, max_len)
  20438 				if curr_length > best_length {
  20439 					best_length = curr_length
  20440 					best_distance = libc.Uint32FromInt32(xsize)
  20441 				}
  20442 				iter = iter - 1
  20443 			}
  20444 			// Heuristic: compare to the previous pixel.
  20445 			curr_length = FindMatchLength(tls, argb_start-uintptr(1)*4, argb_start, best_length, max_len)
  20446 			if curr_length > best_length {
  20447 				best_length = curr_length
  20448 				best_distance = uint32(1)
  20449 			}
  20450 			iter = iter - 1
  20451 			// Skip the for loop if we already have the maximum.
  20452 			if best_length == libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20453 				pos = min_pos - int32(1)
  20454 			}
  20455 		}
  20456 		best_argb = **(**uint32_t)(__ccgo_up(argb_start + uintptr(best_length)*4))
  20457 		for {
  20458 			if v12 = pos >= min_pos; v12 {
  20459 				iter = iter - 1
  20460 				v4 = iter
  20461 			}
  20462 			if !(v12 && v4 != 0) {
  20463 				break
  20464 			}
  20465 			if **(**uint32_t)(__ccgo_up(argb + uintptr(pos+best_length)*4)) != best_argb {
  20466 				goto _10
  20467 			}
  20468 			curr_length1 = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{VP8LVectorMismatch})))(tls, argb+uintptr(pos)*4, argb_start, max_len)
  20469 			if best_length < curr_length1 {
  20470 				best_length = curr_length1
  20471 				best_distance = base_position - libc.Uint32FromInt32(pos)
  20472 				best_argb = **(**uint32_t)(__ccgo_up(argb_start + uintptr(best_length)*4))
  20473 				// Stop if we have reached a good enough length.
  20474 				if best_length >= length_max {
  20475 					break
  20476 				}
  20477 			}
  20478 			goto _10
  20479 		_10:
  20480 			;
  20481 			pos = **(**int32_t)(__ccgo_up(chain + uintptr(pos)*4))
  20482 		}
  20483 		// We have the best match but in case the two intervals continue matching
  20484 		// to the left, we have the best matches for the left-extended pixels.
  20485 		max_base_position = base_position
  20486 		for int32(1) != 0 {
  20487 			**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length + uintptr(base_position)*4)) = best_distance<<libc.Int32FromInt32(MAX_LENGTH_BITS) | libc.Uint32FromInt32(best_length)
  20488 			base_position = base_position - 1
  20489 			// Stop if we don't have a match or if we are out of bounds.
  20490 			if best_distance == uint32(0) || base_position == uint32(0) {
  20491 				break
  20492 			}
  20493 			// Stop if we cannot extend the matching intervals to the left.
  20494 			if base_position < best_distance || **(**uint32_t)(__ccgo_up(argb + uintptr(base_position-best_distance)*4)) != **(**uint32_t)(__ccgo_up(argb + uintptr(base_position)*4)) {
  20495 				break
  20496 			}
  20497 			// Stop if we are matching at its limit because there could be a closer
  20498 			// matching interval with the same maximum length. Then again, if the
  20499 			// matching interval is as close as possible (best_distance == 1), we will
  20500 			// never find anything better so let's continue.
  20501 			if best_length == libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) && best_distance != uint32(1) && base_position+libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1)) < max_base_position {
  20502 				break
  20503 			}
  20504 			if best_length < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20505 				best_length = best_length + 1
  20506 				max_base_position = base_position
  20507 			}
  20508 		}
  20509 		if !(WebPReportProgress(tls, pic, libc.Int32FromUint32(libc.Uint32FromInt32(percent_start)+libc.Uint32FromInt32(percent_range)*(libc.Uint32FromInt32(size-int32(2))-base_position)/libc.Uint32FromInt32(size-libc.Int32FromInt32(2))), percent) != 0) {
  20510 			return 0
  20511 		}
  20512 		goto _7
  20513 	_7:
  20514 	}
  20515 	return WebPReportProgress(tls, pic, percent_start+percent_range, percent)
  20516 }
  20517 
  20518 func AddSingleLiteral(tls *libc.TLS, pixel uint32_t, use_color_cache int32, hashers uintptr, refs uintptr) {
  20519 	var key2, v5 uint32_t
  20520 	var retval, retval1, v, v7 PixOrCopy
  20521 	var v1, v3 int32
  20522 	_, _, _, _, _, _, _, _ = key2, retval, retval1, v, v1, v3, v5, v7
  20523 	if use_color_cache != 0 {
  20524 		v3 = libc.Int32FromUint32(pixel * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(hashers)).Fhash_shift)
  20525 		goto _4
  20526 	_4:
  20527 		v1 = v3
  20528 		goto _2
  20529 	_2:
  20530 		key2 = libc.Uint32FromInt32(v1)
  20531 		v5 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(hashers)).Fcolors + uintptr(key2)*4))
  20532 		goto _6
  20533 	_6:
  20534 		if v5 == pixel {
  20535 			retval.Fmode = uint8(kCacheIdx)
  20536 			retval.Fargb_or_distance = libc.Uint32FromInt32(libc.Int32FromUint32(key2))
  20537 			retval.Flen1 = uint16(1)
  20538 			v7 = retval
  20539 			goto _8
  20540 		_8:
  20541 			v = v7
  20542 		} else {
  20543 			retval1.Fmode = uint8(kLiteral)
  20544 			retval1.Fargb_or_distance = pixel
  20545 			retval1.Flen1 = uint16(1)
  20546 			v7 = retval1
  20547 			goto _10
  20548 		_10:
  20549 			v = v7
  20550 			**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(hashers)).Fcolors + uintptr(key2)*4)) = pixel
  20551 		}
  20552 	} else {
  20553 		retval1.Fmode = uint8(kLiteral)
  20554 		retval1.Fargb_or_distance = pixel
  20555 		retval1.Flen1 = uint16(1)
  20556 		v7 = retval1
  20557 		goto _12
  20558 	_12:
  20559 		v = v7
  20560 	}
  20561 	VP8LBackwardRefsCursorAdd(tls, refs, v)
  20562 }
  20563 
  20564 func BackwardReferencesRle(tls *libc.TLS, xsize int32, ysize int32, argb2 uintptr, cache_bits int32, refs uintptr) (r int32) {
  20565 	bp := tls.Alloc(16)
  20566 	defer tls.Free(16)
  20567 	var i, k, key, max_len, pix_count, prev_row_len, rle_len, use_color_cache, v1 int32
  20568 	var retval, v2 PixOrCopy
  20569 	var v7 uintptr
  20570 	var v8 uint32_t
  20571 	var _ /* hashers at bp+0 */ VP8LColorCache
  20572 	_, _, _, _, _, _, _, _, _, _, _, _, _ = i, k, key, max_len, pix_count, prev_row_len, retval, rle_len, use_color_cache, v1, v2, v7, v8
  20573 	pix_count = xsize * ysize
  20574 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  20575 	if use_color_cache != 0 && !(VP8LColorCacheInit(tls, bp, cache_bits) != 0) {
  20576 		return 0
  20577 	}
  20578 	VP8LClearBackwardRefs(tls, refs)
  20579 	// Add first pixel as literal.
  20580 	AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2)), use_color_cache, bp, refs)
  20581 	i = int32(1)
  20582 	for i < pix_count {
  20583 		max_len = MaxFindCopyLength(tls, pix_count-i)
  20584 		rle_len = FindMatchLength(tls, argb2+uintptr(i)*4, argb2+uintptr(i)*4-uintptr(1)*4, 0, max_len)
  20585 		if i < xsize {
  20586 			v1 = 0
  20587 		} else {
  20588 			v1 = FindMatchLength(tls, argb2+uintptr(i)*4, argb2+uintptr(i)*4-uintptr(xsize)*4, 0, max_len)
  20589 		}
  20590 		prev_row_len = v1
  20591 		if rle_len >= prev_row_len && rle_len >= int32(MIN_LENGTH) {
  20592 			retval.Fmode = uint8(kCopy)
  20593 			retval.Fargb_or_distance = uint32(1)
  20594 			retval.Flen1 = libc.Uint16FromInt32(rle_len)
  20595 			v2 = retval
  20596 			goto _3
  20597 		_3:
  20598 			VP8LBackwardRefsCursorAdd(tls, refs, v2)
  20599 			// We don't need to update the color cache here since it is always the
  20600 			// same pixel being copied, and that does not change the color cache
  20601 			// state.
  20602 			i = i + rle_len
  20603 		} else {
  20604 			if prev_row_len >= int32(MIN_LENGTH) {
  20605 				retval.Fmode = uint8(kCopy)
  20606 				retval.Fargb_or_distance = libc.Uint32FromInt32(xsize)
  20607 				retval.Flen1 = libc.Uint16FromInt32(prev_row_len)
  20608 				v2 = retval
  20609 				goto _5
  20610 			_5:
  20611 				VP8LBackwardRefsCursorAdd(tls, refs, v2)
  20612 				if use_color_cache != 0 {
  20613 					k = 0
  20614 					for {
  20615 						if !(k < prev_row_len) {
  20616 							break
  20617 						}
  20618 						v7 = bp
  20619 						v8 = **(**uint32_t)(__ccgo_up(argb2 + uintptr(i+k)*4))
  20620 						v1 = libc.Int32FromUint32(v8 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  20621 						goto _10
  20622 					_10:
  20623 						key = v1
  20624 						**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  20625 						goto _6
  20626 					_6:
  20627 						;
  20628 						k = k + 1
  20629 					}
  20630 				}
  20631 				i = i + prev_row_len
  20632 			} else {
  20633 				AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2 + uintptr(i)*4)), use_color_cache, bp, refs)
  20634 				i = i + 1
  20635 			}
  20636 		}
  20637 	}
  20638 	if use_color_cache != 0 {
  20639 		VP8LColorCacheClear(tls, bp)
  20640 	}
  20641 	return libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  20642 }
  20643 
  20644 func BackwardReferencesLz77(tls *libc.TLS, xsize int32, ysize int32, argb2 uintptr, cache_bits int32, hash_chain uintptr, refs uintptr) (r int32) {
  20645 	bp := tls.Alloc(32)
  20646 	defer tls.Free(32)
  20647 	var cc_init, i, i_last_check, j, j_max, key, len_ini, len_j, max_reach, ok, pix_count, reach, use_color_cache, v3, v4, v6 int32
  20648 	var retval, v14 PixOrCopy
  20649 	var v2 uintptr
  20650 	var v18 uint32_t
  20651 	var _ /* hashers at bp+0 */ VP8LColorCache
  20652 	var _ /* len at bp+20 */ int32
  20653 	var _ /* offset at bp+16 */ int32
  20654 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cc_init, i, i_last_check, j, j_max, key, len_ini, len_j, max_reach, ok, pix_count, reach, retval, use_color_cache, v14, v18, v2, v3, v4, v6
  20655 	i_last_check = -int32(1)
  20656 	ok = 0
  20657 	cc_init = 0
  20658 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  20659 	pix_count = xsize * ysize
  20660 	if use_color_cache != 0 {
  20661 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  20662 		if !(cc_init != 0) {
  20663 			goto Error
  20664 		}
  20665 	}
  20666 	VP8LClearBackwardRefs(tls, refs)
  20667 	i = 0
  20668 	for {
  20669 		if !(i < pix_count) {
  20670 			break
  20671 		}
  20672 		// Alternative#1: Code the pixels starting at 'i' using backward reference.
  20673 		**(**int32)(__ccgo_up(bp + 16)) = 0
  20674 		**(**int32)(__ccgo_up(bp + 20)) = 0
  20675 		v2 = hash_chain
  20676 		v3 = i
  20677 		v4 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v2)).Foffset_length + uintptr(v3)*4)) >> int32(MAX_LENGTH_BITS))
  20678 		goto _5
  20679 	_5:
  20680 		**(**int32)(__ccgo_up(bp + 16)) = v4
  20681 		v6 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v2)).Foffset_length + uintptr(v3)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  20682 		goto _7
  20683 	_7:
  20684 		**(**int32)(__ccgo_up(bp + 20)) = v6
  20685 		if **(**int32)(__ccgo_up(bp + 20)) >= int32(MIN_LENGTH) {
  20686 			len_ini = **(**int32)(__ccgo_up(bp + 20))
  20687 			max_reach = 0
  20688 			if i+len_ini >= pix_count {
  20689 				v3 = pix_count - int32(1)
  20690 			} else {
  20691 				v3 = i + len_ini
  20692 			}
  20693 			j_max = v3
  20694 			// Only start from what we have not checked already.
  20695 			if i > i_last_check {
  20696 				v4 = i
  20697 			} else {
  20698 				v4 = i_last_check
  20699 			}
  20700 			i_last_check = v4
  20701 			// We know the best match for the current pixel but we try to find the
  20702 			// best matches for the current pixel AND the next one combined.
  20703 			// The naive method would use the intervals:
  20704 			// [i,i+len) + [i+len, length of best match at i+len)
  20705 			// while we check if we can use:
  20706 			// [i,j) (where j<=i+len) + [j, length of best match at j)
  20707 			j = i_last_check + int32(1)
  20708 			for {
  20709 				if !(j <= j_max) {
  20710 					break
  20711 				}
  20712 				v3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(j)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  20713 				goto _12
  20714 			_12:
  20715 				len_j = v3
  20716 				if len_j >= int32(MIN_LENGTH) {
  20717 					v4 = len_j
  20718 				} else {
  20719 					v4 = int32(1)
  20720 				}
  20721 				reach = j + v4 // 1 for single literal.
  20722 				if reach > max_reach {
  20723 					**(**int32)(__ccgo_up(bp + 20)) = j - i
  20724 					max_reach = reach
  20725 					if max_reach >= pix_count {
  20726 						break
  20727 					}
  20728 				}
  20729 				goto _10
  20730 			_10:
  20731 				;
  20732 				j = j + 1
  20733 			}
  20734 		} else {
  20735 			**(**int32)(__ccgo_up(bp + 20)) = int32(1)
  20736 		}
  20737 		// Go with literal or backward reference.
  20738 		if **(**int32)(__ccgo_up(bp + 20)) == int32(1) {
  20739 			AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2 + uintptr(i)*4)), use_color_cache, bp, refs)
  20740 		} else {
  20741 			retval.Fmode = uint8(kCopy)
  20742 			retval.Fargb_or_distance = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 16)))
  20743 			retval.Flen1 = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp + 20)))
  20744 			v14 = retval
  20745 			goto _15
  20746 		_15:
  20747 			VP8LBackwardRefsCursorAdd(tls, refs, v14)
  20748 			if use_color_cache != 0 {
  20749 				j = i
  20750 				for {
  20751 					if !(j < i+**(**int32)(__ccgo_up(bp + 20))) {
  20752 						break
  20753 					}
  20754 					v2 = bp
  20755 					v18 = **(**uint32_t)(__ccgo_up(argb2 + uintptr(j)*4))
  20756 					v3 = libc.Int32FromUint32(v18 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  20757 					goto _20
  20758 				_20:
  20759 					key = v3
  20760 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key)*4)) = v18
  20761 					goto _16
  20762 				_16:
  20763 					;
  20764 					j = j + 1
  20765 				}
  20766 			}
  20767 		}
  20768 		i = i + **(**int32)(__ccgo_up(bp + 20))
  20769 		goto _1
  20770 	_1:
  20771 	}
  20772 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  20773 	goto Error
  20774 Error:
  20775 	;
  20776 	if cc_init != 0 {
  20777 		VP8LColorCacheClear(tls, bp)
  20778 	}
  20779 	return ok
  20780 }
  20781 
  20782 // C documentation
  20783 //
  20784 //	// Compute an LZ77 by forcing matches to happen within a given distance cost.
  20785 //	// We therefore limit the algorithm to the lowest 32 values in the PlaneCode
  20786 //	// definition.
  20787 func BackwardReferencesLz77Box(tls *libc.TLS, xsize int32, ysize int32, argb uintptr, cache_bits int32, hash_chain_best uintptr, hash_chain uintptr, refs uintptr) (r int32) {
  20788 	var best_length, best_length_prev, best_offset, best_offset_prev, counts_j, counts_j_offset, curr_length, do_compute, i, ind, is_reachable, j, j1, j_offset, num_ind, offset, pix_count, plane_code, use_prev, window_offsets_new_size, window_offsets_size, x, y, v5, v9 int32
  20789 	var counts, counts_ini uintptr
  20790 	var window_offsets, window_offsets_new [32]int32
  20791 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_length, best_length_prev, best_offset, best_offset_prev, counts, counts_ini, counts_j, counts_j_offset, curr_length, do_compute, i, ind, is_reachable, j, j1, j_offset, num_ind, offset, pix_count, plane_code, use_prev, window_offsets, window_offsets_new, window_offsets_new_size, window_offsets_size, x, y, v5, v9
  20792 	pix_count = xsize * ysize
  20793 	window_offsets = [32]int32{}
  20794 	window_offsets_new = [32]int32{}
  20795 	window_offsets_size = 0
  20796 	window_offsets_new_size = 0
  20797 	counts_ini = WebPSafeMalloc(tls, libc.Uint64FromInt32(xsize*ysize), uint64(2))
  20798 	best_offset_prev = -int32(1)
  20799 	best_length_prev = -int32(1)
  20800 	if counts_ini == libc.UintptrFromInt32(0) {
  20801 		return 0
  20802 	}
  20803 	// counts[i] counts how many times a pixel is repeated starting at position i.
  20804 	i = pix_count - int32(2)
  20805 	counts = counts_ini + uintptr(i)*2
  20806 	**(**uint16_t)(__ccgo_up(counts + 1*2)) = uint16(1)
  20807 	for {
  20808 		if !(i >= 0) {
  20809 			break
  20810 		}
  20811 		if **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(i+int32(1))*4)) {
  20812 			// Max out the counts to MAX_LENGTH.
  20813 			**(**uint16_t)(__ccgo_up(counts)) = libc.Uint16FromInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts + 1*2))) + libc.BoolInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts + 1*2))) != libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1)))
  20814 		} else {
  20815 			**(**uint16_t)(__ccgo_up(counts)) = uint16(1)
  20816 		}
  20817 		goto _1
  20818 	_1:
  20819 		;
  20820 		i = i - 1
  20821 		counts -= 2
  20822 	}
  20823 	// Figure out the window offsets around a pixel. They are stored in a
  20824 	// spiraling order around the pixel as defined by VP8LDistanceToPlaneCode.
  20825 	y = 0
  20826 	for {
  20827 		if !(y <= int32(6)) {
  20828 			break
  20829 		}
  20830 		x = -int32(6)
  20831 		for {
  20832 			if !(x <= int32(6)) {
  20833 				break
  20834 			}
  20835 			offset = y*xsize + x
  20836 			// Ignore offsets that bring us after the pixel.
  20837 			if offset <= 0 {
  20838 				goto _3
  20839 			}
  20840 			plane_code = VP8LDistanceToPlaneCode(tls, xsize, offset) - int32(1)
  20841 			if plane_code >= int32(WINDOW_OFFSETS_SIZE_MAX) {
  20842 				goto _3
  20843 			}
  20844 			window_offsets[plane_code] = offset
  20845 			goto _3
  20846 		_3:
  20847 			;
  20848 			x = x + 1
  20849 		}
  20850 		goto _2
  20851 	_2:
  20852 		;
  20853 		y = y + 1
  20854 	}
  20855 	// For narrow images, not all plane codes are reached, so remove those.
  20856 	i = 0
  20857 	for {
  20858 		if !(i < int32(WINDOW_OFFSETS_SIZE_MAX)) {
  20859 			break
  20860 		}
  20861 		if window_offsets[i] == 0 {
  20862 			goto _4
  20863 		}
  20864 		v5 = window_offsets_size
  20865 		window_offsets_size = window_offsets_size + 1
  20866 		window_offsets[v5] = window_offsets[i]
  20867 		goto _4
  20868 	_4:
  20869 		;
  20870 		i = i + 1
  20871 	}
  20872 	// Given a pixel P, find the offsets that reach pixels unreachable from P-1
  20873 	// with any of the offsets in window_offsets[].
  20874 	i = 0
  20875 	for {
  20876 		if !(i < window_offsets_size) {
  20877 			break
  20878 		}
  20879 		is_reachable = 0
  20880 		j = 0
  20881 		for {
  20882 			if !(j < window_offsets_size && !(is_reachable != 0)) {
  20883 				break
  20884 			}
  20885 			is_reachable = is_reachable | libc.BoolInt32(window_offsets[i] == window_offsets[j]+int32(1))
  20886 			goto _7
  20887 		_7:
  20888 			;
  20889 			j = j + 1
  20890 		}
  20891 		if !(is_reachable != 0) {
  20892 			window_offsets_new[window_offsets_new_size] = window_offsets[i]
  20893 			window_offsets_new_size = window_offsets_new_size + 1
  20894 		}
  20895 		goto _6
  20896 	_6:
  20897 		;
  20898 		i = i + 1
  20899 	}
  20900 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length)) = uint32(0)
  20901 	i = int32(1)
  20902 	for {
  20903 		if !(i < pix_count) {
  20904 			break
  20905 		}
  20906 		v5 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain_best)).Foffset_length + uintptr(i)*4)) & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Uint32FromInt32(1)))
  20907 		goto _10
  20908 	_10:
  20909 		best_length = v5
  20910 		do_compute = int32(1)
  20911 		if best_length >= libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20912 			// Do not recompute the best match if we already have a maximal one in the
  20913 			// window.
  20914 			v9 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain_best)).Foffset_length + uintptr(i)*4)) >> int32(MAX_LENGTH_BITS))
  20915 			goto _12
  20916 		_12:
  20917 			best_offset = v9
  20918 			ind = 0
  20919 			for {
  20920 				if !(ind < window_offsets_size) {
  20921 					break
  20922 				}
  20923 				if best_offset == window_offsets[ind] {
  20924 					do_compute = 0
  20925 					break
  20926 				}
  20927 				goto _13
  20928 			_13:
  20929 				;
  20930 				ind = ind + 1
  20931 			}
  20932 		}
  20933 		if do_compute != 0 {
  20934 			// Figure out if we should use the offset/length from the previous pixel
  20935 			// as an initial guess and therefore only inspect the offsets in
  20936 			// window_offsets_new[].
  20937 			use_prev = libc.BoolInt32(best_length_prev > int32(1) && best_length_prev < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1))
  20938 			if use_prev != 0 {
  20939 				v5 = window_offsets_new_size
  20940 			} else {
  20941 				v5 = window_offsets_size
  20942 			}
  20943 			num_ind = v5
  20944 			if use_prev != 0 {
  20945 				v9 = best_length_prev - int32(1)
  20946 			} else {
  20947 				v9 = 0
  20948 			}
  20949 			best_length = v9
  20950 			if use_prev != 0 {
  20951 				v5 = best_offset_prev
  20952 			} else {
  20953 				v5 = 0
  20954 			}
  20955 			best_offset = v5
  20956 			// Find the longest match in a window around the pixel.
  20957 			ind = 0
  20958 			for {
  20959 				if !(ind < num_ind) {
  20960 					break
  20961 				}
  20962 				curr_length = 0
  20963 				j1 = i
  20964 				if use_prev != 0 {
  20965 					v5 = i - window_offsets_new[ind]
  20966 				} else {
  20967 					v5 = i - window_offsets[ind]
  20968 				}
  20969 				j_offset = v5
  20970 				if j_offset < 0 || **(**uint32_t)(__ccgo_up(argb + uintptr(j_offset)*4)) != **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) {
  20971 					goto _17
  20972 				}
  20973 				// The longest match is the sum of how many times each pixel is
  20974 				// repeated.
  20975 				for cond := true; cond; cond = curr_length <= libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) && j1 < pix_count && **(**uint32_t)(__ccgo_up(argb + uintptr(j_offset)*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(j1)*4)) {
  20976 					counts_j_offset = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts_ini + uintptr(j_offset)*2)))
  20977 					counts_j = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts_ini + uintptr(j1)*2)))
  20978 					if counts_j_offset != counts_j {
  20979 						if counts_j_offset < counts_j {
  20980 							v5 = counts_j_offset
  20981 						} else {
  20982 							v5 = counts_j
  20983 						}
  20984 						curr_length = curr_length + v5
  20985 						break
  20986 					}
  20987 					// The same color is repeated counts_pos times at j_offset and j.
  20988 					curr_length = curr_length + counts_j_offset
  20989 					j_offset = j_offset + counts_j_offset
  20990 					j1 = j1 + counts_j_offset
  20991 				}
  20992 				if best_length < curr_length {
  20993 					if use_prev != 0 {
  20994 						v5 = window_offsets_new[ind]
  20995 					} else {
  20996 						v5 = window_offsets[ind]
  20997 					}
  20998 					best_offset = v5
  20999 					if curr_length >= libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  21000 						best_length = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  21001 						break
  21002 					} else {
  21003 						best_length = curr_length
  21004 					}
  21005 				}
  21006 				goto _17
  21007 			_17:
  21008 				;
  21009 				ind = ind + 1
  21010 			}
  21011 		}
  21012 		if best_length <= int32(MIN_LENGTH) {
  21013 			**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(i)*4)) = uint32(0)
  21014 			best_offset_prev = 0
  21015 			best_length_prev = 0
  21016 		} else {
  21017 			**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(i)*4)) = libc.Uint32FromInt32(best_offset<<libc.Int32FromInt32(MAX_LENGTH_BITS)) | libc.Uint32FromInt32(best_length)
  21018 			best_offset_prev = best_offset
  21019 			best_length_prev = best_length
  21020 		}
  21021 		goto _8
  21022 	_8:
  21023 		;
  21024 		i = i + 1
  21025 	}
  21026 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length)) = uint32(0)
  21027 	WebPSafeFree(tls, counts_ini)
  21028 	return BackwardReferencesLz77(tls, xsize, ysize, argb, cache_bits, hash_chain, refs)
  21029 }
  21030 
  21031 // -----------------------------------------------------------------------------
  21032 
  21033 func BackwardReferences2DLocality(tls *libc.TLS, xsize int32, refs uintptr) {
  21034 	bp := tls.Alloc(32)
  21035 	defer tls.Free(32)
  21036 	var dist, transformed_dist, v1, v3 int32
  21037 	var v5, v6, v7 uintptr
  21038 	var _ /* c at bp+0 */ VP8LRefsCursor
  21039 	_, _, _, _, _, _, _ = dist, transformed_dist, v1, v3, v5, v6, v7
  21040 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  21041 	for {
  21042 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  21043 		goto _2
  21044 	_2:
  21045 		if !(v1 != 0) {
  21046 			break
  21047 		}
  21048 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fmode) == int32(kCopy))
  21049 		goto _4
  21050 	_4:
  21051 		if v3 != 0 {
  21052 			dist = libc.Int32FromUint32((*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fargb_or_distance)
  21053 			transformed_dist = VP8LDistanceToPlaneCode(tls, xsize, dist)
  21054 			(*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fargb_or_distance = libc.Uint32FromInt32(transformed_dist)
  21055 		}
  21056 		v5 = bp
  21057 		v7 = v5
  21058 		*(*uintptr)(unsafe.Pointer(v7)) += 8
  21059 		v6 = *(*uintptr)(unsafe.Pointer(v7))
  21060 		if v6 == (*VP8LRefsCursor)(unsafe.Pointer(v5)).Flast_pos {
  21061 			VP8LRefsCursorNextBlock(tls, v5)
  21062 		}
  21063 	}
  21064 }
  21065 
  21066 // C documentation
  21067 //
  21068 //	// Evaluate optimal cache bits for the local color cache.
  21069 //	// The input *best_cache_bits sets the maximum cache bits to use (passing 0
  21070 //	// implies disabling the local color cache). The local color cache is also
  21071 //	// disabled for the lower (<= 25) quality.
  21072 //	// Returns 0 in case of memory error.
  21073 func CalculateBestCacheSize(tls *libc.TLS, argb2 uintptr, quality int32, refs uintptr, best_cache_bits uintptr) (r1 int32) {
  21074 	bp := tls.Alloc(224)
  21075 	defer tls.Free(224)
  21076 	var a, argb_prev, b, g, pix, r, v11 uint32_t
  21077 	var cache_bits_max, highest_bit, i, key2, key3, len1, ok, second_highest_bit, v1, v3, v5, v8 int32
  21078 	var cc_init [11]int32
  21079 	var entropy, entropy_min uint64_t
  21080 	var histos [11]uintptr
  21081 	var prefix_code VP8LPrefixCode
  21082 	var v, v16, v17, v18, v7 uintptr
  21083 	var _ /* c at bp+176 */ VP8LRefsCursor
  21084 	var _ /* code at bp+200 */ int32
  21085 	var _ /* extra_bits at bp+204 */ int32
  21086 	var _ /* extra_bits_value at bp+208 */ int32
  21087 	var _ /* hashers at bp+0 */ [11]VP8LColorCache
  21088 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, argb_prev, b, cache_bits_max, cc_init, entropy, entropy_min, g, highest_bit, histos, i, key2, key3, len1, ok, pix, prefix_code, r, second_highest_bit, v, v1, v11, v16, v17, v18, v3, v5, v7, v8
  21089 	if quality <= int32(25) {
  21090 		v1 = 0
  21091 	} else {
  21092 		v1 = **(**int32)(__ccgo_up(best_cache_bits))
  21093 	}
  21094 	cache_bits_max = v1
  21095 	entropy_min = ^libc.Uint64FromUint64(0)
  21096 	cc_init = [11]int32{}
  21097 	**(**VP8LRefsCursor)(__ccgo_up(bp + 176)) = VP8LRefsCursorInit(tls, refs)
  21098 	histos = [11]uintptr{}
  21099 	ok = 0
  21100 	if cache_bits_max == 0 {
  21101 		**(**int32)(__ccgo_up(best_cache_bits)) = 0
  21102 		// Local color cache is disabled.
  21103 		return int32(1)
  21104 	}
  21105 	// Allocate data.
  21106 	i = 0
  21107 	for {
  21108 		if !(i <= cache_bits_max) {
  21109 			break
  21110 		}
  21111 		histos[i] = VP8LAllocateHistogram(tls, i)
  21112 		if histos[i] == libc.UintptrFromInt32(0) {
  21113 			goto Error
  21114 		}
  21115 		VP8LHistogramInit(tls, histos[i], i, int32(1))
  21116 		if i == 0 {
  21117 			goto _2
  21118 		}
  21119 		cc_init[i] = VP8LColorCacheInit(tls, bp+uintptr(i)*16, i)
  21120 		if !(cc_init[i] != 0) {
  21121 			goto Error
  21122 		}
  21123 		goto _2
  21124 	_2:
  21125 		;
  21126 		i = i + 1
  21127 	}
  21128 	// Find the cache_bits giving the lowest entropy. The search is done in a
  21129 	// brute-force way as the function (entropy w.r.t cache_bits) can be
  21130 	// anything in practice.
  21131 	for {
  21132 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp+176)).Fcur_pos != libc.UintptrFromInt32(0))
  21133 		goto _4
  21134 	_4:
  21135 		if !(v1 != 0) {
  21136 			break
  21137 		}
  21138 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp + 176))).Fcur_pos
  21139 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  21140 		goto _6
  21141 	_6:
  21142 		if v3 != 0 {
  21143 			v7 = argb2
  21144 			argb2 += 4
  21145 			pix = **(**uint32_t)(__ccgo_up(v7))
  21146 			a = pix >> libc.Int32FromInt32(24) & uint32(0xff)
  21147 			r = pix >> libc.Int32FromInt32(16) & uint32(0xff)
  21148 			g = pix >> libc.Int32FromInt32(8) & uint32(0xff)
  21149 			b = pix >> libc.Int32FromInt32(0) & uint32(0xff)
  21150 			v5 = libc.Int32FromUint32(pix * kHashMul11 >> (int32(32) - cache_bits_max))
  21151 			goto _9
  21152 		_9:
  21153 			// The keys of the caches can be derived from the longest one.
  21154 			key2 = v5
  21155 			// Do not use the color cache for cache_bits = 0.
  21156 			**(**uint32_t)(__ccgo_up(histos[0] + 1032 + uintptr(b)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 1032 + uintptr(b)*4)) + 1
  21157 			**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[0])).Fliteral + uintptr(g)*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[0])).Fliteral + uintptr(g)*4)) + 1
  21158 			**(**uint32_t)(__ccgo_up(histos[0] + 8 + uintptr(r)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 8 + uintptr(r)*4)) + 1
  21159 			**(**uint32_t)(__ccgo_up(histos[0] + 2056 + uintptr(a)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 2056 + uintptr(a)*4)) + 1
  21160 			// Deal with cache_bits > 0.
  21161 			i = cache_bits_max
  21162 			for {
  21163 				if !(i >= int32(1)) {
  21164 					break
  21165 				}
  21166 				v11 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(bp+uintptr(i)*16)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4))
  21167 				goto _12
  21168 			_12:
  21169 				if v11 == pix {
  21170 					**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(libc.Int32FromInt32(NUM_LITERAL_CODES)+libc.Int32FromInt32(NUM_LENGTH_CODES)+key2)*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(libc.Int32FromInt32(NUM_LITERAL_CODES)+libc.Int32FromInt32(NUM_LENGTH_CODES)+key2)*4)) + 1
  21171 				} else {
  21172 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(bp+uintptr(i)*16)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4)) = pix
  21173 					**(**uint32_t)(__ccgo_up(histos[i] + 1032 + uintptr(b)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 1032 + uintptr(b)*4)) + 1
  21174 					**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(g)*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(g)*4)) + 1
  21175 					**(**uint32_t)(__ccgo_up(histos[i] + 8 + uintptr(r)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 8 + uintptr(r)*4)) + 1
  21176 					**(**uint32_t)(__ccgo_up(histos[i] + 2056 + uintptr(a)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 2056 + uintptr(a)*4)) + 1
  21177 				}
  21178 				goto _10
  21179 			_10:
  21180 				;
  21181 				i = i - 1
  21182 				key2 = key2 >> int32(1)
  21183 			}
  21184 		} else {
  21185 			v11 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  21186 			goto _14
  21187 		_14:
  21188 			// We should compute the contribution of the (distance,length)
  21189 			// histograms but those are the same independently from the cache size.
  21190 			// As those constant contributions are in the end added to the other
  21191 			// histogram contributions, we can ignore them, except for the length
  21192 			// prefix that is part of the 'literal' histogram.
  21193 			len1 = libc.Int32FromUint32(v11)
  21194 			argb_prev = **(**uint32_t)(__ccgo_up(argb2)) ^ uint32(0xffffffff)
  21195 			v1 = len1
  21196 			v7 = bp + 200
  21197 			v16 = bp + 204
  21198 			v17 = bp + 208
  21199 			if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  21200 				prefix_code = kPrefixEncodeCode[v1]
  21201 				**(**int32)(__ccgo_up(v7)) = int32(prefix_code.Fcode)
  21202 				**(**int32)(__ccgo_up(v16)) = int32(prefix_code.Fextra_bits)
  21203 				**(**int32)(__ccgo_up(v17)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v1])
  21204 			} else {
  21205 				v3 = v1
  21206 				v18 = v16
  21207 				v3 = v3 - 1
  21208 				v5 = v3
  21209 				v8 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  21210 				goto _23
  21211 			_23:
  21212 				highest_bit = v8
  21213 				second_highest_bit = v3 >> (highest_bit - int32(1)) & int32(1)
  21214 				**(**int32)(__ccgo_up(v18)) = highest_bit - int32(1)
  21215 				**(**int32)(__ccgo_up(v17)) = v3 & (int32(1)<<**(**int32)(__ccgo_up(v18)) - int32(1))
  21216 				**(**int32)(__ccgo_up(v7)) = int32(2)*highest_bit + second_highest_bit
  21217 			}
  21218 			i = 0
  21219 			for {
  21220 				if !(i <= cache_bits_max) {
  21221 					break
  21222 				}
  21223 				**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(int32(NUM_LITERAL_CODES)+**(**int32)(__ccgo_up(bp + 200)))*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histos[i])).Fliteral + uintptr(int32(NUM_LITERAL_CODES)+**(**int32)(__ccgo_up(bp + 200)))*4)) + 1
  21224 				goto _24
  21225 			_24:
  21226 				;
  21227 				i = i + 1
  21228 			}
  21229 			// Update the color caches.
  21230 			for {
  21231 				if **(**uint32_t)(__ccgo_up(argb2)) != argb_prev {
  21232 					v3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb2)) * kHashMul11 >> (int32(32) - cache_bits_max))
  21233 					goto _28
  21234 				_28:
  21235 					// Efficiency: insert only if the color changes.
  21236 					key3 = v3
  21237 					i = cache_bits_max
  21238 					for {
  21239 						if !(i >= int32(1)) {
  21240 							break
  21241 						}
  21242 						**(**uint32_t)(__ccgo_up((**(**[11]VP8LColorCache)(__ccgo_up(bp)))[i].Fcolors + uintptr(key3)*4)) = **(**uint32_t)(__ccgo_up(argb2))
  21243 						goto _29
  21244 					_29:
  21245 						;
  21246 						i = i - 1
  21247 						key3 = key3 >> int32(1)
  21248 					}
  21249 					argb_prev = **(**uint32_t)(__ccgo_up(argb2))
  21250 				}
  21251 				argb2 += 4
  21252 				goto _26
  21253 			_26:
  21254 				;
  21255 				len1 = len1 - 1
  21256 				v1 = len1
  21257 				if !(v1 != 0) {
  21258 					break
  21259 				}
  21260 			}
  21261 		}
  21262 		v7 = bp + 176
  21263 		v17 = v7
  21264 		*(*uintptr)(unsafe.Pointer(v17)) += 8
  21265 		v16 = *(*uintptr)(unsafe.Pointer(v17))
  21266 		if v16 == (*VP8LRefsCursor)(unsafe.Pointer(v7)).Flast_pos {
  21267 			VP8LRefsCursorNextBlock(tls, v7)
  21268 		}
  21269 	}
  21270 	i = 0
  21271 	for {
  21272 		if !(i <= cache_bits_max) {
  21273 			break
  21274 		}
  21275 		entropy = VP8LHistogramEstimateBits(tls, histos[i])
  21276 		if i == 0 || entropy < entropy_min {
  21277 			entropy_min = entropy
  21278 			**(**int32)(__ccgo_up(best_cache_bits)) = i
  21279 		}
  21280 		goto _33
  21281 	_33:
  21282 		;
  21283 		i = i + 1
  21284 	}
  21285 	ok = int32(1)
  21286 	goto Error
  21287 Error:
  21288 	;
  21289 	i = 0
  21290 	for {
  21291 		if !(i <= cache_bits_max) {
  21292 			break
  21293 		}
  21294 		if cc_init[i] != 0 {
  21295 			VP8LColorCacheClear(tls, bp+uintptr(i)*16)
  21296 		}
  21297 		VP8LFreeHistogram(tls, histos[i])
  21298 		goto _34
  21299 	_34:
  21300 		;
  21301 		i = i + 1
  21302 	}
  21303 	return ok
  21304 }
  21305 
  21306 // C documentation
  21307 //
  21308 //	// Update (in-place) backward references for specified cache_bits.
  21309 func BackwardRefsWithLocalCache(tls *libc.TLS, argb3 uintptr, cache_bits int32, refs uintptr) (r int32) {
  21310 	bp := tls.Alloc(48)
  21311 	defer tls.Free(48)
  21312 	var argb_literal, v6 uint32_t
  21313 	var ix, k, key, key1, pixel_index, v1, v11, v3, v7, v9 int32
  21314 	var retval, v12 PixOrCopy
  21315 	var v, v14, v20, v5 uintptr
  21316 	var _ /* c at bp+16 */ VP8LRefsCursor
  21317 	var _ /* hashers at bp+0 */ VP8LColorCache
  21318 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = argb_literal, ix, k, key, key1, pixel_index, retval, v, v1, v11, v12, v14, v20, v3, v5, v6, v7, v9
  21319 	pixel_index = 0
  21320 	**(**VP8LRefsCursor)(__ccgo_up(bp + 16)) = VP8LRefsCursorInit(tls, refs)
  21321 	if !(VP8LColorCacheInit(tls, bp, cache_bits) != 0) {
  21322 		return 0
  21323 	}
  21324 	for {
  21325 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp+16)).Fcur_pos != libc.UintptrFromInt32(0))
  21326 		goto _2
  21327 	_2:
  21328 		if !(v1 != 0) {
  21329 			break
  21330 		}
  21331 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp + 16))).Fcur_pos
  21332 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  21333 		goto _4
  21334 	_4:
  21335 		if v3 != 0 {
  21336 			argb_literal = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  21337 			v5 = bp
  21338 			v6 = argb_literal
  21339 			v7 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21340 			goto _8
  21341 		_8:
  21342 			key1 = v7
  21343 			if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key1)*4)) == v6 {
  21344 				v11 = key1
  21345 			} else {
  21346 				v11 = -int32(1)
  21347 			}
  21348 			v9 = v11
  21349 			goto _10
  21350 		_10:
  21351 			ix = v9
  21352 			if ix >= 0 {
  21353 				// hashers contains argb_literal
  21354 				retval.Fmode = uint8(kCacheIdx)
  21355 				retval.Fargb_or_distance = libc.Uint32FromInt32(ix)
  21356 				retval.Flen1 = uint16(1)
  21357 				v12 = retval
  21358 				goto _13
  21359 			_13:
  21360 				**(**PixOrCopy)(__ccgo_up(v)) = v12
  21361 			} else {
  21362 				v5 = bp
  21363 				v6 = argb_literal
  21364 				v1 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21365 				goto _17
  21366 			_17:
  21367 				key = v1
  21368 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key)*4)) = v6
  21369 			}
  21370 			pixel_index = pixel_index + 1
  21371 		} else {
  21372 			k = 0
  21373 			for {
  21374 				if !(k < libc.Int32FromUint16((*PixOrCopy)(unsafe.Pointer(v)).Flen1)) {
  21375 					break
  21376 				}
  21377 				v1 = pixel_index
  21378 				pixel_index = pixel_index + 1
  21379 				v5 = bp
  21380 				v6 = **(**uint32_t)(__ccgo_up(argb3 + uintptr(v1)*4))
  21381 				v3 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21382 				goto _23
  21383 			_23:
  21384 				key = v3
  21385 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key)*4)) = v6
  21386 				goto _18
  21387 			_18:
  21388 				;
  21389 				k = k + 1
  21390 			}
  21391 		}
  21392 		v5 = bp + 16
  21393 		v20 = v5
  21394 		*(*uintptr)(unsafe.Pointer(v20)) += 8
  21395 		v14 = *(*uintptr)(unsafe.Pointer(v20))
  21396 		if v14 == (*VP8LRefsCursor)(unsafe.Pointer(v5)).Flast_pos {
  21397 			VP8LRefsCursorNextBlock(tls, v5)
  21398 		}
  21399 	}
  21400 	VP8LColorCacheClear(tls, bp)
  21401 	return int32(1)
  21402 }
  21403 
  21404 func GetBackwardReferencesLowEffort(tls *libc.TLS, width int32, height int32, argb uintptr, cache_bits uintptr, hash_chain uintptr, refs_lz77 uintptr) (r uintptr) {
  21405 	**(**int32)(__ccgo_up(cache_bits)) = 0
  21406 	if !(BackwardReferencesLz77(tls, width, height, argb, 0, hash_chain, refs_lz77) != 0) {
  21407 		return libc.UintptrFromInt32(0)
  21408 	}
  21409 	BackwardReferences2DLocality(tls, width, refs_lz77)
  21410 	return refs_lz77
  21411 }
  21412 
  21413 func GetBackwardReferences(tls *libc.TLS, width int32, height int32, argb uintptr, quality int32, lz77_types_to_try int32, cache_bits_max int32, do_no_cache int32, hash_chain uintptr, refs uintptr, cache_bits_best uintptr) (r int32) {
  21414 	bp := tls.Alloc(32)
  21415 	defer tls.Free(32)
  21416 	var bit_cost, bit_cost_trace uint64_t
  21417 	var bit_costs_best [2]uint64_t
  21418 	var cache_bits1, i, lz77_type, res, status, v1 int32
  21419 	var hash_chain_tmp, histo, refs_tmp, v6 uintptr
  21420 	var lz77_types_best [2]int32
  21421 	var _ /* cache_bits at bp+16 */ int32
  21422 	var _ /* hash_chain_box at bp+0 */ VP8LHashChain
  21423 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit_cost, bit_cost_trace, bit_costs_best, cache_bits1, hash_chain_tmp, histo, i, lz77_type, lz77_types_best, refs_tmp, res, status, v1, v6
  21424 	histo = libc.UintptrFromInt32(0)
  21425 	// Index 0 is for a color cache, index 1 for no cache (if needed).
  21426 	lz77_types_best = [2]int32{}
  21427 	bit_costs_best = [2]uint64_t{
  21428 		0: ^libc.Uint64FromUint64(0),
  21429 		1: ^libc.Uint64FromUint64(0),
  21430 	}
  21431 	if do_no_cache != 0 {
  21432 		v1 = int32(2)
  21433 	} else {
  21434 		v1 = int32(1)
  21435 	}
  21436 	refs_tmp = refs + uintptr(v1)*40
  21437 	status = 0
  21438 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^__predefined_size_t(0))
  21439 	histo = VP8LAllocateHistogram(tls, int32(MAX_COLOR_CACHE_BITS))
  21440 	if histo == libc.UintptrFromInt32(0) {
  21441 		goto Error
  21442 	}
  21443 	lz77_type = int32(1)
  21444 	for {
  21445 		if !(lz77_types_to_try != 0) {
  21446 			break
  21447 		}
  21448 		res = 0
  21449 		bit_cost = 0
  21450 		if lz77_types_to_try&lz77_type == 0 {
  21451 			goto _2
  21452 		}
  21453 		switch lz77_type {
  21454 		case int32(kLZ77RLE):
  21455 			res = BackwardReferencesRle(tls, width, height, argb, 0, refs_tmp)
  21456 		case int32(kLZ77Standard):
  21457 			// Compute LZ77 with no cache (0 bits), as the ideal LZ77 with a color
  21458 			// cache is not that different in practice.
  21459 			res = BackwardReferencesLz77(tls, width, height, argb, 0, hash_chain, refs_tmp)
  21460 		case int32(kLZ77Box):
  21461 			if !(VP8LHashChainInit(tls, bp, width*height) != 0) {
  21462 				goto Error
  21463 			}
  21464 			res = BackwardReferencesLz77Box(tls, width, height, argb, 0, hash_chain, bp, refs_tmp)
  21465 		default:
  21466 		}
  21467 		if !(res != 0) {
  21468 			goto Error
  21469 		}
  21470 		// Start with the no color cache case.
  21471 		i = int32(1)
  21472 		for {
  21473 			if !(i >= 0) {
  21474 				break
  21475 			}
  21476 			if i == int32(1) {
  21477 				v1 = 0
  21478 			} else {
  21479 				v1 = cache_bits_max
  21480 			}
  21481 			**(**int32)(__ccgo_up(bp + 16)) = v1
  21482 			if i == int32(1) && !(do_no_cache != 0) {
  21483 				goto _3
  21484 			}
  21485 			if i == 0 {
  21486 				// Try with a color cache.
  21487 				if !(CalculateBestCacheSize(tls, argb, quality, refs_tmp, bp+16) != 0) {
  21488 					goto Error
  21489 				}
  21490 				if **(**int32)(__ccgo_up(bp + 16)) > 0 {
  21491 					if !(BackwardRefsWithLocalCache(tls, argb, **(**int32)(__ccgo_up(bp + 16)), refs_tmp) != 0) {
  21492 						goto Error
  21493 					}
  21494 				}
  21495 			}
  21496 			if i == 0 && do_no_cache != 0 && **(**int32)(__ccgo_up(bp + 16)) == 0 {
  21497 				// No need to re-compute bit_cost as it was computed at i == 1.
  21498 			} else {
  21499 				VP8LHistogramCreate(tls, histo, refs_tmp, **(**int32)(__ccgo_up(bp + 16)))
  21500 				bit_cost = VP8LHistogramEstimateBits(tls, histo)
  21501 			}
  21502 			if bit_cost < bit_costs_best[i] {
  21503 				if i == int32(1) {
  21504 					// Do not swap as the full cache analysis would have the wrong
  21505 					// VP8LBackwardRefs to start with.
  21506 					if !(BackwardRefsClone(tls, refs_tmp, refs+1*40) != 0) {
  21507 						goto Error
  21508 					}
  21509 				} else {
  21510 					BackwardRefsSwap(tls, refs_tmp, refs)
  21511 				}
  21512 				bit_costs_best[i] = bit_cost
  21513 				lz77_types_best[i] = lz77_type
  21514 				if i == 0 {
  21515 					**(**int32)(__ccgo_up(cache_bits_best)) = **(**int32)(__ccgo_up(bp + 16))
  21516 				}
  21517 			}
  21518 			goto _3
  21519 		_3:
  21520 			;
  21521 			i = i - 1
  21522 		}
  21523 		goto _2
  21524 	_2:
  21525 		;
  21526 		lz77_types_to_try = lz77_types_to_try & ^lz77_type
  21527 		lz77_type = lz77_type << int32(1)
  21528 	}
  21529 	// Improve on simple LZ77 but only for high quality (TraceBackwards is
  21530 	// costly).
  21531 	i = int32(1)
  21532 	for {
  21533 		if !(i >= 0) {
  21534 			break
  21535 		}
  21536 		if i == int32(1) && !(do_no_cache != 0) {
  21537 			goto _5
  21538 		}
  21539 		if (lz77_types_best[i] == int32(kLZ77Standard) || lz77_types_best[i] == int32(kLZ77Box)) && quality >= int32(25) {
  21540 			if lz77_types_best[i] == int32(kLZ77Standard) {
  21541 				v6 = hash_chain
  21542 			} else {
  21543 				v6 = bp
  21544 			}
  21545 			hash_chain_tmp = v6
  21546 			if i == int32(1) {
  21547 				v1 = 0
  21548 			} else {
  21549 				v1 = **(**int32)(__ccgo_up(cache_bits_best))
  21550 			}
  21551 			cache_bits1 = v1
  21552 			if !(VP8LBackwardReferencesTraceBackwards(tls, width, height, argb, cache_bits1, hash_chain_tmp, refs+uintptr(i)*40, refs_tmp) != 0) {
  21553 				goto Error
  21554 			}
  21555 			VP8LHistogramCreate(tls, histo, refs_tmp, cache_bits1)
  21556 			bit_cost_trace = VP8LHistogramEstimateBits(tls, histo)
  21557 			if bit_cost_trace < bit_costs_best[i] {
  21558 				BackwardRefsSwap(tls, refs_tmp, refs+uintptr(i)*40)
  21559 			}
  21560 		}
  21561 		BackwardReferences2DLocality(tls, width, refs+uintptr(i)*40)
  21562 		if i == int32(1) && lz77_types_best[0] == lz77_types_best[int32(1)] && **(**int32)(__ccgo_up(cache_bits_best)) == 0 {
  21563 			// If the best cache size is 0 and we have the same best LZ77, just copy
  21564 			// the data over and stop here.
  21565 			if !(BackwardRefsClone(tls, refs+1*40, refs) != 0) {
  21566 				goto Error
  21567 			}
  21568 			break
  21569 		}
  21570 		goto _5
  21571 	_5:
  21572 		;
  21573 		i = i - 1
  21574 	}
  21575 	status = int32(1)
  21576 	goto Error
  21577 Error:
  21578 	;
  21579 	VP8LHashChainClear(tls, bp)
  21580 	VP8LFreeHistogram(tls, histo)
  21581 	return status
  21582 }
  21583 
  21584 func VP8LGetBackwardReferences(tls *libc.TLS, width int32, height int32, argb uintptr, quality int32, low_effort int32, lz77_types_to_try int32, cache_bits_max int32, do_no_cache int32, hash_chain uintptr, refs uintptr, cache_bits_best uintptr, pic uintptr, percent_range int32, percent uintptr) (r int32) {
  21585 	var refs_best uintptr
  21586 	_ = refs_best
  21587 	if low_effort != 0 {
  21588 		**(**int32)(__ccgo_up(cache_bits_best)) = cache_bits_max
  21589 		refs_best = GetBackwardReferencesLowEffort(tls, width, height, argb, cache_bits_best, hash_chain, refs)
  21590 		if refs_best == libc.UintptrFromInt32(0) {
  21591 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  21592 		}
  21593 		// Set it in first position.
  21594 		BackwardRefsSwap(tls, refs_best, refs)
  21595 	} else {
  21596 		if !(GetBackwardReferences(tls, width, height, argb, quality, lz77_types_to_try, cache_bits_max, do_no_cache, hash_chain, refs, cache_bits_best) != 0) {
  21597 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  21598 		}
  21599 	}
  21600 	return WebPReportProgress(tls, pic, **(**int32)(__ccgo_up(percent))+percent_range, percent)
  21601 }
  21602 
  21603 const MAX_LEVEL1 = 9
  21604 
  21605 //------------------------------------------------------------------------------
  21606 
  21607 // Copyright 2010 Google Inc. All Rights Reserved.
  21608 //
  21609 // Use of this source code is governed by a BSD-style license
  21610 // that can be found in the COPYING file in the root of the source
  21611 // tree. An additional intellectual property rights grant can be found
  21612 // in the file PATENTS. All contributing project authors may
  21613 // be found in the AUTHORS file in the root of the source tree.
  21614 // -----------------------------------------------------------------------------
  21615 //
  21616 //  Common types + memory wrappers
  21617 //
  21618 // Author: Skal (pascal.massimino@gmail.com)
  21619 
  21620 //------------------------------------------------------------------------------
  21621 // WebPConfig
  21622 //------------------------------------------------------------------------------
  21623 
  21624 func WebPConfigInitInternal(tls *libc.TLS, config uintptr, preset WebPPreset1, quality float32, version int32) (r int32) {
  21625 	if version>>int32(8) != libc.Int32FromInt32(WEBP_ENCODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  21626 		return 0 // caller/system version mismatch!
  21627 	}
  21628 	if config == libc.UintptrFromInt32(0) {
  21629 		return 0
  21630 	}
  21631 	(*WebPConfig)(unsafe.Pointer(config)).Fquality = quality
  21632 	(*WebPConfig)(unsafe.Pointer(config)).Ftarget_size = 0
  21633 	(*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR = float32(0)
  21634 	(*WebPConfig)(unsafe.Pointer(config)).Fmethod = int32(4)
  21635 	(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(50)
  21636 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(60) // mid-filtering
  21637 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = 0
  21638 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_type = int32(1) // default: strong (so U/V is filtered too)
  21639 	(*WebPConfig)(unsafe.Pointer(config)).Fpartitions = 0
  21640 	(*WebPConfig)(unsafe.Pointer(config)).Fsegments = int32(4)
  21641 	(*WebPConfig)(unsafe.Pointer(config)).Fpass = int32(1)
  21642 	(*WebPConfig)(unsafe.Pointer(config)).Fqmin = 0
  21643 	(*WebPConfig)(unsafe.Pointer(config)).Fqmax = int32(100)
  21644 	(*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed = 0
  21645 	(*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing = 0
  21646 	(*WebPConfig)(unsafe.Pointer(config)).Fautofilter = 0
  21647 	(*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit = 0
  21648 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_compression = int32(1)
  21649 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering = int32(1)
  21650 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_quality = int32(100)
  21651 	(*WebPConfig)(unsafe.Pointer(config)).Flossless = 0
  21652 	(*WebPConfig)(unsafe.Pointer(config)).Fexact = 0
  21653 	(*WebPConfig)(unsafe.Pointer(config)).Fimage_hint = int32(WEBP_HINT_DEFAULT)
  21654 	(*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size = 0
  21655 	(*WebPConfig)(unsafe.Pointer(config)).Fthread_level = 0
  21656 	(*WebPConfig)(unsafe.Pointer(config)).Flow_memory = 0
  21657 	(*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless = int32(100)
  21658 	(*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv = 0
  21659 	// TODO(skal): tune.
  21660 	switch preset {
  21661 	case int32(WEBP_PRESET_PICTURE):
  21662 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(80)
  21663 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(4)
  21664 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(35)
  21665 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21666 	case int32(WEBP_PRESET_PHOTO):
  21667 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(80)
  21668 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(3)
  21669 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(30)
  21670 		**(**int32)(__ccgo_up(config + 68)) |= int32(2)
  21671 	case int32(WEBP_PRESET_DRAWING):
  21672 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(25)
  21673 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(6)
  21674 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(10)
  21675 	case int32(WEBP_PRESET_ICON):
  21676 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = 0
  21677 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = 0     // disable filtering to retain sharpness
  21678 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21679 	case int32(WEBP_PRESET_TEXT):
  21680 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = 0
  21681 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = 0     // disable filtering to retain sharpness
  21682 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21683 		(*WebPConfig)(unsafe.Pointer(config)).Fsegments = int32(2)
  21684 	case int32(WEBP_PRESET_DEFAULT):
  21685 		fallthrough
  21686 	default:
  21687 		break
  21688 	}
  21689 	return WebPValidateConfig(tls, config)
  21690 }
  21691 
  21692 func WebPValidateConfig(tls *libc.TLS, config uintptr) (r int32) {
  21693 	if config == libc.UintptrFromInt32(0) {
  21694 		return 0
  21695 	}
  21696 	if (*WebPConfig)(unsafe.Pointer(config)).Fquality < libc.Float32FromInt32(0) || (*WebPConfig)(unsafe.Pointer(config)).Fquality > libc.Float32FromInt32(100) {
  21697 		return 0
  21698 	}
  21699 	if (*WebPConfig)(unsafe.Pointer(config)).Ftarget_size < 0 {
  21700 		return 0
  21701 	}
  21702 	if (*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR < libc.Float32FromInt32(0) {
  21703 		return 0
  21704 	}
  21705 	if (*WebPConfig)(unsafe.Pointer(config)).Fmethod < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fmethod > int32(6) {
  21706 		return 0
  21707 	}
  21708 	if (*WebPConfig)(unsafe.Pointer(config)).Fsegments < int32(1) || (*WebPConfig)(unsafe.Pointer(config)).Fsegments > int32(4) {
  21709 		return 0
  21710 	}
  21711 	if (*WebPConfig)(unsafe.Pointer(config)).Fsns_strength < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fsns_strength > int32(100) {
  21712 		return 0
  21713 	}
  21714 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength > int32(100) {
  21715 		return 0
  21716 	}
  21717 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness > int32(7) {
  21718 		return 0
  21719 	}
  21720 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type > int32(1) {
  21721 		return 0
  21722 	}
  21723 	if (*WebPConfig)(unsafe.Pointer(config)).Fautofilter < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fautofilter > int32(1) {
  21724 		return 0
  21725 	}
  21726 	if (*WebPConfig)(unsafe.Pointer(config)).Fpass < int32(1) || (*WebPConfig)(unsafe.Pointer(config)).Fpass > int32(10) {
  21727 		return 0
  21728 	}
  21729 	if (*WebPConfig)(unsafe.Pointer(config)).Fqmin < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fqmax > int32(100) || (*WebPConfig)(unsafe.Pointer(config)).Fqmin > (*WebPConfig)(unsafe.Pointer(config)).Fqmax {
  21730 		return 0
  21731 	}
  21732 	if (*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed > int32(1) {
  21733 		return 0
  21734 	}
  21735 	if (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing > int32(7) {
  21736 		return 0
  21737 	}
  21738 	if (*WebPConfig)(unsafe.Pointer(config)).Fpartitions < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpartitions > int32(3) {
  21739 		return 0
  21740 	}
  21741 	if (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit > int32(100) {
  21742 		return 0
  21743 	}
  21744 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_compression < 0 {
  21745 		return 0
  21746 	}
  21747 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering < 0 {
  21748 		return 0
  21749 	}
  21750 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality < 0 || (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality > int32(100) {
  21751 		return 0
  21752 	}
  21753 	if (*WebPConfig)(unsafe.Pointer(config)).Flossless < 0 || (*WebPConfig)(unsafe.Pointer(config)).Flossless > int32(1) {
  21754 		return 0
  21755 	}
  21756 	if (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless > int32(100) {
  21757 		return 0
  21758 	}
  21759 	if (*WebPConfig)(unsafe.Pointer(config)).Fimage_hint >= int32(WEBP_HINT_LAST) {
  21760 		return 0
  21761 	}
  21762 	if (*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size < 0 || (*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size > int32(1) {
  21763 		return 0
  21764 	}
  21765 	if (*WebPConfig)(unsafe.Pointer(config)).Fthread_level < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fthread_level > int32(1) {
  21766 		return 0
  21767 	}
  21768 	if (*WebPConfig)(unsafe.Pointer(config)).Flow_memory < 0 || (*WebPConfig)(unsafe.Pointer(config)).Flow_memory > int32(1) {
  21769 		return 0
  21770 	}
  21771 	if (*WebPConfig)(unsafe.Pointer(config)).Fexact < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fexact > int32(1) {
  21772 		return 0
  21773 	}
  21774 	if (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv > int32(1) {
  21775 		return 0
  21776 	}
  21777 	return int32(1)
  21778 }
  21779 
  21780 //------------------------------------------------------------------------------
  21781 
  21782 // C documentation
  21783 //
  21784 //	// Mapping between -z level and -m / -q parameter settings.
  21785 var kLosslessPresets = [10]struct {
  21786 	Fmethod  uint8_t
  21787 	Fquality uint8_t
  21788 }{
  21789 	0: {},
  21790 	1: {
  21791 		Fmethod:  uint8(1),
  21792 		Fquality: uint8(20),
  21793 	},
  21794 	2: {
  21795 		Fmethod:  uint8(2),
  21796 		Fquality: uint8(25),
  21797 	},
  21798 	3: {
  21799 		Fmethod:  uint8(3),
  21800 		Fquality: uint8(30),
  21801 	},
  21802 	4: {
  21803 		Fmethod:  uint8(3),
  21804 		Fquality: uint8(50),
  21805 	},
  21806 	5: {
  21807 		Fmethod:  uint8(4),
  21808 		Fquality: uint8(50),
  21809 	},
  21810 	6: {
  21811 		Fmethod:  uint8(4),
  21812 		Fquality: uint8(75),
  21813 	},
  21814 	7: {
  21815 		Fmethod:  uint8(4),
  21816 		Fquality: uint8(90),
  21817 	},
  21818 	8: {
  21819 		Fmethod:  uint8(5),
  21820 		Fquality: uint8(90),
  21821 	},
  21822 	9: {
  21823 		Fmethod:  uint8(6),
  21824 		Fquality: uint8(100),
  21825 	},
  21826 }
  21827 
  21828 func WebPConfigLosslessPreset(tls *libc.TLS, config uintptr, level int32) (r int32) {
  21829 	if config == libc.UintptrFromInt32(0) || level < 0 || level > int32(MAX_LEVEL1) {
  21830 		return 0
  21831 	}
  21832 	(*WebPConfig)(unsafe.Pointer(config)).Flossless = int32(1)
  21833 	(*WebPConfig)(unsafe.Pointer(config)).Fmethod = libc.Int32FromUint8(kLosslessPresets[level].Fmethod)
  21834 	(*WebPConfig)(unsafe.Pointer(config)).Fquality = float32(kLosslessPresets[level].Fquality)
  21835 	return int32(1)
  21836 }
  21837 
  21838 type VP8Residual = struct {
  21839 	Ffirst      int32
  21840 	Flast       int32
  21841 	Fcoeffs     uintptr
  21842 	Fcoeff_type int32
  21843 	Fprob       uintptr
  21844 	Fstats      uintptr
  21845 	Fcosts      CostArrayPtr
  21846 }
  21847 
  21848 //------------------------------------------------------------------------------
  21849 
  21850 // Copyright 2011 Google Inc. All Rights Reserved.
  21851 //
  21852 // Use of this source code is governed by a BSD-style license
  21853 // that can be found in the COPYING file in the root of the source
  21854 // tree. An additional intellectual property rights grant can be found
  21855 // in the file PATENTS. All contributing project authors may
  21856 // be found in the AUTHORS file in the root of the source tree.
  21857 // -----------------------------------------------------------------------------
  21858 //
  21859 //   WebP encoder: internal header.
  21860 //
  21861 // Author: Skal (pascal.massimino@gmail.com)
  21862 
  21863 //------------------------------------------------------------------------------
  21864 // Level cost tables
  21865 
  21866 // C documentation
  21867 //
  21868 //	// For each given level, the following table gives the pattern of contexts to
  21869 //	// use for coding it (in [][0]) as well as the bit value to use for each
  21870 //	// context (in [][1]).
  21871 var VP8LevelCodes = [67][2]uint16_t{
  21872 	0: {
  21873 		0: uint16(0x001),
  21874 	},
  21875 	1: {
  21876 		0: uint16(0x007),
  21877 		1: uint16(0x001),
  21878 	},
  21879 	2: {
  21880 		0: uint16(0x00f),
  21881 		1: uint16(0x005),
  21882 	},
  21883 	3: {
  21884 		0: uint16(0x00f),
  21885 		1: uint16(0x00d),
  21886 	},
  21887 	4: {
  21888 		0: uint16(0x033),
  21889 		1: uint16(0x003),
  21890 	},
  21891 	5: {
  21892 		0: uint16(0x033),
  21893 		1: uint16(0x003),
  21894 	},
  21895 	6: {
  21896 		0: uint16(0x033),
  21897 		1: uint16(0x023),
  21898 	},
  21899 	7: {
  21900 		0: uint16(0x033),
  21901 		1: uint16(0x023),
  21902 	},
  21903 	8: {
  21904 		0: uint16(0x033),
  21905 		1: uint16(0x023),
  21906 	},
  21907 	9: {
  21908 		0: uint16(0x033),
  21909 		1: uint16(0x023),
  21910 	},
  21911 	10: {
  21912 		0: uint16(0x0d3),
  21913 		1: uint16(0x013),
  21914 	},
  21915 	11: {
  21916 		0: uint16(0x0d3),
  21917 		1: uint16(0x013),
  21918 	},
  21919 	12: {
  21920 		0: uint16(0x0d3),
  21921 		1: uint16(0x013),
  21922 	},
  21923 	13: {
  21924 		0: uint16(0x0d3),
  21925 		1: uint16(0x013),
  21926 	},
  21927 	14: {
  21928 		0: uint16(0x0d3),
  21929 		1: uint16(0x013),
  21930 	},
  21931 	15: {
  21932 		0: uint16(0x0d3),
  21933 		1: uint16(0x013),
  21934 	},
  21935 	16: {
  21936 		0: uint16(0x0d3),
  21937 		1: uint16(0x013),
  21938 	},
  21939 	17: {
  21940 		0: uint16(0x0d3),
  21941 		1: uint16(0x013),
  21942 	},
  21943 	18: {
  21944 		0: uint16(0x0d3),
  21945 		1: uint16(0x093),
  21946 	},
  21947 	19: {
  21948 		0: uint16(0x0d3),
  21949 		1: uint16(0x093),
  21950 	},
  21951 	20: {
  21952 		0: uint16(0x0d3),
  21953 		1: uint16(0x093),
  21954 	},
  21955 	21: {
  21956 		0: uint16(0x0d3),
  21957 		1: uint16(0x093),
  21958 	},
  21959 	22: {
  21960 		0: uint16(0x0d3),
  21961 		1: uint16(0x093),
  21962 	},
  21963 	23: {
  21964 		0: uint16(0x0d3),
  21965 		1: uint16(0x093),
  21966 	},
  21967 	24: {
  21968 		0: uint16(0x0d3),
  21969 		1: uint16(0x093),
  21970 	},
  21971 	25: {
  21972 		0: uint16(0x0d3),
  21973 		1: uint16(0x093),
  21974 	},
  21975 	26: {
  21976 		0: uint16(0x0d3),
  21977 		1: uint16(0x093),
  21978 	},
  21979 	27: {
  21980 		0: uint16(0x0d3),
  21981 		1: uint16(0x093),
  21982 	},
  21983 	28: {
  21984 		0: uint16(0x0d3),
  21985 		1: uint16(0x093),
  21986 	},
  21987 	29: {
  21988 		0: uint16(0x0d3),
  21989 		1: uint16(0x093),
  21990 	},
  21991 	30: {
  21992 		0: uint16(0x0d3),
  21993 		1: uint16(0x093),
  21994 	},
  21995 	31: {
  21996 		0: uint16(0x0d3),
  21997 		1: uint16(0x093),
  21998 	},
  21999 	32: {
  22000 		0: uint16(0x0d3),
  22001 		1: uint16(0x093),
  22002 	},
  22003 	33: {
  22004 		0: uint16(0x0d3),
  22005 		1: uint16(0x093),
  22006 	},
  22007 	34: {
  22008 		0: uint16(0x153),
  22009 		1: uint16(0x053),
  22010 	},
  22011 	35: {
  22012 		0: uint16(0x153),
  22013 		1: uint16(0x053),
  22014 	},
  22015 	36: {
  22016 		0: uint16(0x153),
  22017 		1: uint16(0x053),
  22018 	},
  22019 	37: {
  22020 		0: uint16(0x153),
  22021 		1: uint16(0x053),
  22022 	},
  22023 	38: {
  22024 		0: uint16(0x153),
  22025 		1: uint16(0x053),
  22026 	},
  22027 	39: {
  22028 		0: uint16(0x153),
  22029 		1: uint16(0x053),
  22030 	},
  22031 	40: {
  22032 		0: uint16(0x153),
  22033 		1: uint16(0x053),
  22034 	},
  22035 	41: {
  22036 		0: uint16(0x153),
  22037 		1: uint16(0x053),
  22038 	},
  22039 	42: {
  22040 		0: uint16(0x153),
  22041 		1: uint16(0x053),
  22042 	},
  22043 	43: {
  22044 		0: uint16(0x153),
  22045 		1: uint16(0x053),
  22046 	},
  22047 	44: {
  22048 		0: uint16(0x153),
  22049 		1: uint16(0x053),
  22050 	},
  22051 	45: {
  22052 		0: uint16(0x153),
  22053 		1: uint16(0x053),
  22054 	},
  22055 	46: {
  22056 		0: uint16(0x153),
  22057 		1: uint16(0x053),
  22058 	},
  22059 	47: {
  22060 		0: uint16(0x153),
  22061 		1: uint16(0x053),
  22062 	},
  22063 	48: {
  22064 		0: uint16(0x153),
  22065 		1: uint16(0x053),
  22066 	},
  22067 	49: {
  22068 		0: uint16(0x153),
  22069 		1: uint16(0x053),
  22070 	},
  22071 	50: {
  22072 		0: uint16(0x153),
  22073 		1: uint16(0x053),
  22074 	},
  22075 	51: {
  22076 		0: uint16(0x153),
  22077 		1: uint16(0x053),
  22078 	},
  22079 	52: {
  22080 		0: uint16(0x153),
  22081 		1: uint16(0x053),
  22082 	},
  22083 	53: {
  22084 		0: uint16(0x153),
  22085 		1: uint16(0x053),
  22086 	},
  22087 	54: {
  22088 		0: uint16(0x153),
  22089 		1: uint16(0x053),
  22090 	},
  22091 	55: {
  22092 		0: uint16(0x153),
  22093 		1: uint16(0x053),
  22094 	},
  22095 	56: {
  22096 		0: uint16(0x153),
  22097 		1: uint16(0x053),
  22098 	},
  22099 	57: {
  22100 		0: uint16(0x153),
  22101 		1: uint16(0x053),
  22102 	},
  22103 	58: {
  22104 		0: uint16(0x153),
  22105 		1: uint16(0x053),
  22106 	},
  22107 	59: {
  22108 		0: uint16(0x153),
  22109 		1: uint16(0x053),
  22110 	},
  22111 	60: {
  22112 		0: uint16(0x153),
  22113 		1: uint16(0x053),
  22114 	},
  22115 	61: {
  22116 		0: uint16(0x153),
  22117 		1: uint16(0x053),
  22118 	},
  22119 	62: {
  22120 		0: uint16(0x153),
  22121 		1: uint16(0x053),
  22122 	},
  22123 	63: {
  22124 		0: uint16(0x153),
  22125 		1: uint16(0x053),
  22126 	},
  22127 	64: {
  22128 		0: uint16(0x153),
  22129 		1: uint16(0x053),
  22130 	},
  22131 	65: {
  22132 		0: uint16(0x153),
  22133 		1: uint16(0x053),
  22134 	},
  22135 	66: {
  22136 		0: uint16(0x153),
  22137 		1: uint16(0x153),
  22138 	},
  22139 }
  22140 
  22141 func VariableLevelCost(tls *libc.TLS, level int32, probas uintptr) (r int32) {
  22142 	var bits, cost, i, pattern, v3, v5 int32
  22143 	var v2 uint8_t
  22144 	_, _, _, _, _, _, _ = bits, cost, i, pattern, v2, v3, v5
  22145 	pattern = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(level-int32(1))*4)))
  22146 	bits = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(level-int32(1))*4 + 1*2)))
  22147 	cost = 0
  22148 	i = int32(2)
  22149 	for {
  22150 		if !(pattern != 0) {
  22151 			break
  22152 		}
  22153 		if pattern&int32(1) != 0 {
  22154 			v2 = **(**uint8_t)(__ccgo_up(probas + uintptr(i)))
  22155 			if !(bits&int32(1) != 0) {
  22156 				v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  22157 			} else {
  22158 				v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  22159 			}
  22160 			v3 = v5
  22161 			goto _4
  22162 		_4:
  22163 			cost = cost + v3
  22164 		}
  22165 		bits = bits >> int32(1)
  22166 		pattern = pattern >> int32(1)
  22167 		goto _1
  22168 	_1:
  22169 		;
  22170 		i = i + 1
  22171 	}
  22172 	return cost
  22173 }
  22174 
  22175 //------------------------------------------------------------------------------
  22176 // Pre-calc level costs once for all
  22177 
  22178 func VP8CalculateLevelCosts(tls *libc.TLS, proba1 uintptr) {
  22179 	var band, cost0, cost_base, ctx, ctype, n, v, v10, v12, v14, v16, v4, v6, v8 int32
  22180 	var p, table uintptr
  22181 	var v13, v5, v9 uint8_t
  22182 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = band, cost0, cost_base, ctx, ctype, n, p, table, v, v10, v12, v13, v14, v16, v4, v5, v6, v8, v9
  22183 	if !((*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty != 0) {
  22184 		return
  22185 	} // nothing to do.
  22186 	ctype = 0
  22187 	for {
  22188 		if !(ctype < int32(NUM_TYPES)) {
  22189 			break
  22190 		}
  22191 		band = 0
  22192 		for {
  22193 			if !(band < int32(NUM_BANDS)) {
  22194 				break
  22195 			}
  22196 			ctx = 0
  22197 			for {
  22198 				if !(ctx < int32(NUM_CTX)) {
  22199 					break
  22200 				}
  22201 				p = proba1 + 4 + uintptr(ctype)*264 + uintptr(band)*33 + uintptr(ctx)*11
  22202 				table = proba1 + 5284 + uintptr(ctype)*3264 + uintptr(band)*408 + uintptr(ctx)*136
  22203 				if ctx > 0 {
  22204 					v5 = **(**uint8_t)(__ccgo_up(p))
  22205 					if !(int32(1) != 0) {
  22206 						v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  22207 					} else {
  22208 						v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  22209 					}
  22210 					v6 = v8
  22211 					goto _7
  22212 				_7:
  22213 					v4 = v6
  22214 				} else {
  22215 					v4 = 0
  22216 				}
  22217 				cost0 = v4
  22218 				v9 = **(**uint8_t)(__ccgo_up(p + 1))
  22219 				if !(int32(1) != 0) {
  22220 					v12 = libc.Int32FromUint16(VP8EntropyCost[v9])
  22221 				} else {
  22222 					v12 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v9)])
  22223 				}
  22224 				v10 = v12
  22225 				goto _11
  22226 			_11:
  22227 				cost_base = v10 + cost0
  22228 				v13 = **(**uint8_t)(__ccgo_up(p + 1))
  22229 				if !(0 != 0) {
  22230 					v16 = libc.Int32FromUint16(VP8EntropyCost[v13])
  22231 				} else {
  22232 					v16 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v13)])
  22233 				}
  22234 				v14 = v16
  22235 				goto _15
  22236 			_15:
  22237 				**(**uint16_t)(__ccgo_up(table)) = libc.Uint16FromInt32(v14 + cost0)
  22238 				v = int32(1)
  22239 				for {
  22240 					if !(v <= int32(MAX_VARIABLE_LEVEL)) {
  22241 						break
  22242 					}
  22243 					**(**uint16_t)(__ccgo_up(table + uintptr(v)*2)) = libc.Uint16FromInt32(cost_base + VariableLevelCost(tls, v, p))
  22244 					goto _17
  22245 				_17:
  22246 					;
  22247 					v = v + 1
  22248 				}
  22249 				// Starting at level 67 and up, the variable part of the cost is
  22250 				// actually constant.
  22251 				goto _3
  22252 			_3:
  22253 				;
  22254 				ctx = ctx + 1
  22255 			}
  22256 			goto _2
  22257 		_2:
  22258 			;
  22259 			band = band + 1
  22260 		}
  22261 		n = 0
  22262 		for {
  22263 			if !(n < int32(16)) {
  22264 				break
  22265 			} // replicate bands. We don't need to sentinel.
  22266 			ctx = 0
  22267 			for {
  22268 				if !(ctx < int32(NUM_CTX)) {
  22269 					break
  22270 				}
  22271 				**(**uintptr)(__ccgo_up(proba1 + 18344 + uintptr(ctype)*384 + uintptr(n)*24 + uintptr(ctx)*8)) = proba1 + 5284 + uintptr(ctype)*3264 + uintptr(VP8EncBands[n])*408 + uintptr(ctx)*136
  22272 				goto _19
  22273 			_19:
  22274 				;
  22275 				ctx = ctx + 1
  22276 			}
  22277 			goto _18
  22278 		_18:
  22279 			;
  22280 			n = n + 1
  22281 		}
  22282 		goto _1
  22283 	_1:
  22284 		;
  22285 		ctype = ctype + 1
  22286 	}
  22287 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty = 0
  22288 }
  22289 
  22290 //------------------------------------------------------------------------------
  22291 // helper functions for residuals struct VP8Residual.
  22292 
  22293 func VP8InitResidual(tls *libc.TLS, first int32, coeff_type int32, enc uintptr, res uintptr) {
  22294 	(*VP8Residual)(unsafe.Pointer(res)).Fcoeff_type = coeff_type
  22295 	(*VP8Residual)(unsafe.Pointer(res)).Fprob = enc + 3616 + 4 + uintptr(coeff_type)*264
  22296 	(*VP8Residual)(unsafe.Pointer(res)).Fstats = enc + 3616 + 1060 + uintptr(coeff_type)*1056
  22297 	(*VP8Residual)(unsafe.Pointer(res)).Fcosts = enc + 3616 + 18344 + uintptr(coeff_type)*384
  22298 	(*VP8Residual)(unsafe.Pointer(res)).Ffirst = first
  22299 }
  22300 
  22301 //------------------------------------------------------------------------------
  22302 // Mode costs
  22303 
  22304 func VP8GetCostLuma4(tls *libc.TLS, it uintptr, levels uintptr) (r int32) {
  22305 	bp := tls.Alloc(48)
  22306 	defer tls.Free(48)
  22307 	var R, ctx, x, y int32
  22308 	var enc uintptr
  22309 	var _ /* res at bp+0 */ VP8Residual
  22310 	_, _, _, _, _ = R, ctx, enc, x, y
  22311 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & libc.Int32FromInt32(3)
  22312 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> libc.Int32FromInt32(2)
  22313 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22314 	R = 0
  22315 	VP8InitResidual(tls, 0, int32(3), enc, bp)
  22316 	ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  22317 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, levels, bp)
  22318 	R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22319 	return R
  22320 }
  22321 
  22322 func VP8GetCostLuma16(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  22323 	bp := tls.Alloc(48)
  22324 	defer tls.Free(48)
  22325 	var R, ctx, x, y, v3 int32
  22326 	var enc uintptr
  22327 	var _ /* res at bp+0 */ VP8Residual
  22328 	_, _, _, _, _, _ = R, ctx, enc, x, y, v3
  22329 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22330 	R = 0
  22331 	VP8IteratorNzToBytes(tls, it) // re-import the non-zero context
  22332 	// DC
  22333 	VP8InitResidual(tls, 0, int32(1), enc, bp)
  22334 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  22335 	R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, **(**int32)(__ccgo_up(it + 132 + 8*4))+**(**int32)(__ccgo_up(it + 168 + 8*4)), bp)
  22336 	// AC
  22337 	VP8InitResidual(tls, int32(1), 0, enc, bp)
  22338 	y = 0
  22339 	for {
  22340 		if !(y < int32(4)) {
  22341 			break
  22342 		}
  22343 		x = 0
  22344 		for {
  22345 			if !(x < int32(4)) {
  22346 				break
  22347 			}
  22348 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  22349 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  22350 			R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22351 			v3 = libc.BoolInt32((**(**VP8Residual)(__ccgo_up(bp))).Flast >= libc.Int32FromInt32(0))
  22352 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v3
  22353 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v3
  22354 			goto _2
  22355 		_2:
  22356 			;
  22357 			x = x + 1
  22358 		}
  22359 		goto _1
  22360 	_1:
  22361 		;
  22362 		y = y + 1
  22363 	}
  22364 	return R
  22365 }
  22366 
  22367 func VP8GetCostUV(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  22368 	bp := tls.Alloc(48)
  22369 	defer tls.Free(48)
  22370 	var R, ch, ctx, x, y, v4 int32
  22371 	var enc uintptr
  22372 	var _ /* res at bp+0 */ VP8Residual
  22373 	_, _, _, _, _, _, _ = R, ch, ctx, enc, x, y, v4
  22374 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22375 	R = 0
  22376 	VP8IteratorNzToBytes(tls, it) // re-import the non-zero context
  22377 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  22378 	ch = 0
  22379 	for {
  22380 		if !(ch <= int32(2)) {
  22381 			break
  22382 		}
  22383 		y = 0
  22384 		for {
  22385 			if !(y < int32(2)) {
  22386 				break
  22387 			}
  22388 			x = 0
  22389 			for {
  22390 				if !(x < int32(2)) {
  22391 					break
  22392 				}
  22393 				ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  22394 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  22395 				R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22396 				v4 = libc.BoolInt32((**(**VP8Residual)(__ccgo_up(bp))).Flast >= libc.Int32FromInt32(0))
  22397 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v4
  22398 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v4
  22399 				goto _3
  22400 			_3:
  22401 				;
  22402 				x = x + 1
  22403 			}
  22404 			goto _2
  22405 		_2:
  22406 			;
  22407 			y = y + 1
  22408 		}
  22409 		goto _1
  22410 	_1:
  22411 		;
  22412 		ch = ch + int32(2)
  22413 	}
  22414 	return R
  22415 }
  22416 
  22417 //------------------------------------------------------------------------------
  22418 // Recording of token probabilities.
  22419 
  22420 // We keep the table-free variant around for reference, in case.
  22421 
  22422 // C documentation
  22423 //
  22424 //	// Simulate block coding, but only record statistics.
  22425 //	// Note: no need to record the fixed probas.
  22426 func VP8RecordCoeffs(tls *libc.TLS, ctx int32, res uintptr) (r int32) {
  22427 	var bits, i, mask, n, pattern, v, v1, v4, v7 int32
  22428 	var p proba_t
  22429 	var s, v2 uintptr
  22430 	_, _, _, _, _, _, _, _, _, _, _, _ = bits, i, mask, n, p, pattern, s, v, v1, v2, v4, v7
  22431 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  22432 	// should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
  22433 	s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(n)*132 + uintptr(ctx)*44
  22434 	if (*VP8Residual)(unsafe.Pointer(res)).Flast < 0 {
  22435 		v1 = 0
  22436 		v2 = s + uintptr(0)*4
  22437 		p = **(**proba_t)(__ccgo_up(v2))
  22438 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22439 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22440 		}
  22441 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22442 		**(**proba_t)(__ccgo_up(v2)) = p
  22443 		_ = v1
  22444 		goto _3
  22445 	_3:
  22446 		;
  22447 		return 0
  22448 	}
  22449 	for n <= (*VP8Residual)(unsafe.Pointer(res)).Flast {
  22450 		v1 = int32(1)
  22451 		v2 = s + uintptr(0)*4
  22452 		p = **(**proba_t)(__ccgo_up(v2))
  22453 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22454 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22455 		}
  22456 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22457 		**(**proba_t)(__ccgo_up(v2)) = p
  22458 		_ = v1
  22459 		goto _6
  22460 	_6:
  22461 		; // order of record doesn't matter
  22462 		for {
  22463 			v4 = n
  22464 			n = n + 1
  22465 			v1 = int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(v4)*2)))
  22466 			v = v1
  22467 			if !(v1 == 0) {
  22468 				break
  22469 			}
  22470 			v7 = 0
  22471 			v2 = s + uintptr(1)*4
  22472 			p = **(**proba_t)(__ccgo_up(v2))
  22473 			if p >= libc.Uint32FromUint32(0xfffe0000) {
  22474 				p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22475 			}
  22476 			p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v7))
  22477 			**(**proba_t)(__ccgo_up(v2)) = p
  22478 			_ = v7
  22479 			goto _11
  22480 		_11:
  22481 			;
  22482 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132
  22483 		}
  22484 		v1 = int32(1)
  22485 		v2 = s + uintptr(1)*4
  22486 		p = **(**proba_t)(__ccgo_up(v2))
  22487 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22488 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22489 		}
  22490 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22491 		**(**proba_t)(__ccgo_up(v2)) = p
  22492 		_ = v1
  22493 		goto _14
  22494 	_14:
  22495 		;
  22496 		v1 = libc.BoolInt32(uint32(2) < libc.Uint32FromInt32(v+libc.Int32FromInt32(1)))
  22497 		v2 = s + uintptr(2)*4
  22498 		p = **(**proba_t)(__ccgo_up(v2))
  22499 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22500 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22501 		}
  22502 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22503 		**(**proba_t)(__ccgo_up(v2)) = p
  22504 		v4 = v1
  22505 		goto _18
  22506 	_18:
  22507 		if !(v4 != 0) { // v = -1 or 1
  22508 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 1*44
  22509 		} else {
  22510 			v = libc.Xabs(tls, v)
  22511 			if v > int32(MAX_VARIABLE_LEVEL) {
  22512 				v = int32(MAX_VARIABLE_LEVEL)
  22513 			}
  22514 			bits = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(v-int32(1))*4 + 1*2)))
  22515 			pattern = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(v-int32(1))*4)))
  22516 			i = 0
  22517 			for {
  22518 				pattern = pattern >> int32(1)
  22519 				if !(pattern != 0) {
  22520 					break
  22521 				}
  22522 				mask = int32(2) << i
  22523 				if pattern&int32(1) != 0 {
  22524 					v1 = libc.BoolInt32(!!(bits&mask != 0))
  22525 					v2 = s + uintptr(3)*4 + uintptr(i)*4
  22526 					p = **(**proba_t)(__ccgo_up(v2))
  22527 					if p >= libc.Uint32FromUint32(0xfffe0000) {
  22528 						p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22529 					}
  22530 					p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22531 					**(**proba_t)(__ccgo_up(v2)) = p
  22532 					_ = v1
  22533 					goto _22
  22534 				_22:
  22535 				}
  22536 				goto _19
  22537 			_19:
  22538 				;
  22539 				i = i + 1
  22540 			}
  22541 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 2*44
  22542 		}
  22543 	}
  22544 	if n < int32(16) {
  22545 		v1 = 0
  22546 		v2 = s + uintptr(0)*4
  22547 		p = **(**proba_t)(__ccgo_up(v2))
  22548 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22549 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22550 		}
  22551 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22552 		**(**proba_t)(__ccgo_up(v2)) = p
  22553 		_ = v1
  22554 		goto _25
  22555 	_25:
  22556 	}
  22557 	return int32(1)
  22558 }
  22559 
  22560 const MAX_DELTA_SIZE = 64
  22561 
  22562 //------------------------------------------------------------------------------
  22563 
  22564 // C documentation
  22565 //
  22566 //	// This table gives, for a given sharpness, the filtering strength to be
  22567 //	// used (at least) in order to filter a given edge step delta.
  22568 //	// This is constructed by brute force inspection: for all delta, we iterate
  22569 //	// over all possible filtering strength / thresh until needs_filter() returns
  22570 //	// true.
  22571 var kLevelsFromDelta = [8][64]uint8_t{
  22572 	0: {
  22573 		1:  uint8(1),
  22574 		2:  uint8(2),
  22575 		3:  uint8(3),
  22576 		4:  uint8(4),
  22577 		5:  uint8(5),
  22578 		6:  uint8(6),
  22579 		7:  uint8(7),
  22580 		8:  uint8(8),
  22581 		9:  uint8(9),
  22582 		10: uint8(10),
  22583 		11: uint8(11),
  22584 		12: uint8(12),
  22585 		13: uint8(13),
  22586 		14: uint8(14),
  22587 		15: uint8(15),
  22588 		16: uint8(16),
  22589 		17: uint8(17),
  22590 		18: uint8(18),
  22591 		19: uint8(19),
  22592 		20: uint8(20),
  22593 		21: uint8(21),
  22594 		22: uint8(22),
  22595 		23: uint8(23),
  22596 		24: uint8(24),
  22597 		25: uint8(25),
  22598 		26: uint8(26),
  22599 		27: uint8(27),
  22600 		28: uint8(28),
  22601 		29: uint8(29),
  22602 		30: uint8(30),
  22603 		31: uint8(31),
  22604 		32: uint8(32),
  22605 		33: uint8(33),
  22606 		34: uint8(34),
  22607 		35: uint8(35),
  22608 		36: uint8(36),
  22609 		37: uint8(37),
  22610 		38: uint8(38),
  22611 		39: uint8(39),
  22612 		40: uint8(40),
  22613 		41: uint8(41),
  22614 		42: uint8(42),
  22615 		43: uint8(43),
  22616 		44: uint8(44),
  22617 		45: uint8(45),
  22618 		46: uint8(46),
  22619 		47: uint8(47),
  22620 		48: uint8(48),
  22621 		49: uint8(49),
  22622 		50: uint8(50),
  22623 		51: uint8(51),
  22624 		52: uint8(52),
  22625 		53: uint8(53),
  22626 		54: uint8(54),
  22627 		55: uint8(55),
  22628 		56: uint8(56),
  22629 		57: uint8(57),
  22630 		58: uint8(58),
  22631 		59: uint8(59),
  22632 		60: uint8(60),
  22633 		61: uint8(61),
  22634 		62: uint8(62),
  22635 		63: uint8(63),
  22636 	},
  22637 	1: {
  22638 		1:  uint8(1),
  22639 		2:  uint8(2),
  22640 		3:  uint8(3),
  22641 		4:  uint8(5),
  22642 		5:  uint8(6),
  22643 		6:  uint8(7),
  22644 		7:  uint8(8),
  22645 		8:  uint8(9),
  22646 		9:  uint8(11),
  22647 		10: uint8(12),
  22648 		11: uint8(13),
  22649 		12: uint8(14),
  22650 		13: uint8(15),
  22651 		14: uint8(17),
  22652 		15: uint8(18),
  22653 		16: uint8(20),
  22654 		17: uint8(21),
  22655 		18: uint8(23),
  22656 		19: uint8(24),
  22657 		20: uint8(26),
  22658 		21: uint8(27),
  22659 		22: uint8(29),
  22660 		23: uint8(30),
  22661 		24: uint8(32),
  22662 		25: uint8(33),
  22663 		26: uint8(35),
  22664 		27: uint8(36),
  22665 		28: uint8(38),
  22666 		29: uint8(39),
  22667 		30: uint8(41),
  22668 		31: uint8(42),
  22669 		32: uint8(44),
  22670 		33: uint8(45),
  22671 		34: uint8(47),
  22672 		35: uint8(48),
  22673 		36: uint8(50),
  22674 		37: uint8(51),
  22675 		38: uint8(53),
  22676 		39: uint8(54),
  22677 		40: uint8(56),
  22678 		41: uint8(57),
  22679 		42: uint8(59),
  22680 		43: uint8(60),
  22681 		44: uint8(62),
  22682 		45: uint8(63),
  22683 		46: uint8(63),
  22684 		47: uint8(63),
  22685 		48: uint8(63),
  22686 		49: uint8(63),
  22687 		50: uint8(63),
  22688 		51: uint8(63),
  22689 		52: uint8(63),
  22690 		53: uint8(63),
  22691 		54: uint8(63),
  22692 		55: uint8(63),
  22693 		56: uint8(63),
  22694 		57: uint8(63),
  22695 		58: uint8(63),
  22696 		59: uint8(63),
  22697 		60: uint8(63),
  22698 		61: uint8(63),
  22699 		62: uint8(63),
  22700 		63: uint8(63),
  22701 	},
  22702 	2: {
  22703 		1:  uint8(1),
  22704 		2:  uint8(2),
  22705 		3:  uint8(3),
  22706 		4:  uint8(5),
  22707 		5:  uint8(6),
  22708 		6:  uint8(7),
  22709 		7:  uint8(8),
  22710 		8:  uint8(9),
  22711 		9:  uint8(11),
  22712 		10: uint8(12),
  22713 		11: uint8(13),
  22714 		12: uint8(14),
  22715 		13: uint8(16),
  22716 		14: uint8(17),
  22717 		15: uint8(19),
  22718 		16: uint8(20),
  22719 		17: uint8(22),
  22720 		18: uint8(23),
  22721 		19: uint8(25),
  22722 		20: uint8(26),
  22723 		21: uint8(28),
  22724 		22: uint8(29),
  22725 		23: uint8(31),
  22726 		24: uint8(32),
  22727 		25: uint8(34),
  22728 		26: uint8(35),
  22729 		27: uint8(37),
  22730 		28: uint8(38),
  22731 		29: uint8(40),
  22732 		30: uint8(41),
  22733 		31: uint8(43),
  22734 		32: uint8(44),
  22735 		33: uint8(46),
  22736 		34: uint8(47),
  22737 		35: uint8(49),
  22738 		36: uint8(50),
  22739 		37: uint8(52),
  22740 		38: uint8(53),
  22741 		39: uint8(55),
  22742 		40: uint8(56),
  22743 		41: uint8(58),
  22744 		42: uint8(59),
  22745 		43: uint8(61),
  22746 		44: uint8(62),
  22747 		45: uint8(63),
  22748 		46: uint8(63),
  22749 		47: uint8(63),
  22750 		48: uint8(63),
  22751 		49: uint8(63),
  22752 		50: uint8(63),
  22753 		51: uint8(63),
  22754 		52: uint8(63),
  22755 		53: uint8(63),
  22756 		54: uint8(63),
  22757 		55: uint8(63),
  22758 		56: uint8(63),
  22759 		57: uint8(63),
  22760 		58: uint8(63),
  22761 		59: uint8(63),
  22762 		60: uint8(63),
  22763 		61: uint8(63),
  22764 		62: uint8(63),
  22765 		63: uint8(63),
  22766 	},
  22767 	3: {
  22768 		1:  uint8(1),
  22769 		2:  uint8(2),
  22770 		3:  uint8(3),
  22771 		4:  uint8(5),
  22772 		5:  uint8(6),
  22773 		6:  uint8(7),
  22774 		7:  uint8(8),
  22775 		8:  uint8(9),
  22776 		9:  uint8(11),
  22777 		10: uint8(12),
  22778 		11: uint8(13),
  22779 		12: uint8(15),
  22780 		13: uint8(16),
  22781 		14: uint8(18),
  22782 		15: uint8(19),
  22783 		16: uint8(21),
  22784 		17: uint8(22),
  22785 		18: uint8(24),
  22786 		19: uint8(25),
  22787 		20: uint8(27),
  22788 		21: uint8(28),
  22789 		22: uint8(30),
  22790 		23: uint8(31),
  22791 		24: uint8(33),
  22792 		25: uint8(34),
  22793 		26: uint8(36),
  22794 		27: uint8(37),
  22795 		28: uint8(39),
  22796 		29: uint8(40),
  22797 		30: uint8(42),
  22798 		31: uint8(43),
  22799 		32: uint8(45),
  22800 		33: uint8(46),
  22801 		34: uint8(48),
  22802 		35: uint8(49),
  22803 		36: uint8(51),
  22804 		37: uint8(52),
  22805 		38: uint8(54),
  22806 		39: uint8(55),
  22807 		40: uint8(57),
  22808 		41: uint8(58),
  22809 		42: uint8(60),
  22810 		43: uint8(61),
  22811 		44: uint8(63),
  22812 		45: uint8(63),
  22813 		46: uint8(63),
  22814 		47: uint8(63),
  22815 		48: uint8(63),
  22816 		49: uint8(63),
  22817 		50: uint8(63),
  22818 		51: uint8(63),
  22819 		52: uint8(63),
  22820 		53: uint8(63),
  22821 		54: uint8(63),
  22822 		55: uint8(63),
  22823 		56: uint8(63),
  22824 		57: uint8(63),
  22825 		58: uint8(63),
  22826 		59: uint8(63),
  22827 		60: uint8(63),
  22828 		61: uint8(63),
  22829 		62: uint8(63),
  22830 		63: uint8(63),
  22831 	},
  22832 	4: {
  22833 		1:  uint8(1),
  22834 		2:  uint8(2),
  22835 		3:  uint8(3),
  22836 		4:  uint8(5),
  22837 		5:  uint8(6),
  22838 		6:  uint8(7),
  22839 		7:  uint8(8),
  22840 		8:  uint8(9),
  22841 		9:  uint8(11),
  22842 		10: uint8(12),
  22843 		11: uint8(14),
  22844 		12: uint8(15),
  22845 		13: uint8(17),
  22846 		14: uint8(18),
  22847 		15: uint8(20),
  22848 		16: uint8(21),
  22849 		17: uint8(23),
  22850 		18: uint8(24),
  22851 		19: uint8(26),
  22852 		20: uint8(27),
  22853 		21: uint8(29),
  22854 		22: uint8(30),
  22855 		23: uint8(32),
  22856 		24: uint8(33),
  22857 		25: uint8(35),
  22858 		26: uint8(36),
  22859 		27: uint8(38),
  22860 		28: uint8(39),
  22861 		29: uint8(41),
  22862 		30: uint8(42),
  22863 		31: uint8(44),
  22864 		32: uint8(45),
  22865 		33: uint8(47),
  22866 		34: uint8(48),
  22867 		35: uint8(50),
  22868 		36: uint8(51),
  22869 		37: uint8(53),
  22870 		38: uint8(54),
  22871 		39: uint8(56),
  22872 		40: uint8(57),
  22873 		41: uint8(59),
  22874 		42: uint8(60),
  22875 		43: uint8(62),
  22876 		44: uint8(63),
  22877 		45: uint8(63),
  22878 		46: uint8(63),
  22879 		47: uint8(63),
  22880 		48: uint8(63),
  22881 		49: uint8(63),
  22882 		50: uint8(63),
  22883 		51: uint8(63),
  22884 		52: uint8(63),
  22885 		53: uint8(63),
  22886 		54: uint8(63),
  22887 		55: uint8(63),
  22888 		56: uint8(63),
  22889 		57: uint8(63),
  22890 		58: uint8(63),
  22891 		59: uint8(63),
  22892 		60: uint8(63),
  22893 		61: uint8(63),
  22894 		62: uint8(63),
  22895 		63: uint8(63),
  22896 	},
  22897 	5: {
  22898 		1:  uint8(1),
  22899 		2:  uint8(2),
  22900 		3:  uint8(4),
  22901 		4:  uint8(5),
  22902 		5:  uint8(7),
  22903 		6:  uint8(8),
  22904 		7:  uint8(9),
  22905 		8:  uint8(11),
  22906 		9:  uint8(12),
  22907 		10: uint8(13),
  22908 		11: uint8(15),
  22909 		12: uint8(16),
  22910 		13: uint8(17),
  22911 		14: uint8(19),
  22912 		15: uint8(20),
  22913 		16: uint8(22),
  22914 		17: uint8(23),
  22915 		18: uint8(25),
  22916 		19: uint8(26),
  22917 		20: uint8(28),
  22918 		21: uint8(29),
  22919 		22: uint8(31),
  22920 		23: uint8(32),
  22921 		24: uint8(34),
  22922 		25: uint8(35),
  22923 		26: uint8(37),
  22924 		27: uint8(38),
  22925 		28: uint8(40),
  22926 		29: uint8(41),
  22927 		30: uint8(43),
  22928 		31: uint8(44),
  22929 		32: uint8(46),
  22930 		33: uint8(47),
  22931 		34: uint8(49),
  22932 		35: uint8(50),
  22933 		36: uint8(52),
  22934 		37: uint8(53),
  22935 		38: uint8(55),
  22936 		39: uint8(56),
  22937 		40: uint8(58),
  22938 		41: uint8(59),
  22939 		42: uint8(61),
  22940 		43: uint8(62),
  22941 		44: uint8(63),
  22942 		45: uint8(63),
  22943 		46: uint8(63),
  22944 		47: uint8(63),
  22945 		48: uint8(63),
  22946 		49: uint8(63),
  22947 		50: uint8(63),
  22948 		51: uint8(63),
  22949 		52: uint8(63),
  22950 		53: uint8(63),
  22951 		54: uint8(63),
  22952 		55: uint8(63),
  22953 		56: uint8(63),
  22954 		57: uint8(63),
  22955 		58: uint8(63),
  22956 		59: uint8(63),
  22957 		60: uint8(63),
  22958 		61: uint8(63),
  22959 		62: uint8(63),
  22960 		63: uint8(63),
  22961 	},
  22962 	6: {
  22963 		1:  uint8(1),
  22964 		2:  uint8(2),
  22965 		3:  uint8(4),
  22966 		4:  uint8(5),
  22967 		5:  uint8(7),
  22968 		6:  uint8(8),
  22969 		7:  uint8(9),
  22970 		8:  uint8(11),
  22971 		9:  uint8(12),
  22972 		10: uint8(13),
  22973 		11: uint8(15),
  22974 		12: uint8(16),
  22975 		13: uint8(18),
  22976 		14: uint8(19),
  22977 		15: uint8(21),
  22978 		16: uint8(22),
  22979 		17: uint8(24),
  22980 		18: uint8(25),
  22981 		19: uint8(27),
  22982 		20: uint8(28),
  22983 		21: uint8(30),
  22984 		22: uint8(31),
  22985 		23: uint8(33),
  22986 		24: uint8(34),
  22987 		25: uint8(36),
  22988 		26: uint8(37),
  22989 		27: uint8(39),
  22990 		28: uint8(40),
  22991 		29: uint8(42),
  22992 		30: uint8(43),
  22993 		31: uint8(45),
  22994 		32: uint8(46),
  22995 		33: uint8(48),
  22996 		34: uint8(49),
  22997 		35: uint8(51),
  22998 		36: uint8(52),
  22999 		37: uint8(54),
  23000 		38: uint8(55),
  23001 		39: uint8(57),
  23002 		40: uint8(58),
  23003 		41: uint8(60),
  23004 		42: uint8(61),
  23005 		43: uint8(63),
  23006 		44: uint8(63),
  23007 		45: uint8(63),
  23008 		46: uint8(63),
  23009 		47: uint8(63),
  23010 		48: uint8(63),
  23011 		49: uint8(63),
  23012 		50: uint8(63),
  23013 		51: uint8(63),
  23014 		52: uint8(63),
  23015 		53: uint8(63),
  23016 		54: uint8(63),
  23017 		55: uint8(63),
  23018 		56: uint8(63),
  23019 		57: uint8(63),
  23020 		58: uint8(63),
  23021 		59: uint8(63),
  23022 		60: uint8(63),
  23023 		61: uint8(63),
  23024 		62: uint8(63),
  23025 		63: uint8(63),
  23026 	},
  23027 	7: {
  23028 		1:  uint8(1),
  23029 		2:  uint8(2),
  23030 		3:  uint8(4),
  23031 		4:  uint8(5),
  23032 		5:  uint8(7),
  23033 		6:  uint8(8),
  23034 		7:  uint8(9),
  23035 		8:  uint8(11),
  23036 		9:  uint8(12),
  23037 		10: uint8(14),
  23038 		11: uint8(15),
  23039 		12: uint8(17),
  23040 		13: uint8(18),
  23041 		14: uint8(20),
  23042 		15: uint8(21),
  23043 		16: uint8(23),
  23044 		17: uint8(24),
  23045 		18: uint8(26),
  23046 		19: uint8(27),
  23047 		20: uint8(29),
  23048 		21: uint8(30),
  23049 		22: uint8(32),
  23050 		23: uint8(33),
  23051 		24: uint8(35),
  23052 		25: uint8(36),
  23053 		26: uint8(38),
  23054 		27: uint8(39),
  23055 		28: uint8(41),
  23056 		29: uint8(42),
  23057 		30: uint8(44),
  23058 		31: uint8(45),
  23059 		32: uint8(47),
  23060 		33: uint8(48),
  23061 		34: uint8(50),
  23062 		35: uint8(51),
  23063 		36: uint8(53),
  23064 		37: uint8(54),
  23065 		38: uint8(56),
  23066 		39: uint8(57),
  23067 		40: uint8(59),
  23068 		41: uint8(60),
  23069 		42: uint8(62),
  23070 		43: uint8(63),
  23071 		44: uint8(63),
  23072 		45: uint8(63),
  23073 		46: uint8(63),
  23074 		47: uint8(63),
  23075 		48: uint8(63),
  23076 		49: uint8(63),
  23077 		50: uint8(63),
  23078 		51: uint8(63),
  23079 		52: uint8(63),
  23080 		53: uint8(63),
  23081 		54: uint8(63),
  23082 		55: uint8(63),
  23083 		56: uint8(63),
  23084 		57: uint8(63),
  23085 		58: uint8(63),
  23086 		59: uint8(63),
  23087 		60: uint8(63),
  23088 		61: uint8(63),
  23089 		62: uint8(63),
  23090 		63: uint8(63),
  23091 	},
  23092 }
  23093 
  23094 func VP8FilterStrengthFromDelta(tls *libc.TLS, sharpness int32, delta int32) (r int32) {
  23095 	var pos, v1 int32
  23096 	_, _ = pos, v1
  23097 	if delta < int32(MAX_DELTA_SIZE) {
  23098 		v1 = delta
  23099 	} else {
  23100 		v1 = libc.Int32FromInt32(MAX_DELTA_SIZE) - libc.Int32FromInt32(1)
  23101 	}
  23102 	pos = v1
  23103 	return libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kLevelsFromDelta)) + uintptr(sharpness)*64 + uintptr(pos))))
  23104 }
  23105 
  23106 //------------------------------------------------------------------------------
  23107 // Paragraph 15.4: compute the inner-edge filtering strength
  23108 
  23109 func GetILevel(tls *libc.TLS, sharpness int32, level int32) (r int32) {
  23110 	if sharpness > 0 {
  23111 		if sharpness > int32(4) {
  23112 			level = level >> int32(2)
  23113 		} else {
  23114 			level = level >> int32(1)
  23115 		}
  23116 		if level > int32(9)-sharpness {
  23117 			level = int32(9) - sharpness
  23118 		}
  23119 	}
  23120 	if level < int32(1) {
  23121 		level = int32(1)
  23122 	}
  23123 	return level
  23124 }
  23125 
  23126 func DoFilter1(tls *libc.TLS, it uintptr, level int32) {
  23127 	var enc, u_dst, v_dst, y_dst uintptr
  23128 	var hev_thresh, ilevel, limit, v1, v2 int32
  23129 	_, _, _, _, _, _, _, _, _ = enc, hev_thresh, ilevel, limit, u_dst, v_dst, y_dst, v1, v2
  23130 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23131 	ilevel = GetILevel(tls, (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_sharpness, level)
  23132 	limit = int32(2)*level + ilevel
  23133 	y_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  23134 	u_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  23135 	v_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8))
  23136 	// copy current block to yuv_out2
  23137 	libc.X__builtin___memcpy_chk(tls, y_dst, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out, libc.Uint64FromInt32(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  23138 	if (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsimple == int32(1) { // simple
  23139 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16i})))(tls, y_dst, int32(BPS), limit)
  23140 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16i})))(tls, y_dst, int32(BPS), limit)
  23141 	} else {
  23142 		if level >= int32(40) {
  23143 			v1 = int32(2)
  23144 		} else {
  23145 			if level >= int32(15) {
  23146 				v2 = int32(1)
  23147 			} else {
  23148 				v2 = 0
  23149 			}
  23150 			v1 = v2
  23151 		} // complex
  23152 		hev_thresh = v1
  23153 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16i})))(tls, y_dst, int32(BPS), limit, ilevel, hev_thresh)
  23154 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter8i})))(tls, u_dst, v_dst, int32(BPS), limit, ilevel, hev_thresh)
  23155 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16i})))(tls, y_dst, int32(BPS), limit, ilevel, hev_thresh)
  23156 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter8i})))(tls, u_dst, v_dst, int32(BPS), limit, ilevel, hev_thresh)
  23157 	}
  23158 }
  23159 
  23160 //------------------------------------------------------------------------------
  23161 // SSIM metric for one macroblock
  23162 
  23163 func GetMBSSIM(tls *libc.TLS, yuv1 uintptr, yuv2 uintptr) (r float64) {
  23164 	var sum float64
  23165 	var x, y int32
  23166 	_, _, _ = sum, x, y
  23167 	sum = float64(0)
  23168 	// compute SSIM in a 10 x 10 window
  23169 	y = int32(VP8_SSIM_KERNEL)
  23170 	for {
  23171 		if !(y < libc.Int32FromInt32(16)-libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  23172 			break
  23173 		}
  23174 		x = int32(VP8_SSIM_KERNEL)
  23175 		for {
  23176 			if !(x < libc.Int32FromInt32(16)-libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  23177 				break
  23178 			}
  23179 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, yuv1+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), int32(BPS), yuv2+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), int32(BPS), x, y, int32(16), int32(16))
  23180 			goto _2
  23181 		_2:
  23182 			;
  23183 			x = x + 1
  23184 		}
  23185 		goto _1
  23186 	_1:
  23187 		;
  23188 		y = y + 1
  23189 	}
  23190 	x = int32(1)
  23191 	for {
  23192 		if !(x < int32(7)) {
  23193 			break
  23194 		}
  23195 		y = int32(1)
  23196 		for {
  23197 			if !(y < int32(7)) {
  23198 				break
  23199 			}
  23200 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, yuv1+uintptr(libc.Int32FromInt32(U_OFF_ENC)), int32(BPS), yuv2+uintptr(libc.Int32FromInt32(U_OFF_ENC)), int32(BPS), x, y, int32(8), int32(8))
  23201 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, yuv1+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8)), int32(BPS), yuv2+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8)), int32(BPS), x, y, int32(8), int32(8))
  23202 			goto _4
  23203 		_4:
  23204 			;
  23205 			y = y + 1
  23206 		}
  23207 		goto _3
  23208 	_3:
  23209 		;
  23210 		x = x + 1
  23211 	}
  23212 	return sum
  23213 }
  23214 
  23215 //------------------------------------------------------------------------------
  23216 // Exposed APIs: Encoder should call the following 3 functions to adjust
  23217 // loop filter strength
  23218 
  23219 func VP8InitFilter(tls *libc.TLS, it uintptr) {
  23220 	var i, s int32
  23221 	_, _ = i, s
  23222 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats != libc.UintptrFromInt32(0) {
  23223 		s = 0
  23224 		for {
  23225 			if !(s < int32(NUM_MB_SEGMENTS)) {
  23226 				break
  23227 			}
  23228 			i = 0
  23229 			for {
  23230 				if !(i < int32(MAX_LF_LEVELS)) {
  23231 					break
  23232 				}
  23233 				**(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512 + uintptr(i)*8)) = libc.Float64FromInt32(0)
  23234 				goto _2
  23235 			_2:
  23236 				;
  23237 				i = i + 1
  23238 			}
  23239 			goto _1
  23240 		_1:
  23241 			;
  23242 			s = s + 1
  23243 		}
  23244 		VP8SSIMDspInit(tls)
  23245 	}
  23246 }
  23247 
  23248 func VP8StoreFilterStats(tls *libc.TLS, it uintptr) {
  23249 	var d, delta_max, delta_min, level, level0, s, step_size, v1 int32
  23250 	var enc uintptr
  23251 	_, _, _, _, _, _, _, _, _ = d, delta_max, delta_min, enc, level, level0, s, step_size, v1
  23252 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23253 	s = int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0)) & 0x60 >> 5))
  23254 	level0 = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength
  23255 	// explore +/-quant range of values around level0
  23256 	delta_min = -(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant
  23257 	delta_max = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant
  23258 	if delta_max-delta_min >= int32(4) {
  23259 		v1 = int32(4)
  23260 	} else {
  23261 		v1 = int32(1)
  23262 	}
  23263 	step_size = v1
  23264 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats == libc.UintptrFromInt32(0) {
  23265 		return
  23266 	}
  23267 	// NOTE: Currently we are applying filter only across the sublock edges
  23268 	// There are two reasons for that.
  23269 	// 1. Applying filter on macro block edges will change the pixels in
  23270 	// the left and top macro blocks. That will be hard to restore
  23271 	// 2. Macro Blocks on the bottom and right are not yet compressed. So we
  23272 	// cannot apply filter on the right and bottom macro block edges.
  23273 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) && int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x10>>4)) != 0 {
  23274 		return
  23275 	}
  23276 	// Always try filter level  zero
  23277 	**(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512)) += GetMBSSIM(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out)
  23278 	d = delta_min
  23279 	for {
  23280 		if !(d <= delta_max) {
  23281 			break
  23282 		}
  23283 		level = level0 + d
  23284 		if level <= 0 || level >= int32(MAX_LF_LEVELS) {
  23285 			goto _2
  23286 		}
  23287 		DoFilter1(tls, it, level)
  23288 		**(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512 + uintptr(level)*8)) += GetMBSSIM(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2)
  23289 		goto _2
  23290 	_2:
  23291 		;
  23292 		d = d + step_size
  23293 	}
  23294 }
  23295 
  23296 func VP8AdjustFilterStrength(tls *libc.TLS, it uintptr) {
  23297 	var best_level, delta, i, level, max_level, s, s1 int32
  23298 	var best_v, v float64
  23299 	var dqm, enc uintptr
  23300 	_, _, _, _, _, _, _, _, _, _, _ = best_level, best_v, delta, dqm, enc, i, level, max_level, s, s1, v
  23301 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23302 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats != libc.UintptrFromInt32(0) {
  23303 		s = 0
  23304 		for {
  23305 			if !(s < int32(NUM_MB_SEGMENTS)) {
  23306 				break
  23307 			}
  23308 			best_level = 0
  23309 			// Improvement over filter level 0 should be at least 1e-5 (relatively)
  23310 			best_v = float64(float64(1.00001) * **(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512)))
  23311 			i = int32(1)
  23312 			for {
  23313 				if !(i < int32(MAX_LF_LEVELS)) {
  23314 					break
  23315 				}
  23316 				v = **(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512 + uintptr(i)*8))
  23317 				if v > best_v {
  23318 					best_v = v
  23319 					best_level = i
  23320 				}
  23321 				goto _2
  23322 			_2:
  23323 				;
  23324 				i = i + 1
  23325 			}
  23326 			(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength = best_level
  23327 			goto _1
  23328 		_1:
  23329 			;
  23330 			s = s + 1
  23331 		}
  23332 		return
  23333 	}
  23334 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_strength > 0 {
  23335 		max_level = 0
  23336 		s1 = 0
  23337 		for {
  23338 			if !(s1 < int32(NUM_MB_SEGMENTS)) {
  23339 				break
  23340 			}
  23341 			dqm = enc + 608 + uintptr(s1)*744
  23342 			// this '>> 3' accounts for some inverse WHT scaling
  23343 			delta = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(dqm + 224 + 1*2))) >> int32(3)
  23344 			level = VP8FilterStrengthFromDelta(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness, delta)
  23345 			if level > (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength {
  23346 				(*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength = level
  23347 			}
  23348 			if max_level < (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength {
  23349 				max_level = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength
  23350 			}
  23351 			goto _3
  23352 		_3:
  23353 			;
  23354 			s1 = s1 + 1
  23355 		}
  23356 		(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Flevel = max_level
  23357 	}
  23358 }
  23359 
  23360 const DEBUG_SEARCH = 0
  23361 const DOMAIN = 1
  23362 const DQ_LIMIT = 0.4
  23363 const FP_INFINITE = 2
  23364 const FP_NAN = 1
  23365 const FP_NORMAL = 4
  23366 const FP_QNAN = "FP_NAN"
  23367 const FP_SNAN = "FP_NAN"
  23368 const FP_SUBNORMAL = 5
  23369 const FP_SUPERNORMAL = 6
  23370 const FP_ZERO = 3
  23371 const HUGE = "MAXFLOAT"
  23372 const INFINITY = "HUGE_VALF"
  23373 const MATH_ERREXCEPT = 2
  23374 const MATH_ERRNO = 1
  23375 const MAXFLOAT = "0x1.fffffep+127f"
  23376 const MIN_COUNT = 96
  23377 const M_1_PI = 0.318309886183790671537767526745028724
  23378 const M_2_PI = 0.636619772367581343075535053490057448
  23379 const M_2_SQRTPI = 1.12837916709551257389615890312154517
  23380 const M_E = 2.71828182845904523536028747135266250
  23381 const M_LN10 = 2.30258509299404568401799145468436421
  23382 const M_LN2 = 0.693147180559945309417232121458176568
  23383 const M_LOG10E = 0.434294481903251827651128918916605082
  23384 const M_LOG2E = 1.44269504088896340735992468100189214
  23385 const M_PI = 3.14159265358979323846264338327950288
  23386 const M_PI_2 = 1.57079632679489661923132169163975144
  23387 const M_PI_4 = 0.785398163397448309615660845819875721
  23388 const M_SQRT1_2 = 0.707106781186547524400844362104849039
  23389 const M_SQRT2 = 1.41421356237309504880168872420969808
  23390 const OVERFLOW = 3
  23391 const PLOSS = 6
  23392 const SEGMENT_VISU = 0
  23393 const SING = 2
  23394 const SKIP_PROBA_THRESHOLD = 250
  23395 const TLOSS = 5
  23396 const UNDERFLOW = 4
  23397 const X_TLOSS = 1.41484755040568800000e+16
  23398 const __FLT_MIN__1 = 1.1754943508222875e-38
  23399 
  23400 type float_t = float32
  23401 
  23402 type double_t = float64
  23403 
  23404 type __float2 = struct {
  23405 	F__sinval float32
  23406 	F__cosval float32
  23407 }
  23408 
  23409 type __double2 = struct {
  23410 	F__sinval float64
  23411 	F__cosval float64
  23412 }
  23413 
  23414 type exception = struct {
  23415 	Ftype1  int32
  23416 	Fname   uintptr
  23417 	Farg1   float64
  23418 	Farg2   float64
  23419 	Fretval float64
  23420 }
  23421 
  23422 // Alpha related constants.
  23423 
  23424 // Mux related constants.
  23425 
  23426 // Maximum chunk payload is such that adding the header and padding won't
  23427 // overflow a uint32_t.
  23428 
  23429 //------------------------------------------------------------------------------
  23430 // multi-pass convergence
  23431 
  23432 // we allow 2k of extra head-room in PARTITION0 limit.
  23433 
  23434 func Clamp(tls *libc.TLS, v float32, min float32, max float32) (r float32) {
  23435 	var v1, v2 float32
  23436 	_, _ = v1, v2
  23437 	if v < min {
  23438 		v1 = min
  23439 	} else {
  23440 		if v > max {
  23441 			v2 = max
  23442 		} else {
  23443 			v2 = v
  23444 		}
  23445 		v1 = v2
  23446 	}
  23447 	return v1
  23448 }
  23449 
  23450 type PassStats = struct {
  23451 	Fis_first       int32
  23452 	Fdq             float32
  23453 	Fq              float32
  23454 	Flast_q         float32
  23455 	Fqmin           float32
  23456 	Fqmax           float32
  23457 	Fvalue          float64
  23458 	Flast_value     float64
  23459 	Ftarget         float64
  23460 	Fdo_size_search int32
  23461 }
  23462 
  23463 func InitPassStats(tls *libc.TLS, enc uintptr, s uintptr) (r int32) {
  23464 	var do_size_search int32
  23465 	var target_PSNR, v1 float32
  23466 	var target_size uint64_t
  23467 	var v2, v3 float64
  23468 	_, _, _, _, _, _ = do_size_search, target_PSNR, target_size, v1, v2, v3
  23469 	target_size = libc.Uint64FromInt32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ftarget_size)
  23470 	do_size_search = libc.BoolInt32(target_size != libc.Uint64FromInt32(0))
  23471 	target_PSNR = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ftarget_PSNR
  23472 	(*PassStats)(unsafe.Pointer(s)).Fis_first = int32(1)
  23473 	(*PassStats)(unsafe.Pointer(s)).Fdq = libc.Float32FromFloat32(10)
  23474 	(*PassStats)(unsafe.Pointer(s)).Fqmin = float32(libc.Float32FromFloat32(1) * float32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fqmin))
  23475 	(*PassStats)(unsafe.Pointer(s)).Fqmax = float32(libc.Float32FromFloat32(1) * float32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fqmax))
  23476 	v1 = Clamp(tls, (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fquality, (*PassStats)(unsafe.Pointer(s)).Fqmin, (*PassStats)(unsafe.Pointer(s)).Fqmax)
  23477 	(*PassStats)(unsafe.Pointer(s)).Flast_q = v1
  23478 	(*PassStats)(unsafe.Pointer(s)).Fq = v1
  23479 	if do_size_search != 0 {
  23480 		v2 = float64(target_size)
  23481 	} else {
  23482 		if float64(target_PSNR) > float64(0) {
  23483 			v3 = float64(target_PSNR)
  23484 		} else {
  23485 			v3 = float64(40)
  23486 		}
  23487 		v2 = v3
  23488 	}
  23489 	(*PassStats)(unsafe.Pointer(s)).Ftarget = v2 // default, just in case
  23490 	v2 = libc.Float64FromFloat64(0)
  23491 	(*PassStats)(unsafe.Pointer(s)).Flast_value = v2
  23492 	(*PassStats)(unsafe.Pointer(s)).Fvalue = v2
  23493 	(*PassStats)(unsafe.Pointer(s)).Fdo_size_search = do_size_search
  23494 	return do_size_search
  23495 }
  23496 
  23497 func ComputeNextQ(tls *libc.TLS, s uintptr) (r float32) {
  23498 	var dq, v1 float32
  23499 	var slope float64
  23500 	_, _, _ = dq, slope, v1
  23501 	if (*PassStats)(unsafe.Pointer(s)).Fis_first != 0 {
  23502 		if (*PassStats)(unsafe.Pointer(s)).Fvalue > (*PassStats)(unsafe.Pointer(s)).Ftarget {
  23503 			v1 = -(*PassStats)(unsafe.Pointer(s)).Fdq
  23504 		} else {
  23505 			v1 = (*PassStats)(unsafe.Pointer(s)).Fdq
  23506 		}
  23507 		dq = v1
  23508 		(*PassStats)(unsafe.Pointer(s)).Fis_first = 0
  23509 	} else {
  23510 		if (*PassStats)(unsafe.Pointer(s)).Fvalue != (*PassStats)(unsafe.Pointer(s)).Flast_value {
  23511 			slope = ((*PassStats)(unsafe.Pointer(s)).Ftarget - (*PassStats)(unsafe.Pointer(s)).Fvalue) / ((*PassStats)(unsafe.Pointer(s)).Flast_value - (*PassStats)(unsafe.Pointer(s)).Fvalue)
  23512 			dq = float32(float64(slope * float64((*PassStats)(unsafe.Pointer(s)).Flast_q-(*PassStats)(unsafe.Pointer(s)).Fq)))
  23513 		} else {
  23514 			dq = float32(0) // we're done?!
  23515 		}
  23516 	}
  23517 	// Limit variable to avoid large swings.
  23518 	(*PassStats)(unsafe.Pointer(s)).Fdq = Clamp(tls, dq, -libc.Float32FromFloat32(30), libc.Float32FromFloat32(30))
  23519 	(*PassStats)(unsafe.Pointer(s)).Flast_q = (*PassStats)(unsafe.Pointer(s)).Fq
  23520 	(*PassStats)(unsafe.Pointer(s)).Flast_value = (*PassStats)(unsafe.Pointer(s)).Fvalue
  23521 	(*PassStats)(unsafe.Pointer(s)).Fq = Clamp(tls, (*PassStats)(unsafe.Pointer(s)).Fq+(*PassStats)(unsafe.Pointer(s)).Fdq, (*PassStats)(unsafe.Pointer(s)).Fqmin, (*PassStats)(unsafe.Pointer(s)).Fqmax)
  23522 	return (*PassStats)(unsafe.Pointer(s)).Fq
  23523 }
  23524 
  23525 //------------------------------------------------------------------------------
  23526 // Reset the statistics about: number of skips, token proba, level cost,...
  23527 
  23528 func ResetStats(tls *libc.TLS, enc uintptr) {
  23529 	var proba uintptr
  23530 	_ = proba
  23531 	proba = enc + 3616
  23532 	VP8CalculateLevelCosts(tls, proba)
  23533 	(*VP8EncProba)(unsafe.Pointer(proba)).Fnb_skip = 0
  23534 }
  23535 
  23536 //------------------------------------------------------------------------------
  23537 // Skip decision probability
  23538 
  23539 func CalcSkipProba(tls *libc.TLS, nb uint64_t, total uint64_t) (r int32) {
  23540 	var v1 uint64
  23541 	_ = v1
  23542 	if total != 0 {
  23543 		v1 = (total - nb) * uint64(255) / total
  23544 	} else {
  23545 		v1 = uint64(255)
  23546 	}
  23547 	return libc.Int32FromUint64(v1)
  23548 }
  23549 
  23550 // C documentation
  23551 //
  23552 //	// Returns the bit-cost for coding the skip probability.
  23553 func FinalizeSkipProba(tls *libc.TLS, enc uintptr) (r int32) {
  23554 	var nb_events, nb_mbs, size, v2, v4, v6, v8 int32
  23555 	var proba1 uintptr
  23556 	var v1, v5 uint8_t
  23557 	_, _, _, _, _, _, _, _, _, _ = nb_events, nb_mbs, proba1, size, v1, v2, v4, v5, v6, v8
  23558 	proba1 = enc + 3616
  23559 	nb_mbs = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  23560 	nb_events = (*VP8EncProba)(unsafe.Pointer(proba1)).Fnb_skip
  23561 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba = libc.Uint8FromInt32(CalcSkipProba(tls, libc.Uint64FromInt32(nb_events), libc.Uint64FromInt32(nb_mbs)))
  23562 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fuse_skip_proba = libc.BoolInt32(libc.Int32FromUint8((*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba) < int32(SKIP_PROBA_THRESHOLD))
  23563 	size = int32(256) // 'use_skip_proba' bit
  23564 	if (*VP8EncProba)(unsafe.Pointer(proba1)).Fuse_skip_proba != 0 {
  23565 		v1 = (*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba
  23566 		if !(int32(1) != 0) {
  23567 			v4 = libc.Int32FromUint16(VP8EntropyCost[v1])
  23568 		} else {
  23569 			v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v1)])
  23570 		}
  23571 		v2 = v4
  23572 		goto _3
  23573 	_3:
  23574 		v5 = (*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba
  23575 		if !(0 != 0) {
  23576 			v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23577 		} else {
  23578 			v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23579 		}
  23580 		v6 = v8
  23581 		goto _7
  23582 	_7:
  23583 		size = size + (nb_events*v2 + (nb_mbs-nb_events)*v6)
  23584 		size = size + libc.Int32FromInt32(8)*libc.Int32FromInt32(256) // cost of signaling the 'skip_proba' itself.
  23585 	}
  23586 	return size
  23587 }
  23588 
  23589 // C documentation
  23590 //
  23591 //	// Collect statistics and deduce probabilities for next coding pass.
  23592 //	// Return the total bit-cost for coding the probability updates.
  23593 func CalcTokenProba(tls *libc.TLS, nb int32, total int32) (r int32) {
  23594 	var v1 int32
  23595 	_ = v1
  23596 	if nb != 0 {
  23597 		v1 = int32(255) - nb*int32(255)/total
  23598 	} else {
  23599 		v1 = int32(255)
  23600 	}
  23601 	return v1
  23602 }
  23603 
  23604 // C documentation
  23605 //
  23606 //	// Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability.
  23607 func BranchCost(tls *libc.TLS, nb int32, total int32, proba1 int32) (r int32) {
  23608 	var v1, v5 uint8_t
  23609 	var v2, v4, v6, v8 int32
  23610 	_, _, _, _, _, _ = v1, v2, v4, v5, v6, v8
  23611 	v1 = libc.Uint8FromInt32(proba1)
  23612 	if !(int32(1) != 0) {
  23613 		v4 = libc.Int32FromUint16(VP8EntropyCost[v1])
  23614 	} else {
  23615 		v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v1)])
  23616 	}
  23617 	v2 = v4
  23618 	goto _3
  23619 _3:
  23620 	v5 = libc.Uint8FromInt32(proba1)
  23621 	if !(0 != 0) {
  23622 		v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23623 	} else {
  23624 		v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23625 	}
  23626 	v6 = v8
  23627 	goto _7
  23628 _7:
  23629 	return nb*v2 + (total-nb)*v6
  23630 }
  23631 
  23632 func ResetTokenStats(tls *libc.TLS, enc uintptr) {
  23633 	var proba uintptr
  23634 	_ = proba
  23635 	proba = enc + 3616
  23636 	libc.X__builtin___memset_chk(tls, proba+1060, 0, uint64(4224), ^__predefined_size_t(0))
  23637 }
  23638 
  23639 func FinalizeTokenProbas(tls *libc.TLS, proba1 uintptr) (r int32) {
  23640 	var b, c, has_changed, nb, new_cost, new_p, old_cost, old_p, p, size, t, total, update_proba, use_new_p, v10, v12, v14, v16, v6, v8 int32
  23641 	var stats proba_t
  23642 	var v13, v5, v9 uint8_t
  23643 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, c, has_changed, nb, new_cost, new_p, old_cost, old_p, p, size, stats, t, total, update_proba, use_new_p, v10, v12, v13, v14, v16, v5, v6, v8, v9
  23644 	has_changed = 0
  23645 	size = 0
  23646 	t = 0
  23647 	for {
  23648 		if !(t < int32(NUM_TYPES)) {
  23649 			break
  23650 		}
  23651 		b = 0
  23652 		for {
  23653 			if !(b < int32(NUM_BANDS)) {
  23654 				break
  23655 			}
  23656 			c = 0
  23657 			for {
  23658 				if !(c < int32(NUM_CTX)) {
  23659 					break
  23660 				}
  23661 				p = 0
  23662 				for {
  23663 					if !(p < int32(NUM_PROBAS)) {
  23664 						break
  23665 					}
  23666 					stats = **(**proba_t)(__ccgo_up(proba1 + 1060 + uintptr(t)*1056 + uintptr(b)*132 + uintptr(c)*44 + uintptr(p)*4))
  23667 					nb = libc.Int32FromUint32(stats >> libc.Int32FromInt32(0) & uint32(0xffff))
  23668 					total = libc.Int32FromUint32(stats >> libc.Int32FromInt32(16) & uint32(0xffff))
  23669 					update_proba = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsUpdateProba)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  23670 					old_p = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsProba0)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  23671 					new_p = CalcTokenProba(tls, nb, total)
  23672 					v5 = libc.Uint8FromInt32(update_proba)
  23673 					if !(0 != 0) {
  23674 						v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23675 					} else {
  23676 						v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23677 					}
  23678 					v6 = v8
  23679 					goto _7
  23680 				_7:
  23681 					old_cost = BranchCost(tls, nb, total, old_p) + v6
  23682 					v9 = libc.Uint8FromInt32(update_proba)
  23683 					if !(int32(1) != 0) {
  23684 						v12 = libc.Int32FromUint16(VP8EntropyCost[v9])
  23685 					} else {
  23686 						v12 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v9)])
  23687 					}
  23688 					v10 = v12
  23689 					goto _11
  23690 				_11:
  23691 					new_cost = BranchCost(tls, nb, total, new_p) + v10 + libc.Int32FromInt32(8)*libc.Int32FromInt32(256)
  23692 					use_new_p = libc.BoolInt32(old_cost > new_cost)
  23693 					v13 = libc.Uint8FromInt32(update_proba)
  23694 					if !(use_new_p != 0) {
  23695 						v16 = libc.Int32FromUint16(VP8EntropyCost[v13])
  23696 					} else {
  23697 						v16 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v13)])
  23698 					}
  23699 					v14 = v16
  23700 					goto _15
  23701 				_15:
  23702 					size = size + v14
  23703 					if use_new_p != 0 { // only use proba that seem meaningful enough.
  23704 						**(**uint8_t)(__ccgo_up(proba1 + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(new_p)
  23705 						has_changed = has_changed | libc.BoolInt32(new_p != old_p)
  23706 						size = size + libc.Int32FromInt32(8)*libc.Int32FromInt32(256)
  23707 					} else {
  23708 						**(**uint8_t)(__ccgo_up(proba1 + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(old_p)
  23709 					}
  23710 					goto _4
  23711 				_4:
  23712 					;
  23713 					p = p + 1
  23714 				}
  23715 				goto _3
  23716 			_3:
  23717 				;
  23718 				c = c + 1
  23719 			}
  23720 			goto _2
  23721 		_2:
  23722 			;
  23723 			b = b + 1
  23724 		}
  23725 		goto _1
  23726 	_1:
  23727 		;
  23728 		t = t + 1
  23729 	}
  23730 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty = has_changed
  23731 	return size
  23732 }
  23733 
  23734 //------------------------------------------------------------------------------
  23735 // Finalize Segment probability based on the coding tree
  23736 
  23737 func GetProba(tls *libc.TLS, a int32, b int32) (r int32) {
  23738 	var total, v1 int32
  23739 	_, _ = total, v1
  23740 	total = a + b
  23741 	if total == 0 {
  23742 		v1 = int32(255)
  23743 	} else {
  23744 		v1 = (int32(255)*a + total/int32(2)) / total
  23745 	}
  23746 	return v1 // rounded proba
  23747 }
  23748 
  23749 func ResetSegments(tls *libc.TLS, enc uintptr) {
  23750 	var n int32
  23751 	_ = n
  23752 	n = 0
  23753 	for {
  23754 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  23755 			break
  23756 		}
  23757 		libc.SetBitFieldPtr8Uint32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info+uintptr(n)*4+0, libc.Uint32FromInt32(0), 5, 0x60)
  23758 		goto _1
  23759 	_1:
  23760 		;
  23761 		n = n + 1
  23762 	}
  23763 }
  23764 
  23765 func SetSegmentProbas(tls *libc.TLS, enc uintptr) {
  23766 	var mb, probas uintptr
  23767 	var n, v10, v12, v14, v16, v18, v20, v22, v24, v26, v28, v30, v32, v34, v4, v6, v8 int32
  23768 	var p [4]int32
  23769 	var v11, v15, v19, v23, v27, v3, v31, v7 uint8_t
  23770 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = mb, n, p, probas, v10, v11, v12, v14, v15, v16, v18, v19, v20, v22, v23, v24, v26, v27, v28, v3, v30, v31, v32, v34, v4, v6, v7, v8
  23771 	p = [4]int32{}
  23772 	n = 0
  23773 	for {
  23774 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  23775 			break
  23776 		}
  23777 		mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(n)*4
  23778 		p[int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5))] = p[int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5))] + 1
  23779 		goto _1
  23780 	_1:
  23781 		;
  23782 		n = n + 1
  23783 	}
  23784 	if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != libc.UintptrFromInt32(0) {
  23785 		n = 0
  23786 		for {
  23787 			if !(n < int32(NUM_MB_SEGMENTS)) {
  23788 				break
  23789 			}
  23790 			**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats + 92 + uintptr(n)*4)) = p[n]
  23791 			goto _2
  23792 		_2:
  23793 			;
  23794 			n = n + 1
  23795 		}
  23796 	}
  23797 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments > int32(1) {
  23798 		probas = enc + 3616
  23799 		**(**uint8_t)(__ccgo_up(probas)) = libc.Uint8FromInt32(GetProba(tls, p[0]+p[int32(1)], p[int32(2)]+p[int32(3)]))
  23800 		**(**uint8_t)(__ccgo_up(probas + 1)) = libc.Uint8FromInt32(GetProba(tls, p[0], p[int32(1)]))
  23801 		**(**uint8_t)(__ccgo_up(probas + 2)) = libc.Uint8FromInt32(GetProba(tls, p[int32(2)], p[int32(3)]))
  23802 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map = libc.BoolInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas))) != int32(255) || libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + 1))) != int32(255) || libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + 2))) != int32(255))
  23803 		if !((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map != 0) {
  23804 			ResetSegments(tls, enc)
  23805 		}
  23806 		v3 = **(**uint8_t)(__ccgo_up(probas))
  23807 		if !(0 != 0) {
  23808 			v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  23809 		} else {
  23810 			v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  23811 		}
  23812 		v4 = v6
  23813 		goto _5
  23814 	_5:
  23815 		v7 = **(**uint8_t)(__ccgo_up(probas + 1))
  23816 		if !(0 != 0) {
  23817 			v10 = libc.Int32FromUint16(VP8EntropyCost[v7])
  23818 		} else {
  23819 			v10 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v7)])
  23820 		}
  23821 		v8 = v10
  23822 		goto _9
  23823 	_9:
  23824 		v11 = **(**uint8_t)(__ccgo_up(probas))
  23825 		if !(0 != 0) {
  23826 			v14 = libc.Int32FromUint16(VP8EntropyCost[v11])
  23827 		} else {
  23828 			v14 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v11)])
  23829 		}
  23830 		v12 = v14
  23831 		goto _13
  23832 	_13:
  23833 		v15 = **(**uint8_t)(__ccgo_up(probas + 1))
  23834 		if !(int32(1) != 0) {
  23835 			v18 = libc.Int32FromUint16(VP8EntropyCost[v15])
  23836 		} else {
  23837 			v18 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v15)])
  23838 		}
  23839 		v16 = v18
  23840 		goto _17
  23841 	_17:
  23842 		v19 = **(**uint8_t)(__ccgo_up(probas))
  23843 		if !(int32(1) != 0) {
  23844 			v22 = libc.Int32FromUint16(VP8EntropyCost[v19])
  23845 		} else {
  23846 			v22 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v19)])
  23847 		}
  23848 		v20 = v22
  23849 		goto _21
  23850 	_21:
  23851 		v23 = **(**uint8_t)(__ccgo_up(probas + 2))
  23852 		if !(0 != 0) {
  23853 			v26 = libc.Int32FromUint16(VP8EntropyCost[v23])
  23854 		} else {
  23855 			v26 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v23)])
  23856 		}
  23857 		v24 = v26
  23858 		goto _25
  23859 	_25:
  23860 		v27 = **(**uint8_t)(__ccgo_up(probas))
  23861 		if !(int32(1) != 0) {
  23862 			v30 = libc.Int32FromUint16(VP8EntropyCost[v27])
  23863 		} else {
  23864 			v30 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v27)])
  23865 		}
  23866 		v28 = v30
  23867 		goto _29
  23868 	_29:
  23869 		v31 = **(**uint8_t)(__ccgo_up(probas + 2))
  23870 		if !(int32(1) != 0) {
  23871 			v34 = libc.Int32FromUint16(VP8EntropyCost[v31])
  23872 		} else {
  23873 			v34 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v31)])
  23874 		}
  23875 		v32 = v34
  23876 		goto _33
  23877 	_33:
  23878 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize = p[0]*(v4+v8) + p[int32(1)]*(v12+v16) + p[int32(2)]*(v20+v24) + p[int32(3)]*(v28+v32)
  23879 	} else {
  23880 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map = 0
  23881 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize = 0
  23882 	}
  23883 }
  23884 
  23885 //------------------------------------------------------------------------------
  23886 // Coefficient coding
  23887 
  23888 func PutCoeffs(tls *libc.TLS, bw uintptr, ctx int32, res uintptr) (r int32) {
  23889 	var c, mask, n, sign, v, v1, v2 int32
  23890 	var p, tab, v3 uintptr
  23891 	_, _, _, _, _, _, _, _, _, _ = c, mask, n, p, sign, tab, v, v1, v2, v3
  23892 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  23893 	// should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
  23894 	p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(n)*33 + uintptr(ctx)*11
  23895 	if !(VP8PutBit(tls, bw, libc.BoolInt32((*VP8Residual)(unsafe.Pointer(res)).Flast >= 0), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0) {
  23896 		return 0
  23897 	}
  23898 	for n < int32(16) {
  23899 		v1 = n
  23900 		n = n + 1
  23901 		c = int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(v1)*2)))
  23902 		sign = libc.BoolInt32(c < 0)
  23903 		if sign != 0 {
  23904 			v2 = -c
  23905 		} else {
  23906 			v2 = c
  23907 		}
  23908 		v = v2
  23909 		if !(VP8PutBit(tls, bw, libc.BoolInt32(v != 0), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) != 0) {
  23910 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33
  23911 			continue
  23912 		}
  23913 		if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(1)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) != 0) {
  23914 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33 + 1*11
  23915 		} else {
  23916 			if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(4)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 3)))) != 0) {
  23917 				if VP8PutBit(tls, bw, libc.BoolInt32(v != int32(2)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 4)))) != 0 {
  23918 					VP8PutBit(tls, bw, libc.BoolInt32(v == int32(4)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 5))))
  23919 				}
  23920 			} else {
  23921 				if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(10)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 6)))) != 0) {
  23922 					if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(6)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 7)))) != 0) {
  23923 						VP8PutBit(tls, bw, libc.BoolInt32(v == int32(6)), int32(159))
  23924 					} else {
  23925 						VP8PutBit(tls, bw, libc.BoolInt32(v >= int32(9)), int32(165))
  23926 						VP8PutBit(tls, bw, libc.BoolInt32(!(v&libc.Int32FromInt32(1) != 0)), int32(145))
  23927 					}
  23928 				} else {
  23929 					if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(1) { // VP8Cat3  (3b)
  23930 						VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23931 						VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 9))))
  23932 						v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(0))
  23933 						mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(2)
  23934 						tab = uintptr(unsafe.Pointer(&VP8Cat3))
  23935 					} else {
  23936 						if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(2) { // VP8Cat4  (4b)
  23937 							VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23938 							VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 9))))
  23939 							v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(1))
  23940 							mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(3)
  23941 							tab = uintptr(unsafe.Pointer(&VP8Cat4))
  23942 						} else {
  23943 							if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(3) { // VP8Cat5  (5b)
  23944 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23945 								VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 10))))
  23946 								v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(2))
  23947 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(4)
  23948 								tab = uintptr(unsafe.Pointer(&VP8Cat5))
  23949 							} else { // VP8Cat6 (11b)
  23950 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23951 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 10))))
  23952 								v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(3))
  23953 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(10)
  23954 								tab = uintptr(unsafe.Pointer(&VP8Cat6))
  23955 							}
  23956 						}
  23957 					}
  23958 					for mask != 0 {
  23959 						v3 = tab
  23960 						tab = tab + 1
  23961 						VP8PutBit(tls, bw, libc.BoolInt32(!!(v&mask != 0)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v3))))
  23962 						mask = mask >> int32(1)
  23963 					}
  23964 				}
  23965 			}
  23966 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33 + 2*11
  23967 		}
  23968 		VP8PutBitUniform(tls, bw, sign)
  23969 		if n == int32(16) || !(VP8PutBit(tls, bw, libc.BoolInt32(n <= (*VP8Residual)(unsafe.Pointer(res)).Flast), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0) {
  23970 			return int32(1) // EOB
  23971 		}
  23972 	}
  23973 	return int32(1)
  23974 }
  23975 
  23976 func CodeResiduals(tls *libc.TLS, bw1 uintptr, it uintptr, rd uintptr) {
  23977 	bp := tls.Alloc(48)
  23978 	defer tls.Free(48)
  23979 	var ch, ctx, ctx1, i16, segment, x, y, v4 int32
  23980 	var enc, v1 uintptr
  23981 	var nb_bits, pos1, pos2, pos3, v2 uint64_t
  23982 	var _ /* res at bp+0 */ VP8Residual
  23983 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ch, ctx, ctx1, enc, i16, nb_bits, pos1, pos2, pos3, segment, x, y, v1, v2, v4
  23984 	i16 = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == libc.Int32FromInt32(1))
  23985 	segment = int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0)) & 0x60 >> 5))
  23986 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23987 	VP8IteratorNzToBytes(tls, it)
  23988 	v1 = bw1
  23989 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  23990 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  23991 	goto _3
  23992 _3:
  23993 	pos1 = v2
  23994 	if i16 != 0 {
  23995 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  23996 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  23997 		v4 = PutCoeffs(tls, bw1, **(**int32)(__ccgo_up(it + 132 + 8*4))+**(**int32)(__ccgo_up(it + 168 + 8*4)), bp)
  23998 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v4
  23999 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v4
  24000 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24001 	} else {
  24002 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24003 	}
  24004 	// luma-AC
  24005 	y = 0
  24006 	for {
  24007 		if !(y < int32(4)) {
  24008 			break
  24009 		}
  24010 		x = 0
  24011 		for {
  24012 			if !(x < int32(4)) {
  24013 				break
  24014 			}
  24015 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24016 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24017 			v4 = PutCoeffs(tls, bw1, ctx, bp)
  24018 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v4
  24019 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v4
  24020 			goto _6
  24021 		_6:
  24022 			;
  24023 			x = x + 1
  24024 		}
  24025 		goto _5
  24026 	_5:
  24027 		;
  24028 		y = y + 1
  24029 	}
  24030 	v1 = bw1
  24031 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  24032 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  24033 	goto _10
  24034 _10:
  24035 	pos2 = v2
  24036 	// U/V
  24037 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24038 	ch = 0
  24039 	for {
  24040 		if !(ch <= int32(2)) {
  24041 			break
  24042 		}
  24043 		y = 0
  24044 		for {
  24045 			if !(y < int32(2)) {
  24046 				break
  24047 			}
  24048 			x = 0
  24049 			for {
  24050 				if !(x < int32(2)) {
  24051 					break
  24052 				}
  24053 				ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24054 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24055 				v4 = PutCoeffs(tls, bw1, ctx1, bp)
  24056 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v4
  24057 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v4
  24058 				goto _13
  24059 			_13:
  24060 				;
  24061 				x = x + 1
  24062 			}
  24063 			goto _12
  24064 		_12:
  24065 			;
  24066 			y = y + 1
  24067 		}
  24068 		goto _11
  24069 	_11:
  24070 		;
  24071 		ch = ch + int32(2)
  24072 	}
  24073 	v1 = bw1
  24074 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  24075 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  24076 	goto _17
  24077 _17:
  24078 	pos3 = v2
  24079 	(*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits = pos2 - pos1
  24080 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits = pos3 - pos2
  24081 	**(**uint64_t)(__ccgo_up(it + 208 + uintptr(segment)*24 + uintptr(i16)*8)) += (*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits
  24082 	**(**uint64_t)(__ccgo_up(it + 208 + uintptr(segment)*24 + 2*8)) += (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits
  24083 	VP8IteratorBytesToNz(tls, it)
  24084 }
  24085 
  24086 // C documentation
  24087 //
  24088 //	// Same as CodeResiduals, but doesn't actually write anything.
  24089 //	// Instead, it just records the event distribution.
  24090 func RecordResiduals(tls *libc.TLS, it uintptr, rd uintptr) {
  24091 	bp := tls.Alloc(48)
  24092 	defer tls.Free(48)
  24093 	var ch, ctx, ctx1, x, y, v1 int32
  24094 	var enc uintptr
  24095 	var _ /* res at bp+0 */ VP8Residual
  24096 	_, _, _, _, _, _, _ = ch, ctx, ctx1, enc, x, y, v1
  24097 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24098 	VP8IteratorNzToBytes(tls, it)
  24099 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) { // i16x16
  24100 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  24101 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  24102 		v1 = VP8RecordCoeffs(tls, **(**int32)(__ccgo_up(it + 132 + 8*4))+**(**int32)(__ccgo_up(it + 168 + 8*4)), bp)
  24103 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v1
  24104 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v1
  24105 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24106 	} else {
  24107 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24108 	}
  24109 	// luma-AC
  24110 	y = 0
  24111 	for {
  24112 		if !(y < int32(4)) {
  24113 			break
  24114 		}
  24115 		x = 0
  24116 		for {
  24117 			if !(x < int32(4)) {
  24118 				break
  24119 			}
  24120 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24121 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24122 			v1 = VP8RecordCoeffs(tls, ctx, bp)
  24123 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v1
  24124 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v1
  24125 			goto _3
  24126 		_3:
  24127 			;
  24128 			x = x + 1
  24129 		}
  24130 		goto _2
  24131 	_2:
  24132 		;
  24133 		y = y + 1
  24134 	}
  24135 	// U/V
  24136 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24137 	ch = 0
  24138 	for {
  24139 		if !(ch <= int32(2)) {
  24140 			break
  24141 		}
  24142 		y = 0
  24143 		for {
  24144 			if !(y < int32(2)) {
  24145 				break
  24146 			}
  24147 			x = 0
  24148 			for {
  24149 				if !(x < int32(2)) {
  24150 					break
  24151 				}
  24152 				ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24153 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24154 				v1 = VP8RecordCoeffs(tls, ctx1, bp)
  24155 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v1
  24156 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v1
  24157 				goto _7
  24158 			_7:
  24159 				;
  24160 				x = x + 1
  24161 			}
  24162 			goto _6
  24163 		_6:
  24164 			;
  24165 			y = y + 1
  24166 		}
  24167 		goto _5
  24168 	_5:
  24169 		;
  24170 		ch = ch + int32(2)
  24171 	}
  24172 	VP8IteratorBytesToNz(tls, it)
  24173 }
  24174 
  24175 //------------------------------------------------------------------------------
  24176 // Token buffer
  24177 
  24178 func RecordTokens(tls *libc.TLS, it uintptr, rd uintptr, tokens uintptr) (r int32) {
  24179 	bp := tls.Alloc(48)
  24180 	defer tls.Free(48)
  24181 	var ch, ctx, ctx1, ctx2, x, y, v1 int32
  24182 	var enc uintptr
  24183 	var _ /* res at bp+0 */ VP8Residual
  24184 	_, _, _, _, _, _, _, _ = ch, ctx, ctx1, ctx2, enc, x, y, v1
  24185 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24186 	VP8IteratorNzToBytes(tls, it)
  24187 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) { // i16x16
  24188 		ctx = **(**int32)(__ccgo_up(it + 132 + 8*4)) + **(**int32)(__ccgo_up(it + 168 + 8*4))
  24189 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  24190 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  24191 		v1 = VP8RecordCoeffTokens(tls, ctx, bp, tokens)
  24192 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v1
  24193 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v1
  24194 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24195 	} else {
  24196 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24197 	}
  24198 	// luma-AC
  24199 	y = 0
  24200 	for {
  24201 		if !(y < int32(4)) {
  24202 			break
  24203 		}
  24204 		x = 0
  24205 		for {
  24206 			if !(x < int32(4)) {
  24207 				break
  24208 			}
  24209 			ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24210 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24211 			v1 = VP8RecordCoeffTokens(tls, ctx1, bp, tokens)
  24212 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v1
  24213 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v1
  24214 			goto _3
  24215 		_3:
  24216 			;
  24217 			x = x + 1
  24218 		}
  24219 		goto _2
  24220 	_2:
  24221 		;
  24222 		y = y + 1
  24223 	}
  24224 	// U/V
  24225 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24226 	ch = 0
  24227 	for {
  24228 		if !(ch <= int32(2)) {
  24229 			break
  24230 		}
  24231 		y = 0
  24232 		for {
  24233 			if !(y < int32(2)) {
  24234 				break
  24235 			}
  24236 			x = 0
  24237 			for {
  24238 				if !(x < int32(2)) {
  24239 					break
  24240 				}
  24241 				ctx2 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24242 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24243 				v1 = VP8RecordCoeffTokens(tls, ctx2, bp, tokens)
  24244 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v1
  24245 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v1
  24246 				goto _7
  24247 			_7:
  24248 				;
  24249 				x = x + 1
  24250 			}
  24251 			goto _6
  24252 		_6:
  24253 			;
  24254 			y = y + 1
  24255 		}
  24256 		goto _5
  24257 	_5:
  24258 		;
  24259 		ch = ch + int32(2)
  24260 	}
  24261 	VP8IteratorBytesToNz(tls, it)
  24262 	return libc.BoolInt32(!((*VP8TBuffer)(unsafe.Pointer(tokens)).Ferror1 != 0))
  24263 }
  24264 
  24265 //------------------------------------------------------------------------------
  24266 // ExtraInfo map / Debug function
  24267 
  24268 func ResetSSE(tls *libc.TLS, enc uintptr) {
  24269 	**(**uint64_t)(__ccgo_up(enc + 23512)) = uint64(0)
  24270 	**(**uint64_t)(__ccgo_up(enc + 23512 + 1*8)) = uint64(0)
  24271 	**(**uint64_t)(__ccgo_up(enc + 23512 + 2*8)) = uint64(0)
  24272 	// Note: enc->sse[3] is managed by alpha.c
  24273 	(*VP8Encoder)(unsafe.Pointer(enc)).Fsse_count = uint64(0)
  24274 }
  24275 
  24276 func StoreSSE(tls *libc.TLS, it uintptr) {
  24277 	var enc, in, out uintptr
  24278 	_, _, _ = enc, in, out
  24279 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24280 	in = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in
  24281 	out = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out
  24282 	// Note: not totally accurate at boundary. And doesn't include in-loop filter.
  24283 	**(**uint64_t)(__ccgo_up(enc + 23512)) += libc.Uint64FromInt32((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x16})))(tls, in+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), out+uintptr(libc.Int32FromInt32(Y_OFF_ENC))))
  24284 	**(**uint64_t)(__ccgo_up(enc + 23512 + 1*8)) += libc.Uint64FromInt32((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE8x8})))(tls, in+uintptr(libc.Int32FromInt32(U_OFF_ENC)), out+uintptr(libc.Int32FromInt32(U_OFF_ENC))))
  24285 	**(**uint64_t)(__ccgo_up(enc + 23512 + 2*8)) += libc.Uint64FromInt32((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE8x8})))(tls, in+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8)), out+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8))))
  24286 	**(**uint64_t)(__ccgo_up(enc + 23544)) += libc.Uint64FromInt32(libc.Int32FromInt32(16) * libc.Int32FromInt32(16))
  24287 }
  24288 
  24289 func StoreSideInfo(tls *libc.TLS, it uintptr) {
  24290 	var b, v1 int32
  24291 	var enc, info, mb, pic uintptr
  24292 	_, _, _, _, _, _ = b, enc, info, mb, pic, v1
  24293 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24294 	mb = (*VP8EncIterator)(unsafe.Pointer(it)).Fmb
  24295 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  24296 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  24297 		StoreSSE(tls, it)
  24298 		**(**int32)(__ccgo_up(enc + 23604)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == 0)
  24299 		**(**int32)(__ccgo_up(enc + 23604 + 1*4)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == int32(1))
  24300 		**(**int32)(__ccgo_up(enc + 23604 + 2*4)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x10>>4)) != 0)
  24301 	}
  24302 	if (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info != libc.UintptrFromInt32(0) {
  24303 		info = (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx+(*VP8EncIterator)(unsafe.Pointer(it)).Fy*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)
  24304 		switch (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info_type {
  24305 		case int32(1):
  24306 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x3 >> 0)))
  24307 		case int32(2):
  24308 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x60 >> 5)))
  24309 		case int32(3):
  24310 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32((**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5)))*744))).Fquant)
  24311 		case int32(4):
  24312 			if int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == int32(1) {
  24313 				v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds)))
  24314 			} else {
  24315 				v1 = int32(0xff)
  24316 			}
  24317 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(v1)
  24318 		case int32(5):
  24319 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0xc >> 2)))
  24320 		case int32(6):
  24321 			b = libc.Int32FromUint64(((*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits + (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  24322 			if b > int32(255) {
  24323 				v1 = int32(255)
  24324 			} else {
  24325 				v1 = b
  24326 			}
  24327 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(v1)
  24328 		case int32(7):
  24329 			**(**uint8_t)(__ccgo_up(info)) = (*VP8MBInfo)(unsafe.Pointer(mb)).Falpha
  24330 		default:
  24331 			**(**uint8_t)(__ccgo_up(info)) = uint8(0)
  24332 			break
  24333 		}
  24334 	}
  24335 }
  24336 
  24337 func ResetSideInfo(tls *libc.TLS, it uintptr) {
  24338 	var enc, pic uintptr
  24339 	_, _ = enc, pic
  24340 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24341 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  24342 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  24343 		libc.X__builtin___memset_chk(tls, enc+23604, 0, uint64(12), ^__predefined_size_t(0))
  24344 	}
  24345 	ResetSSE(tls, enc)
  24346 }
  24347 
  24348 func GetPSNR(tls *libc.TLS, mse uint64_t, size uint64_t) (r float64) {
  24349 	var v1 float64
  24350 	_ = v1
  24351 	if mse > uint64(0) && size > uint64(0) {
  24352 		v1 = float64(float64(10) * libc.Xlog10(tls, float64(float64(libc.Float64FromFloat64(255)*libc.Float64FromFloat64(255))*float64(size))/float64(mse)))
  24353 	} else {
  24354 		v1 = libc.Float64FromInt32(99)
  24355 	}
  24356 	return v1
  24357 }
  24358 
  24359 //------------------------------------------------------------------------------
  24360 //  StatLoop(): only collect statistics (number of skips, token usage, ...).
  24361 //  This is used for deciding optimal probabilities. It also modifies the
  24362 //  quantizer value if some target (size, PSNR) was specified.
  24363 
  24364 func SetLoopParams(tls *libc.TLS, enc uintptr, q float32) {
  24365 	// Make sure the quality parameter is inside valid bounds
  24366 	q = Clamp(tls, q, libc.Float32FromFloat32(0), libc.Float32FromFloat32(100))
  24367 	VP8SetSegmentParams(tls, enc, q) // setup segment quantizations and filters
  24368 	SetSegmentProbas(tls, enc)       // compute segment probabilities
  24369 	ResetStats(tls, enc)
  24370 	ResetSSE(tls, enc)
  24371 }
  24372 
  24373 func OneStatPass(tls *libc.TLS, enc uintptr, rd_opt VP8RDLevel, nb_mbs int32, percent_delta int32, s uintptr) (r uint64_t) {
  24374 	bp := tls.Alloc(4736)
  24375 	defer tls.Free(4736)
  24376 	var distortion, pixel_count, size, size_p0 uint64_t
  24377 	var v1 int32
  24378 	var v2 bool
  24379 	var _ /* info at bp+3848 */ VP8ModeScore
  24380 	var _ /* it at bp+0 */ VP8EncIterator
  24381 	_, _, _, _, _, _ = distortion, pixel_count, size, size_p0, v1, v2
  24382 	size = uint64(0)
  24383 	size_p0 = uint64(0)
  24384 	distortion = uint64(0)
  24385 	pixel_count = libc.Uint64FromInt32(nb_mbs) * uint64(384)
  24386 	VP8IteratorInit(tls, enc, bp)
  24387 	SetLoopParams(tls, enc, (*PassStats)(unsafe.Pointer(s)).Fq)
  24388 	for {
  24389 		VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24390 		if VP8Decimate(tls, bp, bp+3848, rd_opt) != 0 {
  24391 			// Just record the number of skips and act like skip_proba is not used.
  24392 			(*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fnb_skip = (*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fnb_skip + 1
  24393 		}
  24394 		RecordResiduals(tls, bp, bp+3848)
  24395 		size = size + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FR+(**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FH)
  24396 		size_p0 = size_p0 + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FH)
  24397 		distortion = distortion + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FD)
  24398 		if percent_delta != 0 && !(VP8IteratorProgress(tls, bp, percent_delta) != 0) {
  24399 			return uint64(0)
  24400 		}
  24401 		VP8IteratorSaveBoundary(tls, bp)
  24402 		goto _3
  24403 	_3:
  24404 		;
  24405 		if v2 = VP8IteratorNext(tls, bp) != 0; v2 {
  24406 			nb_mbs = nb_mbs - 1
  24407 			v1 = nb_mbs
  24408 		}
  24409 		if !(v2 && v1 > 0) {
  24410 			break
  24411 		}
  24412 	}
  24413 	size_p0 = size_p0 + libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize)
  24414 	if (*PassStats)(unsafe.Pointer(s)).Fdo_size_search != 0 {
  24415 		size = size + libc.Uint64FromInt32(FinalizeSkipProba(tls, enc))
  24416 		size = size + libc.Uint64FromInt32(FinalizeTokenProbas(tls, enc+3616))
  24417 		size = (size+size_p0+uint64(1024))>>int32(11) + libc.Uint64FromInt32(libc.Int32FromInt32(RIFF_HEADER_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)+libc.Int32FromInt32(VP8_FRAME_HEADER_SIZE))
  24418 		(*PassStats)(unsafe.Pointer(s)).Fvalue = float64(size)
  24419 	} else {
  24420 		(*PassStats)(unsafe.Pointer(s)).Fvalue = GetPSNR(tls, distortion, pixel_count)
  24421 	}
  24422 	return size_p0
  24423 }
  24424 
  24425 func StatLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24426 	bp := tls.Alloc(64)
  24427 	defer tls.Free(64)
  24428 	var do_search, fast_probe, final_percent, is_last_pass, method, nb_mbs, num_pass_left, percent_per_pass, task_percent, v1 int32
  24429 	var rd_opt VP8RDLevel
  24430 	var size_p0 uint64_t
  24431 	var _ /* stats at bp+0 */ PassStats
  24432 	_, _, _, _, _, _, _, _, _, _, _, _ = do_search, fast_probe, final_percent, is_last_pass, method, nb_mbs, num_pass_left, percent_per_pass, rd_opt, size_p0, task_percent, v1
  24433 	method = (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod
  24434 	do_search = (*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search
  24435 	fast_probe = libc.BoolInt32((method == 0 || method == int32(3)) && !(do_search != 0))
  24436 	num_pass_left = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpass
  24437 	task_percent = int32(20)
  24438 	percent_per_pass = (task_percent + num_pass_left/int32(2)) / num_pass_left
  24439 	final_percent = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent + task_percent
  24440 	if method >= int32(3) || do_search != 0 {
  24441 		v1 = int32(RD_OPT_BASIC)
  24442 	} else {
  24443 		v1 = int32(RD_OPT_NONE)
  24444 	}
  24445 	rd_opt = v1
  24446 	nb_mbs = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  24447 	InitPassStats(tls, enc, bp)
  24448 	ResetTokenStats(tls, enc)
  24449 	// Fast mode: quick analysis pass over few mbs. Better than nothing.
  24450 	if fast_probe != 0 {
  24451 		if method == int32(3) { // we need more stats for method 3 to be reliable.
  24452 			if nb_mbs > int32(200) {
  24453 				v1 = nb_mbs >> int32(1)
  24454 			} else {
  24455 				v1 = int32(100)
  24456 			}
  24457 			nb_mbs = v1
  24458 		} else {
  24459 			if nb_mbs > int32(200) {
  24460 				v1 = nb_mbs >> int32(2)
  24461 			} else {
  24462 				v1 = int32(50)
  24463 			}
  24464 			nb_mbs = v1
  24465 		}
  24466 	}
  24467 	for {
  24468 		v1 = num_pass_left
  24469 		num_pass_left = num_pass_left - 1
  24470 		if !(v1 > 0) {
  24471 			break
  24472 		}
  24473 		is_last_pass = libc.BoolInt32(libc.Xfabs(tls, float64((**(**PassStats)(__ccgo_up(bp))).Fdq)) <= float64(DQ_LIMIT) || num_pass_left == 0 || (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits == 0)
  24474 		size_p0 = OneStatPass(tls, enc, rd_opt, nb_mbs, percent_per_pass, bp)
  24475 		if size_p0 == uint64(0) {
  24476 			return 0
  24477 		}
  24478 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits > 0 && size_p0 > (libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19))-libc.Uint64FromUint64(2048))<<libc.Int32FromInt32(11) {
  24479 			num_pass_left = num_pass_left + 1
  24480 			**(**int32)(__ccgo_up(enc + 23624)) >>= int32(1) // strengthen header bit limitation...
  24481 			continue                                         // ...and start over
  24482 		}
  24483 		if is_last_pass != 0 {
  24484 			break
  24485 		}
  24486 		// If no target size: just do several pass without changing 'q'
  24487 		if do_search != 0 {
  24488 			ComputeNextQ(tls, bp)
  24489 			if libc.Xfabs(tls, float64((**(**PassStats)(__ccgo_up(bp))).Fdq)) <= float64(DQ_LIMIT) {
  24490 				break
  24491 			}
  24492 		}
  24493 	}
  24494 	if !(do_search != 0) || !((**(**PassStats)(__ccgo_up(bp))).Fdo_size_search != 0) {
  24495 		// Need to finalize probas now, since it wasn't done during the search.
  24496 		FinalizeSkipProba(tls, enc)
  24497 		FinalizeTokenProbas(tls, enc+3616)
  24498 	}
  24499 	VP8CalculateLevelCosts(tls, enc+3616) // finalize costs
  24500 	return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, final_percent, enc+536)
  24501 }
  24502 
  24503 //------------------------------------------------------------------------------
  24504 // Main loops
  24505 //
  24506 
  24507 var kAverageBytesPerMB = [8]uint8_t{
  24508 	0: uint8(50),
  24509 	1: uint8(24),
  24510 	2: uint8(16),
  24511 	3: uint8(9),
  24512 	4: uint8(7),
  24513 	5: uint8(5),
  24514 	6: uint8(3),
  24515 	7: uint8(2),
  24516 }
  24517 
  24518 func PreLoopInitialize(tls *libc.TLS, enc uintptr) (r int32) {
  24519 	var average_bytes_per_MB, bytes_per_parts, ok, p int32
  24520 	_, _, _, _ = average_bytes_per_MB, bytes_per_parts, ok, p
  24521 	ok = int32(1)
  24522 	average_bytes_per_MB = libc.Int32FromUint8(kAverageBytesPerMB[(*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant>>int32(4)])
  24523 	bytes_per_parts = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h * average_bytes_per_MB / (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts
  24524 	// Initialize the bit-writers
  24525 	p = 0
  24526 	for {
  24527 		if !(ok != 0 && p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  24528 			break
  24529 		}
  24530 		ok = VP8BitWriterInit(tls, enc+112+uintptr(p)*48, libc.Uint64FromInt32(bytes_per_parts))
  24531 		goto _1
  24532 	_1:
  24533 		;
  24534 		p = p + 1
  24535 	}
  24536 	if !(ok != 0) {
  24537 		VP8EncFreeBitWriters(tls, enc) // malloc error occurred
  24538 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24539 	}
  24540 	return ok
  24541 }
  24542 
  24543 func PostLoopFinalize(tls *libc.TLS, it uintptr, ok int32) (r int32) {
  24544 	var enc uintptr
  24545 	var i, p, s int32
  24546 	_, _, _, _ = enc, i, p, s
  24547 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24548 	if ok != 0 {
  24549 		p = 0
  24550 		for {
  24551 			if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  24552 				break
  24553 			}
  24554 			VP8BitWriterFinish(tls, enc+112+uintptr(p)*48)
  24555 			ok = ok & libc.BoolInt32(!((**(**VP8BitWriter)(__ccgo_up(enc + 112 + uintptr(p)*48))).Ferror1 != 0))
  24556 			goto _1
  24557 		_1:
  24558 			;
  24559 			p = p + 1
  24560 		}
  24561 	}
  24562 	if ok != 0 { // All good. Finish up.
  24563 		if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != libc.UintptrFromInt32(0) {
  24564 			i = 0
  24565 			for {
  24566 				if !(i <= int32(2)) {
  24567 					break
  24568 				}
  24569 				s = 0
  24570 				for {
  24571 					if !(s < int32(NUM_MB_SEGMENTS)) {
  24572 						break
  24573 					}
  24574 					**(**int32)(__ccgo_up(enc + 23556 + uintptr(i)*16 + uintptr(s)*4)) = libc.Int32FromUint64((**(**uint64_t)(__ccgo_up(it + 208 + uintptr(s)*24 + uintptr(i)*8)) + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  24575 					goto _3
  24576 				_3:
  24577 					;
  24578 					s = s + 1
  24579 				}
  24580 				goto _2
  24581 			_2:
  24582 				;
  24583 				i = i + 1
  24584 			}
  24585 		}
  24586 		VP8AdjustFilterStrength(tls, it) // ...and store filter stats.
  24587 	} else {
  24588 		// Something bad happened -> need to do some memory cleanup.
  24589 		VP8EncFreeBitWriters(tls, enc)
  24590 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24591 	}
  24592 	return ok
  24593 }
  24594 
  24595 //------------------------------------------------------------------------------
  24596 //  VP8EncLoop(): does the final bitstream coding.
  24597 
  24598 func ResetAfterSkip(tls *libc.TLS, it uintptr) {
  24599 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) {
  24600 		**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) = uint32(0) // reset all predictors
  24601 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = 0
  24602 	} else {
  24603 		**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) &= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(24)) // preserve the dc_nz bit
  24604 	}
  24605 }
  24606 
  24607 func VP8EncLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24608 	bp := tls.Alloc(4736)
  24609 	defer tls.Free(4736)
  24610 	var dont_use_skip, ok int32
  24611 	var rd_opt VP8RDLevel
  24612 	var _ /* info at bp+3848 */ VP8ModeScore
  24613 	var _ /* it at bp+0 */ VP8EncIterator
  24614 	_, _, _ = dont_use_skip, ok, rd_opt
  24615 	ok = PreLoopInitialize(tls, enc)
  24616 	if !(ok != 0) {
  24617 		return 0
  24618 	}
  24619 	StatLoop(tls, enc) // stats-collection loop
  24620 	VP8IteratorInit(tls, enc, bp)
  24621 	VP8InitFilter(tls, bp)
  24622 	for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, bp) != 0 {
  24623 		dont_use_skip = libc.BoolInt32(!((*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fuse_skip_proba != 0))
  24624 		rd_opt = (*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level
  24625 		VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24626 		// Warning! order is important: first call VP8Decimate() and
  24627 		// *then* decide how to code the skip decision if there's one.
  24628 		if !(VP8Decimate(tls, bp, bp+3848, rd_opt) != 0) || dont_use_skip != 0 {
  24629 			CodeResiduals(tls, (**(**VP8EncIterator)(__ccgo_up(bp))).Fbw, bp, bp+3848)
  24630 			if (*VP8BitWriter)(unsafe.Pointer((**(**VP8EncIterator)(__ccgo_up(bp))).Fbw)).Ferror1 != 0 {
  24631 				// enc->pic->error_code is set in PostLoopFinalize().
  24632 				ok = 0
  24633 				break
  24634 			}
  24635 		} else { // reset predictors after a skip
  24636 			ResetAfterSkip(tls, bp)
  24637 		}
  24638 		StoreSideInfo(tls, bp)
  24639 		VP8StoreFilterStats(tls, bp)
  24640 		VP8IteratorExport(tls, bp)
  24641 		ok = VP8IteratorProgress(tls, bp, int32(20))
  24642 		VP8IteratorSaveBoundary(tls, bp)
  24643 	}
  24644 	return PostLoopFinalize(tls, bp, ok)
  24645 }
  24646 
  24647 //------------------------------------------------------------------------------
  24648 // Single pass using Token Buffer.
  24649 
  24650 func VP8EncTokenLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24651 	bp := tls.Alloc(4784)
  24652 	defer tls.Free(4784)
  24653 	var cnt, do_search, is_last_pass, max_count, num_pass_left, ok, pass_progress, remaining_progress, v1 int32
  24654 	var distortion, pixel_count, size, size_p0 uint64_t
  24655 	var proba uintptr
  24656 	var rd_opt VP8RDLevel
  24657 	var v2 bool
  24658 	var _ /* info at bp+3904 */ VP8ModeScore
  24659 	var _ /* it at bp+0 */ VP8EncIterator
  24660 	var _ /* stats at bp+3848 */ PassStats
  24661 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, distortion, do_search, is_last_pass, max_count, num_pass_left, ok, pass_progress, pixel_count, proba, rd_opt, remaining_progress, size, size_p0, v1, v2
  24662 	// Roughly refresh the proba eight times per pass
  24663 	max_count = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h >> int32(3)
  24664 	num_pass_left = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpass
  24665 	remaining_progress = int32(40) // percents
  24666 	do_search = (*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search
  24667 	proba = enc + 3616
  24668 	rd_opt = (*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level
  24669 	pixel_count = libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w) * libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) * uint64(384)
  24670 	InitPassStats(tls, enc, bp+3848)
  24671 	ok = PreLoopInitialize(tls, enc)
  24672 	if !(ok != 0) {
  24673 		return 0
  24674 	}
  24675 	if max_count < int32(MIN_COUNT) {
  24676 		max_count = int32(MIN_COUNT)
  24677 	}
  24678 	// otherwise, token-buffer won't be useful
  24679 	for {
  24680 		if v2 = ok != 0; v2 {
  24681 			v1 = num_pass_left
  24682 			num_pass_left = num_pass_left - 1
  24683 		}
  24684 		if !(v2 && v1 > 0) {
  24685 			break
  24686 		}
  24687 		is_last_pass = libc.BoolInt32(libc.Xfabs(tls, float64((**(**PassStats)(__ccgo_up(bp + 3848))).Fdq)) <= float64(DQ_LIMIT) || num_pass_left == 0 || (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits == 0)
  24688 		size_p0 = uint64(0)
  24689 		distortion = uint64(0)
  24690 		cnt = max_count
  24691 		// The final number of passes is not trivial to know in advance.
  24692 		pass_progress = remaining_progress / (int32(2) + num_pass_left)
  24693 		remaining_progress = remaining_progress - pass_progress
  24694 		VP8IteratorInit(tls, enc, bp)
  24695 		SetLoopParams(tls, enc, (**(**PassStats)(__ccgo_up(bp + 3848))).Fq)
  24696 		if is_last_pass != 0 {
  24697 			ResetTokenStats(tls, enc)
  24698 			VP8InitFilter(tls, bp) // don't collect stats until last pass (too costly)
  24699 		}
  24700 		VP8TBufferClear(tls, enc+496)
  24701 		for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, bp) != 0 {
  24702 			VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24703 			cnt = cnt - 1
  24704 			v1 = cnt
  24705 			if v1 < 0 {
  24706 				FinalizeTokenProbas(tls, proba)
  24707 				VP8CalculateLevelCosts(tls, proba) // refresh cost tables for rd-opt
  24708 				cnt = max_count
  24709 			}
  24710 			VP8Decimate(tls, bp, bp+3904, rd_opt)
  24711 			ok = RecordTokens(tls, bp, bp+3904, enc+496)
  24712 			if !(ok != 0) {
  24713 				WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24714 				break
  24715 			}
  24716 			size_p0 = size_p0 + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3904))).FH)
  24717 			distortion = distortion + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3904))).FD)
  24718 			if is_last_pass != 0 {
  24719 				StoreSideInfo(tls, bp)
  24720 				VP8StoreFilterStats(tls, bp)
  24721 				VP8IteratorExport(tls, bp)
  24722 				ok = VP8IteratorProgress(tls, bp, pass_progress)
  24723 			}
  24724 			VP8IteratorSaveBoundary(tls, bp)
  24725 		}
  24726 		if !(ok != 0) {
  24727 			break
  24728 		}
  24729 		size_p0 = size_p0 + libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize)
  24730 		if (**(**PassStats)(__ccgo_up(bp + 3848))).Fdo_size_search != 0 {
  24731 			size = libc.Uint64FromInt32(FinalizeTokenProbas(tls, enc+3616))
  24732 			size = size + VP8EstimateTokenSize(tls, enc+496, proba+4)
  24733 			size = (size + size_p0 + uint64(1024)) >> int32(11) // -> size in bytes
  24734 			size = size + libc.Uint64FromInt32(libc.Int32FromInt32(RIFF_HEADER_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)+libc.Int32FromInt32(VP8_FRAME_HEADER_SIZE))
  24735 			(**(**PassStats)(__ccgo_up(bp + 3848))).Fvalue = float64(size)
  24736 		} else { // compute and store PSNR
  24737 			(**(**PassStats)(__ccgo_up(bp + 3848))).Fvalue = GetPSNR(tls, distortion, pixel_count)
  24738 		}
  24739 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits > 0 && size_p0 > (libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19))-libc.Uint64FromUint64(2048))<<libc.Int32FromInt32(11) {
  24740 			num_pass_left = num_pass_left + 1
  24741 			**(**int32)(__ccgo_up(enc + 23624)) >>= int32(1) // strengthen header bit limitation...
  24742 			if is_last_pass != 0 {
  24743 				ResetSideInfo(tls, bp)
  24744 			}
  24745 			continue // ...and start over
  24746 		}
  24747 		if is_last_pass != 0 {
  24748 			break // done
  24749 		}
  24750 		if do_search != 0 {
  24751 			ComputeNextQ(tls, bp+3848) // Adjust q
  24752 		}
  24753 	}
  24754 	if ok != 0 {
  24755 		if !((**(**PassStats)(__ccgo_up(bp + 3848))).Fdo_size_search != 0) {
  24756 			FinalizeTokenProbas(tls, enc+3616)
  24757 		}
  24758 		ok = VP8EmitTokens(tls, enc+496, enc+112+uintptr(0)*48, proba+4, int32(1))
  24759 	}
  24760 	ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+remaining_progress, enc+536) != 0)
  24761 	return PostLoopFinalize(tls, bp, ok)
  24762 }
  24763 
  24764 const MAX_HISTO_GREEDY = 100
  24765 const NUM_PARTITIONS = 4
  24766 const __FLT_MIN__2 = 1.17549435082228750796873653722224568e-38
  24767 
  24768 //------------------------------------------------------------------------------
  24769 
  24770 // Copyright 2012 Google Inc. All Rights Reserved.
  24771 //
  24772 // Use of this source code is governed by a BSD-style license
  24773 // that can be found in the COPYING file in the root of the source
  24774 // tree. An additional intellectual property rights grant can be found
  24775 // in the file PATENTS. All contributing project authors may
  24776 // be found in the AUTHORS file in the root of the source tree.
  24777 // -----------------------------------------------------------------------------
  24778 //
  24779 // Misc. common utility functions
  24780 //
  24781 // Authors: Skal (pascal.massimino@gmail.com)
  24782 //          Urvang (urvang@google.com)
  24783 
  24784 // Copyright 2011 Google Inc. All Rights Reserved.
  24785 //
  24786 // Use of this source code is governed by a BSD-style license
  24787 // that can be found in the COPYING file in the root of the source
  24788 // tree. An additional intellectual property rights grant can be found
  24789 // in the file PATENTS. All contributing project authors may
  24790 // be found in the AUTHORS file in the root of the source tree.
  24791 // -----------------------------------------------------------------------------
  24792 //
  24793 //   WebP encoder: main interface
  24794 //
  24795 // Author: Skal (pascal.massimino@gmail.com)
  24796 
  24797 // Copyright 2012 Google Inc. All Rights Reserved.
  24798 //
  24799 // Use of this source code is governed by a BSD-style license
  24800 // that can be found in the COPYING file in the root of the source
  24801 // tree. An additional intellectual property rights grant can be found
  24802 // in the file PATENTS. All contributing project authors may
  24803 // be found in the AUTHORS file in the root of the source tree.
  24804 // -----------------------------------------------------------------------------
  24805 //
  24806 //  Internal header for constants related to WebP file format.
  24807 //
  24808 // Author: Urvang (urvang@google.com)
  24809 
  24810 // Copyright 2010 Google Inc. All Rights Reserved.
  24811 //
  24812 // Use of this source code is governed by a BSD-style license
  24813 // that can be found in the COPYING file in the root of the source
  24814 // tree. An additional intellectual property rights grant can be found
  24815 // in the file PATENTS. All contributing project authors may
  24816 // be found in the AUTHORS file in the root of the source tree.
  24817 // -----------------------------------------------------------------------------
  24818 //
  24819 //  Common types + memory wrappers
  24820 //
  24821 // Author: Skal (pascal.massimino@gmail.com)
  24822 
  24823 // Number of partitions for the three dominant (literal, red and blue) symbol
  24824 // costs.
  24825 // The size of the bin-hash corresponding to the three dominant costs.
  24826 // Maximum number of histograms allowed in greedy combining algorithm.
  24827 
  24828 // C documentation
  24829 //
  24830 //	// Enum to meaningfully access the elements of the Histogram arrays.
  24831 type HistogramIndex = int32
  24832 
  24833 const LITERAL = 0
  24834 const DISTANCE = 4
  24835 
  24836 // C documentation
  24837 //
  24838 //	// Return the size of the histogram for a given cache_bits.
  24839 func GetHistogramSize(tls *libc.TLS, cache_bits int32) (r int32) {
  24840 	var literal_size, v1, v2, v4 int32
  24841 	var total_size size_t
  24842 	_, _, _, _, _ = literal_size, total_size, v1, v2, v4
  24843 	v1 = cache_bits
  24844 	if v1 > 0 {
  24845 		v4 = int32(1) << v1
  24846 	} else {
  24847 		v4 = 0
  24848 	}
  24849 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  24850 	goto _3
  24851 _3:
  24852 	literal_size = v2
  24853 	total_size = uint64(3312) + uint64(4)*libc.Uint64FromInt32(literal_size)
  24854 	return libc.Int32FromUint64(total_size)
  24855 }
  24856 
  24857 func HistogramStatsClear(tls *libc.TLS, h uintptr) {
  24858 	var i int32
  24859 	_ = i
  24860 	i = 0
  24861 	for {
  24862 		if !(i < int32(5)) {
  24863 			break
  24864 		}
  24865 		**(**uint16_t)(__ccgo_up(h + 3244 + uintptr(i)*2)) = libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))
  24866 		// By default, the histogram is assumed to be used.
  24867 		**(**uint8_t)(__ccgo_up(h + 3304 + uintptr(i))) = uint8(1)
  24868 		goto _1
  24869 	_1:
  24870 		;
  24871 		i = i + 1
  24872 	}
  24873 	(*VP8LHistogram)(unsafe.Pointer(h)).Fbit_cost = uint64(0)
  24874 	libc.X__builtin___memset_chk(tls, h+3264, 0, uint64(40), ^__predefined_size_t(0))
  24875 }
  24876 
  24877 func HistogramClear(tls *libc.TLS, h uintptr) {
  24878 	var cache_bits, histo_size int32
  24879 	var literal uintptr
  24880 	_, _, _ = cache_bits, histo_size, literal
  24881 	literal = (*VP8LHistogram)(unsafe.Pointer(h)).Fliteral
  24882 	cache_bits = (*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits
  24883 	histo_size = GetHistogramSize(tls, cache_bits)
  24884 	libc.X__builtin___memset_chk(tls, h, 0, libc.Uint64FromInt32(histo_size), ^__predefined_size_t(0))
  24885 	(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = cache_bits
  24886 	(*VP8LHistogram)(unsafe.Pointer(h)).Fliteral = literal
  24887 	HistogramStatsClear(tls, h)
  24888 }
  24889 
  24890 // C documentation
  24891 //
  24892 //	// Swap two histogram pointers.
  24893 func HistogramSwap(tls *libc.TLS, h1 uintptr, h2 uintptr) {
  24894 	var tmp uintptr
  24895 	_ = tmp
  24896 	tmp = **(**uintptr)(__ccgo_up(h1))
  24897 	**(**uintptr)(__ccgo_up(h1)) = **(**uintptr)(__ccgo_up(h2))
  24898 	**(**uintptr)(__ccgo_up(h2)) = tmp
  24899 }
  24900 
  24901 func HistogramCopy(tls *libc.TLS, src uintptr, dst uintptr) {
  24902 	var dst_cache_bits, histo_size, literal_size, v1, v2, v4 int32
  24903 	var dst_literal uintptr
  24904 	_, _, _, _, _, _, _ = dst_cache_bits, dst_literal, histo_size, literal_size, v1, v2, v4
  24905 	dst_literal = (*VP8LHistogram)(unsafe.Pointer(dst)).Fliteral
  24906 	dst_cache_bits = (*VP8LHistogram)(unsafe.Pointer(dst)).Fpalette_code_bits
  24907 	v1 = dst_cache_bits
  24908 	if v1 > 0 {
  24909 		v4 = int32(1) << v1
  24910 	} else {
  24911 		v4 = 0
  24912 	}
  24913 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  24914 	goto _3
  24915 _3:
  24916 	literal_size = v2
  24917 	histo_size = GetHistogramSize(tls, dst_cache_bits)
  24918 	libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(histo_size), ^__predefined_size_t(0))
  24919 	(*VP8LHistogram)(unsafe.Pointer(dst)).Fliteral = dst_literal
  24920 	libc.X__builtin___memcpy_chk(tls, (*VP8LHistogram)(unsafe.Pointer(dst)).Fliteral, (*VP8LHistogram)(unsafe.Pointer(src)).Fliteral, libc.Uint64FromInt32(literal_size)*uint64(4), ^__predefined_size_t(0))
  24921 }
  24922 
  24923 func VP8LFreeHistogram(tls *libc.TLS, h uintptr) {
  24924 	WebPSafeFree(tls, h)
  24925 }
  24926 
  24927 func VP8LFreeHistogramSet(tls *libc.TLS, histograms uintptr) {
  24928 	WebPSafeFree(tls, histograms)
  24929 }
  24930 
  24931 func VP8LHistogramCreate(tls *libc.TLS, h uintptr, refs uintptr, palette_code_bits int32) {
  24932 	if palette_code_bits >= 0 {
  24933 		(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = palette_code_bits
  24934 	}
  24935 	HistogramClear(tls, h)
  24936 	VP8LHistogramStoreRefs(tls, refs, libc.UintptrFromInt32(0), 0, h)
  24937 }
  24938 
  24939 func VP8LHistogramInit(tls *libc.TLS, h uintptr, palette_code_bits int32, init_arrays int32) {
  24940 	(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = palette_code_bits
  24941 	if init_arrays != 0 {
  24942 		HistogramClear(tls, h)
  24943 	} else {
  24944 		HistogramStatsClear(tls, h)
  24945 	}
  24946 }
  24947 
  24948 func VP8LAllocateHistogram(tls *libc.TLS, cache_bits int32) (r uintptr) {
  24949 	var histo, memory uintptr
  24950 	var total_size int32
  24951 	_, _, _ = histo, memory, total_size
  24952 	histo = libc.UintptrFromInt32(0)
  24953 	total_size = GetHistogramSize(tls, cache_bits)
  24954 	memory = WebPSafeMalloc(tls, libc.Uint64FromInt32(total_size), uint64(1))
  24955 	if memory == libc.UintptrFromInt32(0) {
  24956 		return libc.UintptrFromInt32(0)
  24957 	}
  24958 	histo = memory
  24959 	// 'literal' won't necessary be aligned.
  24960 	(*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral = memory + libc.UintptrFromInt64(3312)
  24961 	VP8LHistogramInit(tls, histo, cache_bits, 0)
  24962 	return histo
  24963 }
  24964 
  24965 // C documentation
  24966 //
  24967 //	// Resets the pointers of the histograms to point to the bit buffer in the set.
  24968 func HistogramSetResetPointers(tls *libc.TLS, set uintptr, cache_bits int32) {
  24969 	var histo_size, i int32
  24970 	var memory uintptr
  24971 	_, _, _ = histo_size, i, memory
  24972 	histo_size = GetHistogramSize(tls, cache_bits)
  24973 	memory = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms
  24974 	memory = memory + uintptr(libc.Uint64FromInt32((*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size)*uint64(8))
  24975 	i = 0
  24976 	for {
  24977 		if !(i < (*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size) {
  24978 			break
  24979 		}
  24980 		memory = uintptr((uint64(memory) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  24981 		**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)) = memory
  24982 		// 'literal' won't necessary be aligned.
  24983 		(*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)))).Fliteral = memory + libc.UintptrFromInt64(3312)
  24984 		memory = memory + uintptr(histo_size)
  24985 		goto _1
  24986 	_1:
  24987 		;
  24988 		i = i + 1
  24989 	}
  24990 }
  24991 
  24992 // C documentation
  24993 //
  24994 //	// Returns the total size of the VP8LHistogramSet.
  24995 func HistogramSetTotalSize(tls *libc.TLS, size int32, cache_bits int32) (r size_t) {
  24996 	var histo_size int32
  24997 	_ = histo_size
  24998 	histo_size = GetHistogramSize(tls, cache_bits)
  24999 	return libc.Uint64FromInt64(16) + libc.Uint64FromInt32(size)*(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(histo_size)+libc.Uint64FromInt32(WEBP_ALIGN_CST))
  25000 }
  25001 
  25002 func VP8LAllocateHistogramSet(tls *libc.TLS, size int32, cache_bits int32) (r uintptr) {
  25003 	var i int32
  25004 	var memory, set uintptr
  25005 	var total_size size_t
  25006 	_, _, _, _ = i, memory, set, total_size
  25007 	total_size = HistogramSetTotalSize(tls, size, cache_bits)
  25008 	memory = WebPSafeMalloc(tls, total_size, uint64(1))
  25009 	if memory == libc.UintptrFromInt32(0) {
  25010 		return libc.UintptrFromInt32(0)
  25011 	}
  25012 	set = memory
  25013 	memory = memory + uintptr(16)
  25014 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms = memory
  25015 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size = size
  25016 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = size
  25017 	HistogramSetResetPointers(tls, set, cache_bits)
  25018 	i = 0
  25019 	for {
  25020 		if !(i < size) {
  25021 			break
  25022 		}
  25023 		VP8LHistogramInit(tls, **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)), cache_bits, 0)
  25024 		goto _1
  25025 	_1:
  25026 		;
  25027 		i = i + 1
  25028 	}
  25029 	return set
  25030 }
  25031 
  25032 func VP8LHistogramSetClear(tls *libc.TLS, set uintptr) {
  25033 	var cache_bits, i, size int32
  25034 	var memory uintptr
  25035 	var total_size size_t
  25036 	_, _, _, _, _ = cache_bits, i, memory, size, total_size
  25037 	cache_bits = (*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms)))).Fpalette_code_bits
  25038 	size = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size
  25039 	total_size = HistogramSetTotalSize(tls, size, cache_bits)
  25040 	memory = set
  25041 	libc.X__builtin___memset_chk(tls, memory, 0, total_size, ^__predefined_size_t(0))
  25042 	memory = memory + uintptr(16)
  25043 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms = memory
  25044 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size = size
  25045 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = size
  25046 	HistogramSetResetPointers(tls, set, cache_bits)
  25047 	i = 0
  25048 	for {
  25049 		if !(i < size) {
  25050 			break
  25051 		}
  25052 		(*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)))).Fpalette_code_bits = cache_bits
  25053 		goto _1
  25054 	_1:
  25055 		;
  25056 		i = i + 1
  25057 	}
  25058 }
  25059 
  25060 // C documentation
  25061 //
  25062 //	// Removes the histogram 'i' from 'set'.
  25063 func HistogramSetRemoveHistogram(tls *libc.TLS, set uintptr, i int32) {
  25064 	**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr((*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize-int32(1))*8))
  25065 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize - 1
  25066 }
  25067 
  25068 // -----------------------------------------------------------------------------
  25069 
  25070 func HistogramAddSinglePixOrCopy(tls *libc.TLS, histo uintptr, v uintptr, __ccgo_fp_distance_modifier uintptr, distance_modifier_arg0 int32) {
  25071 	bp := tls.Alloc(16)
  25072 	defer tls.Free(16)
  25073 	var highest_bit, literal_ix, second_highest_bit, v1, v11, v17, v20 int32
  25074 	var prefix_code VP8LPrefixCode
  25075 	var v3 uint32_t
  25076 	var v18, v19 uintptr
  25077 	var _ /* code at bp+0 */ int32
  25078 	var _ /* extra_bits at bp+4 */ int32
  25079 	_, _, _, _, _, _, _, _, _, _, _ = highest_bit, literal_ix, prefix_code, second_highest_bit, v1, v11, v17, v18, v19, v20, v3
  25080 	v1 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  25081 	goto _2
  25082 _2:
  25083 	if v1 != 0 {
  25084 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(3) * libc.Int32FromInt32(8)) & uint32(0xff)
  25085 		goto _4
  25086 	_4:
  25087 		**(**uint32_t)(__ccgo_up(histo + 2056 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 2056 + uintptr(v3)*4)) + 1
  25088 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(2) * libc.Int32FromInt32(8)) & uint32(0xff)
  25089 		goto _6
  25090 	_6:
  25091 		**(**uint32_t)(__ccgo_up(histo + 8 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 8 + uintptr(v3)*4)) + 1
  25092 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(1) * libc.Int32FromInt32(8)) & uint32(0xff)
  25093 		goto _8
  25094 	_8:
  25095 		**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(v3)*4)) + 1
  25096 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (0 * libc.Int32FromInt32(8)) & uint32(0xff)
  25097 		goto _10
  25098 	_10:
  25099 		**(**uint32_t)(__ccgo_up(histo + 1032 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 1032 + uintptr(v3)*4)) + 1
  25100 	} else {
  25101 		v1 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kCacheIdx))
  25102 		goto _12
  25103 	_12:
  25104 		if v1 != 0 {
  25105 			v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25106 			goto _14
  25107 		_14:
  25108 			literal_ix = libc.Int32FromUint32(libc.Uint32FromInt32(libc.Int32FromInt32(NUM_LITERAL_CODES)+libc.Int32FromInt32(NUM_LENGTH_CODES)) + v3)
  25109 			**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(literal_ix)*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(literal_ix)*4)) + 1
  25110 		} else {
  25111 			v3 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  25112 			goto _16
  25113 		_16:
  25114 			v1 = libc.Int32FromUint32(v3)
  25115 			v18 = bp
  25116 			v19 = bp + 4
  25117 			if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25118 				prefix_code = kPrefixEncodeCode[v1]
  25119 				**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25120 				**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25121 			} else {
  25122 				v11 = v1
  25123 				v11 = v11 - 1
  25124 				v17 = v11
  25125 				v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25126 				goto _23
  25127 			_23:
  25128 				highest_bit = v20
  25129 				second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25130 				**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25131 				**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25132 			}
  25133 			**(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(int32(NUM_LITERAL_CODES)+**(**int32)(__ccgo_up(bp)))*4)) = **(**uint32_t)(__ccgo_up((*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral + uintptr(int32(NUM_LITERAL_CODES)+**(**int32)(__ccgo_up(bp)))*4)) + 1
  25134 			if __ccgo_fp_distance_modifier == libc.UintptrFromInt32(0) {
  25135 				v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25136 				goto _25
  25137 			_25:
  25138 				v1 = libc.Int32FromUint32(v3)
  25139 				v18 = bp
  25140 				v19 = bp + 4
  25141 				if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25142 					prefix_code = kPrefixEncodeCode[v1]
  25143 					**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25144 					**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25145 				} else {
  25146 					v11 = v1
  25147 					v11 = v11 - 1
  25148 					v17 = v11
  25149 					v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25150 					goto _32
  25151 				_32:
  25152 					highest_bit = v20
  25153 					second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25154 					**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25155 					**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25156 				}
  25157 			} else {
  25158 				v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25159 				goto _34
  25160 			_34:
  25161 				v1 = (*(*func(*libc.TLS, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_distance_modifier})))(tls, distance_modifier_arg0, libc.Int32FromUint32(v3))
  25162 				v18 = bp
  25163 				v19 = bp + 4
  25164 				if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25165 					prefix_code = kPrefixEncodeCode[v1]
  25166 					**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25167 					**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25168 				} else {
  25169 					v11 = v1
  25170 					v11 = v11 - 1
  25171 					v17 = v11
  25172 					v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25173 					goto _41
  25174 				_41:
  25175 					highest_bit = v20
  25176 					second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25177 					**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25178 					**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25179 				}
  25180 			}
  25181 			**(**uint32_t)(__ccgo_up(histo + 3080 + uintptr(**(**int32)(__ccgo_up(bp)))*4)) = **(**uint32_t)(__ccgo_up(histo + 3080 + uintptr(**(**int32)(__ccgo_up(bp)))*4)) + 1
  25182 		}
  25183 	}
  25184 }
  25185 
  25186 type __ccgo_fp__XVP8LHistogramStoreRefs_1 = func(*libc.TLS, int32, int32) int32
  25187 
  25188 func VP8LHistogramStoreRefs(tls *libc.TLS, refs uintptr, __ccgo_fp_distance_modifier uintptr, distance_modifier_arg0 int32, histo uintptr) {
  25189 	bp := tls.Alloc(32)
  25190 	defer tls.Free(32)
  25191 	var v1 int32
  25192 	var v3, v4, v5 uintptr
  25193 	var _ /* c at bp+0 */ VP8LRefsCursor
  25194 	_, _, _, _ = v1, v3, v4, v5
  25195 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  25196 	for {
  25197 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  25198 		goto _2
  25199 	_2:
  25200 		if !(v1 != 0) {
  25201 			break
  25202 		}
  25203 		HistogramAddSinglePixOrCopy(tls, histo, (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos, __ccgo_fp_distance_modifier, distance_modifier_arg0)
  25204 		v3 = bp
  25205 		v5 = v3
  25206 		*(*uintptr)(unsafe.Pointer(v5)) += 8
  25207 		v4 = *(*uintptr)(unsafe.Pointer(v5))
  25208 		if v4 == (*VP8LRefsCursor)(unsafe.Pointer(v3)).Flast_pos {
  25209 			VP8LRefsCursorNextBlock(tls, v3)
  25210 		}
  25211 	}
  25212 }
  25213 
  25214 // -----------------------------------------------------------------------------
  25215 // Entropy-related functions.
  25216 
  25217 func BitsEntropyRefine(tls *libc.TLS, entropy uintptr) (r uint64_t) {
  25218 	var min_limit, mix uint64_t
  25219 	var v1, v2, v3 int64_t
  25220 	var v5 int64
  25221 	var v11 uint64
  25222 	_, _, _, _, _, _, _ = min_limit, mix, v1, v11, v2, v3, v5
  25223 	if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros < int32(5) {
  25224 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros <= int32(1) {
  25225 			return uint64(0)
  25226 		}
  25227 		// Two symbols, they will be 0 and 1 in a Huffman code.
  25228 		// Let's mix in a bit of entropy to favor good clustering when
  25229 		// distributions of these are combined.
  25230 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros == int32(2) {
  25231 			v1 = libc.Int64FromUint64(uint64(99)*(uint64((*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)) + (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy)
  25232 			v2 = int64(100)
  25233 			if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25234 				v5 = (v1 + v2/int64(2)) / v2
  25235 			} else {
  25236 				v5 = (v1 - v2/int64(2)) / v2
  25237 			}
  25238 			v3 = v5
  25239 			goto _4
  25240 		_4:
  25241 			return libc.Uint64FromInt64(v3)
  25242 		}
  25243 		// No matter what the entropy says, we cannot be better than min_limit
  25244 		// with Huffman coding. I am mixing a bit of entropy into the
  25245 		// min_limit since it produces much better (~0.5 %) compression results
  25246 		// perhaps because of better entropy clustering.
  25247 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros == int32(3) {
  25248 			mix = uint64(950)
  25249 		} else {
  25250 			mix = uint64(700) // nonzeros == 4.
  25251 		}
  25252 	} else {
  25253 		mix = uint64(627)
  25254 	}
  25255 	min_limit = uint64(libc.Uint32FromInt32(2)*(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum-(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val) << int32(LOG_2_PRECISION_BITS)
  25256 	v1 = libc.Int64FromUint64(mix*min_limit + (uint64(1000)-mix)*(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy)
  25257 	v2 = int64(1000)
  25258 	if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25259 		v5 = (v1 + v2/int64(2)) / v2
  25260 	} else {
  25261 		v5 = (v1 - v2/int64(2)) / v2
  25262 	}
  25263 	v3 = v5
  25264 	goto _9
  25265 _9:
  25266 	min_limit = libc.Uint64FromInt64(v3)
  25267 	if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy < min_limit {
  25268 		v11 = min_limit
  25269 	} else {
  25270 		v11 = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy
  25271 	}
  25272 	return v11
  25273 	return r
  25274 }
  25275 
  25276 func VP8LBitsEntropy(tls *libc.TLS, array uintptr, n int32) (r uint64_t) {
  25277 	bp := tls.Alloc(32)
  25278 	defer tls.Free(32)
  25279 	var _ /* entropy at bp+0 */ VP8LBitEntropy
  25280 	VP8LBitsEntropyUnrefined(tls, array, n, bp)
  25281 	return BitsEntropyRefine(tls, bp)
  25282 }
  25283 
  25284 func InitialHuffmanCost(tls *libc.TLS) (r uint64_t) {
  25285 	var v1, v2, v3 int64_t
  25286 	var v5 int64
  25287 	_, _, _, _ = v1, v2, v3, v5
  25288 	// Subtract a bias of 9.1.
  25289 	v1 = libc.Int64FromInt64(91) << libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  25290 	v2 = int64(10)
  25291 	if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25292 		v5 = (v1 + v2/int64(2)) / v2
  25293 	} else {
  25294 		v5 = (v1 - v2/int64(2)) / v2
  25295 	}
  25296 	v3 = v5
  25297 	goto _4
  25298 _4:
  25299 	return kHuffmanCodeOfHuffmanCodeSize<<libc.Int32FromInt32(LOG_2_PRECISION_BITS) - libc.Uint64FromInt64(v3)
  25300 }
  25301 
  25302 // Small bias because Huffman code length is typically not stored in
  25303 // full length.
  25304 var kHuffmanCodeOfHuffmanCodeSize = libc.Uint64FromInt32(libc.Int32FromInt32(CODE_LENGTH_CODES) * libc.Int32FromInt32(3))
  25305 
  25306 // C documentation
  25307 //
  25308 //	// Finalize the Huffman cost based on streak numbers and length type (<3 or >=3)
  25309 func FinalHuffmanCost(tls *libc.TLS, stats uintptr) (r uint64_t) {
  25310 	var retval uint64_t
  25311 	var retval_extra uint32_t
  25312 	_, _ = retval, retval_extra
  25313 	// The constants in this function are empirical and got rounded from
  25314 	// their original values in 1/8 when switched to 1/1024.
  25315 	retval = InitialHuffmanCost(tls)
  25316 	// Second coefficient: Many zeros in the histogram are covered efficiently
  25317 	// by a run-length encode. Originally 2/8.
  25318 	retval_extra = libc.Uint32FromInt32(**(**int32)(__ccgo_up(stats))*int32(1600) + int32(240)***(**int32)(__ccgo_up(stats + 8 + 1*4)))
  25319 	// Second coefficient: Constant values are encoded less efficiently, but still
  25320 	// RLE'ed. Originally 6/8.
  25321 	retval_extra = retval_extra + libc.Uint32FromInt32(**(**int32)(__ccgo_up(stats + 1*4))*int32(2640)+int32(720)***(**int32)(__ccgo_up(stats + 8 + 1*8 + 1*4)))
  25322 	// 0s are usually encoded more efficiently than non-0s.
  25323 	// Originally 15/8.
  25324 	retval_extra = retval_extra + libc.Uint32FromInt32(int32(1840)***(**int32)(__ccgo_up(stats + 8)))
  25325 	// Originally 26/8.
  25326 	retval_extra = retval_extra + libc.Uint32FromInt32(int32(3360)***(**int32)(__ccgo_up(stats + 8 + 1*8)))
  25327 	return retval + uint64(retval_extra)<<(libc.Int32FromInt32(LOG_2_PRECISION_BITS)-libc.Int32FromInt32(10))
  25328 }
  25329 
  25330 // C documentation
  25331 //
  25332 //	// Get the symbol entropy for the distribution 'population'.
  25333 //	// Set 'trivial_sym', if there's only one symbol present in the distribution.
  25334 func PopulationCost(tls *libc.TLS, population uintptr, length int32, trivial_sym uintptr, is_used uintptr) (r uint64_t) {
  25335 	bp := tls.Alloc(48)
  25336 	defer tls.Free(48)
  25337 	var v1 uint32
  25338 	var _ /* bit_entropy at bp+0 */ VP8LBitEntropy
  25339 	var _ /* stats at bp+24 */ VP8LStreaks
  25340 	_ = v1
  25341 	(*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LGetEntropyUnrefined})))(tls, population, length, bp, bp+24)
  25342 	if trivial_sym != libc.UintptrFromInt32(0) {
  25343 		if (**(**VP8LBitEntropy)(__ccgo_up(bp))).Fnonzeros == int32(1) {
  25344 			v1 = (**(**VP8LBitEntropy)(__ccgo_up(bp))).Fnonzero_code
  25345 		} else {
  25346 			v1 = uint32(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  25347 		}
  25348 		**(**uint16_t)(__ccgo_up(trivial_sym)) = uint16(v1)
  25349 	}
  25350 	if is_used != libc.UintptrFromInt32(0) {
  25351 		// The histogram is used if there is at least one non-zero streak.
  25352 		**(**uint8_t)(__ccgo_up(is_used)) = libc.BoolUint8(**(**int32)(__ccgo_up(bp + 24 + 8 + 1*8)) != 0 || **(**int32)(__ccgo_up(bp + 24 + 8 + 1*8 + 1*4)) != 0)
  25353 	}
  25354 	return BitsEntropyRefine(tls, bp) + FinalHuffmanCost(tls, bp+24)
  25355 }
  25356 
  25357 func GetPopulationInfo(tls *libc.TLS, histo uintptr, index HistogramIndex, population uintptr, length uintptr) {
  25358 	var v1, v2, v4 int32
  25359 	_, _, _ = v1, v2, v4
  25360 	switch index {
  25361 	case int32(LITERAL):
  25362 		**(**uintptr)(__ccgo_up(population)) = (*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral
  25363 		v1 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  25364 		if v1 > 0 {
  25365 			v4 = int32(1) << v1
  25366 		} else {
  25367 			v4 = 0
  25368 		}
  25369 		v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  25370 		goto _3
  25371 	_3:
  25372 		**(**int32)(__ccgo_up(length)) = v2
  25373 	case int32(RED):
  25374 		**(**uintptr)(__ccgo_up(population)) = histo + 8
  25375 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25376 	case int32(BLUE):
  25377 		**(**uintptr)(__ccgo_up(population)) = histo + 1032
  25378 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25379 	case int32(ALPHA):
  25380 		**(**uintptr)(__ccgo_up(population)) = histo + 2056
  25381 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25382 	case int32(DISTANCE):
  25383 		**(**uintptr)(__ccgo_up(population)) = histo + 3080
  25384 		**(**int32)(__ccgo_up(length)) = int32(NUM_DISTANCE_CODES)
  25385 		break
  25386 	}
  25387 }
  25388 
  25389 // C documentation
  25390 //
  25391 //	// trivial_at_end is 1 if the two histograms only have one element that is
  25392 //	// non-zero: both the zero-th one, or both the last one.
  25393 //	// 'index' is the index of the symbol in the histogram (literal, red, blue,
  25394 //	// alpha, distance).
  25395 func GetCombinedEntropy(tls *libc.TLS, h1 uintptr, h2 uintptr, index HistogramIndex) (r uint64_t) {
  25396 	bp := tls.Alloc(80)
  25397 	defer tls.Free(80)
  25398 	var is_h1_used, is_h2_used, is_trivial int32
  25399 	var _ /* X at bp+0 */ uintptr
  25400 	var _ /* Y at bp+8 */ uintptr
  25401 	var _ /* bit_entropy at bp+48 */ VP8LBitEntropy
  25402 	var _ /* length at bp+16 */ int32
  25403 	var _ /* stats at bp+20 */ VP8LStreaks
  25404 	_, _, _ = is_h1_used, is_h2_used, is_trivial
  25405 	is_h1_used = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(index))))
  25406 	is_h2_used = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(index))))
  25407 	is_trivial = libc.BoolInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(index)*2))) != libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) && libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(index)*2))) == libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h2 + 3244 + uintptr(index)*2))))
  25408 	if is_trivial != 0 || !(is_h1_used != 0) || !(is_h2_used != 0) {
  25409 		if is_h1_used != 0 {
  25410 			return **(**uint64_t)(__ccgo_up(h1 + 3264 + uintptr(index)*8))
  25411 		}
  25412 		return **(**uint64_t)(__ccgo_up(h2 + 3264 + uintptr(index)*8))
  25413 	}
  25414 	GetPopulationInfo(tls, h1, index, bp, bp+16)
  25415 	GetPopulationInfo(tls, h2, index, bp+8, bp+16)
  25416 	(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LGetCombinedEntropyUnrefined})))(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp+48, bp+20)
  25417 	return BitsEntropyRefine(tls, bp+48) + FinalHuffmanCost(tls, bp+20)
  25418 }
  25419 
  25420 // C documentation
  25421 //
  25422 //	// Estimates the Entropy + Huffman + other block overhead size cost.
  25423 func VP8LHistogramEstimateBits(tls *libc.TLS, h uintptr) (r uint64_t) {
  25424 	bp := tls.Alloc(16)
  25425 	defer tls.Free(16)
  25426 	var cost uint64_t
  25427 	var i int32
  25428 	var _ /* length at bp+0 */ int32
  25429 	var _ /* population at bp+8 */ uintptr
  25430 	_, _ = cost, i
  25431 	cost = uint64(0)
  25432 	i = 0
  25433 	for {
  25434 		if !(i < int32(5)) {
  25435 			break
  25436 		}
  25437 		GetPopulationInfo(tls, h, i, bp+8, bp)
  25438 		cost = cost + PopulationCost(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp)), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0))
  25439 		goto _1
  25440 	_1:
  25441 		;
  25442 		i = i + 1
  25443 	}
  25444 	cost = cost + uint64((*(*func(*libc.TLS, uintptr, int32) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LExtraCost})))(tls, (*VP8LHistogram)(unsafe.Pointer(h)).Fliteral+uintptr(NUM_LITERAL_CODES)*4, int32(NUM_LENGTH_CODES))+(*(*func(*libc.TLS, uintptr, int32) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LExtraCost})))(tls, h+3080, int32(NUM_DISTANCE_CODES)))<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  25445 	return cost
  25446 }
  25447 
  25448 // -----------------------------------------------------------------------------
  25449 // Various histogram combine/cost-eval functions
  25450 
  25451 // C documentation
  25452 //
  25453 //	// Set a + b in b, saturating at WEBP_INT64_MAX.
  25454 func SaturateAdd(tls *libc.TLS, a uint64_t, b uintptr) {
  25455 	if **(**int64_t)(__ccgo_up(b)) < 0 || libc.Int64FromUint64(a) <= libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63)-libc.Uint64FromInt32(1))-**(**int64_t)(__ccgo_up(b)) {
  25456 		**(**int64_t)(__ccgo_up(b)) += libc.Int64FromUint64(a)
  25457 	} else {
  25458 		**(**int64_t)(__ccgo_up(b)) = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  25459 	}
  25460 }
  25461 
  25462 // C documentation
  25463 //
  25464 //	// Returns 1 if the cost of the combined histogram is less than the threshold.
  25465 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25466 func GetCombinedHistogramEntropy(tls *libc.TLS, a uintptr, b uintptr, cost_threshold_in int64_t, cost uintptr, costs uintptr) (r int32) {
  25467 	var cost_threshold uint64_t
  25468 	var i int32
  25469 	_, _ = cost_threshold, i
  25470 	cost_threshold = libc.Uint64FromInt64(cost_threshold_in)
  25471 	if cost_threshold_in <= 0 {
  25472 		return 0
  25473 	}
  25474 	**(**uint64_t)(__ccgo_up(cost)) = uint64(0)
  25475 	// No need to add the extra cost for length and distance as it is a constant
  25476 	// that does not influence the histograms.
  25477 	i = 0
  25478 	for {
  25479 		if !(i < int32(5)) {
  25480 			break
  25481 		}
  25482 		**(**uint64_t)(__ccgo_up(costs + uintptr(i)*8)) = GetCombinedEntropy(tls, a, b, i)
  25483 		**(**uint64_t)(__ccgo_up(cost)) += **(**uint64_t)(__ccgo_up(costs + uintptr(i)*8))
  25484 		if **(**uint64_t)(__ccgo_up(cost)) >= cost_threshold {
  25485 			return 0
  25486 		}
  25487 		goto _1
  25488 	_1:
  25489 		;
  25490 		i = i + 1
  25491 	}
  25492 	return int32(1)
  25493 }
  25494 
  25495 func HistogramAdd(tls *libc.TLS, h1 uintptr, h2 uintptr, hout uintptr) {
  25496 	bp := tls.Alloc(32)
  25497 	defer tls.Free(32)
  25498 	var i, v3 int32
  25499 	var pout uintptr
  25500 	var _ /* length at bp+0 */ int32
  25501 	var _ /* p1 at bp+8 */ uintptr
  25502 	var _ /* p2 at bp+16 */ uintptr
  25503 	var _ /* pout_const at bp+24 */ uintptr
  25504 	_, _, _ = i, pout, v3
  25505 	i = 0
  25506 	for {
  25507 		if !(i < int32(5)) {
  25508 			break
  25509 		}
  25510 		GetPopulationInfo(tls, h1, i, bp+8, bp)
  25511 		GetPopulationInfo(tls, h2, i, bp+16, bp)
  25512 		GetPopulationInfo(tls, hout, i, bp+24, bp)
  25513 		pout = **(**uintptr)(__ccgo_up(bp + 24))
  25514 		if h2 == hout {
  25515 			if **(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(i))) != 0 {
  25516 				if **(**uint8_t)(__ccgo_up(hout + 3304 + uintptr(i))) != 0 {
  25517 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVectorEq})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), pout, **(**int32)(__ccgo_up(bp)))
  25518 				} else {
  25519 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 8)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25520 				}
  25521 			}
  25522 		} else {
  25523 			if **(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(i))) != 0 {
  25524 				if **(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(i))) != 0 {
  25525 					(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVector})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pout, **(**int32)(__ccgo_up(bp)))
  25526 				} else {
  25527 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 8)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25528 				}
  25529 			} else {
  25530 				if **(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(i))) != 0 {
  25531 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 16)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25532 				} else {
  25533 					libc.X__builtin___memset_chk(tls, pout, 0, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25534 				}
  25535 			}
  25536 		}
  25537 		goto _1
  25538 	_1:
  25539 		;
  25540 		i = i + 1
  25541 	}
  25542 	i = 0
  25543 	for {
  25544 		if !(i < int32(5)) {
  25545 			break
  25546 		}
  25547 		if libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(i)*2))) == libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h2 + 3244 + uintptr(i)*2))) {
  25548 			v3 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(i)*2)))
  25549 		} else {
  25550 			v3 = libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  25551 		}
  25552 		**(**uint16_t)(__ccgo_up(hout + 3244 + uintptr(i)*2)) = libc.Uint16FromInt32(v3)
  25553 		**(**uint8_t)(__ccgo_up(hout + 3304 + uintptr(i))) = libc.BoolUint8(**(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(i))) != 0 || **(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(i))) != 0)
  25554 		goto _2
  25555 	_2:
  25556 		;
  25557 		i = i + 1
  25558 	}
  25559 }
  25560 
  25561 func UpdateHistogramCost(tls *libc.TLS, bit_cost uint64_t, costs uintptr, h uintptr) {
  25562 	var i int32
  25563 	_ = i
  25564 	(*VP8LHistogram)(unsafe.Pointer(h)).Fbit_cost = bit_cost
  25565 	i = 0
  25566 	for {
  25567 		if !(i < int32(5)) {
  25568 			break
  25569 		}
  25570 		**(**uint64_t)(__ccgo_up(h + 3264 + uintptr(i)*8)) = **(**uint64_t)(__ccgo_up(costs + uintptr(i)*8))
  25571 		goto _1
  25572 	_1:
  25573 		;
  25574 		i = i + 1
  25575 	}
  25576 }
  25577 
  25578 // C documentation
  25579 //
  25580 //	// Performs out = a + b, computing the cost C(a+b) - C(a) - C(b) while comparing
  25581 //	// to the threshold value 'cost_threshold'. The score returned is
  25582 //	//  Score = C(a+b) - C(a) - C(b), where C(a) + C(b) is known and fixed.
  25583 //	// Since the previous score passed is 'cost_threshold', we only need to compare
  25584 //	// the partial cost against 'cost_threshold + C(a) + C(b)' to possibly bail-out
  25585 //	// early.
  25586 //	// Returns 1 if the cost is less than the threshold.
  25587 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25588 func HistogramAddEval(tls *libc.TLS, a uintptr, b uintptr, out uintptr, _cost_threshold int64_t) (r int32) {
  25589 	bp := tls.Alloc(64)
  25590 	defer tls.Free(64)
  25591 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  25592 	var sum_cost uint64_t
  25593 	var _ /* bit_cost at bp+8 */ uint64_t
  25594 	var _ /* costs at bp+16 */ [5]uint64_t
  25595 	_ = sum_cost
  25596 	sum_cost = (*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost + (*VP8LHistogram)(unsafe.Pointer(b)).Fbit_cost
  25597 	SaturateAdd(tls, sum_cost, bp)
  25598 	if !(GetCombinedHistogramEntropy(tls, a, b, **(**int64_t)(__ccgo_up(bp)), bp+8, bp+16) != 0) {
  25599 		return 0
  25600 	}
  25601 	HistogramAdd(tls, a, b, out)
  25602 	UpdateHistogramCost(tls, **(**uint64_t)(__ccgo_up(bp + 8)), bp+16, out)
  25603 	return int32(1)
  25604 }
  25605 
  25606 // C documentation
  25607 //
  25608 //	// Same as HistogramAddEval(), except that the resulting histogram
  25609 //	// is not stored. Only the cost C(a+b) - C(a) is evaluated. We omit
  25610 //	// the term C(b) which is constant over all the evaluations.
  25611 //	// Returns 1 if the cost is less than the threshold.
  25612 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25613 func HistogramAddThresh(tls *libc.TLS, a uintptr, b uintptr, _cost_threshold int64_t, cost_out uintptr) (r int32) {
  25614 	bp := tls.Alloc(64)
  25615 	defer tls.Free(64)
  25616 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  25617 	var _ /* cost at bp+8 */ uint64_t
  25618 	var _ /* costs at bp+16 */ [5]uint64_t
  25619 	SaturateAdd(tls, (*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost, bp)
  25620 	if !(GetCombinedHistogramEntropy(tls, a, b, **(**int64_t)(__ccgo_up(bp)), bp+8, bp+16) != 0) {
  25621 		return 0
  25622 	}
  25623 	**(**int64_t)(__ccgo_up(cost_out)) = libc.Int64FromUint64(**(**uint64_t)(__ccgo_up(bp + 8))) - libc.Int64FromUint64((*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost)
  25624 	return int32(1)
  25625 }
  25626 
  25627 // -----------------------------------------------------------------------------
  25628 
  25629 // C documentation
  25630 //
  25631 //	// The structure to keep track of cost range for the three dominant entropy
  25632 //	// symbols.
  25633 type DominantCostRange = struct {
  25634 	Fliteral_max uint64_t
  25635 	Fliteral_min uint64_t
  25636 	Fred_max     uint64_t
  25637 	Fred_min     uint64_t
  25638 	Fblue_max    uint64_t
  25639 	Fblue_min    uint64_t
  25640 }
  25641 
  25642 func DominantCostRangeInit(tls *libc.TLS, c uintptr) {
  25643 	(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max = uint64(0)
  25644 	(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min = ^libc.Uint64FromUint64(0)
  25645 	(*DominantCostRange)(unsafe.Pointer(c)).Fred_max = uint64(0)
  25646 	(*DominantCostRange)(unsafe.Pointer(c)).Fred_min = ^libc.Uint64FromUint64(0)
  25647 	(*DominantCostRange)(unsafe.Pointer(c)).Fblue_max = uint64(0)
  25648 	(*DominantCostRange)(unsafe.Pointer(c)).Fblue_min = ^libc.Uint64FromUint64(0)
  25649 }
  25650 
  25651 func UpdateDominantCostRange(tls *libc.TLS, h uintptr, c uintptr) {
  25652 	if (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)) {
  25653 		(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8))
  25654 	}
  25655 	if (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)) {
  25656 		(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8))
  25657 	}
  25658 	if (*DominantCostRange)(unsafe.Pointer(c)).Fred_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)) {
  25659 		(*DominantCostRange)(unsafe.Pointer(c)).Fred_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8))
  25660 	}
  25661 	if (*DominantCostRange)(unsafe.Pointer(c)).Fred_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)) {
  25662 		(*DominantCostRange)(unsafe.Pointer(c)).Fred_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8))
  25663 	}
  25664 	if (*DominantCostRange)(unsafe.Pointer(c)).Fblue_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)) {
  25665 		(*DominantCostRange)(unsafe.Pointer(c)).Fblue_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8))
  25666 	}
  25667 	if (*DominantCostRange)(unsafe.Pointer(c)).Fblue_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)) {
  25668 		(*DominantCostRange)(unsafe.Pointer(c)).Fblue_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8))
  25669 	}
  25670 }
  25671 
  25672 func ComputeHistogramCost(tls *libc.TLS, h uintptr) {
  25673 	bp := tls.Alloc(16)
  25674 	defer tls.Free(16)
  25675 	var i int32
  25676 	var _ /* length at bp+8 */ int32
  25677 	var _ /* population at bp+0 */ uintptr
  25678 	_ = i
  25679 	// No need to add the extra cost for length and distance as it is a constant
  25680 	// that does not influence the histograms.
  25681 	i = 0
  25682 	for {
  25683 		if !(i < int32(5)) {
  25684 			break
  25685 		}
  25686 		GetPopulationInfo(tls, h, i, bp, bp+8)
  25687 		**(**uint64_t)(__ccgo_up(h + 3264 + uintptr(i)*8)) = PopulationCost(tls, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), h+3244+uintptr(i)*2, h+3304+uintptr(i))
  25688 		goto _1
  25689 	_1:
  25690 		;
  25691 		i = i + 1
  25692 	}
  25693 	(*VP8LHistogram)(unsafe.Pointer(h)).Fbit_cost = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)) + **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)) + **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)) + **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(ALPHA)*8)) + **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(DISTANCE)*8))
  25694 }
  25695 
  25696 func GetBinIdForEntropy(tls *libc.TLS, min uint64_t, max uint64_t, val uint64_t) (r int32) {
  25697 	var delta, range1 uint64_t
  25698 	_, _ = delta, range1
  25699 	range1 = max - min
  25700 	if range1 > uint64(0) {
  25701 		delta = val - min
  25702 		return int32(float64((libc.Float64FromInt32(NUM_PARTITIONS)-libc.Float64FromFloat64(1e-06))*float64(delta)) / float64(range1))
  25703 	} else {
  25704 		return 0
  25705 	}
  25706 	return r
  25707 }
  25708 
  25709 func GetHistoBinIndex(tls *libc.TLS, h uintptr, c uintptr, low_effort int32) (r int32) {
  25710 	var bin_id int32
  25711 	_ = bin_id
  25712 	bin_id = GetBinIdForEntropy(tls, (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min, (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max, **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)))
  25713 	if !(low_effort != 0) {
  25714 		bin_id = bin_id*int32(NUM_PARTITIONS) + GetBinIdForEntropy(tls, (*DominantCostRange)(unsafe.Pointer(c)).Fred_min, (*DominantCostRange)(unsafe.Pointer(c)).Fred_max, **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)))
  25715 		bin_id = bin_id*int32(NUM_PARTITIONS) + GetBinIdForEntropy(tls, (*DominantCostRange)(unsafe.Pointer(c)).Fblue_min, (*DominantCostRange)(unsafe.Pointer(c)).Fblue_max, **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)))
  25716 	}
  25717 	return bin_id
  25718 }
  25719 
  25720 // C documentation
  25721 //
  25722 //	// Construct the histograms from backward references.
  25723 func HistogramBuild(tls *libc.TLS, xsize int32, histo_bits int32, backward_refs uintptr, image_histo uintptr) {
  25724 	bp := tls.Alloc(32)
  25725 	defer tls.Free(32)
  25726 	var histo_xsize, ix, x, y, v4 int32
  25727 	var histograms, v, v10, v8, v9 uintptr
  25728 	var v1, v2 uint32_t
  25729 	var _ /* c at bp+0 */ VP8LRefsCursor
  25730 	_, _, _, _, _, _, _, _, _, _, _, _ = histo_xsize, histograms, ix, v, x, y, v1, v10, v2, v4, v8, v9
  25731 	x = 0
  25732 	y = 0
  25733 	v1 = libc.Uint32FromInt32(histo_bits)
  25734 	v2 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  25735 	goto _3
  25736 _3:
  25737 	histo_xsize = libc.Int32FromUint32(v2)
  25738 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25739 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, backward_refs)
  25740 	VP8LHistogramSetClear(tls, image_histo)
  25741 	for {
  25742 		v4 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  25743 		goto _5
  25744 	_5:
  25745 		if !(v4 != 0) {
  25746 			break
  25747 		}
  25748 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos
  25749 		ix = y>>histo_bits*histo_xsize + x>>histo_bits
  25750 		HistogramAddSinglePixOrCopy(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(ix)*8)), v, libc.UintptrFromInt32(0), 0)
  25751 		v1 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  25752 		goto _7
  25753 	_7:
  25754 		x = libc.Int32FromUint32(uint32(x) + v1)
  25755 		for x >= xsize {
  25756 			x = x - xsize
  25757 			y = y + 1
  25758 		}
  25759 		v8 = bp
  25760 		v10 = v8
  25761 		*(*uintptr)(unsafe.Pointer(v10)) += 8
  25762 		v9 = *(*uintptr)(unsafe.Pointer(v10))
  25763 		if v9 == (*VP8LRefsCursor)(unsafe.Pointer(v8)).Flast_pos {
  25764 			VP8LRefsCursorNextBlock(tls, v8)
  25765 		}
  25766 	}
  25767 }
  25768 
  25769 // C documentation
  25770 //
  25771 //	// Copies the histograms and computes its bit_cost.
  25772 func HistogramCopyAndAnalyze(tls *libc.TLS, orig_histo uintptr, image_histo uintptr) {
  25773 	var histo, histograms, orig_histograms uintptr
  25774 	var i int32
  25775 	_, _, _, _ = histo, histograms, i, orig_histograms
  25776 	orig_histograms = (*VP8LHistogramSet)(unsafe.Pointer(orig_histo)).Fhistograms
  25777 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25778 	(*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize = 0
  25779 	i = 0
  25780 	for {
  25781 		if !(i < (*VP8LHistogramSet)(unsafe.Pointer(orig_histo)).Fmax_size) {
  25782 			break
  25783 		}
  25784 		histo = **(**uintptr)(__ccgo_up(orig_histograms + uintptr(i)*8))
  25785 		ComputeHistogramCost(tls, histo)
  25786 		// Skip the histogram if it is completely empty, which can happen for tiles
  25787 		// with no information (when they are skipped because of LZ77).
  25788 		if !(**(**uint8_t)(__ccgo_up(histo + 3304 + uintptr(LITERAL))) != 0) && !(**(**uint8_t)(__ccgo_up(histo + 3304 + uintptr(RED))) != 0) && !(**(**uint8_t)(__ccgo_up(histo + 3304 + uintptr(BLUE))) != 0) && !(**(**uint8_t)(__ccgo_up(histo + 3304 + uintptr(ALPHA))) != 0) && !(**(**uint8_t)(__ccgo_up(histo + 3304 + uintptr(DISTANCE))) != 0) {
  25789 			// The first histogram is always used.
  25790 			**(**uintptr)(__ccgo_up(orig_histograms + uintptr(i)*8)) = libc.UintptrFromInt32(0)
  25791 		} else {
  25792 			// Copy histograms from orig_histo[] to image_histo[].
  25793 			HistogramCopy(tls, histo, **(**uintptr)(__ccgo_up(histograms + uintptr((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize)*8)))
  25794 			(*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize + 1
  25795 		}
  25796 		goto _1
  25797 	_1:
  25798 		;
  25799 		i = i + 1
  25800 	}
  25801 }
  25802 
  25803 // C documentation
  25804 //
  25805 //	// Partition histograms to different entropy bins for three dominant (literal,
  25806 //	// red and blue) symbol costs and compute the histogram aggregate bit_cost.
  25807 func HistogramAnalyzeEntropyBin(tls *libc.TLS, image_histo uintptr, low_effort int32) {
  25808 	bp := tls.Alloc(48)
  25809 	defer tls.Free(48)
  25810 	var histo_size, i int32
  25811 	var histograms uintptr
  25812 	var _ /* cost_range at bp+0 */ DominantCostRange
  25813 	_, _, _ = histo_size, histograms, i
  25814 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25815 	histo_size = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  25816 	DominantCostRangeInit(tls, bp)
  25817 	// Analyze the dominant (literal, red and blue) entropy costs.
  25818 	i = 0
  25819 	for {
  25820 		if !(i < histo_size) {
  25821 			break
  25822 		}
  25823 		UpdateDominantCostRange(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(i)*8)), bp)
  25824 		goto _1
  25825 	_1:
  25826 		;
  25827 		i = i + 1
  25828 	}
  25829 	// bin-hash histograms on three of the dominant (literal, red and blue)
  25830 	// symbol costs and store the resulting bin_id for each histogram.
  25831 	i = 0
  25832 	for {
  25833 		if !(i < histo_size) {
  25834 			break
  25835 		}
  25836 		(*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(histograms + uintptr(i)*8)))).Fbin_id = libc.Uint16FromInt32(GetHistoBinIndex(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(i)*8)), bp, low_effort))
  25837 		goto _2
  25838 	_2:
  25839 		;
  25840 		i = i + 1
  25841 	}
  25842 }
  25843 
  25844 // C documentation
  25845 //
  25846 //	// Merges some histograms with same bin_id together if it's advantageous.
  25847 //	// Sets the remaining histograms to NULL.
  25848 //	// 'combine_cost_factor' has to be divided by 100.
  25849 func HistogramCombineEntropyBin(tls *libc.TLS, image_histo uintptr, _cur_combo uintptr, num_bins int32, combine_cost_factor int32_t, low_effort int32) {
  25850 	bp := tls.Alloc(16)
  25851 	defer tls.Free(16)
  25852 	*(*uintptr)(unsafe.Pointer(bp)) = _cur_combo
  25853 	var bin_id, first, idx, max_combine_failures, try_combine int32
  25854 	var bin_info [64]struct {
  25855 		Ffirst                int16_t
  25856 		Fnum_combine_failures uint16_t
  25857 	}
  25858 	var bit_cost uint64_t
  25859 	var bit_cost_thresh, v3, v4, v5 int64_t
  25860 	var histograms uintptr
  25861 	var v7 int64
  25862 	_, _, _, _, _, _, _, _, _, _, _, _, _ = bin_id, bin_info, bit_cost, bit_cost_thresh, first, histograms, idx, max_combine_failures, try_combine, v3, v4, v5, v7
  25863 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25864 	idx = 0
  25865 	for {
  25866 		if !(idx < num_bins) {
  25867 			break
  25868 		}
  25869 		bin_info[idx].Ffirst = int16(-int32(1))
  25870 		bin_info[idx].Fnum_combine_failures = uint16(0)
  25871 		goto _1
  25872 	_1:
  25873 		;
  25874 		idx = idx + 1
  25875 	}
  25876 	idx = 0
  25877 	for {
  25878 		if !(idx < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  25879 			break
  25880 		}
  25881 		bin_id = libc.Int32FromUint16((*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))).Fbin_id)
  25882 		first = int32(bin_info[bin_id].Ffirst)
  25883 		if first == -int32(1) {
  25884 			bin_info[bin_id].Ffirst = int16(idx)
  25885 			idx = idx + 1
  25886 		} else {
  25887 			if low_effort != 0 {
  25888 				HistogramAdd(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)))
  25889 				HistogramSetRemoveHistogram(tls, image_histo, idx)
  25890 			} else {
  25891 				// try to merge #idx into #first (both share the same bin_id)
  25892 				bit_cost = (*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))).Fbit_cost
  25893 				v3 = libc.Int64FromUint64(bit_cost) * int64(combine_cost_factor)
  25894 				v4 = int64(100)
  25895 				if libc.BoolInt32(v3 < 0) == libc.BoolInt32(v4 < 0) {
  25896 					v7 = (v3 + v4/int64(2)) / v4
  25897 				} else {
  25898 					v7 = (v3 - v4/int64(2)) / v4
  25899 				}
  25900 				v5 = v7
  25901 				goto _6
  25902 			_6:
  25903 				bit_cost_thresh = -v5
  25904 				if HistogramAddEval(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)), **(**uintptr)(__ccgo_up(bp)), bit_cost_thresh) != 0 {
  25905 					max_combine_failures = int32(32)
  25906 					// Try to merge two histograms only if the combo is a trivial one or
  25907 					// the two candidate histograms are already non-trivial.
  25908 					// For some images, 'try_combine' turns out to be false for a lot of
  25909 					// histogram pairs. In that case, we fallback to combining
  25910 					// histograms as usual to avoid increasing the header size.
  25911 					try_combine = libc.BoolInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 3244 + uintptr(RED)*2))) != libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) && libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 3244 + uintptr(BLUE)*2))) != libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) && libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 3244 + uintptr(ALPHA)*2))) != libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))))
  25912 					if !(try_combine != 0) {
  25913 						try_combine = libc.BoolInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)) + 3244 + uintptr(RED)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) || libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)) + 3244 + uintptr(BLUE)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) || libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)) + 3244 + uintptr(ALPHA)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))))
  25914 						try_combine = try_combine & libc.BoolInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)) + 3244 + uintptr(RED)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) || libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)) + 3244 + uintptr(BLUE)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))) || libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(**(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)) + 3244 + uintptr(ALPHA)*2))) == libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))))
  25915 					}
  25916 					if try_combine != 0 || libc.Int32FromUint16(bin_info[bin_id].Fnum_combine_failures) >= max_combine_failures {
  25917 						// move the (better) merged histogram to its final slot
  25918 						HistogramSwap(tls, bp, histograms+uintptr(first)*8)
  25919 						HistogramSetRemoveHistogram(tls, image_histo, idx)
  25920 					} else {
  25921 						bin_info[bin_id].Fnum_combine_failures = bin_info[bin_id].Fnum_combine_failures + 1
  25922 						idx = idx + 1
  25923 					}
  25924 				} else {
  25925 					idx = idx + 1
  25926 				}
  25927 			}
  25928 		}
  25929 		goto _2
  25930 	_2:
  25931 	}
  25932 	if low_effort != 0 {
  25933 		// for low_effort case, update the final cost when everything is merged
  25934 		idx = 0
  25935 		for {
  25936 			if !(idx < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  25937 				break
  25938 			}
  25939 			ComputeHistogramCost(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))
  25940 			goto _8
  25941 		_8:
  25942 			;
  25943 			idx = idx + 1
  25944 		}
  25945 	}
  25946 }
  25947 
  25948 // C documentation
  25949 //
  25950 //	// Implement a Lehmer random number generator with a multiplicative constant of
  25951 //	// 48271 and a modulo constant of 2^31 - 1.
  25952 func MyRand(tls *libc.TLS, seed uintptr) (r uint32_t) {
  25953 	**(**uint32_t)(__ccgo_up(seed)) = uint32(uint64(**(**uint32_t)(__ccgo_up(seed))) * libc.Uint64FromUint32(48271) % libc.Uint64FromUint32(2147483647))
  25954 	return **(**uint32_t)(__ccgo_up(seed))
  25955 }
  25956 
  25957 // -----------------------------------------------------------------------------
  25958 // Histogram pairs priority queue
  25959 
  25960 // C documentation
  25961 //
  25962 //	// Pair of histograms. Negative idx1 value means that pair is out-of-date.
  25963 type HistogramPair = struct {
  25964 	Fidx1       int32
  25965 	Fidx2       int32
  25966 	Fcost_diff  int64_t
  25967 	Fcost_combo uint64_t
  25968 	Fcosts      [5]uint64_t
  25969 }
  25970 
  25971 type HistoQueue = struct {
  25972 	Fqueue    uintptr
  25973 	Fsize     int32
  25974 	Fmax_size int32
  25975 }
  25976 
  25977 func HistoQueueInit(tls *libc.TLS, histo_queue uintptr, max_size int32) (r int32) {
  25978 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = 0
  25979 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size = max_size
  25980 	// We allocate max_size + 1 because the last element at index "size" is
  25981 	// used as temporary data (and it could be up to max_size).
  25982 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue = WebPSafeMalloc(tls, libc.Uint64FromInt32((*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size+int32(1)), uint64(64))
  25983 	return libc.BoolInt32((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue != libc.UintptrFromInt32(0))
  25984 }
  25985 
  25986 func HistoQueueClear(tls *libc.TLS, histo_queue uintptr) {
  25987 	WebPSafeFree(tls, (*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue)
  25988 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = 0
  25989 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size = 0
  25990 }
  25991 
  25992 // C documentation
  25993 //
  25994 //	// Pop a specific pair in the queue by replacing it with the last one
  25995 //	// and shrinking the queue.
  25996 func HistoQueuePopPair(tls *libc.TLS, histo_queue uintptr, pair uintptr) {
  25997 	**(**HistogramPair)(__ccgo_up(pair)) = **(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue + uintptr((*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize-int32(1))*64))
  25998 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = (*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize - 1
  25999 }
  26000 
  26001 // C documentation
  26002 //
  26003 //	// Check whether a pair in the queue should be updated as head or not.
  26004 func HistoQueueUpdateHead(tls *libc.TLS, histo_queue uintptr, pair uintptr) {
  26005 	var tmp HistogramPair
  26006 	_ = tmp
  26007 	if (*HistogramPair)(unsafe.Pointer(pair)).Fcost_diff < (**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue))).Fcost_diff {
  26008 		// Replace the best pair.
  26009 		tmp = **(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue))
  26010 		**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue)) = **(**HistogramPair)(__ccgo_up(pair))
  26011 		**(**HistogramPair)(__ccgo_up(pair)) = tmp
  26012 	}
  26013 }
  26014 
  26015 // C documentation
  26016 //
  26017 //	// Replaces the bad_id with good_id in the pair.
  26018 func HistoQueueFixPair(tls *libc.TLS, bad_id int32, good_id int32, pair uintptr) {
  26019 	var tmp int32
  26020 	_ = tmp
  26021 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx1 == bad_id {
  26022 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx1 = good_id
  26023 	}
  26024 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx2 == bad_id {
  26025 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx2 = good_id
  26026 	}
  26027 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx1 > (*HistogramPair)(unsafe.Pointer(pair)).Fidx2 {
  26028 		tmp = (*HistogramPair)(unsafe.Pointer(pair)).Fidx1
  26029 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx1 = (*HistogramPair)(unsafe.Pointer(pair)).Fidx2
  26030 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx2 = tmp
  26031 	}
  26032 }
  26033 
  26034 // C documentation
  26035 //
  26036 //	// Update the cost diff and combo of a pair of histograms. This needs to be
  26037 //	// called when the histograms have been merged with a third one.
  26038 //	// Returns 1 if the cost diff is less than the threshold.
  26039 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  26040 func HistoQueueUpdatePair(tls *libc.TLS, h1 uintptr, h2 uintptr, _cost_threshold int64_t, pair uintptr) (r int32) {
  26041 	bp := tls.Alloc(16)
  26042 	defer tls.Free(16)
  26043 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  26044 	var sum_cost int64_t
  26045 	_ = sum_cost
  26046 	sum_cost = libc.Int64FromUint64((*VP8LHistogram)(unsafe.Pointer(h1)).Fbit_cost + (*VP8LHistogram)(unsafe.Pointer(h2)).Fbit_cost)
  26047 	SaturateAdd(tls, libc.Uint64FromInt64(sum_cost), bp)
  26048 	if !(GetCombinedHistogramEntropy(tls, h1, h2, **(**int64_t)(__ccgo_up(bp)), pair+16, pair+24) != 0) {
  26049 		return 0
  26050 	}
  26051 	(*HistogramPair)(unsafe.Pointer(pair)).Fcost_diff = libc.Int64FromUint64((*HistogramPair)(unsafe.Pointer(pair)).Fcost_combo) - sum_cost
  26052 	return int32(1)
  26053 }
  26054 
  26055 // C documentation
  26056 //
  26057 //	// Create a pair from indices "idx1" and "idx2" provided its cost
  26058 //	// is inferior to "threshold", a negative entropy.
  26059 //	// It returns the cost of the pair, or 0 if it superior to threshold.
  26060 func HistoQueuePush(tls *libc.TLS, histo_queue uintptr, histograms uintptr, idx1 int32, idx2 int32, threshold int64_t) (r int64_t) {
  26061 	bp := tls.Alloc(64)
  26062 	defer tls.Free(64)
  26063 	var h1, h2, v2 uintptr
  26064 	var tmp, v1 int32
  26065 	var _ /* pair at bp+0 */ HistogramPair
  26066 	_, _, _, _, _ = h1, h2, tmp, v1, v2
  26067 	// Stop here if the queue is full.
  26068 	if (*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize == (*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size {
  26069 		return 0
  26070 	}
  26071 	if idx1 > idx2 {
  26072 		tmp = idx2
  26073 		idx2 = idx1
  26074 		idx1 = tmp
  26075 	}
  26076 	(**(**HistogramPair)(__ccgo_up(bp))).Fidx1 = idx1
  26077 	(**(**HistogramPair)(__ccgo_up(bp))).Fidx2 = idx2
  26078 	h1 = **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8))
  26079 	h2 = **(**uintptr)(__ccgo_up(histograms + uintptr(idx2)*8))
  26080 	// Do not even consider the pair if it does not improve the entropy.
  26081 	if !(HistoQueueUpdatePair(tls, h1, h2, threshold, bp) != 0) {
  26082 		return 0
  26083 	}
  26084 	v2 = histo_queue + 8
  26085 	v1 = *(*int32)(unsafe.Pointer(v2))
  26086 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  26087 	**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue + uintptr(v1)*64)) = **(**HistogramPair)(__ccgo_up(bp))
  26088 	HistoQueueUpdateHead(tls, histo_queue, (*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue+uintptr((*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize-int32(1))*64)
  26089 	return (**(**HistogramPair)(__ccgo_up(bp))).Fcost_diff
  26090 }
  26091 
  26092 // -----------------------------------------------------------------------------
  26093 
  26094 // C documentation
  26095 //
  26096 //	// Combines histograms by continuously choosing the one with the highest cost
  26097 //	// reduction.
  26098 func HistogramCombineGreedy(tls *libc.TLS, image_histo uintptr) (r int32) {
  26099 	bp := tls.Alloc(16)
  26100 	defer tls.Free(16)
  26101 	var histograms, p uintptr
  26102 	var i, idx1, idx2, image_histo_size, j, ok int32
  26103 	var _ /* histo_queue at bp+0 */ HistoQueue
  26104 	_, _, _, _, _, _, _, _ = histograms, i, idx1, idx2, image_histo_size, j, ok, p
  26105 	ok = 0
  26106 	image_histo_size = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  26107 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  26108 	// image_histo_size^2 for the queue size is safe. If you look at
  26109 	// HistogramCombineGreedy, and imagine that UpdateQueueFront always pushes
  26110 	// data to the queue, you insert at most:
  26111 	// - image_histo_size*(image_histo_size-1)/2 (the first two for loops)
  26112 	// - image_histo_size - 1 in the last for loop at the first iteration of
  26113 	//   the while loop, image_histo_size - 2 at the second iteration ...
  26114 	//   therefore image_histo_size*(image_histo_size-1)/2 overall too
  26115 	if !(HistoQueueInit(tls, bp, image_histo_size*image_histo_size) != 0) {
  26116 		goto End
  26117 	}
  26118 	// Initialize the queue.
  26119 	i = 0
  26120 	for {
  26121 		if !(i < image_histo_size) {
  26122 			break
  26123 		}
  26124 		j = i + int32(1)
  26125 		for {
  26126 			if !(j < image_histo_size) {
  26127 				break
  26128 			}
  26129 			HistoQueuePush(tls, bp, histograms, i, j, 0)
  26130 			goto _2
  26131 		_2:
  26132 			;
  26133 			j = j + 1
  26134 		}
  26135 		goto _1
  26136 	_1:
  26137 		;
  26138 		i = i + 1
  26139 	}
  26140 	for (**(**HistoQueue)(__ccgo_up(bp))).Fsize > 0 {
  26141 		idx1 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp))).Fqueue))).Fidx1
  26142 		idx2 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp))).Fqueue))).Fidx2
  26143 		HistogramAdd(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx2)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8)))
  26144 		UpdateHistogramCost(tls, (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp))).Fqueue))).Fcost_combo, (**(**HistoQueue)(__ccgo_up(bp))).Fqueue+24, **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8)))
  26145 		// Remove merged histogram.
  26146 		HistogramSetRemoveHistogram(tls, image_histo, idx2)
  26147 		// Remove pairs intersecting the just combined best pair.
  26148 		i = 0
  26149 		for {
  26150 			if !(i < (**(**HistoQueue)(__ccgo_up(bp))).Fsize) {
  26151 				break
  26152 			}
  26153 			p = (**(**HistoQueue)(__ccgo_up(bp))).Fqueue + uintptr(i)*64
  26154 			if (*HistogramPair)(unsafe.Pointer(p)).Fidx1 == idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx2 == idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx1 == idx2 || (*HistogramPair)(unsafe.Pointer(p)).Fidx2 == idx2 {
  26155 				HistoQueuePopPair(tls, bp, p)
  26156 			} else {
  26157 				HistoQueueFixPair(tls, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize, idx2, p)
  26158 				HistoQueueUpdateHead(tls, bp, p)
  26159 				i = i + 1
  26160 			}
  26161 			goto _3
  26162 		_3:
  26163 		}
  26164 		// Push new pairs formed with combined histogram to the queue.
  26165 		i = 0
  26166 		for {
  26167 			if !(i < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  26168 				break
  26169 			}
  26170 			if i == idx1 {
  26171 				goto _4
  26172 			}
  26173 			HistoQueuePush(tls, bp, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms, idx1, i, 0)
  26174 			goto _4
  26175 		_4:
  26176 			;
  26177 			i = i + 1
  26178 		}
  26179 	}
  26180 	ok = int32(1)
  26181 	goto End
  26182 End:
  26183 	;
  26184 	HistoQueueClear(tls, bp)
  26185 	return ok
  26186 }
  26187 
  26188 // C documentation
  26189 //
  26190 //	// Perform histogram aggregation using a stochastic approach.
  26191 //	// 'do_greedy' is set to 1 if a greedy approach needs to be performed
  26192 //	// afterwards, 0 otherwise.
  26193 func HistogramCombineStochastic(tls *libc.TLS, image_histo uintptr, min_cluster_size int32, do_greedy uintptr) (r int32) {
  26194 	bp := tls.Alloc(32)
  26195 	defer tls.Free(32)
  26196 	var best_cost, curr_cost int64_t
  26197 	var best_idx1, best_idx2, is_idx1_best, is_idx2_best, iter, j, kHistoQueueSize, num_tries, num_tries_no_success, ok, outer_iters, tries_with_no_success, v2 int32
  26198 	var histograms, p uintptr
  26199 	var idx1, idx2, rand_range, tmp uint32_t
  26200 	var v3 bool
  26201 	var v4 int64
  26202 	var _ /* histo_queue at bp+8 */ HistoQueue
  26203 	var _ /* seed at bp+0 */ uint32_t
  26204 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_cost, best_idx1, best_idx2, curr_cost, histograms, idx1, idx2, is_idx1_best, is_idx2_best, iter, j, kHistoQueueSize, num_tries, num_tries_no_success, ok, outer_iters, p, rand_range, tmp, tries_with_no_success, v2, v3, v4
  26205 	**(**uint32_t)(__ccgo_up(bp)) = uint32(1)
  26206 	tries_with_no_success = 0
  26207 	outer_iters = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  26208 	num_tries_no_success = outer_iters / int32(2)
  26209 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  26210 	kHistoQueueSize = int32(9)
  26211 	ok = 0
  26212 	if (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize < min_cluster_size {
  26213 		**(**int32)(__ccgo_up(do_greedy)) = int32(1)
  26214 		return int32(1)
  26215 	}
  26216 	if !(HistoQueueInit(tls, bp+8, kHistoQueueSize) != 0) {
  26217 		goto End
  26218 	}
  26219 	// Collapse similar histograms in 'image_histo'.
  26220 	iter = 0
  26221 	for {
  26222 		if v3 = iter < outer_iters && (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize >= min_cluster_size; v3 {
  26223 			tries_with_no_success = tries_with_no_success + 1
  26224 			v2 = tries_with_no_success
  26225 		}
  26226 		if !(v3 && v2 < num_tries_no_success) {
  26227 			break
  26228 		}
  26229 		if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == 0 {
  26230 			v4 = 0
  26231 		} else {
  26232 			v4 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fcost_diff
  26233 		}
  26234 		best_cost = v4
  26235 		best_idx1 = -int32(1)
  26236 		best_idx2 = int32(1)
  26237 		rand_range = libc.Uint32FromInt32(((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize - int32(1)) * (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize)
  26238 		// (image_histo->size) / 2 was chosen empirically. Less means faster but
  26239 		// worse compression.
  26240 		num_tries = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize / int32(2)
  26241 		// Pick random samples.
  26242 		j = 0
  26243 		for {
  26244 			if !((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize >= int32(2) && j < num_tries) {
  26245 				break
  26246 			}
  26247 			// Choose two different histograms at random and try to combine them.
  26248 			tmp = MyRand(tls, bp) % rand_range
  26249 			idx1 = tmp / libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize-libc.Int32FromInt32(1))
  26250 			idx2 = tmp % libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize-libc.Int32FromInt32(1))
  26251 			if idx2 >= idx1 {
  26252 				idx2 = idx2 + 1
  26253 			}
  26254 			// Calculate cost reduction on combination.
  26255 			curr_cost = HistoQueuePush(tls, bp+8, histograms, libc.Int32FromUint32(idx1), libc.Int32FromUint32(idx2), best_cost)
  26256 			if curr_cost < 0 { // found a better pair?
  26257 				best_cost = curr_cost
  26258 				// Empty the queue if we reached full capacity.
  26259 				if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == (**(**HistoQueue)(__ccgo_up(bp + 8))).Fmax_size {
  26260 					break
  26261 				}
  26262 			}
  26263 			goto _5
  26264 		_5:
  26265 			;
  26266 			j = j + 1
  26267 		}
  26268 		if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == 0 {
  26269 			goto _1
  26270 		}
  26271 		// Get the best histograms.
  26272 		best_idx1 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fidx1
  26273 		best_idx2 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fidx2
  26274 		// Merge the histograms and remove best_idx2 from the queue.
  26275 		HistogramAdd(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(best_idx2)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(best_idx1)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(best_idx1)*8)))
  26276 		UpdateHistogramCost(tls, (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fcost_combo, (**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue+24, **(**uintptr)(__ccgo_up(histograms + uintptr(best_idx1)*8)))
  26277 		HistogramSetRemoveHistogram(tls, image_histo, best_idx2)
  26278 		// Parse the queue and update each pair that deals with best_idx1,
  26279 		// best_idx2 or image_histo_size.
  26280 		j = 0
  26281 		for {
  26282 			if !(j < (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize) {
  26283 				break
  26284 			}
  26285 			p = (**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue + uintptr(j)*64
  26286 			is_idx1_best = libc.BoolInt32((*HistogramPair)(unsafe.Pointer(p)).Fidx1 == best_idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx1 == best_idx2)
  26287 			is_idx2_best = libc.BoolInt32((*HistogramPair)(unsafe.Pointer(p)).Fidx2 == best_idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx2 == best_idx2)
  26288 			// The front pair could have been duplicated by a random pick so
  26289 			// check for it all the time nevertheless.
  26290 			if is_idx1_best != 0 && is_idx2_best != 0 {
  26291 				HistoQueuePopPair(tls, bp+8, p)
  26292 				goto _6
  26293 			}
  26294 			// Any pair containing one of the two best indices should only refer to
  26295 			// best_idx1. Its cost should also be updated.
  26296 			if is_idx1_best != 0 || is_idx2_best != 0 {
  26297 				HistoQueueFixPair(tls, best_idx2, best_idx1, p)
  26298 				// Re-evaluate the cost of an updated pair.
  26299 				if !(HistoQueueUpdatePair(tls, **(**uintptr)(__ccgo_up(histograms + uintptr((*HistogramPair)(unsafe.Pointer(p)).Fidx1)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr((*HistogramPair)(unsafe.Pointer(p)).Fidx2)*8)), 0, p) != 0) {
  26300 					HistoQueuePopPair(tls, bp+8, p)
  26301 					goto _6
  26302 				}
  26303 			}
  26304 			HistoQueueFixPair(tls, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize, best_idx2, p)
  26305 			HistoQueueUpdateHead(tls, bp+8, p)
  26306 			j = j + 1
  26307 			goto _6
  26308 		_6:
  26309 		}
  26310 		tries_with_no_success = 0
  26311 		goto _1
  26312 	_1:
  26313 		;
  26314 		iter = iter + 1
  26315 	}
  26316 	**(**int32)(__ccgo_up(do_greedy)) = libc.BoolInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize <= min_cluster_size)
  26317 	ok = int32(1)
  26318 	goto End
  26319 End:
  26320 	;
  26321 	HistoQueueClear(tls, bp+8)
  26322 	return ok
  26323 }
  26324 
  26325 // -----------------------------------------------------------------------------
  26326 // Histogram refinement
  26327 
  26328 // C documentation
  26329 //
  26330 //	// Find the best 'out' histogram for each of the 'in' histograms.
  26331 //	// At call-time, 'out' contains the histograms of the clusters.
  26332 //	// Note: we assume that out[]->bit_cost is already up-to-date.
  26333 func HistogramRemap(tls *libc.TLS, in uintptr, out uintptr, symbols uintptr) {
  26334 	bp := tls.Alloc(16)
  26335 	defer tls.Free(16)
  26336 	var best_bits int64_t
  26337 	var best_out, i, idx, in_size, k, out_size int32
  26338 	var in_histo, out_histo uintptr
  26339 	var _ /* cur_bits at bp+0 */ int64_t
  26340 	_, _, _, _, _, _, _, _, _ = best_bits, best_out, i, idx, in_histo, in_size, k, out_histo, out_size
  26341 	in_histo = (*VP8LHistogramSet)(unsafe.Pointer(in)).Fhistograms
  26342 	out_histo = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fhistograms
  26343 	in_size = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fmax_size
  26344 	out_size = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fsize
  26345 	if out_size > int32(1) {
  26346 		i = 0
  26347 		for {
  26348 			if !(i < in_size) {
  26349 				break
  26350 			}
  26351 			best_out = 0
  26352 			best_bits = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  26353 			if **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)) == libc.UintptrFromInt32(0) {
  26354 				// Arbitrarily set to the previous value if unused to help future LZ77.
  26355 				**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(symbols + uintptr(i-int32(1))*4))
  26356 				goto _1
  26357 			}
  26358 			k = 0
  26359 			for {
  26360 				if !(k < out_size) {
  26361 					break
  26362 				}
  26363 				if HistogramAddThresh(tls, **(**uintptr)(__ccgo_up(out_histo + uintptr(k)*8)), **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)), best_bits, bp) != 0 {
  26364 					best_bits = **(**int64_t)(__ccgo_up(bp))
  26365 					best_out = k
  26366 				}
  26367 				goto _2
  26368 			_2:
  26369 				;
  26370 				k = k + 1
  26371 			}
  26372 			**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = libc.Uint32FromInt32(best_out)
  26373 			goto _1
  26374 		_1:
  26375 			;
  26376 			i = i + 1
  26377 		}
  26378 	} else {
  26379 		i = 0
  26380 		for {
  26381 			if !(i < in_size) {
  26382 				break
  26383 			}
  26384 			**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = uint32(0)
  26385 			goto _3
  26386 		_3:
  26387 			;
  26388 			i = i + 1
  26389 		}
  26390 	}
  26391 	// Recompute each out based on raw and symbols.
  26392 	VP8LHistogramSetClear(tls, out)
  26393 	(*VP8LHistogramSet)(unsafe.Pointer(out)).Fsize = out_size
  26394 	i = 0
  26395 	for {
  26396 		if !(i < in_size) {
  26397 			break
  26398 		}
  26399 		if **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)) == libc.UintptrFromInt32(0) {
  26400 			goto _4
  26401 		}
  26402 		idx = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)))
  26403 		HistogramAdd(tls, **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)), **(**uintptr)(__ccgo_up(out_histo + uintptr(idx)*8)), **(**uintptr)(__ccgo_up(out_histo + uintptr(idx)*8)))
  26404 		goto _4
  26405 	_4:
  26406 		;
  26407 		i = i + 1
  26408 	}
  26409 }
  26410 
  26411 func GetCombineCostFactor(tls *libc.TLS, histo_size int32, quality int32) (r int32_t) {
  26412 	var combine_cost_factor int32_t
  26413 	_ = combine_cost_factor
  26414 	combine_cost_factor = int32(16)
  26415 	if quality < int32(90) {
  26416 		if histo_size > int32(256) {
  26417 			combine_cost_factor = combine_cost_factor / int32(2)
  26418 		}
  26419 		if histo_size > int32(512) {
  26420 			combine_cost_factor = combine_cost_factor / int32(2)
  26421 		}
  26422 		if histo_size > int32(1024) {
  26423 			combine_cost_factor = combine_cost_factor / int32(2)
  26424 		}
  26425 		if quality <= int32(50) {
  26426 			combine_cost_factor = combine_cost_factor / int32(2)
  26427 		}
  26428 	}
  26429 	return combine_cost_factor
  26430 }
  26431 
  26432 func VP8LGetHistoImageSymbols(tls *libc.TLS, xsize int32, ysize int32, refs uintptr, quality int32, low_effort int32, histogram_bits int32, cache_bits int32, image_histo uintptr, tmp_histo uintptr, histogram_symbols uintptr, pic uintptr, percent_range int32, percent uintptr) (r int32) {
  26433 	bp := tls.Alloc(16)
  26434 	defer tls.Free(16)
  26435 	var combine_cost_factor int32_t
  26436 	var entropy_combine, entropy_combine_num_bins, histo_xsize, histo_ysize, image_histo_raw_size, threshold_size, v9 int32
  26437 	var orig_histo uintptr
  26438 	var v1, v5 uint32
  26439 	var v10, v11, v12 int64_t
  26440 	var v14 int64
  26441 	var v2, v3, v6, v7 uint32_t
  26442 	var _ /* do_greedy at bp+0 */ int32
  26443 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = combine_cost_factor, entropy_combine, entropy_combine_num_bins, histo_xsize, histo_ysize, image_histo_raw_size, orig_histo, threshold_size, v1, v10, v11, v12, v14, v2, v3, v5, v6, v7, v9
  26444 	if histogram_bits != 0 {
  26445 		v2 = libc.Uint32FromInt32(histogram_bits)
  26446 		v3 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  26447 		goto _4
  26448 	_4:
  26449 		v1 = v3
  26450 	} else {
  26451 		v1 = uint32(1)
  26452 	}
  26453 	histo_xsize = libc.Int32FromUint32(v1)
  26454 	if histogram_bits != 0 {
  26455 		v6 = libc.Uint32FromInt32(histogram_bits)
  26456 		v7 = (libc.Uint32FromInt32(ysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  26457 		goto _8
  26458 	_8:
  26459 		v5 = v7
  26460 	} else {
  26461 		v5 = uint32(1)
  26462 	}
  26463 	histo_ysize = libc.Int32FromUint32(v5)
  26464 	image_histo_raw_size = histo_xsize * histo_ysize
  26465 	orig_histo = VP8LAllocateHistogramSet(tls, image_histo_raw_size, cache_bits)
  26466 	if low_effort != 0 {
  26467 		v9 = int32(NUM_PARTITIONS)
  26468 	} else {
  26469 		v9 = libc.Int32FromInt32(NUM_PARTITIONS) * libc.Int32FromInt32(NUM_PARTITIONS) * libc.Int32FromInt32(NUM_PARTITIONS)
  26470 	}
  26471 	// Don't attempt linear bin-partition heuristic for
  26472 	// histograms of small sizes (as bin_map will be very sparse) and
  26473 	// maximum quality q==100 (to preserve the compression gains at that level).
  26474 	entropy_combine_num_bins = v9
  26475 	if orig_histo == libc.UintptrFromInt32(0) {
  26476 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26477 		goto Error
  26478 	}
  26479 	// Construct the histograms from backward references.
  26480 	HistogramBuild(tls, xsize, histogram_bits, refs, orig_histo)
  26481 	HistogramCopyAndAnalyze(tls, orig_histo, image_histo)
  26482 	entropy_combine = libc.BoolInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize > entropy_combine_num_bins*int32(2) && quality < int32(100))
  26483 	if entropy_combine != 0 {
  26484 		combine_cost_factor = GetCombineCostFactor(tls, image_histo_raw_size, quality)
  26485 		HistogramAnalyzeEntropyBin(tls, image_histo, low_effort)
  26486 		// Collapse histograms with similar entropy.
  26487 		HistogramCombineEntropyBin(tls, image_histo, tmp_histo, entropy_combine_num_bins, combine_cost_factor, low_effort)
  26488 	}
  26489 	// Don't combine the histograms using stochastic and greedy heuristics for
  26490 	// low-effort compression mode.
  26491 	if !(low_effort != 0) || !(entropy_combine != 0) {
  26492 		v10 = int64(quality * quality * quality * (libc.Int32FromInt32(MAX_HISTO_GREEDY) - libc.Int32FromInt32(1)))
  26493 		v11 = int64(libc.Int32FromInt32(100) * libc.Int32FromInt32(100) * libc.Int32FromInt32(100))
  26494 		if libc.BoolInt32(v10 < 0) == libc.BoolInt32(v11 < 0) {
  26495 			v14 = (v10 + v11/int64(2)) / v11
  26496 		} else {
  26497 			v14 = (v10 - v11/int64(2)) / v11
  26498 		}
  26499 		v12 = v14
  26500 		goto _13
  26501 	_13:
  26502 		// cubic ramp between 1 and MAX_HISTO_GREEDY:
  26503 		threshold_size = int32(libc.Int64FromInt32(1) + v12)
  26504 		if !(HistogramCombineStochastic(tls, image_histo, threshold_size, bp) != 0) {
  26505 			WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26506 			goto Error
  26507 		}
  26508 		if **(**int32)(__ccgo_up(bp)) != 0 {
  26509 			if !(HistogramCombineGreedy(tls, image_histo) != 0) {
  26510 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26511 				goto Error
  26512 			}
  26513 		}
  26514 	}
  26515 	// Find the optimal map from original histograms to the final ones.
  26516 	HistogramRemap(tls, orig_histo, image_histo, histogram_symbols)
  26517 	if !(WebPReportProgress(tls, pic, **(**int32)(__ccgo_up(percent))+percent_range, percent) != 0) {
  26518 		goto Error
  26519 	}
  26520 	goto Error
  26521 Error:
  26522 	;
  26523 	VP8LFreeHistogramSet(tls, orig_histo)
  26524 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  26525 }
  26526 
  26527 //------------------------------------------------------------------------------
  26528 
  26529 // Copyright 2012 Google Inc. All Rights Reserved.
  26530 //
  26531 // Use of this source code is governed by a BSD-style license
  26532 // that can be found in the COPYING file in the root of the source
  26533 // tree. An additional intellectual property rights grant can be found
  26534 // in the file PATENTS. All contributing project authors may
  26535 // be found in the AUTHORS file in the root of the source tree.
  26536 // -----------------------------------------------------------------------------
  26537 //
  26538 // Misc. common utility functions
  26539 //
  26540 // Authors: Skal (pascal.massimino@gmail.com)
  26541 //          Urvang (urvang@google.com)
  26542 
  26543 // Copyright 2010 Google Inc. All Rights Reserved.
  26544 //
  26545 // Use of this source code is governed by a BSD-style license
  26546 // that can be found in the COPYING file in the root of the source
  26547 // tree. An additional intellectual property rights grant can be found
  26548 // in the file PATENTS. All contributing project authors may
  26549 // be found in the AUTHORS file in the root of the source tree.
  26550 // -----------------------------------------------------------------------------
  26551 //
  26552 //  Common types + memory wrappers
  26553 //
  26554 // Author: Skal (pascal.massimino@gmail.com)
  26555 
  26556 //------------------------------------------------------------------------------
  26557 // VP8Iterator
  26558 //------------------------------------------------------------------------------
  26559 
  26560 func InitLeft(tls *libc.TLS, it uintptr) {
  26561 	var v1, v2 uint8_t
  26562 	var v3 int32
  26563 	_, _, _ = v1, v2, v3
  26564 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy > 0 {
  26565 		v3 = int32(129)
  26566 	} else {
  26567 		v3 = int32(127)
  26568 	}
  26569 	v2 = libc.Uint8FromInt32(v3)
  26570 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = v2
  26571 	v1 = v2
  26572 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26573 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26574 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left, int32(129), uint64(16), ^__predefined_size_t(0))
  26575 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left, int32(129), uint64(8), ^__predefined_size_t(0))
  26576 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fv_left, int32(129), uint64(8), ^__predefined_size_t(0))
  26577 	**(**int32)(__ccgo_up(it + 168 + 8*4)) = 0
  26578 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  26579 		libc.X__builtin___memset_chk(tls, it+344, 0, uint64(4), ^__predefined_size_t(0))
  26580 	}
  26581 }
  26582 
  26583 func InitTop(tls *libc.TLS, it uintptr) {
  26584 	var enc uintptr
  26585 	var top_size size_t
  26586 	_, _ = enc, top_size
  26587 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26588 	top_size = libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * int32(16))
  26589 	libc.X__builtin___memset_chk(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top, int32(127), uint64(2)*top_size, ^__predefined_size_t(0))
  26590 	libc.X__builtin___memset_chk(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fnz, 0, libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)*uint64(4), ^__predefined_size_t(0))
  26591 	if (*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr != libc.UintptrFromInt32(0) {
  26592 		libc.X__builtin___memset_chk(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr, 0, libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)*uint64(4), ^__predefined_size_t(0))
  26593 	}
  26594 }
  26595 
  26596 func VP8IteratorSetRow(tls *libc.TLS, it uintptr, y int32) {
  26597 	var enc uintptr
  26598 	_ = enc
  26599 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26600 	(*VP8EncIterator)(unsafe.Pointer(it)).Fx = 0
  26601 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy = y
  26602 	(*VP8EncIterator)(unsafe.Pointer(it)).Fbw = enc + 112 + uintptr(y&((*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)))*48
  26603 	(*VP8EncIterator)(unsafe.Pointer(it)).Fpreds = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds + uintptr(y*int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  26604 	(*VP8EncIterator)(unsafe.Pointer(it)).Fnz = (*VP8Encoder)(unsafe.Pointer(enc)).Fnz
  26605 	(*VP8EncIterator)(unsafe.Pointer(it)).Fmb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(y*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)*4
  26606 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top
  26607 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fuv_top
  26608 	InitLeft(tls, it)
  26609 }
  26610 
  26611 // C documentation
  26612 //
  26613 //	// restart a scan
  26614 func VP8IteratorReset(tls *libc.TLS, it uintptr) {
  26615 	var enc uintptr
  26616 	_ = enc
  26617 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26618 	VP8IteratorSetRow(tls, it, 0)
  26619 	VP8IteratorSetCountDown(tls, it, (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) // default
  26620 	InitTop(tls, it)
  26621 	libc.X__builtin___memset_chk(tls, it+208, 0, uint64(96), ^__predefined_size_t(0))
  26622 	(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = 0
  26623 }
  26624 
  26625 func VP8IteratorSetCountDown(tls *libc.TLS, it uintptr, count_down int32) {
  26626 	var v1 int32
  26627 	_ = v1
  26628 	v1 = count_down
  26629 	(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 = v1
  26630 	(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down = v1
  26631 }
  26632 
  26633 func VP8IteratorIsDone(tls *libc.TLS, it uintptr) (r int32) {
  26634 	return libc.BoolInt32((*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down <= 0)
  26635 }
  26636 
  26637 func VP8IteratorInit(tls *libc.TLS, enc uintptr, it uintptr) {
  26638 	(*VP8EncIterator)(unsafe.Pointer(it)).Fenc = enc
  26639 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in = uintptr((uintptr_t(it+488) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  26640 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26641 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26642 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26643 	(*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats = (*VP8Encoder)(unsafe.Pointer(enc)).Flf_stats
  26644 	(*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0 = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent
  26645 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_left = uintptr((uint64(it+400+libc.UintptrFromInt32(1)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  26646 	(*VP8EncIterator)(unsafe.Pointer(it)).Fu_left = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(16) + uintptr(16)
  26647 	(*VP8EncIterator)(unsafe.Pointer(it)).Fv_left = (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(16)
  26648 	(*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr = (*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr
  26649 	VP8IteratorReset(tls, it)
  26650 }
  26651 
  26652 func VP8IteratorProgress(tls *libc.TLS, it uintptr, delta int32) (r int32) {
  26653 	var done, percent, v1 int32
  26654 	var enc uintptr
  26655 	_, _, _, _ = done, enc, percent, v1
  26656 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26657 	if delta != 0 && (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fprogress_hook != libc.UintptrFromInt32(0) {
  26658 		done = (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 - (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down
  26659 		if (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 <= 0 {
  26660 			v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0
  26661 		} else {
  26662 			v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0 + delta*done/(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0
  26663 		}
  26664 		percent = v1
  26665 		return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, percent, enc+536)
  26666 	}
  26667 	return int32(1)
  26668 }
  26669 
  26670 //------------------------------------------------------------------------------
  26671 // Import the source samples into the cache. Takes care of replicating
  26672 // boundary pixels if necessary.
  26673 
  26674 func MinSize(tls *libc.TLS, a int32, b int32) (r int32) {
  26675 	var v1 int32
  26676 	_ = v1
  26677 	if a < b {
  26678 		v1 = a
  26679 	} else {
  26680 		v1 = b
  26681 	}
  26682 	return v1
  26683 }
  26684 
  26685 func ImportBlock(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, w int32, h int32, size int32) {
  26686 	var i int32
  26687 	_ = i
  26688 	i = 0
  26689 	for {
  26690 		if !(i < h) {
  26691 			break
  26692 		}
  26693 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  26694 		if w < size {
  26695 			libc.X__builtin___memset_chk(tls, dst+uintptr(w), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(w-int32(1))))), libc.Uint64FromInt32(size-w), ^__predefined_size_t(0))
  26696 		}
  26697 		dst = dst + uintptr(BPS)
  26698 		src = src + uintptr(src_stride)
  26699 		goto _1
  26700 	_1:
  26701 		;
  26702 		i = i + 1
  26703 	}
  26704 	i = h
  26705 	for {
  26706 		if !(i < size) {
  26707 			break
  26708 		}
  26709 		libc.X__builtin___memcpy_chk(tls, dst, dst-uintptr(BPS), libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  26710 		dst = dst + uintptr(BPS)
  26711 		goto _2
  26712 	_2:
  26713 		;
  26714 		i = i + 1
  26715 	}
  26716 }
  26717 
  26718 func ImportLine(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, len1 int32, total_len int32) {
  26719 	var i int32
  26720 	_ = i
  26721 	i = 0
  26722 	for {
  26723 		if !(i < len1) {
  26724 			break
  26725 		}
  26726 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src))
  26727 		goto _1
  26728 	_1:
  26729 		;
  26730 		i = i + 1
  26731 		src = src + uintptr(src_stride)
  26732 	}
  26733 	for {
  26734 		if !(i < total_len) {
  26735 			break
  26736 		}
  26737 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(dst + uintptr(len1-int32(1))))
  26738 		goto _2
  26739 	_2:
  26740 		;
  26741 		i = i + 1
  26742 	}
  26743 }
  26744 
  26745 func VP8IteratorImport(tls *libc.TLS, it uintptr, tmp_32 uintptr) {
  26746 	var enc, pic, usrc, vsrc, ysrc uintptr
  26747 	var h, uv_h, uv_w, w, x, y int32
  26748 	var v1, v2 uint8_t
  26749 	_, _, _, _, _, _, _, _, _, _, _, _, _ = enc, h, pic, usrc, uv_h, uv_w, vsrc, w, x, y, ysrc, v1, v2
  26750 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26751 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26752 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26753 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  26754 	ysrc = (*WebPPicture)(unsafe.Pointer(pic)).Fy + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride+x)*int32(16))
  26755 	usrc = (*WebPPicture)(unsafe.Pointer(pic)).Fu + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26756 	vsrc = (*WebPPicture)(unsafe.Pointer(pic)).Fv + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26757 	w = MinSize(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth-x*int32(16), int32(16))
  26758 	h = MinSize(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fheight-y*int32(16), int32(16))
  26759 	uv_w = (w + int32(1)) >> int32(1)
  26760 	uv_h = (h + int32(1)) >> int32(1)
  26761 	ImportBlock(tls, ysrc, (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), w, h, int32(16))
  26762 	ImportBlock(tls, usrc, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(U_OFF_ENC)), uv_w, uv_h, int32(8))
  26763 	ImportBlock(tls, vsrc, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8)), uv_w, uv_h, int32(8))
  26764 	if tmp_32 == libc.UintptrFromInt32(0) {
  26765 		return
  26766 	}
  26767 	// Import source (uncompressed) samples into boundary.
  26768 	if x == 0 {
  26769 		InitLeft(tls, it)
  26770 	} else {
  26771 		if y == 0 {
  26772 			v2 = libc.Uint8FromInt32(127)
  26773 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = v2
  26774 			v1 = v2
  26775 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26776 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26777 		} else {
  26778 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up(ysrc + uintptr(-int32(1)-(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride)))
  26779 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up(usrc + uintptr(-int32(1)-(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride)))
  26780 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up(vsrc + uintptr(-int32(1)-(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride)))
  26781 		}
  26782 		ImportLine(tls, ysrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left, h, int32(16))
  26783 		ImportLine(tls, usrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left, uv_h, int32(8))
  26784 		ImportLine(tls, vsrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fv_left, uv_h, int32(8))
  26785 	}
  26786 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_top = tmp_32 + uintptr(0)
  26787 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top = tmp_32 + uintptr(16)
  26788 	if y == 0 {
  26789 		libc.X__builtin___memset_chk(tls, tmp_32, int32(127), libc.Uint64FromInt32(32)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  26790 	} else {
  26791 		ImportLine(tls, ysrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fy_stride), int32(1), tmp_32, w, int32(16))
  26792 		ImportLine(tls, usrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride), int32(1), tmp_32+uintptr(16), uv_w, int32(8))
  26793 		ImportLine(tls, vsrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride), int32(1), tmp_32+uintptr(16)+uintptr(8), uv_w, int32(8))
  26794 	}
  26795 }
  26796 
  26797 //------------------------------------------------------------------------------
  26798 // Copy back the compressed samples into user space if requested.
  26799 
  26800 func ExportBlock(tls *libc.TLS, src uintptr, dst uintptr, dst_stride int32, w int32, h int32) {
  26801 	var v1 int32
  26802 	_ = v1
  26803 	for {
  26804 		v1 = h
  26805 		h = h - 1
  26806 		if !(v1 > 0) {
  26807 			break
  26808 		}
  26809 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  26810 		dst = dst + uintptr(dst_stride)
  26811 		src = src + uintptr(BPS)
  26812 	}
  26813 }
  26814 
  26815 func VP8IteratorExport(tls *libc.TLS, it uintptr) {
  26816 	var enc, pic, udst, usrc, vdst, vsrc, ydst, ysrc uintptr
  26817 	var h, uv_h, uv_w, w, x, y int32
  26818 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc, h, pic, udst, usrc, uv_h, uv_w, vdst, vsrc, w, x, y, ydst, ysrc
  26819 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26820 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fshow_compressed != 0 {
  26821 		x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26822 		y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26823 		ysrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  26824 		usrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  26825 		vsrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8))
  26826 		pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  26827 		ydst = (*WebPPicture)(unsafe.Pointer(pic)).Fy + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride+x)*int32(16))
  26828 		udst = (*WebPPicture)(unsafe.Pointer(pic)).Fu + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26829 		vdst = (*WebPPicture)(unsafe.Pointer(pic)).Fv + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26830 		w = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - x*int32(16)
  26831 		h = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - y*int32(16)
  26832 		if w > int32(16) {
  26833 			w = int32(16)
  26834 		}
  26835 		if h > int32(16) {
  26836 			h = int32(16)
  26837 		}
  26838 		// Luma plane
  26839 		ExportBlock(tls, ysrc, ydst, (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, w, h)
  26840 		// U/V planes
  26841 		uv_w = (w + int32(1)) >> int32(1)
  26842 		uv_h = (h + int32(1)) >> int32(1)
  26843 		ExportBlock(tls, usrc, udst, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, uv_w, uv_h)
  26844 		ExportBlock(tls, vsrc, vdst, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, uv_w, uv_h)
  26845 	}
  26846 }
  26847 
  26848 //------------------------------------------------------------------------------
  26849 // Non-zero contexts setup/teardown
  26850 
  26851 // Nz bits:
  26852 //  0  1  2  3  Y
  26853 //  4  5  6  7
  26854 //  8  9 10 11
  26855 // 12 13 14 15
  26856 // 16 17        U
  26857 // 18 19
  26858 // 20 21        V
  26859 // 22 23
  26860 // 24           DC-intra16
  26861 
  26862 // Convert packed context to byte array
  26863 
  26864 func VP8IteratorNzToBytes(tls *libc.TLS, it uintptr) {
  26865 	var left_nz, top_nz uintptr
  26866 	var lnz, tnz int32
  26867 	_, _, _, _ = left_nz, lnz, tnz, top_nz
  26868 	tnz = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)))
  26869 	lnz = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz + uintptr(-libc.Int32FromInt32(1))*4)))
  26870 	top_nz = it + 132
  26871 	left_nz = it + 168
  26872 	// Top-Y
  26873 	**(**int32)(__ccgo_up(top_nz)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(12)) != 0))
  26874 	**(**int32)(__ccgo_up(top_nz + 1*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(13)) != 0))
  26875 	**(**int32)(__ccgo_up(top_nz + 2*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(14)) != 0))
  26876 	**(**int32)(__ccgo_up(top_nz + 3*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(15)) != 0))
  26877 	// Top-U
  26878 	**(**int32)(__ccgo_up(top_nz + 4*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(18)) != 0))
  26879 	**(**int32)(__ccgo_up(top_nz + 5*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  26880 	// Top-V
  26881 	**(**int32)(__ccgo_up(top_nz + 6*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(22)) != 0))
  26882 	**(**int32)(__ccgo_up(top_nz + 7*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(23)) != 0))
  26883 	// DC
  26884 	**(**int32)(__ccgo_up(top_nz + 8*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(24)) != 0))
  26885 	// left-Y
  26886 	**(**int32)(__ccgo_up(left_nz)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(3)) != 0))
  26887 	**(**int32)(__ccgo_up(left_nz + 1*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(7)) != 0))
  26888 	**(**int32)(__ccgo_up(left_nz + 2*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(11)) != 0))
  26889 	**(**int32)(__ccgo_up(left_nz + 3*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(15)) != 0))
  26890 	// left-U
  26891 	**(**int32)(__ccgo_up(left_nz + 4*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(17)) != 0))
  26892 	**(**int32)(__ccgo_up(left_nz + 5*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  26893 	// left-V
  26894 	**(**int32)(__ccgo_up(left_nz + 6*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(21)) != 0))
  26895 	**(**int32)(__ccgo_up(left_nz + 7*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(23)) != 0))
  26896 	// left-DC is special, iterated separately
  26897 }
  26898 
  26899 func VP8IteratorBytesToNz(tls *libc.TLS, it uintptr) {
  26900 	var left_nz, top_nz uintptr
  26901 	var nz uint32_t
  26902 	_, _, _ = left_nz, nz, top_nz
  26903 	nz = uint32(0)
  26904 	top_nz = it + 132
  26905 	left_nz = it + 168
  26906 	// top
  26907 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz))<<libc.Int32FromInt32(12)|**(**int32)(__ccgo_up(top_nz + 1*4))<<libc.Int32FromInt32(13))
  26908 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 2*4))<<libc.Int32FromInt32(14)|**(**int32)(__ccgo_up(top_nz + 3*4))<<libc.Int32FromInt32(15))
  26909 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 4*4))<<libc.Int32FromInt32(18)|**(**int32)(__ccgo_up(top_nz + 5*4))<<libc.Int32FromInt32(19))
  26910 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 6*4))<<libc.Int32FromInt32(22)|**(**int32)(__ccgo_up(top_nz + 7*4))<<libc.Int32FromInt32(23))
  26911 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 8*4))<<libc.Int32FromInt32(24)) // we propagate the _top_ bit, esp. for intra4
  26912 	// left
  26913 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz))<<libc.Int32FromInt32(3)|**(**int32)(__ccgo_up(left_nz + 1*4))<<libc.Int32FromInt32(7))
  26914 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz + 2*4))<<libc.Int32FromInt32(11))
  26915 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz + 4*4))<<libc.Int32FromInt32(17)|**(**int32)(__ccgo_up(left_nz + 6*4))<<libc.Int32FromInt32(21))
  26916 	**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) = nz
  26917 }
  26918 
  26919 //------------------------------------------------------------------------------
  26920 // Advance to the next position, doing the bookkeeping.
  26921 
  26922 func VP8IteratorSaveBoundary(tls *libc.TLS, it uintptr) {
  26923 	var enc, uvsrc, ysrc uintptr
  26924 	var i, x, y int32
  26925 	_, _, _, _, _, _ = enc, i, uvsrc, x, y, ysrc
  26926 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26927 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26928 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26929 	ysrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  26930 	uvsrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  26931 	if x < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w-int32(1) {
  26932 		i = 0
  26933 		for {
  26934 			if !(i < int32(16)) {
  26935 				break
  26936 			}
  26937 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(ysrc + uintptr(int32(15)+i*int32(BPS))))
  26938 			goto _1
  26939 		_1:
  26940 			;
  26941 			i = i + 1
  26942 		}
  26943 		i = 0
  26944 		for {
  26945 			if !(i < int32(8)) {
  26946 				break
  26947 			}
  26948 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(uvsrc + uintptr(int32(7)+i*int32(BPS))))
  26949 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(uvsrc + uintptr(int32(15)+i*int32(BPS))))
  26950 			goto _2
  26951 		_2:
  26952 			;
  26953 			i = i + 1
  26954 		}
  26955 		// top-left (before 'top'!)
  26956 		**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_top + 15))
  26957 		**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(7))))
  26958 		**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top + uintptr(libc.Int32FromInt32(8)+libc.Int32FromInt32(7))))
  26959 	}
  26960 	if y < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h-int32(1) { // top
  26961 		libc.X__builtin___memcpy_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fy_top, ysrc+uintptr(libc.Int32FromInt32(15)*libc.Int32FromInt32(BPS)), uint64(16), ^__predefined_size_t(0))
  26962 		libc.X__builtin___memcpy_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top, uvsrc+uintptr(libc.Int32FromInt32(7)*libc.Int32FromInt32(BPS)), libc.Uint64FromInt32(libc.Int32FromInt32(8)+libc.Int32FromInt32(8)), ^__predefined_size_t(0))
  26963 	}
  26964 }
  26965 
  26966 func VP8IteratorNext(tls *libc.TLS, it uintptr) (r int32) {
  26967 	var v1, v3 int32
  26968 	var v2, v4 uintptr
  26969 	_, _, _, _ = v1, v2, v3, v4
  26970 	v2 = it
  26971 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  26972 	v1 = *(*int32)(unsafe.Pointer(v2))
  26973 	if v1 == (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmb_w {
  26974 		v4 = it + 4
  26975 		*(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1
  26976 		v3 = *(*int32)(unsafe.Pointer(v4))
  26977 		VP8IteratorSetRow(tls, it, v3)
  26978 	} else {
  26979 		**(**uintptr)(__ccgo_up(it + 64)) += uintptr(4)
  26980 		**(**uintptr)(__ccgo_up(it + 48)) += uintptr(1) * 4
  26981 		**(**uintptr)(__ccgo_up(it + 72)) += uintptr(1) * 4
  26982 		**(**uintptr)(__ccgo_up(it + 384)) += uintptr(16)
  26983 		**(**uintptr)(__ccgo_up(it + 392)) += uintptr(16)
  26984 	}
  26985 	v2 = it + 332
  26986 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  26987 	v1 = *(*int32)(unsafe.Pointer(v2))
  26988 	return libc.BoolInt32(0 < v1)
  26989 }
  26990 
  26991 //------------------------------------------------------------------------------
  26992 // Helper function to set mode properties
  26993 
  26994 func VP8SetIntra16Mode(tls *libc.TLS, it uintptr, mode int32) {
  26995 	var preds uintptr
  26996 	var y int32
  26997 	_, _ = preds, y
  26998 	preds = (*VP8EncIterator)(unsafe.Pointer(it)).Fpreds
  26999 	y = 0
  27000 	for {
  27001 		if !(y < int32(4)) {
  27002 			break
  27003 		}
  27004 		libc.X__builtin___memset_chk(tls, preds, mode, uint64(4), ^__predefined_size_t(0))
  27005 		preds = preds + uintptr((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w)
  27006 		goto _1
  27007 	_1:
  27008 		;
  27009 		y = y + 1
  27010 	}
  27011 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(1), 0, 0x3)
  27012 }
  27013 
  27014 func VP8SetIntra4Mode(tls *libc.TLS, it uintptr, modes uintptr) {
  27015 	var preds uintptr
  27016 	var y int32
  27017 	_, _ = preds, y
  27018 	preds = (*VP8EncIterator)(unsafe.Pointer(it)).Fpreds
  27019 	y = int32(4)
  27020 	for {
  27021 		if !(y > 0) {
  27022 			break
  27023 		}
  27024 		libc.X__builtin___memcpy_chk(tls, preds, modes, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  27025 		preds = preds + uintptr((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w)
  27026 		modes = modes + uintptr(4)
  27027 		goto _1
  27028 	_1:
  27029 		;
  27030 		y = y - 1
  27031 	}
  27032 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(0), 0, 0x3)
  27033 }
  27034 
  27035 func VP8SetIntraUVMode(tls *libc.TLS, it uintptr, mode int32) {
  27036 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(mode), 2, 0xc)
  27037 }
  27038 
  27039 func VP8SetSkip(tls *libc.TLS, it uintptr, skip int32) {
  27040 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(skip), 4, 0x10)
  27041 }
  27042 
  27043 func VP8SetSegment(tls *libc.TLS, it uintptr, segment int32) {
  27044 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(segment), 5, 0x60)
  27045 }
  27046 
  27047 //------------------------------------------------------------------------------
  27048 // Intra4x4 sub-blocks iteration
  27049 //
  27050 //  We store and update the boundary samples into an array of 37 pixels. They
  27051 //  are updated as we iterate and reconstructs each intra4x4 blocks in turn.
  27052 //  The position of the samples has the following snake pattern:
  27053 //
  27054 // 16|17 18 19 20|21 22 23 24|25 26 27 28|29 30 31 32|33 34 35 36  <- Top-right
  27055 // --+-----------+-----------+-----------+-----------+
  27056 // 15|         19|         23|         27|         31|
  27057 // 14|         18|         22|         26|         30|
  27058 // 13|         17|         21|         25|         29|
  27059 // 12|13 14 15 16|17 18 19 20|21 22 23 24|25 26 27 28|
  27060 // --+-----------+-----------+-----------+-----------+
  27061 // 11|         15|         19|         23|         27|
  27062 // 10|         14|         18|         22|         26|
  27063 //  9|         13|         17|         21|         25|
  27064 //  8| 9 10 11 12|13 14 15 16|17 18 19 20|21 22 23 24|
  27065 // --+-----------+-----------+-----------+-----------+
  27066 //  7|         11|         15|         19|         23|
  27067 //  6|         10|         14|         18|         22|
  27068 //  5|          9|         13|         17|         21|
  27069 //  4| 5  6  7  8| 9 10 11 12|13 14 15 16|17 18 19 20|
  27070 // --+-----------+-----------+-----------+-----------+
  27071 //  3|          7|         11|         15|         19|
  27072 //  2|          6|         10|         14|         18|
  27073 //  1|          5|          9|         13|         17|
  27074 //  0| 1  2  3  4| 5  6  7  8| 9 10 11 12|13 14 15 16|
  27075 // --+-----------+-----------+-----------+-----------+
  27076 
  27077 // C documentation
  27078 //
  27079 //	// Array to record the position of the top sample to pass to the prediction
  27080 //	// functions in dsp.c.
  27081 var VP8TopLeftI4 = [16]uint8_t{
  27082 	0:  uint8(17),
  27083 	1:  uint8(21),
  27084 	2:  uint8(25),
  27085 	3:  uint8(29),
  27086 	4:  uint8(13),
  27087 	5:  uint8(17),
  27088 	6:  uint8(21),
  27089 	7:  uint8(25),
  27090 	8:  uint8(9),
  27091 	9:  uint8(13),
  27092 	10: uint8(17),
  27093 	11: uint8(21),
  27094 	12: uint8(5),
  27095 	13: uint8(9),
  27096 	14: uint8(13),
  27097 	15: uint8(17),
  27098 }
  27099 
  27100 func VP8IteratorStartI4(tls *libc.TLS, it uintptr) {
  27101 	var enc uintptr
  27102 	var i int32
  27103 	_, _ = enc, i
  27104 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  27105 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4 = 0 // first 4x4 sub-block
  27106 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top = it + 80 + uintptr(VP8TopLeftI4[0])
  27107 	// Import the boundary samples
  27108 	i = 0
  27109 	for {
  27110 		if !(i < int32(17)) {
  27111 			break
  27112 		} // left
  27113 		**(**uint8_t)(__ccgo_up(it + 80 + uintptr(i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(int32(15)-i)))
  27114 		goto _1
  27115 	_1:
  27116 		;
  27117 		i = i + 1
  27118 	}
  27119 	i = 0
  27120 	for {
  27121 		if !(i < int32(16)) {
  27122 			break
  27123 		} // top
  27124 		**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_top + uintptr(i)))
  27125 		goto _2
  27126 	_2:
  27127 		;
  27128 		i = i + 1
  27129 	}
  27130 	// top-right samples have a special case on the far right of the picture
  27131 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w-int32(1) {
  27132 		i = int32(16)
  27133 		for {
  27134 			if !(i < libc.Int32FromInt32(16)+libc.Int32FromInt32(4)) {
  27135 				break
  27136 			}
  27137 			**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_top + uintptr(i)))
  27138 			goto _3
  27139 		_3:
  27140 			;
  27141 			i = i + 1
  27142 		}
  27143 	} else { // else, replicate the last valid pixel four times
  27144 		i = int32(16)
  27145 		for {
  27146 			if !(i < libc.Int32FromInt32(16)+libc.Int32FromInt32(4)) {
  27147 				break
  27148 			}
  27149 			**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up(it + 80 + uintptr(libc.Int32FromInt32(17)+libc.Int32FromInt32(15))))
  27150 			goto _4
  27151 		_4:
  27152 			;
  27153 			i = i + 1
  27154 		}
  27155 	}
  27156 	VP8IteratorNzToBytes(tls, it) // import the non-zero context
  27157 }
  27158 
  27159 func VP8IteratorRotateI4(tls *libc.TLS, it uintptr, yuv_out uintptr) (r int32) {
  27160 	var blk, top uintptr
  27161 	var i int32
  27162 	_, _, _ = blk, i, top
  27163 	blk = yuv_out + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  27164 	top = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top
  27165 	// Update the cache with 7 fresh samples
  27166 	i = 0
  27167 	for {
  27168 		if !(i <= int32(3)) {
  27169 			break
  27170 		}
  27171 		**(**uint8_t)(__ccgo_up(top + uintptr(-int32(4)+i))) = **(**uint8_t)(__ccgo_up(blk + uintptr(i+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) // store future top samples
  27172 		goto _1
  27173 	_1:
  27174 		;
  27175 		i = i + 1
  27176 	}
  27177 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fi4&int32(3) != int32(3) { // if not on the right sub-blocks #3, #7, #11, #15
  27178 		i = 0
  27179 		for {
  27180 			if !(i <= int32(2)) {
  27181 				break
  27182 			} // store future left samples
  27183 			**(**uint8_t)(__ccgo_up(top + uintptr(i))) = **(**uint8_t)(__ccgo_up(blk + uintptr(int32(3)+(int32(2)-i)*int32(BPS))))
  27184 			goto _2
  27185 		_2:
  27186 			;
  27187 			i = i + 1
  27188 		}
  27189 	} else { // else replicate top-right samples, as says the specs.
  27190 		i = 0
  27191 		for {
  27192 			if !(i <= int32(3)) {
  27193 				break
  27194 			}
  27195 			**(**uint8_t)(__ccgo_up(top + uintptr(i))) = **(**uint8_t)(__ccgo_up(top + uintptr(i+int32(4))))
  27196 			goto _3
  27197 		_3:
  27198 			;
  27199 			i = i + 1
  27200 		}
  27201 	}
  27202 	// move pointers to next sub-block
  27203 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4 = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 + 1
  27204 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 == int32(16) { // we're done
  27205 		return 0
  27206 	}
  27207 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top = it + 80 + uintptr(VP8TopLeftI4[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  27208 	return int32(1)
  27209 }
  27210 
  27211 const MAX_LIMIT_BITS = 5
  27212 const MIN_DIM_FOR_NEAR_LOSSLESS = 64
  27213 
  27214 //------------------------------------------------------------------------------
  27215 
  27216 // Copyright 2012 Google Inc. All Rights Reserved.
  27217 //
  27218 // Use of this source code is governed by a BSD-style license
  27219 // that can be found in the COPYING file in the root of the source
  27220 // tree. An additional intellectual property rights grant can be found
  27221 // in the file PATENTS. All contributing project authors may
  27222 // be found in the AUTHORS file in the root of the source tree.
  27223 // -----------------------------------------------------------------------------
  27224 //
  27225 // Misc. common utility functions
  27226 //
  27227 // Authors: Skal (pascal.massimino@gmail.com)
  27228 //          Urvang (urvang@google.com)
  27229 
  27230 // Copyright 2011 Google Inc. All Rights Reserved.
  27231 //
  27232 // Use of this source code is governed by a BSD-style license
  27233 // that can be found in the COPYING file in the root of the source
  27234 // tree. An additional intellectual property rights grant can be found
  27235 // in the file PATENTS. All contributing project authors may
  27236 // be found in the AUTHORS file in the root of the source tree.
  27237 // -----------------------------------------------------------------------------
  27238 //
  27239 //   WebP encoder: main interface
  27240 //
  27241 // Author: Skal (pascal.massimino@gmail.com)
  27242 
  27243 // C documentation
  27244 //
  27245 //	// Quantizes the value up or down to a multiple of 1<<bits (or to 255),
  27246 //	// choosing the closer one, resolving ties using bankers' rounding.
  27247 func FindClosestDiscretized(tls *libc.TLS, a uint32_t, bits int32) (r uint32_t) {
  27248 	var biased, mask uint32_t
  27249 	_, _ = biased, mask
  27250 	mask = uint32(1)<<bits - uint32(1)
  27251 	biased = a + mask>>libc.Int32FromInt32(1) + a>>bits&uint32(1)
  27252 	if biased > uint32(0xff) {
  27253 		return uint32(0xff)
  27254 	}
  27255 	return biased & ^mask
  27256 }
  27257 
  27258 // C documentation
  27259 //
  27260 //	// Applies FindClosestDiscretized to all channels of pixel.
  27261 func ClosestDiscretizedArgb(tls *libc.TLS, a uint32_t, bits int32) (r uint32_t) {
  27262 	return FindClosestDiscretized(tls, a>>int32(24), bits)<<libc.Int32FromInt32(24) | FindClosestDiscretized(tls, a>>libc.Int32FromInt32(16)&uint32(0xff), bits)<<libc.Int32FromInt32(16) | FindClosestDiscretized(tls, a>>libc.Int32FromInt32(8)&uint32(0xff), bits)<<libc.Int32FromInt32(8) | FindClosestDiscretized(tls, a&uint32(0xff), bits)
  27263 }
  27264 
  27265 // C documentation
  27266 //
  27267 //	// Checks if distance between corresponding channel values of pixels a and b
  27268 //	// is within the given limit.
  27269 func IsNear(tls *libc.TLS, a uint32_t, b uint32_t, limit int32) (r int32) {
  27270 	var delta, k int32
  27271 	_, _ = delta, k
  27272 	k = 0
  27273 	for {
  27274 		if !(k < int32(4)) {
  27275 			break
  27276 		}
  27277 		delta = libc.Int32FromUint32(a>>(k*libc.Int32FromInt32(8))&libc.Uint32FromInt32(0xff)) - libc.Int32FromUint32(b>>(k*libc.Int32FromInt32(8))&libc.Uint32FromInt32(0xff))
  27278 		if delta >= limit || delta <= -limit {
  27279 			return 0
  27280 		}
  27281 		goto _1
  27282 	_1:
  27283 		;
  27284 		k = k + 1
  27285 	}
  27286 	return int32(1)
  27287 }
  27288 
  27289 func IsSmooth(tls *libc.TLS, prev_row uintptr, curr_row uintptr, next_row uintptr, ix int32, limit int32) (r int32) {
  27290 	// Check that all pixels in 4-connected neighborhood are smooth.
  27291 	return libc.BoolInt32(IsNear(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix)*4)), **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix-int32(1))*4)), limit) != 0 && IsNear(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix)*4)), **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix+int32(1))*4)), limit) != 0 && IsNear(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix)*4)), **(**uint32_t)(__ccgo_up(prev_row + uintptr(ix)*4)), limit) != 0 && IsNear(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(ix)*4)), **(**uint32_t)(__ccgo_up(next_row + uintptr(ix)*4)), limit) != 0)
  27292 }
  27293 
  27294 // C documentation
  27295 //
  27296 //	// Adjusts pixel values of image with given maximum error.
  27297 func NearLossless(tls *libc.TLS, xsize int32, ysize int32, argb_src uintptr, stride int32, limit_bits int32, copy_buffer uintptr, argb_dst uintptr) {
  27298 	var curr_row, next_row, prev_row, temp uintptr
  27299 	var limit, x, y int32
  27300 	_, _, _, _, _, _, _ = curr_row, limit, next_row, prev_row, temp, x, y
  27301 	limit = int32(1) << limit_bits
  27302 	prev_row = copy_buffer
  27303 	curr_row = prev_row + uintptr(xsize)*4
  27304 	next_row = curr_row + uintptr(xsize)*4
  27305 	libc.X__builtin___memcpy_chk(tls, curr_row, argb_src, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27306 	libc.X__builtin___memcpy_chk(tls, next_row, argb_src+uintptr(stride)*4, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27307 	y = 0
  27308 	for {
  27309 		if !(y < ysize) {
  27310 			break
  27311 		}
  27312 		if y == 0 || y == ysize-int32(1) {
  27313 			libc.X__builtin___memcpy_chk(tls, argb_dst, argb_src, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27314 		} else {
  27315 			libc.X__builtin___memcpy_chk(tls, next_row, argb_src+uintptr(stride)*4, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27316 			**(**uint32_t)(__ccgo_up(argb_dst)) = **(**uint32_t)(__ccgo_up(argb_src))
  27317 			**(**uint32_t)(__ccgo_up(argb_dst + uintptr(xsize-int32(1))*4)) = **(**uint32_t)(__ccgo_up(argb_src + uintptr(xsize-int32(1))*4))
  27318 			x = int32(1)
  27319 			for {
  27320 				if !(x < xsize-int32(1)) {
  27321 					break
  27322 				}
  27323 				if IsSmooth(tls, prev_row, curr_row, next_row, x, limit) != 0 {
  27324 					**(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4)) = **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4))
  27325 				} else {
  27326 					**(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4)) = ClosestDiscretizedArgb(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4)), limit_bits)
  27327 				}
  27328 				goto _2
  27329 			_2:
  27330 				;
  27331 				x = x + 1
  27332 			}
  27333 		}
  27334 		// Three-way swap.
  27335 		temp = prev_row
  27336 		prev_row = curr_row
  27337 		curr_row = next_row
  27338 		next_row = temp
  27339 		goto _1
  27340 	_1:
  27341 		;
  27342 		y = y + 1
  27343 		argb_src = argb_src + uintptr(stride)*4
  27344 		argb_dst = argb_dst + uintptr(xsize)*4
  27345 	}
  27346 }
  27347 
  27348 func VP8ApplyNearLossless(tls *libc.TLS, picture uintptr, quality int32, argb_dst uintptr) (r int32) {
  27349 	var copy_buffer uintptr
  27350 	var i, limit_bits, stride, xsize, ysize, v1 int32
  27351 	_, _, _, _, _, _, _ = copy_buffer, i, limit_bits, stride, xsize, ysize, v1
  27352 	xsize = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  27353 	ysize = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  27354 	stride = (*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride
  27355 	copy_buffer = WebPSafeMalloc(tls, libc.Uint64FromInt32(xsize*int32(3)), uint64(4))
  27356 	v1 = int32(5) - quality/int32(20)
  27357 	goto _2
  27358 _2:
  27359 	limit_bits = v1
  27360 	if copy_buffer == libc.UintptrFromInt32(0) {
  27361 		return 0
  27362 	}
  27363 	// For small icon images, don't attempt to apply near-lossless compression.
  27364 	if xsize < int32(MIN_DIM_FOR_NEAR_LOSSLESS) && ysize < int32(MIN_DIM_FOR_NEAR_LOSSLESS) || ysize < int32(3) {
  27365 		i = 0
  27366 		for {
  27367 			if !(i < ysize) {
  27368 				break
  27369 			}
  27370 			libc.X__builtin___memcpy_chk(tls, argb_dst+uintptr(i*xsize)*4, (*WebPPicture)(unsafe.Pointer(picture)).Fargb+uintptr(i*(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27371 			goto _3
  27372 		_3:
  27373 			;
  27374 			i = i + 1
  27375 		}
  27376 		WebPSafeFree(tls, copy_buffer)
  27377 		return int32(1)
  27378 	}
  27379 	NearLossless(tls, xsize, ysize, (*WebPPicture)(unsafe.Pointer(picture)).Fargb, stride, limit_bits, copy_buffer, argb_dst)
  27380 	i = limit_bits - int32(1)
  27381 	for {
  27382 		if !(i != 0) {
  27383 			break
  27384 		}
  27385 		NearLossless(tls, xsize, ysize, argb_dst, xsize, i, copy_buffer, argb_dst)
  27386 		goto _4
  27387 	_4:
  27388 		;
  27389 		i = i - 1
  27390 	}
  27391 	WebPSafeFree(tls, copy_buffer)
  27392 	return int32(1)
  27393 }
  27394 
  27395 const GAMMA_FIX = 12
  27396 const GAMMA_TAB_FIX = 7
  27397 const SHARPYUV_INLINE = "inline"
  27398 const SHARPYUV_VERSION_MAJOR = 0
  27399 const SHARPYUV_VERSION_MINOR = 4
  27400 const SHARPYUV_VERSION_PATCH = 2
  27401 const __FLT_MIN__3 = 1.1754943508222875e-38
  27402 
  27403 type SharpYuvConversionMatrix = struct {
  27404 	Frgb_to_y [4]int32
  27405 	Frgb_to_u [4]int32
  27406 	Frgb_to_v [4]int32
  27407 }
  27408 
  27409 type SharpYuvOptions = struct {
  27410 	Fyuv_matrix    uintptr
  27411 	Ftransfer_type SharpYuvTransferFunctionType1
  27412 }
  27413 
  27414 type SharpYuvTransferFunctionType = int32
  27415 
  27416 const kSharpYuvTransferFunctionBt709 = 1
  27417 const kSharpYuvTransferFunctionBt470M = 4
  27418 const kSharpYuvTransferFunctionBt470Bg = 5
  27419 const kSharpYuvTransferFunctionBt601 = 6
  27420 const kSharpYuvTransferFunctionSmpte240 = 7
  27421 const kSharpYuvTransferFunctionLinear = 8
  27422 const kSharpYuvTransferFunctionLog100 = 9
  27423 const kSharpYuvTransferFunctionLog100_Sqrt10 = 10
  27424 const kSharpYuvTransferFunctionIec61966 = 11
  27425 const kSharpYuvTransferFunctionBt1361 = 12
  27426 const kSharpYuvTransferFunctionSrgb = 13
  27427 const kSharpYuvTransferFunctionBt2020_10Bit = 14
  27428 const kSharpYuvTransferFunctionBt2020_12Bit = 15
  27429 const kSharpYuvTransferFunctionSmpte2084 = 16
  27430 const kSharpYuvTransferFunctionSmpte428 = 17
  27431 const kSharpYuvTransferFunctionHlg = 18
  27432 const kSharpYuvTransferFunctionNum = 19
  27433 
  27434 type SharpYuvTransferFunctionType1 = int32
  27435 
  27436 type SharpYuvRange = int32
  27437 
  27438 const kSharpYuvRangeFull = 0
  27439 const kSharpYuvRangeLimited = 1
  27440 
  27441 type SharpYuvColorSpace = struct {
  27442 	Fkr        float32
  27443 	Fkb        float32
  27444 	Fbit_depth int32
  27445 	Frange1    SharpYuvRange
  27446 }
  27447 
  27448 type SharpYuvMatrixType = int32
  27449 
  27450 const kSharpYuvMatrixWebp = 0
  27451 const kSharpYuvMatrixRec601Limited = 1
  27452 const kSharpYuvMatrixRec601Full = 2
  27453 const kSharpYuvMatrixRec709Limited = 3
  27454 const kSharpYuvMatrixRec709Full = 4
  27455 const kSharpYuvMatrixNum = 5
  27456 
  27457 // Copyright 2012 Google Inc. All Rights Reserved.
  27458 //
  27459 // Use of this source code is governed by a BSD-style license
  27460 // that can be found in the COPYING file in the root of the source
  27461 // tree. An additional intellectual property rights grant can be found
  27462 // in the file PATENTS. All contributing project authors may
  27463 // be found in the AUTHORS file in the root of the source tree.
  27464 // -----------------------------------------------------------------------------
  27465 //
  27466 // Misc. common utility functions
  27467 //
  27468 // Authors: Skal (pascal.massimino@gmail.com)
  27469 //          Urvang (urvang@google.com)
  27470 
  27471 // Copyright 2011 Google Inc. All Rights Reserved.
  27472 //
  27473 // Use of this source code is governed by a BSD-style license
  27474 // that can be found in the COPYING file in the root of the source
  27475 // tree. An additional intellectual property rights grant can be found
  27476 // in the file PATENTS. All contributing project authors may
  27477 // be found in the AUTHORS file in the root of the source tree.
  27478 // -----------------------------------------------------------------------------
  27479 //
  27480 //   WebP encoder: main interface
  27481 //
  27482 // Author: Skal (pascal.massimino@gmail.com)
  27483 
  27484 // Copyright 2010 Google Inc. All Rights Reserved.
  27485 //
  27486 // Use of this source code is governed by a BSD-style license
  27487 // that can be found in the COPYING file in the root of the source
  27488 // tree. An additional intellectual property rights grant can be found
  27489 // in the file PATENTS. All contributing project authors may
  27490 // be found in the AUTHORS file in the root of the source tree.
  27491 // -----------------------------------------------------------------------------
  27492 //
  27493 //  Common types + memory wrappers
  27494 //
  27495 // Author: Skal (pascal.massimino@gmail.com)
  27496 
  27497 // Uncomment to disable gamma-compression during RGB->U/V averaging
  27498 
  27499 // If defined, use table to compute x / alpha.
  27500 
  27501 // uint32_t 0xff000000 is 0x00,00,00,ff in memory
  27502 
  27503 //------------------------------------------------------------------------------
  27504 // Detection of non-trivial transparency
  27505 
  27506 // C documentation
  27507 //
  27508 //	// Returns true if alpha[] has non-0xff values.
  27509 func CheckNonOpaque(tls *libc.TLS, alpha uintptr, width int32, height int32, x_step int32, y_step int32) (r int32) {
  27510 	var v2 int32
  27511 	_ = v2
  27512 	if alpha == libc.UintptrFromInt32(0) {
  27513 		return 0
  27514 	}
  27515 	WebPInitAlphaProcessing(tls)
  27516 	if x_step == int32(1) {
  27517 		for {
  27518 			v2 = height
  27519 			height = height - 1
  27520 			if !(v2 > 0) {
  27521 				break
  27522 			}
  27523 			if (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPHasAlpha8b})))(tls, alpha, width) != 0 {
  27524 				return int32(1)
  27525 			}
  27526 			goto _1
  27527 		_1:
  27528 			;
  27529 			alpha = alpha + uintptr(y_step)
  27530 		}
  27531 	} else {
  27532 		for {
  27533 			v2 = height
  27534 			height = height - 1
  27535 			if !(v2 > 0) {
  27536 				break
  27537 			}
  27538 			if (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPHasAlpha32b})))(tls, alpha, width) != 0 {
  27539 				return int32(1)
  27540 			}
  27541 			goto _3
  27542 		_3:
  27543 			;
  27544 			alpha = alpha + uintptr(y_step)
  27545 		}
  27546 	}
  27547 	return 0
  27548 }
  27549 
  27550 // C documentation
  27551 //
  27552 //	// Checking for the presence of non-opaque alpha.
  27553 func WebPPictureHasTransparency(tls *libc.TLS, picture uintptr) (r int32) {
  27554 	if picture == libc.UintptrFromInt32(0) {
  27555 		return 0
  27556 	}
  27557 	if (*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0 {
  27558 		if (*WebPPicture)(unsafe.Pointer(picture)).Fargb != libc.UintptrFromInt32(0) {
  27559 			return CheckNonOpaque(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fargb+uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(0)), (*WebPPicture)(unsafe.Pointer(picture)).Fwidth, (*WebPPicture)(unsafe.Pointer(picture)).Fheight, int32(4), libc.Int32FromUint64(libc.Uint64FromInt32((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*uint64(4)))
  27560 		}
  27561 		return 0
  27562 	}
  27563 	return CheckNonOpaque(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fa, (*WebPPicture)(unsafe.Pointer(picture)).Fwidth, (*WebPPicture)(unsafe.Pointer(picture)).Fheight, int32(1), (*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  27564 }
  27565 
  27566 //------------------------------------------------------------------------------
  27567 // Code for gamma correction
  27568 
  27569 // C documentation
  27570 //
  27571 //	// Gamma correction compensates loss of resolution during chroma subsampling.
  27572 var kGamma = float64(0.8)
  27573 var kGammaScale = libc.Int32FromInt32(1)<<libc.Int32FromInt32(GAMMA_FIX) - libc.Int32FromInt32(1)
  27574 var kGammaTabScale = libc.Int32FromInt32(1) << libc.Int32FromInt32(GAMMA_TAB_FIX)
  27575 var kGammaTabRounder = libc.Int32FromInt32(1) << libc.Int32FromInt32(GAMMA_TAB_FIX) >> libc.Int32FromInt32(1)
  27576 
  27577 var kLinearToGammaTab [33]int32
  27578 var kGammaToLinearTab [256]uint16_t
  27579 var kGammaTablesOk = int32(0)
  27580 
  27581 func InitGammaTables(tls *libc.TLS) {
  27582 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  27583 		goto _1
  27584 	}
  27585 	InitGammaTables_body(tls)
  27586 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used)), VP8GetCPUInfo)
  27587 	goto _2
  27588 _2:
  27589 	;
  27590 	goto _1
  27591 _1: /**/ //
  27592 }
  27593 
  27594 var InitGammaTables_body_last_cpuinfo_used = uintptr(0)
  27595 
  27596 func init() {
  27597 	p := unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used)
  27598 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used))
  27599 }
  27600 
  27601 func InitGammaTables_body(tls *libc.TLS) {
  27602 	var norm, scale float64
  27603 	var v int32
  27604 	_, _, _ = norm, scale, v
  27605 	if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&kGammaTablesOk))) != 0) {
  27606 		scale = float64(libc.Int32FromInt32(1)<<libc.Int32FromInt32(GAMMA_TAB_FIX)) / float64(kGammaScale)
  27607 		norm = libc.Float64FromFloat64(1) / libc.Float64FromFloat64(255)
  27608 		v = 0
  27609 		for {
  27610 			if !(v <= int32(255)) {
  27611 				break
  27612 			}
  27613 			kGammaToLinearTab[v] = uint16(float64(libc.Xpow(tls, float64(norm*float64(v)), kGamma)*float64(kGammaScale)) + libc.Float64FromFloat64(0.5))
  27614 			goto _1
  27615 		_1:
  27616 			;
  27617 			v = v + 1
  27618 		}
  27619 		v = 0
  27620 		for {
  27621 			if !(v <= libc.Int32FromInt32(1)<<(libc.Int32FromInt32(GAMMA_FIX)-libc.Int32FromInt32(GAMMA_TAB_FIX))) {
  27622 				break
  27623 			}
  27624 			kLinearToGammaTab[v] = int32(float64(libc.Float64FromFloat64(255)*libc.Xpow(tls, float64(scale*float64(v)), float64(1)/kGamma)) + libc.Float64FromFloat64(0.5))
  27625 			goto _2
  27626 		_2:
  27627 			;
  27628 			v = v + 1
  27629 		}
  27630 		libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&kGammaTablesOk)), int32(1))
  27631 	}
  27632 }
  27633 
  27634 func GammaToLinear(tls *libc.TLS, v uint8_t) (r uint32_t) {
  27635 	return uint32(kGammaToLinearTab[v])
  27636 }
  27637 
  27638 func Interpolate(tls *libc.TLS, v int32) (r int32) {
  27639 	var tab_pos, v0, v1, x, y int32
  27640 	_, _, _, _, _ = tab_pos, v0, v1, x, y
  27641 	tab_pos = v >> (libc.Int32FromInt32(GAMMA_TAB_FIX) + libc.Int32FromInt32(2)) // integer part
  27642 	x = v & (kGammaTabScale<<libc.Int32FromInt32(2) - int32(1))                  // fractional part
  27643 	v0 = kLinearToGammaTab[tab_pos]
  27644 	v1 = kLinearToGammaTab[tab_pos+int32(1)]
  27645 	y = v1*x + v0*(kGammaTabScale<<libc.Int32FromInt32(2)-x) // interpolate
  27646 	return y
  27647 }
  27648 
  27649 // C documentation
  27650 //
  27651 //	// Convert a linear value 'v' to YUV_FIX+2 fixed-point precision
  27652 //	// U/V value, suitable for RGBToU/V calls.
  27653 func LinearToGamma(tls *libc.TLS, base_value uint32_t, shift int32) (r int32) {
  27654 	var y int32
  27655 	_ = y
  27656 	y = Interpolate(tls, libc.Int32FromUint32(base_value<<shift)) // final uplifted value
  27657 	return (y + kGammaTabRounder) >> int32(GAMMA_TAB_FIX)         // descale
  27658 }
  27659 
  27660 //------------------------------------------------------------------------------
  27661 // RGB -> YUV conversion
  27662 
  27663 func RGBToY(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27664 	var diff, luma, v1, v11, v13, v15, v2, v5, v8, v9 int32
  27665 	var v10, v12, v4, v7 uintptr
  27666 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, luma, v1, v10, v11, v12, v13, v15, v2, v4, v5, v7, v8, v9
  27667 	if rg2 == libc.UintptrFromInt32(0) {
  27668 		luma = int32(16839)*r1 + int32(33059)*g1 + int32(6420)*b1
  27669 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  27670 		goto _3
  27671 	_3:
  27672 		v1 = v2
  27673 	} else {
  27674 		v4 = rg2
  27675 		v7 = v4
  27676 		v8 = int32(YUV_FIX)
  27677 		diff = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(v7 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v7)).Findex1)*4)) - **(**uint32_t)(__ccgo_up(v7 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v7)).Findex2)*4)))
  27678 		if diff < libc.Int32FromInt32(0) {
  27679 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27680 		}
  27681 		**(**uint32_t)(__ccgo_up(v7 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v7)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27682 		v10 = v7
  27683 		*(*int32)(unsafe.Pointer(v10)) = *(*int32)(unsafe.Pointer(v10)) + 1
  27684 		v9 = *(*int32)(unsafe.Pointer(v10))
  27685 		if v9 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27686 			(*VP8Random)(unsafe.Pointer(v7)).Findex1 = 0
  27687 		}
  27688 		v12 = v7 + 4
  27689 		*(*int32)(unsafe.Pointer(v12)) = *(*int32)(unsafe.Pointer(v12)) + 1
  27690 		v11 = *(*int32)(unsafe.Pointer(v12))
  27691 		if v11 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27692 			(*VP8Random)(unsafe.Pointer(v7)).Findex2 = 0
  27693 		}
  27694 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v8)
  27695 		diff = diff * (*VP8Random)(unsafe.Pointer(v4)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27696 		diff = diff + int32(1)<<(v8-int32(1))
  27697 		v13 = diff
  27698 		goto _14
  27699 	_14:
  27700 		v5 = v13
  27701 		goto _6
  27702 	_6:
  27703 		luma = int32(16839)*r1 + int32(33059)*g1 + int32(6420)*b1
  27704 		v15 = (luma + v5 + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  27705 		goto _16
  27706 	_16:
  27707 		v1 = v15
  27708 	}
  27709 	return v1
  27710 }
  27711 
  27712 func RGBToU(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27713 	var diff, u, v1, v10, v13, v14, v16, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8 int32
  27714 	var v12, v15, v17, v9 uintptr
  27715 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, u, v1, v10, v12, v13, v14, v15, v16, v17, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8, v9
  27716 	if rg2 == libc.UintptrFromInt32(0) {
  27717 		u = -int32(9719)*r1 - int32(19081)*g1 + int32(28800)*b1
  27718 		v4 = u
  27719 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27720 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  27721 			v7 = v4
  27722 		} else {
  27723 			if v4 < 0 {
  27724 				v8 = 0
  27725 			} else {
  27726 				v8 = int32(255)
  27727 			}
  27728 			v7 = v8
  27729 		}
  27730 		v5 = v7
  27731 		goto _6
  27732 	_6:
  27733 		v2 = v5
  27734 		goto _3
  27735 	_3:
  27736 		v1 = v2
  27737 	} else {
  27738 		v9 = rg2
  27739 		v12 = v9
  27740 		v13 = int32(YUV_FIX) + libc.Int32FromInt32(2)
  27741 		diff = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) - **(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex2)*4)))
  27742 		if diff < libc.Int32FromInt32(0) {
  27743 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27744 		}
  27745 		**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27746 		v15 = v12
  27747 		*(*int32)(unsafe.Pointer(v15)) = *(*int32)(unsafe.Pointer(v15)) + 1
  27748 		v14 = *(*int32)(unsafe.Pointer(v15))
  27749 		if v14 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27750 			(*VP8Random)(unsafe.Pointer(v12)).Findex1 = 0
  27751 		}
  27752 		v17 = v12 + 4
  27753 		*(*int32)(unsafe.Pointer(v17)) = *(*int32)(unsafe.Pointer(v17)) + 1
  27754 		v16 = *(*int32)(unsafe.Pointer(v17))
  27755 		if v16 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27756 			(*VP8Random)(unsafe.Pointer(v12)).Findex2 = 0
  27757 		}
  27758 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v13)
  27759 		diff = diff * (*VP8Random)(unsafe.Pointer(v9)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27760 		diff = diff + int32(1)<<(v13-int32(1))
  27761 		v18 = diff
  27762 		goto _19
  27763 	_19:
  27764 		v10 = v18
  27765 		goto _11
  27766 	_11:
  27767 		u = -int32(9719)*r1 - int32(19081)*g1 + int32(28800)*b1
  27768 		v22 = u
  27769 		v22 = (v22 + v10 + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27770 		if v22 & ^libc.Int32FromInt32(0xff) == 0 {
  27771 			v25 = v22
  27772 		} else {
  27773 			if v22 < 0 {
  27774 				v26 = 0
  27775 			} else {
  27776 				v26 = int32(255)
  27777 			}
  27778 			v25 = v26
  27779 		}
  27780 		v23 = v25
  27781 		goto _24
  27782 	_24:
  27783 		v20 = v23
  27784 		goto _21
  27785 	_21:
  27786 		v1 = v20
  27787 	}
  27788 	return v1
  27789 }
  27790 
  27791 func RGBToV(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27792 	var diff, v, v1, v10, v13, v14, v16, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8 int32
  27793 	var v12, v15, v17, v9 uintptr
  27794 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, v, v1, v10, v12, v13, v14, v15, v16, v17, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8, v9
  27795 	if rg2 == libc.UintptrFromInt32(0) {
  27796 		v = +libc.Int32FromInt32(28800)*r1 - int32(24116)*g1 - int32(4684)*b1
  27797 		v4 = v
  27798 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27799 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  27800 			v7 = v4
  27801 		} else {
  27802 			if v4 < 0 {
  27803 				v8 = 0
  27804 			} else {
  27805 				v8 = int32(255)
  27806 			}
  27807 			v7 = v8
  27808 		}
  27809 		v5 = v7
  27810 		goto _6
  27811 	_6:
  27812 		v2 = v5
  27813 		goto _3
  27814 	_3:
  27815 		v1 = v2
  27816 	} else {
  27817 		v9 = rg2
  27818 		v12 = v9
  27819 		v13 = int32(YUV_FIX) + libc.Int32FromInt32(2)
  27820 		diff = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) - **(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex2)*4)))
  27821 		if diff < libc.Int32FromInt32(0) {
  27822 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27823 		}
  27824 		**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27825 		v15 = v12
  27826 		*(*int32)(unsafe.Pointer(v15)) = *(*int32)(unsafe.Pointer(v15)) + 1
  27827 		v14 = *(*int32)(unsafe.Pointer(v15))
  27828 		if v14 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27829 			(*VP8Random)(unsafe.Pointer(v12)).Findex1 = 0
  27830 		}
  27831 		v17 = v12 + 4
  27832 		*(*int32)(unsafe.Pointer(v17)) = *(*int32)(unsafe.Pointer(v17)) + 1
  27833 		v16 = *(*int32)(unsafe.Pointer(v17))
  27834 		if v16 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27835 			(*VP8Random)(unsafe.Pointer(v12)).Findex2 = 0
  27836 		}
  27837 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v13)
  27838 		diff = diff * (*VP8Random)(unsafe.Pointer(v9)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27839 		diff = diff + int32(1)<<(v13-int32(1))
  27840 		v18 = diff
  27841 		goto _19
  27842 	_19:
  27843 		v10 = v18
  27844 		goto _11
  27845 	_11:
  27846 		v = +libc.Int32FromInt32(28800)*r1 - int32(24116)*g1 - int32(4684)*b1
  27847 		v22 = v
  27848 		v22 = (v22 + v10 + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27849 		if v22 & ^libc.Int32FromInt32(0xff) == 0 {
  27850 			v25 = v22
  27851 		} else {
  27852 			if v22 < 0 {
  27853 				v26 = 0
  27854 			} else {
  27855 				v26 = int32(255)
  27856 			}
  27857 			v25 = v26
  27858 		}
  27859 		v23 = v25
  27860 		goto _24
  27861 	_24:
  27862 		v20 = v23
  27863 		goto _21
  27864 	_21:
  27865 		v1 = v20
  27866 	}
  27867 	return v1
  27868 }
  27869 
  27870 //------------------------------------------------------------------------------
  27871 // Sharp RGB->YUV conversion
  27872 
  27873 var kMinDimensionIterativeConversion = int32(4)
  27874 
  27875 //------------------------------------------------------------------------------
  27876 // Main function
  27877 
  27878 func PreprocessARGB(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, rgb_stride int32, picture uintptr) (r int32) {
  27879 	var ok int32
  27880 	_ = ok
  27881 	ok = SharpYuvConvert(tls, r_ptr, g_ptr, b_ptr, step, rgb_stride, int32(8), (*WebPPicture)(unsafe.Pointer(picture)).Fy, (*WebPPicture)(unsafe.Pointer(picture)).Fy_stride, (*WebPPicture)(unsafe.Pointer(picture)).Fu, (*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride, (*WebPPicture)(unsafe.Pointer(picture)).Fv, (*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride, int32(8), (*WebPPicture)(unsafe.Pointer(picture)).Fwidth, (*WebPPicture)(unsafe.Pointer(picture)).Fheight, SharpYuvGetConversionMatrix(tls, int32(kSharpYuvMatrixWebp)))
  27882 	if !(ok != 0) {
  27883 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  27884 	}
  27885 	return ok
  27886 }
  27887 
  27888 //------------------------------------------------------------------------------
  27889 // "Fast" regular RGB->YUV
  27890 
  27891 var kAlphaFix = int32(19)
  27892 
  27893 // C documentation
  27894 //
  27895 //	// Following table is (1 << kAlphaFix) / a. The (v * kInvAlpha[a]) >> kAlphaFix
  27896 //	// formula is then equal to v / a in most (99.6%) cases. Note that this table
  27897 //	// and constant are adjusted very tightly to fit 32b arithmetic.
  27898 //	// In particular, they use the fact that the operands for 'v / a' are actually
  27899 //	// derived as v = (a0.p0 + a1.p1 + a2.p2 + a3.p3) and a = a0 + a1 + a2 + a3
  27900 //	// with ai in [0..255] and pi in [0..1<<GAMMA_FIX). The constraint to avoid
  27901 //	// overflow is: GAMMA_FIX + kAlphaFix <= 31.
  27902 var kInvAlpha = [1021]uint32_t{
  27903 	1:    uint32(524288),
  27904 	2:    uint32(262144),
  27905 	3:    uint32(174762),
  27906 	4:    uint32(131072),
  27907 	5:    uint32(104857),
  27908 	6:    uint32(87381),
  27909 	7:    uint32(74898),
  27910 	8:    uint32(65536),
  27911 	9:    uint32(58254),
  27912 	10:   uint32(52428),
  27913 	11:   uint32(47662),
  27914 	12:   uint32(43690),
  27915 	13:   uint32(40329),
  27916 	14:   uint32(37449),
  27917 	15:   uint32(34952),
  27918 	16:   uint32(32768),
  27919 	17:   uint32(30840),
  27920 	18:   uint32(29127),
  27921 	19:   uint32(27594),
  27922 	20:   uint32(26214),
  27923 	21:   uint32(24966),
  27924 	22:   uint32(23831),
  27925 	23:   uint32(22795),
  27926 	24:   uint32(21845),
  27927 	25:   uint32(20971),
  27928 	26:   uint32(20164),
  27929 	27:   uint32(19418),
  27930 	28:   uint32(18724),
  27931 	29:   uint32(18078),
  27932 	30:   uint32(17476),
  27933 	31:   uint32(16912),
  27934 	32:   uint32(16384),
  27935 	33:   uint32(15887),
  27936 	34:   uint32(15420),
  27937 	35:   uint32(14979),
  27938 	36:   uint32(14563),
  27939 	37:   uint32(14169),
  27940 	38:   uint32(13797),
  27941 	39:   uint32(13443),
  27942 	40:   uint32(13107),
  27943 	41:   uint32(12787),
  27944 	42:   uint32(12483),
  27945 	43:   uint32(12192),
  27946 	44:   uint32(11915),
  27947 	45:   uint32(11650),
  27948 	46:   uint32(11397),
  27949 	47:   uint32(11155),
  27950 	48:   uint32(10922),
  27951 	49:   uint32(10699),
  27952 	50:   uint32(10485),
  27953 	51:   uint32(10280),
  27954 	52:   uint32(10082),
  27955 	53:   uint32(9892),
  27956 	54:   uint32(9709),
  27957 	55:   uint32(9532),
  27958 	56:   uint32(9362),
  27959 	57:   uint32(9198),
  27960 	58:   uint32(9039),
  27961 	59:   uint32(8886),
  27962 	60:   uint32(8738),
  27963 	61:   uint32(8594),
  27964 	62:   uint32(8456),
  27965 	63:   uint32(8322),
  27966 	64:   uint32(8192),
  27967 	65:   uint32(8065),
  27968 	66:   uint32(7943),
  27969 	67:   uint32(7825),
  27970 	68:   uint32(7710),
  27971 	69:   uint32(7598),
  27972 	70:   uint32(7489),
  27973 	71:   uint32(7384),
  27974 	72:   uint32(7281),
  27975 	73:   uint32(7182),
  27976 	74:   uint32(7084),
  27977 	75:   uint32(6990),
  27978 	76:   uint32(6898),
  27979 	77:   uint32(6808),
  27980 	78:   uint32(6721),
  27981 	79:   uint32(6636),
  27982 	80:   uint32(6553),
  27983 	81:   uint32(6472),
  27984 	82:   uint32(6393),
  27985 	83:   uint32(6316),
  27986 	84:   uint32(6241),
  27987 	85:   uint32(6168),
  27988 	86:   uint32(6096),
  27989 	87:   uint32(6026),
  27990 	88:   uint32(5957),
  27991 	89:   uint32(5890),
  27992 	90:   uint32(5825),
  27993 	91:   uint32(5761),
  27994 	92:   uint32(5698),
  27995 	93:   uint32(5637),
  27996 	94:   uint32(5577),
  27997 	95:   uint32(5518),
  27998 	96:   uint32(5461),
  27999 	97:   uint32(5405),
  28000 	98:   uint32(5349),
  28001 	99:   uint32(5295),
  28002 	100:  uint32(5242),
  28003 	101:  uint32(5190),
  28004 	102:  uint32(5140),
  28005 	103:  uint32(5090),
  28006 	104:  uint32(5041),
  28007 	105:  uint32(4993),
  28008 	106:  uint32(4946),
  28009 	107:  uint32(4899),
  28010 	108:  uint32(4854),
  28011 	109:  uint32(4809),
  28012 	110:  uint32(4766),
  28013 	111:  uint32(4723),
  28014 	112:  uint32(4681),
  28015 	113:  uint32(4639),
  28016 	114:  uint32(4599),
  28017 	115:  uint32(4559),
  28018 	116:  uint32(4519),
  28019 	117:  uint32(4481),
  28020 	118:  uint32(4443),
  28021 	119:  uint32(4405),
  28022 	120:  uint32(4369),
  28023 	121:  uint32(4332),
  28024 	122:  uint32(4297),
  28025 	123:  uint32(4262),
  28026 	124:  uint32(4228),
  28027 	125:  uint32(4194),
  28028 	126:  uint32(4161),
  28029 	127:  uint32(4128),
  28030 	128:  uint32(4096),
  28031 	129:  uint32(4064),
  28032 	130:  uint32(4032),
  28033 	131:  uint32(4002),
  28034 	132:  uint32(3971),
  28035 	133:  uint32(3942),
  28036 	134:  uint32(3912),
  28037 	135:  uint32(3883),
  28038 	136:  uint32(3855),
  28039 	137:  uint32(3826),
  28040 	138:  uint32(3799),
  28041 	139:  uint32(3771),
  28042 	140:  uint32(3744),
  28043 	141:  uint32(3718),
  28044 	142:  uint32(3692),
  28045 	143:  uint32(3666),
  28046 	144:  uint32(3640),
  28047 	145:  uint32(3615),
  28048 	146:  uint32(3591),
  28049 	147:  uint32(3566),
  28050 	148:  uint32(3542),
  28051 	149:  uint32(3518),
  28052 	150:  uint32(3495),
  28053 	151:  uint32(3472),
  28054 	152:  uint32(3449),
  28055 	153:  uint32(3426),
  28056 	154:  uint32(3404),
  28057 	155:  uint32(3382),
  28058 	156:  uint32(3360),
  28059 	157:  uint32(3339),
  28060 	158:  uint32(3318),
  28061 	159:  uint32(3297),
  28062 	160:  uint32(3276),
  28063 	161:  uint32(3256),
  28064 	162:  uint32(3236),
  28065 	163:  uint32(3216),
  28066 	164:  uint32(3196),
  28067 	165:  uint32(3177),
  28068 	166:  uint32(3158),
  28069 	167:  uint32(3139),
  28070 	168:  uint32(3120),
  28071 	169:  uint32(3102),
  28072 	170:  uint32(3084),
  28073 	171:  uint32(3066),
  28074 	172:  uint32(3048),
  28075 	173:  uint32(3030),
  28076 	174:  uint32(3013),
  28077 	175:  uint32(2995),
  28078 	176:  uint32(2978),
  28079 	177:  uint32(2962),
  28080 	178:  uint32(2945),
  28081 	179:  uint32(2928),
  28082 	180:  uint32(2912),
  28083 	181:  uint32(2896),
  28084 	182:  uint32(2880),
  28085 	183:  uint32(2864),
  28086 	184:  uint32(2849),
  28087 	185:  uint32(2833),
  28088 	186:  uint32(2818),
  28089 	187:  uint32(2803),
  28090 	188:  uint32(2788),
  28091 	189:  uint32(2774),
  28092 	190:  uint32(2759),
  28093 	191:  uint32(2744),
  28094 	192:  uint32(2730),
  28095 	193:  uint32(2716),
  28096 	194:  uint32(2702),
  28097 	195:  uint32(2688),
  28098 	196:  uint32(2674),
  28099 	197:  uint32(2661),
  28100 	198:  uint32(2647),
  28101 	199:  uint32(2634),
  28102 	200:  uint32(2621),
  28103 	201:  uint32(2608),
  28104 	202:  uint32(2595),
  28105 	203:  uint32(2582),
  28106 	204:  uint32(2570),
  28107 	205:  uint32(2557),
  28108 	206:  uint32(2545),
  28109 	207:  uint32(2532),
  28110 	208:  uint32(2520),
  28111 	209:  uint32(2508),
  28112 	210:  uint32(2496),
  28113 	211:  uint32(2484),
  28114 	212:  uint32(2473),
  28115 	213:  uint32(2461),
  28116 	214:  uint32(2449),
  28117 	215:  uint32(2438),
  28118 	216:  uint32(2427),
  28119 	217:  uint32(2416),
  28120 	218:  uint32(2404),
  28121 	219:  uint32(2394),
  28122 	220:  uint32(2383),
  28123 	221:  uint32(2372),
  28124 	222:  uint32(2361),
  28125 	223:  uint32(2351),
  28126 	224:  uint32(2340),
  28127 	225:  uint32(2330),
  28128 	226:  uint32(2319),
  28129 	227:  uint32(2309),
  28130 	228:  uint32(2299),
  28131 	229:  uint32(2289),
  28132 	230:  uint32(2279),
  28133 	231:  uint32(2269),
  28134 	232:  uint32(2259),
  28135 	233:  uint32(2250),
  28136 	234:  uint32(2240),
  28137 	235:  uint32(2231),
  28138 	236:  uint32(2221),
  28139 	237:  uint32(2212),
  28140 	238:  uint32(2202),
  28141 	239:  uint32(2193),
  28142 	240:  uint32(2184),
  28143 	241:  uint32(2175),
  28144 	242:  uint32(2166),
  28145 	243:  uint32(2157),
  28146 	244:  uint32(2148),
  28147 	245:  uint32(2139),
  28148 	246:  uint32(2131),
  28149 	247:  uint32(2122),
  28150 	248:  uint32(2114),
  28151 	249:  uint32(2105),
  28152 	250:  uint32(2097),
  28153 	251:  uint32(2088),
  28154 	252:  uint32(2080),
  28155 	253:  uint32(2072),
  28156 	254:  uint32(2064),
  28157 	255:  uint32(2056),
  28158 	256:  uint32(2048),
  28159 	257:  uint32(2040),
  28160 	258:  uint32(2032),
  28161 	259:  uint32(2024),
  28162 	260:  uint32(2016),
  28163 	261:  uint32(2008),
  28164 	262:  uint32(2001),
  28165 	263:  uint32(1993),
  28166 	264:  uint32(1985),
  28167 	265:  uint32(1978),
  28168 	266:  uint32(1971),
  28169 	267:  uint32(1963),
  28170 	268:  uint32(1956),
  28171 	269:  uint32(1949),
  28172 	270:  uint32(1941),
  28173 	271:  uint32(1934),
  28174 	272:  uint32(1927),
  28175 	273:  uint32(1920),
  28176 	274:  uint32(1913),
  28177 	275:  uint32(1906),
  28178 	276:  uint32(1899),
  28179 	277:  uint32(1892),
  28180 	278:  uint32(1885),
  28181 	279:  uint32(1879),
  28182 	280:  uint32(1872),
  28183 	281:  uint32(1865),
  28184 	282:  uint32(1859),
  28185 	283:  uint32(1852),
  28186 	284:  uint32(1846),
  28187 	285:  uint32(1839),
  28188 	286:  uint32(1833),
  28189 	287:  uint32(1826),
  28190 	288:  uint32(1820),
  28191 	289:  uint32(1814),
  28192 	290:  uint32(1807),
  28193 	291:  uint32(1801),
  28194 	292:  uint32(1795),
  28195 	293:  uint32(1789),
  28196 	294:  uint32(1783),
  28197 	295:  uint32(1777),
  28198 	296:  uint32(1771),
  28199 	297:  uint32(1765),
  28200 	298:  uint32(1759),
  28201 	299:  uint32(1753),
  28202 	300:  uint32(1747),
  28203 	301:  uint32(1741),
  28204 	302:  uint32(1736),
  28205 	303:  uint32(1730),
  28206 	304:  uint32(1724),
  28207 	305:  uint32(1718),
  28208 	306:  uint32(1713),
  28209 	307:  uint32(1707),
  28210 	308:  uint32(1702),
  28211 	309:  uint32(1696),
  28212 	310:  uint32(1691),
  28213 	311:  uint32(1685),
  28214 	312:  uint32(1680),
  28215 	313:  uint32(1675),
  28216 	314:  uint32(1669),
  28217 	315:  uint32(1664),
  28218 	316:  uint32(1659),
  28219 	317:  uint32(1653),
  28220 	318:  uint32(1648),
  28221 	319:  uint32(1643),
  28222 	320:  uint32(1638),
  28223 	321:  uint32(1633),
  28224 	322:  uint32(1628),
  28225 	323:  uint32(1623),
  28226 	324:  uint32(1618),
  28227 	325:  uint32(1613),
  28228 	326:  uint32(1608),
  28229 	327:  uint32(1603),
  28230 	328:  uint32(1598),
  28231 	329:  uint32(1593),
  28232 	330:  uint32(1588),
  28233 	331:  uint32(1583),
  28234 	332:  uint32(1579),
  28235 	333:  uint32(1574),
  28236 	334:  uint32(1569),
  28237 	335:  uint32(1565),
  28238 	336:  uint32(1560),
  28239 	337:  uint32(1555),
  28240 	338:  uint32(1551),
  28241 	339:  uint32(1546),
  28242 	340:  uint32(1542),
  28243 	341:  uint32(1537),
  28244 	342:  uint32(1533),
  28245 	343:  uint32(1528),
  28246 	344:  uint32(1524),
  28247 	345:  uint32(1519),
  28248 	346:  uint32(1515),
  28249 	347:  uint32(1510),
  28250 	348:  uint32(1506),
  28251 	349:  uint32(1502),
  28252 	350:  uint32(1497),
  28253 	351:  uint32(1493),
  28254 	352:  uint32(1489),
  28255 	353:  uint32(1485),
  28256 	354:  uint32(1481),
  28257 	355:  uint32(1476),
  28258 	356:  uint32(1472),
  28259 	357:  uint32(1468),
  28260 	358:  uint32(1464),
  28261 	359:  uint32(1460),
  28262 	360:  uint32(1456),
  28263 	361:  uint32(1452),
  28264 	362:  uint32(1448),
  28265 	363:  uint32(1444),
  28266 	364:  uint32(1440),
  28267 	365:  uint32(1436),
  28268 	366:  uint32(1432),
  28269 	367:  uint32(1428),
  28270 	368:  uint32(1424),
  28271 	369:  uint32(1420),
  28272 	370:  uint32(1416),
  28273 	371:  uint32(1413),
  28274 	372:  uint32(1409),
  28275 	373:  uint32(1405),
  28276 	374:  uint32(1401),
  28277 	375:  uint32(1398),
  28278 	376:  uint32(1394),
  28279 	377:  uint32(1390),
  28280 	378:  uint32(1387),
  28281 	379:  uint32(1383),
  28282 	380:  uint32(1379),
  28283 	381:  uint32(1376),
  28284 	382:  uint32(1372),
  28285 	383:  uint32(1368),
  28286 	384:  uint32(1365),
  28287 	385:  uint32(1361),
  28288 	386:  uint32(1358),
  28289 	387:  uint32(1354),
  28290 	388:  uint32(1351),
  28291 	389:  uint32(1347),
  28292 	390:  uint32(1344),
  28293 	391:  uint32(1340),
  28294 	392:  uint32(1337),
  28295 	393:  uint32(1334),
  28296 	394:  uint32(1330),
  28297 	395:  uint32(1327),
  28298 	396:  uint32(1323),
  28299 	397:  uint32(1320),
  28300 	398:  uint32(1317),
  28301 	399:  uint32(1314),
  28302 	400:  uint32(1310),
  28303 	401:  uint32(1307),
  28304 	402:  uint32(1304),
  28305 	403:  uint32(1300),
  28306 	404:  uint32(1297),
  28307 	405:  uint32(1294),
  28308 	406:  uint32(1291),
  28309 	407:  uint32(1288),
  28310 	408:  uint32(1285),
  28311 	409:  uint32(1281),
  28312 	410:  uint32(1278),
  28313 	411:  uint32(1275),
  28314 	412:  uint32(1272),
  28315 	413:  uint32(1269),
  28316 	414:  uint32(1266),
  28317 	415:  uint32(1263),
  28318 	416:  uint32(1260),
  28319 	417:  uint32(1257),
  28320 	418:  uint32(1254),
  28321 	419:  uint32(1251),
  28322 	420:  uint32(1248),
  28323 	421:  uint32(1245),
  28324 	422:  uint32(1242),
  28325 	423:  uint32(1239),
  28326 	424:  uint32(1236),
  28327 	425:  uint32(1233),
  28328 	426:  uint32(1230),
  28329 	427:  uint32(1227),
  28330 	428:  uint32(1224),
  28331 	429:  uint32(1222),
  28332 	430:  uint32(1219),
  28333 	431:  uint32(1216),
  28334 	432:  uint32(1213),
  28335 	433:  uint32(1210),
  28336 	434:  uint32(1208),
  28337 	435:  uint32(1205),
  28338 	436:  uint32(1202),
  28339 	437:  uint32(1199),
  28340 	438:  uint32(1197),
  28341 	439:  uint32(1194),
  28342 	440:  uint32(1191),
  28343 	441:  uint32(1188),
  28344 	442:  uint32(1186),
  28345 	443:  uint32(1183),
  28346 	444:  uint32(1180),
  28347 	445:  uint32(1178),
  28348 	446:  uint32(1175),
  28349 	447:  uint32(1172),
  28350 	448:  uint32(1170),
  28351 	449:  uint32(1167),
  28352 	450:  uint32(1165),
  28353 	451:  uint32(1162),
  28354 	452:  uint32(1159),
  28355 	453:  uint32(1157),
  28356 	454:  uint32(1154),
  28357 	455:  uint32(1152),
  28358 	456:  uint32(1149),
  28359 	457:  uint32(1147),
  28360 	458:  uint32(1144),
  28361 	459:  uint32(1142),
  28362 	460:  uint32(1139),
  28363 	461:  uint32(1137),
  28364 	462:  uint32(1134),
  28365 	463:  uint32(1132),
  28366 	464:  uint32(1129),
  28367 	465:  uint32(1127),
  28368 	466:  uint32(1125),
  28369 	467:  uint32(1122),
  28370 	468:  uint32(1120),
  28371 	469:  uint32(1117),
  28372 	470:  uint32(1115),
  28373 	471:  uint32(1113),
  28374 	472:  uint32(1110),
  28375 	473:  uint32(1108),
  28376 	474:  uint32(1106),
  28377 	475:  uint32(1103),
  28378 	476:  uint32(1101),
  28379 	477:  uint32(1099),
  28380 	478:  uint32(1096),
  28381 	479:  uint32(1094),
  28382 	480:  uint32(1092),
  28383 	481:  uint32(1089),
  28384 	482:  uint32(1087),
  28385 	483:  uint32(1085),
  28386 	484:  uint32(1083),
  28387 	485:  uint32(1081),
  28388 	486:  uint32(1078),
  28389 	487:  uint32(1076),
  28390 	488:  uint32(1074),
  28391 	489:  uint32(1072),
  28392 	490:  uint32(1069),
  28393 	491:  uint32(1067),
  28394 	492:  uint32(1065),
  28395 	493:  uint32(1063),
  28396 	494:  uint32(1061),
  28397 	495:  uint32(1059),
  28398 	496:  uint32(1057),
  28399 	497:  uint32(1054),
  28400 	498:  uint32(1052),
  28401 	499:  uint32(1050),
  28402 	500:  uint32(1048),
  28403 	501:  uint32(1046),
  28404 	502:  uint32(1044),
  28405 	503:  uint32(1042),
  28406 	504:  uint32(1040),
  28407 	505:  uint32(1038),
  28408 	506:  uint32(1036),
  28409 	507:  uint32(1034),
  28410 	508:  uint32(1032),
  28411 	509:  uint32(1030),
  28412 	510:  uint32(1028),
  28413 	511:  uint32(1026),
  28414 	512:  uint32(1024),
  28415 	513:  uint32(1022),
  28416 	514:  uint32(1020),
  28417 	515:  uint32(1018),
  28418 	516:  uint32(1016),
  28419 	517:  uint32(1014),
  28420 	518:  uint32(1012),
  28421 	519:  uint32(1010),
  28422 	520:  uint32(1008),
  28423 	521:  uint32(1006),
  28424 	522:  uint32(1004),
  28425 	523:  uint32(1002),
  28426 	524:  uint32(1000),
  28427 	525:  uint32(998),
  28428 	526:  uint32(996),
  28429 	527:  uint32(994),
  28430 	528:  uint32(992),
  28431 	529:  uint32(991),
  28432 	530:  uint32(989),
  28433 	531:  uint32(987),
  28434 	532:  uint32(985),
  28435 	533:  uint32(983),
  28436 	534:  uint32(981),
  28437 	535:  uint32(979),
  28438 	536:  uint32(978),
  28439 	537:  uint32(976),
  28440 	538:  uint32(974),
  28441 	539:  uint32(972),
  28442 	540:  uint32(970),
  28443 	541:  uint32(969),
  28444 	542:  uint32(967),
  28445 	543:  uint32(965),
  28446 	544:  uint32(963),
  28447 	545:  uint32(961),
  28448 	546:  uint32(960),
  28449 	547:  uint32(958),
  28450 	548:  uint32(956),
  28451 	549:  uint32(954),
  28452 	550:  uint32(953),
  28453 	551:  uint32(951),
  28454 	552:  uint32(949),
  28455 	553:  uint32(948),
  28456 	554:  uint32(946),
  28457 	555:  uint32(944),
  28458 	556:  uint32(942),
  28459 	557:  uint32(941),
  28460 	558:  uint32(939),
  28461 	559:  uint32(937),
  28462 	560:  uint32(936),
  28463 	561:  uint32(934),
  28464 	562:  uint32(932),
  28465 	563:  uint32(931),
  28466 	564:  uint32(929),
  28467 	565:  uint32(927),
  28468 	566:  uint32(926),
  28469 	567:  uint32(924),
  28470 	568:  uint32(923),
  28471 	569:  uint32(921),
  28472 	570:  uint32(919),
  28473 	571:  uint32(918),
  28474 	572:  uint32(916),
  28475 	573:  uint32(914),
  28476 	574:  uint32(913),
  28477 	575:  uint32(911),
  28478 	576:  uint32(910),
  28479 	577:  uint32(908),
  28480 	578:  uint32(907),
  28481 	579:  uint32(905),
  28482 	580:  uint32(903),
  28483 	581:  uint32(902),
  28484 	582:  uint32(900),
  28485 	583:  uint32(899),
  28486 	584:  uint32(897),
  28487 	585:  uint32(896),
  28488 	586:  uint32(894),
  28489 	587:  uint32(893),
  28490 	588:  uint32(891),
  28491 	589:  uint32(890),
  28492 	590:  uint32(888),
  28493 	591:  uint32(887),
  28494 	592:  uint32(885),
  28495 	593:  uint32(884),
  28496 	594:  uint32(882),
  28497 	595:  uint32(881),
  28498 	596:  uint32(879),
  28499 	597:  uint32(878),
  28500 	598:  uint32(876),
  28501 	599:  uint32(875),
  28502 	600:  uint32(873),
  28503 	601:  uint32(872),
  28504 	602:  uint32(870),
  28505 	603:  uint32(869),
  28506 	604:  uint32(868),
  28507 	605:  uint32(866),
  28508 	606:  uint32(865),
  28509 	607:  uint32(863),
  28510 	608:  uint32(862),
  28511 	609:  uint32(860),
  28512 	610:  uint32(859),
  28513 	611:  uint32(858),
  28514 	612:  uint32(856),
  28515 	613:  uint32(855),
  28516 	614:  uint32(853),
  28517 	615:  uint32(852),
  28518 	616:  uint32(851),
  28519 	617:  uint32(849),
  28520 	618:  uint32(848),
  28521 	619:  uint32(846),
  28522 	620:  uint32(845),
  28523 	621:  uint32(844),
  28524 	622:  uint32(842),
  28525 	623:  uint32(841),
  28526 	624:  uint32(840),
  28527 	625:  uint32(838),
  28528 	626:  uint32(837),
  28529 	627:  uint32(836),
  28530 	628:  uint32(834),
  28531 	629:  uint32(833),
  28532 	630:  uint32(832),
  28533 	631:  uint32(830),
  28534 	632:  uint32(829),
  28535 	633:  uint32(828),
  28536 	634:  uint32(826),
  28537 	635:  uint32(825),
  28538 	636:  uint32(824),
  28539 	637:  uint32(823),
  28540 	638:  uint32(821),
  28541 	639:  uint32(820),
  28542 	640:  uint32(819),
  28543 	641:  uint32(817),
  28544 	642:  uint32(816),
  28545 	643:  uint32(815),
  28546 	644:  uint32(814),
  28547 	645:  uint32(812),
  28548 	646:  uint32(811),
  28549 	647:  uint32(810),
  28550 	648:  uint32(809),
  28551 	649:  uint32(807),
  28552 	650:  uint32(806),
  28553 	651:  uint32(805),
  28554 	652:  uint32(804),
  28555 	653:  uint32(802),
  28556 	654:  uint32(801),
  28557 	655:  uint32(800),
  28558 	656:  uint32(799),
  28559 	657:  uint32(798),
  28560 	658:  uint32(796),
  28561 	659:  uint32(795),
  28562 	660:  uint32(794),
  28563 	661:  uint32(793),
  28564 	662:  uint32(791),
  28565 	663:  uint32(790),
  28566 	664:  uint32(789),
  28567 	665:  uint32(788),
  28568 	666:  uint32(787),
  28569 	667:  uint32(786),
  28570 	668:  uint32(784),
  28571 	669:  uint32(783),
  28572 	670:  uint32(782),
  28573 	671:  uint32(781),
  28574 	672:  uint32(780),
  28575 	673:  uint32(779),
  28576 	674:  uint32(777),
  28577 	675:  uint32(776),
  28578 	676:  uint32(775),
  28579 	677:  uint32(774),
  28580 	678:  uint32(773),
  28581 	679:  uint32(772),
  28582 	680:  uint32(771),
  28583 	681:  uint32(769),
  28584 	682:  uint32(768),
  28585 	683:  uint32(767),
  28586 	684:  uint32(766),
  28587 	685:  uint32(765),
  28588 	686:  uint32(764),
  28589 	687:  uint32(763),
  28590 	688:  uint32(762),
  28591 	689:  uint32(760),
  28592 	690:  uint32(759),
  28593 	691:  uint32(758),
  28594 	692:  uint32(757),
  28595 	693:  uint32(756),
  28596 	694:  uint32(755),
  28597 	695:  uint32(754),
  28598 	696:  uint32(753),
  28599 	697:  uint32(752),
  28600 	698:  uint32(751),
  28601 	699:  uint32(750),
  28602 	700:  uint32(748),
  28603 	701:  uint32(747),
  28604 	702:  uint32(746),
  28605 	703:  uint32(745),
  28606 	704:  uint32(744),
  28607 	705:  uint32(743),
  28608 	706:  uint32(742),
  28609 	707:  uint32(741),
  28610 	708:  uint32(740),
  28611 	709:  uint32(739),
  28612 	710:  uint32(738),
  28613 	711:  uint32(737),
  28614 	712:  uint32(736),
  28615 	713:  uint32(735),
  28616 	714:  uint32(734),
  28617 	715:  uint32(733),
  28618 	716:  uint32(732),
  28619 	717:  uint32(731),
  28620 	718:  uint32(730),
  28621 	719:  uint32(729),
  28622 	720:  uint32(728),
  28623 	721:  uint32(727),
  28624 	722:  uint32(726),
  28625 	723:  uint32(725),
  28626 	724:  uint32(724),
  28627 	725:  uint32(723),
  28628 	726:  uint32(722),
  28629 	727:  uint32(721),
  28630 	728:  uint32(720),
  28631 	729:  uint32(719),
  28632 	730:  uint32(718),
  28633 	731:  uint32(717),
  28634 	732:  uint32(716),
  28635 	733:  uint32(715),
  28636 	734:  uint32(714),
  28637 	735:  uint32(713),
  28638 	736:  uint32(712),
  28639 	737:  uint32(711),
  28640 	738:  uint32(710),
  28641 	739:  uint32(709),
  28642 	740:  uint32(708),
  28643 	741:  uint32(707),
  28644 	742:  uint32(706),
  28645 	743:  uint32(705),
  28646 	744:  uint32(704),
  28647 	745:  uint32(703),
  28648 	746:  uint32(702),
  28649 	747:  uint32(701),
  28650 	748:  uint32(700),
  28651 	749:  uint32(699),
  28652 	750:  uint32(699),
  28653 	751:  uint32(698),
  28654 	752:  uint32(697),
  28655 	753:  uint32(696),
  28656 	754:  uint32(695),
  28657 	755:  uint32(694),
  28658 	756:  uint32(693),
  28659 	757:  uint32(692),
  28660 	758:  uint32(691),
  28661 	759:  uint32(690),
  28662 	760:  uint32(689),
  28663 	761:  uint32(688),
  28664 	762:  uint32(688),
  28665 	763:  uint32(687),
  28666 	764:  uint32(686),
  28667 	765:  uint32(685),
  28668 	766:  uint32(684),
  28669 	767:  uint32(683),
  28670 	768:  uint32(682),
  28671 	769:  uint32(681),
  28672 	770:  uint32(680),
  28673 	771:  uint32(680),
  28674 	772:  uint32(679),
  28675 	773:  uint32(678),
  28676 	774:  uint32(677),
  28677 	775:  uint32(676),
  28678 	776:  uint32(675),
  28679 	777:  uint32(674),
  28680 	778:  uint32(673),
  28681 	779:  uint32(673),
  28682 	780:  uint32(672),
  28683 	781:  uint32(671),
  28684 	782:  uint32(670),
  28685 	783:  uint32(669),
  28686 	784:  uint32(668),
  28687 	785:  uint32(667),
  28688 	786:  uint32(667),
  28689 	787:  uint32(666),
  28690 	788:  uint32(665),
  28691 	789:  uint32(664),
  28692 	790:  uint32(663),
  28693 	791:  uint32(662),
  28694 	792:  uint32(661),
  28695 	793:  uint32(661),
  28696 	794:  uint32(660),
  28697 	795:  uint32(659),
  28698 	796:  uint32(658),
  28699 	797:  uint32(657),
  28700 	798:  uint32(657),
  28701 	799:  uint32(656),
  28702 	800:  uint32(655),
  28703 	801:  uint32(654),
  28704 	802:  uint32(653),
  28705 	803:  uint32(652),
  28706 	804:  uint32(652),
  28707 	805:  uint32(651),
  28708 	806:  uint32(650),
  28709 	807:  uint32(649),
  28710 	808:  uint32(648),
  28711 	809:  uint32(648),
  28712 	810:  uint32(647),
  28713 	811:  uint32(646),
  28714 	812:  uint32(645),
  28715 	813:  uint32(644),
  28716 	814:  uint32(644),
  28717 	815:  uint32(643),
  28718 	816:  uint32(642),
  28719 	817:  uint32(641),
  28720 	818:  uint32(640),
  28721 	819:  uint32(640),
  28722 	820:  uint32(639),
  28723 	821:  uint32(638),
  28724 	822:  uint32(637),
  28725 	823:  uint32(637),
  28726 	824:  uint32(636),
  28727 	825:  uint32(635),
  28728 	826:  uint32(634),
  28729 	827:  uint32(633),
  28730 	828:  uint32(633),
  28731 	829:  uint32(632),
  28732 	830:  uint32(631),
  28733 	831:  uint32(630),
  28734 	832:  uint32(630),
  28735 	833:  uint32(629),
  28736 	834:  uint32(628),
  28737 	835:  uint32(627),
  28738 	836:  uint32(627),
  28739 	837:  uint32(626),
  28740 	838:  uint32(625),
  28741 	839:  uint32(624),
  28742 	840:  uint32(624),
  28743 	841:  uint32(623),
  28744 	842:  uint32(622),
  28745 	843:  uint32(621),
  28746 	844:  uint32(621),
  28747 	845:  uint32(620),
  28748 	846:  uint32(619),
  28749 	847:  uint32(618),
  28750 	848:  uint32(618),
  28751 	849:  uint32(617),
  28752 	850:  uint32(616),
  28753 	851:  uint32(616),
  28754 	852:  uint32(615),
  28755 	853:  uint32(614),
  28756 	854:  uint32(613),
  28757 	855:  uint32(613),
  28758 	856:  uint32(612),
  28759 	857:  uint32(611),
  28760 	858:  uint32(611),
  28761 	859:  uint32(610),
  28762 	860:  uint32(609),
  28763 	861:  uint32(608),
  28764 	862:  uint32(608),
  28765 	863:  uint32(607),
  28766 	864:  uint32(606),
  28767 	865:  uint32(606),
  28768 	866:  uint32(605),
  28769 	867:  uint32(604),
  28770 	868:  uint32(604),
  28771 	869:  uint32(603),
  28772 	870:  uint32(602),
  28773 	871:  uint32(601),
  28774 	872:  uint32(601),
  28775 	873:  uint32(600),
  28776 	874:  uint32(599),
  28777 	875:  uint32(599),
  28778 	876:  uint32(598),
  28779 	877:  uint32(597),
  28780 	878:  uint32(597),
  28781 	879:  uint32(596),
  28782 	880:  uint32(595),
  28783 	881:  uint32(595),
  28784 	882:  uint32(594),
  28785 	883:  uint32(593),
  28786 	884:  uint32(593),
  28787 	885:  uint32(592),
  28788 	886:  uint32(591),
  28789 	887:  uint32(591),
  28790 	888:  uint32(590),
  28791 	889:  uint32(589),
  28792 	890:  uint32(589),
  28793 	891:  uint32(588),
  28794 	892:  uint32(587),
  28795 	893:  uint32(587),
  28796 	894:  uint32(586),
  28797 	895:  uint32(585),
  28798 	896:  uint32(585),
  28799 	897:  uint32(584),
  28800 	898:  uint32(583),
  28801 	899:  uint32(583),
  28802 	900:  uint32(582),
  28803 	901:  uint32(581),
  28804 	902:  uint32(581),
  28805 	903:  uint32(580),
  28806 	904:  uint32(579),
  28807 	905:  uint32(579),
  28808 	906:  uint32(578),
  28809 	907:  uint32(578),
  28810 	908:  uint32(577),
  28811 	909:  uint32(576),
  28812 	910:  uint32(576),
  28813 	911:  uint32(575),
  28814 	912:  uint32(574),
  28815 	913:  uint32(574),
  28816 	914:  uint32(573),
  28817 	915:  uint32(572),
  28818 	916:  uint32(572),
  28819 	917:  uint32(571),
  28820 	918:  uint32(571),
  28821 	919:  uint32(570),
  28822 	920:  uint32(569),
  28823 	921:  uint32(569),
  28824 	922:  uint32(568),
  28825 	923:  uint32(568),
  28826 	924:  uint32(567),
  28827 	925:  uint32(566),
  28828 	926:  uint32(566),
  28829 	927:  uint32(565),
  28830 	928:  uint32(564),
  28831 	929:  uint32(564),
  28832 	930:  uint32(563),
  28833 	931:  uint32(563),
  28834 	932:  uint32(562),
  28835 	933:  uint32(561),
  28836 	934:  uint32(561),
  28837 	935:  uint32(560),
  28838 	936:  uint32(560),
  28839 	937:  uint32(559),
  28840 	938:  uint32(558),
  28841 	939:  uint32(558),
  28842 	940:  uint32(557),
  28843 	941:  uint32(557),
  28844 	942:  uint32(556),
  28845 	943:  uint32(555),
  28846 	944:  uint32(555),
  28847 	945:  uint32(554),
  28848 	946:  uint32(554),
  28849 	947:  uint32(553),
  28850 	948:  uint32(553),
  28851 	949:  uint32(552),
  28852 	950:  uint32(551),
  28853 	951:  uint32(551),
  28854 	952:  uint32(550),
  28855 	953:  uint32(550),
  28856 	954:  uint32(549),
  28857 	955:  uint32(548),
  28858 	956:  uint32(548),
  28859 	957:  uint32(547),
  28860 	958:  uint32(547),
  28861 	959:  uint32(546),
  28862 	960:  uint32(546),
  28863 	961:  uint32(545),
  28864 	962:  uint32(544),
  28865 	963:  uint32(544),
  28866 	964:  uint32(543),
  28867 	965:  uint32(543),
  28868 	966:  uint32(542),
  28869 	967:  uint32(542),
  28870 	968:  uint32(541),
  28871 	969:  uint32(541),
  28872 	970:  uint32(540),
  28873 	971:  uint32(539),
  28874 	972:  uint32(539),
  28875 	973:  uint32(538),
  28876 	974:  uint32(538),
  28877 	975:  uint32(537),
  28878 	976:  uint32(537),
  28879 	977:  uint32(536),
  28880 	978:  uint32(536),
  28881 	979:  uint32(535),
  28882 	980:  uint32(534),
  28883 	981:  uint32(534),
  28884 	982:  uint32(533),
  28885 	983:  uint32(533),
  28886 	984:  uint32(532),
  28887 	985:  uint32(532),
  28888 	986:  uint32(531),
  28889 	987:  uint32(531),
  28890 	988:  uint32(530),
  28891 	989:  uint32(530),
  28892 	990:  uint32(529),
  28893 	991:  uint32(529),
  28894 	992:  uint32(528),
  28895 	993:  uint32(527),
  28896 	994:  uint32(527),
  28897 	995:  uint32(526),
  28898 	996:  uint32(526),
  28899 	997:  uint32(525),
  28900 	998:  uint32(525),
  28901 	999:  uint32(524),
  28902 	1000: uint32(524),
  28903 	1001: uint32(523),
  28904 	1002: uint32(523),
  28905 	1003: uint32(522),
  28906 	1004: uint32(522),
  28907 	1005: uint32(521),
  28908 	1006: uint32(521),
  28909 	1007: uint32(520),
  28910 	1008: uint32(520),
  28911 	1009: uint32(519),
  28912 	1010: uint32(519),
  28913 	1011: uint32(518),
  28914 	1012: uint32(518),
  28915 	1013: uint32(517),
  28916 	1014: uint32(517),
  28917 	1015: uint32(516),
  28918 	1016: uint32(516),
  28919 	1017: uint32(515),
  28920 	1018: uint32(515),
  28921 	1019: uint32(514),
  28922 	1020: uint32(514),
  28923 }
  28924 
  28925 // Note that LinearToGamma() expects the values to be premultiplied by 4,
  28926 // so we incorporate this factor 4 inside the DIVIDE_BY_ALPHA macro directly.
  28927 
  28928 func LinearToGammaWeighted(tls *libc.TLS, src uintptr, a_ptr uintptr, total_a uint32_t, step int32, rgb_stride int32) (r int32) {
  28929 	var sum uint32_t
  28930 	_ = sum
  28931 	sum = uint32(**(**uint8_t)(__ccgo_up(a_ptr)))*GammaToLinear(tls, **(**uint8_t)(__ccgo_up(src))) + uint32(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(step))))*GammaToLinear(tls, **(**uint8_t)(__ccgo_up(src + uintptr(step)))) + uint32(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(rgb_stride))))*GammaToLinear(tls, **(**uint8_t)(__ccgo_up(src + uintptr(rgb_stride)))) + uint32(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(rgb_stride+step))))*GammaToLinear(tls, **(**uint8_t)(__ccgo_up(src + uintptr(rgb_stride+step))))
  28932 	return LinearToGamma(tls, sum*kInvAlpha[total_a]>>(kAlphaFix-libc.Int32FromInt32(2)), 0)
  28933 }
  28934 
  28935 func ConvertRowToY(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, dst_y uintptr, width int32, rg uintptr) {
  28936 	var i, j int32
  28937 	_, _ = i, j
  28938 	i = 0
  28939 	j = libc.Int32FromInt32(0)
  28940 	for {
  28941 		if !(i < width) {
  28942 			break
  28943 		}
  28944 		**(**uint8_t)(__ccgo_up(dst_y + uintptr(i))) = libc.Uint8FromInt32(RGBToY(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(r_ptr + uintptr(j)))), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(g_ptr + uintptr(j)))), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(b_ptr + uintptr(j)))), rg))
  28945 		goto _1
  28946 	_1:
  28947 		;
  28948 		i = i + int32(1)
  28949 		j = j + step
  28950 	}
  28951 }
  28952 
  28953 func AccumulateRGBA(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, a_ptr uintptr, rgb_stride int32, dst uintptr, width int32) {
  28954 	var a, a1 uint32_t
  28955 	var b, b1, g, g1, i, j, r, r1 int32
  28956 	_, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, g, g1, i, j, r, r1
  28957 	// we loop over 2x2 blocks and produce one R/G/B/A value for each.
  28958 	i = 0
  28959 	j = libc.Int32FromInt32(0)
  28960 	for {
  28961 		if !(i < width>>int32(1)) {
  28962 			break
  28963 		}
  28964 		a = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j) + uintptr(rgb_stride)))) + (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j) + libc.UintptrFromInt32(4)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j) + libc.UintptrFromInt32(4) + uintptr(rgb_stride))))))
  28965 		if a == libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(0xff)) || a == uint32(0) {
  28966 			r = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + 4)))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride+int32(4))))), 0)
  28967 			g = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + 4)))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride+int32(4))))), 0)
  28968 			b = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + 4)))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride+int32(4))))), 0)
  28969 		} else {
  28970 			r = LinearToGammaWeighted(tls, r_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28971 			g = LinearToGammaWeighted(tls, g_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28972 			b = LinearToGammaWeighted(tls, b_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28973 		}
  28974 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(r)
  28975 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(g)
  28976 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(b)
  28977 		**(**uint16_t)(__ccgo_up(dst + 3*2)) = uint16(a)
  28978 		goto _1
  28979 	_1:
  28980 		;
  28981 		i = i + int32(1)
  28982 		j = j + libc.Int32FromInt32(2)*libc.Int32FromInt32(4)
  28983 		dst = dst + uintptr(4)*2
  28984 	}
  28985 	if width&int32(1) != 0 {
  28986 		a1 = uint32(2) * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(j) + uintptr(rgb_stride)))))
  28987 		if a1 == libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(0xff)) || a1 == uint32(0) {
  28988 			r1 = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1))
  28989 			g1 = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1))
  28990 			b1 = LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1))
  28991 		} else {
  28992 			r1 = LinearToGammaWeighted(tls, r_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28993 			g1 = LinearToGammaWeighted(tls, g_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28994 			b1 = LinearToGammaWeighted(tls, b_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28995 		}
  28996 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(r1)
  28997 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(g1)
  28998 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(b1)
  28999 		**(**uint16_t)(__ccgo_up(dst + 3*2)) = uint16(a1)
  29000 	}
  29001 }
  29002 
  29003 func AccumulateRGB(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, rgb_stride int32, dst uintptr, width int32) {
  29004 	var i, j int32
  29005 	_, _ = i, j
  29006 	i = 0
  29007 	j = libc.Int32FromInt32(0)
  29008 	for {
  29009 		if !(i < width>>int32(1)) {
  29010 			break
  29011 		}
  29012 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(step))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride+step)))), 0))
  29013 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(step))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride+step)))), 0))
  29014 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(step))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride+step)))), 0))
  29015 		// MemorySanitizer may raise false positives with data that passes through
  29016 		// RGBA32PackedToPlanar_16b_SSE41() due to incorrect modeling of shuffles.
  29017 		// See https://crbug.com/webp/573.
  29018 		goto _1
  29019 	_1:
  29020 		;
  29021 		i = i + int32(1)
  29022 		j = j + int32(2)*step
  29023 		dst = dst + uintptr(4)*2
  29024 	}
  29025 	if width&int32(1) != 0 {
  29026 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(r_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1)))
  29027 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(g_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1)))
  29028 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(LinearToGamma(tls, GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j))))+GammaToLinear(tls, **(**uint8_t)(__ccgo_up(b_ptr + uintptr(j) + uintptr(rgb_stride)))), int32(1)))
  29029 	}
  29030 }
  29031 
  29032 func ConvertRowsToUV(tls *libc.TLS, rgb uintptr, dst_u uintptr, dst_v uintptr, width int32, rg uintptr) {
  29033 	var b, g, i, r int32
  29034 	_, _, _, _ = b, g, i, r
  29035 	i = 0
  29036 	for {
  29037 		if !(i < width) {
  29038 			break
  29039 		}
  29040 		r = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb)))
  29041 		g = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 1*2)))
  29042 		b = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 2*2)))
  29043 		**(**uint8_t)(__ccgo_up(dst_u + uintptr(i))) = libc.Uint8FromInt32(RGBToU(tls, r, g, b, rg))
  29044 		**(**uint8_t)(__ccgo_up(dst_v + uintptr(i))) = libc.Uint8FromInt32(RGBToV(tls, r, g, b, rg))
  29045 		goto _1
  29046 	_1:
  29047 		;
  29048 		i = i + int32(1)
  29049 		rgb = rgb + uintptr(4)*2
  29050 	}
  29051 }
  29052 
  29053 func ImportYUVAFromRGBA(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, a_ptr uintptr, step int32, rgb_stride int32, dithering float32, use_iterative_conversion int32, picture uintptr) (r int32) {
  29054 	bp := tls.Alloc(240)
  29055 	defer tls.Free(240)
  29056 	var dst_a, dst_u, dst_v, dst_y, rg, tmp_rgb uintptr
  29057 	var has_alpha, height, is_rgb, row_has_alpha, rows_have_alpha, use_dsp, uv_width, width, y, v1 int32
  29058 	var _ /* base_rg at bp+0 */ VP8Random
  29059 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = dst_a, dst_u, dst_v, dst_y, has_alpha, height, is_rgb, rg, row_has_alpha, rows_have_alpha, tmp_rgb, use_dsp, uv_width, width, y, v1
  29060 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29061 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29062 	has_alpha = CheckNonOpaque(tls, a_ptr, width, height, step, rgb_stride)
  29063 	is_rgb = libc.BoolInt32(r_ptr < b_ptr) // otherwise it's bgr
  29064 	if has_alpha != 0 {
  29065 		v1 = int32(WEBP_YUV420A)
  29066 	} else {
  29067 		v1 = int32(WEBP_YUV420)
  29068 	}
  29069 	(*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace = v1
  29070 	(*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb = 0
  29071 	// disable smart conversion if source is too small (overkill).
  29072 	if width < kMinDimensionIterativeConversion || height < kMinDimensionIterativeConversion {
  29073 		use_iterative_conversion = 0
  29074 	}
  29075 	if !(WebPPictureAllocYUVA(tls, picture) != 0) {
  29076 		return 0
  29077 	}
  29078 	if has_alpha != 0 {
  29079 	}
  29080 	if use_iterative_conversion != 0 {
  29081 		SharpYuvInit(tls, VP8GetCPUInfo)
  29082 		if !(PreprocessARGB(tls, r_ptr, g_ptr, b_ptr, step, rgb_stride, picture) != 0) {
  29083 			return 0
  29084 		}
  29085 		if has_alpha != 0 {
  29086 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPExtractAlpha})))(tls, a_ptr, rgb_stride, width, height, (*WebPPicture)(unsafe.Pointer(picture)).Fa, (*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  29087 		}
  29088 	} else {
  29089 		uv_width = (width + int32(1)) >> int32(1)
  29090 		use_dsp = libc.BoolInt32(step == int32(3)) // use special function in this case
  29091 		// temporary storage for accumulated R/G/B values during conversion to U/V
  29092 		tmp_rgb = WebPSafeMalloc(tls, libc.Uint64FromInt32(int32(4)*uv_width), uint64(2))
  29093 		dst_y = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  29094 		dst_u = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  29095 		dst_v = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  29096 		dst_a = (*WebPPicture)(unsafe.Pointer(picture)).Fa
  29097 		rg = libc.UintptrFromInt32(0)
  29098 		if float64(dithering) > float64(0) {
  29099 			VP8InitRandom(tls, bp, dithering)
  29100 			rg = bp
  29101 			use_dsp = 0 // can't use dsp in this case
  29102 		}
  29103 		WebPInitConvertARGBToYUV(tls)
  29104 		InitGammaTables(tls)
  29105 		if tmp_rgb == libc.UintptrFromInt32(0) {
  29106 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29107 		}
  29108 		// Downsample Y/U/V planes, two rows at a time
  29109 		y = 0
  29110 		for {
  29111 			if !(y < height>>libc.Int32FromInt32(1)) {
  29112 				break
  29113 			}
  29114 			rows_have_alpha = has_alpha
  29115 			if use_dsp != 0 {
  29116 				if is_rgb != 0 {
  29117 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGB24ToY})))(tls, r_ptr, dst_y, width)
  29118 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGB24ToY})))(tls, r_ptr+uintptr(rgb_stride), dst_y+uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride), width)
  29119 				} else {
  29120 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertBGR24ToY})))(tls, b_ptr, dst_y, width)
  29121 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertBGR24ToY})))(tls, b_ptr+uintptr(rgb_stride), dst_y+uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride), width)
  29122 				}
  29123 			} else {
  29124 				ConvertRowToY(tls, r_ptr, g_ptr, b_ptr, step, dst_y, width, rg)
  29125 				ConvertRowToY(tls, r_ptr+uintptr(rgb_stride), g_ptr+uintptr(rgb_stride), b_ptr+uintptr(rgb_stride), step, dst_y+uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride), width, rg)
  29126 			}
  29127 			dst_y = dst_y + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29128 			if has_alpha != 0 {
  29129 				rows_have_alpha = rows_have_alpha & libc.BoolInt32(!((*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPExtractAlpha})))(tls, a_ptr, rgb_stride, width, int32(2), dst_a, (*WebPPicture)(unsafe.Pointer(picture)).Fa_stride) != 0))
  29130 				dst_a = dst_a + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  29131 			}
  29132 			// Collect averaged R/G/B(/A)
  29133 			if !(rows_have_alpha != 0) {
  29134 				AccumulateRGB(tls, r_ptr, g_ptr, b_ptr, step, rgb_stride, tmp_rgb, width)
  29135 			} else {
  29136 				AccumulateRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, rgb_stride, tmp_rgb, width)
  29137 			}
  29138 			// Convert to U/V
  29139 			if rg == libc.UintptrFromInt32(0) {
  29140 				(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGBA32ToUV})))(tls, tmp_rgb, dst_u, dst_v, uv_width)
  29141 			} else {
  29142 				ConvertRowsToUV(tls, tmp_rgb, dst_u, dst_v, uv_width, rg)
  29143 			}
  29144 			dst_u = dst_u + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29145 			dst_v = dst_v + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29146 			r_ptr = r_ptr + uintptr(int32(2)*rgb_stride)
  29147 			b_ptr = b_ptr + uintptr(int32(2)*rgb_stride)
  29148 			g_ptr = g_ptr + uintptr(int32(2)*rgb_stride)
  29149 			if has_alpha != 0 {
  29150 				a_ptr = a_ptr + uintptr(int32(2)*rgb_stride)
  29151 			}
  29152 			goto _2
  29153 		_2:
  29154 			;
  29155 			y = y + 1
  29156 		}
  29157 		if height&int32(1) != 0 { // extra last row
  29158 			row_has_alpha = has_alpha
  29159 			if use_dsp != 0 {
  29160 				if r_ptr < b_ptr {
  29161 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGB24ToY})))(tls, r_ptr, dst_y, width)
  29162 				} else {
  29163 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertBGR24ToY})))(tls, b_ptr, dst_y, width)
  29164 				}
  29165 			} else {
  29166 				ConvertRowToY(tls, r_ptr, g_ptr, b_ptr, step, dst_y, width, rg)
  29167 			}
  29168 			if row_has_alpha != 0 {
  29169 				row_has_alpha = row_has_alpha & libc.BoolInt32(!((*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPExtractAlpha})))(tls, a_ptr, 0, width, int32(1), dst_a, 0) != 0))
  29170 			}
  29171 			// Collect averaged R/G/B(/A)
  29172 			if !(row_has_alpha != 0) {
  29173 				// Collect averaged R/G/B
  29174 				AccumulateRGB(tls, r_ptr, g_ptr, b_ptr, step, 0, tmp_rgb, width)
  29175 			} else {
  29176 				AccumulateRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, 0, tmp_rgb, width)
  29177 			}
  29178 			if rg == libc.UintptrFromInt32(0) {
  29179 				(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGBA32ToUV})))(tls, tmp_rgb, dst_u, dst_v, uv_width)
  29180 			} else {
  29181 				ConvertRowsToUV(tls, tmp_rgb, dst_u, dst_v, uv_width, rg)
  29182 			}
  29183 		}
  29184 		WebPSafeFree(tls, tmp_rgb)
  29185 	}
  29186 	return int32(1)
  29187 }
  29188 
  29189 //------------------------------------------------------------------------------
  29190 // call for ARGB->YUVA conversion
  29191 
  29192 func PictureARGBToYUVA(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1, dithering float32, use_iterative_conversion int32) (r1 int32) {
  29193 	var a, argb, b, g, r uintptr
  29194 	_, _, _, _, _ = a, argb, b, g, r
  29195 	if picture == libc.UintptrFromInt32(0) {
  29196 		return 0
  29197 	}
  29198 	if (*WebPPicture)(unsafe.Pointer(picture)).Fargb == libc.UintptrFromInt32(0) {
  29199 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29200 	} else {
  29201 		if colorspace&int32(WEBP_CSP_UV_MASK) != int32(WEBP_YUV420) {
  29202 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29203 		} else {
  29204 			argb = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29205 			a = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(0))
  29206 			r = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(1))
  29207 			g = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(2))
  29208 			b = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(3))
  29209 			(*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace = int32(WEBP_YUV420)
  29210 			return ImportYUVAFromRGBA(tls, r, g, b, a, int32(4), int32(4)*(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride, dithering, use_iterative_conversion, picture)
  29211 		}
  29212 	}
  29213 	return r1
  29214 }
  29215 
  29216 func WebPPictureARGBToYUVADithered(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1, dithering float32) (r int32) {
  29217 	return PictureARGBToYUVA(tls, picture, colorspace, dithering, 0)
  29218 }
  29219 
  29220 func WebPPictureARGBToYUVA(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1) (r int32) {
  29221 	return PictureARGBToYUVA(tls, picture, colorspace, libc.Float32FromFloat32(0), 0)
  29222 }
  29223 
  29224 func WebPPictureSharpARGBToYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29225 	return PictureARGBToYUVA(tls, picture, int32(WEBP_YUV420), libc.Float32FromFloat32(0), int32(1))
  29226 }
  29227 
  29228 // C documentation
  29229 //
  29230 //	// for backward compatibility
  29231 func WebPPictureSmartARGBToYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29232 	return WebPPictureSharpARGBToYUVA(tls, picture)
  29233 }
  29234 
  29235 //------------------------------------------------------------------------------
  29236 // call for YUVA -> ARGB conversion
  29237 
  29238 func WebPPictureYUVAToARGB(tls *libc.TLS, picture uintptr) (r int32) {
  29239 	var argb_dst, cur_u, cur_v, cur_y, dst, src, top_u, top_v uintptr
  29240 	var argb_stride, height, width, x, y int32
  29241 	var upsample WebPUpsampleLinePairFunc
  29242 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = argb_dst, argb_stride, cur_u, cur_v, cur_y, dst, height, src, top_u, top_v, upsample, width, x, y
  29243 	if picture == libc.UintptrFromInt32(0) {
  29244 		return 0
  29245 	}
  29246 	if (*WebPPicture)(unsafe.Pointer(picture)).Fy == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(picture)).Fu == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(picture)).Fv == libc.UintptrFromInt32(0) {
  29247 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29248 	}
  29249 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_ALPHA_BIT) != 0 && (*WebPPicture)(unsafe.Pointer(picture)).Fa == libc.UintptrFromInt32(0) {
  29250 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29251 	}
  29252 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_UV_MASK) != int32(WEBP_YUV420) {
  29253 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29254 	}
  29255 	// Allocate a new argb buffer (discarding the previous one).
  29256 	if !(WebPPictureAllocARGB(tls, picture) != 0) {
  29257 		return 0
  29258 	}
  29259 	(*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb = int32(1)
  29260 	// Convert
  29261 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29262 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29263 	argb_stride = int32(4) * (*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride
  29264 	dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29265 	cur_u = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  29266 	cur_v = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  29267 	cur_y = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  29268 	upsample = WebPGetLinePairConverter(tls, libc.BoolInt32(libc.Int32FromInt32(3)-libc.Int32FromInt32(0) > 0))
  29269 	// First row, with replicated top samples.
  29270 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y, libc.UintptrFromInt32(0), cur_u, cur_v, cur_u, cur_v, dst, libc.UintptrFromInt32(0), width)
  29271 	cur_y = cur_y + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29272 	dst = dst + uintptr(argb_stride)
  29273 	// Center rows.
  29274 	y = int32(1)
  29275 	for {
  29276 		if !(y+int32(1) < height) {
  29277 			break
  29278 		}
  29279 		top_u = cur_u
  29280 		top_v = cur_v
  29281 		cur_u = cur_u + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29282 		cur_v = cur_v + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29283 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y, cur_y+uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride), top_u, top_v, cur_u, cur_v, dst, dst+uintptr(argb_stride), width)
  29284 		cur_y = cur_y + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29285 		dst = dst + uintptr(int32(2)*argb_stride)
  29286 		goto _1
  29287 	_1:
  29288 		;
  29289 		y = y + int32(2)
  29290 	}
  29291 	// Last row (if needed), with replicated bottom samples.
  29292 	if height > int32(1) && !(height&libc.Int32FromInt32(1) != 0) {
  29293 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{upsample})))(tls, cur_y, libc.UintptrFromInt32(0), cur_u, cur_v, cur_u, cur_v, dst, libc.UintptrFromInt32(0), width)
  29294 	}
  29295 	// Insert alpha values if needed, in replacement for the default 0xff ones.
  29296 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_ALPHA_BIT) != 0 {
  29297 		y = 0
  29298 		for {
  29299 			if !(y < height) {
  29300 				break
  29301 			}
  29302 			argb_dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb + uintptr(y*(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29303 			src = (*WebPPicture)(unsafe.Pointer(picture)).Fa + uintptr(y*(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  29304 			x = 0
  29305 			for {
  29306 				if !(x < width) {
  29307 					break
  29308 				}
  29309 				**(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4)) = **(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4))&uint32(0x00ffffff) | uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x))))<<libc.Int32FromInt32(24)
  29310 				goto _3
  29311 			_3:
  29312 				;
  29313 				x = x + 1
  29314 			}
  29315 			goto _2
  29316 		_2:
  29317 			;
  29318 			y = y + 1
  29319 		}
  29320 	}
  29321 	return int32(1)
  29322 }
  29323 
  29324 //------------------------------------------------------------------------------
  29325 // automatic import / conversion
  29326 
  29327 func Import(tls *libc.TLS, picture uintptr, rgb uintptr, rgb_stride int32, step int32, swap_rb int32, import_alpha int32) (r int32) {
  29328 	var a_ptr, b_ptr, dst, dst1, g_ptr, r_ptr, v4 uintptr
  29329 	var do_copy, height, width, y, v1, v2, v3 int32
  29330 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_ptr, b_ptr, do_copy, dst, dst1, g_ptr, height, r_ptr, width, y, v1, v2, v3, v4
  29331 	if swap_rb != 0 {
  29332 		v1 = int32(2)
  29333 	} else {
  29334 		v1 = 0
  29335 	}
  29336 	// swap_rb -> b,g,r,a , !swap_rb -> r,g,b,a
  29337 	r_ptr = rgb + uintptr(v1)
  29338 	g_ptr = rgb + uintptr(1)
  29339 	if swap_rb != 0 {
  29340 		v2 = 0
  29341 	} else {
  29342 		v2 = int32(2)
  29343 	}
  29344 	b_ptr = rgb + uintptr(v2)
  29345 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29346 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29347 	if import_alpha != 0 {
  29348 		v3 = int32(4)
  29349 	} else {
  29350 		v3 = int32(3)
  29351 	}
  29352 	if libc.Xabs(tls, rgb_stride) < v3*width {
  29353 		return 0
  29354 	}
  29355 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  29356 		if import_alpha != 0 {
  29357 			v4 = rgb + uintptr(3)
  29358 		} else {
  29359 			v4 = libc.UintptrFromInt32(0)
  29360 		}
  29361 		a_ptr = v4
  29362 		return ImportYUVAFromRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride, libc.Float32FromFloat32(0), 0, picture)
  29363 	}
  29364 	if !(WebPPictureAlloc(tls, picture) != 0) {
  29365 		return 0
  29366 	}
  29367 	VP8LDspInit(tls)
  29368 	WebPInitAlphaProcessing(tls)
  29369 	if import_alpha != 0 {
  29370 		// dst[] byte order is {a,r,g,b} for big-endian, {b,g,r,a} for little endian
  29371 		dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29372 		do_copy = libc.BoolInt32(libc.Bool(libc.Int32FromInt32(3)-libc.Int32FromInt32(0) == int32(3)) && swap_rb != 0)
  29373 		if do_copy != 0 {
  29374 			y = 0
  29375 			for {
  29376 				if !(y < height) {
  29377 					break
  29378 				}
  29379 				libc.X__builtin___memcpy_chk(tls, dst, rgb, libc.Uint64FromInt32(width*int32(4)), ^__predefined_size_t(0))
  29380 				rgb = rgb + uintptr(rgb_stride)
  29381 				dst = dst + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29382 				goto _5
  29383 			_5:
  29384 				;
  29385 				y = y + 1
  29386 			}
  29387 		} else {
  29388 			y = 0
  29389 			for {
  29390 				if !(y < height) {
  29391 					break
  29392 				}
  29393 				// RGBA input order. Need to swap R and B.
  29394 				(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, rgb, width, dst)
  29395 				rgb = rgb + uintptr(rgb_stride)
  29396 				dst = dst + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29397 				goto _6
  29398 			_6:
  29399 				;
  29400 				y = y + 1
  29401 			}
  29402 		}
  29403 	} else {
  29404 		dst1 = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29405 		y = 0
  29406 		for {
  29407 			if !(y < height) {
  29408 				break
  29409 			}
  29410 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPPackRGB})))(tls, r_ptr, g_ptr, b_ptr, width, step, dst1)
  29411 			r_ptr = r_ptr + uintptr(rgb_stride)
  29412 			g_ptr = g_ptr + uintptr(rgb_stride)
  29413 			b_ptr = b_ptr + uintptr(rgb_stride)
  29414 			dst1 = dst1 + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29415 			goto _7
  29416 		_7:
  29417 			;
  29418 			y = y + 1
  29419 		}
  29420 	}
  29421 	return int32(1)
  29422 }
  29423 
  29424 // Public API
  29425 
  29426 func WebPPictureImportBGR(tls *libc.TLS, picture uintptr, bgr uintptr, bgr_stride int32) (r int32) {
  29427 	var v1 int32
  29428 	_ = v1
  29429 	if picture != libc.UintptrFromInt32(0) && bgr != libc.UintptrFromInt32(0) {
  29430 		v1 = Import(tls, picture, bgr, bgr_stride, int32(3), int32(1), 0)
  29431 	} else {
  29432 		v1 = 0
  29433 	}
  29434 	return v1
  29435 }
  29436 
  29437 func WebPPictureImportBGRA(tls *libc.TLS, picture uintptr, bgra uintptr, bgra_stride int32) (r int32) {
  29438 	var v1 int32
  29439 	_ = v1
  29440 	if picture != libc.UintptrFromInt32(0) && bgra != libc.UintptrFromInt32(0) {
  29441 		v1 = Import(tls, picture, bgra, bgra_stride, int32(4), int32(1), int32(1))
  29442 	} else {
  29443 		v1 = 0
  29444 	}
  29445 	return v1
  29446 }
  29447 
  29448 func WebPPictureImportBGRX(tls *libc.TLS, picture uintptr, bgrx uintptr, bgrx_stride int32) (r int32) {
  29449 	var v1 int32
  29450 	_ = v1
  29451 	if picture != libc.UintptrFromInt32(0) && bgrx != libc.UintptrFromInt32(0) {
  29452 		v1 = Import(tls, picture, bgrx, bgrx_stride, int32(4), int32(1), 0)
  29453 	} else {
  29454 		v1 = 0
  29455 	}
  29456 	return v1
  29457 }
  29458 
  29459 func WebPPictureImportRGB(tls *libc.TLS, picture uintptr, rgb uintptr, rgb_stride int32) (r int32) {
  29460 	var v1 int32
  29461 	_ = v1
  29462 	if picture != libc.UintptrFromInt32(0) && rgb != libc.UintptrFromInt32(0) {
  29463 		v1 = Import(tls, picture, rgb, rgb_stride, int32(3), 0, 0)
  29464 	} else {
  29465 		v1 = 0
  29466 	}
  29467 	return v1
  29468 }
  29469 
  29470 func WebPPictureImportRGBA(tls *libc.TLS, picture uintptr, rgba uintptr, rgba_stride int32) (r int32) {
  29471 	var v1 int32
  29472 	_ = v1
  29473 	if picture != libc.UintptrFromInt32(0) && rgba != libc.UintptrFromInt32(0) {
  29474 		v1 = Import(tls, picture, rgba, rgba_stride, int32(4), 0, int32(1))
  29475 	} else {
  29476 		v1 = 0
  29477 	}
  29478 	return v1
  29479 }
  29480 
  29481 func WebPPictureImportRGBX(tls *libc.TLS, picture uintptr, rgbx uintptr, rgbx_stride int32) (r int32) {
  29482 	var v1 int32
  29483 	_ = v1
  29484 	if picture != libc.UintptrFromInt32(0) && rgbx != libc.UintptrFromInt32(0) {
  29485 		v1 = Import(tls, picture, rgbx, rgbx_stride, int32(4), 0, 0)
  29486 	} else {
  29487 		v1 = 0
  29488 	}
  29489 	return v1
  29490 }
  29491 
  29492 const BC_BASE_MAX = 99
  29493 const BC_DIM_MAX = 2048
  29494 const BC_SCALE_MAX = 99
  29495 const BC_STRING_MAX = 1000
  29496 const BITINT_MAXWIDTH = "__BITINT_MAXWIDTH__"
  29497 const BOOL_WIDTH = "__BOOL_WIDTH__"
  29498 const CHARCLASS_NAME_MAX = 14
  29499 const CHAR_WIDTH = "CHAR_BIT"
  29500 const CHILD_MAX = 266
  29501 const CLK_TCK = "__DARWIN_CLK_TCK"
  29502 const COLL_WEIGHTS_MAX = 2
  29503 const EQUIV_CLASS_MAX = 2
  29504 const EXPR_NEST_MAX = 32
  29505 const GID_MAX = 2147483647
  29506 const INT_WIDTH = "__INT_WIDTH__"
  29507 const IOV_MAX = 1024
  29508 const LINE_MAX = 2048
  29509 const LINK_MAX = 32767
  29510 const LLONG_WIDTH = "__LLONG_WIDTH__"
  29511 const LONG_BIT = 64
  29512 const LONG_WIDTH = "__LONG_WIDTH__"
  29513 const LOSSLESS_DEFAULT_QUALITY = 70
  29514 const MAX_CANON = 1024
  29515 const MAX_INPUT = 1024
  29516 const NAME_MAX = 255
  29517 const NGROUPS_MAX = 16
  29518 const NL_ARGMAX = 9
  29519 const NL_LANGMAX = 14
  29520 const NL_MSGMAX = 32767
  29521 const NL_NMAX = 1
  29522 const NL_SETMAX = 255
  29523 const NL_TEXTMAX = 2048
  29524 const NZERO = 20
  29525 const OFF_MAX = "LLONG_MAX"
  29526 const OFF_MIN = "LLONG_MIN"
  29527 const OPEN_MAX = 10240
  29528 const PASS_MAX = 128
  29529 const PATH_MAX = 1024
  29530 const PIPE_BUF = 512
  29531 const PTHREAD_DESTRUCTOR_ITERATIONS = 4
  29532 const PTHREAD_KEYS_MAX = 512
  29533 const PTHREAD_STACK_MIN = 8192
  29534 const QUAD_MAX = "LLONG_MAX"
  29535 const QUAD_MIN = "LLONG_MIN"
  29536 const RE_DUP_MAX = 255
  29537 const SCHAR_WIDTH = "CHAR_BIT"
  29538 const SHRT_WIDTH = "__SHRT_WIDTH__"
  29539 const SIZE_T_MAX = "ULONG_MAX"
  29540 const SSIZE_MAX = "LONG_MAX"
  29541 const UCHAR_WIDTH = "CHAR_BIT"
  29542 const UID_MAX = 2147483647
  29543 const UINT_WIDTH = "__INT_WIDTH__"
  29544 const ULLONG_WIDTH = "__LLONG_WIDTH__"
  29545 const ULONG_WIDTH = "__LONG_WIDTH__"
  29546 const UQUAD_MAX = "ULLONG_MAX"
  29547 const USHRT_WIDTH = "__SHRT_WIDTH__"
  29548 const WORD_BIT = 32
  29549 const _POSIX2_BC_BASE_MAX = 99
  29550 const _POSIX2_BC_DIM_MAX = 2048
  29551 const _POSIX2_BC_SCALE_MAX = 99
  29552 const _POSIX2_BC_STRING_MAX = 1000
  29553 const _POSIX2_CHARCLASS_NAME_MAX = 14
  29554 const _POSIX2_COLL_WEIGHTS_MAX = 2
  29555 const _POSIX2_EQUIV_CLASS_MAX = 2
  29556 const _POSIX2_EXPR_NEST_MAX = 32
  29557 const _POSIX2_LINE_MAX = 2048
  29558 const _POSIX2_RE_DUP_MAX = 255
  29559 const _POSIX_AIO_LISTIO_MAX = 2
  29560 const _POSIX_AIO_MAX = 1
  29561 const _POSIX_ARG_MAX = 4096
  29562 const _POSIX_CHILD_MAX = 25
  29563 const _POSIX_CLOCKRES_MIN = 20000000
  29564 const _POSIX_DELAYTIMER_MAX = 32
  29565 const _POSIX_HOST_NAME_MAX = 255
  29566 const _POSIX_LINK_MAX = 8
  29567 const _POSIX_LOGIN_NAME_MAX = 9
  29568 const _POSIX_MAX_CANON = 255
  29569 const _POSIX_MAX_INPUT = 255
  29570 const _POSIX_MQ_OPEN_MAX = 8
  29571 const _POSIX_MQ_PRIO_MAX = 32
  29572 const _POSIX_NAME_MAX = 14
  29573 const _POSIX_NGROUPS_MAX = 8
  29574 const _POSIX_OPEN_MAX = 20
  29575 const _POSIX_PATH_MAX = 256
  29576 const _POSIX_PIPE_BUF = 512
  29577 const _POSIX_RE_DUP_MAX = "_POSIX2_RE_DUP_MAX"
  29578 const _POSIX_RTSIG_MAX = 8
  29579 const _POSIX_SEM_NSEMS_MAX = 256
  29580 const _POSIX_SEM_VALUE_MAX = 32767
  29581 const _POSIX_SIGQUEUE_MAX = 32
  29582 const _POSIX_SSIZE_MAX = 32767
  29583 const _POSIX_SS_REPL_MAX = 4
  29584 const _POSIX_STREAM_MAX = 8
  29585 const _POSIX_SYMLINK_MAX = 255
  29586 const _POSIX_SYMLOOP_MAX = 8
  29587 const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4
  29588 const _POSIX_THREAD_KEYS_MAX = 128
  29589 const _POSIX_THREAD_THREADS_MAX = 64
  29590 const _POSIX_TIMER_MAX = 32
  29591 const _POSIX_TRACE_EVENT_NAME_MAX = 30
  29592 const _POSIX_TRACE_NAME_MAX = 8
  29593 const _POSIX_TRACE_SYS_MAX = 8
  29594 const _POSIX_TRACE_USER_EVENT_MAX = 32
  29595 const _POSIX_TTY_NAME_MAX = 9
  29596 const _POSIX_TZNAME_MAX = 6
  29597 const _XOPEN_IOV_MAX = 16
  29598 const _XOPEN_NAME_MAX = 255
  29599 const _XOPEN_PATH_MAX = 1024
  29600 const __DARWIN_CLK_TCK = 100
  29601 const __FLT_MIN__4 = 1.17549435082228750796873653722224568e-38
  29602 const __INT_MAX__1 = 2147483647
  29603 
  29604 //------------------------------------------------------------------------------
  29605 
  29606 // Copyright 2012 Google Inc. All Rights Reserved.
  29607 //
  29608 // Use of this source code is governed by a BSD-style license
  29609 // that can be found in the COPYING file in the root of the source
  29610 // tree. An additional intellectual property rights grant can be found
  29611 // in the file PATENTS. All contributing project authors may
  29612 // be found in the AUTHORS file in the root of the source tree.
  29613 // -----------------------------------------------------------------------------
  29614 //
  29615 // Misc. common utility functions
  29616 //
  29617 // Authors: Skal (pascal.massimino@gmail.com)
  29618 //          Urvang (urvang@google.com)
  29619 
  29620 // Copyright 2011 Google Inc. All Rights Reserved.
  29621 //
  29622 // Use of this source code is governed by a BSD-style license
  29623 // that can be found in the COPYING file in the root of the source
  29624 // tree. An additional intellectual property rights grant can be found
  29625 // in the file PATENTS. All contributing project authors may
  29626 // be found in the AUTHORS file in the root of the source tree.
  29627 // -----------------------------------------------------------------------------
  29628 //
  29629 //   WebP encoder: main interface
  29630 //
  29631 // Author: Skal (pascal.massimino@gmail.com)
  29632 
  29633 // Copyright 2010 Google Inc. All Rights Reserved.
  29634 //
  29635 // Use of this source code is governed by a BSD-style license
  29636 // that can be found in the COPYING file in the root of the source
  29637 // tree. An additional intellectual property rights grant can be found
  29638 // in the file PATENTS. All contributing project authors may
  29639 // be found in the AUTHORS file in the root of the source tree.
  29640 // -----------------------------------------------------------------------------
  29641 //
  29642 //  Common types + memory wrappers
  29643 //
  29644 // Author: Skal (pascal.massimino@gmail.com)
  29645 
  29646 //------------------------------------------------------------------------------
  29647 // WebPPicture
  29648 //------------------------------------------------------------------------------
  29649 
  29650 func DummyWriter(tls *libc.TLS, data uintptr, data_size size_t, picture uintptr) (r int32) {
  29651 	// The following are to prevent 'unused variable' error message.
  29652 	_ = data
  29653 	_ = data_size
  29654 	_ = picture
  29655 	return int32(1)
  29656 }
  29657 
  29658 func WebPPictureInitInternal(tls *libc.TLS, picture uintptr, version int32) (r int32) {
  29659 	if version>>int32(8) != libc.Int32FromInt32(WEBP_ENCODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  29660 		return 0 // caller/system version mismatch!
  29661 	}
  29662 	if picture != libc.UintptrFromInt32(0) {
  29663 		libc.X__builtin___memset_chk(tls, picture, 0, uint64(256), ^__predefined_size_t(0))
  29664 		(*WebPPicture)(unsafe.Pointer(picture)).Fwriter = __ccgo_fp(DummyWriter)
  29665 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_OK))
  29666 	}
  29667 	return int32(1)
  29668 }
  29669 
  29670 //------------------------------------------------------------------------------
  29671 
  29672 func WebPValidatePicture(tls *libc.TLS, picture uintptr) (r int32) {
  29673 	if picture == libc.UintptrFromInt32(0) {
  29674 		return 0
  29675 	}
  29676 	if (*WebPPicture)(unsafe.Pointer(picture)).Fwidth <= 0 || (*WebPPicture)(unsafe.Pointer(picture)).Fheight <= 0 {
  29677 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29678 	}
  29679 	if (*WebPPicture)(unsafe.Pointer(picture)).Fwidth <= 0 || (*WebPPicture)(unsafe.Pointer(picture)).Fwidth/int32(4) > libc.Int32FromInt32(__INT_MAX__1)/libc.Int32FromInt32(4) || (*WebPPicture)(unsafe.Pointer(picture)).Fheight <= 0 || (*WebPPicture)(unsafe.Pointer(picture)).Fheight/int32(4) > libc.Int32FromInt32(__INT_MAX__1)/libc.Int32FromInt32(4) {
  29680 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29681 	}
  29682 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace != int32(WEBP_YUV420) && (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace != int32(WEBP_YUV420A) {
  29683 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29684 	}
  29685 	return int32(1)
  29686 }
  29687 
  29688 func WebPPictureResetBufferARGB(tls *libc.TLS, picture uintptr) {
  29689 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ = libc.UintptrFromInt32(0)
  29690 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb = libc.UintptrFromInt32(0)
  29691 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride = 0
  29692 }
  29693 
  29694 func WebPPictureResetBufferYUVA(tls *libc.TLS, picture uintptr) {
  29695 	var v1, v2, v3 uintptr
  29696 	var v4 int32
  29697 	_, _, _, _ = v1, v2, v3, v4
  29698 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ = libc.UintptrFromInt32(0)
  29699 	v3 = libc.UintptrFromInt32(0)
  29700 	(*WebPPicture)(unsafe.Pointer(picture)).Fa = v3
  29701 	v2 = v3
  29702 	(*WebPPicture)(unsafe.Pointer(picture)).Fv = v2
  29703 	v1 = v2
  29704 	(*WebPPicture)(unsafe.Pointer(picture)).Fu = v1
  29705 	(*WebPPicture)(unsafe.Pointer(picture)).Fy = v1
  29706 	v4 = libc.Int32FromInt32(0)
  29707 	(*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride = v4
  29708 	(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride = v4
  29709 	(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride = 0
  29710 }
  29711 
  29712 func WebPPictureResetBuffers(tls *libc.TLS, picture uintptr) {
  29713 	WebPPictureResetBufferARGB(tls, picture)
  29714 	WebPPictureResetBufferYUVA(tls, picture)
  29715 }
  29716 
  29717 func WebPPictureAllocARGB(tls *libc.TLS, picture uintptr) (r int32) {
  29718 	var argb_size uint64_t
  29719 	var height, width int32
  29720 	var memory uintptr
  29721 	_, _, _, _ = argb_size, height, memory, width
  29722 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29723 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29724 	argb_size = libc.Uint64FromInt32(width) * libc.Uint64FromInt32(height)
  29725 	if !(WebPValidatePicture(tls, picture) != 0) {
  29726 		return 0
  29727 	}
  29728 	WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_)
  29729 	WebPPictureResetBufferARGB(tls, picture)
  29730 	// allocate a new buffer.
  29731 	memory = WebPSafeMalloc(tls, argb_size+uint64(WEBP_ALIGN_CST), uint64(4))
  29732 	if memory == libc.UintptrFromInt32(0) {
  29733 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29734 	}
  29735 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ = memory
  29736 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb = uintptr((uint64(memory) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  29737 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride = width
  29738 	return int32(1)
  29739 }
  29740 
  29741 func WebPPictureAllocYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29742 	var a_size, total_size, uv_size, y_size uint64_t
  29743 	var a_stride, a_width, has_alpha, height, uv_height, uv_stride, uv_width, width, y_stride, v1 int32
  29744 	var mem uintptr
  29745 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_size, a_stride, a_width, has_alpha, height, mem, total_size, uv_height, uv_size, uv_stride, uv_width, width, y_size, y_stride, v1
  29746 	has_alpha = (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace & int32(WEBP_CSP_ALPHA_BIT)
  29747 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29748 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29749 	y_stride = width
  29750 	uv_width = int32((int64(width) + libc.Int64FromInt32(1)) >> libc.Int32FromInt32(1))
  29751 	uv_height = int32((int64(height) + libc.Int64FromInt32(1)) >> libc.Int32FromInt32(1))
  29752 	uv_stride = uv_width
  29753 	if !(WebPValidatePicture(tls, picture) != 0) {
  29754 		return 0
  29755 	}
  29756 	WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_)
  29757 	WebPPictureResetBufferYUVA(tls, picture)
  29758 	// alpha
  29759 	if has_alpha != 0 {
  29760 		v1 = width
  29761 	} else {
  29762 		v1 = 0
  29763 	}
  29764 	a_width = v1
  29765 	a_stride = a_width
  29766 	y_size = libc.Uint64FromInt32(y_stride) * libc.Uint64FromInt32(height)
  29767 	uv_size = libc.Uint64FromInt32(uv_stride) * libc.Uint64FromInt32(uv_height)
  29768 	a_size = libc.Uint64FromInt32(a_stride) * libc.Uint64FromInt32(height)
  29769 	total_size = y_size + a_size + uint64(2)*uv_size
  29770 	// Security and validation checks
  29771 	if width <= 0 || height <= 0 || uv_width <= 0 || uv_height <= 0 { // u/v param error
  29772 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29773 	}
  29774 	// allocate a new buffer.
  29775 	mem = WebPSafeMalloc(tls, total_size, uint64(1))
  29776 	if mem == libc.UintptrFromInt32(0) {
  29777 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29778 	}
  29779 	// From now on, we're in the clear, we can no longer fail...
  29780 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ = mem
  29781 	(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride = y_stride
  29782 	(*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride = uv_stride
  29783 	(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride = a_stride
  29784 	// TODO(skal): we could align the y/u/v planes and adjust stride.
  29785 	(*WebPPicture)(unsafe.Pointer(picture)).Fy = mem
  29786 	mem = mem + uintptr(y_size)
  29787 	(*WebPPicture)(unsafe.Pointer(picture)).Fu = mem
  29788 	mem = mem + uintptr(uv_size)
  29789 	(*WebPPicture)(unsafe.Pointer(picture)).Fv = mem
  29790 	mem = mem + uintptr(uv_size)
  29791 	if a_size > uint64(0) {
  29792 		(*WebPPicture)(unsafe.Pointer(picture)).Fa = mem
  29793 		mem = mem + uintptr(a_size)
  29794 	}
  29795 	_ = mem // makes the static analyzer happy
  29796 	return int32(1)
  29797 }
  29798 
  29799 func WebPPictureAlloc(tls *libc.TLS, picture uintptr) (r int32) {
  29800 	if picture != libc.UintptrFromInt32(0) {
  29801 		WebPPictureFree(tls, picture) // erase previous buffer
  29802 		if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  29803 			return WebPPictureAllocYUVA(tls, picture)
  29804 		} else {
  29805 			return WebPPictureAllocARGB(tls, picture)
  29806 		}
  29807 	}
  29808 	return int32(1)
  29809 }
  29810 
  29811 func WebPPictureFree(tls *libc.TLS, picture uintptr) {
  29812 	if picture != libc.UintptrFromInt32(0) {
  29813 		WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_)
  29814 		WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_)
  29815 		WebPPictureResetBuffers(tls, picture)
  29816 	}
  29817 }
  29818 
  29819 //------------------------------------------------------------------------------
  29820 // WebPMemoryWriter: Write-to-memory
  29821 
  29822 func WebPMemoryWriterInit(tls *libc.TLS, writer uintptr) {
  29823 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmem = libc.UintptrFromInt32(0)
  29824 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fsize = uint64(0)
  29825 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmax_size = uint64(0)
  29826 }
  29827 
  29828 func WebPMemoryWrite(tls *libc.TLS, data uintptr, data_size size_t, picture uintptr) (r int32) {
  29829 	var new_mem, w uintptr
  29830 	var next_max_size, next_size uint64_t
  29831 	_, _, _, _ = new_mem, next_max_size, next_size, w
  29832 	w = (*WebPPicture)(unsafe.Pointer(picture)).Fcustom_ptr
  29833 	if w == libc.UintptrFromInt32(0) {
  29834 		return int32(1)
  29835 	}
  29836 	next_size = (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize + data_size
  29837 	if next_size > (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size {
  29838 		next_max_size = uint64(2) * (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size
  29839 		if next_max_size < next_size {
  29840 			next_max_size = next_size
  29841 		}
  29842 		if next_max_size < uint64(8192) {
  29843 			next_max_size = uint64(8192)
  29844 		}
  29845 		new_mem = WebPSafeMalloc(tls, next_max_size, uint64(1))
  29846 		if new_mem == libc.UintptrFromInt32(0) {
  29847 			return 0
  29848 		}
  29849 		if (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize > uint64(0) {
  29850 			libc.X__builtin___memcpy_chk(tls, new_mem, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize, ^__predefined_size_t(0))
  29851 		}
  29852 		WebPSafeFree(tls, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem)
  29853 		(*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem = new_mem
  29854 		// down-cast is ok, thanks to WebPSafeMalloc
  29855 		(*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size = next_max_size
  29856 	}
  29857 	if data_size > uint64(0) {
  29858 		libc.X__builtin___memcpy_chk(tls, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem+uintptr((*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize), data, data_size, ^__predefined_size_t(0))
  29859 		**(**size_t)(__ccgo_up(w + 8)) += data_size
  29860 	}
  29861 	return int32(1)
  29862 }
  29863 
  29864 func WebPMemoryWriterClear(tls *libc.TLS, writer uintptr) {
  29865 	if writer != libc.UintptrFromInt32(0) {
  29866 		WebPSafeFree(tls, (*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmem)
  29867 		WebPMemoryWriterInit(tls, writer)
  29868 	}
  29869 }
  29870 
  29871 //------------------------------------------------------------------------------
  29872 // Simplest high-level calls:
  29873 
  29874 type Importer = uintptr
  29875 
  29876 func Encode(tls *libc.TLS, rgba uintptr, width int32, height int32, stride int32, __ccgo_fp_import Importer, quality_factor float32, lossless int32, output uintptr) (r size_t) {
  29877 	bp := tls.Alloc(416)
  29878 	defer tls.Free(416)
  29879 	var ok, v1, v3 int32
  29880 	var v5 bool
  29881 	var _ /* config at bp+256 */ WebPConfig
  29882 	var _ /* pic at bp+0 */ WebPPicture
  29883 	var _ /* wrt at bp+376 */ WebPMemoryWriter
  29884 	_, _, _, _ = ok, v1, v3, v5
  29885 	if output == libc.UintptrFromInt32(0) {
  29886 		return uint64(0)
  29887 	}
  29888 	v1 = WebPConfigInitInternal(tls, bp+256, int32(WEBP_PRESET_DEFAULT), quality_factor, int32(WEBP_ENCODER_ABI_VERSION))
  29889 	goto _2
  29890 _2:
  29891 	;
  29892 	if v5 = !(v1 != 0); !v5 {
  29893 		v3 = WebPPictureInitInternal(tls, bp, int32(WEBP_ENCODER_ABI_VERSION))
  29894 		goto _4
  29895 	_4:
  29896 	}
  29897 	if v5 || !(v3 != 0) {
  29898 		return uint64(0) // shouldn't happen, except if system installation is broken
  29899 	}
  29900 	(**(**WebPConfig)(__ccgo_up(bp + 256))).Flossless = libc.BoolInt32(!!(lossless != 0))
  29901 	(**(**WebPPicture)(__ccgo_up(bp))).Fuse_argb = libc.BoolInt32(!!(lossless != 0))
  29902 	(**(**WebPPicture)(__ccgo_up(bp))).Fwidth = width
  29903 	(**(**WebPPicture)(__ccgo_up(bp))).Fheight = height
  29904 	(**(**WebPPicture)(__ccgo_up(bp))).Fwriter = __ccgo_fp(WebPMemoryWrite)
  29905 	(**(**WebPPicture)(__ccgo_up(bp))).Fcustom_ptr = bp + 376
  29906 	WebPMemoryWriterInit(tls, bp+376)
  29907 	ok = libc.BoolInt32((*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_import})))(tls, bp, rgba, stride) != 0 && WebPEncode(tls, bp+256, bp) != 0)
  29908 	WebPPictureFree(tls, bp)
  29909 	if !(ok != 0) {
  29910 		WebPMemoryWriterClear(tls, bp+376)
  29911 		**(**uintptr)(__ccgo_up(output)) = libc.UintptrFromInt32(0)
  29912 		return uint64(0)
  29913 	}
  29914 	**(**uintptr)(__ccgo_up(output)) = (**(**WebPMemoryWriter)(__ccgo_up(bp + 376))).Fmem
  29915 	return (**(**WebPMemoryWriter)(__ccgo_up(bp + 376))).Fsize
  29916 }
  29917 
  29918 func WebPEncodeRGB(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29919 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGB), q, 0, out)
  29920 }
  29921 
  29922 func WebPEncodeRGBA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29923 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGBA), q, 0, out)
  29924 }
  29925 
  29926 func WebPEncodeBGR(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29927 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGR), q, 0, out)
  29928 }
  29929 
  29930 func WebPEncodeBGRA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29931 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGRA), q, 0, out)
  29932 }
  29933 
  29934 func WebPEncodeLosslessRGB(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29935 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGB), float32(70), int32(1), out)
  29936 }
  29937 
  29938 func WebPEncodeLosslessRGBA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29939 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGBA), float32(70), int32(1), out)
  29940 }
  29941 
  29942 func WebPEncodeLosslessBGR(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29943 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGR), float32(70), int32(1), out)
  29944 }
  29945 
  29946 func WebPEncodeLosslessBGRA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29947 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGRA), float32(70), int32(1), out)
  29948 }
  29949 
  29950 const __FLT_MIN__5 = 1.1754943508222875e-38
  29951 const __INT_MAX__2 = 0x7fffffff
  29952 
  29953 //------------------------------------------------------------------------------
  29954 
  29955 // Copyright 2012 Google Inc. All Rights Reserved.
  29956 //
  29957 // Use of this source code is governed by a BSD-style license
  29958 // that can be found in the COPYING file in the root of the source
  29959 // tree. An additional intellectual property rights grant can be found
  29960 // in the file PATENTS. All contributing project authors may
  29961 // be found in the AUTHORS file in the root of the source tree.
  29962 // -----------------------------------------------------------------------------
  29963 //
  29964 // Misc. common utility functions
  29965 //
  29966 // Authors: Skal (pascal.massimino@gmail.com)
  29967 //          Urvang (urvang@google.com)
  29968 
  29969 type AccumulateFunc = uintptr
  29970 
  29971 //------------------------------------------------------------------------------
  29972 // local-min distortion
  29973 //
  29974 // For every pixel in the *reference* picture, we search for the local best
  29975 // match in the compressed image. This is not a symmetrical measure.
  29976 
  29977 func AccumulateLSIM(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  29978 	var best_sse, diff, sse, total_sse, value float64
  29979 	var i, j, x, x_0, x_1, y, y_0, y_1, v2, v3, v5, v6 int32
  29980 	var s uintptr
  29981 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_sse, diff, i, j, s, sse, total_sse, value, x, x_0, x_1, y, y_0, y_1, v2, v3, v5, v6
  29982 	total_sse = float64(0)
  29983 	y = 0
  29984 	for {
  29985 		if !(y < h) {
  29986 			break
  29987 		}
  29988 		if y-int32(2) < 0 {
  29989 			v2 = 0
  29990 		} else {
  29991 			v2 = y - int32(2)
  29992 		}
  29993 		y_0 = v2
  29994 		if y+int32(2)+int32(1) >= h {
  29995 			v3 = h
  29996 		} else {
  29997 			v3 = y + int32(2) + int32(1)
  29998 		}
  29999 		y_1 = v3
  30000 		x = 0
  30001 		for {
  30002 			if !(x < w) {
  30003 				break
  30004 			}
  30005 			if x-int32(2) < 0 {
  30006 				v5 = 0
  30007 			} else {
  30008 				v5 = x - int32(2)
  30009 			}
  30010 			x_0 = v5
  30011 			if x+int32(2)+int32(1) >= w {
  30012 				v6 = w
  30013 			} else {
  30014 				v6 = x + int32(2) + int32(1)
  30015 			}
  30016 			x_1 = v6
  30017 			best_sse = float64(libc.Float64FromFloat64(255) * libc.Float64FromFloat64(255))
  30018 			value = float64(**(**uint8_t)(__ccgo_up(ref + uintptr(y*ref_stride+x))))
  30019 			j = y_0
  30020 			for {
  30021 				if !(j < y_1) {
  30022 					break
  30023 				}
  30024 				s = src + uintptr(j*src_stride)
  30025 				i = x_0
  30026 				for {
  30027 					if !(i < x_1) {
  30028 						break
  30029 					}
  30030 					diff = float64(**(**uint8_t)(__ccgo_up(s + uintptr(i)))) - value
  30031 					sse = float64(diff * diff)
  30032 					if sse < best_sse {
  30033 						best_sse = sse
  30034 					}
  30035 					goto _8
  30036 				_8:
  30037 					;
  30038 					i = i + 1
  30039 				}
  30040 				goto _7
  30041 			_7:
  30042 				;
  30043 				j = j + 1
  30044 			}
  30045 			total_sse = total_sse + best_sse
  30046 			goto _4
  30047 		_4:
  30048 			;
  30049 			x = x + 1
  30050 		}
  30051 		goto _1
  30052 	_1:
  30053 		;
  30054 		y = y + 1
  30055 	}
  30056 	return total_sse
  30057 }
  30058 
  30059 func AccumulateSSE(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  30060 	var total_sse float64
  30061 	var y int32
  30062 	_, _ = total_sse, y
  30063 	total_sse = float64(0)
  30064 	y = 0
  30065 	for {
  30066 		if !(y < h) {
  30067 			break
  30068 		}
  30069 		total_sse = total_sse + float64((*(*func(*libc.TLS, uintptr, uintptr, int32) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8AccumulateSSE})))(tls, src, ref, w))
  30070 		src = src + uintptr(src_stride)
  30071 		ref = ref + uintptr(ref_stride)
  30072 		goto _1
  30073 	_1:
  30074 		;
  30075 		y = y + 1
  30076 	}
  30077 	return total_sse
  30078 }
  30079 
  30080 //------------------------------------------------------------------------------
  30081 
  30082 func AccumulateSSIM(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  30083 	var h0, h1, off1, off2, w0, w1, x, y, v1, v2 int32
  30084 	var sum float64
  30085 	_, _, _, _, _, _, _, _, _, _, _ = h0, h1, off1, off2, sum, w0, w1, x, y, v1, v2
  30086 	if w < int32(VP8_SSIM_KERNEL) {
  30087 		v1 = w
  30088 	} else {
  30089 		v1 = int32(VP8_SSIM_KERNEL)
  30090 	}
  30091 	w0 = v1
  30092 	w1 = w - int32(VP8_SSIM_KERNEL) - int32(1)
  30093 	if h < int32(VP8_SSIM_KERNEL) {
  30094 		v2 = h
  30095 	} else {
  30096 		v2 = int32(VP8_SSIM_KERNEL)
  30097 	}
  30098 	h0 = v2
  30099 	h1 = h - int32(VP8_SSIM_KERNEL) - int32(1)
  30100 	sum = float64(0)
  30101 	y = 0
  30102 	for {
  30103 		if !(y < h0) {
  30104 			break
  30105 		}
  30106 		x = 0
  30107 		for {
  30108 			if !(x < w) {
  30109 				break
  30110 			}
  30111 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, src, src_stride, ref, ref_stride, x, y, w, h)
  30112 			goto _4
  30113 		_4:
  30114 			;
  30115 			x = x + 1
  30116 		}
  30117 		goto _3
  30118 	_3:
  30119 		;
  30120 		y = y + 1
  30121 	}
  30122 	for {
  30123 		if !(y < h1) {
  30124 			break
  30125 		}
  30126 		x = 0
  30127 		for {
  30128 			if !(x < w0) {
  30129 				break
  30130 			}
  30131 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, src, src_stride, ref, ref_stride, x, y, w, h)
  30132 			goto _6
  30133 		_6:
  30134 			;
  30135 			x = x + 1
  30136 		}
  30137 		for {
  30138 			if !(x < w1) {
  30139 				break
  30140 			}
  30141 			off1 = x - int32(VP8_SSIM_KERNEL) + (y-int32(VP8_SSIM_KERNEL))*src_stride
  30142 			off2 = x - int32(VP8_SSIM_KERNEL) + (y-int32(VP8_SSIM_KERNEL))*ref_stride
  30143 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGet})))(tls, src+uintptr(off1), src_stride, ref+uintptr(off2), ref_stride)
  30144 			goto _7
  30145 		_7:
  30146 			;
  30147 			x = x + 1
  30148 		}
  30149 		for {
  30150 			if !(x < w) {
  30151 				break
  30152 			}
  30153 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, src, src_stride, ref, ref_stride, x, y, w, h)
  30154 			goto _8
  30155 		_8:
  30156 			;
  30157 			x = x + 1
  30158 		}
  30159 		goto _5
  30160 	_5:
  30161 		;
  30162 		y = y + 1
  30163 	}
  30164 	for {
  30165 		if !(y < h) {
  30166 			break
  30167 		}
  30168 		x = 0
  30169 		for {
  30170 			if !(x < w) {
  30171 				break
  30172 			}
  30173 			sum = sum + (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{VP8SSIMGetClipped})))(tls, src, src_stride, ref, ref_stride, x, y, w, h)
  30174 			goto _10
  30175 		_10:
  30176 			;
  30177 			x = x + 1
  30178 		}
  30179 		goto _9
  30180 	_9:
  30181 		;
  30182 		y = y + 1
  30183 	}
  30184 	return sum
  30185 }
  30186 
  30187 //------------------------------------------------------------------------------
  30188 // Distortion
  30189 
  30190 // C documentation
  30191 //
  30192 //	// Max value returned in case of exact similarity.
  30193 var kMinDistortion_dB = float64(99)
  30194 
  30195 func GetPSNR1(tls *libc.TLS, v float64, size float64) (r float64) {
  30196 	var v1 float64
  30197 	_ = v1
  30198 	if v > float64(0) && size > float64(0) {
  30199 		v1 = float64(-libc.Float64FromFloat64(4.3429448) * libc.Xlog(tls, v/float64(float64(size*libc.Float64FromInt32(255))*float64(255))))
  30200 	} else {
  30201 		v1 = kMinDistortion_dB
  30202 	}
  30203 	return v1
  30204 }
  30205 
  30206 func GetLogSSIM(tls *libc.TLS, v float64, size float64) (r float64) {
  30207 	var v1 float64
  30208 	_ = v1
  30209 	if size > float64(0) {
  30210 		v1 = v / size
  30211 	} else {
  30212 		v1 = float64(1)
  30213 	}
  30214 	v = v1
  30215 	if v < float64(1) {
  30216 		v1 = float64(-libc.Float64FromFloat64(10) * libc.Xlog10(tls, float64(1)-v))
  30217 	} else {
  30218 		v1 = kMinDistortion_dB
  30219 	}
  30220 	return v1
  30221 }
  30222 
  30223 func WebPPlaneDistortion(tls *libc.TLS, src uintptr, src_stride size_t, ref uintptr, ref_stride size_t, width int32, height int32, x_step size_t, type1 int32, distortion uintptr, result uintptr) (r int32) {
  30224 	var allocated, tmp1, tmp2, v1, v2 uintptr
  30225 	var metric AccumulateFunc
  30226 	var x, y int32
  30227 	var v5 float32
  30228 	_, _, _, _, _, _, _, _, _ = allocated, metric, tmp1, tmp2, x, y, v1, v2, v5
  30229 	allocated = libc.UintptrFromInt32(0)
  30230 	if type1 == 0 {
  30231 		v1 = __ccgo_fp(AccumulateSSE)
  30232 	} else {
  30233 		if type1 == int32(1) {
  30234 			v2 = __ccgo_fp(AccumulateSSIM)
  30235 		} else {
  30236 			v2 = __ccgo_fp(AccumulateLSIM)
  30237 		}
  30238 		v1 = v2
  30239 	}
  30240 	metric = v1
  30241 	if src == libc.UintptrFromInt32(0) || ref == libc.UintptrFromInt32(0) || src_stride < x_step*libc.Uint64FromInt32(width) || ref_stride < x_step*libc.Uint64FromInt32(width) || result == libc.UintptrFromInt32(0) || distortion == libc.UintptrFromInt32(0) {
  30242 		return 0
  30243 	}
  30244 	VP8SSIMDspInit(tls)
  30245 	if x_step != uint64(1) {
  30246 		allocated = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height), uint64(1))
  30247 		if allocated == libc.UintptrFromInt32(0) {
  30248 			return 0
  30249 		}
  30250 		tmp1 = allocated
  30251 		tmp2 = tmp1 + uintptr(libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height))
  30252 		y = 0
  30253 		for {
  30254 			if !(y < height) {
  30255 				break
  30256 			}
  30257 			x = 0
  30258 			for {
  30259 				if !(x < width) {
  30260 					break
  30261 				}
  30262 				**(**uint8_t)(__ccgo_up(tmp1 + uintptr(x+y*width))) = **(**uint8_t)(__ccgo_up(src + uintptr(libc.Uint64FromInt32(x)*x_step+libc.Uint64FromInt32(y)*src_stride)))
  30263 				**(**uint8_t)(__ccgo_up(tmp2 + uintptr(x+y*width))) = **(**uint8_t)(__ccgo_up(ref + uintptr(libc.Uint64FromInt32(x)*x_step+libc.Uint64FromInt32(y)*ref_stride)))
  30264 				goto _4
  30265 			_4:
  30266 				;
  30267 				x = x + 1
  30268 			}
  30269 			goto _3
  30270 		_3:
  30271 			;
  30272 			y = y + 1
  30273 		}
  30274 		src = tmp1
  30275 		ref = tmp2
  30276 	}
  30277 	**(**float32)(__ccgo_up(distortion)) = float32((*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) float64)(unsafe.Pointer(&struct{ uintptr }{metric})))(tls, src, width, ref, width, width, height))
  30278 	WebPSafeFree(tls, allocated)
  30279 	if type1 == int32(1) {
  30280 		v5 = float32(GetLogSSIM(tls, float64(**(**float32)(__ccgo_up(distortion))), float64(float64(width)*float64(height))))
  30281 	} else {
  30282 		v5 = float32(GetPSNR1(tls, float64(**(**float32)(__ccgo_up(distortion))), float64(float64(width)*float64(height))))
  30283 	}
  30284 	**(**float32)(__ccgo_up(result)) = v5
  30285 	return int32(1)
  30286 }
  30287 
  30288 func WebPPictureDistortion(tls *libc.TLS, src uintptr, ref uintptr, type1 int32, results uintptr) (r int32) {
  30289 	bp := tls.Alloc(528)
  30290 	defer tls.Free(528)
  30291 	var c, h, offset, ok, w, v1, v3 int32
  30292 	var stride0, stride1 size_t
  30293 	var total_distortion, total_size float64
  30294 	var v5 bool
  30295 	var v7 float32
  30296 	var _ /* distortion at bp+512 */ float32
  30297 	var _ /* p0 at bp+0 */ WebPPicture
  30298 	var _ /* p1 at bp+256 */ WebPPicture
  30299 	_, _, _, _, _, _, _, _, _, _, _, _, _ = c, h, offset, ok, stride0, stride1, total_distortion, total_size, w, v1, v3, v5, v7
  30300 	ok = 0
  30301 	total_size = float64(0)
  30302 	total_distortion = float64(0)
  30303 	if src == libc.UintptrFromInt32(0) || ref == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(src)).Fwidth != (*WebPPicture)(unsafe.Pointer(ref)).Fwidth || (*WebPPicture)(unsafe.Pointer(src)).Fheight != (*WebPPicture)(unsafe.Pointer(ref)).Fheight || results == libc.UintptrFromInt32(0) {
  30304 		return 0
  30305 	}
  30306 	VP8SSIMDspInit(tls)
  30307 	v1 = WebPPictureInitInternal(tls, bp, int32(WEBP_ENCODER_ABI_VERSION))
  30308 	goto _2
  30309 _2:
  30310 	;
  30311 	if v5 = !(v1 != 0); !v5 {
  30312 		v3 = WebPPictureInitInternal(tls, bp+256, int32(WEBP_ENCODER_ABI_VERSION))
  30313 		goto _4
  30314 	_4:
  30315 	}
  30316 	if v5 || !(v3 != 0) {
  30317 		return 0
  30318 	}
  30319 	w = (*WebPPicture)(unsafe.Pointer(src)).Fwidth
  30320 	h = (*WebPPicture)(unsafe.Pointer(src)).Fheight
  30321 	if !(WebPPictureView(tls, src, 0, 0, w, h, bp) != 0) {
  30322 		goto Error
  30323 	}
  30324 	if !(WebPPictureView(tls, ref, 0, 0, w, h, bp+256) != 0) {
  30325 		goto Error
  30326 	}
  30327 	// We always measure distortion in ARGB space.
  30328 	if (**(**WebPPicture)(__ccgo_up(bp))).Fuse_argb == 0 && !(WebPPictureYUVAToARGB(tls, bp) != 0) {
  30329 		goto Error
  30330 	}
  30331 	if (**(**WebPPicture)(__ccgo_up(bp + 256))).Fuse_argb == 0 && !(WebPPictureYUVAToARGB(tls, bp+256) != 0) {
  30332 		goto Error
  30333 	}
  30334 	c = 0
  30335 	for {
  30336 		if !(c < int32(4)) {
  30337 			break
  30338 		}
  30339 		stride0 = uint64(4) * libc.Uint64FromInt32((**(**WebPPicture)(__ccgo_up(bp))).Fargb_stride)
  30340 		stride1 = uint64(4) * libc.Uint64FromInt32((**(**WebPPicture)(__ccgo_up(bp + 256))).Fargb_stride)
  30341 		// results are reported as BGRA
  30342 		offset = c ^ 0
  30343 		if !(WebPPlaneDistortion(tls, (**(**WebPPicture)(__ccgo_up(bp))).Fargb+uintptr(offset), stride0, (**(**WebPPicture)(__ccgo_up(bp + 256))).Fargb+uintptr(offset), stride1, w, h, uint64(4), type1, bp+512, results+uintptr(c)*4) != 0) {
  30344 			goto Error
  30345 		}
  30346 		total_distortion = total_distortion + float64(**(**float32)(__ccgo_up(bp + 512)))
  30347 		total_size = total_size + float64(w*h)
  30348 		goto _6
  30349 	_6:
  30350 		;
  30351 		c = c + 1
  30352 	}
  30353 	if type1 == int32(1) {
  30354 		v7 = float32(GetLogSSIM(tls, total_distortion, total_size))
  30355 	} else {
  30356 		v7 = float32(GetPSNR1(tls, total_distortion, total_size))
  30357 	}
  30358 	**(**float32)(__ccgo_up(results + 4*4)) = v7
  30359 	ok = int32(1)
  30360 	goto Error
  30361 Error:
  30362 	;
  30363 	WebPPictureFree(tls, bp)
  30364 	WebPPictureFree(tls, bp+256)
  30365 	return ok
  30366 }
  30367 
  30368 const __FLT_MIN__6 = 1.17549435082228750796873653722224568e-38
  30369 
  30370 //------------------------------------------------------------------------------
  30371 
  30372 // Copyright 2012 Google Inc. All Rights Reserved.
  30373 //
  30374 // Use of this source code is governed by a BSD-style license
  30375 // that can be found in the COPYING file in the root of the source
  30376 // tree. An additional intellectual property rights grant can be found
  30377 // in the file PATENTS. All contributing project authors may
  30378 // be found in the AUTHORS file in the root of the source tree.
  30379 // -----------------------------------------------------------------------------
  30380 //
  30381 // Misc. common utility functions
  30382 //
  30383 // Authors: Skal (pascal.massimino@gmail.com)
  30384 //          Urvang (urvang@google.com)
  30385 
  30386 // C documentation
  30387 //
  30388 //	// Grab the 'specs' (writer, *opaque, width, height...) from 'src' and copy them
  30389 //	// into 'dst'. Mark 'dst' as not owning any memory.
  30390 func PictureGrabSpecs(tls *libc.TLS, src uintptr, dst uintptr) {
  30391 	**(**WebPPicture)(__ccgo_up(dst)) = **(**WebPPicture)(__ccgo_up(src))
  30392 	WebPPictureResetBuffers(tls, dst)
  30393 }
  30394 
  30395 //------------------------------------------------------------------------------
  30396 
  30397 // C documentation
  30398 //
  30399 //	// Adjust top-left corner to chroma sample position.
  30400 func SnapTopLeftPosition(tls *libc.TLS, pic uintptr, left uintptr, top uintptr) {
  30401 	if !((*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0) {
  30402 		**(**int32)(__ccgo_up(left)) &= ^libc.Int32FromInt32(1)
  30403 		**(**int32)(__ccgo_up(top)) &= ^libc.Int32FromInt32(1)
  30404 	}
  30405 }
  30406 
  30407 // C documentation
  30408 //
  30409 //	// Adjust top-left corner and verify that the sub-rectangle is valid.
  30410 func AdjustAndCheckRectangle(tls *libc.TLS, pic uintptr, left uintptr, top uintptr, width int32, height int32) (r int32) {
  30411 	SnapTopLeftPosition(tls, pic, left, top)
  30412 	if **(**int32)(__ccgo_up(left)) < 0 || **(**int32)(__ccgo_up(top)) < 0 {
  30413 		return 0
  30414 	}
  30415 	if width <= 0 || height <= 0 {
  30416 		return 0
  30417 	}
  30418 	if **(**int32)(__ccgo_up(left))+width > (*WebPPicture)(unsafe.Pointer(pic)).Fwidth {
  30419 		return 0
  30420 	}
  30421 	if **(**int32)(__ccgo_up(top))+height > (*WebPPicture)(unsafe.Pointer(pic)).Fheight {
  30422 		return 0
  30423 	}
  30424 	return int32(1)
  30425 }
  30426 
  30427 func WebPPictureCopy(tls *libc.TLS, src uintptr, dst uintptr) (r int32) {
  30428 	if src == libc.UintptrFromInt32(0) || dst == libc.UintptrFromInt32(0) {
  30429 		return 0
  30430 	}
  30431 	if src == dst {
  30432 		return int32(1)
  30433 	}
  30434 	PictureGrabSpecs(tls, src, dst)
  30435 	if !(WebPPictureAlloc(tls, dst) != 0) {
  30436 		return 0
  30437 	}
  30438 	if !((*WebPPicture)(unsafe.Pointer(src)).Fuse_argb != 0) {
  30439 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fy, (*WebPPicture)(unsafe.Pointer(src)).Fy_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fy, (*WebPPicture)(unsafe.Pointer(dst)).Fy_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fwidth, (*WebPPicture)(unsafe.Pointer(dst)).Fheight)
  30440 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fu, (*WebPPicture)(unsafe.Pointer(src)).Fuv_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fu, (*WebPPicture)(unsafe.Pointer(dst)).Fuv_stride, ((*WebPPicture)(unsafe.Pointer(dst)).Fwidth+int32(1))>>int32(1), ((*WebPPicture)(unsafe.Pointer(dst)).Fheight+int32(1))>>int32(1))
  30441 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fv, (*WebPPicture)(unsafe.Pointer(src)).Fuv_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fv, (*WebPPicture)(unsafe.Pointer(dst)).Fuv_stride, ((*WebPPicture)(unsafe.Pointer(dst)).Fwidth+int32(1))>>int32(1), ((*WebPPicture)(unsafe.Pointer(dst)).Fheight+int32(1))>>int32(1))
  30442 		if (*WebPPicture)(unsafe.Pointer(dst)).Fa != libc.UintptrFromInt32(0) {
  30443 			WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fa, (*WebPPicture)(unsafe.Pointer(src)).Fa_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fa, (*WebPPicture)(unsafe.Pointer(dst)).Fa_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fwidth, (*WebPPicture)(unsafe.Pointer(dst)).Fheight)
  30444 		}
  30445 	} else {
  30446 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fargb, int32(4)*(*WebPPicture)(unsafe.Pointer(src)).Fargb_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fargb, int32(4)*(*WebPPicture)(unsafe.Pointer(dst)).Fargb_stride, int32(4)*(*WebPPicture)(unsafe.Pointer(dst)).Fwidth, (*WebPPicture)(unsafe.Pointer(dst)).Fheight)
  30447 	}
  30448 	return int32(1)
  30449 }
  30450 
  30451 func WebPPictureIsView(tls *libc.TLS, picture uintptr) (r int32) {
  30452 	if picture == libc.UintptrFromInt32(0) {
  30453 		return 0
  30454 	}
  30455 	if (*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0 {
  30456 		return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ == libc.UintptrFromInt32(0))
  30457 	}
  30458 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ == libc.UintptrFromInt32(0))
  30459 }
  30460 
  30461 func WebPPictureView(tls *libc.TLS, src uintptr, _left int32, _top int32, width int32, height int32, dst uintptr) (r int32) {
  30462 	bp := tls.Alloc(16)
  30463 	defer tls.Free(16)
  30464 	*(*int32)(unsafe.Pointer(bp)) = _left
  30465 	*(*int32)(unsafe.Pointer(bp + 4)) = _top
  30466 	if src == libc.UintptrFromInt32(0) || dst == libc.UintptrFromInt32(0) {
  30467 		return 0
  30468 	}
  30469 	// verify rectangle position.
  30470 	if !(AdjustAndCheckRectangle(tls, src, bp, bp+4, width, height) != 0) {
  30471 		return 0
  30472 	}
  30473 	if src != dst { // beware of aliasing! We don't want to leak 'memory_'.
  30474 		PictureGrabSpecs(tls, src, dst)
  30475 	}
  30476 	(*WebPPicture)(unsafe.Pointer(dst)).Fwidth = width
  30477 	(*WebPPicture)(unsafe.Pointer(dst)).Fheight = height
  30478 	if !((*WebPPicture)(unsafe.Pointer(src)).Fuse_argb != 0) {
  30479 		(*WebPPicture)(unsafe.Pointer(dst)).Fy = (*WebPPicture)(unsafe.Pointer(src)).Fy + uintptr(**(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(src)).Fy_stride) + uintptr(**(**int32)(__ccgo_up(bp)))
  30480 		(*WebPPicture)(unsafe.Pointer(dst)).Fu = (*WebPPicture)(unsafe.Pointer(src)).Fu + uintptr(**(**int32)(__ccgo_up(bp + 4))>>int32(1)*(*WebPPicture)(unsafe.Pointer(src)).Fuv_stride) + uintptr(**(**int32)(__ccgo_up(bp))>>libc.Int32FromInt32(1))
  30481 		(*WebPPicture)(unsafe.Pointer(dst)).Fv = (*WebPPicture)(unsafe.Pointer(src)).Fv + uintptr(**(**int32)(__ccgo_up(bp + 4))>>int32(1)*(*WebPPicture)(unsafe.Pointer(src)).Fuv_stride) + uintptr(**(**int32)(__ccgo_up(bp))>>libc.Int32FromInt32(1))
  30482 		(*WebPPicture)(unsafe.Pointer(dst)).Fy_stride = (*WebPPicture)(unsafe.Pointer(src)).Fy_stride
  30483 		(*WebPPicture)(unsafe.Pointer(dst)).Fuv_stride = (*WebPPicture)(unsafe.Pointer(src)).Fuv_stride
  30484 		if (*WebPPicture)(unsafe.Pointer(src)).Fa != libc.UintptrFromInt32(0) {
  30485 			(*WebPPicture)(unsafe.Pointer(dst)).Fa = (*WebPPicture)(unsafe.Pointer(src)).Fa + uintptr(**(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(src)).Fa_stride) + uintptr(**(**int32)(__ccgo_up(bp)))
  30486 			(*WebPPicture)(unsafe.Pointer(dst)).Fa_stride = (*WebPPicture)(unsafe.Pointer(src)).Fa_stride
  30487 		}
  30488 	} else {
  30489 		(*WebPPicture)(unsafe.Pointer(dst)).Fargb = (*WebPPicture)(unsafe.Pointer(src)).Fargb + uintptr(**(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(src)).Fargb_stride)*4 + uintptr(**(**int32)(__ccgo_up(bp)))*4
  30490 		(*WebPPicture)(unsafe.Pointer(dst)).Fargb_stride = (*WebPPicture)(unsafe.Pointer(src)).Fargb_stride
  30491 	}
  30492 	return int32(1)
  30493 }
  30494 
  30495 //------------------------------------------------------------------------------
  30496 // Picture cropping
  30497 
  30498 func WebPPictureCrop(tls *libc.TLS, pic uintptr, _left int32, _top int32, width int32, height int32) (r int32) {
  30499 	bp := tls.Alloc(272)
  30500 	defer tls.Free(272)
  30501 	*(*int32)(unsafe.Pointer(bp)) = _left
  30502 	*(*int32)(unsafe.Pointer(bp + 4)) = _top
  30503 	var a_offset, uv_offset, y_offset int32
  30504 	var src uintptr
  30505 	var _ /* tmp at bp+8 */ WebPPicture
  30506 	_, _, _, _ = a_offset, src, uv_offset, y_offset
  30507 	if pic == libc.UintptrFromInt32(0) {
  30508 		return 0
  30509 	}
  30510 	if !(AdjustAndCheckRectangle(tls, pic, bp, bp+4, width, height) != 0) {
  30511 		return 0
  30512 	}
  30513 	PictureGrabSpecs(tls, pic, bp+8)
  30514 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fwidth = width
  30515 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fheight = height
  30516 	if !(WebPPictureAlloc(tls, bp+8) != 0) {
  30517 		return WebPEncodingSetError(tls, pic, (**(**WebPPicture)(__ccgo_up(bp + 8))).Ferror_code)
  30518 	}
  30519 	if !((*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0) {
  30520 		y_offset = **(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride + **(**int32)(__ccgo_up(bp))
  30521 		uv_offset = **(**int32)(__ccgo_up(bp + 4))/int32(2)*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride + **(**int32)(__ccgo_up(bp))/int32(2)
  30522 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fy+uintptr(y_offset), (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fy, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fy_stride, width, height)
  30523 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fu+uintptr(uv_offset), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fu, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fuv_stride, (width+int32(1))>>int32(1), (height+int32(1))>>int32(1))
  30524 		WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fv+uintptr(uv_offset), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fv, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fuv_stride, (width+int32(1))>>int32(1), (height+int32(1))>>int32(1))
  30525 		if (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa != libc.UintptrFromInt32(0) {
  30526 			a_offset = **(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(pic)).Fa_stride + **(**int32)(__ccgo_up(bp))
  30527 			WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fa+uintptr(a_offset), (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa_stride, width, height)
  30528 		}
  30529 	} else {
  30530 		src = (*WebPPicture)(unsafe.Pointer(pic)).Fargb + uintptr(**(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4 + uintptr(**(**int32)(__ccgo_up(bp)))*4
  30531 		WebPCopyPlane(tls, src, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride*int32(4), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fargb, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fargb_stride*int32(4), width*int32(4), height)
  30532 	}
  30533 	WebPPictureFree(tls, pic)
  30534 	**(**WebPPicture)(__ccgo_up(pic)) = **(**WebPPicture)(__ccgo_up(bp + 8))
  30535 	return int32(1)
  30536 }
  30537 
  30538 //------------------------------------------------------------------------------
  30539 // Simple picture rescaler
  30540 
  30541 func RescalePlane(tls *libc.TLS, src uintptr, src_width int32, src_height int32, src_stride int32, dst uintptr, dst_width int32, dst_height int32, dst_stride int32, work uintptr, num_channels int32) (r int32) {
  30542 	bp := tls.Alloc(112)
  30543 	defer tls.Free(112)
  30544 	var y int32
  30545 	var _ /* rescaler at bp+0 */ WebPRescaler
  30546 	_ = y
  30547 	y = 0
  30548 	if !(WebPRescalerInit(tls, bp, src_width, src_height, dst, dst_width, dst_height, dst_stride, num_channels, work) != 0) {
  30549 		return 0
  30550 	}
  30551 	for y < src_height {
  30552 		y = y + WebPRescalerImport(tls, bp, src_height-y, src+uintptr(y*src_stride), src_stride)
  30553 		WebPRescalerExport(tls, bp)
  30554 	}
  30555 	return int32(1)
  30556 }
  30557 
  30558 func AlphaMultiplyARGB(tls *libc.TLS, pic uintptr, inverse int32) {
  30559 	WebPMultARGBRows(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb, libc.Int32FromUint64(libc.Uint64FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*uint64(4)), (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, (*WebPPicture)(unsafe.Pointer(pic)).Fheight, inverse)
  30560 }
  30561 
  30562 func AlphaMultiplyY(tls *libc.TLS, pic uintptr, inverse int32) {
  30563 	if (*WebPPicture)(unsafe.Pointer(pic)).Fa != libc.UintptrFromInt32(0) {
  30564 		WebPMultRows(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fy, (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, (*WebPPicture)(unsafe.Pointer(pic)).Fa, (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, (*WebPPicture)(unsafe.Pointer(pic)).Fheight, inverse)
  30565 	}
  30566 }
  30567 
  30568 func WebPPictureRescale(tls *libc.TLS, picture uintptr, _width int32, _height int32) (r int32) {
  30569 	bp := tls.Alloc(272)
  30570 	defer tls.Free(272)
  30571 	*(*int32)(unsafe.Pointer(bp)) = _width
  30572 	*(*int32)(unsafe.Pointer(bp + 4)) = _height
  30573 	var prev_height, prev_width int32
  30574 	var work uintptr
  30575 	var _ /* tmp at bp+8 */ WebPPicture
  30576 	_, _, _ = prev_height, prev_width, work
  30577 	if picture == libc.UintptrFromInt32(0) {
  30578 		return 0
  30579 	}
  30580 	prev_width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  30581 	prev_height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  30582 	if !(WebPRescalerGetScaledDimensions(tls, prev_width, prev_height, bp, bp+4) != 0) {
  30583 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30584 	}
  30585 	PictureGrabSpecs(tls, picture, bp+8)
  30586 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fwidth = **(**int32)(__ccgo_up(bp))
  30587 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fheight = **(**int32)(__ccgo_up(bp + 4))
  30588 	if !(WebPPictureAlloc(tls, bp+8) != 0) {
  30589 		return WebPEncodingSetError(tls, picture, (**(**WebPPicture)(__ccgo_up(bp + 8))).Ferror_code)
  30590 	}
  30591 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  30592 		work = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))), uint64(4))
  30593 		if work == libc.UintptrFromInt32(0) {
  30594 			WebPPictureFree(tls, bp+8)
  30595 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  30596 		}
  30597 		// If present, we need to rescale alpha first (for AlphaMultiplyY).
  30598 		if (*WebPPicture)(unsafe.Pointer(picture)).Fa != libc.UintptrFromInt32(0) {
  30599 			WebPInitAlphaProcessing(tls)
  30600 			if !(RescalePlane(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fa, prev_width, prev_height, (*WebPPicture)(unsafe.Pointer(picture)).Fa_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa_stride, work, int32(1)) != 0) {
  30601 				return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30602 			}
  30603 		}
  30604 		// We take transparency into account on the luma plane only. That's not
  30605 		// totally exact blending, but still is a good approximation.
  30606 		AlphaMultiplyY(tls, picture, 0)
  30607 		if !(RescalePlane(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fy, prev_width, prev_height, (*WebPPicture)(unsafe.Pointer(picture)).Fy_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fy, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fy_stride, work, int32(1)) != 0) || !(RescalePlane(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fu, (prev_width+int32(1))>>int32(1), (prev_height+int32(1))>>int32(1), (*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fu, (**(**int32)(__ccgo_up(bp))+int32(1))>>int32(1), (**(**int32)(__ccgo_up(bp + 4))+int32(1))>>int32(1), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fuv_stride, work, int32(1)) != 0) || !(RescalePlane(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fv, (prev_width+int32(1))>>int32(1), (prev_height+int32(1))>>int32(1), (*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride, (**(**WebPPicture)(__ccgo_up(bp + 8))).Fv, (**(**int32)(__ccgo_up(bp))+int32(1))>>int32(1), (**(**int32)(__ccgo_up(bp + 4))+int32(1))>>int32(1), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fuv_stride, work, int32(1)) != 0) {
  30608 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30609 		}
  30610 		AlphaMultiplyY(tls, bp+8, int32(1))
  30611 	} else {
  30612 		work = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), uint64(4))
  30613 		if work == libc.UintptrFromInt32(0) {
  30614 			WebPPictureFree(tls, bp+8)
  30615 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  30616 		}
  30617 		// In order to correctly interpolate colors, we need to apply the alpha
  30618 		// weighting first (black-matting), scale the RGB values, and remove
  30619 		// the premultiplication afterward (while preserving the alpha channel).
  30620 		WebPInitAlphaProcessing(tls)
  30621 		AlphaMultiplyARGB(tls, picture, 0)
  30622 		if !(RescalePlane(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fargb, prev_width, prev_height, (*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride*int32(4), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fargb, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), (**(**WebPPicture)(__ccgo_up(bp + 8))).Fargb_stride*int32(4), work, int32(4)) != 0) {
  30623 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30624 		}
  30625 		AlphaMultiplyARGB(tls, bp+8, int32(1))
  30626 	}
  30627 	WebPPictureFree(tls, picture)
  30628 	WebPSafeFree(tls, work)
  30629 	**(**WebPPicture)(__ccgo_up(picture)) = **(**WebPPicture)(__ccgo_up(bp + 8))
  30630 	return int32(1)
  30631 }
  30632 
  30633 //------------------------------------------------------------------------------
  30634 
  30635 // Copyright 2011 Google Inc. All Rights Reserved.
  30636 //
  30637 // Use of this source code is governed by a BSD-style license
  30638 // that can be found in the COPYING file in the root of the source
  30639 // tree. An additional intellectual property rights grant can be found
  30640 // in the file PATENTS. All contributing project authors may
  30641 // be found in the AUTHORS file in the root of the source tree.
  30642 // -----------------------------------------------------------------------------
  30643 //
  30644 //   WebP encoder: main interface
  30645 //
  30646 // Author: Skal (pascal.massimino@gmail.com)
  30647 
  30648 // Copyright 2010 Google Inc. All Rights Reserved.
  30649 //
  30650 // Use of this source code is governed by a BSD-style license
  30651 // that can be found in the COPYING file in the root of the source
  30652 // tree. An additional intellectual property rights grant can be found
  30653 // in the file PATENTS. All contributing project authors may
  30654 // be found in the AUTHORS file in the root of the source tree.
  30655 // -----------------------------------------------------------------------------
  30656 //
  30657 //  Common types + memory wrappers
  30658 //
  30659 // Author: Skal (pascal.massimino@gmail.com)
  30660 
  30661 //------------------------------------------------------------------------------
  30662 // Helper: clean up fully transparent area to help compressibility.
  30663 
  30664 func IsTransparentARGBArea(tls *libc.TLS, ptr uintptr, stride int32, size int32) (r int32) {
  30665 	var x, y int32
  30666 	_, _ = x, y
  30667 	y = 0
  30668 	for {
  30669 		if !(y < size) {
  30670 			break
  30671 		}
  30672 		x = 0
  30673 		for {
  30674 			if !(x < size) {
  30675 				break
  30676 			}
  30677 			if **(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4))&uint32(0xff000000) != 0 {
  30678 				return 0
  30679 			}
  30680 			goto _2
  30681 		_2:
  30682 			;
  30683 			x = x + 1
  30684 		}
  30685 		ptr = ptr + uintptr(stride)*4
  30686 		goto _1
  30687 	_1:
  30688 		;
  30689 		y = y + 1
  30690 	}
  30691 	return int32(1)
  30692 }
  30693 
  30694 func Flatten(tls *libc.TLS, ptr uintptr, v int32, stride int32, size int32) {
  30695 	var y int32
  30696 	_ = y
  30697 	y = 0
  30698 	for {
  30699 		if !(y < size) {
  30700 			break
  30701 		}
  30702 		libc.X__builtin___memset_chk(tls, ptr, v, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  30703 		ptr = ptr + uintptr(stride)
  30704 		goto _1
  30705 	_1:
  30706 		;
  30707 		y = y + 1
  30708 	}
  30709 }
  30710 
  30711 func FlattenARGB(tls *libc.TLS, ptr uintptr, v uint32_t, stride int32, size int32) {
  30712 	var x, y int32
  30713 	_, _ = x, y
  30714 	y = 0
  30715 	for {
  30716 		if !(y < size) {
  30717 			break
  30718 		}
  30719 		x = 0
  30720 		for {
  30721 			if !(x < size) {
  30722 				break
  30723 			}
  30724 			**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = v
  30725 			goto _2
  30726 		_2:
  30727 			;
  30728 			x = x + 1
  30729 		}
  30730 		ptr = ptr + uintptr(stride)*4
  30731 		goto _1
  30732 	_1:
  30733 		;
  30734 		y = y + 1
  30735 	}
  30736 }
  30737 
  30738 // C documentation
  30739 //
  30740 //	// Smoothen the luma components of transparent pixels. Return true if the whole
  30741 //	// block is transparent.
  30742 func SmoothenBlock(tls *libc.TLS, a_ptr uintptr, a_stride int32, y_ptr uintptr, y_stride int32, width int32, height int32) (r int32) {
  30743 	var alpha_ptr, luma_ptr uintptr
  30744 	var avg_u8 uint8_t
  30745 	var count, sum, x, y int32
  30746 	_, _, _, _, _, _, _ = alpha_ptr, avg_u8, count, luma_ptr, sum, x, y
  30747 	sum = 0
  30748 	count = 0
  30749 	alpha_ptr = a_ptr
  30750 	luma_ptr = y_ptr
  30751 	y = 0
  30752 	for {
  30753 		if !(y < height) {
  30754 			break
  30755 		}
  30756 		x = 0
  30757 		for {
  30758 			if !(x < width) {
  30759 				break
  30760 			}
  30761 			if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_ptr + uintptr(x)))) != 0 {
  30762 				count = count + 1
  30763 				sum = sum + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(luma_ptr + uintptr(x))))
  30764 			}
  30765 			goto _2
  30766 		_2:
  30767 			;
  30768 			x = x + 1
  30769 		}
  30770 		alpha_ptr = alpha_ptr + uintptr(a_stride)
  30771 		luma_ptr = luma_ptr + uintptr(y_stride)
  30772 		goto _1
  30773 	_1:
  30774 		;
  30775 		y = y + 1
  30776 	}
  30777 	if count > 0 && count < width*height {
  30778 		avg_u8 = libc.Uint8FromInt32(sum / count)
  30779 		alpha_ptr = a_ptr
  30780 		luma_ptr = y_ptr
  30781 		y = 0
  30782 		for {
  30783 			if !(y < height) {
  30784 				break
  30785 			}
  30786 			x = 0
  30787 			for {
  30788 				if !(x < width) {
  30789 					break
  30790 				}
  30791 				if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_ptr + uintptr(x)))) == 0 {
  30792 					**(**uint8_t)(__ccgo_up(luma_ptr + uintptr(x))) = avg_u8
  30793 				}
  30794 				goto _4
  30795 			_4:
  30796 				;
  30797 				x = x + 1
  30798 			}
  30799 			alpha_ptr = alpha_ptr + uintptr(a_stride)
  30800 			luma_ptr = luma_ptr + uintptr(y_stride)
  30801 			goto _3
  30802 		_3:
  30803 			;
  30804 			y = y + 1
  30805 		}
  30806 	}
  30807 	return libc.BoolInt32(count == 0)
  30808 }
  30809 
  30810 func WebPReplaceTransparentPixels(tls *libc.TLS, pic uintptr, color uint32_t) {
  30811 	var argb uintptr
  30812 	var y, v1 int32
  30813 	_, _, _ = argb, y, v1
  30814 	if pic != libc.UintptrFromInt32(0) && (*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0 {
  30815 		y = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  30816 		argb = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  30817 		color = color & uint32(0xffffff) // force alpha=0
  30818 		WebPInitAlphaProcessing(tls)
  30819 		for {
  30820 			v1 = y
  30821 			y = y - 1
  30822 			if !(v1 > 0) {
  30823 				break
  30824 			}
  30825 			(*(*func(*libc.TLS, uintptr, int32, uint32_t))(unsafe.Pointer(&struct{ uintptr }{WebPAlphaReplace})))(tls, argb, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, color)
  30826 			argb = argb + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  30827 		}
  30828 	}
  30829 }
  30830 
  30831 func WebPCleanupTransparentArea(tls *libc.TLS, pic uintptr) {
  30832 	var a_ptr, u_ptr, v_ptr, y_ptr uintptr
  30833 	var a_stride, h, height, need_reset, need_reset1, off, sub_height, uv_stride, w, width, x, y, y_stride int32
  30834 	var argb_value uint32_t
  30835 	var values [3]int32
  30836 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_ptr, a_stride, argb_value, h, height, need_reset, need_reset1, off, sub_height, u_ptr, uv_stride, v_ptr, values, w, width, x, y, y_ptr, y_stride
  30837 	if pic == libc.UintptrFromInt32(0) {
  30838 		return
  30839 	}
  30840 	w = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth / int32(8)
  30841 	h = (*WebPPicture)(unsafe.Pointer(pic)).Fheight / int32(8)
  30842 	// note: we ignore the left-overs on right/bottom, except for SmoothenBlock().
  30843 	if (*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0 {
  30844 		argb_value = uint32(0)
  30845 		y = 0
  30846 		for {
  30847 			if !(y < h) {
  30848 				break
  30849 			}
  30850 			need_reset = int32(1)
  30851 			x = 0
  30852 			for {
  30853 				if !(x < w) {
  30854 					break
  30855 				}
  30856 				off = (y*(*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride + x) * int32(8)
  30857 				if IsTransparentARGBArea(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb+uintptr(off)*4, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride, int32(8)) != 0 {
  30858 					if need_reset != 0 {
  30859 						argb_value = **(**uint32_t)(__ccgo_up((*WebPPicture)(unsafe.Pointer(pic)).Fargb + uintptr(off)*4))
  30860 						need_reset = 0
  30861 					}
  30862 					FlattenARGB(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb+uintptr(off)*4, argb_value, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride, int32(8))
  30863 				} else {
  30864 					need_reset = int32(1)
  30865 				}
  30866 				goto _2
  30867 			_2:
  30868 				;
  30869 				x = x + 1
  30870 			}
  30871 			goto _1
  30872 		_1:
  30873 			;
  30874 			y = y + 1
  30875 		}
  30876 	} else {
  30877 		width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  30878 		height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  30879 		y_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride
  30880 		uv_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride
  30881 		a_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride
  30882 		y_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fy
  30883 		u_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fu
  30884 		v_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fv
  30885 		a_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fa
  30886 		values = [3]int32{}
  30887 		if a_ptr == libc.UintptrFromInt32(0) || y_ptr == libc.UintptrFromInt32(0) || u_ptr == libc.UintptrFromInt32(0) || v_ptr == libc.UintptrFromInt32(0) {
  30888 			return
  30889 		}
  30890 		y = 0
  30891 		for {
  30892 			if !(y+int32(8) <= height) {
  30893 				break
  30894 			}
  30895 			need_reset1 = int32(1)
  30896 			x = 0
  30897 			for {
  30898 				if !(x+int32(8) <= width) {
  30899 					break
  30900 				}
  30901 				if SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, int32(8), int32(8)) != 0 {
  30902 					if need_reset1 != 0 {
  30903 						values[0] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y_ptr + uintptr(x))))
  30904 						values[int32(1)] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x>>int32(1)))))
  30905 						values[int32(2)] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x>>int32(1)))))
  30906 						need_reset1 = 0
  30907 					}
  30908 					Flatten(tls, y_ptr+uintptr(x), values[0], y_stride, int32(8))
  30909 					Flatten(tls, u_ptr+uintptr(x>>libc.Int32FromInt32(1)), values[int32(1)], uv_stride, libc.Int32FromInt32(8)/libc.Int32FromInt32(2))
  30910 					Flatten(tls, v_ptr+uintptr(x>>libc.Int32FromInt32(1)), values[int32(2)], uv_stride, libc.Int32FromInt32(8)/libc.Int32FromInt32(2))
  30911 				} else {
  30912 					need_reset1 = int32(1)
  30913 				}
  30914 				goto _4
  30915 			_4:
  30916 				;
  30917 				x = x + int32(8)
  30918 			}
  30919 			if x < width {
  30920 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, width-x, int32(8))
  30921 			}
  30922 			a_ptr = a_ptr + uintptr(int32(8)*a_stride)
  30923 			y_ptr = y_ptr + uintptr(int32(8)*y_stride)
  30924 			u_ptr = u_ptr + uintptr(libc.Int32FromInt32(8)/libc.Int32FromInt32(2)*uv_stride)
  30925 			v_ptr = v_ptr + uintptr(libc.Int32FromInt32(8)/libc.Int32FromInt32(2)*uv_stride)
  30926 			goto _3
  30927 		_3:
  30928 			;
  30929 			y = y + int32(8)
  30930 		}
  30931 		if y < height {
  30932 			sub_height = height - y
  30933 			x = 0
  30934 			for {
  30935 				if !(x+int32(8) <= width) {
  30936 					break
  30937 				}
  30938 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, int32(8), sub_height)
  30939 				goto _5
  30940 			_5:
  30941 				;
  30942 				x = x + int32(8)
  30943 			}
  30944 			if x < width {
  30945 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, width-x, sub_height)
  30946 			}
  30947 		}
  30948 	}
  30949 }
  30950 
  30951 //------------------------------------------------------------------------------
  30952 // Blend color and remove transparency info
  30953 
  30954 func MakeARGB32(tls *libc.TLS, r int32, g int32, b int32) (r1 uint32_t) {
  30955 	return libc.Uint32FromUint32(0xff000000) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  30956 }
  30957 
  30958 func WebPBlendAlpha(tls *libc.TLS, picture uintptr, background_rgb uint32_t) {
  30959 	var U0, V0, Y0, alpha3, b3, blue, g3, green, has_alpha, luma, r3, red, u, uv_width, v, x, y, v1, v10, v12, v13, v15, v16, v3, v5, v6, v8, v9 int32
  30960 	var a_ptr, a_ptr2, argb, u_ptr, v_ptr, y_ptr, v19 uintptr
  30961 	var alpha uint8_t
  30962 	var alpha1, alpha2, background uint32_t
  30963 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = U0, V0, Y0, a_ptr, a_ptr2, alpha, alpha1, alpha2, alpha3, argb, b3, background, blue, g3, green, has_alpha, luma, r3, red, u, u_ptr, uv_width, v, v_ptr, x, y, y_ptr, v1, v10, v12, v13, v15, v16, v19, v3, v5, v6, v8, v9
  30964 	red = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(16) & uint32(0xff))
  30965 	green = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(8) & uint32(0xff))
  30966 	blue = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(0) & uint32(0xff))
  30967 	if picture == libc.UintptrFromInt32(0) {
  30968 		return
  30969 	}
  30970 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  30971 		// omit last pixel during u/v loop
  30972 		uv_width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth >> libc.Int32FromInt32(1)
  30973 		luma = int32(16839)*red + int32(33059)*green + int32(6420)*blue
  30974 		v1 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  30975 		goto _2
  30976 	_2:
  30977 		Y0 = v1
  30978 		u = -int32(9719)*(int32(4)*red) - int32(19081)*(int32(4)*green) + int32(28800)*(int32(4)*blue)
  30979 		v5 = u
  30980 		v5 = (v5 + libc.Int32FromInt32(4)*int32(YUV_HALF) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  30981 		if v5 & ^libc.Int32FromInt32(0xff) == 0 {
  30982 			v8 = v5
  30983 		} else {
  30984 			if v5 < 0 {
  30985 				v9 = 0
  30986 			} else {
  30987 				v9 = int32(255)
  30988 			}
  30989 			v8 = v9
  30990 		}
  30991 		v6 = v8
  30992 		goto _7
  30993 	_7:
  30994 		v3 = v6
  30995 		goto _4
  30996 	_4:
  30997 		// VP8RGBToU/V expects the u/v values summed over four pixels
  30998 		U0 = v3
  30999 		v = +libc.Int32FromInt32(28800)*(int32(4)*red) - int32(24116)*(int32(4)*green) - int32(4684)*(int32(4)*blue)
  31000 		v12 = v
  31001 		v12 = (v12 + libc.Int32FromInt32(4)*int32(YUV_HALF) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  31002 		if v12 & ^libc.Int32FromInt32(0xff) == 0 {
  31003 			v15 = v12
  31004 		} else {
  31005 			if v12 < 0 {
  31006 				v16 = 0
  31007 			} else {
  31008 				v16 = int32(255)
  31009 			}
  31010 			v15 = v16
  31011 		}
  31012 		v13 = v15
  31013 		goto _14
  31014 	_14:
  31015 		v10 = v13
  31016 		goto _11
  31017 	_11:
  31018 		V0 = v10
  31019 		has_alpha = (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace & int32(WEBP_CSP_ALPHA_BIT)
  31020 		y_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  31021 		u_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  31022 		v_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  31023 		a_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fa
  31024 		if !(has_alpha != 0) || a_ptr == libc.UintptrFromInt32(0) {
  31025 			return
  31026 		} // nothing to do
  31027 		y = 0
  31028 		for {
  31029 			if !(y < (*WebPPicture)(unsafe.Pointer(picture)).Fheight) {
  31030 				break
  31031 			}
  31032 			// Luma blending
  31033 			x = 0
  31034 			for {
  31035 				if !(x < (*WebPPicture)(unsafe.Pointer(picture)).Fwidth) {
  31036 					break
  31037 				}
  31038 				alpha = **(**uint8_t)(__ccgo_up(a_ptr + uintptr(x)))
  31039 				if libc.Int32FromUint8(alpha) < int32(0xff) {
  31040 					**(**uint8_t)(__ccgo_up(y_ptr + uintptr(x))) = libc.Uint8FromInt32(((Y0*(libc.Int32FromInt32(255)-libc.Int32FromUint8(alpha))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y_ptr + uintptr(x))))*libc.Int32FromUint8(alpha))*libc.Int32FromInt32(0x101) + libc.Int32FromInt32(256)) >> libc.Int32FromInt32(16))
  31041 				}
  31042 				goto _18
  31043 			_18:
  31044 				;
  31045 				x = x + 1
  31046 			}
  31047 			// Chroma blending every even line
  31048 			if y&int32(1) == 0 {
  31049 				if y+int32(1) == (*WebPPicture)(unsafe.Pointer(picture)).Fheight {
  31050 					v19 = a_ptr
  31051 				} else {
  31052 					v19 = a_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  31053 				}
  31054 				a_ptr2 = v19
  31055 				x = 0
  31056 				for {
  31057 					if !(x < uv_width) {
  31058 						break
  31059 					}
  31060 					// Average four alpha values into a single blending weight.
  31061 					// TODO(skal): might lead to visible contouring. Can we do better?
  31062 					alpha1 = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(int32(2)*x+0)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(int32(2)*x+int32(1))))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr2 + uintptr(int32(2)*x+0)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr2 + uintptr(int32(2)*x+int32(1))))))
  31063 					**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x))) = uint8(((libc.Uint32FromInt32(U0)*(libc.Uint32FromInt32(1020)-alpha1)+uint32(**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x))))*alpha1)*libc.Uint32FromInt32(0x101) + libc.Uint32FromInt32(1024)) >> libc.Int32FromInt32(18))
  31064 					**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x))) = uint8(((libc.Uint32FromInt32(V0)*(libc.Uint32FromInt32(1020)-alpha1)+uint32(**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x))))*alpha1)*libc.Uint32FromInt32(0x101) + libc.Uint32FromInt32(1024)) >> libc.Int32FromInt32(18))
  31065 					goto _20
  31066 				_20:
  31067 					;
  31068 					x = x + 1
  31069 				}
  31070 				if (*WebPPicture)(unsafe.Pointer(picture)).Fwidth&int32(1) != 0 { // rightmost pixel
  31071 					alpha2 = libc.Uint32FromInt32(int32(2) * (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr + uintptr(int32(2)*x+0)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a_ptr2 + uintptr(int32(2)*x+0))))))
  31072 					**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x))) = uint8(((libc.Uint32FromInt32(U0)*(libc.Uint32FromInt32(1020)-alpha2)+uint32(**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x))))*alpha2)*libc.Uint32FromInt32(0x101) + libc.Uint32FromInt32(1024)) >> libc.Int32FromInt32(18))
  31073 					**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x))) = uint8(((libc.Uint32FromInt32(V0)*(libc.Uint32FromInt32(1020)-alpha2)+uint32(**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x))))*alpha2)*libc.Uint32FromInt32(0x101) + libc.Uint32FromInt32(1024)) >> libc.Int32FromInt32(18))
  31074 				}
  31075 			} else {
  31076 				u_ptr = u_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  31077 				v_ptr = v_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  31078 			}
  31079 			libc.X__builtin___memset_chk(tls, a_ptr, int32(0xff), libc.Uint64FromInt32((*WebPPicture)(unsafe.Pointer(picture)).Fwidth), ^__predefined_size_t(0)) // reset alpha value to opaque
  31080 			a_ptr = a_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  31081 			y_ptr = y_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  31082 			goto _17
  31083 		_17:
  31084 			;
  31085 			y = y + 1
  31086 		}
  31087 	} else {
  31088 		argb = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  31089 		background = MakeARGB32(tls, red, green, blue)
  31090 		y = 0
  31091 		for {
  31092 			if !(y < (*WebPPicture)(unsafe.Pointer(picture)).Fheight) {
  31093 				break
  31094 			}
  31095 			x = 0
  31096 			for {
  31097 				if !(x < (*WebPPicture)(unsafe.Pointer(picture)).Fwidth) {
  31098 					break
  31099 				}
  31100 				alpha3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(24) & uint32(0xff))
  31101 				if alpha3 != int32(0xff) {
  31102 					if alpha3 > 0 {
  31103 						r3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(16) & uint32(0xff))
  31104 						g3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  31105 						b3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(0) & uint32(0xff))
  31106 						r3 = ((red*(int32(255)-alpha3)+r3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31107 						g3 = ((green*(int32(255)-alpha3)+g3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31108 						b3 = ((blue*(int32(255)-alpha3)+b3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31109 						**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) = MakeARGB32(tls, r3, g3, b3)
  31110 					} else {
  31111 						**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) = background
  31112 					}
  31113 				}
  31114 				goto _22
  31115 			_22:
  31116 				;
  31117 				x = x + 1
  31118 			}
  31119 			argb = argb + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  31120 			goto _21
  31121 		_21:
  31122 			;
  31123 			y = y + 1
  31124 		}
  31125 	}
  31126 }
  31127 
  31128 const ARGB_BLACK1 = 4278190080
  31129 
  31130 //------------------------------------------------------------------------------
  31131 
  31132 // Copyright 2012 Google Inc. All Rights Reserved.
  31133 //
  31134 // Use of this source code is governed by a BSD-style license
  31135 // that can be found in the COPYING file in the root of the source
  31136 // tree. An additional intellectual property rights grant can be found
  31137 // in the file PATENTS. All contributing project authors may
  31138 // be found in the AUTHORS file in the root of the source tree.
  31139 // -----------------------------------------------------------------------------
  31140 //
  31141 // Misc. common utility functions
  31142 //
  31143 // Authors: Skal (pascal.massimino@gmail.com)
  31144 //          Urvang (urvang@google.com)
  31145 
  31146 // Copyright 2011 Google Inc. All Rights Reserved.
  31147 //
  31148 // Use of this source code is governed by a BSD-style license
  31149 // that can be found in the COPYING file in the root of the source
  31150 // tree. An additional intellectual property rights grant can be found
  31151 // in the file PATENTS. All contributing project authors may
  31152 // be found in the AUTHORS file in the root of the source tree.
  31153 // -----------------------------------------------------------------------------
  31154 //
  31155 //   WebP encoder: main interface
  31156 //
  31157 // Author: Skal (pascal.massimino@gmail.com)
  31158 
  31159 // Copyright 2012 Google Inc. All Rights Reserved.
  31160 //
  31161 // Use of this source code is governed by a BSD-style license
  31162 // that can be found in the COPYING file in the root of the source
  31163 // tree. An additional intellectual property rights grant can be found
  31164 // in the file PATENTS. All contributing project authors may
  31165 // be found in the AUTHORS file in the root of the source tree.
  31166 // -----------------------------------------------------------------------------
  31167 //
  31168 //  Internal header for constants related to WebP file format.
  31169 //
  31170 // Author: Urvang (urvang@google.com)
  31171 
  31172 // Copyright 2010 Google Inc. All Rights Reserved.
  31173 //
  31174 // Use of this source code is governed by a BSD-style license
  31175 // that can be found in the COPYING file in the root of the source
  31176 // tree. An additional intellectual property rights grant can be found
  31177 // in the file PATENTS. All contributing project authors may
  31178 // be found in the AUTHORS file in the root of the source tree.
  31179 // -----------------------------------------------------------------------------
  31180 //
  31181 //  Common types + memory wrappers
  31182 //
  31183 // Author: Skal (pascal.massimino@gmail.com)
  31184 
  31185 var kSpatialPredictorBias = libc.Int64FromInt64(15) << libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  31186 var kPredLowEffort = int32(11)
  31187 var kMaskAlpha = uint32(0xff000000)
  31188 var kNumPredModes = int32(14)
  31189 
  31190 // C documentation
  31191 //
  31192 //	// Mostly used to reduce code size + readability
  31193 func GetMin(tls *libc.TLS, a int32, b int32) (r int32) {
  31194 	var v1 int32
  31195 	_ = v1
  31196 	if a > b {
  31197 		v1 = b
  31198 	} else {
  31199 		v1 = a
  31200 	}
  31201 	return v1
  31202 }
  31203 
  31204 func GetMax(tls *libc.TLS, a int32, b int32) (r int32) {
  31205 	var v1 int32
  31206 	_ = v1
  31207 	if a < b {
  31208 		v1 = b
  31209 	} else {
  31210 		v1 = a
  31211 	}
  31212 	return v1
  31213 }
  31214 
  31215 //------------------------------------------------------------------------------
  31216 // Methods to calculate Entropy (Shannon).
  31217 
  31218 // C documentation
  31219 //
  31220 //	// Compute a bias for prediction entropy using a global heuristic to favor
  31221 //	// values closer to 0. Hence the final negative sign.
  31222 //	// 'exp_val' has a scaling factor of 1/100.
  31223 func PredictionCostBias(tls *libc.TLS, counts uintptr, weight_0 uint64_t, exp_val uint64_t) (r int64_t) {
  31224 	var bits, exp_decay_factor uint64_t
  31225 	var i, significant_symbols int32
  31226 	var v6 int64
  31227 	var v2, v3, v4 int64_t
  31228 	_, _, _, _, _, _, _, _ = bits, exp_decay_factor, i, significant_symbols, v2, v3, v4, v6
  31229 	significant_symbols = libc.Int32FromInt32(256) >> libc.Int32FromInt32(4)
  31230 	exp_decay_factor = uint64(6) // has a scaling factor of 1/10
  31231 	bits = weight_0 * uint64(**(**uint32_t)(__ccgo_up(counts))) << int32(LOG_2_PRECISION_BITS)
  31232 	exp_val = exp_val << uint64(LOG_2_PRECISION_BITS)
  31233 	i = int32(1)
  31234 	for {
  31235 		if !(i < significant_symbols) {
  31236 			break
  31237 		}
  31238 		v2 = libc.Int64FromUint64(exp_val * uint64(**(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))+**(**uint32_t)(__ccgo_up(counts + uintptr(int32(256)-i)*4))))
  31239 		v3 = int64(100)
  31240 		if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31241 			v6 = (v2 + v3/int64(2)) / v3
  31242 		} else {
  31243 			v6 = (v2 - v3/int64(2)) / v3
  31244 		}
  31245 		v4 = v6
  31246 		goto _5
  31247 	_5:
  31248 		bits = bits + libc.Uint64FromInt64(v4)
  31249 		v2 = libc.Int64FromUint64(exp_decay_factor * exp_val)
  31250 		v3 = int64(10)
  31251 		if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31252 			v6 = (v2 + v3/int64(2)) / v3
  31253 		} else {
  31254 			v6 = (v2 - v3/int64(2)) / v3
  31255 		}
  31256 		v4 = v6
  31257 		goto _10
  31258 	_10:
  31259 		exp_val = libc.Uint64FromInt64(v4)
  31260 		goto _1
  31261 	_1:
  31262 		;
  31263 		i = i + 1
  31264 	}
  31265 	v2 = libc.Int64FromUint64(bits)
  31266 	v3 = int64(10)
  31267 	if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31268 		v6 = (v2 + v3/int64(2)) / v3
  31269 	} else {
  31270 		v6 = (v2 - v3/int64(2)) / v3
  31271 	}
  31272 	v4 = v6
  31273 	goto _15
  31274 _15:
  31275 	return -v4
  31276 }
  31277 
  31278 func PredictionCostSpatialHistogram(tls *libc.TLS, accumulated uintptr, tile uintptr, mode int32, left_mode int32, above_mode int32) (r int64_t) {
  31279 	var i int32
  31280 	var kExpValue uint64_t
  31281 	var retval int64_t
  31282 	_, _, _ = i, kExpValue, retval
  31283 	retval = 0
  31284 	i = 0
  31285 	for {
  31286 		if !(i < int32(4)) {
  31287 			break
  31288 		}
  31289 		kExpValue = uint64(94)
  31290 		retval = retval + PredictionCostBias(tls, tile+uintptr(i*int32(256))*4, uint64(1), kExpValue)
  31291 		// Compute the new cost if 'tile' is added to 'accumulate' but also add the
  31292 		// cost of the current histogram to guide the spatial predictor selection.
  31293 		// Basically, favor low entropy, locally and globally.
  31294 		retval = retval + libc.Int64FromUint64((*(*func(*libc.TLS, uintptr, uintptr) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LCombinedShannonEntropy})))(tls, tile+uintptr(i*int32(256))*4, accumulated+uintptr(i*int32(256))*4))
  31295 		goto _1
  31296 	_1:
  31297 		;
  31298 		i = i + 1
  31299 	}
  31300 	// Favor keeping the areas locally similar.
  31301 	if mode == left_mode {
  31302 		retval = retval - kSpatialPredictorBias
  31303 	}
  31304 	if mode == above_mode {
  31305 		retval = retval - kSpatialPredictorBias
  31306 	}
  31307 	return retval
  31308 }
  31309 
  31310 func UpdateHisto(tls *libc.TLS, histo_argb uintptr, argb uint32_t) {
  31311 	**(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(0)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(24))*4)) = **(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(0)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(24))*4)) + 1
  31312 	**(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(1)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(16)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(1)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(16)&uint32(0xff))*4)) + 1
  31313 	**(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(8)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(256))+argb>>libc.Int32FromInt32(8)&uint32(0xff))*4)) + 1
  31314 	**(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(256))+argb&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(histo_argb + uintptr(libc.Uint32FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(256))+argb&uint32(0xff))*4)) + 1
  31315 }
  31316 
  31317 //------------------------------------------------------------------------------
  31318 // Spatial transform functions.
  31319 
  31320 func PredictBatch(tls *libc.TLS, mode int32, x_start int32, y int32, num_pixels int32, current uintptr, upper uintptr, out uintptr) {
  31321 	if x_start == 0 {
  31322 		if y == 0 {
  31323 			// ARGB_BLACK.
  31324 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[libc.Int32FromInt32(0)]})))(tls, current, libc.UintptrFromInt32(0), int32(1), out)
  31325 		} else {
  31326 			// Top one.
  31327 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[libc.Int32FromInt32(2)]})))(tls, current, upper, int32(1), out)
  31328 		}
  31329 		x_start = x_start + 1
  31330 		out += 4
  31331 		num_pixels = num_pixels - 1
  31332 	}
  31333 	if y == 0 {
  31334 		// Left one.
  31335 		(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[libc.Int32FromInt32(1)]})))(tls, current+uintptr(x_start)*4, libc.UintptrFromInt32(0), num_pixels, out)
  31336 	} else {
  31337 		(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[mode]})))(tls, current+uintptr(x_start)*4, upper+uintptr(x_start)*4, num_pixels, out)
  31338 	}
  31339 }
  31340 
  31341 func MaxDiffBetweenPixels(tls *libc.TLS, p1 uint32_t, p2 uint32_t) (r int32) {
  31342 	var diff_a, diff_b, diff_g, diff_r int32
  31343 	_, _, _, _ = diff_a, diff_b, diff_g, diff_r
  31344 	diff_a = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(24))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(24)))
  31345 	diff_r = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(16)&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(16)&libc.Uint32FromInt32(0xff)))
  31346 	diff_g = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0xff)))
  31347 	diff_b = libc.Xabs(tls, libc.Int32FromUint32(p1&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2&libc.Uint32FromInt32(0xff)))
  31348 	return GetMax(tls, GetMax(tls, diff_a, diff_r), GetMax(tls, diff_g, diff_b))
  31349 }
  31350 
  31351 func MaxDiffAroundPixel(tls *libc.TLS, current uint32_t, up uint32_t, down uint32_t, left uint32_t, right uint32_t) (r int32) {
  31352 	var diff_down, diff_left, diff_right, diff_up int32
  31353 	_, _, _, _ = diff_down, diff_left, diff_right, diff_up
  31354 	diff_up = MaxDiffBetweenPixels(tls, current, up)
  31355 	diff_down = MaxDiffBetweenPixels(tls, current, down)
  31356 	diff_left = MaxDiffBetweenPixels(tls, current, left)
  31357 	diff_right = MaxDiffBetweenPixels(tls, current, right)
  31358 	return GetMax(tls, GetMax(tls, diff_up, diff_down), GetMax(tls, diff_left, diff_right))
  31359 }
  31360 
  31361 func AddGreenToBlueAndRed(tls *libc.TLS, argb uint32_t) (r uint32_t) {
  31362 	var green, red_blue uint32_t
  31363 	_, _ = green, red_blue
  31364 	green = argb >> libc.Int32FromInt32(8) & uint32(0xff)
  31365 	red_blue = argb & uint32(0x00ff00ff)
  31366 	red_blue = red_blue + (green<<libc.Int32FromInt32(16) | green)
  31367 	red_blue = red_blue & uint32(0x00ff00ff)
  31368 	return argb&uint32(0xff00ff00) | red_blue
  31369 }
  31370 
  31371 func MaxDiffsForRow(tls *libc.TLS, width int32, stride int32, argb uintptr, max_diffs uintptr, used_subtract_green int32) {
  31372 	var current, down, left, right, up uint32_t
  31373 	var x int32
  31374 	_, _, _, _, _, _ = current, down, left, right, up, x
  31375 	if width <= int32(2) {
  31376 		return
  31377 	}
  31378 	current = **(**uint32_t)(__ccgo_up(argb))
  31379 	right = **(**uint32_t)(__ccgo_up(argb + 1*4))
  31380 	if used_subtract_green != 0 {
  31381 		current = AddGreenToBlueAndRed(tls, current)
  31382 		right = AddGreenToBlueAndRed(tls, right)
  31383 	}
  31384 	// max_diffs[0] and max_diffs[width - 1] are never used.
  31385 	x = int32(1)
  31386 	for {
  31387 		if !(x < width-int32(1)) {
  31388 			break
  31389 		}
  31390 		up = **(**uint32_t)(__ccgo_up(argb + uintptr(-stride+x)*4))
  31391 		down = **(**uint32_t)(__ccgo_up(argb + uintptr(stride+x)*4))
  31392 		left = current
  31393 		current = right
  31394 		right = **(**uint32_t)(__ccgo_up(argb + uintptr(x+int32(1))*4))
  31395 		if used_subtract_green != 0 {
  31396 			up = AddGreenToBlueAndRed(tls, up)
  31397 			down = AddGreenToBlueAndRed(tls, down)
  31398 			right = AddGreenToBlueAndRed(tls, right)
  31399 		}
  31400 		**(**uint8_t)(__ccgo_up(max_diffs + uintptr(x))) = libc.Uint8FromInt32(MaxDiffAroundPixel(tls, current, up, down, left, right))
  31401 		goto _1
  31402 	_1:
  31403 		;
  31404 		x = x + 1
  31405 	}
  31406 }
  31407 
  31408 // C documentation
  31409 //
  31410 //	// Quantize the difference between the actual component value and its prediction
  31411 //	// to a multiple of quantization, working modulo 256, taking care not to cross
  31412 //	// a boundary (inclusive upper limit).
  31413 func NearLosslessComponent(tls *libc.TLS, value uint8_t, predict uint8_t, boundary uint8_t, quantization int32) (r uint8_t) {
  31414 	var bias, boundary_residual, lower, residual, upper int32
  31415 	_, _, _, _, _ = bias, boundary_residual, lower, residual, upper
  31416 	residual = (libc.Int32FromUint8(value) - libc.Int32FromUint8(predict)) & int32(0xff)
  31417 	boundary_residual = (libc.Int32FromUint8(boundary) - libc.Int32FromUint8(predict)) & int32(0xff)
  31418 	lower = residual & ^(quantization - libc.Int32FromInt32(1))
  31419 	upper = lower + quantization
  31420 	// Resolve ties towards a value closer to the prediction (i.e. towards lower
  31421 	// if value comes after prediction and towards upper otherwise).
  31422 	bias = libc.BoolInt32((libc.Int32FromUint8(boundary)-libc.Int32FromUint8(value))&int32(0xff) < boundary_residual)
  31423 	if residual-lower < upper-residual+bias {
  31424 		// lower is closer to residual than upper.
  31425 		if residual > boundary_residual && lower <= boundary_residual {
  31426 			// Halve quantization step to avoid crossing boundary. This midpoint is
  31427 			// on the same side of boundary as residual because midpoint >= residual
  31428 			// (since lower is closer than upper) and residual is above the boundary.
  31429 			return libc.Uint8FromInt32(lower + quantization>>int32(1))
  31430 		}
  31431 		return libc.Uint8FromInt32(lower)
  31432 	} else {
  31433 		// upper is closer to residual than lower.
  31434 		if residual <= boundary_residual && upper > boundary_residual {
  31435 			// Halve quantization step to avoid crossing boundary. This midpoint is
  31436 			// on the same side of boundary as residual because midpoint <= residual
  31437 			// (since upper is closer than lower) and residual is below the boundary.
  31438 			return libc.Uint8FromInt32(lower + quantization>>int32(1))
  31439 		}
  31440 		return libc.Uint8FromInt32(upper & int32(0xff))
  31441 	}
  31442 	return r
  31443 }
  31444 
  31445 func NearLosslessDiff(tls *libc.TLS, a uint8_t, b uint8_t) (r uint8_t) {
  31446 	return libc.Uint8FromInt32((libc.Int32FromUint8(a) - libc.Int32FromUint8(b)) & libc.Int32FromInt32(0xff))
  31447 }
  31448 
  31449 // C documentation
  31450 //
  31451 //	// Quantize every component of the difference between the actual pixel value and
  31452 //	// its prediction to a multiple of a quantization (a power of 2, not larger than
  31453 //	// max_quantization which is a power of 2, smaller than max_diff). Take care if
  31454 //	// value and predict have undergone subtract green, which means that red and
  31455 //	// blue are represented as offsets from green.
  31456 func NearLossless1(tls *libc.TLS, value uint32_t, predict uint32_t, max_quantization int32, max_diff int32, used_subtract_green int32) (r1 uint32_t) {
  31457 	var a1, b1, g, green_diff, new_green, r uint8_t
  31458 	var alpha_and_green, red_and_blue, v1, v2, v3 uint32_t
  31459 	var quantization int32
  31460 	_, _, _, _, _, _, _, _, _, _, _, _ = a1, alpha_and_green, b1, g, green_diff, new_green, quantization, r, red_and_blue, v1, v2, v3
  31461 	new_green = uint8(0)
  31462 	green_diff = uint8(0)
  31463 	if max_diff <= int32(2) {
  31464 		v1 = value
  31465 		v2 = predict
  31466 		alpha_and_green = uint32(0x00ff00ff) + v1&uint32(0xff00ff00) - v2&uint32(0xff00ff00)
  31467 		red_and_blue = uint32(0xff00ff00) + v1&uint32(0x00ff00ff) - v2&uint32(0x00ff00ff)
  31468 		v3 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  31469 		goto _4
  31470 	_4:
  31471 		return v3
  31472 	}
  31473 	quantization = max_quantization
  31474 	for quantization >= max_diff {
  31475 		quantization = quantization >> int32(1)
  31476 	}
  31477 	if value>>libc.Int32FromInt32(24) == uint32(0) || value>>libc.Int32FromInt32(24) == uint32(0xff) {
  31478 		// Preserve transparency of fully transparent or fully opaque pixels.
  31479 		a1 = NearLosslessDiff(tls, uint8(value>>libc.Int32FromInt32(24)&uint32(0xff)), uint8(predict>>libc.Int32FromInt32(24)&uint32(0xff)))
  31480 	} else {
  31481 		a1 = NearLosslessComponent(tls, uint8(value>>int32(24)), uint8(predict>>int32(24)), uint8(0xff), quantization)
  31482 	}
  31483 	g = NearLosslessComponent(tls, uint8(value>>libc.Int32FromInt32(8)&uint32(0xff)), uint8(predict>>libc.Int32FromInt32(8)&uint32(0xff)), uint8(0xff), quantization)
  31484 	if used_subtract_green != 0 {
  31485 		// The green offset will be added to red and blue components during decoding
  31486 		// to obtain the actual red and blue values.
  31487 		new_green = uint8((predict>>libc.Int32FromInt32(8) + uint32(g)) & uint32(0xff))
  31488 		// The amount by which green has been adjusted during quantization. It is
  31489 		// subtracted from red and blue for compensation, to avoid accumulating two
  31490 		// quantization errors in them.
  31491 		green_diff = NearLosslessDiff(tls, new_green, uint8(value>>libc.Int32FromInt32(8)&uint32(0xff)))
  31492 	}
  31493 	r = NearLosslessComponent(tls, NearLosslessDiff(tls, uint8(value>>libc.Int32FromInt32(16)&uint32(0xff)), green_diff), uint8(predict>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Uint8FromInt32(int32(0xff)-libc.Int32FromUint8(new_green)), quantization)
  31494 	b1 = NearLosslessComponent(tls, NearLosslessDiff(tls, uint8(value&uint32(0xff)), green_diff), uint8(predict&uint32(0xff)), libc.Uint8FromInt32(int32(0xff)-libc.Int32FromUint8(new_green)), quantization)
  31495 	return uint32(a1)<<libc.Int32FromInt32(24) | uint32(r)<<libc.Int32FromInt32(16) | uint32(g)<<libc.Int32FromInt32(8) | uint32(b1)
  31496 }
  31497 
  31498 // C documentation
  31499 //
  31500 //	// Stores the difference between the pixel and its prediction in "out".
  31501 //	// In case of a lossy encoding, updates the source image to avoid propagating
  31502 //	// the deviation further to pixels which depend on the current pixel for their
  31503 //	// predictions.
  31504 func GetResidual(tls *libc.TLS, width int32, height int32, upper_row uintptr, current_row uintptr, max_diffs uintptr, mode int32, x_start int32, x_end int32, y int32, max_quantization int32, exact int32, used_subtract_green int32, out uintptr) {
  31505 	var alpha_and_green, alpha_and_green1, predict, red_and_blue, red_and_blue1, residual, v3, v4, v5 uint32_t
  31506 	var pred_func VP8LPredictorFunc
  31507 	var x int32
  31508 	var v2 uint32
  31509 	_, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, alpha_and_green1, pred_func, predict, red_and_blue, red_and_blue1, residual, x, v2, v3, v4, v5
  31510 	if exact != 0 {
  31511 		PredictBatch(tls, mode, x_start, y, x_end-x_start, current_row, upper_row, out)
  31512 	} else {
  31513 		pred_func = VP8LPredictors[mode]
  31514 		x = x_start
  31515 		for {
  31516 			if !(x < x_end) {
  31517 				break
  31518 			}
  31519 			if y == 0 {
  31520 				if x == 0 {
  31521 					v2 = uint32(ARGB_BLACK1)
  31522 				} else {
  31523 					v2 = **(**uint32_t)(__ccgo_up(current_row + uintptr(x-int32(1))*4))
  31524 				}
  31525 				predict = v2 // Left.
  31526 			} else {
  31527 				if x == 0 {
  31528 					predict = **(**uint32_t)(__ccgo_up(upper_row + uintptr(x)*4)) // Top.
  31529 				} else {
  31530 					predict = (*(*func(*libc.TLS, uintptr, uintptr) uint32_t)(unsafe.Pointer(&struct{ uintptr }{pred_func})))(tls, current_row+uintptr(x-int32(1))*4, upper_row+uintptr(x)*4)
  31531 				}
  31532 			}
  31533 			if max_quantization == int32(1) || mode == 0 || y == 0 || y == height-int32(1) || x == 0 || x == width-int32(1) {
  31534 				v3 = **(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4))
  31535 				v4 = predict
  31536 				alpha_and_green1 = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v4&uint32(0xff00ff00)
  31537 				red_and_blue1 = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v4&uint32(0x00ff00ff)
  31538 				v5 = alpha_and_green1&uint32(0xff00ff00) | red_and_blue1&uint32(0x00ff00ff)
  31539 				goto _6
  31540 			_6:
  31541 				residual = v5
  31542 			} else {
  31543 				residual = NearLossless1(tls, **(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4)), predict, max_quantization, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(max_diffs + uintptr(x)))), used_subtract_green)
  31544 				// Update the source image.
  31545 				v3 = predict
  31546 				v4 = residual
  31547 				alpha_and_green = v3&uint32(0xff00ff00) + v4&uint32(0xff00ff00)
  31548 				red_and_blue = v3&uint32(0x00ff00ff) + v4&uint32(0x00ff00ff)
  31549 				v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  31550 				goto _10
  31551 			_10:
  31552 				**(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4)) = v5
  31553 				// x is never 0 here so we do not need to update upper_row like below.
  31554 			}
  31555 			if **(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4))&kMaskAlpha == uint32(0) {
  31556 				// If alpha is 0, cleanup RGB. We can choose the RGB values of the
  31557 				// residual for best compression. The prediction of alpha itself can be
  31558 				// non-zero and must be kept though. We choose RGB of the residual to be
  31559 				// 0.
  31560 				residual = residual & kMaskAlpha
  31561 				// Update the source image.
  31562 				**(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4)) = predict & ^kMaskAlpha
  31563 				// The prediction for the rightmost pixel in a row uses the leftmost
  31564 				// pixel
  31565 				// in that row as its top-right context pixel. Hence if we change the
  31566 				// leftmost pixel of current_row, the corresponding change must be
  31567 				// applied
  31568 				// to upper_row as well where top-right context is being read from.
  31569 				if x == 0 && y != 0 {
  31570 					**(**uint32_t)(__ccgo_up(upper_row + uintptr(width)*4)) = **(**uint32_t)(__ccgo_up(current_row))
  31571 				}
  31572 			}
  31573 			**(**uint32_t)(__ccgo_up(out + uintptr(x-x_start)*4)) = residual
  31574 			goto _1
  31575 		_1:
  31576 			;
  31577 			x = x + 1
  31578 		}
  31579 	}
  31580 }
  31581 
  31582 // C documentation
  31583 //
  31584 //	// Accessors to residual histograms.
  31585 func GetHistoArgb(tls *libc.TLS, all_histos uintptr, subsampling_index int32, mode int32) (r uintptr) {
  31586 	return all_histos + uintptr((subsampling_index*kNumPredModes+mode)*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31587 }
  31588 
  31589 func GetHistoArgbConst(tls *libc.TLS, all_histos uintptr, subsampling_index int32, mode int32) (r uintptr) {
  31590 	return all_histos + uintptr(subsampling_index*kNumPredModes*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256))+mode*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31591 }
  31592 
  31593 // C documentation
  31594 //
  31595 //	// Accessors to accumulated residual histogram.
  31596 func GetAccumulatedHisto(tls *libc.TLS, all_accumulated uintptr, subsampling_index int32) (r uintptr) {
  31597 	return all_accumulated + uintptr(subsampling_index*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31598 }
  31599 
  31600 // C documentation
  31601 //
  31602 //	// Find and store the best predictor for a tile at subsampling
  31603 //	// 'subsampling_index'.
  31604 func GetBestPredictorForTile(tls *libc.TLS, all_argb uintptr, subsampling_index int32, tile_x int32, tile_y int32, tiles_per_row int32, all_accumulated_argb uintptr, all_modes uintptr, all_pred_histos uintptr) {
  31605 	var above_mode, left_mode, mode int32
  31606 	var accumulated_argb, best_histo, histo_argb, modes, pred_histos uintptr
  31607 	var best_diff, cur_diff int64_t
  31608 	var best_mode uint32_t
  31609 	var v1, v2 uint32
  31610 	_, _, _, _, _, _, _, _, _, _, _, _, _ = above_mode, accumulated_argb, best_diff, best_histo, best_mode, cur_diff, histo_argb, left_mode, mode, modes, pred_histos, v1, v2
  31611 	accumulated_argb = GetAccumulatedHisto(tls, all_accumulated_argb, subsampling_index)
  31612 	modes = **(**uintptr)(__ccgo_up(all_modes + uintptr(subsampling_index)*8))
  31613 	pred_histos = all_pred_histos + uintptr(subsampling_index*kNumPredModes)*4
  31614 	if tile_x > 0 {
  31615 		v1 = **(**uint32_t)(__ccgo_up(modes + uintptr(tile_y*tiles_per_row+tile_x-int32(1))*4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  31616 	} else {
  31617 		v1 = uint32(0xff)
  31618 	}
  31619 	// Prediction modes of the left and above neighbor tiles.
  31620 	left_mode = libc.Int32FromUint32(v1)
  31621 	if tile_y > 0 {
  31622 		v2 = **(**uint32_t)(__ccgo_up(modes + uintptr((tile_y-int32(1))*tiles_per_row+tile_x)*4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  31623 	} else {
  31624 		v2 = uint32(0xff)
  31625 	}
  31626 	above_mode = libc.Int32FromUint32(v2)
  31627 	best_diff = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  31628 	best_mode = uint32(0)
  31629 	best_histo = GetHistoArgbConst(tls, all_argb, 0, libc.Int32FromUint32(best_mode))
  31630 	mode = 0
  31631 	for {
  31632 		if !(mode < kNumPredModes) {
  31633 			break
  31634 		}
  31635 		histo_argb = GetHistoArgbConst(tls, all_argb, subsampling_index, mode)
  31636 		cur_diff = PredictionCostSpatialHistogram(tls, accumulated_argb, histo_argb, mode, left_mode, above_mode)
  31637 		if cur_diff < best_diff {
  31638 			best_histo = histo_argb
  31639 			best_diff = cur_diff
  31640 			best_mode = libc.Uint32FromInt32(mode)
  31641 		}
  31642 		goto _3
  31643 	_3:
  31644 		;
  31645 		mode = mode + 1
  31646 	}
  31647 	// Update the accumulated histogram.
  31648 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVectorEq})))(tls, best_histo, accumulated_argb, libc.Int32FromInt32(4)*libc.Int32FromInt32(256))
  31649 	**(**uint32_t)(__ccgo_up(modes + uintptr(tile_y*tiles_per_row+tile_x)*4)) = uint32(ARGB_BLACK1) | best_mode<<libc.Int32FromInt32(8)
  31650 	**(**uint32_t)(__ccgo_up(pred_histos + uintptr(best_mode)*4)) = **(**uint32_t)(__ccgo_up(pred_histos + uintptr(best_mode)*4)) + 1
  31651 }
  31652 
  31653 // C documentation
  31654 //
  31655 //	// Computes the residuals for the different predictors.
  31656 //	// If max_quantization > 1, assumes that near lossless processing will be
  31657 //	// applied, quantizing residuals to multiples of quantization levels up to
  31658 //	// max_quantization (the actual quantization level depends on smoothness near
  31659 //	// the given pixel).
  31660 func ComputeResidualsForTile(tls *libc.TLS, width int32, height int32, tile_x int32, tile_y int32, min_bits int32, update_up_to_index uint32_t, all_argb uintptr, argb_scratch uintptr, argb uintptr, max_quantization int32, exact int32, used_subtract_green int32) {
  31661 	bp := tls.Alloc(2048)
  31662 	defer tls.Free(2048)
  31663 	var context_start_x, context_width, have_left, max_x, max_y, mode, relative_x, relative_y, start_x, start_y, tile_size, y int32
  31664 	var current_row, histo_argb, max_diffs, super_histo, tmp, upper_row uintptr
  31665 	var subsampling_index uint32_t
  31666 	var _ /* residuals at bp+0 */ [512]uint32_t
  31667 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = context_start_x, context_width, current_row, have_left, histo_argb, max_diffs, max_x, max_y, mode, relative_x, relative_y, start_x, start_y, subsampling_index, super_histo, tile_size, tmp, upper_row, y
  31668 	start_x = tile_x << min_bits
  31669 	start_y = tile_y << min_bits
  31670 	tile_size = int32(1) << min_bits
  31671 	max_y = GetMin(tls, tile_size, height-start_y)
  31672 	max_x = GetMin(tls, tile_size, width-start_x)
  31673 	// Whether there exist columns just outside the tile.
  31674 	have_left = libc.BoolInt32(start_x > libc.Int32FromInt32(0))
  31675 	// Position and size of the strip covering the tile and adjacent columns if
  31676 	// they exist.
  31677 	context_start_x = start_x - have_left
  31678 	context_width = max_x + have_left + libc.BoolInt32(max_x < width-start_x)
  31679 	// The width of upper_row and current_row is one pixel larger than image width
  31680 	// to allow the top right pixel to point to the leftmost pixel of the next row
  31681 	// when at the right edge.
  31682 	upper_row = argb_scratch
  31683 	current_row = upper_row + uintptr(width)*4 + uintptr(1)*4
  31684 	max_diffs = current_row + uintptr(width)*4 + libc.UintptrFromInt32(1)*4
  31685 	mode = 0
  31686 	for {
  31687 		if !(mode < kNumPredModes) {
  31688 			break
  31689 		}
  31690 		histo_argb = GetHistoArgb(tls, all_argb, 0, mode)
  31691 		if start_y > 0 {
  31692 			// Read the row above the tile which will become the first upper_row.
  31693 			// Include a pixel to the left if it exists; include a pixel to the right
  31694 			// in all cases (wrapping to the leftmost pixel of the next row if it does
  31695 			// not exist).
  31696 			libc.X__builtin___memcpy_chk(tls, current_row+uintptr(context_start_x)*4, argb+uintptr((start_y-int32(1))*width)*4+uintptr(context_start_x)*4, uint64(4)*libc.Uint64FromInt32(max_x+have_left+libc.Int32FromInt32(1)), ^__predefined_size_t(0))
  31697 		}
  31698 		relative_y = 0
  31699 		for {
  31700 			if !(relative_y < max_y) {
  31701 				break
  31702 			}
  31703 			y = start_y + relative_y
  31704 			tmp = upper_row
  31705 			upper_row = current_row
  31706 			current_row = tmp
  31707 			// Read current_row. Include a pixel to the left if it exists; include a
  31708 			// pixel to the right in all cases except at the bottom right corner of
  31709 			// the image (wrapping to the leftmost pixel of the next row if it does
  31710 			// not exist in the current row).
  31711 			libc.X__builtin___memcpy_chk(tls, current_row+uintptr(context_start_x)*4, argb+uintptr(y*width)*4+uintptr(context_start_x)*4, uint64(4)*libc.Uint64FromInt32(max_x+have_left+libc.BoolInt32(y+libc.Int32FromInt32(1) < height)), ^__predefined_size_t(0))
  31712 			if max_quantization > int32(1) && y >= int32(1) && y+int32(1) < height {
  31713 				MaxDiffsForRow(tls, context_width, width, argb+uintptr(y*width)*4+uintptr(context_start_x)*4, max_diffs+uintptr(context_start_x), used_subtract_green)
  31714 			}
  31715 			GetResidual(tls, width, height, upper_row, current_row, max_diffs, mode, start_x, start_x+max_x, y, max_quantization, exact, used_subtract_green, bp)
  31716 			relative_x = 0
  31717 			for {
  31718 				if !(relative_x < max_x) {
  31719 					break
  31720 				}
  31721 				UpdateHisto(tls, histo_argb, (**(**[512]uint32_t)(__ccgo_up(bp)))[relative_x])
  31722 				goto _3
  31723 			_3:
  31724 				;
  31725 				relative_x = relative_x + 1
  31726 			}
  31727 			if update_up_to_index > uint32(0) {
  31728 				subsampling_index = uint32(1)
  31729 				for {
  31730 					if !(subsampling_index <= update_up_to_index) {
  31731 						break
  31732 					}
  31733 					super_histo = GetHistoArgb(tls, all_argb, libc.Int32FromUint32(subsampling_index), mode)
  31734 					relative_x = 0
  31735 					for {
  31736 						if !(relative_x < max_x) {
  31737 							break
  31738 						}
  31739 						UpdateHisto(tls, super_histo, (**(**[512]uint32_t)(__ccgo_up(bp)))[relative_x])
  31740 						goto _5
  31741 					_5:
  31742 						;
  31743 						relative_x = relative_x + 1
  31744 					}
  31745 					goto _4
  31746 				_4:
  31747 					;
  31748 					subsampling_index = subsampling_index + 1
  31749 				}
  31750 			}
  31751 			goto _2
  31752 		_2:
  31753 			;
  31754 			relative_y = relative_y + 1
  31755 		}
  31756 		goto _1
  31757 	_1:
  31758 		;
  31759 		mode = mode + 1
  31760 	}
  31761 }
  31762 
  31763 // C documentation
  31764 //
  31765 //	// Converts pixels of the image to residuals with respect to predictions.
  31766 //	// If max_quantization > 1, applies near lossless processing, quantizing
  31767 //	// residuals to multiples of quantization levels up to max_quantization
  31768 //	// (the actual quantization level depends on smoothness near the given pixel).
  31769 func CopyImageWithPrediction(tls *libc.TLS, width int32, height int32, bits int32, modes uintptr, argb_scratch uintptr, argb uintptr, low_effort int32, max_quantization int32, exact int32, used_subtract_green int32) {
  31770 	var current_max_diffs, current_row, lower_max_diffs, tmp32, tmp8, upper_row uintptr
  31771 	var mode, tiles_per_row, x, x_end, y int32
  31772 	var v1, v2 uint32_t
  31773 	_, _, _, _, _, _, _, _, _, _, _, _, _ = current_max_diffs, current_row, lower_max_diffs, mode, tiles_per_row, tmp32, tmp8, upper_row, x, x_end, y, v1, v2
  31774 	v1 = libc.Uint32FromInt32(bits)
  31775 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31776 	goto _3
  31777 _3:
  31778 	tiles_per_row = libc.Int32FromUint32(v2)
  31779 	// The width of upper_row and current_row is one pixel larger than image width
  31780 	// to allow the top right pixel to point to the leftmost pixel of the next row
  31781 	// when at the right edge.
  31782 	upper_row = argb_scratch
  31783 	current_row = upper_row + uintptr(width)*4 + uintptr(1)*4
  31784 	current_max_diffs = current_row + uintptr(width)*4 + libc.UintptrFromInt32(1)*4
  31785 	lower_max_diffs = current_max_diffs + uintptr(width)
  31786 	y = 0
  31787 	for {
  31788 		if !(y < height) {
  31789 			break
  31790 		}
  31791 		tmp32 = upper_row
  31792 		upper_row = current_row
  31793 		current_row = tmp32
  31794 		libc.X__builtin___memcpy_chk(tls, current_row, argb+uintptr(y*width)*4, uint64(4)*libc.Uint64FromInt32(width+libc.BoolInt32(y+libc.Int32FromInt32(1) < height)), ^__predefined_size_t(0))
  31795 		if low_effort != 0 {
  31796 			PredictBatch(tls, kPredLowEffort, 0, y, width, current_row, upper_row, argb+uintptr(y*width)*4)
  31797 		} else {
  31798 			if max_quantization > int32(1) {
  31799 				// Compute max_diffs for the lower row now, because that needs the
  31800 				// contents of argb for the current row, which we will overwrite with
  31801 				// residuals before proceeding with the next row.
  31802 				tmp8 = current_max_diffs
  31803 				current_max_diffs = lower_max_diffs
  31804 				lower_max_diffs = tmp8
  31805 				if y+int32(2) < height {
  31806 					MaxDiffsForRow(tls, width, width, argb+uintptr((y+int32(1))*width)*4, lower_max_diffs, used_subtract_green)
  31807 				}
  31808 			}
  31809 			x = 0
  31810 			for {
  31811 				if !(x < width) {
  31812 					break
  31813 				}
  31814 				mode = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(modes + uintptr(y>>bits*tiles_per_row+x>>bits)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  31815 				x_end = x + int32(1)<<bits
  31816 				if x_end > width {
  31817 					x_end = width
  31818 				}
  31819 				GetResidual(tls, width, height, upper_row, current_row, current_max_diffs, mode, x, x_end, y, max_quantization, exact, used_subtract_green, argb+uintptr(y*width)*4+uintptr(x)*4)
  31820 				x = x_end
  31821 				goto _5
  31822 			_5:
  31823 			}
  31824 		}
  31825 		goto _4
  31826 	_4:
  31827 		;
  31828 		y = y + 1
  31829 	}
  31830 }
  31831 
  31832 // C documentation
  31833 //
  31834 //	// Checks whether 'image' can be subsampled by finding the biggest power of 2
  31835 //	// squares (defined by 'best_bits') of uniform value it is made out of.
  31836 func VP8LOptimizeSampling(tls *libc.TLS, image uintptr, full_width int32, full_height int32, bits int32, max_bits int32, best_bits_out uintptr) {
  31837 	var best_bits, height, i, is_good, is_good1, new_square_size, old_width, square_size, width, x, y int32
  31838 	var v1, v2, v4, v5 uint32_t
  31839 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_bits, height, i, is_good, is_good1, new_square_size, old_width, square_size, width, x, y, v1, v2, v4, v5
  31840 	v1 = libc.Uint32FromInt32(bits)
  31841 	v2 = (libc.Uint32FromInt32(full_width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31842 	goto _3
  31843 _3:
  31844 	width = libc.Int32FromUint32(v2)
  31845 	v4 = libc.Uint32FromInt32(bits)
  31846 	v5 = (libc.Uint32FromInt32(full_height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  31847 	goto _6
  31848 _6:
  31849 	height = libc.Int32FromUint32(v5)
  31850 	best_bits = bits
  31851 	**(**int32)(__ccgo_up(best_bits_out)) = bits
  31852 	// Check rows first.
  31853 	for best_bits < max_bits {
  31854 		new_square_size = int32(1) << (best_bits + int32(1) - bits)
  31855 		is_good = int32(1)
  31856 		square_size = int32(1) << (best_bits - bits)
  31857 		y = 0
  31858 		for {
  31859 			if !(y+square_size < height) {
  31860 				break
  31861 			}
  31862 			// Check the first lines of consecutive line groups.
  31863 			if libc.Xmemcmp(tls, image+uintptr(y*width)*4, image+uintptr((y+square_size)*width)*4, libc.Uint64FromInt32(width)*uint64(4)) != 0 {
  31864 				is_good = 0
  31865 				break
  31866 			}
  31867 			goto _7
  31868 		_7:
  31869 			;
  31870 			y = y + new_square_size
  31871 		}
  31872 		if is_good != 0 {
  31873 			best_bits = best_bits + 1
  31874 		} else {
  31875 			break
  31876 		}
  31877 	}
  31878 	if best_bits == bits {
  31879 		return
  31880 	}
  31881 	// Check columns.
  31882 	for best_bits > bits {
  31883 		is_good1 = int32(1)
  31884 		square_size = int32(1) << (best_bits - bits)
  31885 		y = 0
  31886 		for {
  31887 			if !(is_good1 != 0 && y < height) {
  31888 				break
  31889 			}
  31890 			x = 0
  31891 			for {
  31892 				if !(is_good1 != 0 && x < width) {
  31893 					break
  31894 				}
  31895 				i = x + int32(1)
  31896 				for {
  31897 					if !(i < GetMin(tls, x+square_size, width)) {
  31898 						break
  31899 					}
  31900 					if **(**uint32_t)(__ccgo_up(image + uintptr(y*width+i)*4)) != **(**uint32_t)(__ccgo_up(image + uintptr(y*width+x)*4)) {
  31901 						is_good1 = 0
  31902 						break
  31903 					}
  31904 					goto _10
  31905 				_10:
  31906 					;
  31907 					i = i + 1
  31908 				}
  31909 				goto _9
  31910 			_9:
  31911 				;
  31912 				x = x + square_size
  31913 			}
  31914 			goto _8
  31915 		_8:
  31916 			;
  31917 			y = y + 1
  31918 		}
  31919 		if is_good1 != 0 {
  31920 			break
  31921 		}
  31922 		best_bits = best_bits - 1
  31923 	}
  31924 	if best_bits == bits {
  31925 		return
  31926 	}
  31927 	// Subsample the image.
  31928 	old_width = width
  31929 	square_size = int32(1) << (best_bits - bits)
  31930 	v1 = libc.Uint32FromInt32(best_bits)
  31931 	v2 = (libc.Uint32FromInt32(full_width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31932 	goto _13
  31933 _13:
  31934 	width = libc.Int32FromUint32(v2)
  31935 	v1 = libc.Uint32FromInt32(best_bits)
  31936 	v2 = (libc.Uint32FromInt32(full_height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31937 	goto _16
  31938 _16:
  31939 	height = libc.Int32FromUint32(v2)
  31940 	y = 0
  31941 	for {
  31942 		if !(y < height) {
  31943 			break
  31944 		}
  31945 		x = 0
  31946 		for {
  31947 			if !(x < width) {
  31948 				break
  31949 			}
  31950 			**(**uint32_t)(__ccgo_up(image + uintptr(y*width+x)*4)) = **(**uint32_t)(__ccgo_up(image + uintptr(square_size*(y*old_width+x))*4))
  31951 			goto _18
  31952 		_18:
  31953 			;
  31954 			x = x + 1
  31955 		}
  31956 		goto _17
  31957 	_17:
  31958 		;
  31959 		y = y + 1
  31960 	}
  31961 	**(**int32)(__ccgo_up(best_bits_out)) = best_bits
  31962 }
  31963 
  31964 // C documentation
  31965 //
  31966 //	// Computes the best predictor image.
  31967 //	// Finds the best predictors per tile. Once done, finds the best predictor image
  31968 //	// sampling.
  31969 //	// best_bits is set to 0 in case of error.
  31970 //	// The following requires some glossary:
  31971 //	// - a tile is a square of side 2^min_bits pixels.
  31972 //	// - a super-tile of a tile is a square of side 2^bits pixels with bits in
  31973 //	// [min_bits+1, max_bits].
  31974 //	// - the max-tile of a tile is the square of 2^max_bits pixels containing it.
  31975 //	//   If this max-tile crosses the border of an image, it is cropped.
  31976 //	// - tile, super-tiles and max_tile are aligned on powers of 2 in the original
  31977 //	//   image.
  31978 //	// - coordinates for tile, super-tile, max-tile are respectively named
  31979 //	//   tile_x, super_tile_x, max_tile_x at their bit scale.
  31980 //	// - in the max-tile, a tile has local coordinates (local_tile_x, local_tile_y).
  31981 //	// The tiles are processed in the following zigzag order to complete the
  31982 //	// super-tiles as soon as possible:
  31983 //	//   1  2|  5  6
  31984 //	//   3  4|  7  8
  31985 //	// --------------
  31986 //	//   9 10| 13 14
  31987 //	//  11 12| 15 16
  31988 //	// When computing the residuals for a tile, the histogram of the above
  31989 //	// super-tile is updated. If this super-tile is finished, its histogram is used
  31990 //	// to update the histogram of the next super-tile and so on up to the max-tile.
  31991 func GetBestPredictorsAndSubSampling(tls *libc.TLS, width int32, height int32, min_bits int32, max_bits int32, argb_scratch uintptr, argb uintptr, max_quantization int32, exact int32, used_subtract_green int32, pic uintptr, percent_range int32, percent uintptr, all_modes uintptr, best_bits uintptr, best_mode uintptr) {
  31992 	var accumulated, all_accumulated_argb, all_argb, all_pred_histos, raw_data uintptr
  31993 	var best_cost, cost int64_t
  31994 	var coord_x, coord_y, local_tile_x, local_tile_y, max_subsampling_index, max_tile_x, max_tile_y, subsampling_index, super_tile_x, super_tile_y, super_tiles_per_row, tile_x, tile_y, tiles_per_col, tiles_per_row, update_up_to_index, v1, v2, v4, v5 uint32_t
  31995 	var max_tile_size, num_accumulated_rgb, num_argb, num_predictors, percent_start, plane int32
  31996 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = accumulated, all_accumulated_argb, all_argb, all_pred_histos, best_cost, coord_x, coord_y, cost, local_tile_x, local_tile_y, max_subsampling_index, max_tile_size, max_tile_x, max_tile_y, num_accumulated_rgb, num_argb, num_predictors, percent_start, plane, raw_data, subsampling_index, super_tile_x, super_tile_y, super_tiles_per_row, tile_x, tile_y, tiles_per_col, tiles_per_row, update_up_to_index, v1, v2, v4, v5
  31997 	v1 = libc.Uint32FromInt32(min_bits)
  31998 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31999 	goto _3
  32000 _3:
  32001 	tiles_per_row = v2
  32002 	v4 = libc.Uint32FromInt32(min_bits)
  32003 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  32004 	goto _6
  32005 _6:
  32006 	tiles_per_col = v5
  32007 	max_subsampling_index = libc.Uint32FromInt32(max_bits - min_bits)
  32008 	// Compute the needed memory size for residual histograms, accumulated
  32009 	// residual histograms and predictor histograms.
  32010 	num_argb = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(kNumPredModes) * libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))
  32011 	num_accumulated_rgb = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))
  32012 	num_predictors = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(kNumPredModes))
  32013 	raw_data = WebPSafeCalloc(tls, libc.Uint64FromInt32(num_argb+num_accumulated_rgb+num_predictors), uint64(4))
  32014 	all_argb = raw_data
  32015 	all_accumulated_argb = all_argb + uintptr(num_argb)*4
  32016 	all_pred_histos = all_accumulated_argb + uintptr(num_accumulated_rgb)*4
  32017 	max_tile_size = int32(1) << max_subsampling_index // in tile size
  32018 	percent_start = **(**int32)(__ccgo_up(percent))
  32019 	// When using the residuals of a tile for its super-tiles, you can either:
  32020 	// - use each residual to update the histogram of the super-tile, with a cost
  32021 	//   of 4 * (1<<n)^2 increment operations (4 for the number of channels, and
  32022 	//   (1<<n)^2 for the number of pixels in the tile)
  32023 	// - use the histogram of the tile to update the histogram of the super-tile,
  32024 	//   with a cost of HISTO_SIZE (1024)
  32025 	// The first method is therefore faster until n==4. 'update_up_to_index'
  32026 	// defines the maximum subsampling_index for which the residuals should be
  32027 	// individually added to the super-tile histogram.
  32028 	update_up_to_index = libc.Uint32FromInt32(GetMax(tls, GetMin(tls, int32(4), max_bits), min_bits) - min_bits)
  32029 	// Coordinates in the max-tile in tile units.
  32030 	local_tile_x = uint32(0)
  32031 	local_tile_y = uint32(0)
  32032 	max_tile_x = uint32(0)
  32033 	max_tile_y = uint32(0)
  32034 	tile_x = uint32(0)
  32035 	tile_y = uint32(0)
  32036 	**(**int32)(__ccgo_up(best_bits)) = 0
  32037 	**(**uintptr)(__ccgo_up(best_mode)) = libc.UintptrFromInt32(0)
  32038 	if raw_data == libc.UintptrFromInt32(0) {
  32039 		return
  32040 	}
  32041 	for tile_y < tiles_per_col {
  32042 		ComputeResidualsForTile(tls, width, height, libc.Int32FromUint32(tile_x), libc.Int32FromUint32(tile_y), min_bits, update_up_to_index, all_argb, argb_scratch, argb, max_quantization, exact, used_subtract_green)
  32043 		// Update all the super-tiles that are complete.
  32044 		subsampling_index = uint32(0)
  32045 		for int32(1) != 0 {
  32046 			super_tile_x = tile_x >> subsampling_index
  32047 			super_tile_y = tile_y >> subsampling_index
  32048 			v1 = libc.Uint32FromInt32(min_bits) + subsampling_index
  32049 			v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  32050 			goto _9
  32051 		_9:
  32052 			super_tiles_per_row = v2
  32053 			GetBestPredictorForTile(tls, all_argb, libc.Int32FromUint32(subsampling_index), libc.Int32FromUint32(super_tile_x), libc.Int32FromUint32(super_tile_y), libc.Int32FromUint32(super_tiles_per_row), all_accumulated_argb, all_modes, all_pred_histos)
  32054 			if subsampling_index == max_subsampling_index {
  32055 				break
  32056 			}
  32057 			// Update the following super-tile histogram if it has not been updated
  32058 			// yet.
  32059 			subsampling_index = subsampling_index + 1
  32060 			if subsampling_index > update_up_to_index && subsampling_index <= max_subsampling_index {
  32061 				(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVectorEq})))(tls, GetHistoArgbConst(tls, all_argb, libc.Int32FromUint32(subsampling_index-uint32(1)), 0), GetHistoArgb(tls, all_argb, libc.Int32FromUint32(subsampling_index), 0), libc.Int32FromInt32(4)*libc.Int32FromInt32(256)*kNumPredModes)
  32062 			}
  32063 			// Check whether the super-tile is not complete (if the smallest tile
  32064 			// is not at the end of a line/column or at the beginning of a super-tile
  32065 			// of size (1 << subsampling_index)).
  32066 			if !((tile_x == tiles_per_row-uint32(1) || (local_tile_x+uint32(1))%libc.Uint32FromInt32(libc.Int32FromInt32(1)<<subsampling_index) == uint32(0)) && (tile_y == tiles_per_col-uint32(1) || (local_tile_y+uint32(1))%libc.Uint32FromInt32(libc.Int32FromInt32(1)<<subsampling_index) == uint32(0))) {
  32067 				subsampling_index = subsampling_index - 1
  32068 				// subsampling_index now is the index of the last finished super-tile.
  32069 				break
  32070 			}
  32071 		}
  32072 		// Reset all the histograms belonging to finished tiles.
  32073 		libc.X__builtin___memset_chk(tls, all_argb, 0, uint64(libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)*kNumPredModes)*(subsampling_index+uint32(1)))*uint64(4), ^__predefined_size_t(0))
  32074 		if subsampling_index == max_subsampling_index {
  32075 			// If a new max-tile is started.
  32076 			if tile_x == tiles_per_row-uint32(1) {
  32077 				max_tile_x = uint32(0)
  32078 				max_tile_y = max_tile_y + 1
  32079 			} else {
  32080 				max_tile_x = max_tile_x + 1
  32081 			}
  32082 			local_tile_x = uint32(0)
  32083 			local_tile_y = uint32(0)
  32084 		} else {
  32085 			// Proceed with the Z traversal.
  32086 			coord_x = local_tile_x >> subsampling_index
  32087 			coord_y = local_tile_y >> subsampling_index
  32088 			if tile_x == tiles_per_row-uint32(1) && coord_x%uint32(2) == uint32(0) {
  32089 				coord_y = coord_y + 1
  32090 			} else {
  32091 				if coord_x%uint32(2) == uint32(0) {
  32092 					coord_x = coord_x + 1
  32093 				} else {
  32094 					// Z traversal.
  32095 					coord_y = coord_y + 1
  32096 					coord_x = coord_x - 1
  32097 				}
  32098 			}
  32099 			local_tile_x = coord_x << subsampling_index
  32100 			local_tile_y = coord_y << subsampling_index
  32101 		}
  32102 		tile_x = max_tile_x*libc.Uint32FromInt32(max_tile_size) + local_tile_x
  32103 		tile_y = max_tile_y*libc.Uint32FromInt32(max_tile_size) + local_tile_y
  32104 		if tile_x == uint32(0) && !(WebPReportProgress(tls, pic, libc.Int32FromUint32(libc.Uint32FromInt32(percent_start)+libc.Uint32FromInt32(percent_range)*tile_y/tiles_per_col), percent) != 0) {
  32105 			WebPSafeFree(tls, raw_data)
  32106 			return
  32107 		}
  32108 	}
  32109 	// Figure out the best sampling.
  32110 	best_cost = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  32111 	subsampling_index = uint32(0)
  32112 	for {
  32113 		if !(subsampling_index <= max_subsampling_index) {
  32114 			break
  32115 		}
  32116 		accumulated = GetAccumulatedHisto(tls, all_accumulated_argb, libc.Int32FromUint32(subsampling_index))
  32117 		cost = libc.Int64FromUint64((*(*func(*libc.TLS, uintptr, int32) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LShannonEntropy})))(tls, all_pred_histos+uintptr(subsampling_index*libc.Uint32FromInt32(kNumPredModes))*4, kNumPredModes))
  32118 		plane = 0
  32119 		for {
  32120 			if !(plane < int32(4)) {
  32121 				break
  32122 			}
  32123 			cost = libc.Int64FromUint64(uint64(cost) + (*(*func(*libc.TLS, uintptr, int32) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LShannonEntropy})))(tls, accumulated+uintptr(plane*int32(256))*4, int32(256)))
  32124 			goto _11
  32125 		_11:
  32126 			;
  32127 			plane = plane + 1
  32128 		}
  32129 		if cost < best_cost {
  32130 			best_cost = cost
  32131 			**(**int32)(__ccgo_up(best_bits)) = libc.Int32FromUint32(libc.Uint32FromInt32(min_bits) + subsampling_index)
  32132 			**(**uintptr)(__ccgo_up(best_mode)) = **(**uintptr)(__ccgo_up(all_modes + uintptr(subsampling_index)*8))
  32133 		}
  32134 		goto _10
  32135 	_10:
  32136 		;
  32137 		subsampling_index = subsampling_index + 1
  32138 	}
  32139 	WebPSafeFree(tls, raw_data)
  32140 	VP8LOptimizeSampling(tls, **(**uintptr)(__ccgo_up(best_mode)), width, height, **(**int32)(__ccgo_up(best_bits)), libc.Int32FromInt32(MIN_TRANSFORM_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_TRANSFORM_BITS)-libc.Int32FromInt32(1), best_bits)
  32141 }
  32142 
  32143 // C documentation
  32144 //
  32145 //	// Finds the best predictor for each tile, and converts the image to residuals
  32146 //	// with respect to predictions. If near_lossless_quality < 100, applies
  32147 //	// near lossless processing, shaving off more bits of residuals for lower
  32148 //	// qualities.
  32149 func VP8LResidualImage(tls *libc.TLS, width int32, height int32, min_bits int32, max_bits int32, low_effort int32, argb uintptr, argb_scratch uintptr, image uintptr, near_lossless_quality1 int32, exact int32, used_subtract_green int32, pic uintptr, percent_range int32, percent uintptr, best_bits uintptr) (r int32) {
  32150 	bp := tls.Alloc(96)
  32151 	defer tls.Free(96)
  32152 	var bits, i, max_quantization, percent_start, tiles_per_col, tiles_per_col1, tiles_per_row, tiles_per_row1, v1 int32
  32153 	var modes_raw uintptr
  32154 	var num_pixels [10]uint32_t
  32155 	var sum_num_pixels, v3, v4, v6, v7 uint32_t
  32156 	var _ /* best_mode at bp+0 */ uintptr
  32157 	var _ /* modes at bp+8 */ [10]uintptr
  32158 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bits, i, max_quantization, modes_raw, num_pixels, percent_start, sum_num_pixels, tiles_per_col, tiles_per_col1, tiles_per_row, tiles_per_row1, v1, v3, v4, v6, v7
  32159 	percent_start = **(**int32)(__ccgo_up(percent))
  32160 	v1 = int32(5) - near_lossless_quality1/int32(20)
  32161 	goto _2
  32162 _2:
  32163 	max_quantization = int32(1) << v1
  32164 	if low_effort != 0 {
  32165 		v3 = libc.Uint32FromInt32(max_bits)
  32166 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32167 		goto _5
  32168 	_5:
  32169 		tiles_per_row = libc.Int32FromUint32(v4)
  32170 		v6 = libc.Uint32FromInt32(max_bits)
  32171 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32172 		goto _8
  32173 	_8:
  32174 		tiles_per_col = libc.Int32FromUint32(v7)
  32175 		i = 0
  32176 		for {
  32177 			if !(i < tiles_per_row*tiles_per_col) {
  32178 				break
  32179 			}
  32180 			**(**uint32_t)(__ccgo_up(image + uintptr(i)*4)) = uint32(ARGB_BLACK1) | libc.Uint32FromInt32(kPredLowEffort<<libc.Int32FromInt32(8))
  32181 			goto _9
  32182 		_9:
  32183 			;
  32184 			i = i + 1
  32185 		}
  32186 		**(**int32)(__ccgo_up(best_bits)) = max_bits
  32187 	} else {
  32188 		sum_num_pixels = 0
  32189 		bits = min_bits
  32190 		for {
  32191 			if !(bits <= max_bits) {
  32192 				break
  32193 			}
  32194 			v3 = libc.Uint32FromInt32(bits)
  32195 			v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32196 			goto _13
  32197 		_13:
  32198 			tiles_per_row1 = libc.Int32FromUint32(v4)
  32199 			v6 = libc.Uint32FromInt32(bits)
  32200 			v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32201 			goto _16
  32202 		_16:
  32203 			tiles_per_col1 = libc.Int32FromUint32(v7)
  32204 			num_pixels[bits] = libc.Uint32FromInt32(tiles_per_row1 * tiles_per_col1)
  32205 			sum_num_pixels = sum_num_pixels + num_pixels[bits]
  32206 			goto _10
  32207 		_10:
  32208 			;
  32209 			bits = bits + 1
  32210 		}
  32211 		modes_raw = WebPSafeMalloc(tls, uint64(sum_num_pixels), uint64(4))
  32212 		if modes_raw == libc.UintptrFromInt32(0) {
  32213 			return 0
  32214 		}
  32215 		// Have modes point to the right global memory modes_raw.
  32216 		(**(**[10]uintptr)(__ccgo_up(bp + 8)))[min_bits] = modes_raw
  32217 		bits = min_bits + int32(1)
  32218 		for {
  32219 			if !(bits <= max_bits) {
  32220 				break
  32221 			}
  32222 			(**(**[10]uintptr)(__ccgo_up(bp + 8)))[bits] = (**(**[10]uintptr)(__ccgo_up(bp + 8)))[bits-int32(1)] + uintptr(num_pixels[bits-int32(1)])*4
  32223 			goto _17
  32224 		_17:
  32225 			;
  32226 			bits = bits + 1
  32227 		}
  32228 		// Find the best sampling.
  32229 		GetBestPredictorsAndSubSampling(tls, width, height, min_bits, max_bits, argb_scratch, argb, max_quantization, exact, used_subtract_green, pic, percent_range, percent, bp+8+uintptr(min_bits)*8, best_bits, bp)
  32230 		if **(**int32)(__ccgo_up(best_bits)) == 0 {
  32231 			WebPSafeFree(tls, modes_raw)
  32232 			return 0
  32233 		}
  32234 		// Keep the best predictor image.
  32235 		v3 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  32236 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32237 		goto _20
  32238 	_20:
  32239 		v6 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  32240 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32241 		goto _23
  32242 	_23:
  32243 		libc.X__builtin___memcpy_chk(tls, image, **(**uintptr)(__ccgo_up(bp)), uint64(v4*v7)*uint64(4), ^__predefined_size_t(0))
  32244 		WebPSafeFree(tls, modes_raw)
  32245 	}
  32246 	CopyImageWithPrediction(tls, width, height, **(**int32)(__ccgo_up(best_bits)), image, argb_scratch, argb, low_effort, max_quantization, exact, used_subtract_green)
  32247 	return WebPReportProgress(tls, pic, percent_start+percent_range, percent)
  32248 }
  32249 
  32250 //------------------------------------------------------------------------------
  32251 // Color transform functions.
  32252 
  32253 func MultipliersClear(tls *libc.TLS, m uintptr) {
  32254 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(0)
  32255 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(0)
  32256 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(0)
  32257 }
  32258 
  32259 func ColorCodeToMultipliers(tls *libc.TLS, color_code uint32_t, m uintptr) {
  32260 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(color_code >> libc.Int32FromInt32(0) & uint32(0xff))
  32261 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(color_code >> libc.Int32FromInt32(8) & uint32(0xff))
  32262 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(color_code >> libc.Int32FromInt32(16) & uint32(0xff))
  32263 }
  32264 
  32265 func MultipliersToColorCode(tls *libc.TLS, m uintptr) (r uint32_t) {
  32266 	return uint32(0xff000000) | uint32((*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue)<<libc.Int32FromInt32(16) | uint32((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue)<<libc.Int32FromInt32(8) | uint32((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red)
  32267 }
  32268 
  32269 func PredictionCostCrossColor(tls *libc.TLS, accumulated uintptr, counts uintptr) (r int64_t) {
  32270 	return libc.Int64FromUint64((*(*func(*libc.TLS, uintptr, uintptr) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LCombinedShannonEntropy})))(tls, counts, accumulated)) + PredictionCostBias(tls, counts, uint64(3), kExpValue)
  32271 }
  32272 
  32273 // Favor low entropy, locally and globally.
  32274 // Favor small absolute values for PredictionCostSpatial
  32275 var kExpValue = uint64(240)
  32276 
  32277 func GetPredictionCostCrossColorRed(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, prev_x VP8LMultipliers, prev_y VP8LMultipliers, green_to_red int32, accumulated_red_histo uintptr) (r int64_t) {
  32278 	bp := tls.Alloc(1024)
  32279 	defer tls.Free(1024)
  32280 	var cur_diff int64_t
  32281 	var _ /* histo at bp+0 */ [256]uint32_t
  32282 	_ = cur_diff
  32283 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32284 	(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LCollectColorRedTransforms})))(tls, argb, stride, tile_width, tile_height, green_to_red, bp)
  32285 	cur_diff = PredictionCostCrossColor(tls, accumulated_red_histo, bp)
  32286 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_red)) == libc.Int32FromUint8(prev_x.Fgreen_to_red) {
  32287 		// favor keeping the areas locally similar
  32288 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32289 	}
  32290 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_red)) == libc.Int32FromUint8(prev_y.Fgreen_to_red) {
  32291 		// favor keeping the areas locally similar
  32292 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32293 	}
  32294 	if green_to_red == 0 {
  32295 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32296 	}
  32297 	return cur_diff
  32298 }
  32299 
  32300 func GetBestGreenToRed(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, prev_x VP8LMultipliers, prev_y VP8LMultipliers, quality int32, accumulated_red_histo uintptr, best_tx uintptr) {
  32301 	var best_diff, cur_diff int64_t
  32302 	var delta, green_to_red_best, green_to_red_cur, iter, kMaxIters, offset int32
  32303 	_, _, _, _, _, _, _, _ = best_diff, cur_diff, delta, green_to_red_best, green_to_red_cur, iter, kMaxIters, offset
  32304 	kMaxIters = int32(4) + int32(7)*quality>>int32(8) // in range [4..6]
  32305 	green_to_red_best = 0
  32306 	best_diff = GetPredictionCostCrossColorRed(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_red_best, accumulated_red_histo)
  32307 	iter = 0
  32308 	for {
  32309 		if !(iter < kMaxIters) {
  32310 			break
  32311 		}
  32312 		// ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to
  32313 		// one in color computation. Having initial delta here as 1 is sufficient
  32314 		// to explore the range of (-2, 2).
  32315 		delta = int32(32) >> iter
  32316 		// Try a negative and a positive delta from the best known value.
  32317 		offset = -delta
  32318 		for {
  32319 			if !(offset <= delta) {
  32320 				break
  32321 			}
  32322 			green_to_red_cur = offset + green_to_red_best
  32323 			cur_diff = GetPredictionCostCrossColorRed(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_red_cur, accumulated_red_histo)
  32324 			if cur_diff < best_diff {
  32325 				best_diff = cur_diff
  32326 				green_to_red_best = green_to_red_cur
  32327 			}
  32328 			goto _2
  32329 		_2:
  32330 			;
  32331 			offset = offset + int32(2)*delta
  32332 		}
  32333 		goto _1
  32334 	_1:
  32335 		;
  32336 		iter = iter + 1
  32337 	}
  32338 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fgreen_to_red = libc.Uint8FromInt32(green_to_red_best & libc.Int32FromInt32(0xff))
  32339 }
  32340 
  32341 func GetPredictionCostCrossColorBlue(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, prev_x VP8LMultipliers, prev_y VP8LMultipliers, green_to_blue int32, red_to_blue int32, accumulated_blue_histo uintptr) (r int64_t) {
  32342 	bp := tls.Alloc(1024)
  32343 	defer tls.Free(1024)
  32344 	var cur_diff int64_t
  32345 	var _ /* histo at bp+0 */ [256]uint32_t
  32346 	_ = cur_diff
  32347 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32348 	(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LCollectColorBlueTransforms})))(tls, argb, stride, tile_width, tile_height, green_to_blue, red_to_blue, bp)
  32349 	cur_diff = PredictionCostCrossColor(tls, accumulated_blue_histo, bp)
  32350 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_blue)) == libc.Int32FromUint8(prev_x.Fgreen_to_blue) {
  32351 		// favor keeping the areas locally similar
  32352 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32353 	}
  32354 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_blue)) == libc.Int32FromUint8(prev_y.Fgreen_to_blue) {
  32355 		// favor keeping the areas locally similar
  32356 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32357 	}
  32358 	if libc.Int32FromUint8(libc.Uint8FromInt32(red_to_blue)) == libc.Int32FromUint8(prev_x.Fred_to_blue) {
  32359 		// favor keeping the areas locally similar
  32360 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32361 	}
  32362 	if libc.Int32FromUint8(libc.Uint8FromInt32(red_to_blue)) == libc.Int32FromUint8(prev_y.Fred_to_blue) {
  32363 		// favor keeping the areas locally similar
  32364 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32365 	}
  32366 	if green_to_blue == 0 {
  32367 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32368 	}
  32369 	if red_to_blue == 0 {
  32370 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32371 	}
  32372 	return cur_diff
  32373 }
  32374 
  32375 func GetBestGreenRedToBlue(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, prev_x VP8LMultipliers, prev_y VP8LMultipliers, quality int32, accumulated_blue_histo uintptr, best_tx uintptr) {
  32376 	bp := tls.Alloc(16)
  32377 	defer tls.Free(16)
  32378 	var axis, delta, green_to_blue_best, green_to_blue_cur, iter, iters, red_to_blue_best, red_to_blue_cur, v1, v2 int32
  32379 	var best_diff, cur_diff int64_t
  32380 	var delta_lut [7]int8_t
  32381 	var _ /* offset at bp+0 */ [8][2]int8_t
  32382 	_, _, _, _, _, _, _, _, _, _, _, _, _ = axis, best_diff, cur_diff, delta, delta_lut, green_to_blue_best, green_to_blue_cur, iter, iters, red_to_blue_best, red_to_blue_cur, v1, v2
  32383 	**(**[8][2]int8_t)(__ccgo_up(bp)) = [8][2]int8_t{
  32384 		0: {
  32385 			1: int8(-int32(1)),
  32386 		},
  32387 		1: {
  32388 			1: int8(1),
  32389 		},
  32390 		2: {
  32391 			0: int8(-int32(1)),
  32392 		},
  32393 		3: {
  32394 			0: int8(1),
  32395 		},
  32396 		4: {
  32397 			0: int8(-int32(1)),
  32398 			1: int8(-int32(1)),
  32399 		},
  32400 		5: {
  32401 			0: int8(-int32(1)),
  32402 			1: int8(1),
  32403 		},
  32404 		6: {
  32405 			0: int8(1),
  32406 			1: int8(-int32(1)),
  32407 		},
  32408 		7: {
  32409 			0: int8(1),
  32410 			1: int8(1),
  32411 		},
  32412 	}
  32413 	delta_lut = [7]int8_t{
  32414 		0: int8(16),
  32415 		1: int8(16),
  32416 		2: int8(8),
  32417 		3: int8(4),
  32418 		4: int8(2),
  32419 		5: int8(2),
  32420 		6: int8(2),
  32421 	}
  32422 	if quality < int32(25) {
  32423 		v1 = int32(1)
  32424 	} else {
  32425 		if quality > int32(50) {
  32426 			v2 = int32(7)
  32427 		} else {
  32428 			v2 = int32(4)
  32429 		}
  32430 		v1 = v2
  32431 	}
  32432 	iters = v1
  32433 	green_to_blue_best = 0
  32434 	red_to_blue_best = 0
  32435 	// Initial value at origin:
  32436 	best_diff = GetPredictionCostCrossColorBlue(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_blue_best, red_to_blue_best, accumulated_blue_histo)
  32437 	iter = 0
  32438 	for {
  32439 		if !(iter < iters) {
  32440 			break
  32441 		}
  32442 		delta = int32(delta_lut[iter])
  32443 		axis = 0
  32444 		for {
  32445 			if !(axis < int32(8)) {
  32446 				break
  32447 			}
  32448 			green_to_blue_cur = int32(**(**int8_t)(__ccgo_up(bp + uintptr(axis)*2)))*delta + green_to_blue_best
  32449 			red_to_blue_cur = int32(**(**int8_t)(__ccgo_up(bp + uintptr(axis)*2 + 1)))*delta + red_to_blue_best
  32450 			cur_diff = GetPredictionCostCrossColorBlue(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_blue_cur, red_to_blue_cur, accumulated_blue_histo)
  32451 			if cur_diff < best_diff {
  32452 				best_diff = cur_diff
  32453 				green_to_blue_best = green_to_blue_cur
  32454 				red_to_blue_best = red_to_blue_cur
  32455 			}
  32456 			if quality < int32(25) && iter == int32(4) {
  32457 				// Only axis aligned diffs for lower quality.
  32458 				break // next iter.
  32459 			}
  32460 			goto _4
  32461 		_4:
  32462 			;
  32463 			axis = axis + 1
  32464 		}
  32465 		if delta == int32(2) && green_to_blue_best == 0 && red_to_blue_best == 0 {
  32466 			// Further iterations would not help.
  32467 			break // out of iter-loop.
  32468 		}
  32469 		goto _3
  32470 	_3:
  32471 		;
  32472 		iter = iter + 1
  32473 	}
  32474 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fgreen_to_blue = libc.Uint8FromInt32(green_to_blue_best & int32(0xff))
  32475 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fred_to_blue = libc.Uint8FromInt32(red_to_blue_best & int32(0xff))
  32476 }
  32477 
  32478 func GetBestColorTransformForTile(tls *libc.TLS, tile_x int32, tile_y int32, bits int32, prev_x VP8LMultipliers, prev_y VP8LMultipliers, quality int32, xsize int32, ysize int32, accumulated_red_histo uintptr, accumulated_blue_histo uintptr, argb uintptr) (r VP8LMultipliers) {
  32479 	bp := tls.Alloc(16)
  32480 	defer tls.Free(16)
  32481 	var all_x_max, all_y_max, max_tile_size, tile_height, tile_width, tile_x_offset, tile_y_offset int32
  32482 	var tile_argb uintptr
  32483 	var _ /* best_tx at bp+0 */ VP8LMultipliers
  32484 	_, _, _, _, _, _, _, _ = all_x_max, all_y_max, max_tile_size, tile_argb, tile_height, tile_width, tile_x_offset, tile_y_offset
  32485 	max_tile_size = int32(1) << bits
  32486 	tile_y_offset = tile_y * max_tile_size
  32487 	tile_x_offset = tile_x * max_tile_size
  32488 	all_x_max = GetMin(tls, tile_x_offset+max_tile_size, xsize)
  32489 	all_y_max = GetMin(tls, tile_y_offset+max_tile_size, ysize)
  32490 	tile_width = all_x_max - tile_x_offset
  32491 	tile_height = all_y_max - tile_y_offset
  32492 	tile_argb = argb + uintptr(tile_y_offset*xsize)*4 + uintptr(tile_x_offset)*4
  32493 	MultipliersClear(tls, bp)
  32494 	GetBestGreenToRed(tls, tile_argb, xsize, tile_width, tile_height, prev_x, prev_y, quality, accumulated_red_histo, bp)
  32495 	GetBestGreenRedToBlue(tls, tile_argb, xsize, tile_width, tile_height, prev_x, prev_y, quality, accumulated_blue_histo, bp)
  32496 	return **(**VP8LMultipliers)(__ccgo_up(bp))
  32497 }
  32498 
  32499 func CopyTileWithColorTransform(tls *libc.TLS, xsize int32, ysize int32, tile_x int32, tile_y int32, max_tile_size int32, _color_transform VP8LMultipliers, argb uintptr) {
  32500 	bp := tls.Alloc(16)
  32501 	defer tls.Free(16)
  32502 	*(*VP8LMultipliers)(unsafe.Pointer(bp)) = _color_transform
  32503 	var xscan, yscan, v1 int32
  32504 	_, _, _ = xscan, yscan, v1
  32505 	xscan = GetMin(tls, max_tile_size, xsize-tile_x)
  32506 	yscan = GetMin(tls, max_tile_size, ysize-tile_y)
  32507 	argb = argb + uintptr(tile_y*xsize+tile_x)*4
  32508 	for {
  32509 		v1 = yscan
  32510 		yscan = yscan - 1
  32511 		if !(v1 > 0) {
  32512 			break
  32513 		}
  32514 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColor})))(tls, bp, argb, xscan)
  32515 		argb = argb + uintptr(xsize)*4
  32516 	}
  32517 }
  32518 
  32519 func VP8LColorSpaceTransform(tls *libc.TLS, width int32, height int32, bits int32, quality int32, argb uintptr, image uintptr, pic uintptr, percent_range int32, percent uintptr, best_bits uintptr) (r int32) {
  32520 	bp := tls.Alloc(2064)
  32521 	defer tls.Free(2064)
  32522 	var all_x_max, all_y_max, ix, ix_end, max_tile_size, offset, percent_start, tile_x, tile_x_offset, tile_xsize, tile_y, tile_y_offset, tile_ysize, y int32
  32523 	var pix, v1, v2, v4, v5 uint32_t
  32524 	var _ /* accumulated_blue_histo at bp+1024 */ [256]uint32_t
  32525 	var _ /* accumulated_red_histo at bp+0 */ [256]uint32_t
  32526 	var _ /* prev_x at bp+2049 */ VP8LMultipliers
  32527 	var _ /* prev_y at bp+2052 */ VP8LMultipliers
  32528 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = all_x_max, all_y_max, ix, ix_end, max_tile_size, offset, percent_start, pix, tile_x, tile_x_offset, tile_xsize, tile_y, tile_y_offset, tile_ysize, y, v1, v2, v4, v5
  32529 	max_tile_size = int32(1) << bits
  32530 	v1 = libc.Uint32FromInt32(bits)
  32531 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  32532 	goto _3
  32533 _3:
  32534 	tile_xsize = libc.Int32FromUint32(v2)
  32535 	v4 = libc.Uint32FromInt32(bits)
  32536 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  32537 	goto _6
  32538 _6:
  32539 	tile_ysize = libc.Int32FromUint32(v5)
  32540 	percent_start = **(**int32)(__ccgo_up(percent))
  32541 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32542 	**(**[256]uint32_t)(__ccgo_up(bp + 1024)) = [256]uint32_t{}
  32543 	MultipliersClear(tls, bp+2052)
  32544 	MultipliersClear(tls, bp+2049)
  32545 	tile_y = 0
  32546 	for {
  32547 		if !(tile_y < tile_ysize) {
  32548 			break
  32549 		}
  32550 		tile_x = 0
  32551 		for {
  32552 			if !(tile_x < tile_xsize) {
  32553 				break
  32554 			}
  32555 			tile_x_offset = tile_x * max_tile_size
  32556 			tile_y_offset = tile_y * max_tile_size
  32557 			all_x_max = GetMin(tls, tile_x_offset+max_tile_size, width)
  32558 			all_y_max = GetMin(tls, tile_y_offset+max_tile_size, height)
  32559 			offset = tile_y*tile_xsize + tile_x
  32560 			if tile_y != 0 {
  32561 				ColorCodeToMultipliers(tls, **(**uint32_t)(__ccgo_up(image + uintptr(offset-tile_xsize)*4)), bp+2052)
  32562 			}
  32563 			**(**VP8LMultipliers)(__ccgo_up(bp + 2049)) = GetBestColorTransformForTile(tls, tile_x, tile_y, bits, **(**VP8LMultipliers)(__ccgo_up(bp + 2049)), **(**VP8LMultipliers)(__ccgo_up(bp + 2052)), quality, width, height, bp, bp+1024, argb)
  32564 			**(**uint32_t)(__ccgo_up(image + uintptr(offset)*4)) = MultipliersToColorCode(tls, bp+2049)
  32565 			CopyTileWithColorTransform(tls, width, height, tile_x_offset, tile_y_offset, max_tile_size, **(**VP8LMultipliers)(__ccgo_up(bp + 2049)), argb)
  32566 			// Gather accumulated histogram data.
  32567 			y = tile_y_offset
  32568 			for {
  32569 				if !(y < all_y_max) {
  32570 					break
  32571 				}
  32572 				ix = y*width + tile_x_offset
  32573 				ix_end = ix + all_x_max - tile_x_offset
  32574 				for {
  32575 					if !(ix < ix_end) {
  32576 						break
  32577 					}
  32578 					pix = **(**uint32_t)(__ccgo_up(argb + uintptr(ix)*4))
  32579 					if ix >= int32(2) && pix == **(**uint32_t)(__ccgo_up(argb + uintptr(ix-int32(2))*4)) && pix == **(**uint32_t)(__ccgo_up(argb + uintptr(ix-int32(1))*4)) {
  32580 						goto _10 // repeated pixels are handled by backward references
  32581 					}
  32582 					if ix >= width+int32(2) && **(**uint32_t)(__ccgo_up(argb + uintptr(ix-int32(2))*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(ix-width-int32(2))*4)) && **(**uint32_t)(__ccgo_up(argb + uintptr(ix-int32(1))*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(ix-width-int32(1))*4)) && pix == **(**uint32_t)(__ccgo_up(argb + uintptr(ix-width)*4)) {
  32583 						goto _10 // repeated pixels are handled by backward references
  32584 					}
  32585 					(**(**[256]uint32_t)(__ccgo_up(bp)))[pix>>libc.Int32FromInt32(16)&uint32(0xff)] = (**(**[256]uint32_t)(__ccgo_up(bp)))[pix>>libc.Int32FromInt32(16)&uint32(0xff)] + 1
  32586 					(**(**[256]uint32_t)(__ccgo_up(bp + 1024)))[pix>>libc.Int32FromInt32(0)&uint32(0xff)] = (**(**[256]uint32_t)(__ccgo_up(bp + 1024)))[pix>>libc.Int32FromInt32(0)&uint32(0xff)] + 1
  32587 					goto _10
  32588 				_10:
  32589 					;
  32590 					ix = ix + 1
  32591 				}
  32592 				goto _9
  32593 			_9:
  32594 				;
  32595 				y = y + 1
  32596 			}
  32597 			goto _8
  32598 		_8:
  32599 			;
  32600 			tile_x = tile_x + 1
  32601 		}
  32602 		if !(WebPReportProgress(tls, pic, percent_start+percent_range*tile_y/tile_ysize, percent) != 0) {
  32603 			return 0
  32604 		}
  32605 		goto _7
  32606 	_7:
  32607 		;
  32608 		tile_y = tile_y + 1
  32609 	}
  32610 	VP8LOptimizeSampling(tls, image, width, height, bits, libc.Int32FromInt32(MIN_TRANSFORM_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_TRANSFORM_BITS)-libc.Int32FromInt32(1), best_bits)
  32611 	return int32(1)
  32612 }
  32613 
  32614 const DO_TRELLIS_I16 = 1
  32615 const DO_TRELLIS_I4 = 1
  32616 const DO_TRELLIS_UV = 0
  32617 const FLATNESS_LIMIT_I16 = 0
  32618 const FLATNESS_LIMIT_I4 = 3
  32619 const FLATNESS_LIMIT_UV = 2
  32620 const FLATNESS_PENALTY = 140
  32621 const FSTRENGTH_CUTOFF = 2
  32622 const IsFlat = "IsFlat_C"
  32623 const MAX_ALPHA1 = 100
  32624 const MAX_DELTA = 1
  32625 const MAX_DQ_UV = 6
  32626 const MID_ALPHA = 64
  32627 const MIN_ALPHA = 30
  32628 const MIN_DELTA = 0
  32629 const RD_DISTO_MULT = 256
  32630 const SHARPEN_BITS = 11
  32631 const SNS_TO_DQ = 0.9
  32632 const USE_TDISTO = 1
  32633 const __FLT_MIN__7 = 1.1754943508222875e-38
  32634 
  32635 //------------------------------------------------------------------------------
  32636 
  32637 // Copyright 2011 Google Inc. All Rights Reserved.
  32638 //
  32639 // Use of this source code is governed by a BSD-style license
  32640 // that can be found in the COPYING file in the root of the source
  32641 // tree. An additional intellectual property rights grant can be found
  32642 // in the file PATENTS. All contributing project authors may
  32643 // be found in the AUTHORS file in the root of the source tree.
  32644 // -----------------------------------------------------------------------------
  32645 //
  32646 //   WebP encoder: internal header.
  32647 //
  32648 // Author: Skal (pascal.massimino@gmail.com)
  32649 
  32650 // Copyright 2010 Google Inc. All Rights Reserved.
  32651 //
  32652 // Use of this source code is governed by a BSD-style license
  32653 // that can be found in the COPYING file in the root of the source
  32654 // tree. An additional intellectual property rights grant can be found
  32655 // in the file PATENTS. All contributing project authors may
  32656 // be found in the AUTHORS file in the root of the source tree.
  32657 // -----------------------------------------------------------------------------
  32658 //
  32659 //  Common types + memory wrappers
  32660 //
  32661 // Author: Skal (pascal.massimino@gmail.com)
  32662 
  32663 // power-law modulation. Must be strictly less than 1.
  32664 
  32665 // number of non-zero coeffs below which we consider the block very flat
  32666 // (and apply a penalty to complex predictions)
  32667 
  32668 // #define DEBUG_BLOCK
  32669 
  32670 //------------------------------------------------------------------------------
  32671 
  32672 //------------------------------------------------------------------------------
  32673 
  32674 func clip2(tls *libc.TLS, v int32, m int32, M int32) (r int32) {
  32675 	var v1, v2 int32
  32676 	_, _ = v1, v2
  32677 	if v < m {
  32678 		v1 = m
  32679 	} else {
  32680 		if v > M {
  32681 			v2 = M
  32682 		} else {
  32683 			v2 = v
  32684 		}
  32685 		v1 = v2
  32686 	}
  32687 	return v1
  32688 }
  32689 
  32690 var kZigzag1 = [16]uint8_t{
  32691 	1:  uint8(1),
  32692 	2:  uint8(4),
  32693 	3:  uint8(8),
  32694 	4:  uint8(5),
  32695 	5:  uint8(2),
  32696 	6:  uint8(3),
  32697 	7:  uint8(6),
  32698 	8:  uint8(9),
  32699 	9:  uint8(12),
  32700 	10: uint8(13),
  32701 	11: uint8(10),
  32702 	12: uint8(7),
  32703 	13: uint8(11),
  32704 	14: uint8(14),
  32705 	15: uint8(15),
  32706 }
  32707 
  32708 var kDcTable1 = [128]uint8_t{
  32709 	0:   uint8(4),
  32710 	1:   uint8(5),
  32711 	2:   uint8(6),
  32712 	3:   uint8(7),
  32713 	4:   uint8(8),
  32714 	5:   uint8(9),
  32715 	6:   uint8(10),
  32716 	7:   uint8(10),
  32717 	8:   uint8(11),
  32718 	9:   uint8(12),
  32719 	10:  uint8(13),
  32720 	11:  uint8(14),
  32721 	12:  uint8(15),
  32722 	13:  uint8(16),
  32723 	14:  uint8(17),
  32724 	15:  uint8(17),
  32725 	16:  uint8(18),
  32726 	17:  uint8(19),
  32727 	18:  uint8(20),
  32728 	19:  uint8(20),
  32729 	20:  uint8(21),
  32730 	21:  uint8(21),
  32731 	22:  uint8(22),
  32732 	23:  uint8(22),
  32733 	24:  uint8(23),
  32734 	25:  uint8(23),
  32735 	26:  uint8(24),
  32736 	27:  uint8(25),
  32737 	28:  uint8(25),
  32738 	29:  uint8(26),
  32739 	30:  uint8(27),
  32740 	31:  uint8(28),
  32741 	32:  uint8(29),
  32742 	33:  uint8(30),
  32743 	34:  uint8(31),
  32744 	35:  uint8(32),
  32745 	36:  uint8(33),
  32746 	37:  uint8(34),
  32747 	38:  uint8(35),
  32748 	39:  uint8(36),
  32749 	40:  uint8(37),
  32750 	41:  uint8(37),
  32751 	42:  uint8(38),
  32752 	43:  uint8(39),
  32753 	44:  uint8(40),
  32754 	45:  uint8(41),
  32755 	46:  uint8(42),
  32756 	47:  uint8(43),
  32757 	48:  uint8(44),
  32758 	49:  uint8(45),
  32759 	50:  uint8(46),
  32760 	51:  uint8(46),
  32761 	52:  uint8(47),
  32762 	53:  uint8(48),
  32763 	54:  uint8(49),
  32764 	55:  uint8(50),
  32765 	56:  uint8(51),
  32766 	57:  uint8(52),
  32767 	58:  uint8(53),
  32768 	59:  uint8(54),
  32769 	60:  uint8(55),
  32770 	61:  uint8(56),
  32771 	62:  uint8(57),
  32772 	63:  uint8(58),
  32773 	64:  uint8(59),
  32774 	65:  uint8(60),
  32775 	66:  uint8(61),
  32776 	67:  uint8(62),
  32777 	68:  uint8(63),
  32778 	69:  uint8(64),
  32779 	70:  uint8(65),
  32780 	71:  uint8(66),
  32781 	72:  uint8(67),
  32782 	73:  uint8(68),
  32783 	74:  uint8(69),
  32784 	75:  uint8(70),
  32785 	76:  uint8(71),
  32786 	77:  uint8(72),
  32787 	78:  uint8(73),
  32788 	79:  uint8(74),
  32789 	80:  uint8(75),
  32790 	81:  uint8(76),
  32791 	82:  uint8(76),
  32792 	83:  uint8(77),
  32793 	84:  uint8(78),
  32794 	85:  uint8(79),
  32795 	86:  uint8(80),
  32796 	87:  uint8(81),
  32797 	88:  uint8(82),
  32798 	89:  uint8(83),
  32799 	90:  uint8(84),
  32800 	91:  uint8(85),
  32801 	92:  uint8(86),
  32802 	93:  uint8(87),
  32803 	94:  uint8(88),
  32804 	95:  uint8(89),
  32805 	96:  uint8(91),
  32806 	97:  uint8(93),
  32807 	98:  uint8(95),
  32808 	99:  uint8(96),
  32809 	100: uint8(98),
  32810 	101: uint8(100),
  32811 	102: uint8(101),
  32812 	103: uint8(102),
  32813 	104: uint8(104),
  32814 	105: uint8(106),
  32815 	106: uint8(108),
  32816 	107: uint8(110),
  32817 	108: uint8(112),
  32818 	109: uint8(114),
  32819 	110: uint8(116),
  32820 	111: uint8(118),
  32821 	112: uint8(122),
  32822 	113: uint8(124),
  32823 	114: uint8(126),
  32824 	115: uint8(128),
  32825 	116: uint8(130),
  32826 	117: uint8(132),
  32827 	118: uint8(134),
  32828 	119: uint8(136),
  32829 	120: uint8(138),
  32830 	121: uint8(140),
  32831 	122: uint8(143),
  32832 	123: uint8(145),
  32833 	124: uint8(148),
  32834 	125: uint8(151),
  32835 	126: uint8(154),
  32836 	127: uint8(157),
  32837 }
  32838 
  32839 var kAcTable1 = [128]uint16_t{
  32840 	0:   uint16(4),
  32841 	1:   uint16(5),
  32842 	2:   uint16(6),
  32843 	3:   uint16(7),
  32844 	4:   uint16(8),
  32845 	5:   uint16(9),
  32846 	6:   uint16(10),
  32847 	7:   uint16(11),
  32848 	8:   uint16(12),
  32849 	9:   uint16(13),
  32850 	10:  uint16(14),
  32851 	11:  uint16(15),
  32852 	12:  uint16(16),
  32853 	13:  uint16(17),
  32854 	14:  uint16(18),
  32855 	15:  uint16(19),
  32856 	16:  uint16(20),
  32857 	17:  uint16(21),
  32858 	18:  uint16(22),
  32859 	19:  uint16(23),
  32860 	20:  uint16(24),
  32861 	21:  uint16(25),
  32862 	22:  uint16(26),
  32863 	23:  uint16(27),
  32864 	24:  uint16(28),
  32865 	25:  uint16(29),
  32866 	26:  uint16(30),
  32867 	27:  uint16(31),
  32868 	28:  uint16(32),
  32869 	29:  uint16(33),
  32870 	30:  uint16(34),
  32871 	31:  uint16(35),
  32872 	32:  uint16(36),
  32873 	33:  uint16(37),
  32874 	34:  uint16(38),
  32875 	35:  uint16(39),
  32876 	36:  uint16(40),
  32877 	37:  uint16(41),
  32878 	38:  uint16(42),
  32879 	39:  uint16(43),
  32880 	40:  uint16(44),
  32881 	41:  uint16(45),
  32882 	42:  uint16(46),
  32883 	43:  uint16(47),
  32884 	44:  uint16(48),
  32885 	45:  uint16(49),
  32886 	46:  uint16(50),
  32887 	47:  uint16(51),
  32888 	48:  uint16(52),
  32889 	49:  uint16(53),
  32890 	50:  uint16(54),
  32891 	51:  uint16(55),
  32892 	52:  uint16(56),
  32893 	53:  uint16(57),
  32894 	54:  uint16(58),
  32895 	55:  uint16(60),
  32896 	56:  uint16(62),
  32897 	57:  uint16(64),
  32898 	58:  uint16(66),
  32899 	59:  uint16(68),
  32900 	60:  uint16(70),
  32901 	61:  uint16(72),
  32902 	62:  uint16(74),
  32903 	63:  uint16(76),
  32904 	64:  uint16(78),
  32905 	65:  uint16(80),
  32906 	66:  uint16(82),
  32907 	67:  uint16(84),
  32908 	68:  uint16(86),
  32909 	69:  uint16(88),
  32910 	70:  uint16(90),
  32911 	71:  uint16(92),
  32912 	72:  uint16(94),
  32913 	73:  uint16(96),
  32914 	74:  uint16(98),
  32915 	75:  uint16(100),
  32916 	76:  uint16(102),
  32917 	77:  uint16(104),
  32918 	78:  uint16(106),
  32919 	79:  uint16(108),
  32920 	80:  uint16(110),
  32921 	81:  uint16(112),
  32922 	82:  uint16(114),
  32923 	83:  uint16(116),
  32924 	84:  uint16(119),
  32925 	85:  uint16(122),
  32926 	86:  uint16(125),
  32927 	87:  uint16(128),
  32928 	88:  uint16(131),
  32929 	89:  uint16(134),
  32930 	90:  uint16(137),
  32931 	91:  uint16(140),
  32932 	92:  uint16(143),
  32933 	93:  uint16(146),
  32934 	94:  uint16(149),
  32935 	95:  uint16(152),
  32936 	96:  uint16(155),
  32937 	97:  uint16(158),
  32938 	98:  uint16(161),
  32939 	99:  uint16(164),
  32940 	100: uint16(167),
  32941 	101: uint16(170),
  32942 	102: uint16(173),
  32943 	103: uint16(177),
  32944 	104: uint16(181),
  32945 	105: uint16(185),
  32946 	106: uint16(189),
  32947 	107: uint16(193),
  32948 	108: uint16(197),
  32949 	109: uint16(201),
  32950 	110: uint16(205),
  32951 	111: uint16(209),
  32952 	112: uint16(213),
  32953 	113: uint16(217),
  32954 	114: uint16(221),
  32955 	115: uint16(225),
  32956 	116: uint16(229),
  32957 	117: uint16(234),
  32958 	118: uint16(239),
  32959 	119: uint16(245),
  32960 	120: uint16(249),
  32961 	121: uint16(254),
  32962 	122: uint16(259),
  32963 	123: uint16(264),
  32964 	124: uint16(269),
  32965 	125: uint16(274),
  32966 	126: uint16(279),
  32967 	127: uint16(284),
  32968 }
  32969 
  32970 var kAcTable2 = [128]uint16_t{
  32971 	0:   uint16(8),
  32972 	1:   uint16(8),
  32973 	2:   uint16(9),
  32974 	3:   uint16(10),
  32975 	4:   uint16(12),
  32976 	5:   uint16(13),
  32977 	6:   uint16(15),
  32978 	7:   uint16(17),
  32979 	8:   uint16(18),
  32980 	9:   uint16(20),
  32981 	10:  uint16(21),
  32982 	11:  uint16(23),
  32983 	12:  uint16(24),
  32984 	13:  uint16(26),
  32985 	14:  uint16(27),
  32986 	15:  uint16(29),
  32987 	16:  uint16(31),
  32988 	17:  uint16(32),
  32989 	18:  uint16(34),
  32990 	19:  uint16(35),
  32991 	20:  uint16(37),
  32992 	21:  uint16(38),
  32993 	22:  uint16(40),
  32994 	23:  uint16(41),
  32995 	24:  uint16(43),
  32996 	25:  uint16(44),
  32997 	26:  uint16(46),
  32998 	27:  uint16(48),
  32999 	28:  uint16(49),
  33000 	29:  uint16(51),
  33001 	30:  uint16(52),
  33002 	31:  uint16(54),
  33003 	32:  uint16(55),
  33004 	33:  uint16(57),
  33005 	34:  uint16(58),
  33006 	35:  uint16(60),
  33007 	36:  uint16(62),
  33008 	37:  uint16(63),
  33009 	38:  uint16(65),
  33010 	39:  uint16(66),
  33011 	40:  uint16(68),
  33012 	41:  uint16(69),
  33013 	42:  uint16(71),
  33014 	43:  uint16(72),
  33015 	44:  uint16(74),
  33016 	45:  uint16(75),
  33017 	46:  uint16(77),
  33018 	47:  uint16(79),
  33019 	48:  uint16(80),
  33020 	49:  uint16(82),
  33021 	50:  uint16(83),
  33022 	51:  uint16(85),
  33023 	52:  uint16(86),
  33024 	53:  uint16(88),
  33025 	54:  uint16(89),
  33026 	55:  uint16(93),
  33027 	56:  uint16(96),
  33028 	57:  uint16(99),
  33029 	58:  uint16(102),
  33030 	59:  uint16(105),
  33031 	60:  uint16(108),
  33032 	61:  uint16(111),
  33033 	62:  uint16(114),
  33034 	63:  uint16(117),
  33035 	64:  uint16(120),
  33036 	65:  uint16(124),
  33037 	66:  uint16(127),
  33038 	67:  uint16(130),
  33039 	68:  uint16(133),
  33040 	69:  uint16(136),
  33041 	70:  uint16(139),
  33042 	71:  uint16(142),
  33043 	72:  uint16(145),
  33044 	73:  uint16(148),
  33045 	74:  uint16(151),
  33046 	75:  uint16(155),
  33047 	76:  uint16(158),
  33048 	77:  uint16(161),
  33049 	78:  uint16(164),
  33050 	79:  uint16(167),
  33051 	80:  uint16(170),
  33052 	81:  uint16(173),
  33053 	82:  uint16(176),
  33054 	83:  uint16(179),
  33055 	84:  uint16(184),
  33056 	85:  uint16(189),
  33057 	86:  uint16(193),
  33058 	87:  uint16(198),
  33059 	88:  uint16(203),
  33060 	89:  uint16(207),
  33061 	90:  uint16(212),
  33062 	91:  uint16(217),
  33063 	92:  uint16(221),
  33064 	93:  uint16(226),
  33065 	94:  uint16(230),
  33066 	95:  uint16(235),
  33067 	96:  uint16(240),
  33068 	97:  uint16(244),
  33069 	98:  uint16(249),
  33070 	99:  uint16(254),
  33071 	100: uint16(258),
  33072 	101: uint16(263),
  33073 	102: uint16(268),
  33074 	103: uint16(274),
  33075 	104: uint16(280),
  33076 	105: uint16(286),
  33077 	106: uint16(292),
  33078 	107: uint16(299),
  33079 	108: uint16(305),
  33080 	109: uint16(311),
  33081 	110: uint16(317),
  33082 	111: uint16(323),
  33083 	112: uint16(330),
  33084 	113: uint16(336),
  33085 	114: uint16(342),
  33086 	115: uint16(348),
  33087 	116: uint16(354),
  33088 	117: uint16(362),
  33089 	118: uint16(370),
  33090 	119: uint16(379),
  33091 	120: uint16(385),
  33092 	121: uint16(393),
  33093 	122: uint16(401),
  33094 	123: uint16(409),
  33095 	124: uint16(416),
  33096 	125: uint16(424),
  33097 	126: uint16(432),
  33098 	127: uint16(440),
  33099 }
  33100 
  33101 var kBiasMatrices = [3][2]uint8_t{
  33102 	0: {
  33103 		0: uint8(96),
  33104 		1: uint8(110),
  33105 	},
  33106 	1: {
  33107 		0: uint8(96),
  33108 		1: uint8(108),
  33109 	},
  33110 	2: {
  33111 		0: uint8(110),
  33112 		1: uint8(115),
  33113 	},
  33114 }
  33115 
  33116 // C documentation
  33117 //
  33118 //	// Sharpening by (slightly) raising the hi-frequency coeffs.
  33119 //	// Hack-ish but helpful for mid-bitrate range. Use with care.
  33120 var kFreqSharpening = [16]uint8_t{
  33121 	1:  uint8(30),
  33122 	2:  uint8(60),
  33123 	3:  uint8(90),
  33124 	4:  uint8(30),
  33125 	5:  uint8(60),
  33126 	6:  uint8(90),
  33127 	7:  uint8(90),
  33128 	8:  uint8(60),
  33129 	9:  uint8(90),
  33130 	10: uint8(90),
  33131 	11: uint8(90),
  33132 	12: uint8(90),
  33133 	13: uint8(90),
  33134 	14: uint8(90),
  33135 	15: uint8(90),
  33136 }
  33137 
  33138 //------------------------------------------------------------------------------
  33139 // Initialize quantization parameters in VP8Matrix
  33140 
  33141 // C documentation
  33142 //
  33143 //	// Returns the average quantizer
  33144 func ExpandMatrix(tls *libc.TLS, m uintptr, type1 int32) (r int32) {
  33145 	var bias, i, is_ac_coeff, sum int32
  33146 	_, _, _, _ = bias, i, is_ac_coeff, sum
  33147 	i = 0
  33148 	for {
  33149 		if !(i < int32(2)) {
  33150 			break
  33151 		}
  33152 		is_ac_coeff = libc.BoolInt32(i > libc.Int32FromInt32(0))
  33153 		bias = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kBiasMatrices)) + uintptr(type1)*2 + uintptr(is_ac_coeff))))
  33154 		**(**uint16_t)(__ccgo_up(m + 32 + uintptr(i)*2)) = libc.Uint16FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(QFIX) / libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m + uintptr(i)*2))))
  33155 		**(**uint32_t)(__ccgo_up(m + 64 + uintptr(i)*4)) = libc.Uint32FromInt32(bias << (libc.Int32FromInt32(QFIX) - libc.Int32FromInt32(8)))
  33156 		// zthresh is the exact value such that QUANTDIV(coeff, iQ, B) is:
  33157 		//   * zero if coeff <= zthresh
  33158 		//   * non-zero if coeff > zthresh
  33159 		**(**uint32_t)(__ccgo_up(m + 128 + uintptr(i)*4)) = (libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(QFIX)-libc.Int32FromInt32(1)) - **(**uint32_t)(__ccgo_up(m + 64 + uintptr(i)*4))) / uint32(**(**uint16_t)(__ccgo_up(m + 32 + uintptr(i)*2)))
  33160 		goto _1
  33161 	_1:
  33162 		;
  33163 		i = i + 1
  33164 	}
  33165 	i = int32(2)
  33166 	for {
  33167 		if !(i < int32(16)) {
  33168 			break
  33169 		}
  33170 		**(**uint16_t)(__ccgo_up(m + uintptr(i)*2)) = **(**uint16_t)(__ccgo_up(m + 1*2))
  33171 		**(**uint16_t)(__ccgo_up(m + 32 + uintptr(i)*2)) = **(**uint16_t)(__ccgo_up(m + 32 + 1*2))
  33172 		**(**uint32_t)(__ccgo_up(m + 64 + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(m + 64 + 1*4))
  33173 		**(**uint32_t)(__ccgo_up(m + 128 + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(m + 128 + 1*4))
  33174 		goto _2
  33175 	_2:
  33176 		;
  33177 		i = i + 1
  33178 	}
  33179 	sum = 0
  33180 	i = libc.Int32FromInt32(0)
  33181 	for {
  33182 		if !(i < int32(16)) {
  33183 			break
  33184 		}
  33185 		if type1 == 0 { // we only use sharpening for AC luma coeffs
  33186 			**(**uint16_t)(__ccgo_up(m + 192 + uintptr(i)*2)) = libc.Uint16FromInt32(libc.Int32FromUint8(kFreqSharpening[i]) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m + uintptr(i)*2))) >> int32(SHARPEN_BITS))
  33187 		} else {
  33188 			**(**uint16_t)(__ccgo_up(m + 192 + uintptr(i)*2)) = uint16(0)
  33189 		}
  33190 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m + uintptr(i)*2)))
  33191 		goto _3
  33192 	_3:
  33193 		;
  33194 		i = i + 1
  33195 	}
  33196 	return (sum + int32(8)) >> int32(4)
  33197 }
  33198 
  33199 func CheckLambdaValue(tls *libc.TLS, v uintptr) {
  33200 	if **(**int32)(__ccgo_up(v)) < int32(1) {
  33201 		**(**int32)(__ccgo_up(v)) = int32(1)
  33202 	}
  33203 }
  33204 
  33205 func SetupMatrices(tls *libc.TLS, enc uintptr) {
  33206 	var i, num_segments, q, q_i16, q_i4, q_uv, tlambda_scale, v1 int32
  33207 	var m uintptr
  33208 	_, _, _, _, _, _, _, _, _ = i, m, num_segments, q, q_i16, q_i4, q_uv, tlambda_scale, v1
  33209 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod >= int32(4) {
  33210 		v1 = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength
  33211 	} else {
  33212 		v1 = 0
  33213 	}
  33214 	tlambda_scale = v1
  33215 	num_segments = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33216 	i = 0
  33217 	for {
  33218 		if !(i < num_segments) {
  33219 			break
  33220 		}
  33221 		m = enc + 608 + uintptr(i)*744
  33222 		q = (*VP8SegmentInfo)(unsafe.Pointer(m)).Fquant
  33223 		**(**uint16_t)(__ccgo_up(m)) = uint16(kDcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc, 0, int32(127))])
  33224 		**(**uint16_t)(__ccgo_up(m + 1*2)) = kAcTable1[clip2(tls, q, 0, int32(127))]
  33225 		**(**uint16_t)(__ccgo_up(m + 224)) = libc.Uint16FromInt32(libc.Int32FromUint8(kDcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_dc, 0, int32(127))]) * int32(2))
  33226 		**(**uint16_t)(__ccgo_up(m + 224 + 1*2)) = kAcTable2[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac, 0, int32(127))]
  33227 		**(**uint16_t)(__ccgo_up(m + 448)) = uint16(kDcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc, 0, int32(117))])
  33228 		**(**uint16_t)(__ccgo_up(m + 448 + 1*2)) = kAcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac, 0, int32(127))]
  33229 		q_i4 = ExpandMatrix(tls, m, 0)
  33230 		q_i16 = ExpandMatrix(tls, m+224, int32(1))
  33231 		q_uv = ExpandMatrix(tls, m+448, int32(2))
  33232 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_i4 = int32(3) * q_i4 * q_i4 >> int32(7)
  33233 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_i16 = int32(3) * q_i16 * q_i16
  33234 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_uv = int32(3) * q_uv * q_uv >> int32(6)
  33235 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_mode = int32(1) * q_i4 * q_i4 >> int32(7)
  33236 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_i4 = int32(7) * q_i4 * q_i4 >> int32(3)
  33237 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_i16 = q_i16 * q_i16 >> int32(2)
  33238 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_uv = q_uv * q_uv << int32(1)
  33239 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Ftlambda = tlambda_scale * q_i4 >> int32(5)
  33240 		// none of these constants should be < 1
  33241 		CheckLambdaValue(tls, m+700)
  33242 		CheckLambdaValue(tls, m+696)
  33243 		CheckLambdaValue(tls, m+704)
  33244 		CheckLambdaValue(tls, m+708)
  33245 		CheckLambdaValue(tls, m+724)
  33246 		CheckLambdaValue(tls, m+720)
  33247 		CheckLambdaValue(tls, m+728)
  33248 		CheckLambdaValue(tls, m+716)
  33249 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fmin_disto = int32(20) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m))) // quantization-aware min disto
  33250 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fmax_edge = 0
  33251 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fi4_penalty = int64(int32(1000) * q_i4 * q_i4)
  33252 		goto _2
  33253 	_2:
  33254 		;
  33255 		i = i + 1
  33256 	}
  33257 }
  33258 
  33259 //------------------------------------------------------------------------------
  33260 // Initialize filtering parameters
  33261 
  33262 // Very small filter-strength values have close to no visual effect. So we can
  33263 // save a little decoding-CPU by turning filtering off for these.
  33264 
  33265 func SetupFilterStrength(tls *libc.TLS, enc uintptr) {
  33266 	var base_strength, f, i, level0, qstep, v2, v3 int32
  33267 	var m uintptr
  33268 	_, _, _, _, _, _, _, _ = base_strength, f, i, level0, m, qstep, v2, v3
  33269 	// level0 is in [0..500]. Using '-f 50' as filter_strength is mid-filtering.
  33270 	level0 = int32(5) * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_strength
  33271 	i = 0
  33272 	for {
  33273 		if !(i < int32(NUM_MB_SEGMENTS)) {
  33274 			break
  33275 		}
  33276 		m = enc + 608 + uintptr(i)*744
  33277 		// We focus on the quantization of AC coeffs.
  33278 		qstep = libc.Int32FromUint16(kAcTable1[clip2(tls, (*VP8SegmentInfo)(unsafe.Pointer(m)).Fquant, 0, int32(127))]) >> int32(2)
  33279 		base_strength = VP8FilterStrengthFromDelta(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness, qstep)
  33280 		// Segments with lower complexity ('beta') will be less filtered.
  33281 		f = base_strength * level0 / (int32(256) + (*VP8SegmentInfo)(unsafe.Pointer(m)).Fbeta)
  33282 		if f < int32(FSTRENGTH_CUTOFF) {
  33283 			v2 = 0
  33284 		} else {
  33285 			if f > int32(63) {
  33286 				v3 = int32(63)
  33287 			} else {
  33288 				v3 = f
  33289 			}
  33290 			v2 = v3
  33291 		}
  33292 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Ffstrength = v2
  33293 		goto _1
  33294 	_1:
  33295 		;
  33296 		i = i + 1
  33297 	}
  33298 	// We record the initial strength (mainly for the case of 1-segment only).
  33299 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Flevel = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Ffstrength
  33300 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsimple = libc.BoolInt32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_type == 0)
  33301 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_sharpness
  33302 }
  33303 
  33304 //------------------------------------------------------------------------------
  33305 
  33306 // Note: if you change the values below, remember that the max range
  33307 // allowed by the syntax for DQ_UV is [-16,16].
  33308 
  33309 // C documentation
  33310 //
  33311 //	// We want to emulate jpeg-like behaviour where the expected "good" quality
  33312 //	// is around q=75. Internally, our "good" middle is around c=50. So we
  33313 //	// map accordingly using linear piece-wise function
  33314 func QualityToCompression(tls *libc.TLS, c float64) (r float64) {
  33315 	var linear_c, v, v1 float64
  33316 	_, _, _ = linear_c, v, v1
  33317 	if c < float64(0.75) {
  33318 		v1 = float64(c * (libc.Float64FromFloat64(2) / libc.Float64FromFloat64(3)))
  33319 	} else {
  33320 		v1 = float64(float64(2)*c) - float64(1)
  33321 	}
  33322 	linear_c = v1
  33323 	// The file size roughly scales as pow(quantizer, 3.). Actually, the
  33324 	// exponent is somewhere between 2.8 and 3.2, but we're mostly interested
  33325 	// in the mid-quant range. So we scale the compressibility inversely to
  33326 	// this power-law: quant ~= compression ^ 1/3. This law holds well for
  33327 	// low quant. Finer modeling for high-quant would make use of kAcTable[]
  33328 	// more explicitly.
  33329 	v = libc.Xpow(tls, linear_c, libc.Float64FromInt32(1)/libc.Float64FromFloat64(3))
  33330 	return v
  33331 }
  33332 
  33333 func QualityToJPEGCompression(tls *libc.TLS, c float64, alpha float64) (r float64) {
  33334 	var amax, amin, exp_max, exp_min, expn, slope, v, v1, v2 float64
  33335 	_, _, _, _, _, _, _, _, _ = amax, amin, exp_max, exp_min, expn, slope, v, v1, v2
  33336 	// We map the complexity 'alpha' and quality setting 'c' to a compression
  33337 	// exponent empirically matched to the compression curve of libjpeg6b.
  33338 	// On average, the WebP output size will be roughly similar to that of a
  33339 	// JPEG file compressed with same quality factor.
  33340 	amin = float64(0.3)
  33341 	amax = float64(0.85)
  33342 	exp_min = float64(0.4)
  33343 	exp_max = float64(0.9)
  33344 	slope = (exp_min - exp_max) / (amax - amin)
  33345 	if alpha > amax {
  33346 		v1 = exp_min
  33347 	} else {
  33348 		if alpha < amin {
  33349 			v2 = exp_max
  33350 		} else {
  33351 			v2 = exp_max + float64(slope*(alpha-amin))
  33352 		}
  33353 		v1 = v2
  33354 	}
  33355 	// Linearly interpolate 'expn' from exp_min to exp_max
  33356 	// in the [amin, amax] range.
  33357 	expn = v1
  33358 	v = libc.Xpow(tls, c, expn)
  33359 	return v
  33360 }
  33361 
  33362 func SegmentsAreEquivalent(tls *libc.TLS, S1 uintptr, S2 uintptr) (r int32) {
  33363 	return libc.BoolInt32((*VP8SegmentInfo)(unsafe.Pointer(S1)).Fquant == (*VP8SegmentInfo)(unsafe.Pointer(S2)).Fquant && (*VP8SegmentInfo)(unsafe.Pointer(S1)).Ffstrength == (*VP8SegmentInfo)(unsafe.Pointer(S2)).Ffstrength)
  33364 }
  33365 
  33366 func SimplifySegments(tls *libc.TLS, enc uintptr) {
  33367 	var S1, S2 uintptr
  33368 	var found, i, num_final_segments, num_segments, s1, s2, v1 int32
  33369 	var map1 [4]int32
  33370 	_, _, _, _, _, _, _, _, _, _ = S1, S2, found, i, map1, num_final_segments, num_segments, s1, s2, v1
  33371 	map1 = [4]int32{
  33372 		1: int32(1),
  33373 		2: int32(2),
  33374 		3: int32(3),
  33375 	}
  33376 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments < int32(NUM_MB_SEGMENTS) {
  33377 		v1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33378 	} else {
  33379 		v1 = int32(NUM_MB_SEGMENTS)
  33380 	}
  33381 	// 'num_segments' is previously validated and <= NUM_MB_SEGMENTS, but an
  33382 	// explicit check is needed to avoid a spurious warning about 'i' exceeding
  33383 	// array bounds of 'dqm' with some compilers (noticed with gcc-4.9).
  33384 	num_segments = v1
  33385 	num_final_segments = int32(1)
  33386 	s1 = int32(1)
  33387 	for {
  33388 		if !(s1 < num_segments) {
  33389 			break
  33390 		} // find similar segments
  33391 		S1 = enc + 608 + uintptr(s1)*744
  33392 		found = 0
  33393 		// check if we already have similar segment
  33394 		s2 = 0
  33395 		for {
  33396 			if !(s2 < num_final_segments) {
  33397 				break
  33398 			}
  33399 			S2 = enc + 608 + uintptr(s2)*744
  33400 			if SegmentsAreEquivalent(tls, S1, S2) != 0 {
  33401 				found = int32(1)
  33402 				break
  33403 			}
  33404 			goto _3
  33405 		_3:
  33406 			;
  33407 			s2 = s2 + 1
  33408 		}
  33409 		map1[s1] = s2
  33410 		if !(found != 0) {
  33411 			if num_final_segments != s1 {
  33412 				**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(num_final_segments)*744)) = **(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s1)*744))
  33413 			}
  33414 			num_final_segments = num_final_segments + 1
  33415 		}
  33416 		goto _2
  33417 	_2:
  33418 		;
  33419 		s1 = s1 + 1
  33420 	}
  33421 	if num_final_segments < num_segments { // Remap
  33422 		i = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  33423 		for {
  33424 			v1 = i
  33425 			i = i - 1
  33426 			if !(v1 > 0) {
  33427 				break
  33428 			}
  33429 			libc.SetBitFieldPtr8Uint32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info+uintptr(i)*4+0, libc.Uint32FromInt32(map1[int32(uint32(*(*uint8)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(i)*4 + 0))&0x60>>5))]), 5, 0x60)
  33430 		}
  33431 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments = num_final_segments
  33432 		// Replicate the trailing segment infos (it's mostly cosmetics)
  33433 		i = num_final_segments
  33434 		for {
  33435 			if !(i < num_segments) {
  33436 				break
  33437 			}
  33438 			**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744)) = **(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(num_final_segments-int32(1))*744))
  33439 			goto _5
  33440 		_5:
  33441 			;
  33442 			i = i + 1
  33443 		}
  33444 	}
  33445 }
  33446 
  33447 func VP8SetSegmentParams(tls *libc.TLS, enc uintptr, quality float32) {
  33448 	var Q, amp, c, c_base, expn, v1 float64
  33449 	var dq_uv_ac, dq_uv_dc, i, num_segments, q int32
  33450 	_, _, _, _, _, _, _, _, _, _, _ = Q, amp, c, c_base, dq_uv_ac, dq_uv_dc, expn, i, num_segments, q, v1
  33451 	num_segments = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33452 	amp = float64(float64(SNS_TO_DQ)*float64((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength)) / float64(100) / float64(128)
  33453 	Q = float64(quality) / float64(100)
  33454 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Femulate_jpeg_size != 0 {
  33455 		v1 = QualityToJPEGCompression(tls, Q, float64((*VP8Encoder)(unsafe.Pointer(enc)).Falpha)/float64(255))
  33456 	} else {
  33457 		v1 = QualityToCompression(tls, Q)
  33458 	}
  33459 	c_base = v1
  33460 	i = 0
  33461 	for {
  33462 		if !(i < num_segments) {
  33463 			break
  33464 		}
  33465 		// We modulate the base coefficient to accommodate for the quantization
  33466 		// susceptibility and allow denser segments to be quantized more.
  33467 		expn = float64(1) - float64(amp*float64((**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Falpha))
  33468 		c = libc.Xpow(tls, c_base, expn)
  33469 		q = int32(float64(libc.Float64FromFloat64(127) * (libc.Float64FromFloat64(1) - c)))
  33470 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant = clip2(tls, q, 0, int32(127))
  33471 		goto _2
  33472 	_2:
  33473 		;
  33474 		i = i + 1
  33475 	}
  33476 	// purely indicative in the bitstream (except for the 1-segment case)
  33477 	(*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Fquant
  33478 	// fill-in values for the unused segments (required by the syntax)
  33479 	i = num_segments
  33480 	for {
  33481 		if !(i < int32(NUM_MB_SEGMENTS)) {
  33482 			break
  33483 		}
  33484 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant = (*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant
  33485 		goto _3
  33486 	_3:
  33487 		;
  33488 		i = i + 1
  33489 	}
  33490 	// uv_alpha is normally spread around ~60. The useful range is
  33491 	// typically ~30 (quite bad) to ~100 (ok to decimate UV more).
  33492 	// We map it to the safe maximal range of MAX/MIN_DQ_UV for dq_uv.
  33493 	dq_uv_ac = ((*VP8Encoder)(unsafe.Pointer(enc)).Fuv_alpha - int32(MID_ALPHA)) * (libc.Int32FromInt32(MAX_DQ_UV) - -libc.Int32FromInt32(4)) / (libc.Int32FromInt32(MAX_ALPHA1) - libc.Int32FromInt32(MIN_ALPHA))
  33494 	// we rescale by the user-defined strength of adaptation
  33495 	dq_uv_ac = dq_uv_ac * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength / int32(100)
  33496 	// and make it safe.
  33497 	dq_uv_ac = clip2(tls, dq_uv_ac, -int32(4), int32(MAX_DQ_UV))
  33498 	// We also boost the dc-uv-quant a little, based on sns-strength, since
  33499 	// U/V channels are quite more reactive to high quants (flat DC-blocks
  33500 	// tend to appear, and are unpleasant).
  33501 	dq_uv_dc = -int32(4) * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength / int32(100)
  33502 	dq_uv_dc = clip2(tls, dq_uv_dc, -int32(15), int32(15)) // 4bit-signed max allowed
  33503 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc = 0       // TODO(skal): dq-lum
  33504 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_dc = 0
  33505 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac = 0
  33506 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc = dq_uv_dc
  33507 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac = dq_uv_ac
  33508 	SetupFilterStrength(tls, enc) // initialize segments' filtering, eventually
  33509 	if num_segments > int32(1) {
  33510 		SimplifySegments(tls, enc)
  33511 	}
  33512 	SetupMatrices(tls, enc) // finalize quantization matrices
  33513 }
  33514 
  33515 // C documentation
  33516 //
  33517 //	// Must be indexed using {B_DC_PRED -> B_HU_PRED} as index
  33518 var VP8I4ModeOffsets = [10]uint16_t{
  33519 	0: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0)),
  33520 	1: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(4)),
  33521 	2: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(8)),
  33522 	3: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(12)),
  33523 	4: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(16)),
  33524 	5: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(20)),
  33525 	6: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(24)),
  33526 	7: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(28)),
  33527 	8: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33528 	9: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)),
  33529 }
  33530 
  33531 func VP8MakeLuma16Preds(tls *libc.TLS, it uintptr) {
  33532 	var left, top, v1, v2 uintptr
  33533 	_, _, _, _ = left, top, v1, v2
  33534 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx != 0 {
  33535 		v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left
  33536 	} else {
  33537 		v1 = libc.UintptrFromInt32(0)
  33538 	}
  33539 	left = v1
  33540 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy != 0 {
  33541 		v2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_top
  33542 	} else {
  33543 		v2 = libc.UintptrFromInt32(0)
  33544 	}
  33545 	top = v2
  33546 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredLuma16})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, left, top)
  33547 }
  33548 
  33549 func VP8MakeChroma8Preds(tls *libc.TLS, it uintptr) {
  33550 	var left, top, v1, v2 uintptr
  33551 	_, _, _, _ = left, top, v1, v2
  33552 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx != 0 {
  33553 		v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left
  33554 	} else {
  33555 		v1 = libc.UintptrFromInt32(0)
  33556 	}
  33557 	left = v1
  33558 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy != 0 {
  33559 		v2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top
  33560 	} else {
  33561 		v2 = libc.UintptrFromInt32(0)
  33562 	}
  33563 	top = v2
  33564 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredChroma8})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, left, top)
  33565 }
  33566 
  33567 // C documentation
  33568 //
  33569 //	// Form all the ten Intra4x4 predictions in the 'yuv_p' cache
  33570 //	// for the 4x4 block it->i4
  33571 func MakeIntra4Preds(tls *libc.TLS, it uintptr) {
  33572 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredLuma4})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, (*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top)
  33573 }
  33574 
  33575 var VP8ScanUV = [8]uint16_t{
  33576 	1: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33577 	2: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33578 	3: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33579 	4: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33580 	5: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33581 	6: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33582 	7: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33583 }
  33584 
  33585 //------------------------------------------------------------------------------
  33586 // Distortion measurement
  33587 
  33588 var kWeightY = [16]uint16_t{
  33589 	0:  uint16(38),
  33590 	1:  uint16(32),
  33591 	2:  uint16(20),
  33592 	3:  uint16(9),
  33593 	4:  uint16(32),
  33594 	5:  uint16(28),
  33595 	6:  uint16(17),
  33596 	7:  uint16(7),
  33597 	8:  uint16(20),
  33598 	9:  uint16(17),
  33599 	10: uint16(10),
  33600 	11: uint16(4),
  33601 	12: uint16(9),
  33602 	13: uint16(7),
  33603 	14: uint16(4),
  33604 	15: uint16(2),
  33605 }
  33606 
  33607 var kWeightTrellis = [16]uint16_t{
  33608 	0:  uint16(30),
  33609 	1:  uint16(27),
  33610 	2:  uint16(19),
  33611 	3:  uint16(11),
  33612 	4:  uint16(27),
  33613 	5:  uint16(24),
  33614 	6:  uint16(17),
  33615 	7:  uint16(10),
  33616 	8:  uint16(19),
  33617 	9:  uint16(17),
  33618 	10: uint16(12),
  33619 	11: uint16(8),
  33620 	12: uint16(11),
  33621 	13: uint16(10),
  33622 	14: uint16(8),
  33623 	15: uint16(6),
  33624 }
  33625 
  33626 // C documentation
  33627 //
  33628 //	// Init/Copy the common fields in score.
  33629 func InitScore(tls *libc.TLS, rd uintptr) {
  33630 	(*VP8ModeScore)(unsafe.Pointer(rd)).FD = 0
  33631 	(*VP8ModeScore)(unsafe.Pointer(rd)).FSD = 0
  33632 	(*VP8ModeScore)(unsafe.Pointer(rd)).FR = 0
  33633 	(*VP8ModeScore)(unsafe.Pointer(rd)).FH = 0
  33634 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = uint32(0)
  33635 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fscore = libc.Int64FromInt64(0x7fffffffffffff)
  33636 }
  33637 
  33638 func CopyScore(tls *libc.TLS, dst uintptr, src uintptr) {
  33639 	(*VP8ModeScore)(unsafe.Pointer(dst)).FD = (*VP8ModeScore)(unsafe.Pointer(src)).FD
  33640 	(*VP8ModeScore)(unsafe.Pointer(dst)).FSD = (*VP8ModeScore)(unsafe.Pointer(src)).FSD
  33641 	(*VP8ModeScore)(unsafe.Pointer(dst)).FR = (*VP8ModeScore)(unsafe.Pointer(src)).FR
  33642 	(*VP8ModeScore)(unsafe.Pointer(dst)).FH = (*VP8ModeScore)(unsafe.Pointer(src)).FH
  33643 	(*VP8ModeScore)(unsafe.Pointer(dst)).Fnz = (*VP8ModeScore)(unsafe.Pointer(src)).Fnz // note that nz is not accumulated, but just copied.
  33644 	(*VP8ModeScore)(unsafe.Pointer(dst)).Fscore = (*VP8ModeScore)(unsafe.Pointer(src)).Fscore
  33645 }
  33646 
  33647 func AddScore(tls *libc.TLS, dst uintptr, src uintptr) {
  33648 	**(**score_t)(__ccgo_up(dst)) += (*VP8ModeScore)(unsafe.Pointer(src)).FD
  33649 	**(**score_t)(__ccgo_up(dst + 8)) += (*VP8ModeScore)(unsafe.Pointer(src)).FSD
  33650 	**(**score_t)(__ccgo_up(dst + 24)) += (*VP8ModeScore)(unsafe.Pointer(src)).FR
  33651 	**(**score_t)(__ccgo_up(dst + 16)) += (*VP8ModeScore)(unsafe.Pointer(src)).FH
  33652 	**(**uint32_t)(__ccgo_up(dst + 864)) |= (*VP8ModeScore)(unsafe.Pointer(src)).Fnz // here, new nz bits are accumulated.
  33653 	**(**score_t)(__ccgo_up(dst + 32)) += (*VP8ModeScore)(unsafe.Pointer(src)).Fscore
  33654 }
  33655 
  33656 //------------------------------------------------------------------------------
  33657 // Performs trellis-optimized quantization.
  33658 
  33659 // C documentation
  33660 //
  33661 //	// Trellis node
  33662 type Node = struct {
  33663 	Fprev  int8_t
  33664 	Fsign  int8_t
  33665 	Flevel int16_t
  33666 }
  33667 
  33668 // C documentation
  33669 //
  33670 //	// Score state
  33671 type ScoreState = struct {
  33672 	Fscore score_t
  33673 	Fcosts uintptr
  33674 }
  33675 
  33676 // If a coefficient was quantized to a value Q (using a neutral bias),
  33677 // we test all alternate possibilities between [Q-MIN_DELTA, Q+MAX_DELTA]
  33678 // We don't test negative values though.
  33679 
  33680 func SetRDScore(tls *libc.TLS, lambda int32, rd uintptr) {
  33681 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fscore = ((*VP8ModeScore)(unsafe.Pointer(rd)).FR+(*VP8ModeScore)(unsafe.Pointer(rd)).FH)*int64(lambda) + int64(RD_DISTO_MULT)*((*VP8ModeScore)(unsafe.Pointer(rd)).FD+(*VP8ModeScore)(unsafe.Pointer(rd)).FSD)
  33682 }
  33683 
  33684 func RDScoreTrellis(tls *libc.TLS, lambda int32, rate score_t, distortion score_t) (r score_t) {
  33685 	return rate*int64(lambda) + int64(RD_DISTO_MULT)*distortion
  33686 }
  33687 
  33688 const TYPE_I16_AC = 0
  33689 const TYPE_I16_DC = 1
  33690 const TYPE_CHROMA_A = 2
  33691 const TYPE_I4_AC = 3
  33692 
  33693 func TrellisQuantizeBlock(tls *libc.TLS, enc uintptr, in uintptr, out uintptr, ctx0 int32, coeff_type int32, mtx uintptr, lambda int32) (r int32) {
  33694 	bp := tls.Alloc(192)
  33695 	defer tls.Free(192)
  33696 	var B1, Q, coeff0, iQ1 uint32_t
  33697 	var band, best_node, best_prev, ctx, delta_error, err, first, j, j1, j2, last, last_proba, level0, level1, m, n1, new_error, nz, p, sign, thresh, thresh_level, v1, v4, v6 int32
  33698 	var base_score, best_cur_score, best_score, cost, cost1, last_pos_cost, last_pos_score, rate, score score_t
  33699 	var best_path [3]int32
  33700 	var costs CostArrayPtr
  33701 	var cur, node, probas, ss_cur, ss_prev, tmp uintptr
  33702 	var v3 uint8_t
  33703 	var _ /* nodes at bp+0 */ [16][2]Node
  33704 	var _ /* score_states at bp+128 */ [2][2]ScoreState
  33705 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = B1, Q, band, base_score, best_cur_score, best_node, best_path, best_prev, best_score, coeff0, cost, cost1, costs, ctx, cur, delta_error, err, first, iQ1, j, j1, j2, last, last_pos_cost, last_pos_score, last_proba, level0, level1, m, n1, new_error, node, nz, p, probas, rate, score, sign, ss_cur, ss_prev, thresh, thresh_level, tmp, v1, v3, v4, v6
  33706 	probas = enc + 3616 + 4 + uintptr(coeff_type)*264
  33707 	costs = enc + 3616 + 18344 + uintptr(coeff_type)*384
  33708 	if coeff_type == int32(TYPE_I16_AC) {
  33709 		v1 = int32(1)
  33710 	} else {
  33711 		v1 = 0
  33712 	}
  33713 	first = v1
  33714 	ss_cur = bp + 128 + uintptr(libc.Int32FromInt32(MIN_DELTA)+libc.Int32FromInt32(MIN_DELTA))*16
  33715 	ss_prev = bp + 128 + 1*32 + uintptr(libc.Int32FromInt32(MIN_DELTA)+libc.Int32FromInt32(MIN_DELTA))*16
  33716 	best_path = [3]int32{
  33717 		0: -int32(1),
  33718 		1: -int32(1),
  33719 		2: -int32(1),
  33720 	}
  33721 	thresh = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 1*2))) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 1*2))) / int32(4)
  33722 	last_proba = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + uintptr(VP8EncBands[first])*33 + uintptr(ctx0)*11)))
  33723 	// compute the position of the last interesting coefficient
  33724 	last = first - int32(1)
  33725 	n1 = int32(15)
  33726 	for {
  33727 		if !(n1 >= first) {
  33728 			break
  33729 		}
  33730 		j = libc.Int32FromUint8(kZigzag1[n1])
  33731 		err = int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2))) * int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  33732 		if err > thresh {
  33733 			last = n1
  33734 			break
  33735 		}
  33736 		goto _2
  33737 	_2:
  33738 		;
  33739 		n1 = n1 - 1
  33740 	}
  33741 	// we don't need to go inspect up to n = 16 coeffs. We can just go up
  33742 	// to last + 1 (inclusive) without losing much.
  33743 	if last < int32(15) {
  33744 		last = last + 1
  33745 	}
  33746 	// compute 'skip' score. This is the max score one can do.
  33747 	v3 = libc.Uint8FromInt32(last_proba)
  33748 	if !(0 != 0) {
  33749 		v4 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33750 	} else {
  33751 		v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33752 	}
  33753 	v1 = v4
  33754 	goto _5
  33755 _5:
  33756 	cost = int64(v1)
  33757 	best_score = RDScoreTrellis(tls, lambda, cost, 0)
  33758 	// initialize source node.
  33759 	m = -MIN_DELTA
  33760 	for {
  33761 		if !(m <= int32(MAX_DELTA)) {
  33762 			break
  33763 		}
  33764 		if ctx0 == 0 {
  33765 			v3 = libc.Uint8FromInt32(last_proba)
  33766 			if !(int32(1) != 0) {
  33767 				v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33768 			} else {
  33769 				v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33770 			}
  33771 			v4 = v6
  33772 			goto _11
  33773 		_11:
  33774 			v1 = v4
  33775 		} else {
  33776 			v1 = 0
  33777 		}
  33778 		rate = int64(v1)
  33779 		(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = RDScoreTrellis(tls, lambda, rate, 0)
  33780 		(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fcosts = **(**uintptr)(__ccgo_up(costs + uintptr(first)*24 + uintptr(ctx0)*8))
  33781 		goto _7
  33782 	_7:
  33783 		;
  33784 		m = m + 1
  33785 	}
  33786 	// traverse trellis.
  33787 	n1 = first
  33788 	for {
  33789 		if !(n1 <= last) {
  33790 			break
  33791 		}
  33792 		j1 = libc.Int32FromUint8(kZigzag1[n1])
  33793 		Q = uint32(**(**uint16_t)(__ccgo_up(mtx + uintptr(j1)*2)))
  33794 		iQ1 = uint32(**(**uint16_t)(__ccgo_up(mtx + 32 + uintptr(j1)*2)))
  33795 		B1 = libc.Uint32FromInt32(libc.Int32FromInt32(0x00) << (libc.Int32FromInt32(QFIX) - libc.Int32FromInt32(8))) // neutral bias
  33796 		// note: it's important to take sign of the _original_ coeff,
  33797 		// so we don't have to consider level < 0 afterward.
  33798 		sign = libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2))) < libc.Int32FromInt32(0))
  33799 		if sign != 0 {
  33800 			v1 = -int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2)))
  33801 		} else {
  33802 			v1 = int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2)))
  33803 		}
  33804 		coeff0 = libc.Uint32FromInt32(v1 + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 192 + uintptr(j1)*2))))
  33805 		v4 = libc.Int32FromUint32((coeff0*iQ1 + B1) >> libc.Int32FromInt32(QFIX))
  33806 		goto _16
  33807 	_16:
  33808 		level0 = v4
  33809 		v6 = libc.Int32FromUint32((coeff0*iQ1 + libc.Uint32FromInt32(libc.Int32FromInt32(0x80)<<(libc.Int32FromInt32(QFIX)-libc.Int32FromInt32(8)))) >> libc.Int32FromInt32(QFIX))
  33810 		goto _18
  33811 	_18:
  33812 		thresh_level = v6
  33813 		if thresh_level > int32(MAX_LEVEL) {
  33814 			thresh_level = int32(MAX_LEVEL)
  33815 		}
  33816 		if level0 > int32(MAX_LEVEL) {
  33817 			level0 = int32(MAX_LEVEL)
  33818 		}
  33819 		// Swap current and previous score states
  33820 		tmp = ss_cur
  33821 		ss_cur = ss_prev
  33822 		ss_prev = tmp
  33823 		// test all alternate level values around level0.
  33824 		m = -MIN_DELTA
  33825 		for {
  33826 			if !(m <= int32(MAX_DELTA)) {
  33827 				break
  33828 			}
  33829 			cur = bp + uintptr(n1)*8 + uintptr(m+MIN_DELTA)*4
  33830 			level1 = level0 + m
  33831 			if level1 > int32(2) {
  33832 				v1 = int32(2)
  33833 			} else {
  33834 				v1 = level1
  33835 			}
  33836 			ctx = v1
  33837 			band = libc.Int32FromUint8(VP8EncBands[n1+int32(1)])
  33838 			(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fcosts = **(**uintptr)(__ccgo_up(costs + uintptr(n1+int32(1))*24 + uintptr(ctx)*8))
  33839 			if level1 < 0 || level1 > thresh_level {
  33840 				(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = libc.Int64FromInt64(0x7fffffffffffff)
  33841 				// Node is dead.
  33842 				goto _19
  33843 			}
  33844 			// Compute delta_error = how much coding this level will
  33845 			// subtract to max_error as distortion.
  33846 			// Here, distortion = sum of (|coeff_i| - level_i * Q_i)^2
  33847 			new_error = libc.Int32FromUint32(coeff0 - libc.Uint32FromInt32(level1)*Q)
  33848 			delta_error = libc.Int32FromUint32(uint32(kWeightTrellis[j1]) * (libc.Uint32FromInt32(new_error*new_error) - coeff0*coeff0))
  33849 			base_score = RDScoreTrellis(tls, lambda, 0, int64(delta_error))
  33850 			// Inspect all possible non-dead predecessors. Retain only the best one.
  33851 			// The base_score is added to all scores so it is only added for the final
  33852 			// value after the loop.
  33853 			v1 = level1
  33854 			if v1 > int32(MAX_VARIABLE_LEVEL) {
  33855 				v6 = int32(MAX_VARIABLE_LEVEL)
  33856 			} else {
  33857 				v6 = v1
  33858 			}
  33859 			v4 = libc.Int32FromUint16(VP8LevelFixedCosts[v1]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((**(**ScoreState)(__ccgo_up(ss_prev + uintptr(-libc.Int32FromInt32(MIN_DELTA))*16))).Fcosts + uintptr(v6)*2)))
  33860 			goto _23
  33861 		_23:
  33862 			cost1 = int64(v4)
  33863 			best_cur_score = (**(**ScoreState)(__ccgo_up(ss_prev + uintptr(-libc.Int32FromInt32(MIN_DELTA))*16))).Fscore + RDScoreTrellis(tls, lambda, cost1, 0)
  33864 			best_prev = -MIN_DELTA
  33865 			p = -libc.Int32FromInt32(MIN_DELTA) + libc.Int32FromInt32(1)
  33866 			for {
  33867 				if !(p <= int32(MAX_DELTA)) {
  33868 					break
  33869 				}
  33870 				// Dead nodes (with ss_prev[p].score >= MAX_COST) are automatically
  33871 				// eliminated since their score can't be better than the current best.
  33872 				v1 = level1
  33873 				if v1 > int32(MAX_VARIABLE_LEVEL) {
  33874 					v6 = int32(MAX_VARIABLE_LEVEL)
  33875 				} else {
  33876 					v6 = v1
  33877 				}
  33878 				v4 = libc.Int32FromUint16(VP8LevelFixedCosts[v1]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((**(**ScoreState)(__ccgo_up(ss_prev + uintptr(p)*16))).Fcosts + uintptr(v6)*2)))
  33879 				goto _28
  33880 			_28:
  33881 				cost1 = int64(v4)
  33882 				// Examine node assuming it's a non-terminal one.
  33883 				score = (**(**ScoreState)(__ccgo_up(ss_prev + uintptr(p)*16))).Fscore + RDScoreTrellis(tls, lambda, cost1, 0)
  33884 				if score < best_cur_score {
  33885 					best_cur_score = score
  33886 					best_prev = p
  33887 				}
  33888 				goto _25
  33889 			_25:
  33890 				;
  33891 				p = p + 1
  33892 			}
  33893 			best_cur_score = best_cur_score + base_score
  33894 			// Store best finding in current node.
  33895 			(*Node)(unsafe.Pointer(cur)).Fsign = int8(sign)
  33896 			(*Node)(unsafe.Pointer(cur)).Flevel = int16(level1)
  33897 			(*Node)(unsafe.Pointer(cur)).Fprev = int8(best_prev)
  33898 			(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = best_cur_score
  33899 			// Now, record best terminal node (and thus best entry in the graph).
  33900 			if level1 != 0 && best_cur_score < best_score {
  33901 				if n1 < int32(15) {
  33902 					v3 = **(**uint8_t)(__ccgo_up(probas + uintptr(band)*33 + uintptr(ctx)*11))
  33903 					if !(0 != 0) {
  33904 						v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33905 					} else {
  33906 						v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33907 					}
  33908 					v4 = v6
  33909 					goto _33
  33910 				_33:
  33911 					v1 = v4
  33912 				} else {
  33913 					v1 = 0
  33914 				}
  33915 				last_pos_cost = int64(v1)
  33916 				last_pos_score = RDScoreTrellis(tls, lambda, last_pos_cost, 0)
  33917 				score = best_cur_score + last_pos_score
  33918 				if score < best_score {
  33919 					best_score = score
  33920 					best_path[0] = n1               // best eob position
  33921 					best_path[int32(1)] = m         // best node index
  33922 					best_path[int32(2)] = best_prev // best predecessor
  33923 				}
  33924 			}
  33925 			goto _19
  33926 		_19:
  33927 			;
  33928 			m = m + 1
  33929 		}
  33930 		goto _13
  33931 	_13:
  33932 		;
  33933 		n1 = n1 + 1
  33934 	}
  33935 	// Fresh start
  33936 	// Beware! We must preserve in[0]/out[0] value for TYPE_I16_AC case.
  33937 	if coeff_type == int32(TYPE_I16_AC) {
  33938 		libc.X__builtin___memset_chk(tls, in+uintptr(1)*2, 0, libc.Uint64FromInt32(15)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33939 		libc.X__builtin___memset_chk(tls, out+uintptr(1)*2, 0, libc.Uint64FromInt32(15)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33940 	} else {
  33941 		libc.X__builtin___memset_chk(tls, in, 0, libc.Uint64FromInt32(16)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33942 		libc.X__builtin___memset_chk(tls, out, 0, libc.Uint64FromInt32(16)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33943 	}
  33944 	if best_path[0] == -int32(1) {
  33945 		return 0 // skip!
  33946 	}
  33947 	// Unwind the best path.
  33948 	// Note: best-prev on terminal node is not necessarily equal to the
  33949 	// best_prev for non-terminal. So we patch best_path[2] in.
  33950 	nz = 0
  33951 	best_node = best_path[int32(1)]
  33952 	n1 = best_path[0]
  33953 	(**(**Node)(__ccgo_up(bp + uintptr(n1)*8 + uintptr(best_node+MIN_DELTA)*4))).Fprev = int8(best_path[int32(2)]) // force best-prev for terminal
  33954 	for {
  33955 		if !(n1 >= first) {
  33956 			break
  33957 		}
  33958 		node = bp + uintptr(n1)*8 + uintptr(best_node+MIN_DELTA)*4
  33959 		j2 = libc.Int32FromUint8(kZigzag1[n1])
  33960 		if (*Node)(unsafe.Pointer(node)).Fsign != 0 {
  33961 			v1 = -int32((*Node)(unsafe.Pointer(node)).Flevel)
  33962 		} else {
  33963 			v1 = int32((*Node)(unsafe.Pointer(node)).Flevel)
  33964 		}
  33965 		**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = int16(v1)
  33966 		nz = nz | int32((*Node)(unsafe.Pointer(node)).Flevel)
  33967 		**(**int16_t)(__ccgo_up(in + uintptr(j2)*2)) = int16(int32(**(**int16_t)(__ccgo_up(out + uintptr(n1)*2))) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + uintptr(j2)*2))))
  33968 		best_node = int32((*Node)(unsafe.Pointer(node)).Fprev)
  33969 		goto _35
  33970 	_35:
  33971 		;
  33972 		n1 = n1 - 1
  33973 	}
  33974 	return libc.BoolInt32(nz != 0)
  33975 	return r
  33976 }
  33977 
  33978 //------------------------------------------------------------------------------
  33979 // Performs: difference, transform, quantize, back-transform, add
  33980 // all at once. Output is the reconstructed block in *yuv_out, and the
  33981 // quantized levels in *levels.
  33982 
  33983 func ReconstructIntra16(tls *libc.TLS, it uintptr, rd uintptr, yuv_out uintptr, mode int32) (r int32) {
  33984 	bp := tls.Alloc(544)
  33985 	defer tls.Free(544)
  33986 	var ctx, n, non_zero, nz, x, y, v4 int32
  33987 	var dqm, enc, ref, src uintptr
  33988 	var v6 int16_t
  33989 	var _ /* dc_tmp at bp+512 */ [16]int16_t
  33990 	var _ /* tmp at bp+0 */ [16][16]int16_t
  33991 	_, _, _, _, _, _, _, _, _, _, _, _ = ctx, dqm, enc, n, non_zero, nz, ref, src, x, y, v4, v6
  33992 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  33993 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I16ModeOffsets[mode])
  33994 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  33995 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  33996 	nz = 0
  33997 	n = 0
  33998 	for {
  33999 		if !(n < int32(16)) {
  34000 			break
  34001 		}
  34002 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform2})))(tls, src+uintptr(VP8Scan[n]), ref+uintptr(VP8Scan[n]), bp+uintptr(n)*32)
  34003 		goto _1
  34004 	_1:
  34005 		;
  34006 		n = n + int32(2)
  34007 	}
  34008 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransformWHT})))(tls, bp, bp+512)
  34009 	nz = nz | (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlockWHT})))(tls, bp+512, rd+40, dqm+224)<<int32(24)
  34010 	if libc.Bool(int32(DO_TRELLIS_I16) != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34011 		VP8IteratorNzToBytes(tls, it)
  34012 		y = 0
  34013 		n = libc.Int32FromInt32(0)
  34014 		for {
  34015 			if !(y < int32(4)) {
  34016 				break
  34017 			}
  34018 			x = 0
  34019 			for {
  34020 				if !(x < int32(4)) {
  34021 					break
  34022 				}
  34023 				ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  34024 				non_zero = TrellisQuantizeBlock(tls, enc, bp+uintptr(n)*32, rd+72+uintptr(n)*32, ctx, int32(TYPE_I16_AC), dqm, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_trellis_i16)
  34025 				v4 = non_zero
  34026 				**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v4
  34027 				**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v4
  34028 				**(**int16_t)(__ccgo_up(rd + 72 + uintptr(n)*32)) = 0
  34029 				nz = nz | non_zero<<n
  34030 				goto _3
  34031 			_3:
  34032 				;
  34033 				x = x + 1
  34034 				n = n + 1
  34035 			}
  34036 			goto _2
  34037 		_2:
  34038 			;
  34039 			y = y + 1
  34040 		}
  34041 	} else {
  34042 		n = 0
  34043 		for {
  34044 			if !(n < int32(16)) {
  34045 				break
  34046 			}
  34047 			// Zero-out the first coeff, so that: a) nz is correct below, and
  34048 			// b) finding 'last' non-zero coeffs in SetResidualCoeffs() is simplified.
  34049 			v6 = libc.Int16FromInt32(0)
  34050 			**(**int16_t)(__ccgo_up(bp + uintptr(n+int32(1))*32)) = v6
  34051 			**(**int16_t)(__ccgo_up(bp + uintptr(n)*32)) = v6
  34052 			nz = nz | (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantize2Blocks})))(tls, bp+uintptr(n)*32, rd+72+uintptr(n)*32, dqm)<<n
  34053 			goto _5
  34054 		_5:
  34055 			;
  34056 			n = n + int32(2)
  34057 		}
  34058 	}
  34059 	// Transform back
  34060 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformWHT})))(tls, bp+512, bp)
  34061 	n = 0
  34062 	for {
  34063 		if !(n < int32(16)) {
  34064 			break
  34065 		}
  34066 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8ITransform})))(tls, ref+uintptr(VP8Scan[n]), bp+uintptr(n)*32, yuv_out+uintptr(VP8Scan[n]), int32(1))
  34067 		goto _7
  34068 	_7:
  34069 		;
  34070 		n = n + int32(2)
  34071 	}
  34072 	return nz
  34073 }
  34074 
  34075 func ReconstructIntra4(tls *libc.TLS, it uintptr, levels uintptr, src uintptr, yuv_out uintptr, mode int32) (r int32) {
  34076 	bp := tls.Alloc(32)
  34077 	defer tls.Free(32)
  34078 	var ctx, nz, x, y int32
  34079 	var dqm, enc, ref uintptr
  34080 	var _ /* tmp at bp+0 */ [16]int16_t
  34081 	_, _, _, _, _, _, _ = ctx, dqm, enc, nz, ref, x, y
  34082 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34083 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I4ModeOffsets[mode])
  34084 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34085 	nz = 0
  34086 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src, ref, bp)
  34087 	if libc.Bool(int32(DO_TRELLIS_I4) != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34088 		x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & int32(3)
  34089 		y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> int32(2)
  34090 		ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  34091 		nz = TrellisQuantizeBlock(tls, enc, bp, levels, ctx, int32(TYPE_I4_AC), dqm, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_trellis_i4)
  34092 	} else {
  34093 		nz = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlock})))(tls, bp, levels, dqm)
  34094 	}
  34095 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8ITransform})))(tls, ref, bp, yuv_out, 0)
  34096 	return nz
  34097 }
  34098 
  34099 //------------------------------------------------------------------------------
  34100 // DC-error diffusion
  34101 
  34102 // Diffusion weights. We under-correct a bit (15/16th of the error is actually
  34103 // diffused) to avoid 'rainbow' chessboard pattern of blocks at q~=0.
  34104 
  34105 // C documentation
  34106 //
  34107 //	// Quantize as usual, but also compute and return the quantization error.
  34108 //	// Error is already divided by DSHIFT.
  34109 func QuantizeSingle(tls *libc.TLS, v uintptr, mtx uintptr) (r int32) {
  34110 	var V, err, qV, sign, v1, v3 int32
  34111 	_, _, _, _, _, _ = V, err, qV, sign, v1, v3
  34112 	V = int32(**(**int16_t)(__ccgo_up(v)))
  34113 	sign = libc.BoolInt32(V < libc.Int32FromInt32(0))
  34114 	if sign != 0 {
  34115 		V = -V
  34116 	}
  34117 	if V > libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(mtx + 128))) {
  34118 		v1 = libc.Int32FromUint32((libc.Uint32FromInt32(V)*uint32(**(**uint16_t)(__ccgo_up(mtx + 32))) + **(**uint32_t)(__ccgo_up(mtx + 64))) >> libc.Int32FromInt32(QFIX))
  34119 		goto _2
  34120 	_2:
  34121 		qV = v1 * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx)))
  34122 		err = V - qV
  34123 		if sign != 0 {
  34124 			v3 = -qV
  34125 		} else {
  34126 			v3 = qV
  34127 		}
  34128 		**(**int16_t)(__ccgo_up(v)) = int16(v3)
  34129 		if sign != 0 {
  34130 			v1 = -err
  34131 		} else {
  34132 			v1 = err
  34133 		}
  34134 		return v1 >> int32(1)
  34135 	}
  34136 	**(**int16_t)(__ccgo_up(v)) = 0
  34137 	if sign != 0 {
  34138 		v1 = -V
  34139 	} else {
  34140 		v1 = V
  34141 	}
  34142 	return v1 >> int32(1)
  34143 }
  34144 
  34145 func CorrectDCValues(tls *libc.TLS, it uintptr, mtx uintptr, tmp uintptr, rd uintptr) {
  34146 	var c, left, top, v2 uintptr
  34147 	var ch, err0, err1, err2, err3 int32
  34148 	_, _, _, _, _, _, _, _, _ = c, ch, err0, err1, err2, err3, left, top, v2
  34149 	ch = 0
  34150 	for {
  34151 		if !(ch <= int32(1)) {
  34152 			break
  34153 		}
  34154 		top = (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx)*4 + uintptr(ch)*2
  34155 		left = it + 344 + uintptr(ch)*2
  34156 		c = tmp + uintptr(ch*int32(4))*32
  34157 		v2 = c
  34158 		*(*int16_t)(unsafe.Pointer(v2)) = int16_t(int32(*(*int16_t)(unsafe.Pointer(v2))) + (libc.Int32FromInt32(7)*int32(**(**int8_t)(__ccgo_up(top)))+libc.Int32FromInt32(8)*int32(**(**int8_t)(__ccgo_up(left))))>>(libc.Int32FromInt32(4)-libc.Int32FromInt32(1)))
  34159 		err0 = QuantizeSingle(tls, c, mtx)
  34160 		v2 = c + 1*32
  34161 		*(*int16_t)(unsafe.Pointer(v2)) = int16_t(int32(*(*int16_t)(unsafe.Pointer(v2))) + (libc.Int32FromInt32(7)*int32(**(**int8_t)(__ccgo_up(top + 1)))+libc.Int32FromInt32(8)*err0)>>(libc.Int32FromInt32(4)-libc.Int32FromInt32(1)))
  34162 		err1 = QuantizeSingle(tls, c+1*32, mtx)
  34163 		v2 = c + 2*32
  34164 		*(*int16_t)(unsafe.Pointer(v2)) = int16_t(int32(*(*int16_t)(unsafe.Pointer(v2))) + (libc.Int32FromInt32(7)*err0+libc.Int32FromInt32(8)*int32(**(**int8_t)(__ccgo_up(left + 1))))>>(libc.Int32FromInt32(4)-libc.Int32FromInt32(1)))
  34165 		err2 = QuantizeSingle(tls, c+2*32, mtx)
  34166 		v2 = c + 3*32
  34167 		*(*int16_t)(unsafe.Pointer(v2)) = int16_t(int32(*(*int16_t)(unsafe.Pointer(v2))) + (libc.Int32FromInt32(7)*err1+libc.Int32FromInt32(8)*err2)>>(libc.Int32FromInt32(4)-libc.Int32FromInt32(1)))
  34168 		err3 = QuantizeSingle(tls, c+3*32, mtx)
  34169 		// error 'err' is bounded by mtx->q[0] which is 132 at max. Hence
  34170 		// err >> DSCALE will fit in an int8_t type if DSCALE>=1.
  34171 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3)) = int8(err1)
  34172 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 1)) = int8(err2)
  34173 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 2)) = int8(err3)
  34174 		goto _1
  34175 	_1:
  34176 		;
  34177 		ch = ch + 1
  34178 	}
  34179 }
  34180 
  34181 func StoreDiffusionErrors(tls *libc.TLS, it uintptr, rd uintptr) {
  34182 	var ch int32
  34183 	var left, top uintptr
  34184 	_, _, _ = ch, left, top
  34185 	ch = 0
  34186 	for {
  34187 		if !(ch <= int32(1)) {
  34188 			break
  34189 		}
  34190 		top = (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx)*4 + uintptr(ch)*2
  34191 		left = it + 344 + uintptr(ch)*2
  34192 		**(**int8_t)(__ccgo_up(left)) = **(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3))                                                                // restore err1
  34193 		**(**int8_t)(__ccgo_up(left + 1)) = int8(int32(3) * int32(**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 2))) >> int32(2))                    //     ... 3/4th of err3
  34194 		**(**int8_t)(__ccgo_up(top)) = **(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 1))                                                             //     ... err2
  34195 		**(**int8_t)(__ccgo_up(top + 1)) = int8(int32(**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 2))) - int32(**(**int8_t)(__ccgo_up(left + 1)))) //     ... 1/4th of err3.
  34196 		goto _1
  34197 	_1:
  34198 		;
  34199 		ch = ch + 1
  34200 	}
  34201 }
  34202 
  34203 //------------------------------------------------------------------------------
  34204 
  34205 func ReconstructUV(tls *libc.TLS, it uintptr, rd uintptr, yuv_out uintptr, mode int32) (r int32) {
  34206 	bp := tls.Alloc(256)
  34207 	defer tls.Free(256)
  34208 	var ch, ctx, n, non_zero, nz, x, y, v5 int32
  34209 	var dqm, enc, ref, src uintptr
  34210 	var _ /* tmp at bp+0 */ [8][16]int16_t
  34211 	_, _, _, _, _, _, _, _, _, _, _, _ = ch, ctx, dqm, enc, n, non_zero, nz, ref, src, x, y, v5
  34212 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34213 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8UVModeOffsets[mode])
  34214 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34215 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34216 	nz = 0
  34217 	n = 0
  34218 	for {
  34219 		if !(n < int32(8)) {
  34220 			break
  34221 		}
  34222 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform2})))(tls, src+uintptr(VP8ScanUV[n]), ref+uintptr(VP8ScanUV[n]), bp+uintptr(n)*32)
  34223 		goto _1
  34224 	_1:
  34225 		;
  34226 		n = n + int32(2)
  34227 	}
  34228 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  34229 		CorrectDCValues(tls, it, dqm+448, bp, rd)
  34230 	}
  34231 	if libc.Bool(DO_TRELLIS_UV != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34232 		ch = 0
  34233 		n = libc.Int32FromInt32(0)
  34234 		for {
  34235 			if !(ch <= int32(2)) {
  34236 				break
  34237 			}
  34238 			y = 0
  34239 			for {
  34240 				if !(y < int32(2)) {
  34241 					break
  34242 				}
  34243 				x = 0
  34244 				for {
  34245 					if !(x < int32(2)) {
  34246 						break
  34247 					}
  34248 					ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  34249 					non_zero = TrellisQuantizeBlock(tls, enc, bp+uintptr(n)*32, rd+584+uintptr(n)*32, ctx, int32(TYPE_CHROMA_A), dqm+448, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_trellis_uv)
  34250 					v5 = non_zero
  34251 					**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v5
  34252 					**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v5
  34253 					nz = nz | non_zero<<n
  34254 					goto _4
  34255 				_4:
  34256 					;
  34257 					x = x + 1
  34258 					n = n + 1
  34259 				}
  34260 				goto _3
  34261 			_3:
  34262 				;
  34263 				y = y + 1
  34264 			}
  34265 			goto _2
  34266 		_2:
  34267 			;
  34268 			ch = ch + int32(2)
  34269 		}
  34270 	} else {
  34271 		n = 0
  34272 		for {
  34273 			if !(n < int32(8)) {
  34274 				break
  34275 			}
  34276 			nz = nz | (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantize2Blocks})))(tls, bp+uintptr(n)*32, rd+584+uintptr(n)*32, dqm+448)<<n
  34277 			goto _6
  34278 		_6:
  34279 			;
  34280 			n = n + int32(2)
  34281 		}
  34282 	}
  34283 	n = 0
  34284 	for {
  34285 		if !(n < int32(8)) {
  34286 			break
  34287 		}
  34288 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8ITransform})))(tls, ref+uintptr(VP8ScanUV[n]), bp+uintptr(n)*32, yuv_out+uintptr(VP8ScanUV[n]), int32(1))
  34289 		goto _7
  34290 	_7:
  34291 		;
  34292 		n = n + int32(2)
  34293 	}
  34294 	return nz << int32(16)
  34295 }
  34296 
  34297 //------------------------------------------------------------------------------
  34298 // RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost.
  34299 // Pick the mode is lower RD-cost = Rate + lambda * Distortion.
  34300 
  34301 func StoreMaxDelta(tls *libc.TLS, dqm uintptr, DCs uintptr) {
  34302 	var max_v, v0, v1, v2, v11, v21 int32
  34303 	_, _, _, _, _, _ = max_v, v0, v1, v2, v11, v21
  34304 	// We look at the first three AC coefficients to determine what is the average
  34305 	// delta between each sub-4x4 block.
  34306 	v0 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 1*2))))
  34307 	v1 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 2*2))))
  34308 	v2 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 4*2))))
  34309 	if v1 > v0 {
  34310 		v11 = v1
  34311 	} else {
  34312 		v11 = v0
  34313 	}
  34314 	max_v = v11
  34315 	if v2 > max_v {
  34316 		v21 = v2
  34317 	} else {
  34318 		v21 = max_v
  34319 	}
  34320 	max_v = v21
  34321 	if max_v > (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge {
  34322 		(*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge = max_v
  34323 	}
  34324 }
  34325 
  34326 func SwapModeScore(tls *libc.TLS, a uintptr, b uintptr) {
  34327 	var tmp uintptr
  34328 	_ = tmp
  34329 	tmp = **(**uintptr)(__ccgo_up(a))
  34330 	**(**uintptr)(__ccgo_up(a)) = **(**uintptr)(__ccgo_up(b))
  34331 	**(**uintptr)(__ccgo_up(b)) = tmp
  34332 }
  34333 
  34334 func SwapPtr(tls *libc.TLS, a uintptr, b uintptr) {
  34335 	var tmp uintptr
  34336 	_ = tmp
  34337 	tmp = **(**uintptr)(__ccgo_up(a))
  34338 	**(**uintptr)(__ccgo_up(a)) = **(**uintptr)(__ccgo_up(b))
  34339 	**(**uintptr)(__ccgo_up(b)) = tmp
  34340 }
  34341 
  34342 func SwapOut(tls *libc.TLS, it uintptr) {
  34343 	SwapPtr(tls, it+16, it+24)
  34344 }
  34345 
  34346 func PickBestIntra16(tls *libc.TLS, it uintptr, rd uintptr) {
  34347 	bp := tls.Alloc(912)
  34348 	defer tls.Free(912)
  34349 	var dqm, src1, tmp_dst, v1 uintptr
  34350 	var i, i1, is_flat, kNumBlocks, lambda, mode, score, tlambda, v3, v6, v8 int32
  34351 	var _ /* rd_best at bp+896 */ uintptr
  34352 	var _ /* rd_cur at bp+888 */ uintptr
  34353 	var _ /* rd_tmp at bp+8 */ VP8ModeScore
  34354 	var _ /* v at bp+0 */ uint32_t
  34355 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = dqm, i, i1, is_flat, kNumBlocks, lambda, mode, score, src1, tlambda, tmp_dst, v1, v3, v6, v8
  34356 	kNumBlocks = int32(16)
  34357 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34358 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_i16
  34359 	tlambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ftlambda
  34360 	src1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34361 	**(**uintptr)(__ccgo_up(bp + 888)) = bp + 8
  34362 	**(**uintptr)(__ccgo_up(bp + 896)) = rd
  34363 	v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34364 	**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(v1))) * uint32(0x01010101)
  34365 	i1 = libc.Int32FromInt32(0)
  34366 	for {
  34367 		if !(i1 < libc.Int32FromInt32(16)) {
  34368 			break
  34369 		}
  34370 		if libc.Xmemcmp(tls, v1+uintptr(0), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v1+uintptr(4), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v1+uintptr(8), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v1+uintptr(12), bp, uint64(4)) != 0 {
  34371 			v3 = 0
  34372 			goto _4
  34373 		}
  34374 		v1 = v1 + uintptr(BPS)
  34375 		goto _2
  34376 	_2:
  34377 		;
  34378 		i1 = i1 + 1
  34379 	}
  34380 	v3 = int32(1)
  34381 	goto _4
  34382 _4:
  34383 	is_flat = v3
  34384 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_i16 = -int32(1)
  34385 	mode = 0
  34386 	for {
  34387 		if !(mode < int32(NUM_PRED_MODES)) {
  34388 			break
  34389 		}
  34390 		tmp_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) // scratch buffer
  34391 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fmode_i16 = mode
  34392 		// Reconstruct
  34393 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fnz = libc.Uint32FromInt32(ReconstructIntra16(tls, it, **(**uintptr)(__ccgo_up(bp + 888)), tmp_dst, mode))
  34394 		// Measure RD-score
  34395 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FD = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x16})))(tls, src1, tmp_dst))
  34396 		if tlambda != 0 {
  34397 			v3 = (tlambda*(*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8TDisto16x16})))(tls, src1, tmp_dst, uintptr(unsafe.Pointer(&kWeightY))) + int32(128)) >> int32(8)
  34398 		} else {
  34399 			v3 = 0
  34400 		}
  34401 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FSD = int64(v3)
  34402 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FH = libc.Int64FromUint16(VP8FixedCostsI16[mode])
  34403 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FR = int64(VP8GetCostLuma16(tls, it, **(**uintptr)(__ccgo_up(bp + 888))))
  34404 		if is_flat != 0 {
  34405 			// refine the first impression (which was in pixel space)
  34406 			v1 = **(**uintptr)(__ccgo_up(bp + 888)) + 72
  34407 			v3 = kNumBlocks
  34408 			score = 0
  34409 			for {
  34410 				v6 = v3
  34411 				v3 = v3 - 1
  34412 				if !(v6 > libc.Int32FromInt32(0)) {
  34413 					break
  34414 				}
  34415 				i = libc.Int32FromInt32(1)
  34416 				for {
  34417 					if !(i < libc.Int32FromInt32(16)) {
  34418 						break
  34419 					}
  34420 					score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v1 + uintptr(i)*2))) != 0)
  34421 					if score > FLATNESS_LIMIT_I16 {
  34422 						v8 = 0
  34423 						goto _12
  34424 					}
  34425 					goto _10
  34426 				_10:
  34427 					;
  34428 					i = i + 1
  34429 				}
  34430 				v1 = v1 + uintptr(16)*2
  34431 			}
  34432 			v8 = int32(1)
  34433 			goto _12
  34434 		_12:
  34435 			is_flat = v8
  34436 			if is_flat != 0 {
  34437 				// Block is very flat. We put emphasis on the distortion being very low!
  34438 				**(**score_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 888)))) *= int64(2)
  34439 				**(**score_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 888)) + 8)) *= int64(2)
  34440 			}
  34441 		}
  34442 		// Since we always examine Intra16 first, we can overwrite *rd directly.
  34443 		SetRDScore(tls, lambda, **(**uintptr)(__ccgo_up(bp + 888)))
  34444 		if mode == 0 || (*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fscore < (*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 896)))).Fscore {
  34445 			SwapModeScore(tls, bp+888, bp+896)
  34446 			SwapOut(tls, it)
  34447 		}
  34448 		goto _5
  34449 	_5:
  34450 		;
  34451 		mode = mode + 1
  34452 	}
  34453 	if **(**uintptr)(__ccgo_up(bp + 896)) != rd {
  34454 		libc.X__builtin___memcpy_chk(tls, rd, **(**uintptr)(__ccgo_up(bp + 896)), uint64(880), ^__predefined_size_t(0))
  34455 	}
  34456 	SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, rd) // finalize score for mode decision.
  34457 	VP8SetIntra16Mode(tls, it, (*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_i16)
  34458 	// we have a blocky macroblock (only DCs are non-zero) with fairly high
  34459 	// distortion, record max delta so we can later adjust the minimal filtering
  34460 	// strength needed to smooth these blocks out.
  34461 	if (*VP8ModeScore)(unsafe.Pointer(rd)).Fnz&uint32(0x100ffff) == uint32(0x1000000) && (*VP8ModeScore)(unsafe.Pointer(rd)).FD > int64((*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmin_disto) {
  34462 		StoreMaxDelta(tls, dqm, rd+40)
  34463 	}
  34464 }
  34465 
  34466 //------------------------------------------------------------------------------
  34467 
  34468 // C documentation
  34469 //
  34470 //	// return the cost array corresponding to the surrounding prediction modes.
  34471 func GetCostModeI4(tls *libc.TLS, it uintptr, modes uintptr) (r uintptr) {
  34472 	var left, preds_w, top, x, y, v1, v2 int32
  34473 	_, _, _, _, _, _, _ = left, preds_w, top, x, y, v1, v2
  34474 	preds_w = (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w
  34475 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & libc.Int32FromInt32(3)
  34476 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> int32(2)
  34477 	if x == 0 {
  34478 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds + uintptr(y*preds_w-int32(1)))))
  34479 	} else {
  34480 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(modes + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4-int32(1)))))
  34481 	}
  34482 	left = v1
  34483 	if y == 0 {
  34484 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds + uintptr(-preds_w+x))))
  34485 	} else {
  34486 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(modes + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4-int32(4)))))
  34487 	}
  34488 	top = v2
  34489 	return uintptr(unsafe.Pointer(&VP8FixedCostsI4)) + uintptr(top)*200 + uintptr(left)*20
  34490 }
  34491 
  34492 func PickBestIntra4(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  34493 	bp := tls.Alloc(2688)
  34494 	defer tls.Free(2688)
  34495 	var best_blocks, dqm, enc, mode_costs, src, src0, v3 uintptr
  34496 	var best_mode, i, kNumBlocks, lambda, mode, score, tlambda, total_header_bits, v2, v4, v5 int32
  34497 	var v9 bool
  34498 	var _ /* best_block at bp+1760 */ uintptr
  34499 	var _ /* rd_best at bp+0 */ VP8ModeScore
  34500 	var _ /* rd_i4 at bp+880 */ VP8ModeScore
  34501 	var _ /* rd_tmp at bp+1776 */ VP8ModeScore
  34502 	var _ /* tmp_dst at bp+1768 */ uintptr
  34503 	var _ /* tmp_levels at bp+2656 */ [16]int16_t
  34504 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_blocks, best_mode, dqm, enc, i, kNumBlocks, lambda, mode, mode_costs, score, src, src0, tlambda, total_header_bits, v2, v3, v4, v5, v9
  34505 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34506 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34507 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_i4
  34508 	tlambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ftlambda
  34509 	src0 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34510 	best_blocks = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34511 	total_header_bits = 0
  34512 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits == 0 {
  34513 		return 0
  34514 	}
  34515 	InitScore(tls, bp)
  34516 	(**(**VP8ModeScore)(__ccgo_up(bp))).FH = int64(211) // '211' is the value of VP8BitCost(0, 145)
  34517 	SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, bp)
  34518 	VP8IteratorStartI4(tls, it)
  34519 	for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, best_blocks) != 0 {
  34520 		kNumBlocks = int32(1)
  34521 		best_mode = -int32(1)
  34522 		src = src0 + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34523 		mode_costs = GetCostModeI4(tls, it, rd+844)
  34524 		**(**uintptr)(__ccgo_up(bp + 1760)) = best_blocks + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34525 		**(**uintptr)(__ccgo_up(bp + 1768)) = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)) // scratch buffer.
  34526 		InitScore(tls, bp+880)
  34527 		MakeIntra4Preds(tls, it)
  34528 		mode = 0
  34529 		for {
  34530 			if !(mode < int32(NUM_BMODES)) {
  34531 				break
  34532 			}
  34533 			// Reconstruct
  34534 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).Fnz = libc.Uint32FromInt32(ReconstructIntra4(tls, it, bp+2656, src, **(**uintptr)(__ccgo_up(bp + 1768)), mode) << (*VP8EncIterator)(unsafe.Pointer(it)).Fi4)
  34535 			// Compute RD-score
  34536 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FD = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE4x4})))(tls, src, **(**uintptr)(__ccgo_up(bp + 1768))))
  34537 			if tlambda != 0 {
  34538 				v2 = (tlambda*(*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8TDisto4x4})))(tls, src, **(**uintptr)(__ccgo_up(bp + 1768)), uintptr(unsafe.Pointer(&kWeightY))) + int32(128)) >> int32(8)
  34539 			} else {
  34540 				v2 = 0
  34541 			}
  34542 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FSD = int64(v2)
  34543 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FH = libc.Int64FromUint16(**(**uint16_t)(__ccgo_up(mode_costs + uintptr(mode)*2)))
  34544 			// Add flatness penalty, to avoid flat area to be mispredicted
  34545 			// by a complex mode.
  34546 			if v9 = mode > 0; v9 {
  34547 				v3 = bp + 2656
  34548 				v2 = kNumBlocks
  34549 				score = 0
  34550 				for {
  34551 					v4 = v2
  34552 					v2 = v2 - 1
  34553 					if !(v4 > libc.Int32FromInt32(0)) {
  34554 						break
  34555 					}
  34556 					i = libc.Int32FromInt32(1)
  34557 					for {
  34558 						if !(i < libc.Int32FromInt32(16)) {
  34559 							break
  34560 						}
  34561 						score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v3 + uintptr(i)*2))) != 0)
  34562 						if score > int32(FLATNESS_LIMIT_I4) {
  34563 							v5 = 0
  34564 							goto _8
  34565 						}
  34566 						goto _6
  34567 					_6:
  34568 						;
  34569 						i = i + 1
  34570 					}
  34571 					v3 = v3 + uintptr(16)*2
  34572 				}
  34573 				v5 = int32(1)
  34574 				goto _8
  34575 			_8:
  34576 			}
  34577 			if v9 && v5 != 0 {
  34578 				(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR = int64(int32(FLATNESS_PENALTY) * kNumBlocks)
  34579 			} else {
  34580 				(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR = 0
  34581 			}
  34582 			// early-out check
  34583 			SetRDScore(tls, lambda, bp+1776)
  34584 			if best_mode >= 0 && (**(**VP8ModeScore)(__ccgo_up(bp + 1776))).Fscore >= (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fscore {
  34585 				goto _1
  34586 			}
  34587 			// finish computing score
  34588 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR += int64(VP8GetCostLuma4(tls, it, bp+2656))
  34589 			SetRDScore(tls, lambda, bp+1776)
  34590 			if best_mode < 0 || (**(**VP8ModeScore)(__ccgo_up(bp + 1776))).Fscore < (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fscore {
  34591 				CopyScore(tls, bp+880, bp+1776)
  34592 				best_mode = mode
  34593 				SwapPtr(tls, bp+1768, bp+1760)
  34594 				libc.X__builtin___memcpy_chk(tls, bp+72+uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4)*32, bp+2656, uint64(32), ^__predefined_size_t(0))
  34595 			}
  34596 			goto _1
  34597 		_1:
  34598 			;
  34599 			mode = mode + 1
  34600 		}
  34601 		SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, bp+880)
  34602 		AddScore(tls, bp, bp+880)
  34603 		if (**(**VP8ModeScore)(__ccgo_up(bp))).Fscore >= (*VP8ModeScore)(unsafe.Pointer(rd)).Fscore {
  34604 			return 0
  34605 		}
  34606 		total_header_bits = total_header_bits + int32((**(**VP8ModeScore)(__ccgo_up(bp + 880))).FH) // <- equal to mode_costs[best_mode];
  34607 		if total_header_bits > (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits {
  34608 			return 0
  34609 		}
  34610 		// Copy selected samples if not in the right place already.
  34611 		if **(**uintptr)(__ccgo_up(bp + 1760)) != best_blocks+uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4]) {
  34612 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8Copy4x4})))(tls, **(**uintptr)(__ccgo_up(bp + 1760)), best_blocks+uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4]))
  34613 		}
  34614 		**(**uint8_t)(__ccgo_up(rd + 844 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4))) = libc.Uint8FromInt32(best_mode)
  34615 		if (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fnz != 0 {
  34616 			v4 = int32(1)
  34617 		} else {
  34618 			v4 = 0
  34619 		}
  34620 		v2 = v4
  34621 		**(**int32)(__ccgo_up(it + 168 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4>>int32(2))*4)) = v2
  34622 		**(**int32)(__ccgo_up(it + 132 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4&int32(3))*4)) = v2
  34623 	}
  34624 	// finalize state
  34625 	CopyScore(tls, rd, bp)
  34626 	VP8SetIntra4Mode(tls, it, rd+844)
  34627 	SwapOut(tls, it)
  34628 	libc.X__builtin___memcpy_chk(tls, rd+72, bp+72, uint64(512), ^__predefined_size_t(0))
  34629 	return int32(1) // select intra4x4 over intra16x16
  34630 }
  34631 
  34632 //------------------------------------------------------------------------------
  34633 
  34634 func PickBestUV(tls *libc.TLS, it uintptr, rd uintptr) {
  34635 	bp := tls.Alloc(1776)
  34636 	defer tls.Free(1776)
  34637 	var dqm, dst0, src, v2 uintptr
  34638 	var i, kNumBlocks, lambda, mode, score, v3, v4, v6 int32
  34639 	var v8 bool
  34640 	var _ /* dst at bp+8 */ uintptr
  34641 	var _ /* rd_best at bp+16 */ VP8ModeScore
  34642 	var _ /* rd_uv at bp+896 */ VP8ModeScore
  34643 	var _ /* tmp_dst at bp+0 */ uintptr
  34644 	_, _, _, _, _, _, _, _, _, _, _, _, _ = dqm, dst0, i, kNumBlocks, lambda, mode, score, src, v2, v3, v4, v6, v8
  34645 	kNumBlocks = int32(8)
  34646 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34647 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_uv
  34648 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34649 	**(**uintptr)(__ccgo_up(bp)) = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(U_OFF_ENC)) // scratch buffer
  34650 	dst0 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34651 	**(**uintptr)(__ccgo_up(bp + 8)) = dst0
  34652 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv = -int32(1)
  34653 	InitScore(tls, bp+16)
  34654 	mode = 0
  34655 	for {
  34656 		if !(mode < int32(NUM_PRED_MODES)) {
  34657 			break
  34658 		}
  34659 		// Reconstruct
  34660 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).Fnz = libc.Uint32FromInt32(ReconstructUV(tls, it, bp+896, **(**uintptr)(__ccgo_up(bp)), mode))
  34661 		// Compute RD-score
  34662 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FD = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x8})))(tls, src, **(**uintptr)(__ccgo_up(bp))))
  34663 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FSD = 0 // not calling TDisto here: it tends to flatten areas.
  34664 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FH = libc.Int64FromUint16(VP8FixedCostsUV[mode])
  34665 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FR = int64(VP8GetCostUV(tls, it, bp+896))
  34666 		if v8 = mode > 0; v8 {
  34667 			v2 = bp + 896 + 584
  34668 			v3 = kNumBlocks
  34669 			score = 0
  34670 			for {
  34671 				v4 = v3
  34672 				v3 = v3 - 1
  34673 				if !(v4 > libc.Int32FromInt32(0)) {
  34674 					break
  34675 				}
  34676 				i = libc.Int32FromInt32(1)
  34677 				for {
  34678 					if !(i < libc.Int32FromInt32(16)) {
  34679 						break
  34680 					}
  34681 					score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v2 + uintptr(i)*2))) != 0)
  34682 					if score > int32(FLATNESS_LIMIT_UV) {
  34683 						v6 = 0
  34684 						goto _7
  34685 					}
  34686 					goto _5
  34687 				_5:
  34688 					;
  34689 					i = i + 1
  34690 				}
  34691 				v2 = v2 + uintptr(16)*2
  34692 			}
  34693 			v6 = int32(1)
  34694 			goto _7
  34695 		_7:
  34696 		}
  34697 		if v8 && v6 != 0 {
  34698 			(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FR += int64(int32(FLATNESS_PENALTY) * kNumBlocks)
  34699 		}
  34700 		SetRDScore(tls, lambda, bp+896)
  34701 		if mode == 0 || (**(**VP8ModeScore)(__ccgo_up(bp + 896))).Fscore < (**(**VP8ModeScore)(__ccgo_up(bp + 16))).Fscore {
  34702 			CopyScore(tls, bp+16, bp+896)
  34703 			(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv = mode
  34704 			libc.X__builtin___memcpy_chk(tls, rd+584, bp+896+584, uint64(256), ^__predefined_size_t(0))
  34705 			if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  34706 				libc.X__builtin___memcpy_chk(tls, rd+868, bp+896+868, uint64(6), ^__predefined_size_t(0))
  34707 			}
  34708 			SwapPtr(tls, bp+8, bp)
  34709 		}
  34710 		goto _1
  34711 	_1:
  34712 		;
  34713 		mode = mode + 1
  34714 	}
  34715 	VP8SetIntraUVMode(tls, it, (*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv)
  34716 	AddScore(tls, rd, bp+16)
  34717 	if **(**uintptr)(__ccgo_up(bp + 8)) != dst0 { // copy 16x8 block if needed
  34718 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8Copy16x8})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), dst0)
  34719 	}
  34720 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) { // store diffusion errors for next block
  34721 		StoreDiffusionErrors(tls, it, rd)
  34722 	}
  34723 }
  34724 
  34725 //------------------------------------------------------------------------------
  34726 // Final reconstruction and quantization.
  34727 
  34728 func SimpleQuantize(tls *libc.TLS, it uintptr, rd uintptr) {
  34729 	var dst, enc, src uintptr
  34730 	var is_i16, mode, nz int32
  34731 	_, _, _, _, _, _ = dst, enc, is_i16, mode, nz, src
  34732 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34733 	is_i16 = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == libc.Int32FromInt32(1))
  34734 	nz = 0
  34735 	if is_i16 != 0 {
  34736 		nz = ReconstructIntra16(tls, it, rd, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds))))
  34737 	} else {
  34738 		VP8IteratorStartI4(tls, it)
  34739 		for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(Y_OFF_ENC))) != 0 {
  34740 			mode = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4&int32(3)+(*VP8EncIterator)(unsafe.Pointer(it)).Fi4>>int32(2)*(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w))))
  34741 			src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34742 			dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34743 			MakeIntra4Preds(tls, it)
  34744 			nz = nz | ReconstructIntra4(tls, it, rd+72+uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4)*32, src, dst, mode)<<(*VP8EncIterator)(unsafe.Pointer(it)).Fi4
  34745 		}
  34746 	}
  34747 	nz = nz | ReconstructUV(tls, it, rd, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(U_OFF_ENC)), int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0xc>>2)))
  34748 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = libc.Uint32FromInt32(nz)
  34749 }
  34750 
  34751 // C documentation
  34752 //
  34753 //	// Refine intra16/intra4 sub-modes based on distortion only (not rate).
  34754 func RefineUsingDistortion(tls *libc.TLS, it uintptr, try_both_modes int32, refine_uv_mode int32, rd uintptr) {
  34755 	bp := tls.Alloc(16)
  34756 	defer tls.Free(16)
  34757 	var best_i4_mode, best_mode, best_mode1, i, is_i16, lambda_d_i16, lambda_d_i4, lambda_d_uv, mode, nz, v5, v7 int32
  34758 	var best_i4_score, best_score, best_uv_score, bit_limit, i4_bit_sum, score, score1, score2, score_i4 score_t
  34759 	var dqm, mode_costs, ref, ref1, ref2, src1, src2, src3, tmp_dst, v3 uintptr
  34760 	var v1 int64
  34761 	var _ /* v at bp+0 */ uint32_t
  34762 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_i4_mode, best_i4_score, best_mode, best_mode1, best_score, best_uv_score, bit_limit, dqm, i, i4_bit_sum, is_i16, lambda_d_i16, lambda_d_i4, lambda_d_uv, mode, mode_costs, nz, ref, ref1, ref2, score, score1, score2, score_i4, src1, src2, src3, tmp_dst, v1, v3, v5, v7
  34763 	best_score = libc.Int64FromInt64(0x7fffffffffffff)
  34764 	nz = 0
  34765 	is_i16 = libc.BoolInt32(try_both_modes != 0 || int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1))
  34766 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34767 	// Some empiric constants, of approximate order of magnitude.
  34768 	lambda_d_i16 = int32(106)
  34769 	lambda_d_i4 = int32(11)
  34770 	lambda_d_uv = int32(120)
  34771 	score_i4 = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fi4_penalty
  34772 	i4_bit_sum = 0
  34773 	if try_both_modes != 0 {
  34774 		v1 = int64((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmb_header_limit)
  34775 	} else {
  34776 		v1 = libc.Int64FromInt64(0x7fffffffffffff)
  34777 	}
  34778 	bit_limit = v1   // no early-out allowed
  34779 	if is_i16 != 0 { // First, evaluate Intra16 distortion
  34780 		best_mode = -int32(1)
  34781 		src1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34782 		mode = 0
  34783 		for {
  34784 			if !(mode < int32(NUM_PRED_MODES)) {
  34785 				break
  34786 			}
  34787 			ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I16ModeOffsets[mode])
  34788 			score = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x16})))(tls, src1, ref))*int64(RD_DISTO_MULT) + int64(libc.Int32FromUint16(VP8FixedCostsI16[mode])*lambda_d_i16)
  34789 			if mode > 0 && libc.Int64FromUint16(VP8FixedCostsI16[mode]) > bit_limit {
  34790 				goto _2
  34791 			}
  34792 			if score < best_score {
  34793 				best_mode = mode
  34794 				best_score = score
  34795 			}
  34796 			goto _2
  34797 		_2:
  34798 			;
  34799 			mode = mode + 1
  34800 		}
  34801 		if (*VP8EncIterator)(unsafe.Pointer(it)).Fx == 0 || (*VP8EncIterator)(unsafe.Pointer(it)).Fy == 0 {
  34802 			// avoid starting a checkerboard resonance from the border. See bug #432.
  34803 			v3 = src1
  34804 			**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(v3))) * uint32(0x01010101)
  34805 			i = libc.Int32FromInt32(0)
  34806 			for {
  34807 				if !(i < libc.Int32FromInt32(16)) {
  34808 					break
  34809 				}
  34810 				if libc.Xmemcmp(tls, v3+uintptr(0), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v3+uintptr(4), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v3+uintptr(8), bp, uint64(4)) != 0 || libc.Xmemcmp(tls, v3+uintptr(12), bp, uint64(4)) != 0 {
  34811 					v5 = 0
  34812 					goto _6
  34813 				}
  34814 				v3 = v3 + uintptr(BPS)
  34815 				goto _4
  34816 			_4:
  34817 				;
  34818 				i = i + 1
  34819 			}
  34820 			v5 = int32(1)
  34821 			goto _6
  34822 		_6:
  34823 			if v5 != 0 {
  34824 				if (*VP8EncIterator)(unsafe.Pointer(it)).Fx == 0 {
  34825 					v7 = 0
  34826 				} else {
  34827 					v7 = int32(2)
  34828 				}
  34829 				best_mode = v7
  34830 				try_both_modes = 0 // stick to i16
  34831 			}
  34832 		}
  34833 		VP8SetIntra16Mode(tls, it, best_mode)
  34834 		// we'll reconstruct later, if i16 mode actually gets selected
  34835 	}
  34836 	// Next, evaluate Intra4
  34837 	if try_both_modes != 0 || !(is_i16 != 0) {
  34838 		// We don't evaluate the rate here, but just account for it through a
  34839 		// constant penalty (i4 mode usually needs more bits compared to i16).
  34840 		is_i16 = 0
  34841 		VP8IteratorStartI4(tls, it)
  34842 		for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2+uintptr(libc.Int32FromInt32(Y_OFF_ENC))) != 0 {
  34843 			best_i4_mode = -int32(1)
  34844 			best_i4_score = libc.Int64FromInt64(0x7fffffffffffff)
  34845 			src2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34846 			mode_costs = GetCostModeI4(tls, it, rd+844)
  34847 			MakeIntra4Preds(tls, it)
  34848 			mode = 0
  34849 			for {
  34850 				if !(mode < int32(NUM_BMODES)) {
  34851 					break
  34852 				}
  34853 				ref1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I4ModeOffsets[mode])
  34854 				score1 = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE4x4})))(tls, src2, ref1)*int32(RD_DISTO_MULT) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mode_costs + uintptr(mode)*2)))*lambda_d_i4)
  34855 				if score1 < best_i4_score {
  34856 					best_i4_mode = mode
  34857 					best_i4_score = score1
  34858 				}
  34859 				goto _8
  34860 			_8:
  34861 				;
  34862 				mode = mode + 1
  34863 			}
  34864 			i4_bit_sum = i4_bit_sum + libc.Int64FromUint16(**(**uint16_t)(__ccgo_up(mode_costs + uintptr(best_i4_mode)*2)))
  34865 			**(**uint8_t)(__ccgo_up(rd + 844 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4))) = libc.Uint8FromInt32(best_i4_mode)
  34866 			score_i4 = score_i4 + best_i4_score
  34867 			if score_i4 >= best_score || i4_bit_sum > bit_limit {
  34868 				// Intra4 won't be better than Intra16. Bail out and pick Intra16.
  34869 				is_i16 = int32(1)
  34870 				break
  34871 			} else { // reconstruct partial block inside yuv_out2 buffer
  34872 				tmp_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34873 				nz = nz | ReconstructIntra4(tls, it, rd+72+uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4)*32, src2, tmp_dst, best_i4_mode)<<(*VP8EncIterator)(unsafe.Pointer(it)).Fi4
  34874 			}
  34875 		}
  34876 	}
  34877 	// Final reconstruction, depending on which mode is selected.
  34878 	if !(is_i16 != 0) {
  34879 		VP8SetIntra4Mode(tls, it, rd+844)
  34880 		SwapOut(tls, it)
  34881 		best_score = score_i4
  34882 	} else {
  34883 		nz = ReconstructIntra16(tls, it, rd, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(Y_OFF_ENC)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds))))
  34884 	}
  34885 	// ... and UV!
  34886 	if refine_uv_mode != 0 {
  34887 		best_mode1 = -int32(1)
  34888 		best_uv_score = libc.Int64FromInt64(0x7fffffffffffff)
  34889 		src3 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34890 		mode = 0
  34891 		for {
  34892 			if !(mode < int32(NUM_PRED_MODES)) {
  34893 				break
  34894 			}
  34895 			ref2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8UVModeOffsets[mode])
  34896 			score2 = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x8})))(tls, src3, ref2)*int32(RD_DISTO_MULT) + libc.Int32FromUint16(VP8FixedCostsUV[mode])*lambda_d_uv)
  34897 			if score2 < best_uv_score {
  34898 				best_mode1 = mode
  34899 				best_uv_score = score2
  34900 			}
  34901 			goto _9
  34902 		_9:
  34903 			;
  34904 			mode = mode + 1
  34905 		}
  34906 		VP8SetIntraUVMode(tls, it, best_mode1)
  34907 	}
  34908 	nz = nz | ReconstructUV(tls, it, rd, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(U_OFF_ENC)), int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0xc>>2)))
  34909 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = libc.Uint32FromInt32(nz)
  34910 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fscore = best_score
  34911 }
  34912 
  34913 //------------------------------------------------------------------------------
  34914 // Entry point
  34915 
  34916 func VP8Decimate(tls *libc.TLS, it uintptr, rd uintptr, rd_opt VP8RDLevel) (r int32) {
  34917 	var is_skipped, method int32
  34918 	_, _ = is_skipped, method
  34919 	method = (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmethod
  34920 	InitScore(tls, rd)
  34921 	// We can perform predictions for Luma16x16 and Chroma8x8 already.
  34922 	// Luma4x4 predictions needs to be done as-we-go.
  34923 	VP8MakeLuma16Preds(tls, it)
  34924 	VP8MakeChroma8Preds(tls, it)
  34925 	if rd_opt > int32(RD_OPT_NONE) {
  34926 		(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = libc.BoolInt32(rd_opt >= int32(RD_OPT_TRELLIS_ALL))
  34927 		PickBestIntra16(tls, it, rd)
  34928 		if method >= int32(2) {
  34929 			PickBestIntra4(tls, it, rd)
  34930 		}
  34931 		PickBestUV(tls, it, rd)
  34932 		if rd_opt == int32(RD_OPT_TRELLIS) { // finish off with trellis-optim now
  34933 			(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = int32(1)
  34934 			SimpleQuantize(tls, it, rd)
  34935 		}
  34936 	} else {
  34937 		// At this point we have heuristically decided intra16 / intra4.
  34938 		// For method >= 2, pick the best intra4/intra16 based on SSE (~tad slower).
  34939 		// For method <= 1, we don't re-examine the decision but just go ahead with
  34940 		// quantization/reconstruction.
  34941 		RefineUsingDistortion(tls, it, libc.BoolInt32(method >= int32(2)), libc.BoolInt32(method >= int32(1)), rd)
  34942 	}
  34943 	is_skipped = libc.BoolInt32((*VP8ModeScore)(unsafe.Pointer(rd)).Fnz == uint32(0))
  34944 	VP8SetSkip(tls, it, is_skipped)
  34945 	return is_skipped
  34946 }
  34947 
  34948 const ARGB_BLACK2 = 0xff000000
  34949 const VP8_SIGNATURE1 = 10289450
  34950 const __FLT_MIN__8 = 1.17549435082228750796873653722224568e-38
  34951 
  34952 //------------------------------------------------------------------------------
  34953 // Helper functions
  34954 
  34955 func IsVP8XNeeded(tls *libc.TLS, enc uintptr) (r int32) {
  34956 	return libc.BoolInt32(!!((*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0)) // Currently the only case when VP8X is needed.
  34957 	// This could change in the future.
  34958 }
  34959 
  34960 func PutPaddingByte(tls *libc.TLS, pic uintptr) (r int32) {
  34961 	bp := tls.Alloc(16)
  34962 	defer tls.Free(16)
  34963 	var _ /* pad_byte at bp+0 */ [1]uint8_t
  34964 	**(**[1]uint8_t)(__ccgo_up(bp)) = [1]uint8_t{}
  34965 	return libc.BoolInt32(!!((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(1), pic) != 0))
  34966 }
  34967 
  34968 //------------------------------------------------------------------------------
  34969 // Writers for header's various pieces (in order of appearance)
  34970 
  34971 func PutRIFFHeader(tls *libc.TLS, enc uintptr, riff_size size_t) (r WebPEncodingError1) {
  34972 	bp := tls.Alloc(16)
  34973 	defer tls.Free(16)
  34974 	var pic, v1, v3, v5 uintptr
  34975 	var v2 uint32_t
  34976 	var v4, v6 int32
  34977 	var _ /* riff at bp+0 */ [12]uint8_t
  34978 	_, _, _, _, _, _, _ = pic, v1, v2, v3, v4, v5, v6
  34979 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  34980 	**(**[12]uint8_t)(__ccgo_up(bp)) = [12]uint8_t{
  34981 		0:  uint8('R'),
  34982 		1:  uint8('I'),
  34983 		2:  uint8('F'),
  34984 		3:  uint8('F'),
  34985 		8:  uint8('W'),
  34986 		9:  uint8('E'),
  34987 		10: uint8('B'),
  34988 		11: uint8('P'),
  34989 	}
  34990 	v1 = bp + uintptr(TAG_SIZE)
  34991 	v2 = uint32(riff_size)
  34992 	v3 = v1
  34993 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  34994 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  34995 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  34996 	v5 = v1 + uintptr(2)
  34997 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  34998 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  34999 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35000 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(12), pic) != 0) {
  35001 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35002 	}
  35003 	return int32(VP8_ENC_OK)
  35004 }
  35005 
  35006 func PutVP8XHeader(tls *libc.TLS, enc uintptr) (r WebPEncodingError1) {
  35007 	bp := tls.Alloc(32)
  35008 	defer tls.Free(32)
  35009 	var flags, v2 uint32_t
  35010 	var pic, v1, v3, v5 uintptr
  35011 	var v4, v6 int32
  35012 	var _ /* vp8x at bp+0 */ [18]uint8_t
  35013 	_, _, _, _, _, _, _, _ = flags, pic, v1, v2, v3, v4, v5, v6
  35014 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35015 	**(**[18]uint8_t)(__ccgo_up(bp)) = [18]uint8_t{
  35016 		0: uint8('V'),
  35017 		1: uint8('P'),
  35018 		2: uint8('8'),
  35019 		3: uint8('X'),
  35020 	}
  35021 	flags = uint32(0)
  35022 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  35023 		flags = flags | uint32(ALPHA_FLAG)
  35024 	}
  35025 	v1 = bp + uintptr(TAG_SIZE)
  35026 	v2 = uint32(VP8X_CHUNK_SIZE)
  35027 	v3 = v1
  35028 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35029 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35030 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35031 	v5 = v1 + uintptr(2)
  35032 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35033 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35034 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35035 	v1 = bp + uintptr(CHUNK_HEADER_SIZE)
  35036 	v2 = flags
  35037 	v3 = v1
  35038 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35039 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35040 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35041 	v5 = v1 + uintptr(2)
  35042 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35043 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35044 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35045 	v1 = bp + uintptr(CHUNK_HEADER_SIZE) + uintptr(4)
  35046 	v4 = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - int32(1)
  35047 	v3 = v1
  35048 	v6 = v4 & int32(0xffff)
  35049 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35050 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35051 	**(**uint8_t)(__ccgo_up(v1 + 2)) = libc.Uint8FromInt32(v4 >> int32(16) & int32(0xff))
  35052 	v1 = bp + uintptr(CHUNK_HEADER_SIZE) + uintptr(7)
  35053 	v4 = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - int32(1)
  35054 	v3 = v1
  35055 	v6 = v4 & int32(0xffff)
  35056 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35057 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35058 	**(**uint8_t)(__ccgo_up(v1 + 2)) = libc.Uint8FromInt32(v4 >> int32(16) & int32(0xff))
  35059 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(18), pic) != 0) {
  35060 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35061 	}
  35062 	return int32(VP8_ENC_OK)
  35063 }
  35064 
  35065 func PutAlphaChunk(tls *libc.TLS, enc uintptr) (r WebPEncodingError1) {
  35066 	bp := tls.Alloc(16)
  35067 	defer tls.Free(16)
  35068 	var pic, v1, v3, v5 uintptr
  35069 	var v2 uint32_t
  35070 	var v4, v6 int32
  35071 	var _ /* alpha_chunk_hdr at bp+0 */ [8]uint8_t
  35072 	_, _, _, _, _, _, _ = pic, v1, v2, v3, v4, v5, v6
  35073 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35074 	**(**[8]uint8_t)(__ccgo_up(bp)) = [8]uint8_t{
  35075 		0: uint8('A'),
  35076 		1: uint8('L'),
  35077 		2: uint8('P'),
  35078 		3: uint8('H'),
  35079 	}
  35080 	// Alpha chunk header.
  35081 	v1 = bp + uintptr(TAG_SIZE)
  35082 	v2 = (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size
  35083 	v3 = v1
  35084 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35085 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35086 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35087 	v5 = v1 + uintptr(2)
  35088 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35089 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35090 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35091 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(8), pic) != 0) {
  35092 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35093 	}
  35094 	// Alpha chunk data.
  35095 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data, uint64((*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size), pic) != 0) {
  35096 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35097 	}
  35098 	// Padding.
  35099 	if (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size&uint32(1) != 0 && !(PutPaddingByte(tls, pic) != 0) {
  35100 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35101 	}
  35102 	return int32(VP8_ENC_OK)
  35103 }
  35104 
  35105 func PutVP8Header(tls *libc.TLS, pic uintptr, vp8_size size_t) (r WebPEncodingError1) {
  35106 	bp := tls.Alloc(16)
  35107 	defer tls.Free(16)
  35108 	var v1, v3, v5 uintptr
  35109 	var v2 uint32_t
  35110 	var v4, v6 int32
  35111 	var _ /* vp8_chunk_hdr at bp+0 */ [8]uint8_t
  35112 	_, _, _, _, _, _ = v1, v2, v3, v4, v5, v6
  35113 	**(**[8]uint8_t)(__ccgo_up(bp)) = [8]uint8_t{
  35114 		0: uint8('V'),
  35115 		1: uint8('P'),
  35116 		2: uint8('8'),
  35117 		3: uint8(' '),
  35118 	}
  35119 	v1 = bp + uintptr(TAG_SIZE)
  35120 	v2 = uint32(vp8_size)
  35121 	v3 = v1
  35122 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35123 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35124 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35125 	v5 = v1 + uintptr(2)
  35126 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35127 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35128 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35129 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(8), pic) != 0) {
  35130 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35131 	}
  35132 	return int32(VP8_ENC_OK)
  35133 }
  35134 
  35135 func PutVP8FrameHeader(tls *libc.TLS, pic uintptr, profile int32, size0 size_t) (r WebPEncodingError1) {
  35136 	bp := tls.Alloc(16)
  35137 	defer tls.Free(16)
  35138 	var bits uint32_t
  35139 	var _ /* vp8_frm_hdr at bp+0 */ [10]uint8_t
  35140 	_ = bits
  35141 	if size0 >= libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) { // partition #0 is too big to fit
  35142 		return int32(VP8_ENC_ERROR_PARTITION0_OVERFLOW)
  35143 	}
  35144 	// Paragraph 9.1.
  35145 	bits = libc.Uint32FromInt32(0|profile<<int32(1)|libc.Int32FromInt32(1)<<libc.Int32FromInt32(4)) | uint32(size0)<<libc.Int32FromInt32(5) // partition length (19b)
  35146 	(**(**[10]uint8_t)(__ccgo_up(bp)))[0] = uint8(bits >> libc.Int32FromInt32(0) & uint32(0xff))
  35147 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(1)] = uint8(bits >> libc.Int32FromInt32(8) & uint32(0xff))
  35148 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(2)] = uint8(bits >> libc.Int32FromInt32(16) & uint32(0xff))
  35149 	// signature
  35150 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(3)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(16) & libc.Int32FromInt32(0xff))
  35151 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(4)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(8) & libc.Int32FromInt32(0xff))
  35152 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(5)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(0) & libc.Int32FromInt32(0xff))
  35153 	// dimensions
  35154 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(6)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fwidth & int32(0xff))
  35155 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(7)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fwidth >> int32(8))
  35156 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(8)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fheight & int32(0xff))
  35157 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(9)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fheight >> int32(8))
  35158 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(10), pic) != 0) {
  35159 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35160 	}
  35161 	return int32(VP8_ENC_OK)
  35162 }
  35163 
  35164 // C documentation
  35165 //
  35166 //	// WebP Headers.
  35167 func PutWebPHeaders(tls *libc.TLS, enc uintptr, size0 size_t, vp8_size size_t, riff_size size_t) (r int32) {
  35168 	var err WebPEncodingError1
  35169 	var pic uintptr
  35170 	_, _ = err, pic
  35171 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35172 	err = int32(VP8_ENC_OK)
  35173 	// RIFF header.
  35174 	err = PutRIFFHeader(tls, enc, riff_size)
  35175 	if err != int32(VP8_ENC_OK) {
  35176 		goto Error
  35177 	}
  35178 	// VP8X.
  35179 	if IsVP8XNeeded(tls, enc) != 0 {
  35180 		err = PutVP8XHeader(tls, enc)
  35181 		if err != int32(VP8_ENC_OK) {
  35182 			goto Error
  35183 		}
  35184 	}
  35185 	// Alpha.
  35186 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  35187 		err = PutAlphaChunk(tls, enc)
  35188 		if err != int32(VP8_ENC_OK) {
  35189 			goto Error
  35190 		}
  35191 	}
  35192 	// VP8 header.
  35193 	err = PutVP8Header(tls, pic, vp8_size)
  35194 	if err != int32(VP8_ENC_OK) {
  35195 		goto Error
  35196 	}
  35197 	// VP8 frame header.
  35198 	err = PutVP8FrameHeader(tls, pic, (*VP8Encoder)(unsafe.Pointer(enc)).Fprofile, size0)
  35199 	if err != int32(VP8_ENC_OK) {
  35200 		goto Error
  35201 	}
  35202 	// All OK.
  35203 	return int32(1)
  35204 	// Error.
  35205 	goto Error
  35206 Error:
  35207 	;
  35208 	return WebPEncodingSetError(tls, pic, err)
  35209 	return r
  35210 }
  35211 
  35212 // C documentation
  35213 //
  35214 //	// Segmentation header
  35215 func PutSegmentHeader(tls *libc.TLS, bw uintptr, enc uintptr) {
  35216 	var hdr, proba uintptr
  35217 	var s, update_data int32
  35218 	_, _, _, _ = hdr, proba, s, update_data
  35219 	hdr = enc + 32
  35220 	proba = enc + 3616
  35221 	if VP8PutBitUniform(tls, bw, libc.BoolInt32((*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments > int32(1))) != 0 {
  35222 		// We always 'update' the quant and filter strength values
  35223 		update_data = int32(1)
  35224 		VP8PutBitUniform(tls, bw, (*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map)
  35225 		if VP8PutBitUniform(tls, bw, update_data) != 0 {
  35226 			// we always use absolute values, not relative ones
  35227 			VP8PutBitUniform(tls, bw, int32(1)) // (segment_feature_mode = 1. Paragraph 9.3.)
  35228 			s = 0
  35229 			for {
  35230 				if !(s < int32(NUM_MB_SEGMENTS)) {
  35231 					break
  35232 				}
  35233 				VP8PutSignedBits(tls, bw, (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant, int32(7))
  35234 				goto _1
  35235 			_1:
  35236 				;
  35237 				s = s + 1
  35238 			}
  35239 			s = 0
  35240 			for {
  35241 				if !(s < int32(NUM_MB_SEGMENTS)) {
  35242 					break
  35243 				}
  35244 				VP8PutSignedBits(tls, bw, (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength, int32(6))
  35245 				goto _2
  35246 			_2:
  35247 				;
  35248 				s = s + 1
  35249 			}
  35250 		}
  35251 		if (*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map != 0 {
  35252 			s = 0
  35253 			for {
  35254 				if !(s < int32(3)) {
  35255 					break
  35256 				}
  35257 				if VP8PutBitUniform(tls, bw, libc.BoolInt32(uint32(**(**uint8_t)(__ccgo_up(proba + uintptr(s)))) != uint32(255))) != 0 {
  35258 					VP8PutBits(tls, bw, uint32(**(**uint8_t)(__ccgo_up(proba + uintptr(s)))), int32(8))
  35259 				}
  35260 				goto _3
  35261 			_3:
  35262 				;
  35263 				s = s + 1
  35264 			}
  35265 		}
  35266 	}
  35267 }
  35268 
  35269 // C documentation
  35270 //
  35271 //	// Filtering parameters header
  35272 func PutFilterHeader(tls *libc.TLS, bw uintptr, hdr uintptr) {
  35273 	var need_update, use_lf_delta int32
  35274 	_, _ = need_update, use_lf_delta
  35275 	use_lf_delta = libc.BoolInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta != libc.Int32FromInt32(0))
  35276 	VP8PutBitUniform(tls, bw, (*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsimple)
  35277 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Flevel), int32(6))
  35278 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsharpness), int32(3))
  35279 	if VP8PutBitUniform(tls, bw, use_lf_delta) != 0 {
  35280 		// '0' is the default value for i4x4_lf_delta at frame #0.
  35281 		need_update = libc.BoolInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta != libc.Int32FromInt32(0))
  35282 		if VP8PutBitUniform(tls, bw, need_update) != 0 {
  35283 			// we don't use ref_lf_delta => emit four 0 bits
  35284 			VP8PutBits(tls, bw, uint32(0), int32(4))
  35285 			// we use mode_lf_delta for i4x4
  35286 			VP8PutSignedBits(tls, bw, (*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta, int32(6))
  35287 			VP8PutBits(tls, bw, uint32(0), int32(3)) // all others unused
  35288 		}
  35289 	}
  35290 }
  35291 
  35292 // C documentation
  35293 //
  35294 //	// Nominal quantization parameters
  35295 func PutQuant(tls *libc.TLS, bw uintptr, enc uintptr) {
  35296 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant), int32(7))
  35297 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc, int32(4))
  35298 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_dc, int32(4))
  35299 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac, int32(4))
  35300 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc, int32(4))
  35301 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac, int32(4))
  35302 }
  35303 
  35304 // C documentation
  35305 //
  35306 //	// Partition sizes
  35307 func EmitPartitionsSize(tls *libc.TLS, enc uintptr, pic uintptr) (r int32) {
  35308 	bp := tls.Alloc(32)
  35309 	defer tls.Free(32)
  35310 	var p int32
  35311 	var part_size, v2 size_t
  35312 	var _ /* buf at bp+0 */ [21]uint8_t
  35313 	_, _, _ = p, part_size, v2
  35314 	p = 0
  35315 	for {
  35316 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)) {
  35317 			break
  35318 		}
  35319 		v2 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35320 		goto _3
  35321 	_3:
  35322 		part_size = v2
  35323 		if part_size >= libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(24)) {
  35324 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_PARTITION_OVERFLOW))
  35325 		}
  35326 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+0] = uint8(part_size >> libc.Int32FromInt32(0) & uint64(0xff))
  35327 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+int32(1)] = uint8(part_size >> libc.Int32FromInt32(8) & uint64(0xff))
  35328 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+int32(2)] = uint8(part_size >> libc.Int32FromInt32(16) & uint64(0xff))
  35329 		goto _1
  35330 	_1:
  35331 		;
  35332 		p = p + 1
  35333 	}
  35334 	if p != 0 && !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, libc.Uint64FromInt32(int32(3)*p), pic) != 0) {
  35335 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  35336 	}
  35337 	return int32(1)
  35338 }
  35339 
  35340 //------------------------------------------------------------------------------
  35341 
  35342 func GeneratePartition0(tls *libc.TLS, enc uintptr) (r int32) {
  35343 	var bw1, v1 uintptr
  35344 	var mb_size, v4, v5, v6 int32
  35345 	var nb_bits, pos1, pos2, pos3, v2 uint64_t
  35346 	_, _, _, _, _, _, _, _, _, _, _ = bw1, mb_size, nb_bits, pos1, pos2, pos3, v1, v2, v4, v5, v6
  35347 	bw1 = enc + 64
  35348 	mb_size = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  35349 	v1 = bw1
  35350 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35351 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35352 	goto _3
  35353 _3:
  35354 	pos1 = v2
  35355 	if !(VP8BitWriterInit(tls, bw1, libc.Uint64FromInt32(mb_size*int32(7)/int32(8))) != 0) { // ~7 bits per macroblock
  35356 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  35357 	}
  35358 	VP8PutBitUniform(tls, bw1, 0) // colorspace
  35359 	VP8PutBitUniform(tls, bw1, 0) // clamp type
  35360 	PutSegmentHeader(tls, bw1, enc)
  35361 	PutFilterHeader(tls, bw1, enc+16)
  35362 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(8) {
  35363 		v4 = int32(3)
  35364 	} else {
  35365 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(4) {
  35366 			v5 = int32(2)
  35367 		} else {
  35368 			if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(2) {
  35369 				v6 = int32(1)
  35370 			} else {
  35371 				v6 = 0
  35372 			}
  35373 			v5 = v6
  35374 		}
  35375 		v4 = v5
  35376 	}
  35377 	VP8PutBits(tls, bw1, libc.Uint32FromInt32(v4), int32(2))
  35378 	PutQuant(tls, bw1, enc)
  35379 	VP8PutBitUniform(tls, bw1, 0) // no proba update
  35380 	VP8WriteProbas(tls, bw1, enc+3616)
  35381 	v1 = bw1
  35382 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35383 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35384 	goto _9
  35385 _9:
  35386 	pos2 = v2
  35387 	VP8CodeIntraModes(tls, enc)
  35388 	VP8BitWriterFinish(tls, bw1)
  35389 	v1 = bw1
  35390 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35391 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35392 	goto _12
  35393 _12:
  35394 	pos3 = v2
  35395 	if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != 0 {
  35396 		**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats + 36)) = libc.Int32FromUint64((pos2 - pos1 + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  35397 		**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats + 36 + 1*4)) = libc.Int32FromUint64((pos3 - pos2 + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  35398 		(*WebPAuxStats)(unsafe.Pointer((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats)).Falpha_data_size = libc.Int32FromUint32((*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size)
  35399 	}
  35400 	if (*VP8BitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  35401 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  35402 	}
  35403 	return int32(1)
  35404 }
  35405 
  35406 func VP8EncFreeBitWriters(tls *libc.TLS, enc uintptr) {
  35407 	var p int32
  35408 	_ = p
  35409 	VP8BitWriterWipeOut(tls, enc+64)
  35410 	p = 0
  35411 	for {
  35412 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35413 			break
  35414 		}
  35415 		VP8BitWriterWipeOut(tls, enc+112+uintptr(p)*48)
  35416 		goto _1
  35417 	_1:
  35418 		;
  35419 		p = p + 1
  35420 	}
  35421 }
  35422 
  35423 func VP8EncWrite(tls *libc.TLS, enc uintptr) (r int32) {
  35424 	var buf, bw2, part0, pic, v6 uintptr
  35425 	var final_percent, ok, p, percent_per_part, task_percent int32
  35426 	var pad, riff_size, size, size0, vp8_size, v1 size_t
  35427 	var padded_alpha_size uint32_t
  35428 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = buf, bw2, final_percent, ok, p, pad, padded_alpha_size, part0, percent_per_part, pic, riff_size, size, size0, task_percent, vp8_size, v1, v6
  35429 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35430 	bw2 = enc + 64
  35431 	task_percent = int32(19)
  35432 	percent_per_part = task_percent / (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts
  35433 	final_percent = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent + task_percent
  35434 	ok = 0
  35435 	// Partition #0 with header and partition sizes
  35436 	ok = GeneratePartition0(tls, enc)
  35437 	if !(ok != 0) {
  35438 		return 0
  35439 	}
  35440 	// Compute VP8 size
  35441 	v1 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fpos
  35442 	goto _2
  35443 _2:
  35444 	vp8_size = uint64(VP8_FRAME_HEADER_SIZE) + v1 + libc.Uint64FromInt32(int32(3)*((*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)))
  35445 	p = 0
  35446 	for {
  35447 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35448 			break
  35449 		}
  35450 		v1 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35451 		goto _5
  35452 	_5:
  35453 		vp8_size = vp8_size + v1
  35454 		goto _3
  35455 	_3:
  35456 		;
  35457 		p = p + 1
  35458 	}
  35459 	pad = vp8_size & uint64(1)
  35460 	vp8_size = vp8_size + pad
  35461 	// Compute RIFF size
  35462 	// At the minimum it is: "WEBPVP8 nnnn" + VP8 data size.
  35463 	riff_size = libc.Uint64FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) + vp8_size
  35464 	if IsVP8XNeeded(tls, enc) != 0 { // Add size for: VP8X header + data.
  35465 		riff_size = riff_size + libc.Uint64FromInt32(libc.Int32FromInt32(CHUNK_HEADER_SIZE)+libc.Int32FromInt32(VP8X_CHUNK_SIZE))
  35466 	}
  35467 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 { // Add size for: ALPH header + data.
  35468 		padded_alpha_size = (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size + (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size&uint32(1)
  35469 		riff_size = riff_size + uint64(uint32(CHUNK_HEADER_SIZE)+padded_alpha_size)
  35470 	}
  35471 	// RIFF size should fit in 32-bits.
  35472 	if riff_size > uint64(0xfffffffe) {
  35473 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_FILE_TOO_BIG))
  35474 	}
  35475 	// Emit headers and partition #0
  35476 	v6 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fbuf
  35477 	goto _7
  35478 _7:
  35479 	part0 = v6
  35480 	v1 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fpos
  35481 	goto _9
  35482 _9:
  35483 	size0 = v1
  35484 	ok = libc.BoolInt32(ok != 0 && PutWebPHeaders(tls, enc, size0, vp8_size, riff_size) != 0 && (*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, part0, size0, pic) != 0 && EmitPartitionsSize(tls, enc, pic) != 0)
  35485 	VP8BitWriterWipeOut(tls, bw2) // will free the internal buffer.
  35486 	// Token partitions
  35487 	p = 0
  35488 	for {
  35489 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35490 			break
  35491 		}
  35492 		v6 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fbuf
  35493 		goto _12
  35494 	_12:
  35495 		buf = v6
  35496 		v1 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35497 		goto _14
  35498 	_14:
  35499 		size = v1
  35500 		if size != 0 {
  35501 			ok = libc.BoolInt32(ok != 0 && (*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, buf, size, pic) != 0)
  35502 		}
  35503 		VP8BitWriterWipeOut(tls, enc+112+uintptr(p)*48) // will free the internal buffer.
  35504 		ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, pic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+percent_per_part, enc+536) != 0)
  35505 		goto _10
  35506 	_10:
  35507 		;
  35508 		p = p + 1
  35509 	}
  35510 	// Padding byte
  35511 	if ok != 0 && pad != 0 {
  35512 		ok = PutPaddingByte(tls, pic)
  35513 	}
  35514 	(*VP8Encoder)(unsafe.Pointer(enc)).Fcoded_size = libc.Int32FromUint64(libc.Uint64FromInt32(CHUNK_HEADER_SIZE) + riff_size)
  35515 	ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, pic, final_percent, enc+536) != 0)
  35516 	if !(ok != 0) {
  35517 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  35518 	}
  35519 	return ok
  35520 }
  35521 
  35522 const MIN_PAGE_SIZE = 8192
  35523 
  35524 type VP8Tokens = struct {
  35525 	Fnext uintptr
  35526 }
  35527 
  35528 //------------------------------------------------------------------------------
  35529 
  35530 // Copyright 2011 Google Inc. All Rights Reserved.
  35531 //
  35532 // Use of this source code is governed by a BSD-style license
  35533 // that can be found in the COPYING file in the root of the source
  35534 // tree. An additional intellectual property rights grant can be found
  35535 // in the file PATENTS. All contributing project authors may
  35536 // be found in the AUTHORS file in the root of the source tree.
  35537 // -----------------------------------------------------------------------------
  35538 //
  35539 //   WebP encoder: internal header.
  35540 //
  35541 // Author: Skal (pascal.massimino@gmail.com)
  35542 
  35543 // Copyright 2011 Google Inc. All Rights Reserved.
  35544 //
  35545 // Use of this source code is governed by a BSD-style license
  35546 // that can be found in the COPYING file in the root of the source
  35547 // tree. An additional intellectual property rights grant can be found
  35548 // in the file PATENTS. All contributing project authors may
  35549 // be found in the AUTHORS file in the root of the source tree.
  35550 // -----------------------------------------------------------------------------
  35551 //
  35552 // Bit writing and boolean coder
  35553 //
  35554 // Author: Skal (pascal.massimino@gmail.com)
  35555 
  35556 // Copyright 2012 Google Inc. All Rights Reserved.
  35557 //
  35558 // Use of this source code is governed by a BSD-style license
  35559 // that can be found in the COPYING file in the root of the source
  35560 // tree. An additional intellectual property rights grant can be found
  35561 // in the file PATENTS. All contributing project authors may
  35562 // be found in the AUTHORS file in the root of the source tree.
  35563 // -----------------------------------------------------------------------------
  35564 //
  35565 // Misc. common utility functions
  35566 //
  35567 // Authors: Skal (pascal.massimino@gmail.com)
  35568 //          Urvang (urvang@google.com)
  35569 
  35570 // Copyright 2010 Google Inc. All Rights Reserved.
  35571 //
  35572 // Use of this source code is governed by a BSD-style license
  35573 // that can be found in the COPYING file in the root of the source
  35574 // tree. An additional intellectual property rights grant can be found
  35575 // in the file PATENTS. All contributing project authors may
  35576 // be found in the AUTHORS file in the root of the source tree.
  35577 // -----------------------------------------------------------------------------
  35578 //
  35579 //  Common types + memory wrappers
  35580 //
  35581 // Author: Skal (pascal.massimino@gmail.com)
  35582 
  35583 // we use pages to reduce the number of memcpy()
  35584 
  35585 type token_t = uint16
  35586 
  35587 // Token data is located in memory just after the 'next' field.
  35588 // This macro is used to return their address and hide the trick.
  35589 
  35590 //------------------------------------------------------------------------------
  35591 
  35592 func VP8TBufferInit(tls *libc.TLS, b uintptr, page_size int32) {
  35593 	var v1 int32
  35594 	_ = v1
  35595 	(*VP8TBuffer)(unsafe.Pointer(b)).Ftokens = libc.UintptrFromInt32(0)
  35596 	(*VP8TBuffer)(unsafe.Pointer(b)).Fpages = libc.UintptrFromInt32(0)
  35597 	(*VP8TBuffer)(unsafe.Pointer(b)).Flast_page = b
  35598 	(*VP8TBuffer)(unsafe.Pointer(b)).Fleft = 0
  35599 	if page_size < int32(MIN_PAGE_SIZE) {
  35600 		v1 = int32(MIN_PAGE_SIZE)
  35601 	} else {
  35602 		v1 = page_size
  35603 	}
  35604 	(*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size = v1
  35605 	(*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 = 0
  35606 }
  35607 
  35608 func VP8TBufferClear(tls *libc.TLS, b uintptr) {
  35609 	var next, p uintptr
  35610 	_, _ = next, p
  35611 	if b != libc.UintptrFromInt32(0) {
  35612 		p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35613 		for p != libc.UintptrFromInt32(0) {
  35614 			next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35615 			WebPSafeFree(tls, p)
  35616 			p = next
  35617 		}
  35618 		VP8TBufferInit(tls, b, (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size)
  35619 	}
  35620 }
  35621 
  35622 func TBufferNewPage(tls *libc.TLS, b uintptr) (r int32) {
  35623 	var page uintptr
  35624 	var size size_t
  35625 	_, _ = page, size
  35626 	page = libc.UintptrFromInt32(0)
  35627 	if !((*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 != 0) {
  35628 		size = uint64(8) + libc.Uint64FromInt32((*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size)*uint64(2)
  35629 		page = WebPSafeMalloc(tls, uint64(1), size)
  35630 	}
  35631 	if page == libc.UintptrFromInt32(0) {
  35632 		(*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 = int32(1)
  35633 		return 0
  35634 	}
  35635 	(*VP8Tokens)(unsafe.Pointer(page)).Fnext = libc.UintptrFromInt32(0)
  35636 	**(**uintptr)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Flast_page)) = page
  35637 	(*VP8TBuffer)(unsafe.Pointer(b)).Flast_page = page
  35638 	(*VP8TBuffer)(unsafe.Pointer(b)).Fleft = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35639 	(*VP8TBuffer)(unsafe.Pointer(b)).Ftokens = page + 1*8
  35640 	return int32(1)
  35641 }
  35642 
  35643 //------------------------------------------------------------------------------
  35644 
  35645 func AddToken(tls *libc.TLS, b uintptr, bit1 uint32_t, proba_idx uint32_t, stats1 uintptr) (r uint32_t) {
  35646 	var p proba_t
  35647 	var slot, v1 int32
  35648 	var v2 uintptr
  35649 	_, _, _, _ = p, slot, v1, v2
  35650 	if (*VP8TBuffer)(unsafe.Pointer(b)).Fleft > 0 || TBufferNewPage(tls, b) != 0 {
  35651 		v2 = b + 24
  35652 		*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  35653 		v1 = *(*int32)(unsafe.Pointer(v2))
  35654 		slot = v1
  35655 		**(**uint16_t)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Ftokens + uintptr(slot)*2)) = uint16(bit1<<libc.Int32FromInt32(15) | proba_idx)
  35656 	}
  35657 	v1 = libc.Int32FromUint32(bit1)
  35658 	v2 = stats1
  35659 	p = **(**proba_t)(__ccgo_up(v2))
  35660 	if p >= libc.Uint32FromUint32(0xfffe0000) {
  35661 		p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  35662 	}
  35663 	p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  35664 	**(**proba_t)(__ccgo_up(v2)) = p
  35665 	_ = v1
  35666 	goto _5
  35667 _5:
  35668 	;
  35669 	return bit1
  35670 }
  35671 
  35672 func AddConstantToken(tls *libc.TLS, b uintptr, bit uint32_t, proba uint32_t) {
  35673 	var slot, v1 int32
  35674 	var v2 uintptr
  35675 	_, _, _ = slot, v1, v2
  35676 	if (*VP8TBuffer)(unsafe.Pointer(b)).Fleft > 0 || TBufferNewPage(tls, b) != 0 {
  35677 		v2 = b + 24
  35678 		*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  35679 		v1 = *(*int32)(unsafe.Pointer(v2))
  35680 		slot = v1
  35681 		**(**uint16_t)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Ftokens + uintptr(slot)*2)) = uint16(bit<<libc.Int32FromInt32(15) | libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14) | proba)
  35682 	}
  35683 }
  35684 
  35685 func VP8RecordCoeffTokens(tls *libc.TLS, ctx int32, res uintptr, tokens uintptr) (r int32) {
  35686 	var base_id, residue, v uint32_t
  35687 	var c, coeff_type, last, mask, n, sign, v1, v2 int32
  35688 	var coeffs, s, tab, v3 uintptr
  35689 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base_id, c, coeff_type, coeffs, last, mask, n, residue, s, sign, tab, v, v1, v2, v3
  35690 	coeffs = (*VP8Residual)(unsafe.Pointer(res)).Fcoeffs
  35691 	coeff_type = (*VP8Residual)(unsafe.Pointer(res)).Fcoeff_type
  35692 	last = (*VP8Residual)(unsafe.Pointer(res)).Flast
  35693 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  35694 	base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (ctx + int32(NUM_CTX)*(n+int32(NUM_BANDS)*coeff_type)))
  35695 	// should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
  35696 	s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(n)*132 + uintptr(ctx)*44
  35697 	if !(AddToken(tls, tokens, libc.BoolUint32(last >= 0), base_id+uint32(0), s+uintptr(0)*4) != 0) {
  35698 		return 0
  35699 	}
  35700 	for n < int32(16) {
  35701 		v1 = n
  35702 		n = n + 1
  35703 		c = int32(**(**int16_t)(__ccgo_up(coeffs + uintptr(v1)*2)))
  35704 		sign = libc.BoolInt32(c < 0)
  35705 		if sign != 0 {
  35706 			v2 = -c
  35707 		} else {
  35708 			v2 = c
  35709 		}
  35710 		v = libc.Uint32FromInt32(v2)
  35711 		if !(AddToken(tls, tokens, libc.BoolUint32(v != uint32(0)), base_id+uint32(1), s+uintptr(1)*4) != 0) {
  35712 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(0) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=0
  35713 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132
  35714 			continue
  35715 		}
  35716 		if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(1)), base_id+uint32(2), s+uintptr(2)*4) != 0) {
  35717 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(1) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=1
  35718 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 1*44
  35719 		} else {
  35720 			if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(4)), base_id+uint32(3), s+uintptr(3)*4) != 0) {
  35721 				if AddToken(tls, tokens, libc.BoolUint32(v != uint32(2)), base_id+uint32(4), s+uintptr(4)*4) != 0 {
  35722 					AddToken(tls, tokens, libc.BoolUint32(v == uint32(4)), base_id+uint32(5), s+uintptr(5)*4)
  35723 				}
  35724 			} else {
  35725 				if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(10)), base_id+uint32(6), s+uintptr(6)*4) != 0) {
  35726 					if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(6)), base_id+uint32(7), s+uintptr(7)*4) != 0) {
  35727 						AddConstantToken(tls, tokens, libc.BoolUint32(v == uint32(6)), uint32(159))
  35728 					} else {
  35729 						AddConstantToken(tls, tokens, libc.BoolUint32(v >= uint32(9)), uint32(165))
  35730 						AddConstantToken(tls, tokens, libc.BoolUint32(!(v&libc.Uint32FromInt32(1) != 0)), uint32(145))
  35731 					}
  35732 				} else {
  35733 					residue = v - uint32(3)
  35734 					if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(1)) { // VP8Cat3  (3b)
  35735 						AddToken(tls, tokens, uint32(0), base_id+uint32(8), s+uintptr(8)*4)
  35736 						AddToken(tls, tokens, uint32(0), base_id+uint32(9), s+uintptr(9)*4)
  35737 						residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(0))
  35738 						mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(2)
  35739 						tab = uintptr(unsafe.Pointer(&VP8Cat3))
  35740 					} else {
  35741 						if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(2)) { // VP8Cat4  (4b)
  35742 							AddToken(tls, tokens, uint32(0), base_id+uint32(8), s+uintptr(8)*4)
  35743 							AddToken(tls, tokens, uint32(1), base_id+uint32(9), s+uintptr(9)*4)
  35744 							residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(1))
  35745 							mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(3)
  35746 							tab = uintptr(unsafe.Pointer(&VP8Cat4))
  35747 						} else {
  35748 							if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(3)) { // VP8Cat5  (5b)
  35749 								AddToken(tls, tokens, uint32(1), base_id+uint32(8), s+uintptr(8)*4)
  35750 								AddToken(tls, tokens, uint32(0), base_id+uint32(10), s+uintptr(9)*4)
  35751 								residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(2))
  35752 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(4)
  35753 								tab = uintptr(unsafe.Pointer(&VP8Cat5))
  35754 							} else { // VP8Cat6 (11b)
  35755 								AddToken(tls, tokens, uint32(1), base_id+uint32(8), s+uintptr(8)*4)
  35756 								AddToken(tls, tokens, uint32(1), base_id+uint32(10), s+uintptr(9)*4)
  35757 								residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(3))
  35758 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(10)
  35759 								tab = uintptr(unsafe.Pointer(&VP8Cat6))
  35760 							}
  35761 						}
  35762 					}
  35763 					for mask != 0 {
  35764 						v3 = tab
  35765 						tab = tab + 1
  35766 						AddConstantToken(tls, tokens, libc.BoolUint32(!!(residue&libc.Uint32FromInt32(mask) != 0)), uint32(**(**uint8_t)(__ccgo_up(v3))))
  35767 						mask = mask >> int32(1)
  35768 					}
  35769 				}
  35770 			}
  35771 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(2) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=2
  35772 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 2*44
  35773 		}
  35774 		AddConstantToken(tls, tokens, libc.Uint32FromInt32(sign), uint32(128))
  35775 		if n == int32(16) || !(AddToken(tls, tokens, libc.BoolUint32(n <= last), base_id+uint32(0), s+uintptr(0)*4) != 0) {
  35776 			return int32(1) // EOB
  35777 		}
  35778 	}
  35779 	return int32(1)
  35780 }
  35781 
  35782 //------------------------------------------------------------------------------
  35783 // Final coding pass, with known probabilities
  35784 
  35785 func VP8EmitTokens(tls *libc.TLS, b uintptr, bw uintptr, probas uintptr, final_pass int32) (r int32) {
  35786 	var N, bit, n, v1, v2 int32
  35787 	var next, p, tokens uintptr
  35788 	var token token_t
  35789 	_, _, _, _, _, _, _, _, _ = N, bit, n, next, p, token, tokens, v1, v2
  35790 	p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35791 	for p != libc.UintptrFromInt32(0) {
  35792 		next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35793 		if next == libc.UintptrFromInt32(0) {
  35794 			v1 = (*VP8TBuffer)(unsafe.Pointer(b)).Fleft
  35795 		} else {
  35796 			v1 = 0
  35797 		}
  35798 		N = v1
  35799 		n = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35800 		tokens = p + 1*8
  35801 		for {
  35802 			v2 = n
  35803 			n = n - 1
  35804 			if !(v2 > N) {
  35805 				break
  35806 			}
  35807 			token = **(**token_t)(__ccgo_up(tokens + uintptr(n)*2))
  35808 			bit = libc.Int32FromUint16(token) >> int32(15) & int32(1)
  35809 			if uint32(token)&(libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14)) != 0 {
  35810 				VP8PutBit(tls, bw, bit, libc.Int32FromUint32(uint32(token)&uint32(0xff))) // constant proba
  35811 			} else {
  35812 				VP8PutBit(tls, bw, bit, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + uintptr(uint32(token)&uint32(0x3fff))))))
  35813 			}
  35814 		}
  35815 		if final_pass != 0 {
  35816 			WebPSafeFree(tls, p)
  35817 		}
  35818 		p = next
  35819 	}
  35820 	if final_pass != 0 {
  35821 		(*VP8TBuffer)(unsafe.Pointer(b)).Fpages = libc.UintptrFromInt32(0)
  35822 	}
  35823 	return int32(1)
  35824 }
  35825 
  35826 // C documentation
  35827 //
  35828 //	// Size estimation
  35829 func VP8EstimateTokenSize(tls *libc.TLS, b uintptr, probas uintptr) (r size_t) {
  35830 	var N, bit1, n, v1, v2, v4, v6 int32
  35831 	var next, p, tokens uintptr
  35832 	var size size_t
  35833 	var token token_t
  35834 	var v3 uint8_t
  35835 	_, _, _, _, _, _, _, _, _, _, _, _, _ = N, bit1, n, next, p, size, token, tokens, v1, v2, v3, v4, v6
  35836 	size = uint64(0)
  35837 	p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35838 	for p != libc.UintptrFromInt32(0) {
  35839 		next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35840 		if next == libc.UintptrFromInt32(0) {
  35841 			v1 = (*VP8TBuffer)(unsafe.Pointer(b)).Fleft
  35842 		} else {
  35843 			v1 = 0
  35844 		}
  35845 		N = v1
  35846 		n = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35847 		tokens = p + 1*8
  35848 		for {
  35849 			v2 = n
  35850 			n = n - 1
  35851 			if !(v2 > N) {
  35852 				break
  35853 			}
  35854 			token = **(**token_t)(__ccgo_up(tokens + uintptr(n)*2))
  35855 			bit1 = libc.Int32FromUint16(token) & (libc.Int32FromInt32(1) << libc.Int32FromInt32(15))
  35856 			if uint32(token)&(libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14)) != 0 {
  35857 				v3 = uint8(uint32(token) & uint32(0xff))
  35858 				if !(bit1 != 0) {
  35859 					v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  35860 				} else {
  35861 					v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  35862 				}
  35863 				v4 = v6
  35864 				goto _5
  35865 			_5:
  35866 				size = size + libc.Uint64FromInt32(v4)
  35867 			} else {
  35868 				v3 = **(**uint8_t)(__ccgo_up(probas + uintptr(uint32(token)&uint32(0x3fff))))
  35869 				if !(bit1 != 0) {
  35870 					v2 = libc.Int32FromUint16(VP8EntropyCost[v3])
  35871 				} else {
  35872 					v2 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  35873 				}
  35874 				v1 = v2
  35875 				goto _9
  35876 			_9:
  35877 				size = size + libc.Uint64FromInt32(v1)
  35878 			}
  35879 		}
  35880 		p = next
  35881 	}
  35882 	return size
  35883 }
  35884 
  35885 func VP8DefaultProbas(tls *libc.TLS, enc uintptr) {
  35886 	var probas uintptr
  35887 	_ = probas
  35888 	probas = enc + 3616
  35889 	(*VP8EncProba)(unsafe.Pointer(probas)).Fuse_skip_proba = 0
  35890 	libc.X__builtin___memset_chk(tls, probas, libc.Int32FromUint32(255), uint64(3), ^__predefined_size_t(0))
  35891 	libc.X__builtin___memcpy_chk(tls, probas+4, uintptr(unsafe.Pointer(&VP8CoeffsProba0)), uint64(1056), ^__predefined_size_t(0))
  35892 	// Note: we could hard-code the level_costs corresponding to VP8CoeffsProba0,
  35893 	// but that's ~11k of static data. Better call VP8CalculateLevelCosts() later.
  35894 	(*VP8EncProba)(unsafe.Pointer(probas)).Fdirty = int32(1)
  35895 }
  35896 
  35897 // C documentation
  35898 //
  35899 //	// Paragraph 11.5.  900bytes.
  35900 var kBModesProba1 = [10][10][9]uint8_t{
  35901 	0: {
  35902 		0: {
  35903 			0: uint8(231),
  35904 			1: uint8(120),
  35905 			2: uint8(48),
  35906 			3: uint8(89),
  35907 			4: uint8(115),
  35908 			5: uint8(113),
  35909 			6: uint8(120),
  35910 			7: uint8(152),
  35911 			8: uint8(112),
  35912 		},
  35913 		1: {
  35914 			0: uint8(152),
  35915 			1: uint8(179),
  35916 			2: uint8(64),
  35917 			3: uint8(126),
  35918 			4: uint8(170),
  35919 			5: uint8(118),
  35920 			6: uint8(46),
  35921 			7: uint8(70),
  35922 			8: uint8(95),
  35923 		},
  35924 		2: {
  35925 			0: uint8(175),
  35926 			1: uint8(69),
  35927 			2: uint8(143),
  35928 			3: uint8(80),
  35929 			4: uint8(85),
  35930 			5: uint8(82),
  35931 			6: uint8(72),
  35932 			7: uint8(155),
  35933 			8: uint8(103),
  35934 		},
  35935 		3: {
  35936 			0: uint8(56),
  35937 			1: uint8(58),
  35938 			2: uint8(10),
  35939 			3: uint8(171),
  35940 			4: uint8(218),
  35941 			5: uint8(189),
  35942 			6: uint8(17),
  35943 			7: uint8(13),
  35944 			8: uint8(152),
  35945 		},
  35946 		4: {
  35947 			0: uint8(114),
  35948 			1: uint8(26),
  35949 			2: uint8(17),
  35950 			3: uint8(163),
  35951 			4: uint8(44),
  35952 			5: uint8(195),
  35953 			6: uint8(21),
  35954 			7: uint8(10),
  35955 			8: uint8(173),
  35956 		},
  35957 		5: {
  35958 			0: uint8(121),
  35959 			1: uint8(24),
  35960 			2: uint8(80),
  35961 			3: uint8(195),
  35962 			4: uint8(26),
  35963 			5: uint8(62),
  35964 			6: uint8(44),
  35965 			7: uint8(64),
  35966 			8: uint8(85),
  35967 		},
  35968 		6: {
  35969 			0: uint8(144),
  35970 			1: uint8(71),
  35971 			2: uint8(10),
  35972 			3: uint8(38),
  35973 			4: uint8(171),
  35974 			5: uint8(213),
  35975 			6: uint8(144),
  35976 			7: uint8(34),
  35977 			8: uint8(26),
  35978 		},
  35979 		7: {
  35980 			0: uint8(170),
  35981 			1: uint8(46),
  35982 			2: uint8(55),
  35983 			3: uint8(19),
  35984 			4: uint8(136),
  35985 			5: uint8(160),
  35986 			6: uint8(33),
  35987 			7: uint8(206),
  35988 			8: uint8(71),
  35989 		},
  35990 		8: {
  35991 			0: uint8(63),
  35992 			1: uint8(20),
  35993 			2: uint8(8),
  35994 			3: uint8(114),
  35995 			4: uint8(114),
  35996 			5: uint8(208),
  35997 			6: uint8(12),
  35998 			7: uint8(9),
  35999 			8: uint8(226),
  36000 		},
  36001 		9: {
  36002 			0: uint8(81),
  36003 			1: uint8(40),
  36004 			2: uint8(11),
  36005 			3: uint8(96),
  36006 			4: uint8(182),
  36007 			5: uint8(84),
  36008 			6: uint8(29),
  36009 			7: uint8(16),
  36010 			8: uint8(36),
  36011 		},
  36012 	},
  36013 	1: {
  36014 		0: {
  36015 			0: uint8(134),
  36016 			1: uint8(183),
  36017 			2: uint8(89),
  36018 			3: uint8(137),
  36019 			4: uint8(98),
  36020 			5: uint8(101),
  36021 			6: uint8(106),
  36022 			7: uint8(165),
  36023 			8: uint8(148),
  36024 		},
  36025 		1: {
  36026 			0: uint8(72),
  36027 			1: uint8(187),
  36028 			2: uint8(100),
  36029 			3: uint8(130),
  36030 			4: uint8(157),
  36031 			5: uint8(111),
  36032 			6: uint8(32),
  36033 			7: uint8(75),
  36034 			8: uint8(80),
  36035 		},
  36036 		2: {
  36037 			0: uint8(66),
  36038 			1: uint8(102),
  36039 			2: uint8(167),
  36040 			3: uint8(99),
  36041 			4: uint8(74),
  36042 			5: uint8(62),
  36043 			6: uint8(40),
  36044 			7: uint8(234),
  36045 			8: uint8(128),
  36046 		},
  36047 		3: {
  36048 			0: uint8(41),
  36049 			1: uint8(53),
  36050 			2: uint8(9),
  36051 			3: uint8(178),
  36052 			4: uint8(241),
  36053 			5: uint8(141),
  36054 			6: uint8(26),
  36055 			7: uint8(8),
  36056 			8: uint8(107),
  36057 		},
  36058 		4: {
  36059 			0: uint8(74),
  36060 			1: uint8(43),
  36061 			2: uint8(26),
  36062 			3: uint8(146),
  36063 			4: uint8(73),
  36064 			5: uint8(166),
  36065 			6: uint8(49),
  36066 			7: uint8(23),
  36067 			8: uint8(157),
  36068 		},
  36069 		5: {
  36070 			0: uint8(65),
  36071 			1: uint8(38),
  36072 			2: uint8(105),
  36073 			3: uint8(160),
  36074 			4: uint8(51),
  36075 			5: uint8(52),
  36076 			6: uint8(31),
  36077 			7: uint8(115),
  36078 			8: uint8(128),
  36079 		},
  36080 		6: {
  36081 			0: uint8(104),
  36082 			1: uint8(79),
  36083 			2: uint8(12),
  36084 			3: uint8(27),
  36085 			4: uint8(217),
  36086 			5: uint8(255),
  36087 			6: uint8(87),
  36088 			7: uint8(17),
  36089 			8: uint8(7),
  36090 		},
  36091 		7: {
  36092 			0: uint8(87),
  36093 			1: uint8(68),
  36094 			2: uint8(71),
  36095 			3: uint8(44),
  36096 			4: uint8(114),
  36097 			5: uint8(51),
  36098 			6: uint8(15),
  36099 			7: uint8(186),
  36100 			8: uint8(23),
  36101 		},
  36102 		8: {
  36103 			0: uint8(47),
  36104 			1: uint8(41),
  36105 			2: uint8(14),
  36106 			3: uint8(110),
  36107 			4: uint8(182),
  36108 			5: uint8(183),
  36109 			6: uint8(21),
  36110 			7: uint8(17),
  36111 			8: uint8(194),
  36112 		},
  36113 		9: {
  36114 			0: uint8(66),
  36115 			1: uint8(45),
  36116 			2: uint8(25),
  36117 			3: uint8(102),
  36118 			4: uint8(197),
  36119 			5: uint8(189),
  36120 			6: uint8(23),
  36121 			7: uint8(18),
  36122 			8: uint8(22),
  36123 		},
  36124 	},
  36125 	2: {
  36126 		0: {
  36127 			0: uint8(88),
  36128 			1: uint8(88),
  36129 			2: uint8(147),
  36130 			3: uint8(150),
  36131 			4: uint8(42),
  36132 			5: uint8(46),
  36133 			6: uint8(45),
  36134 			7: uint8(196),
  36135 			8: uint8(205),
  36136 		},
  36137 		1: {
  36138 			0: uint8(43),
  36139 			1: uint8(97),
  36140 			2: uint8(183),
  36141 			3: uint8(117),
  36142 			4: uint8(85),
  36143 			5: uint8(38),
  36144 			6: uint8(35),
  36145 			7: uint8(179),
  36146 			8: uint8(61),
  36147 		},
  36148 		2: {
  36149 			0: uint8(39),
  36150 			1: uint8(53),
  36151 			2: uint8(200),
  36152 			3: uint8(87),
  36153 			4: uint8(26),
  36154 			5: uint8(21),
  36155 			6: uint8(43),
  36156 			7: uint8(232),
  36157 			8: uint8(171),
  36158 		},
  36159 		3: {
  36160 			0: uint8(56),
  36161 			1: uint8(34),
  36162 			2: uint8(51),
  36163 			3: uint8(104),
  36164 			4: uint8(114),
  36165 			5: uint8(102),
  36166 			6: uint8(29),
  36167 			7: uint8(93),
  36168 			8: uint8(77),
  36169 		},
  36170 		4: {
  36171 			0: uint8(39),
  36172 			1: uint8(28),
  36173 			2: uint8(85),
  36174 			3: uint8(171),
  36175 			4: uint8(58),
  36176 			5: uint8(165),
  36177 			6: uint8(90),
  36178 			7: uint8(98),
  36179 			8: uint8(64),
  36180 		},
  36181 		5: {
  36182 			0: uint8(34),
  36183 			1: uint8(22),
  36184 			2: uint8(116),
  36185 			3: uint8(206),
  36186 			4: uint8(23),
  36187 			5: uint8(34),
  36188 			6: uint8(43),
  36189 			7: uint8(166),
  36190 			8: uint8(73),
  36191 		},
  36192 		6: {
  36193 			0: uint8(107),
  36194 			1: uint8(54),
  36195 			2: uint8(32),
  36196 			3: uint8(26),
  36197 			4: uint8(51),
  36198 			5: uint8(1),
  36199 			6: uint8(81),
  36200 			7: uint8(43),
  36201 			8: uint8(31),
  36202 		},
  36203 		7: {
  36204 			0: uint8(68),
  36205 			1: uint8(25),
  36206 			2: uint8(106),
  36207 			3: uint8(22),
  36208 			4: uint8(64),
  36209 			5: uint8(171),
  36210 			6: uint8(36),
  36211 			7: uint8(225),
  36212 			8: uint8(114),
  36213 		},
  36214 		8: {
  36215 			0: uint8(34),
  36216 			1: uint8(19),
  36217 			2: uint8(21),
  36218 			3: uint8(102),
  36219 			4: uint8(132),
  36220 			5: uint8(188),
  36221 			6: uint8(16),
  36222 			7: uint8(76),
  36223 			8: uint8(124),
  36224 		},
  36225 		9: {
  36226 			0: uint8(62),
  36227 			1: uint8(18),
  36228 			2: uint8(78),
  36229 			3: uint8(95),
  36230 			4: uint8(85),
  36231 			5: uint8(57),
  36232 			6: uint8(50),
  36233 			7: uint8(48),
  36234 			8: uint8(51),
  36235 		},
  36236 	},
  36237 	3: {
  36238 		0: {
  36239 			0: uint8(193),
  36240 			1: uint8(101),
  36241 			2: uint8(35),
  36242 			3: uint8(159),
  36243 			4: uint8(215),
  36244 			5: uint8(111),
  36245 			6: uint8(89),
  36246 			7: uint8(46),
  36247 			8: uint8(111),
  36248 		},
  36249 		1: {
  36250 			0: uint8(60),
  36251 			1: uint8(148),
  36252 			2: uint8(31),
  36253 			3: uint8(172),
  36254 			4: uint8(219),
  36255 			5: uint8(228),
  36256 			6: uint8(21),
  36257 			7: uint8(18),
  36258 			8: uint8(111),
  36259 		},
  36260 		2: {
  36261 			0: uint8(112),
  36262 			1: uint8(113),
  36263 			2: uint8(77),
  36264 			3: uint8(85),
  36265 			4: uint8(179),
  36266 			5: uint8(255),
  36267 			6: uint8(38),
  36268 			7: uint8(120),
  36269 			8: uint8(114),
  36270 		},
  36271 		3: {
  36272 			0: uint8(40),
  36273 			1: uint8(42),
  36274 			2: uint8(1),
  36275 			3: uint8(196),
  36276 			4: uint8(245),
  36277 			5: uint8(209),
  36278 			6: uint8(10),
  36279 			7: uint8(25),
  36280 			8: uint8(109),
  36281 		},
  36282 		4: {
  36283 			0: uint8(88),
  36284 			1: uint8(43),
  36285 			2: uint8(29),
  36286 			3: uint8(140),
  36287 			4: uint8(166),
  36288 			5: uint8(213),
  36289 			6: uint8(37),
  36290 			7: uint8(43),
  36291 			8: uint8(154),
  36292 		},
  36293 		5: {
  36294 			0: uint8(61),
  36295 			1: uint8(63),
  36296 			2: uint8(30),
  36297 			3: uint8(155),
  36298 			4: uint8(67),
  36299 			5: uint8(45),
  36300 			6: uint8(68),
  36301 			7: uint8(1),
  36302 			8: uint8(209),
  36303 		},
  36304 		6: {
  36305 			0: uint8(100),
  36306 			1: uint8(80),
  36307 			2: uint8(8),
  36308 			3: uint8(43),
  36309 			4: uint8(154),
  36310 			5: uint8(1),
  36311 			6: uint8(51),
  36312 			7: uint8(26),
  36313 			8: uint8(71),
  36314 		},
  36315 		7: {
  36316 			0: uint8(142),
  36317 			1: uint8(78),
  36318 			2: uint8(78),
  36319 			3: uint8(16),
  36320 			4: uint8(255),
  36321 			5: uint8(128),
  36322 			6: uint8(34),
  36323 			7: uint8(197),
  36324 			8: uint8(171),
  36325 		},
  36326 		8: {
  36327 			0: uint8(41),
  36328 			1: uint8(40),
  36329 			2: uint8(5),
  36330 			3: uint8(102),
  36331 			4: uint8(211),
  36332 			5: uint8(183),
  36333 			6: uint8(4),
  36334 			7: uint8(1),
  36335 			8: uint8(221),
  36336 		},
  36337 		9: {
  36338 			0: uint8(51),
  36339 			1: uint8(50),
  36340 			2: uint8(17),
  36341 			3: uint8(168),
  36342 			4: uint8(209),
  36343 			5: uint8(192),
  36344 			6: uint8(23),
  36345 			7: uint8(25),
  36346 			8: uint8(82),
  36347 		},
  36348 	},
  36349 	4: {
  36350 		0: {
  36351 			0: uint8(138),
  36352 			1: uint8(31),
  36353 			2: uint8(36),
  36354 			3: uint8(171),
  36355 			4: uint8(27),
  36356 			5: uint8(166),
  36357 			6: uint8(38),
  36358 			7: uint8(44),
  36359 			8: uint8(229),
  36360 		},
  36361 		1: {
  36362 			0: uint8(67),
  36363 			1: uint8(87),
  36364 			2: uint8(58),
  36365 			3: uint8(169),
  36366 			4: uint8(82),
  36367 			5: uint8(115),
  36368 			6: uint8(26),
  36369 			7: uint8(59),
  36370 			8: uint8(179),
  36371 		},
  36372 		2: {
  36373 			0: uint8(63),
  36374 			1: uint8(59),
  36375 			2: uint8(90),
  36376 			3: uint8(180),
  36377 			4: uint8(59),
  36378 			5: uint8(166),
  36379 			6: uint8(93),
  36380 			7: uint8(73),
  36381 			8: uint8(154),
  36382 		},
  36383 		3: {
  36384 			0: uint8(40),
  36385 			1: uint8(40),
  36386 			2: uint8(21),
  36387 			3: uint8(116),
  36388 			4: uint8(143),
  36389 			5: uint8(209),
  36390 			6: uint8(34),
  36391 			7: uint8(39),
  36392 			8: uint8(175),
  36393 		},
  36394 		4: {
  36395 			0: uint8(47),
  36396 			1: uint8(15),
  36397 			2: uint8(16),
  36398 			3: uint8(183),
  36399 			4: uint8(34),
  36400 			5: uint8(223),
  36401 			6: uint8(49),
  36402 			7: uint8(45),
  36403 			8: uint8(183),
  36404 		},
  36405 		5: {
  36406 			0: uint8(46),
  36407 			1: uint8(17),
  36408 			2: uint8(33),
  36409 			3: uint8(183),
  36410 			4: uint8(6),
  36411 			5: uint8(98),
  36412 			6: uint8(15),
  36413 			7: uint8(32),
  36414 			8: uint8(183),
  36415 		},
  36416 		6: {
  36417 			0: uint8(57),
  36418 			1: uint8(46),
  36419 			2: uint8(22),
  36420 			3: uint8(24),
  36421 			4: uint8(128),
  36422 			5: uint8(1),
  36423 			6: uint8(54),
  36424 			7: uint8(17),
  36425 			8: uint8(37),
  36426 		},
  36427 		7: {
  36428 			0: uint8(65),
  36429 			1: uint8(32),
  36430 			2: uint8(73),
  36431 			3: uint8(115),
  36432 			4: uint8(28),
  36433 			5: uint8(128),
  36434 			6: uint8(23),
  36435 			7: uint8(128),
  36436 			8: uint8(205),
  36437 		},
  36438 		8: {
  36439 			0: uint8(40),
  36440 			1: uint8(3),
  36441 			2: uint8(9),
  36442 			3: uint8(115),
  36443 			4: uint8(51),
  36444 			5: uint8(192),
  36445 			6: uint8(18),
  36446 			7: uint8(6),
  36447 			8: uint8(223),
  36448 		},
  36449 		9: {
  36450 			0: uint8(87),
  36451 			1: uint8(37),
  36452 			2: uint8(9),
  36453 			3: uint8(115),
  36454 			4: uint8(59),
  36455 			5: uint8(77),
  36456 			6: uint8(64),
  36457 			7: uint8(21),
  36458 			8: uint8(47),
  36459 		},
  36460 	},
  36461 	5: {
  36462 		0: {
  36463 			0: uint8(104),
  36464 			1: uint8(55),
  36465 			2: uint8(44),
  36466 			3: uint8(218),
  36467 			4: uint8(9),
  36468 			5: uint8(54),
  36469 			6: uint8(53),
  36470 			7: uint8(130),
  36471 			8: uint8(226),
  36472 		},
  36473 		1: {
  36474 			0: uint8(64),
  36475 			1: uint8(90),
  36476 			2: uint8(70),
  36477 			3: uint8(205),
  36478 			4: uint8(40),
  36479 			5: uint8(41),
  36480 			6: uint8(23),
  36481 			7: uint8(26),
  36482 			8: uint8(57),
  36483 		},
  36484 		2: {
  36485 			0: uint8(54),
  36486 			1: uint8(57),
  36487 			2: uint8(112),
  36488 			3: uint8(184),
  36489 			4: uint8(5),
  36490 			5: uint8(41),
  36491 			6: uint8(38),
  36492 			7: uint8(166),
  36493 			8: uint8(213),
  36494 		},
  36495 		3: {
  36496 			0: uint8(30),
  36497 			1: uint8(34),
  36498 			2: uint8(26),
  36499 			3: uint8(133),
  36500 			4: uint8(152),
  36501 			5: uint8(116),
  36502 			6: uint8(10),
  36503 			7: uint8(32),
  36504 			8: uint8(134),
  36505 		},
  36506 		4: {
  36507 			0: uint8(39),
  36508 			1: uint8(19),
  36509 			2: uint8(53),
  36510 			3: uint8(221),
  36511 			4: uint8(26),
  36512 			5: uint8(114),
  36513 			6: uint8(32),
  36514 			7: uint8(73),
  36515 			8: uint8(255),
  36516 		},
  36517 		5: {
  36518 			0: uint8(31),
  36519 			1: uint8(9),
  36520 			2: uint8(65),
  36521 			3: uint8(234),
  36522 			4: uint8(2),
  36523 			5: uint8(15),
  36524 			6: uint8(1),
  36525 			7: uint8(118),
  36526 			8: uint8(73),
  36527 		},
  36528 		6: {
  36529 			0: uint8(75),
  36530 			1: uint8(32),
  36531 			2: uint8(12),
  36532 			3: uint8(51),
  36533 			4: uint8(192),
  36534 			5: uint8(255),
  36535 			6: uint8(160),
  36536 			7: uint8(43),
  36537 			8: uint8(51),
  36538 		},
  36539 		7: {
  36540 			0: uint8(88),
  36541 			1: uint8(31),
  36542 			2: uint8(35),
  36543 			3: uint8(67),
  36544 			4: uint8(102),
  36545 			5: uint8(85),
  36546 			6: uint8(55),
  36547 			7: uint8(186),
  36548 			8: uint8(85),
  36549 		},
  36550 		8: {
  36551 			0: uint8(56),
  36552 			1: uint8(21),
  36553 			2: uint8(23),
  36554 			3: uint8(111),
  36555 			4: uint8(59),
  36556 			5: uint8(205),
  36557 			6: uint8(45),
  36558 			7: uint8(37),
  36559 			8: uint8(192),
  36560 		},
  36561 		9: {
  36562 			0: uint8(55),
  36563 			1: uint8(38),
  36564 			2: uint8(70),
  36565 			3: uint8(124),
  36566 			4: uint8(73),
  36567 			5: uint8(102),
  36568 			6: uint8(1),
  36569 			7: uint8(34),
  36570 			8: uint8(98),
  36571 		},
  36572 	},
  36573 	6: {
  36574 		0: {
  36575 			0: uint8(125),
  36576 			1: uint8(98),
  36577 			2: uint8(42),
  36578 			3: uint8(88),
  36579 			4: uint8(104),
  36580 			5: uint8(85),
  36581 			6: uint8(117),
  36582 			7: uint8(175),
  36583 			8: uint8(82),
  36584 		},
  36585 		1: {
  36586 			0: uint8(95),
  36587 			1: uint8(84),
  36588 			2: uint8(53),
  36589 			3: uint8(89),
  36590 			4: uint8(128),
  36591 			5: uint8(100),
  36592 			6: uint8(113),
  36593 			7: uint8(101),
  36594 			8: uint8(45),
  36595 		},
  36596 		2: {
  36597 			0: uint8(75),
  36598 			1: uint8(79),
  36599 			2: uint8(123),
  36600 			3: uint8(47),
  36601 			4: uint8(51),
  36602 			5: uint8(128),
  36603 			6: uint8(81),
  36604 			7: uint8(171),
  36605 			8: uint8(1),
  36606 		},
  36607 		3: {
  36608 			0: uint8(57),
  36609 			1: uint8(17),
  36610 			2: uint8(5),
  36611 			3: uint8(71),
  36612 			4: uint8(102),
  36613 			5: uint8(57),
  36614 			6: uint8(53),
  36615 			7: uint8(41),
  36616 			8: uint8(49),
  36617 		},
  36618 		4: {
  36619 			0: uint8(38),
  36620 			1: uint8(33),
  36621 			2: uint8(13),
  36622 			3: uint8(121),
  36623 			4: uint8(57),
  36624 			5: uint8(73),
  36625 			6: uint8(26),
  36626 			7: uint8(1),
  36627 			8: uint8(85),
  36628 		},
  36629 		5: {
  36630 			0: uint8(41),
  36631 			1: uint8(10),
  36632 			2: uint8(67),
  36633 			3: uint8(138),
  36634 			4: uint8(77),
  36635 			5: uint8(110),
  36636 			6: uint8(90),
  36637 			7: uint8(47),
  36638 			8: uint8(114),
  36639 		},
  36640 		6: {
  36641 			0: uint8(115),
  36642 			1: uint8(21),
  36643 			2: uint8(2),
  36644 			3: uint8(10),
  36645 			4: uint8(102),
  36646 			5: uint8(255),
  36647 			6: uint8(166),
  36648 			7: uint8(23),
  36649 			8: uint8(6),
  36650 		},
  36651 		7: {
  36652 			0: uint8(101),
  36653 			1: uint8(29),
  36654 			2: uint8(16),
  36655 			3: uint8(10),
  36656 			4: uint8(85),
  36657 			5: uint8(128),
  36658 			6: uint8(101),
  36659 			7: uint8(196),
  36660 			8: uint8(26),
  36661 		},
  36662 		8: {
  36663 			0: uint8(57),
  36664 			1: uint8(18),
  36665 			2: uint8(10),
  36666 			3: uint8(102),
  36667 			4: uint8(102),
  36668 			5: uint8(213),
  36669 			6: uint8(34),
  36670 			7: uint8(20),
  36671 			8: uint8(43),
  36672 		},
  36673 		9: {
  36674 			0: uint8(117),
  36675 			1: uint8(20),
  36676 			2: uint8(15),
  36677 			3: uint8(36),
  36678 			4: uint8(163),
  36679 			5: uint8(128),
  36680 			6: uint8(68),
  36681 			7: uint8(1),
  36682 			8: uint8(26),
  36683 		},
  36684 	},
  36685 	7: {
  36686 		0: {
  36687 			0: uint8(102),
  36688 			1: uint8(61),
  36689 			2: uint8(71),
  36690 			3: uint8(37),
  36691 			4: uint8(34),
  36692 			5: uint8(53),
  36693 			6: uint8(31),
  36694 			7: uint8(243),
  36695 			8: uint8(192),
  36696 		},
  36697 		1: {
  36698 			0: uint8(69),
  36699 			1: uint8(60),
  36700 			2: uint8(71),
  36701 			3: uint8(38),
  36702 			4: uint8(73),
  36703 			5: uint8(119),
  36704 			6: uint8(28),
  36705 			7: uint8(222),
  36706 			8: uint8(37),
  36707 		},
  36708 		2: {
  36709 			0: uint8(68),
  36710 			1: uint8(45),
  36711 			2: uint8(128),
  36712 			3: uint8(34),
  36713 			4: uint8(1),
  36714 			5: uint8(47),
  36715 			6: uint8(11),
  36716 			7: uint8(245),
  36717 			8: uint8(171),
  36718 		},
  36719 		3: {
  36720 			0: uint8(62),
  36721 			1: uint8(17),
  36722 			2: uint8(19),
  36723 			3: uint8(70),
  36724 			4: uint8(146),
  36725 			5: uint8(85),
  36726 			6: uint8(55),
  36727 			7: uint8(62),
  36728 			8: uint8(70),
  36729 		},
  36730 		4: {
  36731 			0: uint8(37),
  36732 			1: uint8(43),
  36733 			2: uint8(37),
  36734 			3: uint8(154),
  36735 			4: uint8(100),
  36736 			5: uint8(163),
  36737 			6: uint8(85),
  36738 			7: uint8(160),
  36739 			8: uint8(1),
  36740 		},
  36741 		5: {
  36742 			0: uint8(63),
  36743 			1: uint8(9),
  36744 			2: uint8(92),
  36745 			3: uint8(136),
  36746 			4: uint8(28),
  36747 			5: uint8(64),
  36748 			6: uint8(32),
  36749 			7: uint8(201),
  36750 			8: uint8(85),
  36751 		},
  36752 		6: {
  36753 			0: uint8(75),
  36754 			1: uint8(15),
  36755 			2: uint8(9),
  36756 			3: uint8(9),
  36757 			4: uint8(64),
  36758 			5: uint8(255),
  36759 			6: uint8(184),
  36760 			7: uint8(119),
  36761 			8: uint8(16),
  36762 		},
  36763 		7: {
  36764 			0: uint8(86),
  36765 			1: uint8(6),
  36766 			2: uint8(28),
  36767 			3: uint8(5),
  36768 			4: uint8(64),
  36769 			5: uint8(255),
  36770 			6: uint8(25),
  36771 			7: uint8(248),
  36772 			8: uint8(1),
  36773 		},
  36774 		8: {
  36775 			0: uint8(56),
  36776 			1: uint8(8),
  36777 			2: uint8(17),
  36778 			3: uint8(132),
  36779 			4: uint8(137),
  36780 			5: uint8(255),
  36781 			6: uint8(55),
  36782 			7: uint8(116),
  36783 			8: uint8(128),
  36784 		},
  36785 		9: {
  36786 			0: uint8(58),
  36787 			1: uint8(15),
  36788 			2: uint8(20),
  36789 			3: uint8(82),
  36790 			4: uint8(135),
  36791 			5: uint8(57),
  36792 			6: uint8(26),
  36793 			7: uint8(121),
  36794 			8: uint8(40),
  36795 		},
  36796 	},
  36797 	8: {
  36798 		0: {
  36799 			0: uint8(164),
  36800 			1: uint8(50),
  36801 			2: uint8(31),
  36802 			3: uint8(137),
  36803 			4: uint8(154),
  36804 			5: uint8(133),
  36805 			6: uint8(25),
  36806 			7: uint8(35),
  36807 			8: uint8(218),
  36808 		},
  36809 		1: {
  36810 			0: uint8(51),
  36811 			1: uint8(103),
  36812 			2: uint8(44),
  36813 			3: uint8(131),
  36814 			4: uint8(131),
  36815 			5: uint8(123),
  36816 			6: uint8(31),
  36817 			7: uint8(6),
  36818 			8: uint8(158),
  36819 		},
  36820 		2: {
  36821 			0: uint8(86),
  36822 			1: uint8(40),
  36823 			2: uint8(64),
  36824 			3: uint8(135),
  36825 			4: uint8(148),
  36826 			5: uint8(224),
  36827 			6: uint8(45),
  36828 			7: uint8(183),
  36829 			8: uint8(128),
  36830 		},
  36831 		3: {
  36832 			0: uint8(22),
  36833 			1: uint8(26),
  36834 			2: uint8(17),
  36835 			3: uint8(131),
  36836 			4: uint8(240),
  36837 			5: uint8(154),
  36838 			6: uint8(14),
  36839 			7: uint8(1),
  36840 			8: uint8(209),
  36841 		},
  36842 		4: {
  36843 			0: uint8(45),
  36844 			1: uint8(16),
  36845 			2: uint8(21),
  36846 			3: uint8(91),
  36847 			4: uint8(64),
  36848 			5: uint8(222),
  36849 			6: uint8(7),
  36850 			7: uint8(1),
  36851 			8: uint8(197),
  36852 		},
  36853 		5: {
  36854 			0: uint8(56),
  36855 			1: uint8(21),
  36856 			2: uint8(39),
  36857 			3: uint8(155),
  36858 			4: uint8(60),
  36859 			5: uint8(138),
  36860 			6: uint8(23),
  36861 			7: uint8(102),
  36862 			8: uint8(213),
  36863 		},
  36864 		6: {
  36865 			0: uint8(83),
  36866 			1: uint8(12),
  36867 			2: uint8(13),
  36868 			3: uint8(54),
  36869 			4: uint8(192),
  36870 			5: uint8(255),
  36871 			6: uint8(68),
  36872 			7: uint8(47),
  36873 			8: uint8(28),
  36874 		},
  36875 		7: {
  36876 			0: uint8(85),
  36877 			1: uint8(26),
  36878 			2: uint8(85),
  36879 			3: uint8(85),
  36880 			4: uint8(128),
  36881 			5: uint8(128),
  36882 			6: uint8(32),
  36883 			7: uint8(146),
  36884 			8: uint8(171),
  36885 		},
  36886 		8: {
  36887 			0: uint8(18),
  36888 			1: uint8(11),
  36889 			2: uint8(7),
  36890 			3: uint8(63),
  36891 			4: uint8(144),
  36892 			5: uint8(171),
  36893 			6: uint8(4),
  36894 			7: uint8(4),
  36895 			8: uint8(246),
  36896 		},
  36897 		9: {
  36898 			0: uint8(35),
  36899 			1: uint8(27),
  36900 			2: uint8(10),
  36901 			3: uint8(146),
  36902 			4: uint8(174),
  36903 			5: uint8(171),
  36904 			6: uint8(12),
  36905 			7: uint8(26),
  36906 			8: uint8(128),
  36907 		},
  36908 	},
  36909 	9: {
  36910 		0: {
  36911 			0: uint8(190),
  36912 			1: uint8(80),
  36913 			2: uint8(35),
  36914 			3: uint8(99),
  36915 			4: uint8(180),
  36916 			5: uint8(80),
  36917 			6: uint8(126),
  36918 			7: uint8(54),
  36919 			8: uint8(45),
  36920 		},
  36921 		1: {
  36922 			0: uint8(85),
  36923 			1: uint8(126),
  36924 			2: uint8(47),
  36925 			3: uint8(87),
  36926 			4: uint8(176),
  36927 			5: uint8(51),
  36928 			6: uint8(41),
  36929 			7: uint8(20),
  36930 			8: uint8(32),
  36931 		},
  36932 		2: {
  36933 			0: uint8(101),
  36934 			1: uint8(75),
  36935 			2: uint8(128),
  36936 			3: uint8(139),
  36937 			4: uint8(118),
  36938 			5: uint8(146),
  36939 			6: uint8(116),
  36940 			7: uint8(128),
  36941 			8: uint8(85),
  36942 		},
  36943 		3: {
  36944 			0: uint8(56),
  36945 			1: uint8(41),
  36946 			2: uint8(15),
  36947 			3: uint8(176),
  36948 			4: uint8(236),
  36949 			5: uint8(85),
  36950 			6: uint8(37),
  36951 			7: uint8(9),
  36952 			8: uint8(62),
  36953 		},
  36954 		4: {
  36955 			0: uint8(71),
  36956 			1: uint8(30),
  36957 			2: uint8(17),
  36958 			3: uint8(119),
  36959 			4: uint8(118),
  36960 			5: uint8(255),
  36961 			6: uint8(17),
  36962 			7: uint8(18),
  36963 			8: uint8(138),
  36964 		},
  36965 		5: {
  36966 			0: uint8(101),
  36967 			1: uint8(38),
  36968 			2: uint8(60),
  36969 			3: uint8(138),
  36970 			4: uint8(55),
  36971 			5: uint8(70),
  36972 			6: uint8(43),
  36973 			7: uint8(26),
  36974 			8: uint8(142),
  36975 		},
  36976 		6: {
  36977 			0: uint8(146),
  36978 			1: uint8(36),
  36979 			2: uint8(19),
  36980 			3: uint8(30),
  36981 			4: uint8(171),
  36982 			5: uint8(255),
  36983 			6: uint8(97),
  36984 			7: uint8(27),
  36985 			8: uint8(20),
  36986 		},
  36987 		7: {
  36988 			0: uint8(138),
  36989 			1: uint8(45),
  36990 			2: uint8(61),
  36991 			3: uint8(62),
  36992 			4: uint8(219),
  36993 			5: uint8(1),
  36994 			6: uint8(81),
  36995 			7: uint8(188),
  36996 			8: uint8(64),
  36997 		},
  36998 		8: {
  36999 			0: uint8(32),
  37000 			1: uint8(41),
  37001 			2: uint8(20),
  37002 			3: uint8(117),
  37003 			4: uint8(151),
  37004 			5: uint8(142),
  37005 			6: uint8(20),
  37006 			7: uint8(21),
  37007 			8: uint8(163),
  37008 		},
  37009 		9: {
  37010 			0: uint8(112),
  37011 			1: uint8(19),
  37012 			2: uint8(12),
  37013 			3: uint8(61),
  37014 			4: uint8(195),
  37015 			5: uint8(128),
  37016 			6: uint8(48),
  37017 			7: uint8(4),
  37018 			8: uint8(24),
  37019 		},
  37020 	},
  37021 }
  37022 
  37023 func PutI4Mode(tls *libc.TLS, bw uintptr, mode int32, prob uintptr) (r int32) {
  37024 	if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_DC_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob)))) != 0 {
  37025 		if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_TM_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 1)))) != 0 {
  37026 			if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_VE_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 2)))) != 0 {
  37027 				if !(VP8PutBit(tls, bw, libc.BoolInt32(mode >= int32(B_LD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 3)))) != 0) {
  37028 					if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_HE_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 4)))) != 0 {
  37029 						VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_RD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 5))))
  37030 					}
  37031 				} else {
  37032 					if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_LD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 6)))) != 0 {
  37033 						if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_VL_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 7)))) != 0 {
  37034 							VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_HD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 8))))
  37035 						}
  37036 					}
  37037 				}
  37038 			}
  37039 		}
  37040 	}
  37041 	return mode
  37042 }
  37043 
  37044 func PutI16Mode(tls *libc.TLS, bw uintptr, mode int32) {
  37045 	if VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(TM_PRED) || mode == int32(H_PRED)), int32(156)) != 0 {
  37046 		VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(TM_PRED)), int32(128)) // TM or HE
  37047 	} else {
  37048 		VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(V_PRED)), int32(163)) // VE or DC
  37049 	}
  37050 }
  37051 
  37052 func PutUVMode(tls *libc.TLS, bw uintptr, uv_mode int32) {
  37053 	if VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(DC_PRED)), int32(142)) != 0 {
  37054 		if VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(V_PRED)), int32(114)) != 0 {
  37055 			VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(H_PRED)), int32(183)) // else: TM_PRED
  37056 		}
  37057 	}
  37058 }
  37059 
  37060 func PutSegment(tls *libc.TLS, bw uintptr, s int32, p uintptr) {
  37061 	if VP8PutBit(tls, bw, libc.BoolInt32(s >= int32(2)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0 {
  37062 		p = p + uintptr(1)
  37063 	}
  37064 	VP8PutBit(tls, bw, s&int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1))))
  37065 }
  37066 
  37067 func VP8CodeIntraModes(tls *libc.TLS, enc uintptr) {
  37068 	bp := tls.Alloc(3856)
  37069 	defer tls.Free(3856)
  37070 	var bw, mb, preds, probas, top_pred uintptr
  37071 	var left, preds_w, x, y int32
  37072 	var _ /* it at bp+0 */ VP8EncIterator
  37073 	_, _, _, _, _, _, _, _, _ = bw, left, mb, preds, preds_w, probas, top_pred, x, y
  37074 	bw = enc + 64
  37075 	VP8IteratorInit(tls, enc, bp)
  37076 	for cond := true; cond; cond = VP8IteratorNext(tls, bp) != 0 {
  37077 		mb = (**(**VP8EncIterator)(__ccgo_up(bp))).Fmb
  37078 		preds = (**(**VP8EncIterator)(__ccgo_up(bp))).Fpreds
  37079 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map != 0 {
  37080 			PutSegment(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5)), enc+3616)
  37081 		}
  37082 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fuse_skip_proba != 0 {
  37083 			VP8PutBit(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x10>>4)), libc.Int32FromUint8((*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fskip_proba))
  37084 		}
  37085 		if VP8PutBit(tls, bw, libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) != 0), int32(145)) != 0 { // i16x16
  37086 			PutI16Mode(tls, bw, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds))))
  37087 		} else {
  37088 			preds_w = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w
  37089 			top_pred = preds - uintptr(preds_w)
  37090 			y = 0
  37091 			for {
  37092 				if !(y < int32(4)) {
  37093 					break
  37094 				}
  37095 				left = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds + uintptr(-libc.Int32FromInt32(1)))))
  37096 				x = 0
  37097 				for {
  37098 					if !(x < int32(4)) {
  37099 						break
  37100 					}
  37101 					probas = uintptr(unsafe.Pointer(&kBModesProba1)) + uintptr(**(**uint8_t)(__ccgo_up(top_pred + uintptr(x))))*90 + uintptr(left)*9
  37102 					left = PutI4Mode(tls, bw, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds + uintptr(x)))), probas)
  37103 					goto _2
  37104 				_2:
  37105 					;
  37106 					x = x + 1
  37107 				}
  37108 				top_pred = preds
  37109 				preds = preds + uintptr(preds_w)
  37110 				goto _1
  37111 			_1:
  37112 				;
  37113 				y = y + 1
  37114 			}
  37115 		}
  37116 		PutUVMode(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0xc>>2)))
  37117 	}
  37118 }
  37119 
  37120 func VP8WriteProbas(tls *libc.TLS, bw uintptr, probas uintptr) {
  37121 	var b, c, p, t, update int32
  37122 	var p0 uint8_t
  37123 	_, _, _, _, _, _ = b, c, p, p0, t, update
  37124 	t = 0
  37125 	for {
  37126 		if !(t < int32(NUM_TYPES)) {
  37127 			break
  37128 		}
  37129 		b = 0
  37130 		for {
  37131 			if !(b < int32(NUM_BANDS)) {
  37132 				break
  37133 			}
  37134 			c = 0
  37135 			for {
  37136 				if !(c < int32(NUM_CTX)) {
  37137 					break
  37138 				}
  37139 				p = 0
  37140 				for {
  37141 					if !(p < int32(NUM_PROBAS)) {
  37142 						break
  37143 					}
  37144 					p0 = **(**uint8_t)(__ccgo_up(probas + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p)))
  37145 					update = libc.BoolInt32(libc.Int32FromUint8(p0) != libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsProba0)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p)))))
  37146 					if VP8PutBit(tls, bw, update, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsUpdateProba)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))) != 0 {
  37147 						VP8PutBits(tls, bw, uint32(p0), int32(8))
  37148 					}
  37149 					goto _4
  37150 				_4:
  37151 					;
  37152 					p = p + 1
  37153 				}
  37154 				goto _3
  37155 			_3:
  37156 				;
  37157 				c = c + 1
  37158 			}
  37159 			goto _2
  37160 		_2:
  37161 			;
  37162 			b = b + 1
  37163 		}
  37164 		goto _1
  37165 	_1:
  37166 		;
  37167 		t = t + 1
  37168 	}
  37169 	if VP8PutBitUniform(tls, bw, (*VP8EncProba)(unsafe.Pointer(probas)).Fuse_skip_proba) != 0 {
  37170 		VP8PutBits(tls, bw, uint32((*VP8EncProba)(unsafe.Pointer(probas)).Fskip_proba), int32(8))
  37171 	}
  37172 }
  37173 
  37174 const MAX_HUFF_IMAGE_SIZE = 2600
  37175 const NUM_BUCKETS = 256
  37176 const VP8L_MAGIC_BYTE3 = 47
  37177 const VP8_SIGNATURE2 = 0x9d012a
  37178 
  37179 type HuffmanTreeToken = struct {
  37180 	Fcode       uint8_t
  37181 	Fextra_bits uint8_t
  37182 }
  37183 
  37184 type HuffmanTreeCode = struct {
  37185 	Fnum_symbols  int32
  37186 	Fcode_lengths uintptr
  37187 	Fcodes        uintptr
  37188 }
  37189 
  37190 type HuffmanTree = struct {
  37191 	Ftotal_count      uint32_t
  37192 	Fvalue            int32
  37193 	Fpool_index_left  int32
  37194 	Fpool_index_right int32
  37195 }
  37196 
  37197 type PaletteSorting1 = int32
  37198 
  37199 type PaletteSorting = int32
  37200 
  37201 const kSortedDefault = 0
  37202 const kMinimizeDelta = 1
  37203 const kModifiedZeng = 2
  37204 const kUnusedPalette = 3
  37205 const kPaletteSortingNum = 4
  37206 
  37207 // Copyright 2011 Google Inc. All Rights Reserved.
  37208 //
  37209 // Use of this source code is governed by a BSD-style license
  37210 // that can be found in the COPYING file in the root of the source
  37211 // tree. An additional intellectual property rights grant can be found
  37212 // in the file PATENTS. All contributing project authors may
  37213 // be found in the AUTHORS file in the root of the source tree.
  37214 // -----------------------------------------------------------------------------
  37215 //
  37216 // Multi-threaded worker
  37217 //
  37218 // Author: Skal (pascal.massimino@gmail.com)
  37219 
  37220 // Copyright 2012 Google Inc. All Rights Reserved.
  37221 //
  37222 // Use of this source code is governed by a BSD-style license
  37223 // that can be found in the COPYING file in the root of the source
  37224 // tree. An additional intellectual property rights grant can be found
  37225 // in the file PATENTS. All contributing project authors may
  37226 // be found in the AUTHORS file in the root of the source tree.
  37227 // -----------------------------------------------------------------------------
  37228 //
  37229 // Misc. common utility functions
  37230 //
  37231 // Authors: Skal (pascal.massimino@gmail.com)
  37232 //          Urvang (urvang@google.com)
  37233 
  37234 // Copyright 2011 Google Inc. All Rights Reserved.
  37235 //
  37236 // Use of this source code is governed by a BSD-style license
  37237 // that can be found in the COPYING file in the root of the source
  37238 // tree. An additional intellectual property rights grant can be found
  37239 // in the file PATENTS. All contributing project authors may
  37240 // be found in the AUTHORS file in the root of the source tree.
  37241 // -----------------------------------------------------------------------------
  37242 //
  37243 //   WebP encoder: main interface
  37244 //
  37245 // Author: Skal (pascal.massimino@gmail.com)
  37246 
  37247 // Copyright 2012 Google Inc. All Rights Reserved.
  37248 //
  37249 // Use of this source code is governed by a BSD-style license
  37250 // that can be found in the COPYING file in the root of the source
  37251 // tree. An additional intellectual property rights grant can be found
  37252 // in the file PATENTS. All contributing project authors may
  37253 // be found in the AUTHORS file in the root of the source tree.
  37254 // -----------------------------------------------------------------------------
  37255 //
  37256 //  Internal header for constants related to WebP file format.
  37257 //
  37258 // Author: Urvang (urvang@google.com)
  37259 
  37260 // Copyright 2010 Google Inc. All Rights Reserved.
  37261 //
  37262 // Use of this source code is governed by a BSD-style license
  37263 // that can be found in the COPYING file in the root of the source
  37264 // tree. An additional intellectual property rights grant can be found
  37265 // in the file PATENTS. All contributing project authors may
  37266 // be found in the AUTHORS file in the root of the source tree.
  37267 // -----------------------------------------------------------------------------
  37268 //
  37269 //  Common types + memory wrappers
  37270 //
  37271 // Author: Skal (pascal.massimino@gmail.com)
  37272 
  37273 // Maximum number of histogram images (sub-blocks).
  37274 // Empirical value for which it becomes too computationally expensive to
  37275 // compute the best predictor image.
  37276 
  37277 // -----------------------------------------------------------------------------
  37278 // Palette
  37279 
  37280 // C documentation
  37281 //
  37282 //	// These five modes are evaluated and their respective entropy is computed.
  37283 type EntropyIx = int32
  37284 
  37285 const kDirect = 0
  37286 const kSpatial = 1
  37287 const kSubGreen = 2
  37288 const kSpatialSubGreen = 3
  37289 const kPalette = 4
  37290 const kPaletteAndSpatial = 5
  37291 const kNumEntropyIx = 6
  37292 
  37293 type HistoIx = int32
  37294 
  37295 const kHistoAlpha = 0
  37296 const kHistoAlphaPred = 1
  37297 const kHistoGreen = 2
  37298 const kHistoGreenPred = 3
  37299 const kHistoRed = 4
  37300 const kHistoRedPred = 5
  37301 const kHistoBlue = 6
  37302 const kHistoBluePred = 7
  37303 const kHistoRedSubGreen = 8
  37304 const kHistoRedPredSubGreen = 9
  37305 const kHistoBlueSubGreen = 10
  37306 const kHistoBluePredSubGreen = 11
  37307 const kHistoPalette = 12
  37308 const kHistoTotal = 13
  37309 
  37310 type HistogramBuckets = [256]uint32_t
  37311 
  37312 // C documentation
  37313 //
  37314 //	// Keeping track of histograms, indexed by HistoIx.
  37315 //	// Ideally, this would just be a struct with meaningful fields, but the
  37316 //	// calculation of `entropy_comp` uses the index. One refactoring at a time :)
  37317 type Histograms = struct {
  37318 	Fcategory [13]HistogramBuckets
  37319 }
  37320 
  37321 func AddSingleSubGreen(tls *libc.TLS, p uint32_t, r uintptr, b uintptr) {
  37322 	var green int32
  37323 	_ = green
  37324 	green = libc.Int32FromUint32(p) >> int32(8) // The upper bits are masked away later.
  37325 	**(**uint32_t)(__ccgo_up(r + uintptr((libc.Int32FromUint32(p)>>int32(16)-green)&int32(0xff))*4)) = **(**uint32_t)(__ccgo_up(r + uintptr((libc.Int32FromUint32(p)>>int32(16)-green)&int32(0xff))*4)) + 1
  37326 	**(**uint32_t)(__ccgo_up(b + uintptr((libc.Int32FromUint32(p)>>0-green)&int32(0xff))*4)) = **(**uint32_t)(__ccgo_up(b + uintptr((libc.Int32FromUint32(p)>>0-green)&int32(0xff))*4)) + 1
  37327 }
  37328 
  37329 func AddSingle(tls *libc.TLS, p uint32_t, a uintptr, r uintptr, g uintptr, b uintptr) {
  37330 	**(**uint32_t)(__ccgo_up(a + uintptr(p>>libc.Int32FromInt32(24)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(a + uintptr(p>>libc.Int32FromInt32(24)&uint32(0xff))*4)) + 1
  37331 	**(**uint32_t)(__ccgo_up(r + uintptr(p>>libc.Int32FromInt32(16)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(r + uintptr(p>>libc.Int32FromInt32(16)&uint32(0xff))*4)) + 1
  37332 	**(**uint32_t)(__ccgo_up(g + uintptr(p>>libc.Int32FromInt32(8)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(g + uintptr(p>>libc.Int32FromInt32(8)&uint32(0xff))*4)) + 1
  37333 	**(**uint32_t)(__ccgo_up(b + uintptr(p>>libc.Int32FromInt32(0)&uint32(0xff))*4)) = **(**uint32_t)(__ccgo_up(b + uintptr(p>>libc.Int32FromInt32(0)&uint32(0xff))*4)) + 1
  37334 }
  37335 
  37336 func HashPix(tls *libc.TLS, pix uint32_t) (r uint8_t) {
  37337 	// Note that masking with 0xffffffffu is for preventing an
  37338 	// 'unsigned int overflow' warning. Doesn't impact the compiled code.
  37339 	return uint8((uint64(pix) + uint64(pix>>libc.Int32FromInt32(19))) * uint64(0x39c5fba7) & uint64(0xffffffff) >> int32(24))
  37340 }
  37341 
  37342 func AnalyzeEntropy(tls *libc.TLS, argb uintptr, width int32, height int32, argb_stride int32, use_palette int32, palette_size int32, transform_bits int32, min_entropy_ix uintptr, red_and_blue_always_zero uintptr) (r int32) {
  37343 	bp := tls.Alloc(48)
  37344 	defer tls.Free(48)
  37345 	var alpha_and_green, pix, pix_diff, pix_prev, red_and_blue, v10, v12, v3, v4, v5, v9 uint32_t
  37346 	var blue_histo, curr_row, histo, prev_row, red_histo uintptr
  37347 	var entropy_comp [13]uint64_t
  37348 	var hash uint8_t
  37349 	var i, j, k, last_mode_to_analyze, x, y, v7 int32
  37350 	var v18 uint32
  37351 	var _ /* entropy at bp+0 */ [6]uint64_t
  37352 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, blue_histo, curr_row, entropy_comp, hash, histo, i, j, k, last_mode_to_analyze, pix, pix_diff, pix_prev, prev_row, red_and_blue, red_histo, x, y, v10, v12, v18, v3, v4, v5, v7, v9
  37353 	if use_palette != 0 && palette_size <= int32(16) {
  37354 		// In the case of small palettes, we pack 2, 4 or 8 pixels together. In
  37355 		// practice, small palettes are better than any other transform.
  37356 		**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = int32(kPalette)
  37357 		**(**int32)(__ccgo_up(red_and_blue_always_zero)) = int32(1)
  37358 		return int32(1)
  37359 	}
  37360 	histo = WebPSafeCalloc(tls, uint64(1), uint64(13312))
  37361 	if histo != libc.UintptrFromInt32(0) {
  37362 		prev_row = libc.UintptrFromInt32(0)
  37363 		curr_row = argb
  37364 		pix_prev = **(**uint32_t)(__ccgo_up(argb)) // Skip the first pixel.
  37365 		y = 0
  37366 		for {
  37367 			if !(y < height) {
  37368 				break
  37369 			}
  37370 			x = 0
  37371 			for {
  37372 				if !(x < width) {
  37373 					break
  37374 				}
  37375 				pix = **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4))
  37376 				v3 = pix
  37377 				v4 = pix_prev
  37378 				alpha_and_green = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v4&uint32(0xff00ff00)
  37379 				red_and_blue = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v4&uint32(0x00ff00ff)
  37380 				v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  37381 				goto _6
  37382 			_6:
  37383 				pix_diff = v5
  37384 				pix_prev = pix
  37385 				if pix_diff == uint32(0) || prev_row != libc.UintptrFromInt32(0) && pix == **(**uint32_t)(__ccgo_up(prev_row + uintptr(x)*4)) {
  37386 					goto _2
  37387 				}
  37388 				AddSingle(tls, pix, histo+uintptr(kHistoAlpha)*1024, histo+uintptr(kHistoRed)*1024, histo+uintptr(kHistoGreen)*1024, histo+uintptr(kHistoBlue)*1024)
  37389 				AddSingle(tls, pix_diff, histo+uintptr(kHistoAlphaPred)*1024, histo+uintptr(kHistoRedPred)*1024, histo+uintptr(kHistoGreenPred)*1024, histo+uintptr(kHistoBluePred)*1024)
  37390 				AddSingleSubGreen(tls, pix, histo+uintptr(kHistoRedSubGreen)*1024, histo+uintptr(kHistoBlueSubGreen)*1024)
  37391 				AddSingleSubGreen(tls, pix_diff, histo+uintptr(kHistoRedPredSubGreen)*1024, histo+uintptr(kHistoBluePredSubGreen)*1024)
  37392 				// Approximate the palette by the entropy of the multiplicative hash.
  37393 				hash = HashPix(tls, pix)
  37394 				**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoPalette)*1024 + uintptr(hash)*4)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoPalette)*1024 + uintptr(hash)*4)) + 1
  37395 				goto _2
  37396 			_2:
  37397 				;
  37398 				x = x + 1
  37399 			}
  37400 			prev_row = curr_row
  37401 			curr_row = curr_row + uintptr(argb_stride)*4
  37402 			goto _1
  37403 		_1:
  37404 			;
  37405 			y = y + 1
  37406 		}
  37407 		if use_palette != 0 {
  37408 			v7 = int32(kPalette)
  37409 		} else {
  37410 			v7 = int32(kSpatialSubGreen)
  37411 		}
  37412 		last_mode_to_analyze = v7
  37413 		// Let's add one zero to the predicted histograms. The zeros are removed
  37414 		// too efficiently by the pix_diff == 0 comparison, at least one of the
  37415 		// zeros is likely to exist.
  37416 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPredSubGreen)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPredSubGreen)*1024)) + 1
  37417 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePredSubGreen)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePredSubGreen)*1024)) + 1
  37418 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPred)*1024)) + 1
  37419 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoGreenPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoGreenPred)*1024)) + 1
  37420 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePred)*1024)) + 1
  37421 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoAlphaPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoAlphaPred)*1024)) + 1
  37422 		j = 0
  37423 		for {
  37424 			if !(j < int32(kHistoTotal)) {
  37425 				break
  37426 			}
  37427 			entropy_comp[j] = VP8LBitsEntropy(tls, histo+uintptr(j)*1024, int32(NUM_BUCKETS))
  37428 			goto _8
  37429 		_8:
  37430 			;
  37431 			j = j + 1
  37432 		}
  37433 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kDirect)] = entropy_comp[int32(kHistoAlpha)] + entropy_comp[int32(kHistoRed)] + entropy_comp[int32(kHistoGreen)] + entropy_comp[int32(kHistoBlue)]
  37434 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSpatial)] = entropy_comp[int32(kHistoAlphaPred)] + entropy_comp[int32(kHistoRedPred)] + entropy_comp[int32(kHistoGreenPred)] + entropy_comp[int32(kHistoBluePred)]
  37435 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSubGreen)] = entropy_comp[int32(kHistoAlpha)] + entropy_comp[int32(kHistoRedSubGreen)] + entropy_comp[int32(kHistoGreen)] + entropy_comp[int32(kHistoBlueSubGreen)]
  37436 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSpatialSubGreen)] = entropy_comp[int32(kHistoAlphaPred)] + entropy_comp[int32(kHistoRedPredSubGreen)] + entropy_comp[int32(kHistoGreenPred)] + entropy_comp[int32(kHistoBluePredSubGreen)]
  37437 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kPalette)] = entropy_comp[int32(kHistoPalette)]
  37438 		// When including transforms, there is an overhead in bits from
  37439 		// storing them. This overhead is small but matters for small images.
  37440 		// For spatial, there are 14 transformations.
  37441 		v3 = libc.Uint32FromInt32(transform_bits)
  37442 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37443 		goto _11
  37444 	_11:
  37445 		v5 = libc.Uint32FromInt32(transform_bits)
  37446 		v9 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v5) - uint32(1)) >> v5
  37447 		goto _14
  37448 	_14:
  37449 		v10 = uint32(14)
  37450 		if v10 < uint32(LOG_LOOKUP_IDX_MAX) {
  37451 			v18 = kLog2Table[v10]
  37452 		} else {
  37453 			v18 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v10)
  37454 		}
  37455 		v12 = v18
  37456 		goto _17
  37457 	_17:
  37458 		**(**uint64_t)(__ccgo_up(bp + uintptr(kSpatial)*8)) += uint64(v4) * uint64(v9) * uint64(v12)
  37459 		// For color transforms: 24 as only 3 channels are considered in a
  37460 		// ColorTransformElement.
  37461 		v3 = libc.Uint32FromInt32(transform_bits)
  37462 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37463 		goto _21
  37464 	_21:
  37465 		v5 = libc.Uint32FromInt32(transform_bits)
  37466 		v9 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v5) - uint32(1)) >> v5
  37467 		goto _24
  37468 	_24:
  37469 		v10 = uint32(24)
  37470 		if v10 < uint32(LOG_LOOKUP_IDX_MAX) {
  37471 			v18 = kLog2Table[v10]
  37472 		} else {
  37473 			v18 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v10)
  37474 		}
  37475 		v12 = v18
  37476 		goto _27
  37477 	_27:
  37478 		**(**uint64_t)(__ccgo_up(bp + uintptr(kSpatialSubGreen)*8)) += uint64(v4) * uint64(v9) * uint64(v12)
  37479 		// For palettes, add the cost of storing the palette.
  37480 		// We empirically estimate the cost of a compressed entry as 8 bits.
  37481 		// The palette is differential-coded when compressed hence a much
  37482 		// lower cost than sizeof(uint32_t)*8.
  37483 		**(**uint64_t)(__ccgo_up(bp + uintptr(kPalette)*8)) += libc.Uint64FromInt32(palette_size) * uint64(8) << int32(LOG_2_PRECISION_BITS)
  37484 		**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = int32(kDirect)
  37485 		k = int32(kDirect) + libc.Int32FromInt32(1)
  37486 		for {
  37487 			if !(k <= last_mode_to_analyze) {
  37488 				break
  37489 			}
  37490 			if (**(**[6]uint64_t)(__ccgo_up(bp)))[**(**EntropyIx)(__ccgo_up(min_entropy_ix))] > (**(**[6]uint64_t)(__ccgo_up(bp)))[k] {
  37491 				**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = k
  37492 			}
  37493 			goto _29
  37494 		_29:
  37495 			;
  37496 			k = k + 1
  37497 		}
  37498 		**(**int32)(__ccgo_up(red_and_blue_always_zero)) = int32(1)
  37499 		red_histo = histo + uintptr(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kHistoPairs)) + uintptr(**(**EntropyIx)(__ccgo_up(min_entropy_ix)))*2)))*1024
  37500 		blue_histo = histo + uintptr(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kHistoPairs)) + uintptr(**(**EntropyIx)(__ccgo_up(min_entropy_ix)))*2 + 1)))*1024
  37501 		i = int32(1)
  37502 		for {
  37503 			if !(i < int32(NUM_BUCKETS)) {
  37504 				break
  37505 			}
  37506 			if **(**uint32_t)(__ccgo_up(red_histo + uintptr(i)*4))|**(**uint32_t)(__ccgo_up(blue_histo + uintptr(i)*4)) != uint32(0) {
  37507 				**(**int32)(__ccgo_up(red_and_blue_always_zero)) = 0
  37508 				break
  37509 			}
  37510 			goto _30
  37511 		_30:
  37512 			;
  37513 			i = i + 1
  37514 		}
  37515 		WebPSafeFree(tls, histo)
  37516 		return int32(1)
  37517 	} else {
  37518 		return 0
  37519 	}
  37520 	return r
  37521 }
  37522 
  37523 // Let's check if the histogram of the chosen entropy mode has
  37524 // non-zero red and blue values. If all are zero, we can later skip
  37525 // the cross color optimization.
  37526 
  37527 var kHistoPairs = [5][2]uint8_t{
  37528 	0: {
  37529 		0: uint8(kHistoRed),
  37530 		1: uint8(kHistoBlue),
  37531 	},
  37532 	1: {
  37533 		0: uint8(kHistoRedPred),
  37534 		1: uint8(kHistoBluePred),
  37535 	},
  37536 	2: {
  37537 		0: uint8(kHistoRedSubGreen),
  37538 		1: uint8(kHistoBlueSubGreen),
  37539 	},
  37540 	3: {
  37541 		0: uint8(kHistoRedPredSubGreen),
  37542 		1: uint8(kHistoBluePredSubGreen),
  37543 	},
  37544 	4: {
  37545 		0: uint8(kHistoRed),
  37546 		1: uint8(kHistoBlue),
  37547 	},
  37548 }
  37549 
  37550 // C documentation
  37551 //
  37552 //	// Clamp histogram and transform bits.
  37553 func ClampBits(tls *libc.TLS, width int32, height int32, bits int32, min_bits int32, max_bits int32, image_size_max int32) (r int32) {
  37554 	var image_size, v1, v2 int32
  37555 	var v3, v4, v6, v7 uint32_t
  37556 	_, _, _, _, _, _, _ = image_size, v1, v2, v3, v4, v6, v7
  37557 	if bits < min_bits {
  37558 		v1 = min_bits
  37559 	} else {
  37560 		if bits > max_bits {
  37561 			v2 = max_bits
  37562 		} else {
  37563 			v2 = bits
  37564 		}
  37565 		v1 = v2
  37566 	}
  37567 	bits = v1
  37568 	v3 = libc.Uint32FromInt32(bits)
  37569 	v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37570 	goto _5
  37571 _5:
  37572 	v6 = libc.Uint32FromInt32(bits)
  37573 	v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37574 	goto _8
  37575 _8:
  37576 	image_size = libc.Int32FromUint32(v4 * v7)
  37577 	for bits < max_bits && image_size > image_size_max {
  37578 		bits = bits + 1
  37579 		v3 = libc.Uint32FromInt32(bits)
  37580 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37581 		goto _11
  37582 	_11:
  37583 		v6 = libc.Uint32FromInt32(bits)
  37584 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37585 		goto _14
  37586 	_14:
  37587 		image_size = libc.Int32FromUint32(v4 * v7)
  37588 	}
  37589 	// In case the bits reduce the image too much, choose the smallest value
  37590 	// setting the histogram image size to 1.
  37591 	for bits > min_bits && image_size == int32(1) {
  37592 		v3 = libc.Uint32FromInt32(bits - int32(1))
  37593 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37594 		goto _17
  37595 	_17:
  37596 		v6 = libc.Uint32FromInt32(bits - int32(1))
  37597 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37598 		goto _20
  37599 	_20:
  37600 		image_size = libc.Int32FromUint32(v4 * v7)
  37601 		if image_size != int32(1) {
  37602 			break
  37603 		}
  37604 		bits = bits - 1
  37605 	}
  37606 	return bits
  37607 }
  37608 
  37609 func GetHistoBits(tls *libc.TLS, method int32, use_palette int32, width int32, height int32) (r int32) {
  37610 	var histo_bits, v1 int32
  37611 	_, _ = histo_bits, v1
  37612 	if use_palette != 0 {
  37613 		v1 = int32(9)
  37614 	} else {
  37615 		v1 = int32(7)
  37616 	}
  37617 	// Make tile size a function of encoding method (Range: 0 to 6).
  37618 	histo_bits = v1 - method
  37619 	return ClampBits(tls, width, height, histo_bits, int32(MIN_HUFFMAN_BITS), libc.Int32FromInt32(MIN_HUFFMAN_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_HUFFMAN_BITS)-libc.Int32FromInt32(1), int32(MAX_HUFF_IMAGE_SIZE))
  37620 }
  37621 
  37622 func GetTransformBits(tls *libc.TLS, method int32, histo_bits int32) (r int32) {
  37623 	var max_transform_bits, res, v1, v2, v3 int32
  37624 	_, _, _, _, _ = max_transform_bits, res, v1, v2, v3
  37625 	if method < int32(4) {
  37626 		v1 = int32(6)
  37627 	} else {
  37628 		if method > int32(4) {
  37629 			v2 = int32(4)
  37630 		} else {
  37631 			v2 = int32(5)
  37632 		}
  37633 		v1 = v2
  37634 	}
  37635 	max_transform_bits = v1
  37636 	if histo_bits > max_transform_bits {
  37637 		v3 = max_transform_bits
  37638 	} else {
  37639 		v3 = histo_bits
  37640 	}
  37641 	res = v3
  37642 	return res
  37643 }
  37644 
  37645 // C documentation
  37646 //
  37647 //	// Set of parameters to be used in each iteration of the cruncher.
  37648 type CrunchSubConfig = struct {
  37649 	Flz77        int32
  37650 	Fdo_no_cache int32
  37651 }
  37652 
  37653 type CrunchConfig = struct {
  37654 	Fentropy_idx          int32
  37655 	Fpalette_sorting_type PaletteSorting1
  37656 	Fsub_configs          [2]CrunchSubConfig
  37657 	Fsub_configs_size     int32
  37658 }
  37659 
  37660 // +2 because we add a palette sorting configuration for kPalette and
  37661 // kPaletteAndSpatial.
  37662 
  37663 func EncoderAnalyze(tls *libc.TLS, enc uintptr, crunch_configs uintptr, crunch_configs_size uintptr, red_and_blue_always_zero uintptr) (r int32) {
  37664 	bp := tls.Alloc(16)
  37665 	defer tls.Free(16)
  37666 	var config, pic uintptr
  37667 	var do_no_cache, height, i, j, low_effort, method, n_lz77s, sorting_method, transform_bits, use_palette, width, v1 int32
  37668 	var typed_sorting_method PaletteSorting1
  37669 	var _ /* min_entropy_ix at bp+0 */ EntropyIx
  37670 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = config, do_no_cache, height, i, j, low_effort, method, n_lz77s, pic, sorting_method, transform_bits, typed_sorting_method, use_palette, width, v1
  37671 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  37672 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  37673 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  37674 	config = (*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig
  37675 	method = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  37676 	low_effort = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Fmethod == libc.Int32FromInt32(0))
  37677 	// If set to 0, analyze the cache with the computed cache value. If 1, also
  37678 	// analyze with no-cache.
  37679 	do_no_cache = 0
  37680 	// Check whether a palette is possible.
  37681 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size = GetColorPalette(tls, pic, enc+1128)
  37682 	use_palette = libc.BoolInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size <= int32(MAX_PALETTE_SIZE))
  37683 	if !(use_palette != 0) {
  37684 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size = 0
  37685 	}
  37686 	// Empirical bit sizes.
  37687 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits = GetHistoBits(tls, method, use_palette, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, (*WebPPicture)(unsafe.Pointer(pic)).Fheight)
  37688 	transform_bits = GetTransformBits(tls, method, (*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits)
  37689 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpredictor_transform_bits = transform_bits
  37690 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fcross_color_transform_bits = transform_bits
  37691 	if low_effort != 0 {
  37692 		// AnalyzeEntropy is somewhat slow.
  37693 		if use_palette != 0 {
  37694 			v1 = int32(kPalette)
  37695 		} else {
  37696 			v1 = int32(kSpatialSubGreen)
  37697 		}
  37698 		(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fentropy_idx = v1
  37699 		if use_palette != 0 {
  37700 			v1 = int32(kSortedDefault)
  37701 		} else {
  37702 			v1 = int32(kUnusedPalette)
  37703 		}
  37704 		(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fpalette_sorting_type = v1
  37705 		n_lz77s = int32(1)
  37706 		**(**int32)(__ccgo_up(crunch_configs_size)) = int32(1)
  37707 	} else {
  37708 		// Try out multiple LZ77 on images with few colors.
  37709 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size > 0 && (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size <= int32(16) {
  37710 			v1 = int32(2)
  37711 		} else {
  37712 			v1 = int32(1)
  37713 		}
  37714 		n_lz77s = v1
  37715 		if !(AnalyzeEntropy(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb, width, height, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride, use_palette, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size, transform_bits, bp, red_and_blue_always_zero) != 0) {
  37716 			return 0
  37717 		}
  37718 		if method == int32(6) && (*WebPConfig)(unsafe.Pointer(config)).Fquality == libc.Float32FromInt32(100) {
  37719 			do_no_cache = int32(1)
  37720 			// Go brute force on all transforms.
  37721 			**(**int32)(__ccgo_up(crunch_configs_size)) = 0
  37722 			i = 0
  37723 			for {
  37724 				if !(i < int32(kNumEntropyIx)) {
  37725 					break
  37726 				}
  37727 				// We can only apply kPalette or kPaletteAndSpatial if we can indeed use
  37728 				// a palette.
  37729 				if i != int32(kPalette) && i != int32(kPaletteAndSpatial) || use_palette != 0 {
  37730 					if use_palette != 0 && (i == int32(kPalette) || i == int32(kPaletteAndSpatial)) {
  37731 						sorting_method = 0
  37732 						for {
  37733 							if !(sorting_method < int32(kPaletteSortingNum)) {
  37734 								break
  37735 							}
  37736 							typed_sorting_method = sorting_method
  37737 							// TODO(vrabaud) kSortedDefault should be tested. It is omitted
  37738 							// for now for backward compatibility.
  37739 							if typed_sorting_method == int32(kUnusedPalette) || typed_sorting_method == int32(kSortedDefault) {
  37740 								goto _5
  37741 							}
  37742 							(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fentropy_idx = i
  37743 							(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fpalette_sorting_type = typed_sorting_method
  37744 							**(**int32)(__ccgo_up(crunch_configs_size)) = **(**int32)(__ccgo_up(crunch_configs_size)) + 1
  37745 							goto _5
  37746 						_5:
  37747 							;
  37748 							sorting_method = sorting_method + 1
  37749 						}
  37750 					} else {
  37751 						(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fentropy_idx = i
  37752 						(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fpalette_sorting_type = int32(kUnusedPalette)
  37753 						**(**int32)(__ccgo_up(crunch_configs_size)) = **(**int32)(__ccgo_up(crunch_configs_size)) + 1
  37754 					}
  37755 				}
  37756 				goto _4
  37757 			_4:
  37758 				;
  37759 				i = i + 1
  37760 			}
  37761 		} else {
  37762 			// Only choose the guessed best transform.
  37763 			**(**int32)(__ccgo_up(crunch_configs_size)) = int32(1)
  37764 			(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fentropy_idx = **(**EntropyIx)(__ccgo_up(bp))
  37765 			if use_palette != 0 {
  37766 				v1 = int32(kMinimizeDelta)
  37767 			} else {
  37768 				v1 = int32(kUnusedPalette)
  37769 			}
  37770 			(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fpalette_sorting_type = v1
  37771 			if (*WebPConfig)(unsafe.Pointer(config)).Fquality >= libc.Float32FromInt32(75) && method == int32(5) {
  37772 				// Test with and without color cache.
  37773 				do_no_cache = int32(1)
  37774 				// If we have a palette, also check in combination with spatial.
  37775 				if **(**EntropyIx)(__ccgo_up(bp)) == int32(kPalette) {
  37776 					**(**int32)(__ccgo_up(crunch_configs_size)) = int32(2)
  37777 					(**(**CrunchConfig)(__ccgo_up(crunch_configs + 1*28))).Fentropy_idx = int32(kPaletteAndSpatial)
  37778 					(**(**CrunchConfig)(__ccgo_up(crunch_configs + 1*28))).Fpalette_sorting_type = int32(kMinimizeDelta)
  37779 				}
  37780 			}
  37781 		}
  37782 	}
  37783 	// Fill in the different LZ77s.
  37784 	i = 0
  37785 	for {
  37786 		if !(i < **(**int32)(__ccgo_up(crunch_configs_size))) {
  37787 			break
  37788 		}
  37789 		j = 0
  37790 		for {
  37791 			if !(j < n_lz77s) {
  37792 				break
  37793 			}
  37794 			if j == 0 {
  37795 				v1 = int32(kLZ77Standard) | int32(kLZ77RLE)
  37796 			} else {
  37797 				v1 = int32(kLZ77Box)
  37798 			}
  37799 			(**(**CrunchSubConfig)(__ccgo_up(crunch_configs + uintptr(i)*28 + 8 + uintptr(j)*8))).Flz77 = v1
  37800 			(**(**CrunchSubConfig)(__ccgo_up(crunch_configs + uintptr(i)*28 + 8 + uintptr(j)*8))).Fdo_no_cache = do_no_cache
  37801 			goto _8
  37802 		_8:
  37803 			;
  37804 			j = j + 1
  37805 		}
  37806 		(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(i)*28))).Fsub_configs_size = n_lz77s
  37807 		goto _7
  37808 	_7:
  37809 		;
  37810 		i = i + 1
  37811 	}
  37812 	return int32(1)
  37813 }
  37814 
  37815 func EncoderInit(tls *libc.TLS, enc uintptr) (r int32) {
  37816 	var height, i, pix_cnt, refs_block_size, width int32
  37817 	var pic uintptr
  37818 	_, _, _, _, _, _ = height, i, pic, pix_cnt, refs_block_size, width
  37819 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  37820 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  37821 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  37822 	pix_cnt = width * height
  37823 	// we round the block size up, so we're guaranteed to have
  37824 	// at most MAX_REFS_BLOCK_PER_IMAGE blocks used:
  37825 	refs_block_size = (pix_cnt-int32(1))/int32(MAX_REFS_BLOCK_PER_IMAGE) + int32(1)
  37826 	if !(VP8LHashChainInit(tls, enc+2312, pix_cnt) != 0) {
  37827 		return 0
  37828 	}
  37829 	i = 0
  37830 	for {
  37831 		if !(i < int32(4)) {
  37832 			break
  37833 		}
  37834 		VP8LBackwardRefsInit(tls, enc+2152+uintptr(i)*40, refs_block_size)
  37835 		goto _1
  37836 	_1:
  37837 		;
  37838 		i = i + 1
  37839 	}
  37840 	return int32(1)
  37841 }
  37842 
  37843 // C documentation
  37844 //
  37845 //	// Returns false in case of memory error.
  37846 func GetHuffBitLengthsAndCodes(tls *libc.TLS, histogram_image uintptr, huffman_codes uintptr) (r int32) {
  37847 	var bit_length, histogram_image_size, i, k, max_num_symbols, num_symbols, ok, v3, v4, v5, v7, v8 int32
  37848 	var buf_rle, codes, codes1, codes2, histo, histo1, huff_tree, lengths, mem_buf uintptr
  37849 	var total_length_size uint64_t
  37850 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit_length, buf_rle, codes, codes1, codes2, histo, histo1, histogram_image_size, huff_tree, i, k, lengths, max_num_symbols, mem_buf, num_symbols, ok, total_length_size, v3, v4, v5, v7, v8
  37851 	ok = 0
  37852 	total_length_size = uint64(0)
  37853 	mem_buf = libc.UintptrFromInt32(0)
  37854 	histogram_image_size = (*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fsize
  37855 	max_num_symbols = 0
  37856 	buf_rle = libc.UintptrFromInt32(0)
  37857 	huff_tree = libc.UintptrFromInt32(0)
  37858 	// Iterate over all histograms and get the aggregate number of codes used.
  37859 	i = 0
  37860 	for {
  37861 		if !(i < histogram_image_size) {
  37862 			break
  37863 		}
  37864 		histo = **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms + uintptr(i)*8))
  37865 		codes = huffman_codes + uintptr(int32(5)*i)*24
  37866 		k = 0
  37867 		for {
  37868 			if !(k < int32(5)) {
  37869 				break
  37870 			}
  37871 			if k == 0 {
  37872 				v4 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  37873 				if v4 > 0 {
  37874 					v7 = int32(1) << v4
  37875 				} else {
  37876 					v7 = 0
  37877 				}
  37878 				v5 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v7
  37879 				goto _6
  37880 			_6:
  37881 				v3 = v5
  37882 			} else {
  37883 				if k == int32(4) {
  37884 					v8 = int32(NUM_DISTANCE_CODES)
  37885 				} else {
  37886 					v8 = int32(256)
  37887 				}
  37888 				v3 = v8
  37889 			}
  37890 			num_symbols = v3
  37891 			(**(**HuffmanTreeCode)(__ccgo_up(codes + uintptr(k)*24))).Fnum_symbols = num_symbols
  37892 			total_length_size = total_length_size + libc.Uint64FromInt32(num_symbols)
  37893 			goto _2
  37894 		_2:
  37895 			;
  37896 			k = k + 1
  37897 		}
  37898 		goto _1
  37899 	_1:
  37900 		;
  37901 		i = i + 1
  37902 	}
  37903 	// Allocate and Set Huffman codes.
  37904 	mem_buf = WebPSafeCalloc(tls, total_length_size, libc.Uint64FromInt64(1)+libc.Uint64FromInt64(2))
  37905 	if mem_buf == libc.UintptrFromInt32(0) {
  37906 		goto End
  37907 	}
  37908 	codes1 = mem_buf
  37909 	lengths = codes1 + uintptr(total_length_size)*2
  37910 	i = 0
  37911 	for {
  37912 		if !(i < int32(5)*histogram_image_size) {
  37913 			break
  37914 		}
  37915 		bit_length = (**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fnum_symbols
  37916 		(**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fcodes = codes1
  37917 		(**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fcode_lengths = lengths
  37918 		codes1 = codes1 + uintptr(bit_length)*2
  37919 		lengths = lengths + uintptr(bit_length)
  37920 		if max_num_symbols < bit_length {
  37921 			max_num_symbols = bit_length
  37922 		}
  37923 		goto _9
  37924 	_9:
  37925 		;
  37926 		i = i + 1
  37927 	}
  37928 	buf_rle = WebPSafeMalloc(tls, uint64(1), libc.Uint64FromInt32(max_num_symbols))
  37929 	huff_tree = WebPSafeMalloc(tls, uint64(3)*libc.Uint64FromInt32(max_num_symbols), uint64(16))
  37930 	if buf_rle == libc.UintptrFromInt32(0) || huff_tree == libc.UintptrFromInt32(0) {
  37931 		goto End
  37932 	}
  37933 	// Create Huffman trees.
  37934 	i = 0
  37935 	for {
  37936 		if !(i < histogram_image_size) {
  37937 			break
  37938 		}
  37939 		codes2 = huffman_codes + uintptr(int32(5)*i)*24
  37940 		histo1 = **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms + uintptr(i)*8))
  37941 		VP8LCreateHuffmanTree(tls, (*VP8LHistogram)(unsafe.Pointer(histo1)).Fliteral, int32(15), buf_rle, huff_tree, codes2+uintptr(0)*24)
  37942 		VP8LCreateHuffmanTree(tls, histo1+8, int32(15), buf_rle, huff_tree, codes2+uintptr(1)*24)
  37943 		VP8LCreateHuffmanTree(tls, histo1+1032, int32(15), buf_rle, huff_tree, codes2+uintptr(2)*24)
  37944 		VP8LCreateHuffmanTree(tls, histo1+2056, int32(15), buf_rle, huff_tree, codes2+uintptr(3)*24)
  37945 		VP8LCreateHuffmanTree(tls, histo1+3080, int32(15), buf_rle, huff_tree, codes2+uintptr(4)*24)
  37946 		goto _10
  37947 	_10:
  37948 		;
  37949 		i = i + 1
  37950 	}
  37951 	ok = int32(1)
  37952 	goto End
  37953 End:
  37954 	;
  37955 	WebPSafeFree(tls, huff_tree)
  37956 	WebPSafeFree(tls, buf_rle)
  37957 	if !(ok != 0) {
  37958 		WebPSafeFree(tls, mem_buf)
  37959 		libc.X__builtin___memset_chk(tls, huffman_codes, 0, libc.Uint64FromInt32(int32(5)*histogram_image_size)*uint64(24), ^__predefined_size_t(0))
  37960 	}
  37961 	return ok
  37962 }
  37963 
  37964 func StoreHuffmanTreeOfHuffmanTreeToBitMask(tls *libc.TLS, bw1 uintptr, code_length_bitdepth uintptr) {
  37965 	var codes_to_store, i, v4 int32
  37966 	var v2 uintptr
  37967 	var v3 uint32_t
  37968 	_, _, _, _, _ = codes_to_store, i, v2, v3, v4
  37969 	// Throw away trailing zeros:
  37970 	codes_to_store = int32(CODE_LENGTH_CODES)
  37971 	for {
  37972 		if !(codes_to_store > int32(4)) {
  37973 			break
  37974 		}
  37975 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(code_length_bitdepth + uintptr(kStorageOrder[codes_to_store-int32(1)])))) != 0 {
  37976 			break
  37977 		}
  37978 		goto _1
  37979 	_1:
  37980 		;
  37981 		codes_to_store = codes_to_store - 1
  37982 	}
  37983 	v2 = bw1
  37984 	v3 = libc.Uint32FromInt32(codes_to_store - int32(4))
  37985 	v4 = int32(4)
  37986 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  37987 		if v4 > libc.Int32FromInt32(0) {
  37988 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  37989 				VP8LPutBitsFlushBits(tls, v2)
  37990 			}
  37991 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  37992 			**(**int32)(__ccgo_up(v2 + 8)) += v4
  37993 		}
  37994 	} else {
  37995 		VP8LPutBitsInternal(tls, v2, v3, v4)
  37996 	}
  37997 	i = 0
  37998 	for {
  37999 		if !(i < codes_to_store) {
  38000 			break
  38001 		}
  38002 		v2 = bw1
  38003 		v3 = uint32(**(**uint8_t)(__ccgo_up(code_length_bitdepth + uintptr(kStorageOrder[i]))))
  38004 		v4 = int32(3)
  38005 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38006 			if v4 > libc.Int32FromInt32(0) {
  38007 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38008 					VP8LPutBitsFlushBits(tls, v2)
  38009 				}
  38010 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38011 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38012 			}
  38013 		} else {
  38014 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38015 		}
  38016 		goto _5
  38017 	_5:
  38018 		;
  38019 		i = i + 1
  38020 	}
  38021 }
  38022 
  38023 // RFC 1951 will calm you down if you are worried about this funny sequence.
  38024 // This sequence is tuned from that, but more weighted for lower symbol count,
  38025 // and more spiking histograms.
  38026 var kStorageOrder = [19]uint8_t{
  38027 	0:  uint8(17),
  38028 	1:  uint8(18),
  38029 	3:  uint8(1),
  38030 	4:  uint8(2),
  38031 	5:  uint8(3),
  38032 	6:  uint8(4),
  38033 	7:  uint8(5),
  38034 	8:  uint8(16),
  38035 	9:  uint8(6),
  38036 	10: uint8(7),
  38037 	11: uint8(8),
  38038 	12: uint8(9),
  38039 	13: uint8(10),
  38040 	14: uint8(11),
  38041 	15: uint8(12),
  38042 	16: uint8(13),
  38043 	17: uint8(14),
  38044 	18: uint8(15),
  38045 }
  38046 
  38047 func ClearHuffmanTreeIfOnlyOneSymbol(tls *libc.TLS, huffman_code uintptr) {
  38048 	var count, k int32
  38049 	_, _ = count, k
  38050 	count = 0
  38051 	k = 0
  38052 	for {
  38053 		if !(k < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols) {
  38054 			break
  38055 		}
  38056 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(k)))) != 0 {
  38057 			count = count + 1
  38058 			if count > int32(1) {
  38059 				return
  38060 			}
  38061 		}
  38062 		goto _1
  38063 	_1:
  38064 		;
  38065 		k = k + 1
  38066 	}
  38067 	k = 0
  38068 	for {
  38069 		if !(k < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols) {
  38070 			break
  38071 		}
  38072 		**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(k))) = uint8(0)
  38073 		**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcodes + uintptr(k)*2)) = uint16(0)
  38074 		goto _2
  38075 	_2:
  38076 		;
  38077 		k = k + 1
  38078 	}
  38079 }
  38080 
  38081 func StoreHuffmanTreeToBitMask(tls *libc.TLS, bw1 uintptr, tokens uintptr, num_tokens int32, huffman_code uintptr) {
  38082 	var extra_bits, i, ix, v4 int32
  38083 	var v2 uintptr
  38084 	var v3 uint32_t
  38085 	_, _, _, _, _, _ = extra_bits, i, ix, v2, v3, v4
  38086 	i = 0
  38087 	for {
  38088 		if !(i < num_tokens) {
  38089 			break
  38090 		}
  38091 		ix = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fcode)
  38092 		extra_bits = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fextra_bits)
  38093 		v2 = bw1
  38094 		v3 = uint32(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcodes + uintptr(ix)*2)))
  38095 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(ix))))
  38096 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38097 			if v4 > libc.Int32FromInt32(0) {
  38098 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38099 					VP8LPutBitsFlushBits(tls, v2)
  38100 				}
  38101 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38102 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38103 			}
  38104 		} else {
  38105 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38106 		}
  38107 		switch ix {
  38108 		case int32(16):
  38109 			v2 = bw1
  38110 			v3 = libc.Uint32FromInt32(extra_bits)
  38111 			v4 = int32(2)
  38112 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38113 				if v4 > libc.Int32FromInt32(0) {
  38114 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38115 						VP8LPutBitsFlushBits(tls, v2)
  38116 					}
  38117 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38118 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38119 				}
  38120 			} else {
  38121 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38122 			}
  38123 		case int32(17):
  38124 			v2 = bw1
  38125 			v3 = libc.Uint32FromInt32(extra_bits)
  38126 			v4 = int32(3)
  38127 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38128 				if v4 > libc.Int32FromInt32(0) {
  38129 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38130 						VP8LPutBitsFlushBits(tls, v2)
  38131 					}
  38132 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38133 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38134 				}
  38135 			} else {
  38136 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38137 			}
  38138 		case int32(18):
  38139 			v2 = bw1
  38140 			v3 = libc.Uint32FromInt32(extra_bits)
  38141 			v4 = int32(7)
  38142 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38143 				if v4 > libc.Int32FromInt32(0) {
  38144 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38145 						VP8LPutBitsFlushBits(tls, v2)
  38146 					}
  38147 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38148 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38149 				}
  38150 			} else {
  38151 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38152 			}
  38153 			break
  38154 		}
  38155 		goto _1
  38156 	_1:
  38157 		;
  38158 		i = i + 1
  38159 	}
  38160 }
  38161 
  38162 // C documentation
  38163 //
  38164 //	// 'huff_tree' and 'tokens' are pre-alloacted buffers.
  38165 func StoreFullHuffmanCode(tls *libc.TLS, bw1 uintptr, huff_tree uintptr, tokens uintptr, tree uintptr) {
  38166 	bp := tls.Alloc(192)
  38167 	defer tls.Free(192)
  38168 	var i, i1, ix, length, max_tokens, nbitpairs, nbits, num_tokens, trailing_zero_bits, trimmed_length, write_trimmed_length, v3 int32
  38169 	var v1 uintptr
  38170 	var v2 uint32_t
  38171 	var _ /* buf_rle at bp+164 */ [19]uint8_t
  38172 	var _ /* code_length_bitdepth at bp+0 */ [19]uint8_t
  38173 	var _ /* code_length_bitdepth_symbols at bp+20 */ [19]uint16_t
  38174 	var _ /* histogram at bp+88 */ [19]uint32_t
  38175 	var _ /* huffman_code at bp+64 */ HuffmanTreeCode
  38176 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, i1, ix, length, max_tokens, nbitpairs, nbits, num_tokens, trailing_zero_bits, trimmed_length, write_trimmed_length, v1, v2, v3
  38177 	**(**[19]uint8_t)(__ccgo_up(bp)) = [19]uint8_t{}
  38178 	**(**[19]uint16_t)(__ccgo_up(bp + 20)) = [19]uint16_t{}
  38179 	max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  38180 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fnum_symbols = int32(CODE_LENGTH_CODES)
  38181 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fcode_lengths = bp
  38182 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fcodes = bp + 20
  38183 	v1 = bw1
  38184 	v2 = uint32(0)
  38185 	v3 = int32(1)
  38186 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38187 		if v3 > libc.Int32FromInt32(0) {
  38188 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38189 				VP8LPutBitsFlushBits(tls, v1)
  38190 			}
  38191 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38192 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38193 		}
  38194 	} else {
  38195 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38196 	}
  38197 	num_tokens = VP8LCreateCompressedHuffmanTree(tls, tree, tokens, max_tokens)
  38198 	**(**[19]uint32_t)(__ccgo_up(bp + 88)) = [19]uint32_t{}
  38199 	**(**[19]uint8_t)(__ccgo_up(bp + 164)) = [19]uint8_t{}
  38200 	i = 0
  38201 	for {
  38202 		if !(i < num_tokens) {
  38203 			break
  38204 		}
  38205 		(**(**[19]uint32_t)(__ccgo_up(bp + 88)))[(**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fcode] = (**(**[19]uint32_t)(__ccgo_up(bp + 88)))[(**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fcode] + 1
  38206 		goto _4
  38207 	_4:
  38208 		;
  38209 		i = i + 1
  38210 	}
  38211 	VP8LCreateHuffmanTree(tls, bp+88, int32(7), bp+164, huff_tree, bp+64)
  38212 	StoreHuffmanTreeOfHuffmanTreeToBitMask(tls, bw1, bp)
  38213 	ClearHuffmanTreeIfOnlyOneSymbol(tls, bp+64)
  38214 	trailing_zero_bits = 0
  38215 	trimmed_length = num_tokens
  38216 	i1 = num_tokens
  38217 	for {
  38218 		v3 = i1
  38219 		i1 = i1 - 1
  38220 		if !(v3 > 0) {
  38221 			break
  38222 		}
  38223 		ix = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i1)*2))).Fcode)
  38224 		if ix == 0 || ix == int32(17) || ix == int32(18) {
  38225 			trimmed_length = trimmed_length - 1 // discount trailing zeros
  38226 			trailing_zero_bits = trailing_zero_bits + libc.Int32FromUint8((**(**[19]uint8_t)(__ccgo_up(bp)))[ix])
  38227 			if ix == int32(17) {
  38228 				trailing_zero_bits = trailing_zero_bits + int32(3)
  38229 			} else {
  38230 				if ix == int32(18) {
  38231 					trailing_zero_bits = trailing_zero_bits + int32(7)
  38232 				}
  38233 			}
  38234 		} else {
  38235 			break
  38236 		}
  38237 	}
  38238 	write_trimmed_length = libc.BoolInt32(trimmed_length > int32(1) && trailing_zero_bits > int32(12))
  38239 	if write_trimmed_length != 0 {
  38240 		v3 = trimmed_length
  38241 	} else {
  38242 		v3 = num_tokens
  38243 	}
  38244 	length = v3
  38245 	v1 = bw1
  38246 	v2 = libc.Uint32FromInt32(write_trimmed_length)
  38247 	v3 = int32(1)
  38248 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38249 		if v3 > libc.Int32FromInt32(0) {
  38250 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38251 				VP8LPutBitsFlushBits(tls, v1)
  38252 			}
  38253 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38254 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38255 		}
  38256 	} else {
  38257 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38258 	}
  38259 	if write_trimmed_length != 0 {
  38260 		if trimmed_length == int32(2) {
  38261 			v1 = bw1
  38262 			v2 = uint32(0)
  38263 			v3 = libc.Int32FromInt32(3) + libc.Int32FromInt32(2)
  38264 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38265 				if v3 > libc.Int32FromInt32(0) {
  38266 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38267 						VP8LPutBitsFlushBits(tls, v1)
  38268 					}
  38269 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38270 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38271 				}
  38272 			} else {
  38273 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38274 			} // nbitpairs=1, trimmed_length=2
  38275 		} else {
  38276 			v3 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(trimmed_length-int32(2)))
  38277 			goto _14
  38278 		_14:
  38279 			nbits = v3
  38280 			nbitpairs = nbits/int32(2) + int32(1)
  38281 			v1 = bw1
  38282 			v2 = libc.Uint32FromInt32(nbitpairs - int32(1))
  38283 			v3 = int32(3)
  38284 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38285 				if v3 > libc.Int32FromInt32(0) {
  38286 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38287 						VP8LPutBitsFlushBits(tls, v1)
  38288 					}
  38289 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38290 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38291 				}
  38292 			} else {
  38293 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38294 			}
  38295 			v1 = bw1
  38296 			v2 = libc.Uint32FromInt32(trimmed_length - int32(2))
  38297 			v3 = nbitpairs * int32(2)
  38298 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38299 				if v3 > libc.Int32FromInt32(0) {
  38300 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38301 						VP8LPutBitsFlushBits(tls, v1)
  38302 					}
  38303 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38304 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38305 				}
  38306 			} else {
  38307 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38308 			}
  38309 		}
  38310 	}
  38311 	StoreHuffmanTreeToBitMask(tls, bw1, tokens, length, bp+64)
  38312 }
  38313 
  38314 // C documentation
  38315 //
  38316 //	// 'huff_tree' and 'tokens' are pre-alloacted buffers.
  38317 func StoreHuffmanCode(tls *libc.TLS, bw1 uintptr, huff_tree uintptr, tokens uintptr, huffman_code uintptr) {
  38318 	var count, i, kMaxBits, kMaxSymbol, v4 int32
  38319 	var symbols [2]int32
  38320 	var v2 uintptr
  38321 	var v3 uint32_t
  38322 	_, _, _, _, _, _, _, _ = count, i, kMaxBits, kMaxSymbol, symbols, v2, v3, v4
  38323 	count = 0
  38324 	symbols = [2]int32{}
  38325 	kMaxBits = int32(8)
  38326 	kMaxSymbol = int32(1) << kMaxBits
  38327 	// Check whether it's a small tree.
  38328 	i = 0
  38329 	for {
  38330 		if !(i < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols && count < int32(3)) {
  38331 			break
  38332 		}
  38333 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(i)))) != 0 {
  38334 			if count < int32(2) {
  38335 				symbols[count] = i
  38336 			}
  38337 			count = count + 1
  38338 		}
  38339 		goto _1
  38340 	_1:
  38341 		;
  38342 		i = i + 1
  38343 	}
  38344 	if count == 0 { // emit minimal tree for empty cases
  38345 		// bits: small tree marker: 1, count-1: 0, large 8-bit code: 0, code: 0
  38346 		v2 = bw1
  38347 		v3 = uint32(0x01)
  38348 		v4 = int32(4)
  38349 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38350 			if v4 > libc.Int32FromInt32(0) {
  38351 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38352 					VP8LPutBitsFlushBits(tls, v2)
  38353 				}
  38354 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38355 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38356 			}
  38357 		} else {
  38358 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38359 		}
  38360 	} else {
  38361 		if count <= int32(2) && symbols[0] < kMaxSymbol && symbols[int32(1)] < kMaxSymbol {
  38362 			v2 = bw1
  38363 			v3 = uint32(1)
  38364 			v4 = int32(1)
  38365 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38366 				if v4 > libc.Int32FromInt32(0) {
  38367 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38368 						VP8LPutBitsFlushBits(tls, v2)
  38369 					}
  38370 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38371 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38372 				}
  38373 			} else {
  38374 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38375 			} // Small tree marker to encode 1 or 2 symbols.
  38376 			v2 = bw1
  38377 			v3 = libc.Uint32FromInt32(count - int32(1))
  38378 			v4 = int32(1)
  38379 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38380 				if v4 > libc.Int32FromInt32(0) {
  38381 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38382 						VP8LPutBitsFlushBits(tls, v2)
  38383 					}
  38384 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38385 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38386 				}
  38387 			} else {
  38388 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38389 			}
  38390 			if symbols[0] <= int32(1) {
  38391 				v2 = bw1
  38392 				v3 = uint32(0)
  38393 				v4 = int32(1)
  38394 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38395 					if v4 > libc.Int32FromInt32(0) {
  38396 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38397 							VP8LPutBitsFlushBits(tls, v2)
  38398 						}
  38399 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38400 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38401 					}
  38402 				} else {
  38403 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38404 				} // Code bit for small (1 bit) symbol value.
  38405 				v2 = bw1
  38406 				v3 = libc.Uint32FromInt32(symbols[0])
  38407 				v4 = int32(1)
  38408 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38409 					if v4 > libc.Int32FromInt32(0) {
  38410 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38411 							VP8LPutBitsFlushBits(tls, v2)
  38412 						}
  38413 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38414 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38415 					}
  38416 				} else {
  38417 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38418 				}
  38419 			} else {
  38420 				v2 = bw1
  38421 				v3 = uint32(1)
  38422 				v4 = int32(1)
  38423 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38424 					if v4 > libc.Int32FromInt32(0) {
  38425 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38426 							VP8LPutBitsFlushBits(tls, v2)
  38427 						}
  38428 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38429 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38430 					}
  38431 				} else {
  38432 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38433 				}
  38434 				v2 = bw1
  38435 				v3 = libc.Uint32FromInt32(symbols[0])
  38436 				v4 = int32(8)
  38437 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38438 					if v4 > libc.Int32FromInt32(0) {
  38439 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38440 							VP8LPutBitsFlushBits(tls, v2)
  38441 						}
  38442 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38443 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38444 					}
  38445 				} else {
  38446 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38447 				}
  38448 			}
  38449 			if count == int32(2) {
  38450 				v2 = bw1
  38451 				v3 = libc.Uint32FromInt32(symbols[int32(1)])
  38452 				v4 = int32(8)
  38453 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38454 					if v4 > libc.Int32FromInt32(0) {
  38455 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38456 							VP8LPutBitsFlushBits(tls, v2)
  38457 						}
  38458 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38459 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38460 					}
  38461 				} else {
  38462 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38463 				}
  38464 			}
  38465 		} else {
  38466 			StoreFullHuffmanCode(tls, bw1, huff_tree, tokens, huffman_code)
  38467 		}
  38468 	}
  38469 }
  38470 
  38471 func WriteHuffmanCode(tls *libc.TLS, bw1 uintptr, code uintptr, code_index int32) {
  38472 	var depth, symbol, v3 int32
  38473 	var v1 uintptr
  38474 	var v2 uint32_t
  38475 	_, _, _, _, _ = depth, symbol, v1, v2, v3
  38476 	depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcode_lengths + uintptr(code_index))))
  38477 	symbol = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcodes + uintptr(code_index)*2)))
  38478 	v1 = bw1
  38479 	v2 = libc.Uint32FromInt32(symbol)
  38480 	v3 = depth
  38481 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38482 		if v3 > libc.Int32FromInt32(0) {
  38483 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38484 				VP8LPutBitsFlushBits(tls, v1)
  38485 			}
  38486 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38487 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38488 		}
  38489 	} else {
  38490 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38491 	}
  38492 }
  38493 
  38494 func WriteHuffmanCodeWithExtraBits(tls *libc.TLS, bw1 uintptr, code uintptr, code_index int32, bits1 int32, n_bits1 int32) {
  38495 	var depth, symbol, v3 int32
  38496 	var v1 uintptr
  38497 	var v2 uint32_t
  38498 	_, _, _, _, _ = depth, symbol, v1, v2, v3
  38499 	depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcode_lengths + uintptr(code_index))))
  38500 	symbol = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcodes + uintptr(code_index)*2)))
  38501 	v1 = bw1
  38502 	v2 = libc.Uint32FromInt32(bits1<<depth | symbol)
  38503 	v3 = depth + n_bits1
  38504 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38505 		if v3 > libc.Int32FromInt32(0) {
  38506 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38507 				VP8LPutBitsFlushBits(tls, v1)
  38508 			}
  38509 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38510 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38511 		}
  38512 	} else {
  38513 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38514 	}
  38515 }
  38516 
  38517 func StoreImageToBitMask(tls *libc.TLS, bw1 uintptr, width int32, histo_bits int32, refs uintptr, histogram_symbols uintptr, huffman_codes uintptr, pic uintptr) (r int32) {
  38518 	bp := tls.Alloc(48)
  38519 	defer tls.Free(48)
  38520 	var code2, code3, distance2, highest_bit, histo_xsize, histogram_ix, k, literal_ix, second_highest_bit, tile_mask, tile_x, tile_y, x, y, v13, v5, v6, v8 int32
  38521 	var codes, v, v20, v21, v22, v24 uintptr
  38522 	var prefix_code VP8LPrefixCode
  38523 	var v1 uint32
  38524 	var v2, v3 uint32_t
  38525 	var _ /* bits at bp+24 */ int32
  38526 	var _ /* c at bp+0 */ VP8LRefsCursor
  38527 	var _ /* code at bp+32 */ int32
  38528 	var _ /* n_bits at bp+28 */ int32
  38529 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = code2, code3, codes, distance2, highest_bit, histo_xsize, histogram_ix, k, literal_ix, prefix_code, second_highest_bit, tile_mask, tile_x, tile_y, v, x, y, v1, v13, v2, v20, v21, v22, v24, v3, v5, v6, v8
  38530 	if histo_bits != 0 {
  38531 		v2 = libc.Uint32FromInt32(histo_bits)
  38532 		v3 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  38533 		goto _4
  38534 	_4:
  38535 		v1 = v3
  38536 	} else {
  38537 		v1 = uint32(1)
  38538 	}
  38539 	histo_xsize = libc.Int32FromUint32(v1)
  38540 	if histo_bits == 0 {
  38541 		v5 = 0
  38542 	} else {
  38543 		v5 = -(int32(1) << histo_bits)
  38544 	}
  38545 	tile_mask = v5
  38546 	// x and y trace the position in the image.
  38547 	x = 0
  38548 	y = 0
  38549 	tile_x = x & tile_mask
  38550 	tile_y = y & tile_mask
  38551 	histogram_ix = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(histogram_symbols)) >> libc.Int32FromInt32(8) & uint32(0xffff))
  38552 	codes = huffman_codes + uintptr(int32(5)*histogram_ix)*24
  38553 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  38554 	for {
  38555 		v6 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  38556 		goto _7
  38557 	_7:
  38558 		if !(v6 != 0) {
  38559 			break
  38560 		}
  38561 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos
  38562 		if tile_x != x&tile_mask || tile_y != y&tile_mask {
  38563 			tile_x = x & tile_mask
  38564 			tile_y = y & tile_mask
  38565 			histogram_ix = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(histogram_symbols + uintptr(y>>histo_bits*histo_xsize+x>>histo_bits)*4)) >> libc.Int32FromInt32(8) & uint32(0xffff))
  38566 			codes = huffman_codes + uintptr(int32(5)*histogram_ix)*24
  38567 		}
  38568 		v5 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  38569 		goto _9
  38570 	_9:
  38571 		if v5 != 0 {
  38572 			k = 0
  38573 			for {
  38574 				if !(k < int32(4)) {
  38575 					break
  38576 				}
  38577 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (libc.Int32FromUint8(order[k]) * libc.Int32FromInt32(8)) & uint32(0xff)
  38578 				goto _12
  38579 			_12:
  38580 				code2 = libc.Int32FromUint32(v2)
  38581 				WriteHuffmanCode(tls, bw1, codes+uintptr(k)*24, code2)
  38582 				goto _10
  38583 			_10:
  38584 				;
  38585 				k = k + 1
  38586 			}
  38587 		} else {
  38588 			v5 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kCacheIdx))
  38589 			goto _14
  38590 		_14:
  38591 			if v5 != 0 {
  38592 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  38593 				goto _16
  38594 			_16:
  38595 				code3 = libc.Int32FromUint32(v2)
  38596 				literal_ix = libc.Int32FromInt32(256) + libc.Int32FromInt32(NUM_LENGTH_CODES) + code3
  38597 				WriteHuffmanCode(tls, bw1, codes, literal_ix)
  38598 			} else {
  38599 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  38600 				goto _18
  38601 			_18:
  38602 				distance2 = libc.Int32FromUint32(v2)
  38603 				v5 = libc.Int32FromUint16((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  38604 				v20 = bp + 32
  38605 				v21 = bp + 28
  38606 				v22 = bp + 24
  38607 				if v5 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  38608 					prefix_code = kPrefixEncodeCode[v5]
  38609 					**(**int32)(__ccgo_up(v20)) = int32(prefix_code.Fcode)
  38610 					**(**int32)(__ccgo_up(v21)) = int32(prefix_code.Fextra_bits)
  38611 					**(**int32)(__ccgo_up(v22)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v5])
  38612 				} else {
  38613 					v6 = v5
  38614 					v24 = v21
  38615 					v6 = v6 - 1
  38616 					v8 = v6
  38617 					v13 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v8))
  38618 					goto _27
  38619 				_27:
  38620 					highest_bit = v13
  38621 					second_highest_bit = v6 >> (highest_bit - int32(1)) & int32(1)
  38622 					**(**int32)(__ccgo_up(v24)) = highest_bit - int32(1)
  38623 					**(**int32)(__ccgo_up(v22)) = v6 & (int32(1)<<**(**int32)(__ccgo_up(v24)) - int32(1))
  38624 					**(**int32)(__ccgo_up(v20)) = int32(2)*highest_bit + second_highest_bit
  38625 				}
  38626 				WriteHuffmanCodeWithExtraBits(tls, bw1, codes, int32(256)+**(**int32)(__ccgo_up(bp + 32)), **(**int32)(__ccgo_up(bp + 24)), **(**int32)(__ccgo_up(bp + 28)))
  38627 				// Don't write the distance with the extra bits code since
  38628 				// the distance can be up to 18 bits of extra bits, and the prefix
  38629 				// 15 bits, totaling to 33, and our PutBits only supports up to 32 bits.
  38630 				v5 = distance2
  38631 				v20 = bp + 32
  38632 				v21 = bp + 28
  38633 				v22 = bp + 24
  38634 				if v5 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  38635 					prefix_code = kPrefixEncodeCode[v5]
  38636 					**(**int32)(__ccgo_up(v20)) = int32(prefix_code.Fcode)
  38637 					**(**int32)(__ccgo_up(v21)) = int32(prefix_code.Fextra_bits)
  38638 					**(**int32)(__ccgo_up(v22)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v5])
  38639 				} else {
  38640 					v6 = v5
  38641 					v24 = v21
  38642 					v6 = v6 - 1
  38643 					v8 = v6
  38644 					v13 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v8))
  38645 					goto _36
  38646 				_36:
  38647 					highest_bit = v13
  38648 					second_highest_bit = v6 >> (highest_bit - int32(1)) & int32(1)
  38649 					**(**int32)(__ccgo_up(v24)) = highest_bit - int32(1)
  38650 					**(**int32)(__ccgo_up(v22)) = v6 & (int32(1)<<**(**int32)(__ccgo_up(v24)) - int32(1))
  38651 					**(**int32)(__ccgo_up(v20)) = int32(2)*highest_bit + second_highest_bit
  38652 				}
  38653 				WriteHuffmanCode(tls, bw1, codes+uintptr(4)*24, **(**int32)(__ccgo_up(bp + 32)))
  38654 				v20 = bw1
  38655 				v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 24)))
  38656 				v5 = **(**int32)(__ccgo_up(bp + 28))
  38657 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38658 					if v5 > libc.Int32FromInt32(0) {
  38659 						if (*VP8LBitWriter)(unsafe.Pointer(v20)).Fused >= libc.Int32FromInt32(32) {
  38660 							VP8LPutBitsFlushBits(tls, v20)
  38661 						}
  38662 						**(**vp8l_atype_t)(__ccgo_up(v20)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v20)).Fused
  38663 						**(**int32)(__ccgo_up(v20 + 8)) += v5
  38664 					}
  38665 				} else {
  38666 					VP8LPutBitsInternal(tls, v20, v2, v5)
  38667 				}
  38668 			}
  38669 		}
  38670 		v2 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  38671 		goto _41
  38672 	_41:
  38673 		x = libc.Int32FromUint32(uint32(x) + v2)
  38674 		for x >= width {
  38675 			x = x - width
  38676 			y = y + 1
  38677 		}
  38678 		v20 = bp
  38679 		v22 = v20
  38680 		*(*uintptr)(unsafe.Pointer(v22)) += 8
  38681 		v21 = *(*uintptr)(unsafe.Pointer(v22))
  38682 		if v21 == (*VP8LRefsCursor)(unsafe.Pointer(v20)).Flast_pos {
  38683 			VP8LRefsCursorNextBlock(tls, v20)
  38684 		}
  38685 	}
  38686 	if (*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  38687 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38688 	}
  38689 	return int32(1)
  38690 }
  38691 
  38692 var order = [4]uint8_t{
  38693 	0: uint8(1),
  38694 	1: uint8(2),
  38695 	3: uint8(3),
  38696 }
  38697 
  38698 // C documentation
  38699 //
  38700 //	// Special case of EncodeImageInternal() for cache-bits=0, histo_bits=31.
  38701 //	// pic and percent are for progress.
  38702 func EncodeImageNoHuffman(tls *libc.TLS, bw1 uintptr, argb uintptr, hash_chain uintptr, refs_array uintptr, width int32, height int32, quality int32, low_effort int32, pic uintptr, percent_range int32, percent uintptr) (r int32) {
  38703 	bp := tls.Alloc(128)
  38704 	defer tls.Free(128)
  38705 	var codes, codes1, histogram_image, huff_tree, refs, tokens, v1 uintptr
  38706 	var i, max_tokens, v3 int32
  38707 	var v2 uint32_t
  38708 	var _ /* cache_bits at bp+124 */ int32
  38709 	var _ /* histogram_symbols at bp+120 */ [1]uint32_t
  38710 	var _ /* huffman_codes at bp+0 */ [5]HuffmanTreeCode
  38711 	_, _, _, _, _, _, _, _, _, _, _ = codes, codes1, histogram_image, huff_tree, i, max_tokens, refs, tokens, v1, v2, v3
  38712 	max_tokens = 0
  38713 	tokens = libc.UintptrFromInt32(0)
  38714 	**(**[5]HuffmanTreeCode)(__ccgo_up(bp)) = [5]HuffmanTreeCode{}
  38715 	**(**[1]uint32_t)(__ccgo_up(bp + 120)) = [1]uint32_t{} // only one tree, one symbol
  38716 	**(**int32)(__ccgo_up(bp + 124)) = 0
  38717 	histogram_image = libc.UintptrFromInt32(0)
  38718 	huff_tree = WebPSafeMalloc(tls, libc.Uint64FromUint64(3)*libc.Uint64FromInt32(CODE_LENGTH_CODES), uint64(16))
  38719 	if huff_tree == libc.UintptrFromInt32(0) {
  38720 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38721 		goto Error
  38722 	}
  38723 	// Calculate backward references from ARGB image.
  38724 	if !(VP8LHashChainFill(tls, hash_chain, quality, argb, width, height, low_effort, pic, percent_range/int32(2), percent) != 0) {
  38725 		goto Error
  38726 	}
  38727 	if !(VP8LGetBackwardReferences(tls, width, height, argb, quality, 0, int32(kLZ77Standard)|int32(kLZ77RLE), **(**int32)(__ccgo_up(bp + 124)), 0, hash_chain, refs_array, bp+124, pic, percent_range-percent_range/int32(2), percent) != 0) {
  38728 		goto Error
  38729 	}
  38730 	refs = refs_array
  38731 	histogram_image = VP8LAllocateHistogramSet(tls, int32(1), **(**int32)(__ccgo_up(bp + 124)))
  38732 	if histogram_image == libc.UintptrFromInt32(0) {
  38733 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38734 		goto Error
  38735 	}
  38736 	VP8LHistogramSetClear(tls, histogram_image)
  38737 	// Build histogram image and symbols from backward references.
  38738 	VP8LHistogramStoreRefs(tls, refs, libc.UintptrFromInt32(0), 0, **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms)))
  38739 	// Create Huffman bit lengths and codes for each histogram image.
  38740 	if !(GetHuffBitLengthsAndCodes(tls, histogram_image, bp) != 0) {
  38741 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38742 		goto Error
  38743 	}
  38744 	// No color cache, no Huffman image.
  38745 	v1 = bw1
  38746 	v2 = uint32(0)
  38747 	v3 = int32(1)
  38748 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38749 		if v3 > libc.Int32FromInt32(0) {
  38750 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38751 				VP8LPutBitsFlushBits(tls, v1)
  38752 			}
  38753 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38754 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38755 		}
  38756 	} else {
  38757 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38758 	}
  38759 	// Find maximum number of symbols for the huffman tree-set.
  38760 	i = 0
  38761 	for {
  38762 		if !(i < int32(5)) {
  38763 			break
  38764 		}
  38765 		codes = bp + uintptr(i)*24
  38766 		if max_tokens < (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols {
  38767 			max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols
  38768 		}
  38769 		goto _4
  38770 	_4:
  38771 		;
  38772 		i = i + 1
  38773 	}
  38774 	tokens = WebPSafeMalloc(tls, libc.Uint64FromInt32(max_tokens), uint64(2))
  38775 	if tokens == libc.UintptrFromInt32(0) {
  38776 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38777 		goto Error
  38778 	}
  38779 	// Store Huffman codes.
  38780 	i = 0
  38781 	for {
  38782 		if !(i < int32(5)) {
  38783 			break
  38784 		}
  38785 		codes1 = bp + uintptr(i)*24
  38786 		StoreHuffmanCode(tls, bw1, huff_tree, tokens, codes1)
  38787 		ClearHuffmanTreeIfOnlyOneSymbol(tls, codes1)
  38788 		goto _5
  38789 	_5:
  38790 		;
  38791 		i = i + 1
  38792 	}
  38793 	// Store actual literals.
  38794 	if !(StoreImageToBitMask(tls, bw1, width, 0, refs, bp+120, bp, pic) != 0) {
  38795 		goto Error
  38796 	}
  38797 	goto Error
  38798 Error:
  38799 	;
  38800 	WebPSafeFree(tls, tokens)
  38801 	WebPSafeFree(tls, huff_tree)
  38802 	VP8LFreeHistogramSet(tls, histogram_image)
  38803 	WebPSafeFree(tls, (**(**[5]HuffmanTreeCode)(__ccgo_up(bp)))[0].Fcodes)
  38804 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  38805 }
  38806 
  38807 // C documentation
  38808 //
  38809 //	// pic and percent are for progress.
  38810 func EncodeImageInternal(tls *libc.TLS, bw2 uintptr, argb uintptr, hash_chain uintptr, refs_array uintptr, width int32, height int32, quality int32, low_effort int32, config uintptr, cache_bits uintptr, histogram_bits_in int32, init_byte_position size_t, hdr_size uintptr, data_size uintptr, pic uintptr, percent_range int32, percent uintptr) (r int32) {
  38811 	bp := tls.Alloc(128)
  38812 	defer tls.Free(128)
  38813 	var bit_array_size, bw_size_best, v37, v40 size_t
  38814 	var cache_bits_init, cache_bits_tmp, hdr_size_tmp, i_cache, i_percent_range, i_remaining_percent, max_tokens, percent_start, remaining_percent, sub_configs_idx, write_histogram_image, v10, v7 int32
  38815 	var codes, codes1, histogram_argb, histogram_image, huff_tree, huffman_codes, sub_config, tmp_histo, tokens, v12, v15 uintptr
  38816 	var histogram_image_size, histogram_image_xysize, i, v1, v2, v4, v5 uint32_t
  38817 	var _ /* bw_best at bp+48 */ VP8LBitWriter
  38818 	var _ /* bw_init at bp+0 */ VP8LBitWriter
  38819 	var _ /* cache_bits_best at bp+112 */ int32
  38820 	var _ /* hash_chain_histogram at bp+96 */ VP8LHashChain
  38821 	var _ /* histogram_bits at bp+116 */ int32
  38822 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit_array_size, bw_size_best, cache_bits_init, cache_bits_tmp, codes, codes1, hdr_size_tmp, histogram_argb, histogram_image, histogram_image_size, histogram_image_xysize, huff_tree, huffman_codes, i, i_cache, i_percent_range, i_remaining_percent, max_tokens, percent_start, remaining_percent, sub_config, sub_configs_idx, tmp_histo, tokens, write_histogram_image, v1, v10, v12, v15, v2, v37, v4, v40, v5, v7
  38823 	v1 = libc.Uint32FromInt32(histogram_bits_in)
  38824 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  38825 	goto _3
  38826 _3:
  38827 	v4 = libc.Uint32FromInt32(histogram_bits_in)
  38828 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  38829 	goto _6
  38830 _6:
  38831 	histogram_image_xysize = v2 * v5
  38832 	remaining_percent = percent_range
  38833 	percent_start = **(**int32)(__ccgo_up(percent))
  38834 	histogram_image = libc.UintptrFromInt32(0)
  38835 	tmp_histo = libc.UintptrFromInt32(0)
  38836 	histogram_image_size = uint32(0)
  38837 	bit_array_size = uint64(0)
  38838 	huff_tree = WebPSafeMalloc(tls, libc.Uint64FromUint64(3)*libc.Uint64FromInt32(CODE_LENGTH_CODES), uint64(16))
  38839 	tokens = libc.UintptrFromInt32(0)
  38840 	huffman_codes = libc.UintptrFromInt32(0)
  38841 	histogram_argb = WebPSafeMalloc(tls, uint64(histogram_image_xysize), uint64(4))
  38842 	**(**VP8LBitWriter)(__ccgo_up(bp)) = **(**VP8LBitWriter)(__ccgo_up(bw2)) // histogram image hash chain
  38843 	bw_size_best = ^libc.Uint64FromInt32(0)
  38844 	libc.X__builtin___memset_chk(tls, bp+96, 0, uint64(16), ^__predefined_size_t(0))
  38845 	if !(VP8LBitWriterInit(tls, bp+48, uint64(0)) != 0) {
  38846 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38847 		goto Error
  38848 	}
  38849 	// Make sure we can allocate the different objects.
  38850 	if huff_tree == libc.UintptrFromInt32(0) || histogram_argb == libc.UintptrFromInt32(0) || !(VP8LHashChainInit(tls, bp+96, libc.Int32FromUint32(histogram_image_xysize)) != 0) {
  38851 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38852 		goto Error
  38853 	}
  38854 	percent_range = remaining_percent / int32(5)
  38855 	if !(VP8LHashChainFill(tls, hash_chain, quality, argb, width, height, low_effort, pic, percent_range, percent) != 0) {
  38856 		goto Error
  38857 	}
  38858 	percent_start = percent_start + percent_range
  38859 	remaining_percent = remaining_percent - percent_range
  38860 	// If the value is different from zero, it has been set during the palette
  38861 	// analysis.
  38862 	if **(**int32)(__ccgo_up(cache_bits)) == 0 {
  38863 		v7 = int32(MAX_COLOR_CACHE_BITS)
  38864 	} else {
  38865 		v7 = **(**int32)(__ccgo_up(cache_bits))
  38866 	}
  38867 	cache_bits_init = v7
  38868 	// If several iterations will happen, clone into bw_best.
  38869 	if ((*CrunchConfig)(unsafe.Pointer(config)).Fsub_configs_size > int32(1) || (**(**CrunchSubConfig)(__ccgo_up(config + 8))).Fdo_no_cache != 0) && !(VP8LBitWriterClone(tls, bw2, bp+48) != 0) {
  38870 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38871 		goto Error
  38872 	}
  38873 	sub_configs_idx = 0
  38874 	for {
  38875 		if !(sub_configs_idx < (*CrunchConfig)(unsafe.Pointer(config)).Fsub_configs_size) {
  38876 			break
  38877 		}
  38878 		sub_config = config + 8 + uintptr(sub_configs_idx)*8
  38879 		i_remaining_percent = remaining_percent / (*CrunchConfig)(unsafe.Pointer(config)).Fsub_configs_size
  38880 		i_percent_range = i_remaining_percent / int32(4)
  38881 		i_remaining_percent = i_remaining_percent - i_percent_range
  38882 		if !(VP8LGetBackwardReferences(tls, width, height, argb, quality, low_effort, (*CrunchSubConfig)(unsafe.Pointer(sub_config)).Flz77, cache_bits_init, (*CrunchSubConfig)(unsafe.Pointer(sub_config)).Fdo_no_cache, hash_chain, refs_array, bp+112, pic, i_percent_range, percent) != 0) {
  38883 			goto Error
  38884 		}
  38885 		i_cache = 0
  38886 		for {
  38887 			if (*CrunchSubConfig)(unsafe.Pointer(sub_config)).Fdo_no_cache != 0 {
  38888 				v7 = int32(2)
  38889 			} else {
  38890 				v7 = int32(1)
  38891 			}
  38892 			if !(i_cache < v7) {
  38893 				break
  38894 			}
  38895 			if i_cache == 0 {
  38896 				v10 = **(**int32)(__ccgo_up(bp + 112))
  38897 			} else {
  38898 				v10 = 0
  38899 			}
  38900 			cache_bits_tmp = v10
  38901 			**(**int32)(__ccgo_up(bp + 116)) = histogram_bits_in
  38902 			// Speed-up: no need to study the no-cache case if it was already studied
  38903 			// in i_cache == 0.
  38904 			if i_cache == int32(1) && **(**int32)(__ccgo_up(bp + 112)) == 0 {
  38905 				break
  38906 			}
  38907 			// Reset the bit writer for this iteration.
  38908 			VP8LBitWriterReset(tls, bp, bw2)
  38909 			// Build histogram image and symbols from backward references.
  38910 			histogram_image = VP8LAllocateHistogramSet(tls, libc.Int32FromUint32(histogram_image_xysize), cache_bits_tmp)
  38911 			tmp_histo = VP8LAllocateHistogram(tls, cache_bits_tmp)
  38912 			if histogram_image == libc.UintptrFromInt32(0) || tmp_histo == libc.UintptrFromInt32(0) {
  38913 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38914 				goto Error
  38915 			}
  38916 			i_percent_range = i_remaining_percent / int32(3)
  38917 			i_remaining_percent = i_remaining_percent - i_percent_range
  38918 			if !(VP8LGetHistoImageSymbols(tls, width, height, refs_array+uintptr(i_cache)*40, quality, low_effort, **(**int32)(__ccgo_up(bp + 116)), cache_bits_tmp, histogram_image, tmp_histo, histogram_argb, pic, i_percent_range, percent) != 0) {
  38919 				goto Error
  38920 			}
  38921 			// Create Huffman bit lengths and codes for each histogram image.
  38922 			histogram_image_size = libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fsize)
  38923 			bit_array_size = uint64(uint32(5) * histogram_image_size)
  38924 			huffman_codes = WebPSafeCalloc(tls, bit_array_size, uint64(24))
  38925 			// Note: some histogram_image entries may point to tmp_histos[], so the
  38926 			// latter need to outlive the following call to
  38927 			// GetHuffBitLengthsAndCodes().
  38928 			if huffman_codes == libc.UintptrFromInt32(0) || !(GetHuffBitLengthsAndCodes(tls, histogram_image, huffman_codes) != 0) {
  38929 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38930 				goto Error
  38931 			}
  38932 			// Free combined histograms.
  38933 			VP8LFreeHistogramSet(tls, histogram_image)
  38934 			histogram_image = libc.UintptrFromInt32(0)
  38935 			// Free scratch histograms.
  38936 			VP8LFreeHistogram(tls, tmp_histo)
  38937 			tmp_histo = libc.UintptrFromInt32(0)
  38938 			// Color Cache parameters.
  38939 			if cache_bits_tmp > 0 {
  38940 				v12 = bw2
  38941 				v1 = uint32(1)
  38942 				v7 = int32(1)
  38943 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38944 					if v7 > libc.Int32FromInt32(0) {
  38945 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38946 							VP8LPutBitsFlushBits(tls, v12)
  38947 						}
  38948 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38949 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38950 					}
  38951 				} else {
  38952 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38953 				}
  38954 				v12 = bw2
  38955 				v1 = libc.Uint32FromInt32(cache_bits_tmp)
  38956 				v7 = int32(4)
  38957 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38958 					if v7 > libc.Int32FromInt32(0) {
  38959 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38960 							VP8LPutBitsFlushBits(tls, v12)
  38961 						}
  38962 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38963 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38964 					}
  38965 				} else {
  38966 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38967 				}
  38968 			} else {
  38969 				v12 = bw2
  38970 				v1 = uint32(0)
  38971 				v7 = int32(1)
  38972 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38973 					if v7 > libc.Int32FromInt32(0) {
  38974 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38975 							VP8LPutBitsFlushBits(tls, v12)
  38976 						}
  38977 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38978 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38979 					}
  38980 				} else {
  38981 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38982 				}
  38983 			}
  38984 			// Huffman image + meta huffman.
  38985 			histogram_image_size = uint32(0)
  38986 			i = uint32(0)
  38987 			for {
  38988 				if !(i < histogram_image_xysize) {
  38989 					break
  38990 				}
  38991 				if **(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) >= histogram_image_size {
  38992 					histogram_image_size = **(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) + uint32(1)
  38993 				}
  38994 				**(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) <<= uint32(8)
  38995 				goto _21
  38996 			_21:
  38997 				;
  38998 				i = i + 1
  38999 			}
  39000 			write_histogram_image = libc.BoolInt32(histogram_image_size > uint32(1))
  39001 			v12 = bw2
  39002 			v1 = libc.Uint32FromInt32(write_histogram_image)
  39003 			v7 = int32(1)
  39004 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39005 				if v7 > libc.Int32FromInt32(0) {
  39006 					if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  39007 						VP8LPutBitsFlushBits(tls, v12)
  39008 					}
  39009 					**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  39010 					**(**int32)(__ccgo_up(v12 + 8)) += v7
  39011 				}
  39012 			} else {
  39013 				VP8LPutBitsInternal(tls, v12, v1, v7)
  39014 			}
  39015 			if write_histogram_image != 0 {
  39016 				VP8LOptimizeSampling(tls, histogram_argb, width, height, histogram_bits_in, libc.Int32FromInt32(MIN_HUFFMAN_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_HUFFMAN_BITS)-libc.Int32FromInt32(1), bp+116)
  39017 				v12 = bw2
  39018 				v1 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)) - int32(2))
  39019 				v7 = int32(3)
  39020 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39021 					if v7 > libc.Int32FromInt32(0) {
  39022 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  39023 							VP8LPutBitsFlushBits(tls, v12)
  39024 						}
  39025 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  39026 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  39027 					}
  39028 				} else {
  39029 					VP8LPutBitsInternal(tls, v12, v1, v7)
  39030 				}
  39031 				i_percent_range = i_remaining_percent / int32(2)
  39032 				i_remaining_percent = i_remaining_percent - i_percent_range
  39033 				v1 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)))
  39034 				v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  39035 				goto _30
  39036 			_30:
  39037 				v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)))
  39038 				v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  39039 				goto _33
  39040 			_33:
  39041 				if !(EncodeImageNoHuffman(tls, bw2, histogram_argb, bp+96, refs_array+2*40, libc.Int32FromUint32(v2), libc.Int32FromUint32(v5), quality, low_effort, pic, i_percent_range, percent) != 0) {
  39042 					goto Error
  39043 				}
  39044 			}
  39045 			// Store Huffman codes.
  39046 			max_tokens = 0
  39047 			// Find maximum number of symbols for the huffman tree-set.
  39048 			i = uint32(0)
  39049 			for {
  39050 				if !(i < uint32(5)*histogram_image_size) {
  39051 					break
  39052 				}
  39053 				codes = huffman_codes + uintptr(i)*24
  39054 				if max_tokens < (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols {
  39055 					max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols
  39056 				}
  39057 				goto _34
  39058 			_34:
  39059 				;
  39060 				i = i + 1
  39061 			}
  39062 			tokens = WebPSafeMalloc(tls, libc.Uint64FromInt32(max_tokens), uint64(2))
  39063 			if tokens == libc.UintptrFromInt32(0) {
  39064 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39065 				goto Error
  39066 			}
  39067 			i = uint32(0)
  39068 			for {
  39069 				if !(i < uint32(5)*histogram_image_size) {
  39070 					break
  39071 				}
  39072 				codes1 = huffman_codes + uintptr(i)*24
  39073 				StoreHuffmanCode(tls, bw2, huff_tree, tokens, codes1)
  39074 				ClearHuffmanTreeIfOnlyOneSymbol(tls, codes1)
  39075 				goto _35
  39076 			_35:
  39077 				;
  39078 				i = i + 1
  39079 			}
  39080 			// Store actual literals.
  39081 			v12 = bw2
  39082 			v37 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v12)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  39083 			goto _38
  39084 		_38:
  39085 			hdr_size_tmp = libc.Int32FromUint64(v37 - init_byte_position)
  39086 			if !(StoreImageToBitMask(tls, bw2, width, **(**int32)(__ccgo_up(bp + 116)), refs_array+uintptr(i_cache)*40, histogram_argb, huffman_codes, pic) != 0) {
  39087 				goto Error
  39088 			}
  39089 			// Keep track of the smallest image so far.
  39090 			v12 = bw2
  39091 			v37 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v12)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  39092 			goto _41
  39093 		_41:
  39094 			if v37 < bw_size_best {
  39095 				v15 = bw2
  39096 				v40 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v15)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v15)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v15)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  39097 				goto _44
  39098 			_44:
  39099 				bw_size_best = v40
  39100 				**(**int32)(__ccgo_up(cache_bits)) = cache_bits_tmp
  39101 				**(**int32)(__ccgo_up(hdr_size)) = hdr_size_tmp
  39102 				v12 = bw2
  39103 				v37 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v12)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v12)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  39104 				goto _47
  39105 			_47:
  39106 				**(**int32)(__ccgo_up(data_size)) = libc.Int32FromUint64(v37 - init_byte_position - libc.Uint64FromInt32(**(**int32)(__ccgo_up(hdr_size))))
  39107 				VP8LBitWriterSwap(tls, bw2, bp+48)
  39108 			}
  39109 			WebPSafeFree(tls, tokens)
  39110 			tokens = libc.UintptrFromInt32(0)
  39111 			if huffman_codes != libc.UintptrFromInt32(0) {
  39112 				WebPSafeFree(tls, (*HuffmanTreeCode)(unsafe.Pointer(huffman_codes)).Fcodes)
  39113 				WebPSafeFree(tls, huffman_codes)
  39114 				huffman_codes = libc.UintptrFromInt32(0)
  39115 			}
  39116 			goto _9
  39117 		_9:
  39118 			;
  39119 			i_cache = i_cache + 1
  39120 		}
  39121 		goto _8
  39122 	_8:
  39123 		;
  39124 		sub_configs_idx = sub_configs_idx + 1
  39125 	}
  39126 	VP8LBitWriterSwap(tls, bw2, bp+48)
  39127 	if !(WebPReportProgress(tls, pic, percent_start+remaining_percent, percent) != 0) {
  39128 		goto Error
  39129 	}
  39130 	goto Error
  39131 Error:
  39132 	;
  39133 	WebPSafeFree(tls, tokens)
  39134 	WebPSafeFree(tls, huff_tree)
  39135 	VP8LFreeHistogramSet(tls, histogram_image)
  39136 	VP8LFreeHistogram(tls, tmp_histo)
  39137 	VP8LHashChainClear(tls, bp+96)
  39138 	if huffman_codes != libc.UintptrFromInt32(0) {
  39139 		WebPSafeFree(tls, (*HuffmanTreeCode)(unsafe.Pointer(huffman_codes)).Fcodes)
  39140 		WebPSafeFree(tls, huffman_codes)
  39141 	}
  39142 	WebPSafeFree(tls, histogram_argb)
  39143 	VP8LBitWriterWipeOut(tls, bp+48)
  39144 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  39145 }
  39146 
  39147 // -----------------------------------------------------------------------------
  39148 // Transforms
  39149 
  39150 func ApplySubtractGreen(tls *libc.TLS, enc uintptr, width int32, height int32, bw1 uintptr) {
  39151 	var v1 uintptr
  39152 	var v2 uint32_t
  39153 	var v3 int32
  39154 	_, _, _ = v1, v2, v3
  39155 	v1 = bw1
  39156 	v2 = uint32(TRANSFORM_PRESENT)
  39157 	v3 = int32(1)
  39158 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39159 		if v3 > libc.Int32FromInt32(0) {
  39160 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39161 				VP8LPutBitsFlushBits(tls, v1)
  39162 			}
  39163 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39164 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39165 		}
  39166 	} else {
  39167 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39168 	}
  39169 	v1 = bw1
  39170 	v2 = uint32(SUBTRACT_GREEN_TRANSFORM)
  39171 	v3 = int32(2)
  39172 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39173 		if v3 > libc.Int32FromInt32(0) {
  39174 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39175 				VP8LPutBitsFlushBits(tls, v1)
  39176 			}
  39177 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39178 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39179 		}
  39180 	} else {
  39181 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39182 	}
  39183 	(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LSubtractGreenFromBlueAndRed})))(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, width*height)
  39184 }
  39185 
  39186 func ApplyPredictFilter(tls *libc.TLS, enc uintptr, width int32, height int32, quality int32, low_effort int32, used_subtract_green int32, bw1 uintptr, percent_range int32, percent uintptr, best_bits uintptr) (r int32) {
  39187 	var max_bits, min_bits, near_lossless_strength, v1, v2 int32
  39188 	var v10, v12, v4, v7 uint32_t
  39189 	var v3 uintptr
  39190 	_, _, _, _, _, _, _, _, _, _ = max_bits, min_bits, near_lossless_strength, v1, v10, v12, v2, v3, v4, v7
  39191 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  39192 		v1 = int32(100)
  39193 	} else {
  39194 		v1 = (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fnear_lossless
  39195 	}
  39196 	near_lossless_strength = v1
  39197 	max_bits = ClampBits(tls, width, height, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpredictor_transform_bits, int32(MIN_TRANSFORM_BITS), libc.Int32FromInt32(MIN_TRANSFORM_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_TRANSFORM_BITS)-libc.Int32FromInt32(1), libc.Int32FromInt32(1)<<libc.Int32FromInt32(14))
  39198 	if (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fmethod > int32(4) {
  39199 		v2 = (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fmethod - int32(4)
  39200 	} else {
  39201 		v2 = 0
  39202 	}
  39203 	min_bits = ClampBits(tls, width, height, max_bits-int32(2)*v2, int32(MIN_TRANSFORM_BITS), libc.Int32FromInt32(MIN_TRANSFORM_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_TRANSFORM_BITS)-libc.Int32FromInt32(1), libc.Int32FromInt32(1)<<libc.Int32FromInt32(14))
  39204 	if !(VP8LResidualImage(tls, width, height, min_bits, max_bits, low_effort, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_scratch, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data, near_lossless_strength, (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fexact, used_subtract_green, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, percent_range/int32(2), percent, best_bits) != 0) {
  39205 		return 0
  39206 	}
  39207 	v3 = bw1
  39208 	v4 = uint32(TRANSFORM_PRESENT)
  39209 	v1 = int32(1)
  39210 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39211 		if v1 > libc.Int32FromInt32(0) {
  39212 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39213 				VP8LPutBitsFlushBits(tls, v3)
  39214 			}
  39215 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39216 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39217 		}
  39218 	} else {
  39219 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39220 	}
  39221 	v3 = bw1
  39222 	v4 = uint32(PREDICTOR_TRANSFORM)
  39223 	v1 = int32(2)
  39224 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39225 		if v1 > libc.Int32FromInt32(0) {
  39226 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39227 				VP8LPutBitsFlushBits(tls, v3)
  39228 			}
  39229 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39230 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39231 		}
  39232 	} else {
  39233 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39234 	}
  39235 	v3 = bw1
  39236 	v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)) - int32(MIN_TRANSFORM_BITS))
  39237 	v1 = int32(NUM_TRANSFORM_BITS)
  39238 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39239 		if v1 > libc.Int32FromInt32(0) {
  39240 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39241 				VP8LPutBitsFlushBits(tls, v3)
  39242 			}
  39243 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39244 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39245 		}
  39246 	} else {
  39247 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39248 	}
  39249 	v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39250 	v7 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  39251 	goto _14
  39252 _14:
  39253 	v10 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39254 	v12 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v10) - uint32(1)) >> v10
  39255 	goto _17
  39256 _17:
  39257 	return EncodeImageNoHuffman(tls, bw1, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data, enc+2312, enc+2152, libc.Int32FromUint32(v7), libc.Int32FromUint32(v12), quality, low_effort, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, percent_range-percent_range/int32(2), percent)
  39258 }
  39259 
  39260 func ApplyCrossColorFilter(tls *libc.TLS, enc uintptr, width int32, height int32, quality int32, low_effort int32, bw1 uintptr, percent_range int32, percent uintptr, best_bits uintptr) (r int32) {
  39261 	var min_bits, v3 int32
  39262 	var v1 uintptr
  39263 	var v10, v2, v5, v8 uint32_t
  39264 	_, _, _, _, _, _, _ = min_bits, v1, v10, v2, v3, v5, v8
  39265 	min_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fcross_color_transform_bits
  39266 	if !(VP8LColorSpaceTransform(tls, width, height, min_bits, quality, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, percent_range/int32(2), percent, best_bits) != 0) {
  39267 		return 0
  39268 	}
  39269 	v1 = bw1
  39270 	v2 = uint32(TRANSFORM_PRESENT)
  39271 	v3 = int32(1)
  39272 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39273 		if v3 > libc.Int32FromInt32(0) {
  39274 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39275 				VP8LPutBitsFlushBits(tls, v1)
  39276 			}
  39277 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39278 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39279 		}
  39280 	} else {
  39281 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39282 	}
  39283 	v1 = bw1
  39284 	v2 = uint32(CROSS_COLOR_TRANSFORM)
  39285 	v3 = int32(2)
  39286 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39287 		if v3 > libc.Int32FromInt32(0) {
  39288 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39289 				VP8LPutBitsFlushBits(tls, v1)
  39290 			}
  39291 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39292 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39293 		}
  39294 	} else {
  39295 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39296 	}
  39297 	v1 = bw1
  39298 	v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)) - int32(MIN_TRANSFORM_BITS))
  39299 	v3 = int32(NUM_TRANSFORM_BITS)
  39300 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39301 		if v3 > libc.Int32FromInt32(0) {
  39302 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39303 				VP8LPutBitsFlushBits(tls, v1)
  39304 			}
  39305 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39306 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39307 		}
  39308 	} else {
  39309 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39310 	}
  39311 	v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39312 	v5 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  39313 	goto _12
  39314 _12:
  39315 	v8 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39316 	v10 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v8) - uint32(1)) >> v8
  39317 	goto _15
  39318 _15:
  39319 	return EncodeImageNoHuffman(tls, bw1, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data, enc+2312, enc+2152, libc.Int32FromUint32(v5), libc.Int32FromUint32(v10), quality, low_effort, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, percent_range-percent_range/int32(2), percent)
  39320 }
  39321 
  39322 // -----------------------------------------------------------------------------
  39323 
  39324 func WriteRiffHeader(tls *libc.TLS, pic uintptr, riff_size size_t, vp8l_size size_t) (r int32) {
  39325 	bp := tls.Alloc(32)
  39326 	defer tls.Free(32)
  39327 	var v1, v3, v5 uintptr
  39328 	var v4, v6 int32
  39329 	var v2 uint32_t
  39330 	var _ /* riff at bp+0 */ [21]uint8_t
  39331 	_, _, _, _, _, _ = v1, v2, v3, v4, v5, v6
  39332 	**(**[21]uint8_t)(__ccgo_up(bp)) = [21]uint8_t{
  39333 		0:  uint8('R'),
  39334 		1:  uint8('I'),
  39335 		2:  uint8('F'),
  39336 		3:  uint8('F'),
  39337 		8:  uint8('W'),
  39338 		9:  uint8('E'),
  39339 		10: uint8('B'),
  39340 		11: uint8('P'),
  39341 		12: uint8('V'),
  39342 		13: uint8('P'),
  39343 		14: uint8('8'),
  39344 		15: uint8('L'),
  39345 		20: uint8(VP8L_MAGIC_BYTE3),
  39346 	}
  39347 	v1 = bp + uintptr(TAG_SIZE)
  39348 	v2 = uint32(riff_size)
  39349 	v3 = v1
  39350 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  39351 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  39352 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  39353 	v5 = v1 + uintptr(2)
  39354 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  39355 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  39356 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  39357 	v1 = bp + uintptr(RIFF_HEADER_SIZE) + uintptr(TAG_SIZE)
  39358 	v2 = uint32(vp8l_size)
  39359 	v3 = v1
  39360 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  39361 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  39362 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  39363 	v5 = v1 + uintptr(2)
  39364 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  39365 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  39366 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  39367 	return (*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(21), pic)
  39368 }
  39369 
  39370 func WriteImageSize(tls *libc.TLS, pic uintptr, bw1 uintptr) (r int32) {
  39371 	var height, width, v3 int32
  39372 	var v1 uintptr
  39373 	var v2 uint32_t
  39374 	_, _, _, _, _ = height, width, v1, v2, v3
  39375 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - int32(1)
  39376 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - int32(1)
  39377 	v1 = bw1
  39378 	v2 = libc.Uint32FromInt32(width)
  39379 	v3 = int32(VP8L_IMAGE_SIZE_BITS)
  39380 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39381 		if v3 > libc.Int32FromInt32(0) {
  39382 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39383 				VP8LPutBitsFlushBits(tls, v1)
  39384 			}
  39385 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39386 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39387 		}
  39388 	} else {
  39389 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39390 	}
  39391 	v1 = bw1
  39392 	v2 = libc.Uint32FromInt32(height)
  39393 	v3 = int32(VP8L_IMAGE_SIZE_BITS)
  39394 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39395 		if v3 > libc.Int32FromInt32(0) {
  39396 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39397 				VP8LPutBitsFlushBits(tls, v1)
  39398 			}
  39399 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39400 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39401 		}
  39402 	} else {
  39403 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39404 	}
  39405 	return libc.BoolInt32(!((*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0))
  39406 }
  39407 
  39408 func WriteRealAlphaAndVersion(tls *libc.TLS, bw1 uintptr, has_alpha int32) (r int32) {
  39409 	var v1 uintptr
  39410 	var v2 uint32_t
  39411 	var v3 int32
  39412 	_, _, _ = v1, v2, v3
  39413 	v1 = bw1
  39414 	v2 = libc.Uint32FromInt32(has_alpha)
  39415 	v3 = int32(1)
  39416 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39417 		if v3 > libc.Int32FromInt32(0) {
  39418 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39419 				VP8LPutBitsFlushBits(tls, v1)
  39420 			}
  39421 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39422 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39423 		}
  39424 	} else {
  39425 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39426 	}
  39427 	v1 = bw1
  39428 	v2 = uint32(VP8L_VERSION)
  39429 	v3 = int32(VP8L_VERSION_BITS)
  39430 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39431 		if v3 > libc.Int32FromInt32(0) {
  39432 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39433 				VP8LPutBitsFlushBits(tls, v1)
  39434 			}
  39435 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39436 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39437 		}
  39438 	} else {
  39439 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39440 	}
  39441 	return libc.BoolInt32(!((*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0))
  39442 }
  39443 
  39444 func WriteImage(tls *libc.TLS, pic uintptr, bw1 uintptr, coded_size uintptr) (r int32) {
  39445 	bp := tls.Alloc(16)
  39446 	defer tls.Free(16)
  39447 	var pad, riff_size, vp8l_size, webpll_size, v2 size_t
  39448 	var webpll_data, v1 uintptr
  39449 	var _ /* pad_byte at bp+0 */ [1]uint8_t
  39450 	_, _, _, _, _, _, _ = pad, riff_size, vp8l_size, webpll_data, webpll_size, v1, v2
  39451 	webpll_data = VP8LBitWriterFinish(tls, bw1)
  39452 	v1 = bw1
  39453 	v2 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v1)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  39454 	goto _3
  39455 _3:
  39456 	webpll_size = v2
  39457 	vp8l_size = uint64(VP8L_SIGNATURE_SIZE) + webpll_size
  39458 	pad = vp8l_size & uint64(1)
  39459 	riff_size = libc.Uint64FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) + vp8l_size + pad
  39460 	**(**size_t)(__ccgo_up(coded_size)) = uint64(0)
  39461 	if (*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  39462 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39463 	}
  39464 	if !(WriteRiffHeader(tls, pic, riff_size, vp8l_size) != 0) || !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, webpll_data, webpll_size, pic) != 0) {
  39465 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  39466 	}
  39467 	if pad != 0 {
  39468 		**(**[1]uint8_t)(__ccgo_up(bp)) = [1]uint8_t{}
  39469 		if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(1), pic) != 0) {
  39470 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  39471 		}
  39472 	}
  39473 	**(**size_t)(__ccgo_up(coded_size)) = uint64(CHUNK_HEADER_SIZE) + riff_size
  39474 	return int32(1)
  39475 }
  39476 
  39477 // -----------------------------------------------------------------------------
  39478 
  39479 func ClearTransformBuffer(tls *libc.TLS, enc uintptr) {
  39480 	WebPSafeFree(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem)
  39481 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem = libc.UintptrFromInt32(0)
  39482 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size = uint64(0)
  39483 }
  39484 
  39485 // C documentation
  39486 //
  39487 //	// Allocates the memory for argb (W x H) buffer, 2 rows of context for
  39488 //	// prediction and transform data.
  39489 //	// Flags influencing the memory allocated:
  39490 //	//  enc->transform_bits
  39491 //	//  enc->use_predict, enc->use_cross_color
  39492 func AllocateTransformBuffer(tls *libc.TLS, enc uintptr, width int32, height int32) (r int32) {
  39493 	var argb_scratch_size, image_size, max_alignment_in_words, mem_size, transform_data_size uint64_t
  39494 	var mem uintptr
  39495 	var v1, v2 uint64
  39496 	var v3, v4, v6, v7 uint32_t
  39497 	_, _, _, _, _, _, _, _, _, _, _, _ = argb_scratch_size, image_size, max_alignment_in_words, mem, mem_size, transform_data_size, v1, v2, v3, v4, v6, v7
  39498 	image_size = libc.Uint64FromInt32(width) * libc.Uint64FromInt32(height)
  39499 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  39500 		v1 = libc.Uint64FromInt32((width+int32(1))*int32(2)) + (libc.Uint64FromInt32(width*int32(2))+uint64(4)-uint64(1))/uint64(4)
  39501 	} else {
  39502 		v1 = uint64(0)
  39503 	}
  39504 	// VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra
  39505 	// pixel in each, plus 2 regular scanlines of bytes.
  39506 	// TODO(skal): Clean up by using arithmetic in bytes instead of words.
  39507 	argb_scratch_size = v1
  39508 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 || (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  39509 		v3 = uint32(MIN_TRANSFORM_BITS)
  39510 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  39511 		goto _5
  39512 	_5:
  39513 		v6 = uint32(MIN_TRANSFORM_BITS)
  39514 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  39515 		goto _8
  39516 	_8:
  39517 		v2 = uint64(v4) * uint64(v7)
  39518 	} else {
  39519 		v2 = uint64(0)
  39520 	}
  39521 	transform_data_size = v2
  39522 	max_alignment_in_words = uint64((libc.Uint64FromInt32(WEBP_ALIGN_CST) + libc.Uint64FromInt64(4) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt64(4))
  39523 	mem_size = image_size + max_alignment_in_words + argb_scratch_size + max_alignment_in_words + transform_data_size
  39524 	mem = (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem
  39525 	if mem == libc.UintptrFromInt32(0) || mem_size > (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size {
  39526 		ClearTransformBuffer(tls, enc)
  39527 		mem = WebPSafeMalloc(tls, mem_size, uint64(4))
  39528 		if mem == libc.UintptrFromInt32(0) {
  39529 			return WebPEncodingSetError(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39530 		}
  39531 		(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem = mem
  39532 		(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size = mem_size
  39533 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  39534 	}
  39535 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb = mem
  39536 	mem = uintptr((uint64(mem+uintptr(image_size)*4) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  39537 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_scratch = mem
  39538 	mem = uintptr((uint64(mem+uintptr(argb_scratch_size)*4) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  39539 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data = mem
  39540 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width = width
  39541 	return int32(1)
  39542 }
  39543 
  39544 func MakeInputImageCopy(tls *libc.TLS, enc uintptr) (r int32) {
  39545 	var dst, picture, src uintptr
  39546 	var height, width, y int32
  39547 	_, _, _, _, _, _ = dst, height, picture, src, width, y
  39548 	picture = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  39549 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  39550 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  39551 	if !(AllocateTransformBuffer(tls, enc, width, height) != 0) {
  39552 		return 0
  39553 	}
  39554 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content == int32(kEncoderARGB) {
  39555 		return int32(1)
  39556 	}
  39557 	dst = (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb
  39558 	src = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  39559 	y = 0
  39560 	for {
  39561 		if !(y < height) {
  39562 			break
  39563 		}
  39564 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(width)*uint64(4), ^__predefined_size_t(0))
  39565 		dst = dst + uintptr(width)*4
  39566 		src = src + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  39567 		goto _1
  39568 	_1:
  39569 		;
  39570 		y = y + 1
  39571 	}
  39572 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderARGB)
  39573 	return int32(1)
  39574 }
  39575 
  39576 // -----------------------------------------------------------------------------
  39577 
  39578 func SearchColorGreedy(tls *libc.TLS, palette uintptr, palette_size int32, color uint32_t) (r uint32_t) {
  39579 	_ = palette_size
  39580 	if color == **(**uint32_t)(__ccgo_up(palette)) {
  39581 		return uint32(0)
  39582 	}
  39583 	if color == **(**uint32_t)(__ccgo_up(palette + 1*4)) {
  39584 		return uint32(1)
  39585 	}
  39586 	if color == **(**uint32_t)(__ccgo_up(palette + 2*4)) {
  39587 		return uint32(2)
  39588 	}
  39589 	return uint32(3)
  39590 }
  39591 
  39592 func ApplyPaletteHash0(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39593 	// Focus on the green color.
  39594 	return color >> libc.Int32FromInt32(8) & uint32(0xff)
  39595 }
  39596 
  39597 func ApplyPaletteHash1(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39598 	// Forget about alpha.
  39599 	return uint32(uint64(color&libc.Uint32FromUint32(0x00ffffff))*libc.Uint64FromUint64(4222244071)) >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(11))
  39600 }
  39601 
  39602 func ApplyPaletteHash2(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39603 	// Forget about alpha.
  39604 	return uint32(uint64(color&libc.Uint32FromUint32(0x00ffffff))*(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(31)-libc.Uint64FromInt32(1))) >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(11))
  39605 }
  39606 
  39607 // Use 1 pixel cache for ARGB pixels.
  39608 
  39609 // C documentation
  39610 //
  39611 //	// Remap argb values in src[] to packed palettes entries in dst[]
  39612 //	// using 'row' as a temporary buffer of size 'width'.
  39613 //	// We assume that all src[] values have a corresponding entry in the palette.
  39614 //	// Note: src[] can be the same as dst[]
  39615 func ApplyPalette(tls *libc.TLS, src uintptr, src_stride uint32_t, dst uintptr, dst_stride uint32_t, palette uintptr, palette_size int32, width int32, height int32, xbits int32, pic uintptr) (r int32) {
  39616 	bp := tls.Alloc(6144)
  39617 	defer tls.Free(6144)
  39618 	var hash_functions [3]uintptr
  39619 	var i, j, use_LUT, x, y int32
  39620 	var ind, pix, pix1, pix2, pix3, pix4, prev_idx, prev_idx1, prev_idx2, prev_idx3, prev_idx4, prev_pix, prev_pix1, prev_pix2, prev_pix3, prev_pix4 uint32_t
  39621 	var tmp_row uintptr
  39622 	var _ /* buffer at bp+0 */ [2048]uint16_t
  39623 	var _ /* idx_map at bp+4096 */ [256]uint32_t
  39624 	var _ /* palette_sorted at bp+5120 */ [256]uint32_t
  39625 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = hash_functions, i, ind, j, pix, pix1, pix2, pix3, pix4, prev_idx, prev_idx1, prev_idx2, prev_idx3, prev_idx4, prev_pix, prev_pix1, prev_pix2, prev_pix3, prev_pix4, tmp_row, use_LUT, x, y
  39626 	// TODO(skal): this tmp buffer is not needed if VP8LBundleColorMap() can be
  39627 	// made to work in-place.
  39628 	tmp_row = WebPSafeMalloc(tls, libc.Uint64FromInt32(width), uint64(1))
  39629 	if tmp_row == libc.UintptrFromInt32(0) {
  39630 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39631 	}
  39632 	if palette_size < int32(4) {
  39633 		prev_pix = **(**uint32_t)(__ccgo_up(palette))
  39634 		prev_idx = uint32(0)
  39635 		y = 0
  39636 		for {
  39637 			if !(y < height) {
  39638 				break
  39639 			}
  39640 			x = 0
  39641 			for {
  39642 				if !(x < width) {
  39643 					break
  39644 				}
  39645 				pix = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39646 				if pix != prev_pix {
  39647 					prev_idx = SearchColorGreedy(tls, palette, palette_size, pix)
  39648 					prev_pix = pix
  39649 				}
  39650 				**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx)
  39651 				goto _2
  39652 			_2:
  39653 				;
  39654 				x = x + 1
  39655 			}
  39656 			(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39657 			src = src + uintptr(src_stride)*4
  39658 			dst = dst + uintptr(dst_stride)*4
  39659 			goto _1
  39660 		_1:
  39661 			;
  39662 			y = y + 1
  39663 		}
  39664 	} else {
  39665 		hash_functions = [3]uintptr{
  39666 			0: __ccgo_fp(ApplyPaletteHash0),
  39667 			1: __ccgo_fp(ApplyPaletteHash1),
  39668 			2: __ccgo_fp(ApplyPaletteHash2),
  39669 		}
  39670 		// Try to find a perfect hash function able to go from a color to an index
  39671 		// within 1 << PALETTE_INV_SIZE_BITS in order to build a hash map to go
  39672 		// from color to index in palette.
  39673 		i = 0
  39674 		for {
  39675 			if !(i < int32(3)) {
  39676 				break
  39677 			}
  39678 			use_LUT = int32(1)
  39679 			// Set each element in buffer to max uint16_t.
  39680 			libc.X__builtin___memset_chk(tls, bp, int32(0xff), uint64(4096), ^__predefined_size_t(0))
  39681 			j = 0
  39682 			for {
  39683 				if !(j < palette_size) {
  39684 					break
  39685 				}
  39686 				ind = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{hash_functions[i]})))(tls, **(**uint32_t)(__ccgo_up(palette + uintptr(j)*4)))
  39687 				if uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ind]) != uint32(0xffff) {
  39688 					use_LUT = 0
  39689 					break
  39690 				} else {
  39691 					(**(**[2048]uint16_t)(__ccgo_up(bp)))[ind] = libc.Uint16FromInt32(j)
  39692 				}
  39693 				goto _4
  39694 			_4:
  39695 				;
  39696 				j = j + 1
  39697 			}
  39698 			if use_LUT != 0 {
  39699 				break
  39700 			}
  39701 			goto _3
  39702 		_3:
  39703 			;
  39704 			i = i + 1
  39705 		}
  39706 		if i == 0 {
  39707 			prev_pix1 = **(**uint32_t)(__ccgo_up(palette))
  39708 			prev_idx1 = uint32(0)
  39709 			y = 0
  39710 			for {
  39711 				if !(y < height) {
  39712 					break
  39713 				}
  39714 				x = 0
  39715 				for {
  39716 					if !(x < width) {
  39717 						break
  39718 					}
  39719 					pix1 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39720 					if pix1 != prev_pix1 {
  39721 						prev_idx1 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash0(tls, pix1)])
  39722 						prev_pix1 = pix1
  39723 					}
  39724 					**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx1)
  39725 					goto _6
  39726 				_6:
  39727 					;
  39728 					x = x + 1
  39729 				}
  39730 				(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39731 				src = src + uintptr(src_stride)*4
  39732 				dst = dst + uintptr(dst_stride)*4
  39733 				goto _5
  39734 			_5:
  39735 				;
  39736 				y = y + 1
  39737 			}
  39738 		} else {
  39739 			if i == int32(1) {
  39740 				prev_pix2 = **(**uint32_t)(__ccgo_up(palette))
  39741 				prev_idx2 = uint32(0)
  39742 				y = 0
  39743 				for {
  39744 					if !(y < height) {
  39745 						break
  39746 					}
  39747 					x = 0
  39748 					for {
  39749 						if !(x < width) {
  39750 							break
  39751 						}
  39752 						pix2 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39753 						if pix2 != prev_pix2 {
  39754 							prev_idx2 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash1(tls, pix2)])
  39755 							prev_pix2 = pix2
  39756 						}
  39757 						**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx2)
  39758 						goto _8
  39759 					_8:
  39760 						;
  39761 						x = x + 1
  39762 					}
  39763 					(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39764 					src = src + uintptr(src_stride)*4
  39765 					dst = dst + uintptr(dst_stride)*4
  39766 					goto _7
  39767 				_7:
  39768 					;
  39769 					y = y + 1
  39770 				}
  39771 			} else {
  39772 				if i == int32(2) {
  39773 					prev_pix3 = **(**uint32_t)(__ccgo_up(palette))
  39774 					prev_idx3 = uint32(0)
  39775 					y = 0
  39776 					for {
  39777 						if !(y < height) {
  39778 							break
  39779 						}
  39780 						x = 0
  39781 						for {
  39782 							if !(x < width) {
  39783 								break
  39784 							}
  39785 							pix3 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39786 							if pix3 != prev_pix3 {
  39787 								prev_idx3 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash2(tls, pix3)])
  39788 								prev_pix3 = pix3
  39789 							}
  39790 							**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx3)
  39791 							goto _10
  39792 						_10:
  39793 							;
  39794 							x = x + 1
  39795 						}
  39796 						(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39797 						src = src + uintptr(src_stride)*4
  39798 						dst = dst + uintptr(dst_stride)*4
  39799 						goto _9
  39800 					_9:
  39801 						;
  39802 						y = y + 1
  39803 					}
  39804 				} else {
  39805 					PrepareMapToPalette(tls, palette, libc.Uint32FromInt32(palette_size), bp+5120, bp+4096)
  39806 					prev_pix4 = **(**uint32_t)(__ccgo_up(palette))
  39807 					prev_idx4 = uint32(0)
  39808 					y = 0
  39809 					for {
  39810 						if !(y < height) {
  39811 							break
  39812 						}
  39813 						x = 0
  39814 						for {
  39815 							if !(x < width) {
  39816 								break
  39817 							}
  39818 							pix4 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39819 							if pix4 != prev_pix4 {
  39820 								prev_idx4 = (**(**[256]uint32_t)(__ccgo_up(bp + 4096)))[SearchColorNoIdx(tls, bp+5120, pix4, palette_size)]
  39821 								prev_pix4 = pix4
  39822 							}
  39823 							**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx4)
  39824 							goto _12
  39825 						_12:
  39826 							;
  39827 							x = x + 1
  39828 						}
  39829 						(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39830 						src = src + uintptr(src_stride)*4
  39831 						dst = dst + uintptr(dst_stride)*4
  39832 						goto _11
  39833 					_11:
  39834 						;
  39835 						y = y + 1
  39836 					}
  39837 				}
  39838 			}
  39839 		}
  39840 	}
  39841 	WebPSafeFree(tls, tmp_row)
  39842 	return int32(1)
  39843 }
  39844 
  39845 // C documentation
  39846 //
  39847 //	// Note: Expects "enc->palette" to be set properly.
  39848 func MapImageFromPalette(tls *libc.TLS, enc uintptr) (r int32) {
  39849 	var height, palette_size, width, xbits, v1 int32
  39850 	var palette, pic uintptr
  39851 	var v3, v4 uint32_t
  39852 	_, _, _, _, _, _, _, _, _ = height, palette, palette_size, pic, width, xbits, v1, v3, v4
  39853 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  39854 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  39855 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  39856 	palette = enc + 104
  39857 	palette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  39858 	// Replace each input pixel by corresponding palette index.
  39859 	// This is done line by line.
  39860 	if palette_size <= int32(4) {
  39861 		if palette_size <= int32(2) {
  39862 			v1 = int32(3)
  39863 		} else {
  39864 			v1 = int32(2)
  39865 		}
  39866 		xbits = v1
  39867 	} else {
  39868 		if palette_size <= int32(16) {
  39869 			v1 = int32(1)
  39870 		} else {
  39871 			v1 = 0
  39872 		}
  39873 		xbits = v1
  39874 	}
  39875 	v3 = libc.Uint32FromInt32(xbits)
  39876 	v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  39877 	goto _5
  39878 _5:
  39879 	if !(AllocateTransformBuffer(tls, enc, libc.Int32FromUint32(v4), height) != 0) {
  39880 		return 0
  39881 	}
  39882 	if !(ApplyPalette(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb, libc.Uint32FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride), (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, libc.Uint32FromInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width), palette, palette_size, width, height, xbits, pic) != 0) {
  39883 		return 0
  39884 	}
  39885 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderPalette)
  39886 	return int32(1)
  39887 }
  39888 
  39889 // C documentation
  39890 //
  39891 //	// Save palette[] to bitstream.
  39892 func EncodePalette(tls *libc.TLS, bw1 uintptr, low_effort int32, enc uintptr, percent_range int32, percent uintptr) (r int32) {
  39893 	bp := tls.Alloc(1024)
  39894 	defer tls.Free(1024)
  39895 	var alpha_and_green, encoded_palette_size, red_and_blue, v3, v6, v9 uint32_t
  39896 	var i, palette_size, v1, v4 int32
  39897 	var palette, v2 uintptr
  39898 	var _ /* tmp_palette at bp+0 */ [256]uint32_t
  39899 	_, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, encoded_palette_size, i, palette, palette_size, red_and_blue, v1, v2, v3, v4, v6, v9
  39900 	palette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  39901 	palette = enc + 104
  39902 	if **(**uint32_t)(__ccgo_up(enc + 104 + uintptr(palette_size-int32(1))*4)) == uint32(0) && palette_size > int32(17) {
  39903 		v1 = palette_size - int32(1)
  39904 	} else {
  39905 		v1 = palette_size
  39906 	}
  39907 	// If the last element is 0, do not store it and count on automatic palette
  39908 	// 0-filling. This can only happen if there is no pixel packing, hence if
  39909 	// there are strictly more than 16 colors (after 0 is removed).
  39910 	encoded_palette_size = libc.Uint32FromInt32(v1)
  39911 	v2 = bw1
  39912 	v3 = uint32(TRANSFORM_PRESENT)
  39913 	v4 = int32(1)
  39914 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39915 		if v4 > libc.Int32FromInt32(0) {
  39916 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39917 				VP8LPutBitsFlushBits(tls, v2)
  39918 			}
  39919 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39920 			**(**int32)(__ccgo_up(v2 + 8)) += v4
  39921 		}
  39922 	} else {
  39923 		VP8LPutBitsInternal(tls, v2, v3, v4)
  39924 	}
  39925 	v2 = bw1
  39926 	v3 = uint32(COLOR_INDEXING_TRANSFORM)
  39927 	v1 = int32(2)
  39928 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39929 		if v1 > libc.Int32FromInt32(0) {
  39930 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39931 				VP8LPutBitsFlushBits(tls, v2)
  39932 			}
  39933 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39934 			**(**int32)(__ccgo_up(v2 + 8)) += v1
  39935 		}
  39936 	} else {
  39937 		VP8LPutBitsInternal(tls, v2, v3, v1)
  39938 	}
  39939 	v2 = bw1
  39940 	v3 = encoded_palette_size - uint32(1)
  39941 	v1 = int32(8)
  39942 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39943 		if v1 > libc.Int32FromInt32(0) {
  39944 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39945 				VP8LPutBitsFlushBits(tls, v2)
  39946 			}
  39947 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39948 			**(**int32)(__ccgo_up(v2 + 8)) += v1
  39949 		}
  39950 	} else {
  39951 		VP8LPutBitsInternal(tls, v2, v3, v1)
  39952 	}
  39953 	i = libc.Int32FromUint32(encoded_palette_size - uint32(1))
  39954 	for {
  39955 		if !(i >= int32(1)) {
  39956 			break
  39957 		}
  39958 		v3 = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  39959 		v6 = **(**uint32_t)(__ccgo_up(palette + uintptr(i-int32(1))*4))
  39960 		alpha_and_green = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v6&uint32(0xff00ff00)
  39961 		red_and_blue = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v6&uint32(0x00ff00ff)
  39962 		v9 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  39963 		goto _15
  39964 	_15:
  39965 		(**(**[256]uint32_t)(__ccgo_up(bp)))[i] = v9
  39966 		goto _11
  39967 	_11:
  39968 		;
  39969 		i = i - 1
  39970 	}
  39971 	(**(**[256]uint32_t)(__ccgo_up(bp)))[0] = **(**uint32_t)(__ccgo_up(palette))
  39972 	return EncodeImageNoHuffman(tls, bw1, bp, enc+2312, enc+2152, libc.Int32FromUint32(encoded_palette_size), int32(1), int32(20), low_effort, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, percent_range, percent)
  39973 }
  39974 
  39975 // -----------------------------------------------------------------------------
  39976 // VP8LEncoder
  39977 
  39978 func VP8LEncoderNew(tls *libc.TLS, config uintptr, picture uintptr) (r uintptr) {
  39979 	var enc uintptr
  39980 	_ = enc
  39981 	enc = WebPSafeCalloc(tls, uint64(1), uint64(2328))
  39982 	if enc == libc.UintptrFromInt32(0) {
  39983 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39984 		return libc.UintptrFromInt32(0)
  39985 	}
  39986 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig = config
  39987 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpic = picture
  39988 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  39989 	VP8LEncDspInit(tls)
  39990 	return enc
  39991 }
  39992 
  39993 func VP8LEncoderDelete(tls *libc.TLS, enc uintptr) {
  39994 	var i int32
  39995 	_ = i
  39996 	if enc != libc.UintptrFromInt32(0) {
  39997 		VP8LHashChainClear(tls, enc+2312)
  39998 		i = 0
  39999 		for {
  40000 			if !(i < int32(4)) {
  40001 				break
  40002 			}
  40003 			VP8LBackwardRefsClear(tls, enc+2152+uintptr(i)*40)
  40004 			goto _1
  40005 		_1:
  40006 			;
  40007 			i = i + 1
  40008 		}
  40009 		ClearTransformBuffer(tls, enc)
  40010 		WebPSafeFree(tls, enc)
  40011 	}
  40012 }
  40013 
  40014 // -----------------------------------------------------------------------------
  40015 // Main call
  40016 
  40017 type StreamEncodeContext = struct {
  40018 	Fconfig                   uintptr
  40019 	Fpicture                  uintptr
  40020 	Fbw                       uintptr
  40021 	Fenc                      uintptr
  40022 	Fcrunch_configs           [14]CrunchConfig
  40023 	Fnum_crunch_configs       int32
  40024 	Fred_and_blue_always_zero int32
  40025 	Fstats                    uintptr
  40026 }
  40027 
  40028 func EncodeStreamHook(tls *libc.TLS, input uintptr, data2 uintptr) (r int32) {
  40029 	bp := tls.Alloc(128)
  40030 	defer tls.Free(128)
  40031 	var best_size, byte_position, v12, v2 size_t
  40032 	var bw2, config, crunch_configs, enc, params, picture, stats, v1, v8 uintptr
  40033 	var entropy_idx, height, idx, low_effort, num_crunch_configs, percent_range, quality, red_and_blue_always_zero, remaining_percent, use_near_lossless, width, v5 int32
  40034 	var v9 uint32_t
  40035 	var _ /* bw_best at bp+64 */ VP8LBitWriter
  40036 	var _ /* bw_init at bp+16 */ VP8LBitWriter
  40037 	var _ /* cross_color_transform_bits at bp+116 */ int32
  40038 	var _ /* data_size at bp+8 */ int32
  40039 	var _ /* hdr_size at bp+4 */ int32
  40040 	var _ /* percent at bp+0 */ int32
  40041 	var _ /* predictor_transform_bits at bp+112 */ int32
  40042 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_size, bw2, byte_position, config, crunch_configs, enc, entropy_idx, height, idx, low_effort, num_crunch_configs, params, percent_range, picture, quality, red_and_blue_always_zero, remaining_percent, stats, use_near_lossless, width, v1, v12, v2, v5, v8, v9
  40043 	params = input
  40044 	config = (*StreamEncodeContext)(unsafe.Pointer(params)).Fconfig
  40045 	picture = (*StreamEncodeContext)(unsafe.Pointer(params)).Fpicture
  40046 	bw2 = (*StreamEncodeContext)(unsafe.Pointer(params)).Fbw
  40047 	enc = (*StreamEncodeContext)(unsafe.Pointer(params)).Fenc
  40048 	crunch_configs = params + 32
  40049 	num_crunch_configs = (*StreamEncodeContext)(unsafe.Pointer(params)).Fnum_crunch_configs
  40050 	red_and_blue_always_zero = (*StreamEncodeContext)(unsafe.Pointer(params)).Fred_and_blue_always_zero
  40051 	stats = (*StreamEncodeContext)(unsafe.Pointer(params)).Fstats
  40052 	quality = int32((*WebPConfig)(unsafe.Pointer(config)).Fquality)
  40053 	low_effort = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Fmethod == libc.Int32FromInt32(0))
  40054 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  40055 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  40056 	v1 = bw2
  40057 	v2 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v1)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  40058 	goto _3
  40059 _3:
  40060 	byte_position = v2
  40061 	**(**int32)(__ccgo_up(bp)) = int32(2) // for WebPProgressHook
  40062 	use_near_lossless = 0
  40063 	**(**int32)(__ccgo_up(bp + 4)) = 0
  40064 	**(**int32)(__ccgo_up(bp + 8)) = 0
  40065 	best_size = ^libc.Uint64FromInt32(0)
  40066 	**(**VP8LBitWriter)(__ccgo_up(bp + 16)) = **(**VP8LBitWriter)(__ccgo_up(bw2))
  40067 	_ = data2
  40068 	if !(VP8LBitWriterInit(tls, bp+64, uint64(0)) != 0) || num_crunch_configs > int32(1) && !(VP8LBitWriterClone(tls, bw2, bp+64) != 0) {
  40069 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40070 		goto Error
  40071 	}
  40072 	idx = 0
  40073 	for {
  40074 		if !(idx < num_crunch_configs) {
  40075 			break
  40076 		}
  40077 		entropy_idx = (**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(idx)*28))).Fentropy_idx
  40078 		remaining_percent = int32(97) / num_crunch_configs
  40079 		**(**int32)(__ccgo_up(bp + 112)) = 0
  40080 		**(**int32)(__ccgo_up(bp + 116)) = 0
  40081 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette = libc.BoolInt32(entropy_idx == int32(kPalette) || entropy_idx == int32(kPaletteAndSpatial))
  40082 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green = libc.BoolInt32(entropy_idx == int32(kSubGreen) || entropy_idx == int32(kSpatialSubGreen))
  40083 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict = libc.BoolInt32(entropy_idx == int32(kSpatial) || entropy_idx == int32(kSpatialSubGreen) || entropy_idx == int32(kPaletteAndSpatial))
  40084 		// When using a palette, R/B==0, hence no need to test for cross-color.
  40085 		if low_effort != 0 || (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40086 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color = 0
  40087 		} else {
  40088 			if red_and_blue_always_zero != 0 {
  40089 				v5 = 0
  40090 			} else {
  40091 				v5 = (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict
  40092 			}
  40093 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color = v5
  40094 		}
  40095 		// Reset any parameter in the encoder that is set in the previous iteration.
  40096 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits = 0
  40097 		VP8LBackwardRefsClear(tls, enc+2152)
  40098 		VP8LBackwardRefsClear(tls, enc+2152+1*40)
  40099 		// Apply near-lossless preprocessing.
  40100 		use_near_lossless = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless < int32(100) && !((*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0) && !((*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0))
  40101 		if use_near_lossless != 0 {
  40102 			if !(AllocateTransformBuffer(tls, enc, width, height) != 0) {
  40103 				goto Error
  40104 			}
  40105 			if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderNearLossless) && !(VP8ApplyNearLossless(tls, picture, (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb) != 0) {
  40106 				WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40107 				goto Error
  40108 			}
  40109 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNearLossless)
  40110 		} else {
  40111 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  40112 		}
  40113 		// Encode palette
  40114 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40115 			if !(PaletteSort(tls, (**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(idx)*28))).Fpalette_sorting_type, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, enc+1128, libc.Uint32FromInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size), enc+104) != 0) {
  40116 				WebPEncodingSetError(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40117 				goto Error
  40118 			}
  40119 			percent_range = remaining_percent / int32(4)
  40120 			if !(EncodePalette(tls, bw2, low_effort, enc, percent_range, bp) != 0) {
  40121 				goto Error
  40122 			}
  40123 			remaining_percent = remaining_percent - percent_range
  40124 			if !(MapImageFromPalette(tls, enc) != 0) {
  40125 				goto Error
  40126 			}
  40127 			// If using a color cache, do not have it bigger than the number of
  40128 			// colors.
  40129 			if (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_COLOR_CACHE_BITS) {
  40130 				v5 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size))
  40131 				goto _7
  40132 			_7:
  40133 				(*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits = v5 + int32(1)
  40134 			}
  40135 		}
  40136 		// In case image is not packed.
  40137 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderNearLossless) && (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderPalette) {
  40138 			if !(MakeInputImageCopy(tls, enc) != 0) {
  40139 				goto Error
  40140 			}
  40141 		}
  40142 		// -------------------------------------------------------------------------
  40143 		// Apply transforms and write transform data.
  40144 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green != 0 {
  40145 			ApplySubtractGreen(tls, enc, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, bw2)
  40146 		}
  40147 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  40148 			percent_range = remaining_percent / int32(3)
  40149 			if !(ApplyPredictFilter(tls, enc, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, quality, low_effort, (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green, bw2, percent_range, bp, bp+112) != 0) {
  40150 				goto Error
  40151 			}
  40152 			remaining_percent = remaining_percent - percent_range
  40153 		}
  40154 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  40155 			percent_range = remaining_percent / int32(2)
  40156 			if !(ApplyCrossColorFilter(tls, enc, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, quality, low_effort, bw2, percent_range, bp, bp+116) != 0) {
  40157 				goto Error
  40158 			}
  40159 			remaining_percent = remaining_percent - percent_range
  40160 		}
  40161 		v1 = bw2
  40162 		v9 = libc.BoolUint32(!(libc.Int32FromInt32(TRANSFORM_PRESENT) != 0))
  40163 		v5 = int32(1)
  40164 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  40165 			if v5 > libc.Int32FromInt32(0) {
  40166 				if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  40167 					VP8LPutBitsFlushBits(tls, v1)
  40168 				}
  40169 				**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v9) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  40170 				**(**int32)(__ccgo_up(v1 + 8)) += v5
  40171 			}
  40172 		} else {
  40173 			VP8LPutBitsInternal(tls, v1, v9, v5)
  40174 		} // No more transforms.
  40175 		// -------------------------------------------------------------------------
  40176 		// Encode and write the transformed image.
  40177 		if !(EncodeImageInternal(tls, bw2, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, enc+2312, enc+2152, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, quality, low_effort, crunch_configs+uintptr(idx)*28, enc+80, (*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits, byte_position, bp+4, bp+8, picture, remaining_percent, bp) != 0) {
  40178 			goto Error
  40179 		}
  40180 		// If we are better than what we already have.
  40181 		v1 = bw2
  40182 		v2 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v1)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v1)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  40183 		goto _13
  40184 	_13:
  40185 		if v2 < best_size {
  40186 			v8 = bw2
  40187 			v12 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v8)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v8)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v8)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  40188 			goto _16
  40189 		_16:
  40190 			best_size = v12
  40191 			// Store the BitWriter.
  40192 			VP8LBitWriterSwap(tls, bw2, bp+64)
  40193 			// Update the stats.
  40194 			if stats != libc.UintptrFromInt32(0) {
  40195 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_features = uint32(0)
  40196 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  40197 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(1)
  40198 				}
  40199 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  40200 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(2)
  40201 				}
  40202 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green != 0 {
  40203 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(4)
  40204 				}
  40205 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40206 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(8)
  40207 				}
  40208 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fhistogram_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits
  40209 				(*WebPAuxStats)(unsafe.Pointer(stats)).Ftransform_bits = **(**int32)(__ccgo_up(bp + 112))
  40210 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fcross_color_transform_bits = **(**int32)(__ccgo_up(bp + 116))
  40211 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fcache_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits
  40212 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fpalette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  40213 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_size = libc.Int32FromUint64(best_size - byte_position)
  40214 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_hdr_size = **(**int32)(__ccgo_up(bp + 4))
  40215 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_data_size = **(**int32)(__ccgo_up(bp + 8))
  40216 			}
  40217 		}
  40218 		// Reset the bit writer for the following iteration if any.
  40219 		if num_crunch_configs > int32(1) {
  40220 			VP8LBitWriterReset(tls, bp+16, bw2)
  40221 		}
  40222 		goto _4
  40223 	_4:
  40224 		;
  40225 		idx = idx + 1
  40226 	}
  40227 	VP8LBitWriterSwap(tls, bp+64, bw2)
  40228 	goto Error
  40229 Error:
  40230 	;
  40231 	VP8LBitWriterWipeOut(tls, bp+64)
  40232 	// The hook should return false in case of error.
  40233 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer((*StreamEncodeContext)(unsafe.Pointer(params)).Fpicture)).Ferror_code == int32(VP8_ENC_OK))
  40234 }
  40235 
  40236 func VP8LEncodeStream(tls *libc.TLS, config uintptr, picture1 uintptr, bw_main uintptr) (r int32) {
  40237 	bp := tls.Alloc(1872)
  40238 	defer tls.Free(1872)
  40239 	var enc_main, enc_side, param, worker, worker_interface, v7, v8 uintptr
  40240 	var idx, num_crunch_configs_side, ok_main, ok_side, params_size, v1 int32
  40241 	var v11, v14 size_t
  40242 	var _ /* bw_side at bp+1568 */ VP8LBitWriter
  40243 	var _ /* crunch_configs at bp+0 */ [14]CrunchConfig
  40244 	var _ /* num_crunch_configs_main at bp+392 */ int32
  40245 	var _ /* params_main at bp+496 */ StreamEncodeContext
  40246 	var _ /* params_side at bp+936 */ StreamEncodeContext
  40247 	var _ /* picture_side at bp+1616 */ WebPPicture
  40248 	var _ /* red_and_blue_always_zero at bp+396 */ int32
  40249 	var _ /* stats_side at bp+1376 */ WebPAuxStats
  40250 	var _ /* worker_main at bp+400 */ WebPWorker
  40251 	var _ /* worker_side at bp+448 */ WebPWorker
  40252 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc_main, enc_side, idx, num_crunch_configs_side, ok_main, ok_side, param, params_size, worker, worker_interface, v1, v11, v14, v7, v8
  40253 	enc_main = VP8LEncoderNew(tls, config, picture1)
  40254 	enc_side = libc.UintptrFromInt32(0)
  40255 	num_crunch_configs_side = 0
  40256 	**(**int32)(__ccgo_up(bp + 396)) = 0
  40257 	worker_interface = WebPGetWorkerInterface(tls)
  40258 	if enc_main == libc.UintptrFromInt32(0) || !(VP8LBitWriterInit(tls, bp+1568, uint64(0)) != 0) {
  40259 		VP8LEncoderDelete(tls, enc_main)
  40260 		return WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40261 	}
  40262 	// Avoid "garbage value" error from Clang's static analysis tool.
  40263 	v1 = WebPPictureInitInternal(tls, bp+1616, int32(WEBP_ENCODER_ABI_VERSION))
  40264 	goto _2
  40265 _2:
  40266 	if !(v1 != 0) {
  40267 		goto Error
  40268 	}
  40269 	// Analyze image (entropy, num_palettes etc)
  40270 	if !(EncoderAnalyze(tls, enc_main, bp, bp+392, bp+396) != 0) || !(EncoderInit(tls, enc_main) != 0) {
  40271 		WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40272 		goto Error
  40273 	}
  40274 	// Split the configs between the main and side threads (if any).
  40275 	if (*WebPConfig)(unsafe.Pointer(config)).Fthread_level > 0 {
  40276 		num_crunch_configs_side = **(**int32)(__ccgo_up(bp + 392)) / int32(2)
  40277 		idx = 0
  40278 		for {
  40279 			if !(idx < num_crunch_configs_side) {
  40280 				break
  40281 			}
  40282 			**(**CrunchConfig)(__ccgo_up(bp + 936 + 32 + uintptr(idx)*28)) = (**(**[14]CrunchConfig)(__ccgo_up(bp)))[**(**int32)(__ccgo_up(bp + 392))-num_crunch_configs_side+idx]
  40283 			goto _3
  40284 		_3:
  40285 			;
  40286 			idx = idx + 1
  40287 		}
  40288 		(**(**StreamEncodeContext)(__ccgo_up(bp + 936))).Fnum_crunch_configs = num_crunch_configs_side
  40289 	}
  40290 	**(**int32)(__ccgo_up(bp + 392)) = **(**int32)(__ccgo_up(bp + 392)) - num_crunch_configs_side
  40291 	idx = 0
  40292 	for {
  40293 		if !(idx < **(**int32)(__ccgo_up(bp + 392))) {
  40294 			break
  40295 		}
  40296 		**(**CrunchConfig)(__ccgo_up(bp + 496 + 32 + uintptr(idx)*28)) = (**(**[14]CrunchConfig)(__ccgo_up(bp)))[idx]
  40297 		goto _4
  40298 	_4:
  40299 		;
  40300 		idx = idx + 1
  40301 	}
  40302 	(**(**StreamEncodeContext)(__ccgo_up(bp + 496))).Fnum_crunch_configs = **(**int32)(__ccgo_up(bp + 392))
  40303 	// Fill in the parameters for the thread workers.
  40304 	if num_crunch_configs_side > 0 {
  40305 		v1 = int32(2)
  40306 	} else {
  40307 		v1 = int32(1)
  40308 	}
  40309 	params_size = v1
  40310 	idx = 0
  40311 	for {
  40312 		if !(idx < params_size) {
  40313 			break
  40314 		}
  40315 		if idx == 0 {
  40316 			v7 = bp + 400
  40317 		} else {
  40318 			v7 = bp + 448
  40319 		}
  40320 		// Create the parameters for each worker.
  40321 		worker = v7
  40322 		if idx == 0 {
  40323 			v8 = bp + 496
  40324 		} else {
  40325 			v8 = bp + 936
  40326 		}
  40327 		param = v8
  40328 		(*StreamEncodeContext)(unsafe.Pointer(param)).Fconfig = config
  40329 		(*StreamEncodeContext)(unsafe.Pointer(param)).Fred_and_blue_always_zero = **(**int32)(__ccgo_up(bp + 396))
  40330 		if idx == 0 {
  40331 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fpicture = picture1
  40332 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fstats = (*WebPPicture)(unsafe.Pointer(picture1)).Fstats
  40333 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fbw = bw_main
  40334 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fenc = enc_main
  40335 		} else {
  40336 			// Create a side picture (error_code is not thread-safe).
  40337 			if !(WebPPictureView(tls, picture1, 0, 0, (*WebPPicture)(unsafe.Pointer(picture1)).Fwidth, (*WebPPicture)(unsafe.Pointer(picture1)).Fheight, bp+1616) != 0) {
  40338 			}
  40339 			(**(**WebPPicture)(__ccgo_up(bp + 1616))).Fprogress_hook = libc.UintptrFromInt32(0) // Progress hook is not thread-safe.
  40340 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fpicture = bp + 1616                  // No need to free a view afterwards.
  40341 			if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats == libc.UintptrFromInt32(0) {
  40342 				v7 = libc.UintptrFromInt32(0)
  40343 			} else {
  40344 				v7 = bp + 1376
  40345 			}
  40346 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fstats = v7
  40347 			// Create a side bit writer.
  40348 			if !(VP8LBitWriterClone(tls, bw_main, bp+1568) != 0) {
  40349 				WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40350 				goto Error
  40351 			}
  40352 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fbw = bp + 1568
  40353 			// Create a side encoder.
  40354 			enc_side = VP8LEncoderNew(tls, config, bp+1616)
  40355 			if enc_side == libc.UintptrFromInt32(0) || !(EncoderInit(tls, enc_side) != 0) {
  40356 				WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40357 				goto Error
  40358 			}
  40359 			// Copy the values that were computed for the main encoder.
  40360 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fhisto_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fhisto_bits
  40361 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fpredictor_transform_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fpredictor_transform_bits
  40362 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fcross_color_transform_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fcross_color_transform_bits
  40363 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fpalette_size = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fpalette_size
  40364 			libc.X__builtin___memcpy_chk(tls, enc_side+104, enc_main+104, uint64(1024), ^__predefined_size_t(0))
  40365 			libc.X__builtin___memcpy_chk(tls, enc_side+1128, enc_main+1128, uint64(1024), ^__predefined_size_t(0))
  40366 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fenc = enc_side
  40367 		}
  40368 		// Create the workers.
  40369 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FInit})))(tls, worker)
  40370 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = param
  40371 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = libc.UintptrFromInt32(0)
  40372 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(EncodeStreamHook)
  40373 		goto _6
  40374 	_6:
  40375 		;
  40376 		idx = idx + 1
  40377 	}
  40378 	// Start the second thread if needed.
  40379 	if num_crunch_configs_side != 0 {
  40380 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FReset})))(tls, bp+448) != 0) {
  40381 			WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40382 			goto Error
  40383 		}
  40384 		// This line is here and not in the param initialization above to remove a
  40385 		// Clang static analyzer warning.
  40386 		if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats != libc.UintptrFromInt32(0) {
  40387 			libc.X__builtin___memcpy_chk(tls, bp+1376, (*WebPPicture)(unsafe.Pointer(picture1)).Fstats, uint64(188), ^__predefined_size_t(0))
  40388 		}
  40389 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FLaunch})))(tls, bp+448)
  40390 	}
  40391 	// Execute the main thread.
  40392 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FExecute})))(tls, bp+400)
  40393 	ok_main = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp+400)
  40394 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp+400)
  40395 	if num_crunch_configs_side != 0 {
  40396 		// Wait for the second thread.
  40397 		ok_side = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp+448)
  40398 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp+448)
  40399 		if !(ok_main != 0) || !(ok_side != 0) {
  40400 			if (*WebPPicture)(unsafe.Pointer(picture1)).Ferror_code == int32(VP8_ENC_OK) {
  40401 				WebPEncodingSetError(tls, picture1, (**(**WebPPicture)(__ccgo_up(bp + 1616))).Ferror_code)
  40402 			}
  40403 			goto Error
  40404 		}
  40405 		v7 = bp + 1568
  40406 		v11 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v7)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v7)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v7)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  40407 		goto _12
  40408 	_12:
  40409 		v8 = bw_main
  40410 		v14 = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(v8)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(v8)).Fbuf) + int64(((*VP8LBitWriter)(unsafe.Pointer(v8)).Fused+libc.Int32FromInt32(7))>>libc.Int32FromInt32(3)))
  40411 		goto _15
  40412 	_15:
  40413 		if v11 < v14 {
  40414 			VP8LBitWriterSwap(tls, bw_main, bp+1568)
  40415 			if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats != libc.UintptrFromInt32(0) {
  40416 				libc.X__builtin___memcpy_chk(tls, (*WebPPicture)(unsafe.Pointer(picture1)).Fstats, bp+1376, uint64(188), ^__predefined_size_t(0))
  40417 			}
  40418 		}
  40419 	}
  40420 	goto Error
  40421 Error:
  40422 	;
  40423 	VP8LBitWriterWipeOut(tls, bp+1568)
  40424 	VP8LEncoderDelete(tls, enc_main)
  40425 	VP8LEncoderDelete(tls, enc_side)
  40426 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture1)).Ferror_code == int32(VP8_ENC_OK))
  40427 }
  40428 
  40429 func VP8LEncodeImage(tls *libc.TLS, config uintptr, picture uintptr) (r int32) {
  40430 	bp := tls.Alloc(64)
  40431 	defer tls.Free(64)
  40432 	var has_alpha, height, initial_size, mb_h, mb_w, width, v1 int32
  40433 	var stats uintptr
  40434 	var _ /* bw at bp+16 */ VP8LBitWriter
  40435 	var _ /* coded_size at bp+0 */ size_t
  40436 	var _ /* percent at bp+8 */ int32
  40437 	_, _, _, _, _, _, _, _ = has_alpha, height, initial_size, mb_h, mb_w, stats, width, v1
  40438 	**(**int32)(__ccgo_up(bp + 8)) = 0
  40439 	if picture == libc.UintptrFromInt32(0) {
  40440 		return 0
  40441 	}
  40442 	if config == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(picture)).Fargb == libc.UintptrFromInt32(0) {
  40443 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  40444 	}
  40445 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  40446 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  40447 	// Initialize BitWriter with size corresponding to 16 bpp to photo images and
  40448 	// 8 bpp for graphical images.
  40449 	if (*WebPConfig)(unsafe.Pointer(config)).Fimage_hint == int32(WEBP_HINT_GRAPH) {
  40450 		v1 = width * height
  40451 	} else {
  40452 		v1 = width * height * int32(2)
  40453 	}
  40454 	initial_size = v1
  40455 	if !(VP8LBitWriterInit(tls, bp+16, libc.Uint64FromInt32(initial_size)) != 0) {
  40456 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40457 		goto Error
  40458 	}
  40459 	if !!(WebPReportProgress(tls, picture, int32(1), bp+8) != 0) {
  40460 		goto _2
  40461 	}
  40462 	goto UserAbort
  40463 UserAbort:
  40464 	;
  40465 	WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_USER_ABORT))
  40466 	goto Error
  40467 _2:
  40468 	;
  40469 	// Reset stats (for pure lossless coding)
  40470 	if (*WebPPicture)(unsafe.Pointer(picture)).Fstats != libc.UintptrFromInt32(0) {
  40471 		stats = (*WebPPicture)(unsafe.Pointer(picture)).Fstats
  40472 		libc.X__builtin___memset_chk(tls, stats, 0, uint64(188), ^__predefined_size_t(0))
  40473 		**(**float32)(__ccgo_up(stats + 4)) = libc.Float32FromFloat32(99)
  40474 		**(**float32)(__ccgo_up(stats + 4 + 1*4)) = libc.Float32FromFloat32(99)
  40475 		**(**float32)(__ccgo_up(stats + 4 + 2*4)) = libc.Float32FromFloat32(99)
  40476 		**(**float32)(__ccgo_up(stats + 4 + 3*4)) = libc.Float32FromFloat32(99)
  40477 		**(**float32)(__ccgo_up(stats + 4 + 4*4)) = libc.Float32FromFloat32(99)
  40478 	}
  40479 	// Write image size.
  40480 	if !(WriteImageSize(tls, picture, bp+16) != 0) {
  40481 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40482 		goto Error
  40483 	}
  40484 	has_alpha = WebPPictureHasTransparency(tls, picture)
  40485 	// Write the non-trivial Alpha flag and lossless version.
  40486 	if !(WriteRealAlphaAndVersion(tls, bp+16, has_alpha) != 0) {
  40487 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40488 		goto Error
  40489 	}
  40490 	if !(WebPReportProgress(tls, picture, int32(2), bp+8) != 0) {
  40491 		goto UserAbort
  40492 	}
  40493 	// Encode main image stream.
  40494 	if !(VP8LEncodeStream(tls, config, picture, bp+16) != 0) {
  40495 		goto Error
  40496 	}
  40497 	if !(WebPReportProgress(tls, picture, int32(99), bp+8) != 0) {
  40498 		goto UserAbort
  40499 	}
  40500 	// Finish the RIFF chunk.
  40501 	if !(WriteImage(tls, picture, bp+16, bp) != 0) {
  40502 		goto Error
  40503 	}
  40504 	if !(WebPReportProgress(tls, picture, int32(100), bp+8) != 0) {
  40505 		goto UserAbort
  40506 	}
  40507 	// Save size.
  40508 	if (*WebPPicture)(unsafe.Pointer(picture)).Fstats != libc.UintptrFromInt32(0) {
  40509 		**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer(picture)).Fstats)) += libc.Int32FromUint64(**(**size_t)(__ccgo_up(bp)))
  40510 		(*WebPAuxStats)(unsafe.Pointer((*WebPPicture)(unsafe.Pointer(picture)).Fstats)).Flossless_size = libc.Int32FromUint64(**(**size_t)(__ccgo_up(bp)))
  40511 	}
  40512 	if (*WebPPicture)(unsafe.Pointer(picture)).Fextra_info != libc.UintptrFromInt32(0) {
  40513 		mb_w = (width + int32(15)) >> int32(4)
  40514 		mb_h = (height + int32(15)) >> int32(4)
  40515 		libc.X__builtin___memset_chk(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fextra_info, 0, libc.Uint64FromInt32(mb_w*mb_h)*uint64(1), ^__predefined_size_t(0))
  40516 	}
  40517 	goto Error
  40518 Error:
  40519 	;
  40520 	if (**(**VP8LBitWriter)(__ccgo_up(bp + 16))).Ferror1 != 0 {
  40521 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40522 	}
  40523 	VP8LBitWriterWipeOut(tls, bp+16)
  40524 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Ferror_code == int32(VP8_ENC_OK))
  40525 }
  40526 
  40527 const VP8L_MAGIC_BYTE4 = 0x2f
  40528 const __FLT_MIN__9 = 1.1754943508222875e-38
  40529 
  40530 //------------------------------------------------------------------------------
  40531 
  40532 // Copyright 2012 Google Inc. All Rights Reserved.
  40533 //
  40534 // Use of this source code is governed by a BSD-style license
  40535 // that can be found in the COPYING file in the root of the source
  40536 // tree. An additional intellectual property rights grant can be found
  40537 // in the file PATENTS. All contributing project authors may
  40538 // be found in the AUTHORS file in the root of the source tree.
  40539 // -----------------------------------------------------------------------------
  40540 //
  40541 // Misc. common utility functions
  40542 //
  40543 // Authors: Skal (pascal.massimino@gmail.com)
  40544 //          Urvang (urvang@google.com)
  40545 
  40546 // Copyright 2011 Google Inc. All Rights Reserved.
  40547 //
  40548 // Use of this source code is governed by a BSD-style license
  40549 // that can be found in the COPYING file in the root of the source
  40550 // tree. An additional intellectual property rights grant can be found
  40551 // in the file PATENTS. All contributing project authors may
  40552 // be found in the AUTHORS file in the root of the source tree.
  40553 // -----------------------------------------------------------------------------
  40554 //
  40555 //   WebP encoder: main interface
  40556 //
  40557 // Author: Skal (pascal.massimino@gmail.com)
  40558 
  40559 // #define PRINT_MEMORY_INFO
  40560 
  40561 //------------------------------------------------------------------------------
  40562 
  40563 func WebPGetEncoderVersion(tls *libc.TLS) (r int32) {
  40564 	return libc.Int32FromInt32(ENC_MAJ_VERSION)<<libc.Int32FromInt32(16) | libc.Int32FromInt32(ENC_MIN_VERSION)<<libc.Int32FromInt32(8) | libc.Int32FromInt32(ENC_REV_VERSION)
  40565 }
  40566 
  40567 //------------------------------------------------------------------------------
  40568 // VP8Encoder
  40569 //------------------------------------------------------------------------------
  40570 
  40571 func ResetSegmentHeader1(tls *libc.TLS, enc uintptr) {
  40572 	var hdr uintptr
  40573 	_ = hdr
  40574 	hdr = enc + 32
  40575 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsegments
  40576 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = libc.BoolInt32((*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments > int32(1))
  40577 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fsize = 0
  40578 }
  40579 
  40580 func ResetFilterHeader(tls *libc.TLS, enc uintptr) {
  40581 	var hdr uintptr
  40582 	_ = hdr
  40583 	hdr = enc + 16
  40584 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsimple = int32(1)
  40585 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Flevel = 0
  40586 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsharpness = 0
  40587 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta = 0
  40588 }
  40589 
  40590 func ResetBoundaryPredictions(tls *libc.TLS, enc uintptr) {
  40591 	var i int32
  40592 	var left, top uintptr
  40593 	_, _, _ = i, left, top
  40594 	top = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds - uintptr((*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  40595 	left = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds - uintptr(1)
  40596 	i = -int32(1)
  40597 	for {
  40598 		if !(i < int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w) {
  40599 			break
  40600 		}
  40601 		**(**uint8_t)(__ccgo_up(top + uintptr(i))) = uint8(B_DC_PRED)
  40602 		goto _1
  40603 	_1:
  40604 		;
  40605 		i = i + 1
  40606 	}
  40607 	i = 0
  40608 	for {
  40609 		if !(i < int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  40610 			break
  40611 		}
  40612 		**(**uint8_t)(__ccgo_up(left + uintptr(i*(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w))) = uint8(B_DC_PRED)
  40613 		goto _2
  40614 	_2:
  40615 		;
  40616 		i = i + 1
  40617 	}
  40618 	**(**uint32_t)(__ccgo_up((*VP8Encoder)(unsafe.Pointer(enc)).Fnz + uintptr(-libc.Int32FromInt32(1))*4)) = uint32(0) // constant
  40619 }
  40620 
  40621 // Mapping from config->method to coding tools used.
  40622 //-------------------+---+---+---+---+---+---+---+
  40623 //   Method          | 0 | 1 | 2 | 3 |(4)| 5 | 6 |
  40624 //-------------------+---+---+---+---+---+---+---+
  40625 // fast probe        | x |   |   | x |   |   |   |
  40626 //-------------------+---+---+---+---+---+---+---+
  40627 // dynamic proba     | ~ | x | x | x | x | x | x |
  40628 //-------------------+---+---+---+---+---+---+---+
  40629 // fast mode analysis|[x]|[x]|   |   | x | x | x |
  40630 //-------------------+---+---+---+---+---+---+---+
  40631 // basic rd-opt      |   |   |   | x | x | x | x |
  40632 //-------------------+---+---+---+---+---+---+---+
  40633 // disto-refine i4/16| x | x | x |   |   |   |   |
  40634 //-------------------+---+---+---+---+---+---+---+
  40635 // disto-refine uv   |   | x | x |   |   |   |   |
  40636 //-------------------+---+---+---+---+---+---+---+
  40637 // rd-opt i4/16      |   |   | ~ | x | x | x | x |
  40638 //-------------------+---+---+---+---+---+---+---+
  40639 // token buffer (opt)|   |   |   | x | x | x | x |
  40640 //-------------------+---+---+---+---+---+---+---+
  40641 // Trellis           |   |   |   |   |   | x |Ful|
  40642 //-------------------+---+---+---+---+---+---+---+
  40643 // full-SNS          |   |   |   |   | x | x | x |
  40644 //-------------------+---+---+---+---+---+---+---+
  40645 
  40646 func MapConfigToTools(tls *libc.TLS, enc uintptr) {
  40647 	var config uintptr
  40648 	var limit, method, v1, v2, v3 int32
  40649 	_, _, _, _, _, _ = config, limit, method, v1, v2, v3
  40650 	config = (*VP8Encoder)(unsafe.Pointer(enc)).Fconfig
  40651 	method = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  40652 	limit = int32(100) - (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit
  40653 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmethod = method
  40654 	if method >= int32(6) {
  40655 		v1 = int32(RD_OPT_TRELLIS_ALL)
  40656 	} else {
  40657 		if method >= int32(5) {
  40658 			v2 = int32(RD_OPT_TRELLIS)
  40659 		} else {
  40660 			if method >= int32(3) {
  40661 				v3 = int32(RD_OPT_BASIC)
  40662 			} else {
  40663 				v3 = int32(RD_OPT_NONE)
  40664 			}
  40665 			v2 = v3
  40666 		}
  40667 		v1 = v2
  40668 	}
  40669 	(*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level = v1
  40670 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits = libc.Int32FromInt32(256) * libc.Int32FromInt32(16) * libc.Int32FromInt32(16) * (limit * limit) / (libc.Int32FromInt32(100) * libc.Int32FromInt32(100)) // ... modulated with a quadratic curve.
  40671 	// partition0 = 512k max.
  40672 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_header_limit = int32(libc.Int64FromInt32(256) * libc.Int64FromInt32(510) * libc.Int64FromInt32(8) * libc.Int64FromInt32(1024) / int64((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h))
  40673 	(*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level = (*WebPConfig)(unsafe.Pointer(config)).Fthread_level
  40674 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Ftarget_size > 0 || (*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR > libc.Float32FromInt32(0))
  40675 	if !((*WebPConfig)(unsafe.Pointer(config)).Flow_memory != 0) {
  40676 		(*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens = libc.BoolInt32((*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level >= int32(RD_OPT_BASIC)) // need rd stats
  40677 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens != 0 {
  40678 			(*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts = int32(1) // doesn't work with multi-partition
  40679 		}
  40680 	}
  40681 }
  40682 
  40683 // Memory scaling with dimensions:
  40684 //  memory (bytes) ~= 2.25 * w + 0.0625 * w * h
  40685 //
  40686 // Typical memory footprint (614x440 picture)
  40687 //              encoder: 22111
  40688 //                 info: 4368
  40689 //                preds: 17741
  40690 //          top samples: 1263
  40691 //             non-zero: 175
  40692 //             lf-stats: 0
  40693 //                total: 45658
  40694 // Transient object sizes:
  40695 //       VP8EncIterator: 3360
  40696 //         VP8ModeScore: 872
  40697 //       VP8SegmentInfo: 732
  40698 //          VP8EncProba: 18352
  40699 //              LFStats: 2048
  40700 // Picture size (yuv): 419328
  40701 
  40702 func InitVP8Encoder(tls *libc.TLS, config uintptr, picture uintptr) (r uintptr) {
  40703 	var enc, mem, v3 uintptr
  40704 	var info_size, lf_stats_size, nz_size, preds_size, samples_size, top_derr_size size_t
  40705 	var mb_h, mb_w, preds_h, preds_w, top_stride, use_filter, v5, v6 int32
  40706 	var scale float32
  40707 	var size uint64_t
  40708 	var v1, v2 uint64
  40709 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc, info_size, lf_stats_size, mb_h, mb_w, mem, nz_size, preds_h, preds_size, preds_w, samples_size, scale, size, top_derr_size, top_stride, use_filter, v1, v2, v3, v5, v6
  40710 	use_filter = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength > 0 || (*WebPConfig)(unsafe.Pointer(config)).Fautofilter > 0)
  40711 	mb_w = ((*WebPPicture)(unsafe.Pointer(picture)).Fwidth + int32(15)) >> int32(4)
  40712 	mb_h = ((*WebPPicture)(unsafe.Pointer(picture)).Fheight + int32(15)) >> int32(4)
  40713 	preds_w = int32(4)*mb_w + int32(1)
  40714 	preds_h = int32(4)*mb_h + int32(1)
  40715 	preds_size = libc.Uint64FromInt32(preds_w*preds_h) * uint64(1)
  40716 	top_stride = mb_w * int32(16)
  40717 	nz_size = libc.Uint64FromInt32(mb_w+libc.Int32FromInt32(1))*uint64(4) + uint64(WEBP_ALIGN_CST)
  40718 	info_size = libc.Uint64FromInt32(mb_w*mb_h) * uint64(4)
  40719 	samples_size = libc.Uint64FromInt32(int32(2)*top_stride)*uint64(1) + uint64(WEBP_ALIGN_CST)
  40720 	if (*WebPConfig)(unsafe.Pointer(config)).Fautofilter != 0 {
  40721 		v1 = libc.Uint64FromInt64(2048) + libc.Uint64FromInt32(WEBP_ALIGN_CST)
  40722 	} else {
  40723 		v1 = uint64(0)
  40724 	} // align all
  40725 	lf_stats_size = v1
  40726 	if (*WebPConfig)(unsafe.Pointer(config)).Fquality <= libc.Float32FromInt32(ERROR_DIFFUSION_QUALITY) || (*WebPConfig)(unsafe.Pointer(config)).Fpass > int32(1) {
  40727 		v2 = libc.Uint64FromInt32(mb_w) * uint64(4)
  40728 	} else {
  40729 		v2 = uint64(0)
  40730 	}
  40731 	top_derr_size = v2
  40732 	size = libc.Uint64FromInt64(23704) + libc.Uint64FromInt32(WEBP_ALIGN_CST) + info_size + preds_size + samples_size + top_derr_size + nz_size + lf_stats_size // autofilter stats
  40733 	mem = WebPSafeMalloc(tls, size, uint64(1))
  40734 	if mem == libc.UintptrFromInt32(0) {
  40735 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40736 		return libc.UintptrFromInt32(0)
  40737 	}
  40738 	enc = mem
  40739 	mem = uintptr((uint64(mem+libc.UintptrFromInt64(23704)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40740 	libc.X__builtin___memset_chk(tls, enc, 0, uint64(23704), ^__predefined_size_t(0))
  40741 	(*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts = int32(1) << (*WebPConfig)(unsafe.Pointer(config)).Fpartitions
  40742 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w = mb_w
  40743 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h = mb_h
  40744 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w = preds_w
  40745 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info = mem
  40746 	mem = mem + uintptr(info_size)
  40747 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds = mem + uintptr(1) + uintptr((*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  40748 	mem = mem + uintptr(preds_size)
  40749 	(*VP8Encoder)(unsafe.Pointer(enc)).Fnz = uintptr(1)*4 + uintptr((uint64(mem)+libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40750 	mem = mem + uintptr(nz_size)
  40751 	if lf_stats_size != 0 {
  40752 		v3 = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40753 	} else {
  40754 		v3 = libc.UintptrFromInt32(0)
  40755 	}
  40756 	(*VP8Encoder)(unsafe.Pointer(enc)).Flf_stats = v3
  40757 	mem = mem + uintptr(lf_stats_size)
  40758 	// top samples (all 16-aligned)
  40759 	mem = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40760 	(*VP8Encoder)(unsafe.Pointer(enc)).Fy_top = mem
  40761 	(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top + uintptr(top_stride)
  40762 	mem = mem + uintptr(int32(2)*top_stride)
  40763 	if top_derr_size != 0 {
  40764 		v3 = mem
  40765 	} else {
  40766 		v3 = libc.UintptrFromInt32(0)
  40767 	}
  40768 	(*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr = v3
  40769 	mem = mem + uintptr(top_derr_size)
  40770 	(*VP8Encoder)(unsafe.Pointer(enc)).Fconfig = config
  40771 	if use_filter != 0 {
  40772 		if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type == int32(1) {
  40773 			v6 = 0
  40774 		} else {
  40775 			v6 = int32(1)
  40776 		}
  40777 		v5 = v6
  40778 	} else {
  40779 		v5 = int32(2)
  40780 	}
  40781 	(*VP8Encoder)(unsafe.Pointer(enc)).Fprofile = v5
  40782 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpic = picture
  40783 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpercent = 0
  40784 	MapConfigToTools(tls, enc)
  40785 	VP8EncDspInit(tls)
  40786 	VP8DefaultProbas(tls, enc)
  40787 	ResetSegmentHeader1(tls, enc)
  40788 	ResetFilterHeader(tls, enc)
  40789 	ResetBoundaryPredictions(tls, enc)
  40790 	VP8EncDspCostInit(tls)
  40791 	VP8EncInitAlpha(tls, enc)
  40792 	// lower quality means smaller output -> we modulate a little the page
  40793 	// size based on quality. This is just a crude 1rst-order prediction.
  40794 	scale = libc.Float32FromFloat32(1) + float32((*WebPConfig)(unsafe.Pointer(config)).Fquality*libc.Float32FromFloat32(5))/libc.Float32FromFloat32(100) // in [1,6]
  40795 	VP8TBufferInit(tls, enc+496, int32(float32(float32(mb_w*mb_h*libc.Int32FromInt32(4))*scale)))
  40796 	return enc
  40797 }
  40798 
  40799 func DeleteVP8Encoder(tls *libc.TLS, enc uintptr) (r int32) {
  40800 	var ok int32
  40801 	_ = ok
  40802 	ok = int32(1)
  40803 	if enc != libc.UintptrFromInt32(0) {
  40804 		ok = VP8EncDeleteAlpha(tls, enc)
  40805 		VP8TBufferClear(tls, enc+496)
  40806 		WebPSafeFree(tls, enc)
  40807 	}
  40808 	return ok
  40809 }
  40810 
  40811 //------------------------------------------------------------------------------
  40812 
  40813 func GetPSNR2(tls *libc.TLS, err uint64_t, size uint64_t) (r float64) {
  40814 	var v1 float64
  40815 	_ = v1
  40816 	if err > uint64(0) && size > uint64(0) {
  40817 		v1 = float64(float64(10) * libc.Xlog10(tls, float64(float64(libc.Float64FromFloat64(255)*libc.Float64FromFloat64(255))*float64(size))/float64(err)))
  40818 	} else {
  40819 		v1 = float64(99)
  40820 	}
  40821 	return v1
  40822 }
  40823 
  40824 func FinalizePSNR(tls *libc.TLS, enc uintptr) {
  40825 	var size uint64_t
  40826 	var sse, stats uintptr
  40827 	_, _, _ = size, sse, stats
  40828 	stats = (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats
  40829 	size = (*VP8Encoder)(unsafe.Pointer(enc)).Fsse_count
  40830 	sse = enc + 23512
  40831 	**(**float32)(__ccgo_up(stats + 4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse)), size))
  40832 	**(**float32)(__ccgo_up(stats + 4 + 1*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 1*8)), size/uint64(4)))
  40833 	**(**float32)(__ccgo_up(stats + 4 + 2*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 2*8)), size/uint64(4)))
  40834 	**(**float32)(__ccgo_up(stats + 4 + 3*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse))+**(**uint64_t)(__ccgo_up(sse + 1*8))+**(**uint64_t)(__ccgo_up(sse + 2*8)), size*uint64(3)/uint64(2)))
  40835 	**(**float32)(__ccgo_up(stats + 4 + 4*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 3*8)), size))
  40836 }
  40837 
  40838 func StoreStats(tls *libc.TLS, enc uintptr) {
  40839 	var i, s int32
  40840 	var stats uintptr
  40841 	_, _, _ = i, s, stats
  40842 	stats = (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats
  40843 	if stats != libc.UintptrFromInt32(0) {
  40844 		i = 0
  40845 		for {
  40846 			if !(i < int32(NUM_MB_SEGMENTS)) {
  40847 				break
  40848 			}
  40849 			**(**int32)(__ccgo_up(stats + 124 + uintptr(i)*4)) = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Ffstrength
  40850 			**(**int32)(__ccgo_up(stats + 108 + uintptr(i)*4)) = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant
  40851 			s = 0
  40852 			for {
  40853 				if !(s <= int32(2)) {
  40854 					break
  40855 				}
  40856 				**(**int32)(__ccgo_up(stats + 44 + uintptr(s)*16 + uintptr(i)*4)) = **(**int32)(__ccgo_up(enc + 23556 + uintptr(s)*16 + uintptr(i)*4))
  40857 				goto _2
  40858 			_2:
  40859 				;
  40860 				s = s + 1
  40861 			}
  40862 			goto _1
  40863 		_1:
  40864 			;
  40865 			i = i + 1
  40866 		}
  40867 		FinalizePSNR(tls, enc)
  40868 		(*WebPAuxStats)(unsafe.Pointer(stats)).Fcoded_size = (*VP8Encoder)(unsafe.Pointer(enc)).Fcoded_size
  40869 		i = 0
  40870 		for {
  40871 			if !(i < int32(3)) {
  40872 				break
  40873 			}
  40874 			**(**int32)(__ccgo_up(stats + 24 + uintptr(i)*4)) = **(**int32)(__ccgo_up(enc + 23604 + uintptr(i)*4))
  40875 			goto _3
  40876 		_3:
  40877 			;
  40878 			i = i + 1
  40879 		}
  40880 	}
  40881 }
  40882 
  40883 func WebPEncodingSetError(tls *libc.TLS, pic uintptr, error1 WebPEncodingError1) (r int32) {
  40884 	// The oldest error reported takes precedence over the new one.
  40885 	if (*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK) {
  40886 		(*WebPPicture)(unsafe.Pointer(pic)).Ferror_code = error1
  40887 	}
  40888 	return 0
  40889 }
  40890 
  40891 func WebPReportProgress(tls *libc.TLS, pic uintptr, percent int32, percent_store uintptr) (r int32) {
  40892 	if percent_store != libc.UintptrFromInt32(0) && percent != **(**int32)(__ccgo_up(percent_store)) {
  40893 		**(**int32)(__ccgo_up(percent_store)) = percent
  40894 		if (*WebPPicture)(unsafe.Pointer(pic)).Fprogress_hook != 0 && !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fprogress_hook})))(tls, percent, pic) != 0) {
  40895 			// user abort requested
  40896 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_USER_ABORT))
  40897 		}
  40898 	}
  40899 	return int32(1) // ok
  40900 }
  40901 
  40902 //------------------------------------------------------------------------------
  40903 
  40904 func WebPEncode(tls *libc.TLS, config uintptr, pic uintptr) (r int32) {
  40905 	var dithering, x, x2 float32
  40906 	var enc uintptr
  40907 	var ok int32
  40908 	_, _, _, _, _ = dithering, enc, ok, x, x2
  40909 	ok = 0
  40910 	if pic == libc.UintptrFromInt32(0) {
  40911 		return 0
  40912 	}
  40913 	(*WebPPicture)(unsafe.Pointer(pic)).Ferror_code = int32(VP8_ENC_OK) // all ok so far
  40914 	if config == libc.UintptrFromInt32(0) {                             // bad params
  40915 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  40916 	}
  40917 	if !(WebPValidateConfig(tls, config) != 0) {
  40918 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  40919 	}
  40920 	if !(WebPValidatePicture(tls, pic) != 0) {
  40921 		return 0
  40922 	}
  40923 	if (*WebPPicture)(unsafe.Pointer(pic)).Fwidth > int32(WEBP_MAX_DIMENSION) || (*WebPPicture)(unsafe.Pointer(pic)).Fheight > int32(WEBP_MAX_DIMENSION) {
  40924 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  40925 	}
  40926 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  40927 		libc.X__builtin___memset_chk(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fstats, 0, uint64(188), ^__predefined_size_t(0))
  40928 	}
  40929 	if !((*WebPConfig)(unsafe.Pointer(config)).Flossless != 0) {
  40930 		enc = libc.UintptrFromInt32(0)
  40931 		if (*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0 || (*WebPPicture)(unsafe.Pointer(pic)).Fy == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(pic)).Fu == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(pic)).Fv == libc.UintptrFromInt32(0) {
  40932 			// Make sure we have YUVA samples.
  40933 			if (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv != 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing&int32(4) != 0 {
  40934 				if !(WebPPictureSharpARGBToYUVA(tls, pic) != 0) {
  40935 					return 0
  40936 				}
  40937 			} else {
  40938 				dithering = libc.Float32FromFloat32(0)
  40939 				if (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing&int32(2) != 0 {
  40940 					x = (*WebPConfig)(unsafe.Pointer(config)).Fquality / libc.Float32FromFloat32(100)
  40941 					x2 = float32(x * x)
  40942 					// slowly decreasing from max dithering at low quality (q->0)
  40943 					// to 0.5 dithering amplitude at high quality (q->100)
  40944 					dithering = libc.Float32FromFloat32(1) + float32(float32((libc.Float32FromFloat32(0.5)-libc.Float32FromFloat32(1))*x2)*x2)
  40945 				}
  40946 				if !(WebPPictureARGBToYUVADithered(tls, pic, int32(WEBP_YUV420), dithering) != 0) {
  40947 					return 0
  40948 				}
  40949 			}
  40950 		}
  40951 		if !((*WebPConfig)(unsafe.Pointer(config)).Fexact != 0) {
  40952 			WebPCleanupTransparentArea(tls, pic)
  40953 		}
  40954 		enc = InitVP8Encoder(tls, config, pic)
  40955 		if enc == libc.UintptrFromInt32(0) {
  40956 			return 0
  40957 		} // pic->error is already set.
  40958 		// Note: each of the tasks below account for 20% in the progress report.
  40959 		ok = VP8EncAnalyze(tls, enc)
  40960 		// Analysis is done, proceed to actual coding.
  40961 		ok = libc.BoolInt32(ok != 0 && VP8EncStartAlpha(tls, enc) != 0) // possibly done in parallel
  40962 		if !((*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens != 0) {
  40963 			ok = libc.BoolInt32(ok != 0 && VP8EncLoop(tls, enc) != 0)
  40964 		} else {
  40965 			ok = libc.BoolInt32(ok != 0 && VP8EncTokenLoop(tls, enc) != 0)
  40966 		}
  40967 		ok = libc.BoolInt32(ok != 0 && VP8EncFinishAlpha(tls, enc) != 0)
  40968 		ok = libc.BoolInt32(ok != 0 && VP8EncWrite(tls, enc) != 0)
  40969 		StoreStats(tls, enc)
  40970 		if !(ok != 0) {
  40971 			VP8EncFreeBitWriters(tls, enc)
  40972 		}
  40973 		ok = ok & DeleteVP8Encoder(tls, enc) // must always be called, even if !ok
  40974 	} else {
  40975 		// Make sure we have ARGB samples.
  40976 		if (*WebPPicture)(unsafe.Pointer(pic)).Fargb == libc.UintptrFromInt32(0) && !(WebPPictureYUVAToARGB(tls, pic) != 0) {
  40977 			return 0
  40978 		}
  40979 		if !((*WebPConfig)(unsafe.Pointer(config)).Fexact != 0) {
  40980 			WebPReplaceTransparentPixels(tls, pic, uint32(0x000000))
  40981 		}
  40982 		ok = VP8LEncodeImage(tls, config, pic) // Sets pic->error in case of problem.
  40983 	}
  40984 	return ok
  40985 }
  40986 
  40987 const VP8L_LOG8_WBITS = 4
  40988 const __FLT_MIN__10 = 1.17549435082228750796873653722224568e-38
  40989 
  40990 // Copyright 2010 Google Inc. All Rights Reserved.
  40991 //
  40992 // Use of this source code is governed by a BSD-style license
  40993 // that can be found in the COPYING file in the root of the source
  40994 // tree. An additional intellectual property rights grant can be found
  40995 // in the file PATENTS. All contributing project authors may
  40996 // be found in the AUTHORS file in the root of the source tree.
  40997 // -----------------------------------------------------------------------------
  40998 //
  40999 // Boolean decoder
  41000 //
  41001 // Author: Skal (pascal.massimino@gmail.com)
  41002 //         Vikas Arora (vikaas.arora@gmail.com)
  41003 
  41004 // Copyright 2014 Google Inc. All Rights Reserved.
  41005 //
  41006 // Use of this source code is governed by a BSD-style license
  41007 // that can be found in the COPYING file in the root of the source
  41008 // tree. An additional intellectual property rights grant can be found
  41009 // in the file PATENTS. All contributing project authors may
  41010 // be found in the AUTHORS file in the root of the source tree.
  41011 // -----------------------------------------------------------------------------
  41012 //
  41013 // Endian related functions.
  41014 
  41015 // Copyright 2012 Google Inc. All Rights Reserved.
  41016 //
  41017 // Use of this source code is governed by a BSD-style license
  41018 // that can be found in the COPYING file in the root of the source
  41019 // tree. An additional intellectual property rights grant can be found
  41020 // in the file PATENTS. All contributing project authors may
  41021 // be found in the AUTHORS file in the root of the source tree.
  41022 // -----------------------------------------------------------------------------
  41023 //
  41024 // Misc. common utility functions
  41025 //
  41026 // Authors: Skal (pascal.massimino@gmail.com)
  41027 //          Urvang (urvang@google.com)
  41028 
  41029 //------------------------------------------------------------------------------
  41030 // VP8BitReader
  41031 
  41032 func VP8BitReaderSetBuffer(tls *libc.TLS, br uintptr, start uintptr, size size_t) {
  41033 	var v1 uintptr
  41034 	_ = v1
  41035 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf = start
  41036 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end = start + uintptr(size)
  41037 	if size >= uint64(8) {
  41038 		v1 = start + uintptr(size) - uintptr(8) + uintptr(1)
  41039 	} else {
  41040 		v1 = start
  41041 	}
  41042 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf_max = v1
  41043 }
  41044 
  41045 func VP8InitBitReader(tls *libc.TLS, br1 uintptr, start uintptr, size size_t) {
  41046 	bp := tls.Alloc(16)
  41047 	defer tls.Free(16)
  41048 	var bits bit_t
  41049 	var v1 uintptr
  41050 	var v2 uint64_t
  41051 	var _ /* in_bits at bp+0 */ lbit_t
  41052 	_, _, _ = bits, v1, v2
  41053 	// limit ensured by format and upstream checks
  41054 	(*VP8BitReader)(unsafe.Pointer(br1)).Frange1 = libc.Uint32FromInt32(libc.Int32FromInt32(255) - libc.Int32FromInt32(1))
  41055 	(*VP8BitReader)(unsafe.Pointer(br1)).Fvalue = uint64(0)
  41056 	(*VP8BitReader)(unsafe.Pointer(br1)).Fbits = -int32(8) // to load the very first 8bits
  41057 	(*VP8BitReader)(unsafe.Pointer(br1)).Feof = 0
  41058 	VP8BitReaderSetBuffer(tls, br1, start, size)
  41059 	v1 = br1
  41060 	if (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf_max {
  41061 		libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf, uint64(8), ^__predefined_size_t(0))
  41062 		**(**uintptr)(__ccgo_up(v1 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  41063 		v2 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  41064 		goto _3
  41065 	_3:
  41066 		bits = v2
  41067 		bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  41068 		(*VP8BitReader)(unsafe.Pointer(v1)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v1)).Fvalue<<libc.Int32FromInt32(BITS)
  41069 		**(**int32)(__ccgo_up(v1 + 12)) += int32(BITS)
  41070 	} else {
  41071 		VP8LoadFinalBytes(tls, v1)
  41072 	}
  41073 }
  41074 
  41075 func VP8RemapBitReader(tls *libc.TLS, br uintptr, offset ptrdiff_t) {
  41076 	if (*VP8BitReader)(unsafe.Pointer(br)).Fbuf != libc.UintptrFromInt32(0) {
  41077 		**(**uintptr)(__ccgo_up(br + 16)) += uintptr(offset)
  41078 		**(**uintptr)(__ccgo_up(br + 24)) += uintptr(offset)
  41079 		**(**uintptr)(__ccgo_up(br + 32)) += uintptr(offset)
  41080 	}
  41081 }
  41082 
  41083 func VP8LoadFinalBytes(tls *libc.TLS, br uintptr) {
  41084 	var v1, v2 uintptr
  41085 	_, _ = v1, v2
  41086 	// Only read 8bits at a time
  41087 	if (*VP8BitReader)(unsafe.Pointer(br)).Fbuf < (*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end {
  41088 		**(**int32)(__ccgo_up(br + 12)) += int32(8)
  41089 		v2 = br + 16
  41090 		v1 = *(*uintptr)(unsafe.Pointer(v2))
  41091 		*(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1
  41092 		(*VP8BitReader)(unsafe.Pointer(br)).Fvalue = uint64(**(**uint8_t)(__ccgo_up(v1))) | (*VP8BitReader)(unsafe.Pointer(br)).Fvalue<<libc.Int32FromInt32(8)
  41093 	} else {
  41094 		if !((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0) {
  41095 			**(**bit_t)(__ccgo_up(br)) <<= uint64(8)
  41096 			**(**int32)(__ccgo_up(br + 12)) += int32(8)
  41097 			(*VP8BitReader)(unsafe.Pointer(br)).Feof = int32(1)
  41098 		} else {
  41099 			(*VP8BitReader)(unsafe.Pointer(br)).Fbits = 0 // This is to avoid undefined behaviour with shifts.
  41100 		}
  41101 	}
  41102 }
  41103 
  41104 //------------------------------------------------------------------------------
  41105 // Higher-level calls
  41106 
  41107 func VP8GetValue(tls *libc.TLS, br2 uintptr, bits1 int32) (r uint32_t) {
  41108 	bp := tls.Alloc(16)
  41109 	defer tls.Free(16)
  41110 	var bit, pos, shift, v1, v6, v8 int32
  41111 	var bits bit_t
  41112 	var range1, split, value range_t
  41113 	var v uint32_t
  41114 	var v2, v3 uintptr
  41115 	var v4 uint64_t
  41116 	var _ /* in_bits at bp+0 */ lbit_t
  41117 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, pos, range1, shift, split, v, value, v1, v2, v3, v4, v6, v8
  41118 	v = uint32(0)
  41119 	for {
  41120 		v1 = bits1
  41121 		bits1 = bits1 - 1
  41122 		if !(v1 > 0) {
  41123 			break
  41124 		}
  41125 		v2 = br2
  41126 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  41127 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  41128 			v3 = v2
  41129 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  41130 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  41131 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  41132 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  41133 				goto _5
  41134 			_5:
  41135 				bits = v4
  41136 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  41137 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  41138 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  41139 			} else {
  41140 				VP8LoadFinalBytes(tls, v3)
  41141 			}
  41142 		}
  41143 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  41144 		split = range1 * libc.Uint32FromInt32(int32(0x80)) >> int32(8)
  41145 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  41146 		bit = libc.BoolInt32(value > split)
  41147 		if bit != 0 {
  41148 			range1 = range1 - split
  41149 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  41150 		} else {
  41151 			range1 = split + uint32(1)
  41152 		}
  41153 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  41154 		goto _7
  41155 	_7:
  41156 		shift = int32(7) ^ v6
  41157 		range1 = range1 << libc.Uint32FromInt32(shift)
  41158 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  41159 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  41160 		v8 = bit
  41161 		goto _9
  41162 	_9:
  41163 		v = v | libc.Uint32FromInt32(v8<<bits1)
  41164 	}
  41165 	return v
  41166 }
  41167 
  41168 func VP8GetSignedValue(tls *libc.TLS, br uintptr, bits int32) (r int32_t) {
  41169 	var value, v1 int32
  41170 	_, _ = value, v1
  41171 	value = libc.Int32FromUint32(VP8GetValue(tls, br, bits))
  41172 	if VP8GetValue(tls, br, int32(1)) != 0 {
  41173 		v1 = -value
  41174 	} else {
  41175 		v1 = value
  41176 	}
  41177 	return v1
  41178 }
  41179 
  41180 //------------------------------------------------------------------------------
  41181 // VP8LBitReader
  41182 
  41183 var kBitMask = [25]uint32_t{
  41184 	1:  uint32(0x000001),
  41185 	2:  uint32(0x000003),
  41186 	3:  uint32(0x000007),
  41187 	4:  uint32(0x00000f),
  41188 	5:  uint32(0x00001f),
  41189 	6:  uint32(0x00003f),
  41190 	7:  uint32(0x00007f),
  41191 	8:  uint32(0x0000ff),
  41192 	9:  uint32(0x0001ff),
  41193 	10: uint32(0x0003ff),
  41194 	11: uint32(0x0007ff),
  41195 	12: uint32(0x000fff),
  41196 	13: uint32(0x001fff),
  41197 	14: uint32(0x003fff),
  41198 	15: uint32(0x007fff),
  41199 	16: uint32(0x00ffff),
  41200 	17: uint32(0x01ffff),
  41201 	18: uint32(0x03ffff),
  41202 	19: uint32(0x07ffff),
  41203 	20: uint32(0x0fffff),
  41204 	21: uint32(0x1fffff),
  41205 	22: uint32(0x3fffff),
  41206 	23: uint32(0x7fffff),
  41207 	24: uint32(0xffffff),
  41208 }
  41209 
  41210 func VP8LInitBitReader(tls *libc.TLS, br uintptr, start uintptr, length size_t) {
  41211 	var i size_t
  41212 	var value vp8l_val_t
  41213 	_, _ = i, value
  41214 	value = uint64(0)
  41215 	// can't happen with a RIFF chunk.
  41216 	(*VP8LBitReader)(unsafe.Pointer(br)).Flen1 = length
  41217 	(*VP8LBitReader)(unsafe.Pointer(br)).Fval = uint64(0)
  41218 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbit_pos = 0
  41219 	(*VP8LBitReader)(unsafe.Pointer(br)).Feos = 0
  41220 	if length > uint64(8) {
  41221 		length = uint64(8)
  41222 	}
  41223 	i = uint64(0)
  41224 	for {
  41225 		if !(i < length) {
  41226 			break
  41227 		}
  41228 		value = value | uint64(**(**uint8_t)(__ccgo_up(start + uintptr(i))))<<(uint64(8)*i)
  41229 		goto _1
  41230 	_1:
  41231 		;
  41232 		i = i + 1
  41233 	}
  41234 	(*VP8LBitReader)(unsafe.Pointer(br)).Fval = value
  41235 	(*VP8LBitReader)(unsafe.Pointer(br)).Fpos = length
  41236 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbuf = start
  41237 }
  41238 
  41239 func VP8LBitReaderSetBuffer(tls *libc.TLS, br1 uintptr, buf uintptr, len1 size_t) {
  41240 	var v1 uintptr
  41241 	var v2 int32
  41242 	var v4 bool
  41243 	_, _, _ = v1, v2, v4
  41244 	// can't happen with a RIFF chunk.
  41245 	(*VP8LBitReader)(unsafe.Pointer(br1)).Fbuf = buf
  41246 	(*VP8LBitReader)(unsafe.Pointer(br1)).Flen1 = len1
  41247 	// 'pos' > 'len' should be considered a param error.
  41248 	if v4 = (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos > (*VP8LBitReader)(unsafe.Pointer(br1)).Flen1; !v4 {
  41249 		v1 = br1
  41250 		v2 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v1)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v1)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v1)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos > int32(VP8L_LBITS))
  41251 		goto _3
  41252 	_3:
  41253 	}
  41254 	(*VP8LBitReader)(unsafe.Pointer(br1)).Feos = libc.BoolInt32(v4 || v2 != 0)
  41255 }
  41256 
  41257 func VP8LSetEndOfStream(tls *libc.TLS, br uintptr) {
  41258 	(*VP8LBitReader)(unsafe.Pointer(br)).Feos = int32(1)
  41259 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbit_pos = 0 // To avoid undefined behaviour with shifts.
  41260 }
  41261 
  41262 // C documentation
  41263 //
  41264 //	// If not at EOS, reload up to VP8L_LBITS byte-by-byte
  41265 func ShiftBytes(tls *libc.TLS, br1 uintptr) {
  41266 	var v1 uintptr
  41267 	var v2 int32
  41268 	_, _ = v1, v2
  41269 	for (*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos >= int32(8) && (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos < (*VP8LBitReader)(unsafe.Pointer(br1)).Flen1 {
  41270 		**(**vp8l_val_t)(__ccgo_up(br1)) >>= uint64(8)
  41271 		**(**vp8l_val_t)(__ccgo_up(br1)) |= uint64(**(**uint8_t)(__ccgo_up((*VP8LBitReader)(unsafe.Pointer(br1)).Fbuf + uintptr((*VP8LBitReader)(unsafe.Pointer(br1)).Fpos)))) << (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(8))
  41272 		(*VP8LBitReader)(unsafe.Pointer(br1)).Fpos = (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos + 1
  41273 		**(**int32)(__ccgo_up(br1 + 32)) -= int32(8)
  41274 	}
  41275 	v1 = br1
  41276 	v2 = libc.BoolInt32((*VP8LBitReader)(unsafe.Pointer(v1)).Feos != 0 || (*VP8LBitReader)(unsafe.Pointer(v1)).Fpos == (*VP8LBitReader)(unsafe.Pointer(v1)).Flen1 && (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos > int32(VP8L_LBITS))
  41277 	goto _3
  41278 _3:
  41279 	if v2 != 0 {
  41280 		VP8LSetEndOfStream(tls, br1)
  41281 	}
  41282 }
  41283 
  41284 func VP8LDoFillBitWindow(tls *libc.TLS, br uintptr) {
  41285 	bp := tls.Alloc(16)
  41286 	defer tls.Free(16)
  41287 	var v1 uint32_t
  41288 	var _ /* A at bp+0 */ uint32_t
  41289 	_ = v1
  41290 	if (*VP8LBitReader)(unsafe.Pointer(br)).Fpos+uint64(8) < (*VP8LBitReader)(unsafe.Pointer(br)).Flen1 {
  41291 		**(**vp8l_val_t)(__ccgo_up(br)) >>= uint64(VP8L_WBITS)
  41292 		**(**int32)(__ccgo_up(br + 32)) -= int32(VP8L_WBITS)
  41293 		libc.X__builtin___memcpy_chk(tls, bp, (*VP8LBitReader)(unsafe.Pointer(br)).Fbuf+uintptr((*VP8LBitReader)(unsafe.Pointer(br)).Fpos), uint64(4), ^__predefined_size_t(0))
  41294 		v1 = **(**uint32_t)(__ccgo_up(bp))
  41295 		goto _2
  41296 	_2:
  41297 		**(**vp8l_val_t)(__ccgo_up(br)) |= uint64(v1) << (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(VP8L_WBITS))
  41298 		**(**size_t)(__ccgo_up(br + 24)) += uint64(VP8L_LOG8_WBITS)
  41299 		return
  41300 	}
  41301 	ShiftBytes(tls, br) // Slow path.
  41302 }
  41303 
  41304 func VP8LReadBits(tls *libc.TLS, br1 uintptr, n_bits int32) (r uint32_t) {
  41305 	var new_bits int32
  41306 	var val, v2 uint32_t
  41307 	var v1 uintptr
  41308 	_, _, _, _ = new_bits, val, v1, v2
  41309 	// Flag an error if end_of_stream or n_bits is more than allowed limit.
  41310 	if !((*VP8LBitReader)(unsafe.Pointer(br1)).Feos != 0) && n_bits <= int32(VP8L_MAX_NUM_BIT_READ) {
  41311 		v1 = br1
  41312 		v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  41313 		goto _3
  41314 	_3:
  41315 		val = v2 & kBitMask[n_bits]
  41316 		new_bits = (*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos + n_bits
  41317 		(*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos = new_bits
  41318 		ShiftBytes(tls, br1)
  41319 		return val
  41320 	} else {
  41321 		VP8LSetEndOfStream(tls, br1)
  41322 		return uint32(0)
  41323 	}
  41324 	return r
  41325 }
  41326 
  41327 const MIN_EXTRA_SIZE = 32768
  41328 
  41329 //------------------------------------------------------------------------------
  41330 
  41331 //------------------------------------------------------------------------------
  41332 // VP8BitWriter
  41333 
  41334 func BitWriterResize(tls *libc.TLS, bw uintptr, extra_size size_t) (r int32) {
  41335 	var needed_size, new_size size_t
  41336 	var needed_size_64b uint64_t
  41337 	var new_buf uintptr
  41338 	_, _, _, _ = needed_size, needed_size_64b, new_buf, new_size
  41339 	needed_size_64b = (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos + extra_size
  41340 	needed_size = needed_size_64b
  41341 	if needed_size_64b != needed_size {
  41342 		(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41343 		return 0
  41344 	}
  41345 	if needed_size <= (*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos {
  41346 		return int32(1)
  41347 	}
  41348 	// If the following line wraps over 32bit, the test just after will catch it.
  41349 	new_size = uint64(2) * (*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos
  41350 	if new_size < needed_size {
  41351 		new_size = needed_size
  41352 	}
  41353 	if new_size < uint64(1024) {
  41354 		new_size = uint64(1024)
  41355 	}
  41356 	new_buf = WebPSafeMalloc(tls, uint64(1), new_size)
  41357 	if new_buf == libc.UintptrFromInt32(0) {
  41358 		(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41359 		return 0
  41360 	}
  41361 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos > uint64(0) {
  41362 		libc.X__builtin___memcpy_chk(tls, new_buf, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf, (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos, ^__predefined_size_t(0))
  41363 	}
  41364 	WebPSafeFree(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf)
  41365 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf = new_buf
  41366 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos = new_size
  41367 	return int32(1)
  41368 }
  41369 
  41370 func Flush(tls *libc.TLS, bw uintptr) {
  41371 	var bits int32_t
  41372 	var pos, v3 size_t
  41373 	var s, value, v1 int32
  41374 	_, _, _, _, _, _ = bits, pos, s, value, v1, v3
  41375 	s = int32(8) + (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits
  41376 	bits = (*VP8BitWriter)(unsafe.Pointer(bw)).Fvalue >> s
  41377 	**(**int32_t)(__ccgo_up(bw + 4)) -= bits << s
  41378 	**(**int32)(__ccgo_up(bw + 12)) -= int32(8)
  41379 	if bits&int32(0xff) != int32(0xff) {
  41380 		pos = (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos
  41381 		if !(BitWriterResize(tls, bw, libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(bw)).Frun+int32(1))) != 0) {
  41382 			return
  41383 		}
  41384 		if bits&int32(0x100) != 0 { // overflow -> propagate carry over pending 0xff's
  41385 			if pos > uint64(0) {
  41386 				**(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(pos-uint64(1)))) = **(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(pos-uint64(1)))) + 1
  41387 			}
  41388 		}
  41389 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Frun > 0 {
  41390 			if bits&int32(0x100) != 0 {
  41391 				v1 = 0x00
  41392 			} else {
  41393 				v1 = int32(0xff)
  41394 			}
  41395 			value = v1
  41396 			for {
  41397 				if !((*VP8BitWriter)(unsafe.Pointer(bw)).Frun > 0) {
  41398 					break
  41399 				}
  41400 				v3 = pos
  41401 				pos = pos + 1
  41402 				**(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(v3))) = libc.Uint8FromInt32(value)
  41403 				goto _2
  41404 			_2:
  41405 				;
  41406 				(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = (*VP8BitWriter)(unsafe.Pointer(bw)).Frun - 1
  41407 			}
  41408 		}
  41409 		v3 = pos
  41410 		pos = pos + 1
  41411 		**(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(v3))) = libc.Uint8FromInt32(bits & int32(0xff))
  41412 		(*VP8BitWriter)(unsafe.Pointer(bw)).Fpos = pos
  41413 	} else {
  41414 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = (*VP8BitWriter)(unsafe.Pointer(bw)).Frun + 1 // delay writing of bytes 0xff, pending eventual carry.
  41415 	}
  41416 }
  41417 
  41418 //------------------------------------------------------------------------------
  41419 // renormalization
  41420 
  41421 var kNorm = [128]uint8_t{
  41422 	0:   uint8(7),
  41423 	1:   uint8(6),
  41424 	2:   uint8(6),
  41425 	3:   uint8(5),
  41426 	4:   uint8(5),
  41427 	5:   uint8(5),
  41428 	6:   uint8(5),
  41429 	7:   uint8(4),
  41430 	8:   uint8(4),
  41431 	9:   uint8(4),
  41432 	10:  uint8(4),
  41433 	11:  uint8(4),
  41434 	12:  uint8(4),
  41435 	13:  uint8(4),
  41436 	14:  uint8(4),
  41437 	15:  uint8(3),
  41438 	16:  uint8(3),
  41439 	17:  uint8(3),
  41440 	18:  uint8(3),
  41441 	19:  uint8(3),
  41442 	20:  uint8(3),
  41443 	21:  uint8(3),
  41444 	22:  uint8(3),
  41445 	23:  uint8(3),
  41446 	24:  uint8(3),
  41447 	25:  uint8(3),
  41448 	26:  uint8(3),
  41449 	27:  uint8(3),
  41450 	28:  uint8(3),
  41451 	29:  uint8(3),
  41452 	30:  uint8(3),
  41453 	31:  uint8(2),
  41454 	32:  uint8(2),
  41455 	33:  uint8(2),
  41456 	34:  uint8(2),
  41457 	35:  uint8(2),
  41458 	36:  uint8(2),
  41459 	37:  uint8(2),
  41460 	38:  uint8(2),
  41461 	39:  uint8(2),
  41462 	40:  uint8(2),
  41463 	41:  uint8(2),
  41464 	42:  uint8(2),
  41465 	43:  uint8(2),
  41466 	44:  uint8(2),
  41467 	45:  uint8(2),
  41468 	46:  uint8(2),
  41469 	47:  uint8(2),
  41470 	48:  uint8(2),
  41471 	49:  uint8(2),
  41472 	50:  uint8(2),
  41473 	51:  uint8(2),
  41474 	52:  uint8(2),
  41475 	53:  uint8(2),
  41476 	54:  uint8(2),
  41477 	55:  uint8(2),
  41478 	56:  uint8(2),
  41479 	57:  uint8(2),
  41480 	58:  uint8(2),
  41481 	59:  uint8(2),
  41482 	60:  uint8(2),
  41483 	61:  uint8(2),
  41484 	62:  uint8(2),
  41485 	63:  uint8(1),
  41486 	64:  uint8(1),
  41487 	65:  uint8(1),
  41488 	66:  uint8(1),
  41489 	67:  uint8(1),
  41490 	68:  uint8(1),
  41491 	69:  uint8(1),
  41492 	70:  uint8(1),
  41493 	71:  uint8(1),
  41494 	72:  uint8(1),
  41495 	73:  uint8(1),
  41496 	74:  uint8(1),
  41497 	75:  uint8(1),
  41498 	76:  uint8(1),
  41499 	77:  uint8(1),
  41500 	78:  uint8(1),
  41501 	79:  uint8(1),
  41502 	80:  uint8(1),
  41503 	81:  uint8(1),
  41504 	82:  uint8(1),
  41505 	83:  uint8(1),
  41506 	84:  uint8(1),
  41507 	85:  uint8(1),
  41508 	86:  uint8(1),
  41509 	87:  uint8(1),
  41510 	88:  uint8(1),
  41511 	89:  uint8(1),
  41512 	90:  uint8(1),
  41513 	91:  uint8(1),
  41514 	92:  uint8(1),
  41515 	93:  uint8(1),
  41516 	94:  uint8(1),
  41517 	95:  uint8(1),
  41518 	96:  uint8(1),
  41519 	97:  uint8(1),
  41520 	98:  uint8(1),
  41521 	99:  uint8(1),
  41522 	100: uint8(1),
  41523 	101: uint8(1),
  41524 	102: uint8(1),
  41525 	103: uint8(1),
  41526 	104: uint8(1),
  41527 	105: uint8(1),
  41528 	106: uint8(1),
  41529 	107: uint8(1),
  41530 	108: uint8(1),
  41531 	109: uint8(1),
  41532 	110: uint8(1),
  41533 	111: uint8(1),
  41534 	112: uint8(1),
  41535 	113: uint8(1),
  41536 	114: uint8(1),
  41537 	115: uint8(1),
  41538 	116: uint8(1),
  41539 	117: uint8(1),
  41540 	118: uint8(1),
  41541 	119: uint8(1),
  41542 	120: uint8(1),
  41543 	121: uint8(1),
  41544 	122: uint8(1),
  41545 	123: uint8(1),
  41546 	124: uint8(1),
  41547 	125: uint8(1),
  41548 	126: uint8(1),
  41549 }
  41550 
  41551 // C documentation
  41552 //
  41553 //	// range = ((range + 1) << kVP8Log2Range[range]) - 1
  41554 var kNewRange = [128]uint8_t{
  41555 	0:   uint8(127),
  41556 	1:   uint8(127),
  41557 	2:   uint8(191),
  41558 	3:   uint8(127),
  41559 	4:   uint8(159),
  41560 	5:   uint8(191),
  41561 	6:   uint8(223),
  41562 	7:   uint8(127),
  41563 	8:   uint8(143),
  41564 	9:   uint8(159),
  41565 	10:  uint8(175),
  41566 	11:  uint8(191),
  41567 	12:  uint8(207),
  41568 	13:  uint8(223),
  41569 	14:  uint8(239),
  41570 	15:  uint8(127),
  41571 	16:  uint8(135),
  41572 	17:  uint8(143),
  41573 	18:  uint8(151),
  41574 	19:  uint8(159),
  41575 	20:  uint8(167),
  41576 	21:  uint8(175),
  41577 	22:  uint8(183),
  41578 	23:  uint8(191),
  41579 	24:  uint8(199),
  41580 	25:  uint8(207),
  41581 	26:  uint8(215),
  41582 	27:  uint8(223),
  41583 	28:  uint8(231),
  41584 	29:  uint8(239),
  41585 	30:  uint8(247),
  41586 	31:  uint8(127),
  41587 	32:  uint8(131),
  41588 	33:  uint8(135),
  41589 	34:  uint8(139),
  41590 	35:  uint8(143),
  41591 	36:  uint8(147),
  41592 	37:  uint8(151),
  41593 	38:  uint8(155),
  41594 	39:  uint8(159),
  41595 	40:  uint8(163),
  41596 	41:  uint8(167),
  41597 	42:  uint8(171),
  41598 	43:  uint8(175),
  41599 	44:  uint8(179),
  41600 	45:  uint8(183),
  41601 	46:  uint8(187),
  41602 	47:  uint8(191),
  41603 	48:  uint8(195),
  41604 	49:  uint8(199),
  41605 	50:  uint8(203),
  41606 	51:  uint8(207),
  41607 	52:  uint8(211),
  41608 	53:  uint8(215),
  41609 	54:  uint8(219),
  41610 	55:  uint8(223),
  41611 	56:  uint8(227),
  41612 	57:  uint8(231),
  41613 	58:  uint8(235),
  41614 	59:  uint8(239),
  41615 	60:  uint8(243),
  41616 	61:  uint8(247),
  41617 	62:  uint8(251),
  41618 	63:  uint8(127),
  41619 	64:  uint8(129),
  41620 	65:  uint8(131),
  41621 	66:  uint8(133),
  41622 	67:  uint8(135),
  41623 	68:  uint8(137),
  41624 	69:  uint8(139),
  41625 	70:  uint8(141),
  41626 	71:  uint8(143),
  41627 	72:  uint8(145),
  41628 	73:  uint8(147),
  41629 	74:  uint8(149),
  41630 	75:  uint8(151),
  41631 	76:  uint8(153),
  41632 	77:  uint8(155),
  41633 	78:  uint8(157),
  41634 	79:  uint8(159),
  41635 	80:  uint8(161),
  41636 	81:  uint8(163),
  41637 	82:  uint8(165),
  41638 	83:  uint8(167),
  41639 	84:  uint8(169),
  41640 	85:  uint8(171),
  41641 	86:  uint8(173),
  41642 	87:  uint8(175),
  41643 	88:  uint8(177),
  41644 	89:  uint8(179),
  41645 	90:  uint8(181),
  41646 	91:  uint8(183),
  41647 	92:  uint8(185),
  41648 	93:  uint8(187),
  41649 	94:  uint8(189),
  41650 	95:  uint8(191),
  41651 	96:  uint8(193),
  41652 	97:  uint8(195),
  41653 	98:  uint8(197),
  41654 	99:  uint8(199),
  41655 	100: uint8(201),
  41656 	101: uint8(203),
  41657 	102: uint8(205),
  41658 	103: uint8(207),
  41659 	104: uint8(209),
  41660 	105: uint8(211),
  41661 	106: uint8(213),
  41662 	107: uint8(215),
  41663 	108: uint8(217),
  41664 	109: uint8(219),
  41665 	110: uint8(221),
  41666 	111: uint8(223),
  41667 	112: uint8(225),
  41668 	113: uint8(227),
  41669 	114: uint8(229),
  41670 	115: uint8(231),
  41671 	116: uint8(233),
  41672 	117: uint8(235),
  41673 	118: uint8(237),
  41674 	119: uint8(239),
  41675 	120: uint8(241),
  41676 	121: uint8(243),
  41677 	122: uint8(245),
  41678 	123: uint8(247),
  41679 	124: uint8(249),
  41680 	125: uint8(251),
  41681 	126: uint8(253),
  41682 	127: uint8(127),
  41683 }
  41684 
  41685 func VP8PutBit(tls *libc.TLS, bw uintptr, bit int32, prob int32) (r int32) {
  41686 	var shift, split int32
  41687 	_, _ = shift, split
  41688 	split = (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 * prob >> int32(8)
  41689 	if bit != 0 {
  41690 		**(**int32_t)(__ccgo_up(bw + 4)) += split + int32(1)
  41691 		**(**int32_t)(__ccgo_up(bw)) -= split + int32(1)
  41692 	} else {
  41693 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = split
  41694 	}
  41695 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 < int32(127) { // emit 'shift' bits out and renormalize
  41696 		shift = libc.Int32FromUint8(kNorm[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41697 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromUint8(kNewRange[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41698 		**(**int32_t)(__ccgo_up(bw + 4)) <<= shift
  41699 		**(**int32)(__ccgo_up(bw + 12)) += shift
  41700 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits > 0 {
  41701 			Flush(tls, bw)
  41702 		}
  41703 	}
  41704 	return bit
  41705 }
  41706 
  41707 func VP8PutBitUniform(tls *libc.TLS, bw uintptr, bit int32) (r int32) {
  41708 	var split int32
  41709 	_ = split
  41710 	split = (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 >> int32(1)
  41711 	if bit != 0 {
  41712 		**(**int32_t)(__ccgo_up(bw + 4)) += split + int32(1)
  41713 		**(**int32_t)(__ccgo_up(bw)) -= split + int32(1)
  41714 	} else {
  41715 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = split
  41716 	}
  41717 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 < int32(127) {
  41718 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromUint8(kNewRange[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41719 		**(**int32_t)(__ccgo_up(bw + 4)) <<= int32(1)
  41720 		**(**int32)(__ccgo_up(bw + 12)) += int32(1)
  41721 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits > 0 {
  41722 			Flush(tls, bw)
  41723 		}
  41724 	}
  41725 	return bit
  41726 }
  41727 
  41728 func VP8PutBits(tls *libc.TLS, bw uintptr, value uint32_t, nb_bits int32) {
  41729 	var mask uint32_t
  41730 	_ = mask
  41731 	mask = uint32(1) << (nb_bits - int32(1))
  41732 	for {
  41733 		if !(mask != 0) {
  41734 			break
  41735 		}
  41736 		VP8PutBitUniform(tls, bw, libc.Int32FromUint32(value&mask))
  41737 		goto _1
  41738 	_1:
  41739 		;
  41740 		mask = mask >> uint32(1)
  41741 	}
  41742 }
  41743 
  41744 func VP8PutSignedBits(tls *libc.TLS, bw uintptr, value int32, nb_bits int32) {
  41745 	if !(VP8PutBitUniform(tls, bw, libc.BoolInt32(value != 0)) != 0) {
  41746 		return
  41747 	}
  41748 	if value < 0 {
  41749 		VP8PutBits(tls, bw, libc.Uint32FromInt32(-value<<int32(1)|int32(1)), nb_bits+int32(1))
  41750 	} else {
  41751 		VP8PutBits(tls, bw, libc.Uint32FromInt32(value<<int32(1)), nb_bits+int32(1))
  41752 	}
  41753 }
  41754 
  41755 //------------------------------------------------------------------------------
  41756 
  41757 func VP8BitWriterInit(tls *libc.TLS, bw uintptr, expected_size size_t) (r int32) {
  41758 	var v1 int32
  41759 	_ = v1
  41760 	(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromInt32(255) - libc.Int32FromInt32(1)
  41761 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fvalue = 0
  41762 	(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = 0
  41763 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits = -int32(8)
  41764 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fpos = uint64(0)
  41765 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos = uint64(0)
  41766 	(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = 0
  41767 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf = libc.UintptrFromInt32(0)
  41768 	if expected_size > uint64(0) {
  41769 		v1 = BitWriterResize(tls, bw, expected_size)
  41770 	} else {
  41771 		v1 = int32(1)
  41772 	}
  41773 	return v1
  41774 }
  41775 
  41776 func VP8BitWriterFinish(tls *libc.TLS, bw uintptr) (r uintptr) {
  41777 	VP8PutBits(tls, bw, uint32(0), int32(9)-(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits)
  41778 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits = 0 // pad with zeroes
  41779 	Flush(tls, bw)
  41780 	return (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf
  41781 }
  41782 
  41783 func VP8BitWriterAppend(tls *libc.TLS, bw uintptr, data uintptr, size size_t) (r int32) {
  41784 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits != -int32(8) {
  41785 		return 0
  41786 	} // Flush() must have been called
  41787 	if !(BitWriterResize(tls, bw, size) != 0) {
  41788 		return 0
  41789 	}
  41790 	libc.X__builtin___memcpy_chk(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf+uintptr((*VP8BitWriter)(unsafe.Pointer(bw)).Fpos), data, size, ^__predefined_size_t(0))
  41791 	**(**size_t)(__ccgo_up(bw + 24)) += size
  41792 	return int32(1)
  41793 }
  41794 
  41795 func VP8BitWriterWipeOut(tls *libc.TLS, bw uintptr) {
  41796 	if bw != libc.UintptrFromInt32(0) {
  41797 		WebPSafeFree(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf)
  41798 		libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41799 	}
  41800 }
  41801 
  41802 //------------------------------------------------------------------------------
  41803 // VP8LBitWriter
  41804 
  41805 // This is the minimum amount of size the memory buffer is guaranteed to grow
  41806 // when extra space is needed.
  41807 
  41808 // C documentation
  41809 //
  41810 //	// Returns 1 on success.
  41811 func VP8LBitWriterResize(tls *libc.TLS, bw uintptr, extra_size size_t) (r int32) {
  41812 	var allocated_buf uintptr
  41813 	var allocated_size, current_size, max_bytes, size_required size_t
  41814 	var size_required_64b uint64_t
  41815 	_, _, _, _, _, _ = allocated_buf, allocated_size, current_size, max_bytes, size_required, size_required_64b
  41816 	max_bytes = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend) - int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf))
  41817 	current_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf))
  41818 	size_required_64b = current_size + extra_size
  41819 	size_required = size_required_64b
  41820 	if size_required != size_required_64b {
  41821 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41822 		return 0
  41823 	}
  41824 	if max_bytes > uint64(0) && size_required <= max_bytes {
  41825 		return int32(1)
  41826 	}
  41827 	allocated_size = uint64(3) * max_bytes >> int32(1)
  41828 	if allocated_size < size_required {
  41829 		allocated_size = size_required
  41830 	}
  41831 	// make allocated size multiple of 1k
  41832 	allocated_size = (allocated_size>>libc.Int32FromInt32(10) + libc.Uint64FromInt32(1)) << libc.Int32FromInt32(10)
  41833 	allocated_buf = WebPSafeMalloc(tls, uint64(1), allocated_size)
  41834 	if allocated_buf == libc.UintptrFromInt32(0) {
  41835 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41836 		return 0
  41837 	}
  41838 	if current_size > uint64(0) {
  41839 		libc.X__builtin___memcpy_chk(tls, allocated_buf, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf, current_size, ^__predefined_size_t(0))
  41840 	}
  41841 	WebPSafeFree(tls, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)
  41842 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf = allocated_buf
  41843 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(current_size)
  41844 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fend = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(allocated_size)
  41845 	return int32(1)
  41846 }
  41847 
  41848 func VP8LBitWriterInit(tls *libc.TLS, bw uintptr, expected_size size_t) (r int32) {
  41849 	libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41850 	return VP8LBitWriterResize(tls, bw, expected_size)
  41851 }
  41852 
  41853 func VP8LBitWriterClone(tls *libc.TLS, src uintptr, dst uintptr) (r int32) {
  41854 	var current_size size_t
  41855 	_ = current_size
  41856 	current_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(src)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(src)).Fbuf))
  41857 	if !(VP8LBitWriterResize(tls, dst, current_size) != 0) {
  41858 		return 0
  41859 	}
  41860 	libc.X__builtin___memcpy_chk(tls, (*VP8LBitWriter)(unsafe.Pointer(dst)).Fbuf, (*VP8LBitWriter)(unsafe.Pointer(src)).Fbuf, current_size, ^__predefined_size_t(0))
  41861 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fbits = (*VP8LBitWriter)(unsafe.Pointer(src)).Fbits
  41862 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fused = (*VP8LBitWriter)(unsafe.Pointer(src)).Fused
  41863 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Ferror1 = (*VP8LBitWriter)(unsafe.Pointer(src)).Ferror1
  41864 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(dst)).Fbuf + uintptr(current_size)
  41865 	return int32(1)
  41866 }
  41867 
  41868 func VP8LBitWriterWipeOut(tls *libc.TLS, bw uintptr) {
  41869 	if bw != libc.UintptrFromInt32(0) {
  41870 		WebPSafeFree(tls, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)
  41871 		libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41872 	}
  41873 }
  41874 
  41875 func VP8LBitWriterReset(tls *libc.TLS, bw_init uintptr, bw uintptr) {
  41876 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fbits
  41877 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fused
  41878 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(int64((*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fcur)-int64((*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fbuf))
  41879 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Ferror1
  41880 }
  41881 
  41882 func VP8LBitWriterSwap(tls *libc.TLS, src uintptr, dst uintptr) {
  41883 	var tmp VP8LBitWriter
  41884 	_ = tmp
  41885 	tmp = **(**VP8LBitWriter)(__ccgo_up(src))
  41886 	**(**VP8LBitWriter)(__ccgo_up(src)) = **(**VP8LBitWriter)(__ccgo_up(dst))
  41887 	**(**VP8LBitWriter)(__ccgo_up(dst)) = tmp
  41888 }
  41889 
  41890 func VP8LPutBitsFlushBits(tls *libc.TLS, bw uintptr) {
  41891 	var extra_size, v1 uint64_t
  41892 	var v2 int32
  41893 	_, _, _ = extra_size, v1, v2
  41894 	// If needed, make some room by flushing some bits out.
  41895 	if (*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur+uintptr(VP8L_WRITER_BYTES) > (*VP8LBitWriter)(unsafe.Pointer(bw)).Fend {
  41896 		extra_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend)-int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)) + uint64(32768)
  41897 		v1 = extra_size
  41898 		v2 = libc.BoolInt32(v1 == v1)
  41899 		goto _3
  41900 	_3:
  41901 		;
  41902 		if !(v2 != 0) || !(VP8LBitWriterResize(tls, bw, extra_size) != 0) {
  41903 			(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41904 			(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41905 			return
  41906 		}
  41907 	}
  41908 	**(**vp8l_wtype_t)(__ccgo_up((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur)) = uint32((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits)
  41909 	**(**uintptr)(__ccgo_up(bw + 24)) += uintptr(VP8L_WRITER_BYTES)
  41910 	**(**vp8l_atype_t)(__ccgo_up(bw)) >>= uint64(VP8L_WRITER_BITS)
  41911 	**(**int32)(__ccgo_up(bw + 8)) -= int32(VP8L_WRITER_BITS)
  41912 }
  41913 
  41914 func VP8LPutBitsInternal(tls *libc.TLS, bw uintptr, bits uint32_t, n_bits int32) {
  41915 	var extra_size, v1 uint64_t
  41916 	var lbits vp8l_atype_t
  41917 	var used, v2 int32
  41918 	_, _, _, _, _ = extra_size, lbits, used, v1, v2
  41919 	// That's the max we can handle:
  41920 	if n_bits > 0 {
  41921 		lbits = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits
  41922 		used = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fused
  41923 		// Special case of overflow handling for 32bit accumulator (2-steps flush).
  41924 		// If needed, make some room by flushing some bits out.
  41925 		for used >= int32(VP8L_WRITER_BITS) {
  41926 			if (*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur+uintptr(VP8L_WRITER_BYTES) > (*VP8LBitWriter)(unsafe.Pointer(bw)).Fend {
  41927 				extra_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend)-int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)) + uint64(32768)
  41928 				v1 = extra_size
  41929 				v2 = libc.BoolInt32(v1 == v1)
  41930 				goto _3
  41931 			_3:
  41932 				;
  41933 				if !(v2 != 0) || !(VP8LBitWriterResize(tls, bw, extra_size) != 0) {
  41934 					(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41935 					(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41936 					return
  41937 				}
  41938 			}
  41939 			**(**vp8l_wtype_t)(__ccgo_up((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur)) = uint32(lbits)
  41940 			**(**uintptr)(__ccgo_up(bw + 24)) += uintptr(VP8L_WRITER_BYTES)
  41941 			lbits = lbits >> uint64(VP8L_WRITER_BITS)
  41942 			used = used - int32(VP8L_WRITER_BITS)
  41943 		}
  41944 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits = lbits | uint64(bits)<<used
  41945 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = used + n_bits
  41946 	}
  41947 }
  41948 
  41949 func VP8LBitWriterFinish(tls *libc.TLS, bw uintptr) (r uintptr) {
  41950 	var v1, v2 uintptr
  41951 	_, _ = v1, v2
  41952 	// flush leftover bits
  41953 	if VP8LBitWriterResize(tls, bw, libc.Uint64FromInt32(((*VP8LBitWriter)(unsafe.Pointer(bw)).Fused+int32(7))>>int32(3))) != 0 {
  41954 		for (*VP8LBitWriter)(unsafe.Pointer(bw)).Fused > 0 {
  41955 			v2 = bw + 24
  41956 			v1 = *(*uintptr)(unsafe.Pointer(v2))
  41957 			*(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1
  41958 			**(**uint8_t)(__ccgo_up(v1)) = uint8((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits)
  41959 			**(**vp8l_atype_t)(__ccgo_up(bw)) >>= uint64(8)
  41960 			**(**int32)(__ccgo_up(bw + 8)) -= int32(8)
  41961 		}
  41962 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = 0
  41963 	}
  41964 	return (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41965 }
  41966 
  41967 var kHashMul12 = uint32(0x1e35a7bd)
  41968 
  41969 //------------------------------------------------------------------------------
  41970 
  41971 //------------------------------------------------------------------------------
  41972 // VP8LColorCache.
  41973 
  41974 func VP8LColorCacheInit(tls *libc.TLS, color_cache uintptr, hash_bits int32) (r int32) {
  41975 	var hash_size int32
  41976 	_ = hash_size
  41977 	hash_size = int32(1) << hash_bits
  41978 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors = WebPSafeCalloc(tls, libc.Uint64FromInt32(hash_size), uint64(4))
  41979 	if (*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors == libc.UintptrFromInt32(0) {
  41980 		return 0
  41981 	}
  41982 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fhash_shift = int32(32) - hash_bits
  41983 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fhash_bits = hash_bits
  41984 	return int32(1)
  41985 }
  41986 
  41987 func VP8LColorCacheClear(tls *libc.TLS, color_cache uintptr) {
  41988 	if color_cache != libc.UintptrFromInt32(0) {
  41989 		WebPSafeFree(tls, (*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors)
  41990 		(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors = libc.UintptrFromInt32(0)
  41991 	}
  41992 }
  41993 
  41994 func VP8LColorCacheCopy(tls *libc.TLS, src uintptr, dst uintptr) {
  41995 	libc.X__builtin___memcpy_chk(tls, (*VP8LColorCache)(unsafe.Pointer(dst)).Fcolors, (*VP8LColorCache)(unsafe.Pointer(src)).Fcolors, libc.Uint64FromUint32(1)<<(*VP8LColorCache)(unsafe.Pointer(dst)).Fhash_bits*uint64(4), ^__predefined_size_t(0))
  41996 }
  41997 
  41998 // -----------------------------------------------------------------------------
  41999 // Quick estimate of a potentially interesting filter mode to try.
  42000 
  42001 func GradientPredictor(tls *libc.TLS, a uint8_t, b uint8_t, c uint8_t) (r int32) {
  42002 	var g, v1, v2 int32
  42003 	_, _, _ = g, v1, v2
  42004 	g = libc.Int32FromUint8(a) + libc.Int32FromUint8(b) - libc.Int32FromUint8(c)
  42005 	if g & ^libc.Int32FromInt32(0xff) == 0 {
  42006 		v1 = g
  42007 	} else {
  42008 		if g < 0 {
  42009 			v2 = 0
  42010 		} else {
  42011 			v2 = int32(255)
  42012 		}
  42013 		v1 = v2
  42014 	}
  42015 	return v1 // clip to 8bit
  42016 }
  42017 
  42018 func WebPEstimateBestFilter(tls *libc.TLS, data uintptr, width int32, height int32, stride int32) (r WEBP_FILTER_TYPE) {
  42019 	bp := tls.Alloc(256)
  42020 	defer tls.Free(256)
  42021 	var best_filter WEBP_FILTER_TYPE
  42022 	var best_score, diff0, diff1, diff2, diff3, filter, grad_pred, i, j, mean, score int32
  42023 	var p uintptr
  42024 	var _ /* bins at bp+0 */ [4][16]int32
  42025 	_, _, _, _, _, _, _, _, _, _, _, _, _ = best_filter, best_score, diff0, diff1, diff2, diff3, filter, grad_pred, i, j, mean, p, score
  42026 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(256), ^__predefined_size_t(0))
  42027 	// We only sample every other pixels. That's enough.
  42028 	j = int32(2)
  42029 	for {
  42030 		if !(j < height-int32(1)) {
  42031 			break
  42032 		}
  42033 		p = data + uintptr(j*stride)
  42034 		mean = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  42035 		i = int32(2)
  42036 		for {
  42037 			if !(i < width-int32(1)) {
  42038 				break
  42039 			}
  42040 			diff0 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-mean) >> libc.Int32FromInt32(4)
  42041 			diff1 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i-int32(1)))))) >> libc.Int32FromInt32(4)
  42042 			diff2 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i-width))))) >> libc.Int32FromInt32(4)
  42043 			grad_pred = GradientPredictor(tls, **(**uint8_t)(__ccgo_up(p + uintptr(i-int32(1)))), **(**uint8_t)(__ccgo_up(p + uintptr(i-width))), **(**uint8_t)(__ccgo_up(p + uintptr(i-width-int32(1)))))
  42044 			diff3 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-grad_pred) >> libc.Int32FromInt32(4)
  42045 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_NONE)*64 + uintptr(diff0)*4)) = int32(1)
  42046 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_HORIZONTAL)*64 + uintptr(diff1)*4)) = int32(1)
  42047 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_VERTICAL)*64 + uintptr(diff2)*4)) = int32(1)
  42048 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_GRADIENT)*64 + uintptr(diff3)*4)) = int32(1)
  42049 			mean = (int32(3)*mean + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i)))) + int32(2)) >> int32(2)
  42050 			goto _2
  42051 		_2:
  42052 			;
  42053 			i = i + int32(2)
  42054 		}
  42055 		goto _1
  42056 	_1:
  42057 		;
  42058 		j = j + int32(2)
  42059 	}
  42060 	best_filter = int32(WEBP_FILTER_NONE)
  42061 	best_score = int32(0x7fffffff)
  42062 	filter = int32(WEBP_FILTER_NONE)
  42063 	for {
  42064 		if !(filter < int32(WEBP_FILTER_LAST)) {
  42065 			break
  42066 		}
  42067 		score = 0
  42068 		i = 0
  42069 		for {
  42070 			if !(i < int32(16)) {
  42071 				break
  42072 			}
  42073 			if **(**int32)(__ccgo_up(bp + uintptr(filter)*64 + uintptr(i)*4)) > 0 {
  42074 				score = score + i
  42075 			}
  42076 			goto _4
  42077 		_4:
  42078 			;
  42079 			i = i + 1
  42080 		}
  42081 		if score < best_score {
  42082 			best_score = score
  42083 			best_filter = filter
  42084 		}
  42085 		goto _3
  42086 	_3:
  42087 		;
  42088 		filter = filter + 1
  42089 	}
  42090 	return best_filter
  42091 	return r
  42092 }
  42093 
  42094 // Alpha related constants.
  42095 
  42096 // Mux related constants.
  42097 
  42098 // Maximum chunk payload is such that adding the header and padding won't
  42099 // overflow a uint32_t.
  42100 
  42101 // -----------------------------------------------------------------------------
  42102 // Util function to optimize the symbol map for RLE coding
  42103 
  42104 // C documentation
  42105 //
  42106 //	// Heuristics for selecting the stride ranges to collapse.
  42107 func ValuesShouldBeCollapsedToStrideAverage(tls *libc.TLS, a int32, b int32) (r int32) {
  42108 	return libc.BoolInt32(libc.Xabs(tls, a-b) < int32(4))
  42109 }
  42110 
  42111 // C documentation
  42112 //
  42113 //	// Change the population counts in a way that the consequent
  42114 //	// Huffman tree compression, especially its RLE-part, give smaller output.
  42115 func OptimizeHuffmanForRle(tls *libc.TLS, length int32, good_for_rle uintptr, counts uintptr) {
  42116 	var count, k1, limit, stride1, sum, symbol uint32_t
  42117 	var i, k, stride int32
  42118 	_, _, _, _, _, _, _, _, _ = count, i, k, k1, limit, stride, stride1, sum, symbol
  42119 	for {
  42120 		if !(length >= 0) {
  42121 			break
  42122 		}
  42123 		if length == 0 {
  42124 			return // All zeros.
  42125 		}
  42126 		if **(**uint32_t)(__ccgo_up(counts + uintptr(length-int32(1))*4)) != uint32(0) {
  42127 			// Now counts[0..length - 1] does not have trailing zeros.
  42128 			break
  42129 		}
  42130 		goto _1
  42131 	_1:
  42132 		;
  42133 		length = length - 1
  42134 	}
  42135 	// 2) Let's mark all population counts that already can be encoded
  42136 	// with an rle code.
  42137 	// Let's not spoil any of the existing good rle codes.
  42138 	// Mark any seq of 0's that is longer as 5 as a good_for_rle.
  42139 	// Mark any seq of non-0's that is longer as 7 as a good_for_rle.
  42140 	symbol = **(**uint32_t)(__ccgo_up(counts))
  42141 	stride = 0
  42142 	i = 0
  42143 	for {
  42144 		if !(i < length+int32(1)) {
  42145 			break
  42146 		}
  42147 		if i == length || **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4)) != symbol {
  42148 			if symbol == uint32(0) && stride >= int32(5) || symbol != uint32(0) && stride >= int32(7) {
  42149 				k = 0
  42150 				for {
  42151 					if !(k < stride) {
  42152 						break
  42153 					}
  42154 					**(**uint8_t)(__ccgo_up(good_for_rle + uintptr(i-k-int32(1)))) = uint8(1)
  42155 					goto _3
  42156 				_3:
  42157 					;
  42158 					k = k + 1
  42159 				}
  42160 			}
  42161 			stride = int32(1)
  42162 			if i != length {
  42163 				symbol = **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42164 			}
  42165 		} else {
  42166 			stride = stride + 1
  42167 		}
  42168 		goto _2
  42169 	_2:
  42170 		;
  42171 		i = i + 1
  42172 	}
  42173 	// 3) Let's replace those population counts that lead to more rle codes.
  42174 	stride1 = uint32(0)
  42175 	limit = **(**uint32_t)(__ccgo_up(counts))
  42176 	sum = uint32(0)
  42177 	i = 0
  42178 	for {
  42179 		if !(i < length+int32(1)) {
  42180 			break
  42181 		}
  42182 		if i == length || **(**uint8_t)(__ccgo_up(good_for_rle + uintptr(i))) != 0 || i != 0 && **(**uint8_t)(__ccgo_up(good_for_rle + uintptr(i-int32(1)))) != 0 || !(ValuesShouldBeCollapsedToStrideAverage(tls, libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))), libc.Int32FromUint32(limit)) != 0) {
  42183 			if stride1 >= uint32(4) || stride1 >= uint32(3) && sum == uint32(0) {
  42184 				// The stride must end, collapse what we have, if we have enough (4).
  42185 				count = (sum + stride1/uint32(2)) / stride1
  42186 				if count < uint32(1) {
  42187 					count = uint32(1)
  42188 				}
  42189 				if sum == uint32(0) {
  42190 					// Don't make an all zeros stride to be upgraded to ones.
  42191 					count = uint32(0)
  42192 				}
  42193 				k1 = uint32(0)
  42194 				for {
  42195 					if !(k1 < stride1) {
  42196 						break
  42197 					}
  42198 					// We don't want to change value at counts[i],
  42199 					// that is already belonging to the next stride. Thus - 1.
  42200 					**(**uint32_t)(__ccgo_up(counts + uintptr(libc.Uint32FromInt32(i)-k1-uint32(1))*4)) = count
  42201 					goto _5
  42202 				_5:
  42203 					;
  42204 					k1 = k1 + 1
  42205 				}
  42206 			}
  42207 			stride1 = uint32(0)
  42208 			sum = uint32(0)
  42209 			if i < length-int32(3) {
  42210 				// All interesting strides have a count of at least 4,
  42211 				// at least when non-zeros.
  42212 				limit = (**(**uint32_t)(__ccgo_up(counts + uintptr(i)*4)) + **(**uint32_t)(__ccgo_up(counts + uintptr(i+int32(1))*4)) + **(**uint32_t)(__ccgo_up(counts + uintptr(i+int32(2))*4)) + **(**uint32_t)(__ccgo_up(counts + uintptr(i+int32(3))*4)) + uint32(2)) / uint32(4)
  42213 			} else {
  42214 				if i < length {
  42215 					limit = **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42216 				} else {
  42217 					limit = uint32(0)
  42218 				}
  42219 			}
  42220 		}
  42221 		stride1 = stride1 + 1
  42222 		if i != length {
  42223 			sum = sum + **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42224 			if stride1 >= uint32(4) {
  42225 				limit = (sum + stride1/uint32(2)) / stride1
  42226 			}
  42227 		}
  42228 		goto _4
  42229 	_4:
  42230 		;
  42231 		i = i + 1
  42232 	}
  42233 }
  42234 
  42235 // C documentation
  42236 //
  42237 //	// A comparer function for two Huffman trees: sorts first by 'total count'
  42238 //	// (more comes first), and then by 'value' (more comes first).
  42239 func CompareHuffmanTrees(tls *libc.TLS, ptr1 uintptr, ptr2 uintptr) (r int32) {
  42240 	var t1, t2 uintptr
  42241 	var v1 int32
  42242 	_, _, _ = t1, t2, v1
  42243 	t1 = ptr1
  42244 	t2 = ptr2
  42245 	if (*HuffmanTree)(unsafe.Pointer(t1)).Ftotal_count > (*HuffmanTree)(unsafe.Pointer(t2)).Ftotal_count {
  42246 		return -int32(1)
  42247 	} else {
  42248 		if (*HuffmanTree)(unsafe.Pointer(t1)).Ftotal_count < (*HuffmanTree)(unsafe.Pointer(t2)).Ftotal_count {
  42249 			return int32(1)
  42250 		} else {
  42251 			if (*HuffmanTree)(unsafe.Pointer(t1)).Fvalue < (*HuffmanTree)(unsafe.Pointer(t2)).Fvalue {
  42252 				v1 = -int32(1)
  42253 			} else {
  42254 				v1 = int32(1)
  42255 			}
  42256 			return v1
  42257 		}
  42258 	}
  42259 	return r
  42260 }
  42261 
  42262 func SetBitDepths(tls *libc.TLS, tree uintptr, pool uintptr, bit_depths uintptr, level int32) {
  42263 	if (*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_left >= 0 {
  42264 		SetBitDepths(tls, pool+uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_left)*16, pool, bit_depths, level+int32(1))
  42265 		SetBitDepths(tls, pool+uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_right)*16, pool, bit_depths, level+int32(1))
  42266 	} else {
  42267 		**(**uint8_t)(__ccgo_up(bit_depths + uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fvalue))) = libc.Uint8FromInt32(level)
  42268 	}
  42269 }
  42270 
  42271 // C documentation
  42272 //
  42273 //	// Create an optimal Huffman tree.
  42274 //	//
  42275 //	// (data,length): population counts.
  42276 //	// tree_limit: maximum bit depth (inclusive) of the codes.
  42277 //	// bit_depths[]: how many bits are used for the symbol.
  42278 //	//
  42279 //	// Returns 0 when an error has occurred.
  42280 //	//
  42281 //	// The catch here is that the tree cannot be arbitrarily deep
  42282 //	//
  42283 //	// count_limit is the value that is to be faked as the minimum value
  42284 //	// and this minimum value is raised until the tree matches the
  42285 //	// maximum length requirement.
  42286 //	//
  42287 //	// This algorithm is not of excellent performance for very long data blocks,
  42288 //	// especially when population counts are longer than 2**tree_limit, but
  42289 //	// we are not planning to use this with extremely long blocks.
  42290 //	//
  42291 //	// See https://en.wikipedia.org/wiki/Huffman_coding
  42292 func GenerateOptimalTree(tls *libc.TLS, histogram uintptr, histogram_size int32, tree uintptr, tree_depth_limit int32, bit_depths uintptr) {
  42293 	var count, count1, count_min uint32_t
  42294 	var i, idx, j, k, max_depth, tree_pool_size, tree_size, tree_size_orig, v5 int32
  42295 	var tree_pool uintptr
  42296 	var v4 uint32
  42297 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, count1, count_min, i, idx, j, k, max_depth, tree_pool, tree_pool_size, tree_size, tree_size_orig, v4, v5
  42298 	tree_size_orig = 0
  42299 	i = 0
  42300 	for {
  42301 		if !(i < histogram_size) {
  42302 			break
  42303 		}
  42304 		if **(**uint32_t)(__ccgo_up(histogram + uintptr(i)*4)) != uint32(0) {
  42305 			tree_size_orig = tree_size_orig + 1
  42306 		}
  42307 		goto _1
  42308 	_1:
  42309 		;
  42310 		i = i + 1
  42311 	}
  42312 	if tree_size_orig == 0 { // pretty optimal already!
  42313 		return
  42314 	}
  42315 	tree_pool = tree + uintptr(tree_size_orig)*16
  42316 	// For block sizes with less than 64k symbols we never need to do a
  42317 	// second iteration of this loop.
  42318 	// If we actually start running inside this loop a lot, we would perhaps
  42319 	// be better off with the Katajainen algorithm.
  42320 	count_min = uint32(1)
  42321 	for {
  42322 		tree_size = tree_size_orig
  42323 		// We need to pack the Huffman tree in tree_depth_limit bits.
  42324 		// So, we try by faking histogram entries to be at least 'count_min'.
  42325 		idx = 0
  42326 		j = 0
  42327 		for {
  42328 			if !(j < histogram_size) {
  42329 				break
  42330 			}
  42331 			if **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4)) != uint32(0) {
  42332 				if **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4)) < count_min {
  42333 					v4 = count_min
  42334 				} else {
  42335 					v4 = **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4))
  42336 				}
  42337 				count = v4
  42338 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Ftotal_count = count
  42339 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fvalue = j
  42340 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fpool_index_left = -int32(1)
  42341 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fpool_index_right = -int32(1)
  42342 				idx = idx + 1
  42343 			}
  42344 			goto _3
  42345 		_3:
  42346 			;
  42347 			j = j + 1
  42348 		}
  42349 		// Build the Huffman tree.
  42350 		libc.Xqsort(tls, tree, libc.Uint64FromInt32(tree_size), uint64(16), __ccgo_fp(CompareHuffmanTrees))
  42351 		if tree_size > int32(1) { // Normal case.
  42352 			tree_pool_size = 0
  42353 			for tree_size > int32(1) {
  42354 				v5 = tree_pool_size
  42355 				tree_pool_size = tree_pool_size + 1
  42356 				**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(v5)*16)) = **(**HuffmanTree)(__ccgo_up(tree + uintptr(tree_size-int32(1))*16))
  42357 				v5 = tree_pool_size
  42358 				tree_pool_size = tree_pool_size + 1
  42359 				**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(v5)*16)) = **(**HuffmanTree)(__ccgo_up(tree + uintptr(tree_size-int32(2))*16))
  42360 				count1 = (**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(tree_pool_size-int32(1))*16))).Ftotal_count + (**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(tree_pool_size-int32(2))*16))).Ftotal_count
  42361 				tree_size = tree_size - int32(2)
  42362 				k = 0
  42363 				for {
  42364 					if !(k < tree_size) {
  42365 						break
  42366 					}
  42367 					if (**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Ftotal_count <= count1 {
  42368 						break
  42369 					}
  42370 					goto _7
  42371 				_7:
  42372 					;
  42373 					k = k + 1
  42374 				}
  42375 				libc.X__builtin___memmove_chk(tls, tree+uintptr(k+libc.Int32FromInt32(1))*16, tree+uintptr(k)*16, libc.Uint64FromInt32(tree_size-k)*uint64(16), ^__predefined_size_t(0))
  42376 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Ftotal_count = count1
  42377 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fvalue = -int32(1)
  42378 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fpool_index_left = tree_pool_size - int32(1)
  42379 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fpool_index_right = tree_pool_size - int32(2)
  42380 				tree_size = tree_size + int32(1)
  42381 			}
  42382 			SetBitDepths(tls, tree, tree_pool, bit_depths, 0)
  42383 		} else {
  42384 			if tree_size == int32(1) { // Trivial case: only one element.
  42385 				**(**uint8_t)(__ccgo_up(bit_depths + uintptr((**(**HuffmanTree)(__ccgo_up(tree))).Fvalue))) = uint8(1)
  42386 			}
  42387 		}
  42388 		// Test if this Huffman tree satisfies our 'tree_depth_limit' criteria.
  42389 		max_depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths)))
  42390 		j = int32(1)
  42391 		for {
  42392 			if !(j < histogram_size) {
  42393 				break
  42394 			}
  42395 			if max_depth < libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths + uintptr(j)))) {
  42396 				max_depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths + uintptr(j))))
  42397 			}
  42398 			goto _8
  42399 		_8:
  42400 			;
  42401 			j = j + 1
  42402 		}
  42403 		if max_depth <= tree_depth_limit {
  42404 			break
  42405 		}
  42406 		goto _2
  42407 	_2:
  42408 		;
  42409 		count_min = count_min * uint32(2)
  42410 	}
  42411 }
  42412 
  42413 // -----------------------------------------------------------------------------
  42414 // Coding of the Huffman tree values
  42415 
  42416 func CodeRepeatedValues(tls *libc.TLS, repetitions int32, tokens uintptr, value int32, prev_value int32) (r uintptr) {
  42417 	var i int32
  42418 	_ = i
  42419 	if value != prev_value {
  42420 		(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = libc.Uint8FromInt32(value)
  42421 		(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42422 		tokens += 2
  42423 		repetitions = repetitions - 1
  42424 	}
  42425 	for repetitions >= int32(1) {
  42426 		if repetitions < int32(3) {
  42427 			i = 0
  42428 			for {
  42429 				if !(i < repetitions) {
  42430 					break
  42431 				}
  42432 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = libc.Uint8FromInt32(value)
  42433 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42434 				tokens += 2
  42435 				goto _1
  42436 			_1:
  42437 				;
  42438 				i = i + 1
  42439 			}
  42440 			break
  42441 		} else {
  42442 			if repetitions < int32(7) {
  42443 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(16)
  42444 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(3))
  42445 				tokens += 2
  42446 				break
  42447 			} else {
  42448 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(16)
  42449 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(3)
  42450 				tokens += 2
  42451 				repetitions = repetitions - int32(6)
  42452 			}
  42453 		}
  42454 	}
  42455 	return tokens
  42456 }
  42457 
  42458 func CodeRepeatedZeros(tls *libc.TLS, repetitions int32, tokens uintptr) (r uintptr) {
  42459 	var i int32
  42460 	_ = i
  42461 	for repetitions >= int32(1) {
  42462 		if repetitions < int32(3) {
  42463 			i = 0
  42464 			for {
  42465 				if !(i < repetitions) {
  42466 					break
  42467 				}
  42468 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(0) // 0-value
  42469 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42470 				tokens += 2
  42471 				goto _1
  42472 			_1:
  42473 				;
  42474 				i = i + 1
  42475 			}
  42476 			break
  42477 		} else {
  42478 			if repetitions < int32(11) {
  42479 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(17)
  42480 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(3))
  42481 				tokens += 2
  42482 				break
  42483 			} else {
  42484 				if repetitions < int32(139) {
  42485 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(18)
  42486 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(11))
  42487 					tokens += 2
  42488 					break
  42489 				} else {
  42490 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(18)
  42491 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0x7f) // 138 repeated 0s
  42492 					tokens += 2
  42493 					repetitions = repetitions - int32(138)
  42494 				}
  42495 			}
  42496 		}
  42497 	}
  42498 	return tokens
  42499 }
  42500 
  42501 func VP8LCreateCompressedHuffmanTree(tls *libc.TLS, tree uintptr, tokens uintptr, max_tokens int32) (r int32) {
  42502 	var depth_size, i, k, prev_value, runs, value int32
  42503 	var ending_token, starting_token uintptr
  42504 	_, _, _, _, _, _, _, _ = depth_size, ending_token, i, k, prev_value, runs, starting_token, value
  42505 	starting_token = tokens
  42506 	ending_token = tokens + uintptr(max_tokens)*2
  42507 	depth_size = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  42508 	prev_value = int32(8) // 8 is the initial value for rle.
  42509 	i = 0
  42510 	for i < depth_size {
  42511 		value = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42512 		k = i + int32(1)
  42513 		for k < depth_size && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(k)))) == value {
  42514 			k = k + 1
  42515 		}
  42516 		runs = k - i
  42517 		if value == 0 {
  42518 			tokens = CodeRepeatedZeros(tls, runs, tokens)
  42519 		} else {
  42520 			tokens = CodeRepeatedValues(tls, runs, tokens, value, prev_value)
  42521 			prev_value = value
  42522 		}
  42523 		i = i + runs
  42524 	}
  42525 	_ = ending_token // suppress 'unused variable' warning
  42526 	return int32((int64(tokens) - int64(starting_token)) / 2)
  42527 }
  42528 
  42529 // -----------------------------------------------------------------------------
  42530 
  42531 // C documentation
  42532 //
  42533 //	// Pre-reversed 4-bit values.
  42534 var kReversedBits = [16]uint8_t{
  42535 	1:  uint8(0x8),
  42536 	2:  uint8(0x4),
  42537 	3:  uint8(0xc),
  42538 	4:  uint8(0x2),
  42539 	5:  uint8(0xa),
  42540 	6:  uint8(0x6),
  42541 	7:  uint8(0xe),
  42542 	8:  uint8(0x1),
  42543 	9:  uint8(0x9),
  42544 	10: uint8(0x5),
  42545 	11: uint8(0xd),
  42546 	12: uint8(0x3),
  42547 	13: uint8(0xb),
  42548 	14: uint8(0x7),
  42549 	15: uint8(0xf),
  42550 }
  42551 
  42552 func ReverseBits(tls *libc.TLS, num_bits int32, bits uint32_t) (r uint32_t) {
  42553 	var i int32
  42554 	var retval uint32_t
  42555 	_, _ = i, retval
  42556 	retval = uint32(0)
  42557 	i = 0
  42558 	for i < num_bits {
  42559 		i = i + int32(4)
  42560 		retval = retval | libc.Uint32FromInt32(libc.Int32FromUint8(kReversedBits[bits&uint32(0xf)])<<(libc.Int32FromInt32(MAX_ALLOWED_CODE_LENGTH)+libc.Int32FromInt32(1)-i))
  42561 		bits = bits >> uint32(4)
  42562 	}
  42563 	retval = retval >> libc.Uint32FromInt32(libc.Int32FromInt32(MAX_ALLOWED_CODE_LENGTH)+libc.Int32FromInt32(1)-num_bits)
  42564 	return retval
  42565 }
  42566 
  42567 // C documentation
  42568 //
  42569 //	// Get the actual bit values for a tree of bit depths.
  42570 func ConvertBitDepthsToSymbols(tls *libc.TLS, tree uintptr) {
  42571 	bp := tls.Alloc(64)
  42572 	defer tls.Free(64)
  42573 	var code, v4 uint32_t
  42574 	var code_length, code_length1, i, len1 int32
  42575 	var depth_count [16]int32
  42576 	var v5 uintptr
  42577 	var _ /* next_code at bp+0 */ [16]uint32_t
  42578 	_, _, _, _, _, _, _, _ = code, code_length, code_length1, depth_count, i, len1, v4, v5
  42579 	depth_count = [16]int32{}
  42580 	len1 = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  42581 	i = 0
  42582 	for {
  42583 		if !(i < len1) {
  42584 			break
  42585 		}
  42586 		code_length = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42587 		depth_count[code_length] = depth_count[code_length] + 1
  42588 		goto _1
  42589 	_1:
  42590 		;
  42591 		i = i + 1
  42592 	}
  42593 	depth_count[0] = 0 // ignore unused symbol
  42594 	(**(**[16]uint32_t)(__ccgo_up(bp)))[0] = uint32(0)
  42595 	code = uint32(0)
  42596 	i = int32(1)
  42597 	for {
  42598 		if !(i <= int32(MAX_ALLOWED_CODE_LENGTH)) {
  42599 			break
  42600 		}
  42601 		code = (code + libc.Uint32FromInt32(depth_count[i-int32(1)])) << int32(1)
  42602 		(**(**[16]uint32_t)(__ccgo_up(bp)))[i] = code
  42603 		goto _2
  42604 	_2:
  42605 		;
  42606 		i = i + 1
  42607 	}
  42608 	i = 0
  42609 	for {
  42610 		if !(i < len1) {
  42611 			break
  42612 		}
  42613 		code_length1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42614 		v5 = bp + uintptr(code_length1)*4
  42615 		v4 = *(*uint32_t)(unsafe.Pointer(v5))
  42616 		*(*uint32_t)(unsafe.Pointer(v5)) = *(*uint32_t)(unsafe.Pointer(v5)) + 1
  42617 		**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcodes + uintptr(i)*2)) = uint16(ReverseBits(tls, code_length1, v4))
  42618 		goto _3
  42619 	_3:
  42620 		;
  42621 		i = i + 1
  42622 	}
  42623 }
  42624 
  42625 // -----------------------------------------------------------------------------
  42626 // Main entry point
  42627 
  42628 func VP8LCreateHuffmanTree(tls *libc.TLS, histogram uintptr, tree_depth_limit int32, buf_rle uintptr, huff_tree uintptr, huff_code uintptr) {
  42629 	var num_symbols int32
  42630 	_ = num_symbols
  42631 	num_symbols = (*HuffmanTreeCode)(unsafe.Pointer(huff_code)).Fnum_symbols
  42632 	libc.X__builtin___memset_chk(tls, buf_rle, 0, libc.Uint64FromInt32(num_symbols)*uint64(1), ^__predefined_size_t(0))
  42633 	OptimizeHuffmanForRle(tls, num_symbols, buf_rle, histogram)
  42634 	GenerateOptimalTree(tls, histogram, num_symbols, huff_tree, tree_depth_limit, (*HuffmanTreeCode)(unsafe.Pointer(huff_code)).Fcode_lengths)
  42635 	// Create the actual bit codes for the bit lengths.
  42636 	ConvertBitDepthsToSymbols(tls, huff_code)
  42637 }
  42638 
  42639 const MAX_HTREE_GROUPS = 0x10000
  42640 const SORTED_SIZE_CUTOFF = 512
  42641 
  42642 //------------------------------------------------------------------------------
  42643 
  42644 // Copyright 2012 Google Inc. All Rights Reserved.
  42645 //
  42646 // Use of this source code is governed by a BSD-style license
  42647 // that can be found in the COPYING file in the root of the source
  42648 // tree. An additional intellectual property rights grant can be found
  42649 // in the file PATENTS. All contributing project authors may
  42650 // be found in the AUTHORS file in the root of the source tree.
  42651 // -----------------------------------------------------------------------------
  42652 //
  42653 //  Internal header for constants related to WebP file format.
  42654 //
  42655 // Author: Urvang (urvang@google.com)
  42656 
  42657 // Copyright 2010 Google Inc. All Rights Reserved.
  42658 //
  42659 // Use of this source code is governed by a BSD-style license
  42660 // that can be found in the COPYING file in the root of the source
  42661 // tree. An additional intellectual property rights grant can be found
  42662 // in the file PATENTS. All contributing project authors may
  42663 // be found in the AUTHORS file in the root of the source tree.
  42664 // -----------------------------------------------------------------------------
  42665 //
  42666 //  Common types + memory wrappers
  42667 //
  42668 // Author: Skal (pascal.massimino@gmail.com)
  42669 
  42670 // Huffman data read via DecodeImageStream is represented in two (red and green)
  42671 // bytes.
  42672 
  42673 func VP8LHtreeGroupsNew(tls *libc.TLS, num_htree_groups int32) (r uintptr) {
  42674 	var htree_groups uintptr
  42675 	_ = htree_groups
  42676 	htree_groups = WebPSafeMalloc(tls, libc.Uint64FromInt32(num_htree_groups), uint64(568))
  42677 	if htree_groups == libc.UintptrFromInt32(0) {
  42678 		return libc.UintptrFromInt32(0)
  42679 	}
  42680 	return htree_groups
  42681 }
  42682 
  42683 func VP8LHtreeGroupsFree(tls *libc.TLS, htree_groups uintptr) {
  42684 	if htree_groups != libc.UintptrFromInt32(0) {
  42685 		WebPSafeFree(tls, htree_groups)
  42686 	}
  42687 }
  42688 
  42689 // C documentation
  42690 //
  42691 //	// Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the
  42692 //	// bit-wise reversal of the len least significant bits of key.
  42693 func GetNextKey(tls *libc.TLS, key uint32_t, len1 int32) (r uint32_t) {
  42694 	var step uint32_t
  42695 	var v1 uint32
  42696 	_, _ = step, v1
  42697 	step = libc.Uint32FromInt32(int32(1) << (len1 - int32(1)))
  42698 	for key&step != 0 {
  42699 		step = step >> uint32(1)
  42700 	}
  42701 	if step != 0 {
  42702 		v1 = key&(step-uint32(1)) + step
  42703 	} else {
  42704 		v1 = key
  42705 	}
  42706 	return v1
  42707 }
  42708 
  42709 // C documentation
  42710 //
  42711 //	// Stores code in table[0], table[step], table[2*step], ..., table[end].
  42712 //	// Assumes that end is an integer multiple of step.
  42713 func ReplicateValue(tls *libc.TLS, table uintptr, step int32, end int32, code HuffmanCode) {
  42714 	for cond := true; cond; cond = end > 0 {
  42715 		end = end - step
  42716 		**(**HuffmanCode)(__ccgo_up(table + uintptr(end)*4)) = code
  42717 	}
  42718 }
  42719 
  42720 // C documentation
  42721 //
  42722 //	// Returns the table width of the next 2nd level table. count is the histogram
  42723 //	// of bit lengths for the remaining symbols, len is the code length of the next
  42724 //	// processed symbol
  42725 func NextTableBitSize(tls *libc.TLS, count uintptr, len1 int32, root_bits int32) (r int32) {
  42726 	var left int32
  42727 	_ = left
  42728 	left = int32(1) << (len1 - root_bits)
  42729 	for len1 < int32(MAX_ALLOWED_CODE_LENGTH) {
  42730 		left = left - **(**int32)(__ccgo_up(count + uintptr(len1)*4))
  42731 		if left <= 0 {
  42732 			break
  42733 		}
  42734 		len1 = len1 + 1
  42735 		left = left << int32(1)
  42736 	}
  42737 	return len1 - root_bits
  42738 }
  42739 
  42740 // C documentation
  42741 //
  42742 //	// sorted[code_lengths_size] is a pre-allocated array for sorting symbols
  42743 //	// by code length.
  42744 func BuildHuffmanTable(tls *libc.TLS, root_table uintptr, root_bits int32, code_lengths uintptr, code_lengths_size int32, sorted uintptr) (r int32) {
  42745 	bp := tls.Alloc(128)
  42746 	defer tls.Free(128)
  42747 	var code, code1, code2 HuffmanCode
  42748 	var key, low, mask uint32_t
  42749 	var len1, num_nodes, num_open, step, symbol, symbol_code_length, table_bits, table_size, total_size, v4 int32
  42750 	var table, v5 uintptr
  42751 	var _ /* count at bp+0 */ [16]int32
  42752 	var _ /* offset at bp+64 */ [16]int32
  42753 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = code, code1, code2, key, len1, low, mask, num_nodes, num_open, step, symbol, symbol_code_length, table, table_bits, table_size, total_size, v4, v5
  42754 	table = root_table                 // next available space in table
  42755 	total_size = int32(1) << root_bits // symbol index in original or sorted table
  42756 	// number of codes of each length:
  42757 	**(**[16]int32)(__ccgo_up(bp)) = [16]int32{}
  42758 	// Build histogram of code lengths.
  42759 	symbol = 0
  42760 	for {
  42761 		if !(symbol < code_lengths_size) {
  42762 			break
  42763 		}
  42764 		if **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) > int32(MAX_ALLOWED_CODE_LENGTH) {
  42765 			return 0
  42766 		}
  42767 		(**(**[16]int32)(__ccgo_up(bp)))[**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4))] = (**(**[16]int32)(__ccgo_up(bp)))[**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4))] + 1
  42768 		goto _1
  42769 	_1:
  42770 		;
  42771 		symbol = symbol + 1
  42772 	}
  42773 	// Error, all code lengths are zeros.
  42774 	if (**(**[16]int32)(__ccgo_up(bp)))[0] == code_lengths_size {
  42775 		return 0
  42776 	}
  42777 	// Generate offsets into sorted symbol table by code length.
  42778 	(**(**[16]int32)(__ccgo_up(bp + 64)))[int32(1)] = 0
  42779 	len1 = int32(1)
  42780 	for {
  42781 		if !(len1 < int32(MAX_ALLOWED_CODE_LENGTH)) {
  42782 			break
  42783 		}
  42784 		if (**(**[16]int32)(__ccgo_up(bp)))[len1] > int32(1)<<len1 {
  42785 			return 0
  42786 		}
  42787 		(**(**[16]int32)(__ccgo_up(bp + 64)))[len1+int32(1)] = (**(**[16]int32)(__ccgo_up(bp + 64)))[len1] + (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42788 		goto _2
  42789 	_2:
  42790 		;
  42791 		len1 = len1 + 1
  42792 	}
  42793 	// Sort symbols by length, by symbol order within each length.
  42794 	symbol = 0
  42795 	for {
  42796 		if !(symbol < code_lengths_size) {
  42797 			break
  42798 		}
  42799 		symbol_code_length = **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4))
  42800 		if **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) > 0 {
  42801 			if sorted != libc.UintptrFromInt32(0) {
  42802 				if (**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] >= code_lengths_size {
  42803 					return 0
  42804 				}
  42805 				v5 = bp + 64 + uintptr(symbol_code_length)*4
  42806 				v4 = *(*int32)(unsafe.Pointer(v5))
  42807 				*(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1
  42808 				**(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2)) = libc.Uint16FromInt32(symbol)
  42809 			} else {
  42810 				(**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] = (**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] + 1
  42811 			}
  42812 		}
  42813 		goto _3
  42814 	_3:
  42815 		;
  42816 		symbol = symbol + 1
  42817 	}
  42818 	// Special case code with only one value.
  42819 	if (**(**[16]int32)(__ccgo_up(bp + 64)))[int32(MAX_ALLOWED_CODE_LENGTH)] == int32(1) {
  42820 		if sorted != libc.UintptrFromInt32(0) {
  42821 			code.Fbits = uint8(0)
  42822 			code.Fvalue = **(**uint16_t)(__ccgo_up(sorted))
  42823 			ReplicateValue(tls, table, int32(1), total_size, code)
  42824 		}
  42825 		return total_size
  42826 	}
  42827 	// step size to replicate values in current table
  42828 	low = uint32(0xffffffff)                           // low bits for current root entry
  42829 	mask = libc.Uint32FromInt32(total_size - int32(1)) // mask for low bits
  42830 	key = uint32(0)                                    // reversed prefix code
  42831 	num_nodes = int32(1)                               // number of Huffman tree nodes
  42832 	num_open = int32(1)                                // number of open branches in current tree level
  42833 	table_bits = root_bits                             // key length of current table
  42834 	table_size = int32(1) << table_bits                // size of current table
  42835 	symbol = 0
  42836 	// Fill in root table.
  42837 	len1 = int32(1)
  42838 	step = libc.Int32FromInt32(2)
  42839 	for {
  42840 		if !(len1 <= root_bits) {
  42841 			break
  42842 		}
  42843 		num_open = num_open << int32(1)
  42844 		num_nodes = num_nodes + num_open
  42845 		num_open = num_open - (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42846 		if num_open < 0 {
  42847 			return 0
  42848 		}
  42849 		if root_table == libc.UintptrFromInt32(0) {
  42850 			goto _6
  42851 		}
  42852 		for {
  42853 			if !((**(**[16]int32)(__ccgo_up(bp)))[len1] > 0) {
  42854 				break
  42855 			}
  42856 			code1.Fbits = libc.Uint8FromInt32(len1)
  42857 			v4 = symbol
  42858 			symbol = symbol + 1
  42859 			code1.Fvalue = **(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2))
  42860 			ReplicateValue(tls, table+uintptr(key)*4, step, table_size, code1)
  42861 			key = GetNextKey(tls, key, len1)
  42862 			goto _7
  42863 		_7:
  42864 			;
  42865 			(**(**[16]int32)(__ccgo_up(bp)))[len1] = (**(**[16]int32)(__ccgo_up(bp)))[len1] - 1
  42866 		}
  42867 		goto _6
  42868 	_6:
  42869 		;
  42870 		len1 = len1 + 1
  42871 		step = step << int32(1)
  42872 	}
  42873 	// Fill in 2nd level tables and add pointers to root table.
  42874 	len1 = root_bits + int32(1)
  42875 	step = libc.Int32FromInt32(2)
  42876 	for {
  42877 		if !(len1 <= int32(MAX_ALLOWED_CODE_LENGTH)) {
  42878 			break
  42879 		}
  42880 		num_open = num_open << int32(1)
  42881 		num_nodes = num_nodes + num_open
  42882 		num_open = num_open - (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42883 		if num_open < 0 {
  42884 			return 0
  42885 		}
  42886 		for {
  42887 			if !((**(**[16]int32)(__ccgo_up(bp)))[len1] > 0) {
  42888 				break
  42889 			}
  42890 			if key&mask != low {
  42891 				if root_table != libc.UintptrFromInt32(0) {
  42892 					table = table + uintptr(table_size)*4
  42893 				}
  42894 				table_bits = NextTableBitSize(tls, bp, len1, root_bits)
  42895 				table_size = int32(1) << table_bits
  42896 				total_size = total_size + table_size
  42897 				low = key & mask
  42898 				if root_table != libc.UintptrFromInt32(0) {
  42899 					(**(**HuffmanCode)(__ccgo_up(root_table + uintptr(low)*4))).Fbits = libc.Uint8FromInt32(table_bits + root_bits)
  42900 					(**(**HuffmanCode)(__ccgo_up(root_table + uintptr(low)*4))).Fvalue = libc.Uint16FromInt64((int64(table)-int64(root_table))/4 - libc.Int64FromUint32(low))
  42901 				}
  42902 			}
  42903 			if root_table != libc.UintptrFromInt32(0) {
  42904 				code2.Fbits = libc.Uint8FromInt32(len1 - root_bits)
  42905 				v4 = symbol
  42906 				symbol = symbol + 1
  42907 				code2.Fvalue = **(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2))
  42908 				ReplicateValue(tls, table+uintptr(key>>root_bits)*4, step, table_size, code2)
  42909 			}
  42910 			key = GetNextKey(tls, key, len1)
  42911 			goto _10
  42912 		_10:
  42913 			;
  42914 			(**(**[16]int32)(__ccgo_up(bp)))[len1] = (**(**[16]int32)(__ccgo_up(bp)))[len1] - 1
  42915 		}
  42916 		goto _9
  42917 	_9:
  42918 		;
  42919 		len1 = len1 + 1
  42920 		step = step << int32(1)
  42921 	}
  42922 	// Check if tree is full.
  42923 	if num_nodes != int32(2)*(**(**[16]int32)(__ccgo_up(bp + 64)))[int32(MAX_ALLOWED_CODE_LENGTH)]-int32(1) {
  42924 		return 0
  42925 	}
  42926 	return total_size
  42927 }
  42928 
  42929 // C documentation
  42930 //
  42931 //	// Maximum code_lengths_size is 2328 (reached for 11-bit color_cache_bits).
  42932 //	// More commonly, the value is around ~280.
  42933 //	// Cut-off value for switching between heap and stack allocation.
  42934 func VP8LBuildHuffmanTable(tls *libc.TLS, root_table uintptr, root_bits int32, code_lengths uintptr, code_lengths_size int32) (r int32) {
  42935 	bp := tls.Alloc(1024)
  42936 	defer tls.Free(1024)
  42937 	var next, sorted1 uintptr
  42938 	var segment_size, total_size, v1 int32
  42939 	var _ /* sorted at bp+0 */ [512]uint16_t
  42940 	_, _, _, _, _ = next, segment_size, sorted1, total_size, v1
  42941 	total_size = BuildHuffmanTable(tls, libc.UintptrFromInt32(0), root_bits, code_lengths, code_lengths_size, libc.UintptrFromInt32(0))
  42942 	if total_size == 0 || root_table == libc.UintptrFromInt32(0) {
  42943 		return total_size
  42944 	}
  42945 	if (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fcurr_table+uintptr(total_size)*4 >= (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fstart+uintptr((*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fsize)*4 {
  42946 		// If 'root_table' does not have enough memory, allocate a new segment.
  42947 		// The available part of root_table->curr_segment is left unused because we
  42948 		// need a contiguous buffer.
  42949 		segment_size = (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fsize
  42950 		next = WebPSafeMalloc(tls, uint64(1), uint64(32))
  42951 		if next == libc.UintptrFromInt32(0) {
  42952 			return 0
  42953 		}
  42954 		// Fill the new segment.
  42955 		// We need at least 'total_size' but if that value is small, it is better to
  42956 		// allocate a big chunk to prevent more allocations later. 'segment_size' is
  42957 		// therefore chosen (any other arbitrary value could be chosen).
  42958 		if total_size > segment_size {
  42959 			v1 = total_size
  42960 		} else {
  42961 			v1 = segment_size
  42962 		}
  42963 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fsize = v1
  42964 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart = WebPSafeMalloc(tls, libc.Uint64FromInt32((*HuffmanTablesSegment)(unsafe.Pointer(next)).Fsize), uint64(4))
  42965 		if (*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart == libc.UintptrFromInt32(0) {
  42966 			WebPSafeFree(tls, next)
  42967 			return 0
  42968 		}
  42969 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fcurr_table = (*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart
  42970 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fnext = libc.UintptrFromInt32(0)
  42971 		// Point to the new segment.
  42972 		(*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fnext = next
  42973 		(*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment = next
  42974 	}
  42975 	if code_lengths_size <= int32(SORTED_SIZE_CUTOFF) {
  42976 		BuildHuffmanTable(tls, (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fcurr_table, root_bits, code_lengths, code_lengths_size, bp)
  42977 	} else { // rare case. Use heap allocation.
  42978 		sorted1 = WebPSafeMalloc(tls, libc.Uint64FromInt32(code_lengths_size), uint64(2))
  42979 		if sorted1 == libc.UintptrFromInt32(0) {
  42980 			return 0
  42981 		}
  42982 		BuildHuffmanTable(tls, (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fcurr_table, root_bits, code_lengths, code_lengths_size, sorted1)
  42983 		WebPSafeFree(tls, sorted1)
  42984 	}
  42985 	return total_size
  42986 }
  42987 
  42988 func VP8LHuffmanTablesAllocate(tls *libc.TLS, size int32, huffman_tables uintptr) (r int32) {
  42989 	var root uintptr
  42990 	_ = root
  42991 	// Have 'segment' point to the first segment for now, 'root'.
  42992 	root = huffman_tables
  42993 	(*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment = root
  42994 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fnext = libc.UintptrFromInt32(0)
  42995 	// Allocate root.
  42996 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart = WebPSafeMalloc(tls, libc.Uint64FromInt32(size), uint64(4))
  42997 	if (*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart == libc.UintptrFromInt32(0) {
  42998 		return 0
  42999 	}
  43000 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fcurr_table = (*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart
  43001 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fsize = size
  43002 	return int32(1)
  43003 }
  43004 
  43005 func VP8LHuffmanTablesDeallocate(tls *libc.TLS, huffman_tables uintptr) {
  43006 	var current, next uintptr
  43007 	_, _ = current, next
  43008 	if huffman_tables == libc.UintptrFromInt32(0) {
  43009 		return
  43010 	}
  43011 	// Free the root node.
  43012 	current = huffman_tables
  43013 	next = (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext
  43014 	WebPSafeFree(tls, (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart)
  43015 	(*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart = libc.UintptrFromInt32(0)
  43016 	(*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext = libc.UintptrFromInt32(0)
  43017 	current = next
  43018 	// Free the following nodes.
  43019 	for current != libc.UintptrFromInt32(0) {
  43020 		next = (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext
  43021 		WebPSafeFree(tls, (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart)
  43022 		WebPSafeFree(tls, current)
  43023 		current = next
  43024 	}
  43025 }
  43026 
  43027 var kHashMul13 = uint32(0x1e35a7bd)
  43028 
  43029 // Alpha related constants.
  43030 
  43031 // Mux related constants.
  43032 
  43033 // Maximum chunk payload is such that adding the header and padding won't
  43034 // overflow a uint32_t.
  43035 
  43036 // Copyright 2010 Google Inc. All Rights Reserved.
  43037 //
  43038 // Use of this source code is governed by a BSD-style license
  43039 // that can be found in the COPYING file in the root of the source
  43040 // tree. An additional intellectual property rights grant can be found
  43041 // in the file PATENTS. All contributing project authors may
  43042 // be found in the AUTHORS file in the root of the source tree.
  43043 // -----------------------------------------------------------------------------
  43044 //
  43045 //  Common types + memory wrappers
  43046 //
  43047 // Author: Skal (pascal.massimino@gmail.com)
  43048 
  43049 // -----------------------------------------------------------------------------
  43050 
  43051 // Palette reordering for smaller sum of deltas (and for smaller storage).
  43052 
  43053 func PaletteCompareColorsForQsort(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) {
  43054 	bp := tls.Alloc(16)
  43055 	defer tls.Free(16)
  43056 	var a, b, v1, v3 uint32_t
  43057 	var v5 int32
  43058 	var _ /* A at bp+0 */ uint32_t
  43059 	_, _, _, _, _ = a, b, v1, v3, v5
  43060 	libc.X__builtin___memcpy_chk(tls, bp, p1, uint64(4), ^__predefined_size_t(0))
  43061 	v1 = **(**uint32_t)(__ccgo_up(bp))
  43062 	goto _2
  43063 _2:
  43064 	a = v1
  43065 	libc.X__builtin___memcpy_chk(tls, bp, p2, uint64(4), ^__predefined_size_t(0))
  43066 	v3 = **(**uint32_t)(__ccgo_up(bp))
  43067 	goto _4
  43068 _4:
  43069 	b = v3
  43070 	if a < b {
  43071 		v5 = -int32(1)
  43072 	} else {
  43073 		v5 = int32(1)
  43074 	}
  43075 	return v5
  43076 }
  43077 
  43078 func PaletteComponentDistance(tls *libc.TLS, v uint32_t) (r uint32_t) {
  43079 	var v1 uint32
  43080 	_ = v1
  43081 	if v <= uint32(128) {
  43082 		v1 = v
  43083 	} else {
  43084 		v1 = uint32(256) - v
  43085 	}
  43086 	return v1
  43087 }
  43088 
  43089 // C documentation
  43090 //
  43091 //	// Computes a value that is related to the entropy created by the
  43092 //	// palette entry diff.
  43093 //	//
  43094 //	// Note that the last & 0xff is a no-operation in the next statement, but
  43095 //	// removed by most compilers and is here only for regularity of the code.
  43096 func PaletteColorDistance(tls *libc.TLS, col1 uint32_t, col2 uint32_t) (r uint32_t) {
  43097 	var alpha_and_green, diff, red_and_blue, score, v1, v2, v3 uint32_t
  43098 	var kMoreWeightForRGBThanForAlpha int32
  43099 	_, _, _, _, _, _, _, _ = alpha_and_green, diff, kMoreWeightForRGBThanForAlpha, red_and_blue, score, v1, v2, v3
  43100 	v1 = col1
  43101 	v2 = col2
  43102 	alpha_and_green = uint32(0x00ff00ff) + v1&uint32(0xff00ff00) - v2&uint32(0xff00ff00)
  43103 	red_and_blue = uint32(0xff00ff00) + v1&uint32(0x00ff00ff) - v2&uint32(0x00ff00ff)
  43104 	v3 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  43105 	goto _4
  43106 _4:
  43107 	diff = v3
  43108 	kMoreWeightForRGBThanForAlpha = int32(9)
  43109 	score = PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(0)&uint32(0xff))
  43110 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(8)&uint32(0xff))
  43111 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(16)&uint32(0xff))
  43112 	score = score * libc.Uint32FromInt32(kMoreWeightForRGBThanForAlpha)
  43113 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(24)&uint32(0xff))
  43114 	return score
  43115 }
  43116 
  43117 func SwapColor(tls *libc.TLS, col1 uintptr, col2 uintptr) {
  43118 	var tmp uint32_t
  43119 	_ = tmp
  43120 	tmp = **(**uint32_t)(__ccgo_up(col1))
  43121 	**(**uint32_t)(__ccgo_up(col1)) = **(**uint32_t)(__ccgo_up(col2))
  43122 	**(**uint32_t)(__ccgo_up(col2)) = tmp
  43123 }
  43124 
  43125 func SearchColorNoIdx(tls *libc.TLS, sorted uintptr, color uint32_t, num_colors int32) (r int32) {
  43126 	var hi, low, mid int32
  43127 	_, _, _ = hi, low, mid
  43128 	low = 0
  43129 	hi = num_colors
  43130 	if **(**uint32_t)(__ccgo_up(sorted + uintptr(low)*4)) == color {
  43131 		return low
  43132 	} // loop invariant: sorted[low] != color
  43133 	for int32(1) != 0 {
  43134 		mid = (low + hi) >> int32(1)
  43135 		if **(**uint32_t)(__ccgo_up(sorted + uintptr(mid)*4)) == color {
  43136 			return mid
  43137 		} else {
  43138 			if **(**uint32_t)(__ccgo_up(sorted + uintptr(mid)*4)) < color {
  43139 				low = mid
  43140 			} else {
  43141 				hi = mid
  43142 			}
  43143 		}
  43144 	}
  43145 	return 0
  43146 }
  43147 
  43148 func PrepareMapToPalette(tls *libc.TLS, palette uintptr, num_colors uint32_t, sorted uintptr, idx_map uintptr) {
  43149 	var i uint32_t
  43150 	_ = i
  43151 	libc.X__builtin___memcpy_chk(tls, sorted, palette, uint64(num_colors)*uint64(4), ^__predefined_size_t(0))
  43152 	libc.Xqsort(tls, sorted, uint64(num_colors), uint64(4), __ccgo_fp(PaletteCompareColorsForQsort))
  43153 	i = uint32(0)
  43154 	for {
  43155 		if !(i < num_colors) {
  43156 			break
  43157 		}
  43158 		**(**uint32_t)(__ccgo_up(idx_map + uintptr(SearchColorNoIdx(tls, sorted, **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4)), libc.Int32FromUint32(num_colors)))*4)) = i
  43159 		goto _1
  43160 	_1:
  43161 		;
  43162 		i = i + 1
  43163 	}
  43164 }
  43165 
  43166 //------------------------------------------------------------------------------
  43167 
  43168 func GetColorPalette(tls *libc.TLS, pic uintptr, palette uintptr) (r int32) {
  43169 	var argb1 uintptr
  43170 	var colors [1024]uint32_t
  43171 	var height, i, key, num_colors, width, x, y, v3 int32
  43172 	var in_use [1024]uint8_t
  43173 	var last_pix uint32_t
  43174 	_, _, _, _, _, _, _, _, _, _, _, _ = argb1, colors, height, i, in_use, key, last_pix, num_colors, width, x, y, v3
  43175 	num_colors = 0
  43176 	in_use = [1024]uint8_t{}
  43177 	colors = [1024]uint32_t{}
  43178 	argb1 = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  43179 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  43180 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  43181 	last_pix = ^**(**uint32_t)(__ccgo_up(argb1)) // so we're sure that last_pix != argb[0]
  43182 	y = 0
  43183 	for {
  43184 		if !(y < height) {
  43185 			break
  43186 		}
  43187 		x = 0
  43188 		for {
  43189 			if !(x < width) {
  43190 				break
  43191 			}
  43192 			if **(**uint32_t)(__ccgo_up(argb1 + uintptr(x)*4)) == last_pix {
  43193 				goto _2
  43194 			}
  43195 			last_pix = **(**uint32_t)(__ccgo_up(argb1 + uintptr(x)*4))
  43196 			v3 = libc.Int32FromUint32(last_pix * kHashMul13 >> int32(22))
  43197 			goto _4
  43198 		_4:
  43199 			key = v3
  43200 			for int32(1) != 0 {
  43201 				if !(in_use[key] != 0) {
  43202 					colors[key] = last_pix
  43203 					in_use[key] = uint8(1)
  43204 					num_colors = num_colors + 1
  43205 					if num_colors > int32(MAX_PALETTE_SIZE) {
  43206 						return libc.Int32FromInt32(MAX_PALETTE_SIZE) + libc.Int32FromInt32(1) // Exact count not needed.
  43207 					}
  43208 					break
  43209 				} else {
  43210 					if colors[key] == last_pix {
  43211 						break // The color is already there.
  43212 					} else {
  43213 						// Some other color sits here, so do linear conflict resolution.
  43214 						key = key + 1
  43215 						key = key & (libc.Int32FromInt32(MAX_PALETTE_SIZE)*libc.Int32FromInt32(4) - libc.Int32FromInt32(1)) // Key mask.
  43216 					}
  43217 				}
  43218 			}
  43219 			goto _2
  43220 		_2:
  43221 			;
  43222 			x = x + 1
  43223 		}
  43224 		argb1 = argb1 + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  43225 		goto _1
  43226 	_1:
  43227 		;
  43228 		y = y + 1
  43229 	}
  43230 	if palette != libc.UintptrFromInt32(0) { // Fill the colors into palette.
  43231 		num_colors = 0
  43232 		i = 0
  43233 		for {
  43234 			if !(i < libc.Int32FromInt32(MAX_PALETTE_SIZE)*libc.Int32FromInt32(4)) {
  43235 				break
  43236 			}
  43237 			if in_use[i] != 0 {
  43238 				**(**uint32_t)(__ccgo_up(palette + uintptr(num_colors)*4)) = colors[i]
  43239 				num_colors = num_colors + 1
  43240 			}
  43241 			goto _5
  43242 		_5:
  43243 			;
  43244 			i = i + 1
  43245 		}
  43246 		libc.Xqsort(tls, palette, libc.Uint64FromInt32(num_colors), uint64(4), __ccgo_fp(PaletteCompareColorsForQsort))
  43247 	}
  43248 	return num_colors
  43249 }
  43250 
  43251 // -----------------------------------------------------------------------------
  43252 
  43253 // C documentation
  43254 //
  43255 //	// The palette has been sorted by alpha. This function checks if the other
  43256 //	// components of the palette have a monotonic development with regards to
  43257 //	// position in the palette. If all have monotonic development, there is
  43258 //	// no benefit to re-organize them greedily. A monotonic development
  43259 //	// would be spotted in green-only situations (like lossy alpha) or gray-scale
  43260 //	// images.
  43261 func PaletteHasNonMonotonousDeltas(tls *libc.TLS, palette uintptr, num_colors int32) (r int32) {
  43262 	var alpha_and_green, diff, predict, red_and_blue, v2, v3, v4 uint32_t
  43263 	var bd, gd, rd, sign_found uint8_t
  43264 	var i, v6 int32
  43265 	_, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, bd, diff, gd, i, predict, rd, red_and_blue, sign_found, v2, v3, v4, v6
  43266 	predict = uint32(0x000000)
  43267 	sign_found = uint8(0x00)
  43268 	i = 0
  43269 	for {
  43270 		if !(i < num_colors) {
  43271 			break
  43272 		}
  43273 		v2 = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43274 		v3 = predict
  43275 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  43276 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  43277 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  43278 		goto _5
  43279 	_5:
  43280 		diff = v4
  43281 		rd = uint8(diff >> libc.Int32FromInt32(16) & uint32(0xff))
  43282 		gd = uint8(diff >> libc.Int32FromInt32(8) & uint32(0xff))
  43283 		bd = uint8(diff >> libc.Int32FromInt32(0) & uint32(0xff))
  43284 		if libc.Int32FromUint8(rd) != 0x00 {
  43285 			if libc.Int32FromUint8(rd) < int32(0x80) {
  43286 				v6 = int32(1)
  43287 			} else {
  43288 				v6 = int32(2)
  43289 			}
  43290 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43291 		}
  43292 		if libc.Int32FromUint8(gd) != 0x00 {
  43293 			if libc.Int32FromUint8(gd) < int32(0x80) {
  43294 				v6 = int32(8)
  43295 			} else {
  43296 				v6 = int32(16)
  43297 			}
  43298 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43299 		}
  43300 		if libc.Int32FromUint8(bd) != 0x00 {
  43301 			if libc.Int32FromUint8(bd) < int32(0x80) {
  43302 				v6 = int32(64)
  43303 			} else {
  43304 				v6 = int32(128)
  43305 			}
  43306 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43307 		}
  43308 		predict = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43309 		goto _1
  43310 	_1:
  43311 		;
  43312 		i = i + 1
  43313 	}
  43314 	return libc.BoolInt32(libc.Int32FromUint8(sign_found)&(libc.Int32FromUint8(sign_found)<<int32(1)) != 0) // two consequent signs.
  43315 }
  43316 
  43317 func PaletteSortMinimizeDeltas(tls *libc.TLS, palette_sorted uintptr, num_colors int32, palette uintptr) {
  43318 	var best_ix, i, k int32
  43319 	var best_score, cur_score, predict uint32_t
  43320 	_, _, _, _, _, _ = best_ix, best_score, cur_score, i, k, predict
  43321 	predict = uint32(0x00000000)
  43322 	libc.X__builtin___memcpy_chk(tls, palette, palette_sorted, libc.Uint64FromInt32(num_colors)*uint64(4), ^__predefined_size_t(0))
  43323 	if !(PaletteHasNonMonotonousDeltas(tls, palette_sorted, num_colors) != 0) {
  43324 		return
  43325 	}
  43326 	// Find greedily always the closest color of the predicted color to minimize
  43327 	// deltas in the palette. This reduces storage needs since the
  43328 	// palette is stored with delta encoding.
  43329 	if num_colors > int32(17) {
  43330 		if **(**uint32_t)(__ccgo_up(palette)) == uint32(0) {
  43331 			num_colors = num_colors - 1
  43332 			SwapColor(tls, palette+uintptr(num_colors)*4, palette)
  43333 		}
  43334 	}
  43335 	i = 0
  43336 	for {
  43337 		if !(i < num_colors) {
  43338 			break
  43339 		}
  43340 		best_ix = i
  43341 		best_score = ^libc.Uint32FromUint32(0)
  43342 		k = i
  43343 		for {
  43344 			if !(k < num_colors) {
  43345 				break
  43346 			}
  43347 			cur_score = PaletteColorDistance(tls, **(**uint32_t)(__ccgo_up(palette + uintptr(k)*4)), predict)
  43348 			if best_score > cur_score {
  43349 				best_score = cur_score
  43350 				best_ix = k
  43351 			}
  43352 			goto _2
  43353 		_2:
  43354 			;
  43355 			k = k + 1
  43356 		}
  43357 		SwapColor(tls, palette+uintptr(best_ix)*4, palette+uintptr(i)*4)
  43358 		predict = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43359 		goto _1
  43360 	_1:
  43361 		;
  43362 		i = i + 1
  43363 	}
  43364 }
  43365 
  43366 // -----------------------------------------------------------------------------
  43367 // Modified Zeng method from "A Survey on Palette Reordering
  43368 // Methods for Improving the Compression of Color-Indexed Images" by Armando J.
  43369 // Pinho and Antonio J. R. Neves.
  43370 
  43371 // C documentation
  43372 //
  43373 //	// Finds the biggest cooccurrence in the matrix.
  43374 func CoOccurrenceFindMax(tls *libc.TLS, cooccurrence uintptr, num_colors uint32_t, c1 uintptr, c2 uintptr) {
  43375 	var best_cooccurrence, best_sum, i, j, sum uint32_t
  43376 	_, _, _, _, _ = best_cooccurrence, best_sum, i, j, sum
  43377 	// Find the index that is most frequently located adjacent to other
  43378 	// (different) indexes.
  43379 	best_sum = 0
  43380 	**(**uint8_t)(__ccgo_up(c1)) = 0
  43381 	i = uint32(0)
  43382 	for {
  43383 		if !(i < num_colors) {
  43384 			break
  43385 		}
  43386 		sum = uint32(0)
  43387 		j = uint32(0)
  43388 		for {
  43389 			if !(j < num_colors) {
  43390 				break
  43391 			}
  43392 			sum = sum + **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(i*num_colors+j)*4))
  43393 			goto _2
  43394 		_2:
  43395 			;
  43396 			j = j + 1
  43397 		}
  43398 		if sum > best_sum {
  43399 			best_sum = sum
  43400 			**(**uint8_t)(__ccgo_up(c1)) = uint8(i)
  43401 		}
  43402 		goto _1
  43403 	_1:
  43404 		;
  43405 		i = i + 1
  43406 	}
  43407 	// Find the index that is most frequently found adjacent to *c1.
  43408 	**(**uint8_t)(__ccgo_up(c2)) = 0
  43409 	best_cooccurrence = 0
  43410 	i = uint32(0)
  43411 	for {
  43412 		if !(i < num_colors) {
  43413 			break
  43414 		}
  43415 		if **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(**(**uint8_t)(__ccgo_up(c1)))*num_colors+i)*4)) > best_cooccurrence {
  43416 			best_cooccurrence = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(**(**uint8_t)(__ccgo_up(c1)))*num_colors+i)*4))
  43417 			**(**uint8_t)(__ccgo_up(c2)) = uint8(i)
  43418 		}
  43419 		goto _3
  43420 	_3:
  43421 		;
  43422 		i = i + 1
  43423 	}
  43424 }
  43425 
  43426 // C documentation
  43427 //
  43428 //	// Builds the cooccurrence matrix
  43429 func CoOccurrenceBuild(tls *libc.TLS, pic uintptr, palette uintptr, num_colors uint32_t, cooccurrence uintptr) (r int32) {
  43430 	bp := tls.Alloc(2048)
  43431 	defer tls.Free(2048)
  43432 	var left_idx, pix, prev_idx, prev_pix, top_idx uint32_t
  43433 	var line_current, line_tmp, line_top, lines, src uintptr
  43434 	var x, y int32
  43435 	var _ /* idx_map at bp+0 */ [256]uint32_t
  43436 	var _ /* palette_sorted at bp+1024 */ [256]uint32_t
  43437 	_, _, _, _, _, _, _, _, _, _, _, _ = left_idx, line_current, line_tmp, line_top, lines, pix, prev_idx, prev_pix, src, top_idx, x, y
  43438 	src = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  43439 	prev_pix = ^**(**uint32_t)(__ccgo_up(src))
  43440 	prev_idx = 0
  43441 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  43442 	lines = WebPSafeMalloc(tls, libc.Uint64FromInt32(int32(2)*(*WebPPicture)(unsafe.Pointer(pic)).Fwidth), uint64(4))
  43443 	if lines == libc.UintptrFromInt32(0) {
  43444 		return 0
  43445 	}
  43446 	line_top = lines
  43447 	line_current = lines + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fwidth)*4
  43448 	PrepareMapToPalette(tls, palette, num_colors, bp+1024, bp)
  43449 	y = 0
  43450 	for {
  43451 		if !(y < (*WebPPicture)(unsafe.Pointer(pic)).Fheight) {
  43452 			break
  43453 		}
  43454 		x = 0
  43455 		for {
  43456 			if !(x < (*WebPPicture)(unsafe.Pointer(pic)).Fwidth) {
  43457 				break
  43458 			}
  43459 			pix = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  43460 			if pix != prev_pix {
  43461 				prev_idx = (**(**[256]uint32_t)(__ccgo_up(bp)))[SearchColorNoIdx(tls, bp+1024, pix, libc.Int32FromUint32(num_colors))]
  43462 				prev_pix = pix
  43463 			}
  43464 			**(**uint32_t)(__ccgo_up(line_current + uintptr(x)*4)) = prev_idx
  43465 			// 4-connectivity is what works best as mentioned in "On the relation
  43466 			// between Memon's and the modified Zeng's palette reordering methods".
  43467 			if x > 0 && prev_idx != **(**uint32_t)(__ccgo_up(line_current + uintptr(x-int32(1))*4)) {
  43468 				left_idx = **(**uint32_t)(__ccgo_up(line_current + uintptr(x-int32(1))*4))
  43469 				**(**uint32_t)(__ccgo_up(cooccurrence + uintptr(prev_idx*num_colors+left_idx)*4)) = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(prev_idx*num_colors+left_idx)*4)) + 1
  43470 				**(**uint32_t)(__ccgo_up(cooccurrence + uintptr(left_idx*num_colors+prev_idx)*4)) = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(left_idx*num_colors+prev_idx)*4)) + 1
  43471 			}
  43472 			if y > 0 && prev_idx != **(**uint32_t)(__ccgo_up(line_top + uintptr(x)*4)) {
  43473 				top_idx = **(**uint32_t)(__ccgo_up(line_top + uintptr(x)*4))
  43474 				**(**uint32_t)(__ccgo_up(cooccurrence + uintptr(prev_idx*num_colors+top_idx)*4)) = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(prev_idx*num_colors+top_idx)*4)) + 1
  43475 				**(**uint32_t)(__ccgo_up(cooccurrence + uintptr(top_idx*num_colors+prev_idx)*4)) = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(top_idx*num_colors+prev_idx)*4)) + 1
  43476 			}
  43477 			goto _2
  43478 		_2:
  43479 			;
  43480 			x = x + 1
  43481 		}
  43482 		line_tmp = line_top
  43483 		line_top = line_current
  43484 		line_current = line_tmp
  43485 		src = src + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  43486 		goto _1
  43487 	_1:
  43488 		;
  43489 		y = y + 1
  43490 	}
  43491 	WebPSafeFree(tls, lines)
  43492 	return int32(1)
  43493 }
  43494 
  43495 type Sum = struct {
  43496 	Findex uint8_t
  43497 	Fsum   uint32_t
  43498 }
  43499 
  43500 func PaletteSortModifiedZeng(tls *libc.TLS, pic uintptr, palette_in uintptr, num_colors uint32_t, palette uintptr) (r int32) {
  43501 	bp := tls.Alloc(2304)
  43502 	defer tls.Free(2304)
  43503 	var best_index uint8_t
  43504 	var best_sum, cooccurrence uintptr
  43505 	var delta, n int32_t
  43506 	var first, i, ind, j, last, num_sums uint32_t
  43507 	var l_j uint16_t
  43508 	var v3 uint32
  43509 	var _ /* remapping at bp+0 */ [256]uint8_t
  43510 	var _ /* sums at bp+256 */ [256]Sum
  43511 	_, _, _, _, _, _, _, _, _, _, _, _, _ = best_index, best_sum, cooccurrence, delta, first, i, ind, j, l_j, last, n, num_sums, v3
  43512 	// TODO(vrabaud) check whether one color images should use palette or not.
  43513 	if num_colors <= uint32(1) {
  43514 		return int32(1)
  43515 	}
  43516 	// Build the co-occurrence matrix.
  43517 	cooccurrence = WebPSafeCalloc(tls, uint64(num_colors*num_colors), uint64(4))
  43518 	if cooccurrence == libc.UintptrFromInt32(0) {
  43519 		return 0
  43520 	}
  43521 	if !(CoOccurrenceBuild(tls, pic, palette_in, num_colors, cooccurrence) != 0) {
  43522 		WebPSafeFree(tls, cooccurrence)
  43523 		return 0
  43524 	}
  43525 	// Initialize the mapping list with the two best indices.
  43526 	CoOccurrenceFindMax(tls, cooccurrence, num_colors, bp, bp+1)
  43527 	// We need to append and prepend to the list of remapping. To this end, we
  43528 	// actually define the next start/end of the list as indices in a vector (with
  43529 	// a wrap around when the end is reached).
  43530 	first = uint32(0)
  43531 	last = uint32(1)
  43532 	num_sums = num_colors - uint32(2) // -2 because we know the first two values
  43533 	if num_sums > uint32(0) {
  43534 		// Initialize the sums with the first two remappings and find the best one
  43535 		best_sum = bp + 256
  43536 		(*Sum)(unsafe.Pointer(best_sum)).Findex = 0
  43537 		(*Sum)(unsafe.Pointer(best_sum)).Fsum = 0
  43538 		i = uint32(0)
  43539 		j = libc.Uint32FromInt32(0)
  43540 		for {
  43541 			if !(i < num_colors) {
  43542 				break
  43543 			}
  43544 			if i == uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[0]) || i == uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[int32(1)]) {
  43545 				goto _1
  43546 			}
  43547 			(**(**[256]Sum)(__ccgo_up(bp + 256)))[j].Findex = uint8(i)
  43548 			(**(**[256]Sum)(__ccgo_up(bp + 256)))[j].Fsum = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(i*num_colors+uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[0]))*4)) + **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(i*num_colors+uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[int32(1)]))*4))
  43549 			if (**(**[256]Sum)(__ccgo_up(bp + 256)))[j].Fsum > (*Sum)(unsafe.Pointer(best_sum)).Fsum {
  43550 				best_sum = bp + 256 + uintptr(j)*8
  43551 			}
  43552 			j = j + 1
  43553 			goto _1
  43554 		_1:
  43555 			;
  43556 			i = i + 1
  43557 		}
  43558 		for num_sums > uint32(0) {
  43559 			best_index = (*Sum)(unsafe.Pointer(best_sum)).Findex
  43560 			// Compute delta to know if we need to prepend or append the best index.
  43561 			delta = 0
  43562 			n = libc.Int32FromUint32(num_colors - num_sums)
  43563 			ind = first
  43564 			j = libc.Uint32FromInt32(0)
  43565 			for {
  43566 				if !((ind+j)%num_colors != last+uint32(1)) {
  43567 					break
  43568 				}
  43569 				l_j = uint16((**(**[256]uint8_t)(__ccgo_up(bp)))[(ind+j)%num_colors])
  43570 				delta = delta + (n-int32(1)-int32(2)*libc.Int32FromUint32(j))*libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(best_index)*num_colors+uint32(l_j))*4)))
  43571 				goto _2
  43572 			_2:
  43573 				;
  43574 				j = j + 1
  43575 			}
  43576 			if delta > 0 {
  43577 				if first == uint32(0) {
  43578 					v3 = num_colors - uint32(1)
  43579 				} else {
  43580 					v3 = first - uint32(1)
  43581 				}
  43582 				first = v3
  43583 				(**(**[256]uint8_t)(__ccgo_up(bp)))[first] = best_index
  43584 			} else {
  43585 				last = last + 1
  43586 				(**(**[256]uint8_t)(__ccgo_up(bp)))[last] = best_index
  43587 			}
  43588 			// Remove best_sum from sums.
  43589 			**(**Sum)(__ccgo_up(best_sum)) = (**(**[256]Sum)(__ccgo_up(bp + 256)))[num_sums-uint32(1)]
  43590 			num_sums = num_sums - 1
  43591 			// Update all the sums and find the best one.
  43592 			best_sum = bp + 256
  43593 			i = uint32(0)
  43594 			for {
  43595 				if !(i < num_sums) {
  43596 					break
  43597 				}
  43598 				(**(**[256]Sum)(__ccgo_up(bp + 256)))[i].Fsum += **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(best_index)*num_colors+uint32((**(**[256]Sum)(__ccgo_up(bp + 256)))[i].Findex))*4))
  43599 				if (**(**[256]Sum)(__ccgo_up(bp + 256)))[i].Fsum > (*Sum)(unsafe.Pointer(best_sum)).Fsum {
  43600 					best_sum = bp + 256 + uintptr(i)*8
  43601 				}
  43602 				goto _4
  43603 			_4:
  43604 				;
  43605 				i = i + 1
  43606 			}
  43607 		}
  43608 	}
  43609 	WebPSafeFree(tls, cooccurrence)
  43610 	// Re-map the palette.
  43611 	i = uint32(0)
  43612 	for {
  43613 		if !(i < num_colors) {
  43614 			break
  43615 		}
  43616 		**(**uint32_t)(__ccgo_up(palette + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(palette_in + uintptr((**(**[256]uint8_t)(__ccgo_up(bp)))[(first+i)%num_colors])*4))
  43617 		goto _5
  43618 	_5:
  43619 		;
  43620 		i = i + 1
  43621 	}
  43622 	return int32(1)
  43623 }
  43624 
  43625 // -----------------------------------------------------------------------------
  43626 
  43627 func PaletteSort(tls *libc.TLS, method PaletteSorting1, pic uintptr, palette_sorted uintptr, num_colors uint32_t, palette uintptr) (r int32) {
  43628 	switch method {
  43629 	case int32(kSortedDefault):
  43630 		if **(**uint32_t)(__ccgo_up(palette_sorted)) == uint32(0) && num_colors > uint32(17) {
  43631 			libc.X__builtin___memcpy_chk(tls, palette, palette_sorted+uintptr(1)*4, uint64(num_colors-libc.Uint32FromInt32(1))*uint64(4), ^__predefined_size_t(0))
  43632 			**(**uint32_t)(__ccgo_up(palette + uintptr(num_colors-uint32(1))*4)) = uint32(0)
  43633 		} else {
  43634 			libc.X__builtin___memcpy_chk(tls, palette, palette_sorted, uint64(num_colors)*uint64(4), ^__predefined_size_t(0))
  43635 		}
  43636 		return int32(1)
  43637 	case int32(kMinimizeDelta):
  43638 		PaletteSortMinimizeDeltas(tls, palette_sorted, libc.Int32FromUint32(num_colors), palette)
  43639 		return int32(1)
  43640 	case int32(kModifiedZeng):
  43641 		return PaletteSortModifiedZeng(tls, pic, palette_sorted, num_colors, palette)
  43642 	case int32(kUnusedPalette):
  43643 		fallthrough
  43644 	case int32(kPaletteSortingNum):
  43645 		break
  43646 	}
  43647 	return 0
  43648 }
  43649 
  43650 const DFIX = 0
  43651 const FIX = 16
  43652 const LFIX = 2
  43653 
  43654 //------------------------------------------------------------------------------
  43655 
  43656 // Copyright 2010 Google Inc. All Rights Reserved.
  43657 //
  43658 // Use of this source code is governed by a BSD-style license
  43659 // that can be found in the COPYING file in the root of the source
  43660 // tree. An additional intellectual property rights grant can be found
  43661 // in the file PATENTS. All contributing project authors may
  43662 // be found in the AUTHORS file in the root of the source tree.
  43663 // -----------------------------------------------------------------------------
  43664 //
  43665 //  Common types + memory wrappers
  43666 //
  43667 // Author: Skal (pascal.massimino@gmail.com)
  43668 
  43669 // #define USE_DITHERING   // uncomment to enable ordered dithering (not vital)
  43670 
  43671 type SmoothParams = struct {
  43672 	Fwidth          int32
  43673 	Fheight         int32
  43674 	Fstride         int32
  43675 	Frow            int32
  43676 	Fsrc            uintptr
  43677 	Fdst            uintptr
  43678 	Fradius         int32
  43679 	Fscale          int32
  43680 	Fmem            uintptr
  43681 	Fstart          uintptr
  43682 	Fcur            uintptr
  43683 	Fend            uintptr
  43684 	Ftop            uintptr
  43685 	Faverage        uintptr
  43686 	Fnum_levels     int32
  43687 	Fmin            int32
  43688 	Fmax            int32
  43689 	Fmin_level_dist int32
  43690 	Fcorrection     uintptr
  43691 }
  43692 
  43693 //------------------------------------------------------------------------------
  43694 
  43695 func clip_8b(tls *libc.TLS, v int32) (r uint8_t) {
  43696 	var v1, v2 uint32
  43697 	_, _ = v1, v2
  43698 	if !(v&libc.Int32FromUint32(^libc.Uint32FromUint32(0)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(DFIX))) != 0) {
  43699 		v1 = uint32(libc.Uint8FromInt32(v >> libc.Int32FromInt32(DFIX)))
  43700 	} else {
  43701 		if v < 0 {
  43702 			v2 = 0
  43703 		} else {
  43704 			v2 = uint32(255)
  43705 		}
  43706 		v1 = v2
  43707 	}
  43708 	return uint8(v1)
  43709 }
  43710 
  43711 // C documentation
  43712 //
  43713 //	// vertical accumulation
  43714 func VFilter(tls *libc.TLS, p uintptr) {
  43715 	var cur, out, src, top uintptr
  43716 	var new_value, sum uint16_t
  43717 	var w, x int32
  43718 	_, _, _, _, _, _, _, _ = cur, new_value, out, src, sum, top, w, x
  43719 	src = (*SmoothParams)(unsafe.Pointer(p)).Fsrc
  43720 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43721 	cur = (*SmoothParams)(unsafe.Pointer(p)).Fcur
  43722 	top = (*SmoothParams)(unsafe.Pointer(p)).Ftop
  43723 	out = (*SmoothParams)(unsafe.Pointer(p)).Fend
  43724 	sum = uint16(0)
  43725 	x = 0
  43726 	for {
  43727 		if !(x < w) {
  43728 			break
  43729 		}
  43730 		sum = libc.Uint16FromInt32(int32(sum) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + uintptr(x)))))
  43731 		new_value = libc.Uint16FromInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(top + uintptr(x)*2))) + libc.Int32FromUint16(sum))
  43732 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = libc.Uint16FromInt32(libc.Int32FromUint16(new_value) - libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(cur + uintptr(x)*2)))) // vertical sum of 'r' pixels.
  43733 		**(**uint16_t)(__ccgo_up(cur + uintptr(x)*2)) = new_value
  43734 		goto _1
  43735 	_1:
  43736 		;
  43737 		x = x + 1
  43738 	}
  43739 	// move input pointers one row down
  43740 	(*SmoothParams)(unsafe.Pointer(p)).Ftop = (*SmoothParams)(unsafe.Pointer(p)).Fcur
  43741 	**(**uintptr)(__ccgo_up(p + 56)) += uintptr(w) * 2
  43742 	if (*SmoothParams)(unsafe.Pointer(p)).Fcur == (*SmoothParams)(unsafe.Pointer(p)).Fend {
  43743 		(*SmoothParams)(unsafe.Pointer(p)).Fcur = (*SmoothParams)(unsafe.Pointer(p)).Fstart
  43744 	} // roll-over
  43745 	// We replicate edges, as it's somewhat easier as a boundary condition.
  43746 	// That's why we don't update the 'src' pointer on top/bottom area:
  43747 	if (*SmoothParams)(unsafe.Pointer(p)).Frow >= 0 && (*SmoothParams)(unsafe.Pointer(p)).Frow < (*SmoothParams)(unsafe.Pointer(p)).Fheight-int32(1) {
  43748 		**(**uintptr)(__ccgo_up(p + 16)) += uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride)
  43749 	}
  43750 }
  43751 
  43752 // C documentation
  43753 //
  43754 //	// horizontal accumulation. We use mirror replication of missing pixels, as it's
  43755 //	// a little easier to implement (surprisingly).
  43756 func HFilter(tls *libc.TLS, p uintptr) {
  43757 	var delta, delta1, delta2 uint16_t
  43758 	var in, out uintptr
  43759 	var r, w, x int32
  43760 	var scale uint32_t
  43761 	_, _, _, _, _, _, _, _, _ = delta, delta1, delta2, in, out, r, scale, w, x
  43762 	in = (*SmoothParams)(unsafe.Pointer(p)).Fend
  43763 	out = (*SmoothParams)(unsafe.Pointer(p)).Faverage
  43764 	scale = libc.Uint32FromInt32((*SmoothParams)(unsafe.Pointer(p)).Fscale)
  43765 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43766 	r = (*SmoothParams)(unsafe.Pointer(p)).Fradius
  43767 	x = 0
  43768 	for {
  43769 		if !(x <= r) {
  43770 			break
  43771 		} // left mirroring
  43772 		delta = libc.Uint16FromInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(x+r-int32(1))*2))) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(r-x)*2))))
  43773 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta) * scale >> int32(FIX))
  43774 		goto _1
  43775 	_1:
  43776 		;
  43777 		x = x + 1
  43778 	}
  43779 	for {
  43780 		if !(x < w-r) {
  43781 			break
  43782 		} // bulk middle run
  43783 		delta1 = libc.Uint16FromInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(x+r)*2))) - libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(x-r-int32(1))*2))))
  43784 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta1) * scale >> int32(FIX))
  43785 		goto _2
  43786 	_2:
  43787 		;
  43788 		x = x + 1
  43789 	}
  43790 	for {
  43791 		if !(x < w) {
  43792 			break
  43793 		} // right mirroring
  43794 		delta2 = libc.Uint16FromInt32(int32(2)*libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(w-int32(1))*2))) - libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(int32(2)*w-int32(2)-r-x)*2))) - libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(in + uintptr(x-r-int32(1))*2))))
  43795 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta2) * scale >> int32(FIX))
  43796 		goto _3
  43797 	_3:
  43798 		;
  43799 		x = x + 1
  43800 	}
  43801 }
  43802 
  43803 // C documentation
  43804 //
  43805 //	// emit one filtered output row
  43806 func ApplyFilter(tls *libc.TLS, p uintptr) {
  43807 	var average, correction, dst uintptr
  43808 	var c, v, w, x int32
  43809 	_, _, _, _, _, _, _ = average, c, correction, dst, v, w, x
  43810 	average = (*SmoothParams)(unsafe.Pointer(p)).Faverage
  43811 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43812 	correction = (*SmoothParams)(unsafe.Pointer(p)).Fcorrection
  43813 	dst = (*SmoothParams)(unsafe.Pointer(p)).Fdst
  43814 	x = 0
  43815 	for {
  43816 		if !(x < w) {
  43817 			break
  43818 		}
  43819 		v = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(x))))
  43820 		if v < (*SmoothParams)(unsafe.Pointer(p)).Fmax && v > (*SmoothParams)(unsafe.Pointer(p)).Fmin {
  43821 			c = v<<libc.Int32FromInt32(DFIX) + int32(**(**int16_t)(__ccgo_up(correction + uintptr(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(average + uintptr(x)*2)))-v<<libc.Int32FromInt32(LFIX))*2)))
  43822 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = clip_8b(tls, c)
  43823 		}
  43824 		goto _1
  43825 	_1:
  43826 		;
  43827 		x = x + 1
  43828 	}
  43829 	**(**uintptr)(__ccgo_up(p + 24)) += uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride) // advance output pointer
  43830 }
  43831 
  43832 //------------------------------------------------------------------------------
  43833 // Initialize correction table
  43834 
  43835 func InitCorrectionLUT(tls *libc.TLS, lut uintptr, min_dist int32) {
  43836 	var c, delta, i, max_threshold, threshold1, threshold2, v2, v3 int32
  43837 	_, _, _, _, _, _, _, _ = c, delta, i, max_threshold, threshold1, threshold2, v2, v3
  43838 	// The correction curve is:
  43839 	//   f(x) = x for x <= threshold2
  43840 	//   f(x) = 0 for x >= threshold1
  43841 	// and a linear interpolation for range x=[threshold2, threshold1]
  43842 	// (along with f(-x) = -f(x) symmetry).
  43843 	// Note that: threshold2 = 3/4 * threshold1
  43844 	threshold1 = min_dist << int32(LFIX)
  43845 	threshold2 = int32(3) * threshold1 >> int32(2)
  43846 	max_threshold = threshold2 << DFIX
  43847 	delta = threshold1 - threshold2
  43848 	i = int32(1)
  43849 	for {
  43850 		if !(i <= libc.Int32FromInt32(1)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(LFIX))-libc.Int32FromInt32(1)) {
  43851 			break
  43852 		}
  43853 		if i <= threshold2 {
  43854 			v2 = i << DFIX
  43855 		} else {
  43856 			if i < threshold1 {
  43857 				v3 = max_threshold * (threshold1 - i) / delta
  43858 			} else {
  43859 				v3 = 0
  43860 			}
  43861 			v2 = v3
  43862 		}
  43863 		c = v2
  43864 		c = c >> int32(LFIX)
  43865 		**(**int16_t)(__ccgo_up(lut + uintptr(+i)*2)) = int16(+c)
  43866 		**(**int16_t)(__ccgo_up(lut + uintptr(-i)*2)) = int16(-c)
  43867 		goto _1
  43868 	_1:
  43869 		;
  43870 		i = i + 1
  43871 	}
  43872 	**(**int16_t)(__ccgo_up(lut)) = 0
  43873 }
  43874 
  43875 func CountLevels(tls *libc.TLS, p uintptr) {
  43876 	var data uintptr
  43877 	var i, j, last_level, level_dist, v int32
  43878 	var used_levels [256]uint8_t
  43879 	_, _, _, _, _, _, _ = data, i, j, last_level, level_dist, used_levels, v
  43880 	used_levels = [256]uint8_t{}
  43881 	data = (*SmoothParams)(unsafe.Pointer(p)).Fsrc
  43882 	(*SmoothParams)(unsafe.Pointer(p)).Fmin = int32(255)
  43883 	(*SmoothParams)(unsafe.Pointer(p)).Fmax = 0
  43884 	j = 0
  43885 	for {
  43886 		if !(j < (*SmoothParams)(unsafe.Pointer(p)).Fheight) {
  43887 			break
  43888 		}
  43889 		i = 0
  43890 		for {
  43891 			if !(i < (*SmoothParams)(unsafe.Pointer(p)).Fwidth) {
  43892 				break
  43893 			}
  43894 			v = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(i))))
  43895 			if v < (*SmoothParams)(unsafe.Pointer(p)).Fmin {
  43896 				(*SmoothParams)(unsafe.Pointer(p)).Fmin = v
  43897 			}
  43898 			if v > (*SmoothParams)(unsafe.Pointer(p)).Fmax {
  43899 				(*SmoothParams)(unsafe.Pointer(p)).Fmax = v
  43900 			}
  43901 			used_levels[v] = uint8(1)
  43902 			goto _2
  43903 		_2:
  43904 			;
  43905 			i = i + 1
  43906 		}
  43907 		data = data + uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride)
  43908 		goto _1
  43909 	_1:
  43910 		;
  43911 		j = j + 1
  43912 	}
  43913 	// Compute the mininum distance between two non-zero levels.
  43914 	(*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist = (*SmoothParams)(unsafe.Pointer(p)).Fmax - (*SmoothParams)(unsafe.Pointer(p)).Fmin
  43915 	last_level = -int32(1)
  43916 	i = 0
  43917 	for {
  43918 		if !(i < int32(256)) {
  43919 			break
  43920 		}
  43921 		if used_levels[i] != 0 {
  43922 			(*SmoothParams)(unsafe.Pointer(p)).Fnum_levels = (*SmoothParams)(unsafe.Pointer(p)).Fnum_levels + 1
  43923 			if last_level >= 0 {
  43924 				level_dist = i - last_level
  43925 				if level_dist < (*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist {
  43926 					(*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist = level_dist
  43927 				}
  43928 			}
  43929 			last_level = i
  43930 		}
  43931 		goto _3
  43932 	_3:
  43933 		;
  43934 		i = i + 1
  43935 	}
  43936 }
  43937 
  43938 // C documentation
  43939 //
  43940 //	// Initialize all params.
  43941 func InitParams(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, radius int32, p uintptr) (r int32) {
  43942 	var R int32
  43943 	var mem uintptr
  43944 	var size_lut, size_m, size_scratch_m, total_size size_t
  43945 	_, _, _, _, _, _ = R, mem, size_lut, size_m, size_scratch_m, total_size
  43946 	R = int32(2)*radius + int32(1) // total size of the kernel
  43947 	size_scratch_m = libc.Uint64FromInt32((R+int32(1))*width) * uint64(2)
  43948 	size_m = libc.Uint64FromInt32(width) * uint64(2)
  43949 	size_lut = libc.Uint64FromInt32(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*(libc.Int32FromInt32(1)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(LFIX))-libc.Int32FromInt32(1))) * libc.Uint64FromInt64(2)
  43950 	total_size = size_scratch_m + size_m + size_lut
  43951 	mem = WebPSafeMalloc(tls, uint64(1), total_size)
  43952 	if mem == libc.UintptrFromInt32(0) {
  43953 		return 0
  43954 	}
  43955 	(*SmoothParams)(unsafe.Pointer(p)).Fmem = mem
  43956 	(*SmoothParams)(unsafe.Pointer(p)).Fstart = mem
  43957 	(*SmoothParams)(unsafe.Pointer(p)).Fcur = (*SmoothParams)(unsafe.Pointer(p)).Fstart
  43958 	(*SmoothParams)(unsafe.Pointer(p)).Fend = (*SmoothParams)(unsafe.Pointer(p)).Fstart + uintptr(R*width)*2
  43959 	(*SmoothParams)(unsafe.Pointer(p)).Ftop = (*SmoothParams)(unsafe.Pointer(p)).Fend - uintptr(width)*2
  43960 	libc.X__builtin___memset_chk(tls, (*SmoothParams)(unsafe.Pointer(p)).Ftop, 0, libc.Uint64FromInt32(width)*uint64(2), ^__predefined_size_t(0))
  43961 	mem = mem + uintptr(size_scratch_m)
  43962 	(*SmoothParams)(unsafe.Pointer(p)).Faverage = mem
  43963 	mem = mem + uintptr(size_m)
  43964 	(*SmoothParams)(unsafe.Pointer(p)).Fwidth = width
  43965 	(*SmoothParams)(unsafe.Pointer(p)).Fheight = height
  43966 	(*SmoothParams)(unsafe.Pointer(p)).Fstride = stride
  43967 	(*SmoothParams)(unsafe.Pointer(p)).Fsrc = data
  43968 	(*SmoothParams)(unsafe.Pointer(p)).Fdst = data
  43969 	(*SmoothParams)(unsafe.Pointer(p)).Fradius = radius
  43970 	(*SmoothParams)(unsafe.Pointer(p)).Fscale = libc.Int32FromInt32(1) << (libc.Int32FromInt32(FIX) + libc.Int32FromInt32(LFIX)) / (R * R) // normalization constant
  43971 	(*SmoothParams)(unsafe.Pointer(p)).Frow = -radius
  43972 	// analyze the input distribution so we can best-fit the threshold
  43973 	CountLevels(tls, p)
  43974 	// correction table
  43975 	(*SmoothParams)(unsafe.Pointer(p)).Fcorrection = mem + uintptr(libc.Int32FromInt32(1)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(LFIX))-libc.Int32FromInt32(1))*2
  43976 	InitCorrectionLUT(tls, (*SmoothParams)(unsafe.Pointer(p)).Fcorrection, (*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist)
  43977 	return int32(1)
  43978 }
  43979 
  43980 func CleanupParams(tls *libc.TLS, p uintptr) {
  43981 	WebPSafeFree(tls, (*SmoothParams)(unsafe.Pointer(p)).Fmem)
  43982 }
  43983 
  43984 func WebPDequantizeLevels(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, strength int32) (r int32) {
  43985 	bp := tls.Alloc(112)
  43986 	defer tls.Free(112)
  43987 	var radius int32
  43988 	var _ /* p at bp+0 */ SmoothParams
  43989 	_ = radius
  43990 	radius = int32(4) * strength / int32(100)
  43991 	if strength < 0 || strength > int32(100) {
  43992 		return 0
  43993 	}
  43994 	if data == libc.UintptrFromInt32(0) || width <= 0 || height <= 0 {
  43995 		return 0
  43996 	} // bad params
  43997 	// limit the filter size to not exceed the image dimensions
  43998 	if int32(2)*radius+int32(1) > width {
  43999 		radius = (width - int32(1)) >> int32(1)
  44000 	}
  44001 	if int32(2)*radius+int32(1) > height {
  44002 		radius = (height - int32(1)) >> int32(1)
  44003 	}
  44004 	if radius > 0 {
  44005 		libc.X__builtin___memset_chk(tls, bp, 0, uint64(112), ^__predefined_size_t(0))
  44006 		if !(InitParams(tls, data, width, height, stride, radius, bp) != 0) {
  44007 			return 0
  44008 		}
  44009 		if (**(**SmoothParams)(__ccgo_up(bp))).Fnum_levels > int32(2) {
  44010 			for {
  44011 				if !((**(**SmoothParams)(__ccgo_up(bp))).Frow < (**(**SmoothParams)(__ccgo_up(bp))).Fheight) {
  44012 					break
  44013 				}
  44014 				VFilter(tls, bp) // accumulate average of input
  44015 				// Need to wait few rows in order to prime the filter,
  44016 				// before emitting some output.
  44017 				if (**(**SmoothParams)(__ccgo_up(bp))).Frow >= (**(**SmoothParams)(__ccgo_up(bp))).Fradius {
  44018 					HFilter(tls, bp)
  44019 					ApplyFilter(tls, bp)
  44020 				}
  44021 				goto _1
  44022 			_1:
  44023 				;
  44024 				(**(**SmoothParams)(__ccgo_up(bp))).Frow = (**(**SmoothParams)(__ccgo_up(bp))).Frow + 1
  44025 			}
  44026 		}
  44027 		CleanupParams(tls, bp)
  44028 	}
  44029 	return int32(1)
  44030 }
  44031 
  44032 const ERROR_THRESHOLD = 0.0001
  44033 const MAX_ITER = 6
  44034 const NUM_SYMBOLS = 256
  44035 
  44036 // -----------------------------------------------------------------------------
  44037 // Quantize levels.
  44038 
  44039 func QuantizeLevels(tls *libc.TLS, data uintptr, width int32, height int32, num_levels int32, sse uintptr) (r int32) {
  44040 	bp := tls.Alloc(4096)
  44041 	defer tls.Free(4096)
  44042 	var count, err, err_threshold, error1, last_err float64
  44043 	var data_size, n, n1 size_t
  44044 	var freq, q_level [256]int32
  44045 	var i, iter, max_s, min_s, num_levels_in, s, s1, slot, slot1 int32
  44046 	var inv_q_level [256]float64
  44047 	var map1 [256]uint8_t
  44048 	var _ /* q_count at bp+2048 */ [256]float64
  44049 	var _ /* q_sum at bp+0 */ [256]float64
  44050 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, data_size, err, err_threshold, error1, freq, i, inv_q_level, iter, last_err, map1, max_s, min_s, n, n1, num_levels_in, q_level, s, s1, slot, slot1
  44051 	freq = [256]int32{}
  44052 	q_level = [256]int32{}
  44053 	inv_q_level = [256]float64{}
  44054 	min_s = int32(255)
  44055 	max_s = 0
  44056 	data_size = libc.Uint64FromInt32(height * width)
  44057 	last_err = float64(1e+38)
  44058 	err = float64(0)
  44059 	err_threshold = float64(float64(0.0001) * float64(data_size))
  44060 	if data == libc.UintptrFromInt32(0) {
  44061 		return 0
  44062 	}
  44063 	if width <= 0 || height <= 0 {
  44064 		return 0
  44065 	}
  44066 	if num_levels < int32(2) || num_levels > int32(256) {
  44067 		return 0
  44068 	}
  44069 	num_levels_in = 0
  44070 	n = uint64(0)
  44071 	for {
  44072 		if !(n < data_size) {
  44073 			break
  44074 		}
  44075 		num_levels_in = num_levels_in + libc.BoolInt32(freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] == 0)
  44076 		if min_s > libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n)))) {
  44077 			min_s = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n))))
  44078 		}
  44079 		if max_s < libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n)))) {
  44080 			max_s = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n))))
  44081 		}
  44082 		freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] = freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] + 1
  44083 		goto _1
  44084 	_1:
  44085 		;
  44086 		n = n + 1
  44087 	}
  44088 	if num_levels_in <= num_levels {
  44089 		goto End
  44090 	} // nothing to do!
  44091 	// Start with uniformly spread centroids.
  44092 	i = 0
  44093 	for {
  44094 		if !(i < num_levels) {
  44095 			break
  44096 		}
  44097 		inv_q_level[i] = float64(min_s) + float64(float64(max_s-min_s)*float64(i))/float64(num_levels-libc.Int32FromInt32(1))
  44098 		goto _2
  44099 	_2:
  44100 		;
  44101 		i = i + 1
  44102 	}
  44103 	// Fixed values. Won't be changed.
  44104 	q_level[min_s] = 0
  44105 	q_level[max_s] = num_levels - int32(1)
  44106 	// k-Means iterations.
  44107 	iter = 0
  44108 	for {
  44109 		if !(iter < int32(MAX_ITER)) {
  44110 			break
  44111 		}
  44112 		**(**[256]float64)(__ccgo_up(bp)) = [256]float64{}
  44113 		**(**[256]float64)(__ccgo_up(bp + 2048)) = [256]float64{}
  44114 		slot = 0
  44115 		// Assign classes to representatives.
  44116 		s = min_s
  44117 		for {
  44118 			if !(s <= max_s) {
  44119 				break
  44120 			}
  44121 			// Keep track of the nearest neighbour 'slot'
  44122 			for slot < num_levels-int32(1) && float64(int32(2)*s) > inv_q_level[slot]+inv_q_level[slot+int32(1)] {
  44123 				slot = slot + 1
  44124 			}
  44125 			if freq[s] > 0 {
  44126 				**(**float64)(__ccgo_up(bp + uintptr(slot)*8)) += float64(s * freq[s])
  44127 				**(**float64)(__ccgo_up(bp + 2048 + uintptr(slot)*8)) += float64(freq[s])
  44128 			}
  44129 			q_level[s] = slot
  44130 			goto _4
  44131 		_4:
  44132 			;
  44133 			s = s + 1
  44134 		}
  44135 		// Assign new representatives to classes.
  44136 		if num_levels > int32(2) {
  44137 			slot = int32(1)
  44138 			for {
  44139 				if !(slot < num_levels-int32(1)) {
  44140 					break
  44141 				}
  44142 				count = (**(**[256]float64)(__ccgo_up(bp + 2048)))[slot]
  44143 				if count > float64(0) {
  44144 					inv_q_level[slot] = (**(**[256]float64)(__ccgo_up(bp)))[slot] / count
  44145 				}
  44146 				goto _5
  44147 			_5:
  44148 				;
  44149 				slot = slot + 1
  44150 			}
  44151 		}
  44152 		// Compute convergence error.
  44153 		err = float64(0)
  44154 		s = min_s
  44155 		for {
  44156 			if !(s <= max_s) {
  44157 				break
  44158 			}
  44159 			error1 = float64(s) - inv_q_level[q_level[s]]
  44160 			err = err + float64(float64(float64(freq[s])*error1)*error1)
  44161 			goto _6
  44162 		_6:
  44163 			;
  44164 			s = s + 1
  44165 		}
  44166 		// Check for convergence: we stop as soon as the error is no
  44167 		// longer improving.
  44168 		if last_err-err < err_threshold {
  44169 			break
  44170 		}
  44171 		last_err = err
  44172 		goto _3
  44173 	_3:
  44174 		;
  44175 		iter = iter + 1
  44176 	}
  44177 	// Remap the alpha plane to quantized values.
  44178 	s1 = min_s
  44179 	for {
  44180 		if !(s1 <= max_s) {
  44181 			break
  44182 		}
  44183 		slot1 = q_level[s1]
  44184 		map1[s1] = uint8(inv_q_level[slot1] + libc.Float64FromFloat64(0.5))
  44185 		goto _7
  44186 	_7:
  44187 		;
  44188 		s1 = s1 + 1
  44189 	}
  44190 	// Final pass.
  44191 	n1 = uint64(0)
  44192 	for {
  44193 		if !(n1 < data_size) {
  44194 			break
  44195 		}
  44196 		**(**uint8_t)(__ccgo_up(data + uintptr(n1))) = map1[**(**uint8_t)(__ccgo_up(data + uintptr(n1)))]
  44197 		goto _8
  44198 	_8:
  44199 		;
  44200 		n1 = n1 + 1
  44201 	}
  44202 	goto End
  44203 End:
  44204 	;
  44205 	// Store sum of squared error if needed.
  44206 	if sse != libc.UintptrFromInt32(0) {
  44207 		**(**uint64_t)(__ccgo_up(sse)) = uint64(err)
  44208 	}
  44209 	return int32(1)
  44210 }
  44211 
  44212 //------------------------------------------------------------------------------
  44213 
  44214 // C documentation
  44215 //
  44216 //	// 31b-range values
  44217 var kRandomTable = [55]uint32_t{
  44218 	0:  uint32(0x0de15230),
  44219 	1:  uint32(0x03b31886),
  44220 	2:  uint32(0x775faccb),
  44221 	3:  uint32(0x1c88626a),
  44222 	4:  uint32(0x68385c55),
  44223 	5:  uint32(0x14b3b828),
  44224 	6:  uint32(0x4a85fef8),
  44225 	7:  uint32(0x49ddb84b),
  44226 	8:  uint32(0x64fcf397),
  44227 	9:  uint32(0x5c550289),
  44228 	10: uint32(0x4a290000),
  44229 	11: uint32(0x0d7ec1da),
  44230 	12: uint32(0x5940b7ab),
  44231 	13: uint32(0x5492577d),
  44232 	14: uint32(0x4e19ca72),
  44233 	15: uint32(0x38d38c69),
  44234 	16: uint32(0x0c01ee65),
  44235 	17: uint32(0x32a1755f),
  44236 	18: uint32(0x5437f652),
  44237 	19: uint32(0x5abb2c32),
  44238 	20: uint32(0x0faa57b1),
  44239 	21: uint32(0x73f533e7),
  44240 	22: uint32(0x685feeda),
  44241 	23: uint32(0x7563cce2),
  44242 	24: uint32(0x6e990e83),
  44243 	25: uint32(0x4730a7ed),
  44244 	26: uint32(0x4fc0d9c6),
  44245 	27: uint32(0x496b153c),
  44246 	28: uint32(0x4f1403fa),
  44247 	29: uint32(0x541afb0c),
  44248 	30: uint32(0x73990b32),
  44249 	31: uint32(0x26d7cb1c),
  44250 	32: uint32(0x6fcc3706),
  44251 	33: uint32(0x2cbb77d8),
  44252 	34: uint32(0x75762f2a),
  44253 	35: uint32(0x6425ccdd),
  44254 	36: uint32(0x24b35461),
  44255 	37: uint32(0x0a7d8715),
  44256 	38: uint32(0x220414a8),
  44257 	39: uint32(0x141ebf67),
  44258 	40: uint32(0x56b41583),
  44259 	41: uint32(0x73e502e3),
  44260 	42: uint32(0x44cab16f),
  44261 	43: uint32(0x28264d42),
  44262 	44: uint32(0x73baaefb),
  44263 	45: uint32(0x0a50ebed),
  44264 	46: uint32(0x1d6ab6fb),
  44265 	47: uint32(0x0d3ad40b),
  44266 	48: uint32(0x35db3b68),
  44267 	49: uint32(0x2b081e83),
  44268 	50: uint32(0x77ce6b95),
  44269 	51: uint32(0x5181e5f0),
  44270 	52: uint32(0x78853bbc),
  44271 	53: uint32(0x009f9494),
  44272 	54: uint32(0x27e5ed3c),
  44273 }
  44274 
  44275 func VP8InitRandom(tls *libc.TLS, rg uintptr, dithering float32) {
  44276 	var v1, v2 uint32
  44277 	_, _ = v1, v2
  44278 	libc.X__builtin___memcpy_chk(tls, rg+8, uintptr(unsafe.Pointer(&kRandomTable)), uint64(220), ^__predefined_size_t(0))
  44279 	(*VP8Random)(unsafe.Pointer(rg)).Findex1 = 0
  44280 	(*VP8Random)(unsafe.Pointer(rg)).Findex2 = int32(31)
  44281 	if float64(dithering) < float64(0) {
  44282 		v1 = uint32(0)
  44283 	} else {
  44284 		if float64(dithering) > float64(1) {
  44285 			v2 = libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX))
  44286 		} else {
  44287 			v2 = uint32(float32(float32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX)) * dithering))
  44288 		}
  44289 		v1 = v2
  44290 	}
  44291 	(*VP8Random)(unsafe.Pointer(rg)).Famp = libc.Int32FromUint32(v1)
  44292 }
  44293 
  44294 const __INT_MAX__3 = 2147483647
  44295 
  44296 //------------------------------------------------------------------------------
  44297 
  44298 //------------------------------------------------------------------------------
  44299 
  44300 func WebPRescalerInit(tls *libc.TLS, rescaler uintptr, src_width int32, src_height int32, dst uintptr, dst_width int32, dst_height int32, dst_stride int32, num_channels int32, work uintptr) (r int32) {
  44301 	var den, num, ratio, total_size, v1 uint64_t
  44302 	var x_add, x_sub, y_add, y_sub, v2 int32
  44303 	_, _, _, _, _, _, _, _, _, _ = den, num, ratio, total_size, x_add, x_sub, y_add, y_sub, v1, v2
  44304 	x_add = src_width
  44305 	x_sub = dst_width
  44306 	y_add = src_height
  44307 	y_sub = dst_height
  44308 	total_size = uint64(2) * libc.Uint64FromInt32(dst_width) * libc.Uint64FromInt32(num_channels) * uint64(4)
  44309 	v1 = total_size
  44310 	v2 = libc.BoolInt32(v1 == v1)
  44311 	goto _3
  44312 _3:
  44313 	if !(v2 != 0) {
  44314 		return 0
  44315 	}
  44316 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand = libc.BoolInt32(src_width < dst_width)
  44317 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand = libc.BoolInt32(src_height < dst_height)
  44318 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_width = src_width
  44319 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_height = src_height
  44320 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_width = dst_width
  44321 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_height = dst_height
  44322 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_y = 0
  44323 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_y = 0
  44324 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst = dst
  44325 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_stride = dst_stride
  44326 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fnum_channels = num_channels
  44327 	// for 'x_expand', we use bilinear interpolation
  44328 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0 {
  44329 		v2 = x_sub - int32(1)
  44330 	} else {
  44331 		v2 = x_add
  44332 	}
  44333 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_add = v2
  44334 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0 {
  44335 		v2 = x_add - int32(1)
  44336 	} else {
  44337 		v2 = x_sub
  44338 	}
  44339 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_sub = v2
  44340 	if !((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0) { // fx_scale is not used otherwise
  44341 		(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffx_scale = uint32(libc.Uint64FromInt32(libc.Int32FromInt32(1)) << libc.Int32FromInt32(WEBP_RESCALER_RFIX) / libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_sub))
  44342 	}
  44343 	// vertical scaling parameters
  44344 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44345 		v2 = y_add - int32(1)
  44346 	} else {
  44347 		v2 = y_add
  44348 	}
  44349 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add = v2
  44350 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44351 		v2 = y_sub - int32(1)
  44352 	} else {
  44353 		v2 = y_sub
  44354 	}
  44355 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub = v2
  44356 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44357 		v2 = (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub
  44358 	} else {
  44359 		v2 = (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add
  44360 	}
  44361 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_accum = v2
  44362 	if !((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0) {
  44363 		// This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
  44364 		// Its value is <= WEBP_RESCALER_ONE, because dst_height <= rescaler->y_add
  44365 		// and rescaler->x_add >= 1;
  44366 		num = libc.Uint64FromInt32(dst_height) * (libc.Uint64FromUint64(1) << libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  44367 		den = libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_add) * libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add)
  44368 		ratio = num / den
  44369 		if ratio != uint64(uint32(ratio)) {
  44370 			// When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
  44371 			// current fixed-point precision. This happens when src_height ==
  44372 			// rescaler->y_add (which == src_height), and rescaler->x_add == 1.
  44373 			// => We special-case fxy_scale = 0, in WebPRescalerExportRow().
  44374 			(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffxy_scale = uint32(0)
  44375 		} else {
  44376 			(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffxy_scale = uint32(ratio)
  44377 		}
  44378 		(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffy_scale = uint32(libc.Uint64FromInt32(libc.Int32FromInt32(1)) << libc.Int32FromInt32(WEBP_RESCALER_RFIX) / libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub))
  44379 	} else {
  44380 		(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffy_scale = uint32(libc.Uint64FromInt32(libc.Int32FromInt32(1)) << libc.Int32FromInt32(WEBP_RESCALER_RFIX) / libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_add))
  44381 		// rescaler->fxy_scale is unused here.
  44382 	}
  44383 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Firow = work
  44384 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffrow = work + uintptr(num_channels*dst_width)*4
  44385 	libc.X__builtin___memset_chk(tls, work, 0, total_size, ^__predefined_size_t(0))
  44386 	WebPRescalerDspInit(tls)
  44387 	return int32(1)
  44388 }
  44389 
  44390 func WebPRescalerGetScaledDimensions(tls *libc.TLS, src_width int32, src_height int32, scaled_width uintptr, scaled_height uintptr) (r int32) {
  44391 	var height, max_size, width int32
  44392 	_, _, _ = height, max_size, width
  44393 	width = **(**int32)(__ccgo_up(scaled_width))
  44394 	height = **(**int32)(__ccgo_up(scaled_height))
  44395 	max_size = libc.Int32FromInt32(__INT_MAX__3) / libc.Int32FromInt32(2)
  44396 	// if width is unspecified, scale original proportionally to height ratio.
  44397 	if width == 0 && src_height > 0 {
  44398 		width = libc.Int32FromUint64((libc.Uint64FromInt32(src_width)*libc.Uint64FromInt32(height) + libc.Uint64FromInt32(src_height) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt32(src_height))
  44399 	}
  44400 	// if height is unspecified, scale original proportionally to width ratio.
  44401 	if height == 0 && src_width > 0 {
  44402 		height = libc.Int32FromUint64((libc.Uint64FromInt32(src_height)*libc.Uint64FromInt32(width) + libc.Uint64FromInt32(src_width) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt32(src_width))
  44403 	}
  44404 	// Check if the overall dimensions still make sense.
  44405 	if width <= 0 || height <= 0 || width > max_size || height > max_size {
  44406 		return 0
  44407 	}
  44408 	**(**int32)(__ccgo_up(scaled_width)) = width
  44409 	**(**int32)(__ccgo_up(scaled_height)) = height
  44410 	return int32(1)
  44411 	return r
  44412 }
  44413 
  44414 //------------------------------------------------------------------------------
  44415 // all-in-one calls
  44416 
  44417 func WebPRescaleNeededLines(tls *libc.TLS, rescaler uintptr, max_num_lines int32) (r int32) {
  44418 	var num_lines, v1 int32
  44419 	_, _ = num_lines, v1
  44420 	num_lines = ((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_accum + (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub - int32(1)) / (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub
  44421 	if num_lines > max_num_lines {
  44422 		v1 = max_num_lines
  44423 	} else {
  44424 		v1 = num_lines
  44425 	}
  44426 	return v1
  44427 }
  44428 
  44429 func WebPRescalerImport(tls *libc.TLS, rescaler2 uintptr, num_lines int32, src uintptr, src_stride int32) (r int32) {
  44430 	var tmp, v1, v4 uintptr
  44431 	var total_imported, x, v2, v5 int32
  44432 	var v7 bool
  44433 	_, _, _, _, _, _, _, _ = tmp, total_imported, x, v1, v2, v4, v5, v7
  44434 	total_imported = 0
  44435 	for {
  44436 		if v7 = total_imported < num_lines; v7 {
  44437 			v1 = rescaler2
  44438 			v4 = v1
  44439 			v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  44440 			goto _6
  44441 		_6:
  44442 			;
  44443 			v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  44444 			goto _3
  44445 		_3:
  44446 		}
  44447 		if !(v7 && !(v2 != 0)) {
  44448 			break
  44449 		}
  44450 		if (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_expand != 0 {
  44451 			tmp = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow
  44452 			(*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow
  44453 			(*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow = tmp
  44454 		}
  44455 		WebPRescalerImportRow(tls, rescaler2, src)
  44456 		if !((*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_expand != 0) {
  44457 			x = 0
  44458 			for {
  44459 				if !(x < (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fnum_channels*(*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width) {
  44460 					break
  44461 				}
  44462 				**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow + uintptr(x)*4)) += **(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow + uintptr(x)*4))
  44463 				goto _8
  44464 			_8:
  44465 				;
  44466 				x = x + 1
  44467 			}
  44468 		}
  44469 		(*WebPRescaler)(unsafe.Pointer(rescaler2)).Fsrc_y = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fsrc_y + 1
  44470 		src = src + uintptr(src_stride)
  44471 		total_imported = total_imported + 1
  44472 		**(**int32)(__ccgo_up(rescaler2 + 24)) -= (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_sub
  44473 	}
  44474 	return total_imported
  44475 }
  44476 
  44477 func WebPRescalerExport(tls *libc.TLS, rescaler2 uintptr) (r int32) {
  44478 	var total_exported, v2, v5 int32
  44479 	var v1, v4 uintptr
  44480 	_, _, _, _, _ = total_exported, v1, v2, v4, v5
  44481 	total_exported = 0
  44482 	for {
  44483 		v1 = rescaler2
  44484 		v4 = v1
  44485 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  44486 		goto _6
  44487 	_6:
  44488 		;
  44489 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  44490 		goto _3
  44491 	_3:
  44492 		if !(v2 != 0) {
  44493 			break
  44494 		}
  44495 		WebPRescalerExportRow(tls, rescaler2)
  44496 		total_exported = total_exported + 1
  44497 	}
  44498 	return total_exported
  44499 }
  44500 
  44501 const __INT_MAX__4 = 0x7fffffff
  44502 
  44503 //------------------------------------------------------------------------------
  44504 
  44505 //------------------------------------------------------------------------------
  44506 
  44507 func Init(tls *libc.TLS, worker uintptr) {
  44508 	libc.X__builtin___memset_chk(tls, worker, 0, uint64(48), ^__predefined_size_t(0))
  44509 	(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(NOT_OK)
  44510 }
  44511 
  44512 func Sync(tls *libc.TLS, worker uintptr) (r int32) {
  44513 	return libc.BoolInt32(!((*WebPWorker)(unsafe.Pointer(worker)).Fhad_error != 0))
  44514 }
  44515 
  44516 func Reset(tls *libc.TLS, worker uintptr) (r int32) {
  44517 	var ok int32
  44518 	_ = ok
  44519 	ok = int32(1)
  44520 	(*WebPWorker)(unsafe.Pointer(worker)).Fhad_error = 0
  44521 	if (*WebPWorker)(unsafe.Pointer(worker)).Fstatus < int32(OK) {
  44522 		(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(OK)
  44523 	} else {
  44524 		if (*WebPWorker)(unsafe.Pointer(worker)).Fstatus > int32(OK) {
  44525 			ok = Sync(tls, worker)
  44526 		}
  44527 	}
  44528 	return ok
  44529 }
  44530 
  44531 func Execute(tls *libc.TLS, worker uintptr) {
  44532 	if (*WebPWorker)(unsafe.Pointer(worker)).Fhook != libc.UintptrFromInt32(0) {
  44533 		**(**int32)(__ccgo_up(worker + 40)) |= libc.BoolInt32(!((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorker)(unsafe.Pointer(worker)).Fhook})))(tls, (*WebPWorker)(unsafe.Pointer(worker)).Fdata1, (*WebPWorker)(unsafe.Pointer(worker)).Fdata2) != 0))
  44534 	}
  44535 }
  44536 
  44537 func Launch(tls *libc.TLS, worker uintptr) {
  44538 	Execute(tls, worker)
  44539 }
  44540 
  44541 func End(tls *libc.TLS, worker uintptr) {
  44542 	(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(NOT_OK)
  44543 }
  44544 
  44545 //------------------------------------------------------------------------------
  44546 
  44547 var g_worker_interface = WebPWorkerInterface{}
  44548 
  44549 func init() {
  44550 	p := unsafe.Pointer(&g_worker_interface)
  44551 	*(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(Init)
  44552 	*(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(Reset)
  44553 	*(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(Sync)
  44554 	*(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(Launch)
  44555 	*(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(Execute)
  44556 	*(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(End)
  44557 }
  44558 
  44559 func WebPSetWorkerInterface(tls *libc.TLS, winterface uintptr) (r int32) {
  44560 	if winterface == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FInit == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FReset == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FSync == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FLaunch == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FExecute == libc.UintptrFromInt32(0) || (*WebPWorkerInterface)(unsafe.Pointer(winterface)).FEnd == libc.UintptrFromInt32(0) {
  44561 		return 0
  44562 	}
  44563 	g_worker_interface = **(**WebPWorkerInterface)(__ccgo_up(winterface))
  44564 	return int32(1)
  44565 }
  44566 
  44567 func WebPGetWorkerInterface(tls *libc.TLS) (r uintptr) {
  44568 	return uintptr(unsafe.Pointer(&g_worker_interface))
  44569 }
  44570 
  44571 //------------------------------------------------------------------------------
  44572 
  44573 // If PRINT_MEM_INFO is defined, extra info (like total memory used, number of
  44574 // alloc/free etc) is printed. For debugging/tuning purpose only (it's slow,
  44575 // and not multi-thread safe!).
  44576 // An interesting alternative is valgrind's 'massif' tool:
  44577 //    https://valgrind.org/docs/manual/ms-manual.html
  44578 // Here is an example command line:
  44579 /*    valgrind --tool=massif --massif-out-file=massif.out                --stacks=yes --alloc-fn=WebPSafeMalloc --alloc-fn=WebPSafeCalloc
  44580       ms_print massif.out
  44581 */
  44582 // In addition:
  44583 // * if PRINT_MEM_TRAFFIC is defined, all the details of the malloc/free cycles
  44584 //   are printed.
  44585 // * if MALLOC_FAIL_AT is defined, the global environment variable
  44586 //   $MALLOC_FAIL_AT is used to simulate a memory error when calloc or malloc
  44587 //   is called for the nth time. Example usage:
  44588 //   export MALLOC_FAIL_AT=50 && ./examples/cwebp input.png
  44589 // * if MALLOC_LIMIT is defined, the global environment variable $MALLOC_LIMIT
  44590 //   sets the maximum amount of memory (in bytes) made available to libwebp.
  44591 //   This can be used to emulate environment with very limited memory.
  44592 //   Example: export MALLOC_LIMIT=64000000 && ./examples/dwebp picture.webp
  44593 
  44594 // #define PRINT_MEM_INFO
  44595 // #define PRINT_MEM_TRAFFIC
  44596 // #define MALLOC_FAIL_AT
  44597 // #define MALLOC_LIMIT
  44598 
  44599 //------------------------------------------------------------------------------
  44600 // Checked memory allocation
  44601 
  44602 // C documentation
  44603 //
  44604 //	// Returns 0 in case of overflow of nmemb * size.
  44605 func CheckSizeArgumentsOverflow(tls *libc.TLS, nmemb uint64_t, size1 size_t) (r int32) {
  44606 	var total_size, v1 uint64_t
  44607 	var v2 int32
  44608 	_, _, _ = total_size, v1, v2
  44609 	total_size = nmemb * size1
  44610 	if nmemb == uint64(0) {
  44611 		return int32(1)
  44612 	}
  44613 	if size1 > libc.Uint64FromUint64(1)<<libc.Int32FromInt32(34)/nmemb {
  44614 		return 0
  44615 	}
  44616 	v1 = total_size
  44617 	v2 = libc.BoolInt32(v1 == v1)
  44618 	goto _3
  44619 _3:
  44620 	if !(v2 != 0) {
  44621 		return 0
  44622 	}
  44623 	return int32(1)
  44624 }
  44625 
  44626 func WebPSafeMalloc(tls *libc.TLS, nmemb uint64_t, size size_t) (r uintptr) {
  44627 	var ptr uintptr
  44628 	_ = ptr
  44629 	if !(CheckSizeArgumentsOverflow(tls, nmemb, size) != 0) {
  44630 		return libc.UintptrFromInt32(0)
  44631 	}
  44632 	ptr = libc.Xmalloc(tls, nmemb*size)
  44633 	return ptr
  44634 }
  44635 
  44636 func WebPSafeCalloc(tls *libc.TLS, nmemb uint64_t, size size_t) (r uintptr) {
  44637 	var ptr uintptr
  44638 	_ = ptr
  44639 	if !(CheckSizeArgumentsOverflow(tls, nmemb, size) != 0) {
  44640 		return libc.UintptrFromInt32(0)
  44641 	}
  44642 	ptr = libc.Xcalloc(tls, nmemb, size)
  44643 	return ptr
  44644 }
  44645 
  44646 func WebPSafeFree(tls *libc.TLS, ptr uintptr) {
  44647 	if ptr != libc.UintptrFromInt32(0) {
  44648 	}
  44649 	libc.Xfree(tls, ptr)
  44650 }
  44651 
  44652 // Public API functions.
  44653 
  44654 func WebPMalloc(tls *libc.TLS, size size_t) (r uintptr) {
  44655 	return WebPSafeMalloc(tls, uint64(1), size)
  44656 }
  44657 
  44658 func WebPFree(tls *libc.TLS, ptr uintptr) {
  44659 	WebPSafeFree(tls, ptr)
  44660 }
  44661 
  44662 //------------------------------------------------------------------------------
  44663 
  44664 func WebPCopyPlane(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, dst_stride int32, width int32, height int32) {
  44665 	var v1 int32
  44666 	_ = v1
  44667 	for {
  44668 		v1 = height
  44669 		height = height - 1
  44670 		if !(v1 > 0) {
  44671 			break
  44672 		}
  44673 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(width), ^__predefined_size_t(0))
  44674 		src = src + uintptr(src_stride)
  44675 		dst = dst + uintptr(dst_stride)
  44676 	}
  44677 }
  44678 
  44679 func WebPCopyPixels(tls *libc.TLS, src uintptr, dst uintptr) {
  44680 	WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(src)).Fargb, int32(4)*(*WebPPicture)(unsafe.Pointer(src)).Fargb_stride, (*WebPPicture)(unsafe.Pointer(dst)).Fargb, int32(4)*(*WebPPicture)(unsafe.Pointer(dst)).Fargb_stride, int32(4)*(*WebPPicture)(unsafe.Pointer(src)).Fwidth, (*WebPPicture)(unsafe.Pointer(src)).Fheight)
  44681 }
  44682 
  44683 //------------------------------------------------------------------------------
  44684 
  44685 func WebPGetColorPalette(tls *libc.TLS, pic uintptr, palette uintptr) (r int32) {
  44686 	return GetColorPalette(tls, pic, palette)
  44687 }
  44688 
  44689 const USE_TABLES_FOR_ALPHA_MULT = 0
  44690 
  44691 // Copyright 2010 Google Inc. All Rights Reserved.
  44692 //
  44693 // Use of this source code is governed by a BSD-style license
  44694 // that can be found in the COPYING file in the root of the source
  44695 // tree. An additional intellectual property rights grant can be found
  44696 // in the file PATENTS. All contributing project authors may
  44697 // be found in the AUTHORS file in the root of the source tree.
  44698 // -----------------------------------------------------------------------------
  44699 //
  44700 //  Common types + memory wrappers
  44701 //
  44702 // Author: Skal (pascal.massimino@gmail.com)
  44703 
  44704 // Tables can be faster on some platform but incur some extra binary size (~2k).
  44705 
  44706 // -----------------------------------------------------------------------------
  44707 
  44708 func Mult(tls *libc.TLS, x uint8_t, mult uint32_t) (r uint32_t) {
  44709 	var v uint32_t
  44710 	_ = v
  44711 	v = (uint32(x)*mult + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(24)>>libc.Int32FromInt32(1)) >> int32(24)
  44712 	// <- 24bit precision is enough to ensure that.
  44713 	return v
  44714 }
  44715 
  44716 func GetScale(tls *libc.TLS, a uint32_t, inverse int32) (r uint32_t) {
  44717 	var v1 uint32
  44718 	_ = v1
  44719 	if inverse != 0 {
  44720 		v1 = libc.Uint32FromUint32(255) << libc.Int32FromInt32(24) / a
  44721 	} else {
  44722 		v1 = a * (libc.Uint32FromUint32(1) << libc.Int32FromInt32(24) / libc.Uint32FromUint32(255))
  44723 	}
  44724 	return v1
  44725 }
  44726 
  44727 func WebPMultARGBRow_C(tls *libc.TLS, ptr uintptr, width int32, inverse int32) {
  44728 	var alpha, argb, out, scale uint32_t
  44729 	var x int32
  44730 	_, _, _, _, _ = alpha, argb, out, scale, x
  44731 	x = 0
  44732 	for {
  44733 		if !(x < width) {
  44734 			break
  44735 		}
  44736 		argb = **(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4))
  44737 		if argb < uint32(0xff000000) { // alpha < 255
  44738 			if argb <= uint32(0x00ffffff) { // alpha == 0
  44739 				**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = uint32(0)
  44740 			} else {
  44741 				alpha = argb >> libc.Int32FromInt32(24) & uint32(0xff)
  44742 				scale = GetScale(tls, alpha, inverse)
  44743 				out = argb & uint32(0xff000000)
  44744 				out = out | Mult(tls, uint8(argb>>0), scale)<<0
  44745 				out = out | Mult(tls, uint8(argb>>int32(8)), scale)<<int32(8)
  44746 				out = out | Mult(tls, uint8(argb>>int32(16)), scale)<<int32(16)
  44747 				**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = out
  44748 			}
  44749 		}
  44750 		goto _1
  44751 	_1:
  44752 		;
  44753 		x = x + 1
  44754 	}
  44755 }
  44756 
  44757 func WebPMultRow_C(tls *libc.TLS, ptr uintptr, alpha uintptr, width int32, inverse int32) {
  44758 	var a, scale uint32_t
  44759 	var x int32
  44760 	_, _, _ = a, scale, x
  44761 	x = 0
  44762 	for {
  44763 		if !(x < width) {
  44764 			break
  44765 		}
  44766 		a = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(x))))
  44767 		if a != uint32(255) {
  44768 			if a == uint32(0) {
  44769 				**(**uint8_t)(__ccgo_up(ptr + uintptr(x))) = uint8(0)
  44770 			} else {
  44771 				scale = GetScale(tls, a, inverse)
  44772 				**(**uint8_t)(__ccgo_up(ptr + uintptr(x))) = uint8(Mult(tls, **(**uint8_t)(__ccgo_up(ptr + uintptr(x))), scale))
  44773 			}
  44774 		}
  44775 		goto _1
  44776 	_1:
  44777 		;
  44778 		x = x + 1
  44779 	}
  44780 }
  44781 
  44782 //------------------------------------------------------------------------------
  44783 // Generic per-plane calls
  44784 
  44785 func WebPMultARGBRows(tls *libc.TLS, ptr uintptr, stride int32, width int32, num_rows int32, inverse int32) {
  44786 	var n int32
  44787 	_ = n
  44788 	n = 0
  44789 	for {
  44790 		if !(n < num_rows) {
  44791 			break
  44792 		}
  44793 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, ptr, width, inverse)
  44794 		ptr = ptr + uintptr(stride)
  44795 		goto _1
  44796 	_1:
  44797 		;
  44798 		n = n + 1
  44799 	}
  44800 }
  44801 
  44802 func WebPMultRows(tls *libc.TLS, ptr uintptr, stride int32, alpha uintptr, alpha_stride int32, width int32, num_rows int32, inverse int32) {
  44803 	var n int32
  44804 	_ = n
  44805 	n = 0
  44806 	for {
  44807 		if !(n < num_rows) {
  44808 			break
  44809 		}
  44810 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultRow})))(tls, ptr, alpha, width, inverse)
  44811 		ptr = ptr + uintptr(stride)
  44812 		alpha = alpha + uintptr(alpha_stride)
  44813 		goto _1
  44814 	_1:
  44815 		;
  44816 		n = n + 1
  44817 	}
  44818 }
  44819 
  44820 //------------------------------------------------------------------------------
  44821 // Premultiplied modes
  44822 
  44823 // non dithered-modes
  44824 
  44825 // (x * a * 32897) >> 23 is bit-wise equivalent to (int)(x * a / 255.)
  44826 // for all 8bit x or a. For bit-wise equivalence to (int)(x * a / 255. + .5),
  44827 // one can use instead: (x * a * 65793 + (1 << 23)) >> 24
  44828 
  44829 func ApplyAlphaMultiply_C(tls *libc.TLS, rgba uintptr, alpha_first int32, w int32, h int32, stride int32) {
  44830 	var a, mult uint32_t
  44831 	var alpha, rgb uintptr
  44832 	var i, v1, v2, v3 int32
  44833 	_, _, _, _, _, _, _, _ = a, alpha, i, mult, rgb, v1, v2, v3
  44834 	for {
  44835 		v1 = h
  44836 		h = h - 1
  44837 		if !(v1 > 0) {
  44838 			break
  44839 		}
  44840 		if alpha_first != 0 {
  44841 			v2 = int32(1)
  44842 		} else {
  44843 			v2 = 0
  44844 		}
  44845 		rgb = rgba + uintptr(v2)
  44846 		if alpha_first != 0 {
  44847 			v3 = 0
  44848 		} else {
  44849 			v3 = int32(3)
  44850 		}
  44851 		alpha = rgba + uintptr(v3)
  44852 		i = 0
  44853 		for {
  44854 			if !(i < w) {
  44855 				break
  44856 			}
  44857 			a = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(int32(4)*i))))
  44858 			if a != uint32(0xff) {
  44859 				mult = a * libc.Uint32FromUint32(32897)
  44860 				**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+0))) = uint8(uint32(**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+0)))) * mult >> libc.Int32FromInt32(23))
  44861 				**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+int32(1)))) = uint8(uint32(**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+int32(1))))) * mult >> libc.Int32FromInt32(23))
  44862 				**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+int32(2)))) = uint8(uint32(**(**uint8_t)(__ccgo_up(rgb + uintptr(int32(4)*i+int32(2))))) * mult >> libc.Int32FromInt32(23))
  44863 			}
  44864 			goto _4
  44865 		_4:
  44866 			;
  44867 			i = i + 1
  44868 		}
  44869 		rgba = rgba + uintptr(stride)
  44870 	}
  44871 }
  44872 
  44873 // rgbA4444
  44874 
  44875 func dither_hi(tls *libc.TLS, x uint8_t) (r uint8_t) {
  44876 	return libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0xf0) | libc.Int32FromUint8(x)>>int32(4))
  44877 }
  44878 
  44879 func dither_lo(tls *libc.TLS, x uint8_t) (r uint8_t) {
  44880 	return libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0x0f) | libc.Int32FromUint8(x)<<int32(4))
  44881 }
  44882 
  44883 func multiply(tls *libc.TLS, x uint8_t, m uint32_t) (r uint8_t) {
  44884 	return uint8(uint32(x) * m >> int32(16))
  44885 }
  44886 
  44887 func ApplyAlphaMultiply4444_C(tls *libc.TLS, rgba4444 uintptr, w int32, h int32, stride int32, rg_byte_pos int32) {
  44888 	var a, b, g, r uint8_t
  44889 	var ba, mult, rg uint32_t
  44890 	var i, v1 int32
  44891 	_, _, _, _, _, _, _, _, _ = a, b, ba, g, i, mult, r, rg, v1
  44892 	for {
  44893 		v1 = h
  44894 		h = h - 1
  44895 		if !(v1 > 0) {
  44896 			break
  44897 		}
  44898 		i = 0
  44899 		for {
  44900 			if !(i < w) {
  44901 				break
  44902 			}
  44903 			rg = uint32(**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+rg_byte_pos))))
  44904 			ba = uint32(**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+(rg_byte_pos^int32(1))))))
  44905 			a = uint8(ba & uint32(0x0f))
  44906 			mult = libc.Uint32FromInt32(libc.Int32FromUint8(a) * libc.Int32FromInt32(0x1111))
  44907 			r = multiply(tls, dither_hi(tls, uint8(rg)), mult)
  44908 			g = multiply(tls, dither_lo(tls, uint8(rg)), mult)
  44909 			b = multiply(tls, dither_hi(tls, uint8(ba)), mult)
  44910 			**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+rg_byte_pos))) = libc.Uint8FromInt32(libc.Int32FromUint8(r)&int32(0xf0) | libc.Int32FromUint8(g)>>int32(4)&int32(0x0f))
  44911 			**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+(rg_byte_pos^int32(1))))) = libc.Uint8FromInt32(libc.Int32FromUint8(b)&int32(0xf0) | libc.Int32FromUint8(a))
  44912 			goto _2
  44913 		_2:
  44914 			;
  44915 			i = i + 1
  44916 		}
  44917 		rgba4444 = rgba4444 + uintptr(stride)
  44918 	}
  44919 }
  44920 
  44921 func ApplyAlphaMultiply_16b_C(tls *libc.TLS, rgba4444 uintptr, w int32, h int32, stride int32) {
  44922 	ApplyAlphaMultiply4444_C(tls, rgba4444, w, h, stride, 0)
  44923 }
  44924 
  44925 func DispatchAlpha_C(tls *libc.TLS, alpha uintptr, alpha_stride int32, width int32, height int32, dst uintptr, dst_stride int32) (r int32) {
  44926 	var alpha_mask, alpha_value uint32_t
  44927 	var i, j int32
  44928 	_, _, _, _ = alpha_mask, alpha_value, i, j
  44929 	alpha_mask = uint32(0xff)
  44930 	j = 0
  44931 	for {
  44932 		if !(j < height) {
  44933 			break
  44934 		}
  44935 		i = 0
  44936 		for {
  44937 			if !(i < width) {
  44938 				break
  44939 			}
  44940 			alpha_value = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(i))))
  44941 			**(**uint8_t)(__ccgo_up(dst + uintptr(int32(4)*i))) = uint8(alpha_value)
  44942 			alpha_mask = alpha_mask & alpha_value
  44943 			goto _2
  44944 		_2:
  44945 			;
  44946 			i = i + 1
  44947 		}
  44948 		alpha = alpha + uintptr(alpha_stride)
  44949 		dst = dst + uintptr(dst_stride)
  44950 		goto _1
  44951 	_1:
  44952 		;
  44953 		j = j + 1
  44954 	}
  44955 	return libc.BoolInt32(alpha_mask != uint32(0xff))
  44956 }
  44957 
  44958 func DispatchAlphaToGreen_C(tls *libc.TLS, alpha uintptr, alpha_stride int32, width int32, height int32, dst uintptr, dst_stride int32) {
  44959 	var i, j int32
  44960 	_, _ = i, j
  44961 	j = 0
  44962 	for {
  44963 		if !(j < height) {
  44964 			break
  44965 		}
  44966 		i = 0
  44967 		for {
  44968 			if !(i < width) {
  44969 				break
  44970 			}
  44971 			**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha + uintptr(i)))) << int32(8)) // leave A/R/B channels zero'd.
  44972 			goto _2
  44973 		_2:
  44974 			;
  44975 			i = i + 1
  44976 		}
  44977 		alpha = alpha + uintptr(alpha_stride)
  44978 		dst = dst + uintptr(dst_stride)*4
  44979 		goto _1
  44980 	_1:
  44981 		;
  44982 		j = j + 1
  44983 	}
  44984 }
  44985 
  44986 func ExtractAlpha_C(tls *libc.TLS, argb uintptr, argb_stride int32, width int32, height int32, alpha uintptr, alpha_stride int32) (r int32) {
  44987 	var alpha_mask, alpha_value uint8_t
  44988 	var i, j int32
  44989 	_, _, _, _ = alpha_mask, alpha_value, i, j
  44990 	alpha_mask = uint8(0xff)
  44991 	j = 0
  44992 	for {
  44993 		if !(j < height) {
  44994 			break
  44995 		}
  44996 		i = 0
  44997 		for {
  44998 			if !(i < width) {
  44999 				break
  45000 			}
  45001 			alpha_value = **(**uint8_t)(__ccgo_up(argb + uintptr(int32(4)*i)))
  45002 			**(**uint8_t)(__ccgo_up(alpha + uintptr(i))) = alpha_value
  45003 			alpha_mask = libc.Uint8FromInt32(int32(alpha_mask) & libc.Int32FromUint8(alpha_value))
  45004 			goto _2
  45005 		_2:
  45006 			;
  45007 			i = i + 1
  45008 		}
  45009 		argb = argb + uintptr(argb_stride)
  45010 		alpha = alpha + uintptr(alpha_stride)
  45011 		goto _1
  45012 	_1:
  45013 		;
  45014 		j = j + 1
  45015 	}
  45016 	return libc.BoolInt32(libc.Int32FromUint8(alpha_mask) == int32(0xff))
  45017 }
  45018 
  45019 func ExtractGreen_C(tls *libc.TLS, argb uintptr, alpha uintptr, size int32) {
  45020 	var i int32
  45021 	_ = i
  45022 	i = 0
  45023 	for {
  45024 		if !(i < size) {
  45025 			break
  45026 		}
  45027 		**(**uint8_t)(__ccgo_up(alpha + uintptr(i))) = uint8(**(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) >> int32(8))
  45028 		goto _1
  45029 	_1:
  45030 		;
  45031 		i = i + 1
  45032 	}
  45033 }
  45034 
  45035 //------------------------------------------------------------------------------
  45036 
  45037 func HasAlpha8b_C(tls *libc.TLS, src uintptr, length int32) (r int32) {
  45038 	var v1 int32
  45039 	var v2 uintptr
  45040 	_, _ = v1, v2
  45041 	for {
  45042 		v1 = length
  45043 		length = length - 1
  45044 		if !(v1 > 0) {
  45045 			break
  45046 		}
  45047 		v2 = src
  45048 		src = src + 1
  45049 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v2))) != int32(0xff) {
  45050 			return int32(1)
  45051 		}
  45052 	}
  45053 	return 0
  45054 }
  45055 
  45056 func HasAlpha32b_C(tls *libc.TLS, src uintptr, length int32) (r int32) {
  45057 	var x, v2 int32
  45058 	_, _ = x, v2
  45059 	x = 0
  45060 	for {
  45061 		v2 = length
  45062 		length = length - 1
  45063 		if !(v2 > 0) {
  45064 			break
  45065 		}
  45066 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + uintptr(x)))) != int32(0xff) {
  45067 			return int32(1)
  45068 		}
  45069 		goto _1
  45070 	_1:
  45071 		;
  45072 		x = x + int32(4)
  45073 	}
  45074 	return 0
  45075 }
  45076 
  45077 func AlphaReplace_C(tls *libc.TLS, src uintptr, length int32, color uint32_t) {
  45078 	var x int32
  45079 	_ = x
  45080 	x = 0
  45081 	for {
  45082 		if !(x < length) {
  45083 			break
  45084 		}
  45085 		if **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))>>libc.Int32FromInt32(24) == uint32(0) {
  45086 			**(**uint32_t)(__ccgo_up(src + uintptr(x)*4)) = color
  45087 		}
  45088 		goto _1
  45089 	_1:
  45090 		;
  45091 		x = x + 1
  45092 	}
  45093 }
  45094 
  45095 //------------------------------------------------------------------------------
  45096 // Simple channel manipulations.
  45097 
  45098 func MakeARGB321(tls *libc.TLS, a int32, r int32, g int32, b int32) (r1 uint32_t) {
  45099 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  45100 }
  45101 
  45102 func PackRGB_C(tls *libc.TLS, r uintptr, g uintptr, b uintptr, len1 int32, step int32, out uintptr) {
  45103 	var i, offset int32
  45104 	_, _ = i, offset
  45105 	offset = 0
  45106 	i = 0
  45107 	for {
  45108 		if !(i < len1) {
  45109 			break
  45110 		}
  45111 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = MakeARGB321(tls, int32(0xff), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(r + uintptr(offset)))), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(g + uintptr(offset)))), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(b + uintptr(offset)))))
  45112 		offset = offset + step
  45113 		goto _1
  45114 	_1:
  45115 		;
  45116 		i = i + 1
  45117 	}
  45118 }
  45119 
  45120 func WebPInitAlphaProcessing(tls *libc.TLS) {
  45121 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  45122 		goto _1
  45123 	}
  45124 	WebPInitAlphaProcessing_body(tls)
  45125 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used)), VP8GetCPUInfo)
  45126 	goto _2
  45127 _2:
  45128 	;
  45129 	goto _1
  45130 _1: /**/ //
  45131 }
  45132 
  45133 var WebPInitAlphaProcessing_body_last_cpuinfo_used = uintptr(0)
  45134 
  45135 func init() {
  45136 	p := unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used)
  45137 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used))
  45138 }
  45139 
  45140 func WebPInitAlphaProcessing_body(tls *libc.TLS) {
  45141 	WebPMultARGBRow = __ccgo_fp(WebPMultARGBRow_C)
  45142 	WebPMultRow = __ccgo_fp(WebPMultRow_C)
  45143 	WebPApplyAlphaMultiply4444 = __ccgo_fp(ApplyAlphaMultiply_16b_C)
  45144 	WebPPackRGB = __ccgo_fp(PackRGB_C)
  45145 	WebPApplyAlphaMultiply = __ccgo_fp(ApplyAlphaMultiply_C)
  45146 	WebPDispatchAlpha = __ccgo_fp(DispatchAlpha_C)
  45147 	WebPDispatchAlphaToGreen = __ccgo_fp(DispatchAlphaToGreen_C)
  45148 	WebPExtractAlpha = __ccgo_fp(ExtractAlpha_C)
  45149 	WebPExtractGreen = __ccgo_fp(ExtractGreen_C)
  45150 	WebPHasAlpha8b = __ccgo_fp(HasAlpha8b_C)
  45151 	WebPHasAlpha32b = __ccgo_fp(HasAlpha32b_C)
  45152 	WebPAlphaReplace = __ccgo_fp(AlphaReplace_C)
  45153 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  45154 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  45155 	}
  45156 }
  45157 
  45158 func WebPInitAlphaProcessingMIPSdspR2(tls *libc.TLS) {
  45159 }
  45160 
  45161 func WebPInitAlphaProcessingNEON(tls *libc.TLS) {
  45162 }
  45163 
  45164 func WebPInitAlphaProcessingSSE2(tls *libc.TLS) {
  45165 }
  45166 
  45167 func WebPInitAlphaProcessingSSE41(tls *libc.TLS) {
  45168 }
  45169 
  45170 //------------------------------------------------------------------------------
  45171 // Mode costs
  45172 
  45173 func GetResidualCost_C(tls *libc.TLS, ctx0 int32, res uintptr) (r int32) {
  45174 	var b, cost, ctx, ctx1, last_p0, n, p0, v, v1, v11, v3, v5, v7, v9 int32
  45175 	var costs CostArrayPtr
  45176 	var t uintptr
  45177 	var v2, v6 uint8_t
  45178 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, cost, costs, ctx, ctx1, last_p0, n, p0, t, v, v1, v11, v2, v3, v5, v6, v7, v9
  45179 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  45180 	// should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
  45181 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(n)*33 + uintptr(ctx0)*11)))
  45182 	costs = (*VP8Residual)(unsafe.Pointer(res)).Fcosts
  45183 	t = **(**uintptr)(__ccgo_up(costs + uintptr(n)*24 + uintptr(ctx0)*8))
  45184 	if ctx0 == 0 {
  45185 		v2 = libc.Uint8FromInt32(p0)
  45186 		if !(int32(1) != 0) {
  45187 			v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  45188 		} else {
  45189 			v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  45190 		}
  45191 		v3 = v5
  45192 		goto _4
  45193 	_4:
  45194 		v11 = v3
  45195 	} else {
  45196 		v11 = 0
  45197 	}
  45198 	// bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
  45199 	// (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
  45200 	// be missing during the loop.
  45201 	cost = v11
  45202 	if (*VP8Residual)(unsafe.Pointer(res)).Flast < 0 {
  45203 		v6 = libc.Uint8FromInt32(p0)
  45204 		if !(0 != 0) {
  45205 			v9 = libc.Int32FromUint16(VP8EntropyCost[v6])
  45206 		} else {
  45207 			v9 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v6)])
  45208 		}
  45209 		v7 = v9
  45210 		goto _8
  45211 	_8:
  45212 		return v7
  45213 	}
  45214 	for {
  45215 		if !(n < (*VP8Residual)(unsafe.Pointer(res)).Flast) {
  45216 			break
  45217 		}
  45218 		v = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(n)*2))))
  45219 		if v >= int32(2) {
  45220 			v11 = int32(2)
  45221 		} else {
  45222 			v11 = v
  45223 		}
  45224 		ctx = v11
  45225 		v3 = v
  45226 		if v3 > int32(MAX_VARIABLE_LEVEL) {
  45227 			v7 = int32(MAX_VARIABLE_LEVEL)
  45228 		} else {
  45229 			v7 = v3
  45230 		}
  45231 		v5 = libc.Int32FromUint16(VP8LevelFixedCosts[v3]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(t + uintptr(v7)*2)))
  45232 		goto _14
  45233 	_14:
  45234 		cost = cost + v5
  45235 		t = **(**uintptr)(__ccgo_up(costs + uintptr(n+int32(1))*24 + uintptr(ctx)*8))
  45236 		goto _10
  45237 	_10:
  45238 		;
  45239 		n = n + 1
  45240 	}
  45241 	// Last coefficient is always non-zero
  45242 	v1 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(n)*2))))
  45243 	v11 = v1
  45244 	if v11 > int32(MAX_VARIABLE_LEVEL) {
  45245 		v5 = int32(MAX_VARIABLE_LEVEL)
  45246 	} else {
  45247 		v5 = v11
  45248 	}
  45249 	v3 = libc.Int32FromUint16(VP8LevelFixedCosts[v11]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(t + uintptr(v5)*2)))
  45250 	goto _18
  45251 _18:
  45252 	cost = cost + v3
  45253 	if n < int32(15) {
  45254 		b = libc.Int32FromUint8(VP8EncBands[n+int32(1)])
  45255 		if v1 == int32(1) {
  45256 			v11 = int32(1)
  45257 		} else {
  45258 			v11 = int32(2)
  45259 		}
  45260 		ctx1 = v11
  45261 		last_p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(b)*33 + uintptr(ctx1)*11)))
  45262 		v2 = libc.Uint8FromInt32(last_p0)
  45263 		if !(0 != 0) {
  45264 			v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  45265 		} else {
  45266 			v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  45267 		}
  45268 		v3 = v5
  45269 		goto _23
  45270 	_23:
  45271 		cost = cost + v3
  45272 	}
  45273 	return cost
  45274 }
  45275 
  45276 func SetResidualCoeffs_C(tls *libc.TLS, coeffs uintptr, res uintptr) {
  45277 	var n int32
  45278 	_ = n
  45279 	(*VP8Residual)(unsafe.Pointer(res)).Flast = -int32(1)
  45280 	n = int32(15)
  45281 	for {
  45282 		if !(n >= 0) {
  45283 			break
  45284 		}
  45285 		if **(**int16_t)(__ccgo_up(coeffs + uintptr(n)*2)) != 0 {
  45286 			(*VP8Residual)(unsafe.Pointer(res)).Flast = n
  45287 			break
  45288 		}
  45289 		goto _1
  45290 	_1:
  45291 		;
  45292 		n = n - 1
  45293 	}
  45294 	(*VP8Residual)(unsafe.Pointer(res)).Fcoeffs = coeffs
  45295 }
  45296 
  45297 func VP8EncDspCostInit(tls *libc.TLS) {
  45298 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  45299 		goto _1
  45300 	}
  45301 	VP8EncDspCostInit_body(tls)
  45302 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  45303 	goto _2
  45304 _2:
  45305 	;
  45306 	goto _1
  45307 _1: /**/ //
  45308 }
  45309 
  45310 var VP8EncDspCostInit_body_last_cpuinfo_used = uintptr(0)
  45311 
  45312 func init() {
  45313 	p := unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used)
  45314 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used))
  45315 }
  45316 
  45317 func VP8EncDspCostInit_body(tls *libc.TLS) {
  45318 	VP8GetResidualCost = __ccgo_fp(GetResidualCost_C)
  45319 	VP8SetResidualCoeffs = __ccgo_fp(SetResidualCoeffs_C)
  45320 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  45321 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  45322 	}
  45323 }
  45324 
  45325 func VP8EncDspCostInitMIPS32(tls *libc.TLS) {
  45326 }
  45327 
  45328 func VP8EncDspCostInitMIPSdspR2(tls *libc.TLS) {
  45329 }
  45330 
  45331 func VP8EncDspCostInitNEON(tls *libc.TLS) {
  45332 }
  45333 
  45334 func VP8EncDspCostInitSSE2(tls *libc.TLS) {
  45335 }
  45336 
  45337 /*===---- __stddef_wchar.h - Definition of wchar_t -------------------------===
  45338  *
  45339  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45340  * See https://llvm.org/LICENSE.txt for license information.
  45341  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45342  *
  45343  *===-----------------------------------------------------------------------===
  45344  */
  45345 
  45346 /*
  45347  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45348  * and needs to behave as if it was textual.
  45349  */
  45350 
  45351 /*===---- __stddef_nullptr_t.h - Definition of nullptr_t -------------------===
  45352  *
  45353  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45354  * See https://llvm.org/LICENSE.txt for license information.
  45355  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45356  *
  45357  *===-----------------------------------------------------------------------===
  45358  */
  45359 
  45360 /*
  45361  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45362  * and needs to behave as if it was textual.
  45363  */
  45364 
  45365 /*===---- __stddef_unreachable.h - Definition of unreachable ---------------===
  45366  *
  45367  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45368  * See https://llvm.org/LICENSE.txt for license information.
  45369  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45370  *
  45371  *===-----------------------------------------------------------------------===
  45372  */
  45373 
  45374 /*
  45375  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45376  * and needs to behave as if it was textual.
  45377  */
  45378 
  45379 /*===---- __stddef_max_align_t.h - Definition of max_align_t ---------------===
  45380  *
  45381  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45382  * See https://llvm.org/LICENSE.txt for license information.
  45383  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45384  *
  45385  *===-----------------------------------------------------------------------===
  45386  */
  45387 
  45388 /*===---- __stddef_offsetof.h - Definition of offsetof ---------------------===
  45389  *
  45390  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45391  * See https://llvm.org/LICENSE.txt for license information.
  45392  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45393  *
  45394  *===-----------------------------------------------------------------------===
  45395  */
  45396 
  45397 /*
  45398  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45399  * and needs to behave as if it was textual.
  45400  */
  45401 
  45402 /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
  45403 __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
  45404 
  45405 // Copyright 2010 Google Inc. All Rights Reserved.
  45406 //
  45407 // Use of this source code is governed by a BSD-style license
  45408 // that can be found in the COPYING file in the root of the source
  45409 // tree. An additional intellectual property rights grant can be found
  45410 // in the file PATENTS. All contributing project authors may
  45411 // be found in the AUTHORS file in the root of the source tree.
  45412 // -----------------------------------------------------------------------------
  45413 //
  45414 //  Common types + memory wrappers
  45415 //
  45416 // Author: Skal (pascal.massimino@gmail.com)
  45417 
  45418 //------------------------------------------------------------------------------
  45419 // SSE2 detection.
  45420 //
  45421 
  45422 // C documentation
  45423 //
  45424 //	// apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC.
  45425 func GetCPUInfo(tls *libc.TLS, cpu_info uintptr, info_type int32) {
  45426 	//   __asm__ volatile (
  45427 	//     "cpuid\n"
  45428 	//     : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
  45429 	//     : "a"(info_type), "c"(0));
  45430 	libc.X__assert_fail(tls, __ccgo_ts+594, __ccgo_ts+629, 45, __ccgo_ts+635)
  45431 }
  45432 
  45433 // C documentation
  45434 //
  45435 //	// NaCl has no support for xgetbv or the raw opcode.
  45436 func xgetbv(tls *libc.TLS) (r uint64_t) {
  45437 	var eax, ecx, edx uint32_t
  45438 	_, _, _ = eax, ecx, edx
  45439 	ecx = uint32(0)
  45440 	// Use the raw opcode for xgetbv for compatibility with older toolchains.
  45441 	//   // Use the raw opcode for xgetbv for compatibility with older toolchains.
  45442 	//   __asm__ volatile (
  45443 	//     ".byte 0x0f, 0x01, 0xd0\n"
  45444 	//     : "=a"(eax), "=d"(edx) : "c" (ecx));
  45445 	libc.X__assert_fail(tls, __ccgo_ts+594, __ccgo_ts+629, 70, __ccgo_ts+646)
  45446 	return uint64(edx)<<libc.Int32FromInt32(32) | uint64(eax)
  45447 }
  45448 
  45449 // C documentation
  45450 //
  45451 //	// helper function for run-time detection of slow SSSE3 platforms
  45452 func CheckSlowModel(tls *libc.TLS, info int32) (r int32) {
  45453 	var family, model uint32_t
  45454 	var i size_t
  45455 	_, _, _ = family, i, model
  45456 	model = libc.Uint32FromInt32(info&int32(0xf0000)>>int32(12) | info>>int32(4)&int32(0xf))
  45457 	family = libc.Uint32FromInt32(info >> int32(8) & int32(0xf))
  45458 	if family == uint32(0x06) {
  45459 		i = uint64(0)
  45460 		for {
  45461 			if !(i < libc.Uint64FromInt64(6)/libc.Uint64FromInt64(1)) {
  45462 				break
  45463 			}
  45464 			if model == uint32(kSlowModels[i]) {
  45465 				return int32(1)
  45466 			}
  45467 			goto _1
  45468 		_1:
  45469 			;
  45470 			i = i + 1
  45471 		}
  45472 	}
  45473 	return 0
  45474 }
  45475 
  45476 // Table listing display models with longer latencies for the bsr instruction
  45477 // (ie 2 cycles vs 10/16 cycles) and some SSSE3 instructions like pshufb.
  45478 // Refer to Intel 64 and IA-32 Architectures Optimization Reference Manual.
  45479 var kSlowModels = [6]uint8_t{
  45480 	0: uint8(0x37),
  45481 	1: uint8(0x4a),
  45482 	2: uint8(0x4d),
  45483 	3: uint8(0x1c),
  45484 	4: uint8(0x26),
  45485 	5: uint8(0x27),
  45486 }
  45487 
  45488 func x86CPUInfo(tls *libc.TLS, feature CPUFeature) (r int32) {
  45489 	bp := tls.Alloc(16)
  45490 	defer tls.Free(16)
  45491 	var VENDOR_ID_INTEL_EBX, VENDOR_ID_INTEL_ECX, VENDOR_ID_INTEL_EDX, is_intel, max_cpuid_value int32
  45492 	var _ /* cpu_info at bp+0 */ [4]int32
  45493 	_, _, _, _, _ = VENDOR_ID_INTEL_EBX, VENDOR_ID_INTEL_ECX, VENDOR_ID_INTEL_EDX, is_intel, max_cpuid_value
  45494 	is_intel = 0
  45495 	// get the highest feature value cpuid supports
  45496 	GetCPUInfo(tls, bp, 0)
  45497 	max_cpuid_value = (**(**[4]int32)(__ccgo_up(bp)))[0]
  45498 	if max_cpuid_value < int32(1) {
  45499 		return 0
  45500 	} else {
  45501 		VENDOR_ID_INTEL_EBX = int32(0x756e6547)                                                                                                                                                                                             // uneG
  45502 		VENDOR_ID_INTEL_EDX = int32(0x49656e69)                                                                                                                                                                                             // Ieni
  45503 		VENDOR_ID_INTEL_ECX = int32(0x6c65746e)                                                                                                                                                                                             // letn
  45504 		is_intel = libc.BoolInt32((**(**[4]int32)(__ccgo_up(bp)))[int32(1)] == VENDOR_ID_INTEL_EBX && (**(**[4]int32)(__ccgo_up(bp)))[int32(2)] == VENDOR_ID_INTEL_ECX && (**(**[4]int32)(__ccgo_up(bp)))[int32(3)] == VENDOR_ID_INTEL_EDX) // genuine Intel?
  45505 	}
  45506 	GetCPUInfo(tls, bp, int32(1))
  45507 	if feature == int32(kSSE2) {
  45508 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(3)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(26)) != 0))
  45509 	}
  45510 	if feature == int32(kSSE3) {
  45511 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(0)) != 0))
  45512 	}
  45513 	if feature == int32(kSlowSSSE3) {
  45514 		if is_intel != 0 && (**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(9)) != 0 { // SSSE3?
  45515 			return CheckSlowModel(tls, (**(**[4]int32)(__ccgo_up(bp)))[0])
  45516 		}
  45517 		return 0
  45518 	}
  45519 	if feature == int32(kSSE4_1) {
  45520 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  45521 	}
  45522 	if feature == int32(kAVX) {
  45523 		// bits 27 (OSXSAVE) & 28 (256-bit AVX)
  45524 		if (**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&int32(0x18000000) == int32(0x18000000) {
  45525 			// XMM state and YMM state enabled by the OS.
  45526 			return libc.BoolInt32(xgetbv(tls)&uint64(0x6) == uint64(0x6))
  45527 		}
  45528 	}
  45529 	if feature == int32(kAVX2) {
  45530 		if x86CPUInfo(tls, int32(kAVX)) != 0 && max_cpuid_value >= int32(7) {
  45531 			GetCPUInfo(tls, bp, int32(7))
  45532 			return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(1)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(5)) != 0))
  45533 		}
  45534 	}
  45535 	return 0
  45536 }
  45537 
  45538 func init() {
  45539 	p := unsafe.Pointer(&VP8GetCPUInfo)
  45540 	*(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(x86CPUInfo)
  45541 }
  45542 
  45543 var kHashMul14 = uint32(0x1e35a7bd)
  45544 
  45545 //------------------------------------------------------------------------------
  45546 
  45547 // Copyright 2010 Google Inc. All Rights Reserved.
  45548 //
  45549 // Use of this source code is governed by a BSD-style license
  45550 // that can be found in the COPYING file in the root of the source
  45551 // tree. An additional intellectual property rights grant can be found
  45552 // in the file PATENTS. All contributing project authors may
  45553 // be found in the AUTHORS file in the root of the source tree.
  45554 // -----------------------------------------------------------------------------
  45555 //
  45556 //  Common types + memory wrappers
  45557 //
  45558 // Author: Skal (pascal.massimino@gmail.com)
  45559 
  45560 //------------------------------------------------------------------------------
  45561 
  45562 func clip_8b1(tls *libc.TLS, v int32) (r uint8_t) {
  45563 	var v1, v2 int32
  45564 	_, _ = v1, v2
  45565 	if !(v & ^libc.Int32FromInt32(0xff) != 0) {
  45566 		v1 = v
  45567 	} else {
  45568 		if v < 0 {
  45569 			v2 = 0
  45570 		} else {
  45571 			v2 = int32(255)
  45572 		}
  45573 		v1 = v2
  45574 	}
  45575 	return libc.Uint8FromInt32(v1)
  45576 }
  45577 
  45578 //------------------------------------------------------------------------------
  45579 // Transforms (Paragraph 14.4)
  45580 
  45581 func TransformOne_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45582 	bp := tls.Alloc(64)
  45583 	defer tls.Free(64)
  45584 	var a, a1, b, b1, c, c1, d, d1, dc, i int32
  45585 	var tmp uintptr
  45586 	var _ /* C at bp+0 */ [16]int32
  45587 	_, _, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, c, c1, d, d1, dc, i, tmp
  45588 	tmp = bp
  45589 	i = 0
  45590 	for {
  45591 		if !(i < int32(4)) {
  45592 			break
  45593 		} // vertical pass
  45594 		a = int32(**(**int16_t)(__ccgo_up(in))) + int32(**(**int16_t)(__ccgo_up(in + 8*2)))                                                                                                                                       // [-4096, 4094]
  45595 		b = int32(**(**int16_t)(__ccgo_up(in))) - int32(**(**int16_t)(__ccgo_up(in + 8*2)))                                                                                                                                       // [-4095, 4095]
  45596 		c = int32(**(**int16_t)(__ccgo_up(in + 4*2)))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16) - (int32(**(**int16_t)(__ccgo_up(in + 12*2)))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + int32(**(**int16_t)(__ccgo_up(in + 12*2)))) // [-3783, 3783]
  45597 		d = int32(**(**int16_t)(__ccgo_up(in + 4*2)))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + int32(**(**int16_t)(__ccgo_up(in + 4*2))) + int32(**(**int16_t)(__ccgo_up(in + 12*2)))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16)    // [-3785, 3781]
  45598 		**(**int32)(__ccgo_up(tmp)) = a + d                                                                                                                                                                                       // [-7881, 7875]
  45599 		**(**int32)(__ccgo_up(tmp + 1*4)) = b + c                                                                                                                                                                                 // [-7878, 7878]
  45600 		**(**int32)(__ccgo_up(tmp + 2*4)) = b - c                                                                                                                                                                                 // [-7878, 7878]
  45601 		**(**int32)(__ccgo_up(tmp + 3*4)) = a - d                                                                                                                                                                                 // [-7877, 7879]
  45602 		tmp = tmp + uintptr(4)*4
  45603 		in += 2
  45604 		goto _1
  45605 	_1:
  45606 		;
  45607 		i = i + 1
  45608 	}
  45609 	// Each pass is expanding the dynamic range by ~3.85 (upper bound).
  45610 	// The exact value is (2. + (20091 + 35468) / 65536).
  45611 	// After the second pass, maximum interval is [-3794, 3794], assuming
  45612 	// an input in [-2048, 2047] interval. We then need to add a dst value
  45613 	// in the [0, 255] range.
  45614 	// In the worst case scenario, the input to clip_8b() can be as large as
  45615 	// [-60713, 60968].
  45616 	tmp = bp
  45617 	i = 0
  45618 	for {
  45619 		if !(i < int32(4)) {
  45620 			break
  45621 		} // horizontal pass
  45622 		dc = **(**int32)(__ccgo_up(tmp)) + int32(4)
  45623 		a1 = dc + **(**int32)(__ccgo_up(tmp + 8*4))
  45624 		b1 = dc - **(**int32)(__ccgo_up(tmp + 8*4))
  45625 		c1 = **(**int32)(__ccgo_up(tmp + 4*4))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16) - (**(**int32)(__ccgo_up(tmp + 12*4))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + **(**int32)(__ccgo_up(tmp + 12*4)))
  45626 		d1 = **(**int32)(__ccgo_up(tmp + 4*4))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + **(**int32)(__ccgo_up(tmp + 4*4)) + **(**int32)(__ccgo_up(tmp + 12*4))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16)
  45627 		**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(a1+d1)>>int32(3))
  45628 		**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(b1+c1)>>int32(3))
  45629 		**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(b1-c1)>>int32(3))
  45630 		**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(a1-d1)>>int32(3))
  45631 		tmp += 4
  45632 		dst = dst + uintptr(BPS)
  45633 		goto _2
  45634 	_2:
  45635 		;
  45636 		i = i + 1
  45637 	}
  45638 }
  45639 
  45640 // C documentation
  45641 //
  45642 //	// Simplified transform when only in[0], in[1] and in[4] are non-zero
  45643 func TransformAC3_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45644 	var DC, DC1, DC2, DC3, a, c1, c4, d1, d4 int32
  45645 	_, _, _, _, _, _, _, _, _ = DC, DC1, DC2, DC3, a, c1, c4, d1, d4
  45646 	a = int32(**(**int16_t)(__ccgo_up(in))) + int32(4)
  45647 	c4 = int32(**(**int16_t)(__ccgo_up(in + 4*2))) * libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C2) >> libc.Int32FromInt32(16)
  45648 	d4 = int32(**(**int16_t)(__ccgo_up(in + 4*2)))*libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C1)>>libc.Int32FromInt32(16) + int32(**(**int16_t)(__ccgo_up(in + 4*2)))
  45649 	c1 = int32(**(**int16_t)(__ccgo_up(in + 1*2))) * libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C2) >> libc.Int32FromInt32(16)
  45650 	d1 = int32(**(**int16_t)(__ccgo_up(in + 1*2)))*libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C1)>>libc.Int32FromInt32(16) + int32(**(**int16_t)(__ccgo_up(in + 1*2)))
  45651 	DC = a + d4
  45652 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(DC+d1)>>int32(3))
  45653 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(DC+c1)>>int32(3))
  45654 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(DC-c1)>>int32(3))
  45655 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))+(DC-d1)>>int32(3))
  45656 	DC1 = a + c4
  45657 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))+(DC1+d1)>>int32(3))
  45658 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))+(DC1+c1)>>int32(3))
  45659 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))+(DC1-c1)>>int32(3))
  45660 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))+(DC1-d1)>>int32(3))
  45661 	DC2 = a - c4
  45662 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))+(DC2+d1)>>int32(3))
  45663 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))+(DC2+c1)>>int32(3))
  45664 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))+(DC2-c1)>>int32(3))
  45665 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))+(DC2-d1)>>int32(3))
  45666 	DC3 = a - d4
  45667 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))+(DC3+d1)>>int32(3))
  45668 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))+(DC3+c1)>>int32(3))
  45669 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))+(DC3-c1)>>int32(3))
  45670 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))+(DC3-d1)>>int32(3))
  45671 }
  45672 
  45673 func TransformTwo_C(tls *libc.TLS, in uintptr, dst uintptr, do_two int32) {
  45674 	TransformOne_C(tls, in, dst)
  45675 	if do_two != 0 {
  45676 		TransformOne_C(tls, in+uintptr(16)*2, dst+uintptr(4))
  45677 	}
  45678 }
  45679 
  45680 func TransformUV_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45681 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8Transform})))(tls, in+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, dst, int32(1))
  45682 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8Transform})))(tls, in+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2, dst+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)), int32(1))
  45683 }
  45684 
  45685 func TransformDC_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45686 	var DC, i, j int32
  45687 	_, _, _ = DC, i, j
  45688 	DC = int32(**(**int16_t)(__ccgo_up(in))) + int32(4)
  45689 	j = 0
  45690 	for {
  45691 		if !(j < int32(4)) {
  45692 			break
  45693 		}
  45694 		i = 0
  45695 		for {
  45696 			if !(i < int32(4)) {
  45697 				break
  45698 			}
  45699 			**(**uint8_t)(__ccgo_up(dst + uintptr(i+j*int32(BPS)))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i+j*int32(BPS)))))+DC>>libc.Int32FromInt32(3))
  45700 			goto _2
  45701 		_2:
  45702 			;
  45703 			i = i + 1
  45704 		}
  45705 		goto _1
  45706 	_1:
  45707 		;
  45708 		j = j + 1
  45709 	}
  45710 }
  45711 
  45712 func TransformDCUV_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45713 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2)) != 0 {
  45714 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, dst)
  45715 	}
  45716 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2)) != 0 {
  45717 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2, dst+uintptr(4))
  45718 	}
  45719 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2)) != 0 {
  45720 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2, dst+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)))
  45721 	}
  45722 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16))*2)) != 0 {
  45723 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16))*2, dst+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS))+uintptr(4))
  45724 	}
  45725 }
  45726 
  45727 //------------------------------------------------------------------------------
  45728 // Paragraph 14.3
  45729 
  45730 func TransformWHT_C(tls *libc.TLS, in uintptr, out uintptr) {
  45731 	var a0, a01, a1, a11, a2, a21, a3, a31, dc, i int32
  45732 	var tmp [16]int32
  45733 	_, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, dc, i, tmp
  45734 	i = 0
  45735 	for {
  45736 		if !(i < int32(4)) {
  45737 			break
  45738 		}
  45739 		a0 = int32(**(**int16_t)(__ccgo_up(in + uintptr(0+i)*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(12)+i)*2)))
  45740 		a1 = int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(4)+i)*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(8)+i)*2)))
  45741 		a2 = int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(4)+i)*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(8)+i)*2)))
  45742 		a3 = int32(**(**int16_t)(__ccgo_up(in + uintptr(0+i)*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(12)+i)*2)))
  45743 		tmp[0+i] = a0 + a1
  45744 		tmp[int32(8)+i] = a0 - a1
  45745 		tmp[int32(4)+i] = a3 + a2
  45746 		tmp[int32(12)+i] = a3 - a2
  45747 		goto _1
  45748 	_1:
  45749 		;
  45750 		i = i + 1
  45751 	}
  45752 	i = 0
  45753 	for {
  45754 		if !(i < int32(4)) {
  45755 			break
  45756 		}
  45757 		dc = tmp[0+i*int32(4)] + int32(3) // w/ rounder
  45758 		a01 = dc + tmp[int32(3)+i*int32(4)]
  45759 		a11 = tmp[int32(1)+i*int32(4)] + tmp[int32(2)+i*int32(4)]
  45760 		a21 = tmp[int32(1)+i*int32(4)] - tmp[int32(2)+i*int32(4)]
  45761 		a31 = dc - tmp[int32(3)+i*int32(4)]
  45762 		**(**int16_t)(__ccgo_up(out)) = int16((a01 + a11) >> int32(3))
  45763 		**(**int16_t)(__ccgo_up(out + 16*2)) = int16((a31 + a21) >> int32(3))
  45764 		**(**int16_t)(__ccgo_up(out + 32*2)) = int16((a01 - a11) >> int32(3))
  45765 		**(**int16_t)(__ccgo_up(out + 48*2)) = int16((a31 - a21) >> int32(3))
  45766 		out = out + uintptr(64)*2
  45767 		goto _2
  45768 	_2:
  45769 		;
  45770 		i = i + 1
  45771 	}
  45772 }
  45773 
  45774 //------------------------------------------------------------------------------
  45775 // Intra predictions
  45776 
  45777 func TrueMotion(tls *libc.TLS, dst uintptr, size int32) {
  45778 	var clip, clip0, top uintptr
  45779 	var x, y int32
  45780 	_, _, _, _, _ = clip, clip0, top, x, y
  45781 	top = dst - uintptr(BPS)
  45782 	clip0 = VP8kclip1 - uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  45783 	y = 0
  45784 	for {
  45785 		if !(y < size) {
  45786 			break
  45787 		}
  45788 		clip = clip0 + uintptr(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)))))
  45789 		x = 0
  45790 		for {
  45791 			if !(x < size) {
  45792 				break
  45793 			}
  45794 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  45795 			goto _2
  45796 		_2:
  45797 			;
  45798 			x = x + 1
  45799 		}
  45800 		dst = dst + uintptr(BPS)
  45801 		goto _1
  45802 	_1:
  45803 		;
  45804 		y = y + 1
  45805 	}
  45806 }
  45807 
  45808 func TM4_C(tls *libc.TLS, dst uintptr) {
  45809 	TrueMotion(tls, dst, int32(4))
  45810 }
  45811 
  45812 func TM8uv_C(tls *libc.TLS, dst uintptr) {
  45813 	TrueMotion(tls, dst, int32(8))
  45814 }
  45815 
  45816 func TM16_C(tls *libc.TLS, dst uintptr) {
  45817 	TrueMotion(tls, dst, int32(16))
  45818 }
  45819 
  45820 //------------------------------------------------------------------------------
  45821 // 16x16
  45822 
  45823 func VE16_C(tls *libc.TLS, dst uintptr) {
  45824 	var j int32
  45825 	_ = j
  45826 	j = 0
  45827 	for {
  45828 		if !(j < int32(16)) {
  45829 			break
  45830 		}
  45831 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), dst-uintptr(BPS), uint64(16), ^__predefined_size_t(0))
  45832 		goto _1
  45833 	_1:
  45834 		;
  45835 		j = j + 1
  45836 	}
  45837 }
  45838 
  45839 func HE16_C(tls *libc.TLS, dst uintptr) {
  45840 	var j int32
  45841 	_ = j
  45842 	j = int32(16)
  45843 	for {
  45844 		if !(j > 0) {
  45845 			break
  45846 		}
  45847 		libc.X__builtin___memset_chk(tls, dst, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1))))), uint64(16), ^__predefined_size_t(0))
  45848 		dst = dst + uintptr(BPS)
  45849 		goto _1
  45850 	_1:
  45851 		;
  45852 		j = j - 1
  45853 	}
  45854 }
  45855 
  45856 func Put16(tls *libc.TLS, v int32, dst uintptr) {
  45857 	var j int32
  45858 	_ = j
  45859 	j = 0
  45860 	for {
  45861 		if !(j < int32(16)) {
  45862 			break
  45863 		}
  45864 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), v, uint64(16), ^__predefined_size_t(0))
  45865 		goto _1
  45866 	_1:
  45867 		;
  45868 		j = j + 1
  45869 	}
  45870 }
  45871 
  45872 func DC16_C(tls *libc.TLS, dst uintptr) {
  45873 	var DC, j int32
  45874 	_, _ = DC, j // DC
  45875 	DC = int32(16)
  45876 	j = 0
  45877 	for {
  45878 		if !(j < int32(16)) {
  45879 			break
  45880 		}
  45881 		DC = DC + (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+j*int32(BPS))))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(j-int32(BPS))))))
  45882 		goto _1
  45883 	_1:
  45884 		;
  45885 		j = j + 1
  45886 	}
  45887 	Put16(tls, DC>>int32(5), dst)
  45888 }
  45889 
  45890 func DC16NoTop_C(tls *libc.TLS, dst uintptr) {
  45891 	var DC, j int32
  45892 	_, _ = DC, j // DC with top samples not available
  45893 	DC = int32(8)
  45894 	j = 0
  45895 	for {
  45896 		if !(j < int32(16)) {
  45897 			break
  45898 		}
  45899 		DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+j*int32(BPS)))))
  45900 		goto _1
  45901 	_1:
  45902 		;
  45903 		j = j + 1
  45904 	}
  45905 	Put16(tls, DC>>int32(4), dst)
  45906 }
  45907 
  45908 func DC16NoLeft_C(tls *libc.TLS, dst uintptr) {
  45909 	var DC, i int32
  45910 	_, _ = DC, i // DC with left samples not available
  45911 	DC = int32(8)
  45912 	i = 0
  45913 	for {
  45914 		if !(i < int32(16)) {
  45915 			break
  45916 		}
  45917 		DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS)))))
  45918 		goto _1
  45919 	_1:
  45920 		;
  45921 		i = i + 1
  45922 	}
  45923 	Put16(tls, DC>>int32(4), dst)
  45924 }
  45925 
  45926 func DC16NoTopLeft_C(tls *libc.TLS, dst uintptr) {
  45927 	// DC with no top and left samples
  45928 	Put16(tls, int32(0x80), dst)
  45929 }
  45930 
  45931 //------------------------------------------------------------------------------
  45932 // 4x4
  45933 
  45934 func VE4_C(tls *libc.TLS, dst uintptr) {
  45935 	bp := tls.Alloc(16)
  45936 	defer tls.Free(16)
  45937 	var i int32
  45938 	var top uintptr
  45939 	var _ /* vals at bp+0 */ [4]uint8_t
  45940 	_, _ = i, top // vertical
  45941 	top = dst - uintptr(BPS)
  45942 	**(**[4]uint8_t)(__ccgo_up(bp)) = [4]uint8_t{
  45943 		0: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  45944 		1: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  45945 		2: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  45946 		3: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  45947 	}
  45948 	i = 0
  45949 	for {
  45950 		if !(i < int32(4)) {
  45951 			break
  45952 		}
  45953 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(i*int32(BPS)), bp, uint64(4), ^__predefined_size_t(0))
  45954 		goto _1
  45955 	_1:
  45956 		;
  45957 		i = i + 1
  45958 	}
  45959 }
  45960 
  45961 func HE4_C(tls *libc.TLS, dst uintptr) {
  45962 	bp := tls.Alloc(16)
  45963 	defer tls.Free(16)
  45964 	var A, B, C, D, E int32
  45965 	var v1 uintptr
  45966 	var v2 uint32_t
  45967 	_, _, _, _, _, _, _ = A, B, C, D, E, v1, v2 // horizontal
  45968 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  45969 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)))))
  45970 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(BPS)))))
  45971 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  45972 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  45973 	v1 = dst + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS))
  45974 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((A+libc.Int32FromInt32(2)*B+C+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45975 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45976 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45977 	v1 = dst + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS))
  45978 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((B+libc.Int32FromInt32(2)*C+D+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45979 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45980 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45981 	v1 = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))
  45982 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((C+libc.Int32FromInt32(2)*D+E+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45983 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45984 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45985 	v1 = dst + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))
  45986 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((D+libc.Int32FromInt32(2)*E+E+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45987 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45988 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45989 }
  45990 
  45991 func DC4_C(tls *libc.TLS, dst uintptr) {
  45992 	var dc uint32_t
  45993 	var i int32
  45994 	_, _ = dc, i // DC
  45995 	dc = uint32(4)
  45996 	i = 0
  45997 	for {
  45998 		if !(i < int32(4)) {
  45999 			break
  46000 		}
  46001 		dc = dc + libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS)))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+i*int32(BPS))))))
  46002 		goto _1
  46003 	_1:
  46004 		;
  46005 		i = i + 1
  46006 	}
  46007 	dc = dc >> uint32(3)
  46008 	i = 0
  46009 	for {
  46010 		if !(i < int32(4)) {
  46011 			break
  46012 		}
  46013 		libc.X__builtin___memset_chk(tls, dst+uintptr(i*int32(BPS)), libc.Int32FromUint32(dc), uint64(4), ^__predefined_size_t(0))
  46014 		goto _2
  46015 	_2:
  46016 		;
  46017 		i = i + 1
  46018 	}
  46019 }
  46020 
  46021 func RD4_C(tls *libc.TLS, dst uintptr) {
  46022 	var A, B, C, D, I, J, K, L, X int32
  46023 	var v1, v2, v3 uint8_t
  46024 	_, _, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, L, X, v1, v2, v3 // Down-right
  46025 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46026 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46027 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46028 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46029 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46030 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46031 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46032 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46033 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46034 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46035 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46036 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46037 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46038 	v2 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*I + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46039 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v2
  46040 	v1 = v2
  46041 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46042 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46043 	v3 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*X + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46044 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v3
  46045 	v2 = v3
  46046 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v2
  46047 	v1 = v2
  46048 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46049 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46050 	v2 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*A + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46051 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v2
  46052 	v1 = v2
  46053 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46054 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46055 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*B + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46056 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46057 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46058 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*C + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46059 }
  46060 
  46061 func LD4_C(tls *libc.TLS, dst uintptr) {
  46062 	var A, B, C, D, E, F, G, H int32
  46063 	var v1, v2, v3 uint8_t
  46064 	_, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1, v2, v3 // Down-Left
  46065 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46066 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46067 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46068 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46069 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(4)-libc.Int32FromInt32(BPS)))))
  46070 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(5)-libc.Int32FromInt32(BPS)))))
  46071 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(6)-libc.Int32FromInt32(BPS)))))
  46072 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(7)-libc.Int32FromInt32(BPS)))))
  46073 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46074 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46075 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46076 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46077 	v2 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46078 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  46079 	v1 = v2
  46080 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46081 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46082 	v3 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46083 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  46084 	v2 = v3
  46085 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  46086 	v1 = v2
  46087 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46088 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46089 	v2 = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46090 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  46091 	v1 = v2
  46092 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46093 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46094 	v1 = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46095 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46096 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46097 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((G + libc.Int32FromInt32(2)*H + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46098 }
  46099 
  46100 func VR4_C(tls *libc.TLS, dst uintptr) {
  46101 	var A, B, C, D, I, J, K, X int32
  46102 	var v1 uint8_t
  46103 	_, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, X, v1 // Vertical-Right
  46104 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46105 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46106 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46107 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46108 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46109 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46110 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46111 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46112 	v1 = libc.Uint8FromInt32((X + A + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46113 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46114 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46115 	v1 = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46116 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46117 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46118 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46119 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46120 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46121 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46122 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46123 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46124 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46125 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46126 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46127 	v1 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46128 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46129 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46130 	v1 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46131 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46132 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46133 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46134 }
  46135 
  46136 func VL4_C(tls *libc.TLS, dst uintptr) {
  46137 	var A, B, C, D, E, F, G, H int32
  46138 	var v1 uint8_t
  46139 	_, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1 // Vertical-Left
  46140 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46141 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46142 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46143 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46144 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(4)-libc.Int32FromInt32(BPS)))))
  46145 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(5)-libc.Int32FromInt32(BPS)))))
  46146 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(6)-libc.Int32FromInt32(BPS)))))
  46147 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(7)-libc.Int32FromInt32(BPS)))))
  46148 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46149 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46150 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46151 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46152 	v1 = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46153 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46154 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46155 	v1 = libc.Uint8FromInt32((D + E + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46156 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46157 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46158 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46159 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46160 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46161 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46162 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46163 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46164 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46165 	v1 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46166 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46167 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46168 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46169 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46170 }
  46171 
  46172 func HU4_C(tls *libc.TLS, dst uintptr) {
  46173 	var I, J, K, L int32
  46174 	var v1, v2, v3, v4, v5 uint8_t
  46175 	_, _, _, _, _, _, _, _, _ = I, J, K, L, v1, v2, v3, v4, v5 // Horizontal-Up
  46176 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46177 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46178 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46179 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46180 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((I + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46181 	v1 = libc.Uint8FromInt32((J + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46182 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46183 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46184 	v1 = libc.Uint8FromInt32((K + L + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46185 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46186 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46187 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46188 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46189 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46190 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46191 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*L + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46192 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46193 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46194 	v5 = libc.Uint8FromInt32(L)
  46195 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v5
  46196 	v4 = v5
  46197 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v4
  46198 	v3 = v4
  46199 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  46200 	v2 = v3
  46201 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  46202 	v1 = v2
  46203 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46204 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46205 }
  46206 
  46207 func HD4_C(tls *libc.TLS, dst uintptr) {
  46208 	var A, B, C, I, J, K, L, X int32
  46209 	var v1 uint8_t
  46210 	_, _, _, _, _, _, _, _, _ = A, B, C, I, J, K, L, X, v1 // Horizontal-Down
  46211 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46212 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46213 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46214 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46215 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46216 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46217 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46218 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46219 	v1 = libc.Uint8FromInt32((I + X + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46220 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46221 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46222 	v1 = libc.Uint8FromInt32((J + I + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46223 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46224 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46225 	v1 = libc.Uint8FromInt32((K + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46226 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46227 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46228 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((L + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46229 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46230 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46231 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46232 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46233 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46234 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46235 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46236 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46237 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46238 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46239 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46240 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((L + libc.Int32FromInt32(2)*K + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46241 }
  46242 
  46243 //------------------------------------------------------------------------------
  46244 // Chroma
  46245 
  46246 func VE8uv_C(tls *libc.TLS, dst uintptr) {
  46247 	var j int32
  46248 	_ = j
  46249 	j = 0
  46250 	for {
  46251 		if !(j < int32(8)) {
  46252 			break
  46253 		}
  46254 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), dst-uintptr(BPS), uint64(8), ^__predefined_size_t(0))
  46255 		goto _1
  46256 	_1:
  46257 		;
  46258 		j = j + 1
  46259 	}
  46260 }
  46261 
  46262 func HE8uv_C(tls *libc.TLS, dst uintptr) {
  46263 	var j int32
  46264 	_ = j
  46265 	j = 0
  46266 	for {
  46267 		if !(j < int32(8)) {
  46268 			break
  46269 		}
  46270 		libc.X__builtin___memset_chk(tls, dst, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1))))), uint64(8), ^__predefined_size_t(0))
  46271 		dst = dst + uintptr(BPS)
  46272 		goto _1
  46273 	_1:
  46274 		;
  46275 		j = j + 1
  46276 	}
  46277 }
  46278 
  46279 // C documentation
  46280 //
  46281 //	// helper for chroma-DC predictions
  46282 func Put8x8uv(tls *libc.TLS, value uint8_t, dst uintptr) {
  46283 	var j int32
  46284 	_ = j
  46285 	j = 0
  46286 	for {
  46287 		if !(j < int32(8)) {
  46288 			break
  46289 		}
  46290 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), libc.Int32FromUint8(value), uint64(8), ^__predefined_size_t(0))
  46291 		goto _1
  46292 	_1:
  46293 		;
  46294 		j = j + 1
  46295 	}
  46296 }
  46297 
  46298 func DC8uv_C(tls *libc.TLS, dst uintptr) {
  46299 	var dc0, i int32
  46300 	_, _ = dc0, i // DC
  46301 	dc0 = int32(8)
  46302 	i = 0
  46303 	for {
  46304 		if !(i < int32(8)) {
  46305 			break
  46306 		}
  46307 		dc0 = dc0 + (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS))))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+i*int32(BPS))))))
  46308 		goto _1
  46309 	_1:
  46310 		;
  46311 		i = i + 1
  46312 	}
  46313 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(4)), dst)
  46314 }
  46315 
  46316 func DC8uvNoLeft_C(tls *libc.TLS, dst uintptr) {
  46317 	var dc0, i int32
  46318 	_, _ = dc0, i // DC with no left samples
  46319 	dc0 = int32(4)
  46320 	i = 0
  46321 	for {
  46322 		if !(i < int32(8)) {
  46323 			break
  46324 		}
  46325 		dc0 = dc0 + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS)))))
  46326 		goto _1
  46327 	_1:
  46328 		;
  46329 		i = i + 1
  46330 	}
  46331 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(3)), dst)
  46332 }
  46333 
  46334 func DC8uvNoTop_C(tls *libc.TLS, dst uintptr) {
  46335 	var dc0, i int32
  46336 	_, _ = dc0, i // DC with no top samples
  46337 	dc0 = int32(4)
  46338 	i = 0
  46339 	for {
  46340 		if !(i < int32(8)) {
  46341 			break
  46342 		}
  46343 		dc0 = dc0 + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+i*int32(BPS)))))
  46344 		goto _1
  46345 	_1:
  46346 		;
  46347 		i = i + 1
  46348 	}
  46349 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(3)), dst)
  46350 }
  46351 
  46352 func DC8uvNoTopLeft_C(tls *libc.TLS, dst uintptr) {
  46353 	// DC with nothing
  46354 	Put8x8uv(tls, uint8(0x80), dst)
  46355 }
  46356 
  46357 //------------------------------------------------------------------------------
  46358 // Edge filtering functions
  46359 
  46360 // C documentation
  46361 //
  46362 //	// 4 pixels in, 2 pixels out
  46363 func DoFilter2_C(tls *libc.TLS, p uintptr, step int32) {
  46364 	var a, a1, a2, p0, p1, q0, q1 int32
  46365 	_, _, _, _, _, _, _ = a, a1, a2, p0, p1, q0, q1
  46366 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46367 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46368 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46369 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46370 	a = int32(3)*(q0-p0) + int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(p1-q1)))) // in [-893,892]
  46371 	a1 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(4))>>int32(3)))))  // in [-16,15]
  46372 	a2 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(3))>>int32(3)))))
  46373 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a2)))
  46374 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46375 }
  46376 
  46377 // C documentation
  46378 //
  46379 //	// 4 pixels in, 4 pixels out
  46380 func DoFilter4_C(tls *libc.TLS, p uintptr, step int32) {
  46381 	var a, a1, a2, a3, p0, p1, q0, q1 int32
  46382 	_, _, _, _, _, _, _, _ = a, a1, a2, a3, p0, p1, q0, q1
  46383 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46384 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46385 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46386 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46387 	a = int32(3) * (q0 - p0)
  46388 	a1 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(4))>>int32(3)))))
  46389 	a2 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(3))>>int32(3)))))
  46390 	a3 = (a1 + int32(1)) >> int32(1)
  46391 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p1+a3)))
  46392 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a2)))
  46393 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46394 	**(**uint8_t)(__ccgo_up(p + uintptr(step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q1-a3)))
  46395 }
  46396 
  46397 // C documentation
  46398 //
  46399 //	// 6 pixels in, 6 pixels out
  46400 func DoFilter6_C(tls *libc.TLS, p uintptr, step int32) {
  46401 	var a, a1, a2, a3, p0, p1, p2, q0, q1, q2 int32
  46402 	_, _, _, _, _, _, _, _, _, _ = a, a1, a2, a3, p0, p1, p2, q0, q1, q2
  46403 	p2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))))
  46404 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46405 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46406 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46407 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46408 	q2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))))
  46409 	a = int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(int32(3)*(q0-p0)+int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(p1-q1))))))))
  46410 	// a is in [-128,127], a1 in [-27,27], a2 in [-18,18] and a3 in [-9,9]
  46411 	a1 = (int32(27)*a + int32(63)) >> int32(7) // eq. to ((3 * a + 7) * 9) >> 7
  46412 	a2 = (int32(18)*a + int32(63)) >> int32(7) // eq. to ((2 * a + 7) * 9) >> 7
  46413 	a3 = (int32(9)*a + int32(63)) >> int32(7)  // eq. to ((1 * a + 7) * 9) >> 7
  46414 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p2+a3)))
  46415 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p1+a2)))
  46416 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a1)))
  46417 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46418 	**(**uint8_t)(__ccgo_up(p + uintptr(step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q1-a2)))
  46419 	**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q2-a3)))
  46420 }
  46421 
  46422 func Hev(tls *libc.TLS, p uintptr, step int32, thresh int32) (r int32) {
  46423 	var p0, p1, q0, q1 int32
  46424 	_, _, _, _ = p0, p1, q0, q1
  46425 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46426 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46427 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46428 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46429 	return libc.BoolInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p1-p0)))) > thresh || libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(q1-q0)))) > thresh)
  46430 }
  46431 
  46432 func NeedsFilter_C(tls *libc.TLS, p uintptr, step int32, t int32) (r int32) {
  46433 	var p0, p1, q0, q1 int32
  46434 	_, _, _, _ = p0, p1, q0, q1
  46435 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46436 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46437 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46438 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46439 	return libc.BoolInt32(int32(4)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p0-q0))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p1-q1)))) <= t)
  46440 }
  46441 
  46442 func NeedsFilter2_C(tls *libc.TLS, p uintptr, step int32, t int32, it int32) (r int32) {
  46443 	var p0, p1, p2, p3, q0, q1, q2, q3 int32
  46444 	_, _, _, _, _, _, _, _ = p0, p1, p2, p3, q0, q1, q2, q3
  46445 	p3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(4)*step))))
  46446 	p2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))))
  46447 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46448 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46449 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46450 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46451 	q2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))))
  46452 	q3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(3)*step))))
  46453 	if int32(4)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p0-q0))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p1-q1)))) > t {
  46454 		return 0
  46455 	}
  46456 	return libc.BoolInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p3-p2)))) <= it && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p2-p1)))) <= it && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p1-p0)))) <= it && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(q3-q2)))) <= it && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(q2-q1)))) <= it && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(q1-q0)))) <= it)
  46457 }
  46458 
  46459 //------------------------------------------------------------------------------
  46460 // Simple In-loop filtering (Paragraph 15.2)
  46461 
  46462 func SimpleVFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46463 	var i, thresh2 int32
  46464 	_, _ = i, thresh2
  46465 	thresh2 = int32(2)*thresh + int32(1)
  46466 	i = 0
  46467 	for {
  46468 		if !(i < int32(16)) {
  46469 			break
  46470 		}
  46471 		if NeedsFilter_C(tls, p+uintptr(i), stride, thresh2) != 0 {
  46472 			DoFilter2_C(tls, p+uintptr(i), stride)
  46473 		}
  46474 		goto _1
  46475 	_1:
  46476 		;
  46477 		i = i + 1
  46478 	}
  46479 }
  46480 
  46481 func SimpleHFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46482 	var i, thresh2 int32
  46483 	_, _ = i, thresh2
  46484 	thresh2 = int32(2)*thresh + int32(1)
  46485 	i = 0
  46486 	for {
  46487 		if !(i < int32(16)) {
  46488 			break
  46489 		}
  46490 		if NeedsFilter_C(tls, p+uintptr(i*stride), int32(1), thresh2) != 0 {
  46491 			DoFilter2_C(tls, p+uintptr(i*stride), int32(1))
  46492 		}
  46493 		goto _1
  46494 	_1:
  46495 		;
  46496 		i = i + 1
  46497 	}
  46498 }
  46499 
  46500 func SimpleVFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46501 	var k int32
  46502 	_ = k
  46503 	k = int32(3)
  46504 	for {
  46505 		if !(k > 0) {
  46506 			break
  46507 		}
  46508 		p = p + uintptr(int32(4)*stride)
  46509 		SimpleVFilter16_C(tls, p, stride, thresh)
  46510 		goto _1
  46511 	_1:
  46512 		;
  46513 		k = k - 1
  46514 	}
  46515 }
  46516 
  46517 func SimpleHFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46518 	var k int32
  46519 	_ = k
  46520 	k = int32(3)
  46521 	for {
  46522 		if !(k > 0) {
  46523 			break
  46524 		}
  46525 		p = p + uintptr(4)
  46526 		SimpleHFilter16_C(tls, p, stride, thresh)
  46527 		goto _1
  46528 	_1:
  46529 		;
  46530 		k = k - 1
  46531 	}
  46532 }
  46533 
  46534 //------------------------------------------------------------------------------
  46535 // Complex In-loop filtering (Paragraph 15.3)
  46536 
  46537 func FilterLoop26_C(tls *libc.TLS, p uintptr, hstride int32, vstride int32, size int32, thresh int32, ithresh int32, hev_thresh int32) {
  46538 	var thresh2, v1 int32
  46539 	_, _ = thresh2, v1
  46540 	thresh2 = int32(2)*thresh + int32(1)
  46541 	for {
  46542 		v1 = size
  46543 		size = size - 1
  46544 		if !(v1 > 0) {
  46545 			break
  46546 		}
  46547 		if NeedsFilter2_C(tls, p, hstride, thresh2, ithresh) != 0 {
  46548 			if Hev(tls, p, hstride, hev_thresh) != 0 {
  46549 				DoFilter2_C(tls, p, hstride)
  46550 			} else {
  46551 				DoFilter6_C(tls, p, hstride)
  46552 			}
  46553 		}
  46554 		p = p + uintptr(vstride)
  46555 	}
  46556 }
  46557 
  46558 func FilterLoop24_C(tls *libc.TLS, p uintptr, hstride int32, vstride int32, size int32, thresh int32, ithresh int32, hev_thresh int32) {
  46559 	var thresh2, v1 int32
  46560 	_, _ = thresh2, v1
  46561 	thresh2 = int32(2)*thresh + int32(1)
  46562 	for {
  46563 		v1 = size
  46564 		size = size - 1
  46565 		if !(v1 > 0) {
  46566 			break
  46567 		}
  46568 		if NeedsFilter2_C(tls, p, hstride, thresh2, ithresh) != 0 {
  46569 			if Hev(tls, p, hstride, hev_thresh) != 0 {
  46570 				DoFilter2_C(tls, p, hstride)
  46571 			} else {
  46572 				DoFilter4_C(tls, p, hstride)
  46573 			}
  46574 		}
  46575 		p = p + uintptr(vstride)
  46576 	}
  46577 }
  46578 
  46579 // C documentation
  46580 //
  46581 //	// on macroblock edges
  46582 func VFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46583 	FilterLoop26_C(tls, p, stride, int32(1), int32(16), thresh, ithresh, hev_thresh)
  46584 }
  46585 
  46586 func HFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46587 	FilterLoop26_C(tls, p, int32(1), stride, int32(16), thresh, ithresh, hev_thresh)
  46588 }
  46589 
  46590 // C documentation
  46591 //
  46592 //	// on three inner edges
  46593 func VFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46594 	var k int32
  46595 	_ = k
  46596 	k = int32(3)
  46597 	for {
  46598 		if !(k > 0) {
  46599 			break
  46600 		}
  46601 		p = p + uintptr(int32(4)*stride)
  46602 		FilterLoop24_C(tls, p, stride, int32(1), int32(16), thresh, ithresh, hev_thresh)
  46603 		goto _1
  46604 	_1:
  46605 		;
  46606 		k = k - 1
  46607 	}
  46608 }
  46609 
  46610 func HFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46611 	var k int32
  46612 	_ = k
  46613 	k = int32(3)
  46614 	for {
  46615 		if !(k > 0) {
  46616 			break
  46617 		}
  46618 		p = p + uintptr(4)
  46619 		FilterLoop24_C(tls, p, int32(1), stride, int32(16), thresh, ithresh, hev_thresh)
  46620 		goto _1
  46621 	_1:
  46622 		;
  46623 		k = k - 1
  46624 	}
  46625 }
  46626 
  46627 // C documentation
  46628 //
  46629 //	// 8-pixels wide variant, for chroma filtering
  46630 func VFilter8_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46631 	FilterLoop26_C(tls, u, stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46632 	FilterLoop26_C(tls, v, stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46633 }
  46634 
  46635 func HFilter8_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46636 	FilterLoop26_C(tls, u, int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46637 	FilterLoop26_C(tls, v, int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46638 }
  46639 
  46640 func VFilter8i_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46641 	FilterLoop24_C(tls, u+uintptr(int32(4)*stride), stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46642 	FilterLoop24_C(tls, v+uintptr(int32(4)*stride), stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46643 }
  46644 
  46645 func HFilter8i_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46646 	FilterLoop24_C(tls, u+uintptr(4), int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46647 	FilterLoop24_C(tls, v+uintptr(4), int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46648 }
  46649 
  46650 //------------------------------------------------------------------------------
  46651 
  46652 func DitherCombine8x8_C(tls *libc.TLS, dither uintptr, dst uintptr, dst_stride int32) {
  46653 	var delta0, delta1, i, j int32
  46654 	_, _, _, _ = delta0, delta1, i, j
  46655 	j = 0
  46656 	for {
  46657 		if !(j < int32(8)) {
  46658 			break
  46659 		}
  46660 		i = 0
  46661 		for {
  46662 			if !(i < int32(8)) {
  46663 				break
  46664 			}
  46665 			delta0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dither + uintptr(i)))) - libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_DITHER_AMP_BITS)
  46666 			delta1 = (delta0 + libc.Int32FromInt32(1)<<(libc.Int32FromInt32(VP8_DITHER_DESCALE)-libc.Int32FromInt32(1))) >> int32(VP8_DITHER_DESCALE)
  46667 			**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i))))+delta1)
  46668 			goto _2
  46669 		_2:
  46670 			;
  46671 			i = i + 1
  46672 		}
  46673 		dst = dst + uintptr(dst_stride)
  46674 		dither = dither + uintptr(8)
  46675 		goto _1
  46676 	_1:
  46677 		;
  46678 		j = j + 1
  46679 	}
  46680 }
  46681 
  46682 func VP8DspInit(tls *libc.TLS) {
  46683 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  46684 		goto _1
  46685 	}
  46686 	VP8DspInit_body(tls)
  46687 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  46688 	goto _2
  46689 _2:
  46690 	;
  46691 	goto _1
  46692 _1: /**/ //
  46693 }
  46694 
  46695 var VP8DspInit_body_last_cpuinfo_used = uintptr(0)
  46696 
  46697 func init() {
  46698 	p := unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used)
  46699 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used))
  46700 }
  46701 
  46702 func VP8DspInit_body(tls *libc.TLS) {
  46703 	VP8InitClipTables(tls)
  46704 	VP8TransformWHT = __ccgo_fp(TransformWHT_C)
  46705 	VP8Transform = __ccgo_fp(TransformTwo_C)
  46706 	VP8TransformDC = __ccgo_fp(TransformDC_C)
  46707 	VP8TransformAC3 = __ccgo_fp(TransformAC3_C)
  46708 	VP8TransformUV = __ccgo_fp(TransformUV_C)
  46709 	VP8TransformDCUV = __ccgo_fp(TransformDCUV_C)
  46710 	VP8VFilter16 = __ccgo_fp(VFilter16_C)
  46711 	VP8VFilter16i = __ccgo_fp(VFilter16i_C)
  46712 	VP8HFilter16 = __ccgo_fp(HFilter16_C)
  46713 	VP8VFilter8 = __ccgo_fp(VFilter8_C)
  46714 	VP8VFilter8i = __ccgo_fp(VFilter8i_C)
  46715 	VP8SimpleVFilter16 = __ccgo_fp(SimpleVFilter16_C)
  46716 	VP8SimpleHFilter16 = __ccgo_fp(SimpleHFilter16_C)
  46717 	VP8SimpleVFilter16i = __ccgo_fp(SimpleVFilter16i_C)
  46718 	VP8SimpleHFilter16i = __ccgo_fp(SimpleHFilter16i_C)
  46719 	VP8HFilter16i = __ccgo_fp(HFilter16i_C)
  46720 	VP8HFilter8 = __ccgo_fp(HFilter8_C)
  46721 	VP8HFilter8i = __ccgo_fp(HFilter8i_C)
  46722 	VP8PredLuma4[0] = __ccgo_fp(DC4_C)
  46723 	VP8PredLuma4[int32(1)] = __ccgo_fp(TM4_C)
  46724 	VP8PredLuma4[int32(2)] = __ccgo_fp(VE4_C)
  46725 	VP8PredLuma4[int32(4)] = __ccgo_fp(RD4_C)
  46726 	VP8PredLuma4[int32(6)] = __ccgo_fp(LD4_C)
  46727 	VP8PredLuma4[int32(3)] = __ccgo_fp(HE4_C)
  46728 	VP8PredLuma4[int32(5)] = __ccgo_fp(VR4_C)
  46729 	VP8PredLuma4[int32(7)] = __ccgo_fp(VL4_C)
  46730 	VP8PredLuma4[int32(8)] = __ccgo_fp(HD4_C)
  46731 	VP8PredLuma4[int32(9)] = __ccgo_fp(HU4_C)
  46732 	VP8PredLuma16[0] = __ccgo_fp(DC16_C)
  46733 	VP8PredLuma16[int32(1)] = __ccgo_fp(TM16_C)
  46734 	VP8PredLuma16[int32(2)] = __ccgo_fp(VE16_C)
  46735 	VP8PredLuma16[int32(3)] = __ccgo_fp(HE16_C)
  46736 	VP8PredLuma16[int32(4)] = __ccgo_fp(DC16NoTop_C)
  46737 	VP8PredLuma16[int32(5)] = __ccgo_fp(DC16NoLeft_C)
  46738 	VP8PredLuma16[int32(6)] = __ccgo_fp(DC16NoTopLeft_C)
  46739 	VP8PredChroma8[0] = __ccgo_fp(DC8uv_C)
  46740 	VP8PredChroma8[int32(1)] = __ccgo_fp(TM8uv_C)
  46741 	VP8PredChroma8[int32(2)] = __ccgo_fp(VE8uv_C)
  46742 	VP8PredChroma8[int32(3)] = __ccgo_fp(HE8uv_C)
  46743 	VP8PredChroma8[int32(4)] = __ccgo_fp(DC8uvNoTop_C)
  46744 	VP8PredChroma8[int32(5)] = __ccgo_fp(DC8uvNoLeft_C)
  46745 	VP8PredChroma8[int32(6)] = __ccgo_fp(DC8uvNoTopLeft_C)
  46746 	VP8DitherCombine8x8 = __ccgo_fp(DitherCombine8x8_C)
  46747 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  46748 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  46749 	}
  46750 }
  46751 
  46752 const USE_STATIC_TABLES = 1
  46753 
  46754 // define to 0 to have run-time table initialization
  46755 
  46756 var abs0 = [511]uint8_t{
  46757 	0:   uint8(0xff),
  46758 	1:   uint8(0xfe),
  46759 	2:   uint8(0xfd),
  46760 	3:   uint8(0xfc),
  46761 	4:   uint8(0xfb),
  46762 	5:   uint8(0xfa),
  46763 	6:   uint8(0xf9),
  46764 	7:   uint8(0xf8),
  46765 	8:   uint8(0xf7),
  46766 	9:   uint8(0xf6),
  46767 	10:  uint8(0xf5),
  46768 	11:  uint8(0xf4),
  46769 	12:  uint8(0xf3),
  46770 	13:  uint8(0xf2),
  46771 	14:  uint8(0xf1),
  46772 	15:  uint8(0xf0),
  46773 	16:  uint8(0xef),
  46774 	17:  uint8(0xee),
  46775 	18:  uint8(0xed),
  46776 	19:  uint8(0xec),
  46777 	20:  uint8(0xeb),
  46778 	21:  uint8(0xea),
  46779 	22:  uint8(0xe9),
  46780 	23:  uint8(0xe8),
  46781 	24:  uint8(0xe7),
  46782 	25:  uint8(0xe6),
  46783 	26:  uint8(0xe5),
  46784 	27:  uint8(0xe4),
  46785 	28:  uint8(0xe3),
  46786 	29:  uint8(0xe2),
  46787 	30:  uint8(0xe1),
  46788 	31:  uint8(0xe0),
  46789 	32:  uint8(0xdf),
  46790 	33:  uint8(0xde),
  46791 	34:  uint8(0xdd),
  46792 	35:  uint8(0xdc),
  46793 	36:  uint8(0xdb),
  46794 	37:  uint8(0xda),
  46795 	38:  uint8(0xd9),
  46796 	39:  uint8(0xd8),
  46797 	40:  uint8(0xd7),
  46798 	41:  uint8(0xd6),
  46799 	42:  uint8(0xd5),
  46800 	43:  uint8(0xd4),
  46801 	44:  uint8(0xd3),
  46802 	45:  uint8(0xd2),
  46803 	46:  uint8(0xd1),
  46804 	47:  uint8(0xd0),
  46805 	48:  uint8(0xcf),
  46806 	49:  uint8(0xce),
  46807 	50:  uint8(0xcd),
  46808 	51:  uint8(0xcc),
  46809 	52:  uint8(0xcb),
  46810 	53:  uint8(0xca),
  46811 	54:  uint8(0xc9),
  46812 	55:  uint8(0xc8),
  46813 	56:  uint8(0xc7),
  46814 	57:  uint8(0xc6),
  46815 	58:  uint8(0xc5),
  46816 	59:  uint8(0xc4),
  46817 	60:  uint8(0xc3),
  46818 	61:  uint8(0xc2),
  46819 	62:  uint8(0xc1),
  46820 	63:  uint8(0xc0),
  46821 	64:  uint8(0xbf),
  46822 	65:  uint8(0xbe),
  46823 	66:  uint8(0xbd),
  46824 	67:  uint8(0xbc),
  46825 	68:  uint8(0xbb),
  46826 	69:  uint8(0xba),
  46827 	70:  uint8(0xb9),
  46828 	71:  uint8(0xb8),
  46829 	72:  uint8(0xb7),
  46830 	73:  uint8(0xb6),
  46831 	74:  uint8(0xb5),
  46832 	75:  uint8(0xb4),
  46833 	76:  uint8(0xb3),
  46834 	77:  uint8(0xb2),
  46835 	78:  uint8(0xb1),
  46836 	79:  uint8(0xb0),
  46837 	80:  uint8(0xaf),
  46838 	81:  uint8(0xae),
  46839 	82:  uint8(0xad),
  46840 	83:  uint8(0xac),
  46841 	84:  uint8(0xab),
  46842 	85:  uint8(0xaa),
  46843 	86:  uint8(0xa9),
  46844 	87:  uint8(0xa8),
  46845 	88:  uint8(0xa7),
  46846 	89:  uint8(0xa6),
  46847 	90:  uint8(0xa5),
  46848 	91:  uint8(0xa4),
  46849 	92:  uint8(0xa3),
  46850 	93:  uint8(0xa2),
  46851 	94:  uint8(0xa1),
  46852 	95:  uint8(0xa0),
  46853 	96:  uint8(0x9f),
  46854 	97:  uint8(0x9e),
  46855 	98:  uint8(0x9d),
  46856 	99:  uint8(0x9c),
  46857 	100: uint8(0x9b),
  46858 	101: uint8(0x9a),
  46859 	102: uint8(0x99),
  46860 	103: uint8(0x98),
  46861 	104: uint8(0x97),
  46862 	105: uint8(0x96),
  46863 	106: uint8(0x95),
  46864 	107: uint8(0x94),
  46865 	108: uint8(0x93),
  46866 	109: uint8(0x92),
  46867 	110: uint8(0x91),
  46868 	111: uint8(0x90),
  46869 	112: uint8(0x8f),
  46870 	113: uint8(0x8e),
  46871 	114: uint8(0x8d),
  46872 	115: uint8(0x8c),
  46873 	116: uint8(0x8b),
  46874 	117: uint8(0x8a),
  46875 	118: uint8(0x89),
  46876 	119: uint8(0x88),
  46877 	120: uint8(0x87),
  46878 	121: uint8(0x86),
  46879 	122: uint8(0x85),
  46880 	123: uint8(0x84),
  46881 	124: uint8(0x83),
  46882 	125: uint8(0x82),
  46883 	126: uint8(0x81),
  46884 	127: uint8(0x80),
  46885 	128: uint8(0x7f),
  46886 	129: uint8(0x7e),
  46887 	130: uint8(0x7d),
  46888 	131: uint8(0x7c),
  46889 	132: uint8(0x7b),
  46890 	133: uint8(0x7a),
  46891 	134: uint8(0x79),
  46892 	135: uint8(0x78),
  46893 	136: uint8(0x77),
  46894 	137: uint8(0x76),
  46895 	138: uint8(0x75),
  46896 	139: uint8(0x74),
  46897 	140: uint8(0x73),
  46898 	141: uint8(0x72),
  46899 	142: uint8(0x71),
  46900 	143: uint8(0x70),
  46901 	144: uint8(0x6f),
  46902 	145: uint8(0x6e),
  46903 	146: uint8(0x6d),
  46904 	147: uint8(0x6c),
  46905 	148: uint8(0x6b),
  46906 	149: uint8(0x6a),
  46907 	150: uint8(0x69),
  46908 	151: uint8(0x68),
  46909 	152: uint8(0x67),
  46910 	153: uint8(0x66),
  46911 	154: uint8(0x65),
  46912 	155: uint8(0x64),
  46913 	156: uint8(0x63),
  46914 	157: uint8(0x62),
  46915 	158: uint8(0x61),
  46916 	159: uint8(0x60),
  46917 	160: uint8(0x5f),
  46918 	161: uint8(0x5e),
  46919 	162: uint8(0x5d),
  46920 	163: uint8(0x5c),
  46921 	164: uint8(0x5b),
  46922 	165: uint8(0x5a),
  46923 	166: uint8(0x59),
  46924 	167: uint8(0x58),
  46925 	168: uint8(0x57),
  46926 	169: uint8(0x56),
  46927 	170: uint8(0x55),
  46928 	171: uint8(0x54),
  46929 	172: uint8(0x53),
  46930 	173: uint8(0x52),
  46931 	174: uint8(0x51),
  46932 	175: uint8(0x50),
  46933 	176: uint8(0x4f),
  46934 	177: uint8(0x4e),
  46935 	178: uint8(0x4d),
  46936 	179: uint8(0x4c),
  46937 	180: uint8(0x4b),
  46938 	181: uint8(0x4a),
  46939 	182: uint8(0x49),
  46940 	183: uint8(0x48),
  46941 	184: uint8(0x47),
  46942 	185: uint8(0x46),
  46943 	186: uint8(0x45),
  46944 	187: uint8(0x44),
  46945 	188: uint8(0x43),
  46946 	189: uint8(0x42),
  46947 	190: uint8(0x41),
  46948 	191: uint8(0x40),
  46949 	192: uint8(0x3f),
  46950 	193: uint8(0x3e),
  46951 	194: uint8(0x3d),
  46952 	195: uint8(0x3c),
  46953 	196: uint8(0x3b),
  46954 	197: uint8(0x3a),
  46955 	198: uint8(0x39),
  46956 	199: uint8(0x38),
  46957 	200: uint8(0x37),
  46958 	201: uint8(0x36),
  46959 	202: uint8(0x35),
  46960 	203: uint8(0x34),
  46961 	204: uint8(0x33),
  46962 	205: uint8(0x32),
  46963 	206: uint8(0x31),
  46964 	207: uint8(0x30),
  46965 	208: uint8(0x2f),
  46966 	209: uint8(0x2e),
  46967 	210: uint8(0x2d),
  46968 	211: uint8(0x2c),
  46969 	212: uint8(0x2b),
  46970 	213: uint8(0x2a),
  46971 	214: uint8(0x29),
  46972 	215: uint8(0x28),
  46973 	216: uint8(0x27),
  46974 	217: uint8(0x26),
  46975 	218: uint8(0x25),
  46976 	219: uint8(0x24),
  46977 	220: uint8(0x23),
  46978 	221: uint8(0x22),
  46979 	222: uint8(0x21),
  46980 	223: uint8(0x20),
  46981 	224: uint8(0x1f),
  46982 	225: uint8(0x1e),
  46983 	226: uint8(0x1d),
  46984 	227: uint8(0x1c),
  46985 	228: uint8(0x1b),
  46986 	229: uint8(0x1a),
  46987 	230: uint8(0x19),
  46988 	231: uint8(0x18),
  46989 	232: uint8(0x17),
  46990 	233: uint8(0x16),
  46991 	234: uint8(0x15),
  46992 	235: uint8(0x14),
  46993 	236: uint8(0x13),
  46994 	237: uint8(0x12),
  46995 	238: uint8(0x11),
  46996 	239: uint8(0x10),
  46997 	240: uint8(0x0f),
  46998 	241: uint8(0x0e),
  46999 	242: uint8(0x0d),
  47000 	243: uint8(0x0c),
  47001 	244: uint8(0x0b),
  47002 	245: uint8(0x0a),
  47003 	246: uint8(0x09),
  47004 	247: uint8(0x08),
  47005 	248: uint8(0x07),
  47006 	249: uint8(0x06),
  47007 	250: uint8(0x05),
  47008 	251: uint8(0x04),
  47009 	252: uint8(0x03),
  47010 	253: uint8(0x02),
  47011 	254: uint8(0x01),
  47012 	256: uint8(0x01),
  47013 	257: uint8(0x02),
  47014 	258: uint8(0x03),
  47015 	259: uint8(0x04),
  47016 	260: uint8(0x05),
  47017 	261: uint8(0x06),
  47018 	262: uint8(0x07),
  47019 	263: uint8(0x08),
  47020 	264: uint8(0x09),
  47021 	265: uint8(0x0a),
  47022 	266: uint8(0x0b),
  47023 	267: uint8(0x0c),
  47024 	268: uint8(0x0d),
  47025 	269: uint8(0x0e),
  47026 	270: uint8(0x0f),
  47027 	271: uint8(0x10),
  47028 	272: uint8(0x11),
  47029 	273: uint8(0x12),
  47030 	274: uint8(0x13),
  47031 	275: uint8(0x14),
  47032 	276: uint8(0x15),
  47033 	277: uint8(0x16),
  47034 	278: uint8(0x17),
  47035 	279: uint8(0x18),
  47036 	280: uint8(0x19),
  47037 	281: uint8(0x1a),
  47038 	282: uint8(0x1b),
  47039 	283: uint8(0x1c),
  47040 	284: uint8(0x1d),
  47041 	285: uint8(0x1e),
  47042 	286: uint8(0x1f),
  47043 	287: uint8(0x20),
  47044 	288: uint8(0x21),
  47045 	289: uint8(0x22),
  47046 	290: uint8(0x23),
  47047 	291: uint8(0x24),
  47048 	292: uint8(0x25),
  47049 	293: uint8(0x26),
  47050 	294: uint8(0x27),
  47051 	295: uint8(0x28),
  47052 	296: uint8(0x29),
  47053 	297: uint8(0x2a),
  47054 	298: uint8(0x2b),
  47055 	299: uint8(0x2c),
  47056 	300: uint8(0x2d),
  47057 	301: uint8(0x2e),
  47058 	302: uint8(0x2f),
  47059 	303: uint8(0x30),
  47060 	304: uint8(0x31),
  47061 	305: uint8(0x32),
  47062 	306: uint8(0x33),
  47063 	307: uint8(0x34),
  47064 	308: uint8(0x35),
  47065 	309: uint8(0x36),
  47066 	310: uint8(0x37),
  47067 	311: uint8(0x38),
  47068 	312: uint8(0x39),
  47069 	313: uint8(0x3a),
  47070 	314: uint8(0x3b),
  47071 	315: uint8(0x3c),
  47072 	316: uint8(0x3d),
  47073 	317: uint8(0x3e),
  47074 	318: uint8(0x3f),
  47075 	319: uint8(0x40),
  47076 	320: uint8(0x41),
  47077 	321: uint8(0x42),
  47078 	322: uint8(0x43),
  47079 	323: uint8(0x44),
  47080 	324: uint8(0x45),
  47081 	325: uint8(0x46),
  47082 	326: uint8(0x47),
  47083 	327: uint8(0x48),
  47084 	328: uint8(0x49),
  47085 	329: uint8(0x4a),
  47086 	330: uint8(0x4b),
  47087 	331: uint8(0x4c),
  47088 	332: uint8(0x4d),
  47089 	333: uint8(0x4e),
  47090 	334: uint8(0x4f),
  47091 	335: uint8(0x50),
  47092 	336: uint8(0x51),
  47093 	337: uint8(0x52),
  47094 	338: uint8(0x53),
  47095 	339: uint8(0x54),
  47096 	340: uint8(0x55),
  47097 	341: uint8(0x56),
  47098 	342: uint8(0x57),
  47099 	343: uint8(0x58),
  47100 	344: uint8(0x59),
  47101 	345: uint8(0x5a),
  47102 	346: uint8(0x5b),
  47103 	347: uint8(0x5c),
  47104 	348: uint8(0x5d),
  47105 	349: uint8(0x5e),
  47106 	350: uint8(0x5f),
  47107 	351: uint8(0x60),
  47108 	352: uint8(0x61),
  47109 	353: uint8(0x62),
  47110 	354: uint8(0x63),
  47111 	355: uint8(0x64),
  47112 	356: uint8(0x65),
  47113 	357: uint8(0x66),
  47114 	358: uint8(0x67),
  47115 	359: uint8(0x68),
  47116 	360: uint8(0x69),
  47117 	361: uint8(0x6a),
  47118 	362: uint8(0x6b),
  47119 	363: uint8(0x6c),
  47120 	364: uint8(0x6d),
  47121 	365: uint8(0x6e),
  47122 	366: uint8(0x6f),
  47123 	367: uint8(0x70),
  47124 	368: uint8(0x71),
  47125 	369: uint8(0x72),
  47126 	370: uint8(0x73),
  47127 	371: uint8(0x74),
  47128 	372: uint8(0x75),
  47129 	373: uint8(0x76),
  47130 	374: uint8(0x77),
  47131 	375: uint8(0x78),
  47132 	376: uint8(0x79),
  47133 	377: uint8(0x7a),
  47134 	378: uint8(0x7b),
  47135 	379: uint8(0x7c),
  47136 	380: uint8(0x7d),
  47137 	381: uint8(0x7e),
  47138 	382: uint8(0x7f),
  47139 	383: uint8(0x80),
  47140 	384: uint8(0x81),
  47141 	385: uint8(0x82),
  47142 	386: uint8(0x83),
  47143 	387: uint8(0x84),
  47144 	388: uint8(0x85),
  47145 	389: uint8(0x86),
  47146 	390: uint8(0x87),
  47147 	391: uint8(0x88),
  47148 	392: uint8(0x89),
  47149 	393: uint8(0x8a),
  47150 	394: uint8(0x8b),
  47151 	395: uint8(0x8c),
  47152 	396: uint8(0x8d),
  47153 	397: uint8(0x8e),
  47154 	398: uint8(0x8f),
  47155 	399: uint8(0x90),
  47156 	400: uint8(0x91),
  47157 	401: uint8(0x92),
  47158 	402: uint8(0x93),
  47159 	403: uint8(0x94),
  47160 	404: uint8(0x95),
  47161 	405: uint8(0x96),
  47162 	406: uint8(0x97),
  47163 	407: uint8(0x98),
  47164 	408: uint8(0x99),
  47165 	409: uint8(0x9a),
  47166 	410: uint8(0x9b),
  47167 	411: uint8(0x9c),
  47168 	412: uint8(0x9d),
  47169 	413: uint8(0x9e),
  47170 	414: uint8(0x9f),
  47171 	415: uint8(0xa0),
  47172 	416: uint8(0xa1),
  47173 	417: uint8(0xa2),
  47174 	418: uint8(0xa3),
  47175 	419: uint8(0xa4),
  47176 	420: uint8(0xa5),
  47177 	421: uint8(0xa6),
  47178 	422: uint8(0xa7),
  47179 	423: uint8(0xa8),
  47180 	424: uint8(0xa9),
  47181 	425: uint8(0xaa),
  47182 	426: uint8(0xab),
  47183 	427: uint8(0xac),
  47184 	428: uint8(0xad),
  47185 	429: uint8(0xae),
  47186 	430: uint8(0xaf),
  47187 	431: uint8(0xb0),
  47188 	432: uint8(0xb1),
  47189 	433: uint8(0xb2),
  47190 	434: uint8(0xb3),
  47191 	435: uint8(0xb4),
  47192 	436: uint8(0xb5),
  47193 	437: uint8(0xb6),
  47194 	438: uint8(0xb7),
  47195 	439: uint8(0xb8),
  47196 	440: uint8(0xb9),
  47197 	441: uint8(0xba),
  47198 	442: uint8(0xbb),
  47199 	443: uint8(0xbc),
  47200 	444: uint8(0xbd),
  47201 	445: uint8(0xbe),
  47202 	446: uint8(0xbf),
  47203 	447: uint8(0xc0),
  47204 	448: uint8(0xc1),
  47205 	449: uint8(0xc2),
  47206 	450: uint8(0xc3),
  47207 	451: uint8(0xc4),
  47208 	452: uint8(0xc5),
  47209 	453: uint8(0xc6),
  47210 	454: uint8(0xc7),
  47211 	455: uint8(0xc8),
  47212 	456: uint8(0xc9),
  47213 	457: uint8(0xca),
  47214 	458: uint8(0xcb),
  47215 	459: uint8(0xcc),
  47216 	460: uint8(0xcd),
  47217 	461: uint8(0xce),
  47218 	462: uint8(0xcf),
  47219 	463: uint8(0xd0),
  47220 	464: uint8(0xd1),
  47221 	465: uint8(0xd2),
  47222 	466: uint8(0xd3),
  47223 	467: uint8(0xd4),
  47224 	468: uint8(0xd5),
  47225 	469: uint8(0xd6),
  47226 	470: uint8(0xd7),
  47227 	471: uint8(0xd8),
  47228 	472: uint8(0xd9),
  47229 	473: uint8(0xda),
  47230 	474: uint8(0xdb),
  47231 	475: uint8(0xdc),
  47232 	476: uint8(0xdd),
  47233 	477: uint8(0xde),
  47234 	478: uint8(0xdf),
  47235 	479: uint8(0xe0),
  47236 	480: uint8(0xe1),
  47237 	481: uint8(0xe2),
  47238 	482: uint8(0xe3),
  47239 	483: uint8(0xe4),
  47240 	484: uint8(0xe5),
  47241 	485: uint8(0xe6),
  47242 	486: uint8(0xe7),
  47243 	487: uint8(0xe8),
  47244 	488: uint8(0xe9),
  47245 	489: uint8(0xea),
  47246 	490: uint8(0xeb),
  47247 	491: uint8(0xec),
  47248 	492: uint8(0xed),
  47249 	493: uint8(0xee),
  47250 	494: uint8(0xef),
  47251 	495: uint8(0xf0),
  47252 	496: uint8(0xf1),
  47253 	497: uint8(0xf2),
  47254 	498: uint8(0xf3),
  47255 	499: uint8(0xf4),
  47256 	500: uint8(0xf5),
  47257 	501: uint8(0xf6),
  47258 	502: uint8(0xf7),
  47259 	503: uint8(0xf8),
  47260 	504: uint8(0xf9),
  47261 	505: uint8(0xfa),
  47262 	506: uint8(0xfb),
  47263 	507: uint8(0xfc),
  47264 	508: uint8(0xfd),
  47265 	509: uint8(0xfe),
  47266 	510: uint8(0xff),
  47267 }
  47268 
  47269 var sclip1 = [2041]uint8_t{
  47270 	0:    uint8(0x80),
  47271 	1:    uint8(0x80),
  47272 	2:    uint8(0x80),
  47273 	3:    uint8(0x80),
  47274 	4:    uint8(0x80),
  47275 	5:    uint8(0x80),
  47276 	6:    uint8(0x80),
  47277 	7:    uint8(0x80),
  47278 	8:    uint8(0x80),
  47279 	9:    uint8(0x80),
  47280 	10:   uint8(0x80),
  47281 	11:   uint8(0x80),
  47282 	12:   uint8(0x80),
  47283 	13:   uint8(0x80),
  47284 	14:   uint8(0x80),
  47285 	15:   uint8(0x80),
  47286 	16:   uint8(0x80),
  47287 	17:   uint8(0x80),
  47288 	18:   uint8(0x80),
  47289 	19:   uint8(0x80),
  47290 	20:   uint8(0x80),
  47291 	21:   uint8(0x80),
  47292 	22:   uint8(0x80),
  47293 	23:   uint8(0x80),
  47294 	24:   uint8(0x80),
  47295 	25:   uint8(0x80),
  47296 	26:   uint8(0x80),
  47297 	27:   uint8(0x80),
  47298 	28:   uint8(0x80),
  47299 	29:   uint8(0x80),
  47300 	30:   uint8(0x80),
  47301 	31:   uint8(0x80),
  47302 	32:   uint8(0x80),
  47303 	33:   uint8(0x80),
  47304 	34:   uint8(0x80),
  47305 	35:   uint8(0x80),
  47306 	36:   uint8(0x80),
  47307 	37:   uint8(0x80),
  47308 	38:   uint8(0x80),
  47309 	39:   uint8(0x80),
  47310 	40:   uint8(0x80),
  47311 	41:   uint8(0x80),
  47312 	42:   uint8(0x80),
  47313 	43:   uint8(0x80),
  47314 	44:   uint8(0x80),
  47315 	45:   uint8(0x80),
  47316 	46:   uint8(0x80),
  47317 	47:   uint8(0x80),
  47318 	48:   uint8(0x80),
  47319 	49:   uint8(0x80),
  47320 	50:   uint8(0x80),
  47321 	51:   uint8(0x80),
  47322 	52:   uint8(0x80),
  47323 	53:   uint8(0x80),
  47324 	54:   uint8(0x80),
  47325 	55:   uint8(0x80),
  47326 	56:   uint8(0x80),
  47327 	57:   uint8(0x80),
  47328 	58:   uint8(0x80),
  47329 	59:   uint8(0x80),
  47330 	60:   uint8(0x80),
  47331 	61:   uint8(0x80),
  47332 	62:   uint8(0x80),
  47333 	63:   uint8(0x80),
  47334 	64:   uint8(0x80),
  47335 	65:   uint8(0x80),
  47336 	66:   uint8(0x80),
  47337 	67:   uint8(0x80),
  47338 	68:   uint8(0x80),
  47339 	69:   uint8(0x80),
  47340 	70:   uint8(0x80),
  47341 	71:   uint8(0x80),
  47342 	72:   uint8(0x80),
  47343 	73:   uint8(0x80),
  47344 	74:   uint8(0x80),
  47345 	75:   uint8(0x80),
  47346 	76:   uint8(0x80),
  47347 	77:   uint8(0x80),
  47348 	78:   uint8(0x80),
  47349 	79:   uint8(0x80),
  47350 	80:   uint8(0x80),
  47351 	81:   uint8(0x80),
  47352 	82:   uint8(0x80),
  47353 	83:   uint8(0x80),
  47354 	84:   uint8(0x80),
  47355 	85:   uint8(0x80),
  47356 	86:   uint8(0x80),
  47357 	87:   uint8(0x80),
  47358 	88:   uint8(0x80),
  47359 	89:   uint8(0x80),
  47360 	90:   uint8(0x80),
  47361 	91:   uint8(0x80),
  47362 	92:   uint8(0x80),
  47363 	93:   uint8(0x80),
  47364 	94:   uint8(0x80),
  47365 	95:   uint8(0x80),
  47366 	96:   uint8(0x80),
  47367 	97:   uint8(0x80),
  47368 	98:   uint8(0x80),
  47369 	99:   uint8(0x80),
  47370 	100:  uint8(0x80),
  47371 	101:  uint8(0x80),
  47372 	102:  uint8(0x80),
  47373 	103:  uint8(0x80),
  47374 	104:  uint8(0x80),
  47375 	105:  uint8(0x80),
  47376 	106:  uint8(0x80),
  47377 	107:  uint8(0x80),
  47378 	108:  uint8(0x80),
  47379 	109:  uint8(0x80),
  47380 	110:  uint8(0x80),
  47381 	111:  uint8(0x80),
  47382 	112:  uint8(0x80),
  47383 	113:  uint8(0x80),
  47384 	114:  uint8(0x80),
  47385 	115:  uint8(0x80),
  47386 	116:  uint8(0x80),
  47387 	117:  uint8(0x80),
  47388 	118:  uint8(0x80),
  47389 	119:  uint8(0x80),
  47390 	120:  uint8(0x80),
  47391 	121:  uint8(0x80),
  47392 	122:  uint8(0x80),
  47393 	123:  uint8(0x80),
  47394 	124:  uint8(0x80),
  47395 	125:  uint8(0x80),
  47396 	126:  uint8(0x80),
  47397 	127:  uint8(0x80),
  47398 	128:  uint8(0x80),
  47399 	129:  uint8(0x80),
  47400 	130:  uint8(0x80),
  47401 	131:  uint8(0x80),
  47402 	132:  uint8(0x80),
  47403 	133:  uint8(0x80),
  47404 	134:  uint8(0x80),
  47405 	135:  uint8(0x80),
  47406 	136:  uint8(0x80),
  47407 	137:  uint8(0x80),
  47408 	138:  uint8(0x80),
  47409 	139:  uint8(0x80),
  47410 	140:  uint8(0x80),
  47411 	141:  uint8(0x80),
  47412 	142:  uint8(0x80),
  47413 	143:  uint8(0x80),
  47414 	144:  uint8(0x80),
  47415 	145:  uint8(0x80),
  47416 	146:  uint8(0x80),
  47417 	147:  uint8(0x80),
  47418 	148:  uint8(0x80),
  47419 	149:  uint8(0x80),
  47420 	150:  uint8(0x80),
  47421 	151:  uint8(0x80),
  47422 	152:  uint8(0x80),
  47423 	153:  uint8(0x80),
  47424 	154:  uint8(0x80),
  47425 	155:  uint8(0x80),
  47426 	156:  uint8(0x80),
  47427 	157:  uint8(0x80),
  47428 	158:  uint8(0x80),
  47429 	159:  uint8(0x80),
  47430 	160:  uint8(0x80),
  47431 	161:  uint8(0x80),
  47432 	162:  uint8(0x80),
  47433 	163:  uint8(0x80),
  47434 	164:  uint8(0x80),
  47435 	165:  uint8(0x80),
  47436 	166:  uint8(0x80),
  47437 	167:  uint8(0x80),
  47438 	168:  uint8(0x80),
  47439 	169:  uint8(0x80),
  47440 	170:  uint8(0x80),
  47441 	171:  uint8(0x80),
  47442 	172:  uint8(0x80),
  47443 	173:  uint8(0x80),
  47444 	174:  uint8(0x80),
  47445 	175:  uint8(0x80),
  47446 	176:  uint8(0x80),
  47447 	177:  uint8(0x80),
  47448 	178:  uint8(0x80),
  47449 	179:  uint8(0x80),
  47450 	180:  uint8(0x80),
  47451 	181:  uint8(0x80),
  47452 	182:  uint8(0x80),
  47453 	183:  uint8(0x80),
  47454 	184:  uint8(0x80),
  47455 	185:  uint8(0x80),
  47456 	186:  uint8(0x80),
  47457 	187:  uint8(0x80),
  47458 	188:  uint8(0x80),
  47459 	189:  uint8(0x80),
  47460 	190:  uint8(0x80),
  47461 	191:  uint8(0x80),
  47462 	192:  uint8(0x80),
  47463 	193:  uint8(0x80),
  47464 	194:  uint8(0x80),
  47465 	195:  uint8(0x80),
  47466 	196:  uint8(0x80),
  47467 	197:  uint8(0x80),
  47468 	198:  uint8(0x80),
  47469 	199:  uint8(0x80),
  47470 	200:  uint8(0x80),
  47471 	201:  uint8(0x80),
  47472 	202:  uint8(0x80),
  47473 	203:  uint8(0x80),
  47474 	204:  uint8(0x80),
  47475 	205:  uint8(0x80),
  47476 	206:  uint8(0x80),
  47477 	207:  uint8(0x80),
  47478 	208:  uint8(0x80),
  47479 	209:  uint8(0x80),
  47480 	210:  uint8(0x80),
  47481 	211:  uint8(0x80),
  47482 	212:  uint8(0x80),
  47483 	213:  uint8(0x80),
  47484 	214:  uint8(0x80),
  47485 	215:  uint8(0x80),
  47486 	216:  uint8(0x80),
  47487 	217:  uint8(0x80),
  47488 	218:  uint8(0x80),
  47489 	219:  uint8(0x80),
  47490 	220:  uint8(0x80),
  47491 	221:  uint8(0x80),
  47492 	222:  uint8(0x80),
  47493 	223:  uint8(0x80),
  47494 	224:  uint8(0x80),
  47495 	225:  uint8(0x80),
  47496 	226:  uint8(0x80),
  47497 	227:  uint8(0x80),
  47498 	228:  uint8(0x80),
  47499 	229:  uint8(0x80),
  47500 	230:  uint8(0x80),
  47501 	231:  uint8(0x80),
  47502 	232:  uint8(0x80),
  47503 	233:  uint8(0x80),
  47504 	234:  uint8(0x80),
  47505 	235:  uint8(0x80),
  47506 	236:  uint8(0x80),
  47507 	237:  uint8(0x80),
  47508 	238:  uint8(0x80),
  47509 	239:  uint8(0x80),
  47510 	240:  uint8(0x80),
  47511 	241:  uint8(0x80),
  47512 	242:  uint8(0x80),
  47513 	243:  uint8(0x80),
  47514 	244:  uint8(0x80),
  47515 	245:  uint8(0x80),
  47516 	246:  uint8(0x80),
  47517 	247:  uint8(0x80),
  47518 	248:  uint8(0x80),
  47519 	249:  uint8(0x80),
  47520 	250:  uint8(0x80),
  47521 	251:  uint8(0x80),
  47522 	252:  uint8(0x80),
  47523 	253:  uint8(0x80),
  47524 	254:  uint8(0x80),
  47525 	255:  uint8(0x80),
  47526 	256:  uint8(0x80),
  47527 	257:  uint8(0x80),
  47528 	258:  uint8(0x80),
  47529 	259:  uint8(0x80),
  47530 	260:  uint8(0x80),
  47531 	261:  uint8(0x80),
  47532 	262:  uint8(0x80),
  47533 	263:  uint8(0x80),
  47534 	264:  uint8(0x80),
  47535 	265:  uint8(0x80),
  47536 	266:  uint8(0x80),
  47537 	267:  uint8(0x80),
  47538 	268:  uint8(0x80),
  47539 	269:  uint8(0x80),
  47540 	270:  uint8(0x80),
  47541 	271:  uint8(0x80),
  47542 	272:  uint8(0x80),
  47543 	273:  uint8(0x80),
  47544 	274:  uint8(0x80),
  47545 	275:  uint8(0x80),
  47546 	276:  uint8(0x80),
  47547 	277:  uint8(0x80),
  47548 	278:  uint8(0x80),
  47549 	279:  uint8(0x80),
  47550 	280:  uint8(0x80),
  47551 	281:  uint8(0x80),
  47552 	282:  uint8(0x80),
  47553 	283:  uint8(0x80),
  47554 	284:  uint8(0x80),
  47555 	285:  uint8(0x80),
  47556 	286:  uint8(0x80),
  47557 	287:  uint8(0x80),
  47558 	288:  uint8(0x80),
  47559 	289:  uint8(0x80),
  47560 	290:  uint8(0x80),
  47561 	291:  uint8(0x80),
  47562 	292:  uint8(0x80),
  47563 	293:  uint8(0x80),
  47564 	294:  uint8(0x80),
  47565 	295:  uint8(0x80),
  47566 	296:  uint8(0x80),
  47567 	297:  uint8(0x80),
  47568 	298:  uint8(0x80),
  47569 	299:  uint8(0x80),
  47570 	300:  uint8(0x80),
  47571 	301:  uint8(0x80),
  47572 	302:  uint8(0x80),
  47573 	303:  uint8(0x80),
  47574 	304:  uint8(0x80),
  47575 	305:  uint8(0x80),
  47576 	306:  uint8(0x80),
  47577 	307:  uint8(0x80),
  47578 	308:  uint8(0x80),
  47579 	309:  uint8(0x80),
  47580 	310:  uint8(0x80),
  47581 	311:  uint8(0x80),
  47582 	312:  uint8(0x80),
  47583 	313:  uint8(0x80),
  47584 	314:  uint8(0x80),
  47585 	315:  uint8(0x80),
  47586 	316:  uint8(0x80),
  47587 	317:  uint8(0x80),
  47588 	318:  uint8(0x80),
  47589 	319:  uint8(0x80),
  47590 	320:  uint8(0x80),
  47591 	321:  uint8(0x80),
  47592 	322:  uint8(0x80),
  47593 	323:  uint8(0x80),
  47594 	324:  uint8(0x80),
  47595 	325:  uint8(0x80),
  47596 	326:  uint8(0x80),
  47597 	327:  uint8(0x80),
  47598 	328:  uint8(0x80),
  47599 	329:  uint8(0x80),
  47600 	330:  uint8(0x80),
  47601 	331:  uint8(0x80),
  47602 	332:  uint8(0x80),
  47603 	333:  uint8(0x80),
  47604 	334:  uint8(0x80),
  47605 	335:  uint8(0x80),
  47606 	336:  uint8(0x80),
  47607 	337:  uint8(0x80),
  47608 	338:  uint8(0x80),
  47609 	339:  uint8(0x80),
  47610 	340:  uint8(0x80),
  47611 	341:  uint8(0x80),
  47612 	342:  uint8(0x80),
  47613 	343:  uint8(0x80),
  47614 	344:  uint8(0x80),
  47615 	345:  uint8(0x80),
  47616 	346:  uint8(0x80),
  47617 	347:  uint8(0x80),
  47618 	348:  uint8(0x80),
  47619 	349:  uint8(0x80),
  47620 	350:  uint8(0x80),
  47621 	351:  uint8(0x80),
  47622 	352:  uint8(0x80),
  47623 	353:  uint8(0x80),
  47624 	354:  uint8(0x80),
  47625 	355:  uint8(0x80),
  47626 	356:  uint8(0x80),
  47627 	357:  uint8(0x80),
  47628 	358:  uint8(0x80),
  47629 	359:  uint8(0x80),
  47630 	360:  uint8(0x80),
  47631 	361:  uint8(0x80),
  47632 	362:  uint8(0x80),
  47633 	363:  uint8(0x80),
  47634 	364:  uint8(0x80),
  47635 	365:  uint8(0x80),
  47636 	366:  uint8(0x80),
  47637 	367:  uint8(0x80),
  47638 	368:  uint8(0x80),
  47639 	369:  uint8(0x80),
  47640 	370:  uint8(0x80),
  47641 	371:  uint8(0x80),
  47642 	372:  uint8(0x80),
  47643 	373:  uint8(0x80),
  47644 	374:  uint8(0x80),
  47645 	375:  uint8(0x80),
  47646 	376:  uint8(0x80),
  47647 	377:  uint8(0x80),
  47648 	378:  uint8(0x80),
  47649 	379:  uint8(0x80),
  47650 	380:  uint8(0x80),
  47651 	381:  uint8(0x80),
  47652 	382:  uint8(0x80),
  47653 	383:  uint8(0x80),
  47654 	384:  uint8(0x80),
  47655 	385:  uint8(0x80),
  47656 	386:  uint8(0x80),
  47657 	387:  uint8(0x80),
  47658 	388:  uint8(0x80),
  47659 	389:  uint8(0x80),
  47660 	390:  uint8(0x80),
  47661 	391:  uint8(0x80),
  47662 	392:  uint8(0x80),
  47663 	393:  uint8(0x80),
  47664 	394:  uint8(0x80),
  47665 	395:  uint8(0x80),
  47666 	396:  uint8(0x80),
  47667 	397:  uint8(0x80),
  47668 	398:  uint8(0x80),
  47669 	399:  uint8(0x80),
  47670 	400:  uint8(0x80),
  47671 	401:  uint8(0x80),
  47672 	402:  uint8(0x80),
  47673 	403:  uint8(0x80),
  47674 	404:  uint8(0x80),
  47675 	405:  uint8(0x80),
  47676 	406:  uint8(0x80),
  47677 	407:  uint8(0x80),
  47678 	408:  uint8(0x80),
  47679 	409:  uint8(0x80),
  47680 	410:  uint8(0x80),
  47681 	411:  uint8(0x80),
  47682 	412:  uint8(0x80),
  47683 	413:  uint8(0x80),
  47684 	414:  uint8(0x80),
  47685 	415:  uint8(0x80),
  47686 	416:  uint8(0x80),
  47687 	417:  uint8(0x80),
  47688 	418:  uint8(0x80),
  47689 	419:  uint8(0x80),
  47690 	420:  uint8(0x80),
  47691 	421:  uint8(0x80),
  47692 	422:  uint8(0x80),
  47693 	423:  uint8(0x80),
  47694 	424:  uint8(0x80),
  47695 	425:  uint8(0x80),
  47696 	426:  uint8(0x80),
  47697 	427:  uint8(0x80),
  47698 	428:  uint8(0x80),
  47699 	429:  uint8(0x80),
  47700 	430:  uint8(0x80),
  47701 	431:  uint8(0x80),
  47702 	432:  uint8(0x80),
  47703 	433:  uint8(0x80),
  47704 	434:  uint8(0x80),
  47705 	435:  uint8(0x80),
  47706 	436:  uint8(0x80),
  47707 	437:  uint8(0x80),
  47708 	438:  uint8(0x80),
  47709 	439:  uint8(0x80),
  47710 	440:  uint8(0x80),
  47711 	441:  uint8(0x80),
  47712 	442:  uint8(0x80),
  47713 	443:  uint8(0x80),
  47714 	444:  uint8(0x80),
  47715 	445:  uint8(0x80),
  47716 	446:  uint8(0x80),
  47717 	447:  uint8(0x80),
  47718 	448:  uint8(0x80),
  47719 	449:  uint8(0x80),
  47720 	450:  uint8(0x80),
  47721 	451:  uint8(0x80),
  47722 	452:  uint8(0x80),
  47723 	453:  uint8(0x80),
  47724 	454:  uint8(0x80),
  47725 	455:  uint8(0x80),
  47726 	456:  uint8(0x80),
  47727 	457:  uint8(0x80),
  47728 	458:  uint8(0x80),
  47729 	459:  uint8(0x80),
  47730 	460:  uint8(0x80),
  47731 	461:  uint8(0x80),
  47732 	462:  uint8(0x80),
  47733 	463:  uint8(0x80),
  47734 	464:  uint8(0x80),
  47735 	465:  uint8(0x80),
  47736 	466:  uint8(0x80),
  47737 	467:  uint8(0x80),
  47738 	468:  uint8(0x80),
  47739 	469:  uint8(0x80),
  47740 	470:  uint8(0x80),
  47741 	471:  uint8(0x80),
  47742 	472:  uint8(0x80),
  47743 	473:  uint8(0x80),
  47744 	474:  uint8(0x80),
  47745 	475:  uint8(0x80),
  47746 	476:  uint8(0x80),
  47747 	477:  uint8(0x80),
  47748 	478:  uint8(0x80),
  47749 	479:  uint8(0x80),
  47750 	480:  uint8(0x80),
  47751 	481:  uint8(0x80),
  47752 	482:  uint8(0x80),
  47753 	483:  uint8(0x80),
  47754 	484:  uint8(0x80),
  47755 	485:  uint8(0x80),
  47756 	486:  uint8(0x80),
  47757 	487:  uint8(0x80),
  47758 	488:  uint8(0x80),
  47759 	489:  uint8(0x80),
  47760 	490:  uint8(0x80),
  47761 	491:  uint8(0x80),
  47762 	492:  uint8(0x80),
  47763 	493:  uint8(0x80),
  47764 	494:  uint8(0x80),
  47765 	495:  uint8(0x80),
  47766 	496:  uint8(0x80),
  47767 	497:  uint8(0x80),
  47768 	498:  uint8(0x80),
  47769 	499:  uint8(0x80),
  47770 	500:  uint8(0x80),
  47771 	501:  uint8(0x80),
  47772 	502:  uint8(0x80),
  47773 	503:  uint8(0x80),
  47774 	504:  uint8(0x80),
  47775 	505:  uint8(0x80),
  47776 	506:  uint8(0x80),
  47777 	507:  uint8(0x80),
  47778 	508:  uint8(0x80),
  47779 	509:  uint8(0x80),
  47780 	510:  uint8(0x80),
  47781 	511:  uint8(0x80),
  47782 	512:  uint8(0x80),
  47783 	513:  uint8(0x80),
  47784 	514:  uint8(0x80),
  47785 	515:  uint8(0x80),
  47786 	516:  uint8(0x80),
  47787 	517:  uint8(0x80),
  47788 	518:  uint8(0x80),
  47789 	519:  uint8(0x80),
  47790 	520:  uint8(0x80),
  47791 	521:  uint8(0x80),
  47792 	522:  uint8(0x80),
  47793 	523:  uint8(0x80),
  47794 	524:  uint8(0x80),
  47795 	525:  uint8(0x80),
  47796 	526:  uint8(0x80),
  47797 	527:  uint8(0x80),
  47798 	528:  uint8(0x80),
  47799 	529:  uint8(0x80),
  47800 	530:  uint8(0x80),
  47801 	531:  uint8(0x80),
  47802 	532:  uint8(0x80),
  47803 	533:  uint8(0x80),
  47804 	534:  uint8(0x80),
  47805 	535:  uint8(0x80),
  47806 	536:  uint8(0x80),
  47807 	537:  uint8(0x80),
  47808 	538:  uint8(0x80),
  47809 	539:  uint8(0x80),
  47810 	540:  uint8(0x80),
  47811 	541:  uint8(0x80),
  47812 	542:  uint8(0x80),
  47813 	543:  uint8(0x80),
  47814 	544:  uint8(0x80),
  47815 	545:  uint8(0x80),
  47816 	546:  uint8(0x80),
  47817 	547:  uint8(0x80),
  47818 	548:  uint8(0x80),
  47819 	549:  uint8(0x80),
  47820 	550:  uint8(0x80),
  47821 	551:  uint8(0x80),
  47822 	552:  uint8(0x80),
  47823 	553:  uint8(0x80),
  47824 	554:  uint8(0x80),
  47825 	555:  uint8(0x80),
  47826 	556:  uint8(0x80),
  47827 	557:  uint8(0x80),
  47828 	558:  uint8(0x80),
  47829 	559:  uint8(0x80),
  47830 	560:  uint8(0x80),
  47831 	561:  uint8(0x80),
  47832 	562:  uint8(0x80),
  47833 	563:  uint8(0x80),
  47834 	564:  uint8(0x80),
  47835 	565:  uint8(0x80),
  47836 	566:  uint8(0x80),
  47837 	567:  uint8(0x80),
  47838 	568:  uint8(0x80),
  47839 	569:  uint8(0x80),
  47840 	570:  uint8(0x80),
  47841 	571:  uint8(0x80),
  47842 	572:  uint8(0x80),
  47843 	573:  uint8(0x80),
  47844 	574:  uint8(0x80),
  47845 	575:  uint8(0x80),
  47846 	576:  uint8(0x80),
  47847 	577:  uint8(0x80),
  47848 	578:  uint8(0x80),
  47849 	579:  uint8(0x80),
  47850 	580:  uint8(0x80),
  47851 	581:  uint8(0x80),
  47852 	582:  uint8(0x80),
  47853 	583:  uint8(0x80),
  47854 	584:  uint8(0x80),
  47855 	585:  uint8(0x80),
  47856 	586:  uint8(0x80),
  47857 	587:  uint8(0x80),
  47858 	588:  uint8(0x80),
  47859 	589:  uint8(0x80),
  47860 	590:  uint8(0x80),
  47861 	591:  uint8(0x80),
  47862 	592:  uint8(0x80),
  47863 	593:  uint8(0x80),
  47864 	594:  uint8(0x80),
  47865 	595:  uint8(0x80),
  47866 	596:  uint8(0x80),
  47867 	597:  uint8(0x80),
  47868 	598:  uint8(0x80),
  47869 	599:  uint8(0x80),
  47870 	600:  uint8(0x80),
  47871 	601:  uint8(0x80),
  47872 	602:  uint8(0x80),
  47873 	603:  uint8(0x80),
  47874 	604:  uint8(0x80),
  47875 	605:  uint8(0x80),
  47876 	606:  uint8(0x80),
  47877 	607:  uint8(0x80),
  47878 	608:  uint8(0x80),
  47879 	609:  uint8(0x80),
  47880 	610:  uint8(0x80),
  47881 	611:  uint8(0x80),
  47882 	612:  uint8(0x80),
  47883 	613:  uint8(0x80),
  47884 	614:  uint8(0x80),
  47885 	615:  uint8(0x80),
  47886 	616:  uint8(0x80),
  47887 	617:  uint8(0x80),
  47888 	618:  uint8(0x80),
  47889 	619:  uint8(0x80),
  47890 	620:  uint8(0x80),
  47891 	621:  uint8(0x80),
  47892 	622:  uint8(0x80),
  47893 	623:  uint8(0x80),
  47894 	624:  uint8(0x80),
  47895 	625:  uint8(0x80),
  47896 	626:  uint8(0x80),
  47897 	627:  uint8(0x80),
  47898 	628:  uint8(0x80),
  47899 	629:  uint8(0x80),
  47900 	630:  uint8(0x80),
  47901 	631:  uint8(0x80),
  47902 	632:  uint8(0x80),
  47903 	633:  uint8(0x80),
  47904 	634:  uint8(0x80),
  47905 	635:  uint8(0x80),
  47906 	636:  uint8(0x80),
  47907 	637:  uint8(0x80),
  47908 	638:  uint8(0x80),
  47909 	639:  uint8(0x80),
  47910 	640:  uint8(0x80),
  47911 	641:  uint8(0x80),
  47912 	642:  uint8(0x80),
  47913 	643:  uint8(0x80),
  47914 	644:  uint8(0x80),
  47915 	645:  uint8(0x80),
  47916 	646:  uint8(0x80),
  47917 	647:  uint8(0x80),
  47918 	648:  uint8(0x80),
  47919 	649:  uint8(0x80),
  47920 	650:  uint8(0x80),
  47921 	651:  uint8(0x80),
  47922 	652:  uint8(0x80),
  47923 	653:  uint8(0x80),
  47924 	654:  uint8(0x80),
  47925 	655:  uint8(0x80),
  47926 	656:  uint8(0x80),
  47927 	657:  uint8(0x80),
  47928 	658:  uint8(0x80),
  47929 	659:  uint8(0x80),
  47930 	660:  uint8(0x80),
  47931 	661:  uint8(0x80),
  47932 	662:  uint8(0x80),
  47933 	663:  uint8(0x80),
  47934 	664:  uint8(0x80),
  47935 	665:  uint8(0x80),
  47936 	666:  uint8(0x80),
  47937 	667:  uint8(0x80),
  47938 	668:  uint8(0x80),
  47939 	669:  uint8(0x80),
  47940 	670:  uint8(0x80),
  47941 	671:  uint8(0x80),
  47942 	672:  uint8(0x80),
  47943 	673:  uint8(0x80),
  47944 	674:  uint8(0x80),
  47945 	675:  uint8(0x80),
  47946 	676:  uint8(0x80),
  47947 	677:  uint8(0x80),
  47948 	678:  uint8(0x80),
  47949 	679:  uint8(0x80),
  47950 	680:  uint8(0x80),
  47951 	681:  uint8(0x80),
  47952 	682:  uint8(0x80),
  47953 	683:  uint8(0x80),
  47954 	684:  uint8(0x80),
  47955 	685:  uint8(0x80),
  47956 	686:  uint8(0x80),
  47957 	687:  uint8(0x80),
  47958 	688:  uint8(0x80),
  47959 	689:  uint8(0x80),
  47960 	690:  uint8(0x80),
  47961 	691:  uint8(0x80),
  47962 	692:  uint8(0x80),
  47963 	693:  uint8(0x80),
  47964 	694:  uint8(0x80),
  47965 	695:  uint8(0x80),
  47966 	696:  uint8(0x80),
  47967 	697:  uint8(0x80),
  47968 	698:  uint8(0x80),
  47969 	699:  uint8(0x80),
  47970 	700:  uint8(0x80),
  47971 	701:  uint8(0x80),
  47972 	702:  uint8(0x80),
  47973 	703:  uint8(0x80),
  47974 	704:  uint8(0x80),
  47975 	705:  uint8(0x80),
  47976 	706:  uint8(0x80),
  47977 	707:  uint8(0x80),
  47978 	708:  uint8(0x80),
  47979 	709:  uint8(0x80),
  47980 	710:  uint8(0x80),
  47981 	711:  uint8(0x80),
  47982 	712:  uint8(0x80),
  47983 	713:  uint8(0x80),
  47984 	714:  uint8(0x80),
  47985 	715:  uint8(0x80),
  47986 	716:  uint8(0x80),
  47987 	717:  uint8(0x80),
  47988 	718:  uint8(0x80),
  47989 	719:  uint8(0x80),
  47990 	720:  uint8(0x80),
  47991 	721:  uint8(0x80),
  47992 	722:  uint8(0x80),
  47993 	723:  uint8(0x80),
  47994 	724:  uint8(0x80),
  47995 	725:  uint8(0x80),
  47996 	726:  uint8(0x80),
  47997 	727:  uint8(0x80),
  47998 	728:  uint8(0x80),
  47999 	729:  uint8(0x80),
  48000 	730:  uint8(0x80),
  48001 	731:  uint8(0x80),
  48002 	732:  uint8(0x80),
  48003 	733:  uint8(0x80),
  48004 	734:  uint8(0x80),
  48005 	735:  uint8(0x80),
  48006 	736:  uint8(0x80),
  48007 	737:  uint8(0x80),
  48008 	738:  uint8(0x80),
  48009 	739:  uint8(0x80),
  48010 	740:  uint8(0x80),
  48011 	741:  uint8(0x80),
  48012 	742:  uint8(0x80),
  48013 	743:  uint8(0x80),
  48014 	744:  uint8(0x80),
  48015 	745:  uint8(0x80),
  48016 	746:  uint8(0x80),
  48017 	747:  uint8(0x80),
  48018 	748:  uint8(0x80),
  48019 	749:  uint8(0x80),
  48020 	750:  uint8(0x80),
  48021 	751:  uint8(0x80),
  48022 	752:  uint8(0x80),
  48023 	753:  uint8(0x80),
  48024 	754:  uint8(0x80),
  48025 	755:  uint8(0x80),
  48026 	756:  uint8(0x80),
  48027 	757:  uint8(0x80),
  48028 	758:  uint8(0x80),
  48029 	759:  uint8(0x80),
  48030 	760:  uint8(0x80),
  48031 	761:  uint8(0x80),
  48032 	762:  uint8(0x80),
  48033 	763:  uint8(0x80),
  48034 	764:  uint8(0x80),
  48035 	765:  uint8(0x80),
  48036 	766:  uint8(0x80),
  48037 	767:  uint8(0x80),
  48038 	768:  uint8(0x80),
  48039 	769:  uint8(0x80),
  48040 	770:  uint8(0x80),
  48041 	771:  uint8(0x80),
  48042 	772:  uint8(0x80),
  48043 	773:  uint8(0x80),
  48044 	774:  uint8(0x80),
  48045 	775:  uint8(0x80),
  48046 	776:  uint8(0x80),
  48047 	777:  uint8(0x80),
  48048 	778:  uint8(0x80),
  48049 	779:  uint8(0x80),
  48050 	780:  uint8(0x80),
  48051 	781:  uint8(0x80),
  48052 	782:  uint8(0x80),
  48053 	783:  uint8(0x80),
  48054 	784:  uint8(0x80),
  48055 	785:  uint8(0x80),
  48056 	786:  uint8(0x80),
  48057 	787:  uint8(0x80),
  48058 	788:  uint8(0x80),
  48059 	789:  uint8(0x80),
  48060 	790:  uint8(0x80),
  48061 	791:  uint8(0x80),
  48062 	792:  uint8(0x80),
  48063 	793:  uint8(0x80),
  48064 	794:  uint8(0x80),
  48065 	795:  uint8(0x80),
  48066 	796:  uint8(0x80),
  48067 	797:  uint8(0x80),
  48068 	798:  uint8(0x80),
  48069 	799:  uint8(0x80),
  48070 	800:  uint8(0x80),
  48071 	801:  uint8(0x80),
  48072 	802:  uint8(0x80),
  48073 	803:  uint8(0x80),
  48074 	804:  uint8(0x80),
  48075 	805:  uint8(0x80),
  48076 	806:  uint8(0x80),
  48077 	807:  uint8(0x80),
  48078 	808:  uint8(0x80),
  48079 	809:  uint8(0x80),
  48080 	810:  uint8(0x80),
  48081 	811:  uint8(0x80),
  48082 	812:  uint8(0x80),
  48083 	813:  uint8(0x80),
  48084 	814:  uint8(0x80),
  48085 	815:  uint8(0x80),
  48086 	816:  uint8(0x80),
  48087 	817:  uint8(0x80),
  48088 	818:  uint8(0x80),
  48089 	819:  uint8(0x80),
  48090 	820:  uint8(0x80),
  48091 	821:  uint8(0x80),
  48092 	822:  uint8(0x80),
  48093 	823:  uint8(0x80),
  48094 	824:  uint8(0x80),
  48095 	825:  uint8(0x80),
  48096 	826:  uint8(0x80),
  48097 	827:  uint8(0x80),
  48098 	828:  uint8(0x80),
  48099 	829:  uint8(0x80),
  48100 	830:  uint8(0x80),
  48101 	831:  uint8(0x80),
  48102 	832:  uint8(0x80),
  48103 	833:  uint8(0x80),
  48104 	834:  uint8(0x80),
  48105 	835:  uint8(0x80),
  48106 	836:  uint8(0x80),
  48107 	837:  uint8(0x80),
  48108 	838:  uint8(0x80),
  48109 	839:  uint8(0x80),
  48110 	840:  uint8(0x80),
  48111 	841:  uint8(0x80),
  48112 	842:  uint8(0x80),
  48113 	843:  uint8(0x80),
  48114 	844:  uint8(0x80),
  48115 	845:  uint8(0x80),
  48116 	846:  uint8(0x80),
  48117 	847:  uint8(0x80),
  48118 	848:  uint8(0x80),
  48119 	849:  uint8(0x80),
  48120 	850:  uint8(0x80),
  48121 	851:  uint8(0x80),
  48122 	852:  uint8(0x80),
  48123 	853:  uint8(0x80),
  48124 	854:  uint8(0x80),
  48125 	855:  uint8(0x80),
  48126 	856:  uint8(0x80),
  48127 	857:  uint8(0x80),
  48128 	858:  uint8(0x80),
  48129 	859:  uint8(0x80),
  48130 	860:  uint8(0x80),
  48131 	861:  uint8(0x80),
  48132 	862:  uint8(0x80),
  48133 	863:  uint8(0x80),
  48134 	864:  uint8(0x80),
  48135 	865:  uint8(0x80),
  48136 	866:  uint8(0x80),
  48137 	867:  uint8(0x80),
  48138 	868:  uint8(0x80),
  48139 	869:  uint8(0x80),
  48140 	870:  uint8(0x80),
  48141 	871:  uint8(0x80),
  48142 	872:  uint8(0x80),
  48143 	873:  uint8(0x80),
  48144 	874:  uint8(0x80),
  48145 	875:  uint8(0x80),
  48146 	876:  uint8(0x80),
  48147 	877:  uint8(0x80),
  48148 	878:  uint8(0x80),
  48149 	879:  uint8(0x80),
  48150 	880:  uint8(0x80),
  48151 	881:  uint8(0x80),
  48152 	882:  uint8(0x80),
  48153 	883:  uint8(0x80),
  48154 	884:  uint8(0x80),
  48155 	885:  uint8(0x80),
  48156 	886:  uint8(0x80),
  48157 	887:  uint8(0x80),
  48158 	888:  uint8(0x80),
  48159 	889:  uint8(0x80),
  48160 	890:  uint8(0x80),
  48161 	891:  uint8(0x80),
  48162 	892:  uint8(0x80),
  48163 	893:  uint8(0x81),
  48164 	894:  uint8(0x82),
  48165 	895:  uint8(0x83),
  48166 	896:  uint8(0x84),
  48167 	897:  uint8(0x85),
  48168 	898:  uint8(0x86),
  48169 	899:  uint8(0x87),
  48170 	900:  uint8(0x88),
  48171 	901:  uint8(0x89),
  48172 	902:  uint8(0x8a),
  48173 	903:  uint8(0x8b),
  48174 	904:  uint8(0x8c),
  48175 	905:  uint8(0x8d),
  48176 	906:  uint8(0x8e),
  48177 	907:  uint8(0x8f),
  48178 	908:  uint8(0x90),
  48179 	909:  uint8(0x91),
  48180 	910:  uint8(0x92),
  48181 	911:  uint8(0x93),
  48182 	912:  uint8(0x94),
  48183 	913:  uint8(0x95),
  48184 	914:  uint8(0x96),
  48185 	915:  uint8(0x97),
  48186 	916:  uint8(0x98),
  48187 	917:  uint8(0x99),
  48188 	918:  uint8(0x9a),
  48189 	919:  uint8(0x9b),
  48190 	920:  uint8(0x9c),
  48191 	921:  uint8(0x9d),
  48192 	922:  uint8(0x9e),
  48193 	923:  uint8(0x9f),
  48194 	924:  uint8(0xa0),
  48195 	925:  uint8(0xa1),
  48196 	926:  uint8(0xa2),
  48197 	927:  uint8(0xa3),
  48198 	928:  uint8(0xa4),
  48199 	929:  uint8(0xa5),
  48200 	930:  uint8(0xa6),
  48201 	931:  uint8(0xa7),
  48202 	932:  uint8(0xa8),
  48203 	933:  uint8(0xa9),
  48204 	934:  uint8(0xaa),
  48205 	935:  uint8(0xab),
  48206 	936:  uint8(0xac),
  48207 	937:  uint8(0xad),
  48208 	938:  uint8(0xae),
  48209 	939:  uint8(0xaf),
  48210 	940:  uint8(0xb0),
  48211 	941:  uint8(0xb1),
  48212 	942:  uint8(0xb2),
  48213 	943:  uint8(0xb3),
  48214 	944:  uint8(0xb4),
  48215 	945:  uint8(0xb5),
  48216 	946:  uint8(0xb6),
  48217 	947:  uint8(0xb7),
  48218 	948:  uint8(0xb8),
  48219 	949:  uint8(0xb9),
  48220 	950:  uint8(0xba),
  48221 	951:  uint8(0xbb),
  48222 	952:  uint8(0xbc),
  48223 	953:  uint8(0xbd),
  48224 	954:  uint8(0xbe),
  48225 	955:  uint8(0xbf),
  48226 	956:  uint8(0xc0),
  48227 	957:  uint8(0xc1),
  48228 	958:  uint8(0xc2),
  48229 	959:  uint8(0xc3),
  48230 	960:  uint8(0xc4),
  48231 	961:  uint8(0xc5),
  48232 	962:  uint8(0xc6),
  48233 	963:  uint8(0xc7),
  48234 	964:  uint8(0xc8),
  48235 	965:  uint8(0xc9),
  48236 	966:  uint8(0xca),
  48237 	967:  uint8(0xcb),
  48238 	968:  uint8(0xcc),
  48239 	969:  uint8(0xcd),
  48240 	970:  uint8(0xce),
  48241 	971:  uint8(0xcf),
  48242 	972:  uint8(0xd0),
  48243 	973:  uint8(0xd1),
  48244 	974:  uint8(0xd2),
  48245 	975:  uint8(0xd3),
  48246 	976:  uint8(0xd4),
  48247 	977:  uint8(0xd5),
  48248 	978:  uint8(0xd6),
  48249 	979:  uint8(0xd7),
  48250 	980:  uint8(0xd8),
  48251 	981:  uint8(0xd9),
  48252 	982:  uint8(0xda),
  48253 	983:  uint8(0xdb),
  48254 	984:  uint8(0xdc),
  48255 	985:  uint8(0xdd),
  48256 	986:  uint8(0xde),
  48257 	987:  uint8(0xdf),
  48258 	988:  uint8(0xe0),
  48259 	989:  uint8(0xe1),
  48260 	990:  uint8(0xe2),
  48261 	991:  uint8(0xe3),
  48262 	992:  uint8(0xe4),
  48263 	993:  uint8(0xe5),
  48264 	994:  uint8(0xe6),
  48265 	995:  uint8(0xe7),
  48266 	996:  uint8(0xe8),
  48267 	997:  uint8(0xe9),
  48268 	998:  uint8(0xea),
  48269 	999:  uint8(0xeb),
  48270 	1000: uint8(0xec),
  48271 	1001: uint8(0xed),
  48272 	1002: uint8(0xee),
  48273 	1003: uint8(0xef),
  48274 	1004: uint8(0xf0),
  48275 	1005: uint8(0xf1),
  48276 	1006: uint8(0xf2),
  48277 	1007: uint8(0xf3),
  48278 	1008: uint8(0xf4),
  48279 	1009: uint8(0xf5),
  48280 	1010: uint8(0xf6),
  48281 	1011: uint8(0xf7),
  48282 	1012: uint8(0xf8),
  48283 	1013: uint8(0xf9),
  48284 	1014: uint8(0xfa),
  48285 	1015: uint8(0xfb),
  48286 	1016: uint8(0xfc),
  48287 	1017: uint8(0xfd),
  48288 	1018: uint8(0xfe),
  48289 	1019: uint8(0xff),
  48290 	1021: uint8(0x01),
  48291 	1022: uint8(0x02),
  48292 	1023: uint8(0x03),
  48293 	1024: uint8(0x04),
  48294 	1025: uint8(0x05),
  48295 	1026: uint8(0x06),
  48296 	1027: uint8(0x07),
  48297 	1028: uint8(0x08),
  48298 	1029: uint8(0x09),
  48299 	1030: uint8(0x0a),
  48300 	1031: uint8(0x0b),
  48301 	1032: uint8(0x0c),
  48302 	1033: uint8(0x0d),
  48303 	1034: uint8(0x0e),
  48304 	1035: uint8(0x0f),
  48305 	1036: uint8(0x10),
  48306 	1037: uint8(0x11),
  48307 	1038: uint8(0x12),
  48308 	1039: uint8(0x13),
  48309 	1040: uint8(0x14),
  48310 	1041: uint8(0x15),
  48311 	1042: uint8(0x16),
  48312 	1043: uint8(0x17),
  48313 	1044: uint8(0x18),
  48314 	1045: uint8(0x19),
  48315 	1046: uint8(0x1a),
  48316 	1047: uint8(0x1b),
  48317 	1048: uint8(0x1c),
  48318 	1049: uint8(0x1d),
  48319 	1050: uint8(0x1e),
  48320 	1051: uint8(0x1f),
  48321 	1052: uint8(0x20),
  48322 	1053: uint8(0x21),
  48323 	1054: uint8(0x22),
  48324 	1055: uint8(0x23),
  48325 	1056: uint8(0x24),
  48326 	1057: uint8(0x25),
  48327 	1058: uint8(0x26),
  48328 	1059: uint8(0x27),
  48329 	1060: uint8(0x28),
  48330 	1061: uint8(0x29),
  48331 	1062: uint8(0x2a),
  48332 	1063: uint8(0x2b),
  48333 	1064: uint8(0x2c),
  48334 	1065: uint8(0x2d),
  48335 	1066: uint8(0x2e),
  48336 	1067: uint8(0x2f),
  48337 	1068: uint8(0x30),
  48338 	1069: uint8(0x31),
  48339 	1070: uint8(0x32),
  48340 	1071: uint8(0x33),
  48341 	1072: uint8(0x34),
  48342 	1073: uint8(0x35),
  48343 	1074: uint8(0x36),
  48344 	1075: uint8(0x37),
  48345 	1076: uint8(0x38),
  48346 	1077: uint8(0x39),
  48347 	1078: uint8(0x3a),
  48348 	1079: uint8(0x3b),
  48349 	1080: uint8(0x3c),
  48350 	1081: uint8(0x3d),
  48351 	1082: uint8(0x3e),
  48352 	1083: uint8(0x3f),
  48353 	1084: uint8(0x40),
  48354 	1085: uint8(0x41),
  48355 	1086: uint8(0x42),
  48356 	1087: uint8(0x43),
  48357 	1088: uint8(0x44),
  48358 	1089: uint8(0x45),
  48359 	1090: uint8(0x46),
  48360 	1091: uint8(0x47),
  48361 	1092: uint8(0x48),
  48362 	1093: uint8(0x49),
  48363 	1094: uint8(0x4a),
  48364 	1095: uint8(0x4b),
  48365 	1096: uint8(0x4c),
  48366 	1097: uint8(0x4d),
  48367 	1098: uint8(0x4e),
  48368 	1099: uint8(0x4f),
  48369 	1100: uint8(0x50),
  48370 	1101: uint8(0x51),
  48371 	1102: uint8(0x52),
  48372 	1103: uint8(0x53),
  48373 	1104: uint8(0x54),
  48374 	1105: uint8(0x55),
  48375 	1106: uint8(0x56),
  48376 	1107: uint8(0x57),
  48377 	1108: uint8(0x58),
  48378 	1109: uint8(0x59),
  48379 	1110: uint8(0x5a),
  48380 	1111: uint8(0x5b),
  48381 	1112: uint8(0x5c),
  48382 	1113: uint8(0x5d),
  48383 	1114: uint8(0x5e),
  48384 	1115: uint8(0x5f),
  48385 	1116: uint8(0x60),
  48386 	1117: uint8(0x61),
  48387 	1118: uint8(0x62),
  48388 	1119: uint8(0x63),
  48389 	1120: uint8(0x64),
  48390 	1121: uint8(0x65),
  48391 	1122: uint8(0x66),
  48392 	1123: uint8(0x67),
  48393 	1124: uint8(0x68),
  48394 	1125: uint8(0x69),
  48395 	1126: uint8(0x6a),
  48396 	1127: uint8(0x6b),
  48397 	1128: uint8(0x6c),
  48398 	1129: uint8(0x6d),
  48399 	1130: uint8(0x6e),
  48400 	1131: uint8(0x6f),
  48401 	1132: uint8(0x70),
  48402 	1133: uint8(0x71),
  48403 	1134: uint8(0x72),
  48404 	1135: uint8(0x73),
  48405 	1136: uint8(0x74),
  48406 	1137: uint8(0x75),
  48407 	1138: uint8(0x76),
  48408 	1139: uint8(0x77),
  48409 	1140: uint8(0x78),
  48410 	1141: uint8(0x79),
  48411 	1142: uint8(0x7a),
  48412 	1143: uint8(0x7b),
  48413 	1144: uint8(0x7c),
  48414 	1145: uint8(0x7d),
  48415 	1146: uint8(0x7e),
  48416 	1147: uint8(0x7f),
  48417 	1148: uint8(0x7f),
  48418 	1149: uint8(0x7f),
  48419 	1150: uint8(0x7f),
  48420 	1151: uint8(0x7f),
  48421 	1152: uint8(0x7f),
  48422 	1153: uint8(0x7f),
  48423 	1154: uint8(0x7f),
  48424 	1155: uint8(0x7f),
  48425 	1156: uint8(0x7f),
  48426 	1157: uint8(0x7f),
  48427 	1158: uint8(0x7f),
  48428 	1159: uint8(0x7f),
  48429 	1160: uint8(0x7f),
  48430 	1161: uint8(0x7f),
  48431 	1162: uint8(0x7f),
  48432 	1163: uint8(0x7f),
  48433 	1164: uint8(0x7f),
  48434 	1165: uint8(0x7f),
  48435 	1166: uint8(0x7f),
  48436 	1167: uint8(0x7f),
  48437 	1168: uint8(0x7f),
  48438 	1169: uint8(0x7f),
  48439 	1170: uint8(0x7f),
  48440 	1171: uint8(0x7f),
  48441 	1172: uint8(0x7f),
  48442 	1173: uint8(0x7f),
  48443 	1174: uint8(0x7f),
  48444 	1175: uint8(0x7f),
  48445 	1176: uint8(0x7f),
  48446 	1177: uint8(0x7f),
  48447 	1178: uint8(0x7f),
  48448 	1179: uint8(0x7f),
  48449 	1180: uint8(0x7f),
  48450 	1181: uint8(0x7f),
  48451 	1182: uint8(0x7f),
  48452 	1183: uint8(0x7f),
  48453 	1184: uint8(0x7f),
  48454 	1185: uint8(0x7f),
  48455 	1186: uint8(0x7f),
  48456 	1187: uint8(0x7f),
  48457 	1188: uint8(0x7f),
  48458 	1189: uint8(0x7f),
  48459 	1190: uint8(0x7f),
  48460 	1191: uint8(0x7f),
  48461 	1192: uint8(0x7f),
  48462 	1193: uint8(0x7f),
  48463 	1194: uint8(0x7f),
  48464 	1195: uint8(0x7f),
  48465 	1196: uint8(0x7f),
  48466 	1197: uint8(0x7f),
  48467 	1198: uint8(0x7f),
  48468 	1199: uint8(0x7f),
  48469 	1200: uint8(0x7f),
  48470 	1201: uint8(0x7f),
  48471 	1202: uint8(0x7f),
  48472 	1203: uint8(0x7f),
  48473 	1204: uint8(0x7f),
  48474 	1205: uint8(0x7f),
  48475 	1206: uint8(0x7f),
  48476 	1207: uint8(0x7f),
  48477 	1208: uint8(0x7f),
  48478 	1209: uint8(0x7f),
  48479 	1210: uint8(0x7f),
  48480 	1211: uint8(0x7f),
  48481 	1212: uint8(0x7f),
  48482 	1213: uint8(0x7f),
  48483 	1214: uint8(0x7f),
  48484 	1215: uint8(0x7f),
  48485 	1216: uint8(0x7f),
  48486 	1217: uint8(0x7f),
  48487 	1218: uint8(0x7f),
  48488 	1219: uint8(0x7f),
  48489 	1220: uint8(0x7f),
  48490 	1221: uint8(0x7f),
  48491 	1222: uint8(0x7f),
  48492 	1223: uint8(0x7f),
  48493 	1224: uint8(0x7f),
  48494 	1225: uint8(0x7f),
  48495 	1226: uint8(0x7f),
  48496 	1227: uint8(0x7f),
  48497 	1228: uint8(0x7f),
  48498 	1229: uint8(0x7f),
  48499 	1230: uint8(0x7f),
  48500 	1231: uint8(0x7f),
  48501 	1232: uint8(0x7f),
  48502 	1233: uint8(0x7f),
  48503 	1234: uint8(0x7f),
  48504 	1235: uint8(0x7f),
  48505 	1236: uint8(0x7f),
  48506 	1237: uint8(0x7f),
  48507 	1238: uint8(0x7f),
  48508 	1239: uint8(0x7f),
  48509 	1240: uint8(0x7f),
  48510 	1241: uint8(0x7f),
  48511 	1242: uint8(0x7f),
  48512 	1243: uint8(0x7f),
  48513 	1244: uint8(0x7f),
  48514 	1245: uint8(0x7f),
  48515 	1246: uint8(0x7f),
  48516 	1247: uint8(0x7f),
  48517 	1248: uint8(0x7f),
  48518 	1249: uint8(0x7f),
  48519 	1250: uint8(0x7f),
  48520 	1251: uint8(0x7f),
  48521 	1252: uint8(0x7f),
  48522 	1253: uint8(0x7f),
  48523 	1254: uint8(0x7f),
  48524 	1255: uint8(0x7f),
  48525 	1256: uint8(0x7f),
  48526 	1257: uint8(0x7f),
  48527 	1258: uint8(0x7f),
  48528 	1259: uint8(0x7f),
  48529 	1260: uint8(0x7f),
  48530 	1261: uint8(0x7f),
  48531 	1262: uint8(0x7f),
  48532 	1263: uint8(0x7f),
  48533 	1264: uint8(0x7f),
  48534 	1265: uint8(0x7f),
  48535 	1266: uint8(0x7f),
  48536 	1267: uint8(0x7f),
  48537 	1268: uint8(0x7f),
  48538 	1269: uint8(0x7f),
  48539 	1270: uint8(0x7f),
  48540 	1271: uint8(0x7f),
  48541 	1272: uint8(0x7f),
  48542 	1273: uint8(0x7f),
  48543 	1274: uint8(0x7f),
  48544 	1275: uint8(0x7f),
  48545 	1276: uint8(0x7f),
  48546 	1277: uint8(0x7f),
  48547 	1278: uint8(0x7f),
  48548 	1279: uint8(0x7f),
  48549 	1280: uint8(0x7f),
  48550 	1281: uint8(0x7f),
  48551 	1282: uint8(0x7f),
  48552 	1283: uint8(0x7f),
  48553 	1284: uint8(0x7f),
  48554 	1285: uint8(0x7f),
  48555 	1286: uint8(0x7f),
  48556 	1287: uint8(0x7f),
  48557 	1288: uint8(0x7f),
  48558 	1289: uint8(0x7f),
  48559 	1290: uint8(0x7f),
  48560 	1291: uint8(0x7f),
  48561 	1292: uint8(0x7f),
  48562 	1293: uint8(0x7f),
  48563 	1294: uint8(0x7f),
  48564 	1295: uint8(0x7f),
  48565 	1296: uint8(0x7f),
  48566 	1297: uint8(0x7f),
  48567 	1298: uint8(0x7f),
  48568 	1299: uint8(0x7f),
  48569 	1300: uint8(0x7f),
  48570 	1301: uint8(0x7f),
  48571 	1302: uint8(0x7f),
  48572 	1303: uint8(0x7f),
  48573 	1304: uint8(0x7f),
  48574 	1305: uint8(0x7f),
  48575 	1306: uint8(0x7f),
  48576 	1307: uint8(0x7f),
  48577 	1308: uint8(0x7f),
  48578 	1309: uint8(0x7f),
  48579 	1310: uint8(0x7f),
  48580 	1311: uint8(0x7f),
  48581 	1312: uint8(0x7f),
  48582 	1313: uint8(0x7f),
  48583 	1314: uint8(0x7f),
  48584 	1315: uint8(0x7f),
  48585 	1316: uint8(0x7f),
  48586 	1317: uint8(0x7f),
  48587 	1318: uint8(0x7f),
  48588 	1319: uint8(0x7f),
  48589 	1320: uint8(0x7f),
  48590 	1321: uint8(0x7f),
  48591 	1322: uint8(0x7f),
  48592 	1323: uint8(0x7f),
  48593 	1324: uint8(0x7f),
  48594 	1325: uint8(0x7f),
  48595 	1326: uint8(0x7f),
  48596 	1327: uint8(0x7f),
  48597 	1328: uint8(0x7f),
  48598 	1329: uint8(0x7f),
  48599 	1330: uint8(0x7f),
  48600 	1331: uint8(0x7f),
  48601 	1332: uint8(0x7f),
  48602 	1333: uint8(0x7f),
  48603 	1334: uint8(0x7f),
  48604 	1335: uint8(0x7f),
  48605 	1336: uint8(0x7f),
  48606 	1337: uint8(0x7f),
  48607 	1338: uint8(0x7f),
  48608 	1339: uint8(0x7f),
  48609 	1340: uint8(0x7f),
  48610 	1341: uint8(0x7f),
  48611 	1342: uint8(0x7f),
  48612 	1343: uint8(0x7f),
  48613 	1344: uint8(0x7f),
  48614 	1345: uint8(0x7f),
  48615 	1346: uint8(0x7f),
  48616 	1347: uint8(0x7f),
  48617 	1348: uint8(0x7f),
  48618 	1349: uint8(0x7f),
  48619 	1350: uint8(0x7f),
  48620 	1351: uint8(0x7f),
  48621 	1352: uint8(0x7f),
  48622 	1353: uint8(0x7f),
  48623 	1354: uint8(0x7f),
  48624 	1355: uint8(0x7f),
  48625 	1356: uint8(0x7f),
  48626 	1357: uint8(0x7f),
  48627 	1358: uint8(0x7f),
  48628 	1359: uint8(0x7f),
  48629 	1360: uint8(0x7f),
  48630 	1361: uint8(0x7f),
  48631 	1362: uint8(0x7f),
  48632 	1363: uint8(0x7f),
  48633 	1364: uint8(0x7f),
  48634 	1365: uint8(0x7f),
  48635 	1366: uint8(0x7f),
  48636 	1367: uint8(0x7f),
  48637 	1368: uint8(0x7f),
  48638 	1369: uint8(0x7f),
  48639 	1370: uint8(0x7f),
  48640 	1371: uint8(0x7f),
  48641 	1372: uint8(0x7f),
  48642 	1373: uint8(0x7f),
  48643 	1374: uint8(0x7f),
  48644 	1375: uint8(0x7f),
  48645 	1376: uint8(0x7f),
  48646 	1377: uint8(0x7f),
  48647 	1378: uint8(0x7f),
  48648 	1379: uint8(0x7f),
  48649 	1380: uint8(0x7f),
  48650 	1381: uint8(0x7f),
  48651 	1382: uint8(0x7f),
  48652 	1383: uint8(0x7f),
  48653 	1384: uint8(0x7f),
  48654 	1385: uint8(0x7f),
  48655 	1386: uint8(0x7f),
  48656 	1387: uint8(0x7f),
  48657 	1388: uint8(0x7f),
  48658 	1389: uint8(0x7f),
  48659 	1390: uint8(0x7f),
  48660 	1391: uint8(0x7f),
  48661 	1392: uint8(0x7f),
  48662 	1393: uint8(0x7f),
  48663 	1394: uint8(0x7f),
  48664 	1395: uint8(0x7f),
  48665 	1396: uint8(0x7f),
  48666 	1397: uint8(0x7f),
  48667 	1398: uint8(0x7f),
  48668 	1399: uint8(0x7f),
  48669 	1400: uint8(0x7f),
  48670 	1401: uint8(0x7f),
  48671 	1402: uint8(0x7f),
  48672 	1403: uint8(0x7f),
  48673 	1404: uint8(0x7f),
  48674 	1405: uint8(0x7f),
  48675 	1406: uint8(0x7f),
  48676 	1407: uint8(0x7f),
  48677 	1408: uint8(0x7f),
  48678 	1409: uint8(0x7f),
  48679 	1410: uint8(0x7f),
  48680 	1411: uint8(0x7f),
  48681 	1412: uint8(0x7f),
  48682 	1413: uint8(0x7f),
  48683 	1414: uint8(0x7f),
  48684 	1415: uint8(0x7f),
  48685 	1416: uint8(0x7f),
  48686 	1417: uint8(0x7f),
  48687 	1418: uint8(0x7f),
  48688 	1419: uint8(0x7f),
  48689 	1420: uint8(0x7f),
  48690 	1421: uint8(0x7f),
  48691 	1422: uint8(0x7f),
  48692 	1423: uint8(0x7f),
  48693 	1424: uint8(0x7f),
  48694 	1425: uint8(0x7f),
  48695 	1426: uint8(0x7f),
  48696 	1427: uint8(0x7f),
  48697 	1428: uint8(0x7f),
  48698 	1429: uint8(0x7f),
  48699 	1430: uint8(0x7f),
  48700 	1431: uint8(0x7f),
  48701 	1432: uint8(0x7f),
  48702 	1433: uint8(0x7f),
  48703 	1434: uint8(0x7f),
  48704 	1435: uint8(0x7f),
  48705 	1436: uint8(0x7f),
  48706 	1437: uint8(0x7f),
  48707 	1438: uint8(0x7f),
  48708 	1439: uint8(0x7f),
  48709 	1440: uint8(0x7f),
  48710 	1441: uint8(0x7f),
  48711 	1442: uint8(0x7f),
  48712 	1443: uint8(0x7f),
  48713 	1444: uint8(0x7f),
  48714 	1445: uint8(0x7f),
  48715 	1446: uint8(0x7f),
  48716 	1447: uint8(0x7f),
  48717 	1448: uint8(0x7f),
  48718 	1449: uint8(0x7f),
  48719 	1450: uint8(0x7f),
  48720 	1451: uint8(0x7f),
  48721 	1452: uint8(0x7f),
  48722 	1453: uint8(0x7f),
  48723 	1454: uint8(0x7f),
  48724 	1455: uint8(0x7f),
  48725 	1456: uint8(0x7f),
  48726 	1457: uint8(0x7f),
  48727 	1458: uint8(0x7f),
  48728 	1459: uint8(0x7f),
  48729 	1460: uint8(0x7f),
  48730 	1461: uint8(0x7f),
  48731 	1462: uint8(0x7f),
  48732 	1463: uint8(0x7f),
  48733 	1464: uint8(0x7f),
  48734 	1465: uint8(0x7f),
  48735 	1466: uint8(0x7f),
  48736 	1467: uint8(0x7f),
  48737 	1468: uint8(0x7f),
  48738 	1469: uint8(0x7f),
  48739 	1470: uint8(0x7f),
  48740 	1471: uint8(0x7f),
  48741 	1472: uint8(0x7f),
  48742 	1473: uint8(0x7f),
  48743 	1474: uint8(0x7f),
  48744 	1475: uint8(0x7f),
  48745 	1476: uint8(0x7f),
  48746 	1477: uint8(0x7f),
  48747 	1478: uint8(0x7f),
  48748 	1479: uint8(0x7f),
  48749 	1480: uint8(0x7f),
  48750 	1481: uint8(0x7f),
  48751 	1482: uint8(0x7f),
  48752 	1483: uint8(0x7f),
  48753 	1484: uint8(0x7f),
  48754 	1485: uint8(0x7f),
  48755 	1486: uint8(0x7f),
  48756 	1487: uint8(0x7f),
  48757 	1488: uint8(0x7f),
  48758 	1489: uint8(0x7f),
  48759 	1490: uint8(0x7f),
  48760 	1491: uint8(0x7f),
  48761 	1492: uint8(0x7f),
  48762 	1493: uint8(0x7f),
  48763 	1494: uint8(0x7f),
  48764 	1495: uint8(0x7f),
  48765 	1496: uint8(0x7f),
  48766 	1497: uint8(0x7f),
  48767 	1498: uint8(0x7f),
  48768 	1499: uint8(0x7f),
  48769 	1500: uint8(0x7f),
  48770 	1501: uint8(0x7f),
  48771 	1502: uint8(0x7f),
  48772 	1503: uint8(0x7f),
  48773 	1504: uint8(0x7f),
  48774 	1505: uint8(0x7f),
  48775 	1506: uint8(0x7f),
  48776 	1507: uint8(0x7f),
  48777 	1508: uint8(0x7f),
  48778 	1509: uint8(0x7f),
  48779 	1510: uint8(0x7f),
  48780 	1511: uint8(0x7f),
  48781 	1512: uint8(0x7f),
  48782 	1513: uint8(0x7f),
  48783 	1514: uint8(0x7f),
  48784 	1515: uint8(0x7f),
  48785 	1516: uint8(0x7f),
  48786 	1517: uint8(0x7f),
  48787 	1518: uint8(0x7f),
  48788 	1519: uint8(0x7f),
  48789 	1520: uint8(0x7f),
  48790 	1521: uint8(0x7f),
  48791 	1522: uint8(0x7f),
  48792 	1523: uint8(0x7f),
  48793 	1524: uint8(0x7f),
  48794 	1525: uint8(0x7f),
  48795 	1526: uint8(0x7f),
  48796 	1527: uint8(0x7f),
  48797 	1528: uint8(0x7f),
  48798 	1529: uint8(0x7f),
  48799 	1530: uint8(0x7f),
  48800 	1531: uint8(0x7f),
  48801 	1532: uint8(0x7f),
  48802 	1533: uint8(0x7f),
  48803 	1534: uint8(0x7f),
  48804 	1535: uint8(0x7f),
  48805 	1536: uint8(0x7f),
  48806 	1537: uint8(0x7f),
  48807 	1538: uint8(0x7f),
  48808 	1539: uint8(0x7f),
  48809 	1540: uint8(0x7f),
  48810 	1541: uint8(0x7f),
  48811 	1542: uint8(0x7f),
  48812 	1543: uint8(0x7f),
  48813 	1544: uint8(0x7f),
  48814 	1545: uint8(0x7f),
  48815 	1546: uint8(0x7f),
  48816 	1547: uint8(0x7f),
  48817 	1548: uint8(0x7f),
  48818 	1549: uint8(0x7f),
  48819 	1550: uint8(0x7f),
  48820 	1551: uint8(0x7f),
  48821 	1552: uint8(0x7f),
  48822 	1553: uint8(0x7f),
  48823 	1554: uint8(0x7f),
  48824 	1555: uint8(0x7f),
  48825 	1556: uint8(0x7f),
  48826 	1557: uint8(0x7f),
  48827 	1558: uint8(0x7f),
  48828 	1559: uint8(0x7f),
  48829 	1560: uint8(0x7f),
  48830 	1561: uint8(0x7f),
  48831 	1562: uint8(0x7f),
  48832 	1563: uint8(0x7f),
  48833 	1564: uint8(0x7f),
  48834 	1565: uint8(0x7f),
  48835 	1566: uint8(0x7f),
  48836 	1567: uint8(0x7f),
  48837 	1568: uint8(0x7f),
  48838 	1569: uint8(0x7f),
  48839 	1570: uint8(0x7f),
  48840 	1571: uint8(0x7f),
  48841 	1572: uint8(0x7f),
  48842 	1573: uint8(0x7f),
  48843 	1574: uint8(0x7f),
  48844 	1575: uint8(0x7f),
  48845 	1576: uint8(0x7f),
  48846 	1577: uint8(0x7f),
  48847 	1578: uint8(0x7f),
  48848 	1579: uint8(0x7f),
  48849 	1580: uint8(0x7f),
  48850 	1581: uint8(0x7f),
  48851 	1582: uint8(0x7f),
  48852 	1583: uint8(0x7f),
  48853 	1584: uint8(0x7f),
  48854 	1585: uint8(0x7f),
  48855 	1586: uint8(0x7f),
  48856 	1587: uint8(0x7f),
  48857 	1588: uint8(0x7f),
  48858 	1589: uint8(0x7f),
  48859 	1590: uint8(0x7f),
  48860 	1591: uint8(0x7f),
  48861 	1592: uint8(0x7f),
  48862 	1593: uint8(0x7f),
  48863 	1594: uint8(0x7f),
  48864 	1595: uint8(0x7f),
  48865 	1596: uint8(0x7f),
  48866 	1597: uint8(0x7f),
  48867 	1598: uint8(0x7f),
  48868 	1599: uint8(0x7f),
  48869 	1600: uint8(0x7f),
  48870 	1601: uint8(0x7f),
  48871 	1602: uint8(0x7f),
  48872 	1603: uint8(0x7f),
  48873 	1604: uint8(0x7f),
  48874 	1605: uint8(0x7f),
  48875 	1606: uint8(0x7f),
  48876 	1607: uint8(0x7f),
  48877 	1608: uint8(0x7f),
  48878 	1609: uint8(0x7f),
  48879 	1610: uint8(0x7f),
  48880 	1611: uint8(0x7f),
  48881 	1612: uint8(0x7f),
  48882 	1613: uint8(0x7f),
  48883 	1614: uint8(0x7f),
  48884 	1615: uint8(0x7f),
  48885 	1616: uint8(0x7f),
  48886 	1617: uint8(0x7f),
  48887 	1618: uint8(0x7f),
  48888 	1619: uint8(0x7f),
  48889 	1620: uint8(0x7f),
  48890 	1621: uint8(0x7f),
  48891 	1622: uint8(0x7f),
  48892 	1623: uint8(0x7f),
  48893 	1624: uint8(0x7f),
  48894 	1625: uint8(0x7f),
  48895 	1626: uint8(0x7f),
  48896 	1627: uint8(0x7f),
  48897 	1628: uint8(0x7f),
  48898 	1629: uint8(0x7f),
  48899 	1630: uint8(0x7f),
  48900 	1631: uint8(0x7f),
  48901 	1632: uint8(0x7f),
  48902 	1633: uint8(0x7f),
  48903 	1634: uint8(0x7f),
  48904 	1635: uint8(0x7f),
  48905 	1636: uint8(0x7f),
  48906 	1637: uint8(0x7f),
  48907 	1638: uint8(0x7f),
  48908 	1639: uint8(0x7f),
  48909 	1640: uint8(0x7f),
  48910 	1641: uint8(0x7f),
  48911 	1642: uint8(0x7f),
  48912 	1643: uint8(0x7f),
  48913 	1644: uint8(0x7f),
  48914 	1645: uint8(0x7f),
  48915 	1646: uint8(0x7f),
  48916 	1647: uint8(0x7f),
  48917 	1648: uint8(0x7f),
  48918 	1649: uint8(0x7f),
  48919 	1650: uint8(0x7f),
  48920 	1651: uint8(0x7f),
  48921 	1652: uint8(0x7f),
  48922 	1653: uint8(0x7f),
  48923 	1654: uint8(0x7f),
  48924 	1655: uint8(0x7f),
  48925 	1656: uint8(0x7f),
  48926 	1657: uint8(0x7f),
  48927 	1658: uint8(0x7f),
  48928 	1659: uint8(0x7f),
  48929 	1660: uint8(0x7f),
  48930 	1661: uint8(0x7f),
  48931 	1662: uint8(0x7f),
  48932 	1663: uint8(0x7f),
  48933 	1664: uint8(0x7f),
  48934 	1665: uint8(0x7f),
  48935 	1666: uint8(0x7f),
  48936 	1667: uint8(0x7f),
  48937 	1668: uint8(0x7f),
  48938 	1669: uint8(0x7f),
  48939 	1670: uint8(0x7f),
  48940 	1671: uint8(0x7f),
  48941 	1672: uint8(0x7f),
  48942 	1673: uint8(0x7f),
  48943 	1674: uint8(0x7f),
  48944 	1675: uint8(0x7f),
  48945 	1676: uint8(0x7f),
  48946 	1677: uint8(0x7f),
  48947 	1678: uint8(0x7f),
  48948 	1679: uint8(0x7f),
  48949 	1680: uint8(0x7f),
  48950 	1681: uint8(0x7f),
  48951 	1682: uint8(0x7f),
  48952 	1683: uint8(0x7f),
  48953 	1684: uint8(0x7f),
  48954 	1685: uint8(0x7f),
  48955 	1686: uint8(0x7f),
  48956 	1687: uint8(0x7f),
  48957 	1688: uint8(0x7f),
  48958 	1689: uint8(0x7f),
  48959 	1690: uint8(0x7f),
  48960 	1691: uint8(0x7f),
  48961 	1692: uint8(0x7f),
  48962 	1693: uint8(0x7f),
  48963 	1694: uint8(0x7f),
  48964 	1695: uint8(0x7f),
  48965 	1696: uint8(0x7f),
  48966 	1697: uint8(0x7f),
  48967 	1698: uint8(0x7f),
  48968 	1699: uint8(0x7f),
  48969 	1700: uint8(0x7f),
  48970 	1701: uint8(0x7f),
  48971 	1702: uint8(0x7f),
  48972 	1703: uint8(0x7f),
  48973 	1704: uint8(0x7f),
  48974 	1705: uint8(0x7f),
  48975 	1706: uint8(0x7f),
  48976 	1707: uint8(0x7f),
  48977 	1708: uint8(0x7f),
  48978 	1709: uint8(0x7f),
  48979 	1710: uint8(0x7f),
  48980 	1711: uint8(0x7f),
  48981 	1712: uint8(0x7f),
  48982 	1713: uint8(0x7f),
  48983 	1714: uint8(0x7f),
  48984 	1715: uint8(0x7f),
  48985 	1716: uint8(0x7f),
  48986 	1717: uint8(0x7f),
  48987 	1718: uint8(0x7f),
  48988 	1719: uint8(0x7f),
  48989 	1720: uint8(0x7f),
  48990 	1721: uint8(0x7f),
  48991 	1722: uint8(0x7f),
  48992 	1723: uint8(0x7f),
  48993 	1724: uint8(0x7f),
  48994 	1725: uint8(0x7f),
  48995 	1726: uint8(0x7f),
  48996 	1727: uint8(0x7f),
  48997 	1728: uint8(0x7f),
  48998 	1729: uint8(0x7f),
  48999 	1730: uint8(0x7f),
  49000 	1731: uint8(0x7f),
  49001 	1732: uint8(0x7f),
  49002 	1733: uint8(0x7f),
  49003 	1734: uint8(0x7f),
  49004 	1735: uint8(0x7f),
  49005 	1736: uint8(0x7f),
  49006 	1737: uint8(0x7f),
  49007 	1738: uint8(0x7f),
  49008 	1739: uint8(0x7f),
  49009 	1740: uint8(0x7f),
  49010 	1741: uint8(0x7f),
  49011 	1742: uint8(0x7f),
  49012 	1743: uint8(0x7f),
  49013 	1744: uint8(0x7f),
  49014 	1745: uint8(0x7f),
  49015 	1746: uint8(0x7f),
  49016 	1747: uint8(0x7f),
  49017 	1748: uint8(0x7f),
  49018 	1749: uint8(0x7f),
  49019 	1750: uint8(0x7f),
  49020 	1751: uint8(0x7f),
  49021 	1752: uint8(0x7f),
  49022 	1753: uint8(0x7f),
  49023 	1754: uint8(0x7f),
  49024 	1755: uint8(0x7f),
  49025 	1756: uint8(0x7f),
  49026 	1757: uint8(0x7f),
  49027 	1758: uint8(0x7f),
  49028 	1759: uint8(0x7f),
  49029 	1760: uint8(0x7f),
  49030 	1761: uint8(0x7f),
  49031 	1762: uint8(0x7f),
  49032 	1763: uint8(0x7f),
  49033 	1764: uint8(0x7f),
  49034 	1765: uint8(0x7f),
  49035 	1766: uint8(0x7f),
  49036 	1767: uint8(0x7f),
  49037 	1768: uint8(0x7f),
  49038 	1769: uint8(0x7f),
  49039 	1770: uint8(0x7f),
  49040 	1771: uint8(0x7f),
  49041 	1772: uint8(0x7f),
  49042 	1773: uint8(0x7f),
  49043 	1774: uint8(0x7f),
  49044 	1775: uint8(0x7f),
  49045 	1776: uint8(0x7f),
  49046 	1777: uint8(0x7f),
  49047 	1778: uint8(0x7f),
  49048 	1779: uint8(0x7f),
  49049 	1780: uint8(0x7f),
  49050 	1781: uint8(0x7f),
  49051 	1782: uint8(0x7f),
  49052 	1783: uint8(0x7f),
  49053 	1784: uint8(0x7f),
  49054 	1785: uint8(0x7f),
  49055 	1786: uint8(0x7f),
  49056 	1787: uint8(0x7f),
  49057 	1788: uint8(0x7f),
  49058 	1789: uint8(0x7f),
  49059 	1790: uint8(0x7f),
  49060 	1791: uint8(0x7f),
  49061 	1792: uint8(0x7f),
  49062 	1793: uint8(0x7f),
  49063 	1794: uint8(0x7f),
  49064 	1795: uint8(0x7f),
  49065 	1796: uint8(0x7f),
  49066 	1797: uint8(0x7f),
  49067 	1798: uint8(0x7f),
  49068 	1799: uint8(0x7f),
  49069 	1800: uint8(0x7f),
  49070 	1801: uint8(0x7f),
  49071 	1802: uint8(0x7f),
  49072 	1803: uint8(0x7f),
  49073 	1804: uint8(0x7f),
  49074 	1805: uint8(0x7f),
  49075 	1806: uint8(0x7f),
  49076 	1807: uint8(0x7f),
  49077 	1808: uint8(0x7f),
  49078 	1809: uint8(0x7f),
  49079 	1810: uint8(0x7f),
  49080 	1811: uint8(0x7f),
  49081 	1812: uint8(0x7f),
  49082 	1813: uint8(0x7f),
  49083 	1814: uint8(0x7f),
  49084 	1815: uint8(0x7f),
  49085 	1816: uint8(0x7f),
  49086 	1817: uint8(0x7f),
  49087 	1818: uint8(0x7f),
  49088 	1819: uint8(0x7f),
  49089 	1820: uint8(0x7f),
  49090 	1821: uint8(0x7f),
  49091 	1822: uint8(0x7f),
  49092 	1823: uint8(0x7f),
  49093 	1824: uint8(0x7f),
  49094 	1825: uint8(0x7f),
  49095 	1826: uint8(0x7f),
  49096 	1827: uint8(0x7f),
  49097 	1828: uint8(0x7f),
  49098 	1829: uint8(0x7f),
  49099 	1830: uint8(0x7f),
  49100 	1831: uint8(0x7f),
  49101 	1832: uint8(0x7f),
  49102 	1833: uint8(0x7f),
  49103 	1834: uint8(0x7f),
  49104 	1835: uint8(0x7f),
  49105 	1836: uint8(0x7f),
  49106 	1837: uint8(0x7f),
  49107 	1838: uint8(0x7f),
  49108 	1839: uint8(0x7f),
  49109 	1840: uint8(0x7f),
  49110 	1841: uint8(0x7f),
  49111 	1842: uint8(0x7f),
  49112 	1843: uint8(0x7f),
  49113 	1844: uint8(0x7f),
  49114 	1845: uint8(0x7f),
  49115 	1846: uint8(0x7f),
  49116 	1847: uint8(0x7f),
  49117 	1848: uint8(0x7f),
  49118 	1849: uint8(0x7f),
  49119 	1850: uint8(0x7f),
  49120 	1851: uint8(0x7f),
  49121 	1852: uint8(0x7f),
  49122 	1853: uint8(0x7f),
  49123 	1854: uint8(0x7f),
  49124 	1855: uint8(0x7f),
  49125 	1856: uint8(0x7f),
  49126 	1857: uint8(0x7f),
  49127 	1858: uint8(0x7f),
  49128 	1859: uint8(0x7f),
  49129 	1860: uint8(0x7f),
  49130 	1861: uint8(0x7f),
  49131 	1862: uint8(0x7f),
  49132 	1863: uint8(0x7f),
  49133 	1864: uint8(0x7f),
  49134 	1865: uint8(0x7f),
  49135 	1866: uint8(0x7f),
  49136 	1867: uint8(0x7f),
  49137 	1868: uint8(0x7f),
  49138 	1869: uint8(0x7f),
  49139 	1870: uint8(0x7f),
  49140 	1871: uint8(0x7f),
  49141 	1872: uint8(0x7f),
  49142 	1873: uint8(0x7f),
  49143 	1874: uint8(0x7f),
  49144 	1875: uint8(0x7f),
  49145 	1876: uint8(0x7f),
  49146 	1877: uint8(0x7f),
  49147 	1878: uint8(0x7f),
  49148 	1879: uint8(0x7f),
  49149 	1880: uint8(0x7f),
  49150 	1881: uint8(0x7f),
  49151 	1882: uint8(0x7f),
  49152 	1883: uint8(0x7f),
  49153 	1884: uint8(0x7f),
  49154 	1885: uint8(0x7f),
  49155 	1886: uint8(0x7f),
  49156 	1887: uint8(0x7f),
  49157 	1888: uint8(0x7f),
  49158 	1889: uint8(0x7f),
  49159 	1890: uint8(0x7f),
  49160 	1891: uint8(0x7f),
  49161 	1892: uint8(0x7f),
  49162 	1893: uint8(0x7f),
  49163 	1894: uint8(0x7f),
  49164 	1895: uint8(0x7f),
  49165 	1896: uint8(0x7f),
  49166 	1897: uint8(0x7f),
  49167 	1898: uint8(0x7f),
  49168 	1899: uint8(0x7f),
  49169 	1900: uint8(0x7f),
  49170 	1901: uint8(0x7f),
  49171 	1902: uint8(0x7f),
  49172 	1903: uint8(0x7f),
  49173 	1904: uint8(0x7f),
  49174 	1905: uint8(0x7f),
  49175 	1906: uint8(0x7f),
  49176 	1907: uint8(0x7f),
  49177 	1908: uint8(0x7f),
  49178 	1909: uint8(0x7f),
  49179 	1910: uint8(0x7f),
  49180 	1911: uint8(0x7f),
  49181 	1912: uint8(0x7f),
  49182 	1913: uint8(0x7f),
  49183 	1914: uint8(0x7f),
  49184 	1915: uint8(0x7f),
  49185 	1916: uint8(0x7f),
  49186 	1917: uint8(0x7f),
  49187 	1918: uint8(0x7f),
  49188 	1919: uint8(0x7f),
  49189 	1920: uint8(0x7f),
  49190 	1921: uint8(0x7f),
  49191 	1922: uint8(0x7f),
  49192 	1923: uint8(0x7f),
  49193 	1924: uint8(0x7f),
  49194 	1925: uint8(0x7f),
  49195 	1926: uint8(0x7f),
  49196 	1927: uint8(0x7f),
  49197 	1928: uint8(0x7f),
  49198 	1929: uint8(0x7f),
  49199 	1930: uint8(0x7f),
  49200 	1931: uint8(0x7f),
  49201 	1932: uint8(0x7f),
  49202 	1933: uint8(0x7f),
  49203 	1934: uint8(0x7f),
  49204 	1935: uint8(0x7f),
  49205 	1936: uint8(0x7f),
  49206 	1937: uint8(0x7f),
  49207 	1938: uint8(0x7f),
  49208 	1939: uint8(0x7f),
  49209 	1940: uint8(0x7f),
  49210 	1941: uint8(0x7f),
  49211 	1942: uint8(0x7f),
  49212 	1943: uint8(0x7f),
  49213 	1944: uint8(0x7f),
  49214 	1945: uint8(0x7f),
  49215 	1946: uint8(0x7f),
  49216 	1947: uint8(0x7f),
  49217 	1948: uint8(0x7f),
  49218 	1949: uint8(0x7f),
  49219 	1950: uint8(0x7f),
  49220 	1951: uint8(0x7f),
  49221 	1952: uint8(0x7f),
  49222 	1953: uint8(0x7f),
  49223 	1954: uint8(0x7f),
  49224 	1955: uint8(0x7f),
  49225 	1956: uint8(0x7f),
  49226 	1957: uint8(0x7f),
  49227 	1958: uint8(0x7f),
  49228 	1959: uint8(0x7f),
  49229 	1960: uint8(0x7f),
  49230 	1961: uint8(0x7f),
  49231 	1962: uint8(0x7f),
  49232 	1963: uint8(0x7f),
  49233 	1964: uint8(0x7f),
  49234 	1965: uint8(0x7f),
  49235 	1966: uint8(0x7f),
  49236 	1967: uint8(0x7f),
  49237 	1968: uint8(0x7f),
  49238 	1969: uint8(0x7f),
  49239 	1970: uint8(0x7f),
  49240 	1971: uint8(0x7f),
  49241 	1972: uint8(0x7f),
  49242 	1973: uint8(0x7f),
  49243 	1974: uint8(0x7f),
  49244 	1975: uint8(0x7f),
  49245 	1976: uint8(0x7f),
  49246 	1977: uint8(0x7f),
  49247 	1978: uint8(0x7f),
  49248 	1979: uint8(0x7f),
  49249 	1980: uint8(0x7f),
  49250 	1981: uint8(0x7f),
  49251 	1982: uint8(0x7f),
  49252 	1983: uint8(0x7f),
  49253 	1984: uint8(0x7f),
  49254 	1985: uint8(0x7f),
  49255 	1986: uint8(0x7f),
  49256 	1987: uint8(0x7f),
  49257 	1988: uint8(0x7f),
  49258 	1989: uint8(0x7f),
  49259 	1990: uint8(0x7f),
  49260 	1991: uint8(0x7f),
  49261 	1992: uint8(0x7f),
  49262 	1993: uint8(0x7f),
  49263 	1994: uint8(0x7f),
  49264 	1995: uint8(0x7f),
  49265 	1996: uint8(0x7f),
  49266 	1997: uint8(0x7f),
  49267 	1998: uint8(0x7f),
  49268 	1999: uint8(0x7f),
  49269 	2000: uint8(0x7f),
  49270 	2001: uint8(0x7f),
  49271 	2002: uint8(0x7f),
  49272 	2003: uint8(0x7f),
  49273 	2004: uint8(0x7f),
  49274 	2005: uint8(0x7f),
  49275 	2006: uint8(0x7f),
  49276 	2007: uint8(0x7f),
  49277 	2008: uint8(0x7f),
  49278 	2009: uint8(0x7f),
  49279 	2010: uint8(0x7f),
  49280 	2011: uint8(0x7f),
  49281 	2012: uint8(0x7f),
  49282 	2013: uint8(0x7f),
  49283 	2014: uint8(0x7f),
  49284 	2015: uint8(0x7f),
  49285 	2016: uint8(0x7f),
  49286 	2017: uint8(0x7f),
  49287 	2018: uint8(0x7f),
  49288 	2019: uint8(0x7f),
  49289 	2020: uint8(0x7f),
  49290 	2021: uint8(0x7f),
  49291 	2022: uint8(0x7f),
  49292 	2023: uint8(0x7f),
  49293 	2024: uint8(0x7f),
  49294 	2025: uint8(0x7f),
  49295 	2026: uint8(0x7f),
  49296 	2027: uint8(0x7f),
  49297 	2028: uint8(0x7f),
  49298 	2029: uint8(0x7f),
  49299 	2030: uint8(0x7f),
  49300 	2031: uint8(0x7f),
  49301 	2032: uint8(0x7f),
  49302 	2033: uint8(0x7f),
  49303 	2034: uint8(0x7f),
  49304 	2035: uint8(0x7f),
  49305 	2036: uint8(0x7f),
  49306 	2037: uint8(0x7f),
  49307 	2038: uint8(0x7f),
  49308 	2039: uint8(0x7f),
  49309 }
  49310 
  49311 var sclip2 = [225]uint8_t{
  49312 	0:   uint8(0xf0),
  49313 	1:   uint8(0xf0),
  49314 	2:   uint8(0xf0),
  49315 	3:   uint8(0xf0),
  49316 	4:   uint8(0xf0),
  49317 	5:   uint8(0xf0),
  49318 	6:   uint8(0xf0),
  49319 	7:   uint8(0xf0),
  49320 	8:   uint8(0xf0),
  49321 	9:   uint8(0xf0),
  49322 	10:  uint8(0xf0),
  49323 	11:  uint8(0xf0),
  49324 	12:  uint8(0xf0),
  49325 	13:  uint8(0xf0),
  49326 	14:  uint8(0xf0),
  49327 	15:  uint8(0xf0),
  49328 	16:  uint8(0xf0),
  49329 	17:  uint8(0xf0),
  49330 	18:  uint8(0xf0),
  49331 	19:  uint8(0xf0),
  49332 	20:  uint8(0xf0),
  49333 	21:  uint8(0xf0),
  49334 	22:  uint8(0xf0),
  49335 	23:  uint8(0xf0),
  49336 	24:  uint8(0xf0),
  49337 	25:  uint8(0xf0),
  49338 	26:  uint8(0xf0),
  49339 	27:  uint8(0xf0),
  49340 	28:  uint8(0xf0),
  49341 	29:  uint8(0xf0),
  49342 	30:  uint8(0xf0),
  49343 	31:  uint8(0xf0),
  49344 	32:  uint8(0xf0),
  49345 	33:  uint8(0xf0),
  49346 	34:  uint8(0xf0),
  49347 	35:  uint8(0xf0),
  49348 	36:  uint8(0xf0),
  49349 	37:  uint8(0xf0),
  49350 	38:  uint8(0xf0),
  49351 	39:  uint8(0xf0),
  49352 	40:  uint8(0xf0),
  49353 	41:  uint8(0xf0),
  49354 	42:  uint8(0xf0),
  49355 	43:  uint8(0xf0),
  49356 	44:  uint8(0xf0),
  49357 	45:  uint8(0xf0),
  49358 	46:  uint8(0xf0),
  49359 	47:  uint8(0xf0),
  49360 	48:  uint8(0xf0),
  49361 	49:  uint8(0xf0),
  49362 	50:  uint8(0xf0),
  49363 	51:  uint8(0xf0),
  49364 	52:  uint8(0xf0),
  49365 	53:  uint8(0xf0),
  49366 	54:  uint8(0xf0),
  49367 	55:  uint8(0xf0),
  49368 	56:  uint8(0xf0),
  49369 	57:  uint8(0xf0),
  49370 	58:  uint8(0xf0),
  49371 	59:  uint8(0xf0),
  49372 	60:  uint8(0xf0),
  49373 	61:  uint8(0xf0),
  49374 	62:  uint8(0xf0),
  49375 	63:  uint8(0xf0),
  49376 	64:  uint8(0xf0),
  49377 	65:  uint8(0xf0),
  49378 	66:  uint8(0xf0),
  49379 	67:  uint8(0xf0),
  49380 	68:  uint8(0xf0),
  49381 	69:  uint8(0xf0),
  49382 	70:  uint8(0xf0),
  49383 	71:  uint8(0xf0),
  49384 	72:  uint8(0xf0),
  49385 	73:  uint8(0xf0),
  49386 	74:  uint8(0xf0),
  49387 	75:  uint8(0xf0),
  49388 	76:  uint8(0xf0),
  49389 	77:  uint8(0xf0),
  49390 	78:  uint8(0xf0),
  49391 	79:  uint8(0xf0),
  49392 	80:  uint8(0xf0),
  49393 	81:  uint8(0xf0),
  49394 	82:  uint8(0xf0),
  49395 	83:  uint8(0xf0),
  49396 	84:  uint8(0xf0),
  49397 	85:  uint8(0xf0),
  49398 	86:  uint8(0xf0),
  49399 	87:  uint8(0xf0),
  49400 	88:  uint8(0xf0),
  49401 	89:  uint8(0xf0),
  49402 	90:  uint8(0xf0),
  49403 	91:  uint8(0xf0),
  49404 	92:  uint8(0xf0),
  49405 	93:  uint8(0xf0),
  49406 	94:  uint8(0xf0),
  49407 	95:  uint8(0xf0),
  49408 	96:  uint8(0xf0),
  49409 	97:  uint8(0xf1),
  49410 	98:  uint8(0xf2),
  49411 	99:  uint8(0xf3),
  49412 	100: uint8(0xf4),
  49413 	101: uint8(0xf5),
  49414 	102: uint8(0xf6),
  49415 	103: uint8(0xf7),
  49416 	104: uint8(0xf8),
  49417 	105: uint8(0xf9),
  49418 	106: uint8(0xfa),
  49419 	107: uint8(0xfb),
  49420 	108: uint8(0xfc),
  49421 	109: uint8(0xfd),
  49422 	110: uint8(0xfe),
  49423 	111: uint8(0xff),
  49424 	113: uint8(0x01),
  49425 	114: uint8(0x02),
  49426 	115: uint8(0x03),
  49427 	116: uint8(0x04),
  49428 	117: uint8(0x05),
  49429 	118: uint8(0x06),
  49430 	119: uint8(0x07),
  49431 	120: uint8(0x08),
  49432 	121: uint8(0x09),
  49433 	122: uint8(0x0a),
  49434 	123: uint8(0x0b),
  49435 	124: uint8(0x0c),
  49436 	125: uint8(0x0d),
  49437 	126: uint8(0x0e),
  49438 	127: uint8(0x0f),
  49439 	128: uint8(0x0f),
  49440 	129: uint8(0x0f),
  49441 	130: uint8(0x0f),
  49442 	131: uint8(0x0f),
  49443 	132: uint8(0x0f),
  49444 	133: uint8(0x0f),
  49445 	134: uint8(0x0f),
  49446 	135: uint8(0x0f),
  49447 	136: uint8(0x0f),
  49448 	137: uint8(0x0f),
  49449 	138: uint8(0x0f),
  49450 	139: uint8(0x0f),
  49451 	140: uint8(0x0f),
  49452 	141: uint8(0x0f),
  49453 	142: uint8(0x0f),
  49454 	143: uint8(0x0f),
  49455 	144: uint8(0x0f),
  49456 	145: uint8(0x0f),
  49457 	146: uint8(0x0f),
  49458 	147: uint8(0x0f),
  49459 	148: uint8(0x0f),
  49460 	149: uint8(0x0f),
  49461 	150: uint8(0x0f),
  49462 	151: uint8(0x0f),
  49463 	152: uint8(0x0f),
  49464 	153: uint8(0x0f),
  49465 	154: uint8(0x0f),
  49466 	155: uint8(0x0f),
  49467 	156: uint8(0x0f),
  49468 	157: uint8(0x0f),
  49469 	158: uint8(0x0f),
  49470 	159: uint8(0x0f),
  49471 	160: uint8(0x0f),
  49472 	161: uint8(0x0f),
  49473 	162: uint8(0x0f),
  49474 	163: uint8(0x0f),
  49475 	164: uint8(0x0f),
  49476 	165: uint8(0x0f),
  49477 	166: uint8(0x0f),
  49478 	167: uint8(0x0f),
  49479 	168: uint8(0x0f),
  49480 	169: uint8(0x0f),
  49481 	170: uint8(0x0f),
  49482 	171: uint8(0x0f),
  49483 	172: uint8(0x0f),
  49484 	173: uint8(0x0f),
  49485 	174: uint8(0x0f),
  49486 	175: uint8(0x0f),
  49487 	176: uint8(0x0f),
  49488 	177: uint8(0x0f),
  49489 	178: uint8(0x0f),
  49490 	179: uint8(0x0f),
  49491 	180: uint8(0x0f),
  49492 	181: uint8(0x0f),
  49493 	182: uint8(0x0f),
  49494 	183: uint8(0x0f),
  49495 	184: uint8(0x0f),
  49496 	185: uint8(0x0f),
  49497 	186: uint8(0x0f),
  49498 	187: uint8(0x0f),
  49499 	188: uint8(0x0f),
  49500 	189: uint8(0x0f),
  49501 	190: uint8(0x0f),
  49502 	191: uint8(0x0f),
  49503 	192: uint8(0x0f),
  49504 	193: uint8(0x0f),
  49505 	194: uint8(0x0f),
  49506 	195: uint8(0x0f),
  49507 	196: uint8(0x0f),
  49508 	197: uint8(0x0f),
  49509 	198: uint8(0x0f),
  49510 	199: uint8(0x0f),
  49511 	200: uint8(0x0f),
  49512 	201: uint8(0x0f),
  49513 	202: uint8(0x0f),
  49514 	203: uint8(0x0f),
  49515 	204: uint8(0x0f),
  49516 	205: uint8(0x0f),
  49517 	206: uint8(0x0f),
  49518 	207: uint8(0x0f),
  49519 	208: uint8(0x0f),
  49520 	209: uint8(0x0f),
  49521 	210: uint8(0x0f),
  49522 	211: uint8(0x0f),
  49523 	212: uint8(0x0f),
  49524 	213: uint8(0x0f),
  49525 	214: uint8(0x0f),
  49526 	215: uint8(0x0f),
  49527 	216: uint8(0x0f),
  49528 	217: uint8(0x0f),
  49529 	218: uint8(0x0f),
  49530 	219: uint8(0x0f),
  49531 	220: uint8(0x0f),
  49532 	221: uint8(0x0f),
  49533 	222: uint8(0x0f),
  49534 	223: uint8(0x0f),
  49535 }
  49536 
  49537 var clip11 = [767]uint8_t{
  49538 	256: uint8(0x01),
  49539 	257: uint8(0x02),
  49540 	258: uint8(0x03),
  49541 	259: uint8(0x04),
  49542 	260: uint8(0x05),
  49543 	261: uint8(0x06),
  49544 	262: uint8(0x07),
  49545 	263: uint8(0x08),
  49546 	264: uint8(0x09),
  49547 	265: uint8(0x0a),
  49548 	266: uint8(0x0b),
  49549 	267: uint8(0x0c),
  49550 	268: uint8(0x0d),
  49551 	269: uint8(0x0e),
  49552 	270: uint8(0x0f),
  49553 	271: uint8(0x10),
  49554 	272: uint8(0x11),
  49555 	273: uint8(0x12),
  49556 	274: uint8(0x13),
  49557 	275: uint8(0x14),
  49558 	276: uint8(0x15),
  49559 	277: uint8(0x16),
  49560 	278: uint8(0x17),
  49561 	279: uint8(0x18),
  49562 	280: uint8(0x19),
  49563 	281: uint8(0x1a),
  49564 	282: uint8(0x1b),
  49565 	283: uint8(0x1c),
  49566 	284: uint8(0x1d),
  49567 	285: uint8(0x1e),
  49568 	286: uint8(0x1f),
  49569 	287: uint8(0x20),
  49570 	288: uint8(0x21),
  49571 	289: uint8(0x22),
  49572 	290: uint8(0x23),
  49573 	291: uint8(0x24),
  49574 	292: uint8(0x25),
  49575 	293: uint8(0x26),
  49576 	294: uint8(0x27),
  49577 	295: uint8(0x28),
  49578 	296: uint8(0x29),
  49579 	297: uint8(0x2a),
  49580 	298: uint8(0x2b),
  49581 	299: uint8(0x2c),
  49582 	300: uint8(0x2d),
  49583 	301: uint8(0x2e),
  49584 	302: uint8(0x2f),
  49585 	303: uint8(0x30),
  49586 	304: uint8(0x31),
  49587 	305: uint8(0x32),
  49588 	306: uint8(0x33),
  49589 	307: uint8(0x34),
  49590 	308: uint8(0x35),
  49591 	309: uint8(0x36),
  49592 	310: uint8(0x37),
  49593 	311: uint8(0x38),
  49594 	312: uint8(0x39),
  49595 	313: uint8(0x3a),
  49596 	314: uint8(0x3b),
  49597 	315: uint8(0x3c),
  49598 	316: uint8(0x3d),
  49599 	317: uint8(0x3e),
  49600 	318: uint8(0x3f),
  49601 	319: uint8(0x40),
  49602 	320: uint8(0x41),
  49603 	321: uint8(0x42),
  49604 	322: uint8(0x43),
  49605 	323: uint8(0x44),
  49606 	324: uint8(0x45),
  49607 	325: uint8(0x46),
  49608 	326: uint8(0x47),
  49609 	327: uint8(0x48),
  49610 	328: uint8(0x49),
  49611 	329: uint8(0x4a),
  49612 	330: uint8(0x4b),
  49613 	331: uint8(0x4c),
  49614 	332: uint8(0x4d),
  49615 	333: uint8(0x4e),
  49616 	334: uint8(0x4f),
  49617 	335: uint8(0x50),
  49618 	336: uint8(0x51),
  49619 	337: uint8(0x52),
  49620 	338: uint8(0x53),
  49621 	339: uint8(0x54),
  49622 	340: uint8(0x55),
  49623 	341: uint8(0x56),
  49624 	342: uint8(0x57),
  49625 	343: uint8(0x58),
  49626 	344: uint8(0x59),
  49627 	345: uint8(0x5a),
  49628 	346: uint8(0x5b),
  49629 	347: uint8(0x5c),
  49630 	348: uint8(0x5d),
  49631 	349: uint8(0x5e),
  49632 	350: uint8(0x5f),
  49633 	351: uint8(0x60),
  49634 	352: uint8(0x61),
  49635 	353: uint8(0x62),
  49636 	354: uint8(0x63),
  49637 	355: uint8(0x64),
  49638 	356: uint8(0x65),
  49639 	357: uint8(0x66),
  49640 	358: uint8(0x67),
  49641 	359: uint8(0x68),
  49642 	360: uint8(0x69),
  49643 	361: uint8(0x6a),
  49644 	362: uint8(0x6b),
  49645 	363: uint8(0x6c),
  49646 	364: uint8(0x6d),
  49647 	365: uint8(0x6e),
  49648 	366: uint8(0x6f),
  49649 	367: uint8(0x70),
  49650 	368: uint8(0x71),
  49651 	369: uint8(0x72),
  49652 	370: uint8(0x73),
  49653 	371: uint8(0x74),
  49654 	372: uint8(0x75),
  49655 	373: uint8(0x76),
  49656 	374: uint8(0x77),
  49657 	375: uint8(0x78),
  49658 	376: uint8(0x79),
  49659 	377: uint8(0x7a),
  49660 	378: uint8(0x7b),
  49661 	379: uint8(0x7c),
  49662 	380: uint8(0x7d),
  49663 	381: uint8(0x7e),
  49664 	382: uint8(0x7f),
  49665 	383: uint8(0x80),
  49666 	384: uint8(0x81),
  49667 	385: uint8(0x82),
  49668 	386: uint8(0x83),
  49669 	387: uint8(0x84),
  49670 	388: uint8(0x85),
  49671 	389: uint8(0x86),
  49672 	390: uint8(0x87),
  49673 	391: uint8(0x88),
  49674 	392: uint8(0x89),
  49675 	393: uint8(0x8a),
  49676 	394: uint8(0x8b),
  49677 	395: uint8(0x8c),
  49678 	396: uint8(0x8d),
  49679 	397: uint8(0x8e),
  49680 	398: uint8(0x8f),
  49681 	399: uint8(0x90),
  49682 	400: uint8(0x91),
  49683 	401: uint8(0x92),
  49684 	402: uint8(0x93),
  49685 	403: uint8(0x94),
  49686 	404: uint8(0x95),
  49687 	405: uint8(0x96),
  49688 	406: uint8(0x97),
  49689 	407: uint8(0x98),
  49690 	408: uint8(0x99),
  49691 	409: uint8(0x9a),
  49692 	410: uint8(0x9b),
  49693 	411: uint8(0x9c),
  49694 	412: uint8(0x9d),
  49695 	413: uint8(0x9e),
  49696 	414: uint8(0x9f),
  49697 	415: uint8(0xa0),
  49698 	416: uint8(0xa1),
  49699 	417: uint8(0xa2),
  49700 	418: uint8(0xa3),
  49701 	419: uint8(0xa4),
  49702 	420: uint8(0xa5),
  49703 	421: uint8(0xa6),
  49704 	422: uint8(0xa7),
  49705 	423: uint8(0xa8),
  49706 	424: uint8(0xa9),
  49707 	425: uint8(0xaa),
  49708 	426: uint8(0xab),
  49709 	427: uint8(0xac),
  49710 	428: uint8(0xad),
  49711 	429: uint8(0xae),
  49712 	430: uint8(0xaf),
  49713 	431: uint8(0xb0),
  49714 	432: uint8(0xb1),
  49715 	433: uint8(0xb2),
  49716 	434: uint8(0xb3),
  49717 	435: uint8(0xb4),
  49718 	436: uint8(0xb5),
  49719 	437: uint8(0xb6),
  49720 	438: uint8(0xb7),
  49721 	439: uint8(0xb8),
  49722 	440: uint8(0xb9),
  49723 	441: uint8(0xba),
  49724 	442: uint8(0xbb),
  49725 	443: uint8(0xbc),
  49726 	444: uint8(0xbd),
  49727 	445: uint8(0xbe),
  49728 	446: uint8(0xbf),
  49729 	447: uint8(0xc0),
  49730 	448: uint8(0xc1),
  49731 	449: uint8(0xc2),
  49732 	450: uint8(0xc3),
  49733 	451: uint8(0xc4),
  49734 	452: uint8(0xc5),
  49735 	453: uint8(0xc6),
  49736 	454: uint8(0xc7),
  49737 	455: uint8(0xc8),
  49738 	456: uint8(0xc9),
  49739 	457: uint8(0xca),
  49740 	458: uint8(0xcb),
  49741 	459: uint8(0xcc),
  49742 	460: uint8(0xcd),
  49743 	461: uint8(0xce),
  49744 	462: uint8(0xcf),
  49745 	463: uint8(0xd0),
  49746 	464: uint8(0xd1),
  49747 	465: uint8(0xd2),
  49748 	466: uint8(0xd3),
  49749 	467: uint8(0xd4),
  49750 	468: uint8(0xd5),
  49751 	469: uint8(0xd6),
  49752 	470: uint8(0xd7),
  49753 	471: uint8(0xd8),
  49754 	472: uint8(0xd9),
  49755 	473: uint8(0xda),
  49756 	474: uint8(0xdb),
  49757 	475: uint8(0xdc),
  49758 	476: uint8(0xdd),
  49759 	477: uint8(0xde),
  49760 	478: uint8(0xdf),
  49761 	479: uint8(0xe0),
  49762 	480: uint8(0xe1),
  49763 	481: uint8(0xe2),
  49764 	482: uint8(0xe3),
  49765 	483: uint8(0xe4),
  49766 	484: uint8(0xe5),
  49767 	485: uint8(0xe6),
  49768 	486: uint8(0xe7),
  49769 	487: uint8(0xe8),
  49770 	488: uint8(0xe9),
  49771 	489: uint8(0xea),
  49772 	490: uint8(0xeb),
  49773 	491: uint8(0xec),
  49774 	492: uint8(0xed),
  49775 	493: uint8(0xee),
  49776 	494: uint8(0xef),
  49777 	495: uint8(0xf0),
  49778 	496: uint8(0xf1),
  49779 	497: uint8(0xf2),
  49780 	498: uint8(0xf3),
  49781 	499: uint8(0xf4),
  49782 	500: uint8(0xf5),
  49783 	501: uint8(0xf6),
  49784 	502: uint8(0xf7),
  49785 	503: uint8(0xf8),
  49786 	504: uint8(0xf9),
  49787 	505: uint8(0xfa),
  49788 	506: uint8(0xfb),
  49789 	507: uint8(0xfc),
  49790 	508: uint8(0xfd),
  49791 	509: uint8(0xfe),
  49792 	510: uint8(0xff),
  49793 	511: uint8(0xff),
  49794 	512: uint8(0xff),
  49795 	513: uint8(0xff),
  49796 	514: uint8(0xff),
  49797 	515: uint8(0xff),
  49798 	516: uint8(0xff),
  49799 	517: uint8(0xff),
  49800 	518: uint8(0xff),
  49801 	519: uint8(0xff),
  49802 	520: uint8(0xff),
  49803 	521: uint8(0xff),
  49804 	522: uint8(0xff),
  49805 	523: uint8(0xff),
  49806 	524: uint8(0xff),
  49807 	525: uint8(0xff),
  49808 	526: uint8(0xff),
  49809 	527: uint8(0xff),
  49810 	528: uint8(0xff),
  49811 	529: uint8(0xff),
  49812 	530: uint8(0xff),
  49813 	531: uint8(0xff),
  49814 	532: uint8(0xff),
  49815 	533: uint8(0xff),
  49816 	534: uint8(0xff),
  49817 	535: uint8(0xff),
  49818 	536: uint8(0xff),
  49819 	537: uint8(0xff),
  49820 	538: uint8(0xff),
  49821 	539: uint8(0xff),
  49822 	540: uint8(0xff),
  49823 	541: uint8(0xff),
  49824 	542: uint8(0xff),
  49825 	543: uint8(0xff),
  49826 	544: uint8(0xff),
  49827 	545: uint8(0xff),
  49828 	546: uint8(0xff),
  49829 	547: uint8(0xff),
  49830 	548: uint8(0xff),
  49831 	549: uint8(0xff),
  49832 	550: uint8(0xff),
  49833 	551: uint8(0xff),
  49834 	552: uint8(0xff),
  49835 	553: uint8(0xff),
  49836 	554: uint8(0xff),
  49837 	555: uint8(0xff),
  49838 	556: uint8(0xff),
  49839 	557: uint8(0xff),
  49840 	558: uint8(0xff),
  49841 	559: uint8(0xff),
  49842 	560: uint8(0xff),
  49843 	561: uint8(0xff),
  49844 	562: uint8(0xff),
  49845 	563: uint8(0xff),
  49846 	564: uint8(0xff),
  49847 	565: uint8(0xff),
  49848 	566: uint8(0xff),
  49849 	567: uint8(0xff),
  49850 	568: uint8(0xff),
  49851 	569: uint8(0xff),
  49852 	570: uint8(0xff),
  49853 	571: uint8(0xff),
  49854 	572: uint8(0xff),
  49855 	573: uint8(0xff),
  49856 	574: uint8(0xff),
  49857 	575: uint8(0xff),
  49858 	576: uint8(0xff),
  49859 	577: uint8(0xff),
  49860 	578: uint8(0xff),
  49861 	579: uint8(0xff),
  49862 	580: uint8(0xff),
  49863 	581: uint8(0xff),
  49864 	582: uint8(0xff),
  49865 	583: uint8(0xff),
  49866 	584: uint8(0xff),
  49867 	585: uint8(0xff),
  49868 	586: uint8(0xff),
  49869 	587: uint8(0xff),
  49870 	588: uint8(0xff),
  49871 	589: uint8(0xff),
  49872 	590: uint8(0xff),
  49873 	591: uint8(0xff),
  49874 	592: uint8(0xff),
  49875 	593: uint8(0xff),
  49876 	594: uint8(0xff),
  49877 	595: uint8(0xff),
  49878 	596: uint8(0xff),
  49879 	597: uint8(0xff),
  49880 	598: uint8(0xff),
  49881 	599: uint8(0xff),
  49882 	600: uint8(0xff),
  49883 	601: uint8(0xff),
  49884 	602: uint8(0xff),
  49885 	603: uint8(0xff),
  49886 	604: uint8(0xff),
  49887 	605: uint8(0xff),
  49888 	606: uint8(0xff),
  49889 	607: uint8(0xff),
  49890 	608: uint8(0xff),
  49891 	609: uint8(0xff),
  49892 	610: uint8(0xff),
  49893 	611: uint8(0xff),
  49894 	612: uint8(0xff),
  49895 	613: uint8(0xff),
  49896 	614: uint8(0xff),
  49897 	615: uint8(0xff),
  49898 	616: uint8(0xff),
  49899 	617: uint8(0xff),
  49900 	618: uint8(0xff),
  49901 	619: uint8(0xff),
  49902 	620: uint8(0xff),
  49903 	621: uint8(0xff),
  49904 	622: uint8(0xff),
  49905 	623: uint8(0xff),
  49906 	624: uint8(0xff),
  49907 	625: uint8(0xff),
  49908 	626: uint8(0xff),
  49909 	627: uint8(0xff),
  49910 	628: uint8(0xff),
  49911 	629: uint8(0xff),
  49912 	630: uint8(0xff),
  49913 	631: uint8(0xff),
  49914 	632: uint8(0xff),
  49915 	633: uint8(0xff),
  49916 	634: uint8(0xff),
  49917 	635: uint8(0xff),
  49918 	636: uint8(0xff),
  49919 	637: uint8(0xff),
  49920 	638: uint8(0xff),
  49921 	639: uint8(0xff),
  49922 	640: uint8(0xff),
  49923 	641: uint8(0xff),
  49924 	642: uint8(0xff),
  49925 	643: uint8(0xff),
  49926 	644: uint8(0xff),
  49927 	645: uint8(0xff),
  49928 	646: uint8(0xff),
  49929 	647: uint8(0xff),
  49930 	648: uint8(0xff),
  49931 	649: uint8(0xff),
  49932 	650: uint8(0xff),
  49933 	651: uint8(0xff),
  49934 	652: uint8(0xff),
  49935 	653: uint8(0xff),
  49936 	654: uint8(0xff),
  49937 	655: uint8(0xff),
  49938 	656: uint8(0xff),
  49939 	657: uint8(0xff),
  49940 	658: uint8(0xff),
  49941 	659: uint8(0xff),
  49942 	660: uint8(0xff),
  49943 	661: uint8(0xff),
  49944 	662: uint8(0xff),
  49945 	663: uint8(0xff),
  49946 	664: uint8(0xff),
  49947 	665: uint8(0xff),
  49948 	666: uint8(0xff),
  49949 	667: uint8(0xff),
  49950 	668: uint8(0xff),
  49951 	669: uint8(0xff),
  49952 	670: uint8(0xff),
  49953 	671: uint8(0xff),
  49954 	672: uint8(0xff),
  49955 	673: uint8(0xff),
  49956 	674: uint8(0xff),
  49957 	675: uint8(0xff),
  49958 	676: uint8(0xff),
  49959 	677: uint8(0xff),
  49960 	678: uint8(0xff),
  49961 	679: uint8(0xff),
  49962 	680: uint8(0xff),
  49963 	681: uint8(0xff),
  49964 	682: uint8(0xff),
  49965 	683: uint8(0xff),
  49966 	684: uint8(0xff),
  49967 	685: uint8(0xff),
  49968 	686: uint8(0xff),
  49969 	687: uint8(0xff),
  49970 	688: uint8(0xff),
  49971 	689: uint8(0xff),
  49972 	690: uint8(0xff),
  49973 	691: uint8(0xff),
  49974 	692: uint8(0xff),
  49975 	693: uint8(0xff),
  49976 	694: uint8(0xff),
  49977 	695: uint8(0xff),
  49978 	696: uint8(0xff),
  49979 	697: uint8(0xff),
  49980 	698: uint8(0xff),
  49981 	699: uint8(0xff),
  49982 	700: uint8(0xff),
  49983 	701: uint8(0xff),
  49984 	702: uint8(0xff),
  49985 	703: uint8(0xff),
  49986 	704: uint8(0xff),
  49987 	705: uint8(0xff),
  49988 	706: uint8(0xff),
  49989 	707: uint8(0xff),
  49990 	708: uint8(0xff),
  49991 	709: uint8(0xff),
  49992 	710: uint8(0xff),
  49993 	711: uint8(0xff),
  49994 	712: uint8(0xff),
  49995 	713: uint8(0xff),
  49996 	714: uint8(0xff),
  49997 	715: uint8(0xff),
  49998 	716: uint8(0xff),
  49999 	717: uint8(0xff),
  50000 	718: uint8(0xff),
  50001 	719: uint8(0xff),
  50002 	720: uint8(0xff),
  50003 	721: uint8(0xff),
  50004 	722: uint8(0xff),
  50005 	723: uint8(0xff),
  50006 	724: uint8(0xff),
  50007 	725: uint8(0xff),
  50008 	726: uint8(0xff),
  50009 	727: uint8(0xff),
  50010 	728: uint8(0xff),
  50011 	729: uint8(0xff),
  50012 	730: uint8(0xff),
  50013 	731: uint8(0xff),
  50014 	732: uint8(0xff),
  50015 	733: uint8(0xff),
  50016 	734: uint8(0xff),
  50017 	735: uint8(0xff),
  50018 	736: uint8(0xff),
  50019 	737: uint8(0xff),
  50020 	738: uint8(0xff),
  50021 	739: uint8(0xff),
  50022 	740: uint8(0xff),
  50023 	741: uint8(0xff),
  50024 	742: uint8(0xff),
  50025 	743: uint8(0xff),
  50026 	744: uint8(0xff),
  50027 	745: uint8(0xff),
  50028 	746: uint8(0xff),
  50029 	747: uint8(0xff),
  50030 	748: uint8(0xff),
  50031 	749: uint8(0xff),
  50032 	750: uint8(0xff),
  50033 	751: uint8(0xff),
  50034 	752: uint8(0xff),
  50035 	753: uint8(0xff),
  50036 	754: uint8(0xff),
  50037 	755: uint8(0xff),
  50038 	756: uint8(0xff),
  50039 	757: uint8(0xff),
  50040 	758: uint8(0xff),
  50041 	759: uint8(0xff),
  50042 	760: uint8(0xff),
  50043 	761: uint8(0xff),
  50044 	762: uint8(0xff),
  50045 	763: uint8(0xff),
  50046 	764: uint8(0xff),
  50047 	765: uint8(0xff),
  50048 }
  50049 
  50050 func VP8InitClipTables(tls *libc.TLS) {
  50051 }
  50052 
  50053 func VP8DspInitMIPS32(tls *libc.TLS) {
  50054 }
  50055 
  50056 func VP8DspInitMIPSdspR2(tls *libc.TLS) {
  50057 }
  50058 
  50059 func VP8DspInitMSA(tls *libc.TLS) {
  50060 }
  50061 
  50062 func VP8DspInitNEON(tls *libc.TLS) {
  50063 }
  50064 
  50065 func VP8DspInitSSE2(tls *libc.TLS) {
  50066 }
  50067 
  50068 func VP8DspInitSSE41(tls *libc.TLS) {
  50069 }
  50070 
  50071 //------------------------------------------------------------------------------
  50072 
  50073 // Copyright 2012 Google Inc. All Rights Reserved.
  50074 //
  50075 // Use of this source code is governed by a BSD-style license
  50076 // that can be found in the COPYING file in the root of the source
  50077 // tree. An additional intellectual property rights grant can be found
  50078 // in the file PATENTS. All contributing project authors may
  50079 // be found in the AUTHORS file in the root of the source tree.
  50080 // -----------------------------------------------------------------------------
  50081 //
  50082 // Misc. common utility functions
  50083 //
  50084 // Authors: Skal (pascal.massimino@gmail.com)
  50085 //          Urvang (urvang@google.com)
  50086 
  50087 // Copyright 2010 Google Inc. All Rights Reserved.
  50088 //
  50089 // Use of this source code is governed by a BSD-style license
  50090 // that can be found in the COPYING file in the root of the source
  50091 // tree. An additional intellectual property rights grant can be found
  50092 // in the file PATENTS. All contributing project authors may
  50093 // be found in the AUTHORS file in the root of the source tree.
  50094 // -----------------------------------------------------------------------------
  50095 //
  50096 //  Common types + memory wrappers
  50097 //
  50098 // Author: Skal (pascal.massimino@gmail.com)
  50099 
  50100 func clip_8b2(tls *libc.TLS, v int32) (r uint8_t) {
  50101 	var v1, v2 int32
  50102 	_, _ = v1, v2
  50103 	if !(v & ^libc.Int32FromInt32(0xff) != 0) {
  50104 		v1 = v
  50105 	} else {
  50106 		if v < 0 {
  50107 			v2 = 0
  50108 		} else {
  50109 			v2 = int32(255)
  50110 		}
  50111 		v1 = v2
  50112 	}
  50113 	return libc.Uint8FromInt32(v1)
  50114 }
  50115 
  50116 func clip_max(tls *libc.TLS, v int32, max int32) (r int32) {
  50117 	var v1 int32
  50118 	_ = v1
  50119 	if v > max {
  50120 		v1 = max
  50121 	} else {
  50122 		v1 = v
  50123 	}
  50124 	return v1
  50125 }
  50126 
  50127 // C documentation
  50128 //
  50129 //	// general-purpose util function
  50130 func VP8SetHistogramData(tls *libc.TLS, distribution uintptr, histo uintptr) {
  50131 	var k, last_non_zero, max_value, value int32
  50132 	_, _, _, _ = k, last_non_zero, max_value, value
  50133 	max_value = 0
  50134 	last_non_zero = int32(1)
  50135 	k = 0
  50136 	for {
  50137 		if !(k <= int32(MAX_COEFF_THRESH)) {
  50138 			break
  50139 		}
  50140 		value = **(**int32)(__ccgo_up(distribution + uintptr(k)*4))
  50141 		if value > 0 {
  50142 			if value > max_value {
  50143 				max_value = value
  50144 			}
  50145 			last_non_zero = k
  50146 		}
  50147 		goto _1
  50148 	_1:
  50149 		;
  50150 		k = k + 1
  50151 	}
  50152 	(*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value = max_value
  50153 	(*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero = last_non_zero
  50154 }
  50155 
  50156 func CollectHistogram_C(tls *libc.TLS, ref uintptr, pred uintptr, start_block int32, end_block int32, histo uintptr) {
  50157 	bp := tls.Alloc(160)
  50158 	defer tls.Free(160)
  50159 	var clipped_value, j, k, v int32
  50160 	var _ /* distribution at bp+0 */ [32]int32
  50161 	var _ /* out at bp+128 */ [16]int16_t
  50162 	_, _, _, _ = clipped_value, j, k, v
  50163 	**(**[32]int32)(__ccgo_up(bp)) = [32]int32{}
  50164 	j = start_block
  50165 	for {
  50166 		if !(j < end_block) {
  50167 			break
  50168 		}
  50169 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, ref+uintptr(VP8DspScan[j]), pred+uintptr(VP8DspScan[j]), bp+128)
  50170 		// Convert coefficients to bin.
  50171 		k = 0
  50172 		for {
  50173 			if !(k < int32(16)) {
  50174 				break
  50175 			}
  50176 			v = libc.Xabs(tls, int32((**(**[16]int16_t)(__ccgo_up(bp + 128)))[k])) >> int32(3)
  50177 			clipped_value = clip_max(tls, v, int32(MAX_COEFF_THRESH))
  50178 			(**(**[32]int32)(__ccgo_up(bp)))[clipped_value] = (**(**[32]int32)(__ccgo_up(bp)))[clipped_value] + 1
  50179 			goto _2
  50180 		_2:
  50181 			;
  50182 			k = k + 1
  50183 		}
  50184 		goto _1
  50185 	_1:
  50186 		;
  50187 		j = j + 1
  50188 	}
  50189 	VP8SetHistogramData(tls, bp, histo)
  50190 }
  50191 
  50192 //------------------------------------------------------------------------------
  50193 // run-time tables (~4k)
  50194 
  50195 var clip12 [766]uint8_t // clips [-255,510] to [0,255]
  50196 
  50197 // C documentation
  50198 //
  50199 //	// We declare this variable 'volatile' to prevent instruction reordering
  50200 //	// and make sure it's set to true _last_ (so as to be thread-safe)
  50201 var tables_ok = int32(0)
  50202 
  50203 func InitTables(tls *libc.TLS) {
  50204 	var i int32
  50205 	_ = i
  50206 	if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&tables_ok))) != 0) {
  50207 		i = -int32(255)
  50208 		for {
  50209 			if !(i <= libc.Int32FromInt32(255)+libc.Int32FromInt32(255)) {
  50210 				break
  50211 			}
  50212 			clip12[int32(255)+i] = clip_8b2(tls, i)
  50213 			goto _1
  50214 		_1:
  50215 			;
  50216 			i = i + 1
  50217 		}
  50218 		libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&tables_ok)), int32(1))
  50219 	}
  50220 }
  50221 
  50222 //------------------------------------------------------------------------------
  50223 // Transforms (Paragraph 14.4)
  50224 
  50225 func ITransformOne(tls *libc.TLS, ref uintptr, in uintptr, dst uintptr) {
  50226 	bp := tls.Alloc(64)
  50227 	defer tls.Free(64)
  50228 	var a, a1, b, b1, c, c1, d, d1, dc, i int32
  50229 	var tmp uintptr
  50230 	var _ /* C at bp+0 */ [16]int32
  50231 	_, _, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, c, c1, d, d1, dc, i, tmp
  50232 	tmp = bp
  50233 	i = 0
  50234 	for {
  50235 		if !(i < int32(4)) {
  50236 			break
  50237 		} // vertical pass
  50238 		a = int32(**(**int16_t)(__ccgo_up(in))) + int32(**(**int16_t)(__ccgo_up(in + 8*2)))
  50239 		b = int32(**(**int16_t)(__ccgo_up(in))) - int32(**(**int16_t)(__ccgo_up(in + 8*2)))
  50240 		c = int32(**(**int16_t)(__ccgo_up(in + 4*2)))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16) - (int32(**(**int16_t)(__ccgo_up(in + 12*2)))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + int32(**(**int16_t)(__ccgo_up(in + 12*2))))
  50241 		d = int32(**(**int16_t)(__ccgo_up(in + 4*2)))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + int32(**(**int16_t)(__ccgo_up(in + 4*2))) + int32(**(**int16_t)(__ccgo_up(in + 12*2)))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16)
  50242 		**(**int32)(__ccgo_up(tmp)) = a + d
  50243 		**(**int32)(__ccgo_up(tmp + 1*4)) = b + c
  50244 		**(**int32)(__ccgo_up(tmp + 2*4)) = b - c
  50245 		**(**int32)(__ccgo_up(tmp + 3*4)) = a - d
  50246 		tmp = tmp + uintptr(4)*4
  50247 		in += 2
  50248 		goto _1
  50249 	_1:
  50250 		;
  50251 		i = i + 1
  50252 	}
  50253 	tmp = bp
  50254 	i = 0
  50255 	for {
  50256 		if !(i < int32(4)) {
  50257 			break
  50258 		} // horizontal pass
  50259 		dc = **(**int32)(__ccgo_up(tmp)) + int32(4)
  50260 		a1 = dc + **(**int32)(__ccgo_up(tmp + 8*4))
  50261 		b1 = dc - **(**int32)(__ccgo_up(tmp + 8*4))
  50262 		c1 = **(**int32)(__ccgo_up(tmp + 4*4))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16) - (**(**int32)(__ccgo_up(tmp + 12*4))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + **(**int32)(__ccgo_up(tmp + 12*4)))
  50263 		d1 = **(**int32)(__ccgo_up(tmp + 4*4))*int32(WEBP_TRANSFORM_AC3_C1)>>int32(16) + **(**int32)(__ccgo_up(tmp + 4*4)) + **(**int32)(__ccgo_up(tmp + 12*4))*int32(WEBP_TRANSFORM_AC3_C2)>>int32(16)
  50264 		**(**uint8_t)(__ccgo_up(dst + uintptr(0+i*int32(BPS)))) = clip_8b2(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + uintptr(0+i*int32(BPS)))))+(a1+d1)>>int32(3))
  50265 		**(**uint8_t)(__ccgo_up(dst + uintptr(int32(1)+i*int32(BPS)))) = clip_8b2(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + uintptr(int32(1)+i*int32(BPS)))))+(b1+c1)>>int32(3))
  50266 		**(**uint8_t)(__ccgo_up(dst + uintptr(int32(2)+i*int32(BPS)))) = clip_8b2(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + uintptr(int32(2)+i*int32(BPS)))))+(b1-c1)>>int32(3))
  50267 		**(**uint8_t)(__ccgo_up(dst + uintptr(int32(3)+i*int32(BPS)))) = clip_8b2(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + uintptr(int32(3)+i*int32(BPS)))))+(a1-d1)>>int32(3))
  50268 		tmp += 4
  50269 		goto _2
  50270 	_2:
  50271 		;
  50272 		i = i + 1
  50273 	}
  50274 }
  50275 
  50276 func ITransform_C(tls *libc.TLS, ref uintptr, in uintptr, dst uintptr, do_two int32) {
  50277 	ITransformOne(tls, ref, in, dst)
  50278 	if do_two != 0 {
  50279 		ITransformOne(tls, ref+uintptr(4), in+uintptr(16)*2, dst+uintptr(4))
  50280 	}
  50281 }
  50282 
  50283 func FTransform_C(tls *libc.TLS, src uintptr, ref uintptr, out uintptr) {
  50284 	var a0, a01, a1, a11, a2, a21, a3, a31, d0, d1, d2, d3, i int32
  50285 	var tmp [16]int32
  50286 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, d0, d1, d2, d3, i, tmp
  50287 	i = 0
  50288 	for {
  50289 		if !(i < int32(4)) {
  50290 			break
  50291 		}
  50292 		d0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref))) // 9bit dynamic range ([-255,255])
  50293 		d1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 1))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 1)))
  50294 		d2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 2))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 2)))
  50295 		d3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 3))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 3)))
  50296 		a0 = d0 + d3 // 10b                      [-510,510]
  50297 		a1 = d1 + d2
  50298 		a2 = d1 - d2
  50299 		a3 = d0 - d3
  50300 		tmp[0+i*int32(4)] = (a0 + a1) * int32(8)                                               // 14b                      [-8160,8160]
  50301 		tmp[int32(1)+i*int32(4)] = (a2*int32(2217) + a3*int32(5352) + int32(1812)) >> int32(9) // [-7536,7542]
  50302 		tmp[int32(2)+i*int32(4)] = (a0 - a1) * int32(8)
  50303 		tmp[int32(3)+i*int32(4)] = (a3*int32(2217) - a2*int32(5352) + int32(937)) >> int32(9)
  50304 		goto _1
  50305 	_1:
  50306 		;
  50307 		i = i + 1
  50308 		src = src + uintptr(BPS)
  50309 		ref = ref + uintptr(BPS)
  50310 	}
  50311 	i = 0
  50312 	for {
  50313 		if !(i < int32(4)) {
  50314 			break
  50315 		}
  50316 		a01 = tmp[0+i] + tmp[int32(12)+i] // 15b
  50317 		a11 = tmp[int32(4)+i] + tmp[int32(8)+i]
  50318 		a21 = tmp[int32(4)+i] - tmp[int32(8)+i]
  50319 		a31 = tmp[0+i] - tmp[int32(12)+i]
  50320 		**(**int16_t)(__ccgo_up(out + uintptr(0+i)*2)) = int16((a01 + a11 + int32(7)) >> int32(4)) // 12b
  50321 		**(**int16_t)(__ccgo_up(out + uintptr(int32(4)+i)*2)) = int16((a21*int32(2217)+a31*int32(5352)+int32(12000))>>int32(16) + libc.BoolInt32(a31 != 0))
  50322 		**(**int16_t)(__ccgo_up(out + uintptr(int32(8)+i)*2)) = int16((a01 - a11 + int32(7)) >> int32(4))
  50323 		**(**int16_t)(__ccgo_up(out + uintptr(int32(12)+i)*2)) = int16((a31*libc.Int32FromInt32(2217) - a21*libc.Int32FromInt32(5352) + libc.Int32FromInt32(51000)) >> libc.Int32FromInt32(16))
  50324 		goto _2
  50325 	_2:
  50326 		;
  50327 		i = i + 1
  50328 	}
  50329 }
  50330 
  50331 func FTransform2_C(tls *libc.TLS, src uintptr, ref uintptr, out uintptr) {
  50332 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src, ref, out)
  50333 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src+uintptr(4), ref+uintptr(4), out+uintptr(16)*2)
  50334 }
  50335 
  50336 func FTransformWHT_C(tls *libc.TLS, in uintptr, out uintptr) {
  50337 	var a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i int32
  50338 	var tmp [16]int32_t
  50339 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, tmp
  50340 	i = 0
  50341 	for {
  50342 		if !(i < int32(4)) {
  50343 			break
  50344 		}
  50345 		a0 = int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2))) // 13b
  50346 		a1 = int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16))*2)))
  50347 		a2 = int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16))*2)))
  50348 		a3 = int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2)))
  50349 		tmp[0+i*int32(4)] = a0 + a1 // 14b
  50350 		tmp[int32(1)+i*int32(4)] = a3 + a2
  50351 		tmp[int32(2)+i*int32(4)] = a3 - a2
  50352 		tmp[int32(3)+i*int32(4)] = a0 - a1
  50353 		goto _1
  50354 	_1:
  50355 		;
  50356 		i = i + 1
  50357 		in = in + uintptr(64)*2
  50358 	}
  50359 	i = 0
  50360 	for {
  50361 		if !(i < int32(4)) {
  50362 			break
  50363 		}
  50364 		a01 = tmp[0+i] + tmp[int32(8)+i] // 15b
  50365 		a11 = tmp[int32(4)+i] + tmp[int32(12)+i]
  50366 		a21 = tmp[int32(4)+i] - tmp[int32(12)+i]
  50367 		a31 = tmp[0+i] - tmp[int32(8)+i]
  50368 		b0 = a01 + a11 // 16b
  50369 		b1 = a31 + a21
  50370 		b2 = a31 - a21
  50371 		b3 = a01 - a11
  50372 		**(**int16_t)(__ccgo_up(out + uintptr(0+i)*2)) = int16(b0 >> int32(1)) // 15b
  50373 		**(**int16_t)(__ccgo_up(out + uintptr(int32(4)+i)*2)) = int16(b1 >> int32(1))
  50374 		**(**int16_t)(__ccgo_up(out + uintptr(int32(8)+i)*2)) = int16(b2 >> int32(1))
  50375 		**(**int16_t)(__ccgo_up(out + uintptr(int32(12)+i)*2)) = int16(b3 >> int32(1))
  50376 		goto _2
  50377 	_2:
  50378 		;
  50379 		i = i + 1
  50380 	}
  50381 }
  50382 
  50383 //------------------------------------------------------------------------------
  50384 // Intra predictions
  50385 
  50386 func Fill(tls *libc.TLS, dst uintptr, value int32, size int32) {
  50387 	var j int32
  50388 	_ = j
  50389 	j = 0
  50390 	for {
  50391 		if !(j < size) {
  50392 			break
  50393 		}
  50394 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), value, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  50395 		goto _1
  50396 	_1:
  50397 		;
  50398 		j = j + 1
  50399 	}
  50400 }
  50401 
  50402 func VerticalPred(tls *libc.TLS, dst uintptr, top uintptr, size int32) {
  50403 	var j int32
  50404 	_ = j
  50405 	if top != libc.UintptrFromInt32(0) {
  50406 		j = 0
  50407 		for {
  50408 			if !(j < size) {
  50409 				break
  50410 			}
  50411 			libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), top, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  50412 			goto _1
  50413 		_1:
  50414 			;
  50415 			j = j + 1
  50416 		}
  50417 	} else {
  50418 		Fill(tls, dst, int32(127), size)
  50419 	}
  50420 }
  50421 
  50422 func HorizontalPred(tls *libc.TLS, dst uintptr, left uintptr, size int32) {
  50423 	var j int32
  50424 	_ = j
  50425 	if left != libc.UintptrFromInt32(0) {
  50426 		j = 0
  50427 		for {
  50428 			if !(j < size) {
  50429 				break
  50430 			}
  50431 			libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(j)))), libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  50432 			goto _1
  50433 		_1:
  50434 			;
  50435 			j = j + 1
  50436 		}
  50437 	} else {
  50438 		Fill(tls, dst, int32(129), size)
  50439 	}
  50440 }
  50441 
  50442 func TrueMotion1(tls *libc.TLS, dst uintptr, left uintptr, top uintptr, size int32) {
  50443 	var clip, clip_table uintptr
  50444 	var x, y int32
  50445 	_, _, _, _ = clip, clip_table, x, y
  50446 	if left != libc.UintptrFromInt32(0) {
  50447 		if top != libc.UintptrFromInt32(0) {
  50448 			clip = uintptr(unsafe.Pointer(&clip12)) + uintptr(255) - uintptr(**(**uint8_t)(__ccgo_up(left + uintptr(-libc.Int32FromInt32(1)))))
  50449 			y = 0
  50450 			for {
  50451 				if !(y < size) {
  50452 					break
  50453 				}
  50454 				clip_table = clip + uintptr(**(**uint8_t)(__ccgo_up(left + uintptr(y))))
  50455 				x = 0
  50456 				for {
  50457 					if !(x < size) {
  50458 						break
  50459 					}
  50460 					**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip_table + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  50461 					goto _2
  50462 				_2:
  50463 					;
  50464 					x = x + 1
  50465 				}
  50466 				dst = dst + uintptr(BPS)
  50467 				goto _1
  50468 			_1:
  50469 				;
  50470 				y = y + 1
  50471 			}
  50472 		} else {
  50473 			HorizontalPred(tls, dst, left, size)
  50474 		}
  50475 	} else {
  50476 		// true motion without left samples (hence: with default 129 value)
  50477 		// is equivalent to VE prediction where you just copy the top samples.
  50478 		// Note that if top samples are not available, the default value is
  50479 		// then 129, and not 127 as in the VerticalPred case.
  50480 		if top != libc.UintptrFromInt32(0) {
  50481 			VerticalPred(tls, dst, top, size)
  50482 		} else {
  50483 			Fill(tls, dst, int32(129), size)
  50484 		}
  50485 	}
  50486 }
  50487 
  50488 func DCMode(tls *libc.TLS, dst uintptr, left uintptr, top uintptr, size int32, round int32, shift int32) {
  50489 	var DC, j int32
  50490 	_, _ = DC, j
  50491 	DC = 0
  50492 	if top != libc.UintptrFromInt32(0) {
  50493 		j = 0
  50494 		for {
  50495 			if !(j < size) {
  50496 				break
  50497 			}
  50498 			DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(j))))
  50499 			goto _1
  50500 		_1:
  50501 			;
  50502 			j = j + 1
  50503 		}
  50504 		if left != libc.UintptrFromInt32(0) { // top and left present
  50505 			j = 0
  50506 			for {
  50507 				if !(j < size) {
  50508 					break
  50509 				}
  50510 				DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(j))))
  50511 				goto _2
  50512 			_2:
  50513 				;
  50514 				j = j + 1
  50515 			}
  50516 		} else { // top, but no left
  50517 			DC = DC + DC
  50518 		}
  50519 		DC = (DC + round) >> shift
  50520 	} else {
  50521 		if left != libc.UintptrFromInt32(0) { // left but no top
  50522 			j = 0
  50523 			for {
  50524 				if !(j < size) {
  50525 					break
  50526 				}
  50527 				DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(j))))
  50528 				goto _3
  50529 			_3:
  50530 				;
  50531 				j = j + 1
  50532 			}
  50533 			DC = DC + DC
  50534 			DC = (DC + round) >> shift
  50535 		} else { // no top, no left, nothing.
  50536 			DC = int32(0x80)
  50537 		}
  50538 	}
  50539 	Fill(tls, dst, DC, size)
  50540 }
  50541 
  50542 //------------------------------------------------------------------------------
  50543 // Chroma 8x8 prediction (paragraph 12.2)
  50544 
  50545 func IntraChromaPreds_C(tls *libc.TLS, dst uintptr, left uintptr, top uintptr) {
  50546 	// U block
  50547 	DCMode(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(8), int32(8), int32(4))
  50548 	VerticalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS))+dst, top, int32(8))
  50549 	HorizontalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, int32(8))
  50550 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, top, int32(8))
  50551 	// V block
  50552 	dst = dst + uintptr(8)
  50553 	if top != libc.UintptrFromInt32(0) {
  50554 		top = top + uintptr(8)
  50555 	}
  50556 	if left != libc.UintptrFromInt32(0) {
  50557 		left = left + uintptr(16)
  50558 	}
  50559 	DCMode(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(8), int32(8), int32(4))
  50560 	VerticalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS))+dst, top, int32(8))
  50561 	HorizontalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, int32(8))
  50562 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, top, int32(8))
  50563 }
  50564 
  50565 //------------------------------------------------------------------------------
  50566 // luma 16x16 prediction (paragraph 12.3)
  50567 
  50568 func Intra16Preds_C(tls *libc.TLS, dst uintptr, left uintptr, top uintptr) {
  50569 	DCMode(tls, uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(16), int32(16), int32(5))
  50570 	VerticalPred(tls, uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, top, int32(16))
  50571 	HorizontalPred(tls, uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(16))+dst, left, int32(16))
  50572 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(16))+dst, left, top, int32(16))
  50573 }
  50574 
  50575 //------------------------------------------------------------------------------
  50576 // luma 4x4 prediction
  50577 
  50578 // C documentation
  50579 //
  50580 //	// vertical
  50581 func VE4(tls *libc.TLS, dst uintptr, top uintptr) {
  50582 	bp := tls.Alloc(16)
  50583 	defer tls.Free(16)
  50584 	var i int32
  50585 	var _ /* vals at bp+0 */ [4]uint8_t
  50586 	_ = i
  50587 	**(**[4]uint8_t)(__ccgo_up(bp)) = [4]uint8_t{
  50588 		0: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  50589 		1: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  50590 		2: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  50591 		3: libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2))) + libc.Int32FromInt32(2)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4))) + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2)),
  50592 	}
  50593 	i = 0
  50594 	for {
  50595 		if !(i < int32(4)) {
  50596 			break
  50597 		}
  50598 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(i*int32(BPS)), bp, uint64(4), ^__predefined_size_t(0))
  50599 		goto _1
  50600 	_1:
  50601 		;
  50602 		i = i + 1
  50603 	}
  50604 }
  50605 
  50606 // C documentation
  50607 //
  50608 //	// horizontal
  50609 func HE4(tls *libc.TLS, dst uintptr, top uintptr) {
  50610 	bp := tls.Alloc(16)
  50611 	defer tls.Free(16)
  50612 	var I, J, K, L, X int32
  50613 	var v1 uintptr
  50614 	var v2 uint32_t
  50615 	_, _, _, _, _, _, _ = I, J, K, L, X, v1, v2
  50616 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50617 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50618 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50619 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50620 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50621 	v1 = dst + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS))
  50622 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((X+libc.Int32FromInt32(2)*I+J+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50623 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50624 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50625 	v1 = dst + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS))
  50626 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((I+libc.Int32FromInt32(2)*J+K+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50627 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50628 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50629 	v1 = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))
  50630 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((J+libc.Int32FromInt32(2)*K+L+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50631 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50632 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50633 	v1 = dst + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))
  50634 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((K+libc.Int32FromInt32(2)*L+L+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50635 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50636 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50637 }
  50638 
  50639 func DC4(tls *libc.TLS, dst uintptr, top uintptr) {
  50640 	var dc uint32_t
  50641 	var i int32
  50642 	_, _ = dc, i
  50643 	dc = uint32(4)
  50644 	i = 0
  50645 	for {
  50646 		if !(i < int32(4)) {
  50647 			break
  50648 		}
  50649 		dc = dc + libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(i))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-int32(5)+i)))))
  50650 		goto _1
  50651 	_1:
  50652 		;
  50653 		i = i + 1
  50654 	}
  50655 	Fill(tls, dst, libc.Int32FromUint32(dc>>int32(3)), int32(4))
  50656 }
  50657 
  50658 func RD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50659 	var A, B, C, D, I, J, K, L, X int32
  50660 	var v1, v2, v3 uint8_t
  50661 	_, _, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, L, X, v1, v2, v3
  50662 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50663 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50664 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50665 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50666 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50667 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50668 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50669 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50670 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50671 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50672 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50673 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50674 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50675 	v2 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*I + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50676 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50677 	v1 = v2
  50678 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50679 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50680 	v3 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*X + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50681 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50682 	v2 = v3
  50683 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50684 	v1 = v2
  50685 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50686 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50687 	v2 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*A + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50688 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50689 	v1 = v2
  50690 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50691 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50692 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*B + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50693 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50694 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50695 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*C + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50696 }
  50697 
  50698 func LD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50699 	var A, B, C, D, E, F, G, H int32
  50700 	var v1, v2, v3 uint8_t
  50701 	_, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1, v2, v3
  50702 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50703 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50704 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50705 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50706 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4)))
  50707 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 5)))
  50708 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 6)))
  50709 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 7)))
  50710 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50711 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50712 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50713 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50714 	v2 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50715 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50716 	v1 = v2
  50717 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50718 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50719 	v3 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50720 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50721 	v2 = v3
  50722 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50723 	v1 = v2
  50724 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50725 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50726 	v2 = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50727 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50728 	v1 = v2
  50729 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50730 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50731 	v1 = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50732 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50733 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50734 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((G + libc.Int32FromInt32(2)*H + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50735 }
  50736 
  50737 func VR4(tls *libc.TLS, dst uintptr, top uintptr) {
  50738 	var A, B, C, D, I, J, K, X int32
  50739 	var v1 uint8_t
  50740 	_, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, X, v1
  50741 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50742 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50743 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50744 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50745 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50746 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50747 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50748 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50749 	v1 = libc.Uint8FromInt32((X + A + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50750 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50751 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50752 	v1 = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50753 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50754 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50755 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50756 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50757 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50758 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50759 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50760 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50761 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50762 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50763 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50764 	v1 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50765 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50766 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50767 	v1 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50768 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50769 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50770 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50771 }
  50772 
  50773 func VL4(tls *libc.TLS, dst uintptr, top uintptr) {
  50774 	var A, B, C, D, E, F, G, H int32
  50775 	var v1 uint8_t
  50776 	_, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1
  50777 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50778 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50779 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50780 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50781 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4)))
  50782 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 5)))
  50783 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 6)))
  50784 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 7)))
  50785 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50786 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50787 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50788 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50789 	v1 = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50790 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50791 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50792 	v1 = libc.Uint8FromInt32((D + E + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50793 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50794 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50795 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50796 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50797 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50798 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50799 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50800 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50801 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50802 	v1 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50803 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50804 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50805 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50806 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50807 }
  50808 
  50809 func HU4(tls *libc.TLS, dst uintptr, top uintptr) {
  50810 	var I, J, K, L int32
  50811 	var v1, v2, v3, v4, v5 uint8_t
  50812 	_, _, _, _, _, _, _, _, _ = I, J, K, L, v1, v2, v3, v4, v5
  50813 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50814 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50815 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50816 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50817 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((I + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50818 	v1 = libc.Uint8FromInt32((J + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50819 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50820 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50821 	v1 = libc.Uint8FromInt32((K + L + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50822 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50823 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50824 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50825 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50826 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50827 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50828 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*L + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50829 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50830 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50831 	v5 = libc.Uint8FromInt32(L)
  50832 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v5
  50833 	v4 = v5
  50834 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v4
  50835 	v3 = v4
  50836 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50837 	v2 = v3
  50838 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50839 	v1 = v2
  50840 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50841 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50842 }
  50843 
  50844 func HD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50845 	var A, B, C, I, J, K, L, X int32
  50846 	var v1 uint8_t
  50847 	_, _, _, _, _, _, _, _, _ = A, B, C, I, J, K, L, X, v1
  50848 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50849 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50850 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50851 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50852 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50853 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50854 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50855 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50856 	v1 = libc.Uint8FromInt32((I + X + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50857 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50858 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50859 	v1 = libc.Uint8FromInt32((J + I + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50860 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50861 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50862 	v1 = libc.Uint8FromInt32((K + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50863 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50864 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50865 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((L + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50866 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50867 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50868 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50869 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50870 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50871 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50872 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50873 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50874 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50875 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50876 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50877 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = libc.Uint8FromInt32((L + libc.Int32FromInt32(2)*K + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50878 }
  50879 
  50880 func TM4(tls *libc.TLS, dst uintptr, top uintptr) {
  50881 	var clip, clip_table uintptr
  50882 	var x, y int32
  50883 	_, _, _, _ = clip, clip_table, x, y
  50884 	clip = uintptr(unsafe.Pointer(&clip12)) + uintptr(255) - uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50885 	y = 0
  50886 	for {
  50887 		if !(y < int32(4)) {
  50888 			break
  50889 		}
  50890 		clip_table = clip + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-int32(2)-y))))
  50891 		x = 0
  50892 		for {
  50893 			if !(x < int32(4)) {
  50894 				break
  50895 			}
  50896 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip_table + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  50897 			goto _2
  50898 		_2:
  50899 			;
  50900 			x = x + 1
  50901 		}
  50902 		dst = dst + uintptr(BPS)
  50903 		goto _1
  50904 	_1:
  50905 		;
  50906 		y = y + 1
  50907 	}
  50908 }
  50909 
  50910 // C documentation
  50911 //
  50912 //	// Left samples are top[-5 .. -2], top_left is top[-1], top are
  50913 //	// located at top[0..3], and top right is top[4..7]
  50914 func Intra4Preds_C(tls *libc.TLS, dst uintptr, top uintptr) {
  50915 	DC4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0))+dst, top)
  50916 	TM4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(4))+dst, top)
  50917 	VE4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(8))+dst, top)
  50918 	HE4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(12))+dst, top)
  50919 	RD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(16))+dst, top)
  50920 	VR4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(20))+dst, top)
  50921 	LD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(24))+dst, top)
  50922 	VL4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(28))+dst, top)
  50923 	HD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS))+dst, top)
  50924 	HU4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4))+dst, top)
  50925 }
  50926 
  50927 //------------------------------------------------------------------------------
  50928 // Metric
  50929 
  50930 func GetSSE(tls *libc.TLS, a uintptr, b uintptr, w int32, h int32) (r int32) {
  50931 	var count, diff, x, y int32
  50932 	_, _, _, _ = count, diff, x, y
  50933 	count = 0
  50934 	y = 0
  50935 	for {
  50936 		if !(y < h) {
  50937 			break
  50938 		}
  50939 		x = 0
  50940 		for {
  50941 			if !(x < w) {
  50942 				break
  50943 			}
  50944 			diff = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a + uintptr(x)))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(b + uintptr(x))))
  50945 			count = count + diff*diff
  50946 			goto _2
  50947 		_2:
  50948 			;
  50949 			x = x + 1
  50950 		}
  50951 		a = a + uintptr(BPS)
  50952 		b = b + uintptr(BPS)
  50953 		goto _1
  50954 	_1:
  50955 		;
  50956 		y = y + 1
  50957 	}
  50958 	return count
  50959 }
  50960 
  50961 func SSE16x16_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50962 	return GetSSE(tls, a, b, int32(16), int32(16))
  50963 }
  50964 
  50965 func SSE16x8_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50966 	return GetSSE(tls, a, b, int32(16), int32(8))
  50967 }
  50968 
  50969 func SSE8x8_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50970 	return GetSSE(tls, a, b, int32(8), int32(8))
  50971 }
  50972 
  50973 func SSE4x4_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50974 	return GetSSE(tls, a, b, int32(4), int32(4))
  50975 }
  50976 
  50977 func Mean16x4_C(tls *libc.TLS, ref uintptr, dc uintptr) {
  50978 	var avg uint32_t
  50979 	var k, x, y int32
  50980 	_, _, _, _ = avg, k, x, y
  50981 	k = 0
  50982 	for {
  50983 		if !(k < int32(4)) {
  50984 			break
  50985 		}
  50986 		avg = uint32(0)
  50987 		y = 0
  50988 		for {
  50989 			if !(y < int32(4)) {
  50990 				break
  50991 			}
  50992 			x = 0
  50993 			for {
  50994 				if !(x < int32(4)) {
  50995 					break
  50996 				}
  50997 				avg = avg + uint32(**(**uint8_t)(__ccgo_up(ref + uintptr(x+y*int32(BPS)))))
  50998 				goto _3
  50999 			_3:
  51000 				;
  51001 				x = x + 1
  51002 			}
  51003 			goto _2
  51004 		_2:
  51005 			;
  51006 			y = y + 1
  51007 		}
  51008 		**(**uint32_t)(__ccgo_up(dc + uintptr(k)*4)) = avg
  51009 		ref = ref + uintptr(4) // go to next 4x4 block.
  51010 		goto _1
  51011 	_1:
  51012 		;
  51013 		k = k + 1
  51014 	}
  51015 }
  51016 
  51017 //------------------------------------------------------------------------------
  51018 // Texture distortion
  51019 //
  51020 // We try to match the spectral content (weighted) between source and
  51021 // reconstructed samples.
  51022 
  51023 // C documentation
  51024 //
  51025 //	// Hadamard transform
  51026 //	// Returns the weighted sum of the absolute value of transformed coefficients.
  51027 //	// w[] contains a row-major 4 by 4 symmetric matrix.
  51028 func TTransform(tls *libc.TLS, in uintptr, w uintptr) (r int32) {
  51029 	var a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, sum int32
  51030 	var tmp [16]int32
  51031 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, sum, tmp
  51032 	sum = 0
  51033 	// horizontal pass
  51034 	i = 0
  51035 	for {
  51036 		if !(i < int32(4)) {
  51037 			break
  51038 		}
  51039 		a0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 2)))
  51040 		a1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 1))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 3)))
  51041 		a2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 1))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 3)))
  51042 		a3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 2)))
  51043 		tmp[0+i*int32(4)] = a0 + a1
  51044 		tmp[int32(1)+i*int32(4)] = a3 + a2
  51045 		tmp[int32(2)+i*int32(4)] = a3 - a2
  51046 		tmp[int32(3)+i*int32(4)] = a0 - a1
  51047 		goto _1
  51048 	_1:
  51049 		;
  51050 		i = i + 1
  51051 		in = in + uintptr(BPS)
  51052 	}
  51053 	// vertical pass
  51054 	i = 0
  51055 	for {
  51056 		if !(i < int32(4)) {
  51057 			break
  51058 		}
  51059 		a01 = tmp[0+i] + tmp[int32(8)+i]
  51060 		a11 = tmp[int32(4)+i] + tmp[int32(12)+i]
  51061 		a21 = tmp[int32(4)+i] - tmp[int32(12)+i]
  51062 		a31 = tmp[0+i] - tmp[int32(8)+i]
  51063 		b0 = a01 + a11
  51064 		b1 = a31 + a21
  51065 		b2 = a31 - a21
  51066 		b3 = a01 - a11
  51067 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w)))*libc.Xabs(tls, b0)
  51068 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 4*2)))*libc.Xabs(tls, b1)
  51069 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 8*2)))*libc.Xabs(tls, b2)
  51070 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 12*2)))*libc.Xabs(tls, b3)
  51071 		goto _2
  51072 	_2:
  51073 		;
  51074 		i = i + 1
  51075 		w += 2
  51076 	}
  51077 	return sum
  51078 }
  51079 
  51080 func Disto4x4_C(tls *libc.TLS, a uintptr, b uintptr, w uintptr) (r int32) {
  51081 	var sum1, sum2 int32
  51082 	_, _ = sum1, sum2
  51083 	sum1 = TTransform(tls, a, w)
  51084 	sum2 = TTransform(tls, b, w)
  51085 	return libc.Xabs(tls, sum2-sum1) >> int32(5)
  51086 }
  51087 
  51088 func Disto16x16_C(tls *libc.TLS, a uintptr, b uintptr, w uintptr) (r int32) {
  51089 	var D, x, y int32
  51090 	_, _, _ = D, x, y
  51091 	D = 0
  51092 	y = 0
  51093 	for {
  51094 		if !(y < libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)) {
  51095 			break
  51096 		}
  51097 		x = 0
  51098 		for {
  51099 			if !(x < int32(16)) {
  51100 				break
  51101 			}
  51102 			D = D + Disto4x4_C(tls, a+uintptr(x)+uintptr(y), b+uintptr(x)+uintptr(y), w)
  51103 			goto _2
  51104 		_2:
  51105 			;
  51106 			x = x + int32(4)
  51107 		}
  51108 		goto _1
  51109 	_1:
  51110 		;
  51111 		y = y + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)
  51112 	}
  51113 	return D
  51114 }
  51115 
  51116 //------------------------------------------------------------------------------
  51117 // Quantization
  51118 //
  51119 
  51120 var kZigzag2 = [16]uint8_t{
  51121 	1:  uint8(1),
  51122 	2:  uint8(4),
  51123 	3:  uint8(8),
  51124 	4:  uint8(5),
  51125 	5:  uint8(2),
  51126 	6:  uint8(3),
  51127 	7:  uint8(6),
  51128 	8:  uint8(9),
  51129 	9:  uint8(12),
  51130 	10: uint8(13),
  51131 	11: uint8(10),
  51132 	12: uint8(7),
  51133 	13: uint8(11),
  51134 	14: uint8(14),
  51135 	15: uint8(15),
  51136 }
  51137 
  51138 // C documentation
  51139 //
  51140 //	// Simple quantization
  51141 func QuantizeBlock_C(tls *libc.TLS, in uintptr, out uintptr, mtx uintptr) (r int32) {
  51142 	var B1, Q, coeff, iQ1 uint32_t
  51143 	var j, last, level, n1, sign, v2, v3 int32
  51144 	_, _, _, _, _, _, _, _, _, _, _ = B1, Q, coeff, iQ1, j, last, level, n1, sign, v2, v3
  51145 	last = -int32(1)
  51146 	n1 = 0
  51147 	for {
  51148 		if !(n1 < int32(16)) {
  51149 			break
  51150 		}
  51151 		j = libc.Int32FromUint8(kZigzag2[n1])
  51152 		sign = libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2))) < libc.Int32FromInt32(0))
  51153 		if sign != 0 {
  51154 			v2 = -int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  51155 		} else {
  51156 			v2 = int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  51157 		}
  51158 		coeff = libc.Uint32FromInt32(v2 + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 192 + uintptr(j)*2))))
  51159 		if coeff > **(**uint32_t)(__ccgo_up(mtx + 128 + uintptr(j)*4)) {
  51160 			Q = uint32(**(**uint16_t)(__ccgo_up(mtx + uintptr(j)*2)))
  51161 			iQ1 = uint32(**(**uint16_t)(__ccgo_up(mtx + 32 + uintptr(j)*2)))
  51162 			B1 = **(**uint32_t)(__ccgo_up(mtx + 64 + uintptr(j)*4))
  51163 			v3 = libc.Int32FromUint32((coeff*iQ1 + B1) >> libc.Int32FromInt32(QFIX))
  51164 			goto _4
  51165 		_4:
  51166 			level = v3
  51167 			if level > int32(MAX_LEVEL) {
  51168 				level = int32(MAX_LEVEL)
  51169 			}
  51170 			if sign != 0 {
  51171 				level = -level
  51172 			}
  51173 			**(**int16_t)(__ccgo_up(in + uintptr(j)*2)) = int16(level * libc.Int32FromUint32(Q))
  51174 			**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = int16(level)
  51175 			if level != 0 {
  51176 				last = n1
  51177 			}
  51178 		} else {
  51179 			**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = 0
  51180 			**(**int16_t)(__ccgo_up(in + uintptr(j)*2)) = 0
  51181 		}
  51182 		goto _1
  51183 	_1:
  51184 		;
  51185 		n1 = n1 + 1
  51186 	}
  51187 	return libc.BoolInt32(last >= 0)
  51188 }
  51189 
  51190 func Quantize2Blocks_C(tls *libc.TLS, in uintptr, out uintptr, mtx uintptr) (r int32) {
  51191 	var nz int32
  51192 	_ = nz
  51193 	nz = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlock})))(tls, in+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, out+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, mtx) << 0
  51194 	nz = nz | (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlock})))(tls, in+uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2, out+uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2, mtx)<<int32(1)
  51195 	return nz
  51196 }
  51197 
  51198 //------------------------------------------------------------------------------
  51199 // Block copy
  51200 
  51201 func Copy(tls *libc.TLS, src uintptr, dst uintptr, w int32, h int32) {
  51202 	var y int32
  51203 	_ = y
  51204 	y = 0
  51205 	for {
  51206 		if !(y < h) {
  51207 			break
  51208 		}
  51209 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  51210 		src = src + uintptr(BPS)
  51211 		dst = dst + uintptr(BPS)
  51212 		goto _1
  51213 	_1:
  51214 		;
  51215 		y = y + 1
  51216 	}
  51217 }
  51218 
  51219 func Copy4x4_C(tls *libc.TLS, src uintptr, dst uintptr) {
  51220 	Copy(tls, src, dst, int32(4), int32(4))
  51221 }
  51222 
  51223 func Copy16x8_C(tls *libc.TLS, src uintptr, dst uintptr) {
  51224 	Copy(tls, src, dst, int32(16), int32(8))
  51225 }
  51226 
  51227 func VP8EncDspInit(tls *libc.TLS) {
  51228 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  51229 		goto _1
  51230 	}
  51231 	VP8EncDspInit_body(tls)
  51232 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  51233 	goto _2
  51234 _2:
  51235 	;
  51236 	goto _1
  51237 _1: /**/ //
  51238 }
  51239 
  51240 var VP8EncDspInit_body_last_cpuinfo_used = uintptr(0)
  51241 
  51242 func init() {
  51243 	p := unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used)
  51244 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used))
  51245 }
  51246 
  51247 func VP8EncDspInit_body(tls *libc.TLS) {
  51248 	VP8DspInit(tls) // common inverse transforms
  51249 	InitTables(tls)
  51250 	// default C implementations
  51251 	VP8ITransform = __ccgo_fp(ITransform_C)
  51252 	VP8FTransform = __ccgo_fp(FTransform_C)
  51253 	VP8FTransformWHT = __ccgo_fp(FTransformWHT_C)
  51254 	VP8TDisto4x4 = __ccgo_fp(Disto4x4_C)
  51255 	VP8TDisto16x16 = __ccgo_fp(Disto16x16_C)
  51256 	VP8CollectHistogram = __ccgo_fp(CollectHistogram_C)
  51257 	VP8SSE16x16 = __ccgo_fp(SSE16x16_C)
  51258 	VP8SSE16x8 = __ccgo_fp(SSE16x8_C)
  51259 	VP8SSE8x8 = __ccgo_fp(SSE8x8_C)
  51260 	VP8SSE4x4 = __ccgo_fp(SSE4x4_C)
  51261 	VP8EncQuantizeBlock = __ccgo_fp(QuantizeBlock_C)
  51262 	VP8EncQuantize2Blocks = __ccgo_fp(Quantize2Blocks_C)
  51263 	VP8EncQuantizeBlockWHT = __ccgo_fp(QuantizeBlock_C)
  51264 	VP8EncPredLuma4 = __ccgo_fp(Intra4Preds_C)
  51265 	VP8EncPredLuma16 = __ccgo_fp(Intra16Preds_C)
  51266 	VP8FTransform2 = __ccgo_fp(FTransform2_C)
  51267 	VP8EncPredChroma8 = __ccgo_fp(IntraChromaPreds_C)
  51268 	VP8Mean16x4 = __ccgo_fp(Mean16x4_C)
  51269 	VP8Copy4x4 = __ccgo_fp(Copy4x4_C)
  51270 	VP8Copy16x8 = __ccgo_fp(Copy16x8_C)
  51271 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  51272 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  51273 	}
  51274 }
  51275 
  51276 func VP8EncDspInitMIPS32(tls *libc.TLS) {
  51277 }
  51278 
  51279 func VP8EncDspInitMIPSdspR2(tls *libc.TLS) {
  51280 }
  51281 
  51282 func VP8EncDspInitMSA(tls *libc.TLS) {
  51283 }
  51284 
  51285 func VP8EncDspInitNEON(tls *libc.TLS) {
  51286 }
  51287 
  51288 func VP8EncDspInitSSE2(tls *libc.TLS) {
  51289 }
  51290 
  51291 func VP8EncDspInitSSE41(tls *libc.TLS) {
  51292 }
  51293 
  51294 // Copyright 2010 Google Inc. All Rights Reserved.
  51295 //
  51296 // Use of this source code is governed by a BSD-style license
  51297 // that can be found in the COPYING file in the root of the source
  51298 // tree. An additional intellectual property rights grant can be found
  51299 // in the file PATENTS. All contributing project authors may
  51300 // be found in the AUTHORS file in the root of the source tree.
  51301 // -----------------------------------------------------------------------------
  51302 //
  51303 //  Common types + memory wrappers
  51304 //
  51305 // Author: Skal (pascal.massimino@gmail.com)
  51306 
  51307 //------------------------------------------------------------------------------
  51308 // Helpful macro.
  51309 
  51310 func PredictLine_C(tls *libc.TLS, src uintptr, pred uintptr, dst uintptr, length int32) {
  51311 	var i int32
  51312 	_ = i
  51313 	i = 0
  51314 	for {
  51315 		if !(i < length) {
  51316 			break
  51317 		}
  51318 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + uintptr(i)))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(pred + uintptr(i)))))
  51319 		goto _1
  51320 	_1:
  51321 		;
  51322 		i = i + 1
  51323 	}
  51324 }
  51325 
  51326 //------------------------------------------------------------------------------
  51327 // Horizontal filter.
  51328 
  51329 func DoHorizontalFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51330 	var preds uintptr
  51331 	var row int32
  51332 	_, _ = preds, row
  51333 	preds = in
  51334 	// Leftmost pixel is the same as input for topmost scanline.
  51335 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51336 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51337 	preds = preds + uintptr(stride)
  51338 	in = in + uintptr(stride)
  51339 	out = out + uintptr(stride)
  51340 	// Filter line-by-line.
  51341 	row = int32(1)
  51342 	for {
  51343 		if !(row < height) {
  51344 			break
  51345 		}
  51346 		// Leftmost pixel is predicted from above.
  51347 		PredictLine_C(tls, in, preds-uintptr(stride), out, int32(1))
  51348 		PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51349 		preds = preds + uintptr(stride)
  51350 		in = in + uintptr(stride)
  51351 		out = out + uintptr(stride)
  51352 		goto _1
  51353 	_1:
  51354 		;
  51355 		row = row + 1
  51356 	}
  51357 }
  51358 
  51359 //------------------------------------------------------------------------------
  51360 // Vertical filter.
  51361 
  51362 func DoVerticalFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51363 	var preds uintptr
  51364 	var row int32
  51365 	_, _ = preds, row
  51366 	preds = in
  51367 	// Very first top-left pixel is copied.
  51368 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51369 	// Rest of top scan-line is left-predicted.
  51370 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51371 	in = in + uintptr(stride)
  51372 	out = out + uintptr(stride)
  51373 	// Filter line-by-line.
  51374 	row = int32(1)
  51375 	for {
  51376 		if !(row < height) {
  51377 			break
  51378 		}
  51379 		PredictLine_C(tls, in, preds, out, width)
  51380 		preds = preds + uintptr(stride)
  51381 		in = in + uintptr(stride)
  51382 		out = out + uintptr(stride)
  51383 		goto _1
  51384 	_1:
  51385 		;
  51386 		row = row + 1
  51387 	}
  51388 }
  51389 
  51390 //------------------------------------------------------------------------------
  51391 // Gradient filter.
  51392 
  51393 func GradientPredictor_C(tls *libc.TLS, a uint8_t, b uint8_t, c uint8_t) (r int32) {
  51394 	var g, v1, v2 int32
  51395 	_, _, _ = g, v1, v2
  51396 	g = libc.Int32FromUint8(a) + libc.Int32FromUint8(b) - libc.Int32FromUint8(c)
  51397 	if g & ^libc.Int32FromInt32(0xff) == 0 {
  51398 		v1 = g
  51399 	} else {
  51400 		if g < 0 {
  51401 			v2 = 0
  51402 		} else {
  51403 			v2 = int32(255)
  51404 		}
  51405 		v1 = v2
  51406 	}
  51407 	return v1 // clip to 8bit
  51408 }
  51409 
  51410 func DoGradientFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51411 	var pred, row, w int32
  51412 	var preds uintptr
  51413 	_, _, _, _ = pred, preds, row, w
  51414 	preds = in
  51415 	// left prediction for top scan-line
  51416 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51417 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51418 	preds = preds + uintptr(stride)
  51419 	in = in + uintptr(stride)
  51420 	out = out + uintptr(stride)
  51421 	// Filter line-by-line.
  51422 	row = int32(1)
  51423 	for {
  51424 		if !(row < height) {
  51425 			break
  51426 		}
  51427 		// leftmost pixel: predict from above.
  51428 		PredictLine_C(tls, in, preds-uintptr(stride), out, int32(1))
  51429 		w = int32(1)
  51430 		for {
  51431 			if !(w < width) {
  51432 				break
  51433 			}
  51434 			pred = GradientPredictor_C(tls, **(**uint8_t)(__ccgo_up(preds + uintptr(w-int32(1)))), **(**uint8_t)(__ccgo_up(preds + uintptr(w-stride))), **(**uint8_t)(__ccgo_up(preds + uintptr(w-stride-int32(1)))))
  51435 			**(**uint8_t)(__ccgo_up(out + uintptr(w))) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(w)))) - pred)
  51436 			goto _2
  51437 		_2:
  51438 			;
  51439 			w = w + 1
  51440 		}
  51441 		preds = preds + uintptr(stride)
  51442 		in = in + uintptr(stride)
  51443 		out = out + uintptr(stride)
  51444 		goto _1
  51445 	_1:
  51446 		;
  51447 		row = row + 1
  51448 	}
  51449 }
  51450 
  51451 //------------------------------------------------------------------------------
  51452 
  51453 func HorizontalFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51454 	DoHorizontalFilter_C(tls, data, width, height, stride, filtered_data)
  51455 }
  51456 
  51457 func VerticalFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51458 	DoVerticalFilter_C(tls, data, width, height, stride, filtered_data)
  51459 }
  51460 
  51461 func GradientFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51462 	DoGradientFilter_C(tls, data, width, height, stride, filtered_data)
  51463 }
  51464 
  51465 //------------------------------------------------------------------------------
  51466 
  51467 func NoneUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51468 	_ = prev
  51469 	if out != in {
  51470 		libc.X__builtin___memcpy_chk(tls, out, in, libc.Uint64FromInt32(width)*uint64(1), ^__predefined_size_t(0))
  51471 	}
  51472 }
  51473 
  51474 func HorizontalUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51475 	var i, v1 int32
  51476 	var pred uint8_t
  51477 	_, _, _ = i, pred, v1
  51478 	if prev == libc.UintptrFromInt32(0) {
  51479 		v1 = 0
  51480 	} else {
  51481 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prev)))
  51482 	}
  51483 	pred = libc.Uint8FromInt32(v1)
  51484 	i = 0
  51485 	for {
  51486 		if !(i < width) {
  51487 			break
  51488 		}
  51489 		**(**uint8_t)(__ccgo_up(out + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(pred) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(i)))))
  51490 		pred = **(**uint8_t)(__ccgo_up(out + uintptr(i)))
  51491 		goto _2
  51492 	_2:
  51493 		;
  51494 		i = i + 1
  51495 	}
  51496 }
  51497 
  51498 func VerticalUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51499 	var i int32
  51500 	_ = i
  51501 	if prev == libc.UintptrFromInt32(0) {
  51502 		HorizontalUnfilter_C(tls, libc.UintptrFromInt32(0), in, out, width)
  51503 	} else {
  51504 		i = 0
  51505 		for {
  51506 			if !(i < width) {
  51507 				break
  51508 			}
  51509 			**(**uint8_t)(__ccgo_up(out + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prev + uintptr(i)))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(i)))))
  51510 			goto _1
  51511 		_1:
  51512 			;
  51513 			i = i + 1
  51514 		}
  51515 	}
  51516 }
  51517 
  51518 func GradientUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51519 	var i int32
  51520 	var left, top, top_left uint8_t
  51521 	_, _, _, _ = i, left, top, top_left
  51522 	if prev == libc.UintptrFromInt32(0) {
  51523 		HorizontalUnfilter_C(tls, libc.UintptrFromInt32(0), in, out, width)
  51524 	} else {
  51525 		top = **(**uint8_t)(__ccgo_up(prev))
  51526 		top_left = top
  51527 		left = top
  51528 		i = 0
  51529 		for {
  51530 			if !(i < width) {
  51531 				break
  51532 			}
  51533 			top = **(**uint8_t)(__ccgo_up(prev + uintptr(i))) // need to read this first, in case prev==out
  51534 			left = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(i)))) + GradientPredictor_C(tls, left, top, top_left))
  51535 			top_left = top
  51536 			**(**uint8_t)(__ccgo_up(out + uintptr(i))) = left
  51537 			goto _1
  51538 		_1:
  51539 			;
  51540 			i = i + 1
  51541 		}
  51542 	}
  51543 }
  51544 
  51545 func VP8FiltersInit(tls *libc.TLS) {
  51546 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  51547 		goto _1
  51548 	}
  51549 	VP8FiltersInit_body(tls)
  51550 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  51551 	goto _2
  51552 _2:
  51553 	;
  51554 	goto _1
  51555 _1: /**/ //
  51556 }
  51557 
  51558 var VP8FiltersInit_body_last_cpuinfo_used = uintptr(0)
  51559 
  51560 func init() {
  51561 	p := unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used)
  51562 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used))
  51563 }
  51564 
  51565 func VP8FiltersInit_body(tls *libc.TLS) {
  51566 	WebPUnfilters[int32(WEBP_FILTER_NONE)] = __ccgo_fp(NoneUnfilter_C)
  51567 	WebPUnfilters[int32(WEBP_FILTER_HORIZONTAL)] = __ccgo_fp(HorizontalUnfilter_C)
  51568 	WebPUnfilters[int32(WEBP_FILTER_VERTICAL)] = __ccgo_fp(VerticalUnfilter_C)
  51569 	WebPUnfilters[int32(WEBP_FILTER_GRADIENT)] = __ccgo_fp(GradientUnfilter_C)
  51570 	WebPFilters[int32(WEBP_FILTER_NONE)] = libc.UintptrFromInt32(0)
  51571 	WebPFilters[int32(WEBP_FILTER_HORIZONTAL)] = __ccgo_fp(HorizontalFilter_C)
  51572 	WebPFilters[int32(WEBP_FILTER_VERTICAL)] = __ccgo_fp(VerticalFilter_C)
  51573 	WebPFilters[int32(WEBP_FILTER_GRADIENT)] = __ccgo_fp(GradientFilter_C)
  51574 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  51575 	}
  51576 }
  51577 
  51578 func VP8FiltersInitMIPSdspR2(tls *libc.TLS) {
  51579 }
  51580 
  51581 func VP8FiltersInitMSA(tls *libc.TLS) {
  51582 }
  51583 
  51584 func VP8FiltersInitNEON(tls *libc.TLS) {
  51585 }
  51586 
  51587 func VP8FiltersInitSSE2(tls *libc.TLS) {
  51588 }
  51589 
  51590 func VP8LDspInitAVX2(tls *libc.TLS) {
  51591 }
  51592 
  51593 const ARGB_BLACK3 = 4278190080
  51594 
  51595 var kHashMul15 = uint32(0x1e35a7bd)
  51596 
  51597 // Copyright 2012 Google Inc. All Rights Reserved.
  51598 //
  51599 // Use of this source code is governed by a BSD-style license
  51600 // that can be found in the COPYING file in the root of the source
  51601 // tree. An additional intellectual property rights grant can be found
  51602 // in the file PATENTS. All contributing project authors may
  51603 // be found in the AUTHORS file in the root of the source tree.
  51604 // -----------------------------------------------------------------------------
  51605 //
  51606 // Misc. common utility functions
  51607 //
  51608 // Authors: Skal (pascal.massimino@gmail.com)
  51609 //          Urvang (urvang@google.com)
  51610 
  51611 // Copyright 2010 Google Inc. All Rights Reserved.
  51612 //
  51613 // Use of this source code is governed by a BSD-style license
  51614 // that can be found in the COPYING file in the root of the source
  51615 // tree. An additional intellectual property rights grant can be found
  51616 // in the file PATENTS. All contributing project authors may
  51617 // be found in the AUTHORS file in the root of the source tree.
  51618 // -----------------------------------------------------------------------------
  51619 //
  51620 //  Main decoding functions for WebP images.
  51621 //
  51622 // Author: Skal (pascal.massimino@gmail.com)
  51623 
  51624 // Copyright 2012 Google Inc. All Rights Reserved.
  51625 //
  51626 // Use of this source code is governed by a BSD-style license
  51627 // that can be found in the COPYING file in the root of the source
  51628 // tree. An additional intellectual property rights grant can be found
  51629 // in the file PATENTS. All contributing project authors may
  51630 // be found in the AUTHORS file in the root of the source tree.
  51631 // -----------------------------------------------------------------------------
  51632 //
  51633 //  Internal header for constants related to WebP file format.
  51634 //
  51635 // Author: Urvang (urvang@google.com)
  51636 
  51637 // Copyright 2010 Google Inc. All Rights Reserved.
  51638 //
  51639 // Use of this source code is governed by a BSD-style license
  51640 // that can be found in the COPYING file in the root of the source
  51641 // tree. An additional intellectual property rights grant can be found
  51642 // in the file PATENTS. All contributing project authors may
  51643 // be found in the AUTHORS file in the root of the source tree.
  51644 // -----------------------------------------------------------------------------
  51645 //
  51646 //  Common types + memory wrappers
  51647 //
  51648 // Author: Skal (pascal.massimino@gmail.com)
  51649 
  51650 //------------------------------------------------------------------------------
  51651 // Image transforms.
  51652 
  51653 func Average2(tls *libc.TLS, a0 uint32_t, a1 uint32_t) (r uint32_t) {
  51654 	return (a0^a1)&uint32(0xfefefefe)>>int32(1) + a0&a1
  51655 }
  51656 
  51657 func Average3(tls *libc.TLS, a0 uint32_t, a1 uint32_t, a2 uint32_t) (r uint32_t) {
  51658 	return Average2(tls, Average2(tls, a0, a2), a1)
  51659 }
  51660 
  51661 func Average4(tls *libc.TLS, a0 uint32_t, a1 uint32_t, a2 uint32_t, a3 uint32_t) (r uint32_t) {
  51662 	return Average2(tls, Average2(tls, a0, a1), Average2(tls, a2, a3))
  51663 }
  51664 
  51665 func Clip255(tls *libc.TLS, a uint32_t) (r uint32_t) {
  51666 	if a < uint32(256) {
  51667 		return a
  51668 	}
  51669 	// return 0, when a is a negative integer.
  51670 	// return 255, when a is positive.
  51671 	return ^a >> int32(24)
  51672 }
  51673 
  51674 func AddSubtractComponentFull(tls *libc.TLS, a int32, b int32, c int32) (r int32) {
  51675 	return libc.Int32FromUint32(Clip255(tls, libc.Uint32FromInt32(a+b-c)))
  51676 }
  51677 
  51678 func ClampedAddSubtractFull(tls *libc.TLS, c0 uint32_t, c1 uint32_t, c2 uint32_t) (r1 uint32_t) {
  51679 	var a, b, g, r int32
  51680 	_, _, _, _ = a, b, g, r
  51681 	a = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0>>int32(24)), libc.Int32FromUint32(c1>>int32(24)), libc.Int32FromUint32(c2>>int32(24)))
  51682 	r = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(c1>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(16)&uint32(0xff)))
  51683 	g = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(c1>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(8)&uint32(0xff)))
  51684 	b = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0&uint32(0xff)), libc.Int32FromUint32(c1&uint32(0xff)), libc.Int32FromUint32(c2&uint32(0xff)))
  51685 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  51686 }
  51687 
  51688 func AddSubtractComponentHalf(tls *libc.TLS, a int32, b int32) (r int32) {
  51689 	return libc.Int32FromUint32(Clip255(tls, libc.Uint32FromInt32(a+(a-b)/libc.Int32FromInt32(2))))
  51690 }
  51691 
  51692 func ClampedAddSubtractHalf(tls *libc.TLS, c0 uint32_t, c1 uint32_t, c2 uint32_t) (r1 uint32_t) {
  51693 	var a, b, g, r int32
  51694 	var ave uint32_t
  51695 	_, _, _, _, _ = a, ave, b, g, r
  51696 	ave = Average2(tls, c0, c1)
  51697 	a = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>int32(24)), libc.Int32FromUint32(c2>>int32(24)))
  51698 	r = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(16)&uint32(0xff)))
  51699 	g = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(8)&uint32(0xff)))
  51700 	b = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(0)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(0)&uint32(0xff)))
  51701 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  51702 }
  51703 
  51704 // gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is
  51705 // inlined.
  51706 
  51707 func Sub3(tls *libc.TLS, a int32, b int32, c int32) (r int32) {
  51708 	var pa, pb int32
  51709 	_, _ = pa, pb
  51710 	pb = b - c
  51711 	pa = a - c
  51712 	return libc.Xabs(tls, pb) - libc.Xabs(tls, pa)
  51713 }
  51714 
  51715 func Select(tls *libc.TLS, a uint32_t, b uint32_t, c uint32_t) (r uint32_t) {
  51716 	var pa_minus_pb int32
  51717 	var v1 uint32
  51718 	_, _ = pa_minus_pb, v1
  51719 	pa_minus_pb = Sub3(tls, libc.Int32FromUint32(a>>libc.Int32FromInt32(24)), libc.Int32FromUint32(b>>libc.Int32FromInt32(24)), libc.Int32FromUint32(c>>libc.Int32FromInt32(24))) + Sub3(tls, libc.Int32FromUint32(a>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(b>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(c>>libc.Int32FromInt32(16)&uint32(0xff))) + Sub3(tls, libc.Int32FromUint32(a>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(b>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(c>>libc.Int32FromInt32(8)&uint32(0xff))) + Sub3(tls, libc.Int32FromUint32(a&uint32(0xff)), libc.Int32FromUint32(b&uint32(0xff)), libc.Int32FromUint32(c&uint32(0xff)))
  51720 	if pa_minus_pb <= 0 {
  51721 		v1 = a
  51722 	} else {
  51723 		v1 = b
  51724 	}
  51725 	return v1
  51726 }
  51727 
  51728 //------------------------------------------------------------------------------
  51729 // Predictors
  51730 
  51731 func VP8LPredictor0_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51732 	_ = top
  51733 	_ = left
  51734 	return uint32(ARGB_BLACK3)
  51735 }
  51736 
  51737 func VP8LPredictor1_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51738 	_ = top
  51739 	return **(**uint32_t)(__ccgo_up(left))
  51740 }
  51741 
  51742 func VP8LPredictor2_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51743 	_ = left
  51744 	return **(**uint32_t)(__ccgo_up(top))
  51745 }
  51746 
  51747 func VP8LPredictor3_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51748 	_ = left
  51749 	return **(**uint32_t)(__ccgo_up(top + 1*4))
  51750 }
  51751 
  51752 func VP8LPredictor4_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51753 	_ = left
  51754 	return **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4))
  51755 }
  51756 
  51757 func VP8LPredictor5_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51758 	var pred uint32_t
  51759 	_ = pred
  51760 	pred = Average3(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + 1*4)))
  51761 	return pred
  51762 }
  51763 
  51764 func VP8LPredictor6_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51765 	var pred uint32_t
  51766 	_ = pred
  51767 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51768 	return pred
  51769 }
  51770 
  51771 func VP8LPredictor7_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51772 	var pred uint32_t
  51773 	_ = pred
  51774 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)))
  51775 	return pred
  51776 }
  51777 
  51778 func VP8LPredictor8_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51779 	var pred uint32_t
  51780 	_ = pred
  51781 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)), **(**uint32_t)(__ccgo_up(top)))
  51782 	_ = left
  51783 	return pred
  51784 }
  51785 
  51786 func VP8LPredictor9_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51787 	var pred uint32_t
  51788 	_ = pred
  51789 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + 1*4)))
  51790 	_ = left
  51791 	return pred
  51792 }
  51793 
  51794 func VP8LPredictor10_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51795 	var pred uint32_t
  51796 	_ = pred
  51797 	pred = Average4(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + 1*4)))
  51798 	return pred
  51799 }
  51800 
  51801 func VP8LPredictor11_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51802 	var pred uint32_t
  51803 	_ = pred
  51804 	pred = Select(tls, **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51805 	return pred
  51806 }
  51807 
  51808 func VP8LPredictor12_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51809 	var pred uint32_t
  51810 	_ = pred
  51811 	pred = ClampedAddSubtractFull(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51812 	return pred
  51813 }
  51814 
  51815 func VP8LPredictor13_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51816 	var pred uint32_t
  51817 	_ = pred
  51818 	pred = ClampedAddSubtractHalf(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51819 	return pred
  51820 }
  51821 
  51822 func PredictorAdd0_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51823 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  51824 	var x int32
  51825 	_, _, _, _, _, _ = alpha_and_green, red_and_blue, x, v2, v3, v4
  51826 	_ = upper
  51827 	x = 0
  51828 	for {
  51829 		if !(x < num_pixels) {
  51830 			break
  51831 		}
  51832 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51833 		v3 = uint32(ARGB_BLACK3)
  51834 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51835 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51836 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51837 		goto _5
  51838 	_5:
  51839 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51840 		goto _1
  51841 	_1:
  51842 		;
  51843 		x = x + 1
  51844 	}
  51845 }
  51846 
  51847 func PredictorAdd1_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51848 	var alpha_and_green, left, red_and_blue, v2, v3, v4, v5 uint32_t
  51849 	var i int32
  51850 	_, _, _, _, _, _, _, _ = alpha_and_green, i, left, red_and_blue, v2, v3, v4, v5
  51851 	left = **(**uint32_t)(__ccgo_up(out + uintptr(-libc.Int32FromInt32(1))*4))
  51852 	_ = upper
  51853 	i = 0
  51854 	for {
  51855 		if !(i < num_pixels) {
  51856 			break
  51857 		}
  51858 		v3 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  51859 		v4 = left
  51860 		alpha_and_green = v3&uint32(0xff00ff00) + v4&uint32(0xff00ff00)
  51861 		red_and_blue = v3&uint32(0x00ff00ff) + v4&uint32(0x00ff00ff)
  51862 		v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51863 		goto _6
  51864 	_6:
  51865 		v2 = v5
  51866 		left = v2
  51867 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v2
  51868 		goto _1
  51869 	_1:
  51870 		;
  51871 		i = i + 1
  51872 	}
  51873 }
  51874 
  51875 func PredictorAdd2_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51876 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51877 	var x int32
  51878 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51879 	x = 0
  51880 	for {
  51881 		if !(x < num_pixels) {
  51882 			break
  51883 		}
  51884 		pred = VP8LPredictor2_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51885 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51886 		v3 = pred
  51887 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51888 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51889 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51890 		goto _5
  51891 	_5:
  51892 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51893 		goto _1
  51894 	_1:
  51895 		;
  51896 		x = x + 1
  51897 	}
  51898 }
  51899 
  51900 func PredictorAdd3_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51901 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51902 	var x int32
  51903 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51904 	x = 0
  51905 	for {
  51906 		if !(x < num_pixels) {
  51907 			break
  51908 		}
  51909 		pred = VP8LPredictor3_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51910 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51911 		v3 = pred
  51912 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51913 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51914 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51915 		goto _5
  51916 	_5:
  51917 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51918 		goto _1
  51919 	_1:
  51920 		;
  51921 		x = x + 1
  51922 	}
  51923 }
  51924 
  51925 func PredictorAdd4_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51926 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51927 	var x int32
  51928 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51929 	x = 0
  51930 	for {
  51931 		if !(x < num_pixels) {
  51932 			break
  51933 		}
  51934 		pred = VP8LPredictor4_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51935 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51936 		v3 = pred
  51937 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51938 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51939 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51940 		goto _5
  51941 	_5:
  51942 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51943 		goto _1
  51944 	_1:
  51945 		;
  51946 		x = x + 1
  51947 	}
  51948 }
  51949 
  51950 func PredictorAdd5_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51951 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51952 	var x int32
  51953 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51954 	x = 0
  51955 	for {
  51956 		if !(x < num_pixels) {
  51957 			break
  51958 		}
  51959 		pred = VP8LPredictor5_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51960 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51961 		v3 = pred
  51962 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51963 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51964 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51965 		goto _5
  51966 	_5:
  51967 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51968 		goto _1
  51969 	_1:
  51970 		;
  51971 		x = x + 1
  51972 	}
  51973 }
  51974 
  51975 func PredictorAdd6_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51976 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51977 	var x int32
  51978 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51979 	x = 0
  51980 	for {
  51981 		if !(x < num_pixels) {
  51982 			break
  51983 		}
  51984 		pred = VP8LPredictor6_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51985 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51986 		v3 = pred
  51987 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51988 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51989 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51990 		goto _5
  51991 	_5:
  51992 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51993 		goto _1
  51994 	_1:
  51995 		;
  51996 		x = x + 1
  51997 	}
  51998 }
  51999 
  52000 func PredictorAdd7_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52001 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52002 	var x int32
  52003 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52004 	x = 0
  52005 	for {
  52006 		if !(x < num_pixels) {
  52007 			break
  52008 		}
  52009 		pred = VP8LPredictor7_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52010 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52011 		v3 = pred
  52012 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52013 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52014 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52015 		goto _5
  52016 	_5:
  52017 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52018 		goto _1
  52019 	_1:
  52020 		;
  52021 		x = x + 1
  52022 	}
  52023 }
  52024 
  52025 func PredictorAdd8_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52026 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52027 	var x int32
  52028 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52029 	x = 0
  52030 	for {
  52031 		if !(x < num_pixels) {
  52032 			break
  52033 		}
  52034 		pred = VP8LPredictor8_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52035 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52036 		v3 = pred
  52037 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52038 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52039 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52040 		goto _5
  52041 	_5:
  52042 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52043 		goto _1
  52044 	_1:
  52045 		;
  52046 		x = x + 1
  52047 	}
  52048 }
  52049 
  52050 func PredictorAdd9_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52051 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52052 	var x int32
  52053 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52054 	x = 0
  52055 	for {
  52056 		if !(x < num_pixels) {
  52057 			break
  52058 		}
  52059 		pred = VP8LPredictor9_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52060 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52061 		v3 = pred
  52062 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52063 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52064 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52065 		goto _5
  52066 	_5:
  52067 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52068 		goto _1
  52069 	_1:
  52070 		;
  52071 		x = x + 1
  52072 	}
  52073 }
  52074 
  52075 func PredictorAdd10_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52076 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52077 	var x int32
  52078 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52079 	x = 0
  52080 	for {
  52081 		if !(x < num_pixels) {
  52082 			break
  52083 		}
  52084 		pred = VP8LPredictor10_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52085 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52086 		v3 = pred
  52087 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52088 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52089 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52090 		goto _5
  52091 	_5:
  52092 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52093 		goto _1
  52094 	_1:
  52095 		;
  52096 		x = x + 1
  52097 	}
  52098 }
  52099 
  52100 func PredictorAdd11_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52101 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52102 	var x int32
  52103 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52104 	x = 0
  52105 	for {
  52106 		if !(x < num_pixels) {
  52107 			break
  52108 		}
  52109 		pred = VP8LPredictor11_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52110 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52111 		v3 = pred
  52112 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52113 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52114 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52115 		goto _5
  52116 	_5:
  52117 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52118 		goto _1
  52119 	_1:
  52120 		;
  52121 		x = x + 1
  52122 	}
  52123 }
  52124 
  52125 func PredictorAdd12_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52126 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52127 	var x int32
  52128 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52129 	x = 0
  52130 	for {
  52131 		if !(x < num_pixels) {
  52132 			break
  52133 		}
  52134 		pred = VP8LPredictor12_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52135 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52136 		v3 = pred
  52137 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52138 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52139 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52140 		goto _5
  52141 	_5:
  52142 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52143 		goto _1
  52144 	_1:
  52145 		;
  52146 		x = x + 1
  52147 	}
  52148 }
  52149 
  52150 func PredictorAdd13_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52151 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52152 	var x int32
  52153 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52154 	x = 0
  52155 	for {
  52156 		if !(x < num_pixels) {
  52157 			break
  52158 		}
  52159 		pred = VP8LPredictor13_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52160 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52161 		v3 = pred
  52162 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52163 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52164 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52165 		goto _5
  52166 	_5:
  52167 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52168 		goto _1
  52169 	_1:
  52170 		;
  52171 		x = x + 1
  52172 	}
  52173 }
  52174 
  52175 //------------------------------------------------------------------------------
  52176 
  52177 // C documentation
  52178 //
  52179 //	// Inverse prediction.
  52180 func PredictorInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, in uintptr, out uintptr) {
  52181 	var mask, tile_width, tiles_per_row, width, x, x_end, y int32
  52182 	var pred_func VP8LPredictorAddSubFunc
  52183 	var pred_mode_base, pred_mode_src, v4 uintptr
  52184 	var v1, v2 uint32_t
  52185 	_, _, _, _, _, _, _, _, _, _, _, _, _ = mask, pred_func, pred_mode_base, pred_mode_src, tile_width, tiles_per_row, width, x, x_end, y, v1, v2, v4
  52186 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52187 	if y_start == 0 { // First Row follows the L (mode=1) mode.
  52188 		PredictorAdd0_C(tls, in, libc.UintptrFromInt32(0), int32(1), out)
  52189 		PredictorAdd1_C(tls, in+uintptr(1)*4, libc.UintptrFromInt32(0), width-int32(1), out+uintptr(1)*4)
  52190 		in = in + uintptr(width)*4
  52191 		out = out + uintptr(width)*4
  52192 		y_start = y_start + 1
  52193 	}
  52194 	y = y_start
  52195 	tile_width = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52196 	mask = tile_width - int32(1)
  52197 	v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52198 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52199 	goto _3
  52200 _3:
  52201 	tiles_per_row = libc.Int32FromUint32(v2)
  52202 	pred_mode_base = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata + uintptr(y>>(*VP8LTransform)(unsafe.Pointer(transform)).Fbits*tiles_per_row)*4
  52203 	for y < y_end {
  52204 		pred_mode_src = pred_mode_base
  52205 		x = int32(1)
  52206 		// First pixel follows the T (mode=2) mode.
  52207 		PredictorAdd2_C(tls, in, out-uintptr(width)*4, int32(1), out)
  52208 		// .. the rest:
  52209 		for x < width {
  52210 			v4 = pred_mode_src
  52211 			pred_mode_src += 4
  52212 			pred_func = VP8LPredictorsAdd[**(**uint32_t)(__ccgo_up(v4))>>libc.Int32FromInt32(8)&uint32(0xf)]
  52213 			x_end = x & ^mask + tile_width
  52214 			if x_end > width {
  52215 				x_end = width
  52216 			}
  52217 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{pred_func})))(tls, in+uintptr(x)*4, out+uintptr(x)*4-uintptr(width)*4, x_end-x, out+uintptr(x)*4)
  52218 			x = x_end
  52219 		}
  52220 		in = in + uintptr(width)*4
  52221 		out = out + uintptr(width)*4
  52222 		y = y + 1
  52223 		if y&mask == 0 { // Use the same mask, since tiles are squares.
  52224 			pred_mode_base = pred_mode_base + uintptr(tiles_per_row)*4
  52225 		}
  52226 	}
  52227 }
  52228 
  52229 // C documentation
  52230 //
  52231 //	// Add green to blue and red channels (i.e. perform the inverse transform of
  52232 //	// 'subtract green').
  52233 func VP8LAddGreenToBlueAndRed_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52234 	var argb, green, red_blue uint32_t
  52235 	var i int32
  52236 	_, _, _, _ = argb, green, i, red_blue
  52237 	i = 0
  52238 	for {
  52239 		if !(i < num_pixels) {
  52240 			break
  52241 		}
  52242 		argb = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  52243 		green = argb >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xff)
  52244 		red_blue = argb & libc.Uint32FromUint32(0x00ff00ff)
  52245 		red_blue = red_blue + (green<<libc.Int32FromInt32(16) | green)
  52246 		red_blue = red_blue & uint32(0x00ff00ff)
  52247 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = argb&uint32(0xff00ff00) | red_blue
  52248 		goto _1
  52249 	_1:
  52250 		;
  52251 		i = i + 1
  52252 	}
  52253 }
  52254 
  52255 func ColorTransformDelta(tls *libc.TLS, color_pred int8_t, color int8_t) (r int32) {
  52256 	return int32(color_pred) * int32(color) >> int32(5)
  52257 }
  52258 
  52259 func ColorCodeToMultipliers1(tls *libc.TLS, color_code uint32_t, m uintptr) {
  52260 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(color_code >> libc.Int32FromInt32(0) & uint32(0xff))
  52261 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(color_code >> libc.Int32FromInt32(8) & uint32(0xff))
  52262 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(color_code >> libc.Int32FromInt32(16) & uint32(0xff))
  52263 }
  52264 
  52265 func VP8LTransformColorInverse_C(tls *libc.TLS, m uintptr, src uintptr, num_pixels int32, dst uintptr) {
  52266 	var argb, red uint32_t
  52267 	var green int8_t
  52268 	var i, new_blue, new_red int32
  52269 	_, _, _, _, _, _ = argb, green, i, new_blue, new_red, red
  52270 	i = 0
  52271 	for {
  52272 		if !(i < num_pixels) {
  52273 			break
  52274 		}
  52275 		argb = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  52276 		green = libc.Int8FromUint32(argb >> libc.Int32FromInt32(8))
  52277 		red = argb >> int32(16)
  52278 		new_red = libc.Int32FromUint32(red & uint32(0xff))
  52279 		new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  52280 		new_red = new_red + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red), green)
  52281 		new_red = new_red & int32(0xff)
  52282 		new_blue = new_blue + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue), green)
  52283 		new_blue = new_blue + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue), int8(new_red))
  52284 		new_blue = new_blue & int32(0xff)
  52285 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = argb&uint32(0xff00ff00) | libc.Uint32FromInt32(new_red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(new_blue)
  52286 		goto _1
  52287 	_1:
  52288 		;
  52289 		i = i + 1
  52290 	}
  52291 }
  52292 
  52293 // C documentation
  52294 //
  52295 //	// Color space inverse transform.
  52296 func ColorSpaceInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52297 	bp := tls.Alloc(16)
  52298 	defer tls.Free(16)
  52299 	var mask, remaining_width, safe_width, tile_width, tiles_per_row, width, y int32
  52300 	var pred, pred_row, src_end, src_safe_end, v4 uintptr
  52301 	var v1, v2 uint32_t
  52302 	var _ /* m at bp+0 */ VP8LMultipliers
  52303 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = mask, pred, pred_row, remaining_width, safe_width, src_end, src_safe_end, tile_width, tiles_per_row, width, y, v1, v2, v4
  52304 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52305 	tile_width = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52306 	mask = tile_width - int32(1)
  52307 	safe_width = width & ^mask
  52308 	remaining_width = width - safe_width
  52309 	v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52310 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52311 	goto _3
  52312 _3:
  52313 	tiles_per_row = libc.Int32FromUint32(v2)
  52314 	y = y_start
  52315 	pred_row = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata + uintptr(y>>(*VP8LTransform)(unsafe.Pointer(transform)).Fbits*tiles_per_row)*4
  52316 	for y < y_end {
  52317 		pred = pred_row
  52318 		**(**VP8LMultipliers)(__ccgo_up(bp)) = VP8LMultipliers{}
  52319 		src_safe_end = src + uintptr(safe_width)*4
  52320 		src_end = src + uintptr(width)*4
  52321 		for src < src_safe_end {
  52322 			v4 = pred
  52323 			pred += 4
  52324 			ColorCodeToMultipliers1(tls, **(**uint32_t)(__ccgo_up(v4)), bp)
  52325 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColorInverse})))(tls, bp, src, tile_width, dst)
  52326 			src = src + uintptr(tile_width)*4
  52327 			dst = dst + uintptr(tile_width)*4
  52328 		}
  52329 		if src < src_end { // Left-overs using C-version.
  52330 			v4 = pred
  52331 			pred += 4
  52332 			ColorCodeToMultipliers1(tls, **(**uint32_t)(__ccgo_up(v4)), bp)
  52333 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColorInverse})))(tls, bp, src, remaining_width, dst)
  52334 			src = src + uintptr(remaining_width)*4
  52335 			dst = dst + uintptr(remaining_width)*4
  52336 		}
  52337 		y = y + 1
  52338 		if y&mask == 0 {
  52339 			pred_row = pred_row + uintptr(tiles_per_row)*4
  52340 		}
  52341 	}
  52342 }
  52343 
  52344 // Separate out pixels packed together using pixel-bundling.
  52345 // We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
  52346 func MapARGB_C(tls *libc.TLS, src uintptr, color_map uintptr, dst uintptr, y_start int32, y_end int32, width int32) {
  52347 	var x, y int32
  52348 	var v3, v4 uintptr
  52349 	var v5, v7 uint32_t
  52350 	_, _, _, _, _, _ = x, y, v3, v4, v5, v7
  52351 	y = y_start
  52352 	for {
  52353 		if !(y < y_end) {
  52354 			break
  52355 		}
  52356 		x = 0
  52357 		for {
  52358 			if !(x < width) {
  52359 				break
  52360 			}
  52361 			v3 = dst
  52362 			dst += 4
  52363 			v4 = src
  52364 			src += 4
  52365 			v5 = **(**uint32_t)(__ccgo_up(v4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  52366 			goto _6
  52367 		_6:
  52368 			v7 = **(**uint32_t)(__ccgo_up(color_map + uintptr(v5)*4))
  52369 			goto _8
  52370 		_8:
  52371 			**(**uint32_t)(__ccgo_up(v3)) = v7
  52372 			goto _2
  52373 		_2:
  52374 			;
  52375 			x = x + 1
  52376 		}
  52377 		goto _1
  52378 	_1:
  52379 		;
  52380 		y = y + 1
  52381 	}
  52382 }
  52383 
  52384 func ColorIndexInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52385 	var bit_mask, packed_pixels, v4 uint32_t
  52386 	var bits_per_pixel, count_mask, pixels_per_byte, width, x, y int32
  52387 	var color_map, v3 uintptr
  52388 	_, _, _, _, _, _, _, _, _, _, _ = bit_mask, bits_per_pixel, color_map, count_mask, packed_pixels, pixels_per_byte, width, x, y, v3, v4
  52389 	bits_per_pixel = int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52390 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52391 	color_map = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  52392 	if bits_per_pixel < int32(8) {
  52393 		pixels_per_byte = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52394 		count_mask = pixels_per_byte - int32(1)
  52395 		bit_mask = libc.Uint32FromInt32(int32(1)<<bits_per_pixel - int32(1))
  52396 		y = y_start
  52397 		for {
  52398 			if !(y < y_end) {
  52399 				break
  52400 			}
  52401 			packed_pixels = uint32(0)
  52402 			x = 0
  52403 			for {
  52404 				if !(x < width) {
  52405 					break
  52406 				} /* We need to load fresh 'packed_pixels' once every                */ /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ /* is a power of 2, so can just use a mask for that, instead of    */ /* decrementing a counter.                                         */
  52407 				if x&count_mask == 0 {
  52408 					v3 = src
  52409 					src += 4
  52410 					v4 = **(**uint32_t)(__ccgo_up(v3)) >> libc.Int32FromInt32(8) & uint32(0xff)
  52411 					goto _5
  52412 				_5:
  52413 					packed_pixels = v4
  52414 				}
  52415 				v3 = dst
  52416 				dst += 4
  52417 				v4 = **(**uint32_t)(__ccgo_up(color_map + uintptr(packed_pixels&bit_mask)*4))
  52418 				goto _8
  52419 			_8:
  52420 				**(**uint32_t)(__ccgo_up(v3)) = v4
  52421 				packed_pixels = packed_pixels >> libc.Uint32FromInt32(bits_per_pixel)
  52422 				goto _2
  52423 			_2:
  52424 				;
  52425 				x = x + 1
  52426 			}
  52427 			goto _1
  52428 		_1:
  52429 			;
  52430 			y = y + 1
  52431 		}
  52432 	} else {
  52433 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LMapColor32b})))(tls, src, color_map, dst, y_start, y_end, width)
  52434 	}
  52435 }
  52436 
  52437 func MapAlpha_C(tls *libc.TLS, src uintptr, color_map uintptr, dst uintptr, y_start int32, y_end int32, width int32) {
  52438 	var x, y int32
  52439 	var v3, v4 uintptr
  52440 	var v5, v7 uint8_t
  52441 	_, _, _, _, _, _ = x, y, v3, v4, v5, v7
  52442 	y = y_start
  52443 	for {
  52444 		if !(y < y_end) {
  52445 			break
  52446 		}
  52447 		x = 0
  52448 		for {
  52449 			if !(x < width) {
  52450 				break
  52451 			}
  52452 			v3 = dst
  52453 			dst = dst + 1
  52454 			v4 = src
  52455 			src = src + 1
  52456 			v5 = **(**uint8_t)(__ccgo_up(v4))
  52457 			goto _6
  52458 		_6:
  52459 			v7 = uint8(**(**uint32_t)(__ccgo_up(color_map + uintptr(v5)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  52460 			goto _8
  52461 		_8:
  52462 			**(**uint8_t)(__ccgo_up(v3)) = v7
  52463 			goto _2
  52464 		_2:
  52465 			;
  52466 			x = x + 1
  52467 		}
  52468 		goto _1
  52469 	_1:
  52470 		;
  52471 		y = y + 1
  52472 	}
  52473 }
  52474 
  52475 func VP8LColorIndexInverseTransformAlpha(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52476 	var bit_mask, packed_pixels uint32_t
  52477 	var bits_per_pixel, count_mask, pixels_per_byte, width, x, y int32
  52478 	var color_map, v3 uintptr
  52479 	var v4 uint8_t
  52480 	_, _, _, _, _, _, _, _, _, _, _ = bit_mask, bits_per_pixel, color_map, count_mask, packed_pixels, pixels_per_byte, width, x, y, v3, v4
  52481 	bits_per_pixel = int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52482 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52483 	color_map = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  52484 	if bits_per_pixel < int32(8) {
  52485 		pixels_per_byte = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52486 		count_mask = pixels_per_byte - int32(1)
  52487 		bit_mask = libc.Uint32FromInt32(int32(1)<<bits_per_pixel - int32(1))
  52488 		y = y_start
  52489 		for {
  52490 			if !(y < y_end) {
  52491 				break
  52492 			}
  52493 			packed_pixels = uint32(0)
  52494 			x = 0
  52495 			for {
  52496 				if !(x < width) {
  52497 					break
  52498 				} /* We need to load fresh 'packed_pixels' once every                */ /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ /* is a power of 2, so can just use a mask for that, instead of    */ /* decrementing a counter.                                         */
  52499 				if x&count_mask == 0 {
  52500 					v3 = src
  52501 					src = src + 1
  52502 					v4 = **(**uint8_t)(__ccgo_up(v3))
  52503 					goto _5
  52504 				_5:
  52505 					packed_pixels = uint32(v4)
  52506 				}
  52507 				v3 = dst
  52508 				dst = dst + 1
  52509 				v4 = uint8(**(**uint32_t)(__ccgo_up(color_map + uintptr(packed_pixels&bit_mask)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  52510 				goto _8
  52511 			_8:
  52512 				**(**uint8_t)(__ccgo_up(v3)) = v4
  52513 				packed_pixels = packed_pixels >> libc.Uint32FromInt32(bits_per_pixel)
  52514 				goto _2
  52515 			_2:
  52516 				;
  52517 				x = x + 1
  52518 			}
  52519 			goto _1
  52520 		_1:
  52521 			;
  52522 			y = y + 1
  52523 		}
  52524 	} else {
  52525 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LMapColor8b})))(tls, src, color_map, dst, y_start, y_end, width)
  52526 	}
  52527 }
  52528 
  52529 func VP8LInverseTransform(tls *libc.TLS, transform uintptr, row_start int32, row_end int32, in uintptr, out uintptr) {
  52530 	var in_stride, out_stride, width int32
  52531 	var src uintptr
  52532 	var v1, v2 uint32_t
  52533 	_, _, _, _, _, _ = in_stride, out_stride, src, width, v1, v2
  52534 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52535 	switch (*VP8LTransform)(unsafe.Pointer(transform)).Ftype1 {
  52536 	case int32(SUBTRACT_GREEN_TRANSFORM):
  52537 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LAddGreenToBlueAndRed})))(tls, in, (row_end-row_start)*width, out)
  52538 	case int32(PREDICTOR_TRANSFORM):
  52539 		PredictorInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52540 		if row_end != (*VP8LTransform)(unsafe.Pointer(transform)).Fysize {
  52541 			// The last predicted row in this iteration will be the top-pred row
  52542 			// for the first row in next iteration.
  52543 			libc.X__builtin___memcpy_chk(tls, out-uintptr(width)*4, out+uintptr((row_end-row_start-int32(1))*width)*4, libc.Uint64FromInt32(width)*uint64(4), ^__predefined_size_t(0))
  52544 		}
  52545 	case int32(CROSS_COLOR_TRANSFORM):
  52546 		ColorSpaceInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52547 	case int32(COLOR_INDEXING_TRANSFORM):
  52548 		if in == out && (*VP8LTransform)(unsafe.Pointer(transform)).Fbits > 0 {
  52549 			// Move packed pixels to the end of unpacked region, so that unpacking
  52550 			// can occur seamlessly.
  52551 			// Also, note that this is the only transform that applies on
  52552 			// the effective width of VP8LSubSampleSize(xsize, bits). All other
  52553 			// transforms work on effective width of 'xsize'.
  52554 			out_stride = (row_end - row_start) * width
  52555 			v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52556 			v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52557 			goto _3
  52558 		_3:
  52559 			in_stride = libc.Int32FromUint32(libc.Uint32FromInt32(row_end-row_start) * v2)
  52560 			src = out + uintptr(out_stride)*4 - uintptr(in_stride)*4
  52561 			libc.X__builtin___memmove_chk(tls, src, out, libc.Uint64FromInt32(in_stride)*uint64(4), ^__predefined_size_t(0))
  52562 			ColorIndexInverseTransform_C(tls, transform, row_start, row_end, src, out)
  52563 		} else {
  52564 			ColorIndexInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52565 		}
  52566 		break
  52567 	}
  52568 }
  52569 
  52570 //------------------------------------------------------------------------------
  52571 // Color space conversion.
  52572 
  52573 func is_big_endian(tls *libc.TLS) (r int32) {
  52574 	return libc.BoolInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&tmp))))) != int32(1))
  52575 }
  52576 
  52577 var tmp = *(*struct {
  52578 	Fb [0][2]uint8_t
  52579 	Fw uint16_t
  52580 })(unsafe.Pointer(&[1]uint16{0x1}))
  52581 
  52582 func VP8LConvertBGRAToRGB_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52583 	var argb uint32_t
  52584 	var src_end, v1, v2 uintptr
  52585 	_, _, _, _ = argb, src_end, v1, v2
  52586 	src_end = src + uintptr(num_pixels)*4
  52587 	for src < src_end {
  52588 		v1 = src
  52589 		src += 4
  52590 		argb = **(**uint32_t)(__ccgo_up(v1))
  52591 		v2 = dst
  52592 		dst = dst + 1
  52593 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52594 		v1 = dst
  52595 		dst = dst + 1
  52596 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52597 		v1 = dst
  52598 		dst = dst + 1
  52599 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52600 	}
  52601 }
  52602 
  52603 func VP8LConvertBGRAToRGBA_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52604 	var argb uint32_t
  52605 	var src_end, v1, v2 uintptr
  52606 	_, _, _, _ = argb, src_end, v1, v2
  52607 	src_end = src + uintptr(num_pixels)*4
  52608 	for src < src_end {
  52609 		v1 = src
  52610 		src += 4
  52611 		argb = **(**uint32_t)(__ccgo_up(v1))
  52612 		v2 = dst
  52613 		dst = dst + 1
  52614 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52615 		v1 = dst
  52616 		dst = dst + 1
  52617 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52618 		v1 = dst
  52619 		dst = dst + 1
  52620 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52621 		v1 = dst
  52622 		dst = dst + 1
  52623 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(24) & uint32(0xff))
  52624 	}
  52625 }
  52626 
  52627 func VP8LConvertBGRAToRGBA4444_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52628 	var argb uint32_t
  52629 	var ba, rg uint8_t
  52630 	var src_end, v1, v2 uintptr
  52631 	_, _, _, _, _, _ = argb, ba, rg, src_end, v1, v2
  52632 	src_end = src + uintptr(num_pixels)*4
  52633 	for src < src_end {
  52634 		v1 = src
  52635 		src += 4
  52636 		argb = **(**uint32_t)(__ccgo_up(v1))
  52637 		rg = uint8(argb>>libc.Int32FromInt32(16)&uint32(0xf0) | argb>>libc.Int32FromInt32(12)&uint32(0xf))
  52638 		ba = uint8(argb>>libc.Int32FromInt32(0)&uint32(0xf0) | argb>>libc.Int32FromInt32(28)&uint32(0xf))
  52639 		v2 = dst
  52640 		dst = dst + 1
  52641 		**(**uint8_t)(__ccgo_up(v2)) = rg
  52642 		v1 = dst
  52643 		dst = dst + 1
  52644 		**(**uint8_t)(__ccgo_up(v1)) = ba
  52645 	}
  52646 }
  52647 
  52648 func VP8LConvertBGRAToRGB565_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52649 	var argb uint32_t
  52650 	var gb, rg uint8_t
  52651 	var src_end, v1, v2 uintptr
  52652 	_, _, _, _, _, _ = argb, gb, rg, src_end, v1, v2
  52653 	src_end = src + uintptr(num_pixels)*4
  52654 	for src < src_end {
  52655 		v1 = src
  52656 		src += 4
  52657 		argb = **(**uint32_t)(__ccgo_up(v1))
  52658 		rg = uint8(argb>>libc.Int32FromInt32(16)&uint32(0xf8) | argb>>libc.Int32FromInt32(13)&uint32(0x7))
  52659 		gb = uint8(argb>>libc.Int32FromInt32(5)&uint32(0xe0) | argb>>libc.Int32FromInt32(3)&uint32(0x1f))
  52660 		v2 = dst
  52661 		dst = dst + 1
  52662 		**(**uint8_t)(__ccgo_up(v2)) = rg
  52663 		v1 = dst
  52664 		dst = dst + 1
  52665 		**(**uint8_t)(__ccgo_up(v1)) = gb
  52666 	}
  52667 }
  52668 
  52669 func VP8LConvertBGRAToBGR_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52670 	var argb uint32_t
  52671 	var src_end, v1, v2 uintptr
  52672 	_, _, _, _ = argb, src_end, v1, v2
  52673 	src_end = src + uintptr(num_pixels)*4
  52674 	for src < src_end {
  52675 		v1 = src
  52676 		src += 4
  52677 		argb = **(**uint32_t)(__ccgo_up(v1))
  52678 		v2 = dst
  52679 		dst = dst + 1
  52680 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52681 		v1 = dst
  52682 		dst = dst + 1
  52683 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52684 		v1 = dst
  52685 		dst = dst + 1
  52686 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52687 	}
  52688 }
  52689 
  52690 func CopyOrSwap(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr, swap_on_big_endian int32) {
  52691 	bp := tls.Alloc(16)
  52692 	defer tls.Free(16)
  52693 	var argb, v2, v5 uint32_t
  52694 	var src_end, v1, v4 uintptr
  52695 	_, _, _, _, _, _ = argb, src_end, v1, v2, v4, v5
  52696 	if is_big_endian(tls) == swap_on_big_endian {
  52697 		src_end = src + uintptr(num_pixels)*4
  52698 		for src < src_end {
  52699 			v1 = src
  52700 			src += 4
  52701 			argb = **(**uint32_t)(__ccgo_up(v1))
  52702 			v2 = libc.X__builtin_bswap32(tls, argb)
  52703 			goto _3
  52704 		_3:
  52705 			v4 = dst
  52706 			v5 = v2
  52707 			*(*uint32_t)(unsafe.Pointer(bp)) = v5
  52708 			libc.X__builtin___memcpy_chk(tls, v4, bp, uint64(4), ^__predefined_size_t(0))
  52709 			dst = dst + uintptr(4)
  52710 		}
  52711 	} else {
  52712 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(num_pixels)*uint64(4), ^__predefined_size_t(0))
  52713 	}
  52714 }
  52715 
  52716 func VP8LConvertFromBGRA(tls *libc.TLS, in_data uintptr, num_pixels int32, out_colorspace WEBP_CSP_MODE1, rgba uintptr) {
  52717 	switch out_colorspace {
  52718 	case int32(MODE_RGB):
  52719 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGB})))(tls, in_data, num_pixels, rgba)
  52720 	case int32(MODE_RGBA):
  52721 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, in_data, num_pixels, rgba)
  52722 	case int32(MODE_rgbA):
  52723 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, in_data, num_pixels, rgba)
  52724 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, 0, num_pixels, int32(1), 0)
  52725 	case int32(MODE_BGR):
  52726 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToBGR})))(tls, in_data, num_pixels, rgba)
  52727 	case int32(MODE_BGRA):
  52728 		CopyOrSwap(tls, in_data, num_pixels, rgba, int32(1))
  52729 	case int32(MODE_bgrA):
  52730 		CopyOrSwap(tls, in_data, num_pixels, rgba, int32(1))
  52731 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, 0, num_pixels, int32(1), 0)
  52732 	case int32(MODE_ARGB):
  52733 		CopyOrSwap(tls, in_data, num_pixels, rgba, 0)
  52734 	case int32(MODE_Argb):
  52735 		CopyOrSwap(tls, in_data, num_pixels, rgba, 0)
  52736 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, int32(1), num_pixels, int32(1), 0)
  52737 	case int32(MODE_RGBA_4444):
  52738 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA4444})))(tls, in_data, num_pixels, rgba)
  52739 	case int32(MODE_rgbA_4444):
  52740 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA4444})))(tls, in_data, num_pixels, rgba)
  52741 		(*(*func(*libc.TLS, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply4444})))(tls, rgba, num_pixels, int32(1), 0)
  52742 	case int32(MODE_RGB_565):
  52743 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGB565})))(tls, in_data, num_pixels, rgba)
  52744 	default:
  52745 		// Code flow should not reach here.
  52746 	}
  52747 }
  52748 
  52749 func VP8LDspInit(tls *libc.TLS) {
  52750 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  52751 		goto _1
  52752 	}
  52753 	VP8LDspInit_body(tls)
  52754 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  52755 	goto _2
  52756 _2:
  52757 	;
  52758 	goto _1
  52759 _1: /**/ //
  52760 }
  52761 
  52762 var VP8LDspInit_body_last_cpuinfo_used = uintptr(0)
  52763 
  52764 func init() {
  52765 	p := unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used)
  52766 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used))
  52767 }
  52768 
  52769 func VP8LDspInit_body(tls *libc.TLS) {
  52770 	VP8LPredictors[0] = __ccgo_fp(VP8LPredictor0_C)
  52771 	VP8LPredictors[int32(1)] = __ccgo_fp(VP8LPredictor1_C)
  52772 	VP8LPredictors[int32(2)] = __ccgo_fp(VP8LPredictor2_C)
  52773 	VP8LPredictors[int32(3)] = __ccgo_fp(VP8LPredictor3_C)
  52774 	VP8LPredictors[int32(4)] = __ccgo_fp(VP8LPredictor4_C)
  52775 	VP8LPredictors[int32(5)] = __ccgo_fp(VP8LPredictor5_C)
  52776 	VP8LPredictors[int32(6)] = __ccgo_fp(VP8LPredictor6_C)
  52777 	VP8LPredictors[int32(7)] = __ccgo_fp(VP8LPredictor7_C)
  52778 	VP8LPredictors[int32(8)] = __ccgo_fp(VP8LPredictor8_C)
  52779 	VP8LPredictors[int32(9)] = __ccgo_fp(VP8LPredictor9_C)
  52780 	VP8LPredictors[int32(10)] = __ccgo_fp(VP8LPredictor10_C)
  52781 	VP8LPredictors[int32(11)] = __ccgo_fp(VP8LPredictor11_C)
  52782 	VP8LPredictors[int32(12)] = __ccgo_fp(VP8LPredictor12_C)
  52783 	VP8LPredictors[int32(13)] = __ccgo_fp(VP8LPredictor13_C)
  52784 	VP8LPredictors[int32(14)] = __ccgo_fp(VP8LPredictor0_C) /* <- padding security sentinels*/
  52785 	VP8LPredictors[int32(15)] = __ccgo_fp(VP8LPredictor0_C)
  52786 	VP8LPredictorsAdd[0] = __ccgo_fp(PredictorAdd0_C)
  52787 	VP8LPredictorsAdd[int32(1)] = __ccgo_fp(PredictorAdd1_C)
  52788 	VP8LPredictorsAdd[int32(2)] = __ccgo_fp(PredictorAdd2_C)
  52789 	VP8LPredictorsAdd[int32(3)] = __ccgo_fp(PredictorAdd3_C)
  52790 	VP8LPredictorsAdd[int32(4)] = __ccgo_fp(PredictorAdd4_C)
  52791 	VP8LPredictorsAdd[int32(5)] = __ccgo_fp(PredictorAdd5_C)
  52792 	VP8LPredictorsAdd[int32(6)] = __ccgo_fp(PredictorAdd6_C)
  52793 	VP8LPredictorsAdd[int32(7)] = __ccgo_fp(PredictorAdd7_C)
  52794 	VP8LPredictorsAdd[int32(8)] = __ccgo_fp(PredictorAdd8_C)
  52795 	VP8LPredictorsAdd[int32(9)] = __ccgo_fp(PredictorAdd9_C)
  52796 	VP8LPredictorsAdd[int32(10)] = __ccgo_fp(PredictorAdd10_C)
  52797 	VP8LPredictorsAdd[int32(11)] = __ccgo_fp(PredictorAdd11_C)
  52798 	VP8LPredictorsAdd[int32(12)] = __ccgo_fp(PredictorAdd12_C)
  52799 	VP8LPredictorsAdd[int32(13)] = __ccgo_fp(PredictorAdd13_C)
  52800 	VP8LPredictorsAdd[int32(14)] = __ccgo_fp(PredictorAdd0_C) /* <- padding security sentinels*/
  52801 	VP8LPredictorsAdd[int32(15)] = __ccgo_fp(PredictorAdd0_C)
  52802 	VP8LPredictorsAdd_C[0] = __ccgo_fp(PredictorAdd0_C)
  52803 	VP8LPredictorsAdd_C[int32(1)] = __ccgo_fp(PredictorAdd1_C)
  52804 	VP8LPredictorsAdd_C[int32(2)] = __ccgo_fp(PredictorAdd2_C)
  52805 	VP8LPredictorsAdd_C[int32(3)] = __ccgo_fp(PredictorAdd3_C)
  52806 	VP8LPredictorsAdd_C[int32(4)] = __ccgo_fp(PredictorAdd4_C)
  52807 	VP8LPredictorsAdd_C[int32(5)] = __ccgo_fp(PredictorAdd5_C)
  52808 	VP8LPredictorsAdd_C[int32(6)] = __ccgo_fp(PredictorAdd6_C)
  52809 	VP8LPredictorsAdd_C[int32(7)] = __ccgo_fp(PredictorAdd7_C)
  52810 	VP8LPredictorsAdd_C[int32(8)] = __ccgo_fp(PredictorAdd8_C)
  52811 	VP8LPredictorsAdd_C[int32(9)] = __ccgo_fp(PredictorAdd9_C)
  52812 	VP8LPredictorsAdd_C[int32(10)] = __ccgo_fp(PredictorAdd10_C)
  52813 	VP8LPredictorsAdd_C[int32(11)] = __ccgo_fp(PredictorAdd11_C)
  52814 	VP8LPredictorsAdd_C[int32(12)] = __ccgo_fp(PredictorAdd12_C)
  52815 	VP8LPredictorsAdd_C[int32(13)] = __ccgo_fp(PredictorAdd13_C)
  52816 	VP8LPredictorsAdd_C[int32(14)] = __ccgo_fp(PredictorAdd0_C) /* <- padding security sentinels*/
  52817 	VP8LPredictorsAdd_C[int32(15)] = __ccgo_fp(PredictorAdd0_C)
  52818 	VP8LAddGreenToBlueAndRed = __ccgo_fp(VP8LAddGreenToBlueAndRed_C)
  52819 	VP8LTransformColorInverse = __ccgo_fp(VP8LTransformColorInverse_C)
  52820 	VP8LConvertBGRAToRGBA = __ccgo_fp(VP8LConvertBGRAToRGBA_C)
  52821 	VP8LConvertBGRAToRGB = __ccgo_fp(VP8LConvertBGRAToRGB_C)
  52822 	VP8LConvertBGRAToBGR = __ccgo_fp(VP8LConvertBGRAToBGR_C)
  52823 	VP8LConvertBGRAToRGBA4444 = __ccgo_fp(VP8LConvertBGRAToRGBA4444_C)
  52824 	VP8LConvertBGRAToRGB565 = __ccgo_fp(VP8LConvertBGRAToRGB565_C)
  52825 	VP8LMapColor32b = __ccgo_fp(MapARGB_C)
  52826 	VP8LMapColor8b = __ccgo_fp(MapAlpha_C)
  52827 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  52828 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  52829 	}
  52830 }
  52831 
  52832 func VP8LEncDspInitAVX2(tls *libc.TLS) {
  52833 }
  52834 
  52835 const LOG_2_RECIPROCAL_FIXED_DOUBLE1 = 1.2102203161561485e+07
  52836 const __FLT_MIN__11 = 1.1754943508222875e-38
  52837 
  52838 func FastSLog2Slow_C(tls *libc.TLS, v uint32_t) (r uint64_t) {
  52839 	var correction, log_cnt, orig_v uint64_t
  52840 	var y uint32_t
  52841 	var v1 int32
  52842 	_, _, _, _, _ = correction, log_cnt, orig_v, y, v1
  52843 	if v < uint32(APPROX_LOG_WITH_CORRECTION_MAX) {
  52844 		orig_v = uint64(v)
  52845 		v1 = int32(31) ^ libc.X__builtin_clz(tls, v)
  52846 		goto _2
  52847 	_2:
  52848 		// use clz if available
  52849 		log_cnt = libc.Uint64FromInt32(v1 - int32(7))
  52850 		y = libc.Uint32FromInt32(int32(1) << log_cnt)
  52851 		v = uint32(uint64(v) >> log_cnt)
  52852 		// vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256
  52853 		// Xf = floor(Xf) * (1 + (v % y) / v)
  52854 		// log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)
  52855 		// The correction factor: log(1 + d) ~ d; for very small d values, so
  52856 		// log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v
  52857 		correction = libc.Uint64FromInt32(12102203) * (orig_v & uint64(y-libc.Uint32FromInt32(1)))
  52858 		return orig_v*(uint64(kLog2Table[v])+log_cnt<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)) + correction
  52859 	} else {
  52860 		return uint64(float64(float64(libc.Float64FromFloat64(1.2102203161561485e+07)*float64(v))*libc.Xlog(tls, float64(v))) + libc.Float64FromFloat64(0.5))
  52861 	}
  52862 	return r
  52863 }
  52864 
  52865 func FastLog2Slow_C(tls *libc.TLS, v uint32_t) (r uint32_t) {
  52866 	var correction uint64_t
  52867 	var log_2, log_cnt, orig_v, y uint32_t
  52868 	var v1 int32
  52869 	var v3, v4, v5 int64_t
  52870 	var v7 int64
  52871 	_, _, _, _, _, _, _, _, _, _ = correction, log_2, log_cnt, orig_v, y, v1, v3, v4, v5, v7
  52872 	if v < uint32(APPROX_LOG_WITH_CORRECTION_MAX) {
  52873 		orig_v = v
  52874 		v1 = int32(31) ^ libc.X__builtin_clz(tls, v)
  52875 		goto _2
  52876 	_2:
  52877 		// use clz if available
  52878 		log_cnt = libc.Uint32FromInt32(v1 - int32(7))
  52879 		y = libc.Uint32FromInt32(int32(1) << log_cnt)
  52880 		v = v >> log_cnt
  52881 		log_2 = kLog2Table[v] + log_cnt<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  52882 		if orig_v >= uint32(APPROX_LOG_MAX) {
  52883 			// Since the division is still expensive, add this correction factor only
  52884 			// for large values of 'v'.
  52885 			correction = libc.Uint64FromInt32(12102203) * uint64(orig_v&(y-libc.Uint32FromInt32(1)))
  52886 			v3 = libc.Int64FromUint64(correction)
  52887 			v4 = libc.Int64FromUint32(orig_v)
  52888 			if libc.BoolInt32(v3 < 0) == libc.BoolInt32(v4 < 0) {
  52889 				v7 = (v3 + v4/int64(2)) / v4
  52890 			} else {
  52891 				v7 = (v3 - v4/int64(2)) / v4
  52892 			}
  52893 			v5 = v7
  52894 			goto _6
  52895 		_6:
  52896 			log_2 = log_2 + libc.Uint32FromInt64(v5)
  52897 		}
  52898 		return log_2
  52899 	} else {
  52900 		return uint32(float64(libc.Float64FromFloat64(1.2102203161561485e+07)*libc.Xlog(tls, float64(v))) + libc.Float64FromFloat64(0.5))
  52901 	}
  52902 	return r
  52903 }
  52904 
  52905 //------------------------------------------------------------------------------
  52906 // Methods to calculate Entropy (Shannon).
  52907 
  52908 // C documentation
  52909 //
  52910 //	// Compute the combined Shanon's entropy for distribution {X} and {X+Y}
  52911 func CombinedShannonEntropy_C(tls *libc.TLS, X uintptr, Y uintptr) (r uint64_t) {
  52912 	var i int32
  52913 	var retval, v3, v7 uint64_t
  52914 	var sumX, sumXY, x, xy, v2, v6 uint32_t
  52915 	var v5, v9 uint64
  52916 	_, _, _, _, _, _, _, _, _, _, _, _ = i, retval, sumX, sumXY, x, xy, v2, v3, v5, v6, v7, v9
  52917 	retval = uint64(0)
  52918 	sumX = uint32(0)
  52919 	sumXY = uint32(0)
  52920 	i = 0
  52921 	for {
  52922 		if !(i < int32(256)) {
  52923 			break
  52924 		}
  52925 		x = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4))
  52926 		if x != uint32(0) {
  52927 			xy = x + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52928 			sumX = sumX + x
  52929 			v2 = x
  52930 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52931 				v5 = kSLog2Table[v2]
  52932 			} else {
  52933 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52934 			}
  52935 			v3 = v5
  52936 			goto _4
  52937 		_4:
  52938 			retval = retval + v3
  52939 			sumXY = sumXY + xy
  52940 			v2 = xy
  52941 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52942 				v5 = kSLog2Table[v2]
  52943 			} else {
  52944 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52945 			}
  52946 			v3 = v5
  52947 			goto _8
  52948 		_8:
  52949 			retval = retval + v3
  52950 		} else {
  52951 			if **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4)) != uint32(0) {
  52952 				sumXY = sumXY + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52953 				v2 = **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52954 				if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52955 					v5 = kSLog2Table[v2]
  52956 				} else {
  52957 					v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52958 				}
  52959 				v3 = v5
  52960 				goto _12
  52961 			_12:
  52962 				retval = retval + v3
  52963 			}
  52964 		}
  52965 		goto _1
  52966 	_1:
  52967 		;
  52968 		i = i + 1
  52969 	}
  52970 	v2 = sumX
  52971 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52972 		v5 = kSLog2Table[v2]
  52973 	} else {
  52974 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52975 	}
  52976 	v3 = v5
  52977 	goto _16
  52978 _16:
  52979 	v6 = sumXY
  52980 	if v6 < uint32(LOG_LOOKUP_IDX_MAX) {
  52981 		v9 = kSLog2Table[v6]
  52982 	} else {
  52983 		v9 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v6)
  52984 	}
  52985 	v7 = v9
  52986 	goto _20
  52987 _20:
  52988 	retval = v3 + v7 - retval
  52989 	return retval
  52990 }
  52991 
  52992 func ShannonEntropy_C(tls *libc.TLS, X uintptr, n int32) (r uint64_t) {
  52993 	var i, x int32
  52994 	var retval, v3 uint64_t
  52995 	var sumX, v2 uint32_t
  52996 	var v5 uint64
  52997 	_, _, _, _, _, _, _ = i, retval, sumX, x, v2, v3, v5
  52998 	retval = uint64(0)
  52999 	sumX = uint32(0)
  53000 	i = 0
  53001 	for {
  53002 		if !(i < n) {
  53003 			break
  53004 		}
  53005 		x = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(X + uintptr(i)*4)))
  53006 		if x != 0 {
  53007 			sumX = sumX + libc.Uint32FromInt32(x)
  53008 			v2 = libc.Uint32FromInt32(x)
  53009 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53010 				v5 = kSLog2Table[v2]
  53011 			} else {
  53012 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53013 			}
  53014 			v3 = v5
  53015 			goto _4
  53016 		_4:
  53017 			retval = retval + v3
  53018 		}
  53019 		goto _1
  53020 	_1:
  53021 		;
  53022 		i = i + 1
  53023 	}
  53024 	v2 = sumX
  53025 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53026 		v5 = kSLog2Table[v2]
  53027 	} else {
  53028 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53029 	}
  53030 	v3 = v5
  53031 	goto _8
  53032 _8:
  53033 	retval = v3 - retval
  53034 	return retval
  53035 }
  53036 
  53037 func VP8LBitEntropyInit(tls *libc.TLS, entropy uintptr) {
  53038 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy = uint64(0)
  53039 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum = uint32(0)
  53040 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros = 0
  53041 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val = uint32(0)
  53042 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzero_code = uint32(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  53043 }
  53044 
  53045 func VP8LBitsEntropyUnrefined(tls *libc.TLS, array uintptr, n int32, entropy uintptr) {
  53046 	var i int32
  53047 	var v2 uint32_t
  53048 	var v3 uint64_t
  53049 	var v5 uint64
  53050 	_, _, _, _ = i, v2, v3, v5
  53051 	VP8LBitEntropyInit(tls, entropy)
  53052 	i = 0
  53053 	for {
  53054 		if !(i < n) {
  53055 			break
  53056 		}
  53057 		if **(**uint32_t)(__ccgo_up(array + uintptr(i)*4)) != uint32(0) {
  53058 			**(**uint32_t)(__ccgo_up(entropy + 8)) += **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53059 			(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzero_code = libc.Uint32FromInt32(i)
  53060 			(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros + 1
  53061 			v2 = **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53062 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53063 				v5 = kSLog2Table[v2]
  53064 			} else {
  53065 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53066 			}
  53067 			v3 = v5
  53068 			goto _4
  53069 		_4:
  53070 			**(**uint64_t)(__ccgo_up(entropy)) += v3
  53071 			if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val < **(**uint32_t)(__ccgo_up(array + uintptr(i)*4)) {
  53072 				(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val = **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53073 			}
  53074 		}
  53075 		goto _1
  53076 	_1:
  53077 		;
  53078 		i = i + 1
  53079 	}
  53080 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum
  53081 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53082 		v5 = kSLog2Table[v2]
  53083 	} else {
  53084 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53085 	}
  53086 	v3 = v5
  53087 	goto _8
  53088 _8:
  53089 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy
  53090 }
  53091 
  53092 func GetEntropyUnrefinedHelper(tls *libc.TLS, val uint32_t, i int32, val_prev uintptr, i_prev uintptr, bit_entropy uintptr, stats uintptr) {
  53093 	var streak int32
  53094 	var v1 uint32_t
  53095 	var v2 uint64_t
  53096 	var v4 uint64
  53097 	_, _, _, _ = streak, v1, v2, v4
  53098 	streak = i - **(**int32)(__ccgo_up(i_prev))
  53099 	// Gather info for the bit entropy.
  53100 	if **(**uint32_t)(__ccgo_up(val_prev)) != uint32(0) {
  53101 		**(**uint32_t)(__ccgo_up(bit_entropy + 8)) += **(**uint32_t)(__ccgo_up(val_prev)) * libc.Uint32FromInt32(streak)
  53102 		**(**int32)(__ccgo_up(bit_entropy + 12)) += streak
  53103 		(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fnonzero_code = libc.Uint32FromInt32(**(**int32)(__ccgo_up(i_prev)))
  53104 		v1 = **(**uint32_t)(__ccgo_up(val_prev))
  53105 		if v1 < uint32(LOG_LOOKUP_IDX_MAX) {
  53106 			v4 = kSLog2Table[v1]
  53107 		} else {
  53108 			v4 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v1)
  53109 		}
  53110 		v2 = v4
  53111 		goto _3
  53112 	_3:
  53113 		**(**uint64_t)(__ccgo_up(bit_entropy)) += v2 * libc.Uint64FromInt32(streak)
  53114 		if (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fmax_val < **(**uint32_t)(__ccgo_up(val_prev)) {
  53115 			(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fmax_val = **(**uint32_t)(__ccgo_up(val_prev))
  53116 		}
  53117 	}
  53118 	// Gather info for the Huffman cost.
  53119 	**(**int32)(__ccgo_up(stats + libc.BoolUintptr(**(**uint32_t)(__ccgo_up(val_prev)) != uint32(0))*4)) += libc.BoolInt32(streak > int32(3))
  53120 	**(**int32)(__ccgo_up(stats + 8 + libc.BoolUintptr(**(**uint32_t)(__ccgo_up(val_prev)) != uint32(0))*8 + libc.BoolUintptr(streak > libc.Int32FromInt32(3))*4)) += streak
  53121 	**(**uint32_t)(__ccgo_up(val_prev)) = val
  53122 	**(**int32)(__ccgo_up(i_prev)) = i
  53123 }
  53124 
  53125 func GetEntropyUnrefined_C(tls *libc.TLS, X uintptr, length int32, bit_entropy uintptr, stats uintptr) {
  53126 	bp := tls.Alloc(16)
  53127 	defer tls.Free(16)
  53128 	var i int32
  53129 	var x, v2 uint32_t
  53130 	var v3 uint64_t
  53131 	var v5 uint64
  53132 	var _ /* i_prev at bp+0 */ int32
  53133 	var _ /* x_prev at bp+4 */ uint32_t
  53134 	_, _, _, _, _ = i, x, v2, v3, v5
  53135 	**(**int32)(__ccgo_up(bp)) = 0
  53136 	**(**uint32_t)(__ccgo_up(bp + 4)) = **(**uint32_t)(__ccgo_up(X))
  53137 	libc.X__builtin___memset_chk(tls, stats, 0, uint64(24), ^__predefined_size_t(0))
  53138 	VP8LBitEntropyInit(tls, bit_entropy)
  53139 	i = int32(1)
  53140 	for {
  53141 		if !(i < length) {
  53142 			break
  53143 		}
  53144 		x = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4))
  53145 		if x != **(**uint32_t)(__ccgo_up(bp + 4)) {
  53146 			GetEntropyUnrefinedHelper(tls, x, i, bp+4, bp, bit_entropy, stats)
  53147 		}
  53148 		goto _1
  53149 	_1:
  53150 		;
  53151 		i = i + 1
  53152 	}
  53153 	GetEntropyUnrefinedHelper(tls, uint32(0), i, bp+4, bp, bit_entropy, stats)
  53154 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fsum
  53155 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53156 		v5 = kSLog2Table[v2]
  53157 	} else {
  53158 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53159 	}
  53160 	v3 = v5
  53161 	goto _4
  53162 _4:
  53163 	(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy
  53164 }
  53165 
  53166 func GetCombinedEntropyUnrefined_C(tls *libc.TLS, X uintptr, Y uintptr, length int32, bit_entropy uintptr, stats uintptr) {
  53167 	bp := tls.Alloc(16)
  53168 	defer tls.Free(16)
  53169 	var i int32
  53170 	var xy, v2 uint32_t
  53171 	var v3 uint64_t
  53172 	var v5 uint64
  53173 	var _ /* i_prev at bp+0 */ int32
  53174 	var _ /* xy_prev at bp+4 */ uint32_t
  53175 	_, _, _, _, _ = i, xy, v2, v3, v5
  53176 	i = int32(1)
  53177 	**(**int32)(__ccgo_up(bp)) = 0
  53178 	**(**uint32_t)(__ccgo_up(bp + 4)) = **(**uint32_t)(__ccgo_up(X)) + **(**uint32_t)(__ccgo_up(Y))
  53179 	libc.X__builtin___memset_chk(tls, stats, 0, uint64(24), ^__predefined_size_t(0))
  53180 	VP8LBitEntropyInit(tls, bit_entropy)
  53181 	i = int32(1)
  53182 	for {
  53183 		if !(i < length) {
  53184 			break
  53185 		}
  53186 		xy = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4)) + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  53187 		if xy != **(**uint32_t)(__ccgo_up(bp + 4)) {
  53188 			GetEntropyUnrefinedHelper(tls, xy, i, bp+4, bp, bit_entropy, stats)
  53189 		}
  53190 		goto _1
  53191 	_1:
  53192 		;
  53193 		i = i + 1
  53194 	}
  53195 	GetEntropyUnrefinedHelper(tls, uint32(0), i, bp+4, bp, bit_entropy, stats)
  53196 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fsum
  53197 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53198 		v5 = kSLog2Table[v2]
  53199 	} else {
  53200 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53201 	}
  53202 	v3 = v5
  53203 	goto _4
  53204 _4:
  53205 	(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy
  53206 }
  53207 
  53208 //------------------------------------------------------------------------------
  53209 
  53210 func VP8LSubtractGreenFromBlueAndRed_C(tls *libc.TLS, argb_data uintptr, num_pixels int32) {
  53211 	var argb, green, i int32
  53212 	var new_b, new_r uint32_t
  53213 	_, _, _, _, _ = argb, green, i, new_b, new_r
  53214 	i = 0
  53215 	for {
  53216 		if !(i < num_pixels) {
  53217 			break
  53218 		}
  53219 		argb = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb_data + uintptr(i)*4)))
  53220 		green = argb >> libc.Int32FromInt32(8) & int32(0xff)
  53221 		new_r = libc.Uint32FromInt32((argb>>libc.Int32FromInt32(16)&int32(0xff) - green) & int32(0xff))
  53222 		new_b = libc.Uint32FromInt32((argb>>libc.Int32FromInt32(0)&int32(0xff) - green) & int32(0xff))
  53223 		**(**uint32_t)(__ccgo_up(argb_data + uintptr(i)*4)) = libc.Uint32FromInt32(argb)&uint32(0xff00ff00) | new_r<<libc.Int32FromInt32(16) | new_b
  53224 		goto _1
  53225 	_1:
  53226 		;
  53227 		i = i + 1
  53228 	}
  53229 }
  53230 
  53231 func ColorTransformDelta1(tls *libc.TLS, color_pred int8_t, color int8_t) (r int32) {
  53232 	return int32(color_pred) * int32(color) >> int32(5)
  53233 }
  53234 
  53235 func U32ToS8(tls *libc.TLS, v uint32_t) (r int8_t) {
  53236 	return libc.Int8FromUint32(v & libc.Uint32FromInt32(0xff))
  53237 }
  53238 
  53239 func VP8LTransformColor_C(tls *libc.TLS, m uintptr, data uintptr, num_pixels int32) {
  53240 	var argb uint32_t
  53241 	var green, red int8_t
  53242 	var i, new_blue, new_red int32
  53243 	_, _, _, _, _, _ = argb, green, i, new_blue, new_red, red
  53244 	i = 0
  53245 	for {
  53246 		if !(i < num_pixels) {
  53247 			break
  53248 		}
  53249 		argb = **(**uint32_t)(__ccgo_up(data + uintptr(i)*4))
  53250 		green = U32ToS8(tls, argb>>int32(8))
  53251 		red = U32ToS8(tls, argb>>int32(16))
  53252 		new_red = int32(red) & int32(0xff)
  53253 		new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  53254 		new_red = new_red - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red), green)
  53255 		new_red = new_red & int32(0xff)
  53256 		new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue), green)
  53257 		new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue), red)
  53258 		new_blue = new_blue & int32(0xff)
  53259 		**(**uint32_t)(__ccgo_up(data + uintptr(i)*4)) = argb&uint32(0xff00ff00) | libc.Uint32FromInt32(new_red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(new_blue)
  53260 		goto _1
  53261 	_1:
  53262 		;
  53263 		i = i + 1
  53264 	}
  53265 }
  53266 
  53267 func TransformColorRed(tls *libc.TLS, green_to_red uint8_t, argb uint32_t) (r uint8_t) {
  53268 	var green int8_t
  53269 	var new_red int32
  53270 	_, _ = green, new_red
  53271 	green = U32ToS8(tls, argb>>int32(8))
  53272 	new_red = libc.Int32FromUint32(argb >> int32(16))
  53273 	new_red = new_red - ColorTransformDelta1(tls, libc.Int8FromUint8(green_to_red), green)
  53274 	return libc.Uint8FromInt32(new_red & libc.Int32FromInt32(0xff))
  53275 }
  53276 
  53277 func TransformColorBlue(tls *libc.TLS, green_to_blue uint8_t, red_to_blue uint8_t, argb uint32_t) (r uint8_t) {
  53278 	var green, red int8_t
  53279 	var new_blue int32
  53280 	_, _, _ = green, new_blue, red
  53281 	green = U32ToS8(tls, argb>>int32(8))
  53282 	red = U32ToS8(tls, argb>>int32(16))
  53283 	new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  53284 	new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8(green_to_blue), green)
  53285 	new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8(red_to_blue), red)
  53286 	return libc.Uint8FromInt32(new_blue & libc.Int32FromInt32(0xff))
  53287 }
  53288 
  53289 func VP8LCollectColorRedTransforms_C(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, green_to_red int32, histo uintptr) {
  53290 	var x, v1 int32
  53291 	_, _ = x, v1
  53292 	for {
  53293 		v1 = tile_height
  53294 		tile_height = tile_height - 1
  53295 		if !(v1 > 0) {
  53296 			break
  53297 		}
  53298 		x = 0
  53299 		for {
  53300 			if !(x < tile_width) {
  53301 				break
  53302 			}
  53303 			**(**uint32_t)(__ccgo_up(histo + uintptr(TransformColorRed(tls, libc.Uint8FromInt32(green_to_red), **(**uint32_t)(__ccgo_up(argb + uintptr(x)*4))))*4)) = **(**uint32_t)(__ccgo_up(histo + uintptr(TransformColorRed(tls, libc.Uint8FromInt32(green_to_red), **(**uint32_t)(__ccgo_up(argb + uintptr(x)*4))))*4)) + 1
  53304 			goto _2
  53305 		_2:
  53306 			;
  53307 			x = x + 1
  53308 		}
  53309 		argb = argb + uintptr(stride)*4
  53310 	}
  53311 }
  53312 
  53313 func VP8LCollectColorBlueTransforms_C(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, green_to_blue int32, red_to_blue int32, histo uintptr) {
  53314 	var x, v1 int32
  53315 	_, _ = x, v1
  53316 	for {
  53317 		v1 = tile_height
  53318 		tile_height = tile_height - 1
  53319 		if !(v1 > 0) {
  53320 			break
  53321 		}
  53322 		x = 0
  53323 		for {
  53324 			if !(x < tile_width) {
  53325 				break
  53326 			}
  53327 			**(**uint32_t)(__ccgo_up(histo + uintptr(TransformColorBlue(tls, libc.Uint8FromInt32(green_to_blue), libc.Uint8FromInt32(red_to_blue), **(**uint32_t)(__ccgo_up(argb + uintptr(x)*4))))*4)) = **(**uint32_t)(__ccgo_up(histo + uintptr(TransformColorBlue(tls, libc.Uint8FromInt32(green_to_blue), libc.Uint8FromInt32(red_to_blue), **(**uint32_t)(__ccgo_up(argb + uintptr(x)*4))))*4)) + 1
  53328 			goto _2
  53329 		_2:
  53330 			;
  53331 			x = x + 1
  53332 		}
  53333 		argb = argb + uintptr(stride)*4
  53334 	}
  53335 }
  53336 
  53337 //------------------------------------------------------------------------------
  53338 
  53339 func VectorMismatch_C(tls *libc.TLS, array1 uintptr, array2 uintptr, length int32) (r int32) {
  53340 	var match_len int32
  53341 	_ = match_len
  53342 	match_len = 0
  53343 	for match_len < length && **(**uint32_t)(__ccgo_up(array1 + uintptr(match_len)*4)) == **(**uint32_t)(__ccgo_up(array2 + uintptr(match_len)*4)) {
  53344 		match_len = match_len + 1
  53345 	}
  53346 	return match_len
  53347 }
  53348 
  53349 // C documentation
  53350 //
  53351 //	// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
  53352 func VP8LBundleColorMap_C(tls *libc.TLS, row uintptr, width int32, xbits int32, dst uintptr) {
  53353 	var bit_depth, mask, x, xsub int32
  53354 	var code uint32_t
  53355 	_, _, _, _, _ = bit_depth, code, mask, x, xsub
  53356 	if xbits > 0 {
  53357 		bit_depth = int32(1) << (int32(3) - xbits)
  53358 		mask = int32(1)<<xbits - int32(1)
  53359 		code = uint32(0xff000000)
  53360 		x = 0
  53361 		for {
  53362 			if !(x < width) {
  53363 				break
  53364 			}
  53365 			xsub = x & mask
  53366 			if xsub == 0 {
  53367 				code = uint32(0xff000000)
  53368 			}
  53369 			code = code | libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(row + uintptr(x))))<<(int32(8)+bit_depth*xsub))
  53370 			**(**uint32_t)(__ccgo_up(dst + uintptr(x>>xbits)*4)) = code
  53371 			goto _1
  53372 		_1:
  53373 			;
  53374 			x = x + 1
  53375 		}
  53376 	} else {
  53377 		x = 0
  53378 		for {
  53379 			if !(x < width) {
  53380 				break
  53381 			}
  53382 			**(**uint32_t)(__ccgo_up(dst + uintptr(x)*4)) = uint32(0xff000000) | libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(row + uintptr(x))))<<libc.Int32FromInt32(8))
  53383 			goto _2
  53384 		_2:
  53385 			;
  53386 			x = x + 1
  53387 		}
  53388 	}
  53389 }
  53390 
  53391 //------------------------------------------------------------------------------
  53392 
  53393 func ExtraCost_C(tls *libc.TLS, population uintptr, length int32) (r uint32_t) {
  53394 	var cost uint32_t
  53395 	var i int32
  53396 	_, _ = cost, i
  53397 	cost = **(**uint32_t)(__ccgo_up(population + 4*4)) + **(**uint32_t)(__ccgo_up(population + 5*4))
  53398 	i = int32(2)
  53399 	for {
  53400 		if !(i < length/int32(2)-int32(1)) {
  53401 			break
  53402 		}
  53403 		cost = cost + libc.Uint32FromInt32(i)*(**(**uint32_t)(__ccgo_up(population + uintptr(int32(2)*i+int32(2))*4))+**(**uint32_t)(__ccgo_up(population + uintptr(int32(2)*i+int32(3))*4)))
  53404 		goto _1
  53405 	_1:
  53406 		;
  53407 		i = i + 1
  53408 	}
  53409 	return cost
  53410 }
  53411 
  53412 //------------------------------------------------------------------------------
  53413 
  53414 func AddVector_C(tls *libc.TLS, a uintptr, b uintptr, out uintptr, size int32) {
  53415 	var i int32
  53416 	_ = i
  53417 	i = 0
  53418 	for {
  53419 		if !(i < size) {
  53420 			break
  53421 		}
  53422 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(a + uintptr(i)*4)) + **(**uint32_t)(__ccgo_up(b + uintptr(i)*4))
  53423 		goto _1
  53424 	_1:
  53425 		;
  53426 		i = i + 1
  53427 	}
  53428 }
  53429 
  53430 func AddVectorEq_C(tls *libc.TLS, a uintptr, out uintptr, size int32) {
  53431 	var i int32
  53432 	_ = i
  53433 	i = 0
  53434 	for {
  53435 		if !(i < size) {
  53436 			break
  53437 		}
  53438 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) += **(**uint32_t)(__ccgo_up(a + uintptr(i)*4))
  53439 		goto _1
  53440 	_1:
  53441 		;
  53442 		i = i + 1
  53443 	}
  53444 }
  53445 
  53446 //------------------------------------------------------------------------------
  53447 // Image transforms.
  53448 
  53449 func PredictorSub0_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53450 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  53451 	var i int32
  53452 	_, _, _, _, _, _ = alpha_and_green, i, red_and_blue, v2, v3, v4
  53453 	i = 0
  53454 	for {
  53455 		if !(i < num_pixels) {
  53456 			break
  53457 		}
  53458 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  53459 		v3 = uint32(ARGB_BLACK3)
  53460 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53461 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53462 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53463 		goto _5
  53464 	_5:
  53465 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v4
  53466 		goto _1
  53467 	_1:
  53468 		;
  53469 		i = i + 1
  53470 	}
  53471 	_ = upper
  53472 }
  53473 
  53474 func PredictorSub1_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53475 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  53476 	var i int32
  53477 	_, _, _, _, _, _ = alpha_and_green, i, red_and_blue, v2, v3, v4
  53478 	i = 0
  53479 	for {
  53480 		if !(i < num_pixels) {
  53481 			break
  53482 		}
  53483 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  53484 		v3 = **(**uint32_t)(__ccgo_up(in + uintptr(i-int32(1))*4))
  53485 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53486 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53487 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53488 		goto _5
  53489 	_5:
  53490 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v4
  53491 		goto _1
  53492 	_1:
  53493 		;
  53494 		i = i + 1
  53495 	}
  53496 	_ = upper
  53497 }
  53498 
  53499 // It subtracts the prediction from the input pixel and stores the residual
  53500 // in the output pixel.
  53501 func PredictorSub2_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53502 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53503 	var x int32
  53504 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53505 	x = 0
  53506 	for {
  53507 		if !(x < num_pixels) {
  53508 			break
  53509 		}
  53510 		pred = VP8LPredictor2_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53511 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53512 		v3 = pred
  53513 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53514 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53515 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53516 		goto _5
  53517 	_5:
  53518 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53519 		goto _1
  53520 	_1:
  53521 		;
  53522 		x = x + 1
  53523 	}
  53524 }
  53525 
  53526 func PredictorSub3_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53527 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53528 	var x int32
  53529 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53530 	x = 0
  53531 	for {
  53532 		if !(x < num_pixels) {
  53533 			break
  53534 		}
  53535 		pred = VP8LPredictor3_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53536 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53537 		v3 = pred
  53538 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53539 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53540 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53541 		goto _5
  53542 	_5:
  53543 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53544 		goto _1
  53545 	_1:
  53546 		;
  53547 		x = x + 1
  53548 	}
  53549 }
  53550 
  53551 func PredictorSub4_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53552 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53553 	var x int32
  53554 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53555 	x = 0
  53556 	for {
  53557 		if !(x < num_pixels) {
  53558 			break
  53559 		}
  53560 		pred = VP8LPredictor4_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53561 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53562 		v3 = pred
  53563 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53564 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53565 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53566 		goto _5
  53567 	_5:
  53568 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53569 		goto _1
  53570 	_1:
  53571 		;
  53572 		x = x + 1
  53573 	}
  53574 }
  53575 
  53576 func PredictorSub5_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53577 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53578 	var x int32
  53579 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53580 	x = 0
  53581 	for {
  53582 		if !(x < num_pixels) {
  53583 			break
  53584 		}
  53585 		pred = VP8LPredictor5_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53586 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53587 		v3 = pred
  53588 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53589 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53590 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53591 		goto _5
  53592 	_5:
  53593 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53594 		goto _1
  53595 	_1:
  53596 		;
  53597 		x = x + 1
  53598 	}
  53599 }
  53600 
  53601 func PredictorSub6_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53602 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53603 	var x int32
  53604 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53605 	x = 0
  53606 	for {
  53607 		if !(x < num_pixels) {
  53608 			break
  53609 		}
  53610 		pred = VP8LPredictor6_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53611 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53612 		v3 = pred
  53613 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53614 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53615 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53616 		goto _5
  53617 	_5:
  53618 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53619 		goto _1
  53620 	_1:
  53621 		;
  53622 		x = x + 1
  53623 	}
  53624 }
  53625 
  53626 func PredictorSub7_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53627 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53628 	var x int32
  53629 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53630 	x = 0
  53631 	for {
  53632 		if !(x < num_pixels) {
  53633 			break
  53634 		}
  53635 		pred = VP8LPredictor7_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53636 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53637 		v3 = pred
  53638 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53639 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53640 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53641 		goto _5
  53642 	_5:
  53643 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53644 		goto _1
  53645 	_1:
  53646 		;
  53647 		x = x + 1
  53648 	}
  53649 }
  53650 
  53651 func PredictorSub8_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53652 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53653 	var x int32
  53654 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53655 	x = 0
  53656 	for {
  53657 		if !(x < num_pixels) {
  53658 			break
  53659 		}
  53660 		pred = VP8LPredictor8_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53661 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53662 		v3 = pred
  53663 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53664 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53665 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53666 		goto _5
  53667 	_5:
  53668 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53669 		goto _1
  53670 	_1:
  53671 		;
  53672 		x = x + 1
  53673 	}
  53674 }
  53675 
  53676 func PredictorSub9_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53677 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53678 	var x int32
  53679 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53680 	x = 0
  53681 	for {
  53682 		if !(x < num_pixels) {
  53683 			break
  53684 		}
  53685 		pred = VP8LPredictor9_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53686 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53687 		v3 = pred
  53688 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53689 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53690 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53691 		goto _5
  53692 	_5:
  53693 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53694 		goto _1
  53695 	_1:
  53696 		;
  53697 		x = x + 1
  53698 	}
  53699 }
  53700 
  53701 func PredictorSub10_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53702 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53703 	var x int32
  53704 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53705 	x = 0
  53706 	for {
  53707 		if !(x < num_pixels) {
  53708 			break
  53709 		}
  53710 		pred = VP8LPredictor10_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53711 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53712 		v3 = pred
  53713 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53714 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53715 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53716 		goto _5
  53717 	_5:
  53718 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53719 		goto _1
  53720 	_1:
  53721 		;
  53722 		x = x + 1
  53723 	}
  53724 }
  53725 
  53726 func PredictorSub11_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53727 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53728 	var x int32
  53729 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53730 	x = 0
  53731 	for {
  53732 		if !(x < num_pixels) {
  53733 			break
  53734 		}
  53735 		pred = VP8LPredictor11_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53736 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53737 		v3 = pred
  53738 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53739 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53740 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53741 		goto _5
  53742 	_5:
  53743 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53744 		goto _1
  53745 	_1:
  53746 		;
  53747 		x = x + 1
  53748 	}
  53749 }
  53750 
  53751 func PredictorSub12_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53752 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53753 	var x int32
  53754 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53755 	x = 0
  53756 	for {
  53757 		if !(x < num_pixels) {
  53758 			break
  53759 		}
  53760 		pred = VP8LPredictor12_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53761 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53762 		v3 = pred
  53763 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53764 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53765 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53766 		goto _5
  53767 	_5:
  53768 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53769 		goto _1
  53770 	_1:
  53771 		;
  53772 		x = x + 1
  53773 	}
  53774 }
  53775 
  53776 func PredictorSub13_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53777 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53778 	var x int32
  53779 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53780 	x = 0
  53781 	for {
  53782 		if !(x < num_pixels) {
  53783 			break
  53784 		}
  53785 		pred = VP8LPredictor13_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53786 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53787 		v3 = pred
  53788 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53789 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53790 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53791 		goto _5
  53792 	_5:
  53793 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53794 		goto _1
  53795 	_1:
  53796 		;
  53797 		x = x + 1
  53798 	}
  53799 }
  53800 
  53801 func VP8LEncDspInit(tls *libc.TLS) {
  53802 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  53803 		goto _1
  53804 	}
  53805 	VP8LEncDspInit_body(tls)
  53806 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  53807 	goto _2
  53808 _2:
  53809 	;
  53810 	goto _1
  53811 _1: /**/ //
  53812 }
  53813 
  53814 var VP8LEncDspInit_body_last_cpuinfo_used = uintptr(0)
  53815 
  53816 func init() {
  53817 	p := unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used)
  53818 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used))
  53819 }
  53820 
  53821 func VP8LEncDspInit_body(tls *libc.TLS) {
  53822 	VP8LDspInit(tls)
  53823 	VP8LSubtractGreenFromBlueAndRed = __ccgo_fp(VP8LSubtractGreenFromBlueAndRed_C)
  53824 	VP8LTransformColor = __ccgo_fp(VP8LTransformColor_C)
  53825 	VP8LCollectColorBlueTransforms = __ccgo_fp(VP8LCollectColorBlueTransforms_C)
  53826 	VP8LCollectColorRedTransforms = __ccgo_fp(VP8LCollectColorRedTransforms_C)
  53827 	VP8LFastLog2Slow = __ccgo_fp(FastLog2Slow_C)
  53828 	VP8LFastSLog2Slow = __ccgo_fp(FastSLog2Slow_C)
  53829 	VP8LExtraCost = __ccgo_fp(ExtraCost_C)
  53830 	VP8LCombinedShannonEntropy = __ccgo_fp(CombinedShannonEntropy_C)
  53831 	VP8LShannonEntropy = __ccgo_fp(ShannonEntropy_C)
  53832 	VP8LGetEntropyUnrefined = __ccgo_fp(GetEntropyUnrefined_C)
  53833 	VP8LGetCombinedEntropyUnrefined = __ccgo_fp(GetCombinedEntropyUnrefined_C)
  53834 	VP8LAddVector = __ccgo_fp(AddVector_C)
  53835 	VP8LAddVectorEq = __ccgo_fp(AddVectorEq_C)
  53836 	VP8LVectorMismatch = __ccgo_fp(VectorMismatch_C)
  53837 	VP8LBundleColorMap = __ccgo_fp(VP8LBundleColorMap_C)
  53838 	VP8LPredictorsSub[0] = __ccgo_fp(PredictorSub0_C)
  53839 	VP8LPredictorsSub[int32(1)] = __ccgo_fp(PredictorSub1_C)
  53840 	VP8LPredictorsSub[int32(2)] = __ccgo_fp(PredictorSub2_C)
  53841 	VP8LPredictorsSub[int32(3)] = __ccgo_fp(PredictorSub3_C)
  53842 	VP8LPredictorsSub[int32(4)] = __ccgo_fp(PredictorSub4_C)
  53843 	VP8LPredictorsSub[int32(5)] = __ccgo_fp(PredictorSub5_C)
  53844 	VP8LPredictorsSub[int32(6)] = __ccgo_fp(PredictorSub6_C)
  53845 	VP8LPredictorsSub[int32(7)] = __ccgo_fp(PredictorSub7_C)
  53846 	VP8LPredictorsSub[int32(8)] = __ccgo_fp(PredictorSub8_C)
  53847 	VP8LPredictorsSub[int32(9)] = __ccgo_fp(PredictorSub9_C)
  53848 	VP8LPredictorsSub[int32(10)] = __ccgo_fp(PredictorSub10_C)
  53849 	VP8LPredictorsSub[int32(11)] = __ccgo_fp(PredictorSub11_C)
  53850 	VP8LPredictorsSub[int32(12)] = __ccgo_fp(PredictorSub12_C)
  53851 	VP8LPredictorsSub[int32(13)] = __ccgo_fp(PredictorSub13_C)
  53852 	VP8LPredictorsSub[int32(14)] = __ccgo_fp(PredictorSub0_C) // <- padding security sentinels
  53853 	VP8LPredictorsSub[int32(15)] = __ccgo_fp(PredictorSub0_C)
  53854 	VP8LPredictorsSub_C[0] = __ccgo_fp(PredictorSub0_C)
  53855 	VP8LPredictorsSub_C[int32(1)] = __ccgo_fp(PredictorSub1_C)
  53856 	VP8LPredictorsSub_C[int32(2)] = __ccgo_fp(PredictorSub2_C)
  53857 	VP8LPredictorsSub_C[int32(3)] = __ccgo_fp(PredictorSub3_C)
  53858 	VP8LPredictorsSub_C[int32(4)] = __ccgo_fp(PredictorSub4_C)
  53859 	VP8LPredictorsSub_C[int32(5)] = __ccgo_fp(PredictorSub5_C)
  53860 	VP8LPredictorsSub_C[int32(6)] = __ccgo_fp(PredictorSub6_C)
  53861 	VP8LPredictorsSub_C[int32(7)] = __ccgo_fp(PredictorSub7_C)
  53862 	VP8LPredictorsSub_C[int32(8)] = __ccgo_fp(PredictorSub8_C)
  53863 	VP8LPredictorsSub_C[int32(9)] = __ccgo_fp(PredictorSub9_C)
  53864 	VP8LPredictorsSub_C[int32(10)] = __ccgo_fp(PredictorSub10_C)
  53865 	VP8LPredictorsSub_C[int32(11)] = __ccgo_fp(PredictorSub11_C)
  53866 	VP8LPredictorsSub_C[int32(12)] = __ccgo_fp(PredictorSub12_C)
  53867 	VP8LPredictorsSub_C[int32(13)] = __ccgo_fp(PredictorSub13_C)
  53868 	VP8LPredictorsSub_C[int32(14)] = __ccgo_fp(PredictorSub0_C) // <- padding security sentinels
  53869 	VP8LPredictorsSub_C[int32(15)] = __ccgo_fp(PredictorSub0_C)
  53870 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  53871 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  53872 	}
  53873 }
  53874 
  53875 const LOG_2_RECIPROCAL_FIXED_DOUBLE2 = 12102203.161561485379934310913085937500
  53876 const __FLT_MIN__12 = 1.17549435082228750796873653722224568e-38
  53877 
  53878 func VP8LEncDspInitMIPS32(tls *libc.TLS) {
  53879 }
  53880 
  53881 func VP8LEncDspInitMIPSdspR2(tls *libc.TLS) {
  53882 }
  53883 
  53884 func VP8LEncDspInitMSA(tls *libc.TLS) {
  53885 }
  53886 
  53887 func VP8LEncDspInitNEON(tls *libc.TLS) {
  53888 }
  53889 
  53890 func VP8LEncDspInitSSE2(tls *libc.TLS) {
  53891 }
  53892 
  53893 func VP8LEncDspInitSSE41(tls *libc.TLS) {
  53894 }
  53895 
  53896 func VP8LDspInitMIPSdspR2(tls *libc.TLS) {
  53897 }
  53898 
  53899 func VP8LDspInitMSA(tls *libc.TLS) {
  53900 }
  53901 
  53902 func VP8LDspInitNEON(tls *libc.TLS) {
  53903 }
  53904 
  53905 func VP8LDspInitSSE2(tls *libc.TLS) {
  53906 }
  53907 
  53908 func VP8LDspInitSSE41(tls *libc.TLS) {
  53909 }
  53910 
  53911 //------------------------------------------------------------------------------
  53912 
  53913 //------------------------------------------------------------------------------
  53914 // Implementations of critical functions ImportRow / ExportRow
  53915 
  53916 //------------------------------------------------------------------------------
  53917 // Row import
  53918 
  53919 func WebPRescalerImportRowExpand_C(tls *libc.TLS, wrk uintptr, src uintptr) {
  53920 	var accum, channel, x_in, x_out, x_out_max, x_stride int32
  53921 	var left, right rescaler_t
  53922 	var v2 uint32
  53923 	_, _, _, _, _, _, _, _, _ = accum, channel, left, right, x_in, x_out, x_out_max, x_stride, v2
  53924 	x_stride = (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53925 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53926 	channel = 0
  53927 	for {
  53928 		if !(channel < x_stride) {
  53929 			break
  53930 		}
  53931 		x_in = channel
  53932 		x_out = channel
  53933 		// simple bilinear interpolation
  53934 		accum = (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53935 		left = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53936 		if (*WebPRescaler)(unsafe.Pointer(wrk)).Fsrc_width > int32(1) {
  53937 			v2 = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in+x_stride))))
  53938 		} else {
  53939 			v2 = left
  53940 		}
  53941 		right = v2
  53942 		x_in = x_in + x_stride
  53943 		for int32(1) != 0 {
  53944 			**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow + uintptr(x_out)*4)) = right*libc.Uint32FromInt32((*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add) + (left-right)*libc.Uint32FromInt32(accum)
  53945 			x_out = x_out + x_stride
  53946 			if x_out >= x_out_max {
  53947 				break
  53948 			}
  53949 			accum = accum - (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub
  53950 			if accum < 0 {
  53951 				left = right
  53952 				x_in = x_in + x_stride
  53953 				right = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53954 				accum = accum + (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53955 			}
  53956 		}
  53957 		goto _1
  53958 	_1:
  53959 		;
  53960 		channel = channel + 1
  53961 	}
  53962 }
  53963 
  53964 func WebPRescalerImportRowShrink_C(tls *libc.TLS, wrk uintptr, src uintptr) {
  53965 	var accum, channel, x_in, x_out, x_out_max, x_stride int32
  53966 	var base, sum uint32_t
  53967 	var frac rescaler_t
  53968 	_, _, _, _, _, _, _, _, _ = accum, base, channel, frac, sum, x_in, x_out, x_out_max, x_stride
  53969 	x_stride = (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53970 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53971 	channel = 0
  53972 	for {
  53973 		if !(channel < x_stride) {
  53974 			break
  53975 		}
  53976 		x_in = channel
  53977 		x_out = channel
  53978 		sum = uint32(0)
  53979 		accum = 0
  53980 		for x_out < x_out_max {
  53981 			base = uint32(0)
  53982 			accum = accum + (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53983 			for accum > 0 {
  53984 				accum = accum - (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub
  53985 				base = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53986 				sum = sum + base
  53987 				x_in = x_in + x_stride
  53988 			}
  53989 			// Emit next horizontal pixel.
  53990 			frac = base * libc.Uint32FromInt32(-accum)
  53991 			**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow + uintptr(x_out)*4)) = sum*libc.Uint32FromInt32((*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub) - frac
  53992 			// fresh fractional start for next pixel
  53993 			sum = libc.Uint32FromInt32(libc.Int32FromUint64((uint64(frac)*uint64((*WebPRescaler)(unsafe.Pointer(wrk)).Ffx_scale) + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX)))
  53994 			x_out = x_out + x_stride
  53995 		}
  53996 		goto _1
  53997 	_1:
  53998 		;
  53999 		channel = channel + 1
  54000 	}
  54001 }
  54002 
  54003 //------------------------------------------------------------------------------
  54004 // Row export
  54005 
  54006 func WebPRescalerExportRowExpand_C(tls *libc.TLS, wrk uintptr) {
  54007 	var A, B, J, J1 uint32_t
  54008 	var I uint64_t
  54009 	var dst, frow, irow uintptr
  54010 	var v, v1, x_out, x_out_max int32
  54011 	var v2 uint32
  54012 	_, _, _, _, _, _, _, _, _, _, _, _, _ = A, B, I, J, J1, dst, frow, irow, v, v1, x_out, x_out_max, v2
  54013 	dst = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst
  54014 	irow = (*WebPRescaler)(unsafe.Pointer(wrk)).Firow
  54015 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  54016 	frow = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow
  54017 	if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum == 0 {
  54018 		x_out = 0
  54019 		for {
  54020 			if !(x_out < x_out_max) {
  54021 				break
  54022 			}
  54023 			J = **(**rescaler_t)(__ccgo_up(frow + uintptr(x_out)*4))
  54024 			v = libc.Int32FromUint64((uint64(J)*uint64((*WebPRescaler)(unsafe.Pointer(wrk)).Ffy_scale) + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54025 			if v > int32(255) {
  54026 				v2 = uint32(255)
  54027 			} else {
  54028 				v2 = uint32(libc.Uint8FromInt32(v))
  54029 			}
  54030 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54031 			goto _1
  54032 		_1:
  54033 			;
  54034 			x_out = x_out + 1
  54035 		}
  54036 	} else {
  54037 		B = uint32(libc.Uint64FromInt32(-(*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum) << libc.Int32FromInt32(WEBP_RESCALER_RFIX) / libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(wrk)).Fy_sub))
  54038 		A = uint32(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX) - uint64(B))
  54039 		x_out = 0
  54040 		for {
  54041 			if !(x_out < x_out_max) {
  54042 				break
  54043 			}
  54044 			I = uint64(A)*uint64(**(**rescaler_t)(__ccgo_up(frow + uintptr(x_out)*4))) + uint64(B)*uint64(**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)))
  54045 			J1 = uint32((I + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54046 			v1 = libc.Int32FromUint64((uint64(J1)*uint64((*WebPRescaler)(unsafe.Pointer(wrk)).Ffy_scale) + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54047 			if v1 > int32(255) {
  54048 				v2 = uint32(255)
  54049 			} else {
  54050 				v2 = uint32(libc.Uint8FromInt32(v1))
  54051 			}
  54052 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54053 			goto _3
  54054 		_3:
  54055 			;
  54056 			x_out = x_out + 1
  54057 		}
  54058 	}
  54059 }
  54060 
  54061 func WebPRescalerExportRowShrink_C(tls *libc.TLS, wrk uintptr) {
  54062 	var dst, frow, irow uintptr
  54063 	var frac, yscale uint32_t
  54064 	var v, v1, x_out, x_out_max int32
  54065 	var v2 uint32
  54066 	_, _, _, _, _, _, _, _, _, _ = dst, frac, frow, irow, v, v1, x_out, x_out_max, yscale, v2
  54067 	dst = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst
  54068 	irow = (*WebPRescaler)(unsafe.Pointer(wrk)).Firow
  54069 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  54070 	frow = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow
  54071 	yscale = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffy_scale * libc.Uint32FromInt32(-(*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum)
  54072 	if yscale != 0 {
  54073 		x_out = 0
  54074 		for {
  54075 			if !(x_out < x_out_max) {
  54076 				break
  54077 			}
  54078 			frac = uint32(uint64(**(**rescaler_t)(__ccgo_up(frow + uintptr(x_out)*4))) * uint64(yscale) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54079 			v = libc.Int32FromUint64((uint64(**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4))-frac)*uint64((*WebPRescaler)(unsafe.Pointer(wrk)).Ffxy_scale) + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54080 			if v > int32(255) {
  54081 				v2 = uint32(255)
  54082 			} else {
  54083 				v2 = uint32(libc.Uint8FromInt32(v))
  54084 			}
  54085 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54086 			**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)) = frac // new fractional start
  54087 			goto _1
  54088 		_1:
  54089 			;
  54090 			x_out = x_out + 1
  54091 		}
  54092 	} else {
  54093 		x_out = 0
  54094 		for {
  54095 			if !(x_out < x_out_max) {
  54096 				break
  54097 			}
  54098 			v1 = libc.Int32FromUint64((uint64(**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)))*uint64((*WebPRescaler)(unsafe.Pointer(wrk)).Ffxy_scale) + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54099 			if v1 > int32(255) {
  54100 				v2 = uint32(255)
  54101 			} else {
  54102 				v2 = uint32(libc.Uint8FromInt32(v1))
  54103 			}
  54104 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54105 			**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)) = uint32(0)
  54106 			goto _3
  54107 		_3:
  54108 			;
  54109 			x_out = x_out + 1
  54110 		}
  54111 	}
  54112 }
  54113 
  54114 //------------------------------------------------------------------------------
  54115 // Main entry calls
  54116 
  54117 func WebPRescalerImportRow(tls *libc.TLS, wrk uintptr, src uintptr) {
  54118 	if !((*WebPRescaler)(unsafe.Pointer(wrk)).Fx_expand != 0) {
  54119 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerImportRowShrink})))(tls, wrk, src)
  54120 	} else {
  54121 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerImportRowExpand})))(tls, wrk, src)
  54122 	}
  54123 }
  54124 
  54125 func WebPRescalerExportRow(tls *libc.TLS, wrk uintptr) {
  54126 	var i int32
  54127 	_ = i
  54128 	if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum <= 0 {
  54129 		if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_expand != 0 {
  54130 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerExportRowExpand})))(tls, wrk)
  54131 		} else {
  54132 			if (*WebPRescaler)(unsafe.Pointer(wrk)).Ffxy_scale != 0 {
  54133 				(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerExportRowShrink})))(tls, wrk)
  54134 			} else {
  54135 				i = 0
  54136 				for {
  54137 					if !(i < (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels*(*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width) {
  54138 						break
  54139 					}
  54140 					**(**uint8_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Fdst + uintptr(i))) = uint8(**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Firow + uintptr(i)*4)))
  54141 					**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Firow + uintptr(i)*4)) = uint32(0)
  54142 					goto _1
  54143 				_1:
  54144 					;
  54145 					i = i + 1
  54146 				}
  54147 			}
  54148 		}
  54149 		**(**int32)(__ccgo_up(wrk + 24)) += (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_add
  54150 		**(**uintptr)(__ccgo_up(wrk + 72)) += uintptr((*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_stride)
  54151 		(*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_y = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_y + 1
  54152 	}
  54153 }
  54154 
  54155 func WebPRescalerDspInit(tls *libc.TLS) {
  54156 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  54157 		goto _1
  54158 	}
  54159 	WebPRescalerDspInit_body(tls)
  54160 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  54161 	goto _2
  54162 _2:
  54163 	;
  54164 	goto _1
  54165 _1: /**/ //
  54166 }
  54167 
  54168 var WebPRescalerDspInit_body_last_cpuinfo_used = uintptr(0)
  54169 
  54170 func init() {
  54171 	p := unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used)
  54172 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used))
  54173 }
  54174 
  54175 func WebPRescalerDspInit_body(tls *libc.TLS) {
  54176 	WebPRescalerExportRowExpand = __ccgo_fp(WebPRescalerExportRowExpand_C)
  54177 	WebPRescalerExportRowShrink = __ccgo_fp(WebPRescalerExportRowShrink_C)
  54178 	WebPRescalerImportRowExpand = __ccgo_fp(WebPRescalerImportRowExpand_C)
  54179 	WebPRescalerImportRowShrink = __ccgo_fp(WebPRescalerImportRowShrink_C)
  54180 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  54181 	}
  54182 }
  54183 
  54184 func WebPRescalerDspInitMIPS32(tls *libc.TLS) {
  54185 }
  54186 
  54187 func WebPRescalerDspInitMIPSdspR2(tls *libc.TLS) {
  54188 }
  54189 
  54190 func WebPRescalerDspInitMSA(tls *libc.TLS) {
  54191 }
  54192 
  54193 func WebPRescalerDspInitNEON(tls *libc.TLS) {
  54194 }
  54195 
  54196 func WebPRescalerDspInitSSE2(tls *libc.TLS) {
  54197 }
  54198 
  54199 // Copyright 2010 Google Inc. All Rights Reserved.
  54200 //
  54201 // Use of this source code is governed by a BSD-style license
  54202 // that can be found in the COPYING file in the root of the source
  54203 // tree. An additional intellectual property rights grant can be found
  54204 // in the file PATENTS. All contributing project authors may
  54205 // be found in the AUTHORS file in the root of the source tree.
  54206 // -----------------------------------------------------------------------------
  54207 //
  54208 //  Common types + memory wrappers
  54209 //
  54210 // Author: Skal (pascal.massimino@gmail.com)
  54211 
  54212 //------------------------------------------------------------------------------
  54213 // SSIM / PSNR
  54214 
  54215 // C documentation
  54216 //
  54217 //	// hat-shaped filter. Sum of coefficients is equal to 16.
  54218 var kWeight = [7]uint32_t{
  54219 	0: uint32(1),
  54220 	1: uint32(2),
  54221 	2: uint32(3),
  54222 	3: uint32(4),
  54223 	4: uint32(3),
  54224 	5: uint32(2),
  54225 	6: uint32(1),
  54226 }
  54227 var kWeightSum = libc.Uint32FromInt32(libc.Int32FromInt32(16) * libc.Int32FromInt32(16)) // sum{kWeight}^2
  54228 
  54229 func SSIMCalculation(tls *libc.TLS, stats uintptr, N uint32_t) (r1 float64) {
  54230 	var C1, C2, C3, w2 uint32_t
  54231 	var den_S, fden, fnum, num_S, sxx, syy, xmxm, ymym uint64_t
  54232 	var r float64
  54233 	var sxy, xmym int64_t
  54234 	var v1 int64
  54235 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = C1, C2, C3, den_S, fden, fnum, num_S, r, sxx, sxy, syy, w2, xmxm, xmym, ymym, v1
  54236 	w2 = N * N
  54237 	C1 = uint32(20) * w2
  54238 	C2 = uint32(60) * w2
  54239 	C3 = libc.Uint32FromInt32(libc.Int32FromInt32(8)*libc.Int32FromInt32(8)) * w2 // 'dark' limit ~= 6
  54240 	xmxm = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm) * uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm)
  54241 	ymym = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fym) * uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fym)
  54242 	if xmxm+ymym >= uint64(C3) {
  54243 		xmym = libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm) * libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fym)
  54244 		sxy = libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fxym)*libc.Int64FromUint32(N) - xmym // can be negative
  54245 		sxx = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxxm)*uint64(N) - xmxm
  54246 		syy = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fyym)*uint64(N) - ymym
  54247 		if sxy < 0 {
  54248 			v1 = 0
  54249 		} else {
  54250 			v1 = sxy
  54251 		}
  54252 		// we descale by 8 to prevent overflow during the fnum/fden multiply.
  54253 		num_S = (uint64(2)*libc.Uint64FromInt64(v1) + uint64(C2)) >> int32(8)
  54254 		den_S = (sxx + syy + uint64(C2)) >> int32(8)
  54255 		fnum = libc.Uint64FromInt64(libc.Int64FromInt32(2)*xmym+libc.Int64FromUint32(C1)) * num_S
  54256 		fden = (xmxm + ymym + uint64(C1)) * den_S
  54257 		r = float64(fnum) / float64(fden)
  54258 		return r
  54259 	}
  54260 	return float64(1) // area is too dark to contribute meaningfully
  54261 }
  54262 
  54263 func VP8SSIMFromStats(tls *libc.TLS, stats uintptr) (r float64) {
  54264 	return SSIMCalculation(tls, stats, kWeightSum)
  54265 }
  54266 
  54267 func VP8SSIMFromStatsClipped(tls *libc.TLS, stats uintptr) (r float64) {
  54268 	return SSIMCalculation(tls, stats, (*VP8DistoStats)(unsafe.Pointer(stats)).Fw)
  54269 }
  54270 
  54271 func SSIMGetClipped_C(tls *libc.TLS, src1 uintptr, stride1 int32, src2 uintptr, stride2 int32, xo int32, yo int32, W int32, H int32) (r float64) {
  54272 	bp := tls.Alloc(32)
  54273 	defer tls.Free(32)
  54274 	var s1, s2, w uint32_t
  54275 	var x, xmax, xmin, y, ymax, ymin, v1, v2, v3, v4 int32
  54276 	var _ /* stats at bp+0 */ VP8DistoStats
  54277 	_, _, _, _, _, _, _, _, _, _, _, _, _ = s1, s2, w, x, xmax, xmin, y, ymax, ymin, v1, v2, v3, v4
  54278 	**(**VP8DistoStats)(__ccgo_up(bp)) = VP8DistoStats{}
  54279 	if yo-int32(VP8_SSIM_KERNEL) < 0 {
  54280 		v1 = 0
  54281 	} else {
  54282 		v1 = yo - int32(VP8_SSIM_KERNEL)
  54283 	}
  54284 	ymin = v1
  54285 	if yo+int32(VP8_SSIM_KERNEL) > H-int32(1) {
  54286 		v2 = H - int32(1)
  54287 	} else {
  54288 		v2 = yo + int32(VP8_SSIM_KERNEL)
  54289 	}
  54290 	ymax = v2
  54291 	if xo-int32(VP8_SSIM_KERNEL) < 0 {
  54292 		v3 = 0
  54293 	} else {
  54294 		v3 = xo - int32(VP8_SSIM_KERNEL)
  54295 	}
  54296 	xmin = v3
  54297 	if xo+int32(VP8_SSIM_KERNEL) > W-int32(1) {
  54298 		v4 = W - int32(1)
  54299 	} else {
  54300 		v4 = xo + int32(VP8_SSIM_KERNEL)
  54301 	}
  54302 	xmax = v4
  54303 	src1 = src1 + uintptr(ymin*stride1)
  54304 	src2 = src2 + uintptr(ymin*stride2)
  54305 	y = ymin
  54306 	for {
  54307 		if !(y <= ymax) {
  54308 			break
  54309 		}
  54310 		x = xmin
  54311 		for {
  54312 			if !(x <= xmax) {
  54313 				break
  54314 			}
  54315 			w = kWeight[int32(VP8_SSIM_KERNEL)+x-xo] * kWeight[int32(VP8_SSIM_KERNEL)+y-yo]
  54316 			s1 = uint32(**(**uint8_t)(__ccgo_up(src1 + uintptr(x))))
  54317 			s2 = uint32(**(**uint8_t)(__ccgo_up(src2 + uintptr(x))))
  54318 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fw += w
  54319 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxm += w * s1
  54320 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fym += w * s2
  54321 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxxm += w * s1 * s1
  54322 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxym += w * s1 * s2
  54323 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fyym += w * s2 * s2
  54324 			goto _6
  54325 		_6:
  54326 			;
  54327 			x = x + 1
  54328 		}
  54329 		goto _5
  54330 	_5:
  54331 		;
  54332 		y = y + 1
  54333 		src1 = src1 + uintptr(stride1)
  54334 		src2 = src2 + uintptr(stride2)
  54335 	}
  54336 	return VP8SSIMFromStatsClipped(tls, bp)
  54337 }
  54338 
  54339 func SSIMGet_C(tls *libc.TLS, src1 uintptr, stride1 int32, src2 uintptr, stride2 int32) (r float64) {
  54340 	bp := tls.Alloc(32)
  54341 	defer tls.Free(32)
  54342 	var s1, s2, w uint32_t
  54343 	var x, y int32
  54344 	var _ /* stats at bp+0 */ VP8DistoStats
  54345 	_, _, _, _, _ = s1, s2, w, x, y
  54346 	**(**VP8DistoStats)(__ccgo_up(bp)) = VP8DistoStats{}
  54347 	y = 0
  54348 	for {
  54349 		if !(y <= libc.Int32FromInt32(2)*libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  54350 			break
  54351 		}
  54352 		x = 0
  54353 		for {
  54354 			if !(x <= libc.Int32FromInt32(2)*libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  54355 				break
  54356 			}
  54357 			w = kWeight[x] * kWeight[y]
  54358 			s1 = uint32(**(**uint8_t)(__ccgo_up(src1 + uintptr(x))))
  54359 			s2 = uint32(**(**uint8_t)(__ccgo_up(src2 + uintptr(x))))
  54360 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxm += w * s1
  54361 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fym += w * s2
  54362 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxxm += w * s1 * s1
  54363 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxym += w * s1 * s2
  54364 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fyym += w * s2 * s2
  54365 			goto _2
  54366 		_2:
  54367 			;
  54368 			x = x + 1
  54369 		}
  54370 		goto _1
  54371 	_1:
  54372 		;
  54373 		y = y + 1
  54374 		src1 = src1 + uintptr(stride1)
  54375 		src2 = src2 + uintptr(stride2)
  54376 	}
  54377 	return VP8SSIMFromStats(tls, bp)
  54378 }
  54379 
  54380 //------------------------------------------------------------------------------
  54381 
  54382 func AccumulateSSE_C(tls *libc.TLS, src1 uintptr, src2 uintptr, len1 int32) (r uint32_t) {
  54383 	var diff int32_t
  54384 	var i int32
  54385 	var sse2 uint32_t
  54386 	_, _, _ = diff, i, sse2
  54387 	sse2 = uint32(0)
  54388 	// to ensure that accumulation fits within uint32_t
  54389 	i = 0
  54390 	for {
  54391 		if !(i < len1) {
  54392 			break
  54393 		}
  54394 		diff = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src1 + uintptr(i)))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src2 + uintptr(i))))
  54395 		sse2 = sse2 + libc.Uint32FromInt32(diff*diff)
  54396 		goto _1
  54397 	_1:
  54398 		;
  54399 		i = i + 1
  54400 	}
  54401 	return sse2
  54402 }
  54403 
  54404 func VP8SSIMDspInit(tls *libc.TLS) {
  54405 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  54406 		goto _1
  54407 	}
  54408 	VP8SSIMDspInit_body(tls)
  54409 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  54410 	goto _2
  54411 _2:
  54412 	;
  54413 	goto _1
  54414 _1: /**/ //
  54415 }
  54416 
  54417 var VP8SSIMDspInit_body_last_cpuinfo_used = uintptr(0)
  54418 
  54419 func init() {
  54420 	p := unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used)
  54421 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used))
  54422 }
  54423 
  54424 func VP8SSIMDspInit_body(tls *libc.TLS) {
  54425 	VP8SSIMGetClipped = __ccgo_fp(SSIMGetClipped_C)
  54426 	VP8SSIMGet = __ccgo_fp(SSIMGet_C)
  54427 	VP8AccumulateSSE = __ccgo_fp(AccumulateSSE_C)
  54428 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  54429 	}
  54430 }
  54431 
  54432 func VP8SSIMDspInitSSE2(tls *libc.TLS) {
  54433 }
  54434 
  54435 // Given samples laid out in a square as:
  54436 //  [a b]
  54437 //  [c d]
  54438 // we interpolate u/v as:
  54439 //  ([9*a + 3*b + 3*c +   d    3*a + 9*b + 3*c +   d] + [8 8]) / 16
  54440 //  ([3*a +   b + 9*c + 3*d      a + 3*b + 3*c + 9*d]   [8 8]) / 16
  54441 
  54442 // We process u and v together stashed into 32bit (16bit each).
  54443 
  54444 // C documentation
  54445 //
  54446 //	// All variants implemented.
  54447 func UpsampleRgbaLinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  54448 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  54449 	var last_pixel_pair, x, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  54450 	var v1, v5 uintptr
  54451 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, diag_03, diag_12, l_uv, last_pixel_pair, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v6, v8
  54452 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  54453 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  54454 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  54455 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  54456 	v1 = top_dst
  54457 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  54458 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  54459 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  54460 	v5 = v1
  54461 	v8 = v2 * int32(19077) >> int32(8)
  54462 	goto _9
  54463 _9:
  54464 	v10 = v4 * int32(26149) >> int32(8)
  54465 	goto _11
  54466 _11:
  54467 	v12 = v8 + v10 - int32(14234)
  54468 	if v12 & ^int32(YUV_MASK2) == 0 {
  54469 		v15 = v12 >> int32(YUV_FIX2)
  54470 	} else {
  54471 		if v12 < 0 {
  54472 			v16 = 0
  54473 		} else {
  54474 			v16 = int32(255)
  54475 		}
  54476 		v15 = v16
  54477 	}
  54478 	v13 = v15
  54479 	goto _14
  54480 _14:
  54481 	v6 = v13
  54482 	goto _7
  54483 _7:
  54484 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54485 	v19 = v2 * int32(19077) >> int32(8)
  54486 	goto _20
  54487 _20:
  54488 	v21 = v3 * int32(6419) >> int32(8)
  54489 	goto _22
  54490 _22:
  54491 	v23 = v4 * int32(13320) >> int32(8)
  54492 	goto _24
  54493 _24:
  54494 	v25 = v19 - v21 - v23 + int32(8708)
  54495 	if v25 & ^int32(YUV_MASK2) == 0 {
  54496 		v28 = v25 >> int32(YUV_FIX2)
  54497 	} else {
  54498 		if v25 < 0 {
  54499 			v29 = 0
  54500 		} else {
  54501 			v29 = int32(255)
  54502 		}
  54503 		v28 = v29
  54504 	}
  54505 	v26 = v28
  54506 	goto _27
  54507 _27:
  54508 	v17 = v26
  54509 	goto _18
  54510 _18:
  54511 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54512 	v32 = v2 * int32(19077) >> int32(8)
  54513 	goto _33
  54514 _33:
  54515 	v34 = v3 * int32(33050) >> int32(8)
  54516 	goto _35
  54517 _35:
  54518 	v36 = v32 + v34 - int32(17685)
  54519 	if v36 & ^int32(YUV_MASK2) == 0 {
  54520 		v39 = v36 >> int32(YUV_FIX2)
  54521 	} else {
  54522 		if v36 < 0 {
  54523 			v40 = 0
  54524 		} else {
  54525 			v40 = int32(255)
  54526 		}
  54527 		v39 = v40
  54528 	}
  54529 	v37 = v39
  54530 	goto _38
  54531 _38:
  54532 	v30 = v37
  54533 	goto _31
  54534 _31:
  54535 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54536 	**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54537 	if bottom_y != libc.UintptrFromInt32(0) {
  54538 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  54539 		v1 = bottom_dst
  54540 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  54541 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  54542 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  54543 		v5 = v1
  54544 		v8 = v2 * int32(19077) >> int32(8)
  54545 		goto _49
  54546 	_49:
  54547 		v10 = v4 * int32(26149) >> int32(8)
  54548 		goto _51
  54549 	_51:
  54550 		v12 = v8 + v10 - int32(14234)
  54551 		if v12 & ^int32(YUV_MASK2) == 0 {
  54552 			v15 = v12 >> int32(YUV_FIX2)
  54553 		} else {
  54554 			if v12 < 0 {
  54555 				v16 = 0
  54556 			} else {
  54557 				v16 = int32(255)
  54558 			}
  54559 			v15 = v16
  54560 		}
  54561 		v13 = v15
  54562 		goto _54
  54563 	_54:
  54564 		v6 = v13
  54565 		goto _47
  54566 	_47:
  54567 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54568 		v19 = v2 * int32(19077) >> int32(8)
  54569 		goto _60
  54570 	_60:
  54571 		v21 = v3 * int32(6419) >> int32(8)
  54572 		goto _62
  54573 	_62:
  54574 		v23 = v4 * int32(13320) >> int32(8)
  54575 		goto _64
  54576 	_64:
  54577 		v25 = v19 - v21 - v23 + int32(8708)
  54578 		if v25 & ^int32(YUV_MASK2) == 0 {
  54579 			v28 = v25 >> int32(YUV_FIX2)
  54580 		} else {
  54581 			if v25 < 0 {
  54582 				v29 = 0
  54583 			} else {
  54584 				v29 = int32(255)
  54585 			}
  54586 			v28 = v29
  54587 		}
  54588 		v26 = v28
  54589 		goto _67
  54590 	_67:
  54591 		v17 = v26
  54592 		goto _58
  54593 	_58:
  54594 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54595 		v32 = v2 * int32(19077) >> int32(8)
  54596 		goto _73
  54597 	_73:
  54598 		v34 = v3 * int32(33050) >> int32(8)
  54599 		goto _75
  54600 	_75:
  54601 		v36 = v32 + v34 - int32(17685)
  54602 		if v36 & ^int32(YUV_MASK2) == 0 {
  54603 			v39 = v36 >> int32(YUV_FIX2)
  54604 		} else {
  54605 			if v36 < 0 {
  54606 				v40 = 0
  54607 			} else {
  54608 				v40 = int32(255)
  54609 			}
  54610 			v39 = v40
  54611 		}
  54612 		v37 = v39
  54613 		goto _78
  54614 	_78:
  54615 		v30 = v37
  54616 		goto _71
  54617 	_71:
  54618 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54619 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54620 	}
  54621 	x = int32(1)
  54622 	for {
  54623 		if !(x <= last_pixel_pair) {
  54624 			break
  54625 		}
  54626 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  54627 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  54628 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  54629 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  54630 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  54631 		uv02 = (diag_12 + tl_uv) >> int32(1)
  54632 		uv1 = (diag_03 + t_uv) >> int32(1)
  54633 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  54634 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  54635 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  54636 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  54637 		v5 = v1
  54638 		v8 = v2 * int32(19077) >> int32(8)
  54639 		goto _90
  54640 	_90:
  54641 		v10 = v4 * int32(26149) >> int32(8)
  54642 		goto _92
  54643 	_92:
  54644 		v12 = v8 + v10 - int32(14234)
  54645 		if v12 & ^int32(YUV_MASK2) == 0 {
  54646 			v15 = v12 >> int32(YUV_FIX2)
  54647 		} else {
  54648 			if v12 < 0 {
  54649 				v16 = 0
  54650 			} else {
  54651 				v16 = int32(255)
  54652 			}
  54653 			v15 = v16
  54654 		}
  54655 		v13 = v15
  54656 		goto _95
  54657 	_95:
  54658 		v6 = v13
  54659 		goto _88
  54660 	_88:
  54661 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54662 		v19 = v2 * int32(19077) >> int32(8)
  54663 		goto _101
  54664 	_101:
  54665 		v21 = v3 * int32(6419) >> int32(8)
  54666 		goto _103
  54667 	_103:
  54668 		v23 = v4 * int32(13320) >> int32(8)
  54669 		goto _105
  54670 	_105:
  54671 		v25 = v19 - v21 - v23 + int32(8708)
  54672 		if v25 & ^int32(YUV_MASK2) == 0 {
  54673 			v28 = v25 >> int32(YUV_FIX2)
  54674 		} else {
  54675 			if v25 < 0 {
  54676 				v29 = 0
  54677 			} else {
  54678 				v29 = int32(255)
  54679 			}
  54680 			v28 = v29
  54681 		}
  54682 		v26 = v28
  54683 		goto _108
  54684 	_108:
  54685 		v17 = v26
  54686 		goto _99
  54687 	_99:
  54688 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54689 		v32 = v2 * int32(19077) >> int32(8)
  54690 		goto _114
  54691 	_114:
  54692 		v34 = v3 * int32(33050) >> int32(8)
  54693 		goto _116
  54694 	_116:
  54695 		v36 = v32 + v34 - int32(17685)
  54696 		if v36 & ^int32(YUV_MASK2) == 0 {
  54697 			v39 = v36 >> int32(YUV_FIX2)
  54698 		} else {
  54699 			if v36 < 0 {
  54700 				v40 = 0
  54701 			} else {
  54702 				v40 = int32(255)
  54703 			}
  54704 			v39 = v40
  54705 		}
  54706 		v37 = v39
  54707 		goto _119
  54708 	_119:
  54709 		v30 = v37
  54710 		goto _112
  54711 	_112:
  54712 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54713 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54714 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  54715 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  54716 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  54717 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  54718 		v5 = v1
  54719 		v8 = v2 * int32(19077) >> int32(8)
  54720 		goto _130
  54721 	_130:
  54722 		v10 = v4 * int32(26149) >> int32(8)
  54723 		goto _132
  54724 	_132:
  54725 		v12 = v8 + v10 - int32(14234)
  54726 		if v12 & ^int32(YUV_MASK2) == 0 {
  54727 			v15 = v12 >> int32(YUV_FIX2)
  54728 		} else {
  54729 			if v12 < 0 {
  54730 				v16 = 0
  54731 			} else {
  54732 				v16 = int32(255)
  54733 			}
  54734 			v15 = v16
  54735 		}
  54736 		v13 = v15
  54737 		goto _135
  54738 	_135:
  54739 		v6 = v13
  54740 		goto _128
  54741 	_128:
  54742 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54743 		v19 = v2 * int32(19077) >> int32(8)
  54744 		goto _141
  54745 	_141:
  54746 		v21 = v3 * int32(6419) >> int32(8)
  54747 		goto _143
  54748 	_143:
  54749 		v23 = v4 * int32(13320) >> int32(8)
  54750 		goto _145
  54751 	_145:
  54752 		v25 = v19 - v21 - v23 + int32(8708)
  54753 		if v25 & ^int32(YUV_MASK2) == 0 {
  54754 			v28 = v25 >> int32(YUV_FIX2)
  54755 		} else {
  54756 			if v25 < 0 {
  54757 				v29 = 0
  54758 			} else {
  54759 				v29 = int32(255)
  54760 			}
  54761 			v28 = v29
  54762 		}
  54763 		v26 = v28
  54764 		goto _148
  54765 	_148:
  54766 		v17 = v26
  54767 		goto _139
  54768 	_139:
  54769 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54770 		v32 = v2 * int32(19077) >> int32(8)
  54771 		goto _154
  54772 	_154:
  54773 		v34 = v3 * int32(33050) >> int32(8)
  54774 		goto _156
  54775 	_156:
  54776 		v36 = v32 + v34 - int32(17685)
  54777 		if v36 & ^int32(YUV_MASK2) == 0 {
  54778 			v39 = v36 >> int32(YUV_FIX2)
  54779 		} else {
  54780 			if v36 < 0 {
  54781 				v40 = 0
  54782 			} else {
  54783 				v40 = int32(255)
  54784 			}
  54785 			v39 = v40
  54786 		}
  54787 		v37 = v39
  54788 		goto _159
  54789 	_159:
  54790 		v30 = v37
  54791 		goto _152
  54792 	_152:
  54793 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54794 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54795 		if bottom_y != libc.UintptrFromInt32(0) {
  54796 			uv03 = (diag_03 + l_uv) >> int32(1)
  54797 			uv11 = (diag_12 + uv) >> int32(1)
  54798 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  54799 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  54800 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  54801 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  54802 			v5 = v1
  54803 			v8 = v2 * int32(19077) >> int32(8)
  54804 			goto _170
  54805 		_170:
  54806 			v10 = v4 * int32(26149) >> int32(8)
  54807 			goto _172
  54808 		_172:
  54809 			v12 = v8 + v10 - int32(14234)
  54810 			if v12 & ^int32(YUV_MASK2) == 0 {
  54811 				v15 = v12 >> int32(YUV_FIX2)
  54812 			} else {
  54813 				if v12 < 0 {
  54814 					v16 = 0
  54815 				} else {
  54816 					v16 = int32(255)
  54817 				}
  54818 				v15 = v16
  54819 			}
  54820 			v13 = v15
  54821 			goto _175
  54822 		_175:
  54823 			v6 = v13
  54824 			goto _168
  54825 		_168:
  54826 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54827 			v19 = v2 * int32(19077) >> int32(8)
  54828 			goto _181
  54829 		_181:
  54830 			v21 = v3 * int32(6419) >> int32(8)
  54831 			goto _183
  54832 		_183:
  54833 			v23 = v4 * int32(13320) >> int32(8)
  54834 			goto _185
  54835 		_185:
  54836 			v25 = v19 - v21 - v23 + int32(8708)
  54837 			if v25 & ^int32(YUV_MASK2) == 0 {
  54838 				v28 = v25 >> int32(YUV_FIX2)
  54839 			} else {
  54840 				if v25 < 0 {
  54841 					v29 = 0
  54842 				} else {
  54843 					v29 = int32(255)
  54844 				}
  54845 				v28 = v29
  54846 			}
  54847 			v26 = v28
  54848 			goto _188
  54849 		_188:
  54850 			v17 = v26
  54851 			goto _179
  54852 		_179:
  54853 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54854 			v32 = v2 * int32(19077) >> int32(8)
  54855 			goto _194
  54856 		_194:
  54857 			v34 = v3 * int32(33050) >> int32(8)
  54858 			goto _196
  54859 		_196:
  54860 			v36 = v32 + v34 - int32(17685)
  54861 			if v36 & ^int32(YUV_MASK2) == 0 {
  54862 				v39 = v36 >> int32(YUV_FIX2)
  54863 			} else {
  54864 				if v36 < 0 {
  54865 					v40 = 0
  54866 				} else {
  54867 					v40 = int32(255)
  54868 				}
  54869 				v39 = v40
  54870 			}
  54871 			v37 = v39
  54872 			goto _199
  54873 		_199:
  54874 			v30 = v37
  54875 			goto _192
  54876 		_192:
  54877 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54878 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54879 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  54880 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  54881 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  54882 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  54883 			v5 = v1
  54884 			v8 = v2 * int32(19077) >> int32(8)
  54885 			goto _210
  54886 		_210:
  54887 			v10 = v4 * int32(26149) >> int32(8)
  54888 			goto _212
  54889 		_212:
  54890 			v12 = v8 + v10 - int32(14234)
  54891 			if v12 & ^int32(YUV_MASK2) == 0 {
  54892 				v15 = v12 >> int32(YUV_FIX2)
  54893 			} else {
  54894 				if v12 < 0 {
  54895 					v16 = 0
  54896 				} else {
  54897 					v16 = int32(255)
  54898 				}
  54899 				v15 = v16
  54900 			}
  54901 			v13 = v15
  54902 			goto _215
  54903 		_215:
  54904 			v6 = v13
  54905 			goto _208
  54906 		_208:
  54907 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54908 			v19 = v2 * int32(19077) >> int32(8)
  54909 			goto _221
  54910 		_221:
  54911 			v21 = v3 * int32(6419) >> int32(8)
  54912 			goto _223
  54913 		_223:
  54914 			v23 = v4 * int32(13320) >> int32(8)
  54915 			goto _225
  54916 		_225:
  54917 			v25 = v19 - v21 - v23 + int32(8708)
  54918 			if v25 & ^int32(YUV_MASK2) == 0 {
  54919 				v28 = v25 >> int32(YUV_FIX2)
  54920 			} else {
  54921 				if v25 < 0 {
  54922 					v29 = 0
  54923 				} else {
  54924 					v29 = int32(255)
  54925 				}
  54926 				v28 = v29
  54927 			}
  54928 			v26 = v28
  54929 			goto _228
  54930 		_228:
  54931 			v17 = v26
  54932 			goto _219
  54933 		_219:
  54934 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54935 			v32 = v2 * int32(19077) >> int32(8)
  54936 			goto _234
  54937 		_234:
  54938 			v34 = v3 * int32(33050) >> int32(8)
  54939 			goto _236
  54940 		_236:
  54941 			v36 = v32 + v34 - int32(17685)
  54942 			if v36 & ^int32(YUV_MASK2) == 0 {
  54943 				v39 = v36 >> int32(YUV_FIX2)
  54944 			} else {
  54945 				if v36 < 0 {
  54946 					v40 = 0
  54947 				} else {
  54948 					v40 = int32(255)
  54949 				}
  54950 				v39 = v40
  54951 			}
  54952 			v37 = v39
  54953 			goto _239
  54954 		_239:
  54955 			v30 = v37
  54956 			goto _232
  54957 		_232:
  54958 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54959 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54960 		}
  54961 		tl_uv = t_uv
  54962 		l_uv = uv
  54963 		goto _81
  54964 	_81:
  54965 		;
  54966 		x = x + 1
  54967 	}
  54968 	if !(len1&libc.Int32FromInt32(1) != 0) {
  54969 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  54970 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  54971 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  54972 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  54973 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  54974 		v5 = v1
  54975 		v8 = v2 * int32(19077) >> int32(8)
  54976 		goto _250
  54977 	_250:
  54978 		v10 = v4 * int32(26149) >> int32(8)
  54979 		goto _252
  54980 	_252:
  54981 		v12 = v8 + v10 - int32(14234)
  54982 		if v12 & ^int32(YUV_MASK2) == 0 {
  54983 			v15 = v12 >> int32(YUV_FIX2)
  54984 		} else {
  54985 			if v12 < 0 {
  54986 				v16 = 0
  54987 			} else {
  54988 				v16 = int32(255)
  54989 			}
  54990 			v15 = v16
  54991 		}
  54992 		v13 = v15
  54993 		goto _255
  54994 	_255:
  54995 		v6 = v13
  54996 		goto _248
  54997 	_248:
  54998 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54999 		v19 = v2 * int32(19077) >> int32(8)
  55000 		goto _261
  55001 	_261:
  55002 		v21 = v3 * int32(6419) >> int32(8)
  55003 		goto _263
  55004 	_263:
  55005 		v23 = v4 * int32(13320) >> int32(8)
  55006 		goto _265
  55007 	_265:
  55008 		v25 = v19 - v21 - v23 + int32(8708)
  55009 		if v25 & ^int32(YUV_MASK2) == 0 {
  55010 			v28 = v25 >> int32(YUV_FIX2)
  55011 		} else {
  55012 			if v25 < 0 {
  55013 				v29 = 0
  55014 			} else {
  55015 				v29 = int32(255)
  55016 			}
  55017 			v28 = v29
  55018 		}
  55019 		v26 = v28
  55020 		goto _268
  55021 	_268:
  55022 		v17 = v26
  55023 		goto _259
  55024 	_259:
  55025 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55026 		v32 = v2 * int32(19077) >> int32(8)
  55027 		goto _274
  55028 	_274:
  55029 		v34 = v3 * int32(33050) >> int32(8)
  55030 		goto _276
  55031 	_276:
  55032 		v36 = v32 + v34 - int32(17685)
  55033 		if v36 & ^int32(YUV_MASK2) == 0 {
  55034 			v39 = v36 >> int32(YUV_FIX2)
  55035 		} else {
  55036 			if v36 < 0 {
  55037 				v40 = 0
  55038 			} else {
  55039 				v40 = int32(255)
  55040 			}
  55041 			v39 = v40
  55042 		}
  55043 		v37 = v39
  55044 		goto _279
  55045 	_279:
  55046 		v30 = v37
  55047 		goto _272
  55048 	_272:
  55049 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55050 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55051 		if bottom_y != libc.UintptrFromInt32(0) {
  55052 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55053 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  55054 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  55055 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  55056 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  55057 			v5 = v1
  55058 			v8 = v2 * int32(19077) >> int32(8)
  55059 			goto _290
  55060 		_290:
  55061 			v10 = v4 * int32(26149) >> int32(8)
  55062 			goto _292
  55063 		_292:
  55064 			v12 = v8 + v10 - int32(14234)
  55065 			if v12 & ^int32(YUV_MASK2) == 0 {
  55066 				v15 = v12 >> int32(YUV_FIX2)
  55067 			} else {
  55068 				if v12 < 0 {
  55069 					v16 = 0
  55070 				} else {
  55071 					v16 = int32(255)
  55072 				}
  55073 				v15 = v16
  55074 			}
  55075 			v13 = v15
  55076 			goto _295
  55077 		_295:
  55078 			v6 = v13
  55079 			goto _288
  55080 		_288:
  55081 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55082 			v19 = v2 * int32(19077) >> int32(8)
  55083 			goto _301
  55084 		_301:
  55085 			v21 = v3 * int32(6419) >> int32(8)
  55086 			goto _303
  55087 		_303:
  55088 			v23 = v4 * int32(13320) >> int32(8)
  55089 			goto _305
  55090 		_305:
  55091 			v25 = v19 - v21 - v23 + int32(8708)
  55092 			if v25 & ^int32(YUV_MASK2) == 0 {
  55093 				v28 = v25 >> int32(YUV_FIX2)
  55094 			} else {
  55095 				if v25 < 0 {
  55096 					v29 = 0
  55097 				} else {
  55098 					v29 = int32(255)
  55099 				}
  55100 				v28 = v29
  55101 			}
  55102 			v26 = v28
  55103 			goto _308
  55104 		_308:
  55105 			v17 = v26
  55106 			goto _299
  55107 		_299:
  55108 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55109 			v32 = v2 * int32(19077) >> int32(8)
  55110 			goto _314
  55111 		_314:
  55112 			v34 = v3 * int32(33050) >> int32(8)
  55113 			goto _316
  55114 		_316:
  55115 			v36 = v32 + v34 - int32(17685)
  55116 			if v36 & ^int32(YUV_MASK2) == 0 {
  55117 				v39 = v36 >> int32(YUV_FIX2)
  55118 			} else {
  55119 				if v36 < 0 {
  55120 					v40 = 0
  55121 				} else {
  55122 					v40 = int32(255)
  55123 				}
  55124 				v39 = v40
  55125 			}
  55126 			v37 = v39
  55127 			goto _319
  55128 		_319:
  55129 			v30 = v37
  55130 			goto _312
  55131 		_312:
  55132 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55133 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55134 		}
  55135 	}
  55136 }
  55137 
  55138 func UpsampleBgraLinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  55139 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  55140 	var last_pixel_pair, x, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  55141 	var v1, v5 uintptr
  55142 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, diag_03, diag_12, l_uv, last_pixel_pair, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v6, v8
  55143 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  55144 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  55145 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  55146 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55147 	v1 = top_dst
  55148 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  55149 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  55150 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  55151 	v5 = v1
  55152 	v8 = v2 * int32(19077) >> int32(8)
  55153 	goto _9
  55154 _9:
  55155 	v10 = v3 * int32(33050) >> int32(8)
  55156 	goto _11
  55157 _11:
  55158 	v12 = v8 + v10 - int32(17685)
  55159 	if v12 & ^int32(YUV_MASK2) == 0 {
  55160 		v15 = v12 >> int32(YUV_FIX2)
  55161 	} else {
  55162 		if v12 < 0 {
  55163 			v16 = 0
  55164 		} else {
  55165 			v16 = int32(255)
  55166 		}
  55167 		v15 = v16
  55168 	}
  55169 	v13 = v15
  55170 	goto _14
  55171 _14:
  55172 	v6 = v13
  55173 	goto _7
  55174 _7:
  55175 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55176 	v19 = v2 * int32(19077) >> int32(8)
  55177 	goto _20
  55178 _20:
  55179 	v21 = v3 * int32(6419) >> int32(8)
  55180 	goto _22
  55181 _22:
  55182 	v23 = v4 * int32(13320) >> int32(8)
  55183 	goto _24
  55184 _24:
  55185 	v25 = v19 - v21 - v23 + int32(8708)
  55186 	if v25 & ^int32(YUV_MASK2) == 0 {
  55187 		v28 = v25 >> int32(YUV_FIX2)
  55188 	} else {
  55189 		if v25 < 0 {
  55190 			v29 = 0
  55191 		} else {
  55192 			v29 = int32(255)
  55193 		}
  55194 		v28 = v29
  55195 	}
  55196 	v26 = v28
  55197 	goto _27
  55198 _27:
  55199 	v17 = v26
  55200 	goto _18
  55201 _18:
  55202 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55203 	v32 = v2 * int32(19077) >> int32(8)
  55204 	goto _33
  55205 _33:
  55206 	v34 = v4 * int32(26149) >> int32(8)
  55207 	goto _35
  55208 _35:
  55209 	v36 = v32 + v34 - int32(14234)
  55210 	if v36 & ^int32(YUV_MASK2) == 0 {
  55211 		v39 = v36 >> int32(YUV_FIX2)
  55212 	} else {
  55213 		if v36 < 0 {
  55214 			v40 = 0
  55215 		} else {
  55216 			v40 = int32(255)
  55217 		}
  55218 		v39 = v40
  55219 	}
  55220 	v37 = v39
  55221 	goto _38
  55222 _38:
  55223 	v30 = v37
  55224 	goto _31
  55225 _31:
  55226 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55227 	**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55228 	if bottom_y != libc.UintptrFromInt32(0) {
  55229 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55230 		v1 = bottom_dst
  55231 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  55232 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  55233 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  55234 		v5 = v1
  55235 		v8 = v2 * int32(19077) >> int32(8)
  55236 		goto _49
  55237 	_49:
  55238 		v10 = v3 * int32(33050) >> int32(8)
  55239 		goto _51
  55240 	_51:
  55241 		v12 = v8 + v10 - int32(17685)
  55242 		if v12 & ^int32(YUV_MASK2) == 0 {
  55243 			v15 = v12 >> int32(YUV_FIX2)
  55244 		} else {
  55245 			if v12 < 0 {
  55246 				v16 = 0
  55247 			} else {
  55248 				v16 = int32(255)
  55249 			}
  55250 			v15 = v16
  55251 		}
  55252 		v13 = v15
  55253 		goto _54
  55254 	_54:
  55255 		v6 = v13
  55256 		goto _47
  55257 	_47:
  55258 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55259 		v19 = v2 * int32(19077) >> int32(8)
  55260 		goto _60
  55261 	_60:
  55262 		v21 = v3 * int32(6419) >> int32(8)
  55263 		goto _62
  55264 	_62:
  55265 		v23 = v4 * int32(13320) >> int32(8)
  55266 		goto _64
  55267 	_64:
  55268 		v25 = v19 - v21 - v23 + int32(8708)
  55269 		if v25 & ^int32(YUV_MASK2) == 0 {
  55270 			v28 = v25 >> int32(YUV_FIX2)
  55271 		} else {
  55272 			if v25 < 0 {
  55273 				v29 = 0
  55274 			} else {
  55275 				v29 = int32(255)
  55276 			}
  55277 			v28 = v29
  55278 		}
  55279 		v26 = v28
  55280 		goto _67
  55281 	_67:
  55282 		v17 = v26
  55283 		goto _58
  55284 	_58:
  55285 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55286 		v32 = v2 * int32(19077) >> int32(8)
  55287 		goto _73
  55288 	_73:
  55289 		v34 = v4 * int32(26149) >> int32(8)
  55290 		goto _75
  55291 	_75:
  55292 		v36 = v32 + v34 - int32(14234)
  55293 		if v36 & ^int32(YUV_MASK2) == 0 {
  55294 			v39 = v36 >> int32(YUV_FIX2)
  55295 		} else {
  55296 			if v36 < 0 {
  55297 				v40 = 0
  55298 			} else {
  55299 				v40 = int32(255)
  55300 			}
  55301 			v39 = v40
  55302 		}
  55303 		v37 = v39
  55304 		goto _78
  55305 	_78:
  55306 		v30 = v37
  55307 		goto _71
  55308 	_71:
  55309 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55310 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55311 	}
  55312 	x = int32(1)
  55313 	for {
  55314 		if !(x <= last_pixel_pair) {
  55315 			break
  55316 		}
  55317 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  55318 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  55319 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  55320 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  55321 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  55322 		uv02 = (diag_12 + tl_uv) >> int32(1)
  55323 		uv1 = (diag_03 + t_uv) >> int32(1)
  55324 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  55325 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  55326 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  55327 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  55328 		v5 = v1
  55329 		v8 = v2 * int32(19077) >> int32(8)
  55330 		goto _90
  55331 	_90:
  55332 		v10 = v3 * int32(33050) >> int32(8)
  55333 		goto _92
  55334 	_92:
  55335 		v12 = v8 + v10 - int32(17685)
  55336 		if v12 & ^int32(YUV_MASK2) == 0 {
  55337 			v15 = v12 >> int32(YUV_FIX2)
  55338 		} else {
  55339 			if v12 < 0 {
  55340 				v16 = 0
  55341 			} else {
  55342 				v16 = int32(255)
  55343 			}
  55344 			v15 = v16
  55345 		}
  55346 		v13 = v15
  55347 		goto _95
  55348 	_95:
  55349 		v6 = v13
  55350 		goto _88
  55351 	_88:
  55352 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55353 		v19 = v2 * int32(19077) >> int32(8)
  55354 		goto _101
  55355 	_101:
  55356 		v21 = v3 * int32(6419) >> int32(8)
  55357 		goto _103
  55358 	_103:
  55359 		v23 = v4 * int32(13320) >> int32(8)
  55360 		goto _105
  55361 	_105:
  55362 		v25 = v19 - v21 - v23 + int32(8708)
  55363 		if v25 & ^int32(YUV_MASK2) == 0 {
  55364 			v28 = v25 >> int32(YUV_FIX2)
  55365 		} else {
  55366 			if v25 < 0 {
  55367 				v29 = 0
  55368 			} else {
  55369 				v29 = int32(255)
  55370 			}
  55371 			v28 = v29
  55372 		}
  55373 		v26 = v28
  55374 		goto _108
  55375 	_108:
  55376 		v17 = v26
  55377 		goto _99
  55378 	_99:
  55379 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55380 		v32 = v2 * int32(19077) >> int32(8)
  55381 		goto _114
  55382 	_114:
  55383 		v34 = v4 * int32(26149) >> int32(8)
  55384 		goto _116
  55385 	_116:
  55386 		v36 = v32 + v34 - int32(14234)
  55387 		if v36 & ^int32(YUV_MASK2) == 0 {
  55388 			v39 = v36 >> int32(YUV_FIX2)
  55389 		} else {
  55390 			if v36 < 0 {
  55391 				v40 = 0
  55392 			} else {
  55393 				v40 = int32(255)
  55394 			}
  55395 			v39 = v40
  55396 		}
  55397 		v37 = v39
  55398 		goto _119
  55399 	_119:
  55400 		v30 = v37
  55401 		goto _112
  55402 	_112:
  55403 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55404 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55405 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  55406 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  55407 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  55408 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  55409 		v5 = v1
  55410 		v8 = v2 * int32(19077) >> int32(8)
  55411 		goto _130
  55412 	_130:
  55413 		v10 = v3 * int32(33050) >> int32(8)
  55414 		goto _132
  55415 	_132:
  55416 		v12 = v8 + v10 - int32(17685)
  55417 		if v12 & ^int32(YUV_MASK2) == 0 {
  55418 			v15 = v12 >> int32(YUV_FIX2)
  55419 		} else {
  55420 			if v12 < 0 {
  55421 				v16 = 0
  55422 			} else {
  55423 				v16 = int32(255)
  55424 			}
  55425 			v15 = v16
  55426 		}
  55427 		v13 = v15
  55428 		goto _135
  55429 	_135:
  55430 		v6 = v13
  55431 		goto _128
  55432 	_128:
  55433 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55434 		v19 = v2 * int32(19077) >> int32(8)
  55435 		goto _141
  55436 	_141:
  55437 		v21 = v3 * int32(6419) >> int32(8)
  55438 		goto _143
  55439 	_143:
  55440 		v23 = v4 * int32(13320) >> int32(8)
  55441 		goto _145
  55442 	_145:
  55443 		v25 = v19 - v21 - v23 + int32(8708)
  55444 		if v25 & ^int32(YUV_MASK2) == 0 {
  55445 			v28 = v25 >> int32(YUV_FIX2)
  55446 		} else {
  55447 			if v25 < 0 {
  55448 				v29 = 0
  55449 			} else {
  55450 				v29 = int32(255)
  55451 			}
  55452 			v28 = v29
  55453 		}
  55454 		v26 = v28
  55455 		goto _148
  55456 	_148:
  55457 		v17 = v26
  55458 		goto _139
  55459 	_139:
  55460 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55461 		v32 = v2 * int32(19077) >> int32(8)
  55462 		goto _154
  55463 	_154:
  55464 		v34 = v4 * int32(26149) >> int32(8)
  55465 		goto _156
  55466 	_156:
  55467 		v36 = v32 + v34 - int32(14234)
  55468 		if v36 & ^int32(YUV_MASK2) == 0 {
  55469 			v39 = v36 >> int32(YUV_FIX2)
  55470 		} else {
  55471 			if v36 < 0 {
  55472 				v40 = 0
  55473 			} else {
  55474 				v40 = int32(255)
  55475 			}
  55476 			v39 = v40
  55477 		}
  55478 		v37 = v39
  55479 		goto _159
  55480 	_159:
  55481 		v30 = v37
  55482 		goto _152
  55483 	_152:
  55484 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55485 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55486 		if bottom_y != libc.UintptrFromInt32(0) {
  55487 			uv03 = (diag_03 + l_uv) >> int32(1)
  55488 			uv11 = (diag_12 + uv) >> int32(1)
  55489 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  55490 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  55491 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  55492 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  55493 			v5 = v1
  55494 			v8 = v2 * int32(19077) >> int32(8)
  55495 			goto _170
  55496 		_170:
  55497 			v10 = v3 * int32(33050) >> int32(8)
  55498 			goto _172
  55499 		_172:
  55500 			v12 = v8 + v10 - int32(17685)
  55501 			if v12 & ^int32(YUV_MASK2) == 0 {
  55502 				v15 = v12 >> int32(YUV_FIX2)
  55503 			} else {
  55504 				if v12 < 0 {
  55505 					v16 = 0
  55506 				} else {
  55507 					v16 = int32(255)
  55508 				}
  55509 				v15 = v16
  55510 			}
  55511 			v13 = v15
  55512 			goto _175
  55513 		_175:
  55514 			v6 = v13
  55515 			goto _168
  55516 		_168:
  55517 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55518 			v19 = v2 * int32(19077) >> int32(8)
  55519 			goto _181
  55520 		_181:
  55521 			v21 = v3 * int32(6419) >> int32(8)
  55522 			goto _183
  55523 		_183:
  55524 			v23 = v4 * int32(13320) >> int32(8)
  55525 			goto _185
  55526 		_185:
  55527 			v25 = v19 - v21 - v23 + int32(8708)
  55528 			if v25 & ^int32(YUV_MASK2) == 0 {
  55529 				v28 = v25 >> int32(YUV_FIX2)
  55530 			} else {
  55531 				if v25 < 0 {
  55532 					v29 = 0
  55533 				} else {
  55534 					v29 = int32(255)
  55535 				}
  55536 				v28 = v29
  55537 			}
  55538 			v26 = v28
  55539 			goto _188
  55540 		_188:
  55541 			v17 = v26
  55542 			goto _179
  55543 		_179:
  55544 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55545 			v32 = v2 * int32(19077) >> int32(8)
  55546 			goto _194
  55547 		_194:
  55548 			v34 = v4 * int32(26149) >> int32(8)
  55549 			goto _196
  55550 		_196:
  55551 			v36 = v32 + v34 - int32(14234)
  55552 			if v36 & ^int32(YUV_MASK2) == 0 {
  55553 				v39 = v36 >> int32(YUV_FIX2)
  55554 			} else {
  55555 				if v36 < 0 {
  55556 					v40 = 0
  55557 				} else {
  55558 					v40 = int32(255)
  55559 				}
  55560 				v39 = v40
  55561 			}
  55562 			v37 = v39
  55563 			goto _199
  55564 		_199:
  55565 			v30 = v37
  55566 			goto _192
  55567 		_192:
  55568 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55569 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55570 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  55571 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  55572 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  55573 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  55574 			v5 = v1
  55575 			v8 = v2 * int32(19077) >> int32(8)
  55576 			goto _210
  55577 		_210:
  55578 			v10 = v3 * int32(33050) >> int32(8)
  55579 			goto _212
  55580 		_212:
  55581 			v12 = v8 + v10 - int32(17685)
  55582 			if v12 & ^int32(YUV_MASK2) == 0 {
  55583 				v15 = v12 >> int32(YUV_FIX2)
  55584 			} else {
  55585 				if v12 < 0 {
  55586 					v16 = 0
  55587 				} else {
  55588 					v16 = int32(255)
  55589 				}
  55590 				v15 = v16
  55591 			}
  55592 			v13 = v15
  55593 			goto _215
  55594 		_215:
  55595 			v6 = v13
  55596 			goto _208
  55597 		_208:
  55598 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55599 			v19 = v2 * int32(19077) >> int32(8)
  55600 			goto _221
  55601 		_221:
  55602 			v21 = v3 * int32(6419) >> int32(8)
  55603 			goto _223
  55604 		_223:
  55605 			v23 = v4 * int32(13320) >> int32(8)
  55606 			goto _225
  55607 		_225:
  55608 			v25 = v19 - v21 - v23 + int32(8708)
  55609 			if v25 & ^int32(YUV_MASK2) == 0 {
  55610 				v28 = v25 >> int32(YUV_FIX2)
  55611 			} else {
  55612 				if v25 < 0 {
  55613 					v29 = 0
  55614 				} else {
  55615 					v29 = int32(255)
  55616 				}
  55617 				v28 = v29
  55618 			}
  55619 			v26 = v28
  55620 			goto _228
  55621 		_228:
  55622 			v17 = v26
  55623 			goto _219
  55624 		_219:
  55625 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55626 			v32 = v2 * int32(19077) >> int32(8)
  55627 			goto _234
  55628 		_234:
  55629 			v34 = v4 * int32(26149) >> int32(8)
  55630 			goto _236
  55631 		_236:
  55632 			v36 = v32 + v34 - int32(14234)
  55633 			if v36 & ^int32(YUV_MASK2) == 0 {
  55634 				v39 = v36 >> int32(YUV_FIX2)
  55635 			} else {
  55636 				if v36 < 0 {
  55637 					v40 = 0
  55638 				} else {
  55639 					v40 = int32(255)
  55640 				}
  55641 				v39 = v40
  55642 			}
  55643 			v37 = v39
  55644 			goto _239
  55645 		_239:
  55646 			v30 = v37
  55647 			goto _232
  55648 		_232:
  55649 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55650 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55651 		}
  55652 		tl_uv = t_uv
  55653 		l_uv = uv
  55654 		goto _81
  55655 	_81:
  55656 		;
  55657 		x = x + 1
  55658 	}
  55659 	if !(len1&libc.Int32FromInt32(1) != 0) {
  55660 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55661 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  55662 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  55663 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  55664 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  55665 		v5 = v1
  55666 		v8 = v2 * int32(19077) >> int32(8)
  55667 		goto _250
  55668 	_250:
  55669 		v10 = v3 * int32(33050) >> int32(8)
  55670 		goto _252
  55671 	_252:
  55672 		v12 = v8 + v10 - int32(17685)
  55673 		if v12 & ^int32(YUV_MASK2) == 0 {
  55674 			v15 = v12 >> int32(YUV_FIX2)
  55675 		} else {
  55676 			if v12 < 0 {
  55677 				v16 = 0
  55678 			} else {
  55679 				v16 = int32(255)
  55680 			}
  55681 			v15 = v16
  55682 		}
  55683 		v13 = v15
  55684 		goto _255
  55685 	_255:
  55686 		v6 = v13
  55687 		goto _248
  55688 	_248:
  55689 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55690 		v19 = v2 * int32(19077) >> int32(8)
  55691 		goto _261
  55692 	_261:
  55693 		v21 = v3 * int32(6419) >> int32(8)
  55694 		goto _263
  55695 	_263:
  55696 		v23 = v4 * int32(13320) >> int32(8)
  55697 		goto _265
  55698 	_265:
  55699 		v25 = v19 - v21 - v23 + int32(8708)
  55700 		if v25 & ^int32(YUV_MASK2) == 0 {
  55701 			v28 = v25 >> int32(YUV_FIX2)
  55702 		} else {
  55703 			if v25 < 0 {
  55704 				v29 = 0
  55705 			} else {
  55706 				v29 = int32(255)
  55707 			}
  55708 			v28 = v29
  55709 		}
  55710 		v26 = v28
  55711 		goto _268
  55712 	_268:
  55713 		v17 = v26
  55714 		goto _259
  55715 	_259:
  55716 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55717 		v32 = v2 * int32(19077) >> int32(8)
  55718 		goto _274
  55719 	_274:
  55720 		v34 = v4 * int32(26149) >> int32(8)
  55721 		goto _276
  55722 	_276:
  55723 		v36 = v32 + v34 - int32(14234)
  55724 		if v36 & ^int32(YUV_MASK2) == 0 {
  55725 			v39 = v36 >> int32(YUV_FIX2)
  55726 		} else {
  55727 			if v36 < 0 {
  55728 				v40 = 0
  55729 			} else {
  55730 				v40 = int32(255)
  55731 			}
  55732 			v39 = v40
  55733 		}
  55734 		v37 = v39
  55735 		goto _279
  55736 	_279:
  55737 		v30 = v37
  55738 		goto _272
  55739 	_272:
  55740 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55741 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55742 		if bottom_y != libc.UintptrFromInt32(0) {
  55743 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55744 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  55745 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  55746 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  55747 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  55748 			v5 = v1
  55749 			v8 = v2 * int32(19077) >> int32(8)
  55750 			goto _290
  55751 		_290:
  55752 			v10 = v3 * int32(33050) >> int32(8)
  55753 			goto _292
  55754 		_292:
  55755 			v12 = v8 + v10 - int32(17685)
  55756 			if v12 & ^int32(YUV_MASK2) == 0 {
  55757 				v15 = v12 >> int32(YUV_FIX2)
  55758 			} else {
  55759 				if v12 < 0 {
  55760 					v16 = 0
  55761 				} else {
  55762 					v16 = int32(255)
  55763 				}
  55764 				v15 = v16
  55765 			}
  55766 			v13 = v15
  55767 			goto _295
  55768 		_295:
  55769 			v6 = v13
  55770 			goto _288
  55771 		_288:
  55772 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55773 			v19 = v2 * int32(19077) >> int32(8)
  55774 			goto _301
  55775 		_301:
  55776 			v21 = v3 * int32(6419) >> int32(8)
  55777 			goto _303
  55778 		_303:
  55779 			v23 = v4 * int32(13320) >> int32(8)
  55780 			goto _305
  55781 		_305:
  55782 			v25 = v19 - v21 - v23 + int32(8708)
  55783 			if v25 & ^int32(YUV_MASK2) == 0 {
  55784 				v28 = v25 >> int32(YUV_FIX2)
  55785 			} else {
  55786 				if v25 < 0 {
  55787 					v29 = 0
  55788 				} else {
  55789 					v29 = int32(255)
  55790 				}
  55791 				v28 = v29
  55792 			}
  55793 			v26 = v28
  55794 			goto _308
  55795 		_308:
  55796 			v17 = v26
  55797 			goto _299
  55798 		_299:
  55799 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55800 			v32 = v2 * int32(19077) >> int32(8)
  55801 			goto _314
  55802 		_314:
  55803 			v34 = v4 * int32(26149) >> int32(8)
  55804 			goto _316
  55805 		_316:
  55806 			v36 = v32 + v34 - int32(14234)
  55807 			if v36 & ^int32(YUV_MASK2) == 0 {
  55808 				v39 = v36 >> int32(YUV_FIX2)
  55809 			} else {
  55810 				if v36 < 0 {
  55811 					v40 = 0
  55812 				} else {
  55813 					v40 = int32(255)
  55814 				}
  55815 				v39 = v40
  55816 			}
  55817 			v37 = v39
  55818 			goto _319
  55819 		_319:
  55820 			v30 = v37
  55821 			goto _312
  55822 		_312:
  55823 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55824 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55825 		}
  55826 	}
  55827 }
  55828 
  55829 func UpsampleArgbLinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  55830 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  55831 	var last_pixel_pair, x, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  55832 	var v1, v5 uintptr
  55833 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, diag_03, diag_12, l_uv, last_pixel_pair, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v6, v8
  55834 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  55835 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  55836 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  55837 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55838 	v1 = top_dst
  55839 	**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  55840 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  55841 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  55842 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  55843 	v5 = v1 + uintptr(1)
  55844 	v8 = v2 * int32(19077) >> int32(8)
  55845 	goto _9
  55846 _9:
  55847 	v10 = v4 * int32(26149) >> int32(8)
  55848 	goto _11
  55849 _11:
  55850 	v12 = v8 + v10 - int32(14234)
  55851 	if v12 & ^int32(YUV_MASK2) == 0 {
  55852 		v15 = v12 >> int32(YUV_FIX2)
  55853 	} else {
  55854 		if v12 < 0 {
  55855 			v16 = 0
  55856 		} else {
  55857 			v16 = int32(255)
  55858 		}
  55859 		v15 = v16
  55860 	}
  55861 	v13 = v15
  55862 	goto _14
  55863 _14:
  55864 	v6 = v13
  55865 	goto _7
  55866 _7:
  55867 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55868 	v19 = v2 * int32(19077) >> int32(8)
  55869 	goto _20
  55870 _20:
  55871 	v21 = v3 * int32(6419) >> int32(8)
  55872 	goto _22
  55873 _22:
  55874 	v23 = v4 * int32(13320) >> int32(8)
  55875 	goto _24
  55876 _24:
  55877 	v25 = v19 - v21 - v23 + int32(8708)
  55878 	if v25 & ^int32(YUV_MASK2) == 0 {
  55879 		v28 = v25 >> int32(YUV_FIX2)
  55880 	} else {
  55881 		if v25 < 0 {
  55882 			v29 = 0
  55883 		} else {
  55884 			v29 = int32(255)
  55885 		}
  55886 		v28 = v29
  55887 	}
  55888 	v26 = v28
  55889 	goto _27
  55890 _27:
  55891 	v17 = v26
  55892 	goto _18
  55893 _18:
  55894 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55895 	v32 = v2 * int32(19077) >> int32(8)
  55896 	goto _33
  55897 _33:
  55898 	v34 = v3 * int32(33050) >> int32(8)
  55899 	goto _35
  55900 _35:
  55901 	v36 = v32 + v34 - int32(17685)
  55902 	if v36 & ^int32(YUV_MASK2) == 0 {
  55903 		v39 = v36 >> int32(YUV_FIX2)
  55904 	} else {
  55905 		if v36 < 0 {
  55906 			v40 = 0
  55907 		} else {
  55908 			v40 = int32(255)
  55909 		}
  55910 		v39 = v40
  55911 	}
  55912 	v37 = v39
  55913 	goto _38
  55914 _38:
  55915 	v30 = v37
  55916 	goto _31
  55917 _31:
  55918 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55919 	if bottom_y != libc.UintptrFromInt32(0) {
  55920 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55921 		v1 = bottom_dst
  55922 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  55923 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  55924 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  55925 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  55926 		v5 = v1 + uintptr(1)
  55927 		v8 = v2 * int32(19077) >> int32(8)
  55928 		goto _49
  55929 	_49:
  55930 		v10 = v4 * int32(26149) >> int32(8)
  55931 		goto _51
  55932 	_51:
  55933 		v12 = v8 + v10 - int32(14234)
  55934 		if v12 & ^int32(YUV_MASK2) == 0 {
  55935 			v15 = v12 >> int32(YUV_FIX2)
  55936 		} else {
  55937 			if v12 < 0 {
  55938 				v16 = 0
  55939 			} else {
  55940 				v16 = int32(255)
  55941 			}
  55942 			v15 = v16
  55943 		}
  55944 		v13 = v15
  55945 		goto _54
  55946 	_54:
  55947 		v6 = v13
  55948 		goto _47
  55949 	_47:
  55950 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55951 		v19 = v2 * int32(19077) >> int32(8)
  55952 		goto _60
  55953 	_60:
  55954 		v21 = v3 * int32(6419) >> int32(8)
  55955 		goto _62
  55956 	_62:
  55957 		v23 = v4 * int32(13320) >> int32(8)
  55958 		goto _64
  55959 	_64:
  55960 		v25 = v19 - v21 - v23 + int32(8708)
  55961 		if v25 & ^int32(YUV_MASK2) == 0 {
  55962 			v28 = v25 >> int32(YUV_FIX2)
  55963 		} else {
  55964 			if v25 < 0 {
  55965 				v29 = 0
  55966 			} else {
  55967 				v29 = int32(255)
  55968 			}
  55969 			v28 = v29
  55970 		}
  55971 		v26 = v28
  55972 		goto _67
  55973 	_67:
  55974 		v17 = v26
  55975 		goto _58
  55976 	_58:
  55977 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55978 		v32 = v2 * int32(19077) >> int32(8)
  55979 		goto _73
  55980 	_73:
  55981 		v34 = v3 * int32(33050) >> int32(8)
  55982 		goto _75
  55983 	_75:
  55984 		v36 = v32 + v34 - int32(17685)
  55985 		if v36 & ^int32(YUV_MASK2) == 0 {
  55986 			v39 = v36 >> int32(YUV_FIX2)
  55987 		} else {
  55988 			if v36 < 0 {
  55989 				v40 = 0
  55990 			} else {
  55991 				v40 = int32(255)
  55992 			}
  55993 			v39 = v40
  55994 		}
  55995 		v37 = v39
  55996 		goto _78
  55997 	_78:
  55998 		v30 = v37
  55999 		goto _71
  56000 	_71:
  56001 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56002 	}
  56003 	x = int32(1)
  56004 	for {
  56005 		if !(x <= last_pixel_pair) {
  56006 			break
  56007 		}
  56008 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  56009 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  56010 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  56011 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  56012 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  56013 		uv02 = (diag_12 + tl_uv) >> int32(1)
  56014 		uv1 = (diag_03 + t_uv) >> int32(1)
  56015 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  56016 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56017 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  56018 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  56019 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  56020 		v5 = v1 + uintptr(1)
  56021 		v8 = v2 * int32(19077) >> int32(8)
  56022 		goto _90
  56023 	_90:
  56024 		v10 = v4 * int32(26149) >> int32(8)
  56025 		goto _92
  56026 	_92:
  56027 		v12 = v8 + v10 - int32(14234)
  56028 		if v12 & ^int32(YUV_MASK2) == 0 {
  56029 			v15 = v12 >> int32(YUV_FIX2)
  56030 		} else {
  56031 			if v12 < 0 {
  56032 				v16 = 0
  56033 			} else {
  56034 				v16 = int32(255)
  56035 			}
  56036 			v15 = v16
  56037 		}
  56038 		v13 = v15
  56039 		goto _95
  56040 	_95:
  56041 		v6 = v13
  56042 		goto _88
  56043 	_88:
  56044 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56045 		v19 = v2 * int32(19077) >> int32(8)
  56046 		goto _101
  56047 	_101:
  56048 		v21 = v3 * int32(6419) >> int32(8)
  56049 		goto _103
  56050 	_103:
  56051 		v23 = v4 * int32(13320) >> int32(8)
  56052 		goto _105
  56053 	_105:
  56054 		v25 = v19 - v21 - v23 + int32(8708)
  56055 		if v25 & ^int32(YUV_MASK2) == 0 {
  56056 			v28 = v25 >> int32(YUV_FIX2)
  56057 		} else {
  56058 			if v25 < 0 {
  56059 				v29 = 0
  56060 			} else {
  56061 				v29 = int32(255)
  56062 			}
  56063 			v28 = v29
  56064 		}
  56065 		v26 = v28
  56066 		goto _108
  56067 	_108:
  56068 		v17 = v26
  56069 		goto _99
  56070 	_99:
  56071 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56072 		v32 = v2 * int32(19077) >> int32(8)
  56073 		goto _114
  56074 	_114:
  56075 		v34 = v3 * int32(33050) >> int32(8)
  56076 		goto _116
  56077 	_116:
  56078 		v36 = v32 + v34 - int32(17685)
  56079 		if v36 & ^int32(YUV_MASK2) == 0 {
  56080 			v39 = v36 >> int32(YUV_FIX2)
  56081 		} else {
  56082 			if v36 < 0 {
  56083 				v40 = 0
  56084 			} else {
  56085 				v40 = int32(255)
  56086 			}
  56087 			v39 = v40
  56088 		}
  56089 		v37 = v39
  56090 		goto _119
  56091 	_119:
  56092 		v30 = v37
  56093 		goto _112
  56094 	_112:
  56095 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56096 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  56097 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56098 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  56099 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  56100 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  56101 		v5 = v1 + uintptr(1)
  56102 		v8 = v2 * int32(19077) >> int32(8)
  56103 		goto _130
  56104 	_130:
  56105 		v10 = v4 * int32(26149) >> int32(8)
  56106 		goto _132
  56107 	_132:
  56108 		v12 = v8 + v10 - int32(14234)
  56109 		if v12 & ^int32(YUV_MASK2) == 0 {
  56110 			v15 = v12 >> int32(YUV_FIX2)
  56111 		} else {
  56112 			if v12 < 0 {
  56113 				v16 = 0
  56114 			} else {
  56115 				v16 = int32(255)
  56116 			}
  56117 			v15 = v16
  56118 		}
  56119 		v13 = v15
  56120 		goto _135
  56121 	_135:
  56122 		v6 = v13
  56123 		goto _128
  56124 	_128:
  56125 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56126 		v19 = v2 * int32(19077) >> int32(8)
  56127 		goto _141
  56128 	_141:
  56129 		v21 = v3 * int32(6419) >> int32(8)
  56130 		goto _143
  56131 	_143:
  56132 		v23 = v4 * int32(13320) >> int32(8)
  56133 		goto _145
  56134 	_145:
  56135 		v25 = v19 - v21 - v23 + int32(8708)
  56136 		if v25 & ^int32(YUV_MASK2) == 0 {
  56137 			v28 = v25 >> int32(YUV_FIX2)
  56138 		} else {
  56139 			if v25 < 0 {
  56140 				v29 = 0
  56141 			} else {
  56142 				v29 = int32(255)
  56143 			}
  56144 			v28 = v29
  56145 		}
  56146 		v26 = v28
  56147 		goto _148
  56148 	_148:
  56149 		v17 = v26
  56150 		goto _139
  56151 	_139:
  56152 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56153 		v32 = v2 * int32(19077) >> int32(8)
  56154 		goto _154
  56155 	_154:
  56156 		v34 = v3 * int32(33050) >> int32(8)
  56157 		goto _156
  56158 	_156:
  56159 		v36 = v32 + v34 - int32(17685)
  56160 		if v36 & ^int32(YUV_MASK2) == 0 {
  56161 			v39 = v36 >> int32(YUV_FIX2)
  56162 		} else {
  56163 			if v36 < 0 {
  56164 				v40 = 0
  56165 			} else {
  56166 				v40 = int32(255)
  56167 			}
  56168 			v39 = v40
  56169 		}
  56170 		v37 = v39
  56171 		goto _159
  56172 	_159:
  56173 		v30 = v37
  56174 		goto _152
  56175 	_152:
  56176 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56177 		if bottom_y != libc.UintptrFromInt32(0) {
  56178 			uv03 = (diag_03 + l_uv) >> int32(1)
  56179 			uv11 = (diag_12 + uv) >> int32(1)
  56180 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  56181 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56182 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  56183 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  56184 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  56185 			v5 = v1 + uintptr(1)
  56186 			v8 = v2 * int32(19077) >> int32(8)
  56187 			goto _170
  56188 		_170:
  56189 			v10 = v4 * int32(26149) >> int32(8)
  56190 			goto _172
  56191 		_172:
  56192 			v12 = v8 + v10 - int32(14234)
  56193 			if v12 & ^int32(YUV_MASK2) == 0 {
  56194 				v15 = v12 >> int32(YUV_FIX2)
  56195 			} else {
  56196 				if v12 < 0 {
  56197 					v16 = 0
  56198 				} else {
  56199 					v16 = int32(255)
  56200 				}
  56201 				v15 = v16
  56202 			}
  56203 			v13 = v15
  56204 			goto _175
  56205 		_175:
  56206 			v6 = v13
  56207 			goto _168
  56208 		_168:
  56209 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56210 			v19 = v2 * int32(19077) >> int32(8)
  56211 			goto _181
  56212 		_181:
  56213 			v21 = v3 * int32(6419) >> int32(8)
  56214 			goto _183
  56215 		_183:
  56216 			v23 = v4 * int32(13320) >> int32(8)
  56217 			goto _185
  56218 		_185:
  56219 			v25 = v19 - v21 - v23 + int32(8708)
  56220 			if v25 & ^int32(YUV_MASK2) == 0 {
  56221 				v28 = v25 >> int32(YUV_FIX2)
  56222 			} else {
  56223 				if v25 < 0 {
  56224 					v29 = 0
  56225 				} else {
  56226 					v29 = int32(255)
  56227 				}
  56228 				v28 = v29
  56229 			}
  56230 			v26 = v28
  56231 			goto _188
  56232 		_188:
  56233 			v17 = v26
  56234 			goto _179
  56235 		_179:
  56236 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56237 			v32 = v2 * int32(19077) >> int32(8)
  56238 			goto _194
  56239 		_194:
  56240 			v34 = v3 * int32(33050) >> int32(8)
  56241 			goto _196
  56242 		_196:
  56243 			v36 = v32 + v34 - int32(17685)
  56244 			if v36 & ^int32(YUV_MASK2) == 0 {
  56245 				v39 = v36 >> int32(YUV_FIX2)
  56246 			} else {
  56247 				if v36 < 0 {
  56248 					v40 = 0
  56249 				} else {
  56250 					v40 = int32(255)
  56251 				}
  56252 				v39 = v40
  56253 			}
  56254 			v37 = v39
  56255 			goto _199
  56256 		_199:
  56257 			v30 = v37
  56258 			goto _192
  56259 		_192:
  56260 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56261 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  56262 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56263 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  56264 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  56265 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  56266 			v5 = v1 + uintptr(1)
  56267 			v8 = v2 * int32(19077) >> int32(8)
  56268 			goto _210
  56269 		_210:
  56270 			v10 = v4 * int32(26149) >> int32(8)
  56271 			goto _212
  56272 		_212:
  56273 			v12 = v8 + v10 - int32(14234)
  56274 			if v12 & ^int32(YUV_MASK2) == 0 {
  56275 				v15 = v12 >> int32(YUV_FIX2)
  56276 			} else {
  56277 				if v12 < 0 {
  56278 					v16 = 0
  56279 				} else {
  56280 					v16 = int32(255)
  56281 				}
  56282 				v15 = v16
  56283 			}
  56284 			v13 = v15
  56285 			goto _215
  56286 		_215:
  56287 			v6 = v13
  56288 			goto _208
  56289 		_208:
  56290 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56291 			v19 = v2 * int32(19077) >> int32(8)
  56292 			goto _221
  56293 		_221:
  56294 			v21 = v3 * int32(6419) >> int32(8)
  56295 			goto _223
  56296 		_223:
  56297 			v23 = v4 * int32(13320) >> int32(8)
  56298 			goto _225
  56299 		_225:
  56300 			v25 = v19 - v21 - v23 + int32(8708)
  56301 			if v25 & ^int32(YUV_MASK2) == 0 {
  56302 				v28 = v25 >> int32(YUV_FIX2)
  56303 			} else {
  56304 				if v25 < 0 {
  56305 					v29 = 0
  56306 				} else {
  56307 					v29 = int32(255)
  56308 				}
  56309 				v28 = v29
  56310 			}
  56311 			v26 = v28
  56312 			goto _228
  56313 		_228:
  56314 			v17 = v26
  56315 			goto _219
  56316 		_219:
  56317 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56318 			v32 = v2 * int32(19077) >> int32(8)
  56319 			goto _234
  56320 		_234:
  56321 			v34 = v3 * int32(33050) >> int32(8)
  56322 			goto _236
  56323 		_236:
  56324 			v36 = v32 + v34 - int32(17685)
  56325 			if v36 & ^int32(YUV_MASK2) == 0 {
  56326 				v39 = v36 >> int32(YUV_FIX2)
  56327 			} else {
  56328 				if v36 < 0 {
  56329 					v40 = 0
  56330 				} else {
  56331 					v40 = int32(255)
  56332 				}
  56333 				v39 = v40
  56334 			}
  56335 			v37 = v39
  56336 			goto _239
  56337 		_239:
  56338 			v30 = v37
  56339 			goto _232
  56340 		_232:
  56341 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56342 		}
  56343 		tl_uv = t_uv
  56344 		l_uv = uv
  56345 		goto _81
  56346 	_81:
  56347 		;
  56348 		x = x + 1
  56349 	}
  56350 	if !(len1&libc.Int32FromInt32(1) != 0) {
  56351 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  56352 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  56353 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56354 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  56355 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  56356 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  56357 		v5 = v1 + uintptr(1)
  56358 		v8 = v2 * int32(19077) >> int32(8)
  56359 		goto _250
  56360 	_250:
  56361 		v10 = v4 * int32(26149) >> int32(8)
  56362 		goto _252
  56363 	_252:
  56364 		v12 = v8 + v10 - int32(14234)
  56365 		if v12 & ^int32(YUV_MASK2) == 0 {
  56366 			v15 = v12 >> int32(YUV_FIX2)
  56367 		} else {
  56368 			if v12 < 0 {
  56369 				v16 = 0
  56370 			} else {
  56371 				v16 = int32(255)
  56372 			}
  56373 			v15 = v16
  56374 		}
  56375 		v13 = v15
  56376 		goto _255
  56377 	_255:
  56378 		v6 = v13
  56379 		goto _248
  56380 	_248:
  56381 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56382 		v19 = v2 * int32(19077) >> int32(8)
  56383 		goto _261
  56384 	_261:
  56385 		v21 = v3 * int32(6419) >> int32(8)
  56386 		goto _263
  56387 	_263:
  56388 		v23 = v4 * int32(13320) >> int32(8)
  56389 		goto _265
  56390 	_265:
  56391 		v25 = v19 - v21 - v23 + int32(8708)
  56392 		if v25 & ^int32(YUV_MASK2) == 0 {
  56393 			v28 = v25 >> int32(YUV_FIX2)
  56394 		} else {
  56395 			if v25 < 0 {
  56396 				v29 = 0
  56397 			} else {
  56398 				v29 = int32(255)
  56399 			}
  56400 			v28 = v29
  56401 		}
  56402 		v26 = v28
  56403 		goto _268
  56404 	_268:
  56405 		v17 = v26
  56406 		goto _259
  56407 	_259:
  56408 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56409 		v32 = v2 * int32(19077) >> int32(8)
  56410 		goto _274
  56411 	_274:
  56412 		v34 = v3 * int32(33050) >> int32(8)
  56413 		goto _276
  56414 	_276:
  56415 		v36 = v32 + v34 - int32(17685)
  56416 		if v36 & ^int32(YUV_MASK2) == 0 {
  56417 			v39 = v36 >> int32(YUV_FIX2)
  56418 		} else {
  56419 			if v36 < 0 {
  56420 				v40 = 0
  56421 			} else {
  56422 				v40 = int32(255)
  56423 			}
  56424 			v39 = v40
  56425 		}
  56426 		v37 = v39
  56427 		goto _279
  56428 	_279:
  56429 		v30 = v37
  56430 		goto _272
  56431 	_272:
  56432 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56433 		if bottom_y != libc.UintptrFromInt32(0) {
  56434 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  56435 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  56436 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56437 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  56438 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  56439 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  56440 			v5 = v1 + uintptr(1)
  56441 			v8 = v2 * int32(19077) >> int32(8)
  56442 			goto _290
  56443 		_290:
  56444 			v10 = v4 * int32(26149) >> int32(8)
  56445 			goto _292
  56446 		_292:
  56447 			v12 = v8 + v10 - int32(14234)
  56448 			if v12 & ^int32(YUV_MASK2) == 0 {
  56449 				v15 = v12 >> int32(YUV_FIX2)
  56450 			} else {
  56451 				if v12 < 0 {
  56452 					v16 = 0
  56453 				} else {
  56454 					v16 = int32(255)
  56455 				}
  56456 				v15 = v16
  56457 			}
  56458 			v13 = v15
  56459 			goto _295
  56460 		_295:
  56461 			v6 = v13
  56462 			goto _288
  56463 		_288:
  56464 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56465 			v19 = v2 * int32(19077) >> int32(8)
  56466 			goto _301
  56467 		_301:
  56468 			v21 = v3 * int32(6419) >> int32(8)
  56469 			goto _303
  56470 		_303:
  56471 			v23 = v4 * int32(13320) >> int32(8)
  56472 			goto _305
  56473 		_305:
  56474 			v25 = v19 - v21 - v23 + int32(8708)
  56475 			if v25 & ^int32(YUV_MASK2) == 0 {
  56476 				v28 = v25 >> int32(YUV_FIX2)
  56477 			} else {
  56478 				if v25 < 0 {
  56479 					v29 = 0
  56480 				} else {
  56481 					v29 = int32(255)
  56482 				}
  56483 				v28 = v29
  56484 			}
  56485 			v26 = v28
  56486 			goto _308
  56487 		_308:
  56488 			v17 = v26
  56489 			goto _299
  56490 		_299:
  56491 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56492 			v32 = v2 * int32(19077) >> int32(8)
  56493 			goto _314
  56494 		_314:
  56495 			v34 = v3 * int32(33050) >> int32(8)
  56496 			goto _316
  56497 		_316:
  56498 			v36 = v32 + v34 - int32(17685)
  56499 			if v36 & ^int32(YUV_MASK2) == 0 {
  56500 				v39 = v36 >> int32(YUV_FIX2)
  56501 			} else {
  56502 				if v36 < 0 {
  56503 					v40 = 0
  56504 				} else {
  56505 					v40 = int32(255)
  56506 				}
  56507 				v39 = v40
  56508 			}
  56509 			v37 = v39
  56510 			goto _319
  56511 		_319:
  56512 			v30 = v37
  56513 			goto _312
  56514 		_312:
  56515 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56516 		}
  56517 	}
  56518 }
  56519 
  56520 func UpsampleRgbLinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  56521 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  56522 	var last_pixel_pair, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v5, v7, v9 int32
  56523 	var v4 uintptr
  56524 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, diag_03, diag_12, l_uv, last_pixel_pair, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v5, v7, v9
  56525 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  56526 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  56527 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  56528 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  56529 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  56530 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  56531 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  56532 	v4 = top_dst
  56533 	v7 = v1 * int32(19077) >> int32(8)
  56534 	goto _8
  56535 _8:
  56536 	v9 = v3 * int32(26149) >> int32(8)
  56537 	goto _10
  56538 _10:
  56539 	v11 = v7 + v9 - int32(14234)
  56540 	if v11 & ^int32(YUV_MASK2) == 0 {
  56541 		v14 = v11 >> int32(YUV_FIX2)
  56542 	} else {
  56543 		if v11 < 0 {
  56544 			v15 = 0
  56545 		} else {
  56546 			v15 = int32(255)
  56547 		}
  56548 		v14 = v15
  56549 	}
  56550 	v12 = v14
  56551 	goto _13
  56552 _13:
  56553 	v5 = v12
  56554 	goto _6
  56555 _6:
  56556 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56557 	v18 = v1 * int32(19077) >> int32(8)
  56558 	goto _19
  56559 _19:
  56560 	v20 = v2 * int32(6419) >> int32(8)
  56561 	goto _21
  56562 _21:
  56563 	v22 = v3 * int32(13320) >> int32(8)
  56564 	goto _23
  56565 _23:
  56566 	v24 = v18 - v20 - v22 + int32(8708)
  56567 	if v24 & ^int32(YUV_MASK2) == 0 {
  56568 		v27 = v24 >> int32(YUV_FIX2)
  56569 	} else {
  56570 		if v24 < 0 {
  56571 			v28 = 0
  56572 		} else {
  56573 			v28 = int32(255)
  56574 		}
  56575 		v27 = v28
  56576 	}
  56577 	v25 = v27
  56578 	goto _26
  56579 _26:
  56580 	v16 = v25
  56581 	goto _17
  56582 _17:
  56583 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56584 	v31 = v1 * int32(19077) >> int32(8)
  56585 	goto _32
  56586 _32:
  56587 	v33 = v2 * int32(33050) >> int32(8)
  56588 	goto _34
  56589 _34:
  56590 	v35 = v31 + v33 - int32(17685)
  56591 	if v35 & ^int32(YUV_MASK2) == 0 {
  56592 		v38 = v35 >> int32(YUV_FIX2)
  56593 	} else {
  56594 		if v35 < 0 {
  56595 			v39 = 0
  56596 		} else {
  56597 			v39 = int32(255)
  56598 		}
  56599 		v38 = v39
  56600 	}
  56601 	v36 = v38
  56602 	goto _37
  56603 _37:
  56604 	v29 = v36
  56605 	goto _30
  56606 _30:
  56607 	**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56608 	if bottom_y != libc.UintptrFromInt32(0) {
  56609 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  56610 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  56611 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  56612 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  56613 		v4 = bottom_dst
  56614 		v7 = v1 * int32(19077) >> int32(8)
  56615 		goto _47
  56616 	_47:
  56617 		v9 = v3 * int32(26149) >> int32(8)
  56618 		goto _49
  56619 	_49:
  56620 		v11 = v7 + v9 - int32(14234)
  56621 		if v11 & ^int32(YUV_MASK2) == 0 {
  56622 			v14 = v11 >> int32(YUV_FIX2)
  56623 		} else {
  56624 			if v11 < 0 {
  56625 				v15 = 0
  56626 			} else {
  56627 				v15 = int32(255)
  56628 			}
  56629 			v14 = v15
  56630 		}
  56631 		v12 = v14
  56632 		goto _52
  56633 	_52:
  56634 		v5 = v12
  56635 		goto _45
  56636 	_45:
  56637 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56638 		v18 = v1 * int32(19077) >> int32(8)
  56639 		goto _58
  56640 	_58:
  56641 		v20 = v2 * int32(6419) >> int32(8)
  56642 		goto _60
  56643 	_60:
  56644 		v22 = v3 * int32(13320) >> int32(8)
  56645 		goto _62
  56646 	_62:
  56647 		v24 = v18 - v20 - v22 + int32(8708)
  56648 		if v24 & ^int32(YUV_MASK2) == 0 {
  56649 			v27 = v24 >> int32(YUV_FIX2)
  56650 		} else {
  56651 			if v24 < 0 {
  56652 				v28 = 0
  56653 			} else {
  56654 				v28 = int32(255)
  56655 			}
  56656 			v27 = v28
  56657 		}
  56658 		v25 = v27
  56659 		goto _65
  56660 	_65:
  56661 		v16 = v25
  56662 		goto _56
  56663 	_56:
  56664 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56665 		v31 = v1 * int32(19077) >> int32(8)
  56666 		goto _71
  56667 	_71:
  56668 		v33 = v2 * int32(33050) >> int32(8)
  56669 		goto _73
  56670 	_73:
  56671 		v35 = v31 + v33 - int32(17685)
  56672 		if v35 & ^int32(YUV_MASK2) == 0 {
  56673 			v38 = v35 >> int32(YUV_FIX2)
  56674 		} else {
  56675 			if v35 < 0 {
  56676 				v39 = 0
  56677 			} else {
  56678 				v39 = int32(255)
  56679 			}
  56680 			v38 = v39
  56681 		}
  56682 		v36 = v38
  56683 		goto _76
  56684 	_76:
  56685 		v29 = v36
  56686 		goto _69
  56687 	_69:
  56688 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56689 	}
  56690 	x = int32(1)
  56691 	for {
  56692 		if !(x <= last_pixel_pair) {
  56693 			break
  56694 		}
  56695 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  56696 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  56697 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  56698 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  56699 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  56700 		uv02 = (diag_12 + tl_uv) >> int32(1)
  56701 		uv1 = (diag_03 + t_uv) >> int32(1)
  56702 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  56703 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  56704 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  56705 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  56706 		v7 = v1 * int32(19077) >> int32(8)
  56707 		goto _87
  56708 	_87:
  56709 		v9 = v3 * int32(26149) >> int32(8)
  56710 		goto _89
  56711 	_89:
  56712 		v11 = v7 + v9 - int32(14234)
  56713 		if v11 & ^int32(YUV_MASK2) == 0 {
  56714 			v14 = v11 >> int32(YUV_FIX2)
  56715 		} else {
  56716 			if v11 < 0 {
  56717 				v15 = 0
  56718 			} else {
  56719 				v15 = int32(255)
  56720 			}
  56721 			v14 = v15
  56722 		}
  56723 		v12 = v14
  56724 		goto _92
  56725 	_92:
  56726 		v5 = v12
  56727 		goto _85
  56728 	_85:
  56729 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56730 		v18 = v1 * int32(19077) >> int32(8)
  56731 		goto _98
  56732 	_98:
  56733 		v20 = v2 * int32(6419) >> int32(8)
  56734 		goto _100
  56735 	_100:
  56736 		v22 = v3 * int32(13320) >> int32(8)
  56737 		goto _102
  56738 	_102:
  56739 		v24 = v18 - v20 - v22 + int32(8708)
  56740 		if v24 & ^int32(YUV_MASK2) == 0 {
  56741 			v27 = v24 >> int32(YUV_FIX2)
  56742 		} else {
  56743 			if v24 < 0 {
  56744 				v28 = 0
  56745 			} else {
  56746 				v28 = int32(255)
  56747 			}
  56748 			v27 = v28
  56749 		}
  56750 		v25 = v27
  56751 		goto _105
  56752 	_105:
  56753 		v16 = v25
  56754 		goto _96
  56755 	_96:
  56756 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56757 		v31 = v1 * int32(19077) >> int32(8)
  56758 		goto _111
  56759 	_111:
  56760 		v33 = v2 * int32(33050) >> int32(8)
  56761 		goto _113
  56762 	_113:
  56763 		v35 = v31 + v33 - int32(17685)
  56764 		if v35 & ^int32(YUV_MASK2) == 0 {
  56765 			v38 = v35 >> int32(YUV_FIX2)
  56766 		} else {
  56767 			if v35 < 0 {
  56768 				v39 = 0
  56769 			} else {
  56770 				v39 = int32(255)
  56771 			}
  56772 			v38 = v39
  56773 		}
  56774 		v36 = v38
  56775 		goto _116
  56776 	_116:
  56777 		v29 = v36
  56778 		goto _109
  56779 	_109:
  56780 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56781 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  56782 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  56783 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  56784 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(3))
  56785 		v7 = v1 * int32(19077) >> int32(8)
  56786 		goto _126
  56787 	_126:
  56788 		v9 = v3 * int32(26149) >> int32(8)
  56789 		goto _128
  56790 	_128:
  56791 		v11 = v7 + v9 - int32(14234)
  56792 		if v11 & ^int32(YUV_MASK2) == 0 {
  56793 			v14 = v11 >> int32(YUV_FIX2)
  56794 		} else {
  56795 			if v11 < 0 {
  56796 				v15 = 0
  56797 			} else {
  56798 				v15 = int32(255)
  56799 			}
  56800 			v14 = v15
  56801 		}
  56802 		v12 = v14
  56803 		goto _131
  56804 	_131:
  56805 		v5 = v12
  56806 		goto _124
  56807 	_124:
  56808 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56809 		v18 = v1 * int32(19077) >> int32(8)
  56810 		goto _137
  56811 	_137:
  56812 		v20 = v2 * int32(6419) >> int32(8)
  56813 		goto _139
  56814 	_139:
  56815 		v22 = v3 * int32(13320) >> int32(8)
  56816 		goto _141
  56817 	_141:
  56818 		v24 = v18 - v20 - v22 + int32(8708)
  56819 		if v24 & ^int32(YUV_MASK2) == 0 {
  56820 			v27 = v24 >> int32(YUV_FIX2)
  56821 		} else {
  56822 			if v24 < 0 {
  56823 				v28 = 0
  56824 			} else {
  56825 				v28 = int32(255)
  56826 			}
  56827 			v27 = v28
  56828 		}
  56829 		v25 = v27
  56830 		goto _144
  56831 	_144:
  56832 		v16 = v25
  56833 		goto _135
  56834 	_135:
  56835 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56836 		v31 = v1 * int32(19077) >> int32(8)
  56837 		goto _150
  56838 	_150:
  56839 		v33 = v2 * int32(33050) >> int32(8)
  56840 		goto _152
  56841 	_152:
  56842 		v35 = v31 + v33 - int32(17685)
  56843 		if v35 & ^int32(YUV_MASK2) == 0 {
  56844 			v38 = v35 >> int32(YUV_FIX2)
  56845 		} else {
  56846 			if v35 < 0 {
  56847 				v39 = 0
  56848 			} else {
  56849 				v39 = int32(255)
  56850 			}
  56851 			v38 = v39
  56852 		}
  56853 		v36 = v38
  56854 		goto _155
  56855 	_155:
  56856 		v29 = v36
  56857 		goto _148
  56858 	_148:
  56859 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56860 		if bottom_y != libc.UintptrFromInt32(0) {
  56861 			uv03 = (diag_03 + l_uv) >> int32(1)
  56862 			uv11 = (diag_12 + uv) >> int32(1)
  56863 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  56864 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  56865 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  56866 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  56867 			v7 = v1 * int32(19077) >> int32(8)
  56868 			goto _165
  56869 		_165:
  56870 			v9 = v3 * int32(26149) >> int32(8)
  56871 			goto _167
  56872 		_167:
  56873 			v11 = v7 + v9 - int32(14234)
  56874 			if v11 & ^int32(YUV_MASK2) == 0 {
  56875 				v14 = v11 >> int32(YUV_FIX2)
  56876 			} else {
  56877 				if v11 < 0 {
  56878 					v15 = 0
  56879 				} else {
  56880 					v15 = int32(255)
  56881 				}
  56882 				v14 = v15
  56883 			}
  56884 			v12 = v14
  56885 			goto _170
  56886 		_170:
  56887 			v5 = v12
  56888 			goto _163
  56889 		_163:
  56890 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56891 			v18 = v1 * int32(19077) >> int32(8)
  56892 			goto _176
  56893 		_176:
  56894 			v20 = v2 * int32(6419) >> int32(8)
  56895 			goto _178
  56896 		_178:
  56897 			v22 = v3 * int32(13320) >> int32(8)
  56898 			goto _180
  56899 		_180:
  56900 			v24 = v18 - v20 - v22 + int32(8708)
  56901 			if v24 & ^int32(YUV_MASK2) == 0 {
  56902 				v27 = v24 >> int32(YUV_FIX2)
  56903 			} else {
  56904 				if v24 < 0 {
  56905 					v28 = 0
  56906 				} else {
  56907 					v28 = int32(255)
  56908 				}
  56909 				v27 = v28
  56910 			}
  56911 			v25 = v27
  56912 			goto _183
  56913 		_183:
  56914 			v16 = v25
  56915 			goto _174
  56916 		_174:
  56917 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56918 			v31 = v1 * int32(19077) >> int32(8)
  56919 			goto _189
  56920 		_189:
  56921 			v33 = v2 * int32(33050) >> int32(8)
  56922 			goto _191
  56923 		_191:
  56924 			v35 = v31 + v33 - int32(17685)
  56925 			if v35 & ^int32(YUV_MASK2) == 0 {
  56926 				v38 = v35 >> int32(YUV_FIX2)
  56927 			} else {
  56928 				if v35 < 0 {
  56929 					v39 = 0
  56930 				} else {
  56931 					v39 = int32(255)
  56932 				}
  56933 				v38 = v39
  56934 			}
  56935 			v36 = v38
  56936 			goto _194
  56937 		_194:
  56938 			v29 = v36
  56939 			goto _187
  56940 		_187:
  56941 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56942 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  56943 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  56944 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  56945 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(3))
  56946 			v7 = v1 * int32(19077) >> int32(8)
  56947 			goto _204
  56948 		_204:
  56949 			v9 = v3 * int32(26149) >> int32(8)
  56950 			goto _206
  56951 		_206:
  56952 			v11 = v7 + v9 - int32(14234)
  56953 			if v11 & ^int32(YUV_MASK2) == 0 {
  56954 				v14 = v11 >> int32(YUV_FIX2)
  56955 			} else {
  56956 				if v11 < 0 {
  56957 					v15 = 0
  56958 				} else {
  56959 					v15 = int32(255)
  56960 				}
  56961 				v14 = v15
  56962 			}
  56963 			v12 = v14
  56964 			goto _209
  56965 		_209:
  56966 			v5 = v12
  56967 			goto _202
  56968 		_202:
  56969 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56970 			v18 = v1 * int32(19077) >> int32(8)
  56971 			goto _215
  56972 		_215:
  56973 			v20 = v2 * int32(6419) >> int32(8)
  56974 			goto _217
  56975 		_217:
  56976 			v22 = v3 * int32(13320) >> int32(8)
  56977 			goto _219
  56978 		_219:
  56979 			v24 = v18 - v20 - v22 + int32(8708)
  56980 			if v24 & ^int32(YUV_MASK2) == 0 {
  56981 				v27 = v24 >> int32(YUV_FIX2)
  56982 			} else {
  56983 				if v24 < 0 {
  56984 					v28 = 0
  56985 				} else {
  56986 					v28 = int32(255)
  56987 				}
  56988 				v27 = v28
  56989 			}
  56990 			v25 = v27
  56991 			goto _222
  56992 		_222:
  56993 			v16 = v25
  56994 			goto _213
  56995 		_213:
  56996 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56997 			v31 = v1 * int32(19077) >> int32(8)
  56998 			goto _228
  56999 		_228:
  57000 			v33 = v2 * int32(33050) >> int32(8)
  57001 			goto _230
  57002 		_230:
  57003 			v35 = v31 + v33 - int32(17685)
  57004 			if v35 & ^int32(YUV_MASK2) == 0 {
  57005 				v38 = v35 >> int32(YUV_FIX2)
  57006 			} else {
  57007 				if v35 < 0 {
  57008 					v39 = 0
  57009 				} else {
  57010 					v39 = int32(255)
  57011 				}
  57012 				v38 = v39
  57013 			}
  57014 			v36 = v38
  57015 			goto _233
  57016 		_233:
  57017 			v29 = v36
  57018 			goto _226
  57019 		_226:
  57020 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57021 		}
  57022 		tl_uv = t_uv
  57023 		l_uv = uv
  57024 		goto _79
  57025 	_79:
  57026 		;
  57027 		x = x + 1
  57028 	}
  57029 	if !(len1&libc.Int32FromInt32(1) != 0) {
  57030 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57031 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  57032 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  57033 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  57034 		v4 = top_dst + uintptr((len1-int32(1))*int32(3))
  57035 		v7 = v1 * int32(19077) >> int32(8)
  57036 		goto _243
  57037 	_243:
  57038 		v9 = v3 * int32(26149) >> int32(8)
  57039 		goto _245
  57040 	_245:
  57041 		v11 = v7 + v9 - int32(14234)
  57042 		if v11 & ^int32(YUV_MASK2) == 0 {
  57043 			v14 = v11 >> int32(YUV_FIX2)
  57044 		} else {
  57045 			if v11 < 0 {
  57046 				v15 = 0
  57047 			} else {
  57048 				v15 = int32(255)
  57049 			}
  57050 			v14 = v15
  57051 		}
  57052 		v12 = v14
  57053 		goto _248
  57054 	_248:
  57055 		v5 = v12
  57056 		goto _241
  57057 	_241:
  57058 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57059 		v18 = v1 * int32(19077) >> int32(8)
  57060 		goto _254
  57061 	_254:
  57062 		v20 = v2 * int32(6419) >> int32(8)
  57063 		goto _256
  57064 	_256:
  57065 		v22 = v3 * int32(13320) >> int32(8)
  57066 		goto _258
  57067 	_258:
  57068 		v24 = v18 - v20 - v22 + int32(8708)
  57069 		if v24 & ^int32(YUV_MASK2) == 0 {
  57070 			v27 = v24 >> int32(YUV_FIX2)
  57071 		} else {
  57072 			if v24 < 0 {
  57073 				v28 = 0
  57074 			} else {
  57075 				v28 = int32(255)
  57076 			}
  57077 			v27 = v28
  57078 		}
  57079 		v25 = v27
  57080 		goto _261
  57081 	_261:
  57082 		v16 = v25
  57083 		goto _252
  57084 	_252:
  57085 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57086 		v31 = v1 * int32(19077) >> int32(8)
  57087 		goto _267
  57088 	_267:
  57089 		v33 = v2 * int32(33050) >> int32(8)
  57090 		goto _269
  57091 	_269:
  57092 		v35 = v31 + v33 - int32(17685)
  57093 		if v35 & ^int32(YUV_MASK2) == 0 {
  57094 			v38 = v35 >> int32(YUV_FIX2)
  57095 		} else {
  57096 			if v35 < 0 {
  57097 				v39 = 0
  57098 			} else {
  57099 				v39 = int32(255)
  57100 			}
  57101 			v38 = v39
  57102 		}
  57103 		v36 = v38
  57104 		goto _272
  57105 	_272:
  57106 		v29 = v36
  57107 		goto _265
  57108 	_265:
  57109 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57110 		if bottom_y != libc.UintptrFromInt32(0) {
  57111 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57112 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  57113 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  57114 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  57115 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(3))
  57116 			v7 = v1 * int32(19077) >> int32(8)
  57117 			goto _282
  57118 		_282:
  57119 			v9 = v3 * int32(26149) >> int32(8)
  57120 			goto _284
  57121 		_284:
  57122 			v11 = v7 + v9 - int32(14234)
  57123 			if v11 & ^int32(YUV_MASK2) == 0 {
  57124 				v14 = v11 >> int32(YUV_FIX2)
  57125 			} else {
  57126 				if v11 < 0 {
  57127 					v15 = 0
  57128 				} else {
  57129 					v15 = int32(255)
  57130 				}
  57131 				v14 = v15
  57132 			}
  57133 			v12 = v14
  57134 			goto _287
  57135 		_287:
  57136 			v5 = v12
  57137 			goto _280
  57138 		_280:
  57139 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57140 			v18 = v1 * int32(19077) >> int32(8)
  57141 			goto _293
  57142 		_293:
  57143 			v20 = v2 * int32(6419) >> int32(8)
  57144 			goto _295
  57145 		_295:
  57146 			v22 = v3 * int32(13320) >> int32(8)
  57147 			goto _297
  57148 		_297:
  57149 			v24 = v18 - v20 - v22 + int32(8708)
  57150 			if v24 & ^int32(YUV_MASK2) == 0 {
  57151 				v27 = v24 >> int32(YUV_FIX2)
  57152 			} else {
  57153 				if v24 < 0 {
  57154 					v28 = 0
  57155 				} else {
  57156 					v28 = int32(255)
  57157 				}
  57158 				v27 = v28
  57159 			}
  57160 			v25 = v27
  57161 			goto _300
  57162 		_300:
  57163 			v16 = v25
  57164 			goto _291
  57165 		_291:
  57166 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57167 			v31 = v1 * int32(19077) >> int32(8)
  57168 			goto _306
  57169 		_306:
  57170 			v33 = v2 * int32(33050) >> int32(8)
  57171 			goto _308
  57172 		_308:
  57173 			v35 = v31 + v33 - int32(17685)
  57174 			if v35 & ^int32(YUV_MASK2) == 0 {
  57175 				v38 = v35 >> int32(YUV_FIX2)
  57176 			} else {
  57177 				if v35 < 0 {
  57178 					v39 = 0
  57179 				} else {
  57180 					v39 = int32(255)
  57181 				}
  57182 				v38 = v39
  57183 			}
  57184 			v36 = v38
  57185 			goto _311
  57186 		_311:
  57187 			v29 = v36
  57188 			goto _304
  57189 		_304:
  57190 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57191 		}
  57192 	}
  57193 }
  57194 
  57195 func UpsampleBgrLinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  57196 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  57197 	var last_pixel_pair, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v5, v7, v9 int32
  57198 	var v4 uintptr
  57199 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, diag_03, diag_12, l_uv, last_pixel_pair, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v5, v7, v9
  57200 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  57201 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  57202 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  57203 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57204 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  57205 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  57206 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  57207 	v4 = top_dst
  57208 	v7 = v1 * int32(19077) >> int32(8)
  57209 	goto _8
  57210 _8:
  57211 	v9 = v2 * int32(33050) >> int32(8)
  57212 	goto _10
  57213 _10:
  57214 	v11 = v7 + v9 - int32(17685)
  57215 	if v11 & ^int32(YUV_MASK2) == 0 {
  57216 		v14 = v11 >> int32(YUV_FIX2)
  57217 	} else {
  57218 		if v11 < 0 {
  57219 			v15 = 0
  57220 		} else {
  57221 			v15 = int32(255)
  57222 		}
  57223 		v14 = v15
  57224 	}
  57225 	v12 = v14
  57226 	goto _13
  57227 _13:
  57228 	v5 = v12
  57229 	goto _6
  57230 _6:
  57231 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57232 	v18 = v1 * int32(19077) >> int32(8)
  57233 	goto _19
  57234 _19:
  57235 	v20 = v2 * int32(6419) >> int32(8)
  57236 	goto _21
  57237 _21:
  57238 	v22 = v3 * int32(13320) >> int32(8)
  57239 	goto _23
  57240 _23:
  57241 	v24 = v18 - v20 - v22 + int32(8708)
  57242 	if v24 & ^int32(YUV_MASK2) == 0 {
  57243 		v27 = v24 >> int32(YUV_FIX2)
  57244 	} else {
  57245 		if v24 < 0 {
  57246 			v28 = 0
  57247 		} else {
  57248 			v28 = int32(255)
  57249 		}
  57250 		v27 = v28
  57251 	}
  57252 	v25 = v27
  57253 	goto _26
  57254 _26:
  57255 	v16 = v25
  57256 	goto _17
  57257 _17:
  57258 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57259 	v31 = v1 * int32(19077) >> int32(8)
  57260 	goto _32
  57261 _32:
  57262 	v33 = v3 * int32(26149) >> int32(8)
  57263 	goto _34
  57264 _34:
  57265 	v35 = v31 + v33 - int32(14234)
  57266 	if v35 & ^int32(YUV_MASK2) == 0 {
  57267 		v38 = v35 >> int32(YUV_FIX2)
  57268 	} else {
  57269 		if v35 < 0 {
  57270 			v39 = 0
  57271 		} else {
  57272 			v39 = int32(255)
  57273 		}
  57274 		v38 = v39
  57275 	}
  57276 	v36 = v38
  57277 	goto _37
  57278 _37:
  57279 	v29 = v36
  57280 	goto _30
  57281 _30:
  57282 	**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57283 	if bottom_y != libc.UintptrFromInt32(0) {
  57284 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57285 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  57286 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  57287 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  57288 		v4 = bottom_dst
  57289 		v7 = v1 * int32(19077) >> int32(8)
  57290 		goto _47
  57291 	_47:
  57292 		v9 = v2 * int32(33050) >> int32(8)
  57293 		goto _49
  57294 	_49:
  57295 		v11 = v7 + v9 - int32(17685)
  57296 		if v11 & ^int32(YUV_MASK2) == 0 {
  57297 			v14 = v11 >> int32(YUV_FIX2)
  57298 		} else {
  57299 			if v11 < 0 {
  57300 				v15 = 0
  57301 			} else {
  57302 				v15 = int32(255)
  57303 			}
  57304 			v14 = v15
  57305 		}
  57306 		v12 = v14
  57307 		goto _52
  57308 	_52:
  57309 		v5 = v12
  57310 		goto _45
  57311 	_45:
  57312 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57313 		v18 = v1 * int32(19077) >> int32(8)
  57314 		goto _58
  57315 	_58:
  57316 		v20 = v2 * int32(6419) >> int32(8)
  57317 		goto _60
  57318 	_60:
  57319 		v22 = v3 * int32(13320) >> int32(8)
  57320 		goto _62
  57321 	_62:
  57322 		v24 = v18 - v20 - v22 + int32(8708)
  57323 		if v24 & ^int32(YUV_MASK2) == 0 {
  57324 			v27 = v24 >> int32(YUV_FIX2)
  57325 		} else {
  57326 			if v24 < 0 {
  57327 				v28 = 0
  57328 			} else {
  57329 				v28 = int32(255)
  57330 			}
  57331 			v27 = v28
  57332 		}
  57333 		v25 = v27
  57334 		goto _65
  57335 	_65:
  57336 		v16 = v25
  57337 		goto _56
  57338 	_56:
  57339 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57340 		v31 = v1 * int32(19077) >> int32(8)
  57341 		goto _71
  57342 	_71:
  57343 		v33 = v3 * int32(26149) >> int32(8)
  57344 		goto _73
  57345 	_73:
  57346 		v35 = v31 + v33 - int32(14234)
  57347 		if v35 & ^int32(YUV_MASK2) == 0 {
  57348 			v38 = v35 >> int32(YUV_FIX2)
  57349 		} else {
  57350 			if v35 < 0 {
  57351 				v39 = 0
  57352 			} else {
  57353 				v39 = int32(255)
  57354 			}
  57355 			v38 = v39
  57356 		}
  57357 		v36 = v38
  57358 		goto _76
  57359 	_76:
  57360 		v29 = v36
  57361 		goto _69
  57362 	_69:
  57363 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57364 	}
  57365 	x = int32(1)
  57366 	for {
  57367 		if !(x <= last_pixel_pair) {
  57368 			break
  57369 		}
  57370 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  57371 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  57372 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  57373 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  57374 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  57375 		uv02 = (diag_12 + tl_uv) >> int32(1)
  57376 		uv1 = (diag_03 + t_uv) >> int32(1)
  57377 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  57378 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  57379 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  57380 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  57381 		v7 = v1 * int32(19077) >> int32(8)
  57382 		goto _87
  57383 	_87:
  57384 		v9 = v2 * int32(33050) >> int32(8)
  57385 		goto _89
  57386 	_89:
  57387 		v11 = v7 + v9 - int32(17685)
  57388 		if v11 & ^int32(YUV_MASK2) == 0 {
  57389 			v14 = v11 >> int32(YUV_FIX2)
  57390 		} else {
  57391 			if v11 < 0 {
  57392 				v15 = 0
  57393 			} else {
  57394 				v15 = int32(255)
  57395 			}
  57396 			v14 = v15
  57397 		}
  57398 		v12 = v14
  57399 		goto _92
  57400 	_92:
  57401 		v5 = v12
  57402 		goto _85
  57403 	_85:
  57404 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57405 		v18 = v1 * int32(19077) >> int32(8)
  57406 		goto _98
  57407 	_98:
  57408 		v20 = v2 * int32(6419) >> int32(8)
  57409 		goto _100
  57410 	_100:
  57411 		v22 = v3 * int32(13320) >> int32(8)
  57412 		goto _102
  57413 	_102:
  57414 		v24 = v18 - v20 - v22 + int32(8708)
  57415 		if v24 & ^int32(YUV_MASK2) == 0 {
  57416 			v27 = v24 >> int32(YUV_FIX2)
  57417 		} else {
  57418 			if v24 < 0 {
  57419 				v28 = 0
  57420 			} else {
  57421 				v28 = int32(255)
  57422 			}
  57423 			v27 = v28
  57424 		}
  57425 		v25 = v27
  57426 		goto _105
  57427 	_105:
  57428 		v16 = v25
  57429 		goto _96
  57430 	_96:
  57431 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57432 		v31 = v1 * int32(19077) >> int32(8)
  57433 		goto _111
  57434 	_111:
  57435 		v33 = v3 * int32(26149) >> int32(8)
  57436 		goto _113
  57437 	_113:
  57438 		v35 = v31 + v33 - int32(14234)
  57439 		if v35 & ^int32(YUV_MASK2) == 0 {
  57440 			v38 = v35 >> int32(YUV_FIX2)
  57441 		} else {
  57442 			if v35 < 0 {
  57443 				v39 = 0
  57444 			} else {
  57445 				v39 = int32(255)
  57446 			}
  57447 			v38 = v39
  57448 		}
  57449 		v36 = v38
  57450 		goto _116
  57451 	_116:
  57452 		v29 = v36
  57453 		goto _109
  57454 	_109:
  57455 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57456 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  57457 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  57458 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  57459 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(3))
  57460 		v7 = v1 * int32(19077) >> int32(8)
  57461 		goto _126
  57462 	_126:
  57463 		v9 = v2 * int32(33050) >> int32(8)
  57464 		goto _128
  57465 	_128:
  57466 		v11 = v7 + v9 - int32(17685)
  57467 		if v11 & ^int32(YUV_MASK2) == 0 {
  57468 			v14 = v11 >> int32(YUV_FIX2)
  57469 		} else {
  57470 			if v11 < 0 {
  57471 				v15 = 0
  57472 			} else {
  57473 				v15 = int32(255)
  57474 			}
  57475 			v14 = v15
  57476 		}
  57477 		v12 = v14
  57478 		goto _131
  57479 	_131:
  57480 		v5 = v12
  57481 		goto _124
  57482 	_124:
  57483 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57484 		v18 = v1 * int32(19077) >> int32(8)
  57485 		goto _137
  57486 	_137:
  57487 		v20 = v2 * int32(6419) >> int32(8)
  57488 		goto _139
  57489 	_139:
  57490 		v22 = v3 * int32(13320) >> int32(8)
  57491 		goto _141
  57492 	_141:
  57493 		v24 = v18 - v20 - v22 + int32(8708)
  57494 		if v24 & ^int32(YUV_MASK2) == 0 {
  57495 			v27 = v24 >> int32(YUV_FIX2)
  57496 		} else {
  57497 			if v24 < 0 {
  57498 				v28 = 0
  57499 			} else {
  57500 				v28 = int32(255)
  57501 			}
  57502 			v27 = v28
  57503 		}
  57504 		v25 = v27
  57505 		goto _144
  57506 	_144:
  57507 		v16 = v25
  57508 		goto _135
  57509 	_135:
  57510 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57511 		v31 = v1 * int32(19077) >> int32(8)
  57512 		goto _150
  57513 	_150:
  57514 		v33 = v3 * int32(26149) >> int32(8)
  57515 		goto _152
  57516 	_152:
  57517 		v35 = v31 + v33 - int32(14234)
  57518 		if v35 & ^int32(YUV_MASK2) == 0 {
  57519 			v38 = v35 >> int32(YUV_FIX2)
  57520 		} else {
  57521 			if v35 < 0 {
  57522 				v39 = 0
  57523 			} else {
  57524 				v39 = int32(255)
  57525 			}
  57526 			v38 = v39
  57527 		}
  57528 		v36 = v38
  57529 		goto _155
  57530 	_155:
  57531 		v29 = v36
  57532 		goto _148
  57533 	_148:
  57534 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57535 		if bottom_y != libc.UintptrFromInt32(0) {
  57536 			uv03 = (diag_03 + l_uv) >> int32(1)
  57537 			uv11 = (diag_12 + uv) >> int32(1)
  57538 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  57539 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  57540 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  57541 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  57542 			v7 = v1 * int32(19077) >> int32(8)
  57543 			goto _165
  57544 		_165:
  57545 			v9 = v2 * int32(33050) >> int32(8)
  57546 			goto _167
  57547 		_167:
  57548 			v11 = v7 + v9 - int32(17685)
  57549 			if v11 & ^int32(YUV_MASK2) == 0 {
  57550 				v14 = v11 >> int32(YUV_FIX2)
  57551 			} else {
  57552 				if v11 < 0 {
  57553 					v15 = 0
  57554 				} else {
  57555 					v15 = int32(255)
  57556 				}
  57557 				v14 = v15
  57558 			}
  57559 			v12 = v14
  57560 			goto _170
  57561 		_170:
  57562 			v5 = v12
  57563 			goto _163
  57564 		_163:
  57565 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57566 			v18 = v1 * int32(19077) >> int32(8)
  57567 			goto _176
  57568 		_176:
  57569 			v20 = v2 * int32(6419) >> int32(8)
  57570 			goto _178
  57571 		_178:
  57572 			v22 = v3 * int32(13320) >> int32(8)
  57573 			goto _180
  57574 		_180:
  57575 			v24 = v18 - v20 - v22 + int32(8708)
  57576 			if v24 & ^int32(YUV_MASK2) == 0 {
  57577 				v27 = v24 >> int32(YUV_FIX2)
  57578 			} else {
  57579 				if v24 < 0 {
  57580 					v28 = 0
  57581 				} else {
  57582 					v28 = int32(255)
  57583 				}
  57584 				v27 = v28
  57585 			}
  57586 			v25 = v27
  57587 			goto _183
  57588 		_183:
  57589 			v16 = v25
  57590 			goto _174
  57591 		_174:
  57592 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57593 			v31 = v1 * int32(19077) >> int32(8)
  57594 			goto _189
  57595 		_189:
  57596 			v33 = v3 * int32(26149) >> int32(8)
  57597 			goto _191
  57598 		_191:
  57599 			v35 = v31 + v33 - int32(14234)
  57600 			if v35 & ^int32(YUV_MASK2) == 0 {
  57601 				v38 = v35 >> int32(YUV_FIX2)
  57602 			} else {
  57603 				if v35 < 0 {
  57604 					v39 = 0
  57605 				} else {
  57606 					v39 = int32(255)
  57607 				}
  57608 				v38 = v39
  57609 			}
  57610 			v36 = v38
  57611 			goto _194
  57612 		_194:
  57613 			v29 = v36
  57614 			goto _187
  57615 		_187:
  57616 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57617 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  57618 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  57619 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  57620 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(3))
  57621 			v7 = v1 * int32(19077) >> int32(8)
  57622 			goto _204
  57623 		_204:
  57624 			v9 = v2 * int32(33050) >> int32(8)
  57625 			goto _206
  57626 		_206:
  57627 			v11 = v7 + v9 - int32(17685)
  57628 			if v11 & ^int32(YUV_MASK2) == 0 {
  57629 				v14 = v11 >> int32(YUV_FIX2)
  57630 			} else {
  57631 				if v11 < 0 {
  57632 					v15 = 0
  57633 				} else {
  57634 					v15 = int32(255)
  57635 				}
  57636 				v14 = v15
  57637 			}
  57638 			v12 = v14
  57639 			goto _209
  57640 		_209:
  57641 			v5 = v12
  57642 			goto _202
  57643 		_202:
  57644 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57645 			v18 = v1 * int32(19077) >> int32(8)
  57646 			goto _215
  57647 		_215:
  57648 			v20 = v2 * int32(6419) >> int32(8)
  57649 			goto _217
  57650 		_217:
  57651 			v22 = v3 * int32(13320) >> int32(8)
  57652 			goto _219
  57653 		_219:
  57654 			v24 = v18 - v20 - v22 + int32(8708)
  57655 			if v24 & ^int32(YUV_MASK2) == 0 {
  57656 				v27 = v24 >> int32(YUV_FIX2)
  57657 			} else {
  57658 				if v24 < 0 {
  57659 					v28 = 0
  57660 				} else {
  57661 					v28 = int32(255)
  57662 				}
  57663 				v27 = v28
  57664 			}
  57665 			v25 = v27
  57666 			goto _222
  57667 		_222:
  57668 			v16 = v25
  57669 			goto _213
  57670 		_213:
  57671 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57672 			v31 = v1 * int32(19077) >> int32(8)
  57673 			goto _228
  57674 		_228:
  57675 			v33 = v3 * int32(26149) >> int32(8)
  57676 			goto _230
  57677 		_230:
  57678 			v35 = v31 + v33 - int32(14234)
  57679 			if v35 & ^int32(YUV_MASK2) == 0 {
  57680 				v38 = v35 >> int32(YUV_FIX2)
  57681 			} else {
  57682 				if v35 < 0 {
  57683 					v39 = 0
  57684 				} else {
  57685 					v39 = int32(255)
  57686 				}
  57687 				v38 = v39
  57688 			}
  57689 			v36 = v38
  57690 			goto _233
  57691 		_233:
  57692 			v29 = v36
  57693 			goto _226
  57694 		_226:
  57695 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57696 		}
  57697 		tl_uv = t_uv
  57698 		l_uv = uv
  57699 		goto _79
  57700 	_79:
  57701 		;
  57702 		x = x + 1
  57703 	}
  57704 	if !(len1&libc.Int32FromInt32(1) != 0) {
  57705 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57706 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  57707 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  57708 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  57709 		v4 = top_dst + uintptr((len1-int32(1))*int32(3))
  57710 		v7 = v1 * int32(19077) >> int32(8)
  57711 		goto _243
  57712 	_243:
  57713 		v9 = v2 * int32(33050) >> int32(8)
  57714 		goto _245
  57715 	_245:
  57716 		v11 = v7 + v9 - int32(17685)
  57717 		if v11 & ^int32(YUV_MASK2) == 0 {
  57718 			v14 = v11 >> int32(YUV_FIX2)
  57719 		} else {
  57720 			if v11 < 0 {
  57721 				v15 = 0
  57722 			} else {
  57723 				v15 = int32(255)
  57724 			}
  57725 			v14 = v15
  57726 		}
  57727 		v12 = v14
  57728 		goto _248
  57729 	_248:
  57730 		v5 = v12
  57731 		goto _241
  57732 	_241:
  57733 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57734 		v18 = v1 * int32(19077) >> int32(8)
  57735 		goto _254
  57736 	_254:
  57737 		v20 = v2 * int32(6419) >> int32(8)
  57738 		goto _256
  57739 	_256:
  57740 		v22 = v3 * int32(13320) >> int32(8)
  57741 		goto _258
  57742 	_258:
  57743 		v24 = v18 - v20 - v22 + int32(8708)
  57744 		if v24 & ^int32(YUV_MASK2) == 0 {
  57745 			v27 = v24 >> int32(YUV_FIX2)
  57746 		} else {
  57747 			if v24 < 0 {
  57748 				v28 = 0
  57749 			} else {
  57750 				v28 = int32(255)
  57751 			}
  57752 			v27 = v28
  57753 		}
  57754 		v25 = v27
  57755 		goto _261
  57756 	_261:
  57757 		v16 = v25
  57758 		goto _252
  57759 	_252:
  57760 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57761 		v31 = v1 * int32(19077) >> int32(8)
  57762 		goto _267
  57763 	_267:
  57764 		v33 = v3 * int32(26149) >> int32(8)
  57765 		goto _269
  57766 	_269:
  57767 		v35 = v31 + v33 - int32(14234)
  57768 		if v35 & ^int32(YUV_MASK2) == 0 {
  57769 			v38 = v35 >> int32(YUV_FIX2)
  57770 		} else {
  57771 			if v35 < 0 {
  57772 				v39 = 0
  57773 			} else {
  57774 				v39 = int32(255)
  57775 			}
  57776 			v38 = v39
  57777 		}
  57778 		v36 = v38
  57779 		goto _272
  57780 	_272:
  57781 		v29 = v36
  57782 		goto _265
  57783 	_265:
  57784 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57785 		if bottom_y != libc.UintptrFromInt32(0) {
  57786 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57787 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  57788 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  57789 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  57790 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(3))
  57791 			v7 = v1 * int32(19077) >> int32(8)
  57792 			goto _282
  57793 		_282:
  57794 			v9 = v2 * int32(33050) >> int32(8)
  57795 			goto _284
  57796 		_284:
  57797 			v11 = v7 + v9 - int32(17685)
  57798 			if v11 & ^int32(YUV_MASK2) == 0 {
  57799 				v14 = v11 >> int32(YUV_FIX2)
  57800 			} else {
  57801 				if v11 < 0 {
  57802 					v15 = 0
  57803 				} else {
  57804 					v15 = int32(255)
  57805 				}
  57806 				v14 = v15
  57807 			}
  57808 			v12 = v14
  57809 			goto _287
  57810 		_287:
  57811 			v5 = v12
  57812 			goto _280
  57813 		_280:
  57814 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57815 			v18 = v1 * int32(19077) >> int32(8)
  57816 			goto _293
  57817 		_293:
  57818 			v20 = v2 * int32(6419) >> int32(8)
  57819 			goto _295
  57820 		_295:
  57821 			v22 = v3 * int32(13320) >> int32(8)
  57822 			goto _297
  57823 		_297:
  57824 			v24 = v18 - v20 - v22 + int32(8708)
  57825 			if v24 & ^int32(YUV_MASK2) == 0 {
  57826 				v27 = v24 >> int32(YUV_FIX2)
  57827 			} else {
  57828 				if v24 < 0 {
  57829 					v28 = 0
  57830 				} else {
  57831 					v28 = int32(255)
  57832 				}
  57833 				v27 = v28
  57834 			}
  57835 			v25 = v27
  57836 			goto _300
  57837 		_300:
  57838 			v16 = v25
  57839 			goto _291
  57840 		_291:
  57841 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57842 			v31 = v1 * int32(19077) >> int32(8)
  57843 			goto _306
  57844 		_306:
  57845 			v33 = v3 * int32(26149) >> int32(8)
  57846 			goto _308
  57847 		_308:
  57848 			v35 = v31 + v33 - int32(14234)
  57849 			if v35 & ^int32(YUV_MASK2) == 0 {
  57850 				v38 = v35 >> int32(YUV_FIX2)
  57851 			} else {
  57852 				if v35 < 0 {
  57853 					v39 = 0
  57854 				} else {
  57855 					v39 = int32(255)
  57856 				}
  57857 				v38 = v39
  57858 			}
  57859 			v36 = v38
  57860 			goto _311
  57861 		_311:
  57862 			v29 = v36
  57863 			goto _304
  57864 		_304:
  57865 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57866 		}
  57867 	}
  57868 }
  57869 
  57870 func UpsampleRgba4444LinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  57871 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  57872 	var b, ba, g, last_pixel_pair, r, rg, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v5, v7, v9 int32
  57873 	var v4 uintptr
  57874 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, b, ba, diag_03, diag_12, g, l_uv, last_pixel_pair, r, rg, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v5, v7, v9
  57875 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  57876 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  57877 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  57878 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57879 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  57880 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  57881 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  57882 	v4 = top_dst
  57883 	v7 = v1 * int32(19077) >> int32(8)
  57884 	goto _8
  57885 _8:
  57886 	v9 = v3 * int32(26149) >> int32(8)
  57887 	goto _10
  57888 _10:
  57889 	v11 = v7 + v9 - int32(14234)
  57890 	if v11 & ^int32(YUV_MASK2) == 0 {
  57891 		v14 = v11 >> int32(YUV_FIX2)
  57892 	} else {
  57893 		if v11 < 0 {
  57894 			v15 = 0
  57895 		} else {
  57896 			v15 = int32(255)
  57897 		}
  57898 		v14 = v15
  57899 	}
  57900 	v12 = v14
  57901 	goto _13
  57902 _13:
  57903 	v5 = v12
  57904 	goto _6
  57905 _6:
  57906 	r = v5
  57907 	v18 = v1 * int32(19077) >> int32(8)
  57908 	goto _19
  57909 _19:
  57910 	v20 = v2 * int32(6419) >> int32(8)
  57911 	goto _21
  57912 _21:
  57913 	v22 = v3 * int32(13320) >> int32(8)
  57914 	goto _23
  57915 _23:
  57916 	v24 = v18 - v20 - v22 + int32(8708)
  57917 	if v24 & ^int32(YUV_MASK2) == 0 {
  57918 		v27 = v24 >> int32(YUV_FIX2)
  57919 	} else {
  57920 		if v24 < 0 {
  57921 			v28 = 0
  57922 		} else {
  57923 			v28 = int32(255)
  57924 		}
  57925 		v27 = v28
  57926 	}
  57927 	v25 = v27
  57928 	goto _26
  57929 _26:
  57930 	v16 = v25
  57931 	goto _17
  57932 _17:
  57933 	g = v16
  57934 	v31 = v1 * int32(19077) >> int32(8)
  57935 	goto _32
  57936 _32:
  57937 	v33 = v2 * int32(33050) >> int32(8)
  57938 	goto _34
  57939 _34:
  57940 	v35 = v31 + v33 - int32(17685)
  57941 	if v35 & ^int32(YUV_MASK2) == 0 {
  57942 		v38 = v35 >> int32(YUV_FIX2)
  57943 	} else {
  57944 		if v35 < 0 {
  57945 			v39 = 0
  57946 		} else {
  57947 			v39 = int32(255)
  57948 		}
  57949 		v38 = v39
  57950 	}
  57951 	v36 = v38
  57952 	goto _37
  57953 _37:
  57954 	v29 = v36
  57955 	goto _30
  57956 _30:
  57957 	b = v29
  57958 	rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  57959 	ba = b&int32(0xf0) | int32(0x0f)
  57960 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  57961 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  57962 	if bottom_y != libc.UintptrFromInt32(0) {
  57963 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57964 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  57965 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  57966 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  57967 		v4 = bottom_dst
  57968 		v7 = v1 * int32(19077) >> int32(8)
  57969 		goto _47
  57970 	_47:
  57971 		v9 = v3 * int32(26149) >> int32(8)
  57972 		goto _49
  57973 	_49:
  57974 		v11 = v7 + v9 - int32(14234)
  57975 		if v11 & ^int32(YUV_MASK2) == 0 {
  57976 			v14 = v11 >> int32(YUV_FIX2)
  57977 		} else {
  57978 			if v11 < 0 {
  57979 				v15 = 0
  57980 			} else {
  57981 				v15 = int32(255)
  57982 			}
  57983 			v14 = v15
  57984 		}
  57985 		v12 = v14
  57986 		goto _52
  57987 	_52:
  57988 		v5 = v12
  57989 		goto _45
  57990 	_45:
  57991 		r = v5
  57992 		v18 = v1 * int32(19077) >> int32(8)
  57993 		goto _58
  57994 	_58:
  57995 		v20 = v2 * int32(6419) >> int32(8)
  57996 		goto _60
  57997 	_60:
  57998 		v22 = v3 * int32(13320) >> int32(8)
  57999 		goto _62
  58000 	_62:
  58001 		v24 = v18 - v20 - v22 + int32(8708)
  58002 		if v24 & ^int32(YUV_MASK2) == 0 {
  58003 			v27 = v24 >> int32(YUV_FIX2)
  58004 		} else {
  58005 			if v24 < 0 {
  58006 				v28 = 0
  58007 			} else {
  58008 				v28 = int32(255)
  58009 			}
  58010 			v27 = v28
  58011 		}
  58012 		v25 = v27
  58013 		goto _65
  58014 	_65:
  58015 		v16 = v25
  58016 		goto _56
  58017 	_56:
  58018 		g = v16
  58019 		v31 = v1 * int32(19077) >> int32(8)
  58020 		goto _71
  58021 	_71:
  58022 		v33 = v2 * int32(33050) >> int32(8)
  58023 		goto _73
  58024 	_73:
  58025 		v35 = v31 + v33 - int32(17685)
  58026 		if v35 & ^int32(YUV_MASK2) == 0 {
  58027 			v38 = v35 >> int32(YUV_FIX2)
  58028 		} else {
  58029 			if v35 < 0 {
  58030 				v39 = 0
  58031 			} else {
  58032 				v39 = int32(255)
  58033 			}
  58034 			v38 = v39
  58035 		}
  58036 		v36 = v38
  58037 		goto _76
  58038 	_76:
  58039 		v29 = v36
  58040 		goto _69
  58041 	_69:
  58042 		b = v29
  58043 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58044 		ba = b&int32(0xf0) | int32(0x0f)
  58045 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58046 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58047 	}
  58048 	x = int32(1)
  58049 	for {
  58050 		if !(x <= last_pixel_pair) {
  58051 			break
  58052 		}
  58053 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  58054 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  58055 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  58056 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  58057 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  58058 		uv02 = (diag_12 + tl_uv) >> int32(1)
  58059 		uv1 = (diag_03 + t_uv) >> int32(1)
  58060 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  58061 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  58062 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  58063 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58064 		v7 = v1 * int32(19077) >> int32(8)
  58065 		goto _87
  58066 	_87:
  58067 		v9 = v3 * int32(26149) >> int32(8)
  58068 		goto _89
  58069 	_89:
  58070 		v11 = v7 + v9 - int32(14234)
  58071 		if v11 & ^int32(YUV_MASK2) == 0 {
  58072 			v14 = v11 >> int32(YUV_FIX2)
  58073 		} else {
  58074 			if v11 < 0 {
  58075 				v15 = 0
  58076 			} else {
  58077 				v15 = int32(255)
  58078 			}
  58079 			v14 = v15
  58080 		}
  58081 		v12 = v14
  58082 		goto _92
  58083 	_92:
  58084 		v5 = v12
  58085 		goto _85
  58086 	_85:
  58087 		r = v5
  58088 		v18 = v1 * int32(19077) >> int32(8)
  58089 		goto _98
  58090 	_98:
  58091 		v20 = v2 * int32(6419) >> int32(8)
  58092 		goto _100
  58093 	_100:
  58094 		v22 = v3 * int32(13320) >> int32(8)
  58095 		goto _102
  58096 	_102:
  58097 		v24 = v18 - v20 - v22 + int32(8708)
  58098 		if v24 & ^int32(YUV_MASK2) == 0 {
  58099 			v27 = v24 >> int32(YUV_FIX2)
  58100 		} else {
  58101 			if v24 < 0 {
  58102 				v28 = 0
  58103 			} else {
  58104 				v28 = int32(255)
  58105 			}
  58106 			v27 = v28
  58107 		}
  58108 		v25 = v27
  58109 		goto _105
  58110 	_105:
  58111 		v16 = v25
  58112 		goto _96
  58113 	_96:
  58114 		g = v16
  58115 		v31 = v1 * int32(19077) >> int32(8)
  58116 		goto _111
  58117 	_111:
  58118 		v33 = v2 * int32(33050) >> int32(8)
  58119 		goto _113
  58120 	_113:
  58121 		v35 = v31 + v33 - int32(17685)
  58122 		if v35 & ^int32(YUV_MASK2) == 0 {
  58123 			v38 = v35 >> int32(YUV_FIX2)
  58124 		} else {
  58125 			if v35 < 0 {
  58126 				v39 = 0
  58127 			} else {
  58128 				v39 = int32(255)
  58129 			}
  58130 			v38 = v39
  58131 		}
  58132 		v36 = v38
  58133 		goto _116
  58134 	_116:
  58135 		v29 = v36
  58136 		goto _109
  58137 	_109:
  58138 		b = v29
  58139 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58140 		ba = b&int32(0xf0) | int32(0x0f)
  58141 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58142 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58143 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  58144 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  58145 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  58146 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(2))
  58147 		v7 = v1 * int32(19077) >> int32(8)
  58148 		goto _126
  58149 	_126:
  58150 		v9 = v3 * int32(26149) >> int32(8)
  58151 		goto _128
  58152 	_128:
  58153 		v11 = v7 + v9 - int32(14234)
  58154 		if v11 & ^int32(YUV_MASK2) == 0 {
  58155 			v14 = v11 >> int32(YUV_FIX2)
  58156 		} else {
  58157 			if v11 < 0 {
  58158 				v15 = 0
  58159 			} else {
  58160 				v15 = int32(255)
  58161 			}
  58162 			v14 = v15
  58163 		}
  58164 		v12 = v14
  58165 		goto _131
  58166 	_131:
  58167 		v5 = v12
  58168 		goto _124
  58169 	_124:
  58170 		r = v5
  58171 		v18 = v1 * int32(19077) >> int32(8)
  58172 		goto _137
  58173 	_137:
  58174 		v20 = v2 * int32(6419) >> int32(8)
  58175 		goto _139
  58176 	_139:
  58177 		v22 = v3 * int32(13320) >> int32(8)
  58178 		goto _141
  58179 	_141:
  58180 		v24 = v18 - v20 - v22 + int32(8708)
  58181 		if v24 & ^int32(YUV_MASK2) == 0 {
  58182 			v27 = v24 >> int32(YUV_FIX2)
  58183 		} else {
  58184 			if v24 < 0 {
  58185 				v28 = 0
  58186 			} else {
  58187 				v28 = int32(255)
  58188 			}
  58189 			v27 = v28
  58190 		}
  58191 		v25 = v27
  58192 		goto _144
  58193 	_144:
  58194 		v16 = v25
  58195 		goto _135
  58196 	_135:
  58197 		g = v16
  58198 		v31 = v1 * int32(19077) >> int32(8)
  58199 		goto _150
  58200 	_150:
  58201 		v33 = v2 * int32(33050) >> int32(8)
  58202 		goto _152
  58203 	_152:
  58204 		v35 = v31 + v33 - int32(17685)
  58205 		if v35 & ^int32(YUV_MASK2) == 0 {
  58206 			v38 = v35 >> int32(YUV_FIX2)
  58207 		} else {
  58208 			if v35 < 0 {
  58209 				v39 = 0
  58210 			} else {
  58211 				v39 = int32(255)
  58212 			}
  58213 			v38 = v39
  58214 		}
  58215 		v36 = v38
  58216 		goto _155
  58217 	_155:
  58218 		v29 = v36
  58219 		goto _148
  58220 	_148:
  58221 		b = v29
  58222 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58223 		ba = b&int32(0xf0) | int32(0x0f)
  58224 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58225 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58226 		if bottom_y != libc.UintptrFromInt32(0) {
  58227 			uv03 = (diag_03 + l_uv) >> int32(1)
  58228 			uv11 = (diag_12 + uv) >> int32(1)
  58229 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  58230 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  58231 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  58232 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58233 			v7 = v1 * int32(19077) >> int32(8)
  58234 			goto _165
  58235 		_165:
  58236 			v9 = v3 * int32(26149) >> int32(8)
  58237 			goto _167
  58238 		_167:
  58239 			v11 = v7 + v9 - int32(14234)
  58240 			if v11 & ^int32(YUV_MASK2) == 0 {
  58241 				v14 = v11 >> int32(YUV_FIX2)
  58242 			} else {
  58243 				if v11 < 0 {
  58244 					v15 = 0
  58245 				} else {
  58246 					v15 = int32(255)
  58247 				}
  58248 				v14 = v15
  58249 			}
  58250 			v12 = v14
  58251 			goto _170
  58252 		_170:
  58253 			v5 = v12
  58254 			goto _163
  58255 		_163:
  58256 			r = v5
  58257 			v18 = v1 * int32(19077) >> int32(8)
  58258 			goto _176
  58259 		_176:
  58260 			v20 = v2 * int32(6419) >> int32(8)
  58261 			goto _178
  58262 		_178:
  58263 			v22 = v3 * int32(13320) >> int32(8)
  58264 			goto _180
  58265 		_180:
  58266 			v24 = v18 - v20 - v22 + int32(8708)
  58267 			if v24 & ^int32(YUV_MASK2) == 0 {
  58268 				v27 = v24 >> int32(YUV_FIX2)
  58269 			} else {
  58270 				if v24 < 0 {
  58271 					v28 = 0
  58272 				} else {
  58273 					v28 = int32(255)
  58274 				}
  58275 				v27 = v28
  58276 			}
  58277 			v25 = v27
  58278 			goto _183
  58279 		_183:
  58280 			v16 = v25
  58281 			goto _174
  58282 		_174:
  58283 			g = v16
  58284 			v31 = v1 * int32(19077) >> int32(8)
  58285 			goto _189
  58286 		_189:
  58287 			v33 = v2 * int32(33050) >> int32(8)
  58288 			goto _191
  58289 		_191:
  58290 			v35 = v31 + v33 - int32(17685)
  58291 			if v35 & ^int32(YUV_MASK2) == 0 {
  58292 				v38 = v35 >> int32(YUV_FIX2)
  58293 			} else {
  58294 				if v35 < 0 {
  58295 					v39 = 0
  58296 				} else {
  58297 					v39 = int32(255)
  58298 				}
  58299 				v38 = v39
  58300 			}
  58301 			v36 = v38
  58302 			goto _194
  58303 		_194:
  58304 			v29 = v36
  58305 			goto _187
  58306 		_187:
  58307 			b = v29
  58308 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58309 			ba = b&int32(0xf0) | int32(0x0f)
  58310 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58311 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58312 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  58313 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  58314 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  58315 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(2))
  58316 			v7 = v1 * int32(19077) >> int32(8)
  58317 			goto _204
  58318 		_204:
  58319 			v9 = v3 * int32(26149) >> int32(8)
  58320 			goto _206
  58321 		_206:
  58322 			v11 = v7 + v9 - int32(14234)
  58323 			if v11 & ^int32(YUV_MASK2) == 0 {
  58324 				v14 = v11 >> int32(YUV_FIX2)
  58325 			} else {
  58326 				if v11 < 0 {
  58327 					v15 = 0
  58328 				} else {
  58329 					v15 = int32(255)
  58330 				}
  58331 				v14 = v15
  58332 			}
  58333 			v12 = v14
  58334 			goto _209
  58335 		_209:
  58336 			v5 = v12
  58337 			goto _202
  58338 		_202:
  58339 			r = v5
  58340 			v18 = v1 * int32(19077) >> int32(8)
  58341 			goto _215
  58342 		_215:
  58343 			v20 = v2 * int32(6419) >> int32(8)
  58344 			goto _217
  58345 		_217:
  58346 			v22 = v3 * int32(13320) >> int32(8)
  58347 			goto _219
  58348 		_219:
  58349 			v24 = v18 - v20 - v22 + int32(8708)
  58350 			if v24 & ^int32(YUV_MASK2) == 0 {
  58351 				v27 = v24 >> int32(YUV_FIX2)
  58352 			} else {
  58353 				if v24 < 0 {
  58354 					v28 = 0
  58355 				} else {
  58356 					v28 = int32(255)
  58357 				}
  58358 				v27 = v28
  58359 			}
  58360 			v25 = v27
  58361 			goto _222
  58362 		_222:
  58363 			v16 = v25
  58364 			goto _213
  58365 		_213:
  58366 			g = v16
  58367 			v31 = v1 * int32(19077) >> int32(8)
  58368 			goto _228
  58369 		_228:
  58370 			v33 = v2 * int32(33050) >> int32(8)
  58371 			goto _230
  58372 		_230:
  58373 			v35 = v31 + v33 - int32(17685)
  58374 			if v35 & ^int32(YUV_MASK2) == 0 {
  58375 				v38 = v35 >> int32(YUV_FIX2)
  58376 			} else {
  58377 				if v35 < 0 {
  58378 					v39 = 0
  58379 				} else {
  58380 					v39 = int32(255)
  58381 				}
  58382 				v38 = v39
  58383 			}
  58384 			v36 = v38
  58385 			goto _233
  58386 		_233:
  58387 			v29 = v36
  58388 			goto _226
  58389 		_226:
  58390 			b = v29
  58391 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58392 			ba = b&int32(0xf0) | int32(0x0f)
  58393 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58394 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58395 		}
  58396 		tl_uv = t_uv
  58397 		l_uv = uv
  58398 		goto _79
  58399 	_79:
  58400 		;
  58401 		x = x + 1
  58402 	}
  58403 	if !(len1&libc.Int32FromInt32(1) != 0) {
  58404 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  58405 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  58406 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  58407 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  58408 		v4 = top_dst + uintptr((len1-int32(1))*int32(2))
  58409 		v7 = v1 * int32(19077) >> int32(8)
  58410 		goto _243
  58411 	_243:
  58412 		v9 = v3 * int32(26149) >> int32(8)
  58413 		goto _245
  58414 	_245:
  58415 		v11 = v7 + v9 - int32(14234)
  58416 		if v11 & ^int32(YUV_MASK2) == 0 {
  58417 			v14 = v11 >> int32(YUV_FIX2)
  58418 		} else {
  58419 			if v11 < 0 {
  58420 				v15 = 0
  58421 			} else {
  58422 				v15 = int32(255)
  58423 			}
  58424 			v14 = v15
  58425 		}
  58426 		v12 = v14
  58427 		goto _248
  58428 	_248:
  58429 		v5 = v12
  58430 		goto _241
  58431 	_241:
  58432 		r = v5
  58433 		v18 = v1 * int32(19077) >> int32(8)
  58434 		goto _254
  58435 	_254:
  58436 		v20 = v2 * int32(6419) >> int32(8)
  58437 		goto _256
  58438 	_256:
  58439 		v22 = v3 * int32(13320) >> int32(8)
  58440 		goto _258
  58441 	_258:
  58442 		v24 = v18 - v20 - v22 + int32(8708)
  58443 		if v24 & ^int32(YUV_MASK2) == 0 {
  58444 			v27 = v24 >> int32(YUV_FIX2)
  58445 		} else {
  58446 			if v24 < 0 {
  58447 				v28 = 0
  58448 			} else {
  58449 				v28 = int32(255)
  58450 			}
  58451 			v27 = v28
  58452 		}
  58453 		v25 = v27
  58454 		goto _261
  58455 	_261:
  58456 		v16 = v25
  58457 		goto _252
  58458 	_252:
  58459 		g = v16
  58460 		v31 = v1 * int32(19077) >> int32(8)
  58461 		goto _267
  58462 	_267:
  58463 		v33 = v2 * int32(33050) >> int32(8)
  58464 		goto _269
  58465 	_269:
  58466 		v35 = v31 + v33 - int32(17685)
  58467 		if v35 & ^int32(YUV_MASK2) == 0 {
  58468 			v38 = v35 >> int32(YUV_FIX2)
  58469 		} else {
  58470 			if v35 < 0 {
  58471 				v39 = 0
  58472 			} else {
  58473 				v39 = int32(255)
  58474 			}
  58475 			v38 = v39
  58476 		}
  58477 		v36 = v38
  58478 		goto _272
  58479 	_272:
  58480 		v29 = v36
  58481 		goto _265
  58482 	_265:
  58483 		b = v29
  58484 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58485 		ba = b&int32(0xf0) | int32(0x0f)
  58486 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58487 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58488 		if bottom_y != libc.UintptrFromInt32(0) {
  58489 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  58490 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  58491 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  58492 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  58493 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(2))
  58494 			v7 = v1 * int32(19077) >> int32(8)
  58495 			goto _282
  58496 		_282:
  58497 			v9 = v3 * int32(26149) >> int32(8)
  58498 			goto _284
  58499 		_284:
  58500 			v11 = v7 + v9 - int32(14234)
  58501 			if v11 & ^int32(YUV_MASK2) == 0 {
  58502 				v14 = v11 >> int32(YUV_FIX2)
  58503 			} else {
  58504 				if v11 < 0 {
  58505 					v15 = 0
  58506 				} else {
  58507 					v15 = int32(255)
  58508 				}
  58509 				v14 = v15
  58510 			}
  58511 			v12 = v14
  58512 			goto _287
  58513 		_287:
  58514 			v5 = v12
  58515 			goto _280
  58516 		_280:
  58517 			r = v5
  58518 			v18 = v1 * int32(19077) >> int32(8)
  58519 			goto _293
  58520 		_293:
  58521 			v20 = v2 * int32(6419) >> int32(8)
  58522 			goto _295
  58523 		_295:
  58524 			v22 = v3 * int32(13320) >> int32(8)
  58525 			goto _297
  58526 		_297:
  58527 			v24 = v18 - v20 - v22 + int32(8708)
  58528 			if v24 & ^int32(YUV_MASK2) == 0 {
  58529 				v27 = v24 >> int32(YUV_FIX2)
  58530 			} else {
  58531 				if v24 < 0 {
  58532 					v28 = 0
  58533 				} else {
  58534 					v28 = int32(255)
  58535 				}
  58536 				v27 = v28
  58537 			}
  58538 			v25 = v27
  58539 			goto _300
  58540 		_300:
  58541 			v16 = v25
  58542 			goto _291
  58543 		_291:
  58544 			g = v16
  58545 			v31 = v1 * int32(19077) >> int32(8)
  58546 			goto _306
  58547 		_306:
  58548 			v33 = v2 * int32(33050) >> int32(8)
  58549 			goto _308
  58550 		_308:
  58551 			v35 = v31 + v33 - int32(17685)
  58552 			if v35 & ^int32(YUV_MASK2) == 0 {
  58553 				v38 = v35 >> int32(YUV_FIX2)
  58554 			} else {
  58555 				if v35 < 0 {
  58556 					v39 = 0
  58557 				} else {
  58558 					v39 = int32(255)
  58559 				}
  58560 				v38 = v39
  58561 			}
  58562 			v36 = v38
  58563 			goto _311
  58564 		_311:
  58565 			v29 = v36
  58566 			goto _304
  58567 		_304:
  58568 			b = v29
  58569 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58570 			ba = b&int32(0xf0) | int32(0x0f)
  58571 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58572 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58573 		}
  58574 	}
  58575 }
  58576 
  58577 func UpsampleRgb565LinePair_C(tls *libc.TLS, top_y uintptr, bottom_y uintptr, top_u uintptr, top_v uintptr, cur_u uintptr, cur_v uintptr, top_dst uintptr, bottom_dst uintptr, len1 int32) {
  58578 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  58579 	var b, g, gb, last_pixel_pair, r, rg, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v5, v7, v9 int32
  58580 	var v4 uintptr
  58581 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avg, b, diag_03, diag_12, g, gb, l_uv, last_pixel_pair, r, rg, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11, x, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v5, v7, v9
  58582 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  58583 	tl_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v)))<<libc.Int32FromInt32(16)) /* top-left sample */
  58584 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  58585 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  58586 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  58587 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  58588 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  58589 	v4 = top_dst
  58590 	v7 = v1 * int32(19077) >> int32(8)
  58591 	goto _8
  58592 _8:
  58593 	v9 = v3 * int32(26149) >> int32(8)
  58594 	goto _10
  58595 _10:
  58596 	v11 = v7 + v9 - int32(14234)
  58597 	if v11 & ^int32(YUV_MASK2) == 0 {
  58598 		v14 = v11 >> int32(YUV_FIX2)
  58599 	} else {
  58600 		if v11 < 0 {
  58601 			v15 = 0
  58602 		} else {
  58603 			v15 = int32(255)
  58604 		}
  58605 		v14 = v15
  58606 	}
  58607 	v12 = v14
  58608 	goto _13
  58609 _13:
  58610 	v5 = v12
  58611 	goto _6
  58612 _6:
  58613 	r = v5
  58614 	v18 = v1 * int32(19077) >> int32(8)
  58615 	goto _19
  58616 _19:
  58617 	v20 = v2 * int32(6419) >> int32(8)
  58618 	goto _21
  58619 _21:
  58620 	v22 = v3 * int32(13320) >> int32(8)
  58621 	goto _23
  58622 _23:
  58623 	v24 = v18 - v20 - v22 + int32(8708)
  58624 	if v24 & ^int32(YUV_MASK2) == 0 {
  58625 		v27 = v24 >> int32(YUV_FIX2)
  58626 	} else {
  58627 		if v24 < 0 {
  58628 			v28 = 0
  58629 		} else {
  58630 			v28 = int32(255)
  58631 		}
  58632 		v27 = v28
  58633 	}
  58634 	v25 = v27
  58635 	goto _26
  58636 _26:
  58637 	v16 = v25
  58638 	goto _17
  58639 _17:
  58640 	g = v16
  58641 	v31 = v1 * int32(19077) >> int32(8)
  58642 	goto _32
  58643 _32:
  58644 	v33 = v2 * int32(33050) >> int32(8)
  58645 	goto _34
  58646 _34:
  58647 	v35 = v31 + v33 - int32(17685)
  58648 	if v35 & ^int32(YUV_MASK2) == 0 {
  58649 		v38 = v35 >> int32(YUV_FIX2)
  58650 	} else {
  58651 		if v35 < 0 {
  58652 			v39 = 0
  58653 		} else {
  58654 			v39 = int32(255)
  58655 		}
  58656 		v38 = v39
  58657 	}
  58658 	v36 = v38
  58659 	goto _37
  58660 _37:
  58661 	v29 = v36
  58662 	goto _30
  58663 _30:
  58664 	b = v29
  58665 	rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58666 	gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58667 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58668 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58669 	if bottom_y != libc.UintptrFromInt32(0) {
  58670 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  58671 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  58672 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  58673 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  58674 		v4 = bottom_dst
  58675 		v7 = v1 * int32(19077) >> int32(8)
  58676 		goto _47
  58677 	_47:
  58678 		v9 = v3 * int32(26149) >> int32(8)
  58679 		goto _49
  58680 	_49:
  58681 		v11 = v7 + v9 - int32(14234)
  58682 		if v11 & ^int32(YUV_MASK2) == 0 {
  58683 			v14 = v11 >> int32(YUV_FIX2)
  58684 		} else {
  58685 			if v11 < 0 {
  58686 				v15 = 0
  58687 			} else {
  58688 				v15 = int32(255)
  58689 			}
  58690 			v14 = v15
  58691 		}
  58692 		v12 = v14
  58693 		goto _52
  58694 	_52:
  58695 		v5 = v12
  58696 		goto _45
  58697 	_45:
  58698 		r = v5
  58699 		v18 = v1 * int32(19077) >> int32(8)
  58700 		goto _58
  58701 	_58:
  58702 		v20 = v2 * int32(6419) >> int32(8)
  58703 		goto _60
  58704 	_60:
  58705 		v22 = v3 * int32(13320) >> int32(8)
  58706 		goto _62
  58707 	_62:
  58708 		v24 = v18 - v20 - v22 + int32(8708)
  58709 		if v24 & ^int32(YUV_MASK2) == 0 {
  58710 			v27 = v24 >> int32(YUV_FIX2)
  58711 		} else {
  58712 			if v24 < 0 {
  58713 				v28 = 0
  58714 			} else {
  58715 				v28 = int32(255)
  58716 			}
  58717 			v27 = v28
  58718 		}
  58719 		v25 = v27
  58720 		goto _65
  58721 	_65:
  58722 		v16 = v25
  58723 		goto _56
  58724 	_56:
  58725 		g = v16
  58726 		v31 = v1 * int32(19077) >> int32(8)
  58727 		goto _71
  58728 	_71:
  58729 		v33 = v2 * int32(33050) >> int32(8)
  58730 		goto _73
  58731 	_73:
  58732 		v35 = v31 + v33 - int32(17685)
  58733 		if v35 & ^int32(YUV_MASK2) == 0 {
  58734 			v38 = v35 >> int32(YUV_FIX2)
  58735 		} else {
  58736 			if v35 < 0 {
  58737 				v39 = 0
  58738 			} else {
  58739 				v39 = int32(255)
  58740 			}
  58741 			v38 = v39
  58742 		}
  58743 		v36 = v38
  58744 		goto _76
  58745 	_76:
  58746 		v29 = v36
  58747 		goto _69
  58748 	_69:
  58749 		b = v29
  58750 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58751 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58752 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58753 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58754 	}
  58755 	x = int32(1)
  58756 	for {
  58757 		if !(x <= last_pixel_pair) {
  58758 			break
  58759 		}
  58760 		t_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_v + uintptr(x))))<<libc.Int32FromInt32(16)) /* top sample */
  58761 		uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u + uintptr(x)))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v + uintptr(x))))<<libc.Int32FromInt32(16))   /* sample */ /* precompute invariant values associated with first and second diagonals*/
  58762 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  58763 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  58764 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  58765 		uv02 = (diag_12 + tl_uv) >> int32(1)
  58766 		uv1 = (diag_03 + t_uv) >> int32(1)
  58767 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  58768 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  58769 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  58770 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58771 		v7 = v1 * int32(19077) >> int32(8)
  58772 		goto _87
  58773 	_87:
  58774 		v9 = v3 * int32(26149) >> int32(8)
  58775 		goto _89
  58776 	_89:
  58777 		v11 = v7 + v9 - int32(14234)
  58778 		if v11 & ^int32(YUV_MASK2) == 0 {
  58779 			v14 = v11 >> int32(YUV_FIX2)
  58780 		} else {
  58781 			if v11 < 0 {
  58782 				v15 = 0
  58783 			} else {
  58784 				v15 = int32(255)
  58785 			}
  58786 			v14 = v15
  58787 		}
  58788 		v12 = v14
  58789 		goto _92
  58790 	_92:
  58791 		v5 = v12
  58792 		goto _85
  58793 	_85:
  58794 		r = v5
  58795 		v18 = v1 * int32(19077) >> int32(8)
  58796 		goto _98
  58797 	_98:
  58798 		v20 = v2 * int32(6419) >> int32(8)
  58799 		goto _100
  58800 	_100:
  58801 		v22 = v3 * int32(13320) >> int32(8)
  58802 		goto _102
  58803 	_102:
  58804 		v24 = v18 - v20 - v22 + int32(8708)
  58805 		if v24 & ^int32(YUV_MASK2) == 0 {
  58806 			v27 = v24 >> int32(YUV_FIX2)
  58807 		} else {
  58808 			if v24 < 0 {
  58809 				v28 = 0
  58810 			} else {
  58811 				v28 = int32(255)
  58812 			}
  58813 			v27 = v28
  58814 		}
  58815 		v25 = v27
  58816 		goto _105
  58817 	_105:
  58818 		v16 = v25
  58819 		goto _96
  58820 	_96:
  58821 		g = v16
  58822 		v31 = v1 * int32(19077) >> int32(8)
  58823 		goto _111
  58824 	_111:
  58825 		v33 = v2 * int32(33050) >> int32(8)
  58826 		goto _113
  58827 	_113:
  58828 		v35 = v31 + v33 - int32(17685)
  58829 		if v35 & ^int32(YUV_MASK2) == 0 {
  58830 			v38 = v35 >> int32(YUV_FIX2)
  58831 		} else {
  58832 			if v35 < 0 {
  58833 				v39 = 0
  58834 			} else {
  58835 				v39 = int32(255)
  58836 			}
  58837 			v38 = v39
  58838 		}
  58839 		v36 = v38
  58840 		goto _116
  58841 	_116:
  58842 		v29 = v36
  58843 		goto _109
  58844 	_109:
  58845 		b = v29
  58846 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58847 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58848 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58849 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58850 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  58851 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  58852 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  58853 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(2))
  58854 		v7 = v1 * int32(19077) >> int32(8)
  58855 		goto _126
  58856 	_126:
  58857 		v9 = v3 * int32(26149) >> int32(8)
  58858 		goto _128
  58859 	_128:
  58860 		v11 = v7 + v9 - int32(14234)
  58861 		if v11 & ^int32(YUV_MASK2) == 0 {
  58862 			v14 = v11 >> int32(YUV_FIX2)
  58863 		} else {
  58864 			if v11 < 0 {
  58865 				v15 = 0
  58866 			} else {
  58867 				v15 = int32(255)
  58868 			}
  58869 			v14 = v15
  58870 		}
  58871 		v12 = v14
  58872 		goto _131
  58873 	_131:
  58874 		v5 = v12
  58875 		goto _124
  58876 	_124:
  58877 		r = v5
  58878 		v18 = v1 * int32(19077) >> int32(8)
  58879 		goto _137
  58880 	_137:
  58881 		v20 = v2 * int32(6419) >> int32(8)
  58882 		goto _139
  58883 	_139:
  58884 		v22 = v3 * int32(13320) >> int32(8)
  58885 		goto _141
  58886 	_141:
  58887 		v24 = v18 - v20 - v22 + int32(8708)
  58888 		if v24 & ^int32(YUV_MASK2) == 0 {
  58889 			v27 = v24 >> int32(YUV_FIX2)
  58890 		} else {
  58891 			if v24 < 0 {
  58892 				v28 = 0
  58893 			} else {
  58894 				v28 = int32(255)
  58895 			}
  58896 			v27 = v28
  58897 		}
  58898 		v25 = v27
  58899 		goto _144
  58900 	_144:
  58901 		v16 = v25
  58902 		goto _135
  58903 	_135:
  58904 		g = v16
  58905 		v31 = v1 * int32(19077) >> int32(8)
  58906 		goto _150
  58907 	_150:
  58908 		v33 = v2 * int32(33050) >> int32(8)
  58909 		goto _152
  58910 	_152:
  58911 		v35 = v31 + v33 - int32(17685)
  58912 		if v35 & ^int32(YUV_MASK2) == 0 {
  58913 			v38 = v35 >> int32(YUV_FIX2)
  58914 		} else {
  58915 			if v35 < 0 {
  58916 				v39 = 0
  58917 			} else {
  58918 				v39 = int32(255)
  58919 			}
  58920 			v38 = v39
  58921 		}
  58922 		v36 = v38
  58923 		goto _155
  58924 	_155:
  58925 		v29 = v36
  58926 		goto _148
  58927 	_148:
  58928 		b = v29
  58929 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58930 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58931 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58932 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58933 		if bottom_y != libc.UintptrFromInt32(0) {
  58934 			uv03 = (diag_03 + l_uv) >> int32(1)
  58935 			uv11 = (diag_12 + uv) >> int32(1)
  58936 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  58937 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  58938 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  58939 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58940 			v7 = v1 * int32(19077) >> int32(8)
  58941 			goto _165
  58942 		_165:
  58943 			v9 = v3 * int32(26149) >> int32(8)
  58944 			goto _167
  58945 		_167:
  58946 			v11 = v7 + v9 - int32(14234)
  58947 			if v11 & ^int32(YUV_MASK2) == 0 {
  58948 				v14 = v11 >> int32(YUV_FIX2)
  58949 			} else {
  58950 				if v11 < 0 {
  58951 					v15 = 0
  58952 				} else {
  58953 					v15 = int32(255)
  58954 				}
  58955 				v14 = v15
  58956 			}
  58957 			v12 = v14
  58958 			goto _170
  58959 		_170:
  58960 			v5 = v12
  58961 			goto _163
  58962 		_163:
  58963 			r = v5
  58964 			v18 = v1 * int32(19077) >> int32(8)
  58965 			goto _176
  58966 		_176:
  58967 			v20 = v2 * int32(6419) >> int32(8)
  58968 			goto _178
  58969 		_178:
  58970 			v22 = v3 * int32(13320) >> int32(8)
  58971 			goto _180
  58972 		_180:
  58973 			v24 = v18 - v20 - v22 + int32(8708)
  58974 			if v24 & ^int32(YUV_MASK2) == 0 {
  58975 				v27 = v24 >> int32(YUV_FIX2)
  58976 			} else {
  58977 				if v24 < 0 {
  58978 					v28 = 0
  58979 				} else {
  58980 					v28 = int32(255)
  58981 				}
  58982 				v27 = v28
  58983 			}
  58984 			v25 = v27
  58985 			goto _183
  58986 		_183:
  58987 			v16 = v25
  58988 			goto _174
  58989 		_174:
  58990 			g = v16
  58991 			v31 = v1 * int32(19077) >> int32(8)
  58992 			goto _189
  58993 		_189:
  58994 			v33 = v2 * int32(33050) >> int32(8)
  58995 			goto _191
  58996 		_191:
  58997 			v35 = v31 + v33 - int32(17685)
  58998 			if v35 & ^int32(YUV_MASK2) == 0 {
  58999 				v38 = v35 >> int32(YUV_FIX2)
  59000 			} else {
  59001 				if v35 < 0 {
  59002 					v39 = 0
  59003 				} else {
  59004 					v39 = int32(255)
  59005 				}
  59006 				v38 = v39
  59007 			}
  59008 			v36 = v38
  59009 			goto _194
  59010 		_194:
  59011 			v29 = v36
  59012 			goto _187
  59013 		_187:
  59014 			b = v29
  59015 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59016 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59017 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59018 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59019 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  59020 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  59021 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  59022 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(2))
  59023 			v7 = v1 * int32(19077) >> int32(8)
  59024 			goto _204
  59025 		_204:
  59026 			v9 = v3 * int32(26149) >> int32(8)
  59027 			goto _206
  59028 		_206:
  59029 			v11 = v7 + v9 - int32(14234)
  59030 			if v11 & ^int32(YUV_MASK2) == 0 {
  59031 				v14 = v11 >> int32(YUV_FIX2)
  59032 			} else {
  59033 				if v11 < 0 {
  59034 					v15 = 0
  59035 				} else {
  59036 					v15 = int32(255)
  59037 				}
  59038 				v14 = v15
  59039 			}
  59040 			v12 = v14
  59041 			goto _209
  59042 		_209:
  59043 			v5 = v12
  59044 			goto _202
  59045 		_202:
  59046 			r = v5
  59047 			v18 = v1 * int32(19077) >> int32(8)
  59048 			goto _215
  59049 		_215:
  59050 			v20 = v2 * int32(6419) >> int32(8)
  59051 			goto _217
  59052 		_217:
  59053 			v22 = v3 * int32(13320) >> int32(8)
  59054 			goto _219
  59055 		_219:
  59056 			v24 = v18 - v20 - v22 + int32(8708)
  59057 			if v24 & ^int32(YUV_MASK2) == 0 {
  59058 				v27 = v24 >> int32(YUV_FIX2)
  59059 			} else {
  59060 				if v24 < 0 {
  59061 					v28 = 0
  59062 				} else {
  59063 					v28 = int32(255)
  59064 				}
  59065 				v27 = v28
  59066 			}
  59067 			v25 = v27
  59068 			goto _222
  59069 		_222:
  59070 			v16 = v25
  59071 			goto _213
  59072 		_213:
  59073 			g = v16
  59074 			v31 = v1 * int32(19077) >> int32(8)
  59075 			goto _228
  59076 		_228:
  59077 			v33 = v2 * int32(33050) >> int32(8)
  59078 			goto _230
  59079 		_230:
  59080 			v35 = v31 + v33 - int32(17685)
  59081 			if v35 & ^int32(YUV_MASK2) == 0 {
  59082 				v38 = v35 >> int32(YUV_FIX2)
  59083 			} else {
  59084 				if v35 < 0 {
  59085 					v39 = 0
  59086 				} else {
  59087 					v39 = int32(255)
  59088 				}
  59089 				v38 = v39
  59090 			}
  59091 			v36 = v38
  59092 			goto _233
  59093 		_233:
  59094 			v29 = v36
  59095 			goto _226
  59096 		_226:
  59097 			b = v29
  59098 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59099 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59100 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59101 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59102 		}
  59103 		tl_uv = t_uv
  59104 		l_uv = uv
  59105 		goto _79
  59106 	_79:
  59107 		;
  59108 		x = x + 1
  59109 	}
  59110 	if !(len1&libc.Int32FromInt32(1) != 0) {
  59111 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  59112 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  59113 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  59114 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  59115 		v4 = top_dst + uintptr((len1-int32(1))*int32(2))
  59116 		v7 = v1 * int32(19077) >> int32(8)
  59117 		goto _243
  59118 	_243:
  59119 		v9 = v3 * int32(26149) >> int32(8)
  59120 		goto _245
  59121 	_245:
  59122 		v11 = v7 + v9 - int32(14234)
  59123 		if v11 & ^int32(YUV_MASK2) == 0 {
  59124 			v14 = v11 >> int32(YUV_FIX2)
  59125 		} else {
  59126 			if v11 < 0 {
  59127 				v15 = 0
  59128 			} else {
  59129 				v15 = int32(255)
  59130 			}
  59131 			v14 = v15
  59132 		}
  59133 		v12 = v14
  59134 		goto _248
  59135 	_248:
  59136 		v5 = v12
  59137 		goto _241
  59138 	_241:
  59139 		r = v5
  59140 		v18 = v1 * int32(19077) >> int32(8)
  59141 		goto _254
  59142 	_254:
  59143 		v20 = v2 * int32(6419) >> int32(8)
  59144 		goto _256
  59145 	_256:
  59146 		v22 = v3 * int32(13320) >> int32(8)
  59147 		goto _258
  59148 	_258:
  59149 		v24 = v18 - v20 - v22 + int32(8708)
  59150 		if v24 & ^int32(YUV_MASK2) == 0 {
  59151 			v27 = v24 >> int32(YUV_FIX2)
  59152 		} else {
  59153 			if v24 < 0 {
  59154 				v28 = 0
  59155 			} else {
  59156 				v28 = int32(255)
  59157 			}
  59158 			v27 = v28
  59159 		}
  59160 		v25 = v27
  59161 		goto _261
  59162 	_261:
  59163 		v16 = v25
  59164 		goto _252
  59165 	_252:
  59166 		g = v16
  59167 		v31 = v1 * int32(19077) >> int32(8)
  59168 		goto _267
  59169 	_267:
  59170 		v33 = v2 * int32(33050) >> int32(8)
  59171 		goto _269
  59172 	_269:
  59173 		v35 = v31 + v33 - int32(17685)
  59174 		if v35 & ^int32(YUV_MASK2) == 0 {
  59175 			v38 = v35 >> int32(YUV_FIX2)
  59176 		} else {
  59177 			if v35 < 0 {
  59178 				v39 = 0
  59179 			} else {
  59180 				v39 = int32(255)
  59181 			}
  59182 			v38 = v39
  59183 		}
  59184 		v36 = v38
  59185 		goto _272
  59186 	_272:
  59187 		v29 = v36
  59188 		goto _265
  59189 	_265:
  59190 		b = v29
  59191 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59192 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59193 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59194 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59195 		if bottom_y != libc.UintptrFromInt32(0) {
  59196 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  59197 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  59198 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  59199 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  59200 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(2))
  59201 			v7 = v1 * int32(19077) >> int32(8)
  59202 			goto _282
  59203 		_282:
  59204 			v9 = v3 * int32(26149) >> int32(8)
  59205 			goto _284
  59206 		_284:
  59207 			v11 = v7 + v9 - int32(14234)
  59208 			if v11 & ^int32(YUV_MASK2) == 0 {
  59209 				v14 = v11 >> int32(YUV_FIX2)
  59210 			} else {
  59211 				if v11 < 0 {
  59212 					v15 = 0
  59213 				} else {
  59214 					v15 = int32(255)
  59215 				}
  59216 				v14 = v15
  59217 			}
  59218 			v12 = v14
  59219 			goto _287
  59220 		_287:
  59221 			v5 = v12
  59222 			goto _280
  59223 		_280:
  59224 			r = v5
  59225 			v18 = v1 * int32(19077) >> int32(8)
  59226 			goto _293
  59227 		_293:
  59228 			v20 = v2 * int32(6419) >> int32(8)
  59229 			goto _295
  59230 		_295:
  59231 			v22 = v3 * int32(13320) >> int32(8)
  59232 			goto _297
  59233 		_297:
  59234 			v24 = v18 - v20 - v22 + int32(8708)
  59235 			if v24 & ^int32(YUV_MASK2) == 0 {
  59236 				v27 = v24 >> int32(YUV_FIX2)
  59237 			} else {
  59238 				if v24 < 0 {
  59239 					v28 = 0
  59240 				} else {
  59241 					v28 = int32(255)
  59242 				}
  59243 				v27 = v28
  59244 			}
  59245 			v25 = v27
  59246 			goto _300
  59247 		_300:
  59248 			v16 = v25
  59249 			goto _291
  59250 		_291:
  59251 			g = v16
  59252 			v31 = v1 * int32(19077) >> int32(8)
  59253 			goto _306
  59254 		_306:
  59255 			v33 = v2 * int32(33050) >> int32(8)
  59256 			goto _308
  59257 		_308:
  59258 			v35 = v31 + v33 - int32(17685)
  59259 			if v35 & ^int32(YUV_MASK2) == 0 {
  59260 				v38 = v35 >> int32(YUV_FIX2)
  59261 			} else {
  59262 				if v35 < 0 {
  59263 					v39 = 0
  59264 				} else {
  59265 					v39 = int32(255)
  59266 				}
  59267 				v38 = v39
  59268 			}
  59269 			v36 = v38
  59270 			goto _311
  59271 		_311:
  59272 			v29 = v36
  59273 			goto _304
  59274 		_304:
  59275 			b = v29
  59276 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59277 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59278 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59279 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59280 		}
  59281 	}
  59282 }
  59283 
  59284 //------------------------------------------------------------------------------
  59285 
  59286 func WebPGetLinePairConverter(tls *libc.TLS, alpha_is_last int32) (r WebPUpsampleLinePairFunc) {
  59287 	var v1 int32
  59288 	_ = v1
  59289 	WebPInitUpsamplers(tls)
  59290 	if alpha_is_last != 0 {
  59291 		v1 = int32(MODE_BGRA)
  59292 	} else {
  59293 		v1 = int32(MODE_ARGB)
  59294 	}
  59295 	return WebPUpsamplers[v1]
  59296 }
  59297 
  59298 func WebPYuv444ToRgba_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59299 	var i, v11, v13, v14, v16, v17, v18, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v7, v9 int32
  59300 	var v2, v61 uintptr
  59301 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, v11, v13, v14, v16, v17, v18, v2, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v61, v7, v9
  59302 	i = 0
  59303 	for {
  59304 		if !(i < len1) {
  59305 			break
  59306 		}
  59307 		v2 = dst + uintptr(i*int32(4))
  59308 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59309 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59310 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59311 		v61 = v2
  59312 		v9 = v3 * int32(19077) >> int32(8)
  59313 		goto _10
  59314 	_10:
  59315 		v11 = v5 * int32(26149) >> int32(8)
  59316 		goto _12
  59317 	_12:
  59318 		v13 = v9 + v11 - int32(14234)
  59319 		if v13 & ^int32(YUV_MASK2) == 0 {
  59320 			v16 = v13 >> int32(YUV_FIX2)
  59321 		} else {
  59322 			if v13 < 0 {
  59323 				v17 = 0
  59324 			} else {
  59325 				v17 = int32(255)
  59326 			}
  59327 			v16 = v17
  59328 		}
  59329 		v14 = v16
  59330 		goto _15
  59331 	_15:
  59332 		v7 = v14
  59333 		goto _8
  59334 	_8:
  59335 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59336 		v20 = v3 * int32(19077) >> int32(8)
  59337 		goto _21
  59338 	_21:
  59339 		v22 = v4 * int32(6419) >> int32(8)
  59340 		goto _23
  59341 	_23:
  59342 		v24 = v5 * int32(13320) >> int32(8)
  59343 		goto _25
  59344 	_25:
  59345 		v26 = v20 - v22 - v24 + int32(8708)
  59346 		if v26 & ^int32(YUV_MASK2) == 0 {
  59347 			v29 = v26 >> int32(YUV_FIX2)
  59348 		} else {
  59349 			if v26 < 0 {
  59350 				v30 = 0
  59351 			} else {
  59352 				v30 = int32(255)
  59353 			}
  59354 			v29 = v30
  59355 		}
  59356 		v27 = v29
  59357 		goto _28
  59358 	_28:
  59359 		v18 = v27
  59360 		goto _19
  59361 	_19:
  59362 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59363 		v33 = v3 * int32(19077) >> int32(8)
  59364 		goto _34
  59365 	_34:
  59366 		v35 = v4 * int32(33050) >> int32(8)
  59367 		goto _36
  59368 	_36:
  59369 		v37 = v33 + v35 - int32(17685)
  59370 		if v37 & ^int32(YUV_MASK2) == 0 {
  59371 			v40 = v37 >> int32(YUV_FIX2)
  59372 		} else {
  59373 			if v37 < 0 {
  59374 				v41 = 0
  59375 			} else {
  59376 				v41 = int32(255)
  59377 			}
  59378 			v40 = v41
  59379 		}
  59380 		v38 = v40
  59381 		goto _39
  59382 	_39:
  59383 		v31 = v38
  59384 		goto _32
  59385 	_32:
  59386 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59387 		**(**uint8_t)(__ccgo_up(v2 + 3)) = uint8(0xff)
  59388 		goto _1
  59389 	_1:
  59390 		;
  59391 		i = i + 1
  59392 	}
  59393 }
  59394 
  59395 func WebPYuv444ToBgra_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59396 	var i, v11, v13, v14, v16, v17, v18, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v7, v9 int32
  59397 	var v2, v61 uintptr
  59398 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, v11, v13, v14, v16, v17, v18, v2, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v61, v7, v9
  59399 	i = 0
  59400 	for {
  59401 		if !(i < len1) {
  59402 			break
  59403 		}
  59404 		v2 = dst + uintptr(i*int32(4))
  59405 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59406 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59407 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59408 		v61 = v2
  59409 		v9 = v3 * int32(19077) >> int32(8)
  59410 		goto _10
  59411 	_10:
  59412 		v11 = v4 * int32(33050) >> int32(8)
  59413 		goto _12
  59414 	_12:
  59415 		v13 = v9 + v11 - int32(17685)
  59416 		if v13 & ^int32(YUV_MASK2) == 0 {
  59417 			v16 = v13 >> int32(YUV_FIX2)
  59418 		} else {
  59419 			if v13 < 0 {
  59420 				v17 = 0
  59421 			} else {
  59422 				v17 = int32(255)
  59423 			}
  59424 			v16 = v17
  59425 		}
  59426 		v14 = v16
  59427 		goto _15
  59428 	_15:
  59429 		v7 = v14
  59430 		goto _8
  59431 	_8:
  59432 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59433 		v20 = v3 * int32(19077) >> int32(8)
  59434 		goto _21
  59435 	_21:
  59436 		v22 = v4 * int32(6419) >> int32(8)
  59437 		goto _23
  59438 	_23:
  59439 		v24 = v5 * int32(13320) >> int32(8)
  59440 		goto _25
  59441 	_25:
  59442 		v26 = v20 - v22 - v24 + int32(8708)
  59443 		if v26 & ^int32(YUV_MASK2) == 0 {
  59444 			v29 = v26 >> int32(YUV_FIX2)
  59445 		} else {
  59446 			if v26 < 0 {
  59447 				v30 = 0
  59448 			} else {
  59449 				v30 = int32(255)
  59450 			}
  59451 			v29 = v30
  59452 		}
  59453 		v27 = v29
  59454 		goto _28
  59455 	_28:
  59456 		v18 = v27
  59457 		goto _19
  59458 	_19:
  59459 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59460 		v33 = v3 * int32(19077) >> int32(8)
  59461 		goto _34
  59462 	_34:
  59463 		v35 = v5 * int32(26149) >> int32(8)
  59464 		goto _36
  59465 	_36:
  59466 		v37 = v33 + v35 - int32(14234)
  59467 		if v37 & ^int32(YUV_MASK2) == 0 {
  59468 			v40 = v37 >> int32(YUV_FIX2)
  59469 		} else {
  59470 			if v37 < 0 {
  59471 				v41 = 0
  59472 			} else {
  59473 				v41 = int32(255)
  59474 			}
  59475 			v40 = v41
  59476 		}
  59477 		v38 = v40
  59478 		goto _39
  59479 	_39:
  59480 		v31 = v38
  59481 		goto _32
  59482 	_32:
  59483 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59484 		**(**uint8_t)(__ccgo_up(v2 + 3)) = uint8(0xff)
  59485 		goto _1
  59486 	_1:
  59487 		;
  59488 		i = i + 1
  59489 	}
  59490 }
  59491 
  59492 func WebPYuv444ToRgb_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59493 	var i, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  59494 	var v51 uintptr
  59495 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v51, v6, v8
  59496 	i = 0
  59497 	for {
  59498 		if !(i < len1) {
  59499 			break
  59500 		}
  59501 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59502 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59503 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59504 		v51 = dst + uintptr(i*int32(3))
  59505 		v8 = v2 * int32(19077) >> int32(8)
  59506 		goto _9
  59507 	_9:
  59508 		v10 = v4 * int32(26149) >> int32(8)
  59509 		goto _11
  59510 	_11:
  59511 		v12 = v8 + v10 - int32(14234)
  59512 		if v12 & ^int32(YUV_MASK2) == 0 {
  59513 			v15 = v12 >> int32(YUV_FIX2)
  59514 		} else {
  59515 			if v12 < 0 {
  59516 				v16 = 0
  59517 			} else {
  59518 				v16 = int32(255)
  59519 			}
  59520 			v15 = v16
  59521 		}
  59522 		v13 = v15
  59523 		goto _14
  59524 	_14:
  59525 		v6 = v13
  59526 		goto _7
  59527 	_7:
  59528 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(v6)
  59529 		v19 = v2 * int32(19077) >> int32(8)
  59530 		goto _20
  59531 	_20:
  59532 		v21 = v3 * int32(6419) >> int32(8)
  59533 		goto _22
  59534 	_22:
  59535 		v23 = v4 * int32(13320) >> int32(8)
  59536 		goto _24
  59537 	_24:
  59538 		v25 = v19 - v21 - v23 + int32(8708)
  59539 		if v25 & ^int32(YUV_MASK2) == 0 {
  59540 			v28 = v25 >> int32(YUV_FIX2)
  59541 		} else {
  59542 			if v25 < 0 {
  59543 				v29 = 0
  59544 			} else {
  59545 				v29 = int32(255)
  59546 			}
  59547 			v28 = v29
  59548 		}
  59549 		v26 = v28
  59550 		goto _27
  59551 	_27:
  59552 		v17 = v26
  59553 		goto _18
  59554 	_18:
  59555 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(v17)
  59556 		v32 = v2 * int32(19077) >> int32(8)
  59557 		goto _33
  59558 	_33:
  59559 		v34 = v3 * int32(33050) >> int32(8)
  59560 		goto _35
  59561 	_35:
  59562 		v36 = v32 + v34 - int32(17685)
  59563 		if v36 & ^int32(YUV_MASK2) == 0 {
  59564 			v39 = v36 >> int32(YUV_FIX2)
  59565 		} else {
  59566 			if v36 < 0 {
  59567 				v40 = 0
  59568 			} else {
  59569 				v40 = int32(255)
  59570 			}
  59571 			v39 = v40
  59572 		}
  59573 		v37 = v39
  59574 		goto _38
  59575 	_38:
  59576 		v30 = v37
  59577 		goto _31
  59578 	_31:
  59579 		**(**uint8_t)(__ccgo_up(v51 + 2)) = libc.Uint8FromInt32(v30)
  59580 		goto _1
  59581 	_1:
  59582 		;
  59583 		i = i + 1
  59584 	}
  59585 }
  59586 
  59587 func WebPYuv444ToBgr_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59588 	var i, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  59589 	var v51 uintptr
  59590 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v51, v6, v8
  59591 	i = 0
  59592 	for {
  59593 		if !(i < len1) {
  59594 			break
  59595 		}
  59596 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59597 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59598 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59599 		v51 = dst + uintptr(i*int32(3))
  59600 		v8 = v2 * int32(19077) >> int32(8)
  59601 		goto _9
  59602 	_9:
  59603 		v10 = v3 * int32(33050) >> int32(8)
  59604 		goto _11
  59605 	_11:
  59606 		v12 = v8 + v10 - int32(17685)
  59607 		if v12 & ^int32(YUV_MASK2) == 0 {
  59608 			v15 = v12 >> int32(YUV_FIX2)
  59609 		} else {
  59610 			if v12 < 0 {
  59611 				v16 = 0
  59612 			} else {
  59613 				v16 = int32(255)
  59614 			}
  59615 			v15 = v16
  59616 		}
  59617 		v13 = v15
  59618 		goto _14
  59619 	_14:
  59620 		v6 = v13
  59621 		goto _7
  59622 	_7:
  59623 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(v6)
  59624 		v19 = v2 * int32(19077) >> int32(8)
  59625 		goto _20
  59626 	_20:
  59627 		v21 = v3 * int32(6419) >> int32(8)
  59628 		goto _22
  59629 	_22:
  59630 		v23 = v4 * int32(13320) >> int32(8)
  59631 		goto _24
  59632 	_24:
  59633 		v25 = v19 - v21 - v23 + int32(8708)
  59634 		if v25 & ^int32(YUV_MASK2) == 0 {
  59635 			v28 = v25 >> int32(YUV_FIX2)
  59636 		} else {
  59637 			if v25 < 0 {
  59638 				v29 = 0
  59639 			} else {
  59640 				v29 = int32(255)
  59641 			}
  59642 			v28 = v29
  59643 		}
  59644 		v26 = v28
  59645 		goto _27
  59646 	_27:
  59647 		v17 = v26
  59648 		goto _18
  59649 	_18:
  59650 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(v17)
  59651 		v32 = v2 * int32(19077) >> int32(8)
  59652 		goto _33
  59653 	_33:
  59654 		v34 = v4 * int32(26149) >> int32(8)
  59655 		goto _35
  59656 	_35:
  59657 		v36 = v32 + v34 - int32(14234)
  59658 		if v36 & ^int32(YUV_MASK2) == 0 {
  59659 			v39 = v36 >> int32(YUV_FIX2)
  59660 		} else {
  59661 			if v36 < 0 {
  59662 				v40 = 0
  59663 			} else {
  59664 				v40 = int32(255)
  59665 			}
  59666 			v39 = v40
  59667 		}
  59668 		v37 = v39
  59669 		goto _38
  59670 	_38:
  59671 		v30 = v37
  59672 		goto _31
  59673 	_31:
  59674 		**(**uint8_t)(__ccgo_up(v51 + 2)) = libc.Uint8FromInt32(v30)
  59675 		goto _1
  59676 	_1:
  59677 		;
  59678 		i = i + 1
  59679 	}
  59680 }
  59681 
  59682 func WebPYuv444ToArgb_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59683 	var i, v11, v13, v14, v16, v17, v18, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v7, v9 int32
  59684 	var v2, v61 uintptr
  59685 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, v11, v13, v14, v16, v17, v18, v2, v20, v22, v24, v26, v27, v29, v3, v30, v31, v33, v35, v37, v38, v4, v40, v41, v5, v61, v7, v9
  59686 	i = 0
  59687 	for {
  59688 		if !(i < len1) {
  59689 			break
  59690 		}
  59691 		v2 = dst + uintptr(i*int32(4))
  59692 		**(**uint8_t)(__ccgo_up(v2)) = uint8(0xff)
  59693 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59694 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59695 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59696 		v61 = v2 + uintptr(1)
  59697 		v9 = v3 * int32(19077) >> int32(8)
  59698 		goto _10
  59699 	_10:
  59700 		v11 = v5 * int32(26149) >> int32(8)
  59701 		goto _12
  59702 	_12:
  59703 		v13 = v9 + v11 - int32(14234)
  59704 		if v13 & ^int32(YUV_MASK2) == 0 {
  59705 			v16 = v13 >> int32(YUV_FIX2)
  59706 		} else {
  59707 			if v13 < 0 {
  59708 				v17 = 0
  59709 			} else {
  59710 				v17 = int32(255)
  59711 			}
  59712 			v16 = v17
  59713 		}
  59714 		v14 = v16
  59715 		goto _15
  59716 	_15:
  59717 		v7 = v14
  59718 		goto _8
  59719 	_8:
  59720 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59721 		v20 = v3 * int32(19077) >> int32(8)
  59722 		goto _21
  59723 	_21:
  59724 		v22 = v4 * int32(6419) >> int32(8)
  59725 		goto _23
  59726 	_23:
  59727 		v24 = v5 * int32(13320) >> int32(8)
  59728 		goto _25
  59729 	_25:
  59730 		v26 = v20 - v22 - v24 + int32(8708)
  59731 		if v26 & ^int32(YUV_MASK2) == 0 {
  59732 			v29 = v26 >> int32(YUV_FIX2)
  59733 		} else {
  59734 			if v26 < 0 {
  59735 				v30 = 0
  59736 			} else {
  59737 				v30 = int32(255)
  59738 			}
  59739 			v29 = v30
  59740 		}
  59741 		v27 = v29
  59742 		goto _28
  59743 	_28:
  59744 		v18 = v27
  59745 		goto _19
  59746 	_19:
  59747 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59748 		v33 = v3 * int32(19077) >> int32(8)
  59749 		goto _34
  59750 	_34:
  59751 		v35 = v4 * int32(33050) >> int32(8)
  59752 		goto _36
  59753 	_36:
  59754 		v37 = v33 + v35 - int32(17685)
  59755 		if v37 & ^int32(YUV_MASK2) == 0 {
  59756 			v40 = v37 >> int32(YUV_FIX2)
  59757 		} else {
  59758 			if v37 < 0 {
  59759 				v41 = 0
  59760 			} else {
  59761 				v41 = int32(255)
  59762 			}
  59763 			v40 = v41
  59764 		}
  59765 		v38 = v40
  59766 		goto _39
  59767 	_39:
  59768 		v31 = v38
  59769 		goto _32
  59770 	_32:
  59771 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59772 		goto _1
  59773 	_1:
  59774 		;
  59775 		i = i + 1
  59776 	}
  59777 }
  59778 
  59779 func WebPYuv444ToRgba4444_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59780 	var b, ba, g, i, r, rg, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  59781 	var v51 uintptr
  59782 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, ba, g, i, r, rg, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v51, v6, v8
  59783 	i = 0
  59784 	for {
  59785 		if !(i < len1) {
  59786 			break
  59787 		}
  59788 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59789 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59790 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59791 		v51 = dst + uintptr(i*int32(2))
  59792 		v8 = v2 * int32(19077) >> int32(8)
  59793 		goto _9
  59794 	_9:
  59795 		v10 = v4 * int32(26149) >> int32(8)
  59796 		goto _11
  59797 	_11:
  59798 		v12 = v8 + v10 - int32(14234)
  59799 		if v12 & ^int32(YUV_MASK2) == 0 {
  59800 			v15 = v12 >> int32(YUV_FIX2)
  59801 		} else {
  59802 			if v12 < 0 {
  59803 				v16 = 0
  59804 			} else {
  59805 				v16 = int32(255)
  59806 			}
  59807 			v15 = v16
  59808 		}
  59809 		v13 = v15
  59810 		goto _14
  59811 	_14:
  59812 		v6 = v13
  59813 		goto _7
  59814 	_7:
  59815 		r = v6
  59816 		v19 = v2 * int32(19077) >> int32(8)
  59817 		goto _20
  59818 	_20:
  59819 		v21 = v3 * int32(6419) >> int32(8)
  59820 		goto _22
  59821 	_22:
  59822 		v23 = v4 * int32(13320) >> int32(8)
  59823 		goto _24
  59824 	_24:
  59825 		v25 = v19 - v21 - v23 + int32(8708)
  59826 		if v25 & ^int32(YUV_MASK2) == 0 {
  59827 			v28 = v25 >> int32(YUV_FIX2)
  59828 		} else {
  59829 			if v25 < 0 {
  59830 				v29 = 0
  59831 			} else {
  59832 				v29 = int32(255)
  59833 			}
  59834 			v28 = v29
  59835 		}
  59836 		v26 = v28
  59837 		goto _27
  59838 	_27:
  59839 		v17 = v26
  59840 		goto _18
  59841 	_18:
  59842 		g = v17
  59843 		v32 = v2 * int32(19077) >> int32(8)
  59844 		goto _33
  59845 	_33:
  59846 		v34 = v3 * int32(33050) >> int32(8)
  59847 		goto _35
  59848 	_35:
  59849 		v36 = v32 + v34 - int32(17685)
  59850 		if v36 & ^int32(YUV_MASK2) == 0 {
  59851 			v39 = v36 >> int32(YUV_FIX2)
  59852 		} else {
  59853 			if v36 < 0 {
  59854 				v40 = 0
  59855 			} else {
  59856 				v40 = int32(255)
  59857 			}
  59858 			v39 = v40
  59859 		}
  59860 		v37 = v39
  59861 		goto _38
  59862 	_38:
  59863 		v30 = v37
  59864 		goto _31
  59865 	_31:
  59866 		b = v30
  59867 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  59868 		ba = b&int32(0xf0) | int32(0x0f)
  59869 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(rg)
  59870 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(ba)
  59871 		goto _1
  59872 	_1:
  59873 		;
  59874 		i = i + 1
  59875 	}
  59876 }
  59877 
  59878 func WebPYuv444ToRgb565_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59879 	var b, g, gb, i, r, rg, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v6, v8 int32
  59880 	var v51 uintptr
  59881 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, g, gb, i, r, rg, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v51, v6, v8
  59882 	i = 0
  59883 	for {
  59884 		if !(i < len1) {
  59885 			break
  59886 		}
  59887 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59888 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59889 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59890 		v51 = dst + uintptr(i*int32(2))
  59891 		v8 = v2 * int32(19077) >> int32(8)
  59892 		goto _9
  59893 	_9:
  59894 		v10 = v4 * int32(26149) >> int32(8)
  59895 		goto _11
  59896 	_11:
  59897 		v12 = v8 + v10 - int32(14234)
  59898 		if v12 & ^int32(YUV_MASK2) == 0 {
  59899 			v15 = v12 >> int32(YUV_FIX2)
  59900 		} else {
  59901 			if v12 < 0 {
  59902 				v16 = 0
  59903 			} else {
  59904 				v16 = int32(255)
  59905 			}
  59906 			v15 = v16
  59907 		}
  59908 		v13 = v15
  59909 		goto _14
  59910 	_14:
  59911 		v6 = v13
  59912 		goto _7
  59913 	_7:
  59914 		r = v6
  59915 		v19 = v2 * int32(19077) >> int32(8)
  59916 		goto _20
  59917 	_20:
  59918 		v21 = v3 * int32(6419) >> int32(8)
  59919 		goto _22
  59920 	_22:
  59921 		v23 = v4 * int32(13320) >> int32(8)
  59922 		goto _24
  59923 	_24:
  59924 		v25 = v19 - v21 - v23 + int32(8708)
  59925 		if v25 & ^int32(YUV_MASK2) == 0 {
  59926 			v28 = v25 >> int32(YUV_FIX2)
  59927 		} else {
  59928 			if v25 < 0 {
  59929 				v29 = 0
  59930 			} else {
  59931 				v29 = int32(255)
  59932 			}
  59933 			v28 = v29
  59934 		}
  59935 		v26 = v28
  59936 		goto _27
  59937 	_27:
  59938 		v17 = v26
  59939 		goto _18
  59940 	_18:
  59941 		g = v17
  59942 		v32 = v2 * int32(19077) >> int32(8)
  59943 		goto _33
  59944 	_33:
  59945 		v34 = v3 * int32(33050) >> int32(8)
  59946 		goto _35
  59947 	_35:
  59948 		v36 = v32 + v34 - int32(17685)
  59949 		if v36 & ^int32(YUV_MASK2) == 0 {
  59950 			v39 = v36 >> int32(YUV_FIX2)
  59951 		} else {
  59952 			if v36 < 0 {
  59953 				v40 = 0
  59954 			} else {
  59955 				v40 = int32(255)
  59956 			}
  59957 			v39 = v40
  59958 		}
  59959 		v37 = v39
  59960 		goto _38
  59961 	_38:
  59962 		v30 = v37
  59963 		goto _31
  59964 	_31:
  59965 		b = v30
  59966 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59967 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59968 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(rg)
  59969 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(gb)
  59970 		goto _1
  59971 	_1:
  59972 		;
  59973 		i = i + 1
  59974 	}
  59975 }
  59976 
  59977 func WebPInitYUV444Converters(tls *libc.TLS) {
  59978 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  59979 		goto _1
  59980 	}
  59981 	WebPInitYUV444Converters_body(tls)
  59982 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used)), VP8GetCPUInfo)
  59983 	goto _2
  59984 _2:
  59985 	;
  59986 	goto _1
  59987 _1: /**/ //
  59988 }
  59989 
  59990 var WebPInitYUV444Converters_body_last_cpuinfo_used = uintptr(0)
  59991 
  59992 func init() {
  59993 	p := unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used)
  59994 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used))
  59995 }
  59996 
  59997 func WebPInitYUV444Converters_body(tls *libc.TLS) {
  59998 	WebPYUV444Converters[int32(MODE_RGBA)] = __ccgo_fp(WebPYuv444ToRgba_C)
  59999 	WebPYUV444Converters[int32(MODE_BGRA)] = __ccgo_fp(WebPYuv444ToBgra_C)
  60000 	WebPYUV444Converters[int32(MODE_RGB)] = __ccgo_fp(WebPYuv444ToRgb_C)
  60001 	WebPYUV444Converters[int32(MODE_BGR)] = __ccgo_fp(WebPYuv444ToBgr_C)
  60002 	WebPYUV444Converters[int32(MODE_ARGB)] = __ccgo_fp(WebPYuv444ToArgb_C)
  60003 	WebPYUV444Converters[int32(MODE_RGBA_4444)] = __ccgo_fp(WebPYuv444ToRgba4444_C)
  60004 	WebPYUV444Converters[int32(MODE_RGB_565)] = __ccgo_fp(WebPYuv444ToRgb565_C)
  60005 	WebPYUV444Converters[int32(MODE_rgbA)] = __ccgo_fp(WebPYuv444ToRgba_C)
  60006 	WebPYUV444Converters[int32(MODE_bgrA)] = __ccgo_fp(WebPYuv444ToBgra_C)
  60007 	WebPYUV444Converters[int32(MODE_Argb)] = __ccgo_fp(WebPYuv444ToArgb_C)
  60008 	WebPYUV444Converters[int32(MODE_rgbA_4444)] = __ccgo_fp(WebPYuv444ToRgba4444_C)
  60009 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  60010 	}
  60011 }
  60012 
  60013 func WebPInitUpsamplers(tls *libc.TLS) {
  60014 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  60015 		goto _1
  60016 	}
  60017 	WebPInitUpsamplers_body(tls)
  60018 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used)), VP8GetCPUInfo)
  60019 	goto _2
  60020 _2:
  60021 	;
  60022 	goto _1
  60023 _1: /**/ //
  60024 }
  60025 
  60026 var WebPInitUpsamplers_body_last_cpuinfo_used = uintptr(0)
  60027 
  60028 func init() {
  60029 	p := unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used)
  60030 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used))
  60031 }
  60032 
  60033 func WebPInitUpsamplers_body(tls *libc.TLS) {
  60034 	WebPUpsamplers[int32(MODE_RGBA)] = __ccgo_fp(UpsampleRgbaLinePair_C)
  60035 	WebPUpsamplers[int32(MODE_BGRA)] = __ccgo_fp(UpsampleBgraLinePair_C)
  60036 	WebPUpsamplers[int32(MODE_rgbA)] = __ccgo_fp(UpsampleRgbaLinePair_C)
  60037 	WebPUpsamplers[int32(MODE_bgrA)] = __ccgo_fp(UpsampleBgraLinePair_C)
  60038 	WebPUpsamplers[int32(MODE_RGB)] = __ccgo_fp(UpsampleRgbLinePair_C)
  60039 	WebPUpsamplers[int32(MODE_BGR)] = __ccgo_fp(UpsampleBgrLinePair_C)
  60040 	WebPUpsamplers[int32(MODE_ARGB)] = __ccgo_fp(UpsampleArgbLinePair_C)
  60041 	WebPUpsamplers[int32(MODE_RGBA_4444)] = __ccgo_fp(UpsampleRgba4444LinePair_C)
  60042 	WebPUpsamplers[int32(MODE_RGB_565)] = __ccgo_fp(UpsampleRgb565LinePair_C)
  60043 	WebPUpsamplers[int32(MODE_Argb)] = __ccgo_fp(UpsampleArgbLinePair_C)
  60044 	WebPUpsamplers[int32(MODE_rgbA_4444)] = __ccgo_fp(UpsampleRgba4444LinePair_C)
  60045 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  60046 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  60047 	}
  60048 }
  60049 
  60050 func WebPInitYUV444ConvertersMIPSdspR2(tls *libc.TLS) {
  60051 }
  60052 
  60053 func WebPInitUpsamplersMIPSdspR2(tls *libc.TLS) {
  60054 }
  60055 
  60056 func WebPInitUpsamplersMSA(tls *libc.TLS) {
  60057 }
  60058 
  60059 func WebPInitUpsamplersNEON(tls *libc.TLS) {
  60060 }
  60061 
  60062 func WebPInitYUV444ConvertersSSE2(tls *libc.TLS) {
  60063 }
  60064 
  60065 func WebPInitUpsamplersSSE2(tls *libc.TLS) {
  60066 }
  60067 
  60068 func WebPInitYUV444ConvertersSSE41(tls *libc.TLS) {
  60069 }
  60070 
  60071 func WebPInitUpsamplersSSE41(tls *libc.TLS) {
  60072 }
  60073 
  60074 // Copyright 2010 Google Inc. All Rights Reserved.
  60075 //
  60076 // Use of this source code is governed by a BSD-style license
  60077 // that can be found in the COPYING file in the root of the source
  60078 // tree. An additional intellectual property rights grant can be found
  60079 // in the file PATENTS. All contributing project authors may
  60080 // be found in the AUTHORS file in the root of the source tree.
  60081 // -----------------------------------------------------------------------------
  60082 //
  60083 //  Main decoding functions for WebP images.
  60084 //
  60085 // Author: Skal (pascal.massimino@gmail.com)
  60086 
  60087 //-----------------------------------------------------------------------------
  60088 // Plain-C version
  60089 
  60090 // C documentation
  60091 //
  60092 //	// All variants implemented.
  60093 func YuvToRgbRow(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  60094 	var end, v4 uintptr
  60095 	var v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v51, v7, v9 int32
  60096 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v51, v7, v9
  60097 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(3))
  60098 	for dst != end {
  60099 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60100 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60101 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60102 		v4 = dst
  60103 		v7 = v1 * int32(19077) >> int32(8)
  60104 		goto _8
  60105 	_8:
  60106 		v9 = v3 * int32(26149) >> int32(8)
  60107 		goto _10
  60108 	_10:
  60109 		v11 = v7 + v9 - int32(14234)
  60110 		if v11 & ^int32(YUV_MASK2) == 0 {
  60111 			v14 = v11 >> int32(YUV_FIX2)
  60112 		} else {
  60113 			if v11 < 0 {
  60114 				v15 = 0
  60115 			} else {
  60116 				v15 = int32(255)
  60117 			}
  60118 			v14 = v15
  60119 		}
  60120 		v12 = v14
  60121 		goto _13
  60122 	_13:
  60123 		v51 = v12
  60124 		goto _6
  60125 	_6:
  60126 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60127 		v18 = v1 * int32(19077) >> int32(8)
  60128 		goto _19
  60129 	_19:
  60130 		v20 = v2 * int32(6419) >> int32(8)
  60131 		goto _21
  60132 	_21:
  60133 		v22 = v3 * int32(13320) >> int32(8)
  60134 		goto _23
  60135 	_23:
  60136 		v24 = v18 - v20 - v22 + int32(8708)
  60137 		if v24 & ^int32(YUV_MASK2) == 0 {
  60138 			v27 = v24 >> int32(YUV_FIX2)
  60139 		} else {
  60140 			if v24 < 0 {
  60141 				v28 = 0
  60142 			} else {
  60143 				v28 = int32(255)
  60144 			}
  60145 			v27 = v28
  60146 		}
  60147 		v25 = v27
  60148 		goto _26
  60149 	_26:
  60150 		v16 = v25
  60151 		goto _17
  60152 	_17:
  60153 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60154 		v31 = v1 * int32(19077) >> int32(8)
  60155 		goto _32
  60156 	_32:
  60157 		v33 = v2 * int32(33050) >> int32(8)
  60158 		goto _34
  60159 	_34:
  60160 		v35 = v31 + v33 - int32(17685)
  60161 		if v35 & ^int32(YUV_MASK2) == 0 {
  60162 			v38 = v35 >> int32(YUV_FIX2)
  60163 		} else {
  60164 			if v35 < 0 {
  60165 				v39 = 0
  60166 			} else {
  60167 				v39 = int32(255)
  60168 			}
  60169 			v38 = v39
  60170 		}
  60171 		v36 = v38
  60172 		goto _37
  60173 	_37:
  60174 		v29 = v36
  60175 		goto _30
  60176 	_30:
  60177 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60178 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  60179 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60180 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60181 		v4 = dst + uintptr(libc.Int32FromInt32(3))
  60182 		v7 = v1 * int32(19077) >> int32(8)
  60183 		goto _47
  60184 	_47:
  60185 		v9 = v3 * int32(26149) >> int32(8)
  60186 		goto _49
  60187 	_49:
  60188 		v11 = v7 + v9 - int32(14234)
  60189 		if v11 & ^int32(YUV_MASK2) == 0 {
  60190 			v14 = v11 >> int32(YUV_FIX2)
  60191 		} else {
  60192 			if v11 < 0 {
  60193 				v15 = 0
  60194 			} else {
  60195 				v15 = int32(255)
  60196 			}
  60197 			v14 = v15
  60198 		}
  60199 		v12 = v14
  60200 		goto _52
  60201 	_52:
  60202 		v51 = v12
  60203 		goto _45
  60204 	_45:
  60205 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60206 		v18 = v1 * int32(19077) >> int32(8)
  60207 		goto _58
  60208 	_58:
  60209 		v20 = v2 * int32(6419) >> int32(8)
  60210 		goto _60
  60211 	_60:
  60212 		v22 = v3 * int32(13320) >> int32(8)
  60213 		goto _62
  60214 	_62:
  60215 		v24 = v18 - v20 - v22 + int32(8708)
  60216 		if v24 & ^int32(YUV_MASK2) == 0 {
  60217 			v27 = v24 >> int32(YUV_FIX2)
  60218 		} else {
  60219 			if v24 < 0 {
  60220 				v28 = 0
  60221 			} else {
  60222 				v28 = int32(255)
  60223 			}
  60224 			v27 = v28
  60225 		}
  60226 		v25 = v27
  60227 		goto _65
  60228 	_65:
  60229 		v16 = v25
  60230 		goto _56
  60231 	_56:
  60232 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60233 		v31 = v1 * int32(19077) >> int32(8)
  60234 		goto _71
  60235 	_71:
  60236 		v33 = v2 * int32(33050) >> int32(8)
  60237 		goto _73
  60238 	_73:
  60239 		v35 = v31 + v33 - int32(17685)
  60240 		if v35 & ^int32(YUV_MASK2) == 0 {
  60241 			v38 = v35 >> int32(YUV_FIX2)
  60242 		} else {
  60243 			if v35 < 0 {
  60244 				v39 = 0
  60245 			} else {
  60246 				v39 = int32(255)
  60247 			}
  60248 			v38 = v39
  60249 		}
  60250 		v36 = v38
  60251 		goto _76
  60252 	_76:
  60253 		v29 = v36
  60254 		goto _69
  60255 	_69:
  60256 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60257 		y4 = y4 + uintptr(2)
  60258 		u3 = u3 + 1
  60259 		v5 = v5 + 1
  60260 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(3))
  60261 	}
  60262 	if len1&int32(1) != 0 {
  60263 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60264 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60265 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60266 		v4 = dst
  60267 		v7 = v1 * int32(19077) >> int32(8)
  60268 		goto _86
  60269 	_86:
  60270 		v9 = v3 * int32(26149) >> int32(8)
  60271 		goto _88
  60272 	_88:
  60273 		v11 = v7 + v9 - int32(14234)
  60274 		if v11 & ^int32(YUV_MASK2) == 0 {
  60275 			v14 = v11 >> int32(YUV_FIX2)
  60276 		} else {
  60277 			if v11 < 0 {
  60278 				v15 = 0
  60279 			} else {
  60280 				v15 = int32(255)
  60281 			}
  60282 			v14 = v15
  60283 		}
  60284 		v12 = v14
  60285 		goto _91
  60286 	_91:
  60287 		v51 = v12
  60288 		goto _84
  60289 	_84:
  60290 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60291 		v18 = v1 * int32(19077) >> int32(8)
  60292 		goto _97
  60293 	_97:
  60294 		v20 = v2 * int32(6419) >> int32(8)
  60295 		goto _99
  60296 	_99:
  60297 		v22 = v3 * int32(13320) >> int32(8)
  60298 		goto _101
  60299 	_101:
  60300 		v24 = v18 - v20 - v22 + int32(8708)
  60301 		if v24 & ^int32(YUV_MASK2) == 0 {
  60302 			v27 = v24 >> int32(YUV_FIX2)
  60303 		} else {
  60304 			if v24 < 0 {
  60305 				v28 = 0
  60306 			} else {
  60307 				v28 = int32(255)
  60308 			}
  60309 			v27 = v28
  60310 		}
  60311 		v25 = v27
  60312 		goto _104
  60313 	_104:
  60314 		v16 = v25
  60315 		goto _95
  60316 	_95:
  60317 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60318 		v31 = v1 * int32(19077) >> int32(8)
  60319 		goto _110
  60320 	_110:
  60321 		v33 = v2 * int32(33050) >> int32(8)
  60322 		goto _112
  60323 	_112:
  60324 		v35 = v31 + v33 - int32(17685)
  60325 		if v35 & ^int32(YUV_MASK2) == 0 {
  60326 			v38 = v35 >> int32(YUV_FIX2)
  60327 		} else {
  60328 			if v35 < 0 {
  60329 				v39 = 0
  60330 			} else {
  60331 				v39 = int32(255)
  60332 			}
  60333 			v38 = v39
  60334 		}
  60335 		v36 = v38
  60336 		goto _115
  60337 	_115:
  60338 		v29 = v36
  60339 		goto _108
  60340 	_108:
  60341 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60342 	}
  60343 }
  60344 
  60345 func YuvToBgrRow(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  60346 	var end, v4 uintptr
  60347 	var v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v51, v7, v9 int32
  60348 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v51, v7, v9
  60349 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(3))
  60350 	for dst != end {
  60351 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60352 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60353 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60354 		v4 = dst
  60355 		v7 = v1 * int32(19077) >> int32(8)
  60356 		goto _8
  60357 	_8:
  60358 		v9 = v2 * int32(33050) >> int32(8)
  60359 		goto _10
  60360 	_10:
  60361 		v11 = v7 + v9 - int32(17685)
  60362 		if v11 & ^int32(YUV_MASK2) == 0 {
  60363 			v14 = v11 >> int32(YUV_FIX2)
  60364 		} else {
  60365 			if v11 < 0 {
  60366 				v15 = 0
  60367 			} else {
  60368 				v15 = int32(255)
  60369 			}
  60370 			v14 = v15
  60371 		}
  60372 		v12 = v14
  60373 		goto _13
  60374 	_13:
  60375 		v51 = v12
  60376 		goto _6
  60377 	_6:
  60378 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60379 		v18 = v1 * int32(19077) >> int32(8)
  60380 		goto _19
  60381 	_19:
  60382 		v20 = v2 * int32(6419) >> int32(8)
  60383 		goto _21
  60384 	_21:
  60385 		v22 = v3 * int32(13320) >> int32(8)
  60386 		goto _23
  60387 	_23:
  60388 		v24 = v18 - v20 - v22 + int32(8708)
  60389 		if v24 & ^int32(YUV_MASK2) == 0 {
  60390 			v27 = v24 >> int32(YUV_FIX2)
  60391 		} else {
  60392 			if v24 < 0 {
  60393 				v28 = 0
  60394 			} else {
  60395 				v28 = int32(255)
  60396 			}
  60397 			v27 = v28
  60398 		}
  60399 		v25 = v27
  60400 		goto _26
  60401 	_26:
  60402 		v16 = v25
  60403 		goto _17
  60404 	_17:
  60405 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60406 		v31 = v1 * int32(19077) >> int32(8)
  60407 		goto _32
  60408 	_32:
  60409 		v33 = v3 * int32(26149) >> int32(8)
  60410 		goto _34
  60411 	_34:
  60412 		v35 = v31 + v33 - int32(14234)
  60413 		if v35 & ^int32(YUV_MASK2) == 0 {
  60414 			v38 = v35 >> int32(YUV_FIX2)
  60415 		} else {
  60416 			if v35 < 0 {
  60417 				v39 = 0
  60418 			} else {
  60419 				v39 = int32(255)
  60420 			}
  60421 			v38 = v39
  60422 		}
  60423 		v36 = v38
  60424 		goto _37
  60425 	_37:
  60426 		v29 = v36
  60427 		goto _30
  60428 	_30:
  60429 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60430 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  60431 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60432 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60433 		v4 = dst + uintptr(libc.Int32FromInt32(3))
  60434 		v7 = v1 * int32(19077) >> int32(8)
  60435 		goto _47
  60436 	_47:
  60437 		v9 = v2 * int32(33050) >> int32(8)
  60438 		goto _49
  60439 	_49:
  60440 		v11 = v7 + v9 - int32(17685)
  60441 		if v11 & ^int32(YUV_MASK2) == 0 {
  60442 			v14 = v11 >> int32(YUV_FIX2)
  60443 		} else {
  60444 			if v11 < 0 {
  60445 				v15 = 0
  60446 			} else {
  60447 				v15 = int32(255)
  60448 			}
  60449 			v14 = v15
  60450 		}
  60451 		v12 = v14
  60452 		goto _52
  60453 	_52:
  60454 		v51 = v12
  60455 		goto _45
  60456 	_45:
  60457 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60458 		v18 = v1 * int32(19077) >> int32(8)
  60459 		goto _58
  60460 	_58:
  60461 		v20 = v2 * int32(6419) >> int32(8)
  60462 		goto _60
  60463 	_60:
  60464 		v22 = v3 * int32(13320) >> int32(8)
  60465 		goto _62
  60466 	_62:
  60467 		v24 = v18 - v20 - v22 + int32(8708)
  60468 		if v24 & ^int32(YUV_MASK2) == 0 {
  60469 			v27 = v24 >> int32(YUV_FIX2)
  60470 		} else {
  60471 			if v24 < 0 {
  60472 				v28 = 0
  60473 			} else {
  60474 				v28 = int32(255)
  60475 			}
  60476 			v27 = v28
  60477 		}
  60478 		v25 = v27
  60479 		goto _65
  60480 	_65:
  60481 		v16 = v25
  60482 		goto _56
  60483 	_56:
  60484 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60485 		v31 = v1 * int32(19077) >> int32(8)
  60486 		goto _71
  60487 	_71:
  60488 		v33 = v3 * int32(26149) >> int32(8)
  60489 		goto _73
  60490 	_73:
  60491 		v35 = v31 + v33 - int32(14234)
  60492 		if v35 & ^int32(YUV_MASK2) == 0 {
  60493 			v38 = v35 >> int32(YUV_FIX2)
  60494 		} else {
  60495 			if v35 < 0 {
  60496 				v39 = 0
  60497 			} else {
  60498 				v39 = int32(255)
  60499 			}
  60500 			v38 = v39
  60501 		}
  60502 		v36 = v38
  60503 		goto _76
  60504 	_76:
  60505 		v29 = v36
  60506 		goto _69
  60507 	_69:
  60508 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60509 		y4 = y4 + uintptr(2)
  60510 		u3 = u3 + 1
  60511 		v5 = v5 + 1
  60512 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(3))
  60513 	}
  60514 	if len1&int32(1) != 0 {
  60515 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60516 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60517 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60518 		v4 = dst
  60519 		v7 = v1 * int32(19077) >> int32(8)
  60520 		goto _86
  60521 	_86:
  60522 		v9 = v2 * int32(33050) >> int32(8)
  60523 		goto _88
  60524 	_88:
  60525 		v11 = v7 + v9 - int32(17685)
  60526 		if v11 & ^int32(YUV_MASK2) == 0 {
  60527 			v14 = v11 >> int32(YUV_FIX2)
  60528 		} else {
  60529 			if v11 < 0 {
  60530 				v15 = 0
  60531 			} else {
  60532 				v15 = int32(255)
  60533 			}
  60534 			v14 = v15
  60535 		}
  60536 		v12 = v14
  60537 		goto _91
  60538 	_91:
  60539 		v51 = v12
  60540 		goto _84
  60541 	_84:
  60542 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60543 		v18 = v1 * int32(19077) >> int32(8)
  60544 		goto _97
  60545 	_97:
  60546 		v20 = v2 * int32(6419) >> int32(8)
  60547 		goto _99
  60548 	_99:
  60549 		v22 = v3 * int32(13320) >> int32(8)
  60550 		goto _101
  60551 	_101:
  60552 		v24 = v18 - v20 - v22 + int32(8708)
  60553 		if v24 & ^int32(YUV_MASK2) == 0 {
  60554 			v27 = v24 >> int32(YUV_FIX2)
  60555 		} else {
  60556 			if v24 < 0 {
  60557 				v28 = 0
  60558 			} else {
  60559 				v28 = int32(255)
  60560 			}
  60561 			v27 = v28
  60562 		}
  60563 		v25 = v27
  60564 		goto _104
  60565 	_104:
  60566 		v16 = v25
  60567 		goto _95
  60568 	_95:
  60569 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60570 		v31 = v1 * int32(19077) >> int32(8)
  60571 		goto _110
  60572 	_110:
  60573 		v33 = v3 * int32(26149) >> int32(8)
  60574 		goto _112
  60575 	_112:
  60576 		v35 = v31 + v33 - int32(14234)
  60577 		if v35 & ^int32(YUV_MASK2) == 0 {
  60578 			v38 = v35 >> int32(YUV_FIX2)
  60579 		} else {
  60580 			if v35 < 0 {
  60581 				v39 = 0
  60582 			} else {
  60583 				v39 = int32(255)
  60584 			}
  60585 			v38 = v39
  60586 		}
  60587 		v36 = v38
  60588 		goto _115
  60589 	_115:
  60590 		v29 = v36
  60591 		goto _108
  60592 	_108:
  60593 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60594 	}
  60595 }
  60596 
  60597 func YuvToRgbaRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  60598 	var end, v1, v5 uintptr
  60599 	var v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v61, v8 int32
  60600 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v61, v8
  60601 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  60602 	for dst != end {
  60603 		v1 = dst
  60604 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60605 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60606 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60607 		v5 = v1
  60608 		v8 = v2 * int32(19077) >> int32(8)
  60609 		goto _9
  60610 	_9:
  60611 		v10 = v4 * int32(26149) >> int32(8)
  60612 		goto _11
  60613 	_11:
  60614 		v12 = v8 + v10 - int32(14234)
  60615 		if v12 & ^int32(YUV_MASK2) == 0 {
  60616 			v15 = v12 >> int32(YUV_FIX2)
  60617 		} else {
  60618 			if v12 < 0 {
  60619 				v16 = 0
  60620 			} else {
  60621 				v16 = int32(255)
  60622 			}
  60623 			v15 = v16
  60624 		}
  60625 		v13 = v15
  60626 		goto _14
  60627 	_14:
  60628 		v61 = v13
  60629 		goto _7
  60630 	_7:
  60631 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60632 		v19 = v2 * int32(19077) >> int32(8)
  60633 		goto _20
  60634 	_20:
  60635 		v21 = v3 * int32(6419) >> int32(8)
  60636 		goto _22
  60637 	_22:
  60638 		v23 = v4 * int32(13320) >> int32(8)
  60639 		goto _24
  60640 	_24:
  60641 		v25 = v19 - v21 - v23 + int32(8708)
  60642 		if v25 & ^int32(YUV_MASK2) == 0 {
  60643 			v28 = v25 >> int32(YUV_FIX2)
  60644 		} else {
  60645 			if v25 < 0 {
  60646 				v29 = 0
  60647 			} else {
  60648 				v29 = int32(255)
  60649 			}
  60650 			v28 = v29
  60651 		}
  60652 		v26 = v28
  60653 		goto _27
  60654 	_27:
  60655 		v17 = v26
  60656 		goto _18
  60657 	_18:
  60658 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60659 		v32 = v2 * int32(19077) >> int32(8)
  60660 		goto _33
  60661 	_33:
  60662 		v34 = v3 * int32(33050) >> int32(8)
  60663 		goto _35
  60664 	_35:
  60665 		v36 = v32 + v34 - int32(17685)
  60666 		if v36 & ^int32(YUV_MASK2) == 0 {
  60667 			v39 = v36 >> int32(YUV_FIX2)
  60668 		} else {
  60669 			if v36 < 0 {
  60670 				v40 = 0
  60671 			} else {
  60672 				v40 = int32(255)
  60673 			}
  60674 			v39 = v40
  60675 		}
  60676 		v37 = v39
  60677 		goto _38
  60678 	_38:
  60679 		v30 = v37
  60680 		goto _31
  60681 	_31:
  60682 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60683 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60684 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  60685 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  60686 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60687 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60688 		v5 = v1
  60689 		v8 = v2 * int32(19077) >> int32(8)
  60690 		goto _49
  60691 	_49:
  60692 		v10 = v4 * int32(26149) >> int32(8)
  60693 		goto _51
  60694 	_51:
  60695 		v12 = v8 + v10 - int32(14234)
  60696 		if v12 & ^int32(YUV_MASK2) == 0 {
  60697 			v15 = v12 >> int32(YUV_FIX2)
  60698 		} else {
  60699 			if v12 < 0 {
  60700 				v16 = 0
  60701 			} else {
  60702 				v16 = int32(255)
  60703 			}
  60704 			v15 = v16
  60705 		}
  60706 		v13 = v15
  60707 		goto _54
  60708 	_54:
  60709 		v61 = v13
  60710 		goto _47
  60711 	_47:
  60712 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60713 		v19 = v2 * int32(19077) >> int32(8)
  60714 		goto _60
  60715 	_60:
  60716 		v21 = v3 * int32(6419) >> int32(8)
  60717 		goto _62
  60718 	_62:
  60719 		v23 = v4 * int32(13320) >> int32(8)
  60720 		goto _64
  60721 	_64:
  60722 		v25 = v19 - v21 - v23 + int32(8708)
  60723 		if v25 & ^int32(YUV_MASK2) == 0 {
  60724 			v28 = v25 >> int32(YUV_FIX2)
  60725 		} else {
  60726 			if v25 < 0 {
  60727 				v29 = 0
  60728 			} else {
  60729 				v29 = int32(255)
  60730 			}
  60731 			v28 = v29
  60732 		}
  60733 		v26 = v28
  60734 		goto _67
  60735 	_67:
  60736 		v17 = v26
  60737 		goto _58
  60738 	_58:
  60739 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60740 		v32 = v2 * int32(19077) >> int32(8)
  60741 		goto _73
  60742 	_73:
  60743 		v34 = v3 * int32(33050) >> int32(8)
  60744 		goto _75
  60745 	_75:
  60746 		v36 = v32 + v34 - int32(17685)
  60747 		if v36 & ^int32(YUV_MASK2) == 0 {
  60748 			v39 = v36 >> int32(YUV_FIX2)
  60749 		} else {
  60750 			if v36 < 0 {
  60751 				v40 = 0
  60752 			} else {
  60753 				v40 = int32(255)
  60754 			}
  60755 			v39 = v40
  60756 		}
  60757 		v37 = v39
  60758 		goto _78
  60759 	_78:
  60760 		v30 = v37
  60761 		goto _71
  60762 	_71:
  60763 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60764 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60765 		y5 = y5 + uintptr(2)
  60766 		u4 = u4 + 1
  60767 		v6 = v6 + 1
  60768 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  60769 	}
  60770 	if len1&int32(1) != 0 {
  60771 		v1 = dst
  60772 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60773 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60774 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60775 		v5 = v1
  60776 		v8 = v2 * int32(19077) >> int32(8)
  60777 		goto _89
  60778 	_89:
  60779 		v10 = v4 * int32(26149) >> int32(8)
  60780 		goto _91
  60781 	_91:
  60782 		v12 = v8 + v10 - int32(14234)
  60783 		if v12 & ^int32(YUV_MASK2) == 0 {
  60784 			v15 = v12 >> int32(YUV_FIX2)
  60785 		} else {
  60786 			if v12 < 0 {
  60787 				v16 = 0
  60788 			} else {
  60789 				v16 = int32(255)
  60790 			}
  60791 			v15 = v16
  60792 		}
  60793 		v13 = v15
  60794 		goto _94
  60795 	_94:
  60796 		v61 = v13
  60797 		goto _87
  60798 	_87:
  60799 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60800 		v19 = v2 * int32(19077) >> int32(8)
  60801 		goto _100
  60802 	_100:
  60803 		v21 = v3 * int32(6419) >> int32(8)
  60804 		goto _102
  60805 	_102:
  60806 		v23 = v4 * int32(13320) >> int32(8)
  60807 		goto _104
  60808 	_104:
  60809 		v25 = v19 - v21 - v23 + int32(8708)
  60810 		if v25 & ^int32(YUV_MASK2) == 0 {
  60811 			v28 = v25 >> int32(YUV_FIX2)
  60812 		} else {
  60813 			if v25 < 0 {
  60814 				v29 = 0
  60815 			} else {
  60816 				v29 = int32(255)
  60817 			}
  60818 			v28 = v29
  60819 		}
  60820 		v26 = v28
  60821 		goto _107
  60822 	_107:
  60823 		v17 = v26
  60824 		goto _98
  60825 	_98:
  60826 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60827 		v32 = v2 * int32(19077) >> int32(8)
  60828 		goto _113
  60829 	_113:
  60830 		v34 = v3 * int32(33050) >> int32(8)
  60831 		goto _115
  60832 	_115:
  60833 		v36 = v32 + v34 - int32(17685)
  60834 		if v36 & ^int32(YUV_MASK2) == 0 {
  60835 			v39 = v36 >> int32(YUV_FIX2)
  60836 		} else {
  60837 			if v36 < 0 {
  60838 				v40 = 0
  60839 			} else {
  60840 				v40 = int32(255)
  60841 			}
  60842 			v39 = v40
  60843 		}
  60844 		v37 = v39
  60845 		goto _118
  60846 	_118:
  60847 		v30 = v37
  60848 		goto _111
  60849 	_111:
  60850 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60851 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60852 	}
  60853 }
  60854 
  60855 func YuvToBgraRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  60856 	var end, v1, v5 uintptr
  60857 	var v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v61, v8 int32
  60858 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v61, v8
  60859 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  60860 	for dst != end {
  60861 		v1 = dst
  60862 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60863 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60864 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60865 		v5 = v1
  60866 		v8 = v2 * int32(19077) >> int32(8)
  60867 		goto _9
  60868 	_9:
  60869 		v10 = v3 * int32(33050) >> int32(8)
  60870 		goto _11
  60871 	_11:
  60872 		v12 = v8 + v10 - int32(17685)
  60873 		if v12 & ^int32(YUV_MASK2) == 0 {
  60874 			v15 = v12 >> int32(YUV_FIX2)
  60875 		} else {
  60876 			if v12 < 0 {
  60877 				v16 = 0
  60878 			} else {
  60879 				v16 = int32(255)
  60880 			}
  60881 			v15 = v16
  60882 		}
  60883 		v13 = v15
  60884 		goto _14
  60885 	_14:
  60886 		v61 = v13
  60887 		goto _7
  60888 	_7:
  60889 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60890 		v19 = v2 * int32(19077) >> int32(8)
  60891 		goto _20
  60892 	_20:
  60893 		v21 = v3 * int32(6419) >> int32(8)
  60894 		goto _22
  60895 	_22:
  60896 		v23 = v4 * int32(13320) >> int32(8)
  60897 		goto _24
  60898 	_24:
  60899 		v25 = v19 - v21 - v23 + int32(8708)
  60900 		if v25 & ^int32(YUV_MASK2) == 0 {
  60901 			v28 = v25 >> int32(YUV_FIX2)
  60902 		} else {
  60903 			if v25 < 0 {
  60904 				v29 = 0
  60905 			} else {
  60906 				v29 = int32(255)
  60907 			}
  60908 			v28 = v29
  60909 		}
  60910 		v26 = v28
  60911 		goto _27
  60912 	_27:
  60913 		v17 = v26
  60914 		goto _18
  60915 	_18:
  60916 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60917 		v32 = v2 * int32(19077) >> int32(8)
  60918 		goto _33
  60919 	_33:
  60920 		v34 = v4 * int32(26149) >> int32(8)
  60921 		goto _35
  60922 	_35:
  60923 		v36 = v32 + v34 - int32(14234)
  60924 		if v36 & ^int32(YUV_MASK2) == 0 {
  60925 			v39 = v36 >> int32(YUV_FIX2)
  60926 		} else {
  60927 			if v36 < 0 {
  60928 				v40 = 0
  60929 			} else {
  60930 				v40 = int32(255)
  60931 			}
  60932 			v39 = v40
  60933 		}
  60934 		v37 = v39
  60935 		goto _38
  60936 	_38:
  60937 		v30 = v37
  60938 		goto _31
  60939 	_31:
  60940 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60941 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60942 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  60943 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  60944 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60945 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60946 		v5 = v1
  60947 		v8 = v2 * int32(19077) >> int32(8)
  60948 		goto _49
  60949 	_49:
  60950 		v10 = v3 * int32(33050) >> int32(8)
  60951 		goto _51
  60952 	_51:
  60953 		v12 = v8 + v10 - int32(17685)
  60954 		if v12 & ^int32(YUV_MASK2) == 0 {
  60955 			v15 = v12 >> int32(YUV_FIX2)
  60956 		} else {
  60957 			if v12 < 0 {
  60958 				v16 = 0
  60959 			} else {
  60960 				v16 = int32(255)
  60961 			}
  60962 			v15 = v16
  60963 		}
  60964 		v13 = v15
  60965 		goto _54
  60966 	_54:
  60967 		v61 = v13
  60968 		goto _47
  60969 	_47:
  60970 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60971 		v19 = v2 * int32(19077) >> int32(8)
  60972 		goto _60
  60973 	_60:
  60974 		v21 = v3 * int32(6419) >> int32(8)
  60975 		goto _62
  60976 	_62:
  60977 		v23 = v4 * int32(13320) >> int32(8)
  60978 		goto _64
  60979 	_64:
  60980 		v25 = v19 - v21 - v23 + int32(8708)
  60981 		if v25 & ^int32(YUV_MASK2) == 0 {
  60982 			v28 = v25 >> int32(YUV_FIX2)
  60983 		} else {
  60984 			if v25 < 0 {
  60985 				v29 = 0
  60986 			} else {
  60987 				v29 = int32(255)
  60988 			}
  60989 			v28 = v29
  60990 		}
  60991 		v26 = v28
  60992 		goto _67
  60993 	_67:
  60994 		v17 = v26
  60995 		goto _58
  60996 	_58:
  60997 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60998 		v32 = v2 * int32(19077) >> int32(8)
  60999 		goto _73
  61000 	_73:
  61001 		v34 = v4 * int32(26149) >> int32(8)
  61002 		goto _75
  61003 	_75:
  61004 		v36 = v32 + v34 - int32(14234)
  61005 		if v36 & ^int32(YUV_MASK2) == 0 {
  61006 			v39 = v36 >> int32(YUV_FIX2)
  61007 		} else {
  61008 			if v36 < 0 {
  61009 				v40 = 0
  61010 			} else {
  61011 				v40 = int32(255)
  61012 			}
  61013 			v39 = v40
  61014 		}
  61015 		v37 = v39
  61016 		goto _78
  61017 	_78:
  61018 		v30 = v37
  61019 		goto _71
  61020 	_71:
  61021 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61022 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  61023 		y5 = y5 + uintptr(2)
  61024 		u4 = u4 + 1
  61025 		v6 = v6 + 1
  61026 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  61027 	}
  61028 	if len1&int32(1) != 0 {
  61029 		v1 = dst
  61030 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61031 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61032 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61033 		v5 = v1
  61034 		v8 = v2 * int32(19077) >> int32(8)
  61035 		goto _89
  61036 	_89:
  61037 		v10 = v3 * int32(33050) >> int32(8)
  61038 		goto _91
  61039 	_91:
  61040 		v12 = v8 + v10 - int32(17685)
  61041 		if v12 & ^int32(YUV_MASK2) == 0 {
  61042 			v15 = v12 >> int32(YUV_FIX2)
  61043 		} else {
  61044 			if v12 < 0 {
  61045 				v16 = 0
  61046 			} else {
  61047 				v16 = int32(255)
  61048 			}
  61049 			v15 = v16
  61050 		}
  61051 		v13 = v15
  61052 		goto _94
  61053 	_94:
  61054 		v61 = v13
  61055 		goto _87
  61056 	_87:
  61057 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61058 		v19 = v2 * int32(19077) >> int32(8)
  61059 		goto _100
  61060 	_100:
  61061 		v21 = v3 * int32(6419) >> int32(8)
  61062 		goto _102
  61063 	_102:
  61064 		v23 = v4 * int32(13320) >> int32(8)
  61065 		goto _104
  61066 	_104:
  61067 		v25 = v19 - v21 - v23 + int32(8708)
  61068 		if v25 & ^int32(YUV_MASK2) == 0 {
  61069 			v28 = v25 >> int32(YUV_FIX2)
  61070 		} else {
  61071 			if v25 < 0 {
  61072 				v29 = 0
  61073 			} else {
  61074 				v29 = int32(255)
  61075 			}
  61076 			v28 = v29
  61077 		}
  61078 		v26 = v28
  61079 		goto _107
  61080 	_107:
  61081 		v17 = v26
  61082 		goto _98
  61083 	_98:
  61084 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61085 		v32 = v2 * int32(19077) >> int32(8)
  61086 		goto _113
  61087 	_113:
  61088 		v34 = v4 * int32(26149) >> int32(8)
  61089 		goto _115
  61090 	_115:
  61091 		v36 = v32 + v34 - int32(14234)
  61092 		if v36 & ^int32(YUV_MASK2) == 0 {
  61093 			v39 = v36 >> int32(YUV_FIX2)
  61094 		} else {
  61095 			if v36 < 0 {
  61096 				v40 = 0
  61097 			} else {
  61098 				v40 = int32(255)
  61099 			}
  61100 			v39 = v40
  61101 		}
  61102 		v37 = v39
  61103 		goto _118
  61104 	_118:
  61105 		v30 = v37
  61106 		goto _111
  61107 	_111:
  61108 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61109 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  61110 	}
  61111 }
  61112 
  61113 func YuvToArgbRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  61114 	var end, v1, v5 uintptr
  61115 	var v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v61, v8 int32
  61116 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, v1, v10, v12, v13, v15, v16, v17, v19, v2, v21, v23, v25, v26, v28, v29, v3, v30, v32, v34, v36, v37, v39, v4, v40, v5, v61, v8
  61117 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  61118 	for dst != end {
  61119 		v1 = dst
  61120 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61121 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61122 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61123 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61124 		v5 = v1 + uintptr(1)
  61125 		v8 = v2 * int32(19077) >> int32(8)
  61126 		goto _9
  61127 	_9:
  61128 		v10 = v4 * int32(26149) >> int32(8)
  61129 		goto _11
  61130 	_11:
  61131 		v12 = v8 + v10 - int32(14234)
  61132 		if v12 & ^int32(YUV_MASK2) == 0 {
  61133 			v15 = v12 >> int32(YUV_FIX2)
  61134 		} else {
  61135 			if v12 < 0 {
  61136 				v16 = 0
  61137 			} else {
  61138 				v16 = int32(255)
  61139 			}
  61140 			v15 = v16
  61141 		}
  61142 		v13 = v15
  61143 		goto _14
  61144 	_14:
  61145 		v61 = v13
  61146 		goto _7
  61147 	_7:
  61148 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61149 		v19 = v2 * int32(19077) >> int32(8)
  61150 		goto _20
  61151 	_20:
  61152 		v21 = v3 * int32(6419) >> int32(8)
  61153 		goto _22
  61154 	_22:
  61155 		v23 = v4 * int32(13320) >> int32(8)
  61156 		goto _24
  61157 	_24:
  61158 		v25 = v19 - v21 - v23 + int32(8708)
  61159 		if v25 & ^int32(YUV_MASK2) == 0 {
  61160 			v28 = v25 >> int32(YUV_FIX2)
  61161 		} else {
  61162 			if v25 < 0 {
  61163 				v29 = 0
  61164 			} else {
  61165 				v29 = int32(255)
  61166 			}
  61167 			v28 = v29
  61168 		}
  61169 		v26 = v28
  61170 		goto _27
  61171 	_27:
  61172 		v17 = v26
  61173 		goto _18
  61174 	_18:
  61175 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61176 		v32 = v2 * int32(19077) >> int32(8)
  61177 		goto _33
  61178 	_33:
  61179 		v34 = v3 * int32(33050) >> int32(8)
  61180 		goto _35
  61181 	_35:
  61182 		v36 = v32 + v34 - int32(17685)
  61183 		if v36 & ^int32(YUV_MASK2) == 0 {
  61184 			v39 = v36 >> int32(YUV_FIX2)
  61185 		} else {
  61186 			if v36 < 0 {
  61187 				v40 = 0
  61188 			} else {
  61189 				v40 = int32(255)
  61190 			}
  61191 			v39 = v40
  61192 		}
  61193 		v37 = v39
  61194 		goto _38
  61195 	_38:
  61196 		v30 = v37
  61197 		goto _31
  61198 	_31:
  61199 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61200 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  61201 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61202 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  61203 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61204 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61205 		v5 = v1 + uintptr(1)
  61206 		v8 = v2 * int32(19077) >> int32(8)
  61207 		goto _49
  61208 	_49:
  61209 		v10 = v4 * int32(26149) >> int32(8)
  61210 		goto _51
  61211 	_51:
  61212 		v12 = v8 + v10 - int32(14234)
  61213 		if v12 & ^int32(YUV_MASK2) == 0 {
  61214 			v15 = v12 >> int32(YUV_FIX2)
  61215 		} else {
  61216 			if v12 < 0 {
  61217 				v16 = 0
  61218 			} else {
  61219 				v16 = int32(255)
  61220 			}
  61221 			v15 = v16
  61222 		}
  61223 		v13 = v15
  61224 		goto _54
  61225 	_54:
  61226 		v61 = v13
  61227 		goto _47
  61228 	_47:
  61229 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61230 		v19 = v2 * int32(19077) >> int32(8)
  61231 		goto _60
  61232 	_60:
  61233 		v21 = v3 * int32(6419) >> int32(8)
  61234 		goto _62
  61235 	_62:
  61236 		v23 = v4 * int32(13320) >> int32(8)
  61237 		goto _64
  61238 	_64:
  61239 		v25 = v19 - v21 - v23 + int32(8708)
  61240 		if v25 & ^int32(YUV_MASK2) == 0 {
  61241 			v28 = v25 >> int32(YUV_FIX2)
  61242 		} else {
  61243 			if v25 < 0 {
  61244 				v29 = 0
  61245 			} else {
  61246 				v29 = int32(255)
  61247 			}
  61248 			v28 = v29
  61249 		}
  61250 		v26 = v28
  61251 		goto _67
  61252 	_67:
  61253 		v17 = v26
  61254 		goto _58
  61255 	_58:
  61256 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61257 		v32 = v2 * int32(19077) >> int32(8)
  61258 		goto _73
  61259 	_73:
  61260 		v34 = v3 * int32(33050) >> int32(8)
  61261 		goto _75
  61262 	_75:
  61263 		v36 = v32 + v34 - int32(17685)
  61264 		if v36 & ^int32(YUV_MASK2) == 0 {
  61265 			v39 = v36 >> int32(YUV_FIX2)
  61266 		} else {
  61267 			if v36 < 0 {
  61268 				v40 = 0
  61269 			} else {
  61270 				v40 = int32(255)
  61271 			}
  61272 			v39 = v40
  61273 		}
  61274 		v37 = v39
  61275 		goto _78
  61276 	_78:
  61277 		v30 = v37
  61278 		goto _71
  61279 	_71:
  61280 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61281 		y5 = y5 + uintptr(2)
  61282 		u4 = u4 + 1
  61283 		v6 = v6 + 1
  61284 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  61285 	}
  61286 	if len1&int32(1) != 0 {
  61287 		v1 = dst
  61288 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61289 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61290 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61291 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61292 		v5 = v1 + uintptr(1)
  61293 		v8 = v2 * int32(19077) >> int32(8)
  61294 		goto _89
  61295 	_89:
  61296 		v10 = v4 * int32(26149) >> int32(8)
  61297 		goto _91
  61298 	_91:
  61299 		v12 = v8 + v10 - int32(14234)
  61300 		if v12 & ^int32(YUV_MASK2) == 0 {
  61301 			v15 = v12 >> int32(YUV_FIX2)
  61302 		} else {
  61303 			if v12 < 0 {
  61304 				v16 = 0
  61305 			} else {
  61306 				v16 = int32(255)
  61307 			}
  61308 			v15 = v16
  61309 		}
  61310 		v13 = v15
  61311 		goto _94
  61312 	_94:
  61313 		v61 = v13
  61314 		goto _87
  61315 	_87:
  61316 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61317 		v19 = v2 * int32(19077) >> int32(8)
  61318 		goto _100
  61319 	_100:
  61320 		v21 = v3 * int32(6419) >> int32(8)
  61321 		goto _102
  61322 	_102:
  61323 		v23 = v4 * int32(13320) >> int32(8)
  61324 		goto _104
  61325 	_104:
  61326 		v25 = v19 - v21 - v23 + int32(8708)
  61327 		if v25 & ^int32(YUV_MASK2) == 0 {
  61328 			v28 = v25 >> int32(YUV_FIX2)
  61329 		} else {
  61330 			if v25 < 0 {
  61331 				v29 = 0
  61332 			} else {
  61333 				v29 = int32(255)
  61334 			}
  61335 			v28 = v29
  61336 		}
  61337 		v26 = v28
  61338 		goto _107
  61339 	_107:
  61340 		v17 = v26
  61341 		goto _98
  61342 	_98:
  61343 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61344 		v32 = v2 * int32(19077) >> int32(8)
  61345 		goto _113
  61346 	_113:
  61347 		v34 = v3 * int32(33050) >> int32(8)
  61348 		goto _115
  61349 	_115:
  61350 		v36 = v32 + v34 - int32(17685)
  61351 		if v36 & ^int32(YUV_MASK2) == 0 {
  61352 			v39 = v36 >> int32(YUV_FIX2)
  61353 		} else {
  61354 			if v36 < 0 {
  61355 				v40 = 0
  61356 			} else {
  61357 				v40 = int32(255)
  61358 			}
  61359 			v39 = v40
  61360 		}
  61361 		v37 = v39
  61362 		goto _118
  61363 	_118:
  61364 		v30 = v37
  61365 		goto _111
  61366 	_111:
  61367 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61368 	}
  61369 }
  61370 
  61371 func YuvToRgba4444Row(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  61372 	var b, ba, g, r, rg, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v51, v7, v9 int32
  61373 	var end, v4 uintptr
  61374 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, ba, end, g, r, rg, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v51, v7, v9
  61375 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(2))
  61376 	for dst != end {
  61377 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61378 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61379 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61380 		v4 = dst
  61381 		v7 = v1 * int32(19077) >> int32(8)
  61382 		goto _8
  61383 	_8:
  61384 		v9 = v3 * int32(26149) >> int32(8)
  61385 		goto _10
  61386 	_10:
  61387 		v11 = v7 + v9 - int32(14234)
  61388 		if v11 & ^int32(YUV_MASK2) == 0 {
  61389 			v14 = v11 >> int32(YUV_FIX2)
  61390 		} else {
  61391 			if v11 < 0 {
  61392 				v15 = 0
  61393 			} else {
  61394 				v15 = int32(255)
  61395 			}
  61396 			v14 = v15
  61397 		}
  61398 		v12 = v14
  61399 		goto _13
  61400 	_13:
  61401 		v51 = v12
  61402 		goto _6
  61403 	_6:
  61404 		r = v51
  61405 		v18 = v1 * int32(19077) >> int32(8)
  61406 		goto _19
  61407 	_19:
  61408 		v20 = v2 * int32(6419) >> int32(8)
  61409 		goto _21
  61410 	_21:
  61411 		v22 = v3 * int32(13320) >> int32(8)
  61412 		goto _23
  61413 	_23:
  61414 		v24 = v18 - v20 - v22 + int32(8708)
  61415 		if v24 & ^int32(YUV_MASK2) == 0 {
  61416 			v27 = v24 >> int32(YUV_FIX2)
  61417 		} else {
  61418 			if v24 < 0 {
  61419 				v28 = 0
  61420 			} else {
  61421 				v28 = int32(255)
  61422 			}
  61423 			v27 = v28
  61424 		}
  61425 		v25 = v27
  61426 		goto _26
  61427 	_26:
  61428 		v16 = v25
  61429 		goto _17
  61430 	_17:
  61431 		g = v16
  61432 		v31 = v1 * int32(19077) >> int32(8)
  61433 		goto _32
  61434 	_32:
  61435 		v33 = v2 * int32(33050) >> int32(8)
  61436 		goto _34
  61437 	_34:
  61438 		v35 = v31 + v33 - int32(17685)
  61439 		if v35 & ^int32(YUV_MASK2) == 0 {
  61440 			v38 = v35 >> int32(YUV_FIX2)
  61441 		} else {
  61442 			if v35 < 0 {
  61443 				v39 = 0
  61444 			} else {
  61445 				v39 = int32(255)
  61446 			}
  61447 			v38 = v39
  61448 		}
  61449 		v36 = v38
  61450 		goto _37
  61451 	_37:
  61452 		v29 = v36
  61453 		goto _30
  61454 	_30:
  61455 		b = v29
  61456 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61457 		ba = b&int32(0xf0) | int32(0x0f)
  61458 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61459 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61460 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  61461 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61462 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61463 		v4 = dst + uintptr(libc.Int32FromInt32(2))
  61464 		v7 = v1 * int32(19077) >> int32(8)
  61465 		goto _47
  61466 	_47:
  61467 		v9 = v3 * int32(26149) >> int32(8)
  61468 		goto _49
  61469 	_49:
  61470 		v11 = v7 + v9 - int32(14234)
  61471 		if v11 & ^int32(YUV_MASK2) == 0 {
  61472 			v14 = v11 >> int32(YUV_FIX2)
  61473 		} else {
  61474 			if v11 < 0 {
  61475 				v15 = 0
  61476 			} else {
  61477 				v15 = int32(255)
  61478 			}
  61479 			v14 = v15
  61480 		}
  61481 		v12 = v14
  61482 		goto _52
  61483 	_52:
  61484 		v51 = v12
  61485 		goto _45
  61486 	_45:
  61487 		r = v51
  61488 		v18 = v1 * int32(19077) >> int32(8)
  61489 		goto _58
  61490 	_58:
  61491 		v20 = v2 * int32(6419) >> int32(8)
  61492 		goto _60
  61493 	_60:
  61494 		v22 = v3 * int32(13320) >> int32(8)
  61495 		goto _62
  61496 	_62:
  61497 		v24 = v18 - v20 - v22 + int32(8708)
  61498 		if v24 & ^int32(YUV_MASK2) == 0 {
  61499 			v27 = v24 >> int32(YUV_FIX2)
  61500 		} else {
  61501 			if v24 < 0 {
  61502 				v28 = 0
  61503 			} else {
  61504 				v28 = int32(255)
  61505 			}
  61506 			v27 = v28
  61507 		}
  61508 		v25 = v27
  61509 		goto _65
  61510 	_65:
  61511 		v16 = v25
  61512 		goto _56
  61513 	_56:
  61514 		g = v16
  61515 		v31 = v1 * int32(19077) >> int32(8)
  61516 		goto _71
  61517 	_71:
  61518 		v33 = v2 * int32(33050) >> int32(8)
  61519 		goto _73
  61520 	_73:
  61521 		v35 = v31 + v33 - int32(17685)
  61522 		if v35 & ^int32(YUV_MASK2) == 0 {
  61523 			v38 = v35 >> int32(YUV_FIX2)
  61524 		} else {
  61525 			if v35 < 0 {
  61526 				v39 = 0
  61527 			} else {
  61528 				v39 = int32(255)
  61529 			}
  61530 			v38 = v39
  61531 		}
  61532 		v36 = v38
  61533 		goto _76
  61534 	_76:
  61535 		v29 = v36
  61536 		goto _69
  61537 	_69:
  61538 		b = v29
  61539 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61540 		ba = b&int32(0xf0) | int32(0x0f)
  61541 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61542 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61543 		y4 = y4 + uintptr(2)
  61544 		u3 = u3 + 1
  61545 		v5 = v5 + 1
  61546 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))
  61547 	}
  61548 	if len1&int32(1) != 0 {
  61549 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61550 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61551 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61552 		v4 = dst
  61553 		v7 = v1 * int32(19077) >> int32(8)
  61554 		goto _86
  61555 	_86:
  61556 		v9 = v3 * int32(26149) >> int32(8)
  61557 		goto _88
  61558 	_88:
  61559 		v11 = v7 + v9 - int32(14234)
  61560 		if v11 & ^int32(YUV_MASK2) == 0 {
  61561 			v14 = v11 >> int32(YUV_FIX2)
  61562 		} else {
  61563 			if v11 < 0 {
  61564 				v15 = 0
  61565 			} else {
  61566 				v15 = int32(255)
  61567 			}
  61568 			v14 = v15
  61569 		}
  61570 		v12 = v14
  61571 		goto _91
  61572 	_91:
  61573 		v51 = v12
  61574 		goto _84
  61575 	_84:
  61576 		r = v51
  61577 		v18 = v1 * int32(19077) >> int32(8)
  61578 		goto _97
  61579 	_97:
  61580 		v20 = v2 * int32(6419) >> int32(8)
  61581 		goto _99
  61582 	_99:
  61583 		v22 = v3 * int32(13320) >> int32(8)
  61584 		goto _101
  61585 	_101:
  61586 		v24 = v18 - v20 - v22 + int32(8708)
  61587 		if v24 & ^int32(YUV_MASK2) == 0 {
  61588 			v27 = v24 >> int32(YUV_FIX2)
  61589 		} else {
  61590 			if v24 < 0 {
  61591 				v28 = 0
  61592 			} else {
  61593 				v28 = int32(255)
  61594 			}
  61595 			v27 = v28
  61596 		}
  61597 		v25 = v27
  61598 		goto _104
  61599 	_104:
  61600 		v16 = v25
  61601 		goto _95
  61602 	_95:
  61603 		g = v16
  61604 		v31 = v1 * int32(19077) >> int32(8)
  61605 		goto _110
  61606 	_110:
  61607 		v33 = v2 * int32(33050) >> int32(8)
  61608 		goto _112
  61609 	_112:
  61610 		v35 = v31 + v33 - int32(17685)
  61611 		if v35 & ^int32(YUV_MASK2) == 0 {
  61612 			v38 = v35 >> int32(YUV_FIX2)
  61613 		} else {
  61614 			if v35 < 0 {
  61615 				v39 = 0
  61616 			} else {
  61617 				v39 = int32(255)
  61618 			}
  61619 			v38 = v39
  61620 		}
  61621 		v36 = v38
  61622 		goto _115
  61623 	_115:
  61624 		v29 = v36
  61625 		goto _108
  61626 	_108:
  61627 		b = v29
  61628 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61629 		ba = b&int32(0xf0) | int32(0x0f)
  61630 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61631 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61632 	}
  61633 }
  61634 
  61635 func YuvToRgb565Row(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  61636 	var b, g, gb, r, rg, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v51, v7, v9 int32
  61637 	var end, v4 uintptr
  61638 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, end, g, gb, r, rg, v1, v11, v12, v14, v15, v16, v18, v2, v20, v22, v24, v25, v27, v28, v29, v3, v31, v33, v35, v36, v38, v39, v4, v51, v7, v9
  61639 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(2))
  61640 	for dst != end {
  61641 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61642 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61643 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61644 		v4 = dst
  61645 		v7 = v1 * int32(19077) >> int32(8)
  61646 		goto _8
  61647 	_8:
  61648 		v9 = v3 * int32(26149) >> int32(8)
  61649 		goto _10
  61650 	_10:
  61651 		v11 = v7 + v9 - int32(14234)
  61652 		if v11 & ^int32(YUV_MASK2) == 0 {
  61653 			v14 = v11 >> int32(YUV_FIX2)
  61654 		} else {
  61655 			if v11 < 0 {
  61656 				v15 = 0
  61657 			} else {
  61658 				v15 = int32(255)
  61659 			}
  61660 			v14 = v15
  61661 		}
  61662 		v12 = v14
  61663 		goto _13
  61664 	_13:
  61665 		v51 = v12
  61666 		goto _6
  61667 	_6:
  61668 		r = v51
  61669 		v18 = v1 * int32(19077) >> int32(8)
  61670 		goto _19
  61671 	_19:
  61672 		v20 = v2 * int32(6419) >> int32(8)
  61673 		goto _21
  61674 	_21:
  61675 		v22 = v3 * int32(13320) >> int32(8)
  61676 		goto _23
  61677 	_23:
  61678 		v24 = v18 - v20 - v22 + int32(8708)
  61679 		if v24 & ^int32(YUV_MASK2) == 0 {
  61680 			v27 = v24 >> int32(YUV_FIX2)
  61681 		} else {
  61682 			if v24 < 0 {
  61683 				v28 = 0
  61684 			} else {
  61685 				v28 = int32(255)
  61686 			}
  61687 			v27 = v28
  61688 		}
  61689 		v25 = v27
  61690 		goto _26
  61691 	_26:
  61692 		v16 = v25
  61693 		goto _17
  61694 	_17:
  61695 		g = v16
  61696 		v31 = v1 * int32(19077) >> int32(8)
  61697 		goto _32
  61698 	_32:
  61699 		v33 = v2 * int32(33050) >> int32(8)
  61700 		goto _34
  61701 	_34:
  61702 		v35 = v31 + v33 - int32(17685)
  61703 		if v35 & ^int32(YUV_MASK2) == 0 {
  61704 			v38 = v35 >> int32(YUV_FIX2)
  61705 		} else {
  61706 			if v35 < 0 {
  61707 				v39 = 0
  61708 			} else {
  61709 				v39 = int32(255)
  61710 			}
  61711 			v38 = v39
  61712 		}
  61713 		v36 = v38
  61714 		goto _37
  61715 	_37:
  61716 		v29 = v36
  61717 		goto _30
  61718 	_30:
  61719 		b = v29
  61720 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61721 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61722 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61723 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61724 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  61725 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61726 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61727 		v4 = dst + uintptr(libc.Int32FromInt32(2))
  61728 		v7 = v1 * int32(19077) >> int32(8)
  61729 		goto _47
  61730 	_47:
  61731 		v9 = v3 * int32(26149) >> int32(8)
  61732 		goto _49
  61733 	_49:
  61734 		v11 = v7 + v9 - int32(14234)
  61735 		if v11 & ^int32(YUV_MASK2) == 0 {
  61736 			v14 = v11 >> int32(YUV_FIX2)
  61737 		} else {
  61738 			if v11 < 0 {
  61739 				v15 = 0
  61740 			} else {
  61741 				v15 = int32(255)
  61742 			}
  61743 			v14 = v15
  61744 		}
  61745 		v12 = v14
  61746 		goto _52
  61747 	_52:
  61748 		v51 = v12
  61749 		goto _45
  61750 	_45:
  61751 		r = v51
  61752 		v18 = v1 * int32(19077) >> int32(8)
  61753 		goto _58
  61754 	_58:
  61755 		v20 = v2 * int32(6419) >> int32(8)
  61756 		goto _60
  61757 	_60:
  61758 		v22 = v3 * int32(13320) >> int32(8)
  61759 		goto _62
  61760 	_62:
  61761 		v24 = v18 - v20 - v22 + int32(8708)
  61762 		if v24 & ^int32(YUV_MASK2) == 0 {
  61763 			v27 = v24 >> int32(YUV_FIX2)
  61764 		} else {
  61765 			if v24 < 0 {
  61766 				v28 = 0
  61767 			} else {
  61768 				v28 = int32(255)
  61769 			}
  61770 			v27 = v28
  61771 		}
  61772 		v25 = v27
  61773 		goto _65
  61774 	_65:
  61775 		v16 = v25
  61776 		goto _56
  61777 	_56:
  61778 		g = v16
  61779 		v31 = v1 * int32(19077) >> int32(8)
  61780 		goto _71
  61781 	_71:
  61782 		v33 = v2 * int32(33050) >> int32(8)
  61783 		goto _73
  61784 	_73:
  61785 		v35 = v31 + v33 - int32(17685)
  61786 		if v35 & ^int32(YUV_MASK2) == 0 {
  61787 			v38 = v35 >> int32(YUV_FIX2)
  61788 		} else {
  61789 			if v35 < 0 {
  61790 				v39 = 0
  61791 			} else {
  61792 				v39 = int32(255)
  61793 			}
  61794 			v38 = v39
  61795 		}
  61796 		v36 = v38
  61797 		goto _76
  61798 	_76:
  61799 		v29 = v36
  61800 		goto _69
  61801 	_69:
  61802 		b = v29
  61803 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61804 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61805 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61806 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61807 		y4 = y4 + uintptr(2)
  61808 		u3 = u3 + 1
  61809 		v5 = v5 + 1
  61810 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))
  61811 	}
  61812 	if len1&int32(1) != 0 {
  61813 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61814 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61815 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61816 		v4 = dst
  61817 		v7 = v1 * int32(19077) >> int32(8)
  61818 		goto _86
  61819 	_86:
  61820 		v9 = v3 * int32(26149) >> int32(8)
  61821 		goto _88
  61822 	_88:
  61823 		v11 = v7 + v9 - int32(14234)
  61824 		if v11 & ^int32(YUV_MASK2) == 0 {
  61825 			v14 = v11 >> int32(YUV_FIX2)
  61826 		} else {
  61827 			if v11 < 0 {
  61828 				v15 = 0
  61829 			} else {
  61830 				v15 = int32(255)
  61831 			}
  61832 			v14 = v15
  61833 		}
  61834 		v12 = v14
  61835 		goto _91
  61836 	_91:
  61837 		v51 = v12
  61838 		goto _84
  61839 	_84:
  61840 		r = v51
  61841 		v18 = v1 * int32(19077) >> int32(8)
  61842 		goto _97
  61843 	_97:
  61844 		v20 = v2 * int32(6419) >> int32(8)
  61845 		goto _99
  61846 	_99:
  61847 		v22 = v3 * int32(13320) >> int32(8)
  61848 		goto _101
  61849 	_101:
  61850 		v24 = v18 - v20 - v22 + int32(8708)
  61851 		if v24 & ^int32(YUV_MASK2) == 0 {
  61852 			v27 = v24 >> int32(YUV_FIX2)
  61853 		} else {
  61854 			if v24 < 0 {
  61855 				v28 = 0
  61856 			} else {
  61857 				v28 = int32(255)
  61858 			}
  61859 			v27 = v28
  61860 		}
  61861 		v25 = v27
  61862 		goto _104
  61863 	_104:
  61864 		v16 = v25
  61865 		goto _95
  61866 	_95:
  61867 		g = v16
  61868 		v31 = v1 * int32(19077) >> int32(8)
  61869 		goto _110
  61870 	_110:
  61871 		v33 = v2 * int32(33050) >> int32(8)
  61872 		goto _112
  61873 	_112:
  61874 		v35 = v31 + v33 - int32(17685)
  61875 		if v35 & ^int32(YUV_MASK2) == 0 {
  61876 			v38 = v35 >> int32(YUV_FIX2)
  61877 		} else {
  61878 			if v35 < 0 {
  61879 				v39 = 0
  61880 			} else {
  61881 				v39 = int32(255)
  61882 			}
  61883 			v38 = v39
  61884 		}
  61885 		v36 = v38
  61886 		goto _115
  61887 	_115:
  61888 		v29 = v36
  61889 		goto _108
  61890 	_108:
  61891 		b = v29
  61892 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61893 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61894 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61895 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61896 	}
  61897 }
  61898 
  61899 type __ccgo_fp__XWebPSamplerProcessPlane_9 = func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32)
  61900 
  61901 // C documentation
  61902 //
  61903 //	// Main call for processing a plane with a WebPSamplerRowFunc function:
  61904 func WebPSamplerProcessPlane(tls *libc.TLS, y uintptr, y_stride int32, u uintptr, v uintptr, uv_stride int32, dst uintptr, dst_stride int32, width int32, height int32, __ccgo_fp_func WebPSamplerRowFunc) {
  61905 	var j int32
  61906 	_ = j
  61907 	j = 0
  61908 	for {
  61909 		if !(j < height) {
  61910 			break
  61911 		}
  61912 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_func})))(tls, y, u, v, dst, width)
  61913 		y = y + uintptr(y_stride)
  61914 		if j&int32(1) != 0 {
  61915 			u = u + uintptr(uv_stride)
  61916 			v = v + uintptr(uv_stride)
  61917 		}
  61918 		dst = dst + uintptr(dst_stride)
  61919 		goto _1
  61920 	_1:
  61921 		;
  61922 		j = j + 1
  61923 	}
  61924 }
  61925 
  61926 func WebPInitSamplers(tls *libc.TLS) {
  61927 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  61928 		goto _1
  61929 	}
  61930 	WebPInitSamplers_body(tls)
  61931 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used)), VP8GetCPUInfo)
  61932 	goto _2
  61933 _2:
  61934 	;
  61935 	goto _1
  61936 _1: /**/ //
  61937 }
  61938 
  61939 var WebPInitSamplers_body_last_cpuinfo_used = uintptr(0)
  61940 
  61941 func init() {
  61942 	p := unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used)
  61943 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used))
  61944 }
  61945 
  61946 func WebPInitSamplers_body(tls *libc.TLS) {
  61947 	WebPSamplers[int32(MODE_RGB)] = __ccgo_fp(YuvToRgbRow)
  61948 	WebPSamplers[int32(MODE_RGBA)] = __ccgo_fp(YuvToRgbaRow)
  61949 	WebPSamplers[int32(MODE_BGR)] = __ccgo_fp(YuvToBgrRow)
  61950 	WebPSamplers[int32(MODE_BGRA)] = __ccgo_fp(YuvToBgraRow)
  61951 	WebPSamplers[int32(MODE_ARGB)] = __ccgo_fp(YuvToArgbRow)
  61952 	WebPSamplers[int32(MODE_RGBA_4444)] = __ccgo_fp(YuvToRgba4444Row)
  61953 	WebPSamplers[int32(MODE_RGB_565)] = __ccgo_fp(YuvToRgb565Row)
  61954 	WebPSamplers[int32(MODE_rgbA)] = __ccgo_fp(YuvToRgbaRow)
  61955 	WebPSamplers[int32(MODE_bgrA)] = __ccgo_fp(YuvToBgraRow)
  61956 	WebPSamplers[int32(MODE_Argb)] = __ccgo_fp(YuvToArgbRow)
  61957 	WebPSamplers[int32(MODE_rgbA_4444)] = __ccgo_fp(YuvToRgba4444Row)
  61958 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  61959 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  61960 	}
  61961 }
  61962 
  61963 //-----------------------------------------------------------------------------
  61964 // ARGB -> YUV converters
  61965 
  61966 func ConvertARGBToY_C(tls *libc.TLS, argb uintptr, y uintptr, width int32) {
  61967 	var i, luma, v2 int32
  61968 	var p uint32_t
  61969 	_, _, _, _ = i, luma, p, v2
  61970 	i = 0
  61971 	for {
  61972 		if !(i < width) {
  61973 			break
  61974 		}
  61975 		p = **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4))
  61976 		luma = int32(16839)*libc.Int32FromUint32(p>>libc.Int32FromInt32(16)&uint32(0xff)) + int32(33059)*libc.Int32FromUint32(p>>libc.Int32FromInt32(8)&uint32(0xff)) + int32(6420)*libc.Int32FromUint32(p>>libc.Int32FromInt32(0)&uint32(0xff))
  61977 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  61978 		goto _3
  61979 	_3:
  61980 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  61981 		goto _1
  61982 	_1:
  61983 		;
  61984 		i = i + 1
  61985 	}
  61986 }
  61987 
  61988 func WebPConvertARGBToUV_C(tls *libc.TLS, argb uintptr, u1 uintptr, v1 uintptr, src_width int32, do_store int32) {
  61989 	var b2, b3, g2, g3, i, r2, r3, tmp_u, tmp_u1, tmp_v, tmp_v1, u, uv_width, v, v111, v12, v14, v15, v2, v4, v5, v7, v8, v9 int32
  61990 	var v0, v01, v11 uint32_t
  61991 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b2, b3, g2, g3, i, r2, r3, tmp_u, tmp_u1, tmp_v, tmp_v1, u, uv_width, v, v0, v01, v11, v111, v12, v14, v15, v2, v4, v5, v7, v8, v9
  61992 	// No rounding. Last pixel is dealt with separately.
  61993 	uv_width = src_width >> int32(1)
  61994 	i = 0
  61995 	for {
  61996 		if !(i < uv_width) {
  61997 			break
  61998 		}
  61999 		v0 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+0)*4))
  62000 		v11 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+int32(1))*4))
  62001 		// VP8RGBToU/V expects four accumulated pixels. Hence we need to
  62002 		// scale r/g/b value by a factor 2. We just shift v0/v1 one bit less.
  62003 		r2 = libc.Int32FromUint32(v0>>libc.Int32FromInt32(15)&uint32(0x1fe) + v11>>libc.Int32FromInt32(15)&uint32(0x1fe))
  62004 		g2 = libc.Int32FromUint32(v0>>libc.Int32FromInt32(7)&uint32(0x1fe) + v11>>libc.Int32FromInt32(7)&uint32(0x1fe))
  62005 		b2 = libc.Int32FromUint32(v0<<libc.Int32FromInt32(1)&uint32(0x1fe) + v11<<libc.Int32FromInt32(1)&uint32(0x1fe))
  62006 		u = -int32(9719)*r2 - int32(19081)*g2 + int32(28800)*b2
  62007 		v4 = u
  62008 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62009 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62010 			v7 = v4
  62011 		} else {
  62012 			if v4 < 0 {
  62013 				v8 = 0
  62014 			} else {
  62015 				v8 = int32(255)
  62016 			}
  62017 			v7 = v8
  62018 		}
  62019 		v5 = v7
  62020 		goto _6
  62021 	_6:
  62022 		v2 = v5
  62023 		goto _3
  62024 	_3:
  62025 		tmp_u = v2
  62026 		v = +libc.Int32FromInt32(28800)*r2 - int32(24116)*g2 - int32(4684)*b2
  62027 		v111 = v
  62028 		v111 = (v111 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62029 		if v111 & ^libc.Int32FromInt32(0xff) == 0 {
  62030 			v14 = v111
  62031 		} else {
  62032 			if v111 < 0 {
  62033 				v15 = 0
  62034 			} else {
  62035 				v15 = int32(255)
  62036 			}
  62037 			v14 = v15
  62038 		}
  62039 		v12 = v14
  62040 		goto _13
  62041 	_13:
  62042 		v9 = v12
  62043 		goto _10
  62044 	_10:
  62045 		tmp_v = v9
  62046 		if do_store != 0 {
  62047 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(tmp_u)
  62048 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(tmp_v)
  62049 		} else {
  62050 			// Approximated average-of-four. But it's an acceptable diff.
  62051 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u1 + uintptr(i)))) + tmp_u + int32(1)) >> int32(1))
  62052 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + uintptr(i)))) + tmp_v + int32(1)) >> int32(1))
  62053 		}
  62054 		goto _1
  62055 	_1:
  62056 		;
  62057 		i = i + 1
  62058 	}
  62059 	if src_width&int32(1) != 0 { // last pixel
  62060 		v01 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+0)*4))
  62061 		r3 = libc.Int32FromUint32(v01 >> libc.Int32FromInt32(14) & uint32(0x3fc))
  62062 		g3 = libc.Int32FromUint32(v01 >> libc.Int32FromInt32(6) & uint32(0x3fc))
  62063 		b3 = libc.Int32FromUint32(v01 << libc.Int32FromInt32(2) & uint32(0x3fc))
  62064 		u = -int32(9719)*r3 - int32(19081)*g3 + int32(28800)*b3
  62065 		v4 = u
  62066 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62067 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62068 			v7 = v4
  62069 		} else {
  62070 			if v4 < 0 {
  62071 				v8 = 0
  62072 			} else {
  62073 				v8 = int32(255)
  62074 			}
  62075 			v7 = v8
  62076 		}
  62077 		v5 = v7
  62078 		goto _20
  62079 	_20:
  62080 		v2 = v5
  62081 		goto _17
  62082 	_17:
  62083 		tmp_u1 = v2
  62084 		v = +libc.Int32FromInt32(28800)*r3 - int32(24116)*g3 - int32(4684)*b3
  62085 		v111 = v
  62086 		v111 = (v111 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62087 		if v111 & ^libc.Int32FromInt32(0xff) == 0 {
  62088 			v14 = v111
  62089 		} else {
  62090 			if v111 < 0 {
  62091 				v15 = 0
  62092 			} else {
  62093 				v15 = int32(255)
  62094 			}
  62095 			v14 = v15
  62096 		}
  62097 		v12 = v14
  62098 		goto _27
  62099 	_27:
  62100 		v9 = v12
  62101 		goto _24
  62102 	_24:
  62103 		tmp_v1 = v9
  62104 		if do_store != 0 {
  62105 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(tmp_u1)
  62106 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(tmp_v1)
  62107 		} else {
  62108 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u1 + uintptr(i)))) + tmp_u1 + int32(1)) >> int32(1))
  62109 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + uintptr(i)))) + tmp_v1 + int32(1)) >> int32(1))
  62110 		}
  62111 	}
  62112 }
  62113 
  62114 //-----------------------------------------------------------------------------
  62115 
  62116 func ConvertRGB24ToY_C(tls *libc.TLS, rgb uintptr, y uintptr, width int32) {
  62117 	var i, luma, v2 int32
  62118 	_, _, _ = i, luma, v2
  62119 	i = 0
  62120 	for {
  62121 		if !(i < width) {
  62122 			break
  62123 		}
  62124 		luma = int32(16839)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(rgb))) + int32(33059)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(rgb + 1))) + int32(6420)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(rgb + 2)))
  62125 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  62126 		goto _3
  62127 	_3:
  62128 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  62129 		goto _1
  62130 	_1:
  62131 		;
  62132 		i = i + 1
  62133 		rgb = rgb + uintptr(3)
  62134 	}
  62135 }
  62136 
  62137 func ConvertBGR24ToY_C(tls *libc.TLS, bgr uintptr, y uintptr, width int32) {
  62138 	var i, luma, v2 int32
  62139 	_, _, _ = i, luma, v2
  62140 	i = 0
  62141 	for {
  62142 		if !(i < width) {
  62143 			break
  62144 		}
  62145 		luma = int32(16839)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bgr + 2))) + int32(33059)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bgr + 1))) + int32(6420)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bgr)))
  62146 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  62147 		goto _3
  62148 	_3:
  62149 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  62150 		goto _1
  62151 	_1:
  62152 		;
  62153 		i = i + 1
  62154 		bgr = bgr + uintptr(3)
  62155 	}
  62156 }
  62157 
  62158 func WebPConvertRGBA32ToUV_C(tls *libc.TLS, rgb uintptr, u1 uintptr, v1 uintptr, width int32) {
  62159 	var b2, g2, i, r2, u, v, v2, v4, v5, v7, v8 int32
  62160 	_, _, _, _, _, _, _, _, _, _, _ = b2, g2, i, r2, u, v, v2, v4, v5, v7, v8
  62161 	i = 0
  62162 	for {
  62163 		if !(i < width) {
  62164 			break
  62165 		}
  62166 		r2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb)))
  62167 		g2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 1*2)))
  62168 		b2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 2*2)))
  62169 		u = -int32(9719)*r2 - int32(19081)*g2 + int32(28800)*b2
  62170 		v4 = u
  62171 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62172 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62173 			v7 = v4
  62174 		} else {
  62175 			if v4 < 0 {
  62176 				v8 = 0
  62177 			} else {
  62178 				v8 = int32(255)
  62179 			}
  62180 			v7 = v8
  62181 		}
  62182 		v5 = v7
  62183 		goto _6
  62184 	_6:
  62185 		v2 = v5
  62186 		goto _3
  62187 	_3:
  62188 		**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(v2)
  62189 		v = +libc.Int32FromInt32(28800)*r2 - int32(24116)*g2 - int32(4684)*b2
  62190 		v4 = v
  62191 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62192 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62193 			v7 = v4
  62194 		} else {
  62195 			if v4 < 0 {
  62196 				v8 = 0
  62197 			} else {
  62198 				v8 = int32(255)
  62199 			}
  62200 			v7 = v8
  62201 		}
  62202 		v5 = v7
  62203 		goto _13
  62204 	_13:
  62205 		v2 = v5
  62206 		goto _10
  62207 	_10:
  62208 		**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(v2)
  62209 		goto _1
  62210 	_1:
  62211 		;
  62212 		i = i + int32(1)
  62213 		rgb = rgb + uintptr(4)*2
  62214 	}
  62215 }
  62216 
  62217 func WebPInitConvertARGBToYUV(tls *libc.TLS) {
  62218 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  62219 		goto _1
  62220 	}
  62221 	WebPInitConvertARGBToYUV_body(tls)
  62222 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used)), VP8GetCPUInfo)
  62223 	goto _2
  62224 _2:
  62225 	;
  62226 	goto _1
  62227 _1: /**/ //
  62228 }
  62229 
  62230 var WebPInitConvertARGBToYUV_body_last_cpuinfo_used = uintptr(0)
  62231 
  62232 func init() {
  62233 	p := unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used)
  62234 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used))
  62235 }
  62236 
  62237 func WebPInitConvertARGBToYUV_body(tls *libc.TLS) {
  62238 	WebPConvertARGBToY = __ccgo_fp(ConvertARGBToY_C)
  62239 	WebPConvertARGBToUV = __ccgo_fp(WebPConvertARGBToUV_C)
  62240 	WebPConvertRGB24ToY = __ccgo_fp(ConvertRGB24ToY_C)
  62241 	WebPConvertBGR24ToY = __ccgo_fp(ConvertBGR24ToY_C)
  62242 	WebPConvertRGBA32ToUV = __ccgo_fp(WebPConvertRGBA32ToUV_C)
  62243 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  62244 	}
  62245 }
  62246 
  62247 func WebPInitSamplersMIPS32(tls *libc.TLS) {
  62248 }
  62249 
  62250 func WebPInitSamplersMIPSdspR2(tls *libc.TLS) {
  62251 }
  62252 
  62253 func WebPInitConvertARGBToYUVNEON(tls *libc.TLS) {
  62254 }
  62255 
  62256 func WebPInitSamplersSSE2(tls *libc.TLS) {
  62257 }
  62258 
  62259 func WebPInitConvertARGBToYUVSSE2(tls *libc.TLS) {
  62260 }
  62261 
  62262 func WebPInitSamplersSSE41(tls *libc.TLS) {
  62263 }
  62264 
  62265 func WebPInitConvertARGBToYUVSSE41(tls *libc.TLS) {
  62266 }
  62267 
  62268 type __ccgo_fp__XSharpYuvInit_0 = func(*libc.TLS, int32) int32
  62269 
  62270 func SharpYuvInit(tls *libc.TLS, __ccgo_fp_cpu_info_func VP8CPUInfo) {
  62271 	_ = __ccgo_fp_cpu_info_func
  62272 }
  62273 
  62274 func SharpYuvGetConversionMatrix(tls *libc.TLS, matrix_type SharpYuvMatrixType) (r uintptr) {
  62275 	_ = matrix_type
  62276 	return libc.UintptrFromInt32(0)
  62277 }
  62278 
  62279 func SharpYuvConvert(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, rgb_step int32, rgb_stride int32, rgb_bit_depth int32, y_ptr uintptr, y_stride int32, u_ptr uintptr, u_stride int32, v_ptr uintptr, v_stride int32, yuv_bit_depth int32, width int32, height int32, yuv_matrix uintptr) (r int32) {
  62280 	_ = r_ptr
  62281 	_ = g_ptr
  62282 	_ = b_ptr
  62283 	_ = rgb_step
  62284 	_ = rgb_stride
  62285 	_ = rgb_bit_depth
  62286 	_ = y_ptr
  62287 	_ = y_stride
  62288 	_ = u_ptr
  62289 	_ = u_stride
  62290 	_ = v_ptr
  62291 	_ = v_stride
  62292 	_ = yuv_bit_depth
  62293 	_ = width
  62294 	_ = height
  62295 	_ = yuv_matrix
  62296 	return 0
  62297 }
  62298 
  62299 func __ccgo_fp(f interface{}) uintptr {
  62300 	type iface [2]uintptr
  62301 	return (*iface)(unsafe.Pointer(&f))[1]
  62302 }
  62303 
  62304 func __ccgo_up(n uintptr) unsafe.Pointer {
  62305 	return unsafe.Pointer(&n)
  62306 }
  62307 
  62308 var VP8AccumulateSSE VP8AccumulateSSEFunc
  62309 
  62310 //------------------------------------------------------------------------------
  62311 // Tables for level coding
  62312 
  62313 var VP8Cat3 = [3]uint8_t{
  62314 	0: uint8(173),
  62315 	1: uint8(148),
  62316 	2: uint8(140),
  62317 }
  62318 
  62319 var VP8Cat4 = [4]uint8_t{
  62320 	0: uint8(176),
  62321 	1: uint8(155),
  62322 	2: uint8(140),
  62323 	3: uint8(135),
  62324 }
  62325 
  62326 var VP8Cat5 = [5]uint8_t{
  62327 	0: uint8(180),
  62328 	1: uint8(157),
  62329 	2: uint8(141),
  62330 	3: uint8(134),
  62331 	4: uint8(130),
  62332 }
  62333 
  62334 var VP8Cat6 = [11]uint8_t{
  62335 	0:  uint8(254),
  62336 	1:  uint8(254),
  62337 	2:  uint8(243),
  62338 	3:  uint8(230),
  62339 	4:  uint8(196),
  62340 	5:  uint8(177),
  62341 	6:  uint8(153),
  62342 	7:  uint8(140),
  62343 	8:  uint8(133),
  62344 	9:  uint8(130),
  62345 	10: uint8(129),
  62346 }
  62347 
  62348 //------------------------------------------------------------------------------
  62349 
  62350 // Copyright 2011 Google Inc. All Rights Reserved.
  62351 //
  62352 // Use of this source code is governed by a BSD-style license
  62353 // that can be found in the COPYING file in the root of the source
  62354 // tree. An additional intellectual property rights grant can be found
  62355 // in the file PATENTS. All contributing project authors may
  62356 // be found in the AUTHORS file in the root of the source tree.
  62357 // -----------------------------------------------------------------------------
  62358 //
  62359 // Bit writing and boolean coder
  62360 //
  62361 // Author: Skal (pascal.massimino@gmail.com)
  62362 
  62363 //------------------------------------------------------------------------------
  62364 // Default probabilities
  62365 
  62366 // C documentation
  62367 //
  62368 //	// Paragraph 13.5
  62369 
  62370 var VP8CoeffsProba0 = [4][8][3][11]uint8_t{
  62371 	0: {
  62372 		0: {
  62373 			0: {
  62374 				0:  uint8(128),
  62375 				1:  uint8(128),
  62376 				2:  uint8(128),
  62377 				3:  uint8(128),
  62378 				4:  uint8(128),
  62379 				5:  uint8(128),
  62380 				6:  uint8(128),
  62381 				7:  uint8(128),
  62382 				8:  uint8(128),
  62383 				9:  uint8(128),
  62384 				10: uint8(128),
  62385 			},
  62386 			1: {
  62387 				0:  uint8(128),
  62388 				1:  uint8(128),
  62389 				2:  uint8(128),
  62390 				3:  uint8(128),
  62391 				4:  uint8(128),
  62392 				5:  uint8(128),
  62393 				6:  uint8(128),
  62394 				7:  uint8(128),
  62395 				8:  uint8(128),
  62396 				9:  uint8(128),
  62397 				10: uint8(128),
  62398 			},
  62399 			2: {
  62400 				0:  uint8(128),
  62401 				1:  uint8(128),
  62402 				2:  uint8(128),
  62403 				3:  uint8(128),
  62404 				4:  uint8(128),
  62405 				5:  uint8(128),
  62406 				6:  uint8(128),
  62407 				7:  uint8(128),
  62408 				8:  uint8(128),
  62409 				9:  uint8(128),
  62410 				10: uint8(128),
  62411 			},
  62412 		},
  62413 		1: {
  62414 			0: {
  62415 				0:  uint8(253),
  62416 				1:  uint8(136),
  62417 				2:  uint8(254),
  62418 				3:  uint8(255),
  62419 				4:  uint8(228),
  62420 				5:  uint8(219),
  62421 				6:  uint8(128),
  62422 				7:  uint8(128),
  62423 				8:  uint8(128),
  62424 				9:  uint8(128),
  62425 				10: uint8(128),
  62426 			},
  62427 			1: {
  62428 				0:  uint8(189),
  62429 				1:  uint8(129),
  62430 				2:  uint8(242),
  62431 				3:  uint8(255),
  62432 				4:  uint8(227),
  62433 				5:  uint8(213),
  62434 				6:  uint8(255),
  62435 				7:  uint8(219),
  62436 				8:  uint8(128),
  62437 				9:  uint8(128),
  62438 				10: uint8(128),
  62439 			},
  62440 			2: {
  62441 				0:  uint8(106),
  62442 				1:  uint8(126),
  62443 				2:  uint8(227),
  62444 				3:  uint8(252),
  62445 				4:  uint8(214),
  62446 				5:  uint8(209),
  62447 				6:  uint8(255),
  62448 				7:  uint8(255),
  62449 				8:  uint8(128),
  62450 				9:  uint8(128),
  62451 				10: uint8(128),
  62452 			},
  62453 		},
  62454 		2: {
  62455 			0: {
  62456 				0:  uint8(1),
  62457 				1:  uint8(98),
  62458 				2:  uint8(248),
  62459 				3:  uint8(255),
  62460 				4:  uint8(236),
  62461 				5:  uint8(226),
  62462 				6:  uint8(255),
  62463 				7:  uint8(255),
  62464 				8:  uint8(128),
  62465 				9:  uint8(128),
  62466 				10: uint8(128),
  62467 			},
  62468 			1: {
  62469 				0:  uint8(181),
  62470 				1:  uint8(133),
  62471 				2:  uint8(238),
  62472 				3:  uint8(254),
  62473 				4:  uint8(221),
  62474 				5:  uint8(234),
  62475 				6:  uint8(255),
  62476 				7:  uint8(154),
  62477 				8:  uint8(128),
  62478 				9:  uint8(128),
  62479 				10: uint8(128),
  62480 			},
  62481 			2: {
  62482 				0:  uint8(78),
  62483 				1:  uint8(134),
  62484 				2:  uint8(202),
  62485 				3:  uint8(247),
  62486 				4:  uint8(198),
  62487 				5:  uint8(180),
  62488 				6:  uint8(255),
  62489 				7:  uint8(219),
  62490 				8:  uint8(128),
  62491 				9:  uint8(128),
  62492 				10: uint8(128),
  62493 			},
  62494 		},
  62495 		3: {
  62496 			0: {
  62497 				0:  uint8(1),
  62498 				1:  uint8(185),
  62499 				2:  uint8(249),
  62500 				3:  uint8(255),
  62501 				4:  uint8(243),
  62502 				5:  uint8(255),
  62503 				6:  uint8(128),
  62504 				7:  uint8(128),
  62505 				8:  uint8(128),
  62506 				9:  uint8(128),
  62507 				10: uint8(128),
  62508 			},
  62509 			1: {
  62510 				0:  uint8(184),
  62511 				1:  uint8(150),
  62512 				2:  uint8(247),
  62513 				3:  uint8(255),
  62514 				4:  uint8(236),
  62515 				5:  uint8(224),
  62516 				6:  uint8(128),
  62517 				7:  uint8(128),
  62518 				8:  uint8(128),
  62519 				9:  uint8(128),
  62520 				10: uint8(128),
  62521 			},
  62522 			2: {
  62523 				0:  uint8(77),
  62524 				1:  uint8(110),
  62525 				2:  uint8(216),
  62526 				3:  uint8(255),
  62527 				4:  uint8(236),
  62528 				5:  uint8(230),
  62529 				6:  uint8(128),
  62530 				7:  uint8(128),
  62531 				8:  uint8(128),
  62532 				9:  uint8(128),
  62533 				10: uint8(128),
  62534 			},
  62535 		},
  62536 		4: {
  62537 			0: {
  62538 				0:  uint8(1),
  62539 				1:  uint8(101),
  62540 				2:  uint8(251),
  62541 				3:  uint8(255),
  62542 				4:  uint8(241),
  62543 				5:  uint8(255),
  62544 				6:  uint8(128),
  62545 				7:  uint8(128),
  62546 				8:  uint8(128),
  62547 				9:  uint8(128),
  62548 				10: uint8(128),
  62549 			},
  62550 			1: {
  62551 				0:  uint8(170),
  62552 				1:  uint8(139),
  62553 				2:  uint8(241),
  62554 				3:  uint8(252),
  62555 				4:  uint8(236),
  62556 				5:  uint8(209),
  62557 				6:  uint8(255),
  62558 				7:  uint8(255),
  62559 				8:  uint8(128),
  62560 				9:  uint8(128),
  62561 				10: uint8(128),
  62562 			},
  62563 			2: {
  62564 				0:  uint8(37),
  62565 				1:  uint8(116),
  62566 				2:  uint8(196),
  62567 				3:  uint8(243),
  62568 				4:  uint8(228),
  62569 				5:  uint8(255),
  62570 				6:  uint8(255),
  62571 				7:  uint8(255),
  62572 				8:  uint8(128),
  62573 				9:  uint8(128),
  62574 				10: uint8(128),
  62575 			},
  62576 		},
  62577 		5: {
  62578 			0: {
  62579 				0:  uint8(1),
  62580 				1:  uint8(204),
  62581 				2:  uint8(254),
  62582 				3:  uint8(255),
  62583 				4:  uint8(245),
  62584 				5:  uint8(255),
  62585 				6:  uint8(128),
  62586 				7:  uint8(128),
  62587 				8:  uint8(128),
  62588 				9:  uint8(128),
  62589 				10: uint8(128),
  62590 			},
  62591 			1: {
  62592 				0:  uint8(207),
  62593 				1:  uint8(160),
  62594 				2:  uint8(250),
  62595 				3:  uint8(255),
  62596 				4:  uint8(238),
  62597 				5:  uint8(128),
  62598 				6:  uint8(128),
  62599 				7:  uint8(128),
  62600 				8:  uint8(128),
  62601 				9:  uint8(128),
  62602 				10: uint8(128),
  62603 			},
  62604 			2: {
  62605 				0:  uint8(102),
  62606 				1:  uint8(103),
  62607 				2:  uint8(231),
  62608 				3:  uint8(255),
  62609 				4:  uint8(211),
  62610 				5:  uint8(171),
  62611 				6:  uint8(128),
  62612 				7:  uint8(128),
  62613 				8:  uint8(128),
  62614 				9:  uint8(128),
  62615 				10: uint8(128),
  62616 			},
  62617 		},
  62618 		6: {
  62619 			0: {
  62620 				0:  uint8(1),
  62621 				1:  uint8(152),
  62622 				2:  uint8(252),
  62623 				3:  uint8(255),
  62624 				4:  uint8(240),
  62625 				5:  uint8(255),
  62626 				6:  uint8(128),
  62627 				7:  uint8(128),
  62628 				8:  uint8(128),
  62629 				9:  uint8(128),
  62630 				10: uint8(128),
  62631 			},
  62632 			1: {
  62633 				0:  uint8(177),
  62634 				1:  uint8(135),
  62635 				2:  uint8(243),
  62636 				3:  uint8(255),
  62637 				4:  uint8(234),
  62638 				5:  uint8(225),
  62639 				6:  uint8(128),
  62640 				7:  uint8(128),
  62641 				8:  uint8(128),
  62642 				9:  uint8(128),
  62643 				10: uint8(128),
  62644 			},
  62645 			2: {
  62646 				0:  uint8(80),
  62647 				1:  uint8(129),
  62648 				2:  uint8(211),
  62649 				3:  uint8(255),
  62650 				4:  uint8(194),
  62651 				5:  uint8(224),
  62652 				6:  uint8(128),
  62653 				7:  uint8(128),
  62654 				8:  uint8(128),
  62655 				9:  uint8(128),
  62656 				10: uint8(128),
  62657 			},
  62658 		},
  62659 		7: {
  62660 			0: {
  62661 				0:  uint8(1),
  62662 				1:  uint8(1),
  62663 				2:  uint8(255),
  62664 				3:  uint8(128),
  62665 				4:  uint8(128),
  62666 				5:  uint8(128),
  62667 				6:  uint8(128),
  62668 				7:  uint8(128),
  62669 				8:  uint8(128),
  62670 				9:  uint8(128),
  62671 				10: uint8(128),
  62672 			},
  62673 			1: {
  62674 				0:  uint8(246),
  62675 				1:  uint8(1),
  62676 				2:  uint8(255),
  62677 				3:  uint8(128),
  62678 				4:  uint8(128),
  62679 				5:  uint8(128),
  62680 				6:  uint8(128),
  62681 				7:  uint8(128),
  62682 				8:  uint8(128),
  62683 				9:  uint8(128),
  62684 				10: uint8(128),
  62685 			},
  62686 			2: {
  62687 				0:  uint8(255),
  62688 				1:  uint8(128),
  62689 				2:  uint8(128),
  62690 				3:  uint8(128),
  62691 				4:  uint8(128),
  62692 				5:  uint8(128),
  62693 				6:  uint8(128),
  62694 				7:  uint8(128),
  62695 				8:  uint8(128),
  62696 				9:  uint8(128),
  62697 				10: uint8(128),
  62698 			},
  62699 		},
  62700 	},
  62701 	1: {
  62702 		0: {
  62703 			0: {
  62704 				0:  uint8(198),
  62705 				1:  uint8(35),
  62706 				2:  uint8(237),
  62707 				3:  uint8(223),
  62708 				4:  uint8(193),
  62709 				5:  uint8(187),
  62710 				6:  uint8(162),
  62711 				7:  uint8(160),
  62712 				8:  uint8(145),
  62713 				9:  uint8(155),
  62714 				10: uint8(62),
  62715 			},
  62716 			1: {
  62717 				0:  uint8(131),
  62718 				1:  uint8(45),
  62719 				2:  uint8(198),
  62720 				3:  uint8(221),
  62721 				4:  uint8(172),
  62722 				5:  uint8(176),
  62723 				6:  uint8(220),
  62724 				7:  uint8(157),
  62725 				8:  uint8(252),
  62726 				9:  uint8(221),
  62727 				10: uint8(1),
  62728 			},
  62729 			2: {
  62730 				0:  uint8(68),
  62731 				1:  uint8(47),
  62732 				2:  uint8(146),
  62733 				3:  uint8(208),
  62734 				4:  uint8(149),
  62735 				5:  uint8(167),
  62736 				6:  uint8(221),
  62737 				7:  uint8(162),
  62738 				8:  uint8(255),
  62739 				9:  uint8(223),
  62740 				10: uint8(128),
  62741 			},
  62742 		},
  62743 		1: {
  62744 			0: {
  62745 				0:  uint8(1),
  62746 				1:  uint8(149),
  62747 				2:  uint8(241),
  62748 				3:  uint8(255),
  62749 				4:  uint8(221),
  62750 				5:  uint8(224),
  62751 				6:  uint8(255),
  62752 				7:  uint8(255),
  62753 				8:  uint8(128),
  62754 				9:  uint8(128),
  62755 				10: uint8(128),
  62756 			},
  62757 			1: {
  62758 				0:  uint8(184),
  62759 				1:  uint8(141),
  62760 				2:  uint8(234),
  62761 				3:  uint8(253),
  62762 				4:  uint8(222),
  62763 				5:  uint8(220),
  62764 				6:  uint8(255),
  62765 				7:  uint8(199),
  62766 				8:  uint8(128),
  62767 				9:  uint8(128),
  62768 				10: uint8(128),
  62769 			},
  62770 			2: {
  62771 				0:  uint8(81),
  62772 				1:  uint8(99),
  62773 				2:  uint8(181),
  62774 				3:  uint8(242),
  62775 				4:  uint8(176),
  62776 				5:  uint8(190),
  62777 				6:  uint8(249),
  62778 				7:  uint8(202),
  62779 				8:  uint8(255),
  62780 				9:  uint8(255),
  62781 				10: uint8(128),
  62782 			},
  62783 		},
  62784 		2: {
  62785 			0: {
  62786 				0:  uint8(1),
  62787 				1:  uint8(129),
  62788 				2:  uint8(232),
  62789 				3:  uint8(253),
  62790 				4:  uint8(214),
  62791 				5:  uint8(197),
  62792 				6:  uint8(242),
  62793 				7:  uint8(196),
  62794 				8:  uint8(255),
  62795 				9:  uint8(255),
  62796 				10: uint8(128),
  62797 			},
  62798 			1: {
  62799 				0:  uint8(99),
  62800 				1:  uint8(121),
  62801 				2:  uint8(210),
  62802 				3:  uint8(250),
  62803 				4:  uint8(201),
  62804 				5:  uint8(198),
  62805 				6:  uint8(255),
  62806 				7:  uint8(202),
  62807 				8:  uint8(128),
  62808 				9:  uint8(128),
  62809 				10: uint8(128),
  62810 			},
  62811 			2: {
  62812 				0:  uint8(23),
  62813 				1:  uint8(91),
  62814 				2:  uint8(163),
  62815 				3:  uint8(242),
  62816 				4:  uint8(170),
  62817 				5:  uint8(187),
  62818 				6:  uint8(247),
  62819 				7:  uint8(210),
  62820 				8:  uint8(255),
  62821 				9:  uint8(255),
  62822 				10: uint8(128),
  62823 			},
  62824 		},
  62825 		3: {
  62826 			0: {
  62827 				0:  uint8(1),
  62828 				1:  uint8(200),
  62829 				2:  uint8(246),
  62830 				3:  uint8(255),
  62831 				4:  uint8(234),
  62832 				5:  uint8(255),
  62833 				6:  uint8(128),
  62834 				7:  uint8(128),
  62835 				8:  uint8(128),
  62836 				9:  uint8(128),
  62837 				10: uint8(128),
  62838 			},
  62839 			1: {
  62840 				0:  uint8(109),
  62841 				1:  uint8(178),
  62842 				2:  uint8(241),
  62843 				3:  uint8(255),
  62844 				4:  uint8(231),
  62845 				5:  uint8(245),
  62846 				6:  uint8(255),
  62847 				7:  uint8(255),
  62848 				8:  uint8(128),
  62849 				9:  uint8(128),
  62850 				10: uint8(128),
  62851 			},
  62852 			2: {
  62853 				0:  uint8(44),
  62854 				1:  uint8(130),
  62855 				2:  uint8(201),
  62856 				3:  uint8(253),
  62857 				4:  uint8(205),
  62858 				5:  uint8(192),
  62859 				6:  uint8(255),
  62860 				7:  uint8(255),
  62861 				8:  uint8(128),
  62862 				9:  uint8(128),
  62863 				10: uint8(128),
  62864 			},
  62865 		},
  62866 		4: {
  62867 			0: {
  62868 				0:  uint8(1),
  62869 				1:  uint8(132),
  62870 				2:  uint8(239),
  62871 				3:  uint8(251),
  62872 				4:  uint8(219),
  62873 				5:  uint8(209),
  62874 				6:  uint8(255),
  62875 				7:  uint8(165),
  62876 				8:  uint8(128),
  62877 				9:  uint8(128),
  62878 				10: uint8(128),
  62879 			},
  62880 			1: {
  62881 				0:  uint8(94),
  62882 				1:  uint8(136),
  62883 				2:  uint8(225),
  62884 				3:  uint8(251),
  62885 				4:  uint8(218),
  62886 				5:  uint8(190),
  62887 				6:  uint8(255),
  62888 				7:  uint8(255),
  62889 				8:  uint8(128),
  62890 				9:  uint8(128),
  62891 				10: uint8(128),
  62892 			},
  62893 			2: {
  62894 				0:  uint8(22),
  62895 				1:  uint8(100),
  62896 				2:  uint8(174),
  62897 				3:  uint8(245),
  62898 				4:  uint8(186),
  62899 				5:  uint8(161),
  62900 				6:  uint8(255),
  62901 				7:  uint8(199),
  62902 				8:  uint8(128),
  62903 				9:  uint8(128),
  62904 				10: uint8(128),
  62905 			},
  62906 		},
  62907 		5: {
  62908 			0: {
  62909 				0:  uint8(1),
  62910 				1:  uint8(182),
  62911 				2:  uint8(249),
  62912 				3:  uint8(255),
  62913 				4:  uint8(232),
  62914 				5:  uint8(235),
  62915 				6:  uint8(128),
  62916 				7:  uint8(128),
  62917 				8:  uint8(128),
  62918 				9:  uint8(128),
  62919 				10: uint8(128),
  62920 			},
  62921 			1: {
  62922 				0:  uint8(124),
  62923 				1:  uint8(143),
  62924 				2:  uint8(241),
  62925 				3:  uint8(255),
  62926 				4:  uint8(227),
  62927 				5:  uint8(234),
  62928 				6:  uint8(128),
  62929 				7:  uint8(128),
  62930 				8:  uint8(128),
  62931 				9:  uint8(128),
  62932 				10: uint8(128),
  62933 			},
  62934 			2: {
  62935 				0:  uint8(35),
  62936 				1:  uint8(77),
  62937 				2:  uint8(181),
  62938 				3:  uint8(251),
  62939 				4:  uint8(193),
  62940 				5:  uint8(211),
  62941 				6:  uint8(255),
  62942 				7:  uint8(205),
  62943 				8:  uint8(128),
  62944 				9:  uint8(128),
  62945 				10: uint8(128),
  62946 			},
  62947 		},
  62948 		6: {
  62949 			0: {
  62950 				0:  uint8(1),
  62951 				1:  uint8(157),
  62952 				2:  uint8(247),
  62953 				3:  uint8(255),
  62954 				4:  uint8(236),
  62955 				5:  uint8(231),
  62956 				6:  uint8(255),
  62957 				7:  uint8(255),
  62958 				8:  uint8(128),
  62959 				9:  uint8(128),
  62960 				10: uint8(128),
  62961 			},
  62962 			1: {
  62963 				0:  uint8(121),
  62964 				1:  uint8(141),
  62965 				2:  uint8(235),
  62966 				3:  uint8(255),
  62967 				4:  uint8(225),
  62968 				5:  uint8(227),
  62969 				6:  uint8(255),
  62970 				7:  uint8(255),
  62971 				8:  uint8(128),
  62972 				9:  uint8(128),
  62973 				10: uint8(128),
  62974 			},
  62975 			2: {
  62976 				0:  uint8(45),
  62977 				1:  uint8(99),
  62978 				2:  uint8(188),
  62979 				3:  uint8(251),
  62980 				4:  uint8(195),
  62981 				5:  uint8(217),
  62982 				6:  uint8(255),
  62983 				7:  uint8(224),
  62984 				8:  uint8(128),
  62985 				9:  uint8(128),
  62986 				10: uint8(128),
  62987 			},
  62988 		},
  62989 		7: {
  62990 			0: {
  62991 				0:  uint8(1),
  62992 				1:  uint8(1),
  62993 				2:  uint8(251),
  62994 				3:  uint8(255),
  62995 				4:  uint8(213),
  62996 				5:  uint8(255),
  62997 				6:  uint8(128),
  62998 				7:  uint8(128),
  62999 				8:  uint8(128),
  63000 				9:  uint8(128),
  63001 				10: uint8(128),
  63002 			},
  63003 			1: {
  63004 				0:  uint8(203),
  63005 				1:  uint8(1),
  63006 				2:  uint8(248),
  63007 				3:  uint8(255),
  63008 				4:  uint8(255),
  63009 				5:  uint8(128),
  63010 				6:  uint8(128),
  63011 				7:  uint8(128),
  63012 				8:  uint8(128),
  63013 				9:  uint8(128),
  63014 				10: uint8(128),
  63015 			},
  63016 			2: {
  63017 				0:  uint8(137),
  63018 				1:  uint8(1),
  63019 				2:  uint8(177),
  63020 				3:  uint8(255),
  63021 				4:  uint8(224),
  63022 				5:  uint8(255),
  63023 				6:  uint8(128),
  63024 				7:  uint8(128),
  63025 				8:  uint8(128),
  63026 				9:  uint8(128),
  63027 				10: uint8(128),
  63028 			},
  63029 		},
  63030 	},
  63031 	2: {
  63032 		0: {
  63033 			0: {
  63034 				0:  uint8(253),
  63035 				1:  uint8(9),
  63036 				2:  uint8(248),
  63037 				3:  uint8(251),
  63038 				4:  uint8(207),
  63039 				5:  uint8(208),
  63040 				6:  uint8(255),
  63041 				7:  uint8(192),
  63042 				8:  uint8(128),
  63043 				9:  uint8(128),
  63044 				10: uint8(128),
  63045 			},
  63046 			1: {
  63047 				0:  uint8(175),
  63048 				1:  uint8(13),
  63049 				2:  uint8(224),
  63050 				3:  uint8(243),
  63051 				4:  uint8(193),
  63052 				5:  uint8(185),
  63053 				6:  uint8(249),
  63054 				7:  uint8(198),
  63055 				8:  uint8(255),
  63056 				9:  uint8(255),
  63057 				10: uint8(128),
  63058 			},
  63059 			2: {
  63060 				0:  uint8(73),
  63061 				1:  uint8(17),
  63062 				2:  uint8(171),
  63063 				3:  uint8(221),
  63064 				4:  uint8(161),
  63065 				5:  uint8(179),
  63066 				6:  uint8(236),
  63067 				7:  uint8(167),
  63068 				8:  uint8(255),
  63069 				9:  uint8(234),
  63070 				10: uint8(128),
  63071 			},
  63072 		},
  63073 		1: {
  63074 			0: {
  63075 				0:  uint8(1),
  63076 				1:  uint8(95),
  63077 				2:  uint8(247),
  63078 				3:  uint8(253),
  63079 				4:  uint8(212),
  63080 				5:  uint8(183),
  63081 				6:  uint8(255),
  63082 				7:  uint8(255),
  63083 				8:  uint8(128),
  63084 				9:  uint8(128),
  63085 				10: uint8(128),
  63086 			},
  63087 			1: {
  63088 				0:  uint8(239),
  63089 				1:  uint8(90),
  63090 				2:  uint8(244),
  63091 				3:  uint8(250),
  63092 				4:  uint8(211),
  63093 				5:  uint8(209),
  63094 				6:  uint8(255),
  63095 				7:  uint8(255),
  63096 				8:  uint8(128),
  63097 				9:  uint8(128),
  63098 				10: uint8(128),
  63099 			},
  63100 			2: {
  63101 				0:  uint8(155),
  63102 				1:  uint8(77),
  63103 				2:  uint8(195),
  63104 				3:  uint8(248),
  63105 				4:  uint8(188),
  63106 				5:  uint8(195),
  63107 				6:  uint8(255),
  63108 				7:  uint8(255),
  63109 				8:  uint8(128),
  63110 				9:  uint8(128),
  63111 				10: uint8(128),
  63112 			},
  63113 		},
  63114 		2: {
  63115 			0: {
  63116 				0:  uint8(1),
  63117 				1:  uint8(24),
  63118 				2:  uint8(239),
  63119 				3:  uint8(251),
  63120 				4:  uint8(218),
  63121 				5:  uint8(219),
  63122 				6:  uint8(255),
  63123 				7:  uint8(205),
  63124 				8:  uint8(128),
  63125 				9:  uint8(128),
  63126 				10: uint8(128),
  63127 			},
  63128 			1: {
  63129 				0:  uint8(201),
  63130 				1:  uint8(51),
  63131 				2:  uint8(219),
  63132 				3:  uint8(255),
  63133 				4:  uint8(196),
  63134 				5:  uint8(186),
  63135 				6:  uint8(128),
  63136 				7:  uint8(128),
  63137 				8:  uint8(128),
  63138 				9:  uint8(128),
  63139 				10: uint8(128),
  63140 			},
  63141 			2: {
  63142 				0:  uint8(69),
  63143 				1:  uint8(46),
  63144 				2:  uint8(190),
  63145 				3:  uint8(239),
  63146 				4:  uint8(201),
  63147 				5:  uint8(218),
  63148 				6:  uint8(255),
  63149 				7:  uint8(228),
  63150 				8:  uint8(128),
  63151 				9:  uint8(128),
  63152 				10: uint8(128),
  63153 			},
  63154 		},
  63155 		3: {
  63156 			0: {
  63157 				0:  uint8(1),
  63158 				1:  uint8(191),
  63159 				2:  uint8(251),
  63160 				3:  uint8(255),
  63161 				4:  uint8(255),
  63162 				5:  uint8(128),
  63163 				6:  uint8(128),
  63164 				7:  uint8(128),
  63165 				8:  uint8(128),
  63166 				9:  uint8(128),
  63167 				10: uint8(128),
  63168 			},
  63169 			1: {
  63170 				0:  uint8(223),
  63171 				1:  uint8(165),
  63172 				2:  uint8(249),
  63173 				3:  uint8(255),
  63174 				4:  uint8(213),
  63175 				5:  uint8(255),
  63176 				6:  uint8(128),
  63177 				7:  uint8(128),
  63178 				8:  uint8(128),
  63179 				9:  uint8(128),
  63180 				10: uint8(128),
  63181 			},
  63182 			2: {
  63183 				0:  uint8(141),
  63184 				1:  uint8(124),
  63185 				2:  uint8(248),
  63186 				3:  uint8(255),
  63187 				4:  uint8(255),
  63188 				5:  uint8(128),
  63189 				6:  uint8(128),
  63190 				7:  uint8(128),
  63191 				8:  uint8(128),
  63192 				9:  uint8(128),
  63193 				10: uint8(128),
  63194 			},
  63195 		},
  63196 		4: {
  63197 			0: {
  63198 				0:  uint8(1),
  63199 				1:  uint8(16),
  63200 				2:  uint8(248),
  63201 				3:  uint8(255),
  63202 				4:  uint8(255),
  63203 				5:  uint8(128),
  63204 				6:  uint8(128),
  63205 				7:  uint8(128),
  63206 				8:  uint8(128),
  63207 				9:  uint8(128),
  63208 				10: uint8(128),
  63209 			},
  63210 			1: {
  63211 				0:  uint8(190),
  63212 				1:  uint8(36),
  63213 				2:  uint8(230),
  63214 				3:  uint8(255),
  63215 				4:  uint8(236),
  63216 				5:  uint8(255),
  63217 				6:  uint8(128),
  63218 				7:  uint8(128),
  63219 				8:  uint8(128),
  63220 				9:  uint8(128),
  63221 				10: uint8(128),
  63222 			},
  63223 			2: {
  63224 				0:  uint8(149),
  63225 				1:  uint8(1),
  63226 				2:  uint8(255),
  63227 				3:  uint8(128),
  63228 				4:  uint8(128),
  63229 				5:  uint8(128),
  63230 				6:  uint8(128),
  63231 				7:  uint8(128),
  63232 				8:  uint8(128),
  63233 				9:  uint8(128),
  63234 				10: uint8(128),
  63235 			},
  63236 		},
  63237 		5: {
  63238 			0: {
  63239 				0:  uint8(1),
  63240 				1:  uint8(226),
  63241 				2:  uint8(255),
  63242 				3:  uint8(128),
  63243 				4:  uint8(128),
  63244 				5:  uint8(128),
  63245 				6:  uint8(128),
  63246 				7:  uint8(128),
  63247 				8:  uint8(128),
  63248 				9:  uint8(128),
  63249 				10: uint8(128),
  63250 			},
  63251 			1: {
  63252 				0:  uint8(247),
  63253 				1:  uint8(192),
  63254 				2:  uint8(255),
  63255 				3:  uint8(128),
  63256 				4:  uint8(128),
  63257 				5:  uint8(128),
  63258 				6:  uint8(128),
  63259 				7:  uint8(128),
  63260 				8:  uint8(128),
  63261 				9:  uint8(128),
  63262 				10: uint8(128),
  63263 			},
  63264 			2: {
  63265 				0:  uint8(240),
  63266 				1:  uint8(128),
  63267 				2:  uint8(255),
  63268 				3:  uint8(128),
  63269 				4:  uint8(128),
  63270 				5:  uint8(128),
  63271 				6:  uint8(128),
  63272 				7:  uint8(128),
  63273 				8:  uint8(128),
  63274 				9:  uint8(128),
  63275 				10: uint8(128),
  63276 			},
  63277 		},
  63278 		6: {
  63279 			0: {
  63280 				0:  uint8(1),
  63281 				1:  uint8(134),
  63282 				2:  uint8(252),
  63283 				3:  uint8(255),
  63284 				4:  uint8(255),
  63285 				5:  uint8(128),
  63286 				6:  uint8(128),
  63287 				7:  uint8(128),
  63288 				8:  uint8(128),
  63289 				9:  uint8(128),
  63290 				10: uint8(128),
  63291 			},
  63292 			1: {
  63293 				0:  uint8(213),
  63294 				1:  uint8(62),
  63295 				2:  uint8(250),
  63296 				3:  uint8(255),
  63297 				4:  uint8(255),
  63298 				5:  uint8(128),
  63299 				6:  uint8(128),
  63300 				7:  uint8(128),
  63301 				8:  uint8(128),
  63302 				9:  uint8(128),
  63303 				10: uint8(128),
  63304 			},
  63305 			2: {
  63306 				0:  uint8(55),
  63307 				1:  uint8(93),
  63308 				2:  uint8(255),
  63309 				3:  uint8(128),
  63310 				4:  uint8(128),
  63311 				5:  uint8(128),
  63312 				6:  uint8(128),
  63313 				7:  uint8(128),
  63314 				8:  uint8(128),
  63315 				9:  uint8(128),
  63316 				10: uint8(128),
  63317 			},
  63318 		},
  63319 		7: {
  63320 			0: {
  63321 				0:  uint8(128),
  63322 				1:  uint8(128),
  63323 				2:  uint8(128),
  63324 				3:  uint8(128),
  63325 				4:  uint8(128),
  63326 				5:  uint8(128),
  63327 				6:  uint8(128),
  63328 				7:  uint8(128),
  63329 				8:  uint8(128),
  63330 				9:  uint8(128),
  63331 				10: uint8(128),
  63332 			},
  63333 			1: {
  63334 				0:  uint8(128),
  63335 				1:  uint8(128),
  63336 				2:  uint8(128),
  63337 				3:  uint8(128),
  63338 				4:  uint8(128),
  63339 				5:  uint8(128),
  63340 				6:  uint8(128),
  63341 				7:  uint8(128),
  63342 				8:  uint8(128),
  63343 				9:  uint8(128),
  63344 				10: uint8(128),
  63345 			},
  63346 			2: {
  63347 				0:  uint8(128),
  63348 				1:  uint8(128),
  63349 				2:  uint8(128),
  63350 				3:  uint8(128),
  63351 				4:  uint8(128),
  63352 				5:  uint8(128),
  63353 				6:  uint8(128),
  63354 				7:  uint8(128),
  63355 				8:  uint8(128),
  63356 				9:  uint8(128),
  63357 				10: uint8(128),
  63358 			},
  63359 		},
  63360 	},
  63361 	3: {
  63362 		0: {
  63363 			0: {
  63364 				0:  uint8(202),
  63365 				1:  uint8(24),
  63366 				2:  uint8(213),
  63367 				3:  uint8(235),
  63368 				4:  uint8(186),
  63369 				5:  uint8(191),
  63370 				6:  uint8(220),
  63371 				7:  uint8(160),
  63372 				8:  uint8(240),
  63373 				9:  uint8(175),
  63374 				10: uint8(255),
  63375 			},
  63376 			1: {
  63377 				0:  uint8(126),
  63378 				1:  uint8(38),
  63379 				2:  uint8(182),
  63380 				3:  uint8(232),
  63381 				4:  uint8(169),
  63382 				5:  uint8(184),
  63383 				6:  uint8(228),
  63384 				7:  uint8(174),
  63385 				8:  uint8(255),
  63386 				9:  uint8(187),
  63387 				10: uint8(128),
  63388 			},
  63389 			2: {
  63390 				0:  uint8(61),
  63391 				1:  uint8(46),
  63392 				2:  uint8(138),
  63393 				3:  uint8(219),
  63394 				4:  uint8(151),
  63395 				5:  uint8(178),
  63396 				6:  uint8(240),
  63397 				7:  uint8(170),
  63398 				8:  uint8(255),
  63399 				9:  uint8(216),
  63400 				10: uint8(128),
  63401 			},
  63402 		},
  63403 		1: {
  63404 			0: {
  63405 				0:  uint8(1),
  63406 				1:  uint8(112),
  63407 				2:  uint8(230),
  63408 				3:  uint8(250),
  63409 				4:  uint8(199),
  63410 				5:  uint8(191),
  63411 				6:  uint8(247),
  63412 				7:  uint8(159),
  63413 				8:  uint8(255),
  63414 				9:  uint8(255),
  63415 				10: uint8(128),
  63416 			},
  63417 			1: {
  63418 				0:  uint8(166),
  63419 				1:  uint8(109),
  63420 				2:  uint8(228),
  63421 				3:  uint8(252),
  63422 				4:  uint8(211),
  63423 				5:  uint8(215),
  63424 				6:  uint8(255),
  63425 				7:  uint8(174),
  63426 				8:  uint8(128),
  63427 				9:  uint8(128),
  63428 				10: uint8(128),
  63429 			},
  63430 			2: {
  63431 				0:  uint8(39),
  63432 				1:  uint8(77),
  63433 				2:  uint8(162),
  63434 				3:  uint8(232),
  63435 				4:  uint8(172),
  63436 				5:  uint8(180),
  63437 				6:  uint8(245),
  63438 				7:  uint8(178),
  63439 				8:  uint8(255),
  63440 				9:  uint8(255),
  63441 				10: uint8(128),
  63442 			},
  63443 		},
  63444 		2: {
  63445 			0: {
  63446 				0:  uint8(1),
  63447 				1:  uint8(52),
  63448 				2:  uint8(220),
  63449 				3:  uint8(246),
  63450 				4:  uint8(198),
  63451 				5:  uint8(199),
  63452 				6:  uint8(249),
  63453 				7:  uint8(220),
  63454 				8:  uint8(255),
  63455 				9:  uint8(255),
  63456 				10: uint8(128),
  63457 			},
  63458 			1: {
  63459 				0:  uint8(124),
  63460 				1:  uint8(74),
  63461 				2:  uint8(191),
  63462 				3:  uint8(243),
  63463 				4:  uint8(183),
  63464 				5:  uint8(193),
  63465 				6:  uint8(250),
  63466 				7:  uint8(221),
  63467 				8:  uint8(255),
  63468 				9:  uint8(255),
  63469 				10: uint8(128),
  63470 			},
  63471 			2: {
  63472 				0:  uint8(24),
  63473 				1:  uint8(71),
  63474 				2:  uint8(130),
  63475 				3:  uint8(219),
  63476 				4:  uint8(154),
  63477 				5:  uint8(170),
  63478 				6:  uint8(243),
  63479 				7:  uint8(182),
  63480 				8:  uint8(255),
  63481 				9:  uint8(255),
  63482 				10: uint8(128),
  63483 			},
  63484 		},
  63485 		3: {
  63486 			0: {
  63487 				0:  uint8(1),
  63488 				1:  uint8(182),
  63489 				2:  uint8(225),
  63490 				3:  uint8(249),
  63491 				4:  uint8(219),
  63492 				5:  uint8(240),
  63493 				6:  uint8(255),
  63494 				7:  uint8(224),
  63495 				8:  uint8(128),
  63496 				9:  uint8(128),
  63497 				10: uint8(128),
  63498 			},
  63499 			1: {
  63500 				0:  uint8(149),
  63501 				1:  uint8(150),
  63502 				2:  uint8(226),
  63503 				3:  uint8(252),
  63504 				4:  uint8(216),
  63505 				5:  uint8(205),
  63506 				6:  uint8(255),
  63507 				7:  uint8(171),
  63508 				8:  uint8(128),
  63509 				9:  uint8(128),
  63510 				10: uint8(128),
  63511 			},
  63512 			2: {
  63513 				0:  uint8(28),
  63514 				1:  uint8(108),
  63515 				2:  uint8(170),
  63516 				3:  uint8(242),
  63517 				4:  uint8(183),
  63518 				5:  uint8(194),
  63519 				6:  uint8(254),
  63520 				7:  uint8(223),
  63521 				8:  uint8(255),
  63522 				9:  uint8(255),
  63523 				10: uint8(128),
  63524 			},
  63525 		},
  63526 		4: {
  63527 			0: {
  63528 				0:  uint8(1),
  63529 				1:  uint8(81),
  63530 				2:  uint8(230),
  63531 				3:  uint8(252),
  63532 				4:  uint8(204),
  63533 				5:  uint8(203),
  63534 				6:  uint8(255),
  63535 				7:  uint8(192),
  63536 				8:  uint8(128),
  63537 				9:  uint8(128),
  63538 				10: uint8(128),
  63539 			},
  63540 			1: {
  63541 				0:  uint8(123),
  63542 				1:  uint8(102),
  63543 				2:  uint8(209),
  63544 				3:  uint8(247),
  63545 				4:  uint8(188),
  63546 				5:  uint8(196),
  63547 				6:  uint8(255),
  63548 				7:  uint8(233),
  63549 				8:  uint8(128),
  63550 				9:  uint8(128),
  63551 				10: uint8(128),
  63552 			},
  63553 			2: {
  63554 				0:  uint8(20),
  63555 				1:  uint8(95),
  63556 				2:  uint8(153),
  63557 				3:  uint8(243),
  63558 				4:  uint8(164),
  63559 				5:  uint8(173),
  63560 				6:  uint8(255),
  63561 				7:  uint8(203),
  63562 				8:  uint8(128),
  63563 				9:  uint8(128),
  63564 				10: uint8(128),
  63565 			},
  63566 		},
  63567 		5: {
  63568 			0: {
  63569 				0:  uint8(1),
  63570 				1:  uint8(222),
  63571 				2:  uint8(248),
  63572 				3:  uint8(255),
  63573 				4:  uint8(216),
  63574 				5:  uint8(213),
  63575 				6:  uint8(128),
  63576 				7:  uint8(128),
  63577 				8:  uint8(128),
  63578 				9:  uint8(128),
  63579 				10: uint8(128),
  63580 			},
  63581 			1: {
  63582 				0:  uint8(168),
  63583 				1:  uint8(175),
  63584 				2:  uint8(246),
  63585 				3:  uint8(252),
  63586 				4:  uint8(235),
  63587 				5:  uint8(205),
  63588 				6:  uint8(255),
  63589 				7:  uint8(255),
  63590 				8:  uint8(128),
  63591 				9:  uint8(128),
  63592 				10: uint8(128),
  63593 			},
  63594 			2: {
  63595 				0:  uint8(47),
  63596 				1:  uint8(116),
  63597 				2:  uint8(215),
  63598 				3:  uint8(255),
  63599 				4:  uint8(211),
  63600 				5:  uint8(212),
  63601 				6:  uint8(255),
  63602 				7:  uint8(255),
  63603 				8:  uint8(128),
  63604 				9:  uint8(128),
  63605 				10: uint8(128),
  63606 			},
  63607 		},
  63608 		6: {
  63609 			0: {
  63610 				0:  uint8(1),
  63611 				1:  uint8(121),
  63612 				2:  uint8(236),
  63613 				3:  uint8(253),
  63614 				4:  uint8(212),
  63615 				5:  uint8(214),
  63616 				6:  uint8(255),
  63617 				7:  uint8(255),
  63618 				8:  uint8(128),
  63619 				9:  uint8(128),
  63620 				10: uint8(128),
  63621 			},
  63622 			1: {
  63623 				0:  uint8(141),
  63624 				1:  uint8(84),
  63625 				2:  uint8(213),
  63626 				3:  uint8(252),
  63627 				4:  uint8(201),
  63628 				5:  uint8(202),
  63629 				6:  uint8(255),
  63630 				7:  uint8(219),
  63631 				8:  uint8(128),
  63632 				9:  uint8(128),
  63633 				10: uint8(128),
  63634 			},
  63635 			2: {
  63636 				0:  uint8(42),
  63637 				1:  uint8(80),
  63638 				2:  uint8(160),
  63639 				3:  uint8(240),
  63640 				4:  uint8(162),
  63641 				5:  uint8(185),
  63642 				6:  uint8(255),
  63643 				7:  uint8(205),
  63644 				8:  uint8(128),
  63645 				9:  uint8(128),
  63646 				10: uint8(128),
  63647 			},
  63648 		},
  63649 		7: {
  63650 			0: {
  63651 				0:  uint8(1),
  63652 				1:  uint8(1),
  63653 				2:  uint8(255),
  63654 				3:  uint8(128),
  63655 				4:  uint8(128),
  63656 				5:  uint8(128),
  63657 				6:  uint8(128),
  63658 				7:  uint8(128),
  63659 				8:  uint8(128),
  63660 				9:  uint8(128),
  63661 				10: uint8(128),
  63662 			},
  63663 			1: {
  63664 				0:  uint8(244),
  63665 				1:  uint8(1),
  63666 				2:  uint8(255),
  63667 				3:  uint8(128),
  63668 				4:  uint8(128),
  63669 				5:  uint8(128),
  63670 				6:  uint8(128),
  63671 				7:  uint8(128),
  63672 				8:  uint8(128),
  63673 				9:  uint8(128),
  63674 				10: uint8(128),
  63675 			},
  63676 			2: {
  63677 				0:  uint8(238),
  63678 				1:  uint8(1),
  63679 				2:  uint8(255),
  63680 				3:  uint8(128),
  63681 				4:  uint8(128),
  63682 				5:  uint8(128),
  63683 				6:  uint8(128),
  63684 				7:  uint8(128),
  63685 				8:  uint8(128),
  63686 				9:  uint8(128),
  63687 				10: uint8(128),
  63688 			},
  63689 		},
  63690 	},
  63691 }
  63692 
  63693 //------------------------------------------------------------------------------
  63694 // Paragraph 13
  63695 
  63696 var VP8CoeffsUpdateProba = [4][8][3][11]uint8_t{
  63697 	0: {
  63698 		0: {
  63699 			0: {
  63700 				0:  uint8(255),
  63701 				1:  uint8(255),
  63702 				2:  uint8(255),
  63703 				3:  uint8(255),
  63704 				4:  uint8(255),
  63705 				5:  uint8(255),
  63706 				6:  uint8(255),
  63707 				7:  uint8(255),
  63708 				8:  uint8(255),
  63709 				9:  uint8(255),
  63710 				10: uint8(255),
  63711 			},
  63712 			1: {
  63713 				0:  uint8(255),
  63714 				1:  uint8(255),
  63715 				2:  uint8(255),
  63716 				3:  uint8(255),
  63717 				4:  uint8(255),
  63718 				5:  uint8(255),
  63719 				6:  uint8(255),
  63720 				7:  uint8(255),
  63721 				8:  uint8(255),
  63722 				9:  uint8(255),
  63723 				10: uint8(255),
  63724 			},
  63725 			2: {
  63726 				0:  uint8(255),
  63727 				1:  uint8(255),
  63728 				2:  uint8(255),
  63729 				3:  uint8(255),
  63730 				4:  uint8(255),
  63731 				5:  uint8(255),
  63732 				6:  uint8(255),
  63733 				7:  uint8(255),
  63734 				8:  uint8(255),
  63735 				9:  uint8(255),
  63736 				10: uint8(255),
  63737 			},
  63738 		},
  63739 		1: {
  63740 			0: {
  63741 				0:  uint8(176),
  63742 				1:  uint8(246),
  63743 				2:  uint8(255),
  63744 				3:  uint8(255),
  63745 				4:  uint8(255),
  63746 				5:  uint8(255),
  63747 				6:  uint8(255),
  63748 				7:  uint8(255),
  63749 				8:  uint8(255),
  63750 				9:  uint8(255),
  63751 				10: uint8(255),
  63752 			},
  63753 			1: {
  63754 				0:  uint8(223),
  63755 				1:  uint8(241),
  63756 				2:  uint8(252),
  63757 				3:  uint8(255),
  63758 				4:  uint8(255),
  63759 				5:  uint8(255),
  63760 				6:  uint8(255),
  63761 				7:  uint8(255),
  63762 				8:  uint8(255),
  63763 				9:  uint8(255),
  63764 				10: uint8(255),
  63765 			},
  63766 			2: {
  63767 				0:  uint8(249),
  63768 				1:  uint8(253),
  63769 				2:  uint8(253),
  63770 				3:  uint8(255),
  63771 				4:  uint8(255),
  63772 				5:  uint8(255),
  63773 				6:  uint8(255),
  63774 				7:  uint8(255),
  63775 				8:  uint8(255),
  63776 				9:  uint8(255),
  63777 				10: uint8(255),
  63778 			},
  63779 		},
  63780 		2: {
  63781 			0: {
  63782 				0:  uint8(255),
  63783 				1:  uint8(244),
  63784 				2:  uint8(252),
  63785 				3:  uint8(255),
  63786 				4:  uint8(255),
  63787 				5:  uint8(255),
  63788 				6:  uint8(255),
  63789 				7:  uint8(255),
  63790 				8:  uint8(255),
  63791 				9:  uint8(255),
  63792 				10: uint8(255),
  63793 			},
  63794 			1: {
  63795 				0:  uint8(234),
  63796 				1:  uint8(254),
  63797 				2:  uint8(254),
  63798 				3:  uint8(255),
  63799 				4:  uint8(255),
  63800 				5:  uint8(255),
  63801 				6:  uint8(255),
  63802 				7:  uint8(255),
  63803 				8:  uint8(255),
  63804 				9:  uint8(255),
  63805 				10: uint8(255),
  63806 			},
  63807 			2: {
  63808 				0:  uint8(253),
  63809 				1:  uint8(255),
  63810 				2:  uint8(255),
  63811 				3:  uint8(255),
  63812 				4:  uint8(255),
  63813 				5:  uint8(255),
  63814 				6:  uint8(255),
  63815 				7:  uint8(255),
  63816 				8:  uint8(255),
  63817 				9:  uint8(255),
  63818 				10: uint8(255),
  63819 			},
  63820 		},
  63821 		3: {
  63822 			0: {
  63823 				0:  uint8(255),
  63824 				1:  uint8(246),
  63825 				2:  uint8(254),
  63826 				3:  uint8(255),
  63827 				4:  uint8(255),
  63828 				5:  uint8(255),
  63829 				6:  uint8(255),
  63830 				7:  uint8(255),
  63831 				8:  uint8(255),
  63832 				9:  uint8(255),
  63833 				10: uint8(255),
  63834 			},
  63835 			1: {
  63836 				0:  uint8(239),
  63837 				1:  uint8(253),
  63838 				2:  uint8(254),
  63839 				3:  uint8(255),
  63840 				4:  uint8(255),
  63841 				5:  uint8(255),
  63842 				6:  uint8(255),
  63843 				7:  uint8(255),
  63844 				8:  uint8(255),
  63845 				9:  uint8(255),
  63846 				10: uint8(255),
  63847 			},
  63848 			2: {
  63849 				0:  uint8(254),
  63850 				1:  uint8(255),
  63851 				2:  uint8(254),
  63852 				3:  uint8(255),
  63853 				4:  uint8(255),
  63854 				5:  uint8(255),
  63855 				6:  uint8(255),
  63856 				7:  uint8(255),
  63857 				8:  uint8(255),
  63858 				9:  uint8(255),
  63859 				10: uint8(255),
  63860 			},
  63861 		},
  63862 		4: {
  63863 			0: {
  63864 				0:  uint8(255),
  63865 				1:  uint8(248),
  63866 				2:  uint8(254),
  63867 				3:  uint8(255),
  63868 				4:  uint8(255),
  63869 				5:  uint8(255),
  63870 				6:  uint8(255),
  63871 				7:  uint8(255),
  63872 				8:  uint8(255),
  63873 				9:  uint8(255),
  63874 				10: uint8(255),
  63875 			},
  63876 			1: {
  63877 				0:  uint8(251),
  63878 				1:  uint8(255),
  63879 				2:  uint8(254),
  63880 				3:  uint8(255),
  63881 				4:  uint8(255),
  63882 				5:  uint8(255),
  63883 				6:  uint8(255),
  63884 				7:  uint8(255),
  63885 				8:  uint8(255),
  63886 				9:  uint8(255),
  63887 				10: uint8(255),
  63888 			},
  63889 			2: {
  63890 				0:  uint8(255),
  63891 				1:  uint8(255),
  63892 				2:  uint8(255),
  63893 				3:  uint8(255),
  63894 				4:  uint8(255),
  63895 				5:  uint8(255),
  63896 				6:  uint8(255),
  63897 				7:  uint8(255),
  63898 				8:  uint8(255),
  63899 				9:  uint8(255),
  63900 				10: uint8(255),
  63901 			},
  63902 		},
  63903 		5: {
  63904 			0: {
  63905 				0:  uint8(255),
  63906 				1:  uint8(253),
  63907 				2:  uint8(254),
  63908 				3:  uint8(255),
  63909 				4:  uint8(255),
  63910 				5:  uint8(255),
  63911 				6:  uint8(255),
  63912 				7:  uint8(255),
  63913 				8:  uint8(255),
  63914 				9:  uint8(255),
  63915 				10: uint8(255),
  63916 			},
  63917 			1: {
  63918 				0:  uint8(251),
  63919 				1:  uint8(254),
  63920 				2:  uint8(254),
  63921 				3:  uint8(255),
  63922 				4:  uint8(255),
  63923 				5:  uint8(255),
  63924 				6:  uint8(255),
  63925 				7:  uint8(255),
  63926 				8:  uint8(255),
  63927 				9:  uint8(255),
  63928 				10: uint8(255),
  63929 			},
  63930 			2: {
  63931 				0:  uint8(254),
  63932 				1:  uint8(255),
  63933 				2:  uint8(254),
  63934 				3:  uint8(255),
  63935 				4:  uint8(255),
  63936 				5:  uint8(255),
  63937 				6:  uint8(255),
  63938 				7:  uint8(255),
  63939 				8:  uint8(255),
  63940 				9:  uint8(255),
  63941 				10: uint8(255),
  63942 			},
  63943 		},
  63944 		6: {
  63945 			0: {
  63946 				0:  uint8(255),
  63947 				1:  uint8(254),
  63948 				2:  uint8(253),
  63949 				3:  uint8(255),
  63950 				4:  uint8(254),
  63951 				5:  uint8(255),
  63952 				6:  uint8(255),
  63953 				7:  uint8(255),
  63954 				8:  uint8(255),
  63955 				9:  uint8(255),
  63956 				10: uint8(255),
  63957 			},
  63958 			1: {
  63959 				0:  uint8(250),
  63960 				1:  uint8(255),
  63961 				2:  uint8(254),
  63962 				3:  uint8(255),
  63963 				4:  uint8(254),
  63964 				5:  uint8(255),
  63965 				6:  uint8(255),
  63966 				7:  uint8(255),
  63967 				8:  uint8(255),
  63968 				9:  uint8(255),
  63969 				10: uint8(255),
  63970 			},
  63971 			2: {
  63972 				0:  uint8(254),
  63973 				1:  uint8(255),
  63974 				2:  uint8(255),
  63975 				3:  uint8(255),
  63976 				4:  uint8(255),
  63977 				5:  uint8(255),
  63978 				6:  uint8(255),
  63979 				7:  uint8(255),
  63980 				8:  uint8(255),
  63981 				9:  uint8(255),
  63982 				10: uint8(255),
  63983 			},
  63984 		},
  63985 		7: {
  63986 			0: {
  63987 				0:  uint8(255),
  63988 				1:  uint8(255),
  63989 				2:  uint8(255),
  63990 				3:  uint8(255),
  63991 				4:  uint8(255),
  63992 				5:  uint8(255),
  63993 				6:  uint8(255),
  63994 				7:  uint8(255),
  63995 				8:  uint8(255),
  63996 				9:  uint8(255),
  63997 				10: uint8(255),
  63998 			},
  63999 			1: {
  64000 				0:  uint8(255),
  64001 				1:  uint8(255),
  64002 				2:  uint8(255),
  64003 				3:  uint8(255),
  64004 				4:  uint8(255),
  64005 				5:  uint8(255),
  64006 				6:  uint8(255),
  64007 				7:  uint8(255),
  64008 				8:  uint8(255),
  64009 				9:  uint8(255),
  64010 				10: uint8(255),
  64011 			},
  64012 			2: {
  64013 				0:  uint8(255),
  64014 				1:  uint8(255),
  64015 				2:  uint8(255),
  64016 				3:  uint8(255),
  64017 				4:  uint8(255),
  64018 				5:  uint8(255),
  64019 				6:  uint8(255),
  64020 				7:  uint8(255),
  64021 				8:  uint8(255),
  64022 				9:  uint8(255),
  64023 				10: uint8(255),
  64024 			},
  64025 		},
  64026 	},
  64027 	1: {
  64028 		0: {
  64029 			0: {
  64030 				0:  uint8(217),
  64031 				1:  uint8(255),
  64032 				2:  uint8(255),
  64033 				3:  uint8(255),
  64034 				4:  uint8(255),
  64035 				5:  uint8(255),
  64036 				6:  uint8(255),
  64037 				7:  uint8(255),
  64038 				8:  uint8(255),
  64039 				9:  uint8(255),
  64040 				10: uint8(255),
  64041 			},
  64042 			1: {
  64043 				0:  uint8(225),
  64044 				1:  uint8(252),
  64045 				2:  uint8(241),
  64046 				3:  uint8(253),
  64047 				4:  uint8(255),
  64048 				5:  uint8(255),
  64049 				6:  uint8(254),
  64050 				7:  uint8(255),
  64051 				8:  uint8(255),
  64052 				9:  uint8(255),
  64053 				10: uint8(255),
  64054 			},
  64055 			2: {
  64056 				0:  uint8(234),
  64057 				1:  uint8(250),
  64058 				2:  uint8(241),
  64059 				3:  uint8(250),
  64060 				4:  uint8(253),
  64061 				5:  uint8(255),
  64062 				6:  uint8(253),
  64063 				7:  uint8(254),
  64064 				8:  uint8(255),
  64065 				9:  uint8(255),
  64066 				10: uint8(255),
  64067 			},
  64068 		},
  64069 		1: {
  64070 			0: {
  64071 				0:  uint8(255),
  64072 				1:  uint8(254),
  64073 				2:  uint8(255),
  64074 				3:  uint8(255),
  64075 				4:  uint8(255),
  64076 				5:  uint8(255),
  64077 				6:  uint8(255),
  64078 				7:  uint8(255),
  64079 				8:  uint8(255),
  64080 				9:  uint8(255),
  64081 				10: uint8(255),
  64082 			},
  64083 			1: {
  64084 				0:  uint8(223),
  64085 				1:  uint8(254),
  64086 				2:  uint8(254),
  64087 				3:  uint8(255),
  64088 				4:  uint8(255),
  64089 				5:  uint8(255),
  64090 				6:  uint8(255),
  64091 				7:  uint8(255),
  64092 				8:  uint8(255),
  64093 				9:  uint8(255),
  64094 				10: uint8(255),
  64095 			},
  64096 			2: {
  64097 				0:  uint8(238),
  64098 				1:  uint8(253),
  64099 				2:  uint8(254),
  64100 				3:  uint8(254),
  64101 				4:  uint8(255),
  64102 				5:  uint8(255),
  64103 				6:  uint8(255),
  64104 				7:  uint8(255),
  64105 				8:  uint8(255),
  64106 				9:  uint8(255),
  64107 				10: uint8(255),
  64108 			},
  64109 		},
  64110 		2: {
  64111 			0: {
  64112 				0:  uint8(255),
  64113 				1:  uint8(248),
  64114 				2:  uint8(254),
  64115 				3:  uint8(255),
  64116 				4:  uint8(255),
  64117 				5:  uint8(255),
  64118 				6:  uint8(255),
  64119 				7:  uint8(255),
  64120 				8:  uint8(255),
  64121 				9:  uint8(255),
  64122 				10: uint8(255),
  64123 			},
  64124 			1: {
  64125 				0:  uint8(249),
  64126 				1:  uint8(254),
  64127 				2:  uint8(255),
  64128 				3:  uint8(255),
  64129 				4:  uint8(255),
  64130 				5:  uint8(255),
  64131 				6:  uint8(255),
  64132 				7:  uint8(255),
  64133 				8:  uint8(255),
  64134 				9:  uint8(255),
  64135 				10: uint8(255),
  64136 			},
  64137 			2: {
  64138 				0:  uint8(255),
  64139 				1:  uint8(255),
  64140 				2:  uint8(255),
  64141 				3:  uint8(255),
  64142 				4:  uint8(255),
  64143 				5:  uint8(255),
  64144 				6:  uint8(255),
  64145 				7:  uint8(255),
  64146 				8:  uint8(255),
  64147 				9:  uint8(255),
  64148 				10: uint8(255),
  64149 			},
  64150 		},
  64151 		3: {
  64152 			0: {
  64153 				0:  uint8(255),
  64154 				1:  uint8(253),
  64155 				2:  uint8(255),
  64156 				3:  uint8(255),
  64157 				4:  uint8(255),
  64158 				5:  uint8(255),
  64159 				6:  uint8(255),
  64160 				7:  uint8(255),
  64161 				8:  uint8(255),
  64162 				9:  uint8(255),
  64163 				10: uint8(255),
  64164 			},
  64165 			1: {
  64166 				0:  uint8(247),
  64167 				1:  uint8(254),
  64168 				2:  uint8(255),
  64169 				3:  uint8(255),
  64170 				4:  uint8(255),
  64171 				5:  uint8(255),
  64172 				6:  uint8(255),
  64173 				7:  uint8(255),
  64174 				8:  uint8(255),
  64175 				9:  uint8(255),
  64176 				10: uint8(255),
  64177 			},
  64178 			2: {
  64179 				0:  uint8(255),
  64180 				1:  uint8(255),
  64181 				2:  uint8(255),
  64182 				3:  uint8(255),
  64183 				4:  uint8(255),
  64184 				5:  uint8(255),
  64185 				6:  uint8(255),
  64186 				7:  uint8(255),
  64187 				8:  uint8(255),
  64188 				9:  uint8(255),
  64189 				10: uint8(255),
  64190 			},
  64191 		},
  64192 		4: {
  64193 			0: {
  64194 				0:  uint8(255),
  64195 				1:  uint8(253),
  64196 				2:  uint8(254),
  64197 				3:  uint8(255),
  64198 				4:  uint8(255),
  64199 				5:  uint8(255),
  64200 				6:  uint8(255),
  64201 				7:  uint8(255),
  64202 				8:  uint8(255),
  64203 				9:  uint8(255),
  64204 				10: uint8(255),
  64205 			},
  64206 			1: {
  64207 				0:  uint8(252),
  64208 				1:  uint8(255),
  64209 				2:  uint8(255),
  64210 				3:  uint8(255),
  64211 				4:  uint8(255),
  64212 				5:  uint8(255),
  64213 				6:  uint8(255),
  64214 				7:  uint8(255),
  64215 				8:  uint8(255),
  64216 				9:  uint8(255),
  64217 				10: uint8(255),
  64218 			},
  64219 			2: {
  64220 				0:  uint8(255),
  64221 				1:  uint8(255),
  64222 				2:  uint8(255),
  64223 				3:  uint8(255),
  64224 				4:  uint8(255),
  64225 				5:  uint8(255),
  64226 				6:  uint8(255),
  64227 				7:  uint8(255),
  64228 				8:  uint8(255),
  64229 				9:  uint8(255),
  64230 				10: uint8(255),
  64231 			},
  64232 		},
  64233 		5: {
  64234 			0: {
  64235 				0:  uint8(255),
  64236 				1:  uint8(254),
  64237 				2:  uint8(254),
  64238 				3:  uint8(255),
  64239 				4:  uint8(255),
  64240 				5:  uint8(255),
  64241 				6:  uint8(255),
  64242 				7:  uint8(255),
  64243 				8:  uint8(255),
  64244 				9:  uint8(255),
  64245 				10: uint8(255),
  64246 			},
  64247 			1: {
  64248 				0:  uint8(253),
  64249 				1:  uint8(255),
  64250 				2:  uint8(255),
  64251 				3:  uint8(255),
  64252 				4:  uint8(255),
  64253 				5:  uint8(255),
  64254 				6:  uint8(255),
  64255 				7:  uint8(255),
  64256 				8:  uint8(255),
  64257 				9:  uint8(255),
  64258 				10: uint8(255),
  64259 			},
  64260 			2: {
  64261 				0:  uint8(255),
  64262 				1:  uint8(255),
  64263 				2:  uint8(255),
  64264 				3:  uint8(255),
  64265 				4:  uint8(255),
  64266 				5:  uint8(255),
  64267 				6:  uint8(255),
  64268 				7:  uint8(255),
  64269 				8:  uint8(255),
  64270 				9:  uint8(255),
  64271 				10: uint8(255),
  64272 			},
  64273 		},
  64274 		6: {
  64275 			0: {
  64276 				0:  uint8(255),
  64277 				1:  uint8(254),
  64278 				2:  uint8(253),
  64279 				3:  uint8(255),
  64280 				4:  uint8(255),
  64281 				5:  uint8(255),
  64282 				6:  uint8(255),
  64283 				7:  uint8(255),
  64284 				8:  uint8(255),
  64285 				9:  uint8(255),
  64286 				10: uint8(255),
  64287 			},
  64288 			1: {
  64289 				0:  uint8(250),
  64290 				1:  uint8(255),
  64291 				2:  uint8(255),
  64292 				3:  uint8(255),
  64293 				4:  uint8(255),
  64294 				5:  uint8(255),
  64295 				6:  uint8(255),
  64296 				7:  uint8(255),
  64297 				8:  uint8(255),
  64298 				9:  uint8(255),
  64299 				10: uint8(255),
  64300 			},
  64301 			2: {
  64302 				0:  uint8(254),
  64303 				1:  uint8(255),
  64304 				2:  uint8(255),
  64305 				3:  uint8(255),
  64306 				4:  uint8(255),
  64307 				5:  uint8(255),
  64308 				6:  uint8(255),
  64309 				7:  uint8(255),
  64310 				8:  uint8(255),
  64311 				9:  uint8(255),
  64312 				10: uint8(255),
  64313 			},
  64314 		},
  64315 		7: {
  64316 			0: {
  64317 				0:  uint8(255),
  64318 				1:  uint8(255),
  64319 				2:  uint8(255),
  64320 				3:  uint8(255),
  64321 				4:  uint8(255),
  64322 				5:  uint8(255),
  64323 				6:  uint8(255),
  64324 				7:  uint8(255),
  64325 				8:  uint8(255),
  64326 				9:  uint8(255),
  64327 				10: uint8(255),
  64328 			},
  64329 			1: {
  64330 				0:  uint8(255),
  64331 				1:  uint8(255),
  64332 				2:  uint8(255),
  64333 				3:  uint8(255),
  64334 				4:  uint8(255),
  64335 				5:  uint8(255),
  64336 				6:  uint8(255),
  64337 				7:  uint8(255),
  64338 				8:  uint8(255),
  64339 				9:  uint8(255),
  64340 				10: uint8(255),
  64341 			},
  64342 			2: {
  64343 				0:  uint8(255),
  64344 				1:  uint8(255),
  64345 				2:  uint8(255),
  64346 				3:  uint8(255),
  64347 				4:  uint8(255),
  64348 				5:  uint8(255),
  64349 				6:  uint8(255),
  64350 				7:  uint8(255),
  64351 				8:  uint8(255),
  64352 				9:  uint8(255),
  64353 				10: uint8(255),
  64354 			},
  64355 		},
  64356 	},
  64357 	2: {
  64358 		0: {
  64359 			0: {
  64360 				0:  uint8(186),
  64361 				1:  uint8(251),
  64362 				2:  uint8(250),
  64363 				3:  uint8(255),
  64364 				4:  uint8(255),
  64365 				5:  uint8(255),
  64366 				6:  uint8(255),
  64367 				7:  uint8(255),
  64368 				8:  uint8(255),
  64369 				9:  uint8(255),
  64370 				10: uint8(255),
  64371 			},
  64372 			1: {
  64373 				0:  uint8(234),
  64374 				1:  uint8(251),
  64375 				2:  uint8(244),
  64376 				3:  uint8(254),
  64377 				4:  uint8(255),
  64378 				5:  uint8(255),
  64379 				6:  uint8(255),
  64380 				7:  uint8(255),
  64381 				8:  uint8(255),
  64382 				9:  uint8(255),
  64383 				10: uint8(255),
  64384 			},
  64385 			2: {
  64386 				0:  uint8(251),
  64387 				1:  uint8(251),
  64388 				2:  uint8(243),
  64389 				3:  uint8(253),
  64390 				4:  uint8(254),
  64391 				5:  uint8(255),
  64392 				6:  uint8(254),
  64393 				7:  uint8(255),
  64394 				8:  uint8(255),
  64395 				9:  uint8(255),
  64396 				10: uint8(255),
  64397 			},
  64398 		},
  64399 		1: {
  64400 			0: {
  64401 				0:  uint8(255),
  64402 				1:  uint8(253),
  64403 				2:  uint8(254),
  64404 				3:  uint8(255),
  64405 				4:  uint8(255),
  64406 				5:  uint8(255),
  64407 				6:  uint8(255),
  64408 				7:  uint8(255),
  64409 				8:  uint8(255),
  64410 				9:  uint8(255),
  64411 				10: uint8(255),
  64412 			},
  64413 			1: {
  64414 				0:  uint8(236),
  64415 				1:  uint8(253),
  64416 				2:  uint8(254),
  64417 				3:  uint8(255),
  64418 				4:  uint8(255),
  64419 				5:  uint8(255),
  64420 				6:  uint8(255),
  64421 				7:  uint8(255),
  64422 				8:  uint8(255),
  64423 				9:  uint8(255),
  64424 				10: uint8(255),
  64425 			},
  64426 			2: {
  64427 				0:  uint8(251),
  64428 				1:  uint8(253),
  64429 				2:  uint8(253),
  64430 				3:  uint8(254),
  64431 				4:  uint8(254),
  64432 				5:  uint8(255),
  64433 				6:  uint8(255),
  64434 				7:  uint8(255),
  64435 				8:  uint8(255),
  64436 				9:  uint8(255),
  64437 				10: uint8(255),
  64438 			},
  64439 		},
  64440 		2: {
  64441 			0: {
  64442 				0:  uint8(255),
  64443 				1:  uint8(254),
  64444 				2:  uint8(254),
  64445 				3:  uint8(255),
  64446 				4:  uint8(255),
  64447 				5:  uint8(255),
  64448 				6:  uint8(255),
  64449 				7:  uint8(255),
  64450 				8:  uint8(255),
  64451 				9:  uint8(255),
  64452 				10: uint8(255),
  64453 			},
  64454 			1: {
  64455 				0:  uint8(254),
  64456 				1:  uint8(254),
  64457 				2:  uint8(254),
  64458 				3:  uint8(255),
  64459 				4:  uint8(255),
  64460 				5:  uint8(255),
  64461 				6:  uint8(255),
  64462 				7:  uint8(255),
  64463 				8:  uint8(255),
  64464 				9:  uint8(255),
  64465 				10: uint8(255),
  64466 			},
  64467 			2: {
  64468 				0:  uint8(255),
  64469 				1:  uint8(255),
  64470 				2:  uint8(255),
  64471 				3:  uint8(255),
  64472 				4:  uint8(255),
  64473 				5:  uint8(255),
  64474 				6:  uint8(255),
  64475 				7:  uint8(255),
  64476 				8:  uint8(255),
  64477 				9:  uint8(255),
  64478 				10: uint8(255),
  64479 			},
  64480 		},
  64481 		3: {
  64482 			0: {
  64483 				0:  uint8(255),
  64484 				1:  uint8(254),
  64485 				2:  uint8(255),
  64486 				3:  uint8(255),
  64487 				4:  uint8(255),
  64488 				5:  uint8(255),
  64489 				6:  uint8(255),
  64490 				7:  uint8(255),
  64491 				8:  uint8(255),
  64492 				9:  uint8(255),
  64493 				10: uint8(255),
  64494 			},
  64495 			1: {
  64496 				0:  uint8(254),
  64497 				1:  uint8(254),
  64498 				2:  uint8(255),
  64499 				3:  uint8(255),
  64500 				4:  uint8(255),
  64501 				5:  uint8(255),
  64502 				6:  uint8(255),
  64503 				7:  uint8(255),
  64504 				8:  uint8(255),
  64505 				9:  uint8(255),
  64506 				10: uint8(255),
  64507 			},
  64508 			2: {
  64509 				0:  uint8(254),
  64510 				1:  uint8(255),
  64511 				2:  uint8(255),
  64512 				3:  uint8(255),
  64513 				4:  uint8(255),
  64514 				5:  uint8(255),
  64515 				6:  uint8(255),
  64516 				7:  uint8(255),
  64517 				8:  uint8(255),
  64518 				9:  uint8(255),
  64519 				10: uint8(255),
  64520 			},
  64521 		},
  64522 		4: {
  64523 			0: {
  64524 				0:  uint8(255),
  64525 				1:  uint8(255),
  64526 				2:  uint8(255),
  64527 				3:  uint8(255),
  64528 				4:  uint8(255),
  64529 				5:  uint8(255),
  64530 				6:  uint8(255),
  64531 				7:  uint8(255),
  64532 				8:  uint8(255),
  64533 				9:  uint8(255),
  64534 				10: uint8(255),
  64535 			},
  64536 			1: {
  64537 				0:  uint8(254),
  64538 				1:  uint8(255),
  64539 				2:  uint8(255),
  64540 				3:  uint8(255),
  64541 				4:  uint8(255),
  64542 				5:  uint8(255),
  64543 				6:  uint8(255),
  64544 				7:  uint8(255),
  64545 				8:  uint8(255),
  64546 				9:  uint8(255),
  64547 				10: uint8(255),
  64548 			},
  64549 			2: {
  64550 				0:  uint8(255),
  64551 				1:  uint8(255),
  64552 				2:  uint8(255),
  64553 				3:  uint8(255),
  64554 				4:  uint8(255),
  64555 				5:  uint8(255),
  64556 				6:  uint8(255),
  64557 				7:  uint8(255),
  64558 				8:  uint8(255),
  64559 				9:  uint8(255),
  64560 				10: uint8(255),
  64561 			},
  64562 		},
  64563 		5: {
  64564 			0: {
  64565 				0:  uint8(255),
  64566 				1:  uint8(255),
  64567 				2:  uint8(255),
  64568 				3:  uint8(255),
  64569 				4:  uint8(255),
  64570 				5:  uint8(255),
  64571 				6:  uint8(255),
  64572 				7:  uint8(255),
  64573 				8:  uint8(255),
  64574 				9:  uint8(255),
  64575 				10: uint8(255),
  64576 			},
  64577 			1: {
  64578 				0:  uint8(255),
  64579 				1:  uint8(255),
  64580 				2:  uint8(255),
  64581 				3:  uint8(255),
  64582 				4:  uint8(255),
  64583 				5:  uint8(255),
  64584 				6:  uint8(255),
  64585 				7:  uint8(255),
  64586 				8:  uint8(255),
  64587 				9:  uint8(255),
  64588 				10: uint8(255),
  64589 			},
  64590 			2: {
  64591 				0:  uint8(255),
  64592 				1:  uint8(255),
  64593 				2:  uint8(255),
  64594 				3:  uint8(255),
  64595 				4:  uint8(255),
  64596 				5:  uint8(255),
  64597 				6:  uint8(255),
  64598 				7:  uint8(255),
  64599 				8:  uint8(255),
  64600 				9:  uint8(255),
  64601 				10: uint8(255),
  64602 			},
  64603 		},
  64604 		6: {
  64605 			0: {
  64606 				0:  uint8(255),
  64607 				1:  uint8(255),
  64608 				2:  uint8(255),
  64609 				3:  uint8(255),
  64610 				4:  uint8(255),
  64611 				5:  uint8(255),
  64612 				6:  uint8(255),
  64613 				7:  uint8(255),
  64614 				8:  uint8(255),
  64615 				9:  uint8(255),
  64616 				10: uint8(255),
  64617 			},
  64618 			1: {
  64619 				0:  uint8(255),
  64620 				1:  uint8(255),
  64621 				2:  uint8(255),
  64622 				3:  uint8(255),
  64623 				4:  uint8(255),
  64624 				5:  uint8(255),
  64625 				6:  uint8(255),
  64626 				7:  uint8(255),
  64627 				8:  uint8(255),
  64628 				9:  uint8(255),
  64629 				10: uint8(255),
  64630 			},
  64631 			2: {
  64632 				0:  uint8(255),
  64633 				1:  uint8(255),
  64634 				2:  uint8(255),
  64635 				3:  uint8(255),
  64636 				4:  uint8(255),
  64637 				5:  uint8(255),
  64638 				6:  uint8(255),
  64639 				7:  uint8(255),
  64640 				8:  uint8(255),
  64641 				9:  uint8(255),
  64642 				10: uint8(255),
  64643 			},
  64644 		},
  64645 		7: {
  64646 			0: {
  64647 				0:  uint8(255),
  64648 				1:  uint8(255),
  64649 				2:  uint8(255),
  64650 				3:  uint8(255),
  64651 				4:  uint8(255),
  64652 				5:  uint8(255),
  64653 				6:  uint8(255),
  64654 				7:  uint8(255),
  64655 				8:  uint8(255),
  64656 				9:  uint8(255),
  64657 				10: uint8(255),
  64658 			},
  64659 			1: {
  64660 				0:  uint8(255),
  64661 				1:  uint8(255),
  64662 				2:  uint8(255),
  64663 				3:  uint8(255),
  64664 				4:  uint8(255),
  64665 				5:  uint8(255),
  64666 				6:  uint8(255),
  64667 				7:  uint8(255),
  64668 				8:  uint8(255),
  64669 				9:  uint8(255),
  64670 				10: uint8(255),
  64671 			},
  64672 			2: {
  64673 				0:  uint8(255),
  64674 				1:  uint8(255),
  64675 				2:  uint8(255),
  64676 				3:  uint8(255),
  64677 				4:  uint8(255),
  64678 				5:  uint8(255),
  64679 				6:  uint8(255),
  64680 				7:  uint8(255),
  64681 				8:  uint8(255),
  64682 				9:  uint8(255),
  64683 				10: uint8(255),
  64684 			},
  64685 		},
  64686 	},
  64687 	3: {
  64688 		0: {
  64689 			0: {
  64690 				0:  uint8(248),
  64691 				1:  uint8(255),
  64692 				2:  uint8(255),
  64693 				3:  uint8(255),
  64694 				4:  uint8(255),
  64695 				5:  uint8(255),
  64696 				6:  uint8(255),
  64697 				7:  uint8(255),
  64698 				8:  uint8(255),
  64699 				9:  uint8(255),
  64700 				10: uint8(255),
  64701 			},
  64702 			1: {
  64703 				0:  uint8(250),
  64704 				1:  uint8(254),
  64705 				2:  uint8(252),
  64706 				3:  uint8(254),
  64707 				4:  uint8(255),
  64708 				5:  uint8(255),
  64709 				6:  uint8(255),
  64710 				7:  uint8(255),
  64711 				8:  uint8(255),
  64712 				9:  uint8(255),
  64713 				10: uint8(255),
  64714 			},
  64715 			2: {
  64716 				0:  uint8(248),
  64717 				1:  uint8(254),
  64718 				2:  uint8(249),
  64719 				3:  uint8(253),
  64720 				4:  uint8(255),
  64721 				5:  uint8(255),
  64722 				6:  uint8(255),
  64723 				7:  uint8(255),
  64724 				8:  uint8(255),
  64725 				9:  uint8(255),
  64726 				10: uint8(255),
  64727 			},
  64728 		},
  64729 		1: {
  64730 			0: {
  64731 				0:  uint8(255),
  64732 				1:  uint8(253),
  64733 				2:  uint8(253),
  64734 				3:  uint8(255),
  64735 				4:  uint8(255),
  64736 				5:  uint8(255),
  64737 				6:  uint8(255),
  64738 				7:  uint8(255),
  64739 				8:  uint8(255),
  64740 				9:  uint8(255),
  64741 				10: uint8(255),
  64742 			},
  64743 			1: {
  64744 				0:  uint8(246),
  64745 				1:  uint8(253),
  64746 				2:  uint8(253),
  64747 				3:  uint8(255),
  64748 				4:  uint8(255),
  64749 				5:  uint8(255),
  64750 				6:  uint8(255),
  64751 				7:  uint8(255),
  64752 				8:  uint8(255),
  64753 				9:  uint8(255),
  64754 				10: uint8(255),
  64755 			},
  64756 			2: {
  64757 				0:  uint8(252),
  64758 				1:  uint8(254),
  64759 				2:  uint8(251),
  64760 				3:  uint8(254),
  64761 				4:  uint8(254),
  64762 				5:  uint8(255),
  64763 				6:  uint8(255),
  64764 				7:  uint8(255),
  64765 				8:  uint8(255),
  64766 				9:  uint8(255),
  64767 				10: uint8(255),
  64768 			},
  64769 		},
  64770 		2: {
  64771 			0: {
  64772 				0:  uint8(255),
  64773 				1:  uint8(254),
  64774 				2:  uint8(252),
  64775 				3:  uint8(255),
  64776 				4:  uint8(255),
  64777 				5:  uint8(255),
  64778 				6:  uint8(255),
  64779 				7:  uint8(255),
  64780 				8:  uint8(255),
  64781 				9:  uint8(255),
  64782 				10: uint8(255),
  64783 			},
  64784 			1: {
  64785 				0:  uint8(248),
  64786 				1:  uint8(254),
  64787 				2:  uint8(253),
  64788 				3:  uint8(255),
  64789 				4:  uint8(255),
  64790 				5:  uint8(255),
  64791 				6:  uint8(255),
  64792 				7:  uint8(255),
  64793 				8:  uint8(255),
  64794 				9:  uint8(255),
  64795 				10: uint8(255),
  64796 			},
  64797 			2: {
  64798 				0:  uint8(253),
  64799 				1:  uint8(255),
  64800 				2:  uint8(254),
  64801 				3:  uint8(254),
  64802 				4:  uint8(255),
  64803 				5:  uint8(255),
  64804 				6:  uint8(255),
  64805 				7:  uint8(255),
  64806 				8:  uint8(255),
  64807 				9:  uint8(255),
  64808 				10: uint8(255),
  64809 			},
  64810 		},
  64811 		3: {
  64812 			0: {
  64813 				0:  uint8(255),
  64814 				1:  uint8(251),
  64815 				2:  uint8(254),
  64816 				3:  uint8(255),
  64817 				4:  uint8(255),
  64818 				5:  uint8(255),
  64819 				6:  uint8(255),
  64820 				7:  uint8(255),
  64821 				8:  uint8(255),
  64822 				9:  uint8(255),
  64823 				10: uint8(255),
  64824 			},
  64825 			1: {
  64826 				0:  uint8(245),
  64827 				1:  uint8(251),
  64828 				2:  uint8(254),
  64829 				3:  uint8(255),
  64830 				4:  uint8(255),
  64831 				5:  uint8(255),
  64832 				6:  uint8(255),
  64833 				7:  uint8(255),
  64834 				8:  uint8(255),
  64835 				9:  uint8(255),
  64836 				10: uint8(255),
  64837 			},
  64838 			2: {
  64839 				0:  uint8(253),
  64840 				1:  uint8(253),
  64841 				2:  uint8(254),
  64842 				3:  uint8(255),
  64843 				4:  uint8(255),
  64844 				5:  uint8(255),
  64845 				6:  uint8(255),
  64846 				7:  uint8(255),
  64847 				8:  uint8(255),
  64848 				9:  uint8(255),
  64849 				10: uint8(255),
  64850 			},
  64851 		},
  64852 		4: {
  64853 			0: {
  64854 				0:  uint8(255),
  64855 				1:  uint8(251),
  64856 				2:  uint8(253),
  64857 				3:  uint8(255),
  64858 				4:  uint8(255),
  64859 				5:  uint8(255),
  64860 				6:  uint8(255),
  64861 				7:  uint8(255),
  64862 				8:  uint8(255),
  64863 				9:  uint8(255),
  64864 				10: uint8(255),
  64865 			},
  64866 			1: {
  64867 				0:  uint8(252),
  64868 				1:  uint8(253),
  64869 				2:  uint8(254),
  64870 				3:  uint8(255),
  64871 				4:  uint8(255),
  64872 				5:  uint8(255),
  64873 				6:  uint8(255),
  64874 				7:  uint8(255),
  64875 				8:  uint8(255),
  64876 				9:  uint8(255),
  64877 				10: uint8(255),
  64878 			},
  64879 			2: {
  64880 				0:  uint8(255),
  64881 				1:  uint8(254),
  64882 				2:  uint8(255),
  64883 				3:  uint8(255),
  64884 				4:  uint8(255),
  64885 				5:  uint8(255),
  64886 				6:  uint8(255),
  64887 				7:  uint8(255),
  64888 				8:  uint8(255),
  64889 				9:  uint8(255),
  64890 				10: uint8(255),
  64891 			},
  64892 		},
  64893 		5: {
  64894 			0: {
  64895 				0:  uint8(255),
  64896 				1:  uint8(252),
  64897 				2:  uint8(255),
  64898 				3:  uint8(255),
  64899 				4:  uint8(255),
  64900 				5:  uint8(255),
  64901 				6:  uint8(255),
  64902 				7:  uint8(255),
  64903 				8:  uint8(255),
  64904 				9:  uint8(255),
  64905 				10: uint8(255),
  64906 			},
  64907 			1: {
  64908 				0:  uint8(249),
  64909 				1:  uint8(255),
  64910 				2:  uint8(254),
  64911 				3:  uint8(255),
  64912 				4:  uint8(255),
  64913 				5:  uint8(255),
  64914 				6:  uint8(255),
  64915 				7:  uint8(255),
  64916 				8:  uint8(255),
  64917 				9:  uint8(255),
  64918 				10: uint8(255),
  64919 			},
  64920 			2: {
  64921 				0:  uint8(255),
  64922 				1:  uint8(255),
  64923 				2:  uint8(254),
  64924 				3:  uint8(255),
  64925 				4:  uint8(255),
  64926 				5:  uint8(255),
  64927 				6:  uint8(255),
  64928 				7:  uint8(255),
  64929 				8:  uint8(255),
  64930 				9:  uint8(255),
  64931 				10: uint8(255),
  64932 			},
  64933 		},
  64934 		6: {
  64935 			0: {
  64936 				0:  uint8(255),
  64937 				1:  uint8(255),
  64938 				2:  uint8(253),
  64939 				3:  uint8(255),
  64940 				4:  uint8(255),
  64941 				5:  uint8(255),
  64942 				6:  uint8(255),
  64943 				7:  uint8(255),
  64944 				8:  uint8(255),
  64945 				9:  uint8(255),
  64946 				10: uint8(255),
  64947 			},
  64948 			1: {
  64949 				0:  uint8(250),
  64950 				1:  uint8(255),
  64951 				2:  uint8(255),
  64952 				3:  uint8(255),
  64953 				4:  uint8(255),
  64954 				5:  uint8(255),
  64955 				6:  uint8(255),
  64956 				7:  uint8(255),
  64957 				8:  uint8(255),
  64958 				9:  uint8(255),
  64959 				10: uint8(255),
  64960 			},
  64961 			2: {
  64962 				0:  uint8(255),
  64963 				1:  uint8(255),
  64964 				2:  uint8(255),
  64965 				3:  uint8(255),
  64966 				4:  uint8(255),
  64967 				5:  uint8(255),
  64968 				6:  uint8(255),
  64969 				7:  uint8(255),
  64970 				8:  uint8(255),
  64971 				9:  uint8(255),
  64972 				10: uint8(255),
  64973 			},
  64974 		},
  64975 		7: {
  64976 			0: {
  64977 				0:  uint8(255),
  64978 				1:  uint8(255),
  64979 				2:  uint8(255),
  64980 				3:  uint8(255),
  64981 				4:  uint8(255),
  64982 				5:  uint8(255),
  64983 				6:  uint8(255),
  64984 				7:  uint8(255),
  64985 				8:  uint8(255),
  64986 				9:  uint8(255),
  64987 				10: uint8(255),
  64988 			},
  64989 			1: {
  64990 				0:  uint8(254),
  64991 				1:  uint8(255),
  64992 				2:  uint8(255),
  64993 				3:  uint8(255),
  64994 				4:  uint8(255),
  64995 				5:  uint8(255),
  64996 				6:  uint8(255),
  64997 				7:  uint8(255),
  64998 				8:  uint8(255),
  64999 				9:  uint8(255),
  65000 				10: uint8(255),
  65001 			},
  65002 			2: {
  65003 				0:  uint8(255),
  65004 				1:  uint8(255),
  65005 				2:  uint8(255),
  65006 				3:  uint8(255),
  65007 				4:  uint8(255),
  65008 				5:  uint8(255),
  65009 				6:  uint8(255),
  65010 				7:  uint8(255),
  65011 				8:  uint8(255),
  65012 				9:  uint8(255),
  65013 				10: uint8(255),
  65014 			},
  65015 		},
  65016 	},
  65017 }
  65018 
  65019 //------------------------------------------------------------------------------
  65020 // Initialization
  65021 
  65022 // C documentation
  65023 //
  65024 //	// Speed-critical function pointers. We have to initialize them to the default
  65025 //	// implementations within VP8EncDspInit().
  65026 var VP8CollectHistogram VP8CHisto
  65027 
  65028 var VP8Copy16x8 VP8BlockCopy
  65029 
  65030 var VP8Copy4x4 VP8BlockCopy
  65031 
  65032 var VP8DitherCombine8x8 uintptr
  65033 
  65034 //------------------------------------------------------------------------------
  65035 // Compute susceptibility based on DCT-coeff histograms:
  65036 // the higher, the "easier" the macroblock is to compress.
  65037 
  65038 var VP8DspScan = [24]int32{
  65039 	1:  libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65040 	2:  libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65041 	3:  libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65042 	4:  libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65043 	5:  libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65044 	6:  libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65045 	7:  libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65046 	8:  libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65047 	9:  libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65048 	10: libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65049 	11: libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65050 	12: libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65051 	13: libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65052 	14: libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65053 	15: libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65054 	17: libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65055 	18: libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65056 	19: libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65057 	20: libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65058 	21: libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65059 	22: libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65060 	23: libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65061 }
  65062 
  65063 //------------------------------------------------------------------------------
  65064 // Tables for level coding
  65065 
  65066 var VP8EncBands = [17]uint8_t{
  65067 	1:  uint8(1),
  65068 	2:  uint8(2),
  65069 	3:  uint8(3),
  65070 	4:  uint8(6),
  65071 	5:  uint8(4),
  65072 	6:  uint8(5),
  65073 	7:  uint8(6),
  65074 	8:  uint8(6),
  65075 	9:  uint8(6),
  65076 	10: uint8(6),
  65077 	11: uint8(6),
  65078 	12: uint8(6),
  65079 	13: uint8(6),
  65080 	14: uint8(6),
  65081 	15: uint8(7),
  65082 }
  65083 
  65084 var VP8EncPredChroma8 VP8IntraPreds
  65085 
  65086 var VP8EncPredLuma16 VP8IntraPreds
  65087 
  65088 var VP8EncPredLuma4 VP8Intra4Preds
  65089 
  65090 var VP8EncQuantize2Blocks VP8Quantize2Blocks
  65091 
  65092 var VP8EncQuantizeBlock VP8QuantizeBlock
  65093 
  65094 var VP8EncQuantizeBlockWHT VP8QuantizeBlockWHT
  65095 
  65096 //------------------------------------------------------------------------------
  65097 
  65098 // Copyright 2011 Google Inc. All Rights Reserved.
  65099 //
  65100 // Use of this source code is governed by a BSD-style license
  65101 // that can be found in the COPYING file in the root of the source
  65102 // tree. An additional intellectual property rights grant can be found
  65103 // in the file PATENTS. All contributing project authors may
  65104 // be found in the AUTHORS file in the root of the source tree.
  65105 // -----------------------------------------------------------------------------
  65106 //
  65107 //   WebP encoder: internal header.
  65108 //
  65109 // Author: Skal (pascal.massimino@gmail.com)
  65110 
  65111 //------------------------------------------------------------------------------
  65112 // Boolean-cost cost table
  65113 
  65114 var VP8EntropyCost = [256]uint16_t{
  65115 	0:   uint16(1792),
  65116 	1:   uint16(1792),
  65117 	2:   uint16(1792),
  65118 	3:   uint16(1536),
  65119 	4:   uint16(1536),
  65120 	5:   uint16(1408),
  65121 	6:   uint16(1366),
  65122 	7:   uint16(1280),
  65123 	8:   uint16(1280),
  65124 	9:   uint16(1216),
  65125 	10:  uint16(1178),
  65126 	11:  uint16(1152),
  65127 	12:  uint16(1110),
  65128 	13:  uint16(1076),
  65129 	14:  uint16(1061),
  65130 	15:  uint16(1024),
  65131 	16:  uint16(1024),
  65132 	17:  uint16(992),
  65133 	18:  uint16(968),
  65134 	19:  uint16(951),
  65135 	20:  uint16(939),
  65136 	21:  uint16(911),
  65137 	22:  uint16(896),
  65138 	23:  uint16(878),
  65139 	24:  uint16(871),
  65140 	25:  uint16(854),
  65141 	26:  uint16(838),
  65142 	27:  uint16(820),
  65143 	28:  uint16(811),
  65144 	29:  uint16(794),
  65145 	30:  uint16(786),
  65146 	31:  uint16(768),
  65147 	32:  uint16(768),
  65148 	33:  uint16(752),
  65149 	34:  uint16(740),
  65150 	35:  uint16(732),
  65151 	36:  uint16(720),
  65152 	37:  uint16(709),
  65153 	38:  uint16(704),
  65154 	39:  uint16(690),
  65155 	40:  uint16(683),
  65156 	41:  uint16(672),
  65157 	42:  uint16(666),
  65158 	43:  uint16(655),
  65159 	44:  uint16(647),
  65160 	45:  uint16(640),
  65161 	46:  uint16(631),
  65162 	47:  uint16(622),
  65163 	48:  uint16(615),
  65164 	49:  uint16(607),
  65165 	50:  uint16(598),
  65166 	51:  uint16(592),
  65167 	52:  uint16(586),
  65168 	53:  uint16(576),
  65169 	54:  uint16(572),
  65170 	55:  uint16(564),
  65171 	56:  uint16(559),
  65172 	57:  uint16(555),
  65173 	58:  uint16(547),
  65174 	59:  uint16(541),
  65175 	60:  uint16(534),
  65176 	61:  uint16(528),
  65177 	62:  uint16(522),
  65178 	63:  uint16(512),
  65179 	64:  uint16(512),
  65180 	65:  uint16(504),
  65181 	66:  uint16(500),
  65182 	67:  uint16(494),
  65183 	68:  uint16(488),
  65184 	69:  uint16(483),
  65185 	70:  uint16(477),
  65186 	71:  uint16(473),
  65187 	72:  uint16(467),
  65188 	73:  uint16(461),
  65189 	74:  uint16(458),
  65190 	75:  uint16(452),
  65191 	76:  uint16(448),
  65192 	77:  uint16(443),
  65193 	78:  uint16(438),
  65194 	79:  uint16(434),
  65195 	80:  uint16(427),
  65196 	81:  uint16(424),
  65197 	82:  uint16(419),
  65198 	83:  uint16(415),
  65199 	84:  uint16(410),
  65200 	85:  uint16(406),
  65201 	86:  uint16(403),
  65202 	87:  uint16(399),
  65203 	88:  uint16(394),
  65204 	89:  uint16(390),
  65205 	90:  uint16(384),
  65206 	91:  uint16(384),
  65207 	92:  uint16(377),
  65208 	93:  uint16(374),
  65209 	94:  uint16(370),
  65210 	95:  uint16(366),
  65211 	96:  uint16(362),
  65212 	97:  uint16(359),
  65213 	98:  uint16(355),
  65214 	99:  uint16(351),
  65215 	100: uint16(347),
  65216 	101: uint16(342),
  65217 	102: uint16(342),
  65218 	103: uint16(336),
  65219 	104: uint16(333),
  65220 	105: uint16(330),
  65221 	106: uint16(326),
  65222 	107: uint16(323),
  65223 	108: uint16(320),
  65224 	109: uint16(316),
  65225 	110: uint16(312),
  65226 	111: uint16(308),
  65227 	112: uint16(305),
  65228 	113: uint16(302),
  65229 	114: uint16(299),
  65230 	115: uint16(296),
  65231 	116: uint16(293),
  65232 	117: uint16(288),
  65233 	118: uint16(287),
  65234 	119: uint16(283),
  65235 	120: uint16(280),
  65236 	121: uint16(277),
  65237 	122: uint16(274),
  65238 	123: uint16(272),
  65239 	124: uint16(268),
  65240 	125: uint16(266),
  65241 	126: uint16(262),
  65242 	127: uint16(256),
  65243 	128: uint16(256),
  65244 	129: uint16(256),
  65245 	130: uint16(251),
  65246 	131: uint16(248),
  65247 	132: uint16(245),
  65248 	133: uint16(242),
  65249 	134: uint16(240),
  65250 	135: uint16(237),
  65251 	136: uint16(234),
  65252 	137: uint16(232),
  65253 	138: uint16(228),
  65254 	139: uint16(226),
  65255 	140: uint16(223),
  65256 	141: uint16(221),
  65257 	142: uint16(218),
  65258 	143: uint16(216),
  65259 	144: uint16(214),
  65260 	145: uint16(211),
  65261 	146: uint16(208),
  65262 	147: uint16(205),
  65263 	148: uint16(203),
  65264 	149: uint16(201),
  65265 	150: uint16(198),
  65266 	151: uint16(196),
  65267 	152: uint16(192),
  65268 	153: uint16(191),
  65269 	154: uint16(188),
  65270 	155: uint16(187),
  65271 	156: uint16(183),
  65272 	157: uint16(181),
  65273 	158: uint16(179),
  65274 	159: uint16(176),
  65275 	160: uint16(175),
  65276 	161: uint16(171),
  65277 	162: uint16(171),
  65278 	163: uint16(168),
  65279 	164: uint16(165),
  65280 	165: uint16(163),
  65281 	166: uint16(160),
  65282 	167: uint16(159),
  65283 	168: uint16(156),
  65284 	169: uint16(154),
  65285 	170: uint16(152),
  65286 	171: uint16(150),
  65287 	172: uint16(148),
  65288 	173: uint16(146),
  65289 	174: uint16(144),
  65290 	175: uint16(142),
  65291 	176: uint16(139),
  65292 	177: uint16(138),
  65293 	178: uint16(135),
  65294 	179: uint16(133),
  65295 	180: uint16(131),
  65296 	181: uint16(128),
  65297 	182: uint16(128),
  65298 	183: uint16(125),
  65299 	184: uint16(123),
  65300 	185: uint16(121),
  65301 	186: uint16(119),
  65302 	187: uint16(117),
  65303 	188: uint16(115),
  65304 	189: uint16(113),
  65305 	190: uint16(111),
  65306 	191: uint16(110),
  65307 	192: uint16(107),
  65308 	193: uint16(105),
  65309 	194: uint16(103),
  65310 	195: uint16(102),
  65311 	196: uint16(100),
  65312 	197: uint16(98),
  65313 	198: uint16(96),
  65314 	199: uint16(94),
  65315 	200: uint16(92),
  65316 	201: uint16(91),
  65317 	202: uint16(89),
  65318 	203: uint16(86),
  65319 	204: uint16(86),
  65320 	205: uint16(83),
  65321 	206: uint16(82),
  65322 	207: uint16(80),
  65323 	208: uint16(77),
  65324 	209: uint16(76),
  65325 	210: uint16(74),
  65326 	211: uint16(73),
  65327 	212: uint16(71),
  65328 	213: uint16(69),
  65329 	214: uint16(67),
  65330 	215: uint16(66),
  65331 	216: uint16(64),
  65332 	217: uint16(63),
  65333 	218: uint16(61),
  65334 	219: uint16(59),
  65335 	220: uint16(57),
  65336 	221: uint16(55),
  65337 	222: uint16(54),
  65338 	223: uint16(52),
  65339 	224: uint16(51),
  65340 	225: uint16(49),
  65341 	226: uint16(47),
  65342 	227: uint16(46),
  65343 	228: uint16(44),
  65344 	229: uint16(43),
  65345 	230: uint16(41),
  65346 	231: uint16(40),
  65347 	232: uint16(38),
  65348 	233: uint16(36),
  65349 	234: uint16(35),
  65350 	235: uint16(33),
  65351 	236: uint16(32),
  65352 	237: uint16(30),
  65353 	238: uint16(29),
  65354 	239: uint16(27),
  65355 	240: uint16(25),
  65356 	241: uint16(24),
  65357 	242: uint16(22),
  65358 	243: uint16(21),
  65359 	244: uint16(19),
  65360 	245: uint16(18),
  65361 	246: uint16(16),
  65362 	247: uint16(15),
  65363 	248: uint16(13),
  65364 	249: uint16(12),
  65365 	250: uint16(10),
  65366 	251: uint16(9),
  65367 	252: uint16(7),
  65368 	253: uint16(6),
  65369 	254: uint16(4),
  65370 	255: uint16(3),
  65371 }
  65372 
  65373 var VP8FTransform VP8Fdct
  65374 
  65375 var VP8FTransform2 VP8Fdct
  65376 
  65377 var VP8FTransformWHT VP8WHT
  65378 
  65379 // C documentation
  65380 //
  65381 //	// note: these values include the fixed VP8BitCost(1, 145) mode selection cost.
  65382 var VP8FixedCostsI16 = [4]uint16_t{
  65383 	0: uint16(663),
  65384 	1: uint16(919),
  65385 	2: uint16(872),
  65386 	3: uint16(919),
  65387 }
  65388 
  65389 var VP8FixedCostsI4 = [10][10][10]uint16_t{
  65390 	0: {
  65391 		0: {
  65392 			0: uint16(40),
  65393 			1: uint16(1151),
  65394 			2: uint16(1723),
  65395 			3: uint16(1874),
  65396 			4: uint16(2103),
  65397 			5: uint16(2019),
  65398 			6: uint16(1628),
  65399 			7: uint16(1777),
  65400 			8: uint16(2226),
  65401 			9: uint16(2137),
  65402 		},
  65403 		1: {
  65404 			0: uint16(192),
  65405 			1: uint16(469),
  65406 			2: uint16(1296),
  65407 			3: uint16(1308),
  65408 			4: uint16(1849),
  65409 			5: uint16(1794),
  65410 			6: uint16(1781),
  65411 			7: uint16(1703),
  65412 			8: uint16(1713),
  65413 			9: uint16(1522),
  65414 		},
  65415 		2: {
  65416 			0: uint16(142),
  65417 			1: uint16(910),
  65418 			2: uint16(762),
  65419 			3: uint16(1684),
  65420 			4: uint16(1849),
  65421 			5: uint16(1576),
  65422 			6: uint16(1460),
  65423 			7: uint16(1305),
  65424 			8: uint16(1801),
  65425 			9: uint16(1657),
  65426 		},
  65427 		3: {
  65428 			0: uint16(559),
  65429 			1: uint16(641),
  65430 			2: uint16(1370),
  65431 			3: uint16(421),
  65432 			4: uint16(1182),
  65433 			5: uint16(1569),
  65434 			6: uint16(1612),
  65435 			7: uint16(1725),
  65436 			8: uint16(863),
  65437 			9: uint16(1007),
  65438 		},
  65439 		4: {
  65440 			0: uint16(299),
  65441 			1: uint16(1059),
  65442 			2: uint16(1256),
  65443 			3: uint16(1108),
  65444 			4: uint16(636),
  65445 			5: uint16(1068),
  65446 			6: uint16(1581),
  65447 			7: uint16(1883),
  65448 			8: uint16(869),
  65449 			9: uint16(1142),
  65450 		},
  65451 		5: {
  65452 			0: uint16(277),
  65453 			1: uint16(1111),
  65454 			2: uint16(707),
  65455 			3: uint16(1362),
  65456 			4: uint16(1089),
  65457 			5: uint16(672),
  65458 			6: uint16(1603),
  65459 			7: uint16(1541),
  65460 			8: uint16(1545),
  65461 			9: uint16(1291),
  65462 		},
  65463 		6: {
  65464 			0: uint16(214),
  65465 			1: uint16(781),
  65466 			2: uint16(1609),
  65467 			3: uint16(1303),
  65468 			4: uint16(1632),
  65469 			5: uint16(2229),
  65470 			6: uint16(726),
  65471 			7: uint16(1560),
  65472 			8: uint16(1713),
  65473 			9: uint16(918),
  65474 		},
  65475 		7: {
  65476 			0: uint16(152),
  65477 			1: uint16(1037),
  65478 			2: uint16(1046),
  65479 			3: uint16(1759),
  65480 			4: uint16(1983),
  65481 			5: uint16(2174),
  65482 			6: uint16(1358),
  65483 			7: uint16(742),
  65484 			8: uint16(1740),
  65485 			9: uint16(1390),
  65486 		},
  65487 		8: {
  65488 			0: uint16(512),
  65489 			1: uint16(1046),
  65490 			2: uint16(1420),
  65491 			3: uint16(753),
  65492 			4: uint16(752),
  65493 			5: uint16(1297),
  65494 			6: uint16(1486),
  65495 			7: uint16(1613),
  65496 			8: uint16(460),
  65497 			9: uint16(1207),
  65498 		},
  65499 		9: {
  65500 			0: uint16(424),
  65501 			1: uint16(827),
  65502 			2: uint16(1362),
  65503 			3: uint16(719),
  65504 			4: uint16(1462),
  65505 			5: uint16(1202),
  65506 			6: uint16(1199),
  65507 			7: uint16(1476),
  65508 			8: uint16(1199),
  65509 			9: uint16(538),
  65510 		},
  65511 	},
  65512 	1: {
  65513 		0: {
  65514 			0: uint16(240),
  65515 			1: uint16(402),
  65516 			2: uint16(1134),
  65517 			3: uint16(1491),
  65518 			4: uint16(1659),
  65519 			5: uint16(1505),
  65520 			6: uint16(1517),
  65521 			7: uint16(1555),
  65522 			8: uint16(1979),
  65523 			9: uint16(2099),
  65524 		},
  65525 		1: {
  65526 			0: uint16(467),
  65527 			1: uint16(242),
  65528 			2: uint16(960),
  65529 			3: uint16(1232),
  65530 			4: uint16(1714),
  65531 			5: uint16(1620),
  65532 			6: uint16(1834),
  65533 			7: uint16(1570),
  65534 			8: uint16(1676),
  65535 			9: uint16(1391),
  65536 		},
  65537 		2: {
  65538 			0: uint16(500),
  65539 			1: uint16(455),
  65540 			2: uint16(463),
  65541 			3: uint16(1507),
  65542 			4: uint16(1699),
  65543 			5: uint16(1282),
  65544 			6: uint16(1564),
  65545 			7: uint16(982),
  65546 			8: uint16(2114),
  65547 			9: uint16(2114),
  65548 		},
  65549 		3: {
  65550 			0: uint16(672),
  65551 			1: uint16(643),
  65552 			2: uint16(1372),
  65553 			3: uint16(331),
  65554 			4: uint16(1589),
  65555 			5: uint16(1667),
  65556 			6: uint16(1453),
  65557 			7: uint16(1938),
  65558 			8: uint16(996),
  65559 			9: uint16(876),
  65560 		},
  65561 		4: {
  65562 			0: uint16(458),
  65563 			1: uint16(783),
  65564 			2: uint16(1037),
  65565 			3: uint16(911),
  65566 			4: uint16(738),
  65567 			5: uint16(968),
  65568 			6: uint16(1165),
  65569 			7: uint16(1518),
  65570 			8: uint16(859),
  65571 			9: uint16(1033),
  65572 		},
  65573 		5: {
  65574 			0: uint16(504),
  65575 			1: uint16(815),
  65576 			2: uint16(504),
  65577 			3: uint16(1139),
  65578 			4: uint16(1219),
  65579 			5: uint16(719),
  65580 			6: uint16(1506),
  65581 			7: uint16(1085),
  65582 			8: uint16(1268),
  65583 			9: uint16(1268),
  65584 		},
  65585 		6: {
  65586 			0: uint16(333),
  65587 			1: uint16(630),
  65588 			2: uint16(1445),
  65589 			3: uint16(1239),
  65590 			4: uint16(1883),
  65591 			5: uint16(3672),
  65592 			6: uint16(799),
  65593 			7: uint16(1548),
  65594 			8: uint16(1865),
  65595 			9: uint16(598),
  65596 		},
  65597 		7: {
  65598 			0: uint16(399),
  65599 			1: uint16(644),
  65600 			2: uint16(746),
  65601 			3: uint16(1342),
  65602 			4: uint16(1856),
  65603 			5: uint16(1350),
  65604 			6: uint16(1493),
  65605 			7: uint16(613),
  65606 			8: uint16(1855),
  65607 			9: uint16(1015),
  65608 		},
  65609 		8: {
  65610 			0: uint16(622),
  65611 			1: uint16(749),
  65612 			2: uint16(1205),
  65613 			3: uint16(608),
  65614 			4: uint16(1066),
  65615 			5: uint16(1408),
  65616 			6: uint16(1290),
  65617 			7: uint16(1406),
  65618 			8: uint16(546),
  65619 			9: uint16(971),
  65620 		},
  65621 		9: {
  65622 			0: uint16(500),
  65623 			1: uint16(753),
  65624 			2: uint16(1041),
  65625 			3: uint16(668),
  65626 			4: uint16(1230),
  65627 			5: uint16(1617),
  65628 			6: uint16(1297),
  65629 			7: uint16(1425),
  65630 			8: uint16(1383),
  65631 			9: uint16(523),
  65632 		},
  65633 	},
  65634 	2: {
  65635 		0: {
  65636 			0: uint16(394),
  65637 			1: uint16(553),
  65638 			2: uint16(523),
  65639 			3: uint16(1502),
  65640 			4: uint16(1536),
  65641 			5: uint16(981),
  65642 			6: uint16(1608),
  65643 			7: uint16(1142),
  65644 			8: uint16(1666),
  65645 			9: uint16(2181),
  65646 		},
  65647 		1: {
  65648 			0: uint16(655),
  65649 			1: uint16(430),
  65650 			2: uint16(375),
  65651 			3: uint16(1411),
  65652 			4: uint16(1861),
  65653 			5: uint16(1220),
  65654 			6: uint16(1677),
  65655 			7: uint16(1135),
  65656 			8: uint16(1978),
  65657 			9: uint16(1553),
  65658 		},
  65659 		2: {
  65660 			0: uint16(690),
  65661 			1: uint16(640),
  65662 			2: uint16(245),
  65663 			3: uint16(1954),
  65664 			4: uint16(2070),
  65665 			5: uint16(1194),
  65666 			6: uint16(1528),
  65667 			7: uint16(982),
  65668 			8: uint16(1972),
  65669 			9: uint16(2232),
  65670 		},
  65671 		3: {
  65672 			0: uint16(559),
  65673 			1: uint16(834),
  65674 			2: uint16(741),
  65675 			3: uint16(867),
  65676 			4: uint16(1131),
  65677 			5: uint16(980),
  65678 			6: uint16(1225),
  65679 			7: uint16(852),
  65680 			8: uint16(1092),
  65681 			9: uint16(784),
  65682 		},
  65683 		4: {
  65684 			0: uint16(690),
  65685 			1: uint16(875),
  65686 			2: uint16(516),
  65687 			3: uint16(959),
  65688 			4: uint16(673),
  65689 			5: uint16(894),
  65690 			6: uint16(1056),
  65691 			7: uint16(1190),
  65692 			8: uint16(1528),
  65693 			9: uint16(1126),
  65694 		},
  65695 		5: {
  65696 			0: uint16(740),
  65697 			1: uint16(951),
  65698 			2: uint16(384),
  65699 			3: uint16(1277),
  65700 			4: uint16(1177),
  65701 			5: uint16(492),
  65702 			6: uint16(1579),
  65703 			7: uint16(1155),
  65704 			8: uint16(1846),
  65705 			9: uint16(1513),
  65706 		},
  65707 		6: {
  65708 			0: uint16(323),
  65709 			1: uint16(775),
  65710 			2: uint16(1062),
  65711 			3: uint16(1776),
  65712 			4: uint16(3062),
  65713 			5: uint16(1274),
  65714 			6: uint16(813),
  65715 			7: uint16(1188),
  65716 			8: uint16(1372),
  65717 			9: uint16(655),
  65718 		},
  65719 		7: {
  65720 			0: uint16(488),
  65721 			1: uint16(971),
  65722 			2: uint16(484),
  65723 			3: uint16(1767),
  65724 			4: uint16(1515),
  65725 			5: uint16(1775),
  65726 			6: uint16(1115),
  65727 			7: uint16(503),
  65728 			8: uint16(1539),
  65729 			9: uint16(1461),
  65730 		},
  65731 		8: {
  65732 			0: uint16(740),
  65733 			1: uint16(1006),
  65734 			2: uint16(998),
  65735 			3: uint16(709),
  65736 			4: uint16(851),
  65737 			5: uint16(1230),
  65738 			6: uint16(1337),
  65739 			7: uint16(788),
  65740 			8: uint16(741),
  65741 			9: uint16(721),
  65742 		},
  65743 		9: {
  65744 			0: uint16(522),
  65745 			1: uint16(1073),
  65746 			2: uint16(573),
  65747 			3: uint16(1045),
  65748 			4: uint16(1346),
  65749 			5: uint16(887),
  65750 			6: uint16(1046),
  65751 			7: uint16(1146),
  65752 			8: uint16(1203),
  65753 			9: uint16(697),
  65754 		},
  65755 	},
  65756 	3: {
  65757 		0: {
  65758 			0: uint16(105),
  65759 			1: uint16(864),
  65760 			2: uint16(1442),
  65761 			3: uint16(1009),
  65762 			4: uint16(1934),
  65763 			5: uint16(1840),
  65764 			6: uint16(1519),
  65765 			7: uint16(1920),
  65766 			8: uint16(1673),
  65767 			9: uint16(1579),
  65768 		},
  65769 		1: {
  65770 			0: uint16(534),
  65771 			1: uint16(305),
  65772 			2: uint16(1193),
  65773 			3: uint16(683),
  65774 			4: uint16(1388),
  65775 			5: uint16(2164),
  65776 			6: uint16(1802),
  65777 			7: uint16(1894),
  65778 			8: uint16(1264),
  65779 			9: uint16(1170),
  65780 		},
  65781 		2: {
  65782 			0: uint16(305),
  65783 			1: uint16(518),
  65784 			2: uint16(877),
  65785 			3: uint16(1108),
  65786 			4: uint16(1426),
  65787 			5: uint16(3215),
  65788 			6: uint16(1425),
  65789 			7: uint16(1064),
  65790 			8: uint16(1320),
  65791 			9: uint16(1242),
  65792 		},
  65793 		3: {
  65794 			0: uint16(683),
  65795 			1: uint16(732),
  65796 			2: uint16(1927),
  65797 			3: uint16(257),
  65798 			4: uint16(1493),
  65799 			5: uint16(2048),
  65800 			6: uint16(1858),
  65801 			7: uint16(1552),
  65802 			8: uint16(1055),
  65803 			9: uint16(947),
  65804 		},
  65805 		4: {
  65806 			0: uint16(394),
  65807 			1: uint16(814),
  65808 			2: uint16(1024),
  65809 			3: uint16(660),
  65810 			4: uint16(959),
  65811 			5: uint16(1556),
  65812 			6: uint16(1282),
  65813 			7: uint16(1289),
  65814 			8: uint16(893),
  65815 			9: uint16(1047),
  65816 		},
  65817 		5: {
  65818 			0: uint16(528),
  65819 			1: uint16(615),
  65820 			2: uint16(996),
  65821 			3: uint16(940),
  65822 			4: uint16(1201),
  65823 			5: uint16(635),
  65824 			6: uint16(1094),
  65825 			7: uint16(2515),
  65826 			8: uint16(803),
  65827 			9: uint16(1358),
  65828 		},
  65829 		6: {
  65830 			0: uint16(347),
  65831 			1: uint16(614),
  65832 			2: uint16(1609),
  65833 			3: uint16(1187),
  65834 			4: uint16(3133),
  65835 			5: uint16(1345),
  65836 			6: uint16(1007),
  65837 			7: uint16(1339),
  65838 			8: uint16(1017),
  65839 			9: uint16(667),
  65840 		},
  65841 		7: {
  65842 			0: uint16(218),
  65843 			1: uint16(740),
  65844 			2: uint16(878),
  65845 			3: uint16(1605),
  65846 			4: uint16(3650),
  65847 			5: uint16(3650),
  65848 			6: uint16(1345),
  65849 			7: uint16(758),
  65850 			8: uint16(1357),
  65851 			9: uint16(1617),
  65852 		},
  65853 		8: {
  65854 			0: uint16(672),
  65855 			1: uint16(750),
  65856 			2: uint16(1541),
  65857 			3: uint16(558),
  65858 			4: uint16(1257),
  65859 			5: uint16(1599),
  65860 			6: uint16(1870),
  65861 			7: uint16(2135),
  65862 			8: uint16(402),
  65863 			9: uint16(1087),
  65864 		},
  65865 		9: {
  65866 			0: uint16(592),
  65867 			1: uint16(684),
  65868 			2: uint16(1161),
  65869 			3: uint16(430),
  65870 			4: uint16(1092),
  65871 			5: uint16(1497),
  65872 			6: uint16(1475),
  65873 			7: uint16(1489),
  65874 			8: uint16(1095),
  65875 			9: uint16(822),
  65876 		},
  65877 	},
  65878 	4: {
  65879 		0: {
  65880 			0: uint16(228),
  65881 			1: uint16(1056),
  65882 			2: uint16(1059),
  65883 			3: uint16(1368),
  65884 			4: uint16(752),
  65885 			5: uint16(982),
  65886 			6: uint16(1512),
  65887 			7: uint16(1518),
  65888 			8: uint16(987),
  65889 			9: uint16(1782),
  65890 		},
  65891 		1: {
  65892 			0: uint16(494),
  65893 			1: uint16(514),
  65894 			2: uint16(818),
  65895 			3: uint16(942),
  65896 			4: uint16(965),
  65897 			5: uint16(892),
  65898 			6: uint16(1610),
  65899 			7: uint16(1356),
  65900 			8: uint16(1048),
  65901 			9: uint16(1363),
  65902 		},
  65903 		2: {
  65904 			0: uint16(512),
  65905 			1: uint16(648),
  65906 			2: uint16(591),
  65907 			3: uint16(1042),
  65908 			4: uint16(761),
  65909 			5: uint16(991),
  65910 			6: uint16(1196),
  65911 			7: uint16(1454),
  65912 			8: uint16(1309),
  65913 			9: uint16(1463),
  65914 		},
  65915 		3: {
  65916 			0: uint16(683),
  65917 			1: uint16(749),
  65918 			2: uint16(1043),
  65919 			3: uint16(676),
  65920 			4: uint16(841),
  65921 			5: uint16(1396),
  65922 			6: uint16(1133),
  65923 			7: uint16(1138),
  65924 			8: uint16(654),
  65925 			9: uint16(939),
  65926 		},
  65927 		4: {
  65928 			0: uint16(622),
  65929 			1: uint16(1101),
  65930 			2: uint16(1126),
  65931 			3: uint16(994),
  65932 			4: uint16(361),
  65933 			5: uint16(1077),
  65934 			6: uint16(1203),
  65935 			7: uint16(1318),
  65936 			8: uint16(877),
  65937 			9: uint16(1219),
  65938 		},
  65939 		5: {
  65940 			0: uint16(631),
  65941 			1: uint16(1068),
  65942 			2: uint16(857),
  65943 			3: uint16(1650),
  65944 			4: uint16(651),
  65945 			5: uint16(477),
  65946 			6: uint16(1650),
  65947 			7: uint16(1419),
  65948 			8: uint16(828),
  65949 			9: uint16(1170),
  65950 		},
  65951 		6: {
  65952 			0: uint16(555),
  65953 			1: uint16(727),
  65954 			2: uint16(1068),
  65955 			3: uint16(1335),
  65956 			4: uint16(3127),
  65957 			5: uint16(1339),
  65958 			6: uint16(820),
  65959 			7: uint16(1331),
  65960 			8: uint16(1077),
  65961 			9: uint16(429),
  65962 		},
  65963 		7: {
  65964 			0: uint16(504),
  65965 			1: uint16(879),
  65966 			2: uint16(624),
  65967 			3: uint16(1398),
  65968 			4: uint16(889),
  65969 			5: uint16(889),
  65970 			6: uint16(1392),
  65971 			7: uint16(808),
  65972 			8: uint16(891),
  65973 			9: uint16(1406),
  65974 		},
  65975 		8: {
  65976 			0: uint16(683),
  65977 			1: uint16(1602),
  65978 			2: uint16(1289),
  65979 			3: uint16(977),
  65980 			4: uint16(578),
  65981 			5: uint16(983),
  65982 			6: uint16(1280),
  65983 			7: uint16(1708),
  65984 			8: uint16(406),
  65985 			9: uint16(1122),
  65986 		},
  65987 		9: {
  65988 			0: uint16(399),
  65989 			1: uint16(865),
  65990 			2: uint16(1433),
  65991 			3: uint16(1070),
  65992 			4: uint16(1072),
  65993 			5: uint16(764),
  65994 			6: uint16(968),
  65995 			7: uint16(1477),
  65996 			8: uint16(1223),
  65997 			9: uint16(678),
  65998 		},
  65999 	},
  66000 	5: {
  66001 		0: {
  66002 			0: uint16(333),
  66003 			1: uint16(760),
  66004 			2: uint16(935),
  66005 			3: uint16(1638),
  66006 			4: uint16(1010),
  66007 			5: uint16(529),
  66008 			6: uint16(1646),
  66009 			7: uint16(1410),
  66010 			8: uint16(1472),
  66011 			9: uint16(2219),
  66012 		},
  66013 		1: {
  66014 			0: uint16(512),
  66015 			1: uint16(494),
  66016 			2: uint16(750),
  66017 			3: uint16(1160),
  66018 			4: uint16(1215),
  66019 			5: uint16(610),
  66020 			6: uint16(1870),
  66021 			7: uint16(1868),
  66022 			8: uint16(1628),
  66023 			9: uint16(1169),
  66024 		},
  66025 		2: {
  66026 			0: uint16(572),
  66027 			1: uint16(646),
  66028 			2: uint16(492),
  66029 			3: uint16(1934),
  66030 			4: uint16(1208),
  66031 			5: uint16(603),
  66032 			6: uint16(1580),
  66033 			7: uint16(1099),
  66034 			8: uint16(1398),
  66035 			9: uint16(1995),
  66036 		},
  66037 		3: {
  66038 			0: uint16(786),
  66039 			1: uint16(789),
  66040 			2: uint16(942),
  66041 			3: uint16(581),
  66042 			4: uint16(1018),
  66043 			5: uint16(951),
  66044 			6: uint16(1599),
  66045 			7: uint16(1207),
  66046 			8: uint16(731),
  66047 			9: uint16(768),
  66048 		},
  66049 		4: {
  66050 			0: uint16(690),
  66051 			1: uint16(1015),
  66052 			2: uint16(672),
  66053 			3: uint16(1078),
  66054 			4: uint16(582),
  66055 			5: uint16(504),
  66056 			6: uint16(1693),
  66057 			7: uint16(1438),
  66058 			8: uint16(1108),
  66059 			9: uint16(2897),
  66060 		},
  66061 		5: {
  66062 			0: uint16(768),
  66063 			1: uint16(1267),
  66064 			2: uint16(571),
  66065 			3: uint16(2005),
  66066 			4: uint16(1243),
  66067 			5: uint16(244),
  66068 			6: uint16(2881),
  66069 			7: uint16(1380),
  66070 			8: uint16(1786),
  66071 			9: uint16(1453),
  66072 		},
  66073 		6: {
  66074 			0: uint16(452),
  66075 			1: uint16(899),
  66076 			2: uint16(1293),
  66077 			3: uint16(903),
  66078 			4: uint16(1311),
  66079 			5: uint16(3100),
  66080 			6: uint16(465),
  66081 			7: uint16(1311),
  66082 			8: uint16(1319),
  66083 			9: uint16(813),
  66084 		},
  66085 		7: {
  66086 			0: uint16(394),
  66087 			1: uint16(927),
  66088 			2: uint16(942),
  66089 			3: uint16(1103),
  66090 			4: uint16(1358),
  66091 			5: uint16(1104),
  66092 			6: uint16(946),
  66093 			7: uint16(593),
  66094 			8: uint16(1363),
  66095 			9: uint16(1109),
  66096 		},
  66097 		8: {
  66098 			0: uint16(559),
  66099 			1: uint16(1005),
  66100 			2: uint16(1007),
  66101 			3: uint16(1016),
  66102 			4: uint16(658),
  66103 			5: uint16(1173),
  66104 			6: uint16(1021),
  66105 			7: uint16(1164),
  66106 			8: uint16(623),
  66107 			9: uint16(1028),
  66108 		},
  66109 		9: {
  66110 			0: uint16(564),
  66111 			1: uint16(796),
  66112 			2: uint16(632),
  66113 			3: uint16(1005),
  66114 			4: uint16(1014),
  66115 			5: uint16(863),
  66116 			6: uint16(2316),
  66117 			7: uint16(1268),
  66118 			8: uint16(938),
  66119 			9: uint16(764),
  66120 		},
  66121 	},
  66122 	6: {
  66123 		0: {
  66124 			0: uint16(266),
  66125 			1: uint16(606),
  66126 			2: uint16(1098),
  66127 			3: uint16(1228),
  66128 			4: uint16(1497),
  66129 			5: uint16(1243),
  66130 			6: uint16(948),
  66131 			7: uint16(1030),
  66132 			8: uint16(1734),
  66133 			9: uint16(1461),
  66134 		},
  66135 		1: {
  66136 			0: uint16(366),
  66137 			1: uint16(585),
  66138 			2: uint16(901),
  66139 			3: uint16(1060),
  66140 			4: uint16(1407),
  66141 			5: uint16(1247),
  66142 			6: uint16(876),
  66143 			7: uint16(1134),
  66144 			8: uint16(1620),
  66145 			9: uint16(1054),
  66146 		},
  66147 		2: {
  66148 			0: uint16(452),
  66149 			1: uint16(565),
  66150 			2: uint16(542),
  66151 			3: uint16(1729),
  66152 			4: uint16(1479),
  66153 			5: uint16(1479),
  66154 			6: uint16(1016),
  66155 			7: uint16(886),
  66156 			8: uint16(2938),
  66157 			9: uint16(1150),
  66158 		},
  66159 		3: {
  66160 			0: uint16(555),
  66161 			1: uint16(1088),
  66162 			2: uint16(1533),
  66163 			3: uint16(950),
  66164 			4: uint16(1354),
  66165 			5: uint16(895),
  66166 			6: uint16(834),
  66167 			7: uint16(1019),
  66168 			8: uint16(1021),
  66169 			9: uint16(496),
  66170 		},
  66171 		4: {
  66172 			0: uint16(704),
  66173 			1: uint16(815),
  66174 			2: uint16(1193),
  66175 			3: uint16(971),
  66176 			4: uint16(973),
  66177 			5: uint16(640),
  66178 			6: uint16(1217),
  66179 			7: uint16(2214),
  66180 			8: uint16(832),
  66181 			9: uint16(578),
  66182 		},
  66183 		5: {
  66184 			0: uint16(672),
  66185 			1: uint16(1245),
  66186 			2: uint16(579),
  66187 			3: uint16(871),
  66188 			4: uint16(875),
  66189 			5: uint16(774),
  66190 			6: uint16(872),
  66191 			7: uint16(1273),
  66192 			8: uint16(1027),
  66193 			9: uint16(949),
  66194 		},
  66195 		6: {
  66196 			0: uint16(296),
  66197 			1: uint16(1134),
  66198 			2: uint16(2050),
  66199 			3: uint16(1784),
  66200 			4: uint16(1636),
  66201 			5: uint16(3425),
  66202 			6: uint16(442),
  66203 			7: uint16(1550),
  66204 			8: uint16(2076),
  66205 			9: uint16(722),
  66206 		},
  66207 		7: {
  66208 			0: uint16(342),
  66209 			1: uint16(982),
  66210 			2: uint16(1259),
  66211 			3: uint16(1846),
  66212 			4: uint16(1848),
  66213 			5: uint16(1848),
  66214 			6: uint16(622),
  66215 			7: uint16(568),
  66216 			8: uint16(1847),
  66217 			9: uint16(1052),
  66218 		},
  66219 		8: {
  66220 			0: uint16(555),
  66221 			1: uint16(1064),
  66222 			2: uint16(1304),
  66223 			3: uint16(828),
  66224 			4: uint16(746),
  66225 			5: uint16(1343),
  66226 			6: uint16(1075),
  66227 			7: uint16(1329),
  66228 			8: uint16(1078),
  66229 			9: uint16(494),
  66230 		},
  66231 		9: {
  66232 			0: uint16(288),
  66233 			1: uint16(1167),
  66234 			2: uint16(1285),
  66235 			3: uint16(1174),
  66236 			4: uint16(1639),
  66237 			5: uint16(1639),
  66238 			6: uint16(833),
  66239 			7: uint16(2254),
  66240 			8: uint16(1304),
  66241 			9: uint16(509),
  66242 		},
  66243 	},
  66244 	7: {
  66245 		0: {
  66246 			0: uint16(342),
  66247 			1: uint16(719),
  66248 			2: uint16(767),
  66249 			3: uint16(1866),
  66250 			4: uint16(1757),
  66251 			5: uint16(1270),
  66252 			6: uint16(1246),
  66253 			7: uint16(550),
  66254 			8: uint16(1746),
  66255 			9: uint16(2151),
  66256 		},
  66257 		1: {
  66258 			0: uint16(483),
  66259 			1: uint16(653),
  66260 			2: uint16(694),
  66261 			3: uint16(1509),
  66262 			4: uint16(1459),
  66263 			5: uint16(1410),
  66264 			6: uint16(1218),
  66265 			7: uint16(507),
  66266 			8: uint16(1914),
  66267 			9: uint16(1266),
  66268 		},
  66269 		2: {
  66270 			0: uint16(488),
  66271 			1: uint16(757),
  66272 			2: uint16(447),
  66273 			3: uint16(2979),
  66274 			4: uint16(1813),
  66275 			5: uint16(1268),
  66276 			6: uint16(1654),
  66277 			7: uint16(539),
  66278 			8: uint16(1849),
  66279 			9: uint16(2109),
  66280 		},
  66281 		3: {
  66282 			0: uint16(522),
  66283 			1: uint16(1097),
  66284 			2: uint16(1085),
  66285 			3: uint16(851),
  66286 			4: uint16(1365),
  66287 			5: uint16(1111),
  66288 			6: uint16(851),
  66289 			7: uint16(901),
  66290 			8: uint16(961),
  66291 			9: uint16(605),
  66292 		},
  66293 		4: {
  66294 			0: uint16(709),
  66295 			1: uint16(716),
  66296 			2: uint16(841),
  66297 			3: uint16(728),
  66298 			4: uint16(736),
  66299 			5: uint16(945),
  66300 			6: uint16(941),
  66301 			7: uint16(862),
  66302 			8: uint16(2845),
  66303 			9: uint16(1057),
  66304 		},
  66305 		5: {
  66306 			0: uint16(512),
  66307 			1: uint16(1323),
  66308 			2: uint16(500),
  66309 			3: uint16(1336),
  66310 			4: uint16(1083),
  66311 			5: uint16(681),
  66312 			6: uint16(1342),
  66313 			7: uint16(717),
  66314 			8: uint16(1604),
  66315 			9: uint16(1350),
  66316 		},
  66317 		6: {
  66318 			0: uint16(452),
  66319 			1: uint16(1155),
  66320 			2: uint16(1372),
  66321 			3: uint16(1900),
  66322 			4: uint16(1501),
  66323 			5: uint16(3290),
  66324 			6: uint16(311),
  66325 			7: uint16(944),
  66326 			8: uint16(1919),
  66327 			9: uint16(922),
  66328 		},
  66329 		7: {
  66330 			0: uint16(403),
  66331 			1: uint16(1520),
  66332 			2: uint16(977),
  66333 			3: uint16(2132),
  66334 			4: uint16(1733),
  66335 			5: uint16(3522),
  66336 			6: uint16(1076),
  66337 			7: uint16(276),
  66338 			8: uint16(3335),
  66339 			9: uint16(1547),
  66340 		},
  66341 		8: {
  66342 			0: uint16(559),
  66343 			1: uint16(1374),
  66344 			2: uint16(1101),
  66345 			3: uint16(615),
  66346 			4: uint16(673),
  66347 			5: uint16(2462),
  66348 			6: uint16(974),
  66349 			7: uint16(795),
  66350 			8: uint16(984),
  66351 			9: uint16(984),
  66352 		},
  66353 		9: {
  66354 			0: uint16(547),
  66355 			1: uint16(1122),
  66356 			2: uint16(1062),
  66357 			3: uint16(812),
  66358 			4: uint16(1410),
  66359 			5: uint16(951),
  66360 			6: uint16(1140),
  66361 			7: uint16(622),
  66362 			8: uint16(1268),
  66363 			9: uint16(651),
  66364 		},
  66365 	},
  66366 	8: {
  66367 		0: {
  66368 			0: uint16(165),
  66369 			1: uint16(982),
  66370 			2: uint16(1235),
  66371 			3: uint16(938),
  66372 			4: uint16(1334),
  66373 			5: uint16(1366),
  66374 			6: uint16(1659),
  66375 			7: uint16(1578),
  66376 			8: uint16(964),
  66377 			9: uint16(1612),
  66378 		},
  66379 		1: {
  66380 			0: uint16(592),
  66381 			1: uint16(422),
  66382 			2: uint16(925),
  66383 			3: uint16(847),
  66384 			4: uint16(1139),
  66385 			5: uint16(1112),
  66386 			6: uint16(1387),
  66387 			7: uint16(2036),
  66388 			8: uint16(861),
  66389 			9: uint16(1041),
  66390 		},
  66391 		2: {
  66392 			0: uint16(403),
  66393 			1: uint16(837),
  66394 			2: uint16(732),
  66395 			3: uint16(770),
  66396 			4: uint16(941),
  66397 			5: uint16(1658),
  66398 			6: uint16(1250),
  66399 			7: uint16(809),
  66400 			8: uint16(1407),
  66401 			9: uint16(1407),
  66402 		},
  66403 		3: {
  66404 			0: uint16(896),
  66405 			1: uint16(874),
  66406 			2: uint16(1071),
  66407 			3: uint16(381),
  66408 			4: uint16(1568),
  66409 			5: uint16(1722),
  66410 			6: uint16(1437),
  66411 			7: uint16(2192),
  66412 			8: uint16(480),
  66413 			9: uint16(1035),
  66414 		},
  66415 		4: {
  66416 			0: uint16(640),
  66417 			1: uint16(1098),
  66418 			2: uint16(1012),
  66419 			3: uint16(1032),
  66420 			4: uint16(684),
  66421 			5: uint16(1382),
  66422 			6: uint16(1581),
  66423 			7: uint16(2106),
  66424 			8: uint16(416),
  66425 			9: uint16(865),
  66426 		},
  66427 		5: {
  66428 			0: uint16(559),
  66429 			1: uint16(1005),
  66430 			2: uint16(819),
  66431 			3: uint16(914),
  66432 			4: uint16(710),
  66433 			5: uint16(770),
  66434 			6: uint16(1418),
  66435 			7: uint16(920),
  66436 			8: uint16(838),
  66437 			9: uint16(1435),
  66438 		},
  66439 		6: {
  66440 			0: uint16(415),
  66441 			1: uint16(1258),
  66442 			2: uint16(1245),
  66443 			3: uint16(870),
  66444 			4: uint16(1278),
  66445 			5: uint16(3067),
  66446 			6: uint16(770),
  66447 			7: uint16(1021),
  66448 			8: uint16(1287),
  66449 			9: uint16(522),
  66450 		},
  66451 		7: {
  66452 			0: uint16(406),
  66453 			1: uint16(990),
  66454 			2: uint16(601),
  66455 			3: uint16(1009),
  66456 			4: uint16(1265),
  66457 			5: uint16(1265),
  66458 			6: uint16(1267),
  66459 			7: uint16(759),
  66460 			8: uint16(1017),
  66461 			9: uint16(1277),
  66462 		},
  66463 		8: {
  66464 			0: uint16(968),
  66465 			1: uint16(1182),
  66466 			2: uint16(1329),
  66467 			3: uint16(788),
  66468 			4: uint16(1032),
  66469 			5: uint16(1292),
  66470 			6: uint16(1705),
  66471 			7: uint16(1714),
  66472 			8: uint16(203),
  66473 			9: uint16(1403),
  66474 		},
  66475 		9: {
  66476 			0: uint16(732),
  66477 			1: uint16(877),
  66478 			2: uint16(1279),
  66479 			3: uint16(471),
  66480 			4: uint16(901),
  66481 			5: uint16(1161),
  66482 			6: uint16(1545),
  66483 			7: uint16(1294),
  66484 			8: uint16(755),
  66485 			9: uint16(755),
  66486 		},
  66487 	},
  66488 	9: {
  66489 		0: {
  66490 			0: uint16(111),
  66491 			1: uint16(931),
  66492 			2: uint16(1378),
  66493 			3: uint16(1185),
  66494 			4: uint16(1933),
  66495 			5: uint16(1648),
  66496 			6: uint16(1148),
  66497 			7: uint16(1714),
  66498 			8: uint16(1873),
  66499 			9: uint16(1307),
  66500 		},
  66501 		1: {
  66502 			0: uint16(406),
  66503 			1: uint16(414),
  66504 			2: uint16(1030),
  66505 			3: uint16(1023),
  66506 			4: uint16(1910),
  66507 			5: uint16(1404),
  66508 			6: uint16(1313),
  66509 			7: uint16(1647),
  66510 			8: uint16(1509),
  66511 			9: uint16(793),
  66512 		},
  66513 		2: {
  66514 			0: uint16(342),
  66515 			1: uint16(640),
  66516 			2: uint16(575),
  66517 			3: uint16(1088),
  66518 			4: uint16(1241),
  66519 			5: uint16(1349),
  66520 			6: uint16(1161),
  66521 			7: uint16(1350),
  66522 			8: uint16(1756),
  66523 			9: uint16(1502),
  66524 		},
  66525 		3: {
  66526 			0: uint16(559),
  66527 			1: uint16(766),
  66528 			2: uint16(1185),
  66529 			3: uint16(357),
  66530 			4: uint16(1682),
  66531 			5: uint16(1428),
  66532 			6: uint16(1329),
  66533 			7: uint16(1897),
  66534 			8: uint16(1219),
  66535 			9: uint16(802),
  66536 		},
  66537 		4: {
  66538 			0: uint16(473),
  66539 			1: uint16(909),
  66540 			2: uint16(1164),
  66541 			3: uint16(771),
  66542 			4: uint16(719),
  66543 			5: uint16(2508),
  66544 			6: uint16(1427),
  66545 			7: uint16(1432),
  66546 			8: uint16(722),
  66547 			9: uint16(782),
  66548 		},
  66549 		5: {
  66550 			0: uint16(342),
  66551 			1: uint16(892),
  66552 			2: uint16(785),
  66553 			3: uint16(1145),
  66554 			4: uint16(1150),
  66555 			5: uint16(794),
  66556 			6: uint16(1296),
  66557 			7: uint16(1550),
  66558 			8: uint16(973),
  66559 			9: uint16(1057),
  66560 		},
  66561 		6: {
  66562 			0: uint16(208),
  66563 			1: uint16(1036),
  66564 			2: uint16(1326),
  66565 			3: uint16(1343),
  66566 			4: uint16(1606),
  66567 			5: uint16(3395),
  66568 			6: uint16(815),
  66569 			7: uint16(1455),
  66570 			8: uint16(1618),
  66571 			9: uint16(712),
  66572 		},
  66573 		7: {
  66574 			0: uint16(228),
  66575 			1: uint16(928),
  66576 			2: uint16(890),
  66577 			3: uint16(1046),
  66578 			4: uint16(3499),
  66579 			5: uint16(1711),
  66580 			6: uint16(994),
  66581 			7: uint16(829),
  66582 			8: uint16(1720),
  66583 			9: uint16(1318),
  66584 		},
  66585 		8: {
  66586 			0: uint16(768),
  66587 			1: uint16(724),
  66588 			2: uint16(1058),
  66589 			3: uint16(636),
  66590 			4: uint16(991),
  66591 			5: uint16(1075),
  66592 			6: uint16(1319),
  66593 			7: uint16(1324),
  66594 			8: uint16(616),
  66595 			9: uint16(825),
  66596 		},
  66597 		9: {
  66598 			0: uint16(305),
  66599 			1: uint16(1167),
  66600 			2: uint16(1358),
  66601 			3: uint16(899),
  66602 			4: uint16(1587),
  66603 			5: uint16(1587),
  66604 			6: uint16(987),
  66605 			7: uint16(1988),
  66606 			8: uint16(1332),
  66607 			9: uint16(501),
  66608 		},
  66609 	},
  66610 }
  66611 
  66612 //------------------------------------------------------------------------------
  66613 // Mode cost tables.
  66614 
  66615 // C documentation
  66616 //
  66617 //	// These are the fixed probabilities (in the coding trees) turned into bit-cost
  66618 //	// by calling VP8BitCost().
  66619 var VP8FixedCostsUV = [4]uint16_t{
  66620 	0: uint16(302),
  66621 	1: uint16(984),
  66622 	2: uint16(439),
  66623 	3: uint16(642),
  66624 }
  66625 
  66626 var VP8GetCPUInfo = uintptr(0)
  66627 
  66628 //------------------------------------------------------------------------------
  66629 // init function
  66630 
  66631 var VP8GetResidualCost VP8GetResidualCostFunc
  66632 
  66633 var VP8HFilter16 VP8LumaFilterFunc
  66634 
  66635 var VP8HFilter16i VP8LumaFilterFunc
  66636 
  66637 var VP8HFilter8 VP8ChromaFilterFunc
  66638 
  66639 var VP8HFilter8i VP8ChromaFilterFunc
  66640 
  66641 //------------------------------------------------------------------------------
  66642 // Form the predictions in cache
  66643 
  66644 // C documentation
  66645 //
  66646 //	// Must be ordered using {DC_PRED, TM_PRED, V_PRED, H_PRED} as index
  66647 var VP8I16ModeOffsets = [4]uint16_t{
  66648 	1: libc.Uint16FromInt32(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(16)),
  66649 	2: libc.Uint16FromInt32(libc.Int32FromInt32(1) * libc.Int32FromInt32(16) * libc.Int32FromInt32(BPS)),
  66650 	3: libc.Uint16FromInt32(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(16)),
  66651 }
  66652 
  66653 var VP8ITransform VP8Idct
  66654 
  66655 //------------------------------------------------------------------------------
  66656 
  66657 var VP8LAddGreenToBlueAndRed VP8LProcessDecBlueAndRedFunc
  66658 
  66659 var VP8LAddGreenToBlueAndRed_SSE VP8LProcessDecBlueAndRedFunc
  66660 
  66661 var VP8LAddVector VP8LAddVectorFunc
  66662 
  66663 var VP8LAddVectorEq VP8LAddVectorEqFunc
  66664 
  66665 var VP8LBundleColorMap VP8LBundleColorMapFunc
  66666 
  66667 var VP8LBundleColorMap_SSE VP8LBundleColorMapFunc
  66668 
  66669 var VP8LCollectColorBlueTransforms VP8LCollectColorBlueTransformsFunc
  66670 
  66671 var VP8LCollectColorBlueTransforms_SSE VP8LCollectColorBlueTransformsFunc
  66672 
  66673 var VP8LCollectColorRedTransforms VP8LCollectColorRedTransformsFunc
  66674 
  66675 var VP8LCollectColorRedTransforms_SSE VP8LCollectColorRedTransformsFunc
  66676 
  66677 var VP8LCombinedShannonEntropy VP8LCombinedShannonEntropyFunc
  66678 
  66679 var VP8LConvertBGRAToBGR VP8LConvertFunc
  66680 
  66681 var VP8LConvertBGRAToRGB VP8LConvertFunc
  66682 
  66683 var VP8LConvertBGRAToRGB565 VP8LConvertFunc
  66684 
  66685 var VP8LConvertBGRAToRGBA VP8LConvertFunc
  66686 
  66687 var VP8LConvertBGRAToRGBA4444 VP8LConvertFunc
  66688 
  66689 var VP8LConvertBGRAToRGBA_SSE VP8LConvertFunc
  66690 
  66691 var VP8LConvertBGRAToRGB_SSE VP8LConvertFunc
  66692 
  66693 var VP8LExtraCost VP8LCostFunc
  66694 
  66695 var VP8LFastLog2Slow VP8LFastLog2SlowFunc
  66696 
  66697 var VP8LFastSLog2Slow VP8LFastSLog2SlowFunc
  66698 
  66699 var VP8LGetCombinedEntropyUnrefined VP8LGetCombinedEntropyUnrefinedFunc
  66700 
  66701 var VP8LGetEntropyUnrefined VP8LGetEntropyUnrefinedFunc
  66702 
  66703 var VP8LMapColor32b VP8LMapARGBFunc
  66704 
  66705 var VP8LMapColor8b VP8LMapAlphaFunc
  66706 
  66707 var VP8LPredictors [16]VP8LPredictorFunc
  66708 
  66709 var VP8LPredictorsAdd [16]VP8LPredictorAddSubFunc
  66710 
  66711 // C documentation
  66712 //
  66713 //	// exposed plain-C implementations
  66714 var VP8LPredictorsAdd_C [16]VP8LPredictorAddSubFunc
  66715 
  66716 var VP8LPredictorsAdd_SSE [16]VP8LPredictorAddSubFunc
  66717 
  66718 var VP8LPredictorsSub [16]VP8LPredictorAddSubFunc
  66719 
  66720 var VP8LPredictorsSub_C [16]VP8LPredictorAddSubFunc
  66721 
  66722 var VP8LPredictorsSub_SSE [16]VP8LPredictorAddSubFunc
  66723 
  66724 var VP8LShannonEntropy VP8LShannonEntropyFunc
  66725 
  66726 //------------------------------------------------------------------------------
  66727 
  66728 var VP8LSubtractGreenFromBlueAndRed VP8LProcessEncBlueAndRedFunc
  66729 
  66730 var VP8LSubtractGreenFromBlueAndRed_SSE VP8LProcessEncBlueAndRedFunc
  66731 
  66732 var VP8LTransformColor VP8LTransformColorFunc
  66733 
  66734 var VP8LTransformColorInverse VP8LTransformColorInverseFunc
  66735 
  66736 var VP8LTransformColorInverse_SSE VP8LTransformColorInverseFunc
  66737 
  66738 var VP8LTransformColor_SSE VP8LTransformColorFunc
  66739 
  66740 var VP8LVectorMismatch VP8LVectorMismatchFunc
  66741 
  66742 //------------------------------------------------------------------------------
  66743 // Level cost tables
  66744 
  66745 // C documentation
  66746 //
  66747 //	// fixed costs for coding levels, deduce from the coding tree.
  66748 //	// This is only the part that doesn't depend on the probability state.
  66749 var VP8LevelFixedCosts = [2048]uint16_t{
  66750 	1:    uint16(256),
  66751 	2:    uint16(256),
  66752 	3:    uint16(256),
  66753 	4:    uint16(256),
  66754 	5:    uint16(432),
  66755 	6:    uint16(618),
  66756 	7:    uint16(630),
  66757 	8:    uint16(731),
  66758 	9:    uint16(640),
  66759 	10:   uint16(640),
  66760 	11:   uint16(828),
  66761 	12:   uint16(901),
  66762 	13:   uint16(948),
  66763 	14:   uint16(1021),
  66764 	15:   uint16(1101),
  66765 	16:   uint16(1174),
  66766 	17:   uint16(1221),
  66767 	18:   uint16(1294),
  66768 	19:   uint16(1042),
  66769 	20:   uint16(1085),
  66770 	21:   uint16(1115),
  66771 	22:   uint16(1158),
  66772 	23:   uint16(1202),
  66773 	24:   uint16(1245),
  66774 	25:   uint16(1275),
  66775 	26:   uint16(1318),
  66776 	27:   uint16(1337),
  66777 	28:   uint16(1380),
  66778 	29:   uint16(1410),
  66779 	30:   uint16(1453),
  66780 	31:   uint16(1497),
  66781 	32:   uint16(1540),
  66782 	33:   uint16(1570),
  66783 	34:   uint16(1613),
  66784 	35:   uint16(1280),
  66785 	36:   uint16(1295),
  66786 	37:   uint16(1317),
  66787 	38:   uint16(1332),
  66788 	39:   uint16(1358),
  66789 	40:   uint16(1373),
  66790 	41:   uint16(1395),
  66791 	42:   uint16(1410),
  66792 	43:   uint16(1454),
  66793 	44:   uint16(1469),
  66794 	45:   uint16(1491),
  66795 	46:   uint16(1506),
  66796 	47:   uint16(1532),
  66797 	48:   uint16(1547),
  66798 	49:   uint16(1569),
  66799 	50:   uint16(1584),
  66800 	51:   uint16(1601),
  66801 	52:   uint16(1616),
  66802 	53:   uint16(1638),
  66803 	54:   uint16(1653),
  66804 	55:   uint16(1679),
  66805 	56:   uint16(1694),
  66806 	57:   uint16(1716),
  66807 	58:   uint16(1731),
  66808 	59:   uint16(1775),
  66809 	60:   uint16(1790),
  66810 	61:   uint16(1812),
  66811 	62:   uint16(1827),
  66812 	63:   uint16(1853),
  66813 	64:   uint16(1868),
  66814 	65:   uint16(1890),
  66815 	66:   uint16(1905),
  66816 	67:   uint16(1727),
  66817 	68:   uint16(1733),
  66818 	69:   uint16(1742),
  66819 	70:   uint16(1748),
  66820 	71:   uint16(1759),
  66821 	72:   uint16(1765),
  66822 	73:   uint16(1774),
  66823 	74:   uint16(1780),
  66824 	75:   uint16(1800),
  66825 	76:   uint16(1806),
  66826 	77:   uint16(1815),
  66827 	78:   uint16(1821),
  66828 	79:   uint16(1832),
  66829 	80:   uint16(1838),
  66830 	81:   uint16(1847),
  66831 	82:   uint16(1853),
  66832 	83:   uint16(1878),
  66833 	84:   uint16(1884),
  66834 	85:   uint16(1893),
  66835 	86:   uint16(1899),
  66836 	87:   uint16(1910),
  66837 	88:   uint16(1916),
  66838 	89:   uint16(1925),
  66839 	90:   uint16(1931),
  66840 	91:   uint16(1951),
  66841 	92:   uint16(1957),
  66842 	93:   uint16(1966),
  66843 	94:   uint16(1972),
  66844 	95:   uint16(1983),
  66845 	96:   uint16(1989),
  66846 	97:   uint16(1998),
  66847 	98:   uint16(2004),
  66848 	99:   uint16(2027),
  66849 	100:  uint16(2033),
  66850 	101:  uint16(2042),
  66851 	102:  uint16(2048),
  66852 	103:  uint16(2059),
  66853 	104:  uint16(2065),
  66854 	105:  uint16(2074),
  66855 	106:  uint16(2080),
  66856 	107:  uint16(2100),
  66857 	108:  uint16(2106),
  66858 	109:  uint16(2115),
  66859 	110:  uint16(2121),
  66860 	111:  uint16(2132),
  66861 	112:  uint16(2138),
  66862 	113:  uint16(2147),
  66863 	114:  uint16(2153),
  66864 	115:  uint16(2178),
  66865 	116:  uint16(2184),
  66866 	117:  uint16(2193),
  66867 	118:  uint16(2199),
  66868 	119:  uint16(2210),
  66869 	120:  uint16(2216),
  66870 	121:  uint16(2225),
  66871 	122:  uint16(2231),
  66872 	123:  uint16(2251),
  66873 	124:  uint16(2257),
  66874 	125:  uint16(2266),
  66875 	126:  uint16(2272),
  66876 	127:  uint16(2283),
  66877 	128:  uint16(2289),
  66878 	129:  uint16(2298),
  66879 	130:  uint16(2304),
  66880 	131:  uint16(2168),
  66881 	132:  uint16(2174),
  66882 	133:  uint16(2183),
  66883 	134:  uint16(2189),
  66884 	135:  uint16(2200),
  66885 	136:  uint16(2206),
  66886 	137:  uint16(2215),
  66887 	138:  uint16(2221),
  66888 	139:  uint16(2241),
  66889 	140:  uint16(2247),
  66890 	141:  uint16(2256),
  66891 	142:  uint16(2262),
  66892 	143:  uint16(2273),
  66893 	144:  uint16(2279),
  66894 	145:  uint16(2288),
  66895 	146:  uint16(2294),
  66896 	147:  uint16(2319),
  66897 	148:  uint16(2325),
  66898 	149:  uint16(2334),
  66899 	150:  uint16(2340),
  66900 	151:  uint16(2351),
  66901 	152:  uint16(2357),
  66902 	153:  uint16(2366),
  66903 	154:  uint16(2372),
  66904 	155:  uint16(2392),
  66905 	156:  uint16(2398),
  66906 	157:  uint16(2407),
  66907 	158:  uint16(2413),
  66908 	159:  uint16(2424),
  66909 	160:  uint16(2430),
  66910 	161:  uint16(2439),
  66911 	162:  uint16(2445),
  66912 	163:  uint16(2468),
  66913 	164:  uint16(2474),
  66914 	165:  uint16(2483),
  66915 	166:  uint16(2489),
  66916 	167:  uint16(2500),
  66917 	168:  uint16(2506),
  66918 	169:  uint16(2515),
  66919 	170:  uint16(2521),
  66920 	171:  uint16(2541),
  66921 	172:  uint16(2547),
  66922 	173:  uint16(2556),
  66923 	174:  uint16(2562),
  66924 	175:  uint16(2573),
  66925 	176:  uint16(2579),
  66926 	177:  uint16(2588),
  66927 	178:  uint16(2594),
  66928 	179:  uint16(2619),
  66929 	180:  uint16(2625),
  66930 	181:  uint16(2634),
  66931 	182:  uint16(2640),
  66932 	183:  uint16(2651),
  66933 	184:  uint16(2657),
  66934 	185:  uint16(2666),
  66935 	186:  uint16(2672),
  66936 	187:  uint16(2692),
  66937 	188:  uint16(2698),
  66938 	189:  uint16(2707),
  66939 	190:  uint16(2713),
  66940 	191:  uint16(2724),
  66941 	192:  uint16(2730),
  66942 	193:  uint16(2739),
  66943 	194:  uint16(2745),
  66944 	195:  uint16(2540),
  66945 	196:  uint16(2546),
  66946 	197:  uint16(2555),
  66947 	198:  uint16(2561),
  66948 	199:  uint16(2572),
  66949 	200:  uint16(2578),
  66950 	201:  uint16(2587),
  66951 	202:  uint16(2593),
  66952 	203:  uint16(2613),
  66953 	204:  uint16(2619),
  66954 	205:  uint16(2628),
  66955 	206:  uint16(2634),
  66956 	207:  uint16(2645),
  66957 	208:  uint16(2651),
  66958 	209:  uint16(2660),
  66959 	210:  uint16(2666),
  66960 	211:  uint16(2691),
  66961 	212:  uint16(2697),
  66962 	213:  uint16(2706),
  66963 	214:  uint16(2712),
  66964 	215:  uint16(2723),
  66965 	216:  uint16(2729),
  66966 	217:  uint16(2738),
  66967 	218:  uint16(2744),
  66968 	219:  uint16(2764),
  66969 	220:  uint16(2770),
  66970 	221:  uint16(2779),
  66971 	222:  uint16(2785),
  66972 	223:  uint16(2796),
  66973 	224:  uint16(2802),
  66974 	225:  uint16(2811),
  66975 	226:  uint16(2817),
  66976 	227:  uint16(2840),
  66977 	228:  uint16(2846),
  66978 	229:  uint16(2855),
  66979 	230:  uint16(2861),
  66980 	231:  uint16(2872),
  66981 	232:  uint16(2878),
  66982 	233:  uint16(2887),
  66983 	234:  uint16(2893),
  66984 	235:  uint16(2913),
  66985 	236:  uint16(2919),
  66986 	237:  uint16(2928),
  66987 	238:  uint16(2934),
  66988 	239:  uint16(2945),
  66989 	240:  uint16(2951),
  66990 	241:  uint16(2960),
  66991 	242:  uint16(2966),
  66992 	243:  uint16(2991),
  66993 	244:  uint16(2997),
  66994 	245:  uint16(3006),
  66995 	246:  uint16(3012),
  66996 	247:  uint16(3023),
  66997 	248:  uint16(3029),
  66998 	249:  uint16(3038),
  66999 	250:  uint16(3044),
  67000 	251:  uint16(3064),
  67001 	252:  uint16(3070),
  67002 	253:  uint16(3079),
  67003 	254:  uint16(3085),
  67004 	255:  uint16(3096),
  67005 	256:  uint16(3102),
  67006 	257:  uint16(3111),
  67007 	258:  uint16(3117),
  67008 	259:  uint16(2981),
  67009 	260:  uint16(2987),
  67010 	261:  uint16(2996),
  67011 	262:  uint16(3002),
  67012 	263:  uint16(3013),
  67013 	264:  uint16(3019),
  67014 	265:  uint16(3028),
  67015 	266:  uint16(3034),
  67016 	267:  uint16(3054),
  67017 	268:  uint16(3060),
  67018 	269:  uint16(3069),
  67019 	270:  uint16(3075),
  67020 	271:  uint16(3086),
  67021 	272:  uint16(3092),
  67022 	273:  uint16(3101),
  67023 	274:  uint16(3107),
  67024 	275:  uint16(3132),
  67025 	276:  uint16(3138),
  67026 	277:  uint16(3147),
  67027 	278:  uint16(3153),
  67028 	279:  uint16(3164),
  67029 	280:  uint16(3170),
  67030 	281:  uint16(3179),
  67031 	282:  uint16(3185),
  67032 	283:  uint16(3205),
  67033 	284:  uint16(3211),
  67034 	285:  uint16(3220),
  67035 	286:  uint16(3226),
  67036 	287:  uint16(3237),
  67037 	288:  uint16(3243),
  67038 	289:  uint16(3252),
  67039 	290:  uint16(3258),
  67040 	291:  uint16(3281),
  67041 	292:  uint16(3287),
  67042 	293:  uint16(3296),
  67043 	294:  uint16(3302),
  67044 	295:  uint16(3313),
  67045 	296:  uint16(3319),
  67046 	297:  uint16(3328),
  67047 	298:  uint16(3334),
  67048 	299:  uint16(3354),
  67049 	300:  uint16(3360),
  67050 	301:  uint16(3369),
  67051 	302:  uint16(3375),
  67052 	303:  uint16(3386),
  67053 	304:  uint16(3392),
  67054 	305:  uint16(3401),
  67055 	306:  uint16(3407),
  67056 	307:  uint16(3432),
  67057 	308:  uint16(3438),
  67058 	309:  uint16(3447),
  67059 	310:  uint16(3453),
  67060 	311:  uint16(3464),
  67061 	312:  uint16(3470),
  67062 	313:  uint16(3479),
  67063 	314:  uint16(3485),
  67064 	315:  uint16(3505),
  67065 	316:  uint16(3511),
  67066 	317:  uint16(3520),
  67067 	318:  uint16(3526),
  67068 	319:  uint16(3537),
  67069 	320:  uint16(3543),
  67070 	321:  uint16(3552),
  67071 	322:  uint16(3558),
  67072 	323:  uint16(2816),
  67073 	324:  uint16(2822),
  67074 	325:  uint16(2831),
  67075 	326:  uint16(2837),
  67076 	327:  uint16(2848),
  67077 	328:  uint16(2854),
  67078 	329:  uint16(2863),
  67079 	330:  uint16(2869),
  67080 	331:  uint16(2889),
  67081 	332:  uint16(2895),
  67082 	333:  uint16(2904),
  67083 	334:  uint16(2910),
  67084 	335:  uint16(2921),
  67085 	336:  uint16(2927),
  67086 	337:  uint16(2936),
  67087 	338:  uint16(2942),
  67088 	339:  uint16(2967),
  67089 	340:  uint16(2973),
  67090 	341:  uint16(2982),
  67091 	342:  uint16(2988),
  67092 	343:  uint16(2999),
  67093 	344:  uint16(3005),
  67094 	345:  uint16(3014),
  67095 	346:  uint16(3020),
  67096 	347:  uint16(3040),
  67097 	348:  uint16(3046),
  67098 	349:  uint16(3055),
  67099 	350:  uint16(3061),
  67100 	351:  uint16(3072),
  67101 	352:  uint16(3078),
  67102 	353:  uint16(3087),
  67103 	354:  uint16(3093),
  67104 	355:  uint16(3116),
  67105 	356:  uint16(3122),
  67106 	357:  uint16(3131),
  67107 	358:  uint16(3137),
  67108 	359:  uint16(3148),
  67109 	360:  uint16(3154),
  67110 	361:  uint16(3163),
  67111 	362:  uint16(3169),
  67112 	363:  uint16(3189),
  67113 	364:  uint16(3195),
  67114 	365:  uint16(3204),
  67115 	366:  uint16(3210),
  67116 	367:  uint16(3221),
  67117 	368:  uint16(3227),
  67118 	369:  uint16(3236),
  67119 	370:  uint16(3242),
  67120 	371:  uint16(3267),
  67121 	372:  uint16(3273),
  67122 	373:  uint16(3282),
  67123 	374:  uint16(3288),
  67124 	375:  uint16(3299),
  67125 	376:  uint16(3305),
  67126 	377:  uint16(3314),
  67127 	378:  uint16(3320),
  67128 	379:  uint16(3340),
  67129 	380:  uint16(3346),
  67130 	381:  uint16(3355),
  67131 	382:  uint16(3361),
  67132 	383:  uint16(3372),
  67133 	384:  uint16(3378),
  67134 	385:  uint16(3387),
  67135 	386:  uint16(3393),
  67136 	387:  uint16(3257),
  67137 	388:  uint16(3263),
  67138 	389:  uint16(3272),
  67139 	390:  uint16(3278),
  67140 	391:  uint16(3289),
  67141 	392:  uint16(3295),
  67142 	393:  uint16(3304),
  67143 	394:  uint16(3310),
  67144 	395:  uint16(3330),
  67145 	396:  uint16(3336),
  67146 	397:  uint16(3345),
  67147 	398:  uint16(3351),
  67148 	399:  uint16(3362),
  67149 	400:  uint16(3368),
  67150 	401:  uint16(3377),
  67151 	402:  uint16(3383),
  67152 	403:  uint16(3408),
  67153 	404:  uint16(3414),
  67154 	405:  uint16(3423),
  67155 	406:  uint16(3429),
  67156 	407:  uint16(3440),
  67157 	408:  uint16(3446),
  67158 	409:  uint16(3455),
  67159 	410:  uint16(3461),
  67160 	411:  uint16(3481),
  67161 	412:  uint16(3487),
  67162 	413:  uint16(3496),
  67163 	414:  uint16(3502),
  67164 	415:  uint16(3513),
  67165 	416:  uint16(3519),
  67166 	417:  uint16(3528),
  67167 	418:  uint16(3534),
  67168 	419:  uint16(3557),
  67169 	420:  uint16(3563),
  67170 	421:  uint16(3572),
  67171 	422:  uint16(3578),
  67172 	423:  uint16(3589),
  67173 	424:  uint16(3595),
  67174 	425:  uint16(3604),
  67175 	426:  uint16(3610),
  67176 	427:  uint16(3630),
  67177 	428:  uint16(3636),
  67178 	429:  uint16(3645),
  67179 	430:  uint16(3651),
  67180 	431:  uint16(3662),
  67181 	432:  uint16(3668),
  67182 	433:  uint16(3677),
  67183 	434:  uint16(3683),
  67184 	435:  uint16(3708),
  67185 	436:  uint16(3714),
  67186 	437:  uint16(3723),
  67187 	438:  uint16(3729),
  67188 	439:  uint16(3740),
  67189 	440:  uint16(3746),
  67190 	441:  uint16(3755),
  67191 	442:  uint16(3761),
  67192 	443:  uint16(3781),
  67193 	444:  uint16(3787),
  67194 	445:  uint16(3796),
  67195 	446:  uint16(3802),
  67196 	447:  uint16(3813),
  67197 	448:  uint16(3819),
  67198 	449:  uint16(3828),
  67199 	450:  uint16(3834),
  67200 	451:  uint16(3629),
  67201 	452:  uint16(3635),
  67202 	453:  uint16(3644),
  67203 	454:  uint16(3650),
  67204 	455:  uint16(3661),
  67205 	456:  uint16(3667),
  67206 	457:  uint16(3676),
  67207 	458:  uint16(3682),
  67208 	459:  uint16(3702),
  67209 	460:  uint16(3708),
  67210 	461:  uint16(3717),
  67211 	462:  uint16(3723),
  67212 	463:  uint16(3734),
  67213 	464:  uint16(3740),
  67214 	465:  uint16(3749),
  67215 	466:  uint16(3755),
  67216 	467:  uint16(3780),
  67217 	468:  uint16(3786),
  67218 	469:  uint16(3795),
  67219 	470:  uint16(3801),
  67220 	471:  uint16(3812),
  67221 	472:  uint16(3818),
  67222 	473:  uint16(3827),
  67223 	474:  uint16(3833),
  67224 	475:  uint16(3853),
  67225 	476:  uint16(3859),
  67226 	477:  uint16(3868),
  67227 	478:  uint16(3874),
  67228 	479:  uint16(3885),
  67229 	480:  uint16(3891),
  67230 	481:  uint16(3900),
  67231 	482:  uint16(3906),
  67232 	483:  uint16(3929),
  67233 	484:  uint16(3935),
  67234 	485:  uint16(3944),
  67235 	486:  uint16(3950),
  67236 	487:  uint16(3961),
  67237 	488:  uint16(3967),
  67238 	489:  uint16(3976),
  67239 	490:  uint16(3982),
  67240 	491:  uint16(4002),
  67241 	492:  uint16(4008),
  67242 	493:  uint16(4017),
  67243 	494:  uint16(4023),
  67244 	495:  uint16(4034),
  67245 	496:  uint16(4040),
  67246 	497:  uint16(4049),
  67247 	498:  uint16(4055),
  67248 	499:  uint16(4080),
  67249 	500:  uint16(4086),
  67250 	501:  uint16(4095),
  67251 	502:  uint16(4101),
  67252 	503:  uint16(4112),
  67253 	504:  uint16(4118),
  67254 	505:  uint16(4127),
  67255 	506:  uint16(4133),
  67256 	507:  uint16(4153),
  67257 	508:  uint16(4159),
  67258 	509:  uint16(4168),
  67259 	510:  uint16(4174),
  67260 	511:  uint16(4185),
  67261 	512:  uint16(4191),
  67262 	513:  uint16(4200),
  67263 	514:  uint16(4206),
  67264 	515:  uint16(4070),
  67265 	516:  uint16(4076),
  67266 	517:  uint16(4085),
  67267 	518:  uint16(4091),
  67268 	519:  uint16(4102),
  67269 	520:  uint16(4108),
  67270 	521:  uint16(4117),
  67271 	522:  uint16(4123),
  67272 	523:  uint16(4143),
  67273 	524:  uint16(4149),
  67274 	525:  uint16(4158),
  67275 	526:  uint16(4164),
  67276 	527:  uint16(4175),
  67277 	528:  uint16(4181),
  67278 	529:  uint16(4190),
  67279 	530:  uint16(4196),
  67280 	531:  uint16(4221),
  67281 	532:  uint16(4227),
  67282 	533:  uint16(4236),
  67283 	534:  uint16(4242),
  67284 	535:  uint16(4253),
  67285 	536:  uint16(4259),
  67286 	537:  uint16(4268),
  67287 	538:  uint16(4274),
  67288 	539:  uint16(4294),
  67289 	540:  uint16(4300),
  67290 	541:  uint16(4309),
  67291 	542:  uint16(4315),
  67292 	543:  uint16(4326),
  67293 	544:  uint16(4332),
  67294 	545:  uint16(4341),
  67295 	546:  uint16(4347),
  67296 	547:  uint16(4370),
  67297 	548:  uint16(4376),
  67298 	549:  uint16(4385),
  67299 	550:  uint16(4391),
  67300 	551:  uint16(4402),
  67301 	552:  uint16(4408),
  67302 	553:  uint16(4417),
  67303 	554:  uint16(4423),
  67304 	555:  uint16(4443),
  67305 	556:  uint16(4449),
  67306 	557:  uint16(4458),
  67307 	558:  uint16(4464),
  67308 	559:  uint16(4475),
  67309 	560:  uint16(4481),
  67310 	561:  uint16(4490),
  67311 	562:  uint16(4496),
  67312 	563:  uint16(4521),
  67313 	564:  uint16(4527),
  67314 	565:  uint16(4536),
  67315 	566:  uint16(4542),
  67316 	567:  uint16(4553),
  67317 	568:  uint16(4559),
  67318 	569:  uint16(4568),
  67319 	570:  uint16(4574),
  67320 	571:  uint16(4594),
  67321 	572:  uint16(4600),
  67322 	573:  uint16(4609),
  67323 	574:  uint16(4615),
  67324 	575:  uint16(4626),
  67325 	576:  uint16(4632),
  67326 	577:  uint16(4641),
  67327 	578:  uint16(4647),
  67328 	579:  uint16(3515),
  67329 	580:  uint16(3521),
  67330 	581:  uint16(3530),
  67331 	582:  uint16(3536),
  67332 	583:  uint16(3547),
  67333 	584:  uint16(3553),
  67334 	585:  uint16(3562),
  67335 	586:  uint16(3568),
  67336 	587:  uint16(3588),
  67337 	588:  uint16(3594),
  67338 	589:  uint16(3603),
  67339 	590:  uint16(3609),
  67340 	591:  uint16(3620),
  67341 	592:  uint16(3626),
  67342 	593:  uint16(3635),
  67343 	594:  uint16(3641),
  67344 	595:  uint16(3666),
  67345 	596:  uint16(3672),
  67346 	597:  uint16(3681),
  67347 	598:  uint16(3687),
  67348 	599:  uint16(3698),
  67349 	600:  uint16(3704),
  67350 	601:  uint16(3713),
  67351 	602:  uint16(3719),
  67352 	603:  uint16(3739),
  67353 	604:  uint16(3745),
  67354 	605:  uint16(3754),
  67355 	606:  uint16(3760),
  67356 	607:  uint16(3771),
  67357 	608:  uint16(3777),
  67358 	609:  uint16(3786),
  67359 	610:  uint16(3792),
  67360 	611:  uint16(3815),
  67361 	612:  uint16(3821),
  67362 	613:  uint16(3830),
  67363 	614:  uint16(3836),
  67364 	615:  uint16(3847),
  67365 	616:  uint16(3853),
  67366 	617:  uint16(3862),
  67367 	618:  uint16(3868),
  67368 	619:  uint16(3888),
  67369 	620:  uint16(3894),
  67370 	621:  uint16(3903),
  67371 	622:  uint16(3909),
  67372 	623:  uint16(3920),
  67373 	624:  uint16(3926),
  67374 	625:  uint16(3935),
  67375 	626:  uint16(3941),
  67376 	627:  uint16(3966),
  67377 	628:  uint16(3972),
  67378 	629:  uint16(3981),
  67379 	630:  uint16(3987),
  67380 	631:  uint16(3998),
  67381 	632:  uint16(4004),
  67382 	633:  uint16(4013),
  67383 	634:  uint16(4019),
  67384 	635:  uint16(4039),
  67385 	636:  uint16(4045),
  67386 	637:  uint16(4054),
  67387 	638:  uint16(4060),
  67388 	639:  uint16(4071),
  67389 	640:  uint16(4077),
  67390 	641:  uint16(4086),
  67391 	642:  uint16(4092),
  67392 	643:  uint16(3956),
  67393 	644:  uint16(3962),
  67394 	645:  uint16(3971),
  67395 	646:  uint16(3977),
  67396 	647:  uint16(3988),
  67397 	648:  uint16(3994),
  67398 	649:  uint16(4003),
  67399 	650:  uint16(4009),
  67400 	651:  uint16(4029),
  67401 	652:  uint16(4035),
  67402 	653:  uint16(4044),
  67403 	654:  uint16(4050),
  67404 	655:  uint16(4061),
  67405 	656:  uint16(4067),
  67406 	657:  uint16(4076),
  67407 	658:  uint16(4082),
  67408 	659:  uint16(4107),
  67409 	660:  uint16(4113),
  67410 	661:  uint16(4122),
  67411 	662:  uint16(4128),
  67412 	663:  uint16(4139),
  67413 	664:  uint16(4145),
  67414 	665:  uint16(4154),
  67415 	666:  uint16(4160),
  67416 	667:  uint16(4180),
  67417 	668:  uint16(4186),
  67418 	669:  uint16(4195),
  67419 	670:  uint16(4201),
  67420 	671:  uint16(4212),
  67421 	672:  uint16(4218),
  67422 	673:  uint16(4227),
  67423 	674:  uint16(4233),
  67424 	675:  uint16(4256),
  67425 	676:  uint16(4262),
  67426 	677:  uint16(4271),
  67427 	678:  uint16(4277),
  67428 	679:  uint16(4288),
  67429 	680:  uint16(4294),
  67430 	681:  uint16(4303),
  67431 	682:  uint16(4309),
  67432 	683:  uint16(4329),
  67433 	684:  uint16(4335),
  67434 	685:  uint16(4344),
  67435 	686:  uint16(4350),
  67436 	687:  uint16(4361),
  67437 	688:  uint16(4367),
  67438 	689:  uint16(4376),
  67439 	690:  uint16(4382),
  67440 	691:  uint16(4407),
  67441 	692:  uint16(4413),
  67442 	693:  uint16(4422),
  67443 	694:  uint16(4428),
  67444 	695:  uint16(4439),
  67445 	696:  uint16(4445),
  67446 	697:  uint16(4454),
  67447 	698:  uint16(4460),
  67448 	699:  uint16(4480),
  67449 	700:  uint16(4486),
  67450 	701:  uint16(4495),
  67451 	702:  uint16(4501),
  67452 	703:  uint16(4512),
  67453 	704:  uint16(4518),
  67454 	705:  uint16(4527),
  67455 	706:  uint16(4533),
  67456 	707:  uint16(4328),
  67457 	708:  uint16(4334),
  67458 	709:  uint16(4343),
  67459 	710:  uint16(4349),
  67460 	711:  uint16(4360),
  67461 	712:  uint16(4366),
  67462 	713:  uint16(4375),
  67463 	714:  uint16(4381),
  67464 	715:  uint16(4401),
  67465 	716:  uint16(4407),
  67466 	717:  uint16(4416),
  67467 	718:  uint16(4422),
  67468 	719:  uint16(4433),
  67469 	720:  uint16(4439),
  67470 	721:  uint16(4448),
  67471 	722:  uint16(4454),
  67472 	723:  uint16(4479),
  67473 	724:  uint16(4485),
  67474 	725:  uint16(4494),
  67475 	726:  uint16(4500),
  67476 	727:  uint16(4511),
  67477 	728:  uint16(4517),
  67478 	729:  uint16(4526),
  67479 	730:  uint16(4532),
  67480 	731:  uint16(4552),
  67481 	732:  uint16(4558),
  67482 	733:  uint16(4567),
  67483 	734:  uint16(4573),
  67484 	735:  uint16(4584),
  67485 	736:  uint16(4590),
  67486 	737:  uint16(4599),
  67487 	738:  uint16(4605),
  67488 	739:  uint16(4628),
  67489 	740:  uint16(4634),
  67490 	741:  uint16(4643),
  67491 	742:  uint16(4649),
  67492 	743:  uint16(4660),
  67493 	744:  uint16(4666),
  67494 	745:  uint16(4675),
  67495 	746:  uint16(4681),
  67496 	747:  uint16(4701),
  67497 	748:  uint16(4707),
  67498 	749:  uint16(4716),
  67499 	750:  uint16(4722),
  67500 	751:  uint16(4733),
  67501 	752:  uint16(4739),
  67502 	753:  uint16(4748),
  67503 	754:  uint16(4754),
  67504 	755:  uint16(4779),
  67505 	756:  uint16(4785),
  67506 	757:  uint16(4794),
  67507 	758:  uint16(4800),
  67508 	759:  uint16(4811),
  67509 	760:  uint16(4817),
  67510 	761:  uint16(4826),
  67511 	762:  uint16(4832),
  67512 	763:  uint16(4852),
  67513 	764:  uint16(4858),
  67514 	765:  uint16(4867),
  67515 	766:  uint16(4873),
  67516 	767:  uint16(4884),
  67517 	768:  uint16(4890),
  67518 	769:  uint16(4899),
  67519 	770:  uint16(4905),
  67520 	771:  uint16(4769),
  67521 	772:  uint16(4775),
  67522 	773:  uint16(4784),
  67523 	774:  uint16(4790),
  67524 	775:  uint16(4801),
  67525 	776:  uint16(4807),
  67526 	777:  uint16(4816),
  67527 	778:  uint16(4822),
  67528 	779:  uint16(4842),
  67529 	780:  uint16(4848),
  67530 	781:  uint16(4857),
  67531 	782:  uint16(4863),
  67532 	783:  uint16(4874),
  67533 	784:  uint16(4880),
  67534 	785:  uint16(4889),
  67535 	786:  uint16(4895),
  67536 	787:  uint16(4920),
  67537 	788:  uint16(4926),
  67538 	789:  uint16(4935),
  67539 	790:  uint16(4941),
  67540 	791:  uint16(4952),
  67541 	792:  uint16(4958),
  67542 	793:  uint16(4967),
  67543 	794:  uint16(4973),
  67544 	795:  uint16(4993),
  67545 	796:  uint16(4999),
  67546 	797:  uint16(5008),
  67547 	798:  uint16(5014),
  67548 	799:  uint16(5025),
  67549 	800:  uint16(5031),
  67550 	801:  uint16(5040),
  67551 	802:  uint16(5046),
  67552 	803:  uint16(5069),
  67553 	804:  uint16(5075),
  67554 	805:  uint16(5084),
  67555 	806:  uint16(5090),
  67556 	807:  uint16(5101),
  67557 	808:  uint16(5107),
  67558 	809:  uint16(5116),
  67559 	810:  uint16(5122),
  67560 	811:  uint16(5142),
  67561 	812:  uint16(5148),
  67562 	813:  uint16(5157),
  67563 	814:  uint16(5163),
  67564 	815:  uint16(5174),
  67565 	816:  uint16(5180),
  67566 	817:  uint16(5189),
  67567 	818:  uint16(5195),
  67568 	819:  uint16(5220),
  67569 	820:  uint16(5226),
  67570 	821:  uint16(5235),
  67571 	822:  uint16(5241),
  67572 	823:  uint16(5252),
  67573 	824:  uint16(5258),
  67574 	825:  uint16(5267),
  67575 	826:  uint16(5273),
  67576 	827:  uint16(5293),
  67577 	828:  uint16(5299),
  67578 	829:  uint16(5308),
  67579 	830:  uint16(5314),
  67580 	831:  uint16(5325),
  67581 	832:  uint16(5331),
  67582 	833:  uint16(5340),
  67583 	834:  uint16(5346),
  67584 	835:  uint16(4604),
  67585 	836:  uint16(4610),
  67586 	837:  uint16(4619),
  67587 	838:  uint16(4625),
  67588 	839:  uint16(4636),
  67589 	840:  uint16(4642),
  67590 	841:  uint16(4651),
  67591 	842:  uint16(4657),
  67592 	843:  uint16(4677),
  67593 	844:  uint16(4683),
  67594 	845:  uint16(4692),
  67595 	846:  uint16(4698),
  67596 	847:  uint16(4709),
  67597 	848:  uint16(4715),
  67598 	849:  uint16(4724),
  67599 	850:  uint16(4730),
  67600 	851:  uint16(4755),
  67601 	852:  uint16(4761),
  67602 	853:  uint16(4770),
  67603 	854:  uint16(4776),
  67604 	855:  uint16(4787),
  67605 	856:  uint16(4793),
  67606 	857:  uint16(4802),
  67607 	858:  uint16(4808),
  67608 	859:  uint16(4828),
  67609 	860:  uint16(4834),
  67610 	861:  uint16(4843),
  67611 	862:  uint16(4849),
  67612 	863:  uint16(4860),
  67613 	864:  uint16(4866),
  67614 	865:  uint16(4875),
  67615 	866:  uint16(4881),
  67616 	867:  uint16(4904),
  67617 	868:  uint16(4910),
  67618 	869:  uint16(4919),
  67619 	870:  uint16(4925),
  67620 	871:  uint16(4936),
  67621 	872:  uint16(4942),
  67622 	873:  uint16(4951),
  67623 	874:  uint16(4957),
  67624 	875:  uint16(4977),
  67625 	876:  uint16(4983),
  67626 	877:  uint16(4992),
  67627 	878:  uint16(4998),
  67628 	879:  uint16(5009),
  67629 	880:  uint16(5015),
  67630 	881:  uint16(5024),
  67631 	882:  uint16(5030),
  67632 	883:  uint16(5055),
  67633 	884:  uint16(5061),
  67634 	885:  uint16(5070),
  67635 	886:  uint16(5076),
  67636 	887:  uint16(5087),
  67637 	888:  uint16(5093),
  67638 	889:  uint16(5102),
  67639 	890:  uint16(5108),
  67640 	891:  uint16(5128),
  67641 	892:  uint16(5134),
  67642 	893:  uint16(5143),
  67643 	894:  uint16(5149),
  67644 	895:  uint16(5160),
  67645 	896:  uint16(5166),
  67646 	897:  uint16(5175),
  67647 	898:  uint16(5181),
  67648 	899:  uint16(5045),
  67649 	900:  uint16(5051),
  67650 	901:  uint16(5060),
  67651 	902:  uint16(5066),
  67652 	903:  uint16(5077),
  67653 	904:  uint16(5083),
  67654 	905:  uint16(5092),
  67655 	906:  uint16(5098),
  67656 	907:  uint16(5118),
  67657 	908:  uint16(5124),
  67658 	909:  uint16(5133),
  67659 	910:  uint16(5139),
  67660 	911:  uint16(5150),
  67661 	912:  uint16(5156),
  67662 	913:  uint16(5165),
  67663 	914:  uint16(5171),
  67664 	915:  uint16(5196),
  67665 	916:  uint16(5202),
  67666 	917:  uint16(5211),
  67667 	918:  uint16(5217),
  67668 	919:  uint16(5228),
  67669 	920:  uint16(5234),
  67670 	921:  uint16(5243),
  67671 	922:  uint16(5249),
  67672 	923:  uint16(5269),
  67673 	924:  uint16(5275),
  67674 	925:  uint16(5284),
  67675 	926:  uint16(5290),
  67676 	927:  uint16(5301),
  67677 	928:  uint16(5307),
  67678 	929:  uint16(5316),
  67679 	930:  uint16(5322),
  67680 	931:  uint16(5345),
  67681 	932:  uint16(5351),
  67682 	933:  uint16(5360),
  67683 	934:  uint16(5366),
  67684 	935:  uint16(5377),
  67685 	936:  uint16(5383),
  67686 	937:  uint16(5392),
  67687 	938:  uint16(5398),
  67688 	939:  uint16(5418),
  67689 	940:  uint16(5424),
  67690 	941:  uint16(5433),
  67691 	942:  uint16(5439),
  67692 	943:  uint16(5450),
  67693 	944:  uint16(5456),
  67694 	945:  uint16(5465),
  67695 	946:  uint16(5471),
  67696 	947:  uint16(5496),
  67697 	948:  uint16(5502),
  67698 	949:  uint16(5511),
  67699 	950:  uint16(5517),
  67700 	951:  uint16(5528),
  67701 	952:  uint16(5534),
  67702 	953:  uint16(5543),
  67703 	954:  uint16(5549),
  67704 	955:  uint16(5569),
  67705 	956:  uint16(5575),
  67706 	957:  uint16(5584),
  67707 	958:  uint16(5590),
  67708 	959:  uint16(5601),
  67709 	960:  uint16(5607),
  67710 	961:  uint16(5616),
  67711 	962:  uint16(5622),
  67712 	963:  uint16(5417),
  67713 	964:  uint16(5423),
  67714 	965:  uint16(5432),
  67715 	966:  uint16(5438),
  67716 	967:  uint16(5449),
  67717 	968:  uint16(5455),
  67718 	969:  uint16(5464),
  67719 	970:  uint16(5470),
  67720 	971:  uint16(5490),
  67721 	972:  uint16(5496),
  67722 	973:  uint16(5505),
  67723 	974:  uint16(5511),
  67724 	975:  uint16(5522),
  67725 	976:  uint16(5528),
  67726 	977:  uint16(5537),
  67727 	978:  uint16(5543),
  67728 	979:  uint16(5568),
  67729 	980:  uint16(5574),
  67730 	981:  uint16(5583),
  67731 	982:  uint16(5589),
  67732 	983:  uint16(5600),
  67733 	984:  uint16(5606),
  67734 	985:  uint16(5615),
  67735 	986:  uint16(5621),
  67736 	987:  uint16(5641),
  67737 	988:  uint16(5647),
  67738 	989:  uint16(5656),
  67739 	990:  uint16(5662),
  67740 	991:  uint16(5673),
  67741 	992:  uint16(5679),
  67742 	993:  uint16(5688),
  67743 	994:  uint16(5694),
  67744 	995:  uint16(5717),
  67745 	996:  uint16(5723),
  67746 	997:  uint16(5732),
  67747 	998:  uint16(5738),
  67748 	999:  uint16(5749),
  67749 	1000: uint16(5755),
  67750 	1001: uint16(5764),
  67751 	1002: uint16(5770),
  67752 	1003: uint16(5790),
  67753 	1004: uint16(5796),
  67754 	1005: uint16(5805),
  67755 	1006: uint16(5811),
  67756 	1007: uint16(5822),
  67757 	1008: uint16(5828),
  67758 	1009: uint16(5837),
  67759 	1010: uint16(5843),
  67760 	1011: uint16(5868),
  67761 	1012: uint16(5874),
  67762 	1013: uint16(5883),
  67763 	1014: uint16(5889),
  67764 	1015: uint16(5900),
  67765 	1016: uint16(5906),
  67766 	1017: uint16(5915),
  67767 	1018: uint16(5921),
  67768 	1019: uint16(5941),
  67769 	1020: uint16(5947),
  67770 	1021: uint16(5956),
  67771 	1022: uint16(5962),
  67772 	1023: uint16(5973),
  67773 	1024: uint16(5979),
  67774 	1025: uint16(5988),
  67775 	1026: uint16(5994),
  67776 	1027: uint16(5858),
  67777 	1028: uint16(5864),
  67778 	1029: uint16(5873),
  67779 	1030: uint16(5879),
  67780 	1031: uint16(5890),
  67781 	1032: uint16(5896),
  67782 	1033: uint16(5905),
  67783 	1034: uint16(5911),
  67784 	1035: uint16(5931),
  67785 	1036: uint16(5937),
  67786 	1037: uint16(5946),
  67787 	1038: uint16(5952),
  67788 	1039: uint16(5963),
  67789 	1040: uint16(5969),
  67790 	1041: uint16(5978),
  67791 	1042: uint16(5984),
  67792 	1043: uint16(6009),
  67793 	1044: uint16(6015),
  67794 	1045: uint16(6024),
  67795 	1046: uint16(6030),
  67796 	1047: uint16(6041),
  67797 	1048: uint16(6047),
  67798 	1049: uint16(6056),
  67799 	1050: uint16(6062),
  67800 	1051: uint16(6082),
  67801 	1052: uint16(6088),
  67802 	1053: uint16(6097),
  67803 	1054: uint16(6103),
  67804 	1055: uint16(6114),
  67805 	1056: uint16(6120),
  67806 	1057: uint16(6129),
  67807 	1058: uint16(6135),
  67808 	1059: uint16(6158),
  67809 	1060: uint16(6164),
  67810 	1061: uint16(6173),
  67811 	1062: uint16(6179),
  67812 	1063: uint16(6190),
  67813 	1064: uint16(6196),
  67814 	1065: uint16(6205),
  67815 	1066: uint16(6211),
  67816 	1067: uint16(6231),
  67817 	1068: uint16(6237),
  67818 	1069: uint16(6246),
  67819 	1070: uint16(6252),
  67820 	1071: uint16(6263),
  67821 	1072: uint16(6269),
  67822 	1073: uint16(6278),
  67823 	1074: uint16(6284),
  67824 	1075: uint16(6309),
  67825 	1076: uint16(6315),
  67826 	1077: uint16(6324),
  67827 	1078: uint16(6330),
  67828 	1079: uint16(6341),
  67829 	1080: uint16(6347),
  67830 	1081: uint16(6356),
  67831 	1082: uint16(6362),
  67832 	1083: uint16(6382),
  67833 	1084: uint16(6388),
  67834 	1085: uint16(6397),
  67835 	1086: uint16(6403),
  67836 	1087: uint16(6414),
  67837 	1088: uint16(6420),
  67838 	1089: uint16(6429),
  67839 	1090: uint16(6435),
  67840 	1091: uint16(3515),
  67841 	1092: uint16(3521),
  67842 	1093: uint16(3530),
  67843 	1094: uint16(3536),
  67844 	1095: uint16(3547),
  67845 	1096: uint16(3553),
  67846 	1097: uint16(3562),
  67847 	1098: uint16(3568),
  67848 	1099: uint16(3588),
  67849 	1100: uint16(3594),
  67850 	1101: uint16(3603),
  67851 	1102: uint16(3609),
  67852 	1103: uint16(3620),
  67853 	1104: uint16(3626),
  67854 	1105: uint16(3635),
  67855 	1106: uint16(3641),
  67856 	1107: uint16(3666),
  67857 	1108: uint16(3672),
  67858 	1109: uint16(3681),
  67859 	1110: uint16(3687),
  67860 	1111: uint16(3698),
  67861 	1112: uint16(3704),
  67862 	1113: uint16(3713),
  67863 	1114: uint16(3719),
  67864 	1115: uint16(3739),
  67865 	1116: uint16(3745),
  67866 	1117: uint16(3754),
  67867 	1118: uint16(3760),
  67868 	1119: uint16(3771),
  67869 	1120: uint16(3777),
  67870 	1121: uint16(3786),
  67871 	1122: uint16(3792),
  67872 	1123: uint16(3815),
  67873 	1124: uint16(3821),
  67874 	1125: uint16(3830),
  67875 	1126: uint16(3836),
  67876 	1127: uint16(3847),
  67877 	1128: uint16(3853),
  67878 	1129: uint16(3862),
  67879 	1130: uint16(3868),
  67880 	1131: uint16(3888),
  67881 	1132: uint16(3894),
  67882 	1133: uint16(3903),
  67883 	1134: uint16(3909),
  67884 	1135: uint16(3920),
  67885 	1136: uint16(3926),
  67886 	1137: uint16(3935),
  67887 	1138: uint16(3941),
  67888 	1139: uint16(3966),
  67889 	1140: uint16(3972),
  67890 	1141: uint16(3981),
  67891 	1142: uint16(3987),
  67892 	1143: uint16(3998),
  67893 	1144: uint16(4004),
  67894 	1145: uint16(4013),
  67895 	1146: uint16(4019),
  67896 	1147: uint16(4039),
  67897 	1148: uint16(4045),
  67898 	1149: uint16(4054),
  67899 	1150: uint16(4060),
  67900 	1151: uint16(4071),
  67901 	1152: uint16(4077),
  67902 	1153: uint16(4086),
  67903 	1154: uint16(4092),
  67904 	1155: uint16(3956),
  67905 	1156: uint16(3962),
  67906 	1157: uint16(3971),
  67907 	1158: uint16(3977),
  67908 	1159: uint16(3988),
  67909 	1160: uint16(3994),
  67910 	1161: uint16(4003),
  67911 	1162: uint16(4009),
  67912 	1163: uint16(4029),
  67913 	1164: uint16(4035),
  67914 	1165: uint16(4044),
  67915 	1166: uint16(4050),
  67916 	1167: uint16(4061),
  67917 	1168: uint16(4067),
  67918 	1169: uint16(4076),
  67919 	1170: uint16(4082),
  67920 	1171: uint16(4107),
  67921 	1172: uint16(4113),
  67922 	1173: uint16(4122),
  67923 	1174: uint16(4128),
  67924 	1175: uint16(4139),
  67925 	1176: uint16(4145),
  67926 	1177: uint16(4154),
  67927 	1178: uint16(4160),
  67928 	1179: uint16(4180),
  67929 	1180: uint16(4186),
  67930 	1181: uint16(4195),
  67931 	1182: uint16(4201),
  67932 	1183: uint16(4212),
  67933 	1184: uint16(4218),
  67934 	1185: uint16(4227),
  67935 	1186: uint16(4233),
  67936 	1187: uint16(4256),
  67937 	1188: uint16(4262),
  67938 	1189: uint16(4271),
  67939 	1190: uint16(4277),
  67940 	1191: uint16(4288),
  67941 	1192: uint16(4294),
  67942 	1193: uint16(4303),
  67943 	1194: uint16(4309),
  67944 	1195: uint16(4329),
  67945 	1196: uint16(4335),
  67946 	1197: uint16(4344),
  67947 	1198: uint16(4350),
  67948 	1199: uint16(4361),
  67949 	1200: uint16(4367),
  67950 	1201: uint16(4376),
  67951 	1202: uint16(4382),
  67952 	1203: uint16(4407),
  67953 	1204: uint16(4413),
  67954 	1205: uint16(4422),
  67955 	1206: uint16(4428),
  67956 	1207: uint16(4439),
  67957 	1208: uint16(4445),
  67958 	1209: uint16(4454),
  67959 	1210: uint16(4460),
  67960 	1211: uint16(4480),
  67961 	1212: uint16(4486),
  67962 	1213: uint16(4495),
  67963 	1214: uint16(4501),
  67964 	1215: uint16(4512),
  67965 	1216: uint16(4518),
  67966 	1217: uint16(4527),
  67967 	1218: uint16(4533),
  67968 	1219: uint16(4328),
  67969 	1220: uint16(4334),
  67970 	1221: uint16(4343),
  67971 	1222: uint16(4349),
  67972 	1223: uint16(4360),
  67973 	1224: uint16(4366),
  67974 	1225: uint16(4375),
  67975 	1226: uint16(4381),
  67976 	1227: uint16(4401),
  67977 	1228: uint16(4407),
  67978 	1229: uint16(4416),
  67979 	1230: uint16(4422),
  67980 	1231: uint16(4433),
  67981 	1232: uint16(4439),
  67982 	1233: uint16(4448),
  67983 	1234: uint16(4454),
  67984 	1235: uint16(4479),
  67985 	1236: uint16(4485),
  67986 	1237: uint16(4494),
  67987 	1238: uint16(4500),
  67988 	1239: uint16(4511),
  67989 	1240: uint16(4517),
  67990 	1241: uint16(4526),
  67991 	1242: uint16(4532),
  67992 	1243: uint16(4552),
  67993 	1244: uint16(4558),
  67994 	1245: uint16(4567),
  67995 	1246: uint16(4573),
  67996 	1247: uint16(4584),
  67997 	1248: uint16(4590),
  67998 	1249: uint16(4599),
  67999 	1250: uint16(4605),
  68000 	1251: uint16(4628),
  68001 	1252: uint16(4634),
  68002 	1253: uint16(4643),
  68003 	1254: uint16(4649),
  68004 	1255: uint16(4660),
  68005 	1256: uint16(4666),
  68006 	1257: uint16(4675),
  68007 	1258: uint16(4681),
  68008 	1259: uint16(4701),
  68009 	1260: uint16(4707),
  68010 	1261: uint16(4716),
  68011 	1262: uint16(4722),
  68012 	1263: uint16(4733),
  68013 	1264: uint16(4739),
  68014 	1265: uint16(4748),
  68015 	1266: uint16(4754),
  68016 	1267: uint16(4779),
  68017 	1268: uint16(4785),
  68018 	1269: uint16(4794),
  68019 	1270: uint16(4800),
  68020 	1271: uint16(4811),
  68021 	1272: uint16(4817),
  68022 	1273: uint16(4826),
  68023 	1274: uint16(4832),
  68024 	1275: uint16(4852),
  68025 	1276: uint16(4858),
  68026 	1277: uint16(4867),
  68027 	1278: uint16(4873),
  68028 	1279: uint16(4884),
  68029 	1280: uint16(4890),
  68030 	1281: uint16(4899),
  68031 	1282: uint16(4905),
  68032 	1283: uint16(4769),
  68033 	1284: uint16(4775),
  68034 	1285: uint16(4784),
  68035 	1286: uint16(4790),
  68036 	1287: uint16(4801),
  68037 	1288: uint16(4807),
  68038 	1289: uint16(4816),
  68039 	1290: uint16(4822),
  68040 	1291: uint16(4842),
  68041 	1292: uint16(4848),
  68042 	1293: uint16(4857),
  68043 	1294: uint16(4863),
  68044 	1295: uint16(4874),
  68045 	1296: uint16(4880),
  68046 	1297: uint16(4889),
  68047 	1298: uint16(4895),
  68048 	1299: uint16(4920),
  68049 	1300: uint16(4926),
  68050 	1301: uint16(4935),
  68051 	1302: uint16(4941),
  68052 	1303: uint16(4952),
  68053 	1304: uint16(4958),
  68054 	1305: uint16(4967),
  68055 	1306: uint16(4973),
  68056 	1307: uint16(4993),
  68057 	1308: uint16(4999),
  68058 	1309: uint16(5008),
  68059 	1310: uint16(5014),
  68060 	1311: uint16(5025),
  68061 	1312: uint16(5031),
  68062 	1313: uint16(5040),
  68063 	1314: uint16(5046),
  68064 	1315: uint16(5069),
  68065 	1316: uint16(5075),
  68066 	1317: uint16(5084),
  68067 	1318: uint16(5090),
  68068 	1319: uint16(5101),
  68069 	1320: uint16(5107),
  68070 	1321: uint16(5116),
  68071 	1322: uint16(5122),
  68072 	1323: uint16(5142),
  68073 	1324: uint16(5148),
  68074 	1325: uint16(5157),
  68075 	1326: uint16(5163),
  68076 	1327: uint16(5174),
  68077 	1328: uint16(5180),
  68078 	1329: uint16(5189),
  68079 	1330: uint16(5195),
  68080 	1331: uint16(5220),
  68081 	1332: uint16(5226),
  68082 	1333: uint16(5235),
  68083 	1334: uint16(5241),
  68084 	1335: uint16(5252),
  68085 	1336: uint16(5258),
  68086 	1337: uint16(5267),
  68087 	1338: uint16(5273),
  68088 	1339: uint16(5293),
  68089 	1340: uint16(5299),
  68090 	1341: uint16(5308),
  68091 	1342: uint16(5314),
  68092 	1343: uint16(5325),
  68093 	1344: uint16(5331),
  68094 	1345: uint16(5340),
  68095 	1346: uint16(5346),
  68096 	1347: uint16(4604),
  68097 	1348: uint16(4610),
  68098 	1349: uint16(4619),
  68099 	1350: uint16(4625),
  68100 	1351: uint16(4636),
  68101 	1352: uint16(4642),
  68102 	1353: uint16(4651),
  68103 	1354: uint16(4657),
  68104 	1355: uint16(4677),
  68105 	1356: uint16(4683),
  68106 	1357: uint16(4692),
  68107 	1358: uint16(4698),
  68108 	1359: uint16(4709),
  68109 	1360: uint16(4715),
  68110 	1361: uint16(4724),
  68111 	1362: uint16(4730),
  68112 	1363: uint16(4755),
  68113 	1364: uint16(4761),
  68114 	1365: uint16(4770),
  68115 	1366: uint16(4776),
  68116 	1367: uint16(4787),
  68117 	1368: uint16(4793),
  68118 	1369: uint16(4802),
  68119 	1370: uint16(4808),
  68120 	1371: uint16(4828),
  68121 	1372: uint16(4834),
  68122 	1373: uint16(4843),
  68123 	1374: uint16(4849),
  68124 	1375: uint16(4860),
  68125 	1376: uint16(4866),
  68126 	1377: uint16(4875),
  68127 	1378: uint16(4881),
  68128 	1379: uint16(4904),
  68129 	1380: uint16(4910),
  68130 	1381: uint16(4919),
  68131 	1382: uint16(4925),
  68132 	1383: uint16(4936),
  68133 	1384: uint16(4942),
  68134 	1385: uint16(4951),
  68135 	1386: uint16(4957),
  68136 	1387: uint16(4977),
  68137 	1388: uint16(4983),
  68138 	1389: uint16(4992),
  68139 	1390: uint16(4998),
  68140 	1391: uint16(5009),
  68141 	1392: uint16(5015),
  68142 	1393: uint16(5024),
  68143 	1394: uint16(5030),
  68144 	1395: uint16(5055),
  68145 	1396: uint16(5061),
  68146 	1397: uint16(5070),
  68147 	1398: uint16(5076),
  68148 	1399: uint16(5087),
  68149 	1400: uint16(5093),
  68150 	1401: uint16(5102),
  68151 	1402: uint16(5108),
  68152 	1403: uint16(5128),
  68153 	1404: uint16(5134),
  68154 	1405: uint16(5143),
  68155 	1406: uint16(5149),
  68156 	1407: uint16(5160),
  68157 	1408: uint16(5166),
  68158 	1409: uint16(5175),
  68159 	1410: uint16(5181),
  68160 	1411: uint16(5045),
  68161 	1412: uint16(5051),
  68162 	1413: uint16(5060),
  68163 	1414: uint16(5066),
  68164 	1415: uint16(5077),
  68165 	1416: uint16(5083),
  68166 	1417: uint16(5092),
  68167 	1418: uint16(5098),
  68168 	1419: uint16(5118),
  68169 	1420: uint16(5124),
  68170 	1421: uint16(5133),
  68171 	1422: uint16(5139),
  68172 	1423: uint16(5150),
  68173 	1424: uint16(5156),
  68174 	1425: uint16(5165),
  68175 	1426: uint16(5171),
  68176 	1427: uint16(5196),
  68177 	1428: uint16(5202),
  68178 	1429: uint16(5211),
  68179 	1430: uint16(5217),
  68180 	1431: uint16(5228),
  68181 	1432: uint16(5234),
  68182 	1433: uint16(5243),
  68183 	1434: uint16(5249),
  68184 	1435: uint16(5269),
  68185 	1436: uint16(5275),
  68186 	1437: uint16(5284),
  68187 	1438: uint16(5290),
  68188 	1439: uint16(5301),
  68189 	1440: uint16(5307),
  68190 	1441: uint16(5316),
  68191 	1442: uint16(5322),
  68192 	1443: uint16(5345),
  68193 	1444: uint16(5351),
  68194 	1445: uint16(5360),
  68195 	1446: uint16(5366),
  68196 	1447: uint16(5377),
  68197 	1448: uint16(5383),
  68198 	1449: uint16(5392),
  68199 	1450: uint16(5398),
  68200 	1451: uint16(5418),
  68201 	1452: uint16(5424),
  68202 	1453: uint16(5433),
  68203 	1454: uint16(5439),
  68204 	1455: uint16(5450),
  68205 	1456: uint16(5456),
  68206 	1457: uint16(5465),
  68207 	1458: uint16(5471),
  68208 	1459: uint16(5496),
  68209 	1460: uint16(5502),
  68210 	1461: uint16(5511),
  68211 	1462: uint16(5517),
  68212 	1463: uint16(5528),
  68213 	1464: uint16(5534),
  68214 	1465: uint16(5543),
  68215 	1466: uint16(5549),
  68216 	1467: uint16(5569),
  68217 	1468: uint16(5575),
  68218 	1469: uint16(5584),
  68219 	1470: uint16(5590),
  68220 	1471: uint16(5601),
  68221 	1472: uint16(5607),
  68222 	1473: uint16(5616),
  68223 	1474: uint16(5622),
  68224 	1475: uint16(5417),
  68225 	1476: uint16(5423),
  68226 	1477: uint16(5432),
  68227 	1478: uint16(5438),
  68228 	1479: uint16(5449),
  68229 	1480: uint16(5455),
  68230 	1481: uint16(5464),
  68231 	1482: uint16(5470),
  68232 	1483: uint16(5490),
  68233 	1484: uint16(5496),
  68234 	1485: uint16(5505),
  68235 	1486: uint16(5511),
  68236 	1487: uint16(5522),
  68237 	1488: uint16(5528),
  68238 	1489: uint16(5537),
  68239 	1490: uint16(5543),
  68240 	1491: uint16(5568),
  68241 	1492: uint16(5574),
  68242 	1493: uint16(5583),
  68243 	1494: uint16(5589),
  68244 	1495: uint16(5600),
  68245 	1496: uint16(5606),
  68246 	1497: uint16(5615),
  68247 	1498: uint16(5621),
  68248 	1499: uint16(5641),
  68249 	1500: uint16(5647),
  68250 	1501: uint16(5656),
  68251 	1502: uint16(5662),
  68252 	1503: uint16(5673),
  68253 	1504: uint16(5679),
  68254 	1505: uint16(5688),
  68255 	1506: uint16(5694),
  68256 	1507: uint16(5717),
  68257 	1508: uint16(5723),
  68258 	1509: uint16(5732),
  68259 	1510: uint16(5738),
  68260 	1511: uint16(5749),
  68261 	1512: uint16(5755),
  68262 	1513: uint16(5764),
  68263 	1514: uint16(5770),
  68264 	1515: uint16(5790),
  68265 	1516: uint16(5796),
  68266 	1517: uint16(5805),
  68267 	1518: uint16(5811),
  68268 	1519: uint16(5822),
  68269 	1520: uint16(5828),
  68270 	1521: uint16(5837),
  68271 	1522: uint16(5843),
  68272 	1523: uint16(5868),
  68273 	1524: uint16(5874),
  68274 	1525: uint16(5883),
  68275 	1526: uint16(5889),
  68276 	1527: uint16(5900),
  68277 	1528: uint16(5906),
  68278 	1529: uint16(5915),
  68279 	1530: uint16(5921),
  68280 	1531: uint16(5941),
  68281 	1532: uint16(5947),
  68282 	1533: uint16(5956),
  68283 	1534: uint16(5962),
  68284 	1535: uint16(5973),
  68285 	1536: uint16(5979),
  68286 	1537: uint16(5988),
  68287 	1538: uint16(5994),
  68288 	1539: uint16(5858),
  68289 	1540: uint16(5864),
  68290 	1541: uint16(5873),
  68291 	1542: uint16(5879),
  68292 	1543: uint16(5890),
  68293 	1544: uint16(5896),
  68294 	1545: uint16(5905),
  68295 	1546: uint16(5911),
  68296 	1547: uint16(5931),
  68297 	1548: uint16(5937),
  68298 	1549: uint16(5946),
  68299 	1550: uint16(5952),
  68300 	1551: uint16(5963),
  68301 	1552: uint16(5969),
  68302 	1553: uint16(5978),
  68303 	1554: uint16(5984),
  68304 	1555: uint16(6009),
  68305 	1556: uint16(6015),
  68306 	1557: uint16(6024),
  68307 	1558: uint16(6030),
  68308 	1559: uint16(6041),
  68309 	1560: uint16(6047),
  68310 	1561: uint16(6056),
  68311 	1562: uint16(6062),
  68312 	1563: uint16(6082),
  68313 	1564: uint16(6088),
  68314 	1565: uint16(6097),
  68315 	1566: uint16(6103),
  68316 	1567: uint16(6114),
  68317 	1568: uint16(6120),
  68318 	1569: uint16(6129),
  68319 	1570: uint16(6135),
  68320 	1571: uint16(6158),
  68321 	1572: uint16(6164),
  68322 	1573: uint16(6173),
  68323 	1574: uint16(6179),
  68324 	1575: uint16(6190),
  68325 	1576: uint16(6196),
  68326 	1577: uint16(6205),
  68327 	1578: uint16(6211),
  68328 	1579: uint16(6231),
  68329 	1580: uint16(6237),
  68330 	1581: uint16(6246),
  68331 	1582: uint16(6252),
  68332 	1583: uint16(6263),
  68333 	1584: uint16(6269),
  68334 	1585: uint16(6278),
  68335 	1586: uint16(6284),
  68336 	1587: uint16(6309),
  68337 	1588: uint16(6315),
  68338 	1589: uint16(6324),
  68339 	1590: uint16(6330),
  68340 	1591: uint16(6341),
  68341 	1592: uint16(6347),
  68342 	1593: uint16(6356),
  68343 	1594: uint16(6362),
  68344 	1595: uint16(6382),
  68345 	1596: uint16(6388),
  68346 	1597: uint16(6397),
  68347 	1598: uint16(6403),
  68348 	1599: uint16(6414),
  68349 	1600: uint16(6420),
  68350 	1601: uint16(6429),
  68351 	1602: uint16(6435),
  68352 	1603: uint16(5303),
  68353 	1604: uint16(5309),
  68354 	1605: uint16(5318),
  68355 	1606: uint16(5324),
  68356 	1607: uint16(5335),
  68357 	1608: uint16(5341),
  68358 	1609: uint16(5350),
  68359 	1610: uint16(5356),
  68360 	1611: uint16(5376),
  68361 	1612: uint16(5382),
  68362 	1613: uint16(5391),
  68363 	1614: uint16(5397),
  68364 	1615: uint16(5408),
  68365 	1616: uint16(5414),
  68366 	1617: uint16(5423),
  68367 	1618: uint16(5429),
  68368 	1619: uint16(5454),
  68369 	1620: uint16(5460),
  68370 	1621: uint16(5469),
  68371 	1622: uint16(5475),
  68372 	1623: uint16(5486),
  68373 	1624: uint16(5492),
  68374 	1625: uint16(5501),
  68375 	1626: uint16(5507),
  68376 	1627: uint16(5527),
  68377 	1628: uint16(5533),
  68378 	1629: uint16(5542),
  68379 	1630: uint16(5548),
  68380 	1631: uint16(5559),
  68381 	1632: uint16(5565),
  68382 	1633: uint16(5574),
  68383 	1634: uint16(5580),
  68384 	1635: uint16(5603),
  68385 	1636: uint16(5609),
  68386 	1637: uint16(5618),
  68387 	1638: uint16(5624),
  68388 	1639: uint16(5635),
  68389 	1640: uint16(5641),
  68390 	1641: uint16(5650),
  68391 	1642: uint16(5656),
  68392 	1643: uint16(5676),
  68393 	1644: uint16(5682),
  68394 	1645: uint16(5691),
  68395 	1646: uint16(5697),
  68396 	1647: uint16(5708),
  68397 	1648: uint16(5714),
  68398 	1649: uint16(5723),
  68399 	1650: uint16(5729),
  68400 	1651: uint16(5754),
  68401 	1652: uint16(5760),
  68402 	1653: uint16(5769),
  68403 	1654: uint16(5775),
  68404 	1655: uint16(5786),
  68405 	1656: uint16(5792),
  68406 	1657: uint16(5801),
  68407 	1658: uint16(5807),
  68408 	1659: uint16(5827),
  68409 	1660: uint16(5833),
  68410 	1661: uint16(5842),
  68411 	1662: uint16(5848),
  68412 	1663: uint16(5859),
  68413 	1664: uint16(5865),
  68414 	1665: uint16(5874),
  68415 	1666: uint16(5880),
  68416 	1667: uint16(5744),
  68417 	1668: uint16(5750),
  68418 	1669: uint16(5759),
  68419 	1670: uint16(5765),
  68420 	1671: uint16(5776),
  68421 	1672: uint16(5782),
  68422 	1673: uint16(5791),
  68423 	1674: uint16(5797),
  68424 	1675: uint16(5817),
  68425 	1676: uint16(5823),
  68426 	1677: uint16(5832),
  68427 	1678: uint16(5838),
  68428 	1679: uint16(5849),
  68429 	1680: uint16(5855),
  68430 	1681: uint16(5864),
  68431 	1682: uint16(5870),
  68432 	1683: uint16(5895),
  68433 	1684: uint16(5901),
  68434 	1685: uint16(5910),
  68435 	1686: uint16(5916),
  68436 	1687: uint16(5927),
  68437 	1688: uint16(5933),
  68438 	1689: uint16(5942),
  68439 	1690: uint16(5948),
  68440 	1691: uint16(5968),
  68441 	1692: uint16(5974),
  68442 	1693: uint16(5983),
  68443 	1694: uint16(5989),
  68444 	1695: uint16(6000),
  68445 	1696: uint16(6006),
  68446 	1697: uint16(6015),
  68447 	1698: uint16(6021),
  68448 	1699: uint16(6044),
  68449 	1700: uint16(6050),
  68450 	1701: uint16(6059),
  68451 	1702: uint16(6065),
  68452 	1703: uint16(6076),
  68453 	1704: uint16(6082),
  68454 	1705: uint16(6091),
  68455 	1706: uint16(6097),
  68456 	1707: uint16(6117),
  68457 	1708: uint16(6123),
  68458 	1709: uint16(6132),
  68459 	1710: uint16(6138),
  68460 	1711: uint16(6149),
  68461 	1712: uint16(6155),
  68462 	1713: uint16(6164),
  68463 	1714: uint16(6170),
  68464 	1715: uint16(6195),
  68465 	1716: uint16(6201),
  68466 	1717: uint16(6210),
  68467 	1718: uint16(6216),
  68468 	1719: uint16(6227),
  68469 	1720: uint16(6233),
  68470 	1721: uint16(6242),
  68471 	1722: uint16(6248),
  68472 	1723: uint16(6268),
  68473 	1724: uint16(6274),
  68474 	1725: uint16(6283),
  68475 	1726: uint16(6289),
  68476 	1727: uint16(6300),
  68477 	1728: uint16(6306),
  68478 	1729: uint16(6315),
  68479 	1730: uint16(6321),
  68480 	1731: uint16(6116),
  68481 	1732: uint16(6122),
  68482 	1733: uint16(6131),
  68483 	1734: uint16(6137),
  68484 	1735: uint16(6148),
  68485 	1736: uint16(6154),
  68486 	1737: uint16(6163),
  68487 	1738: uint16(6169),
  68488 	1739: uint16(6189),
  68489 	1740: uint16(6195),
  68490 	1741: uint16(6204),
  68491 	1742: uint16(6210),
  68492 	1743: uint16(6221),
  68493 	1744: uint16(6227),
  68494 	1745: uint16(6236),
  68495 	1746: uint16(6242),
  68496 	1747: uint16(6267),
  68497 	1748: uint16(6273),
  68498 	1749: uint16(6282),
  68499 	1750: uint16(6288),
  68500 	1751: uint16(6299),
  68501 	1752: uint16(6305),
  68502 	1753: uint16(6314),
  68503 	1754: uint16(6320),
  68504 	1755: uint16(6340),
  68505 	1756: uint16(6346),
  68506 	1757: uint16(6355),
  68507 	1758: uint16(6361),
  68508 	1759: uint16(6372),
  68509 	1760: uint16(6378),
  68510 	1761: uint16(6387),
  68511 	1762: uint16(6393),
  68512 	1763: uint16(6416),
  68513 	1764: uint16(6422),
  68514 	1765: uint16(6431),
  68515 	1766: uint16(6437),
  68516 	1767: uint16(6448),
  68517 	1768: uint16(6454),
  68518 	1769: uint16(6463),
  68519 	1770: uint16(6469),
  68520 	1771: uint16(6489),
  68521 	1772: uint16(6495),
  68522 	1773: uint16(6504),
  68523 	1774: uint16(6510),
  68524 	1775: uint16(6521),
  68525 	1776: uint16(6527),
  68526 	1777: uint16(6536),
  68527 	1778: uint16(6542),
  68528 	1779: uint16(6567),
  68529 	1780: uint16(6573),
  68530 	1781: uint16(6582),
  68531 	1782: uint16(6588),
  68532 	1783: uint16(6599),
  68533 	1784: uint16(6605),
  68534 	1785: uint16(6614),
  68535 	1786: uint16(6620),
  68536 	1787: uint16(6640),
  68537 	1788: uint16(6646),
  68538 	1789: uint16(6655),
  68539 	1790: uint16(6661),
  68540 	1791: uint16(6672),
  68541 	1792: uint16(6678),
  68542 	1793: uint16(6687),
  68543 	1794: uint16(6693),
  68544 	1795: uint16(6557),
  68545 	1796: uint16(6563),
  68546 	1797: uint16(6572),
  68547 	1798: uint16(6578),
  68548 	1799: uint16(6589),
  68549 	1800: uint16(6595),
  68550 	1801: uint16(6604),
  68551 	1802: uint16(6610),
  68552 	1803: uint16(6630),
  68553 	1804: uint16(6636),
  68554 	1805: uint16(6645),
  68555 	1806: uint16(6651),
  68556 	1807: uint16(6662),
  68557 	1808: uint16(6668),
  68558 	1809: uint16(6677),
  68559 	1810: uint16(6683),
  68560 	1811: uint16(6708),
  68561 	1812: uint16(6714),
  68562 	1813: uint16(6723),
  68563 	1814: uint16(6729),
  68564 	1815: uint16(6740),
  68565 	1816: uint16(6746),
  68566 	1817: uint16(6755),
  68567 	1818: uint16(6761),
  68568 	1819: uint16(6781),
  68569 	1820: uint16(6787),
  68570 	1821: uint16(6796),
  68571 	1822: uint16(6802),
  68572 	1823: uint16(6813),
  68573 	1824: uint16(6819),
  68574 	1825: uint16(6828),
  68575 	1826: uint16(6834),
  68576 	1827: uint16(6857),
  68577 	1828: uint16(6863),
  68578 	1829: uint16(6872),
  68579 	1830: uint16(6878),
  68580 	1831: uint16(6889),
  68581 	1832: uint16(6895),
  68582 	1833: uint16(6904),
  68583 	1834: uint16(6910),
  68584 	1835: uint16(6930),
  68585 	1836: uint16(6936),
  68586 	1837: uint16(6945),
  68587 	1838: uint16(6951),
  68588 	1839: uint16(6962),
  68589 	1840: uint16(6968),
  68590 	1841: uint16(6977),
  68591 	1842: uint16(6983),
  68592 	1843: uint16(7008),
  68593 	1844: uint16(7014),
  68594 	1845: uint16(7023),
  68595 	1846: uint16(7029),
  68596 	1847: uint16(7040),
  68597 	1848: uint16(7046),
  68598 	1849: uint16(7055),
  68599 	1850: uint16(7061),
  68600 	1851: uint16(7081),
  68601 	1852: uint16(7087),
  68602 	1853: uint16(7096),
  68603 	1854: uint16(7102),
  68604 	1855: uint16(7113),
  68605 	1856: uint16(7119),
  68606 	1857: uint16(7128),
  68607 	1858: uint16(7134),
  68608 	1859: uint16(6392),
  68609 	1860: uint16(6398),
  68610 	1861: uint16(6407),
  68611 	1862: uint16(6413),
  68612 	1863: uint16(6424),
  68613 	1864: uint16(6430),
  68614 	1865: uint16(6439),
  68615 	1866: uint16(6445),
  68616 	1867: uint16(6465),
  68617 	1868: uint16(6471),
  68618 	1869: uint16(6480),
  68619 	1870: uint16(6486),
  68620 	1871: uint16(6497),
  68621 	1872: uint16(6503),
  68622 	1873: uint16(6512),
  68623 	1874: uint16(6518),
  68624 	1875: uint16(6543),
  68625 	1876: uint16(6549),
  68626 	1877: uint16(6558),
  68627 	1878: uint16(6564),
  68628 	1879: uint16(6575),
  68629 	1880: uint16(6581),
  68630 	1881: uint16(6590),
  68631 	1882: uint16(6596),
  68632 	1883: uint16(6616),
  68633 	1884: uint16(6622),
  68634 	1885: uint16(6631),
  68635 	1886: uint16(6637),
  68636 	1887: uint16(6648),
  68637 	1888: uint16(6654),
  68638 	1889: uint16(6663),
  68639 	1890: uint16(6669),
  68640 	1891: uint16(6692),
  68641 	1892: uint16(6698),
  68642 	1893: uint16(6707),
  68643 	1894: uint16(6713),
  68644 	1895: uint16(6724),
  68645 	1896: uint16(6730),
  68646 	1897: uint16(6739),
  68647 	1898: uint16(6745),
  68648 	1899: uint16(6765),
  68649 	1900: uint16(6771),
  68650 	1901: uint16(6780),
  68651 	1902: uint16(6786),
  68652 	1903: uint16(6797),
  68653 	1904: uint16(6803),
  68654 	1905: uint16(6812),
  68655 	1906: uint16(6818),
  68656 	1907: uint16(6843),
  68657 	1908: uint16(6849),
  68658 	1909: uint16(6858),
  68659 	1910: uint16(6864),
  68660 	1911: uint16(6875),
  68661 	1912: uint16(6881),
  68662 	1913: uint16(6890),
  68663 	1914: uint16(6896),
  68664 	1915: uint16(6916),
  68665 	1916: uint16(6922),
  68666 	1917: uint16(6931),
  68667 	1918: uint16(6937),
  68668 	1919: uint16(6948),
  68669 	1920: uint16(6954),
  68670 	1921: uint16(6963),
  68671 	1922: uint16(6969),
  68672 	1923: uint16(6833),
  68673 	1924: uint16(6839),
  68674 	1925: uint16(6848),
  68675 	1926: uint16(6854),
  68676 	1927: uint16(6865),
  68677 	1928: uint16(6871),
  68678 	1929: uint16(6880),
  68679 	1930: uint16(6886),
  68680 	1931: uint16(6906),
  68681 	1932: uint16(6912),
  68682 	1933: uint16(6921),
  68683 	1934: uint16(6927),
  68684 	1935: uint16(6938),
  68685 	1936: uint16(6944),
  68686 	1937: uint16(6953),
  68687 	1938: uint16(6959),
  68688 	1939: uint16(6984),
  68689 	1940: uint16(6990),
  68690 	1941: uint16(6999),
  68691 	1942: uint16(7005),
  68692 	1943: uint16(7016),
  68693 	1944: uint16(7022),
  68694 	1945: uint16(7031),
  68695 	1946: uint16(7037),
  68696 	1947: uint16(7057),
  68697 	1948: uint16(7063),
  68698 	1949: uint16(7072),
  68699 	1950: uint16(7078),
  68700 	1951: uint16(7089),
  68701 	1952: uint16(7095),
  68702 	1953: uint16(7104),
  68703 	1954: uint16(7110),
  68704 	1955: uint16(7133),
  68705 	1956: uint16(7139),
  68706 	1957: uint16(7148),
  68707 	1958: uint16(7154),
  68708 	1959: uint16(7165),
  68709 	1960: uint16(7171),
  68710 	1961: uint16(7180),
  68711 	1962: uint16(7186),
  68712 	1963: uint16(7206),
  68713 	1964: uint16(7212),
  68714 	1965: uint16(7221),
  68715 	1966: uint16(7227),
  68716 	1967: uint16(7238),
  68717 	1968: uint16(7244),
  68718 	1969: uint16(7253),
  68719 	1970: uint16(7259),
  68720 	1971: uint16(7284),
  68721 	1972: uint16(7290),
  68722 	1973: uint16(7299),
  68723 	1974: uint16(7305),
  68724 	1975: uint16(7316),
  68725 	1976: uint16(7322),
  68726 	1977: uint16(7331),
  68727 	1978: uint16(7337),
  68728 	1979: uint16(7357),
  68729 	1980: uint16(7363),
  68730 	1981: uint16(7372),
  68731 	1982: uint16(7378),
  68732 	1983: uint16(7389),
  68733 	1984: uint16(7395),
  68734 	1985: uint16(7404),
  68735 	1986: uint16(7410),
  68736 	1987: uint16(7205),
  68737 	1988: uint16(7211),
  68738 	1989: uint16(7220),
  68739 	1990: uint16(7226),
  68740 	1991: uint16(7237),
  68741 	1992: uint16(7243),
  68742 	1993: uint16(7252),
  68743 	1994: uint16(7258),
  68744 	1995: uint16(7278),
  68745 	1996: uint16(7284),
  68746 	1997: uint16(7293),
  68747 	1998: uint16(7299),
  68748 	1999: uint16(7310),
  68749 	2000: uint16(7316),
  68750 	2001: uint16(7325),
  68751 	2002: uint16(7331),
  68752 	2003: uint16(7356),
  68753 	2004: uint16(7362),
  68754 	2005: uint16(7371),
  68755 	2006: uint16(7377),
  68756 	2007: uint16(7388),
  68757 	2008: uint16(7394),
  68758 	2009: uint16(7403),
  68759 	2010: uint16(7409),
  68760 	2011: uint16(7429),
  68761 	2012: uint16(7435),
  68762 	2013: uint16(7444),
  68763 	2014: uint16(7450),
  68764 	2015: uint16(7461),
  68765 	2016: uint16(7467),
  68766 	2017: uint16(7476),
  68767 	2018: uint16(7482),
  68768 	2019: uint16(7505),
  68769 	2020: uint16(7511),
  68770 	2021: uint16(7520),
  68771 	2022: uint16(7526),
  68772 	2023: uint16(7537),
  68773 	2024: uint16(7543),
  68774 	2025: uint16(7552),
  68775 	2026: uint16(7558),
  68776 	2027: uint16(7578),
  68777 	2028: uint16(7584),
  68778 	2029: uint16(7593),
  68779 	2030: uint16(7599),
  68780 	2031: uint16(7610),
  68781 	2032: uint16(7616),
  68782 	2033: uint16(7625),
  68783 	2034: uint16(7631),
  68784 	2035: uint16(7656),
  68785 	2036: uint16(7662),
  68786 	2037: uint16(7671),
  68787 	2038: uint16(7677),
  68788 	2039: uint16(7688),
  68789 	2040: uint16(7694),
  68790 	2041: uint16(7703),
  68791 	2042: uint16(7709),
  68792 	2043: uint16(7729),
  68793 	2044: uint16(7735),
  68794 	2045: uint16(7744),
  68795 	2046: uint16(7750),
  68796 	2047: uint16(7761),
  68797 }
  68798 
  68799 var VP8Mean16x4 VP8MeanMetric
  68800 
  68801 var VP8PredChroma8 [7]VP8PredFunc
  68802 
  68803 var VP8PredLuma16 [7]VP8PredFunc
  68804 
  68805 var VP8PredLuma4 [10]VP8PredFunc
  68806 
  68807 var VP8SSE16x16 VP8Metric
  68808 
  68809 var VP8SSE16x8 VP8Metric
  68810 
  68811 var VP8SSE4x4 VP8Metric
  68812 
  68813 var VP8SSE8x8 VP8Metric
  68814 
  68815 //------------------------------------------------------------------------------
  68816 
  68817 var VP8SSIMGet VP8SSIMGetFunc
  68818 
  68819 var VP8SSIMGetClipped VP8SSIMGetClippedFunc
  68820 
  68821 //------------------------------------------------------------------------------
  68822 // Quantize
  68823 
  68824 // Layout:
  68825 // +----+----+
  68826 // |YYYY|UUVV| 0
  68827 // |YYYY|UUVV| 4
  68828 // |YYYY|....| 8
  68829 // |YYYY|....| 12
  68830 // +----+----+
  68831 
  68832 var VP8Scan = [16]uint16_t{
  68833 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68834 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68835 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68836 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68837 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68838 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68839 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68840 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68841 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68842 	10: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68843 	11: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68844 	12: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68845 	13: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68846 	14: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68847 	15: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68848 }
  68849 
  68850 var VP8SetResidualCoeffs VP8SetResidualCoeffsFunc
  68851 
  68852 var VP8SimpleHFilter16 VP8SimpleFilterFunc
  68853 
  68854 var VP8SimpleHFilter16i VP8SimpleFilterFunc
  68855 
  68856 var VP8SimpleVFilter16 VP8SimpleFilterFunc
  68857 
  68858 var VP8SimpleVFilter16i VP8SimpleFilterFunc
  68859 
  68860 var VP8TDisto16x16 VP8WMetric
  68861 
  68862 var VP8TDisto4x4 VP8WMetric
  68863 
  68864 //------------------------------------------------------------------------------
  68865 
  68866 var VP8Transform VP8DecIdct2
  68867 
  68868 var VP8TransformAC3 VP8DecIdct
  68869 
  68870 var VP8TransformDC VP8DecIdct
  68871 
  68872 var VP8TransformDCUV VP8DecIdct
  68873 
  68874 var VP8TransformUV VP8DecIdct
  68875 
  68876 var VP8TransformWHT VP8WHT
  68877 
  68878 var VP8UVModeOffsets = [4]uint16_t{
  68879 	0: libc.Uint16FromInt32(libc.Int32FromInt32(2) * libc.Int32FromInt32(16) * libc.Int32FromInt32(BPS)),
  68880 	1: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(1)*libc.Int32FromInt32(16)),
  68881 	2: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68882 	3: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(1)*libc.Int32FromInt32(16)),
  68883 }
  68884 
  68885 var VP8VFilter16 VP8LumaFilterFunc
  68886 
  68887 var VP8VFilter16i VP8LumaFilterFunc
  68888 
  68889 var VP8VFilter8 VP8ChromaFilterFunc
  68890 
  68891 var VP8VFilter8i VP8ChromaFilterFunc
  68892 
  68893 var VP8kabs0 = uintptr(unsafe.Pointer(&abs0)) + 255
  68894 
  68895 var VP8kclip1 = uintptr(unsafe.Pointer(&clip11)) + 255
  68896 
  68897 var VP8ksclip1 = uintptr(unsafe.Pointer(&sclip1)) + 1020
  68898 
  68899 var VP8ksclip2 = uintptr(unsafe.Pointer(&sclip2)) + 112
  68900 
  68901 var WebPAlphaReplace uintptr
  68902 
  68903 var WebPApplyAlphaMultiply uintptr
  68904 
  68905 var WebPApplyAlphaMultiply4444 uintptr
  68906 
  68907 var WebPConvertARGBToUV uintptr
  68908 
  68909 var WebPConvertARGBToY uintptr
  68910 
  68911 var WebPConvertBGR24ToY uintptr
  68912 
  68913 //-----------------------------------------------------------------------------
  68914 
  68915 var WebPConvertRGB24ToY uintptr
  68916 
  68917 var WebPConvertRGBA32ToUV uintptr
  68918 
  68919 var WebPDispatchAlpha uintptr
  68920 
  68921 var WebPDispatchAlphaToGreen uintptr
  68922 
  68923 var WebPExtractAlpha uintptr
  68924 
  68925 var WebPExtractGreen uintptr
  68926 
  68927 //------------------------------------------------------------------------------
  68928 // Init function
  68929 
  68930 var WebPFilters [4]WebPFilterFunc
  68931 
  68932 var WebPHasAlpha32b uintptr
  68933 
  68934 var WebPHasAlpha8b uintptr
  68935 
  68936 var WebPMultARGBRow uintptr
  68937 
  68938 var WebPMultRow uintptr
  68939 
  68940 var WebPPackRGB uintptr
  68941 
  68942 var WebPRescalerExportRowExpand WebPRescalerExportRowFunc
  68943 
  68944 var WebPRescalerExportRowShrink WebPRescalerExportRowFunc
  68945 
  68946 //------------------------------------------------------------------------------
  68947 
  68948 var WebPRescalerImportRowExpand WebPRescalerImportRowFunc
  68949 
  68950 var WebPRescalerImportRowShrink WebPRescalerImportRowFunc
  68951 
  68952 //-----------------------------------------------------------------------------
  68953 // Main call
  68954 
  68955 var WebPSamplers [13]WebPSamplerRowFunc
  68956 
  68957 var WebPUnfilters [4]WebPUnfilterFunc
  68958 
  68959 // Copyright 2010 Google Inc. All Rights Reserved.
  68960 //
  68961 // Use of this source code is governed by a BSD-style license
  68962 // that can be found in the COPYING file in the root of the source
  68963 // tree. An additional intellectual property rights grant can be found
  68964 // in the file PATENTS. All contributing project authors may
  68965 // be found in the AUTHORS file in the root of the source tree.
  68966 // -----------------------------------------------------------------------------
  68967 //
  68968 //  Main decoding functions for WebP images.
  68969 //
  68970 // Author: Skal (pascal.massimino@gmail.com)
  68971 
  68972 //------------------------------------------------------------------------------
  68973 // Fancy upsampler
  68974 
  68975 // C documentation
  68976 //
  68977 //	// Fancy upsampling functions to convert YUV to RGB
  68978 var WebPUpsamplers [13]WebPUpsampleLinePairFunc
  68979 
  68980 var WebPYUV444Converters [13]WebPYUV444Converter
  68981 
  68982 // Copyright 2012 Google Inc. All Rights Reserved.
  68983 //
  68984 // Use of this source code is governed by a BSD-style license
  68985 // that can be found in the COPYING file in the root of the source
  68986 // tree. An additional intellectual property rights grant can be found
  68987 // in the file PATENTS. All contributing project authors may
  68988 // be found in the AUTHORS file in the root of the source tree.
  68989 // -----------------------------------------------------------------------------
  68990 //
  68991 // Misc. common utility functions
  68992 //
  68993 // Authors: Skal (pascal.massimino@gmail.com)
  68994 //          Urvang (urvang@google.com)
  68995 
  68996 // Copyright 2012 Google Inc. All Rights Reserved.
  68997 //
  68998 // Use of this source code is governed by a BSD-style license
  68999 // that can be found in the COPYING file in the root of the source
  69000 // tree. An additional intellectual property rights grant can be found
  69001 // in the file PATENTS. All contributing project authors may
  69002 // be found in the AUTHORS file in the root of the source tree.
  69003 // -----------------------------------------------------------------------------
  69004 //
  69005 //  Internal header for constants related to WebP file format.
  69006 //
  69007 // Author: Urvang (urvang@google.com)
  69008 
  69009 // Copyright 2010 Google Inc. All Rights Reserved.
  69010 //
  69011 // Use of this source code is governed by a BSD-style license
  69012 // that can be found in the COPYING file in the root of the source
  69013 // tree. An additional intellectual property rights grant can be found
  69014 // in the file PATENTS. All contributing project authors may
  69015 // be found in the AUTHORS file in the root of the source tree.
  69016 // -----------------------------------------------------------------------------
  69017 //
  69018 //  Common types + memory wrappers
  69019 //
  69020 // Author: Skal (pascal.massimino@gmail.com)
  69021 
  69022 // C documentation
  69023 //
  69024 //	// lookup table for small values of log2(int) * (1 << LOG_2_PRECISION_BITS).
  69025 //	// Obtained in Python with:
  69026 //	// a = [ str(round((1<<23)*math.log2(i))) if i else "0" for i in range(256)]
  69027 //	// print(',\n'.join(['  '+','.join(v)
  69028 //	//       for v in batched([i.rjust(9) for i in a],7)]))
  69029 var kLog2Table = [256]uint32_t{
  69030 	2:   uint32(8388608),
  69031 	3:   uint32(13295629),
  69032 	4:   uint32(16777216),
  69033 	5:   uint32(19477745),
  69034 	6:   uint32(21684237),
  69035 	7:   uint32(23549800),
  69036 	8:   uint32(25165824),
  69037 	9:   uint32(26591258),
  69038 	10:  uint32(27866353),
  69039 	11:  uint32(29019816),
  69040 	12:  uint32(30072845),
  69041 	13:  uint32(31041538),
  69042 	14:  uint32(31938408),
  69043 	15:  uint32(32773374),
  69044 	16:  uint32(33554432),
  69045 	17:  uint32(34288123),
  69046 	18:  uint32(34979866),
  69047 	19:  uint32(35634199),
  69048 	20:  uint32(36254961),
  69049 	21:  uint32(36845429),
  69050 	22:  uint32(37408424),
  69051 	23:  uint32(37946388),
  69052 	24:  uint32(38461453),
  69053 	25:  uint32(38955489),
  69054 	26:  uint32(39430146),
  69055 	27:  uint32(39886887),
  69056 	28:  uint32(40327016),
  69057 	29:  uint32(40751698),
  69058 	30:  uint32(41161982),
  69059 	31:  uint32(41558811),
  69060 	32:  uint32(41943040),
  69061 	33:  uint32(42315445),
  69062 	34:  uint32(42676731),
  69063 	35:  uint32(43027545),
  69064 	36:  uint32(43368474),
  69065 	37:  uint32(43700062),
  69066 	38:  uint32(44022807),
  69067 	39:  uint32(44337167),
  69068 	40:  uint32(44643569),
  69069 	41:  uint32(44942404),
  69070 	42:  uint32(45234037),
  69071 	43:  uint32(45518808),
  69072 	44:  uint32(45797032),
  69073 	45:  uint32(46069003),
  69074 	46:  uint32(46334996),
  69075 	47:  uint32(46595268),
  69076 	48:  uint32(46850061),
  69077 	49:  uint32(47099600),
  69078 	50:  uint32(47344097),
  69079 	51:  uint32(47583753),
  69080 	52:  uint32(47818754),
  69081 	53:  uint32(48049279),
  69082 	54:  uint32(48275495),
  69083 	55:  uint32(48497560),
  69084 	56:  uint32(48715624),
  69085 	57:  uint32(48929828),
  69086 	58:  uint32(49140306),
  69087 	59:  uint32(49347187),
  69088 	60:  uint32(49550590),
  69089 	61:  uint32(49750631),
  69090 	62:  uint32(49947419),
  69091 	63:  uint32(50141058),
  69092 	64:  uint32(50331648),
  69093 	65:  uint32(50519283),
  69094 	66:  uint32(50704053),
  69095 	67:  uint32(50886044),
  69096 	68:  uint32(51065339),
  69097 	69:  uint32(51242017),
  69098 	70:  uint32(51416153),
  69099 	71:  uint32(51587818),
  69100 	72:  uint32(51757082),
  69101 	73:  uint32(51924012),
  69102 	74:  uint32(52088670),
  69103 	75:  uint32(52251118),
  69104 	76:  uint32(52411415),
  69105 	77:  uint32(52569616),
  69106 	78:  uint32(52725775),
  69107 	79:  uint32(52879946),
  69108 	80:  uint32(53032177),
  69109 	81:  uint32(53182516),
  69110 	82:  uint32(53331012),
  69111 	83:  uint32(53477707),
  69112 	84:  uint32(53622645),
  69113 	85:  uint32(53765868),
  69114 	86:  uint32(53907416),
  69115 	87:  uint32(54047327),
  69116 	88:  uint32(54185640),
  69117 	89:  uint32(54322389),
  69118 	90:  uint32(54457611),
  69119 	91:  uint32(54591338),
  69120 	92:  uint32(54723604),
  69121 	93:  uint32(54854440),
  69122 	94:  uint32(54983876),
  69123 	95:  uint32(55111943),
  69124 	96:  uint32(55238669),
  69125 	97:  uint32(55364082),
  69126 	98:  uint32(55488208),
  69127 	99:  uint32(55611074),
  69128 	100: uint32(55732705),
  69129 	101: uint32(55853126),
  69130 	102: uint32(55972361),
  69131 	103: uint32(56090432),
  69132 	104: uint32(56207362),
  69133 	105: uint32(56323174),
  69134 	106: uint32(56437887),
  69135 	107: uint32(56551524),
  69136 	108: uint32(56664103),
  69137 	109: uint32(56775645),
  69138 	110: uint32(56886168),
  69139 	111: uint32(56995691),
  69140 	112: uint32(57104232),
  69141 	113: uint32(57211808),
  69142 	114: uint32(57318436),
  69143 	115: uint32(57424133),
  69144 	116: uint32(57528914),
  69145 	117: uint32(57632796),
  69146 	118: uint32(57735795),
  69147 	119: uint32(57837923),
  69148 	120: uint32(57939198),
  69149 	121: uint32(58039632),
  69150 	122: uint32(58139239),
  69151 	123: uint32(58238033),
  69152 	124: uint32(58336027),
  69153 	125: uint32(58433234),
  69154 	126: uint32(58529666),
  69155 	127: uint32(58625336),
  69156 	128: uint32(58720256),
  69157 	129: uint32(58814437),
  69158 	130: uint32(58907891),
  69159 	131: uint32(59000628),
  69160 	132: uint32(59092661),
  69161 	133: uint32(59183999),
  69162 	134: uint32(59274652),
  69163 	135: uint32(59364632),
  69164 	136: uint32(59453947),
  69165 	137: uint32(59542609),
  69166 	138: uint32(59630625),
  69167 	139: uint32(59718006),
  69168 	140: uint32(59804761),
  69169 	141: uint32(59890898),
  69170 	142: uint32(59976426),
  69171 	143: uint32(60061354),
  69172 	144: uint32(60145690),
  69173 	145: uint32(60229443),
  69174 	146: uint32(60312620),
  69175 	147: uint32(60395229),
  69176 	148: uint32(60477278),
  69177 	149: uint32(60558775),
  69178 	150: uint32(60639726),
  69179 	151: uint32(60720140),
  69180 	152: uint32(60800023),
  69181 	153: uint32(60879382),
  69182 	154: uint32(60958224),
  69183 	155: uint32(61036555),
  69184 	156: uint32(61114383),
  69185 	157: uint32(61191714),
  69186 	158: uint32(61268554),
  69187 	159: uint32(61344908),
  69188 	160: uint32(61420785),
  69189 	161: uint32(61496188),
  69190 	162: uint32(61571124),
  69191 	163: uint32(61645600),
  69192 	164: uint32(61719620),
  69193 	165: uint32(61793189),
  69194 	166: uint32(61866315),
  69195 	167: uint32(61939001),
  69196 	168: uint32(62011253),
  69197 	169: uint32(62083076),
  69198 	170: uint32(62154476),
  69199 	171: uint32(62225457),
  69200 	172: uint32(62296024),
  69201 	173: uint32(62366182),
  69202 	174: uint32(62435935),
  69203 	175: uint32(62505289),
  69204 	176: uint32(62574248),
  69205 	177: uint32(62642816),
  69206 	178: uint32(62710997),
  69207 	179: uint32(62778797),
  69208 	180: uint32(62846219),
  69209 	181: uint32(62913267),
  69210 	182: uint32(62979946),
  69211 	183: uint32(63046260),
  69212 	184: uint32(63112212),
  69213 	185: uint32(63177807),
  69214 	186: uint32(63243048),
  69215 	187: uint32(63307939),
  69216 	188: uint32(63372484),
  69217 	189: uint32(63436687),
  69218 	190: uint32(63500551),
  69219 	191: uint32(63564080),
  69220 	192: uint32(63627277),
  69221 	193: uint32(63690146),
  69222 	194: uint32(63752690),
  69223 	195: uint32(63814912),
  69224 	196: uint32(63876816),
  69225 	197: uint32(63938405),
  69226 	198: uint32(63999682),
  69227 	199: uint32(64060650),
  69228 	200: uint32(64121313),
  69229 	201: uint32(64181673),
  69230 	202: uint32(64241734),
  69231 	203: uint32(64301498),
  69232 	204: uint32(64360969),
  69233 	205: uint32(64420148),
  69234 	206: uint32(64479040),
  69235 	207: uint32(64537646),
  69236 	208: uint32(64595970),
  69237 	209: uint32(64654014),
  69238 	210: uint32(64711782),
  69239 	211: uint32(64769274),
  69240 	212: uint32(64826495),
  69241 	213: uint32(64883447),
  69242 	214: uint32(64940132),
  69243 	215: uint32(64996553),
  69244 	216: uint32(65052711),
  69245 	217: uint32(65108611),
  69246 	218: uint32(65164253),
  69247 	219: uint32(65219641),
  69248 	220: uint32(65274776),
  69249 	221: uint32(65329662),
  69250 	222: uint32(65384299),
  69251 	223: uint32(65438691),
  69252 	224: uint32(65492840),
  69253 	225: uint32(65546747),
  69254 	226: uint32(65600416),
  69255 	227: uint32(65653847),
  69256 	228: uint32(65707044),
  69257 	229: uint32(65760008),
  69258 	230: uint32(65812741),
  69259 	231: uint32(65865245),
  69260 	232: uint32(65917522),
  69261 	233: uint32(65969575),
  69262 	234: uint32(66021404),
  69263 	235: uint32(66073013),
  69264 	236: uint32(66124403),
  69265 	237: uint32(66175575),
  69266 	238: uint32(66226531),
  69267 	239: uint32(66277275),
  69268 	240: uint32(66327806),
  69269 	241: uint32(66378127),
  69270 	242: uint32(66428240),
  69271 	243: uint32(66478146),
  69272 	244: uint32(66527847),
  69273 	245: uint32(66577345),
  69274 	246: uint32(66626641),
  69275 	247: uint32(66675737),
  69276 	248: uint32(66724635),
  69277 	249: uint32(66773336),
  69278 	250: uint32(66821842),
  69279 	251: uint32(66870154),
  69280 	252: uint32(66918274),
  69281 	253: uint32(66966204),
  69282 	254: uint32(67013944),
  69283 	255: uint32(67061497),
  69284 }
  69285 
  69286 var kPrefixEncodeCode = [512]VP8LPrefixCode{
  69287 	0: {},
  69288 	1: {},
  69289 	2: {
  69290 		Fcode: int8(1),
  69291 	},
  69292 	3: {
  69293 		Fcode: int8(2),
  69294 	},
  69295 	4: {
  69296 		Fcode: int8(3),
  69297 	},
  69298 	5: {
  69299 		Fcode:       int8(4),
  69300 		Fextra_bits: int8(1),
  69301 	},
  69302 	6: {
  69303 		Fcode:       int8(4),
  69304 		Fextra_bits: int8(1),
  69305 	},
  69306 	7: {
  69307 		Fcode:       int8(5),
  69308 		Fextra_bits: int8(1),
  69309 	},
  69310 	8: {
  69311 		Fcode:       int8(5),
  69312 		Fextra_bits: int8(1),
  69313 	},
  69314 	9: {
  69315 		Fcode:       int8(6),
  69316 		Fextra_bits: int8(2),
  69317 	},
  69318 	10: {
  69319 		Fcode:       int8(6),
  69320 		Fextra_bits: int8(2),
  69321 	},
  69322 	11: {
  69323 		Fcode:       int8(6),
  69324 		Fextra_bits: int8(2),
  69325 	},
  69326 	12: {
  69327 		Fcode:       int8(6),
  69328 		Fextra_bits: int8(2),
  69329 	},
  69330 	13: {
  69331 		Fcode:       int8(7),
  69332 		Fextra_bits: int8(2),
  69333 	},
  69334 	14: {
  69335 		Fcode:       int8(7),
  69336 		Fextra_bits: int8(2),
  69337 	},
  69338 	15: {
  69339 		Fcode:       int8(7),
  69340 		Fextra_bits: int8(2),
  69341 	},
  69342 	16: {
  69343 		Fcode:       int8(7),
  69344 		Fextra_bits: int8(2),
  69345 	},
  69346 	17: {
  69347 		Fcode:       int8(8),
  69348 		Fextra_bits: int8(3),
  69349 	},
  69350 	18: {
  69351 		Fcode:       int8(8),
  69352 		Fextra_bits: int8(3),
  69353 	},
  69354 	19: {
  69355 		Fcode:       int8(8),
  69356 		Fextra_bits: int8(3),
  69357 	},
  69358 	20: {
  69359 		Fcode:       int8(8),
  69360 		Fextra_bits: int8(3),
  69361 	},
  69362 	21: {
  69363 		Fcode:       int8(8),
  69364 		Fextra_bits: int8(3),
  69365 	},
  69366 	22: {
  69367 		Fcode:       int8(8),
  69368 		Fextra_bits: int8(3),
  69369 	},
  69370 	23: {
  69371 		Fcode:       int8(8),
  69372 		Fextra_bits: int8(3),
  69373 	},
  69374 	24: {
  69375 		Fcode:       int8(8),
  69376 		Fextra_bits: int8(3),
  69377 	},
  69378 	25: {
  69379 		Fcode:       int8(9),
  69380 		Fextra_bits: int8(3),
  69381 	},
  69382 	26: {
  69383 		Fcode:       int8(9),
  69384 		Fextra_bits: int8(3),
  69385 	},
  69386 	27: {
  69387 		Fcode:       int8(9),
  69388 		Fextra_bits: int8(3),
  69389 	},
  69390 	28: {
  69391 		Fcode:       int8(9),
  69392 		Fextra_bits: int8(3),
  69393 	},
  69394 	29: {
  69395 		Fcode:       int8(9),
  69396 		Fextra_bits: int8(3),
  69397 	},
  69398 	30: {
  69399 		Fcode:       int8(9),
  69400 		Fextra_bits: int8(3),
  69401 	},
  69402 	31: {
  69403 		Fcode:       int8(9),
  69404 		Fextra_bits: int8(3),
  69405 	},
  69406 	32: {
  69407 		Fcode:       int8(9),
  69408 		Fextra_bits: int8(3),
  69409 	},
  69410 	33: {
  69411 		Fcode:       int8(10),
  69412 		Fextra_bits: int8(4),
  69413 	},
  69414 	34: {
  69415 		Fcode:       int8(10),
  69416 		Fextra_bits: int8(4),
  69417 	},
  69418 	35: {
  69419 		Fcode:       int8(10),
  69420 		Fextra_bits: int8(4),
  69421 	},
  69422 	36: {
  69423 		Fcode:       int8(10),
  69424 		Fextra_bits: int8(4),
  69425 	},
  69426 	37: {
  69427 		Fcode:       int8(10),
  69428 		Fextra_bits: int8(4),
  69429 	},
  69430 	38: {
  69431 		Fcode:       int8(10),
  69432 		Fextra_bits: int8(4),
  69433 	},
  69434 	39: {
  69435 		Fcode:       int8(10),
  69436 		Fextra_bits: int8(4),
  69437 	},
  69438 	40: {
  69439 		Fcode:       int8(10),
  69440 		Fextra_bits: int8(4),
  69441 	},
  69442 	41: {
  69443 		Fcode:       int8(10),
  69444 		Fextra_bits: int8(4),
  69445 	},
  69446 	42: {
  69447 		Fcode:       int8(10),
  69448 		Fextra_bits: int8(4),
  69449 	},
  69450 	43: {
  69451 		Fcode:       int8(10),
  69452 		Fextra_bits: int8(4),
  69453 	},
  69454 	44: {
  69455 		Fcode:       int8(10),
  69456 		Fextra_bits: int8(4),
  69457 	},
  69458 	45: {
  69459 		Fcode:       int8(10),
  69460 		Fextra_bits: int8(4),
  69461 	},
  69462 	46: {
  69463 		Fcode:       int8(10),
  69464 		Fextra_bits: int8(4),
  69465 	},
  69466 	47: {
  69467 		Fcode:       int8(10),
  69468 		Fextra_bits: int8(4),
  69469 	},
  69470 	48: {
  69471 		Fcode:       int8(10),
  69472 		Fextra_bits: int8(4),
  69473 	},
  69474 	49: {
  69475 		Fcode:       int8(11),
  69476 		Fextra_bits: int8(4),
  69477 	},
  69478 	50: {
  69479 		Fcode:       int8(11),
  69480 		Fextra_bits: int8(4),
  69481 	},
  69482 	51: {
  69483 		Fcode:       int8(11),
  69484 		Fextra_bits: int8(4),
  69485 	},
  69486 	52: {
  69487 		Fcode:       int8(11),
  69488 		Fextra_bits: int8(4),
  69489 	},
  69490 	53: {
  69491 		Fcode:       int8(11),
  69492 		Fextra_bits: int8(4),
  69493 	},
  69494 	54: {
  69495 		Fcode:       int8(11),
  69496 		Fextra_bits: int8(4),
  69497 	},
  69498 	55: {
  69499 		Fcode:       int8(11),
  69500 		Fextra_bits: int8(4),
  69501 	},
  69502 	56: {
  69503 		Fcode:       int8(11),
  69504 		Fextra_bits: int8(4),
  69505 	},
  69506 	57: {
  69507 		Fcode:       int8(11),
  69508 		Fextra_bits: int8(4),
  69509 	},
  69510 	58: {
  69511 		Fcode:       int8(11),
  69512 		Fextra_bits: int8(4),
  69513 	},
  69514 	59: {
  69515 		Fcode:       int8(11),
  69516 		Fextra_bits: int8(4),
  69517 	},
  69518 	60: {
  69519 		Fcode:       int8(11),
  69520 		Fextra_bits: int8(4),
  69521 	},
  69522 	61: {
  69523 		Fcode:       int8(11),
  69524 		Fextra_bits: int8(4),
  69525 	},
  69526 	62: {
  69527 		Fcode:       int8(11),
  69528 		Fextra_bits: int8(4),
  69529 	},
  69530 	63: {
  69531 		Fcode:       int8(11),
  69532 		Fextra_bits: int8(4),
  69533 	},
  69534 	64: {
  69535 		Fcode:       int8(11),
  69536 		Fextra_bits: int8(4),
  69537 	},
  69538 	65: {
  69539 		Fcode:       int8(12),
  69540 		Fextra_bits: int8(5),
  69541 	},
  69542 	66: {
  69543 		Fcode:       int8(12),
  69544 		Fextra_bits: int8(5),
  69545 	},
  69546 	67: {
  69547 		Fcode:       int8(12),
  69548 		Fextra_bits: int8(5),
  69549 	},
  69550 	68: {
  69551 		Fcode:       int8(12),
  69552 		Fextra_bits: int8(5),
  69553 	},
  69554 	69: {
  69555 		Fcode:       int8(12),
  69556 		Fextra_bits: int8(5),
  69557 	},
  69558 	70: {
  69559 		Fcode:       int8(12),
  69560 		Fextra_bits: int8(5),
  69561 	},
  69562 	71: {
  69563 		Fcode:       int8(12),
  69564 		Fextra_bits: int8(5),
  69565 	},
  69566 	72: {
  69567 		Fcode:       int8(12),
  69568 		Fextra_bits: int8(5),
  69569 	},
  69570 	73: {
  69571 		Fcode:       int8(12),
  69572 		Fextra_bits: int8(5),
  69573 	},
  69574 	74: {
  69575 		Fcode:       int8(12),
  69576 		Fextra_bits: int8(5),
  69577 	},
  69578 	75: {
  69579 		Fcode:       int8(12),
  69580 		Fextra_bits: int8(5),
  69581 	},
  69582 	76: {
  69583 		Fcode:       int8(12),
  69584 		Fextra_bits: int8(5),
  69585 	},
  69586 	77: {
  69587 		Fcode:       int8(12),
  69588 		Fextra_bits: int8(5),
  69589 	},
  69590 	78: {
  69591 		Fcode:       int8(12),
  69592 		Fextra_bits: int8(5),
  69593 	},
  69594 	79: {
  69595 		Fcode:       int8(12),
  69596 		Fextra_bits: int8(5),
  69597 	},
  69598 	80: {
  69599 		Fcode:       int8(12),
  69600 		Fextra_bits: int8(5),
  69601 	},
  69602 	81: {
  69603 		Fcode:       int8(12),
  69604 		Fextra_bits: int8(5),
  69605 	},
  69606 	82: {
  69607 		Fcode:       int8(12),
  69608 		Fextra_bits: int8(5),
  69609 	},
  69610 	83: {
  69611 		Fcode:       int8(12),
  69612 		Fextra_bits: int8(5),
  69613 	},
  69614 	84: {
  69615 		Fcode:       int8(12),
  69616 		Fextra_bits: int8(5),
  69617 	},
  69618 	85: {
  69619 		Fcode:       int8(12),
  69620 		Fextra_bits: int8(5),
  69621 	},
  69622 	86: {
  69623 		Fcode:       int8(12),
  69624 		Fextra_bits: int8(5),
  69625 	},
  69626 	87: {
  69627 		Fcode:       int8(12),
  69628 		Fextra_bits: int8(5),
  69629 	},
  69630 	88: {
  69631 		Fcode:       int8(12),
  69632 		Fextra_bits: int8(5),
  69633 	},
  69634 	89: {
  69635 		Fcode:       int8(12),
  69636 		Fextra_bits: int8(5),
  69637 	},
  69638 	90: {
  69639 		Fcode:       int8(12),
  69640 		Fextra_bits: int8(5),
  69641 	},
  69642 	91: {
  69643 		Fcode:       int8(12),
  69644 		Fextra_bits: int8(5),
  69645 	},
  69646 	92: {
  69647 		Fcode:       int8(12),
  69648 		Fextra_bits: int8(5),
  69649 	},
  69650 	93: {
  69651 		Fcode:       int8(12),
  69652 		Fextra_bits: int8(5),
  69653 	},
  69654 	94: {
  69655 		Fcode:       int8(12),
  69656 		Fextra_bits: int8(5),
  69657 	},
  69658 	95: {
  69659 		Fcode:       int8(12),
  69660 		Fextra_bits: int8(5),
  69661 	},
  69662 	96: {
  69663 		Fcode:       int8(12),
  69664 		Fextra_bits: int8(5),
  69665 	},
  69666 	97: {
  69667 		Fcode:       int8(13),
  69668 		Fextra_bits: int8(5),
  69669 	},
  69670 	98: {
  69671 		Fcode:       int8(13),
  69672 		Fextra_bits: int8(5),
  69673 	},
  69674 	99: {
  69675 		Fcode:       int8(13),
  69676 		Fextra_bits: int8(5),
  69677 	},
  69678 	100: {
  69679 		Fcode:       int8(13),
  69680 		Fextra_bits: int8(5),
  69681 	},
  69682 	101: {
  69683 		Fcode:       int8(13),
  69684 		Fextra_bits: int8(5),
  69685 	},
  69686 	102: {
  69687 		Fcode:       int8(13),
  69688 		Fextra_bits: int8(5),
  69689 	},
  69690 	103: {
  69691 		Fcode:       int8(13),
  69692 		Fextra_bits: int8(5),
  69693 	},
  69694 	104: {
  69695 		Fcode:       int8(13),
  69696 		Fextra_bits: int8(5),
  69697 	},
  69698 	105: {
  69699 		Fcode:       int8(13),
  69700 		Fextra_bits: int8(5),
  69701 	},
  69702 	106: {
  69703 		Fcode:       int8(13),
  69704 		Fextra_bits: int8(5),
  69705 	},
  69706 	107: {
  69707 		Fcode:       int8(13),
  69708 		Fextra_bits: int8(5),
  69709 	},
  69710 	108: {
  69711 		Fcode:       int8(13),
  69712 		Fextra_bits: int8(5),
  69713 	},
  69714 	109: {
  69715 		Fcode:       int8(13),
  69716 		Fextra_bits: int8(5),
  69717 	},
  69718 	110: {
  69719 		Fcode:       int8(13),
  69720 		Fextra_bits: int8(5),
  69721 	},
  69722 	111: {
  69723 		Fcode:       int8(13),
  69724 		Fextra_bits: int8(5),
  69725 	},
  69726 	112: {
  69727 		Fcode:       int8(13),
  69728 		Fextra_bits: int8(5),
  69729 	},
  69730 	113: {
  69731 		Fcode:       int8(13),
  69732 		Fextra_bits: int8(5),
  69733 	},
  69734 	114: {
  69735 		Fcode:       int8(13),
  69736 		Fextra_bits: int8(5),
  69737 	},
  69738 	115: {
  69739 		Fcode:       int8(13),
  69740 		Fextra_bits: int8(5),
  69741 	},
  69742 	116: {
  69743 		Fcode:       int8(13),
  69744 		Fextra_bits: int8(5),
  69745 	},
  69746 	117: {
  69747 		Fcode:       int8(13),
  69748 		Fextra_bits: int8(5),
  69749 	},
  69750 	118: {
  69751 		Fcode:       int8(13),
  69752 		Fextra_bits: int8(5),
  69753 	},
  69754 	119: {
  69755 		Fcode:       int8(13),
  69756 		Fextra_bits: int8(5),
  69757 	},
  69758 	120: {
  69759 		Fcode:       int8(13),
  69760 		Fextra_bits: int8(5),
  69761 	},
  69762 	121: {
  69763 		Fcode:       int8(13),
  69764 		Fextra_bits: int8(5),
  69765 	},
  69766 	122: {
  69767 		Fcode:       int8(13),
  69768 		Fextra_bits: int8(5),
  69769 	},
  69770 	123: {
  69771 		Fcode:       int8(13),
  69772 		Fextra_bits: int8(5),
  69773 	},
  69774 	124: {
  69775 		Fcode:       int8(13),
  69776 		Fextra_bits: int8(5),
  69777 	},
  69778 	125: {
  69779 		Fcode:       int8(13),
  69780 		Fextra_bits: int8(5),
  69781 	},
  69782 	126: {
  69783 		Fcode:       int8(13),
  69784 		Fextra_bits: int8(5),
  69785 	},
  69786 	127: {
  69787 		Fcode:       int8(13),
  69788 		Fextra_bits: int8(5),
  69789 	},
  69790 	128: {
  69791 		Fcode:       int8(13),
  69792 		Fextra_bits: int8(5),
  69793 	},
  69794 	129: {
  69795 		Fcode:       int8(14),
  69796 		Fextra_bits: int8(6),
  69797 	},
  69798 	130: {
  69799 		Fcode:       int8(14),
  69800 		Fextra_bits: int8(6),
  69801 	},
  69802 	131: {
  69803 		Fcode:       int8(14),
  69804 		Fextra_bits: int8(6),
  69805 	},
  69806 	132: {
  69807 		Fcode:       int8(14),
  69808 		Fextra_bits: int8(6),
  69809 	},
  69810 	133: {
  69811 		Fcode:       int8(14),
  69812 		Fextra_bits: int8(6),
  69813 	},
  69814 	134: {
  69815 		Fcode:       int8(14),
  69816 		Fextra_bits: int8(6),
  69817 	},
  69818 	135: {
  69819 		Fcode:       int8(14),
  69820 		Fextra_bits: int8(6),
  69821 	},
  69822 	136: {
  69823 		Fcode:       int8(14),
  69824 		Fextra_bits: int8(6),
  69825 	},
  69826 	137: {
  69827 		Fcode:       int8(14),
  69828 		Fextra_bits: int8(6),
  69829 	},
  69830 	138: {
  69831 		Fcode:       int8(14),
  69832 		Fextra_bits: int8(6),
  69833 	},
  69834 	139: {
  69835 		Fcode:       int8(14),
  69836 		Fextra_bits: int8(6),
  69837 	},
  69838 	140: {
  69839 		Fcode:       int8(14),
  69840 		Fextra_bits: int8(6),
  69841 	},
  69842 	141: {
  69843 		Fcode:       int8(14),
  69844 		Fextra_bits: int8(6),
  69845 	},
  69846 	142: {
  69847 		Fcode:       int8(14),
  69848 		Fextra_bits: int8(6),
  69849 	},
  69850 	143: {
  69851 		Fcode:       int8(14),
  69852 		Fextra_bits: int8(6),
  69853 	},
  69854 	144: {
  69855 		Fcode:       int8(14),
  69856 		Fextra_bits: int8(6),
  69857 	},
  69858 	145: {
  69859 		Fcode:       int8(14),
  69860 		Fextra_bits: int8(6),
  69861 	},
  69862 	146: {
  69863 		Fcode:       int8(14),
  69864 		Fextra_bits: int8(6),
  69865 	},
  69866 	147: {
  69867 		Fcode:       int8(14),
  69868 		Fextra_bits: int8(6),
  69869 	},
  69870 	148: {
  69871 		Fcode:       int8(14),
  69872 		Fextra_bits: int8(6),
  69873 	},
  69874 	149: {
  69875 		Fcode:       int8(14),
  69876 		Fextra_bits: int8(6),
  69877 	},
  69878 	150: {
  69879 		Fcode:       int8(14),
  69880 		Fextra_bits: int8(6),
  69881 	},
  69882 	151: {
  69883 		Fcode:       int8(14),
  69884 		Fextra_bits: int8(6),
  69885 	},
  69886 	152: {
  69887 		Fcode:       int8(14),
  69888 		Fextra_bits: int8(6),
  69889 	},
  69890 	153: {
  69891 		Fcode:       int8(14),
  69892 		Fextra_bits: int8(6),
  69893 	},
  69894 	154: {
  69895 		Fcode:       int8(14),
  69896 		Fextra_bits: int8(6),
  69897 	},
  69898 	155: {
  69899 		Fcode:       int8(14),
  69900 		Fextra_bits: int8(6),
  69901 	},
  69902 	156: {
  69903 		Fcode:       int8(14),
  69904 		Fextra_bits: int8(6),
  69905 	},
  69906 	157: {
  69907 		Fcode:       int8(14),
  69908 		Fextra_bits: int8(6),
  69909 	},
  69910 	158: {
  69911 		Fcode:       int8(14),
  69912 		Fextra_bits: int8(6),
  69913 	},
  69914 	159: {
  69915 		Fcode:       int8(14),
  69916 		Fextra_bits: int8(6),
  69917 	},
  69918 	160: {
  69919 		Fcode:       int8(14),
  69920 		Fextra_bits: int8(6),
  69921 	},
  69922 	161: {
  69923 		Fcode:       int8(14),
  69924 		Fextra_bits: int8(6),
  69925 	},
  69926 	162: {
  69927 		Fcode:       int8(14),
  69928 		Fextra_bits: int8(6),
  69929 	},
  69930 	163: {
  69931 		Fcode:       int8(14),
  69932 		Fextra_bits: int8(6),
  69933 	},
  69934 	164: {
  69935 		Fcode:       int8(14),
  69936 		Fextra_bits: int8(6),
  69937 	},
  69938 	165: {
  69939 		Fcode:       int8(14),
  69940 		Fextra_bits: int8(6),
  69941 	},
  69942 	166: {
  69943 		Fcode:       int8(14),
  69944 		Fextra_bits: int8(6),
  69945 	},
  69946 	167: {
  69947 		Fcode:       int8(14),
  69948 		Fextra_bits: int8(6),
  69949 	},
  69950 	168: {
  69951 		Fcode:       int8(14),
  69952 		Fextra_bits: int8(6),
  69953 	},
  69954 	169: {
  69955 		Fcode:       int8(14),
  69956 		Fextra_bits: int8(6),
  69957 	},
  69958 	170: {
  69959 		Fcode:       int8(14),
  69960 		Fextra_bits: int8(6),
  69961 	},
  69962 	171: {
  69963 		Fcode:       int8(14),
  69964 		Fextra_bits: int8(6),
  69965 	},
  69966 	172: {
  69967 		Fcode:       int8(14),
  69968 		Fextra_bits: int8(6),
  69969 	},
  69970 	173: {
  69971 		Fcode:       int8(14),
  69972 		Fextra_bits: int8(6),
  69973 	},
  69974 	174: {
  69975 		Fcode:       int8(14),
  69976 		Fextra_bits: int8(6),
  69977 	},
  69978 	175: {
  69979 		Fcode:       int8(14),
  69980 		Fextra_bits: int8(6),
  69981 	},
  69982 	176: {
  69983 		Fcode:       int8(14),
  69984 		Fextra_bits: int8(6),
  69985 	},
  69986 	177: {
  69987 		Fcode:       int8(14),
  69988 		Fextra_bits: int8(6),
  69989 	},
  69990 	178: {
  69991 		Fcode:       int8(14),
  69992 		Fextra_bits: int8(6),
  69993 	},
  69994 	179: {
  69995 		Fcode:       int8(14),
  69996 		Fextra_bits: int8(6),
  69997 	},
  69998 	180: {
  69999 		Fcode:       int8(14),
  70000 		Fextra_bits: int8(6),
  70001 	},
  70002 	181: {
  70003 		Fcode:       int8(14),
  70004 		Fextra_bits: int8(6),
  70005 	},
  70006 	182: {
  70007 		Fcode:       int8(14),
  70008 		Fextra_bits: int8(6),
  70009 	},
  70010 	183: {
  70011 		Fcode:       int8(14),
  70012 		Fextra_bits: int8(6),
  70013 	},
  70014 	184: {
  70015 		Fcode:       int8(14),
  70016 		Fextra_bits: int8(6),
  70017 	},
  70018 	185: {
  70019 		Fcode:       int8(14),
  70020 		Fextra_bits: int8(6),
  70021 	},
  70022 	186: {
  70023 		Fcode:       int8(14),
  70024 		Fextra_bits: int8(6),
  70025 	},
  70026 	187: {
  70027 		Fcode:       int8(14),
  70028 		Fextra_bits: int8(6),
  70029 	},
  70030 	188: {
  70031 		Fcode:       int8(14),
  70032 		Fextra_bits: int8(6),
  70033 	},
  70034 	189: {
  70035 		Fcode:       int8(14),
  70036 		Fextra_bits: int8(6),
  70037 	},
  70038 	190: {
  70039 		Fcode:       int8(14),
  70040 		Fextra_bits: int8(6),
  70041 	},
  70042 	191: {
  70043 		Fcode:       int8(14),
  70044 		Fextra_bits: int8(6),
  70045 	},
  70046 	192: {
  70047 		Fcode:       int8(14),
  70048 		Fextra_bits: int8(6),
  70049 	},
  70050 	193: {
  70051 		Fcode:       int8(15),
  70052 		Fextra_bits: int8(6),
  70053 	},
  70054 	194: {
  70055 		Fcode:       int8(15),
  70056 		Fextra_bits: int8(6),
  70057 	},
  70058 	195: {
  70059 		Fcode:       int8(15),
  70060 		Fextra_bits: int8(6),
  70061 	},
  70062 	196: {
  70063 		Fcode:       int8(15),
  70064 		Fextra_bits: int8(6),
  70065 	},
  70066 	197: {
  70067 		Fcode:       int8(15),
  70068 		Fextra_bits: int8(6),
  70069 	},
  70070 	198: {
  70071 		Fcode:       int8(15),
  70072 		Fextra_bits: int8(6),
  70073 	},
  70074 	199: {
  70075 		Fcode:       int8(15),
  70076 		Fextra_bits: int8(6),
  70077 	},
  70078 	200: {
  70079 		Fcode:       int8(15),
  70080 		Fextra_bits: int8(6),
  70081 	},
  70082 	201: {
  70083 		Fcode:       int8(15),
  70084 		Fextra_bits: int8(6),
  70085 	},
  70086 	202: {
  70087 		Fcode:       int8(15),
  70088 		Fextra_bits: int8(6),
  70089 	},
  70090 	203: {
  70091 		Fcode:       int8(15),
  70092 		Fextra_bits: int8(6),
  70093 	},
  70094 	204: {
  70095 		Fcode:       int8(15),
  70096 		Fextra_bits: int8(6),
  70097 	},
  70098 	205: {
  70099 		Fcode:       int8(15),
  70100 		Fextra_bits: int8(6),
  70101 	},
  70102 	206: {
  70103 		Fcode:       int8(15),
  70104 		Fextra_bits: int8(6),
  70105 	},
  70106 	207: {
  70107 		Fcode:       int8(15),
  70108 		Fextra_bits: int8(6),
  70109 	},
  70110 	208: {
  70111 		Fcode:       int8(15),
  70112 		Fextra_bits: int8(6),
  70113 	},
  70114 	209: {
  70115 		Fcode:       int8(15),
  70116 		Fextra_bits: int8(6),
  70117 	},
  70118 	210: {
  70119 		Fcode:       int8(15),
  70120 		Fextra_bits: int8(6),
  70121 	},
  70122 	211: {
  70123 		Fcode:       int8(15),
  70124 		Fextra_bits: int8(6),
  70125 	},
  70126 	212: {
  70127 		Fcode:       int8(15),
  70128 		Fextra_bits: int8(6),
  70129 	},
  70130 	213: {
  70131 		Fcode:       int8(15),
  70132 		Fextra_bits: int8(6),
  70133 	},
  70134 	214: {
  70135 		Fcode:       int8(15),
  70136 		Fextra_bits: int8(6),
  70137 	},
  70138 	215: {
  70139 		Fcode:       int8(15),
  70140 		Fextra_bits: int8(6),
  70141 	},
  70142 	216: {
  70143 		Fcode:       int8(15),
  70144 		Fextra_bits: int8(6),
  70145 	},
  70146 	217: {
  70147 		Fcode:       int8(15),
  70148 		Fextra_bits: int8(6),
  70149 	},
  70150 	218: {
  70151 		Fcode:       int8(15),
  70152 		Fextra_bits: int8(6),
  70153 	},
  70154 	219: {
  70155 		Fcode:       int8(15),
  70156 		Fextra_bits: int8(6),
  70157 	},
  70158 	220: {
  70159 		Fcode:       int8(15),
  70160 		Fextra_bits: int8(6),
  70161 	},
  70162 	221: {
  70163 		Fcode:       int8(15),
  70164 		Fextra_bits: int8(6),
  70165 	},
  70166 	222: {
  70167 		Fcode:       int8(15),
  70168 		Fextra_bits: int8(6),
  70169 	},
  70170 	223: {
  70171 		Fcode:       int8(15),
  70172 		Fextra_bits: int8(6),
  70173 	},
  70174 	224: {
  70175 		Fcode:       int8(15),
  70176 		Fextra_bits: int8(6),
  70177 	},
  70178 	225: {
  70179 		Fcode:       int8(15),
  70180 		Fextra_bits: int8(6),
  70181 	},
  70182 	226: {
  70183 		Fcode:       int8(15),
  70184 		Fextra_bits: int8(6),
  70185 	},
  70186 	227: {
  70187 		Fcode:       int8(15),
  70188 		Fextra_bits: int8(6),
  70189 	},
  70190 	228: {
  70191 		Fcode:       int8(15),
  70192 		Fextra_bits: int8(6),
  70193 	},
  70194 	229: {
  70195 		Fcode:       int8(15),
  70196 		Fextra_bits: int8(6),
  70197 	},
  70198 	230: {
  70199 		Fcode:       int8(15),
  70200 		Fextra_bits: int8(6),
  70201 	},
  70202 	231: {
  70203 		Fcode:       int8(15),
  70204 		Fextra_bits: int8(6),
  70205 	},
  70206 	232: {
  70207 		Fcode:       int8(15),
  70208 		Fextra_bits: int8(6),
  70209 	},
  70210 	233: {
  70211 		Fcode:       int8(15),
  70212 		Fextra_bits: int8(6),
  70213 	},
  70214 	234: {
  70215 		Fcode:       int8(15),
  70216 		Fextra_bits: int8(6),
  70217 	},
  70218 	235: {
  70219 		Fcode:       int8(15),
  70220 		Fextra_bits: int8(6),
  70221 	},
  70222 	236: {
  70223 		Fcode:       int8(15),
  70224 		Fextra_bits: int8(6),
  70225 	},
  70226 	237: {
  70227 		Fcode:       int8(15),
  70228 		Fextra_bits: int8(6),
  70229 	},
  70230 	238: {
  70231 		Fcode:       int8(15),
  70232 		Fextra_bits: int8(6),
  70233 	},
  70234 	239: {
  70235 		Fcode:       int8(15),
  70236 		Fextra_bits: int8(6),
  70237 	},
  70238 	240: {
  70239 		Fcode:       int8(15),
  70240 		Fextra_bits: int8(6),
  70241 	},
  70242 	241: {
  70243 		Fcode:       int8(15),
  70244 		Fextra_bits: int8(6),
  70245 	},
  70246 	242: {
  70247 		Fcode:       int8(15),
  70248 		Fextra_bits: int8(6),
  70249 	},
  70250 	243: {
  70251 		Fcode:       int8(15),
  70252 		Fextra_bits: int8(6),
  70253 	},
  70254 	244: {
  70255 		Fcode:       int8(15),
  70256 		Fextra_bits: int8(6),
  70257 	},
  70258 	245: {
  70259 		Fcode:       int8(15),
  70260 		Fextra_bits: int8(6),
  70261 	},
  70262 	246: {
  70263 		Fcode:       int8(15),
  70264 		Fextra_bits: int8(6),
  70265 	},
  70266 	247: {
  70267 		Fcode:       int8(15),
  70268 		Fextra_bits: int8(6),
  70269 	},
  70270 	248: {
  70271 		Fcode:       int8(15),
  70272 		Fextra_bits: int8(6),
  70273 	},
  70274 	249: {
  70275 		Fcode:       int8(15),
  70276 		Fextra_bits: int8(6),
  70277 	},
  70278 	250: {
  70279 		Fcode:       int8(15),
  70280 		Fextra_bits: int8(6),
  70281 	},
  70282 	251: {
  70283 		Fcode:       int8(15),
  70284 		Fextra_bits: int8(6),
  70285 	},
  70286 	252: {
  70287 		Fcode:       int8(15),
  70288 		Fextra_bits: int8(6),
  70289 	},
  70290 	253: {
  70291 		Fcode:       int8(15),
  70292 		Fextra_bits: int8(6),
  70293 	},
  70294 	254: {
  70295 		Fcode:       int8(15),
  70296 		Fextra_bits: int8(6),
  70297 	},
  70298 	255: {
  70299 		Fcode:       int8(15),
  70300 		Fextra_bits: int8(6),
  70301 	},
  70302 	256: {
  70303 		Fcode:       int8(15),
  70304 		Fextra_bits: int8(6),
  70305 	},
  70306 	257: {
  70307 		Fcode:       int8(16),
  70308 		Fextra_bits: int8(7),
  70309 	},
  70310 	258: {
  70311 		Fcode:       int8(16),
  70312 		Fextra_bits: int8(7),
  70313 	},
  70314 	259: {
  70315 		Fcode:       int8(16),
  70316 		Fextra_bits: int8(7),
  70317 	},
  70318 	260: {
  70319 		Fcode:       int8(16),
  70320 		Fextra_bits: int8(7),
  70321 	},
  70322 	261: {
  70323 		Fcode:       int8(16),
  70324 		Fextra_bits: int8(7),
  70325 	},
  70326 	262: {
  70327 		Fcode:       int8(16),
  70328 		Fextra_bits: int8(7),
  70329 	},
  70330 	263: {
  70331 		Fcode:       int8(16),
  70332 		Fextra_bits: int8(7),
  70333 	},
  70334 	264: {
  70335 		Fcode:       int8(16),
  70336 		Fextra_bits: int8(7),
  70337 	},
  70338 	265: {
  70339 		Fcode:       int8(16),
  70340 		Fextra_bits: int8(7),
  70341 	},
  70342 	266: {
  70343 		Fcode:       int8(16),
  70344 		Fextra_bits: int8(7),
  70345 	},
  70346 	267: {
  70347 		Fcode:       int8(16),
  70348 		Fextra_bits: int8(7),
  70349 	},
  70350 	268: {
  70351 		Fcode:       int8(16),
  70352 		Fextra_bits: int8(7),
  70353 	},
  70354 	269: {
  70355 		Fcode:       int8(16),
  70356 		Fextra_bits: int8(7),
  70357 	},
  70358 	270: {
  70359 		Fcode:       int8(16),
  70360 		Fextra_bits: int8(7),
  70361 	},
  70362 	271: {
  70363 		Fcode:       int8(16),
  70364 		Fextra_bits: int8(7),
  70365 	},
  70366 	272: {
  70367 		Fcode:       int8(16),
  70368 		Fextra_bits: int8(7),
  70369 	},
  70370 	273: {
  70371 		Fcode:       int8(16),
  70372 		Fextra_bits: int8(7),
  70373 	},
  70374 	274: {
  70375 		Fcode:       int8(16),
  70376 		Fextra_bits: int8(7),
  70377 	},
  70378 	275: {
  70379 		Fcode:       int8(16),
  70380 		Fextra_bits: int8(7),
  70381 	},
  70382 	276: {
  70383 		Fcode:       int8(16),
  70384 		Fextra_bits: int8(7),
  70385 	},
  70386 	277: {
  70387 		Fcode:       int8(16),
  70388 		Fextra_bits: int8(7),
  70389 	},
  70390 	278: {
  70391 		Fcode:       int8(16),
  70392 		Fextra_bits: int8(7),
  70393 	},
  70394 	279: {
  70395 		Fcode:       int8(16),
  70396 		Fextra_bits: int8(7),
  70397 	},
  70398 	280: {
  70399 		Fcode:       int8(16),
  70400 		Fextra_bits: int8(7),
  70401 	},
  70402 	281: {
  70403 		Fcode:       int8(16),
  70404 		Fextra_bits: int8(7),
  70405 	},
  70406 	282: {
  70407 		Fcode:       int8(16),
  70408 		Fextra_bits: int8(7),
  70409 	},
  70410 	283: {
  70411 		Fcode:       int8(16),
  70412 		Fextra_bits: int8(7),
  70413 	},
  70414 	284: {
  70415 		Fcode:       int8(16),
  70416 		Fextra_bits: int8(7),
  70417 	},
  70418 	285: {
  70419 		Fcode:       int8(16),
  70420 		Fextra_bits: int8(7),
  70421 	},
  70422 	286: {
  70423 		Fcode:       int8(16),
  70424 		Fextra_bits: int8(7),
  70425 	},
  70426 	287: {
  70427 		Fcode:       int8(16),
  70428 		Fextra_bits: int8(7),
  70429 	},
  70430 	288: {
  70431 		Fcode:       int8(16),
  70432 		Fextra_bits: int8(7),
  70433 	},
  70434 	289: {
  70435 		Fcode:       int8(16),
  70436 		Fextra_bits: int8(7),
  70437 	},
  70438 	290: {
  70439 		Fcode:       int8(16),
  70440 		Fextra_bits: int8(7),
  70441 	},
  70442 	291: {
  70443 		Fcode:       int8(16),
  70444 		Fextra_bits: int8(7),
  70445 	},
  70446 	292: {
  70447 		Fcode:       int8(16),
  70448 		Fextra_bits: int8(7),
  70449 	},
  70450 	293: {
  70451 		Fcode:       int8(16),
  70452 		Fextra_bits: int8(7),
  70453 	},
  70454 	294: {
  70455 		Fcode:       int8(16),
  70456 		Fextra_bits: int8(7),
  70457 	},
  70458 	295: {
  70459 		Fcode:       int8(16),
  70460 		Fextra_bits: int8(7),
  70461 	},
  70462 	296: {
  70463 		Fcode:       int8(16),
  70464 		Fextra_bits: int8(7),
  70465 	},
  70466 	297: {
  70467 		Fcode:       int8(16),
  70468 		Fextra_bits: int8(7),
  70469 	},
  70470 	298: {
  70471 		Fcode:       int8(16),
  70472 		Fextra_bits: int8(7),
  70473 	},
  70474 	299: {
  70475 		Fcode:       int8(16),
  70476 		Fextra_bits: int8(7),
  70477 	},
  70478 	300: {
  70479 		Fcode:       int8(16),
  70480 		Fextra_bits: int8(7),
  70481 	},
  70482 	301: {
  70483 		Fcode:       int8(16),
  70484 		Fextra_bits: int8(7),
  70485 	},
  70486 	302: {
  70487 		Fcode:       int8(16),
  70488 		Fextra_bits: int8(7),
  70489 	},
  70490 	303: {
  70491 		Fcode:       int8(16),
  70492 		Fextra_bits: int8(7),
  70493 	},
  70494 	304: {
  70495 		Fcode:       int8(16),
  70496 		Fextra_bits: int8(7),
  70497 	},
  70498 	305: {
  70499 		Fcode:       int8(16),
  70500 		Fextra_bits: int8(7),
  70501 	},
  70502 	306: {
  70503 		Fcode:       int8(16),
  70504 		Fextra_bits: int8(7),
  70505 	},
  70506 	307: {
  70507 		Fcode:       int8(16),
  70508 		Fextra_bits: int8(7),
  70509 	},
  70510 	308: {
  70511 		Fcode:       int8(16),
  70512 		Fextra_bits: int8(7),
  70513 	},
  70514 	309: {
  70515 		Fcode:       int8(16),
  70516 		Fextra_bits: int8(7),
  70517 	},
  70518 	310: {
  70519 		Fcode:       int8(16),
  70520 		Fextra_bits: int8(7),
  70521 	},
  70522 	311: {
  70523 		Fcode:       int8(16),
  70524 		Fextra_bits: int8(7),
  70525 	},
  70526 	312: {
  70527 		Fcode:       int8(16),
  70528 		Fextra_bits: int8(7),
  70529 	},
  70530 	313: {
  70531 		Fcode:       int8(16),
  70532 		Fextra_bits: int8(7),
  70533 	},
  70534 	314: {
  70535 		Fcode:       int8(16),
  70536 		Fextra_bits: int8(7),
  70537 	},
  70538 	315: {
  70539 		Fcode:       int8(16),
  70540 		Fextra_bits: int8(7),
  70541 	},
  70542 	316: {
  70543 		Fcode:       int8(16),
  70544 		Fextra_bits: int8(7),
  70545 	},
  70546 	317: {
  70547 		Fcode:       int8(16),
  70548 		Fextra_bits: int8(7),
  70549 	},
  70550 	318: {
  70551 		Fcode:       int8(16),
  70552 		Fextra_bits: int8(7),
  70553 	},
  70554 	319: {
  70555 		Fcode:       int8(16),
  70556 		Fextra_bits: int8(7),
  70557 	},
  70558 	320: {
  70559 		Fcode:       int8(16),
  70560 		Fextra_bits: int8(7),
  70561 	},
  70562 	321: {
  70563 		Fcode:       int8(16),
  70564 		Fextra_bits: int8(7),
  70565 	},
  70566 	322: {
  70567 		Fcode:       int8(16),
  70568 		Fextra_bits: int8(7),
  70569 	},
  70570 	323: {
  70571 		Fcode:       int8(16),
  70572 		Fextra_bits: int8(7),
  70573 	},
  70574 	324: {
  70575 		Fcode:       int8(16),
  70576 		Fextra_bits: int8(7),
  70577 	},
  70578 	325: {
  70579 		Fcode:       int8(16),
  70580 		Fextra_bits: int8(7),
  70581 	},
  70582 	326: {
  70583 		Fcode:       int8(16),
  70584 		Fextra_bits: int8(7),
  70585 	},
  70586 	327: {
  70587 		Fcode:       int8(16),
  70588 		Fextra_bits: int8(7),
  70589 	},
  70590 	328: {
  70591 		Fcode:       int8(16),
  70592 		Fextra_bits: int8(7),
  70593 	},
  70594 	329: {
  70595 		Fcode:       int8(16),
  70596 		Fextra_bits: int8(7),
  70597 	},
  70598 	330: {
  70599 		Fcode:       int8(16),
  70600 		Fextra_bits: int8(7),
  70601 	},
  70602 	331: {
  70603 		Fcode:       int8(16),
  70604 		Fextra_bits: int8(7),
  70605 	},
  70606 	332: {
  70607 		Fcode:       int8(16),
  70608 		Fextra_bits: int8(7),
  70609 	},
  70610 	333: {
  70611 		Fcode:       int8(16),
  70612 		Fextra_bits: int8(7),
  70613 	},
  70614 	334: {
  70615 		Fcode:       int8(16),
  70616 		Fextra_bits: int8(7),
  70617 	},
  70618 	335: {
  70619 		Fcode:       int8(16),
  70620 		Fextra_bits: int8(7),
  70621 	},
  70622 	336: {
  70623 		Fcode:       int8(16),
  70624 		Fextra_bits: int8(7),
  70625 	},
  70626 	337: {
  70627 		Fcode:       int8(16),
  70628 		Fextra_bits: int8(7),
  70629 	},
  70630 	338: {
  70631 		Fcode:       int8(16),
  70632 		Fextra_bits: int8(7),
  70633 	},
  70634 	339: {
  70635 		Fcode:       int8(16),
  70636 		Fextra_bits: int8(7),
  70637 	},
  70638 	340: {
  70639 		Fcode:       int8(16),
  70640 		Fextra_bits: int8(7),
  70641 	},
  70642 	341: {
  70643 		Fcode:       int8(16),
  70644 		Fextra_bits: int8(7),
  70645 	},
  70646 	342: {
  70647 		Fcode:       int8(16),
  70648 		Fextra_bits: int8(7),
  70649 	},
  70650 	343: {
  70651 		Fcode:       int8(16),
  70652 		Fextra_bits: int8(7),
  70653 	},
  70654 	344: {
  70655 		Fcode:       int8(16),
  70656 		Fextra_bits: int8(7),
  70657 	},
  70658 	345: {
  70659 		Fcode:       int8(16),
  70660 		Fextra_bits: int8(7),
  70661 	},
  70662 	346: {
  70663 		Fcode:       int8(16),
  70664 		Fextra_bits: int8(7),
  70665 	},
  70666 	347: {
  70667 		Fcode:       int8(16),
  70668 		Fextra_bits: int8(7),
  70669 	},
  70670 	348: {
  70671 		Fcode:       int8(16),
  70672 		Fextra_bits: int8(7),
  70673 	},
  70674 	349: {
  70675 		Fcode:       int8(16),
  70676 		Fextra_bits: int8(7),
  70677 	},
  70678 	350: {
  70679 		Fcode:       int8(16),
  70680 		Fextra_bits: int8(7),
  70681 	},
  70682 	351: {
  70683 		Fcode:       int8(16),
  70684 		Fextra_bits: int8(7),
  70685 	},
  70686 	352: {
  70687 		Fcode:       int8(16),
  70688 		Fextra_bits: int8(7),
  70689 	},
  70690 	353: {
  70691 		Fcode:       int8(16),
  70692 		Fextra_bits: int8(7),
  70693 	},
  70694 	354: {
  70695 		Fcode:       int8(16),
  70696 		Fextra_bits: int8(7),
  70697 	},
  70698 	355: {
  70699 		Fcode:       int8(16),
  70700 		Fextra_bits: int8(7),
  70701 	},
  70702 	356: {
  70703 		Fcode:       int8(16),
  70704 		Fextra_bits: int8(7),
  70705 	},
  70706 	357: {
  70707 		Fcode:       int8(16),
  70708 		Fextra_bits: int8(7),
  70709 	},
  70710 	358: {
  70711 		Fcode:       int8(16),
  70712 		Fextra_bits: int8(7),
  70713 	},
  70714 	359: {
  70715 		Fcode:       int8(16),
  70716 		Fextra_bits: int8(7),
  70717 	},
  70718 	360: {
  70719 		Fcode:       int8(16),
  70720 		Fextra_bits: int8(7),
  70721 	},
  70722 	361: {
  70723 		Fcode:       int8(16),
  70724 		Fextra_bits: int8(7),
  70725 	},
  70726 	362: {
  70727 		Fcode:       int8(16),
  70728 		Fextra_bits: int8(7),
  70729 	},
  70730 	363: {
  70731 		Fcode:       int8(16),
  70732 		Fextra_bits: int8(7),
  70733 	},
  70734 	364: {
  70735 		Fcode:       int8(16),
  70736 		Fextra_bits: int8(7),
  70737 	},
  70738 	365: {
  70739 		Fcode:       int8(16),
  70740 		Fextra_bits: int8(7),
  70741 	},
  70742 	366: {
  70743 		Fcode:       int8(16),
  70744 		Fextra_bits: int8(7),
  70745 	},
  70746 	367: {
  70747 		Fcode:       int8(16),
  70748 		Fextra_bits: int8(7),
  70749 	},
  70750 	368: {
  70751 		Fcode:       int8(16),
  70752 		Fextra_bits: int8(7),
  70753 	},
  70754 	369: {
  70755 		Fcode:       int8(16),
  70756 		Fextra_bits: int8(7),
  70757 	},
  70758 	370: {
  70759 		Fcode:       int8(16),
  70760 		Fextra_bits: int8(7),
  70761 	},
  70762 	371: {
  70763 		Fcode:       int8(16),
  70764 		Fextra_bits: int8(7),
  70765 	},
  70766 	372: {
  70767 		Fcode:       int8(16),
  70768 		Fextra_bits: int8(7),
  70769 	},
  70770 	373: {
  70771 		Fcode:       int8(16),
  70772 		Fextra_bits: int8(7),
  70773 	},
  70774 	374: {
  70775 		Fcode:       int8(16),
  70776 		Fextra_bits: int8(7),
  70777 	},
  70778 	375: {
  70779 		Fcode:       int8(16),
  70780 		Fextra_bits: int8(7),
  70781 	},
  70782 	376: {
  70783 		Fcode:       int8(16),
  70784 		Fextra_bits: int8(7),
  70785 	},
  70786 	377: {
  70787 		Fcode:       int8(16),
  70788 		Fextra_bits: int8(7),
  70789 	},
  70790 	378: {
  70791 		Fcode:       int8(16),
  70792 		Fextra_bits: int8(7),
  70793 	},
  70794 	379: {
  70795 		Fcode:       int8(16),
  70796 		Fextra_bits: int8(7),
  70797 	},
  70798 	380: {
  70799 		Fcode:       int8(16),
  70800 		Fextra_bits: int8(7),
  70801 	},
  70802 	381: {
  70803 		Fcode:       int8(16),
  70804 		Fextra_bits: int8(7),
  70805 	},
  70806 	382: {
  70807 		Fcode:       int8(16),
  70808 		Fextra_bits: int8(7),
  70809 	},
  70810 	383: {
  70811 		Fcode:       int8(16),
  70812 		Fextra_bits: int8(7),
  70813 	},
  70814 	384: {
  70815 		Fcode:       int8(16),
  70816 		Fextra_bits: int8(7),
  70817 	},
  70818 	385: {
  70819 		Fcode:       int8(17),
  70820 		Fextra_bits: int8(7),
  70821 	},
  70822 	386: {
  70823 		Fcode:       int8(17),
  70824 		Fextra_bits: int8(7),
  70825 	},
  70826 	387: {
  70827 		Fcode:       int8(17),
  70828 		Fextra_bits: int8(7),
  70829 	},
  70830 	388: {
  70831 		Fcode:       int8(17),
  70832 		Fextra_bits: int8(7),
  70833 	},
  70834 	389: {
  70835 		Fcode:       int8(17),
  70836 		Fextra_bits: int8(7),
  70837 	},
  70838 	390: {
  70839 		Fcode:       int8(17),
  70840 		Fextra_bits: int8(7),
  70841 	},
  70842 	391: {
  70843 		Fcode:       int8(17),
  70844 		Fextra_bits: int8(7),
  70845 	},
  70846 	392: {
  70847 		Fcode:       int8(17),
  70848 		Fextra_bits: int8(7),
  70849 	},
  70850 	393: {
  70851 		Fcode:       int8(17),
  70852 		Fextra_bits: int8(7),
  70853 	},
  70854 	394: {
  70855 		Fcode:       int8(17),
  70856 		Fextra_bits: int8(7),
  70857 	},
  70858 	395: {
  70859 		Fcode:       int8(17),
  70860 		Fextra_bits: int8(7),
  70861 	},
  70862 	396: {
  70863 		Fcode:       int8(17),
  70864 		Fextra_bits: int8(7),
  70865 	},
  70866 	397: {
  70867 		Fcode:       int8(17),
  70868 		Fextra_bits: int8(7),
  70869 	},
  70870 	398: {
  70871 		Fcode:       int8(17),
  70872 		Fextra_bits: int8(7),
  70873 	},
  70874 	399: {
  70875 		Fcode:       int8(17),
  70876 		Fextra_bits: int8(7),
  70877 	},
  70878 	400: {
  70879 		Fcode:       int8(17),
  70880 		Fextra_bits: int8(7),
  70881 	},
  70882 	401: {
  70883 		Fcode:       int8(17),
  70884 		Fextra_bits: int8(7),
  70885 	},
  70886 	402: {
  70887 		Fcode:       int8(17),
  70888 		Fextra_bits: int8(7),
  70889 	},
  70890 	403: {
  70891 		Fcode:       int8(17),
  70892 		Fextra_bits: int8(7),
  70893 	},
  70894 	404: {
  70895 		Fcode:       int8(17),
  70896 		Fextra_bits: int8(7),
  70897 	},
  70898 	405: {
  70899 		Fcode:       int8(17),
  70900 		Fextra_bits: int8(7),
  70901 	},
  70902 	406: {
  70903 		Fcode:       int8(17),
  70904 		Fextra_bits: int8(7),
  70905 	},
  70906 	407: {
  70907 		Fcode:       int8(17),
  70908 		Fextra_bits: int8(7),
  70909 	},
  70910 	408: {
  70911 		Fcode:       int8(17),
  70912 		Fextra_bits: int8(7),
  70913 	},
  70914 	409: {
  70915 		Fcode:       int8(17),
  70916 		Fextra_bits: int8(7),
  70917 	},
  70918 	410: {
  70919 		Fcode:       int8(17),
  70920 		Fextra_bits: int8(7),
  70921 	},
  70922 	411: {
  70923 		Fcode:       int8(17),
  70924 		Fextra_bits: int8(7),
  70925 	},
  70926 	412: {
  70927 		Fcode:       int8(17),
  70928 		Fextra_bits: int8(7),
  70929 	},
  70930 	413: {
  70931 		Fcode:       int8(17),
  70932 		Fextra_bits: int8(7),
  70933 	},
  70934 	414: {
  70935 		Fcode:       int8(17),
  70936 		Fextra_bits: int8(7),
  70937 	},
  70938 	415: {
  70939 		Fcode:       int8(17),
  70940 		Fextra_bits: int8(7),
  70941 	},
  70942 	416: {
  70943 		Fcode:       int8(17),
  70944 		Fextra_bits: int8(7),
  70945 	},
  70946 	417: {
  70947 		Fcode:       int8(17),
  70948 		Fextra_bits: int8(7),
  70949 	},
  70950 	418: {
  70951 		Fcode:       int8(17),
  70952 		Fextra_bits: int8(7),
  70953 	},
  70954 	419: {
  70955 		Fcode:       int8(17),
  70956 		Fextra_bits: int8(7),
  70957 	},
  70958 	420: {
  70959 		Fcode:       int8(17),
  70960 		Fextra_bits: int8(7),
  70961 	},
  70962 	421: {
  70963 		Fcode:       int8(17),
  70964 		Fextra_bits: int8(7),
  70965 	},
  70966 	422: {
  70967 		Fcode:       int8(17),
  70968 		Fextra_bits: int8(7),
  70969 	},
  70970 	423: {
  70971 		Fcode:       int8(17),
  70972 		Fextra_bits: int8(7),
  70973 	},
  70974 	424: {
  70975 		Fcode:       int8(17),
  70976 		Fextra_bits: int8(7),
  70977 	},
  70978 	425: {
  70979 		Fcode:       int8(17),
  70980 		Fextra_bits: int8(7),
  70981 	},
  70982 	426: {
  70983 		Fcode:       int8(17),
  70984 		Fextra_bits: int8(7),
  70985 	},
  70986 	427: {
  70987 		Fcode:       int8(17),
  70988 		Fextra_bits: int8(7),
  70989 	},
  70990 	428: {
  70991 		Fcode:       int8(17),
  70992 		Fextra_bits: int8(7),
  70993 	},
  70994 	429: {
  70995 		Fcode:       int8(17),
  70996 		Fextra_bits: int8(7),
  70997 	},
  70998 	430: {
  70999 		Fcode:       int8(17),
  71000 		Fextra_bits: int8(7),
  71001 	},
  71002 	431: {
  71003 		Fcode:       int8(17),
  71004 		Fextra_bits: int8(7),
  71005 	},
  71006 	432: {
  71007 		Fcode:       int8(17),
  71008 		Fextra_bits: int8(7),
  71009 	},
  71010 	433: {
  71011 		Fcode:       int8(17),
  71012 		Fextra_bits: int8(7),
  71013 	},
  71014 	434: {
  71015 		Fcode:       int8(17),
  71016 		Fextra_bits: int8(7),
  71017 	},
  71018 	435: {
  71019 		Fcode:       int8(17),
  71020 		Fextra_bits: int8(7),
  71021 	},
  71022 	436: {
  71023 		Fcode:       int8(17),
  71024 		Fextra_bits: int8(7),
  71025 	},
  71026 	437: {
  71027 		Fcode:       int8(17),
  71028 		Fextra_bits: int8(7),
  71029 	},
  71030 	438: {
  71031 		Fcode:       int8(17),
  71032 		Fextra_bits: int8(7),
  71033 	},
  71034 	439: {
  71035 		Fcode:       int8(17),
  71036 		Fextra_bits: int8(7),
  71037 	},
  71038 	440: {
  71039 		Fcode:       int8(17),
  71040 		Fextra_bits: int8(7),
  71041 	},
  71042 	441: {
  71043 		Fcode:       int8(17),
  71044 		Fextra_bits: int8(7),
  71045 	},
  71046 	442: {
  71047 		Fcode:       int8(17),
  71048 		Fextra_bits: int8(7),
  71049 	},
  71050 	443: {
  71051 		Fcode:       int8(17),
  71052 		Fextra_bits: int8(7),
  71053 	},
  71054 	444: {
  71055 		Fcode:       int8(17),
  71056 		Fextra_bits: int8(7),
  71057 	},
  71058 	445: {
  71059 		Fcode:       int8(17),
  71060 		Fextra_bits: int8(7),
  71061 	},
  71062 	446: {
  71063 		Fcode:       int8(17),
  71064 		Fextra_bits: int8(7),
  71065 	},
  71066 	447: {
  71067 		Fcode:       int8(17),
  71068 		Fextra_bits: int8(7),
  71069 	},
  71070 	448: {
  71071 		Fcode:       int8(17),
  71072 		Fextra_bits: int8(7),
  71073 	},
  71074 	449: {
  71075 		Fcode:       int8(17),
  71076 		Fextra_bits: int8(7),
  71077 	},
  71078 	450: {
  71079 		Fcode:       int8(17),
  71080 		Fextra_bits: int8(7),
  71081 	},
  71082 	451: {
  71083 		Fcode:       int8(17),
  71084 		Fextra_bits: int8(7),
  71085 	},
  71086 	452: {
  71087 		Fcode:       int8(17),
  71088 		Fextra_bits: int8(7),
  71089 	},
  71090 	453: {
  71091 		Fcode:       int8(17),
  71092 		Fextra_bits: int8(7),
  71093 	},
  71094 	454: {
  71095 		Fcode:       int8(17),
  71096 		Fextra_bits: int8(7),
  71097 	},
  71098 	455: {
  71099 		Fcode:       int8(17),
  71100 		Fextra_bits: int8(7),
  71101 	},
  71102 	456: {
  71103 		Fcode:       int8(17),
  71104 		Fextra_bits: int8(7),
  71105 	},
  71106 	457: {
  71107 		Fcode:       int8(17),
  71108 		Fextra_bits: int8(7),
  71109 	},
  71110 	458: {
  71111 		Fcode:       int8(17),
  71112 		Fextra_bits: int8(7),
  71113 	},
  71114 	459: {
  71115 		Fcode:       int8(17),
  71116 		Fextra_bits: int8(7),
  71117 	},
  71118 	460: {
  71119 		Fcode:       int8(17),
  71120 		Fextra_bits: int8(7),
  71121 	},
  71122 	461: {
  71123 		Fcode:       int8(17),
  71124 		Fextra_bits: int8(7),
  71125 	},
  71126 	462: {
  71127 		Fcode:       int8(17),
  71128 		Fextra_bits: int8(7),
  71129 	},
  71130 	463: {
  71131 		Fcode:       int8(17),
  71132 		Fextra_bits: int8(7),
  71133 	},
  71134 	464: {
  71135 		Fcode:       int8(17),
  71136 		Fextra_bits: int8(7),
  71137 	},
  71138 	465: {
  71139 		Fcode:       int8(17),
  71140 		Fextra_bits: int8(7),
  71141 	},
  71142 	466: {
  71143 		Fcode:       int8(17),
  71144 		Fextra_bits: int8(7),
  71145 	},
  71146 	467: {
  71147 		Fcode:       int8(17),
  71148 		Fextra_bits: int8(7),
  71149 	},
  71150 	468: {
  71151 		Fcode:       int8(17),
  71152 		Fextra_bits: int8(7),
  71153 	},
  71154 	469: {
  71155 		Fcode:       int8(17),
  71156 		Fextra_bits: int8(7),
  71157 	},
  71158 	470: {
  71159 		Fcode:       int8(17),
  71160 		Fextra_bits: int8(7),
  71161 	},
  71162 	471: {
  71163 		Fcode:       int8(17),
  71164 		Fextra_bits: int8(7),
  71165 	},
  71166 	472: {
  71167 		Fcode:       int8(17),
  71168 		Fextra_bits: int8(7),
  71169 	},
  71170 	473: {
  71171 		Fcode:       int8(17),
  71172 		Fextra_bits: int8(7),
  71173 	},
  71174 	474: {
  71175 		Fcode:       int8(17),
  71176 		Fextra_bits: int8(7),
  71177 	},
  71178 	475: {
  71179 		Fcode:       int8(17),
  71180 		Fextra_bits: int8(7),
  71181 	},
  71182 	476: {
  71183 		Fcode:       int8(17),
  71184 		Fextra_bits: int8(7),
  71185 	},
  71186 	477: {
  71187 		Fcode:       int8(17),
  71188 		Fextra_bits: int8(7),
  71189 	},
  71190 	478: {
  71191 		Fcode:       int8(17),
  71192 		Fextra_bits: int8(7),
  71193 	},
  71194 	479: {
  71195 		Fcode:       int8(17),
  71196 		Fextra_bits: int8(7),
  71197 	},
  71198 	480: {
  71199 		Fcode:       int8(17),
  71200 		Fextra_bits: int8(7),
  71201 	},
  71202 	481: {
  71203 		Fcode:       int8(17),
  71204 		Fextra_bits: int8(7),
  71205 	},
  71206 	482: {
  71207 		Fcode:       int8(17),
  71208 		Fextra_bits: int8(7),
  71209 	},
  71210 	483: {
  71211 		Fcode:       int8(17),
  71212 		Fextra_bits: int8(7),
  71213 	},
  71214 	484: {
  71215 		Fcode:       int8(17),
  71216 		Fextra_bits: int8(7),
  71217 	},
  71218 	485: {
  71219 		Fcode:       int8(17),
  71220 		Fextra_bits: int8(7),
  71221 	},
  71222 	486: {
  71223 		Fcode:       int8(17),
  71224 		Fextra_bits: int8(7),
  71225 	},
  71226 	487: {
  71227 		Fcode:       int8(17),
  71228 		Fextra_bits: int8(7),
  71229 	},
  71230 	488: {
  71231 		Fcode:       int8(17),
  71232 		Fextra_bits: int8(7),
  71233 	},
  71234 	489: {
  71235 		Fcode:       int8(17),
  71236 		Fextra_bits: int8(7),
  71237 	},
  71238 	490: {
  71239 		Fcode:       int8(17),
  71240 		Fextra_bits: int8(7),
  71241 	},
  71242 	491: {
  71243 		Fcode:       int8(17),
  71244 		Fextra_bits: int8(7),
  71245 	},
  71246 	492: {
  71247 		Fcode:       int8(17),
  71248 		Fextra_bits: int8(7),
  71249 	},
  71250 	493: {
  71251 		Fcode:       int8(17),
  71252 		Fextra_bits: int8(7),
  71253 	},
  71254 	494: {
  71255 		Fcode:       int8(17),
  71256 		Fextra_bits: int8(7),
  71257 	},
  71258 	495: {
  71259 		Fcode:       int8(17),
  71260 		Fextra_bits: int8(7),
  71261 	},
  71262 	496: {
  71263 		Fcode:       int8(17),
  71264 		Fextra_bits: int8(7),
  71265 	},
  71266 	497: {
  71267 		Fcode:       int8(17),
  71268 		Fextra_bits: int8(7),
  71269 	},
  71270 	498: {
  71271 		Fcode:       int8(17),
  71272 		Fextra_bits: int8(7),
  71273 	},
  71274 	499: {
  71275 		Fcode:       int8(17),
  71276 		Fextra_bits: int8(7),
  71277 	},
  71278 	500: {
  71279 		Fcode:       int8(17),
  71280 		Fextra_bits: int8(7),
  71281 	},
  71282 	501: {
  71283 		Fcode:       int8(17),
  71284 		Fextra_bits: int8(7),
  71285 	},
  71286 	502: {
  71287 		Fcode:       int8(17),
  71288 		Fextra_bits: int8(7),
  71289 	},
  71290 	503: {
  71291 		Fcode:       int8(17),
  71292 		Fextra_bits: int8(7),
  71293 	},
  71294 	504: {
  71295 		Fcode:       int8(17),
  71296 		Fextra_bits: int8(7),
  71297 	},
  71298 	505: {
  71299 		Fcode:       int8(17),
  71300 		Fextra_bits: int8(7),
  71301 	},
  71302 	506: {
  71303 		Fcode:       int8(17),
  71304 		Fextra_bits: int8(7),
  71305 	},
  71306 	507: {
  71307 		Fcode:       int8(17),
  71308 		Fextra_bits: int8(7),
  71309 	},
  71310 	508: {
  71311 		Fcode:       int8(17),
  71312 		Fextra_bits: int8(7),
  71313 	},
  71314 	509: {
  71315 		Fcode:       int8(17),
  71316 		Fextra_bits: int8(7),
  71317 	},
  71318 	510: {
  71319 		Fcode:       int8(17),
  71320 		Fextra_bits: int8(7),
  71321 	},
  71322 	511: {
  71323 		Fcode:       int8(17),
  71324 		Fextra_bits: int8(7),
  71325 	},
  71326 }
  71327 
  71328 var kPrefixEncodeExtraBitsValue = [512]uint8_t{
  71329 	6:   uint8(1),
  71330 	8:   uint8(1),
  71331 	10:  uint8(1),
  71332 	11:  uint8(2),
  71333 	12:  uint8(3),
  71334 	14:  uint8(1),
  71335 	15:  uint8(2),
  71336 	16:  uint8(3),
  71337 	18:  uint8(1),
  71338 	19:  uint8(2),
  71339 	20:  uint8(3),
  71340 	21:  uint8(4),
  71341 	22:  uint8(5),
  71342 	23:  uint8(6),
  71343 	24:  uint8(7),
  71344 	26:  uint8(1),
  71345 	27:  uint8(2),
  71346 	28:  uint8(3),
  71347 	29:  uint8(4),
  71348 	30:  uint8(5),
  71349 	31:  uint8(6),
  71350 	32:  uint8(7),
  71351 	34:  uint8(1),
  71352 	35:  uint8(2),
  71353 	36:  uint8(3),
  71354 	37:  uint8(4),
  71355 	38:  uint8(5),
  71356 	39:  uint8(6),
  71357 	40:  uint8(7),
  71358 	41:  uint8(8),
  71359 	42:  uint8(9),
  71360 	43:  uint8(10),
  71361 	44:  uint8(11),
  71362 	45:  uint8(12),
  71363 	46:  uint8(13),
  71364 	47:  uint8(14),
  71365 	48:  uint8(15),
  71366 	50:  uint8(1),
  71367 	51:  uint8(2),
  71368 	52:  uint8(3),
  71369 	53:  uint8(4),
  71370 	54:  uint8(5),
  71371 	55:  uint8(6),
  71372 	56:  uint8(7),
  71373 	57:  uint8(8),
  71374 	58:  uint8(9),
  71375 	59:  uint8(10),
  71376 	60:  uint8(11),
  71377 	61:  uint8(12),
  71378 	62:  uint8(13),
  71379 	63:  uint8(14),
  71380 	64:  uint8(15),
  71381 	66:  uint8(1),
  71382 	67:  uint8(2),
  71383 	68:  uint8(3),
  71384 	69:  uint8(4),
  71385 	70:  uint8(5),
  71386 	71:  uint8(6),
  71387 	72:  uint8(7),
  71388 	73:  uint8(8),
  71389 	74:  uint8(9),
  71390 	75:  uint8(10),
  71391 	76:  uint8(11),
  71392 	77:  uint8(12),
  71393 	78:  uint8(13),
  71394 	79:  uint8(14),
  71395 	80:  uint8(15),
  71396 	81:  uint8(16),
  71397 	82:  uint8(17),
  71398 	83:  uint8(18),
  71399 	84:  uint8(19),
  71400 	85:  uint8(20),
  71401 	86:  uint8(21),
  71402 	87:  uint8(22),
  71403 	88:  uint8(23),
  71404 	89:  uint8(24),
  71405 	90:  uint8(25),
  71406 	91:  uint8(26),
  71407 	92:  uint8(27),
  71408 	93:  uint8(28),
  71409 	94:  uint8(29),
  71410 	95:  uint8(30),
  71411 	96:  uint8(31),
  71412 	98:  uint8(1),
  71413 	99:  uint8(2),
  71414 	100: uint8(3),
  71415 	101: uint8(4),
  71416 	102: uint8(5),
  71417 	103: uint8(6),
  71418 	104: uint8(7),
  71419 	105: uint8(8),
  71420 	106: uint8(9),
  71421 	107: uint8(10),
  71422 	108: uint8(11),
  71423 	109: uint8(12),
  71424 	110: uint8(13),
  71425 	111: uint8(14),
  71426 	112: uint8(15),
  71427 	113: uint8(16),
  71428 	114: uint8(17),
  71429 	115: uint8(18),
  71430 	116: uint8(19),
  71431 	117: uint8(20),
  71432 	118: uint8(21),
  71433 	119: uint8(22),
  71434 	120: uint8(23),
  71435 	121: uint8(24),
  71436 	122: uint8(25),
  71437 	123: uint8(26),
  71438 	124: uint8(27),
  71439 	125: uint8(28),
  71440 	126: uint8(29),
  71441 	127: uint8(30),
  71442 	128: uint8(31),
  71443 	130: uint8(1),
  71444 	131: uint8(2),
  71445 	132: uint8(3),
  71446 	133: uint8(4),
  71447 	134: uint8(5),
  71448 	135: uint8(6),
  71449 	136: uint8(7),
  71450 	137: uint8(8),
  71451 	138: uint8(9),
  71452 	139: uint8(10),
  71453 	140: uint8(11),
  71454 	141: uint8(12),
  71455 	142: uint8(13),
  71456 	143: uint8(14),
  71457 	144: uint8(15),
  71458 	145: uint8(16),
  71459 	146: uint8(17),
  71460 	147: uint8(18),
  71461 	148: uint8(19),
  71462 	149: uint8(20),
  71463 	150: uint8(21),
  71464 	151: uint8(22),
  71465 	152: uint8(23),
  71466 	153: uint8(24),
  71467 	154: uint8(25),
  71468 	155: uint8(26),
  71469 	156: uint8(27),
  71470 	157: uint8(28),
  71471 	158: uint8(29),
  71472 	159: uint8(30),
  71473 	160: uint8(31),
  71474 	161: uint8(32),
  71475 	162: uint8(33),
  71476 	163: uint8(34),
  71477 	164: uint8(35),
  71478 	165: uint8(36),
  71479 	166: uint8(37),
  71480 	167: uint8(38),
  71481 	168: uint8(39),
  71482 	169: uint8(40),
  71483 	170: uint8(41),
  71484 	171: uint8(42),
  71485 	172: uint8(43),
  71486 	173: uint8(44),
  71487 	174: uint8(45),
  71488 	175: uint8(46),
  71489 	176: uint8(47),
  71490 	177: uint8(48),
  71491 	178: uint8(49),
  71492 	179: uint8(50),
  71493 	180: uint8(51),
  71494 	181: uint8(52),
  71495 	182: uint8(53),
  71496 	183: uint8(54),
  71497 	184: uint8(55),
  71498 	185: uint8(56),
  71499 	186: uint8(57),
  71500 	187: uint8(58),
  71501 	188: uint8(59),
  71502 	189: uint8(60),
  71503 	190: uint8(61),
  71504 	191: uint8(62),
  71505 	192: uint8(63),
  71506 	194: uint8(1),
  71507 	195: uint8(2),
  71508 	196: uint8(3),
  71509 	197: uint8(4),
  71510 	198: uint8(5),
  71511 	199: uint8(6),
  71512 	200: uint8(7),
  71513 	201: uint8(8),
  71514 	202: uint8(9),
  71515 	203: uint8(10),
  71516 	204: uint8(11),
  71517 	205: uint8(12),
  71518 	206: uint8(13),
  71519 	207: uint8(14),
  71520 	208: uint8(15),
  71521 	209: uint8(16),
  71522 	210: uint8(17),
  71523 	211: uint8(18),
  71524 	212: uint8(19),
  71525 	213: uint8(20),
  71526 	214: uint8(21),
  71527 	215: uint8(22),
  71528 	216: uint8(23),
  71529 	217: uint8(24),
  71530 	218: uint8(25),
  71531 	219: uint8(26),
  71532 	220: uint8(27),
  71533 	221: uint8(28),
  71534 	222: uint8(29),
  71535 	223: uint8(30),
  71536 	224: uint8(31),
  71537 	225: uint8(32),
  71538 	226: uint8(33),
  71539 	227: uint8(34),
  71540 	228: uint8(35),
  71541 	229: uint8(36),
  71542 	230: uint8(37),
  71543 	231: uint8(38),
  71544 	232: uint8(39),
  71545 	233: uint8(40),
  71546 	234: uint8(41),
  71547 	235: uint8(42),
  71548 	236: uint8(43),
  71549 	237: uint8(44),
  71550 	238: uint8(45),
  71551 	239: uint8(46),
  71552 	240: uint8(47),
  71553 	241: uint8(48),
  71554 	242: uint8(49),
  71555 	243: uint8(50),
  71556 	244: uint8(51),
  71557 	245: uint8(52),
  71558 	246: uint8(53),
  71559 	247: uint8(54),
  71560 	248: uint8(55),
  71561 	249: uint8(56),
  71562 	250: uint8(57),
  71563 	251: uint8(58),
  71564 	252: uint8(59),
  71565 	253: uint8(60),
  71566 	254: uint8(61),
  71567 	255: uint8(62),
  71568 	256: uint8(63),
  71569 	258: uint8(1),
  71570 	259: uint8(2),
  71571 	260: uint8(3),
  71572 	261: uint8(4),
  71573 	262: uint8(5),
  71574 	263: uint8(6),
  71575 	264: uint8(7),
  71576 	265: uint8(8),
  71577 	266: uint8(9),
  71578 	267: uint8(10),
  71579 	268: uint8(11),
  71580 	269: uint8(12),
  71581 	270: uint8(13),
  71582 	271: uint8(14),
  71583 	272: uint8(15),
  71584 	273: uint8(16),
  71585 	274: uint8(17),
  71586 	275: uint8(18),
  71587 	276: uint8(19),
  71588 	277: uint8(20),
  71589 	278: uint8(21),
  71590 	279: uint8(22),
  71591 	280: uint8(23),
  71592 	281: uint8(24),
  71593 	282: uint8(25),
  71594 	283: uint8(26),
  71595 	284: uint8(27),
  71596 	285: uint8(28),
  71597 	286: uint8(29),
  71598 	287: uint8(30),
  71599 	288: uint8(31),
  71600 	289: uint8(32),
  71601 	290: uint8(33),
  71602 	291: uint8(34),
  71603 	292: uint8(35),
  71604 	293: uint8(36),
  71605 	294: uint8(37),
  71606 	295: uint8(38),
  71607 	296: uint8(39),
  71608 	297: uint8(40),
  71609 	298: uint8(41),
  71610 	299: uint8(42),
  71611 	300: uint8(43),
  71612 	301: uint8(44),
  71613 	302: uint8(45),
  71614 	303: uint8(46),
  71615 	304: uint8(47),
  71616 	305: uint8(48),
  71617 	306: uint8(49),
  71618 	307: uint8(50),
  71619 	308: uint8(51),
  71620 	309: uint8(52),
  71621 	310: uint8(53),
  71622 	311: uint8(54),
  71623 	312: uint8(55),
  71624 	313: uint8(56),
  71625 	314: uint8(57),
  71626 	315: uint8(58),
  71627 	316: uint8(59),
  71628 	317: uint8(60),
  71629 	318: uint8(61),
  71630 	319: uint8(62),
  71631 	320: uint8(63),
  71632 	321: uint8(64),
  71633 	322: uint8(65),
  71634 	323: uint8(66),
  71635 	324: uint8(67),
  71636 	325: uint8(68),
  71637 	326: uint8(69),
  71638 	327: uint8(70),
  71639 	328: uint8(71),
  71640 	329: uint8(72),
  71641 	330: uint8(73),
  71642 	331: uint8(74),
  71643 	332: uint8(75),
  71644 	333: uint8(76),
  71645 	334: uint8(77),
  71646 	335: uint8(78),
  71647 	336: uint8(79),
  71648 	337: uint8(80),
  71649 	338: uint8(81),
  71650 	339: uint8(82),
  71651 	340: uint8(83),
  71652 	341: uint8(84),
  71653 	342: uint8(85),
  71654 	343: uint8(86),
  71655 	344: uint8(87),
  71656 	345: uint8(88),
  71657 	346: uint8(89),
  71658 	347: uint8(90),
  71659 	348: uint8(91),
  71660 	349: uint8(92),
  71661 	350: uint8(93),
  71662 	351: uint8(94),
  71663 	352: uint8(95),
  71664 	353: uint8(96),
  71665 	354: uint8(97),
  71666 	355: uint8(98),
  71667 	356: uint8(99),
  71668 	357: uint8(100),
  71669 	358: uint8(101),
  71670 	359: uint8(102),
  71671 	360: uint8(103),
  71672 	361: uint8(104),
  71673 	362: uint8(105),
  71674 	363: uint8(106),
  71675 	364: uint8(107),
  71676 	365: uint8(108),
  71677 	366: uint8(109),
  71678 	367: uint8(110),
  71679 	368: uint8(111),
  71680 	369: uint8(112),
  71681 	370: uint8(113),
  71682 	371: uint8(114),
  71683 	372: uint8(115),
  71684 	373: uint8(116),
  71685 	374: uint8(117),
  71686 	375: uint8(118),
  71687 	376: uint8(119),
  71688 	377: uint8(120),
  71689 	378: uint8(121),
  71690 	379: uint8(122),
  71691 	380: uint8(123),
  71692 	381: uint8(124),
  71693 	382: uint8(125),
  71694 	383: uint8(126),
  71695 	384: uint8(127),
  71696 	386: uint8(1),
  71697 	387: uint8(2),
  71698 	388: uint8(3),
  71699 	389: uint8(4),
  71700 	390: uint8(5),
  71701 	391: uint8(6),
  71702 	392: uint8(7),
  71703 	393: uint8(8),
  71704 	394: uint8(9),
  71705 	395: uint8(10),
  71706 	396: uint8(11),
  71707 	397: uint8(12),
  71708 	398: uint8(13),
  71709 	399: uint8(14),
  71710 	400: uint8(15),
  71711 	401: uint8(16),
  71712 	402: uint8(17),
  71713 	403: uint8(18),
  71714 	404: uint8(19),
  71715 	405: uint8(20),
  71716 	406: uint8(21),
  71717 	407: uint8(22),
  71718 	408: uint8(23),
  71719 	409: uint8(24),
  71720 	410: uint8(25),
  71721 	411: uint8(26),
  71722 	412: uint8(27),
  71723 	413: uint8(28),
  71724 	414: uint8(29),
  71725 	415: uint8(30),
  71726 	416: uint8(31),
  71727 	417: uint8(32),
  71728 	418: uint8(33),
  71729 	419: uint8(34),
  71730 	420: uint8(35),
  71731 	421: uint8(36),
  71732 	422: uint8(37),
  71733 	423: uint8(38),
  71734 	424: uint8(39),
  71735 	425: uint8(40),
  71736 	426: uint8(41),
  71737 	427: uint8(42),
  71738 	428: uint8(43),
  71739 	429: uint8(44),
  71740 	430: uint8(45),
  71741 	431: uint8(46),
  71742 	432: uint8(47),
  71743 	433: uint8(48),
  71744 	434: uint8(49),
  71745 	435: uint8(50),
  71746 	436: uint8(51),
  71747 	437: uint8(52),
  71748 	438: uint8(53),
  71749 	439: uint8(54),
  71750 	440: uint8(55),
  71751 	441: uint8(56),
  71752 	442: uint8(57),
  71753 	443: uint8(58),
  71754 	444: uint8(59),
  71755 	445: uint8(60),
  71756 	446: uint8(61),
  71757 	447: uint8(62),
  71758 	448: uint8(63),
  71759 	449: uint8(64),
  71760 	450: uint8(65),
  71761 	451: uint8(66),
  71762 	452: uint8(67),
  71763 	453: uint8(68),
  71764 	454: uint8(69),
  71765 	455: uint8(70),
  71766 	456: uint8(71),
  71767 	457: uint8(72),
  71768 	458: uint8(73),
  71769 	459: uint8(74),
  71770 	460: uint8(75),
  71771 	461: uint8(76),
  71772 	462: uint8(77),
  71773 	463: uint8(78),
  71774 	464: uint8(79),
  71775 	465: uint8(80),
  71776 	466: uint8(81),
  71777 	467: uint8(82),
  71778 	468: uint8(83),
  71779 	469: uint8(84),
  71780 	470: uint8(85),
  71781 	471: uint8(86),
  71782 	472: uint8(87),
  71783 	473: uint8(88),
  71784 	474: uint8(89),
  71785 	475: uint8(90),
  71786 	476: uint8(91),
  71787 	477: uint8(92),
  71788 	478: uint8(93),
  71789 	479: uint8(94),
  71790 	480: uint8(95),
  71791 	481: uint8(96),
  71792 	482: uint8(97),
  71793 	483: uint8(98),
  71794 	484: uint8(99),
  71795 	485: uint8(100),
  71796 	486: uint8(101),
  71797 	487: uint8(102),
  71798 	488: uint8(103),
  71799 	489: uint8(104),
  71800 	490: uint8(105),
  71801 	491: uint8(106),
  71802 	492: uint8(107),
  71803 	493: uint8(108),
  71804 	494: uint8(109),
  71805 	495: uint8(110),
  71806 	496: uint8(111),
  71807 	497: uint8(112),
  71808 	498: uint8(113),
  71809 	499: uint8(114),
  71810 	500: uint8(115),
  71811 	501: uint8(116),
  71812 	502: uint8(117),
  71813 	503: uint8(118),
  71814 	504: uint8(119),
  71815 	505: uint8(120),
  71816 	506: uint8(121),
  71817 	507: uint8(122),
  71818 	508: uint8(123),
  71819 	509: uint8(124),
  71820 	510: uint8(125),
  71821 	511: uint8(126),
  71822 }
  71823 
  71824 // C documentation
  71825 //
  71826 //	// lookup table for small values of int*log2(int) * (1 << LOG_2_PRECISION_BITS).
  71827 //	// Obtained in Python with:
  71828 //	// a=[ "%d"%i if i<(1<<32) else "%dull"%i
  71829 //	//     for i in [ round((1<<LOG_2_PRECISION_BITS)*math.log2(i)*i) if i
  71830 //	//     else 0 for i in range(256)]]
  71831 //	// print(',\n '.join([','.join(v) for v in batched([i.rjust(15)
  71832 //	//                      for i in a],4)]))
  71833 var kSLog2Table = [256]uint64_t{
  71834 	2:   uint64(16777216),
  71835 	3:   uint64(39886887),
  71836 	4:   uint64(67108864),
  71837 	5:   uint64(97388723),
  71838 	6:   uint64(130105423),
  71839 	7:   uint64(164848600),
  71840 	8:   uint64(201326592),
  71841 	9:   uint64(239321324),
  71842 	10:  uint64(278663526),
  71843 	11:  uint64(319217973),
  71844 	12:  uint64(360874141),
  71845 	13:  uint64(403539997),
  71846 	14:  uint64(447137711),
  71847 	15:  uint64(491600606),
  71848 	16:  uint64(536870912),
  71849 	17:  uint64(582898099),
  71850 	18:  uint64(629637592),
  71851 	19:  uint64(677049776),
  71852 	20:  uint64(725099212),
  71853 	21:  uint64(773754010),
  71854 	22:  uint64(822985323),
  71855 	23:  uint64(872766924),
  71856 	24:  uint64(923074875),
  71857 	25:  uint64(973887230),
  71858 	26:  uint64(1025183802),
  71859 	27:  uint64(1076945958),
  71860 	28:  uint64(1129156447),
  71861 	29:  uint64(1181799249),
  71862 	30:  uint64(1234859451),
  71863 	31:  uint64(1288323135),
  71864 	32:  uint64(1342177280),
  71865 	33:  uint64(1396409681),
  71866 	34:  uint64(1451008871),
  71867 	35:  uint64(1505964059),
  71868 	36:  uint64(1561265072),
  71869 	37:  uint64(1616902301),
  71870 	38:  uint64(1672866655),
  71871 	39:  uint64(1729149526),
  71872 	40:  uint64(1785742744),
  71873 	41:  uint64(1842638548),
  71874 	42:  uint64(1899829557),
  71875 	43:  uint64(1957308741),
  71876 	44:  uint64(2015069397),
  71877 	45:  uint64(2073105127),
  71878 	46:  uint64(2131409817),
  71879 	47:  uint64(2189977618),
  71880 	48:  uint64(2248802933),
  71881 	49:  uint64(2307880396),
  71882 	50:  uint64(2367204859),
  71883 	51:  uint64(2426771383),
  71884 	52:  uint64(2486575220),
  71885 	53:  uint64(2546611805),
  71886 	54:  uint64(2606876748),
  71887 	55:  uint64(2667365819),
  71888 	56:  uint64(2728074942),
  71889 	57:  uint64(2789000187),
  71890 	58:  uint64(2850137762),
  71891 	59:  uint64(2911484006),
  71892 	60:  uint64(2973035382),
  71893 	61:  uint64(3034788471),
  71894 	62:  uint64(3096739966),
  71895 	63:  uint64(3158886666),
  71896 	64:  uint64(3221225472),
  71897 	65:  uint64(3283753383),
  71898 	66:  uint64(3346467489),
  71899 	67:  uint64(3409364969),
  71900 	68:  uint64(3472443085),
  71901 	69:  uint64(3535699182),
  71902 	70:  uint64(3599130679),
  71903 	71:  uint64(3662735070),
  71904 	72:  uint64(3726509920),
  71905 	73:  uint64(3790452862),
  71906 	74:  uint64(3854561593),
  71907 	75:  uint64(3918833872),
  71908 	76:  uint64(3983267519),
  71909 	77:  uint64(4047860410),
  71910 	78:  uint64(4112610476),
  71911 	79:  uint64(4177515704),
  71912 	80:  uint64(4242574127),
  71913 	81:  uint64(4307783833),
  71914 	82:  uint64(4373142952),
  71915 	83:  uint64(4438649662),
  71916 	84:  uint64(4504302186),
  71917 	85:  uint64(4570098787),
  71918 	86:  uint64(4636037770),
  71919 	87:  uint64(4702117480),
  71920 	88:  uint64(4768336298),
  71921 	89:  uint64(4834692645),
  71922 	90:  uint64(4901184974),
  71923 	91:  uint64(4967811774),
  71924 	92:  uint64(5034571569),
  71925 	93:  uint64(5101462912),
  71926 	94:  uint64(5168484389),
  71927 	95:  uint64(5235634615),
  71928 	96:  uint64(5302912235),
  71929 	97:  uint64(5370315922),
  71930 	98:  uint64(5437844376),
  71931 	99:  uint64(5505496324),
  71932 	100: uint64(5573270518),
  71933 	101: uint64(5641165737),
  71934 	102: uint64(5709180782),
  71935 	103: uint64(5777314477),
  71936 	104: uint64(5845565671),
  71937 	105: uint64(5913933235),
  71938 	106: uint64(5982416059),
  71939 	107: uint64(6051013057),
  71940 	108: uint64(6119723161),
  71941 	109: uint64(6188545324),
  71942 	110: uint64(6257478518),
  71943 	111: uint64(6326521733),
  71944 	112: uint64(6395673979),
  71945 	113: uint64(6464934282),
  71946 	114: uint64(6534301685),
  71947 	115: uint64(6603775250),
  71948 	116: uint64(6673354052),
  71949 	117: uint64(6743037185),
  71950 	118: uint64(6812823756),
  71951 	119: uint64(6882712890),
  71952 	120: uint64(6952703725),
  71953 	121: uint64(7022795412),
  71954 	122: uint64(7092987118),
  71955 	123: uint64(7163278025),
  71956 	124: uint64(7233667324),
  71957 	125: uint64(7304154222),
  71958 	126: uint64(7374737939),
  71959 	127: uint64(7445417707),
  71960 	128: uint64(7516192768),
  71961 	129: uint64(7587062379),
  71962 	130: uint64(7658025806),
  71963 	131: uint64(7729082328),
  71964 	132: uint64(7800231234),
  71965 	133: uint64(7871471825),
  71966 	134: uint64(7942803410),
  71967 	135: uint64(8014225311),
  71968 	136: uint64(8085736859),
  71969 	137: uint64(8157337394),
  71970 	138: uint64(8229026267),
  71971 	139: uint64(8300802839),
  71972 	140: uint64(8372666477),
  71973 	141: uint64(8444616560),
  71974 	142: uint64(8516652476),
  71975 	143: uint64(8588773618),
  71976 	144: uint64(8660979393),
  71977 	145: uint64(8733269211),
  71978 	146: uint64(8805642493),
  71979 	147: uint64(8878098667),
  71980 	148: uint64(8950637170),
  71981 	149: uint64(9023257446),
  71982 	150: uint64(9095958945),
  71983 	151: uint64(9168741125),
  71984 	152: uint64(9241603454),
  71985 	153: uint64(9314545403),
  71986 	154: uint64(9387566451),
  71987 	155: uint64(9460666086),
  71988 	156: uint64(9533843800),
  71989 	157: uint64(9607099093),
  71990 	158: uint64(9680431471),
  71991 	159: uint64(9753840445),
  71992 	160: uint64(9827325535),
  71993 	161: uint64(9900886263),
  71994 	162: uint64(9974522161),
  71995 	163: uint64(10048232765),
  71996 	164: uint64(10122017615),
  71997 	165: uint64(10195876260),
  71998 	166: uint64(10269808253),
  71999 	167: uint64(10343813150),
  72000 	168: uint64(10417890516),
  72001 	169: uint64(10492039919),
  72002 	170: uint64(10566260934),
  72003 	171: uint64(10640553138),
  72004 	172: uint64(10714916116),
  72005 	173: uint64(10789349456),
  72006 	174: uint64(10863852751),
  72007 	175: uint64(10938425600),
  72008 	176: uint64(11013067604),
  72009 	177: uint64(11087778372),
  72010 	178: uint64(11162557513),
  72011 	179: uint64(11237404645),
  72012 	180: uint64(11312319387),
  72013 	181: uint64(11387301364),
  72014 	182: uint64(11462350205),
  72015 	183: uint64(11537465541),
  72016 	184: uint64(11612647010),
  72017 	185: uint64(11687894253),
  72018 	186: uint64(11763206912),
  72019 	187: uint64(11838584638),
  72020 	188: uint64(11914027082),
  72021 	189: uint64(11989533899),
  72022 	190: uint64(12065104750),
  72023 	191: uint64(12140739296),
  72024 	192: uint64(12216437206),
  72025 	193: uint64(12292198148),
  72026 	194: uint64(12368021795),
  72027 	195: uint64(12443907826),
  72028 	196: uint64(12519855920),
  72029 	197: uint64(12595865759),
  72030 	198: uint64(12671937032),
  72031 	199: uint64(12748069427),
  72032 	200: uint64(12824262637),
  72033 	201: uint64(12900516358),
  72034 	202: uint64(12976830290),
  72035 	203: uint64(13053204134),
  72036 	204: uint64(13129637595),
  72037 	205: uint64(13206130381),
  72038 	206: uint64(13282682202),
  72039 	207: uint64(13359292772),
  72040 	208: uint64(13435961806),
  72041 	209: uint64(13512689025),
  72042 	210: uint64(13589474149),
  72043 	211: uint64(13666316903),
  72044 	212: uint64(13743217014),
  72045 	213: uint64(13820174211),
  72046 	214: uint64(13897188225),
  72047 	215: uint64(13974258793),
  72048 	216: uint64(14051385649),
  72049 	217: uint64(14128568535),
  72050 	218: uint64(14205807192),
  72051 	219: uint64(14283101363),
  72052 	220: uint64(14360450796),
  72053 	221: uint64(14437855239),
  72054 	222: uint64(14515314443),
  72055 	223: uint64(14592828162),
  72056 	224: uint64(14670396151),
  72057 	225: uint64(14748018167),
  72058 	226: uint64(14825693972),
  72059 	227: uint64(14903423326),
  72060 	228: uint64(14981205995),
  72061 	229: uint64(15059041743),
  72062 	230: uint64(15136930339),
  72063 	231: uint64(15214871554),
  72064 	232: uint64(15292865160),
  72065 	233: uint64(15370910930),
  72066 	234: uint64(15449008641),
  72067 	235: uint64(15527158071),
  72068 	236: uint64(15605359001),
  72069 	237: uint64(15683611210),
  72070 	238: uint64(15761914485),
  72071 	239: uint64(15840268608),
  72072 	240: uint64(15918673369),
  72073 	241: uint64(15997128556),
  72074 	242: uint64(16075633960),
  72075 	243: uint64(16154189373),
  72076 	244: uint64(16232794589),
  72077 	245: uint64(16311449405),
  72078 	246: uint64(16390153617),
  72079 	247: uint64(16468907026),
  72080 	248: uint64(16547709431),
  72081 	249: uint64(16626560636),
  72082 	250: uint64(16705460444),
  72083 	251: uint64(16784408661),
  72084 	252: uint64(16863405094),
  72085 	253: uint64(16942449552),
  72086 	254: uint64(17021541845),
  72087 	255: uint64(17100681785),
  72088 }
  72089 
  72090 var kVP8Log2Range = [128]uint8_t{
  72091 	0:   uint8(7),
  72092 	1:   uint8(6),
  72093 	2:   uint8(6),
  72094 	3:   uint8(5),
  72095 	4:   uint8(5),
  72096 	5:   uint8(5),
  72097 	6:   uint8(5),
  72098 	7:   uint8(4),
  72099 	8:   uint8(4),
  72100 	9:   uint8(4),
  72101 	10:  uint8(4),
  72102 	11:  uint8(4),
  72103 	12:  uint8(4),
  72104 	13:  uint8(4),
  72105 	14:  uint8(4),
  72106 	15:  uint8(3),
  72107 	16:  uint8(3),
  72108 	17:  uint8(3),
  72109 	18:  uint8(3),
  72110 	19:  uint8(3),
  72111 	20:  uint8(3),
  72112 	21:  uint8(3),
  72113 	22:  uint8(3),
  72114 	23:  uint8(3),
  72115 	24:  uint8(3),
  72116 	25:  uint8(3),
  72117 	26:  uint8(3),
  72118 	27:  uint8(3),
  72119 	28:  uint8(3),
  72120 	29:  uint8(3),
  72121 	30:  uint8(3),
  72122 	31:  uint8(2),
  72123 	32:  uint8(2),
  72124 	33:  uint8(2),
  72125 	34:  uint8(2),
  72126 	35:  uint8(2),
  72127 	36:  uint8(2),
  72128 	37:  uint8(2),
  72129 	38:  uint8(2),
  72130 	39:  uint8(2),
  72131 	40:  uint8(2),
  72132 	41:  uint8(2),
  72133 	42:  uint8(2),
  72134 	43:  uint8(2),
  72135 	44:  uint8(2),
  72136 	45:  uint8(2),
  72137 	46:  uint8(2),
  72138 	47:  uint8(2),
  72139 	48:  uint8(2),
  72140 	49:  uint8(2),
  72141 	50:  uint8(2),
  72142 	51:  uint8(2),
  72143 	52:  uint8(2),
  72144 	53:  uint8(2),
  72145 	54:  uint8(2),
  72146 	55:  uint8(2),
  72147 	56:  uint8(2),
  72148 	57:  uint8(2),
  72149 	58:  uint8(2),
  72150 	59:  uint8(2),
  72151 	60:  uint8(2),
  72152 	61:  uint8(2),
  72153 	62:  uint8(2),
  72154 	63:  uint8(1),
  72155 	64:  uint8(1),
  72156 	65:  uint8(1),
  72157 	66:  uint8(1),
  72158 	67:  uint8(1),
  72159 	68:  uint8(1),
  72160 	69:  uint8(1),
  72161 	70:  uint8(1),
  72162 	71:  uint8(1),
  72163 	72:  uint8(1),
  72164 	73:  uint8(1),
  72165 	74:  uint8(1),
  72166 	75:  uint8(1),
  72167 	76:  uint8(1),
  72168 	77:  uint8(1),
  72169 	78:  uint8(1),
  72170 	79:  uint8(1),
  72171 	80:  uint8(1),
  72172 	81:  uint8(1),
  72173 	82:  uint8(1),
  72174 	83:  uint8(1),
  72175 	84:  uint8(1),
  72176 	85:  uint8(1),
  72177 	86:  uint8(1),
  72178 	87:  uint8(1),
  72179 	88:  uint8(1),
  72180 	89:  uint8(1),
  72181 	90:  uint8(1),
  72182 	91:  uint8(1),
  72183 	92:  uint8(1),
  72184 	93:  uint8(1),
  72185 	94:  uint8(1),
  72186 	95:  uint8(1),
  72187 	96:  uint8(1),
  72188 	97:  uint8(1),
  72189 	98:  uint8(1),
  72190 	99:  uint8(1),
  72191 	100: uint8(1),
  72192 	101: uint8(1),
  72193 	102: uint8(1),
  72194 	103: uint8(1),
  72195 	104: uint8(1),
  72196 	105: uint8(1),
  72197 	106: uint8(1),
  72198 	107: uint8(1),
  72199 	108: uint8(1),
  72200 	109: uint8(1),
  72201 	110: uint8(1),
  72202 	111: uint8(1),
  72203 	112: uint8(1),
  72204 	113: uint8(1),
  72205 	114: uint8(1),
  72206 	115: uint8(1),
  72207 	116: uint8(1),
  72208 	117: uint8(1),
  72209 	118: uint8(1),
  72210 	119: uint8(1),
  72211 	120: uint8(1),
  72212 	121: uint8(1),
  72213 	122: uint8(1),
  72214 	123: uint8(1),
  72215 	124: uint8(1),
  72216 	125: uint8(1),
  72217 	126: uint8(1),
  72218 }
  72219 
  72220 // C documentation
  72221 //
  72222 //	// range = ((range - 1) << kVP8Log2Range[range]) + 1
  72223 var kVP8NewRange = [128]uint8_t{
  72224 	0:   uint8(127),
  72225 	1:   uint8(127),
  72226 	2:   uint8(191),
  72227 	3:   uint8(127),
  72228 	4:   uint8(159),
  72229 	5:   uint8(191),
  72230 	6:   uint8(223),
  72231 	7:   uint8(127),
  72232 	8:   uint8(143),
  72233 	9:   uint8(159),
  72234 	10:  uint8(175),
  72235 	11:  uint8(191),
  72236 	12:  uint8(207),
  72237 	13:  uint8(223),
  72238 	14:  uint8(239),
  72239 	15:  uint8(127),
  72240 	16:  uint8(135),
  72241 	17:  uint8(143),
  72242 	18:  uint8(151),
  72243 	19:  uint8(159),
  72244 	20:  uint8(167),
  72245 	21:  uint8(175),
  72246 	22:  uint8(183),
  72247 	23:  uint8(191),
  72248 	24:  uint8(199),
  72249 	25:  uint8(207),
  72250 	26:  uint8(215),
  72251 	27:  uint8(223),
  72252 	28:  uint8(231),
  72253 	29:  uint8(239),
  72254 	30:  uint8(247),
  72255 	31:  uint8(127),
  72256 	32:  uint8(131),
  72257 	33:  uint8(135),
  72258 	34:  uint8(139),
  72259 	35:  uint8(143),
  72260 	36:  uint8(147),
  72261 	37:  uint8(151),
  72262 	38:  uint8(155),
  72263 	39:  uint8(159),
  72264 	40:  uint8(163),
  72265 	41:  uint8(167),
  72266 	42:  uint8(171),
  72267 	43:  uint8(175),
  72268 	44:  uint8(179),
  72269 	45:  uint8(183),
  72270 	46:  uint8(187),
  72271 	47:  uint8(191),
  72272 	48:  uint8(195),
  72273 	49:  uint8(199),
  72274 	50:  uint8(203),
  72275 	51:  uint8(207),
  72276 	52:  uint8(211),
  72277 	53:  uint8(215),
  72278 	54:  uint8(219),
  72279 	55:  uint8(223),
  72280 	56:  uint8(227),
  72281 	57:  uint8(231),
  72282 	58:  uint8(235),
  72283 	59:  uint8(239),
  72284 	60:  uint8(243),
  72285 	61:  uint8(247),
  72286 	62:  uint8(251),
  72287 	63:  uint8(127),
  72288 	64:  uint8(129),
  72289 	65:  uint8(131),
  72290 	66:  uint8(133),
  72291 	67:  uint8(135),
  72292 	68:  uint8(137),
  72293 	69:  uint8(139),
  72294 	70:  uint8(141),
  72295 	71:  uint8(143),
  72296 	72:  uint8(145),
  72297 	73:  uint8(147),
  72298 	74:  uint8(149),
  72299 	75:  uint8(151),
  72300 	76:  uint8(153),
  72301 	77:  uint8(155),
  72302 	78:  uint8(157),
  72303 	79:  uint8(159),
  72304 	80:  uint8(161),
  72305 	81:  uint8(163),
  72306 	82:  uint8(165),
  72307 	83:  uint8(167),
  72308 	84:  uint8(169),
  72309 	85:  uint8(171),
  72310 	86:  uint8(173),
  72311 	87:  uint8(175),
  72312 	88:  uint8(177),
  72313 	89:  uint8(179),
  72314 	90:  uint8(181),
  72315 	91:  uint8(183),
  72316 	92:  uint8(185),
  72317 	93:  uint8(187),
  72318 	94:  uint8(189),
  72319 	95:  uint8(191),
  72320 	96:  uint8(193),
  72321 	97:  uint8(195),
  72322 	98:  uint8(197),
  72323 	99:  uint8(199),
  72324 	100: uint8(201),
  72325 	101: uint8(203),
  72326 	102: uint8(205),
  72327 	103: uint8(207),
  72328 	104: uint8(209),
  72329 	105: uint8(211),
  72330 	106: uint8(213),
  72331 	107: uint8(215),
  72332 	108: uint8(217),
  72333 	109: uint8(219),
  72334 	110: uint8(221),
  72335 	111: uint8(223),
  72336 	112: uint8(225),
  72337 	113: uint8(227),
  72338 	114: uint8(229),
  72339 	115: uint8(231),
  72340 	116: uint8(233),
  72341 	117: uint8(235),
  72342 	118: uint8(237),
  72343 	119: uint8(239),
  72344 	120: uint8(241),
  72345 	121: uint8(243),
  72346 	122: uint8(245),
  72347 	123: uint8(247),
  72348 	124: uint8(249),
  72349 	125: uint8(251),
  72350 	126: uint8(253),
  72351 	127: uint8(127),
  72352 }
  72353 
  72354 var __ccgo_ts = (*reflect.StringHeader)(unsafe.Pointer(&__ccgo_ts1)).Data
  72355 
  72356 var __ccgo_ts1 = "Alpha decoder initialization failed.\x00Could not decode alpha data.\x00Frame setup failed\x00thread initialization failed.\x00no memory during frame initialization.\x00OK\x00no object\x00null VP8Io passed to VP8GetHeaders()\x00Truncated header.\x00Incorrect keyframe parameters.\x00Frame not displayable.\x00cannot parse picture header\x00Bad code word\x00bad partition length\x00cannot parse segment header\x00cannot parse filter header\x00cannot parse partitions\x00Not a key frame.\x00Premature end-of-partition0 encountered.\x00Premature end-of-file encountered.\x00Output aborted.\x00NULL VP8Io parameter in VP8Decode().\x00RIFF\x00WEBP\x00VP8X\x00VP8 \x00VP8L\x00ALPH\x00assembler statements not supported\x00cpu.c\x00GetCPUInfo\x00xgetbv\x00"