go-libwebp

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

libwebp_darwin_arm64.go (2234950B)


      1 // Code generated for darwin/arm64 by 'ccgo --goos=darwin --goarch=arm64 --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_arm64.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 && arm64
      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__ = 21
    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__ = 21
    765 const __FLT64X_DENORM_MIN__ = 3.64519953188247460252840593361941982e-4951
    766 const __FLT64X_DIG__ = 18
    767 const __FLT64X_EPSILON__ = 1.08420217248550443400745280086994171e-19
    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__ = 64
    773 const __FLT64X_MAX_10_EXP__ = 4932
    774 const __FLT64X_MAX_EXP__ = 16384
    775 const __FLT64X_MAX__ = "1.18973149535723176502126385303097021e+4932"
    776 const __FLT64X_MIN__ = 3.36210314311209350626267781732175260e-4932
    777 const __FLT64X_NORM_MAX__ = "1.18973149535723176502126385303097021e+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__ = 21
    958 const __LDBL_DENORM_MIN__ = 3.64519953188247460252840593361941982e-4951
    959 const __LDBL_DIG__ = 18
    960 const __LDBL_EPSILON__ = 1.08420217248550443400745280086994171e-19
    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__ = 64
    966 const __LDBL_MAX_10_EXP__ = 4932
    967 const __LDBL_MAX_EXP__ = 16384
    968 const __LDBL_MAX__ = "1.18973149535723176502126385303097021e+4932"
    969 const __LDBL_MIN__ = 3.36210314311209350626267781732175260e-4932
    970 const __LDBL_NORM_MAX__ = "1.18973149535723176502126385303097021e+4932"
    971 const __LONG_LONG_MAX__ = 0x7fffffffffffffff
    972 const __LONG_LONG_WIDTH__ = 64
    973 const __LONG_MAX__ = 0x7fffffffffffffff
    974 const __LONG_WIDTH__ = 64
    975 const __LP64__ = 1
    976 const __MAC_10_0 = 1000
    977 const __MAC_10_1 = 1010
    978 const __MAC_10_10 = 101000
    979 const __MAC_10_10_2 = 101002
    980 const __MAC_10_10_3 = 101003
    981 const __MAC_10_11 = 101100
    982 const __MAC_10_11_2 = 101102
    983 const __MAC_10_11_3 = 101103
    984 const __MAC_10_11_4 = 101104
    985 const __MAC_10_12 = 101200
    986 const __MAC_10_12_1 = 101201
    987 const __MAC_10_12_2 = 101202
    988 const __MAC_10_12_4 = 101204
    989 const __MAC_10_13 = 101300
    990 const __MAC_10_13_1 = 101301
    991 const __MAC_10_13_2 = 101302
    992 const __MAC_10_13_4 = 101304
    993 const __MAC_10_14 = 101400
    994 const __MAC_10_14_1 = 101401
    995 const __MAC_10_14_4 = 101404
    996 const __MAC_10_14_5 = 101405
    997 const __MAC_10_14_6 = 101406
    998 const __MAC_10_15 = 101500
    999 const __MAC_10_15_1 = 101501
   1000 const __MAC_10_15_4 = 101504
   1001 const __MAC_10_16 = 101600
   1002 const __MAC_10_2 = 1020
   1003 const __MAC_10_3 = 1030
   1004 const __MAC_10_4 = 1040
   1005 const __MAC_10_5 = 1050
   1006 const __MAC_10_6 = 1060
   1007 const __MAC_10_7 = 1070
   1008 const __MAC_10_8 = 1080
   1009 const __MAC_10_9 = 1090
   1010 const __MAC_11_0 = 110000
   1011 const __MAC_11_1 = 110100
   1012 const __MAC_11_3 = 110300
   1013 const __MAC_11_4 = 110400
   1014 const __MAC_11_5 = 110500
   1015 const __MAC_11_6 = 110600
   1016 const __MAC_12_0 = 120000
   1017 const __MAC_12_1 = 120100
   1018 const __MAC_12_2 = 120200
   1019 const __MAC_12_3 = 120300
   1020 const __MAC_12_4 = 120400
   1021 const __MAC_12_5 = 120500
   1022 const __MAC_12_6 = 120600
   1023 const __MAC_12_7 = 120700
   1024 const __MAC_13_0 = 130000
   1025 const __MAC_13_1 = 130100
   1026 const __MAC_13_2 = 130200
   1027 const __MAC_13_3 = 130300
   1028 const __MAC_13_4 = 130400
   1029 const __MAC_13_5 = 130500
   1030 const __MAC_13_6 = 130600
   1031 const __MAC_13_7 = 130700
   1032 const __MAC_14_0 = 140000
   1033 const __MAC_14_1 = 140100
   1034 const __MAC_14_2 = 140200
   1035 const __MAC_14_3 = 140300
   1036 const __MAC_14_4 = 140400
   1037 const __MAC_14_5 = 140500
   1038 const __MAC_14_6 = 140600
   1039 const __MAC_14_7 = 140700
   1040 const __MAC_15_0 = 150000
   1041 const __MAC_15_1 = 150100
   1042 const __MAC_15_2 = 150200
   1043 const __MAC_15_3 = 150300
   1044 const __MAC_15_4 = 150400
   1045 const __MAC_15_5 = 150500
   1046 const __MMX_WITH_SSE__ = 1
   1047 const __MMX__ = 1
   1048 const __NO_INLINE__ = 1
   1049 const __ORDER_BIG_ENDIAN__ = 4321
   1050 const __ORDER_LITTLE_ENDIAN__ = 1234
   1051 const __ORDER_PDP_ENDIAN__ = 3412
   1052 const __PIC__ = 2
   1053 const __PIE__ = 2
   1054 const __PRAGMA_REDEFINE_EXTNAME = 1
   1055 const __PRETTY_FUNCTION__ = "__func__"
   1056 const __PRI_64_LENGTH_MODIFIER__ = "ll"
   1057 const __PRI_8_LENGTH_MODIFIER__ = "hh"
   1058 const __PRI_MAX_LENGTH_MODIFIER__ = "j"
   1059 const __PTHREAD_ATTR_SIZE__ = 56
   1060 const __PTHREAD_CONDATTR_SIZE__ = 8
   1061 const __PTHREAD_COND_SIZE__ = 40
   1062 const __PTHREAD_MUTEXATTR_SIZE__ = 8
   1063 const __PTHREAD_MUTEX_SIZE__ = 56
   1064 const __PTHREAD_ONCE_SIZE__ = 8
   1065 const __PTHREAD_RWLOCKATTR_SIZE__ = 16
   1066 const __PTHREAD_RWLOCK_SIZE__ = 192
   1067 const __PTHREAD_SIZE__ = 8176
   1068 const __PTRDIFF_MAX__ = 0x7fffffffffffffff
   1069 const __PTRDIFF_WIDTH__ = 64
   1070 const __SCHAR_MAX__ = 0x7f
   1071 const __SCHAR_WIDTH__ = 8
   1072 const __SCN_64_LENGTH_MODIFIER__ = "ll"
   1073 const __SCN_MAX_LENGTH_MODIFIER__ = "j"
   1074 const __SEG_FS = 1
   1075 const __SEG_GS = 1
   1076 const __SHRT_MAX__ = 0x7fff
   1077 const __SHRT_WIDTH__ = 16
   1078 const __SIG_ATOMIC_MAX__ = 0x7fffffff
   1079 const __SIG_ATOMIC_TYPE__ = "int"
   1080 const __SIG_ATOMIC_WIDTH__ = 32
   1081 const __SIZEOF_DOUBLE__ = 8
   1082 const __SIZEOF_FLOAT128__ = 16
   1083 const __SIZEOF_FLOAT80__ = 16
   1084 const __SIZEOF_FLOAT__ = 4
   1085 const __SIZEOF_INT128__ = 16
   1086 const __SIZEOF_INT__ = 4
   1087 const __SIZEOF_LONG_DOUBLE__ = 8
   1088 const __SIZEOF_LONG_LONG__ = 8
   1089 const __SIZEOF_LONG__ = 8
   1090 const __SIZEOF_POINTER__ = 8
   1091 const __SIZEOF_PTRDIFF_T__ = 8
   1092 const __SIZEOF_SHORT__ = 2
   1093 const __SIZEOF_SIZE_T__ = 8
   1094 const __SIZEOF_WCHAR_T__ = 4
   1095 const __SIZEOF_WINT_T__ = 4
   1096 const __SIZE_MAX__ = 0xffffffffffffffff
   1097 const __SIZE_WIDTH__ = 64
   1098 const __SSE2_MATH__ = 1
   1099 const __SSE2__ = 1
   1100 const __SSE_MATH__ = 1
   1101 const __SSE__ = 1
   1102 const __SSP_STRONG__ = 3
   1103 const __STDC_EMBED_EMPTY__ = 2
   1104 const __STDC_EMBED_FOUND__ = 1
   1105 const __STDC_EMBED_NOT_FOUND__ = 0
   1106 const __STDC_HOSTED__ = 1
   1107 const __STDC_UTF_16__ = 1
   1108 const __STDC_UTF_32__ = 1
   1109 const __STDC_VERSION__ = 202311
   1110 const __STDC_WANT_LIB_EXT1__ = 1
   1111 const __STDC__ = 1
   1112 const __TVOS_10_0 = 100000
   1113 const __TVOS_10_0_1 = 100001
   1114 const __TVOS_10_1 = 100100
   1115 const __TVOS_10_2 = 100200
   1116 const __TVOS_11_0 = 110000
   1117 const __TVOS_11_1 = 110100
   1118 const __TVOS_11_2 = 110200
   1119 const __TVOS_11_3 = 110300
   1120 const __TVOS_11_4 = 110400
   1121 const __TVOS_12_0 = 120000
   1122 const __TVOS_12_1 = 120100
   1123 const __TVOS_12_2 = 120200
   1124 const __TVOS_12_3 = 120300
   1125 const __TVOS_12_4 = 120400
   1126 const __TVOS_13_0 = 130000
   1127 const __TVOS_13_2 = 130200
   1128 const __TVOS_13_3 = 130300
   1129 const __TVOS_13_4 = 130400
   1130 const __TVOS_14_0 = 140000
   1131 const __TVOS_14_1 = 140100
   1132 const __TVOS_14_2 = 140200
   1133 const __TVOS_14_3 = 140300
   1134 const __TVOS_14_5 = 140500
   1135 const __TVOS_14_6 = 140600
   1136 const __TVOS_14_7 = 140700
   1137 const __TVOS_15_0 = 150000
   1138 const __TVOS_15_1 = 150100
   1139 const __TVOS_15_2 = 150200
   1140 const __TVOS_15_3 = 150300
   1141 const __TVOS_15_4 = 150400
   1142 const __TVOS_15_5 = 150500
   1143 const __TVOS_15_6 = 150600
   1144 const __TVOS_16_0 = 160000
   1145 const __TVOS_16_1 = 160100
   1146 const __TVOS_16_2 = 160200
   1147 const __TVOS_16_3 = 160300
   1148 const __TVOS_16_4 = 160400
   1149 const __TVOS_16_5 = 160500
   1150 const __TVOS_16_6 = 160600
   1151 const __TVOS_17_0 = 170000
   1152 const __TVOS_17_1 = 170100
   1153 const __TVOS_17_2 = 170200
   1154 const __TVOS_17_3 = 170300
   1155 const __TVOS_17_4 = 170400
   1156 const __TVOS_17_5 = 170500
   1157 const __TVOS_17_6 = 170600
   1158 const __TVOS_18_0 = 180000
   1159 const __TVOS_18_1 = 180100
   1160 const __TVOS_18_2 = 180200
   1161 const __TVOS_18_3 = 180300
   1162 const __TVOS_18_4 = 180400
   1163 const __TVOS_18_5 = 180500
   1164 const __TVOS_9_0 = 90000
   1165 const __TVOS_9_1 = 90100
   1166 const __TVOS_9_2 = 90200
   1167 const __UINT16_MAX__ = 0xffff
   1168 const __UINT32_MAX__ = 0xffffffff
   1169 const __UINT64_MAX__ = 0xffffffffffffffff
   1170 const __UINT8_MAX__ = 0xff
   1171 const __UINTMAX_MAX__ = 0xffffffffffffffff
   1172 const __UINTPTR_MAX__ = 0xffffffffffffffff
   1173 const __UINT_FAST16_MAX__ = 0xffffffffffffffff
   1174 const __UINT_FAST32_MAX__ = 0xffffffffffffffff
   1175 const __UINT_FAST64_MAX__ = 0xffffffffffffffff
   1176 const __UINT_FAST8_MAX__ = 0xff
   1177 const __UINT_LEAST16_MAX__ = 0xffff
   1178 const __UINT_LEAST32_MAX__ = 0xffffffff
   1179 const __UINT_LEAST64_MAX__ = 0xffffffffffffffff
   1180 const __UINT_LEAST8_MAX__ = 0xff
   1181 const __VERSION__ = "16.2.1 20260810"
   1182 const __VISIONOS_1_0 = 10000
   1183 const __VISIONOS_1_1 = 10100
   1184 const __VISIONOS_1_2 = 10200
   1185 const __VISIONOS_1_3 = 10300
   1186 const __VISIONOS_2_0 = 20000
   1187 const __VISIONOS_2_1 = 20100
   1188 const __VISIONOS_2_2 = 20200
   1189 const __VISIONOS_2_3 = 20300
   1190 const __VISIONOS_2_4 = 20400
   1191 const __VISIONOS_2_5 = 20500
   1192 const __WATCHOS_10_0 = 100000
   1193 const __WATCHOS_10_1 = 100100
   1194 const __WATCHOS_10_2 = 100200
   1195 const __WATCHOS_10_3 = 100300
   1196 const __WATCHOS_10_4 = 100400
   1197 const __WATCHOS_10_5 = 100500
   1198 const __WATCHOS_10_6 = 100600
   1199 const __WATCHOS_10_7 = 100700
   1200 const __WATCHOS_11_0 = 110000
   1201 const __WATCHOS_11_1 = 110100
   1202 const __WATCHOS_11_2 = 110200
   1203 const __WATCHOS_11_3 = 110300
   1204 const __WATCHOS_11_4 = 110400
   1205 const __WATCHOS_11_5 = 110500
   1206 const __WATCHOS_1_0 = 10000
   1207 const __WATCHOS_2_0 = 20000
   1208 const __WATCHOS_2_1 = 20100
   1209 const __WATCHOS_2_2 = 20200
   1210 const __WATCHOS_3_0 = 30000
   1211 const __WATCHOS_3_1 = 30100
   1212 const __WATCHOS_3_1_1 = 30101
   1213 const __WATCHOS_3_2 = 30200
   1214 const __WATCHOS_4_0 = 40000
   1215 const __WATCHOS_4_1 = 40100
   1216 const __WATCHOS_4_2 = 40200
   1217 const __WATCHOS_4_3 = 40300
   1218 const __WATCHOS_5_0 = 50000
   1219 const __WATCHOS_5_1 = 50100
   1220 const __WATCHOS_5_2 = 50200
   1221 const __WATCHOS_5_3 = 50300
   1222 const __WATCHOS_6_0 = 60000
   1223 const __WATCHOS_6_1 = 60100
   1224 const __WATCHOS_6_2 = 60200
   1225 const __WATCHOS_7_0 = 70000
   1226 const __WATCHOS_7_1 = 70100
   1227 const __WATCHOS_7_2 = 70200
   1228 const __WATCHOS_7_3 = 70300
   1229 const __WATCHOS_7_4 = 70400
   1230 const __WATCHOS_7_5 = 70500
   1231 const __WATCHOS_7_6 = 70600
   1232 const __WATCHOS_8_0 = 80000
   1233 const __WATCHOS_8_1 = 80100
   1234 const __WATCHOS_8_3 = 80300
   1235 const __WATCHOS_8_4 = 80400
   1236 const __WATCHOS_8_5 = 80500
   1237 const __WATCHOS_8_6 = 80600
   1238 const __WATCHOS_8_7 = 80700
   1239 const __WATCHOS_8_8 = 80800
   1240 const __WATCHOS_9_0 = 90000
   1241 const __WATCHOS_9_1 = 90100
   1242 const __WATCHOS_9_2 = 90200
   1243 const __WATCHOS_9_3 = 90300
   1244 const __WATCHOS_9_4 = 90400
   1245 const __WATCHOS_9_5 = 90500
   1246 const __WATCHOS_9_6 = 90600
   1247 const __WCHAR_MAX__ = 0x7fffffff
   1248 const __WCHAR_TYPE__ = "int"
   1249 const __WCHAR_WIDTH__ = 32
   1250 const __WINT_MAX__ = 0xffffffff
   1251 const __WINT_MIN__ = 0
   1252 const __WINT_WIDTH__ = 32
   1253 const __WORDSIZE = 64
   1254 const __amd64 = 1
   1255 const __amd64__ = 1
   1256 const __code_model_small__ = 1
   1257 const __const = "const"
   1258 const __gnu_linux__ = 1
   1259 const __has_ptrcheck = 0
   1260 const __has_safe_buffers = 0
   1261 const __k8 = 1
   1262 const __k8__ = 1
   1263 const __linux = 1
   1264 const __linux__ = 1
   1265 const __pic__ = 2
   1266 const __pie__ = 2
   1267 const __restrict = "restrict"
   1268 const __restrict_arr = "restrict"
   1269 const __signed = "signed"
   1270 const __unix = 1
   1271 const __unix__ = 1
   1272 const __volatile = "volatile"
   1273 const __x86_64 = 1
   1274 const __x86_64__ = 1
   1275 const false1 = 0
   1276 const linux = 1
   1277 const ru_first = "ru_ixrss"
   1278 const ru_last = "ru_nivcsw"
   1279 const static_assert = "_Static_assert"
   1280 const sv_onstack = "sv_flags"
   1281 const true1 = 1
   1282 const unix = 1
   1283 
   1284 /* C23 keywords, no longer defined as macros by <stdbool.h> and <stddef.h>. */
   1285 
   1286 type __builtin_va_list = uintptr
   1287 
   1288 type __predefined_size_t = uint64
   1289 
   1290 type __predefined_wchar_t = int32
   1291 
   1292 type __predefined_ptrdiff_t = int64
   1293 
   1294 type __int8_t = int8
   1295 
   1296 type __uint8_t = uint8
   1297 
   1298 type __int16_t = int16
   1299 
   1300 type __uint16_t = uint16
   1301 
   1302 type __int32_t = int32
   1303 
   1304 type __uint32_t = uint32
   1305 
   1306 type __int64_t = int64
   1307 
   1308 type __uint64_t = uint64
   1309 
   1310 type __darwin_intptr_t = int64
   1311 
   1312 type __darwin_natural_t = uint32
   1313 
   1314 type __darwin_ct_rune_t = int32
   1315 
   1316 type __mbstate_t = struct {
   1317 	F_mbstateL  [0]int64
   1318 	F__mbstate8 [128]int8
   1319 }
   1320 
   1321 type __darwin_mbstate_t = struct {
   1322 	F_mbstateL  [0]int64
   1323 	F__mbstate8 [128]int8
   1324 }
   1325 
   1326 type __darwin_ptrdiff_t = int64
   1327 
   1328 type __darwin_size_t = uint64
   1329 
   1330 type __darwin_va_list = uintptr
   1331 
   1332 type __darwin_wchar_t = int32
   1333 
   1334 type __darwin_rune_t = int32
   1335 
   1336 type __darwin_wint_t = uint32
   1337 
   1338 type __darwin_clock_t = uint64
   1339 
   1340 type __darwin_socklen_t = uint32
   1341 
   1342 type __darwin_ssize_t = int64
   1343 
   1344 type __darwin_time_t = int64
   1345 
   1346 type __darwin_blkcnt_t = int64
   1347 
   1348 type __darwin_blksize_t = int32
   1349 
   1350 type __darwin_dev_t = int32
   1351 
   1352 type __darwin_fsblkcnt_t = uint32
   1353 
   1354 type __darwin_fsfilcnt_t = uint32
   1355 
   1356 type __darwin_gid_t = uint32
   1357 
   1358 type __darwin_id_t = uint32
   1359 
   1360 type __darwin_ino64_t = uint64
   1361 
   1362 type __darwin_ino_t = uint64
   1363 
   1364 type __darwin_mach_port_name_t = uint32
   1365 
   1366 type __darwin_mach_port_t = uint32
   1367 
   1368 type __darwin_mode_t = uint16
   1369 
   1370 type __darwin_off_t = int64
   1371 
   1372 type __darwin_pid_t = int32
   1373 
   1374 type __darwin_sigset_t = uint32
   1375 
   1376 type __darwin_suseconds_t = int32
   1377 
   1378 type __darwin_uid_t = uint32
   1379 
   1380 type __darwin_useconds_t = uint32
   1381 
   1382 type __darwin_uuid_t = [16]uint8
   1383 
   1384 type __darwin_uuid_string_t = [37]int8
   1385 
   1386 type __darwin_pthread_handler_rec = struct {
   1387 	F__routine uintptr
   1388 	F__arg     uintptr
   1389 	F__next    uintptr
   1390 }
   1391 
   1392 type _opaque_pthread_attr_t = struct {
   1393 	F__sig    int64
   1394 	F__opaque [56]int8
   1395 }
   1396 
   1397 type _opaque_pthread_cond_t = struct {
   1398 	F__sig    int64
   1399 	F__opaque [40]int8
   1400 }
   1401 
   1402 type _opaque_pthread_condattr_t = struct {
   1403 	F__sig    int64
   1404 	F__opaque [8]int8
   1405 }
   1406 
   1407 type _opaque_pthread_mutex_t = struct {
   1408 	F__sig    int64
   1409 	F__opaque [56]int8
   1410 }
   1411 
   1412 type _opaque_pthread_mutexattr_t = struct {
   1413 	F__sig    int64
   1414 	F__opaque [8]int8
   1415 }
   1416 
   1417 type _opaque_pthread_once_t = struct {
   1418 	F__sig    int64
   1419 	F__opaque [8]int8
   1420 }
   1421 
   1422 type _opaque_pthread_rwlock_t = struct {
   1423 	F__sig    int64
   1424 	F__opaque [192]int8
   1425 }
   1426 
   1427 type _opaque_pthread_rwlockattr_t = struct {
   1428 	F__sig    int64
   1429 	F__opaque [16]int8
   1430 }
   1431 
   1432 type _opaque_pthread_t = struct {
   1433 	F__sig           int64
   1434 	F__cleanup_stack uintptr
   1435 	F__opaque        [8176]int8
   1436 }
   1437 
   1438 type __darwin_pthread_attr_t = struct {
   1439 	F__sig    int64
   1440 	F__opaque [56]int8
   1441 }
   1442 
   1443 type __darwin_pthread_cond_t = struct {
   1444 	F__sig    int64
   1445 	F__opaque [40]int8
   1446 }
   1447 
   1448 type __darwin_pthread_condattr_t = struct {
   1449 	F__sig    int64
   1450 	F__opaque [8]int8
   1451 }
   1452 
   1453 type __darwin_pthread_key_t = uint64
   1454 
   1455 type __darwin_pthread_mutex_t = struct {
   1456 	F__sig    int64
   1457 	F__opaque [56]int8
   1458 }
   1459 
   1460 type __darwin_pthread_mutexattr_t = struct {
   1461 	F__sig    int64
   1462 	F__opaque [8]int8
   1463 }
   1464 
   1465 type __darwin_pthread_once_t = struct {
   1466 	F__sig    int64
   1467 	F__opaque [8]int8
   1468 }
   1469 
   1470 type __darwin_pthread_rwlock_t = struct {
   1471 	F__sig    int64
   1472 	F__opaque [192]int8
   1473 }
   1474 
   1475 type __darwin_pthread_rwlockattr_t = struct {
   1476 	F__sig    int64
   1477 	F__opaque [16]int8
   1478 }
   1479 
   1480 type __darwin_pthread_t = uintptr
   1481 
   1482 type __darwin_nl_item = int32
   1483 
   1484 type __darwin_wctrans_t = int32
   1485 
   1486 type __darwin_wctype_t = uint32
   1487 
   1488 type idtype_t = int32
   1489 
   1490 const P_ALL = 0
   1491 const P_PID = 1
   1492 const P_PGID = 2
   1493 
   1494 type pid_t = int32
   1495 
   1496 type id_t = uint32
   1497 
   1498 type sig_atomic_t = int32
   1499 
   1500 type int8_t = int8
   1501 
   1502 type int16_t = int16
   1503 
   1504 type int32_t = int32
   1505 
   1506 type int64_t = int64
   1507 
   1508 type u_int8_t = uint8
   1509 
   1510 type u_int16_t = uint16
   1511 
   1512 type u_int32_t = uint32
   1513 
   1514 type u_int64_t = uint64
   1515 
   1516 type register_t = int64
   1517 
   1518 type intptr_t = int64
   1519 
   1520 type uintptr_t = uint64
   1521 
   1522 type user_addr_t = uint64
   1523 
   1524 type user_size_t = uint64
   1525 
   1526 type user_ssize_t = int64
   1527 
   1528 type user_long_t = int64
   1529 
   1530 type user_ulong_t = uint64
   1531 
   1532 type user_time_t = int64
   1533 
   1534 type user_off_t = int64
   1535 
   1536 type syscall_arg_t = uint64
   1537 
   1538 type __darwin_i386_thread_state = struct {
   1539 	F__eax    uint32
   1540 	F__ebx    uint32
   1541 	F__ecx    uint32
   1542 	F__edx    uint32
   1543 	F__edi    uint32
   1544 	F__esi    uint32
   1545 	F__ebp    uint32
   1546 	F__esp    uint32
   1547 	F__ss     uint32
   1548 	F__eflags uint32
   1549 	F__eip    uint32
   1550 	F__cs     uint32
   1551 	F__ds     uint32
   1552 	F__es     uint32
   1553 	F__fs     uint32
   1554 	F__gs     uint32
   1555 }
   1556 
   1557 type __darwin_fp_control = struct {
   1558 	F__ccgo0 uint16
   1559 }
   1560 
   1561 type __darwin_fp_control_t = struct {
   1562 	F__ccgo0 uint16
   1563 }
   1564 
   1565 type __darwin_fp_status = struct {
   1566 	F__ccgo0 uint16
   1567 }
   1568 
   1569 type __darwin_fp_status_t = struct {
   1570 	F__ccgo0 uint16
   1571 }
   1572 
   1573 type __darwin_mmst_reg = struct {
   1574 	F__mmst_reg  [10]int8
   1575 	F__mmst_rsrv [6]int8
   1576 }
   1577 
   1578 type __darwin_xmm_reg = struct {
   1579 	F__xmm_reg [16]int8
   1580 }
   1581 
   1582 type __darwin_ymm_reg = struct {
   1583 	F__ymm_reg [32]int8
   1584 }
   1585 
   1586 type __darwin_zmm_reg = struct {
   1587 	F__zmm_reg [64]int8
   1588 }
   1589 
   1590 type __darwin_opmask_reg = struct {
   1591 	F__opmask_reg [8]int8
   1592 }
   1593 
   1594 type __darwin_i386_float_state = struct {
   1595 	F__fpu_reserved  [2]int32
   1596 	F__fpu_fcw       __darwin_fp_control
   1597 	F__fpu_fsw       __darwin_fp_status
   1598 	F__fpu_ftw       __uint8_t
   1599 	F__fpu_rsrv1     __uint8_t
   1600 	F__fpu_fop       __uint16_t
   1601 	F__fpu_ip        __uint32_t
   1602 	F__fpu_cs        __uint16_t
   1603 	F__fpu_rsrv2     __uint16_t
   1604 	F__fpu_dp        __uint32_t
   1605 	F__fpu_ds        __uint16_t
   1606 	F__fpu_rsrv3     __uint16_t
   1607 	F__fpu_mxcsr     __uint32_t
   1608 	F__fpu_mxcsrmask __uint32_t
   1609 	F__fpu_stmm0     __darwin_mmst_reg
   1610 	F__fpu_stmm1     __darwin_mmst_reg
   1611 	F__fpu_stmm2     __darwin_mmst_reg
   1612 	F__fpu_stmm3     __darwin_mmst_reg
   1613 	F__fpu_stmm4     __darwin_mmst_reg
   1614 	F__fpu_stmm5     __darwin_mmst_reg
   1615 	F__fpu_stmm6     __darwin_mmst_reg
   1616 	F__fpu_stmm7     __darwin_mmst_reg
   1617 	F__fpu_xmm0      __darwin_xmm_reg
   1618 	F__fpu_xmm1      __darwin_xmm_reg
   1619 	F__fpu_xmm2      __darwin_xmm_reg
   1620 	F__fpu_xmm3      __darwin_xmm_reg
   1621 	F__fpu_xmm4      __darwin_xmm_reg
   1622 	F__fpu_xmm5      __darwin_xmm_reg
   1623 	F__fpu_xmm6      __darwin_xmm_reg
   1624 	F__fpu_xmm7      __darwin_xmm_reg
   1625 	F__fpu_rsrv4     [224]int8
   1626 	F__fpu_reserved1 int32
   1627 }
   1628 
   1629 type __darwin_i386_avx_state = struct {
   1630 	F__fpu_reserved  [2]int32
   1631 	F__fpu_fcw       __darwin_fp_control
   1632 	F__fpu_fsw       __darwin_fp_status
   1633 	F__fpu_ftw       __uint8_t
   1634 	F__fpu_rsrv1     __uint8_t
   1635 	F__fpu_fop       __uint16_t
   1636 	F__fpu_ip        __uint32_t
   1637 	F__fpu_cs        __uint16_t
   1638 	F__fpu_rsrv2     __uint16_t
   1639 	F__fpu_dp        __uint32_t
   1640 	F__fpu_ds        __uint16_t
   1641 	F__fpu_rsrv3     __uint16_t
   1642 	F__fpu_mxcsr     __uint32_t
   1643 	F__fpu_mxcsrmask __uint32_t
   1644 	F__fpu_stmm0     __darwin_mmst_reg
   1645 	F__fpu_stmm1     __darwin_mmst_reg
   1646 	F__fpu_stmm2     __darwin_mmst_reg
   1647 	F__fpu_stmm3     __darwin_mmst_reg
   1648 	F__fpu_stmm4     __darwin_mmst_reg
   1649 	F__fpu_stmm5     __darwin_mmst_reg
   1650 	F__fpu_stmm6     __darwin_mmst_reg
   1651 	F__fpu_stmm7     __darwin_mmst_reg
   1652 	F__fpu_xmm0      __darwin_xmm_reg
   1653 	F__fpu_xmm1      __darwin_xmm_reg
   1654 	F__fpu_xmm2      __darwin_xmm_reg
   1655 	F__fpu_xmm3      __darwin_xmm_reg
   1656 	F__fpu_xmm4      __darwin_xmm_reg
   1657 	F__fpu_xmm5      __darwin_xmm_reg
   1658 	F__fpu_xmm6      __darwin_xmm_reg
   1659 	F__fpu_xmm7      __darwin_xmm_reg
   1660 	F__fpu_rsrv4     [224]int8
   1661 	F__fpu_reserved1 int32
   1662 	F__avx_reserved1 [64]int8
   1663 	F__fpu_ymmh0     __darwin_xmm_reg
   1664 	F__fpu_ymmh1     __darwin_xmm_reg
   1665 	F__fpu_ymmh2     __darwin_xmm_reg
   1666 	F__fpu_ymmh3     __darwin_xmm_reg
   1667 	F__fpu_ymmh4     __darwin_xmm_reg
   1668 	F__fpu_ymmh5     __darwin_xmm_reg
   1669 	F__fpu_ymmh6     __darwin_xmm_reg
   1670 	F__fpu_ymmh7     __darwin_xmm_reg
   1671 }
   1672 
   1673 type __darwin_i386_avx512_state = struct {
   1674 	F__fpu_reserved  [2]int32
   1675 	F__fpu_fcw       __darwin_fp_control
   1676 	F__fpu_fsw       __darwin_fp_status
   1677 	F__fpu_ftw       __uint8_t
   1678 	F__fpu_rsrv1     __uint8_t
   1679 	F__fpu_fop       __uint16_t
   1680 	F__fpu_ip        __uint32_t
   1681 	F__fpu_cs        __uint16_t
   1682 	F__fpu_rsrv2     __uint16_t
   1683 	F__fpu_dp        __uint32_t
   1684 	F__fpu_ds        __uint16_t
   1685 	F__fpu_rsrv3     __uint16_t
   1686 	F__fpu_mxcsr     __uint32_t
   1687 	F__fpu_mxcsrmask __uint32_t
   1688 	F__fpu_stmm0     __darwin_mmst_reg
   1689 	F__fpu_stmm1     __darwin_mmst_reg
   1690 	F__fpu_stmm2     __darwin_mmst_reg
   1691 	F__fpu_stmm3     __darwin_mmst_reg
   1692 	F__fpu_stmm4     __darwin_mmst_reg
   1693 	F__fpu_stmm5     __darwin_mmst_reg
   1694 	F__fpu_stmm6     __darwin_mmst_reg
   1695 	F__fpu_stmm7     __darwin_mmst_reg
   1696 	F__fpu_xmm0      __darwin_xmm_reg
   1697 	F__fpu_xmm1      __darwin_xmm_reg
   1698 	F__fpu_xmm2      __darwin_xmm_reg
   1699 	F__fpu_xmm3      __darwin_xmm_reg
   1700 	F__fpu_xmm4      __darwin_xmm_reg
   1701 	F__fpu_xmm5      __darwin_xmm_reg
   1702 	F__fpu_xmm6      __darwin_xmm_reg
   1703 	F__fpu_xmm7      __darwin_xmm_reg
   1704 	F__fpu_rsrv4     [224]int8
   1705 	F__fpu_reserved1 int32
   1706 	F__avx_reserved1 [64]int8
   1707 	F__fpu_ymmh0     __darwin_xmm_reg
   1708 	F__fpu_ymmh1     __darwin_xmm_reg
   1709 	F__fpu_ymmh2     __darwin_xmm_reg
   1710 	F__fpu_ymmh3     __darwin_xmm_reg
   1711 	F__fpu_ymmh4     __darwin_xmm_reg
   1712 	F__fpu_ymmh5     __darwin_xmm_reg
   1713 	F__fpu_ymmh6     __darwin_xmm_reg
   1714 	F__fpu_ymmh7     __darwin_xmm_reg
   1715 	F__fpu_k0        __darwin_opmask_reg
   1716 	F__fpu_k1        __darwin_opmask_reg
   1717 	F__fpu_k2        __darwin_opmask_reg
   1718 	F__fpu_k3        __darwin_opmask_reg
   1719 	F__fpu_k4        __darwin_opmask_reg
   1720 	F__fpu_k5        __darwin_opmask_reg
   1721 	F__fpu_k6        __darwin_opmask_reg
   1722 	F__fpu_k7        __darwin_opmask_reg
   1723 	F__fpu_zmmh0     __darwin_ymm_reg
   1724 	F__fpu_zmmh1     __darwin_ymm_reg
   1725 	F__fpu_zmmh2     __darwin_ymm_reg
   1726 	F__fpu_zmmh3     __darwin_ymm_reg
   1727 	F__fpu_zmmh4     __darwin_ymm_reg
   1728 	F__fpu_zmmh5     __darwin_ymm_reg
   1729 	F__fpu_zmmh6     __darwin_ymm_reg
   1730 	F__fpu_zmmh7     __darwin_ymm_reg
   1731 }
   1732 
   1733 type __darwin_i386_exception_state = struct {
   1734 	F__trapno     __uint16_t
   1735 	F__cpu        __uint16_t
   1736 	F__err        __uint32_t
   1737 	F__faultvaddr __uint32_t
   1738 }
   1739 
   1740 type __darwin_x86_debug_state32 = struct {
   1741 	F__dr0 uint32
   1742 	F__dr1 uint32
   1743 	F__dr2 uint32
   1744 	F__dr3 uint32
   1745 	F__dr4 uint32
   1746 	F__dr5 uint32
   1747 	F__dr6 uint32
   1748 	F__dr7 uint32
   1749 }
   1750 
   1751 type __x86_instruction_state = struct {
   1752 	F__insn_stream_valid_bytes int32
   1753 	F__insn_offset             int32
   1754 	F__out_of_synch            int32
   1755 	F__insn_bytes              [2380]__uint8_t
   1756 	F__insn_cacheline          [64]__uint8_t
   1757 }
   1758 
   1759 type __last_branch_record = struct {
   1760 	F__from_ip __uint64_t
   1761 	F__to_ip   __uint64_t
   1762 	F__ccgo16  uint32
   1763 }
   1764 
   1765 type __last_branch_state = struct {
   1766 	F__lbr_count int32
   1767 	F__ccgo4     uint32
   1768 	F__lbrs      [32]__last_branch_record
   1769 }
   1770 
   1771 type __x86_pagein_state = struct {
   1772 	F__pagein_error int32
   1773 }
   1774 
   1775 type __darwin_x86_thread_state64 = struct {
   1776 	F__rax    __uint64_t
   1777 	F__rbx    __uint64_t
   1778 	F__rcx    __uint64_t
   1779 	F__rdx    __uint64_t
   1780 	F__rdi    __uint64_t
   1781 	F__rsi    __uint64_t
   1782 	F__rbp    __uint64_t
   1783 	F__rsp    __uint64_t
   1784 	F__r8     __uint64_t
   1785 	F__r9     __uint64_t
   1786 	F__r10    __uint64_t
   1787 	F__r11    __uint64_t
   1788 	F__r12    __uint64_t
   1789 	F__r13    __uint64_t
   1790 	F__r14    __uint64_t
   1791 	F__r15    __uint64_t
   1792 	F__rip    __uint64_t
   1793 	F__rflags __uint64_t
   1794 	F__cs     __uint64_t
   1795 	F__fs     __uint64_t
   1796 	F__gs     __uint64_t
   1797 }
   1798 
   1799 type __darwin_x86_thread_full_state64 = struct {
   1800 	F__ss64   __darwin_x86_thread_state64
   1801 	F__ds     __uint64_t
   1802 	F__es     __uint64_t
   1803 	F__ss     __uint64_t
   1804 	F__gsbase __uint64_t
   1805 }
   1806 
   1807 type __darwin_x86_float_state64 = struct {
   1808 	F__fpu_reserved  [2]int32
   1809 	F__fpu_fcw       __darwin_fp_control
   1810 	F__fpu_fsw       __darwin_fp_status
   1811 	F__fpu_ftw       __uint8_t
   1812 	F__fpu_rsrv1     __uint8_t
   1813 	F__fpu_fop       __uint16_t
   1814 	F__fpu_ip        __uint32_t
   1815 	F__fpu_cs        __uint16_t
   1816 	F__fpu_rsrv2     __uint16_t
   1817 	F__fpu_dp        __uint32_t
   1818 	F__fpu_ds        __uint16_t
   1819 	F__fpu_rsrv3     __uint16_t
   1820 	F__fpu_mxcsr     __uint32_t
   1821 	F__fpu_mxcsrmask __uint32_t
   1822 	F__fpu_stmm0     __darwin_mmst_reg
   1823 	F__fpu_stmm1     __darwin_mmst_reg
   1824 	F__fpu_stmm2     __darwin_mmst_reg
   1825 	F__fpu_stmm3     __darwin_mmst_reg
   1826 	F__fpu_stmm4     __darwin_mmst_reg
   1827 	F__fpu_stmm5     __darwin_mmst_reg
   1828 	F__fpu_stmm6     __darwin_mmst_reg
   1829 	F__fpu_stmm7     __darwin_mmst_reg
   1830 	F__fpu_xmm0      __darwin_xmm_reg
   1831 	F__fpu_xmm1      __darwin_xmm_reg
   1832 	F__fpu_xmm2      __darwin_xmm_reg
   1833 	F__fpu_xmm3      __darwin_xmm_reg
   1834 	F__fpu_xmm4      __darwin_xmm_reg
   1835 	F__fpu_xmm5      __darwin_xmm_reg
   1836 	F__fpu_xmm6      __darwin_xmm_reg
   1837 	F__fpu_xmm7      __darwin_xmm_reg
   1838 	F__fpu_xmm8      __darwin_xmm_reg
   1839 	F__fpu_xmm9      __darwin_xmm_reg
   1840 	F__fpu_xmm10     __darwin_xmm_reg
   1841 	F__fpu_xmm11     __darwin_xmm_reg
   1842 	F__fpu_xmm12     __darwin_xmm_reg
   1843 	F__fpu_xmm13     __darwin_xmm_reg
   1844 	F__fpu_xmm14     __darwin_xmm_reg
   1845 	F__fpu_xmm15     __darwin_xmm_reg
   1846 	F__fpu_rsrv4     [96]int8
   1847 	F__fpu_reserved1 int32
   1848 }
   1849 
   1850 type __darwin_x86_avx_state64 = struct {
   1851 	F__fpu_reserved  [2]int32
   1852 	F__fpu_fcw       __darwin_fp_control
   1853 	F__fpu_fsw       __darwin_fp_status
   1854 	F__fpu_ftw       __uint8_t
   1855 	F__fpu_rsrv1     __uint8_t
   1856 	F__fpu_fop       __uint16_t
   1857 	F__fpu_ip        __uint32_t
   1858 	F__fpu_cs        __uint16_t
   1859 	F__fpu_rsrv2     __uint16_t
   1860 	F__fpu_dp        __uint32_t
   1861 	F__fpu_ds        __uint16_t
   1862 	F__fpu_rsrv3     __uint16_t
   1863 	F__fpu_mxcsr     __uint32_t
   1864 	F__fpu_mxcsrmask __uint32_t
   1865 	F__fpu_stmm0     __darwin_mmst_reg
   1866 	F__fpu_stmm1     __darwin_mmst_reg
   1867 	F__fpu_stmm2     __darwin_mmst_reg
   1868 	F__fpu_stmm3     __darwin_mmst_reg
   1869 	F__fpu_stmm4     __darwin_mmst_reg
   1870 	F__fpu_stmm5     __darwin_mmst_reg
   1871 	F__fpu_stmm6     __darwin_mmst_reg
   1872 	F__fpu_stmm7     __darwin_mmst_reg
   1873 	F__fpu_xmm0      __darwin_xmm_reg
   1874 	F__fpu_xmm1      __darwin_xmm_reg
   1875 	F__fpu_xmm2      __darwin_xmm_reg
   1876 	F__fpu_xmm3      __darwin_xmm_reg
   1877 	F__fpu_xmm4      __darwin_xmm_reg
   1878 	F__fpu_xmm5      __darwin_xmm_reg
   1879 	F__fpu_xmm6      __darwin_xmm_reg
   1880 	F__fpu_xmm7      __darwin_xmm_reg
   1881 	F__fpu_xmm8      __darwin_xmm_reg
   1882 	F__fpu_xmm9      __darwin_xmm_reg
   1883 	F__fpu_xmm10     __darwin_xmm_reg
   1884 	F__fpu_xmm11     __darwin_xmm_reg
   1885 	F__fpu_xmm12     __darwin_xmm_reg
   1886 	F__fpu_xmm13     __darwin_xmm_reg
   1887 	F__fpu_xmm14     __darwin_xmm_reg
   1888 	F__fpu_xmm15     __darwin_xmm_reg
   1889 	F__fpu_rsrv4     [96]int8
   1890 	F__fpu_reserved1 int32
   1891 	F__avx_reserved1 [64]int8
   1892 	F__fpu_ymmh0     __darwin_xmm_reg
   1893 	F__fpu_ymmh1     __darwin_xmm_reg
   1894 	F__fpu_ymmh2     __darwin_xmm_reg
   1895 	F__fpu_ymmh3     __darwin_xmm_reg
   1896 	F__fpu_ymmh4     __darwin_xmm_reg
   1897 	F__fpu_ymmh5     __darwin_xmm_reg
   1898 	F__fpu_ymmh6     __darwin_xmm_reg
   1899 	F__fpu_ymmh7     __darwin_xmm_reg
   1900 	F__fpu_ymmh8     __darwin_xmm_reg
   1901 	F__fpu_ymmh9     __darwin_xmm_reg
   1902 	F__fpu_ymmh10    __darwin_xmm_reg
   1903 	F__fpu_ymmh11    __darwin_xmm_reg
   1904 	F__fpu_ymmh12    __darwin_xmm_reg
   1905 	F__fpu_ymmh13    __darwin_xmm_reg
   1906 	F__fpu_ymmh14    __darwin_xmm_reg
   1907 	F__fpu_ymmh15    __darwin_xmm_reg
   1908 }
   1909 
   1910 type __darwin_x86_avx512_state64 = struct {
   1911 	F__fpu_reserved  [2]int32
   1912 	F__fpu_fcw       __darwin_fp_control
   1913 	F__fpu_fsw       __darwin_fp_status
   1914 	F__fpu_ftw       __uint8_t
   1915 	F__fpu_rsrv1     __uint8_t
   1916 	F__fpu_fop       __uint16_t
   1917 	F__fpu_ip        __uint32_t
   1918 	F__fpu_cs        __uint16_t
   1919 	F__fpu_rsrv2     __uint16_t
   1920 	F__fpu_dp        __uint32_t
   1921 	F__fpu_ds        __uint16_t
   1922 	F__fpu_rsrv3     __uint16_t
   1923 	F__fpu_mxcsr     __uint32_t
   1924 	F__fpu_mxcsrmask __uint32_t
   1925 	F__fpu_stmm0     __darwin_mmst_reg
   1926 	F__fpu_stmm1     __darwin_mmst_reg
   1927 	F__fpu_stmm2     __darwin_mmst_reg
   1928 	F__fpu_stmm3     __darwin_mmst_reg
   1929 	F__fpu_stmm4     __darwin_mmst_reg
   1930 	F__fpu_stmm5     __darwin_mmst_reg
   1931 	F__fpu_stmm6     __darwin_mmst_reg
   1932 	F__fpu_stmm7     __darwin_mmst_reg
   1933 	F__fpu_xmm0      __darwin_xmm_reg
   1934 	F__fpu_xmm1      __darwin_xmm_reg
   1935 	F__fpu_xmm2      __darwin_xmm_reg
   1936 	F__fpu_xmm3      __darwin_xmm_reg
   1937 	F__fpu_xmm4      __darwin_xmm_reg
   1938 	F__fpu_xmm5      __darwin_xmm_reg
   1939 	F__fpu_xmm6      __darwin_xmm_reg
   1940 	F__fpu_xmm7      __darwin_xmm_reg
   1941 	F__fpu_xmm8      __darwin_xmm_reg
   1942 	F__fpu_xmm9      __darwin_xmm_reg
   1943 	F__fpu_xmm10     __darwin_xmm_reg
   1944 	F__fpu_xmm11     __darwin_xmm_reg
   1945 	F__fpu_xmm12     __darwin_xmm_reg
   1946 	F__fpu_xmm13     __darwin_xmm_reg
   1947 	F__fpu_xmm14     __darwin_xmm_reg
   1948 	F__fpu_xmm15     __darwin_xmm_reg
   1949 	F__fpu_rsrv4     [96]int8
   1950 	F__fpu_reserved1 int32
   1951 	F__avx_reserved1 [64]int8
   1952 	F__fpu_ymmh0     __darwin_xmm_reg
   1953 	F__fpu_ymmh1     __darwin_xmm_reg
   1954 	F__fpu_ymmh2     __darwin_xmm_reg
   1955 	F__fpu_ymmh3     __darwin_xmm_reg
   1956 	F__fpu_ymmh4     __darwin_xmm_reg
   1957 	F__fpu_ymmh5     __darwin_xmm_reg
   1958 	F__fpu_ymmh6     __darwin_xmm_reg
   1959 	F__fpu_ymmh7     __darwin_xmm_reg
   1960 	F__fpu_ymmh8     __darwin_xmm_reg
   1961 	F__fpu_ymmh9     __darwin_xmm_reg
   1962 	F__fpu_ymmh10    __darwin_xmm_reg
   1963 	F__fpu_ymmh11    __darwin_xmm_reg
   1964 	F__fpu_ymmh12    __darwin_xmm_reg
   1965 	F__fpu_ymmh13    __darwin_xmm_reg
   1966 	F__fpu_ymmh14    __darwin_xmm_reg
   1967 	F__fpu_ymmh15    __darwin_xmm_reg
   1968 	F__fpu_k0        __darwin_opmask_reg
   1969 	F__fpu_k1        __darwin_opmask_reg
   1970 	F__fpu_k2        __darwin_opmask_reg
   1971 	F__fpu_k3        __darwin_opmask_reg
   1972 	F__fpu_k4        __darwin_opmask_reg
   1973 	F__fpu_k5        __darwin_opmask_reg
   1974 	F__fpu_k6        __darwin_opmask_reg
   1975 	F__fpu_k7        __darwin_opmask_reg
   1976 	F__fpu_zmmh0     __darwin_ymm_reg
   1977 	F__fpu_zmmh1     __darwin_ymm_reg
   1978 	F__fpu_zmmh2     __darwin_ymm_reg
   1979 	F__fpu_zmmh3     __darwin_ymm_reg
   1980 	F__fpu_zmmh4     __darwin_ymm_reg
   1981 	F__fpu_zmmh5     __darwin_ymm_reg
   1982 	F__fpu_zmmh6     __darwin_ymm_reg
   1983 	F__fpu_zmmh7     __darwin_ymm_reg
   1984 	F__fpu_zmmh8     __darwin_ymm_reg
   1985 	F__fpu_zmmh9     __darwin_ymm_reg
   1986 	F__fpu_zmmh10    __darwin_ymm_reg
   1987 	F__fpu_zmmh11    __darwin_ymm_reg
   1988 	F__fpu_zmmh12    __darwin_ymm_reg
   1989 	F__fpu_zmmh13    __darwin_ymm_reg
   1990 	F__fpu_zmmh14    __darwin_ymm_reg
   1991 	F__fpu_zmmh15    __darwin_ymm_reg
   1992 	F__fpu_zmm16     __darwin_zmm_reg
   1993 	F__fpu_zmm17     __darwin_zmm_reg
   1994 	F__fpu_zmm18     __darwin_zmm_reg
   1995 	F__fpu_zmm19     __darwin_zmm_reg
   1996 	F__fpu_zmm20     __darwin_zmm_reg
   1997 	F__fpu_zmm21     __darwin_zmm_reg
   1998 	F__fpu_zmm22     __darwin_zmm_reg
   1999 	F__fpu_zmm23     __darwin_zmm_reg
   2000 	F__fpu_zmm24     __darwin_zmm_reg
   2001 	F__fpu_zmm25     __darwin_zmm_reg
   2002 	F__fpu_zmm26     __darwin_zmm_reg
   2003 	F__fpu_zmm27     __darwin_zmm_reg
   2004 	F__fpu_zmm28     __darwin_zmm_reg
   2005 	F__fpu_zmm29     __darwin_zmm_reg
   2006 	F__fpu_zmm30     __darwin_zmm_reg
   2007 	F__fpu_zmm31     __darwin_zmm_reg
   2008 }
   2009 
   2010 type __darwin_x86_exception_state64 = struct {
   2011 	F__trapno     __uint16_t
   2012 	F__cpu        __uint16_t
   2013 	F__err        __uint32_t
   2014 	F__faultvaddr __uint64_t
   2015 }
   2016 
   2017 type __darwin_x86_debug_state64 = struct {
   2018 	F__dr0 __uint64_t
   2019 	F__dr1 __uint64_t
   2020 	F__dr2 __uint64_t
   2021 	F__dr3 __uint64_t
   2022 	F__dr4 __uint64_t
   2023 	F__dr5 __uint64_t
   2024 	F__dr6 __uint64_t
   2025 	F__dr7 __uint64_t
   2026 }
   2027 
   2028 type __darwin_x86_cpmu_state64 = struct {
   2029 	F__ctrs [16]__uint64_t
   2030 }
   2031 
   2032 type __darwin_mcontext32 = struct {
   2033 	F__es __darwin_i386_exception_state
   2034 	F__ss __darwin_i386_thread_state
   2035 	F__fs __darwin_i386_float_state
   2036 }
   2037 
   2038 type __darwin_mcontext_avx32 = struct {
   2039 	F__es __darwin_i386_exception_state
   2040 	F__ss __darwin_i386_thread_state
   2041 	F__fs __darwin_i386_avx_state
   2042 }
   2043 
   2044 type __darwin_mcontext_avx512_32 = struct {
   2045 	F__es __darwin_i386_exception_state
   2046 	F__ss __darwin_i386_thread_state
   2047 	F__fs __darwin_i386_avx512_state
   2048 }
   2049 
   2050 type __darwin_mcontext64 = struct {
   2051 	F__es __darwin_x86_exception_state64
   2052 	F__ss __darwin_x86_thread_state64
   2053 	F__fs __darwin_x86_float_state64
   2054 }
   2055 
   2056 type __darwin_mcontext64_full = struct {
   2057 	F__es __darwin_x86_exception_state64
   2058 	F__ss __darwin_x86_thread_full_state64
   2059 	F__fs __darwin_x86_float_state64
   2060 }
   2061 
   2062 type __darwin_mcontext_avx64 = struct {
   2063 	F__es __darwin_x86_exception_state64
   2064 	F__ss __darwin_x86_thread_state64
   2065 	F__fs __darwin_x86_avx_state64
   2066 }
   2067 
   2068 type __darwin_mcontext_avx64_full = struct {
   2069 	F__es __darwin_x86_exception_state64
   2070 	F__ss __darwin_x86_thread_full_state64
   2071 	F__fs __darwin_x86_avx_state64
   2072 }
   2073 
   2074 type __darwin_mcontext_avx512_64 = struct {
   2075 	F__es __darwin_x86_exception_state64
   2076 	F__ss __darwin_x86_thread_state64
   2077 	F__fs __darwin_x86_avx512_state64
   2078 }
   2079 
   2080 type __darwin_mcontext_avx512_64_full = struct {
   2081 	F__es __darwin_x86_exception_state64
   2082 	F__ss __darwin_x86_thread_full_state64
   2083 	F__fs __darwin_x86_avx512_state64
   2084 }
   2085 
   2086 type mcontext_t = uintptr
   2087 
   2088 type pthread_attr_t = struct {
   2089 	F__sig    int64
   2090 	F__opaque [56]int8
   2091 }
   2092 
   2093 type __darwin_sigaltstack = struct {
   2094 	Fss_sp    uintptr
   2095 	Fss_size  __darwin_size_t
   2096 	Fss_flags int32
   2097 }
   2098 
   2099 type stack_t = struct {
   2100 	Fss_sp    uintptr
   2101 	Fss_size  __darwin_size_t
   2102 	Fss_flags int32
   2103 }
   2104 
   2105 type __darwin_ucontext = struct {
   2106 	Fuc_onstack  int32
   2107 	Fuc_sigmask  __darwin_sigset_t
   2108 	Fuc_stack    __darwin_sigaltstack
   2109 	Fuc_link     uintptr
   2110 	Fuc_mcsize   __darwin_size_t
   2111 	Fuc_mcontext uintptr
   2112 }
   2113 
   2114 type ucontext_t = struct {
   2115 	Fuc_onstack  int32
   2116 	Fuc_sigmask  __darwin_sigset_t
   2117 	Fuc_stack    __darwin_sigaltstack
   2118 	Fuc_link     uintptr
   2119 	Fuc_mcsize   __darwin_size_t
   2120 	Fuc_mcontext uintptr
   2121 }
   2122 
   2123 type sigset_t = uint32
   2124 
   2125 type size_t = uint64
   2126 
   2127 type uid_t = uint32
   2128 
   2129 type sigval = struct {
   2130 	Fsival_ptr   [0]uintptr
   2131 	Fsival_int   int32
   2132 	F__ccgo_pad2 [4]byte
   2133 }
   2134 
   2135 type sigevent = struct {
   2136 	Fsigev_notify            int32
   2137 	Fsigev_signo             int32
   2138 	Fsigev_value             sigval
   2139 	Fsigev_notify_function   uintptr
   2140 	Fsigev_notify_attributes uintptr
   2141 }
   2142 
   2143 type siginfo_t = struct {
   2144 	Fsi_signo  int32
   2145 	Fsi_errno  int32
   2146 	Fsi_code   int32
   2147 	Fsi_pid    pid_t
   2148 	Fsi_uid    uid_t
   2149 	Fsi_status int32
   2150 	Fsi_addr   uintptr
   2151 	Fsi_value  sigval
   2152 	Fsi_band   int64
   2153 	F__pad     [7]uint64
   2154 }
   2155 
   2156 type __siginfo = siginfo_t
   2157 
   2158 type __sigaction_u = struct {
   2159 	F__sa_sigaction [0]uintptr
   2160 	F__sa_handler   uintptr
   2161 }
   2162 
   2163 type __sigaction = struct {
   2164 	F__sigaction_u __sigaction_u
   2165 	Fsa_tramp      uintptr
   2166 	Fsa_mask       sigset_t
   2167 	Fsa_flags      int32
   2168 }
   2169 
   2170 type sigaction1 = struct {
   2171 	F__sigaction_u __sigaction_u
   2172 	Fsa_mask       sigset_t
   2173 	Fsa_flags      int32
   2174 }
   2175 
   2176 type sig_t = uintptr
   2177 
   2178 type sigvec = struct {
   2179 	Fsv_handler uintptr
   2180 	Fsv_mask    int32
   2181 	Fsv_flags   int32
   2182 }
   2183 
   2184 type sigstack = struct {
   2185 	Fss_sp      uintptr
   2186 	Fss_onstack int32
   2187 }
   2188 
   2189 type uint8_t = uint8
   2190 
   2191 type uint16_t = uint16
   2192 
   2193 type uint32_t = uint32
   2194 
   2195 type uint64_t = uint64
   2196 
   2197 type int_least8_t = int8
   2198 
   2199 type int_least16_t = int16
   2200 
   2201 type int_least32_t = int32
   2202 
   2203 type int_least64_t = int64
   2204 
   2205 type uint_least8_t = uint8
   2206 
   2207 type uint_least16_t = uint16
   2208 
   2209 type uint_least32_t = uint32
   2210 
   2211 type uint_least64_t = uint64
   2212 
   2213 type int_fast8_t = int8
   2214 
   2215 type int_fast16_t = int16
   2216 
   2217 type int_fast32_t = int32
   2218 
   2219 type int_fast64_t = int64
   2220 
   2221 type uint_fast8_t = uint8
   2222 
   2223 type uint_fast16_t = uint16
   2224 
   2225 type uint_fast32_t = uint32
   2226 
   2227 type uint_fast64_t = uint64
   2228 
   2229 type intmax_t = int64
   2230 
   2231 type uintmax_t = uint64
   2232 
   2233 type timeval = struct {
   2234 	Ftv_sec  __darwin_time_t
   2235 	Ftv_usec __darwin_suseconds_t
   2236 }
   2237 
   2238 type rlim_t = uint64
   2239 
   2240 type rusage = struct {
   2241 	Fru_utime    timeval
   2242 	Fru_stime    timeval
   2243 	Fru_maxrss   int64
   2244 	Fru_ixrss    int64
   2245 	Fru_idrss    int64
   2246 	Fru_isrss    int64
   2247 	Fru_minflt   int64
   2248 	Fru_majflt   int64
   2249 	Fru_nswap    int64
   2250 	Fru_inblock  int64
   2251 	Fru_oublock  int64
   2252 	Fru_msgsnd   int64
   2253 	Fru_msgrcv   int64
   2254 	Fru_nsignals int64
   2255 	Fru_nvcsw    int64
   2256 	Fru_nivcsw   int64
   2257 }
   2258 
   2259 type rusage_info_t = uintptr
   2260 
   2261 type rusage_info_v0 = struct {
   2262 	Fri_uuid               [16]uint8_t
   2263 	Fri_user_time          uint64_t
   2264 	Fri_system_time        uint64_t
   2265 	Fri_pkg_idle_wkups     uint64_t
   2266 	Fri_interrupt_wkups    uint64_t
   2267 	Fri_pageins            uint64_t
   2268 	Fri_wired_size         uint64_t
   2269 	Fri_resident_size      uint64_t
   2270 	Fri_phys_footprint     uint64_t
   2271 	Fri_proc_start_abstime uint64_t
   2272 	Fri_proc_exit_abstime  uint64_t
   2273 }
   2274 
   2275 type rusage_info_v1 = struct {
   2276 	Fri_uuid                  [16]uint8_t
   2277 	Fri_user_time             uint64_t
   2278 	Fri_system_time           uint64_t
   2279 	Fri_pkg_idle_wkups        uint64_t
   2280 	Fri_interrupt_wkups       uint64_t
   2281 	Fri_pageins               uint64_t
   2282 	Fri_wired_size            uint64_t
   2283 	Fri_resident_size         uint64_t
   2284 	Fri_phys_footprint        uint64_t
   2285 	Fri_proc_start_abstime    uint64_t
   2286 	Fri_proc_exit_abstime     uint64_t
   2287 	Fri_child_user_time       uint64_t
   2288 	Fri_child_system_time     uint64_t
   2289 	Fri_child_pkg_idle_wkups  uint64_t
   2290 	Fri_child_interrupt_wkups uint64_t
   2291 	Fri_child_pageins         uint64_t
   2292 	Fri_child_elapsed_abstime uint64_t
   2293 }
   2294 
   2295 type rusage_info_v2 = struct {
   2296 	Fri_uuid                  [16]uint8_t
   2297 	Fri_user_time             uint64_t
   2298 	Fri_system_time           uint64_t
   2299 	Fri_pkg_idle_wkups        uint64_t
   2300 	Fri_interrupt_wkups       uint64_t
   2301 	Fri_pageins               uint64_t
   2302 	Fri_wired_size            uint64_t
   2303 	Fri_resident_size         uint64_t
   2304 	Fri_phys_footprint        uint64_t
   2305 	Fri_proc_start_abstime    uint64_t
   2306 	Fri_proc_exit_abstime     uint64_t
   2307 	Fri_child_user_time       uint64_t
   2308 	Fri_child_system_time     uint64_t
   2309 	Fri_child_pkg_idle_wkups  uint64_t
   2310 	Fri_child_interrupt_wkups uint64_t
   2311 	Fri_child_pageins         uint64_t
   2312 	Fri_child_elapsed_abstime uint64_t
   2313 	Fri_diskio_bytesread      uint64_t
   2314 	Fri_diskio_byteswritten   uint64_t
   2315 }
   2316 
   2317 type rusage_info_v3 = struct {
   2318 	Fri_uuid                          [16]uint8_t
   2319 	Fri_user_time                     uint64_t
   2320 	Fri_system_time                   uint64_t
   2321 	Fri_pkg_idle_wkups                uint64_t
   2322 	Fri_interrupt_wkups               uint64_t
   2323 	Fri_pageins                       uint64_t
   2324 	Fri_wired_size                    uint64_t
   2325 	Fri_resident_size                 uint64_t
   2326 	Fri_phys_footprint                uint64_t
   2327 	Fri_proc_start_abstime            uint64_t
   2328 	Fri_proc_exit_abstime             uint64_t
   2329 	Fri_child_user_time               uint64_t
   2330 	Fri_child_system_time             uint64_t
   2331 	Fri_child_pkg_idle_wkups          uint64_t
   2332 	Fri_child_interrupt_wkups         uint64_t
   2333 	Fri_child_pageins                 uint64_t
   2334 	Fri_child_elapsed_abstime         uint64_t
   2335 	Fri_diskio_bytesread              uint64_t
   2336 	Fri_diskio_byteswritten           uint64_t
   2337 	Fri_cpu_time_qos_default          uint64_t
   2338 	Fri_cpu_time_qos_maintenance      uint64_t
   2339 	Fri_cpu_time_qos_background       uint64_t
   2340 	Fri_cpu_time_qos_utility          uint64_t
   2341 	Fri_cpu_time_qos_legacy           uint64_t
   2342 	Fri_cpu_time_qos_user_initiated   uint64_t
   2343 	Fri_cpu_time_qos_user_interactive uint64_t
   2344 	Fri_billed_system_time            uint64_t
   2345 	Fri_serviced_system_time          uint64_t
   2346 }
   2347 
   2348 type rusage_info_v4 = struct {
   2349 	Fri_uuid                          [16]uint8_t
   2350 	Fri_user_time                     uint64_t
   2351 	Fri_system_time                   uint64_t
   2352 	Fri_pkg_idle_wkups                uint64_t
   2353 	Fri_interrupt_wkups               uint64_t
   2354 	Fri_pageins                       uint64_t
   2355 	Fri_wired_size                    uint64_t
   2356 	Fri_resident_size                 uint64_t
   2357 	Fri_phys_footprint                uint64_t
   2358 	Fri_proc_start_abstime            uint64_t
   2359 	Fri_proc_exit_abstime             uint64_t
   2360 	Fri_child_user_time               uint64_t
   2361 	Fri_child_system_time             uint64_t
   2362 	Fri_child_pkg_idle_wkups          uint64_t
   2363 	Fri_child_interrupt_wkups         uint64_t
   2364 	Fri_child_pageins                 uint64_t
   2365 	Fri_child_elapsed_abstime         uint64_t
   2366 	Fri_diskio_bytesread              uint64_t
   2367 	Fri_diskio_byteswritten           uint64_t
   2368 	Fri_cpu_time_qos_default          uint64_t
   2369 	Fri_cpu_time_qos_maintenance      uint64_t
   2370 	Fri_cpu_time_qos_background       uint64_t
   2371 	Fri_cpu_time_qos_utility          uint64_t
   2372 	Fri_cpu_time_qos_legacy           uint64_t
   2373 	Fri_cpu_time_qos_user_initiated   uint64_t
   2374 	Fri_cpu_time_qos_user_interactive uint64_t
   2375 	Fri_billed_system_time            uint64_t
   2376 	Fri_serviced_system_time          uint64_t
   2377 	Fri_logical_writes                uint64_t
   2378 	Fri_lifetime_max_phys_footprint   uint64_t
   2379 	Fri_instructions                  uint64_t
   2380 	Fri_cycles                        uint64_t
   2381 	Fri_billed_energy                 uint64_t
   2382 	Fri_serviced_energy               uint64_t
   2383 	Fri_interval_max_phys_footprint   uint64_t
   2384 	Fri_runnable_time                 uint64_t
   2385 }
   2386 
   2387 type rusage_info_v5 = struct {
   2388 	Fri_uuid                          [16]uint8_t
   2389 	Fri_user_time                     uint64_t
   2390 	Fri_system_time                   uint64_t
   2391 	Fri_pkg_idle_wkups                uint64_t
   2392 	Fri_interrupt_wkups               uint64_t
   2393 	Fri_pageins                       uint64_t
   2394 	Fri_wired_size                    uint64_t
   2395 	Fri_resident_size                 uint64_t
   2396 	Fri_phys_footprint                uint64_t
   2397 	Fri_proc_start_abstime            uint64_t
   2398 	Fri_proc_exit_abstime             uint64_t
   2399 	Fri_child_user_time               uint64_t
   2400 	Fri_child_system_time             uint64_t
   2401 	Fri_child_pkg_idle_wkups          uint64_t
   2402 	Fri_child_interrupt_wkups         uint64_t
   2403 	Fri_child_pageins                 uint64_t
   2404 	Fri_child_elapsed_abstime         uint64_t
   2405 	Fri_diskio_bytesread              uint64_t
   2406 	Fri_diskio_byteswritten           uint64_t
   2407 	Fri_cpu_time_qos_default          uint64_t
   2408 	Fri_cpu_time_qos_maintenance      uint64_t
   2409 	Fri_cpu_time_qos_background       uint64_t
   2410 	Fri_cpu_time_qos_utility          uint64_t
   2411 	Fri_cpu_time_qos_legacy           uint64_t
   2412 	Fri_cpu_time_qos_user_initiated   uint64_t
   2413 	Fri_cpu_time_qos_user_interactive uint64_t
   2414 	Fri_billed_system_time            uint64_t
   2415 	Fri_serviced_system_time          uint64_t
   2416 	Fri_logical_writes                uint64_t
   2417 	Fri_lifetime_max_phys_footprint   uint64_t
   2418 	Fri_instructions                  uint64_t
   2419 	Fri_cycles                        uint64_t
   2420 	Fri_billed_energy                 uint64_t
   2421 	Fri_serviced_energy               uint64_t
   2422 	Fri_interval_max_phys_footprint   uint64_t
   2423 	Fri_runnable_time                 uint64_t
   2424 	Fri_flags                         uint64_t
   2425 }
   2426 
   2427 type rusage_info_v6 = struct {
   2428 	Fri_uuid                          [16]uint8_t
   2429 	Fri_user_time                     uint64_t
   2430 	Fri_system_time                   uint64_t
   2431 	Fri_pkg_idle_wkups                uint64_t
   2432 	Fri_interrupt_wkups               uint64_t
   2433 	Fri_pageins                       uint64_t
   2434 	Fri_wired_size                    uint64_t
   2435 	Fri_resident_size                 uint64_t
   2436 	Fri_phys_footprint                uint64_t
   2437 	Fri_proc_start_abstime            uint64_t
   2438 	Fri_proc_exit_abstime             uint64_t
   2439 	Fri_child_user_time               uint64_t
   2440 	Fri_child_system_time             uint64_t
   2441 	Fri_child_pkg_idle_wkups          uint64_t
   2442 	Fri_child_interrupt_wkups         uint64_t
   2443 	Fri_child_pageins                 uint64_t
   2444 	Fri_child_elapsed_abstime         uint64_t
   2445 	Fri_diskio_bytesread              uint64_t
   2446 	Fri_diskio_byteswritten           uint64_t
   2447 	Fri_cpu_time_qos_default          uint64_t
   2448 	Fri_cpu_time_qos_maintenance      uint64_t
   2449 	Fri_cpu_time_qos_background       uint64_t
   2450 	Fri_cpu_time_qos_utility          uint64_t
   2451 	Fri_cpu_time_qos_legacy           uint64_t
   2452 	Fri_cpu_time_qos_user_initiated   uint64_t
   2453 	Fri_cpu_time_qos_user_interactive uint64_t
   2454 	Fri_billed_system_time            uint64_t
   2455 	Fri_serviced_system_time          uint64_t
   2456 	Fri_logical_writes                uint64_t
   2457 	Fri_lifetime_max_phys_footprint   uint64_t
   2458 	Fri_instructions                  uint64_t
   2459 	Fri_cycles                        uint64_t
   2460 	Fri_billed_energy                 uint64_t
   2461 	Fri_serviced_energy               uint64_t
   2462 	Fri_interval_max_phys_footprint   uint64_t
   2463 	Fri_runnable_time                 uint64_t
   2464 	Fri_flags                         uint64_t
   2465 	Fri_user_ptime                    uint64_t
   2466 	Fri_system_ptime                  uint64_t
   2467 	Fri_pinstructions                 uint64_t
   2468 	Fri_pcycles                       uint64_t
   2469 	Fri_energy_nj                     uint64_t
   2470 	Fri_penergy_nj                    uint64_t
   2471 	Fri_secure_time_in_system         uint64_t
   2472 	Fri_secure_ptime_in_system        uint64_t
   2473 	Fri_neural_footprint              uint64_t
   2474 	Fri_lifetime_max_neural_footprint uint64_t
   2475 	Fri_interval_max_neural_footprint uint64_t
   2476 	Fri_reserved                      [9]uint64_t
   2477 }
   2478 
   2479 type rusage_info_current = struct {
   2480 	Fri_uuid                          [16]uint8_t
   2481 	Fri_user_time                     uint64_t
   2482 	Fri_system_time                   uint64_t
   2483 	Fri_pkg_idle_wkups                uint64_t
   2484 	Fri_interrupt_wkups               uint64_t
   2485 	Fri_pageins                       uint64_t
   2486 	Fri_wired_size                    uint64_t
   2487 	Fri_resident_size                 uint64_t
   2488 	Fri_phys_footprint                uint64_t
   2489 	Fri_proc_start_abstime            uint64_t
   2490 	Fri_proc_exit_abstime             uint64_t
   2491 	Fri_child_user_time               uint64_t
   2492 	Fri_child_system_time             uint64_t
   2493 	Fri_child_pkg_idle_wkups          uint64_t
   2494 	Fri_child_interrupt_wkups         uint64_t
   2495 	Fri_child_pageins                 uint64_t
   2496 	Fri_child_elapsed_abstime         uint64_t
   2497 	Fri_diskio_bytesread              uint64_t
   2498 	Fri_diskio_byteswritten           uint64_t
   2499 	Fri_cpu_time_qos_default          uint64_t
   2500 	Fri_cpu_time_qos_maintenance      uint64_t
   2501 	Fri_cpu_time_qos_background       uint64_t
   2502 	Fri_cpu_time_qos_utility          uint64_t
   2503 	Fri_cpu_time_qos_legacy           uint64_t
   2504 	Fri_cpu_time_qos_user_initiated   uint64_t
   2505 	Fri_cpu_time_qos_user_interactive uint64_t
   2506 	Fri_billed_system_time            uint64_t
   2507 	Fri_serviced_system_time          uint64_t
   2508 	Fri_logical_writes                uint64_t
   2509 	Fri_lifetime_max_phys_footprint   uint64_t
   2510 	Fri_instructions                  uint64_t
   2511 	Fri_cycles                        uint64_t
   2512 	Fri_billed_energy                 uint64_t
   2513 	Fri_serviced_energy               uint64_t
   2514 	Fri_interval_max_phys_footprint   uint64_t
   2515 	Fri_runnable_time                 uint64_t
   2516 	Fri_flags                         uint64_t
   2517 	Fri_user_ptime                    uint64_t
   2518 	Fri_system_ptime                  uint64_t
   2519 	Fri_pinstructions                 uint64_t
   2520 	Fri_pcycles                       uint64_t
   2521 	Fri_energy_nj                     uint64_t
   2522 	Fri_penergy_nj                    uint64_t
   2523 	Fri_secure_time_in_system         uint64_t
   2524 	Fri_secure_ptime_in_system        uint64_t
   2525 	Fri_neural_footprint              uint64_t
   2526 	Fri_lifetime_max_neural_footprint uint64_t
   2527 	Fri_interval_max_neural_footprint uint64_t
   2528 	Fri_reserved                      [9]uint64_t
   2529 }
   2530 
   2531 type rlimit = struct {
   2532 	Frlim_cur rlim_t
   2533 	Frlim_max rlim_t
   2534 }
   2535 
   2536 type proc_rlimit_control_wakeupmon = struct {
   2537 	Fwm_flags uint32_t
   2538 	Fwm_rate  int32_t
   2539 }
   2540 
   2541 type wait = struct {
   2542 	Fw_T [0]struct {
   2543 		F__ccgo0 uint32
   2544 	}
   2545 	Fw_S [0]struct {
   2546 		F__ccgo0 uint32
   2547 	}
   2548 	Fw_status int32
   2549 }
   2550 
   2551 type ct_rune_t = int32
   2552 
   2553 type rune_t = int32
   2554 
   2555 type wchar_t = int32
   2556 
   2557 type div_t = struct {
   2558 	Fquot int32
   2559 	Frem  int32
   2560 }
   2561 
   2562 type ldiv_t = struct {
   2563 	Fquot int64
   2564 	Frem  int64
   2565 }
   2566 
   2567 type lldiv_t = struct {
   2568 	Fquot int64
   2569 	Frem  int64
   2570 }
   2571 
   2572 type malloc_type_id_t = uint64
   2573 
   2574 type dev_t = int32
   2575 
   2576 type mode_t = uint16
   2577 
   2578 type ptrdiff_t = int64
   2579 
   2580 type rsize_t = uint64
   2581 
   2582 type nullptr_t = uintptr
   2583 
   2584 type max_align_t = struct {
   2585 	F__clang_max_align_nonce1 int64
   2586 	F__clang_max_align_nonce2 float64
   2587 }
   2588 
   2589 type imaxdiv_t = struct {
   2590 	Fquot intmax_t
   2591 	Frem  intmax_t
   2592 }
   2593 
   2594 type WebPRGBABuffer = struct {
   2595 	Frgba   uintptr
   2596 	Fstride int32
   2597 	Fsize   size_t
   2598 }
   2599 
   2600 type WebPYUVABuffer = struct {
   2601 	Fy        uintptr
   2602 	Fu        uintptr
   2603 	Fv        uintptr
   2604 	Fa        uintptr
   2605 	Fy_stride int32
   2606 	Fu_stride int32
   2607 	Fv_stride int32
   2608 	Fa_stride int32
   2609 	Fy_size   size_t
   2610 	Fu_size   size_t
   2611 	Fv_size   size_t
   2612 	Fa_size   size_t
   2613 }
   2614 
   2615 type WebPDecBuffer = struct {
   2616 	Fcolorspace         WEBP_CSP_MODE1
   2617 	Fwidth              int32
   2618 	Fheight             int32
   2619 	Fis_external_memory int32
   2620 	Fu                  struct {
   2621 		FYUVA        [0]WebPYUVABuffer
   2622 		FRGBA        WebPRGBABuffer
   2623 		F__ccgo_pad2 [56]byte
   2624 	}
   2625 	Fpad            [4]uint32_t
   2626 	Fprivate_memory uintptr
   2627 }
   2628 
   2629 type WEBP_CSP_MODE = int32
   2630 
   2631 const MODE_RGB = 0
   2632 const MODE_RGBA = 1
   2633 const MODE_BGR = 2
   2634 const MODE_BGRA = 3
   2635 const MODE_ARGB = 4
   2636 const MODE_RGBA_4444 = 5
   2637 const MODE_RGB_565 = 6
   2638 const MODE_rgbA = 7
   2639 const MODE_bgrA = 8
   2640 const MODE_Argb = 9
   2641 const MODE_rgbA_4444 = 10
   2642 const MODE_YUV = 11
   2643 const MODE_YUVA = 12
   2644 const MODE_LAST = 13
   2645 
   2646 type WebPBitstreamFeatures = struct {
   2647 	Fwidth         int32
   2648 	Fheight        int32
   2649 	Fhas_alpha     int32
   2650 	Fhas_animation int32
   2651 	Fformat        int32
   2652 	Fpad           [5]uint32_t
   2653 }
   2654 
   2655 type WebPDecoderOptions = struct {
   2656 	Fbypass_filtering         int32
   2657 	Fno_fancy_upsampling      int32
   2658 	Fuse_cropping             int32
   2659 	Fcrop_left                int32
   2660 	Fcrop_top                 int32
   2661 	Fcrop_width               int32
   2662 	Fcrop_height              int32
   2663 	Fuse_scaling              int32
   2664 	Fscaled_width             int32
   2665 	Fscaled_height            int32
   2666 	Fuse_threads              int32
   2667 	Fdithering_strength       int32
   2668 	Fflip                     int32
   2669 	Falpha_dithering_strength int32
   2670 	Fpad                      [5]uint32_t
   2671 }
   2672 
   2673 type WebPDecoderConfig = struct {
   2674 	Finput   WebPBitstreamFeatures
   2675 	Foutput  WebPDecBuffer
   2676 	Foptions WebPDecoderOptions
   2677 }
   2678 
   2679 type WEBP_CSP_MODE1 = int32
   2680 
   2681 type VP8StatusCode1 = int32
   2682 
   2683 type VP8StatusCode = int32
   2684 
   2685 const VP8_STATUS_OK = 0
   2686 const VP8_STATUS_OUT_OF_MEMORY = 1
   2687 const VP8_STATUS_INVALID_PARAM = 2
   2688 const VP8_STATUS_BITSTREAM_ERROR = 3
   2689 const VP8_STATUS_UNSUPPORTED_FEATURE = 4
   2690 const VP8_STATUS_SUSPENDED = 5
   2691 const VP8_STATUS_USER_ABORT = 6
   2692 const VP8_STATUS_NOT_ENOUGH_DATA = 7
   2693 
   2694 type VP8Io = struct {
   2695 	Fwidth            int32
   2696 	Fheight           int32
   2697 	Fmb_y             int32
   2698 	Fmb_w             int32
   2699 	Fmb_h             int32
   2700 	Fy                uintptr
   2701 	Fu                uintptr
   2702 	Fv                uintptr
   2703 	Fy_stride         int32
   2704 	Fuv_stride        int32
   2705 	Fopaque           uintptr
   2706 	Fput              VP8IoPutHook
   2707 	Fsetup            VP8IoSetupHook
   2708 	Fteardown         VP8IoTeardownHook
   2709 	Ffancy_upsampling int32
   2710 	Fdata_size        size_t
   2711 	Fdata             uintptr
   2712 	Fbypass_filtering int32
   2713 	Fuse_cropping     int32
   2714 	Fcrop_left        int32
   2715 	Fcrop_right       int32
   2716 	Fcrop_top         int32
   2717 	Fcrop_bottom      int32
   2718 	Fuse_scaling      int32
   2719 	Fscaled_width     int32
   2720 	Fscaled_height    int32
   2721 	Fa                uintptr
   2722 }
   2723 
   2724 type VP8IoPutHook = uintptr
   2725 
   2726 type VP8IoSetupHook = uintptr
   2727 
   2728 type VP8IoTeardownHook = uintptr
   2729 
   2730 type VP8Decoder = struct {
   2731 	Fstatus              VP8StatusCode1
   2732 	Fready               int32
   2733 	Ferror_msg           uintptr
   2734 	Fbr                  VP8BitReader
   2735 	Fincremental         int32
   2736 	Ffrm_hdr             VP8FrameHeader
   2737 	Fpic_hdr             VP8PictureHeader
   2738 	Ffilter_hdr          VP8FilterHeader
   2739 	Fsegment_hdr         VP8SegmentHeader
   2740 	Fworker              WebPWorker
   2741 	Fmt_method           int32
   2742 	Fcache_id            int32
   2743 	Fnum_caches          int32
   2744 	Fthread_ctx          VP8ThreadContext
   2745 	Fmb_w                int32
   2746 	Fmb_h                int32
   2747 	Ftl_mb_x             int32
   2748 	Ftl_mb_y             int32
   2749 	Fbr_mb_x             int32
   2750 	Fbr_mb_y             int32
   2751 	Fnum_parts_minus_one uint32_t
   2752 	Fparts               [8]VP8BitReader
   2753 	Fdither              int32
   2754 	Fdithering_rg        VP8Random
   2755 	Fdqm                 [4]VP8QuantMatrix
   2756 	Fproba               VP8Proba
   2757 	Fuse_skip_proba      int32
   2758 	Fskip_p              uint8_t
   2759 	Fintra_t             uintptr
   2760 	Fintra_l             [4]uint8_t
   2761 	Fyuv_t               uintptr
   2762 	Fmb_info             uintptr
   2763 	Ff_info              uintptr
   2764 	Fyuv_b               uintptr
   2765 	Fcache_y             uintptr
   2766 	Fcache_u             uintptr
   2767 	Fcache_v             uintptr
   2768 	Fcache_y_stride      int32
   2769 	Fcache_uv_stride     int32
   2770 	Fmem                 uintptr
   2771 	Fmem_size            size_t
   2772 	Fmb_x                int32
   2773 	Fmb_y                int32
   2774 	Fmb_data             uintptr
   2775 	Ffilter_type         int32
   2776 	Ffstrengths          [4][2]VP8FInfo
   2777 	Falph_dec            uintptr
   2778 	Falpha_data          uintptr
   2779 	Falpha_data_size     size_t
   2780 	Fis_alpha_decoded    int32
   2781 	Falpha_plane_mem     uintptr
   2782 	Falpha_plane         uintptr
   2783 	Falpha_prev_line     uintptr
   2784 	Falpha_dithering     int32
   2785 }
   2786 
   2787 type rescaler_t = uint32
   2788 
   2789 type WebPRescaler = struct {
   2790 	Fx_expand     int32
   2791 	Fy_expand     int32
   2792 	Fnum_channels int32
   2793 	Ffx_scale     uint32_t
   2794 	Ffy_scale     uint32_t
   2795 	Ffxy_scale    uint32_t
   2796 	Fy_accum      int32
   2797 	Fy_add        int32
   2798 	Fy_sub        int32
   2799 	Fx_add        int32
   2800 	Fx_sub        int32
   2801 	Fsrc_width    int32
   2802 	Fsrc_height   int32
   2803 	Fdst_width    int32
   2804 	Fdst_height   int32
   2805 	Fsrc_y        int32
   2806 	Fdst_y        int32
   2807 	Fdst          uintptr
   2808 	Fdst_stride   int32
   2809 	Firow         uintptr
   2810 	Ffrow         uintptr
   2811 }
   2812 
   2813 type WebPDecParams = struct {
   2814 	Foutput         uintptr
   2815 	Ftmp_y          uintptr
   2816 	Ftmp_u          uintptr
   2817 	Ftmp_v          uintptr
   2818 	Flast_y         int32
   2819 	Foptions        uintptr
   2820 	Fscaler_y       uintptr
   2821 	Fscaler_u       uintptr
   2822 	Fscaler_v       uintptr
   2823 	Fscaler_a       uintptr
   2824 	Fmemory         uintptr
   2825 	Femit           OutputFunc
   2826 	Femit_alpha     OutputAlphaFunc
   2827 	Femit_alpha_row OutputRowFunc
   2828 }
   2829 
   2830 type OutputFunc = uintptr
   2831 
   2832 type OutputAlphaFunc = uintptr
   2833 
   2834 type OutputRowFunc = uintptr
   2835 
   2836 type WebPHeaderStructure = struct {
   2837 	Fdata            uintptr
   2838 	Fdata_size       size_t
   2839 	Fhave_all_data   int32
   2840 	Foffset          size_t
   2841 	Falpha_data      uintptr
   2842 	Falpha_data_size size_t
   2843 	Fcompressed_size size_t
   2844 	Friff_size       size_t
   2845 	Fis_lossless     int32
   2846 }
   2847 
   2848 type CPUFeature = int32
   2849 
   2850 const kSSE2 = 0
   2851 const kSSE3 = 1
   2852 const kSlowSSSE3 = 2
   2853 const kSSE4_1 = 3
   2854 const kAVX = 4
   2855 const kAVX2 = 5
   2856 const kNEON = 6
   2857 const kMIPS32 = 7
   2858 const kMIPSdspR2 = 8
   2859 const kMSA = 9
   2860 
   2861 type VP8CPUInfo = uintptr
   2862 
   2863 type VP8Idct = uintptr
   2864 
   2865 type VP8Fdct = uintptr
   2866 
   2867 type VP8WHT = uintptr
   2868 
   2869 type VP8IntraPreds = uintptr
   2870 
   2871 type VP8Intra4Preds = uintptr
   2872 
   2873 type VP8Metric = uintptr
   2874 
   2875 type VP8WMetric = uintptr
   2876 
   2877 type VP8MeanMetric = uintptr
   2878 
   2879 type VP8BlockCopy = uintptr
   2880 
   2881 type VP8QuantizeBlock = uintptr
   2882 
   2883 type VP8Quantize2Blocks = uintptr
   2884 
   2885 type VP8QuantizeBlockWHT = uintptr
   2886 
   2887 type VP8Histogram = struct {
   2888 	Fmax_value     int32
   2889 	Flast_non_zero int32
   2890 }
   2891 
   2892 type VP8CHisto = uintptr
   2893 
   2894 type VP8SetResidualCoeffsFunc = uintptr
   2895 
   2896 type VP8GetResidualCostFunc = uintptr
   2897 
   2898 type VP8DistoStats = struct {
   2899 	Fw   uint32_t
   2900 	Fxm  uint32_t
   2901 	Fym  uint32_t
   2902 	Fxxm uint32_t
   2903 	Fxym uint32_t
   2904 	Fyym uint32_t
   2905 }
   2906 
   2907 type VP8SSIMGetClippedFunc = uintptr
   2908 
   2909 type VP8SSIMGetFunc = uintptr
   2910 
   2911 type VP8AccumulateSSEFunc = uintptr
   2912 
   2913 type VP8DecIdct = uintptr
   2914 
   2915 type VP8DecIdct2 = uintptr
   2916 
   2917 type VP8PredFunc = uintptr
   2918 
   2919 type VP8SimpleFilterFunc = uintptr
   2920 
   2921 type VP8LumaFilterFunc = uintptr
   2922 
   2923 type VP8ChromaFilterFunc = uintptr
   2924 
   2925 type WebPUpsampleLinePairFunc = uintptr
   2926 
   2927 type WebPSamplerRowFunc = uintptr
   2928 
   2929 type WebPYUV444Converter = uintptr
   2930 
   2931 type WebPRescalerImportRowFunc = uintptr
   2932 
   2933 type WebPRescalerExportRowFunc = uintptr
   2934 
   2935 type WEBP_FILTER_TYPE = int32
   2936 
   2937 const WEBP_FILTER_NONE = 0
   2938 const WEBP_FILTER_HORIZONTAL = 1
   2939 const WEBP_FILTER_VERTICAL = 2
   2940 const WEBP_FILTER_GRADIENT = 3
   2941 const WEBP_FILTER_LAST = 4
   2942 const WEBP_FILTER_BEST = 5
   2943 const WEBP_FILTER_FAST = 6
   2944 
   2945 type WebPFilterFunc = uintptr
   2946 
   2947 type WebPUnfilterFunc = uintptr
   2948 
   2949 type VP8LDecoder = struct {
   2950 	Fstatus           VP8StatusCode1
   2951 	Fstate            VP8LDecodeState
   2952 	Fio               uintptr
   2953 	Foutput           uintptr
   2954 	Fpixels           uintptr
   2955 	Fargb_cache       uintptr
   2956 	Fbr               VP8LBitReader
   2957 	Fincremental      int32
   2958 	Fsaved_br         VP8LBitReader
   2959 	Fsaved_last_pixel int32
   2960 	Fwidth            int32
   2961 	Fheight           int32
   2962 	Flast_row         int32
   2963 	Flast_pixel       int32
   2964 	Flast_out_row     int32
   2965 	Fhdr              VP8LMetadata
   2966 	Fnext_transform   int32
   2967 	Ftransforms       [4]VP8LTransform
   2968 	Ftransforms_seen  uint32_t
   2969 	Frescaler_memory  uintptr
   2970 	Frescaler         uintptr
   2971 }
   2972 
   2973 const READ_DATA = 0
   2974 const READ_HDR = 1
   2975 const READ_DIM = 2
   2976 
   2977 type ALPHDecoder = struct {
   2978 	Fwidth          int32
   2979 	Fheight         int32
   2980 	Fmethod         int32
   2981 	Ffilter         WEBP_FILTER_TYPE
   2982 	Fpre_processing int32
   2983 	Fvp8l_dec       uintptr
   2984 	Fio             VP8Io
   2985 	Fuse_8b_decode  int32
   2986 	Foutput         uintptr
   2987 	Fprev_line      uintptr
   2988 }
   2989 
   2990 type errno_t = int32
   2991 
   2992 type ssize_t = int64
   2993 
   2994 const B_DC_PRED = 0
   2995 const B_TM_PRED = 1
   2996 const B_VE_PRED = 2
   2997 const B_HE_PRED = 3
   2998 const B_RD_PRED = 4
   2999 const B_VR_PRED = 5
   3000 const B_LD_PRED = 6
   3001 const B_VL_PRED = 7
   3002 const B_HD_PRED = 8
   3003 const B_HU_PRED = 9
   3004 const NUM_BMODES = 10
   3005 const DC_PRED = 0
   3006 const V_PRED = 2
   3007 const H_PRED = 3
   3008 const TM_PRED = 1
   3009 const B_PRED = 10
   3010 const NUM_PRED_MODES = 4
   3011 const B_DC_PRED_NOTOP = 4
   3012 const B_DC_PRED_NOLEFT = 5
   3013 const B_DC_PRED_NOTOPLEFT = 6
   3014 const NUM_B_DC_MODES = 7
   3015 const MB_FEATURE_TREE_PROBS = 3
   3016 const NUM_MB_SEGMENTS = 4
   3017 const NUM_REF_LF_DELTAS = 4
   3018 const NUM_MODE_LF_DELTAS = 4
   3019 const MAX_NUM_PARTITIONS = 8
   3020 const NUM_TYPES = 4
   3021 const NUM_BANDS = 8
   3022 const NUM_CTX = 3
   3023 const NUM_PROBAS = 11
   3024 
   3025 type bit_t = uint64
   3026 
   3027 type range_t = uint32
   3028 
   3029 type VP8BitReader = struct {
   3030 	Fvalue   bit_t
   3031 	Frange1  range_t
   3032 	Fbits    int32
   3033 	Fbuf     uintptr
   3034 	Fbuf_end uintptr
   3035 	Fbuf_max uintptr
   3036 	Feof     int32
   3037 }
   3038 
   3039 type vp8l_val_t = uint64
   3040 
   3041 type VP8LBitReader = struct {
   3042 	Fval     vp8l_val_t
   3043 	Fbuf     uintptr
   3044 	Flen1    size_t
   3045 	Fpos     size_t
   3046 	Fbit_pos int32
   3047 	Feos     int32
   3048 }
   3049 
   3050 type VP8LColorCache = struct {
   3051 	Fcolors     uintptr
   3052 	Fhash_shift int32
   3053 	Fhash_bits  int32
   3054 }
   3055 
   3056 var kHashMul = uint32(0x1e35a7bd)
   3057 
   3058 type VP8LImageTransformType = int32
   3059 
   3060 const PREDICTOR_TRANSFORM = 0
   3061 const CROSS_COLOR_TRANSFORM = 1
   3062 const SUBTRACT_GREEN_TRANSFORM = 2
   3063 const COLOR_INDEXING_TRANSFORM = 3
   3064 
   3065 type HuffmanCode = struct {
   3066 	Fbits  uint8_t
   3067 	Fvalue uint16_t
   3068 }
   3069 
   3070 type HuffmanCode32 = struct {
   3071 	Fbits  int32
   3072 	Fvalue uint32_t
   3073 }
   3074 
   3075 type HuffmanTablesSegment = struct {
   3076 	Fstart      uintptr
   3077 	Fcurr_table uintptr
   3078 	Fnext       uintptr
   3079 	Fsize       int32
   3080 }
   3081 
   3082 type HuffmanTables = struct {
   3083 	Froot         HuffmanTablesSegment
   3084 	Fcurr_segment uintptr
   3085 }
   3086 
   3087 type HTreeGroup = struct {
   3088 	Fhtrees             [5]uintptr
   3089 	Fis_trivial_literal int32
   3090 	Fliteral_arb        uint32_t
   3091 	Fis_trivial_code    int32
   3092 	Fuse_packed_table   int32
   3093 	Fpacked_table       [64]HuffmanCode32
   3094 }
   3095 
   3096 type VP8LDecodeState = int32
   3097 
   3098 type VP8LTransform = struct {
   3099 	Ftype1 VP8LImageTransformType
   3100 	Fbits  int32
   3101 	Fxsize int32
   3102 	Fysize int32
   3103 	Fdata  uintptr
   3104 }
   3105 
   3106 type VP8LMetadata = struct {
   3107 	Fcolor_cache_size       int32
   3108 	Fcolor_cache            VP8LColorCache
   3109 	Fsaved_color_cache      VP8LColorCache
   3110 	Fhuffman_mask           int32
   3111 	Fhuffman_subsample_bits int32
   3112 	Fhuffman_xsize          int32
   3113 	Fhuffman_image          uintptr
   3114 	Fnum_htree_groups       int32
   3115 	Fhtree_groups           uintptr
   3116 	Fhuffman_tables         HuffmanTables
   3117 }
   3118 
   3119 type VP8Random = struct {
   3120 	Findex1 int32
   3121 	Findex2 int32
   3122 	Ftab    [55]uint32_t
   3123 	Famp    int32
   3124 }
   3125 
   3126 type WebPWorkerStatus = int32
   3127 
   3128 const NOT_OK = 0
   3129 const OK = 1
   3130 const WORK = 2
   3131 
   3132 type WebPWorkerHook = uintptr
   3133 
   3134 type WebPWorker = struct {
   3135 	Fimpl      uintptr
   3136 	Fstatus    WebPWorkerStatus
   3137 	Fhook      WebPWorkerHook
   3138 	Fdata1     uintptr
   3139 	Fdata2     uintptr
   3140 	Fhad_error int32
   3141 }
   3142 
   3143 type WebPWorkerInterface = struct {
   3144 	FInit    uintptr
   3145 	FReset   uintptr
   3146 	FSync    uintptr
   3147 	FLaunch  uintptr
   3148 	FExecute uintptr
   3149 	FEnd     uintptr
   3150 }
   3151 
   3152 type VP8FrameHeader = struct {
   3153 	Fkey_frame        uint8_t
   3154 	Fprofile          uint8_t
   3155 	Fshow             uint8_t
   3156 	Fpartition_length uint32_t
   3157 }
   3158 
   3159 type VP8PictureHeader = struct {
   3160 	Fwidth      uint16_t
   3161 	Fheight     uint16_t
   3162 	Fxscale     uint8_t
   3163 	Fyscale     uint8_t
   3164 	Fcolorspace uint8_t
   3165 	Fclamp_type uint8_t
   3166 }
   3167 
   3168 type VP8SegmentHeader = struct {
   3169 	Fuse_segment     int32
   3170 	Fupdate_map      int32
   3171 	Fabsolute_delta  int32
   3172 	Fquantizer       [4]int8_t
   3173 	Ffilter_strength [4]int8_t
   3174 }
   3175 
   3176 type VP8ProbaArray = [11]uint8_t
   3177 
   3178 type VP8BandProbas = struct {
   3179 	Fprobas [3]VP8ProbaArray
   3180 }
   3181 
   3182 type VP8Proba = struct {
   3183 	Fsegments  [3]uint8_t
   3184 	Fbands     [4][8]VP8BandProbas
   3185 	Fbands_ptr [4][17]uintptr
   3186 }
   3187 
   3188 type VP8FilterHeader = struct {
   3189 	Fsimple        int32
   3190 	Flevel         int32
   3191 	Fsharpness     int32
   3192 	Fuse_lf_delta  int32
   3193 	Fref_lf_delta  [4]int32
   3194 	Fmode_lf_delta [4]int32
   3195 }
   3196 
   3197 type VP8FInfo = struct {
   3198 	Ff_limit    uint8_t
   3199 	Ff_ilevel   uint8_t
   3200 	Ff_inner    uint8_t
   3201 	Fhev_thresh uint8_t
   3202 }
   3203 
   3204 type VP8MB = struct {
   3205 	Fnz    uint8_t
   3206 	Fnz_dc uint8_t
   3207 }
   3208 
   3209 type quant_t = [2]int32
   3210 
   3211 type VP8QuantMatrix = struct {
   3212 	Fy1_mat   quant_t
   3213 	Fy2_mat   quant_t
   3214 	Fuv_mat   quant_t
   3215 	Fuv_quant int32
   3216 	Fdither   int32
   3217 }
   3218 
   3219 type VP8MBData = struct {
   3220 	Fcoeffs      [384]int16_t
   3221 	Fis_i4x4     uint8_t
   3222 	Fimodes      [16]uint8_t
   3223 	Fuvmode      uint8_t
   3224 	Fnon_zero_y  uint32_t
   3225 	Fnon_zero_uv uint32_t
   3226 	Fdither      uint8_t
   3227 	Fskip        uint8_t
   3228 	Fsegment     uint8_t
   3229 }
   3230 
   3231 type VP8ThreadContext = struct {
   3232 	Fid         int32
   3233 	Fmb_y       int32
   3234 	Ffilter_row int32
   3235 	Ff_info     uintptr
   3236 	Fmb_data    uintptr
   3237 	Fio         VP8Io
   3238 }
   3239 
   3240 type VP8TopSamples = struct {
   3241 	Fy [16]uint8_t
   3242 	Fu [8]uint8_t
   3243 	Fv [8]uint8_t
   3244 }
   3245 
   3246 //------------------------------------------------------------------------------
   3247 
   3248 // Copyright 2010 Google Inc. All Rights Reserved.
   3249 //
   3250 // Use of this source code is governed by a BSD-style license
   3251 // that can be found in the COPYING file in the root of the source
   3252 // tree. An additional intellectual property rights grant can be found
   3253 // in the file PATENTS. All contributing project authors may
   3254 // be found in the AUTHORS file in the root of the source tree.
   3255 // -----------------------------------------------------------------------------
   3256 //
   3257 //  Main decoding functions for WebP images.
   3258 //
   3259 // Author: Skal (pascal.massimino@gmail.com)
   3260 
   3261 // Copyright 2012 Google Inc. All Rights Reserved.
   3262 //
   3263 // Use of this source code is governed by a BSD-style license
   3264 // that can be found in the COPYING file in the root of the source
   3265 // tree. An additional intellectual property rights grant can be found
   3266 // in the file PATENTS. All contributing project authors may
   3267 // be found in the AUTHORS file in the root of the source tree.
   3268 // -----------------------------------------------------------------------------
   3269 //
   3270 //  Internal header for constants related to WebP file format.
   3271 //
   3272 // Author: Urvang (urvang@google.com)
   3273 
   3274 // Copyright 2010 Google Inc. All Rights Reserved.
   3275 //
   3276 // Use of this source code is governed by a BSD-style license
   3277 // that can be found in the COPYING file in the root of the source
   3278 // tree. An additional intellectual property rights grant can be found
   3279 // in the file PATENTS. All contributing project authors may
   3280 // be found in the AUTHORS file in the root of the source tree.
   3281 // -----------------------------------------------------------------------------
   3282 //
   3283 //  Common types + memory wrappers
   3284 //
   3285 // Author: Skal (pascal.massimino@gmail.com)
   3286 
   3287 //------------------------------------------------------------------------------
   3288 // ALPHDecoder object.
   3289 
   3290 // C documentation
   3291 //
   3292 //	// Allocates a new alpha decoder instance.
   3293 func ALPHNew(tls *libc.TLS) (r uintptr) {
   3294 	var dec uintptr
   3295 	_ = dec
   3296 	dec = WebPSafeCalloc(tls, uint64(1), uint64(216))
   3297 	return dec
   3298 }
   3299 
   3300 // C documentation
   3301 //
   3302 //	// Clears and deallocates an alpha decoder instance.
   3303 func ALPHDelete(tls *libc.TLS, dec uintptr) {
   3304 	if dec != libc.UintptrFromInt32(0) {
   3305 		VP8LDelete(tls, (*ALPHDecoder)(unsafe.Pointer(dec)).Fvp8l_dec)
   3306 		(*ALPHDecoder)(unsafe.Pointer(dec)).Fvp8l_dec = libc.UintptrFromInt32(0)
   3307 		WebPSafeFree(tls, dec)
   3308 	}
   3309 }
   3310 
   3311 //------------------------------------------------------------------------------
   3312 // Decoding.
   3313 
   3314 // C documentation
   3315 //
   3316 //	// Initialize alpha decoding by parsing the alpha header and decoding the image
   3317 //	// header for alpha data stored using lossless compression.
   3318 //	// Returns false in case of error in alpha header (data too short, invalid
   3319 //	// compression method or filter, error in lossless header data etc).
   3320 func ALPHInit(tls *libc.TLS, dec uintptr, data uintptr, data_size size_t, src_io uintptr, output uintptr) (r int32) {
   3321 	var alpha_data, io1 uintptr
   3322 	var alpha_data_size, alpha_decoded_size size_t
   3323 	var ok, rsrv, v1 int32
   3324 	_, _, _, _, _, _, _ = alpha_data, alpha_data_size, alpha_decoded_size, io1, ok, rsrv, v1
   3325 	ok = 0
   3326 	alpha_data = data + uintptr(ALPHA_HEADER_LEN)
   3327 	alpha_data_size = data_size - uint64(ALPHA_HEADER_LEN)
   3328 	io1 = dec + 32
   3329 	VP8FiltersInit(tls)
   3330 	(*ALPHDecoder)(unsafe.Pointer(dec)).Foutput = output
   3331 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fwidth = (*VP8Io)(unsafe.Pointer(src_io)).Fwidth
   3332 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fheight = (*VP8Io)(unsafe.Pointer(src_io)).Fheight
   3333 	if data_size <= uint64(ALPHA_HEADER_LEN) {
   3334 		return 0
   3335 	}
   3336 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> 0 & int32(0x03)
   3337 	(*ALPHDecoder)(unsafe.Pointer(dec)).Ffilter = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> libc.Int32FromInt32(2) & libc.Int32FromInt32(0x03)
   3338 	(*ALPHDecoder)(unsafe.Pointer(dec)).Fpre_processing = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> int32(4) & int32(0x03)
   3339 	rsrv = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data))) >> int32(6) & int32(0x03)
   3340 	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 {
   3341 		return 0
   3342 	}
   3343 	// Copy the necessary parameters from src_io to io
   3344 	v1 = VP8InitIoInternal(tls, io1, int32(WEBP_DECODER_ABI_VERSION))
   3345 	goto _2
   3346 _2:
   3347 	if !(v1 != 0) {
   3348 		return 0
   3349 	}
   3350 	WebPInitCustomIo(tls, libc.UintptrFromInt32(0), io1)
   3351 	(*VP8Io)(unsafe.Pointer(io1)).Fopaque = dec
   3352 	(*VP8Io)(unsafe.Pointer(io1)).Fwidth = (*VP8Io)(unsafe.Pointer(src_io)).Fwidth
   3353 	(*VP8Io)(unsafe.Pointer(io1)).Fheight = (*VP8Io)(unsafe.Pointer(src_io)).Fheight
   3354 	(*VP8Io)(unsafe.Pointer(io1)).Fuse_cropping = (*VP8Io)(unsafe.Pointer(src_io)).Fuse_cropping
   3355 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_left = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_left
   3356 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_right = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_right
   3357 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_top = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_top
   3358 	(*VP8Io)(unsafe.Pointer(io1)).Fcrop_bottom = (*VP8Io)(unsafe.Pointer(src_io)).Fcrop_bottom
   3359 	// No need to copy the scaling parameters.
   3360 	if (*ALPHDecoder)(unsafe.Pointer(dec)).Fmethod == ALPHA_NO_COMPRESSION {
   3361 		alpha_decoded_size = libc.Uint64FromInt32((*ALPHDecoder)(unsafe.Pointer(dec)).Fwidth * (*ALPHDecoder)(unsafe.Pointer(dec)).Fheight)
   3362 		ok = libc.BoolInt32(alpha_data_size >= alpha_decoded_size)
   3363 	} else {
   3364 		ok = VP8LDecodeAlphaHeader(tls, dec, alpha_data, alpha_data_size)
   3365 	}
   3366 	return ok
   3367 }
   3368 
   3369 // C documentation
   3370 //
   3371 //	// Decodes, unfilters and dequantizes *at least* 'num_rows' rows of alpha
   3372 //	// starting from row number 'row'. It assumes that rows up to (row - 1) have
   3373 //	// already been decoded.
   3374 //	// Returns false in case of bitstream error.
   3375 func ALPHDecode(tls *libc.TLS, dec uintptr, row int32, num_rows int32) (r int32) {
   3376 	var alph_dec, deltas, dst, prev_line uintptr
   3377 	var height, width, y int32
   3378 	_, _, _, _, _, _, _ = alph_dec, deltas, dst, height, prev_line, width, y
   3379 	alph_dec = (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec
   3380 	width = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
   3381 	height = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fio.Fcrop_bottom
   3382 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fmethod == ALPHA_NO_COMPRESSION {
   3383 		prev_line = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line
   3384 		deltas = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data + uintptr(ALPHA_HEADER_LEN) + uintptr(row*width)
   3385 		dst = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr(row*width)
   3386 		y = 0
   3387 		for {
   3388 			if !(y < num_rows) {
   3389 				break
   3390 			}
   3391 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPUnfilters[(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter]})))(tls, prev_line, deltas, dst, width)
   3392 			prev_line = dst
   3393 			dst = dst + uintptr(width)
   3394 			deltas = deltas + uintptr(width)
   3395 			goto _1
   3396 		_1:
   3397 			;
   3398 			y = y + 1
   3399 		}
   3400 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line = prev_line
   3401 	} else { // alph_dec->method == ALPHA_LOSSLESS_COMPRESSION
   3402 		if !(VP8LDecodeAlphaImageStream(tls, alph_dec, row+num_rows) != 0) {
   3403 			return 0
   3404 		}
   3405 	}
   3406 	if row+num_rows >= height {
   3407 		(*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded = int32(1)
   3408 	}
   3409 	return int32(1)
   3410 }
   3411 
   3412 func AllocateAlphaPlane(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   3413 	var alpha_size uint64_t
   3414 	var height, stride int32
   3415 	_, _, _ = alpha_size, height, stride
   3416 	stride = (*VP8Io)(unsafe.Pointer(io)).Fwidth
   3417 	height = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom
   3418 	alpha_size = libc.Uint64FromInt32(stride) * libc.Uint64FromInt32(height)
   3419 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem = WebPSafeMalloc(tls, alpha_size, uint64(1))
   3420 	if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem == libc.UintptrFromInt32(0) {
   3421 		return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts)
   3422 	}
   3423 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem
   3424 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_prev_line = libc.UintptrFromInt32(0)
   3425 	return int32(1)
   3426 }
   3427 
   3428 func WebPDeallocateAlphaMemory(tls *libc.TLS, dec uintptr) {
   3429 	WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem)
   3430 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane_mem = libc.UintptrFromInt32(0)
   3431 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = libc.UintptrFromInt32(0)
   3432 	ALPHDelete(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)
   3433 	(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = libc.UintptrFromInt32(0)
   3434 }
   3435 
   3436 // ------------------------------------------------------------------------------
   3437 // Main entry point.
   3438 func VP8DecompressAlphaRows(tls *libc.TLS, dec uintptr, io uintptr, row int32, num_rows int32) (r uintptr) {
   3439 	var alpha, vp8l_dec uintptr
   3440 	var height, width, v1 int32
   3441 	_, _, _, _, _ = alpha, height, vp8l_dec, width, v1
   3442 	width = (*VP8Io)(unsafe.Pointer(io)).Fwidth
   3443 	height = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom
   3444 	if row < 0 || num_rows <= 0 || row+num_rows > height {
   3445 		return libc.UintptrFromInt32(0)
   3446 	}
   3447 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0) {
   3448 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec == libc.UintptrFromInt32(0) { // Initialize decoder.
   3449 			(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = ALPHNew(tls)
   3450 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec == libc.UintptrFromInt32(0) {
   3451 				VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts)
   3452 				return libc.UintptrFromInt32(0)
   3453 			}
   3454 			if !(AllocateAlphaPlane(tls, dec, io) != 0) {
   3455 				goto Error
   3456 			}
   3457 			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) {
   3458 				vp8l_dec = (*ALPHDecoder)(unsafe.Pointer((*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)).Fvp8l_dec
   3459 				if vp8l_dec == libc.UintptrFromInt32(0) {
   3460 					v1 = int32(VP8_STATUS_OUT_OF_MEMORY)
   3461 				} else {
   3462 					v1 = (*VP8LDecoder)(unsafe.Pointer(vp8l_dec)).Fstatus
   3463 				}
   3464 				VP8SetError(tls, dec, v1, __ccgo_ts)
   3465 				goto Error
   3466 			}
   3467 			// if we allowed use of alpha dithering, check whether it's needed at all
   3468 			if (*ALPHDecoder)(unsafe.Pointer((*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)).Fpre_processing != int32(ALPHA_PREPROCESSED_LEVELS) {
   3469 				(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = 0 // disable dithering
   3470 			} else {
   3471 				num_rows = height - row // decode everything in one pass
   3472 			}
   3473 		}
   3474 		if !(ALPHDecode(tls, dec, row, num_rows) != 0) {
   3475 			goto Error
   3476 		}
   3477 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0 { // finished?
   3478 			ALPHDelete(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec)
   3479 			(*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec = libc.UintptrFromInt32(0)
   3480 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering > 0 {
   3481 				alpha = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_top*width) + uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   3482 				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) {
   3483 					goto Error
   3484 				}
   3485 			}
   3486 		}
   3487 	}
   3488 	// Return a pointer to the current decoded row.
   3489 	return (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane + uintptr(row*width)
   3490 	goto Error
   3491 Error:
   3492 	;
   3493 	WebPDeallocateAlphaMemory(tls, dec)
   3494 	return libc.UintptrFromInt32(0)
   3495 }
   3496 
   3497 var kHashMul1 = uint32(0x1e35a7bd)
   3498 
   3499 //------------------------------------------------------------------------------
   3500 
   3501 // Copyright 2010 Google Inc. All Rights Reserved.
   3502 //
   3503 // Use of this source code is governed by a BSD-style license
   3504 // that can be found in the COPYING file in the root of the source
   3505 // tree. An additional intellectual property rights grant can be found
   3506 // in the file PATENTS. All contributing project authors may
   3507 // be found in the AUTHORS file in the root of the source tree.
   3508 // -----------------------------------------------------------------------------
   3509 //
   3510 //  Main decoding functions for WebP images.
   3511 //
   3512 // Author: Skal (pascal.massimino@gmail.com)
   3513 
   3514 // Copyright 2010 Google Inc. All Rights Reserved.
   3515 //
   3516 // Use of this source code is governed by a BSD-style license
   3517 // that can be found in the COPYING file in the root of the source
   3518 // tree. An additional intellectual property rights grant can be found
   3519 // in the file PATENTS. All contributing project authors may
   3520 // be found in the AUTHORS file in the root of the source tree.
   3521 // -----------------------------------------------------------------------------
   3522 //
   3523 //  Common types + memory wrappers
   3524 //
   3525 // Author: Skal (pascal.massimino@gmail.com)
   3526 
   3527 //------------------------------------------------------------------------------
   3528 // WebPDecBuffer
   3529 
   3530 // C documentation
   3531 //
   3532 //	// Number of bytes per pixel for the different color-spaces.
   3533 var kModeBpp = [13]uint8_t{
   3534 	0:  uint8(3),
   3535 	1:  uint8(4),
   3536 	2:  uint8(3),
   3537 	3:  uint8(4),
   3538 	4:  uint8(4),
   3539 	5:  uint8(2),
   3540 	6:  uint8(2),
   3541 	7:  uint8(4),
   3542 	8:  uint8(4),
   3543 	9:  uint8(4),
   3544 	10: uint8(2),
   3545 	11: uint8(1),
   3546 	12: uint8(1),
   3547 }
   3548 
   3549 // C documentation
   3550 //
   3551 //	// Convert to an integer to handle both the unsigned/signed enum cases
   3552 //	// without the need for casting to remove type limit warnings.
   3553 func IsValidColorspace(tls *libc.TLS, webp_csp_mode int32) (r int32) {
   3554 	return libc.BoolInt32(webp_csp_mode >= int32(MODE_RGB) && webp_csp_mode < int32(MODE_LAST))
   3555 }
   3556 
   3557 // strictly speaking, the very last (or first, if flipped) row
   3558 // doesn't require padding.
   3559 
   3560 func CheckDecBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3561 	var a_size, size, u_size, v_size, y_size uint64_t
   3562 	var a_stride, height, ok, stride, u_stride, uv_height, uv_width, v_stride, width, y_stride, v1 int32
   3563 	var buf, buf1 uintptr
   3564 	var mode1 WEBP_CSP_MODE1
   3565 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   3566 	ok = int32(1)
   3567 	mode1 = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace
   3568 	width = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth
   3569 	height = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight
   3570 	if !(IsValidColorspace(tls, mode1) != 0) {
   3571 		ok = 0
   3572 	} else {
   3573 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3574 		goto _2
   3575 	_2:
   3576 		if !(v1 != 0) { // YUV checks
   3577 			buf = buffer + 16
   3578 			uv_width = (width + int32(1)) / int32(2)
   3579 			uv_height = (height + int32(1)) / int32(2)
   3580 			y_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride)
   3581 			u_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride)
   3582 			v_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride)
   3583 			a_stride = libc.Xabs(tls, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   3584 			y_size = libc.Uint64FromInt32(y_stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)
   3585 			u_size = libc.Uint64FromInt32(u_stride)*libc.Uint64FromInt32(uv_height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(uv_width)
   3586 			v_size = libc.Uint64FromInt32(v_stride)*libc.Uint64FromInt32(uv_height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(uv_width)
   3587 			a_size = libc.Uint64FromInt32(a_stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)
   3588 			ok = ok & libc.BoolInt32(y_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_size)
   3589 			ok = ok & libc.BoolInt32(u_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_size)
   3590 			ok = ok & libc.BoolInt32(v_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_size)
   3591 			ok = ok & libc.BoolInt32(y_stride >= width)
   3592 			ok = ok & libc.BoolInt32(u_stride >= uv_width)
   3593 			ok = ok & libc.BoolInt32(v_stride >= uv_width)
   3594 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy != libc.UintptrFromInt32(0))
   3595 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu != libc.UintptrFromInt32(0))
   3596 			ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv != libc.UintptrFromInt32(0))
   3597 			if mode1 == int32(MODE_YUVA) {
   3598 				ok = ok & libc.BoolInt32(a_stride >= width)
   3599 				ok = ok & libc.BoolInt32(a_size <= (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_size)
   3600 				ok = ok & libc.BoolInt32((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0))
   3601 			}
   3602 		} else { // RGB checks
   3603 			buf1 = buffer + 16
   3604 			stride = libc.Xabs(tls, (*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fstride)
   3605 			size = libc.Uint64FromInt32(stride)*libc.Uint64FromInt32(height-libc.Int32FromInt32(1)) + libc.Uint64FromInt32(width)*uint64(kModeBpp[mode1])
   3606 			ok = ok & libc.BoolInt32(size <= (*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fsize)
   3607 			ok = ok & libc.BoolInt32(stride >= width*libc.Int32FromUint8(kModeBpp[mode1]))
   3608 			ok = ok & libc.BoolInt32((*WebPRGBABuffer)(unsafe.Pointer(buf1)).Frgba != libc.UintptrFromInt32(0))
   3609 		}
   3610 	}
   3611 	if ok != 0 {
   3612 		v1 = int32(VP8_STATUS_OK)
   3613 	} else {
   3614 		v1 = int32(VP8_STATUS_INVALID_PARAM)
   3615 	}
   3616 	return v1
   3617 }
   3618 
   3619 func AllocateBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3620 	var a_size, size, total_size, uv_size uint64_t
   3621 	var a_stride, h, stride, uv_stride, w, v1 int32
   3622 	var buf, buf1, output uintptr
   3623 	var mode1 WEBP_CSP_MODE1
   3624 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_size, a_stride, buf, buf1, h, mode1, output, size, stride, total_size, uv_size, uv_stride, w, v1
   3625 	w = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth
   3626 	h = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight
   3627 	mode1 = (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace
   3628 	if w <= 0 || h <= 0 || !(IsValidColorspace(tls, mode1) != 0) {
   3629 		return int32(VP8_STATUS_INVALID_PARAM)
   3630 	}
   3631 	if (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fis_external_memory <= 0 && (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory == libc.UintptrFromInt32(0) {
   3632 		uv_stride = 0
   3633 		a_stride = 0
   3634 		uv_size = uint64(0)
   3635 		a_size = uint64(0)
   3636 		if libc.Uint64FromInt32(w)*uint64(kModeBpp[mode1]) >= libc.Uint64FromUint64(1)<<libc.Int32FromInt32(31) {
   3637 			return int32(VP8_STATUS_INVALID_PARAM)
   3638 		}
   3639 		stride = w * libc.Int32FromUint8(kModeBpp[mode1])
   3640 		size = libc.Uint64FromInt32(stride) * libc.Uint64FromInt32(h)
   3641 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3642 		goto _2
   3643 	_2:
   3644 		if !(v1 != 0) {
   3645 			uv_stride = (w + int32(1)) / int32(2)
   3646 			uv_size = libc.Uint64FromInt32(uv_stride) * libc.Uint64FromInt32((h+libc.Int32FromInt32(1))/libc.Int32FromInt32(2))
   3647 			if mode1 == int32(MODE_YUVA) {
   3648 				a_stride = w
   3649 				a_size = libc.Uint64FromInt32(a_stride) * libc.Uint64FromInt32(h)
   3650 			}
   3651 		}
   3652 		total_size = size + uint64(2)*uv_size + a_size
   3653 		output = WebPSafeMalloc(tls, total_size, uint64(1))
   3654 		if output == libc.UintptrFromInt32(0) {
   3655 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   3656 		}
   3657 		(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory = output
   3658 		v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
   3659 		goto _4
   3660 	_4:
   3661 		if !(v1 != 0) { // YUVA initialization
   3662 			buf = buffer + 16
   3663 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy = output
   3664 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride = stride
   3665 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_size = size
   3666 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu = output + uintptr(size)
   3667 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride = uv_stride
   3668 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_size = uv_size
   3669 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv = output + uintptr(size) + uintptr(uv_size)
   3670 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride = uv_stride
   3671 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_size = uv_size
   3672 			if mode1 == int32(MODE_YUVA) {
   3673 				(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa = output + uintptr(size) + uintptr(uint64(2)*uv_size)
   3674 			}
   3675 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_size = a_size
   3676 			(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride = a_stride
   3677 		} else { // RGBA initialization
   3678 			buf1 = buffer + 16
   3679 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Frgba = output
   3680 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fstride = stride
   3681 			(*WebPRGBABuffer)(unsafe.Pointer(buf1)).Fsize = size
   3682 		}
   3683 	}
   3684 	return CheckDecBuffer(tls, buffer)
   3685 }
   3686 
   3687 func WebPFlipBuffer(tls *libc.TLS, buffer uintptr) (r VP8StatusCode1) {
   3688 	var H int64_t
   3689 	var buf, buf1 uintptr
   3690 	var v1 int32
   3691 	_, _, _, _ = H, buf, buf1, v1
   3692 	if buffer == libc.UintptrFromInt32(0) {
   3693 		return int32(VP8_STATUS_INVALID_PARAM)
   3694 	}
   3695 	v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fcolorspace < int32(MODE_YUV))
   3696 	goto _2
   3697 _2:
   3698 	if v1 != 0 {
   3699 		buf = buffer + 16
   3700 		**(**uintptr)(__ccgo_up(buf)) += uintptr(int64((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight-libc.Int32FromInt32(1)) * int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   3701 		(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride = -(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride
   3702 	} else {
   3703 		buf1 = buffer + 16
   3704 		H = int64((*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight)
   3705 		**(**uintptr)(__ccgo_up(buf1)) += uintptr((H - int64(1)) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride))
   3706 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fy_stride
   3707 		**(**uintptr)(__ccgo_up(buf1 + 8)) += uintptr((H - int64(1)) >> int32(1) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride))
   3708 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fu_stride
   3709 		**(**uintptr)(__ccgo_up(buf1 + 16)) += uintptr((H - int64(1)) >> int32(1) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride))
   3710 		(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fv_stride
   3711 		if (*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa != libc.UintptrFromInt32(0) {
   3712 			**(**uintptr)(__ccgo_up(buf1 + 24)) += uintptr((H - int64(1)) * int64((*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride))
   3713 			(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride = -(*WebPYUVABuffer)(unsafe.Pointer(buf1)).Fa_stride
   3714 		}
   3715 	}
   3716 	return int32(VP8_STATUS_OK)
   3717 }
   3718 
   3719 func WebPAllocateDecBuffer(tls *libc.TLS, width int32, height int32, options uintptr, buffer uintptr) (r VP8StatusCode1) {
   3720 	bp := tls.Alloc(16)
   3721 	defer tls.Free(16)
   3722 	var ch, cw, x, y int32
   3723 	var status VP8StatusCode1
   3724 	var _ /* scaled_height at bp+4 */ int32
   3725 	var _ /* scaled_width at bp+0 */ int32
   3726 	_, _, _, _, _ = ch, cw, status, x, y
   3727 	if buffer == libc.UintptrFromInt32(0) || width <= 0 || height <= 0 {
   3728 		return int32(VP8_STATUS_INVALID_PARAM)
   3729 	}
   3730 	if options != libc.UintptrFromInt32(0) { // First, apply options if there is any.
   3731 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0 {
   3732 			cw = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width
   3733 			ch = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height
   3734 			x = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left & ^libc.Int32FromInt32(1)
   3735 			y = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top & ^libc.Int32FromInt32(1)
   3736 			if !(WebPCheckCropDimensions(tls, width, height, x, y, cw, ch) != 0) {
   3737 				return int32(VP8_STATUS_INVALID_PARAM) // out of frame boundary.
   3738 			}
   3739 			width = cw
   3740 			height = ch
   3741 		}
   3742 		if (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0 {
   3743 			**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
   3744 			**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
   3745 			if !(WebPRescalerGetScaledDimensions(tls, width, height, bp, bp+4) != 0) {
   3746 				return int32(VP8_STATUS_INVALID_PARAM)
   3747 			}
   3748 			width = **(**int32)(__ccgo_up(bp))
   3749 			height = **(**int32)(__ccgo_up(bp + 4))
   3750 		}
   3751 	}
   3752 	(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fwidth = width
   3753 	(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fheight = height
   3754 	// Then, allocate buffer for real.
   3755 	status = AllocateBuffer(tls, buffer)
   3756 	if status != int32(VP8_STATUS_OK) {
   3757 		return status
   3758 	}
   3759 	// Use the stride trick if vertical flip is needed.
   3760 	if options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fflip != 0 {
   3761 		status = WebPFlipBuffer(tls, buffer)
   3762 	}
   3763 	return status
   3764 }
   3765 
   3766 //------------------------------------------------------------------------------
   3767 // constructors / destructors
   3768 
   3769 func WebPInitDecBufferInternal(tls *libc.TLS, buffer uintptr, version int32) (r int32) {
   3770 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
   3771 		return 0 // version mismatch
   3772 	}
   3773 	if buffer == libc.UintptrFromInt32(0) {
   3774 		return 0
   3775 	}
   3776 	libc.X__builtin___memset_chk(tls, buffer, 0, uint64(120), ^__predefined_size_t(0))
   3777 	return int32(1)
   3778 }
   3779 
   3780 func WebPFreeDecBuffer(tls *libc.TLS, buffer uintptr) {
   3781 	if buffer != libc.UintptrFromInt32(0) {
   3782 		if (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fis_external_memory <= 0 {
   3783 			WebPSafeFree(tls, (*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory)
   3784 		}
   3785 		(*WebPDecBuffer)(unsafe.Pointer(buffer)).Fprivate_memory = libc.UintptrFromInt32(0)
   3786 	}
   3787 }
   3788 
   3789 func WebPCopyDecBuffer(tls *libc.TLS, src uintptr, dst uintptr) {
   3790 	if src != libc.UintptrFromInt32(0) && dst != libc.UintptrFromInt32(0) {
   3791 		**(**WebPDecBuffer)(__ccgo_up(dst)) = **(**WebPDecBuffer)(__ccgo_up(src))
   3792 		if (*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory != libc.UintptrFromInt32(0) {
   3793 			(*WebPDecBuffer)(unsafe.Pointer(dst)).Fis_external_memory = int32(1) // dst buffer doesn't own the memory.
   3794 			(*WebPDecBuffer)(unsafe.Pointer(dst)).Fprivate_memory = libc.UintptrFromInt32(0)
   3795 		}
   3796 	}
   3797 }
   3798 
   3799 // C documentation
   3800 //
   3801 //	// Copy and transfer ownership from src to dst (beware of parameter order!)
   3802 func WebPGrabDecBuffer(tls *libc.TLS, src uintptr, dst uintptr) {
   3803 	if src != libc.UintptrFromInt32(0) && dst != libc.UintptrFromInt32(0) {
   3804 		**(**WebPDecBuffer)(__ccgo_up(dst)) = **(**WebPDecBuffer)(__ccgo_up(src))
   3805 		if (*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory != libc.UintptrFromInt32(0) {
   3806 			(*WebPDecBuffer)(unsafe.Pointer(src)).Fis_external_memory = int32(1) // src relinquishes ownership
   3807 			(*WebPDecBuffer)(unsafe.Pointer(src)).Fprivate_memory = libc.UintptrFromInt32(0)
   3808 		}
   3809 	}
   3810 }
   3811 
   3812 func WebPCopyDecBufferPixels(tls *libc.TLS, src_buf uintptr, dst_buf uintptr) (r VP8StatusCode1) {
   3813 	var dst, dst1, src, src1 uintptr
   3814 	var v1, v4 int32
   3815 	var v3, v6 WEBP_CSP_MODE1
   3816 	var v9 bool
   3817 	_, _, _, _, _, _, _, _, _ = dst, dst1, src, src1, v1, v3, v4, v6, v9
   3818 	(*WebPDecBuffer)(unsafe.Pointer(dst_buf)).Fwidth = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fwidth
   3819 	(*WebPDecBuffer)(unsafe.Pointer(dst_buf)).Fheight = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fheight
   3820 	if CheckDecBuffer(tls, dst_buf) != int32(VP8_STATUS_OK) {
   3821 		return int32(VP8_STATUS_INVALID_PARAM)
   3822 	}
   3823 	v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fcolorspace < int32(MODE_YUV))
   3824 	goto _2
   3825 _2:
   3826 	if v1 != 0 {
   3827 		src = src_buf + 16
   3828 		dst = dst_buf + 16
   3829 		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)
   3830 	} else {
   3831 		src1 = src_buf + 16
   3832 		dst1 = dst_buf + 16
   3833 		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)
   3834 		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))
   3835 		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))
   3836 		v3 = (*WebPDecBuffer)(unsafe.Pointer(src_buf)).Fcolorspace
   3837 		if v9 = v3 == int32(MODE_RGBA) || v3 == int32(MODE_BGRA) || v3 == int32(MODE_ARGB) || v3 == int32(MODE_RGBA_4444) || v3 == int32(MODE_YUVA); !v9 {
   3838 			v6 = v3
   3839 			v4 = libc.BoolInt32(v6 == int32(MODE_rgbA) || v6 == int32(MODE_bgrA) || v6 == int32(MODE_Argb) || v6 == int32(MODE_rgbA_4444))
   3840 			goto _8
   3841 		_8:
   3842 		}
   3843 		v1 = libc.BoolInt32(v9 || v4 != 0)
   3844 		goto _5
   3845 	_5:
   3846 		if v1 != 0 {
   3847 			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)
   3848 		}
   3849 	}
   3850 	return int32(VP8_STATUS_OK)
   3851 }
   3852 
   3853 func WebPAvoidSlowMemory(tls *libc.TLS, output uintptr, features uintptr) (r int32) {
   3854 	var v1 WEBP_CSP_MODE1
   3855 	var v2 int32
   3856 	var v4 bool
   3857 	_, _, _ = v1, v2, v4
   3858 	if v4 = (*WebPDecBuffer)(unsafe.Pointer(output)).Fis_external_memory >= int32(2); v4 {
   3859 		v1 = (*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace
   3860 		v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
   3861 		goto _3
   3862 	_3:
   3863 	}
   3864 	return libc.BoolInt32(v4 && v2 != 0 && (features != libc.UintptrFromInt32(0) && (*WebPBitstreamFeatures)(unsafe.Pointer(features)).Fhas_alpha != 0))
   3865 }
   3866 
   3867 const DITHER_AMP_TAB_SIZE = 12
   3868 const MIN_DITHER_AMP = 4
   3869 
   3870 var kHashMul2 = uint32(0x1e35a7bd)
   3871 
   3872 //------------------------------------------------------------------------------
   3873 
   3874 // Copyright 2010 Google Inc. All Rights Reserved.
   3875 //
   3876 // Use of this source code is governed by a BSD-style license
   3877 // that can be found in the COPYING file in the root of the source
   3878 // tree. An additional intellectual property rights grant can be found
   3879 // in the file PATENTS. All contributing project authors may
   3880 // be found in the AUTHORS file in the root of the source tree.
   3881 // -----------------------------------------------------------------------------
   3882 //
   3883 //  Main decoding functions for WebP images.
   3884 //
   3885 // Author: Skal (pascal.massimino@gmail.com)
   3886 
   3887 // Copyright 2010 Google Inc. All Rights Reserved.
   3888 //
   3889 // Use of this source code is governed by a BSD-style license
   3890 // that can be found in the COPYING file in the root of the source
   3891 // tree. An additional intellectual property rights grant can be found
   3892 // in the file PATENTS. All contributing project authors may
   3893 // be found in the AUTHORS file in the root of the source tree.
   3894 // -----------------------------------------------------------------------------
   3895 //
   3896 //  Common types + memory wrappers
   3897 //
   3898 // Author: Skal (pascal.massimino@gmail.com)
   3899 
   3900 //------------------------------------------------------------------------------
   3901 // Main reconstruction function.
   3902 
   3903 var kScan = [16]uint16_t{
   3904 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3905 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3906 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
   3907 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3908 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3909 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3910 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
   3911 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3912 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3913 	10: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3914 	11: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
   3915 	12: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3916 	13: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3917 	14: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3918 	15: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
   3919 }
   3920 
   3921 func CheckMode(tls *libc.TLS, mb_x int32, mb_y int32, mode int32) (r int32) {
   3922 	var v1 int32
   3923 	_ = v1
   3924 	if mode == int32(B_DC_PRED) {
   3925 		if mb_x == 0 {
   3926 			if mb_y == 0 {
   3927 				v1 = int32(B_DC_PRED_NOTOPLEFT)
   3928 			} else {
   3929 				v1 = int32(B_DC_PRED_NOLEFT)
   3930 			}
   3931 			return v1
   3932 		} else {
   3933 			if mb_y == 0 {
   3934 				v1 = int32(B_DC_PRED_NOTOP)
   3935 			} else {
   3936 				v1 = int32(B_DC_PRED)
   3937 			}
   3938 			return v1
   3939 		}
   3940 	}
   3941 	return mode
   3942 }
   3943 
   3944 func Copy32b(tls *libc.TLS, dst uintptr, src uintptr) {
   3945 	libc.X__builtin___memcpy_chk(tls, dst, src, uint64(4), ^__predefined_size_t(0))
   3946 }
   3947 
   3948 func DoTransform(tls *libc.TLS, bits uint32_t, src uintptr, dst uintptr) {
   3949 	switch bits >> libc.Int32FromInt32(30) {
   3950 	case uint32(3):
   3951 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8Transform})))(tls, src, dst, 0)
   3952 	case uint32(2):
   3953 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformAC3})))(tls, src, dst)
   3954 	case uint32(1):
   3955 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, src, dst)
   3956 	default:
   3957 		break
   3958 	}
   3959 }
   3960 
   3961 func DoUVTransform(tls *libc.TLS, bits uint32_t, src uintptr, dst uintptr) {
   3962 	if bits&uint32(0xff) != 0 { // any non-zero coeff at all?
   3963 		if bits&uint32(0xaa) != 0 { // any non-zero AC coefficient?
   3964 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformUV})))(tls, src, dst) // note we don't use the AC3 variant for U/V
   3965 		} else {
   3966 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDCUV})))(tls, src, dst)
   3967 		}
   3968 	}
   3969 }
   3970 
   3971 func ReconstructRow(tls *libc.TLS, dec uintptr, ctx uintptr) {
   3972 	var bits, bits_uv, v8, v9 uint32_t
   3973 	var block, coeffs, dst, top_right, top_yuv, u_dst, u_out, v_dst, v_out, y_dst, y_out uintptr
   3974 	var cache_id, j, mb_x, mb_y, n, pred_func, pred_func1, uv_offset, y_offset int32
   3975 	var v3, v4 uint8_t
   3976 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   3977 	mb_y = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y
   3978 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   3979 	y_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(1)+libc.Int32FromInt32(8))
   3980 	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))
   3981 	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))
   3982 	// Initialize left-most block.
   3983 	j = 0
   3984 	for {
   3985 		if !(j < int32(16)) {
   3986 			break
   3987 		}
   3988 		**(**uint8_t)(__ccgo_up(y_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   3989 		goto _1
   3990 	_1:
   3991 		;
   3992 		j = j + 1
   3993 	}
   3994 	j = 0
   3995 	for {
   3996 		if !(j < int32(8)) {
   3997 			break
   3998 		}
   3999 		**(**uint8_t)(__ccgo_up(u_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   4000 		**(**uint8_t)(__ccgo_up(v_dst + uintptr(j*int32(BPS)-int32(1)))) = uint8(129)
   4001 		goto _2
   4002 	_2:
   4003 		;
   4004 		j = j + 1
   4005 	}
   4006 	// Init top-left sample on left column too.
   4007 	if mb_y > 0 {
   4008 		v4 = libc.Uint8FromInt32(129)
   4009 		**(**uint8_t)(__ccgo_up(v_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v4
   4010 		v3 = v4
   4011 		**(**uint8_t)(__ccgo_up(u_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v3
   4012 		**(**uint8_t)(__ccgo_up(y_dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))) = v3
   4013 	} else {
   4014 		// we only need to do this init once at block (0,0).
   4015 		// Afterward, it remains valid for the whole topmost row.
   4016 		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))
   4017 		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))
   4018 		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))
   4019 	}
   4020 	// Reconstruct one row.
   4021 	mb_x = 0
   4022 	for {
   4023 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
   4024 			break
   4025 		}
   4026 		block = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data + uintptr(mb_x)*800
   4027 		// Rotate in the left samples from previously decoded block. We move four
   4028 		// pixels at a time for alignment reason, and because of in-loop filter.
   4029 		if mb_x > 0 {
   4030 			j = -int32(1)
   4031 			for {
   4032 				if !(j < int32(16)) {
   4033 					break
   4034 				}
   4035 				Copy32b(tls, y_dst+uintptr(j*int32(BPS)-int32(4)), y_dst+uintptr(j*int32(BPS)+int32(12)))
   4036 				goto _6
   4037 			_6:
   4038 				;
   4039 				j = j + 1
   4040 			}
   4041 			j = -int32(1)
   4042 			for {
   4043 				if !(j < int32(8)) {
   4044 					break
   4045 				}
   4046 				Copy32b(tls, u_dst+uintptr(j*int32(BPS)-int32(4)), u_dst+uintptr(j*int32(BPS)+int32(4)))
   4047 				Copy32b(tls, v_dst+uintptr(j*int32(BPS)-int32(4)), v_dst+uintptr(j*int32(BPS)+int32(4)))
   4048 				goto _7
   4049 			_7:
   4050 				;
   4051 				j = j + 1
   4052 			}
   4053 		}
   4054 		// bring top samples into the cache
   4055 		top_yuv = (*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_t + uintptr(mb_x)*32
   4056 		coeffs = block
   4057 		bits = (*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y
   4058 		if mb_y > 0 {
   4059 			libc.X__builtin___memcpy_chk(tls, y_dst-uintptr(BPS), top_yuv, uint64(16), ^__predefined_size_t(0))
   4060 			libc.X__builtin___memcpy_chk(tls, u_dst-uintptr(BPS), top_yuv+16, uint64(8), ^__predefined_size_t(0))
   4061 			libc.X__builtin___memcpy_chk(tls, v_dst-uintptr(BPS), top_yuv+24, uint64(8), ^__predefined_size_t(0))
   4062 		}
   4063 		// predict and add residuals
   4064 		if (*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0 { // 4x4
   4065 			top_right = y_dst - libc.UintptrFromInt32(BPS) + libc.UintptrFromInt32(16)
   4066 			if mb_y > 0 {
   4067 				if mb_x >= (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w-int32(1) { // on rightmost border
   4068 					libc.X__builtin___memset_chk(tls, top_right, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_yuv + 15))), uint64(4), ^__predefined_size_t(0))
   4069 				} else {
   4070 					libc.X__builtin___memcpy_chk(tls, top_right, top_yuv+1*32, uint64(4), ^__predefined_size_t(0))
   4071 				}
   4072 			}
   4073 			// replicate the top-right pixels below
   4074 			v9 = **(**uint32_t)(__ccgo_up(top_right))
   4075 			**(**uint32_t)(__ccgo_up(top_right + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))*4)) = v9
   4076 			v8 = v9
   4077 			**(**uint32_t)(__ccgo_up(top_right + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))*4)) = v8
   4078 			**(**uint32_t)(__ccgo_up(top_right + 32*4)) = v8
   4079 			// predict and add residuals for all 4x4 blocks in turn.
   4080 			n = 0
   4081 			for {
   4082 				if !(n < int32(16)) {
   4083 					break
   4084 				}
   4085 				dst = y_dst + uintptr(kScan[n])
   4086 				(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredLuma4[**(**uint8_t)(__ccgo_up(block + 769 + uintptr(n)))]})))(tls, dst)
   4087 				DoTransform(tls, bits, coeffs+uintptr(n*int32(16))*2, dst)
   4088 				goto _10
   4089 			_10:
   4090 				;
   4091 				n = n + 1
   4092 				bits = bits << uint32(2)
   4093 			}
   4094 		} else { // 16x16
   4095 			pred_func = CheckMode(tls, mb_x, mb_y, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(block + 769))))
   4096 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredLuma16[pred_func]})))(tls, y_dst)
   4097 			if bits != uint32(0) {
   4098 				n = 0
   4099 				for {
   4100 					if !(n < int32(16)) {
   4101 						break
   4102 					}
   4103 					DoTransform(tls, bits, coeffs+uintptr(n*int32(16))*2, y_dst+uintptr(kScan[n]))
   4104 					goto _11
   4105 				_11:
   4106 					;
   4107 					n = n + 1
   4108 					bits = bits << uint32(2)
   4109 				}
   4110 			}
   4111 		}
   4112 		// Chroma
   4113 		bits_uv = (*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv
   4114 		pred_func1 = CheckMode(tls, mb_x, mb_y, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(block)).Fuvmode))
   4115 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredChroma8[pred_func1]})))(tls, u_dst)
   4116 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8PredChroma8[pred_func1]})))(tls, v_dst)
   4117 		DoUVTransform(tls, bits_uv>>0, coeffs+uintptr(libc.Int32FromInt32(16)*libc.Int32FromInt32(16))*2, u_dst)
   4118 		DoUVTransform(tls, bits_uv>>int32(8), coeffs+uintptr(libc.Int32FromInt32(20)*libc.Int32FromInt32(16))*2, v_dst)
   4119 		// stash away top samples for next block
   4120 		if mb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h-int32(1) {
   4121 			libc.X__builtin___memcpy_chk(tls, top_yuv, y_dst+uintptr(libc.Int32FromInt32(15)*libc.Int32FromInt32(BPS)), uint64(16), ^__predefined_size_t(0))
   4122 			libc.X__builtin___memcpy_chk(tls, top_yuv+16, u_dst+uintptr(libc.Int32FromInt32(7)*libc.Int32FromInt32(BPS)), uint64(8), ^__predefined_size_t(0))
   4123 			libc.X__builtin___memcpy_chk(tls, top_yuv+24, v_dst+uintptr(libc.Int32FromInt32(7)*libc.Int32FromInt32(BPS)), uint64(8), ^__predefined_size_t(0))
   4124 		}
   4125 		// Transfer reconstructed samples from yuv_b cache to final destination.
   4126 		y_offset = cache_id * int32(16) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4127 		uv_offset = cache_id * int32(8) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4128 		y_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(mb_x*int32(16)) + uintptr(y_offset)
   4129 		u_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(mb_x*int32(8)) + uintptr(uv_offset)
   4130 		v_out = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(mb_x*int32(8)) + uintptr(uv_offset)
   4131 		j = 0
   4132 		for {
   4133 			if !(j < int32(16)) {
   4134 				break
   4135 			}
   4136 			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))
   4137 			goto _12
   4138 		_12:
   4139 			;
   4140 			j = j + 1
   4141 		}
   4142 		j = 0
   4143 		for {
   4144 			if !(j < int32(8)) {
   4145 				break
   4146 			}
   4147 			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))
   4148 			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))
   4149 			goto _13
   4150 		_13:
   4151 			;
   4152 			j = j + 1
   4153 		}
   4154 		goto _5
   4155 	_5:
   4156 		;
   4157 		mb_x = mb_x + 1
   4158 	}
   4159 }
   4160 
   4161 //------------------------------------------------------------------------------
   4162 // Filtering
   4163 
   4164 // C documentation
   4165 //
   4166 //	// kFilterExtraRows[] = How many extra lines are needed on the MB boundary
   4167 //	// for caching, given a filtering level.
   4168 //	// Simple filter:  up to 2 luma samples are read and 1 is written.
   4169 //	// Complex filter: up to 4 luma samples are read and 3 are written. Same for
   4170 //	//                 U/V, so it's 8 samples total (because of the 2x upsampling).
   4171 var kFilterExtraRows = [3]uint8_t{
   4172 	1: uint8(2),
   4173 	2: uint8(8),
   4174 }
   4175 
   4176 func DoFilter(tls *libc.TLS, dec uintptr, mb_x int32, mb_y int32) {
   4177 	var cache_id, hev_thresh, ilevel, limit, uv_bps, y_bps int32
   4178 	var ctx, f_info, u_dst, v_dst, y_dst uintptr
   4179 	_, _, _, _, _, _, _, _, _, _, _ = cache_id, ctx, f_info, hev_thresh, ilevel, limit, u_dst, uv_bps, v_dst, y_bps, y_dst
   4180 	ctx = dec + 216
   4181 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4182 	y_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4183 	f_info = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info + uintptr(mb_x)*4
   4184 	y_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(cache_id*int32(16)*y_bps) + uintptr(mb_x*int32(16))
   4185 	ilevel = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Ff_ilevel)
   4186 	limit = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Ff_limit)
   4187 	if limit == 0 {
   4188 		return
   4189 	}
   4190 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type == int32(1) { // simple
   4191 		if mb_x > 0 {
   4192 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16})))(tls, y_dst, y_bps, limit+int32(4))
   4193 		}
   4194 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4195 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16i})))(tls, y_dst, y_bps, limit)
   4196 		}
   4197 		if mb_y > 0 {
   4198 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16})))(tls, y_dst, y_bps, limit+int32(4))
   4199 		}
   4200 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4201 			(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16i})))(tls, y_dst, y_bps, limit)
   4202 		}
   4203 	} else { // complex
   4204 		uv_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4205 		u_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4206 		v_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4207 		hev_thresh = libc.Int32FromUint8((*VP8FInfo)(unsafe.Pointer(f_info)).Fhev_thresh)
   4208 		if mb_x > 0 {
   4209 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16})))(tls, y_dst, y_bps, limit+int32(4), ilevel, hev_thresh)
   4210 			(*(*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)
   4211 		}
   4212 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4213 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16i})))(tls, y_dst, y_bps, limit, ilevel, hev_thresh)
   4214 			(*(*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)
   4215 		}
   4216 		if mb_y > 0 {
   4217 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16})))(tls, y_dst, y_bps, limit+int32(4), ilevel, hev_thresh)
   4218 			(*(*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)
   4219 		}
   4220 		if (*VP8FInfo)(unsafe.Pointer(f_info)).Ff_inner != 0 {
   4221 			(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16i})))(tls, y_dst, y_bps, limit, ilevel, hev_thresh)
   4222 			(*(*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)
   4223 		}
   4224 	}
   4225 }
   4226 
   4227 // C documentation
   4228 //
   4229 //	// Filter the decoded macroblock row (if needed)
   4230 func FilterRow(tls *libc.TLS, dec uintptr) {
   4231 	var mb_x, mb_y int32
   4232 	_, _ = mb_x, mb_y
   4233 	mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_y
   4234 	mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x
   4235 	for {
   4236 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x) {
   4237 			break
   4238 		}
   4239 		DoFilter(tls, dec, mb_x, mb_y)
   4240 		goto _1
   4241 	_1:
   4242 		;
   4243 		mb_x = mb_x + 1
   4244 	}
   4245 }
   4246 
   4247 //------------------------------------------------------------------------------
   4248 // Precompute the filtering strength for each segment and each i4x4/i16x16 mode.
   4249 
   4250 func PrecomputeFilterStrengths(tls *libc.TLS, dec uintptr) {
   4251 	var base_level, i4x4, ilevel, level, s, v3, v4 int32
   4252 	var hdr, info uintptr
   4253 	_, _, _, _, _, _, _, _, _ = base_level, hdr, i4x4, ilevel, info, level, s, v3, v4
   4254 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4255 		hdr = dec + 84
   4256 		s = 0
   4257 		for {
   4258 			if !(s < int32(NUM_MB_SEGMENTS)) {
   4259 				break
   4260 			}
   4261 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fuse_segment != 0 {
   4262 				base_level = int32(**(**int8_t)(__ccgo_up(dec + 132 + 16 + uintptr(s))))
   4263 				if !((*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fabsolute_delta != 0) {
   4264 					base_level = base_level + (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel
   4265 				}
   4266 			} else {
   4267 				base_level = (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel
   4268 			}
   4269 			i4x4 = 0
   4270 			for {
   4271 				if !(i4x4 <= int32(1)) {
   4272 					break
   4273 				}
   4274 				info = dec + 2924 + uintptr(s)*8 + uintptr(i4x4)*4
   4275 				level = base_level
   4276 				if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta != 0 {
   4277 					level = level + **(**int32)(__ccgo_up(hdr + 16))
   4278 					if i4x4 != 0 {
   4279 						level = level + **(**int32)(__ccgo_up(hdr + 32))
   4280 					}
   4281 				}
   4282 				if level < 0 {
   4283 					v3 = 0
   4284 				} else {
   4285 					if level > int32(63) {
   4286 						v4 = int32(63)
   4287 					} else {
   4288 						v4 = level
   4289 					}
   4290 					v3 = v4
   4291 				}
   4292 				level = v3
   4293 				if level > 0 {
   4294 					ilevel = level
   4295 					if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness > 0 {
   4296 						if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness > int32(4) {
   4297 							ilevel = ilevel >> int32(2)
   4298 						} else {
   4299 							ilevel = ilevel >> int32(1)
   4300 						}
   4301 						if ilevel > int32(9)-(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness {
   4302 							ilevel = int32(9) - (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness
   4303 						}
   4304 					}
   4305 					if ilevel < int32(1) {
   4306 						ilevel = int32(1)
   4307 					}
   4308 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_ilevel = libc.Uint8FromInt32(ilevel)
   4309 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_limit = libc.Uint8FromInt32(int32(2)*level + ilevel)
   4310 					if level >= int32(40) {
   4311 						v3 = int32(2)
   4312 					} else {
   4313 						if level >= int32(15) {
   4314 							v4 = int32(1)
   4315 						} else {
   4316 							v4 = 0
   4317 						}
   4318 						v3 = v4
   4319 					}
   4320 					(*VP8FInfo)(unsafe.Pointer(info)).Fhev_thresh = libc.Uint8FromInt32(v3)
   4321 				} else {
   4322 					(*VP8FInfo)(unsafe.Pointer(info)).Ff_limit = uint8(0) // no filtering
   4323 				}
   4324 				(*VP8FInfo)(unsafe.Pointer(info)).Ff_inner = libc.Uint8FromInt32(i4x4)
   4325 				goto _2
   4326 			_2:
   4327 				;
   4328 				i4x4 = i4x4 + 1
   4329 			}
   4330 			goto _1
   4331 		_1:
   4332 			;
   4333 			s = s + 1
   4334 		}
   4335 	}
   4336 }
   4337 
   4338 //------------------------------------------------------------------------------
   4339 // Dithering
   4340 
   4341 // minimal amp that will provide a non-zero dithering effect
   4342 
   4343 var kQuantToDitherAmp = [12]uint8_t{
   4344 	0:  uint8(8),
   4345 	1:  uint8(7),
   4346 	2:  uint8(6),
   4347 	3:  uint8(4),
   4348 	4:  uint8(4),
   4349 	5:  uint8(2),
   4350 	6:  uint8(2),
   4351 	7:  uint8(2),
   4352 	8:  uint8(1),
   4353 	9:  uint8(1),
   4354 	10: uint8(1),
   4355 	11: uint8(1),
   4356 }
   4357 
   4358 func VP8InitDithering(tls *libc.TLS, options uintptr, dec uintptr) {
   4359 	var all_amp, d, f, idx, max_amp, s, v1, v2, v4 int32
   4360 	var dqm uintptr
   4361 	_, _, _, _, _, _, _, _, _, _ = all_amp, d, dqm, f, idx, max_amp, s, v1, v2, v4
   4362 	if options != libc.UintptrFromInt32(0) {
   4363 		d = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fdithering_strength
   4364 		max_amp = libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX) - libc.Int32FromInt32(1)
   4365 		if d < 0 {
   4366 			v1 = 0
   4367 		} else {
   4368 			if d > int32(100) {
   4369 				v2 = max_amp
   4370 			} else {
   4371 				v2 = d * max_amp / int32(100)
   4372 			}
   4373 			v1 = v2
   4374 		}
   4375 		f = v1
   4376 		if f > 0 {
   4377 			all_amp = 0
   4378 			s = 0
   4379 			for {
   4380 				if !(s < int32(NUM_MB_SEGMENTS)) {
   4381 					break
   4382 				}
   4383 				dqm = dec + 1060 + uintptr(s)*32
   4384 				if (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant < int32(DITHER_AMP_TAB_SIZE) {
   4385 					if (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant < 0 {
   4386 						v4 = 0
   4387 					} else {
   4388 						v4 = (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fuv_quant
   4389 					}
   4390 					idx = v4
   4391 					(*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fdither = f * libc.Int32FromUint8(kQuantToDitherAmp[idx]) >> int32(3)
   4392 				}
   4393 				all_amp = all_amp | (*VP8QuantMatrix)(unsafe.Pointer(dqm)).Fdither
   4394 				goto _3
   4395 			_3:
   4396 				;
   4397 				s = s + 1
   4398 			}
   4399 			if all_amp != 0 {
   4400 				VP8InitRandom(tls, dec+828, libc.Float32FromFloat32(1))
   4401 				(*VP8Decoder)(unsafe.Pointer(dec)).Fdither = int32(1)
   4402 			}
   4403 		}
   4404 		// potentially allow alpha dithering
   4405 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = (*WebPDecoderOptions)(unsafe.Pointer(options)).Falpha_dithering_strength
   4406 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering > int32(100) {
   4407 			(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = int32(100)
   4408 		} else {
   4409 			if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering < 0 {
   4410 				(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_dithering = 0
   4411 			}
   4412 		}
   4413 	}
   4414 }
   4415 
   4416 // C documentation
   4417 //
   4418 //	// Convert to range: [-2,2] for dither=50, [-4,4] for dither=100
   4419 func Dither8x8(tls *libc.TLS, rg1 uintptr, dst uintptr, bps int32, amp1 int32) {
   4420 	bp := tls.Alloc(64)
   4421 	defer tls.Free(64)
   4422 	var diff, i, v3, v4, v6, v8 int32
   4423 	var v2, v5, v7 uintptr
   4424 	var _ /* dither at bp+0 */ [64]uint8_t
   4425 	_, _, _, _, _, _, _, _, _ = diff, i, v2, v3, v4, v5, v6, v7, v8
   4426 	i = 0
   4427 	for {
   4428 		if !(i < libc.Int32FromInt32(8)*libc.Int32FromInt32(8)) {
   4429 			break
   4430 		}
   4431 		v2 = rg1
   4432 		v3 = libc.Int32FromInt32(VP8_DITHER_AMP_BITS) + libc.Int32FromInt32(1)
   4433 		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)))
   4434 		if diff < libc.Int32FromInt32(0) {
   4435 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
   4436 		}
   4437 		**(**uint32_t)(__ccgo_up(v2 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v2)).Findex1)*4)) = libc.Uint32FromInt32(diff)
   4438 		v5 = v2
   4439 		*(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1
   4440 		v4 = *(*int32)(unsafe.Pointer(v5))
   4441 		if v4 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
   4442 			(*VP8Random)(unsafe.Pointer(v2)).Findex1 = 0
   4443 		}
   4444 		v7 = v2 + 4
   4445 		*(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1
   4446 		v6 = *(*int32)(unsafe.Pointer(v7))
   4447 		if v6 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
   4448 			(*VP8Random)(unsafe.Pointer(v2)).Findex2 = 0
   4449 		}
   4450 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v3)
   4451 		diff = diff * amp1 >> int32(VP8_RANDOM_DITHER_FIX)
   4452 		diff = diff + int32(1)<<(v3-int32(1))
   4453 		v8 = diff
   4454 		goto _9
   4455 	_9:
   4456 		(**(**[64]uint8_t)(__ccgo_up(bp)))[i] = libc.Uint8FromInt32(v8)
   4457 		goto _1
   4458 	_1:
   4459 		;
   4460 		i = i + 1
   4461 	}
   4462 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8DitherCombine8x8})))(tls, bp, dst, bps)
   4463 }
   4464 
   4465 func DitherRow(tls *libc.TLS, dec uintptr) {
   4466 	var cache_id, mb_x, uv_bps int32
   4467 	var ctx, data, u_dst, v_dst uintptr
   4468 	_, _, _, _, _, _, _ = cache_id, ctx, data, mb_x, u_dst, uv_bps, v_dst
   4469 	mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x
   4470 	for {
   4471 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x) {
   4472 			break
   4473 		}
   4474 		ctx = dec + 216
   4475 		data = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data + uintptr(mb_x)*800
   4476 		cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4477 		uv_bps = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4478 		if libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither) >= int32(MIN_DITHER_AMP) {
   4479 			u_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4480 			v_dst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(cache_id*int32(8)*uv_bps) + uintptr(mb_x*int32(8))
   4481 			Dither8x8(tls, dec+828, u_dst, uv_bps, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither))
   4482 			Dither8x8(tls, dec+828, v_dst, uv_bps, libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(data)).Fdither))
   4483 		}
   4484 		goto _1
   4485 	_1:
   4486 		;
   4487 		mb_x = mb_x + 1
   4488 	}
   4489 }
   4490 
   4491 //------------------------------------------------------------------------------
   4492 // This function is called after a row of macroblocks is finished decoding.
   4493 // It also takes into account the following restrictions:
   4494 //  * In case of in-loop filtering, we must hold off sending some of the bottom
   4495 //    pixels as they are yet unfiltered. They will be when the next macroblock
   4496 //    row is decoded. Meanwhile, we must preserve them by rotating them in the
   4497 //    cache area. This doesn't hold for the very bottom row of the uncropped
   4498 //    picture of course.
   4499 //  * we must clip the remaining pixels against the cropping area. The VP8Io
   4500 //    struct must have the following fields set correctly before calling put():
   4501 
   4502 // C documentation
   4503 //
   4504 //	// Finalize and transmit a complete row. Return false in case of user-abort.
   4505 func FinishRow(tls *libc.TLS, arg1 uintptr, arg2 uintptr) (r int32) {
   4506 	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
   4507 	var ctx, dec, io, udst, vdst, ydst uintptr
   4508 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   4509 	dec = arg1
   4510 	io = arg2
   4511 	ok = int32(1)
   4512 	ctx = dec + 216
   4513 	cache_id = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid
   4514 	extra_y_rows = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4515 	ysize = extra_y_rows * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4516 	uvsize = extra_y_rows / int32(2) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4517 	y_offset = cache_id * int32(16) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4518 	uv_offset = cache_id * int32(8) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4519 	ydst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y - uintptr(ysize) + uintptr(y_offset)
   4520 	udst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u - uintptr(uvsize) + uintptr(uv_offset)
   4521 	vdst = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v - uintptr(uvsize) + uintptr(uv_offset)
   4522 	mb_y = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y
   4523 	is_first_row = libc.BoolInt32(mb_y == libc.Int32FromInt32(0))
   4524 	is_last_row = libc.BoolInt32(mb_y >= (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y-libc.Int32FromInt32(1))
   4525 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4526 		ReconstructRow(tls, dec, ctx)
   4527 	}
   4528 	if (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row != 0 {
   4529 		FilterRow(tls, dec)
   4530 	}
   4531 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fdither != 0 {
   4532 		DitherRow(tls, dec)
   4533 	}
   4534 	if (*VP8Io)(unsafe.Pointer(io)).Fput != libc.UintptrFromInt32(0) {
   4535 		y_start = mb_y * int32(16)
   4536 		y_end = (mb_y + int32(1)) * int32(16)
   4537 		if !(is_first_row != 0) {
   4538 			y_start = y_start - extra_y_rows
   4539 			(*VP8Io)(unsafe.Pointer(io)).Fy = ydst
   4540 			(*VP8Io)(unsafe.Pointer(io)).Fu = udst
   4541 			(*VP8Io)(unsafe.Pointer(io)).Fv = vdst
   4542 		} else {
   4543 			(*VP8Io)(unsafe.Pointer(io)).Fy = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y + uintptr(y_offset)
   4544 			(*VP8Io)(unsafe.Pointer(io)).Fu = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u + uintptr(uv_offset)
   4545 			(*VP8Io)(unsafe.Pointer(io)).Fv = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v + uintptr(uv_offset)
   4546 		}
   4547 		if !(is_last_row != 0) {
   4548 			y_end = y_end - extra_y_rows
   4549 		}
   4550 		if y_end > (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
   4551 			y_end = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom // make sure we don't overflow on last row.
   4552 		}
   4553 		// If dec->alpha_data is not NULL, we have some alpha plane present.
   4554 		(*VP8Io)(unsafe.Pointer(io)).Fa = libc.UintptrFromInt32(0)
   4555 		if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) && y_start < y_end {
   4556 			(*VP8Io)(unsafe.Pointer(io)).Fa = VP8DecompressAlphaRows(tls, dec, io, y_start, y_end-y_start)
   4557 			if (*VP8Io)(unsafe.Pointer(io)).Fa == libc.UintptrFromInt32(0) {
   4558 				return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+37)
   4559 			}
   4560 		}
   4561 		if y_start < (*VP8Io)(unsafe.Pointer(io)).Fcrop_top {
   4562 			delta_y = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - y_start
   4563 			y_start = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
   4564 			**(**uintptr)(__ccgo_up(io + 24)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride * delta_y)
   4565 			**(**uintptr)(__ccgo_up(io + 32)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride * (delta_y >> libc.Int32FromInt32(1)))
   4566 			**(**uintptr)(__ccgo_up(io + 40)) += uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride * (delta_y >> libc.Int32FromInt32(1)))
   4567 			if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   4568 				**(**uintptr)(__ccgo_up(io + 152)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth * delta_y)
   4569 			}
   4570 		}
   4571 		if y_start < y_end {
   4572 			**(**uintptr)(__ccgo_up(io + 24)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   4573 			**(**uintptr)(__ccgo_up(io + 32)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left >> int32(1))
   4574 			**(**uintptr)(__ccgo_up(io + 40)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left >> int32(1))
   4575 			if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   4576 				**(**uintptr)(__ccgo_up(io + 152)) += uintptr((*VP8Io)(unsafe.Pointer(io)).Fcrop_left)
   4577 			}
   4578 			(*VP8Io)(unsafe.Pointer(io)).Fmb_y = y_start - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
   4579 			(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fcrop_right - (*VP8Io)(unsafe.Pointer(io)).Fcrop_left
   4580 			(*VP8Io)(unsafe.Pointer(io)).Fmb_h = y_end - y_start
   4581 			ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*VP8Io)(unsafe.Pointer(io)).Fput})))(tls, io)
   4582 		}
   4583 	}
   4584 	// rotate top samples if needed
   4585 	if cache_id+int32(1) == (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches {
   4586 		if !(is_last_row != 0) {
   4587 			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))
   4588 			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))
   4589 			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))
   4590 		}
   4591 	}
   4592 	return ok
   4593 }
   4594 
   4595 //------------------------------------------------------------------------------
   4596 
   4597 func VP8ProcessRow(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4598 	var ctx, tmp, tmp1, worker, v2 uintptr
   4599 	var filter_row, ok, v1 int32
   4600 	_, _, _, _, _, _, _, _ = ctx, filter_row, ok, tmp, tmp1, worker, v1, v2
   4601 	ok = int32(1)
   4602 	ctx = dec + 216
   4603 	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)
   4604 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == 0 {
   4605 		// ctx->id and ctx->f_info are already set
   4606 		(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   4607 		(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row = filter_row
   4608 		ReconstructRow(tls, dec, ctx)
   4609 		ok = FinishRow(tls, dec, io)
   4610 	} else {
   4611 		worker = dec + 152
   4612 		// Finish previous job *before* updating context
   4613 		ok = ok & (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker)
   4614 		if ok != 0 { // spawn a new deblocking/output job
   4615 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fio = **(**VP8Io)(__ccgo_up(io))
   4616 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fid = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id
   4617 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   4618 			(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ffilter_row = filter_row
   4619 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) { // swap macroblock data
   4620 				tmp = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data
   4621 				(*VP8ThreadContext)(unsafe.Pointer(ctx)).Fmb_data = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data
   4622 				(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data = tmp
   4623 			} else {
   4624 				// perform reconstruction directly in main thread
   4625 				ReconstructRow(tls, dec, ctx)
   4626 			}
   4627 			if filter_row != 0 { // swap filter info
   4628 				tmp1 = (*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info
   4629 				(*VP8ThreadContext)(unsafe.Pointer(ctx)).Ff_info = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info
   4630 				(*VP8Decoder)(unsafe.Pointer(dec)).Ff_info = tmp1
   4631 			}
   4632 			// (reconstruct)+filter in parallel
   4633 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FLaunch})))(tls, worker)
   4634 			v2 = dec + 204
   4635 			*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
   4636 			v1 = *(*int32)(unsafe.Pointer(v2))
   4637 			if v1 == (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches {
   4638 				(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4639 			}
   4640 		}
   4641 	}
   4642 	return ok
   4643 }
   4644 
   4645 //------------------------------------------------------------------------------
   4646 // Finish setting up the decoding parameter once user's setup() is called.
   4647 
   4648 func VP8EnterCritical(tls *libc.TLS, dec uintptr, io uintptr) (r VP8StatusCode1) {
   4649 	var extra_pixels int32
   4650 	_ = extra_pixels
   4651 	// Call setup() first. This may trigger additional decoding features on 'io'.
   4652 	// Note: Afterward, we must call teardown() no matter what.
   4653 	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) {
   4654 		VP8SetError(tls, dec, int32(VP8_STATUS_USER_ABORT), __ccgo_ts+66)
   4655 		return (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
   4656 	}
   4657 	// Disable filtering per user request
   4658 	if (*VP8Io)(unsafe.Pointer(io)).Fbypass_filtering != 0 {
   4659 		(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type = 0
   4660 	}
   4661 	// Define the area where we can skip in-loop filtering, in case of cropping.
   4662 	//
   4663 	// 'Simple' filter reads two luma samples outside of the macroblock
   4664 	// and filters one. It doesn't filter the chroma samples. Hence, we can
   4665 	// avoid doing the in-loop filtering before crop_top/crop_left position.
   4666 	// For the 'Complex' filter, 3 samples are read and up to 3 are filtered.
   4667 	// Means: there's a dependency chain that goes all the way up to the
   4668 	// top-left corner of the picture (MB #0). We must filter all the previous
   4669 	// macroblocks.
   4670 	extra_pixels = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4671 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type == int32(2) {
   4672 		// For complex filter, we need to preserve the dependency chain.
   4673 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = 0
   4674 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = 0
   4675 	} else {
   4676 		// For simple filter, we can filter only the cropped region.
   4677 		// We include 'extra_pixels' on the other side of the boundary, since
   4678 		// vertical or horizontal filtering of the previous macroblock can
   4679 		// modify some abutting pixels.
   4680 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_left - extra_pixels) >> int32(4)
   4681 		(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_top - extra_pixels) >> int32(4)
   4682 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x < 0 {
   4683 			(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_x = 0
   4684 		}
   4685 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y < 0 {
   4686 			(*VP8Decoder)(unsafe.Pointer(dec)).Ftl_mb_y = 0
   4687 		}
   4688 	}
   4689 	// We need some 'extra' pixels on the right/bottom.
   4690 	(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom + int32(15) + extra_pixels) >> int32(4)
   4691 	(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x = ((*VP8Io)(unsafe.Pointer(io)).Fcrop_right + int32(15) + extra_pixels) >> int32(4)
   4692 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x > (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w {
   4693 		(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w
   4694 	}
   4695 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y > (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h {
   4696 		(*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h
   4697 	}
   4698 	PrecomputeFilterStrengths(tls, dec)
   4699 	return int32(VP8_STATUS_OK)
   4700 }
   4701 
   4702 func VP8ExitCritical(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4703 	var ok int32
   4704 	_ = ok
   4705 	ok = int32(1)
   4706 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4707 		ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152)
   4708 	}
   4709 	if (*VP8Io)(unsafe.Pointer(io)).Fteardown != libc.UintptrFromInt32(0) {
   4710 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*VP8Io)(unsafe.Pointer(io)).Fteardown})))(tls, io)
   4711 	}
   4712 	return ok
   4713 }
   4714 
   4715 //------------------------------------------------------------------------------
   4716 // For multi-threaded decoding we need to use 3 rows of 16 pixels as delay line.
   4717 //
   4718 // Reason is: the deblocking filter cannot deblock the bottom horizontal edges
   4719 // immediately, and needs to wait for first few rows of the next macroblock to
   4720 // be decoded. Hence, deblocking is lagging behind by 4 or 8 pixels (depending
   4721 // on strength).
   4722 // With two threads, the vertical positions of the rows being decoded are:
   4723 // Decode:  [ 0..15][16..31][32..47][48..63][64..79][...
   4724 // Deblock:         [ 0..11][12..27][28..43][44..59][...
   4725 // If we use two threads and two caches of 16 pixels, the sequence would be:
   4726 // Decode:  [ 0..15][16..31][ 0..15!!][16..31][ 0..15][...
   4727 // Deblock:         [ 0..11][12..27!!][-4..11][12..27][...
   4728 // The problem occurs during row [12..15!!] that both the decoding and
   4729 // deblocking threads are writing simultaneously.
   4730 // With 3 cache lines, one get a safe write pattern:
   4731 // Decode:  [ 0..15][16..31][32..47][ 0..15][16..31][32..47][0..
   4732 // Deblock:         [ 0..11][12..27][28..43][-4..11][12..27][28...
   4733 // Note that multi-threaded output _without_ deblocking can make use of two
   4734 // cache lines of 16 pixels only, since there's no lagging behind. The decoding
   4735 // and output process have non-concurrent writing:
   4736 // Decode:  [ 0..15][16..31][ 0..15][16..31][...
   4737 // io->put:         [ 0..15][16..31][ 0..15][...
   4738 
   4739 // C documentation
   4740 //
   4741 //	// Initialize multi/single-thread worker
   4742 func InitThreadContext(tls *libc.TLS, dec uintptr) (r int32) {
   4743 	var worker uintptr
   4744 	var v1 int32
   4745 	_, _ = worker, v1
   4746 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4747 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4748 		worker = dec + 152
   4749 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FReset})))(tls, worker) != 0) {
   4750 			return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts+85)
   4751 		}
   4752 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = dec
   4753 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = dec + 216 + 32
   4754 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(FinishRow)
   4755 		if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4756 			v1 = int32(3)
   4757 		} else {
   4758 			v1 = libc.Int32FromInt32(3) - libc.Int32FromInt32(1)
   4759 		}
   4760 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches = v1
   4761 	} else {
   4762 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches = int32(1)
   4763 	}
   4764 	return int32(1)
   4765 }
   4766 
   4767 func VP8GetThreadMethod(tls *libc.TLS, options uintptr, headers uintptr, width int32, height int32) (r int32) {
   4768 	if options == libc.UintptrFromInt32(0) || (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_threads == 0 {
   4769 		return 0
   4770 	}
   4771 	_ = headers
   4772 	_ = width
   4773 	_ = height
   4774 	return 0
   4775 }
   4776 
   4777 //------------------------------------------------------------------------------
   4778 // Memory setup
   4779 
   4780 func AllocateMemory(tls *libc.TLS, dec uintptr) (r int32) {
   4781 	var alpha_size, needed, v5 uint64_t
   4782 	var cache_height, cache_size, f_info_size, intra_pred_mode_size, mb_data_size, mb_info_size, top_size, yuv_size size_t
   4783 	var extra_rows, extra_uv, extra_y, mb_w, num_caches, v2, v3, v6 int32
   4784 	var mem, v8 uintptr
   4785 	var v1, v4 uint64
   4786 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   4787 	num_caches = (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_caches
   4788 	mb_w = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w
   4789 	// Note: we use 'size_t' when there's no overflow risk, uint64_t otherwise.
   4790 	intra_pred_mode_size = libc.Uint64FromInt32(int32(4)*mb_w) * uint64(1)
   4791 	top_size = uint64(32) * libc.Uint64FromInt32(mb_w)
   4792 	mb_info_size = libc.Uint64FromInt32(mb_w+libc.Int32FromInt32(1)) * uint64(2)
   4793 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 {
   4794 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4795 			v2 = int32(2)
   4796 		} else {
   4797 			v2 = int32(1)
   4798 		}
   4799 		v1 = libc.Uint64FromInt32(mb_w*v2) * uint64(4)
   4800 	} else {
   4801 		v1 = uint64(0)
   4802 	}
   4803 	f_info_size = v1
   4804 	yuv_size = libc.Uint64FromInt32(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(17)+libc.Int32FromInt32(BPS)*libc.Int32FromInt32(9)) * libc.Uint64FromInt64(1)
   4805 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4806 		v3 = int32(2)
   4807 	} else {
   4808 		v3 = int32(1)
   4809 	}
   4810 	mb_data_size = libc.Uint64FromInt32(v3*mb_w) * uint64(800)
   4811 	cache_height = libc.Uint64FromInt32((int32(16)*num_caches + libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])) * int32(3) / int32(2))
   4812 	cache_size = top_size * cache_height
   4813 	if (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) {
   4814 		v4 = uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fpic_hdr.Fwidth) * uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fpic_hdr.Fheight)
   4815 	} else {
   4816 		v4 = 0
   4817 	}
   4818 	// alpha_size is the only one that scales as width x height.
   4819 	alpha_size = v4
   4820 	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)
   4821 	v5 = needed
   4822 	v6 = libc.BoolInt32(v5 == v5)
   4823 	goto _7
   4824 _7:
   4825 	if !(v6 != 0) {
   4826 		return 0
   4827 	} // check for overflow
   4828 	if needed > (*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size {
   4829 		WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmem)
   4830 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = uint64(0)
   4831 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem = WebPSafeMalloc(tls, needed, uint64(1))
   4832 		if (*VP8Decoder)(unsafe.Pointer(dec)).Fmem == libc.UintptrFromInt32(0) {
   4833 			return VP8SetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY), __ccgo_ts+115)
   4834 		}
   4835 		// down-cast is ok, thanks to WebPSafeMalloc() above.
   4836 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = needed
   4837 	}
   4838 	mem = (*VP8Decoder)(unsafe.Pointer(dec)).Fmem
   4839 	(*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t = mem
   4840 	mem = mem + uintptr(intra_pred_mode_size)
   4841 	(*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_t = mem
   4842 	mem = mem + uintptr(top_size)
   4843 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info = mem + uintptr(1)*2
   4844 	mem = mem + uintptr(mb_info_size)
   4845 	if f_info_size != 0 {
   4846 		v8 = mem
   4847 	} else {
   4848 		v8 = libc.UintptrFromInt32(0)
   4849 	}
   4850 	(*VP8Decoder)(unsafe.Pointer(dec)).Ff_info = v8
   4851 	mem = mem + uintptr(f_info_size)
   4852 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fid = 0
   4853 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Ff_info = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info
   4854 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 && (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   4855 		// secondary cache line. The deblocking process need to make use of the
   4856 		// filtering strength from previous macroblock row, while the new ones
   4857 		// are being decoded in parallel. We'll just swap the pointers.
   4858 		(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Ff_info += uintptr(mb_w) * 4
   4859 	}
   4860 	mem = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   4861 	(*VP8Decoder)(unsafe.Pointer(dec)).Fyuv_b = mem
   4862 	mem = mem + uintptr(yuv_size)
   4863 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data = mem
   4864 	(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_data = mem
   4865 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method == int32(2) {
   4866 		(*VP8Decoder)(unsafe.Pointer(dec)).Fthread_ctx.Fmb_data += uintptr(mb_w) * 800
   4867 	}
   4868 	mem = mem + uintptr(mb_data_size)
   4869 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride = int32(16) * mb_w
   4870 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride = int32(8) * mb_w
   4871 	extra_rows = libc.Int32FromUint8(kFilterExtraRows[(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type])
   4872 	extra_y = extra_rows * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4873 	extra_uv = extra_rows / int32(2) * (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4874 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y = mem + uintptr(extra_y)
   4875 	(*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)
   4876 	(*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)
   4877 	(*VP8Decoder)(unsafe.Pointer(dec)).Fcache_id = 0
   4878 	mem = mem + uintptr(cache_size)
   4879 	// alpha plane
   4880 	if alpha_size != 0 {
   4881 		v8 = mem
   4882 	} else {
   4883 		v8 = libc.UintptrFromInt32(0)
   4884 	}
   4885 	(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_plane = v8
   4886 	mem = mem + uintptr(alpha_size)
   4887 	// note: left/top-info is initialized once for all.
   4888 	libc.X__builtin___memset_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info-uintptr(1)*2, 0, mb_info_size, ^__predefined_size_t(0))
   4889 	VP8InitScanline(tls, dec) // initialize left too.
   4890 	// initialize top
   4891 	libc.X__builtin___memset_chk(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t, int32(B_DC_PRED), intra_pred_mode_size, ^__predefined_size_t(0))
   4892 	return int32(1)
   4893 }
   4894 
   4895 func InitIo(tls *libc.TLS, dec uintptr, io uintptr) {
   4896 	// prepare 'io'
   4897 	(*VP8Io)(unsafe.Pointer(io)).Fmb_y = 0
   4898 	(*VP8Io)(unsafe.Pointer(io)).Fy = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y
   4899 	(*VP8Io)(unsafe.Pointer(io)).Fu = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_u
   4900 	(*VP8Io)(unsafe.Pointer(io)).Fv = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_v
   4901 	(*VP8Io)(unsafe.Pointer(io)).Fy_stride = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_y_stride
   4902 	(*VP8Io)(unsafe.Pointer(io)).Fuv_stride = (*VP8Decoder)(unsafe.Pointer(dec)).Fcache_uv_stride
   4903 	(*VP8Io)(unsafe.Pointer(io)).Fa = libc.UintptrFromInt32(0)
   4904 }
   4905 
   4906 func VP8InitFrame(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
   4907 	if !(InitThreadContext(tls, dec) != 0) {
   4908 		return 0
   4909 	} // call first. Sets dec->num_caches.
   4910 	if !(AllocateMemory(tls, dec) != 0) {
   4911 		return 0
   4912 	}
   4913 	InitIo(tls, dec, io)
   4914 	VP8DspInit(tls) // Init critical function pointers and look-up tables.
   4915 	return int32(1)
   4916 }
   4917 
   4918 const CHUNK_SIZE = 4096
   4919 const MAX_MB_SIZE = 4096
   4920 
   4921 type WebPIDecoder = struct {
   4922 	Fstate        DecState
   4923 	Fparams       WebPDecParams
   4924 	Fis_lossless  int32
   4925 	Fdec          uintptr
   4926 	Fio           VP8Io
   4927 	Fmem          MemBuffer
   4928 	Foutput       WebPDecBuffer
   4929 	Ffinal_output uintptr
   4930 	Fchunk_size   size_t
   4931 	Flast_mb_y    int32
   4932 }
   4933 
   4934 const STATE_WEBP_HEADER = 0
   4935 const // All the data before that of the VP8/VP8L chunk.
   4936 STATE_VP8_HEADER = 1
   4937 const // The VP8 Frame header (within the VP8 chunk).
   4938 STATE_VP8_PARTS0 = 2
   4939 const STATE_VP8_DATA = 3
   4940 const STATE_VP8L_HEADER = 4
   4941 const STATE_VP8L_DATA = 5
   4942 const STATE_DONE = 6
   4943 const STATE_ERROR = 7
   4944 
   4945 var kHashMul3 = uint32(0x1e35a7bd)
   4946 
   4947 //------------------------------------------------------------------------------
   4948 
   4949 // Copyright 2010 Google Inc. All Rights Reserved.
   4950 //
   4951 // Use of this source code is governed by a BSD-style license
   4952 // that can be found in the COPYING file in the root of the source
   4953 // tree. An additional intellectual property rights grant can be found
   4954 // in the file PATENTS. All contributing project authors may
   4955 // be found in the AUTHORS file in the root of the source tree.
   4956 // -----------------------------------------------------------------------------
   4957 //
   4958 //  Main decoding functions for WebP images.
   4959 //
   4960 // Author: Skal (pascal.massimino@gmail.com)
   4961 
   4962 // Copyright 2012 Google Inc. All Rights Reserved.
   4963 //
   4964 // Use of this source code is governed by a BSD-style license
   4965 // that can be found in the COPYING file in the root of the source
   4966 // tree. An additional intellectual property rights grant can be found
   4967 // in the file PATENTS. All contributing project authors may
   4968 // be found in the AUTHORS file in the root of the source tree.
   4969 // -----------------------------------------------------------------------------
   4970 //
   4971 //  Internal header for constants related to WebP file format.
   4972 //
   4973 // Author: Urvang (urvang@google.com)
   4974 
   4975 // Copyright 2010 Google Inc. All Rights Reserved.
   4976 //
   4977 // Use of this source code is governed by a BSD-style license
   4978 // that can be found in the COPYING file in the root of the source
   4979 // tree. An additional intellectual property rights grant can be found
   4980 // in the file PATENTS. All contributing project authors may
   4981 // be found in the AUTHORS file in the root of the source tree.
   4982 // -----------------------------------------------------------------------------
   4983 //
   4984 //  Common types + memory wrappers
   4985 //
   4986 // Author: Skal (pascal.massimino@gmail.com)
   4987 
   4988 // In append mode, buffer allocations increase as multiples of this value.
   4989 // Needs to be a power of 2.
   4990 
   4991 //------------------------------------------------------------------------------
   4992 // Data structures for memory and states
   4993 
   4994 // C documentation
   4995 //
   4996 //	// Decoding states. State normally flows as:
   4997 //	// WEBP_HEADER->VP8_HEADER->VP8_PARTS0->VP8_DATA->DONE for a lossy image, and
   4998 //	// WEBP_HEADER->VP8L_HEADER->VP8L_DATA->DONE for a lossless image.
   4999 //	// If there is any error the decoder goes into state ERROR.
   5000 type DecState = int32
   5001 
   5002 // C documentation
   5003 //
   5004 //	// Operating state for the MemBuffer
   5005 type MemBufferMode = int32
   5006 
   5007 const MEM_MODE_NONE = 0
   5008 const MEM_MODE_APPEND = 1
   5009 const MEM_MODE_MAP = 2
   5010 
   5011 // C documentation
   5012 //
   5013 //	// storage for partition #0 and partial data (in a rolling fashion)
   5014 type MemBuffer = struct {
   5015 	Fmode       MemBufferMode
   5016 	Fstart      size_t
   5017 	Fend        size_t
   5018 	Fbuf_size   size_t
   5019 	Fbuf        uintptr
   5020 	Fpart0_size size_t
   5021 	Fpart0_buf  uintptr
   5022 }
   5023 
   5024 // C documentation
   5025 //
   5026 //	// MB context to restore in case VP8DecodeMB() fails
   5027 type MBContext = struct {
   5028 	Fleft     VP8MB
   5029 	Finfo     VP8MB
   5030 	Ftoken_br VP8BitReader
   5031 }
   5032 
   5033 //------------------------------------------------------------------------------
   5034 // MemBuffer: incoming data handling
   5035 
   5036 func MemDataSize(tls *libc.TLS, mem uintptr) (r size_t) {
   5037 	return (*MemBuffer)(unsafe.Pointer(mem)).Fend - (*MemBuffer)(unsafe.Pointer(mem)).Fstart
   5038 }
   5039 
   5040 // C documentation
   5041 //
   5042 //	// Check if we need to preserve the compressed alpha data, as it may not have
   5043 //	// been decoded yet.
   5044 func NeedCompressedAlpha(tls *libc.TLS, idec uintptr) (r int32) {
   5045 	var dec uintptr
   5046 	_ = dec
   5047 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_WEBP_HEADER) {
   5048 		// We haven't parsed the headers yet, so we don't know whether the image is
   5049 		// lossy or lossless. This also means that we haven't parsed the ALPH chunk.
   5050 		return 0
   5051 	}
   5052 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0 {
   5053 		return 0 // ALPH chunk is not present for lossless images.
   5054 	} else {
   5055 		dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5056 		// Must be true as idec->state != STATE_WEBP_HEADER.
   5057 		return libc.BoolInt32((*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data != libc.UintptrFromInt32(0) && !((*VP8Decoder)(unsafe.Pointer(dec)).Fis_alpha_decoded != 0))
   5058 	}
   5059 	return r
   5060 }
   5061 
   5062 func DoRemap(tls *libc.TLS, idec uintptr, offset ptrdiff_t) {
   5063 	var alph_dec, alph_vp8l_dec, dec, dec1, last_start, mem, new_base uintptr
   5064 	var last_part, p uint32_t
   5065 	_, _, _, _, _, _, _, _, _ = alph_dec, alph_vp8l_dec, dec, dec1, last_part, last_start, mem, new_base, p
   5066 	mem = idec + 296
   5067 	new_base = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5068 	// note: for VP8, setting up idec->io is only really needed at the beginning
   5069 	// of the decoding, till partition #0 is complete.
   5070 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = new_base
   5071 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = MemDataSize(tls, mem)
   5072 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec != libc.UintptrFromInt32(0) {
   5073 		if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5074 			dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5075 			last_part = (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one
   5076 			if offset != 0 {
   5077 				p = uint32(0)
   5078 				for {
   5079 					if !(p <= last_part) {
   5080 						break
   5081 					}
   5082 					VP8RemapBitReader(tls, dec+440+uintptr(p)*48, offset)
   5083 					goto _1
   5084 				_1:
   5085 					;
   5086 					p = p + 1
   5087 				}
   5088 				// Remap partition #0 data pointer to new offset, but only in MAP
   5089 				// mode (in APPEND mode, partition #0 is copied into a fixed memory).
   5090 				if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_MAP) {
   5091 					VP8RemapBitReader(tls, dec+16, offset)
   5092 				}
   5093 			}
   5094 			last_start = (**(**VP8BitReader)(__ccgo_up(dec + 440 + uintptr(last_part)*48))).Fbuf
   5095 			// 'last_start' will be NULL when 'idec->state' is < STATE_VP8_PARTS0
   5096 			// and through a portion of that state (when there isn't enough data to
   5097 			// parse the partitions). The bitreader is only used meaningfully when
   5098 			// there is enough data to begin parsing partition 0.
   5099 			if last_start != libc.UintptrFromInt32(0) {
   5100 				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)))
   5101 			}
   5102 			if NeedCompressedAlpha(tls, idec) != 0 {
   5103 				alph_dec = (*VP8Decoder)(unsafe.Pointer(dec)).Falph_dec
   5104 				**(**uintptr)(__ccgo_up(dec + 2968)) += uintptr(offset)
   5105 				if alph_dec != libc.UintptrFromInt32(0) && (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec != libc.UintptrFromInt32(0) {
   5106 					if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fmethod == int32(ALPHA_LOSSLESS_COMPRESSION) {
   5107 						alph_vp8l_dec = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec
   5108 						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))
   5109 					} else { // alph_dec->method == ALPHA_NO_COMPRESSION
   5110 						// Nothing special to do in this case.
   5111 					}
   5112 				}
   5113 			}
   5114 		} else { // Resize lossless bitreader
   5115 			dec1 = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5116 			VP8LBitReaderSetBuffer(tls, dec1+40, new_base, MemDataSize(tls, mem))
   5117 		}
   5118 	}
   5119 }
   5120 
   5121 // C documentation
   5122 //
   5123 //	// Appends data to the end of MemBuffer->buf. It expands the allocated memory
   5124 //	// size if required and also updates VP8BitReader's if new memory is allocated.
   5125 func AppendToMemBuffer(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r int32) {
   5126 	var current_size, new_mem_start size_t
   5127 	var dec, mem, new_buf, old_base, old_start, v1, v2 uintptr
   5128 	var extra_size, new_size uint64_t
   5129 	var need_compressed_alpha int32
   5130 	_, _, _, _, _, _, _, _, _, _, _, _ = current_size, dec, extra_size, mem, need_compressed_alpha, new_buf, new_mem_start, new_size, old_base, old_start, v1, v2
   5131 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5132 	mem = idec + 296
   5133 	need_compressed_alpha = NeedCompressedAlpha(tls, idec)
   5134 	if (*MemBuffer)(unsafe.Pointer(mem)).Fbuf == libc.UintptrFromInt32(0) {
   5135 		v1 = libc.UintptrFromInt32(0)
   5136 	} else {
   5137 		v1 = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5138 	}
   5139 	old_start = v1
   5140 	if need_compressed_alpha != 0 {
   5141 		v2 = (*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data
   5142 	} else {
   5143 		v2 = old_start
   5144 	}
   5145 	old_base = v2
   5146 	if data_size > uint64(^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1)) {
   5147 		// security safeguard: trying to allocate more than what the format
   5148 		// allows for a chunk should be considered a smoke smell.
   5149 		return 0
   5150 	}
   5151 	if (*MemBuffer)(unsafe.Pointer(mem)).Fend+data_size > (*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size { // Need some free memory
   5152 		new_mem_start = libc.Uint64FromInt64(int64(old_start) - int64(old_base))
   5153 		current_size = MemDataSize(tls, mem) + new_mem_start
   5154 		new_size = current_size + data_size
   5155 		extra_size = (new_size + uint64(CHUNK_SIZE) - uint64(1)) & libc.Uint64FromInt32(^(libc.Int32FromInt32(CHUNK_SIZE) - libc.Int32FromInt32(1)))
   5156 		new_buf = WebPSafeMalloc(tls, extra_size, uint64(1))
   5157 		if new_buf == libc.UintptrFromInt32(0) {
   5158 			return 0
   5159 		}
   5160 		if old_base != libc.UintptrFromInt32(0) {
   5161 			libc.X__builtin___memcpy_chk(tls, new_buf, old_base, current_size, ^__predefined_size_t(0))
   5162 		}
   5163 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf)
   5164 		(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = new_buf
   5165 		(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = extra_size
   5166 		(*MemBuffer)(unsafe.Pointer(mem)).Fstart = new_mem_start
   5167 		(*MemBuffer)(unsafe.Pointer(mem)).Fend = current_size
   5168 	}
   5169 	libc.X__builtin___memcpy_chk(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fend), data, data_size, ^__predefined_size_t(0))
   5170 	**(**size_t)(__ccgo_up(mem + 16)) += data_size
   5171 	DoRemap(tls, idec, int64((*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart))-int64(old_start))
   5172 	return int32(1)
   5173 }
   5174 
   5175 func RemapMemBuffer(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r int32) {
   5176 	var mem, old_buf, old_start, v1 uintptr
   5177 	var v2 size_t
   5178 	_, _, _, _, _ = mem, old_buf, old_start, v1, v2
   5179 	mem = idec + 296
   5180 	old_buf = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf
   5181 	if old_buf == libc.UintptrFromInt32(0) {
   5182 		v1 = libc.UintptrFromInt32(0)
   5183 	} else {
   5184 		v1 = old_buf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5185 	}
   5186 	old_start = v1
   5187 	if data_size < (*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size {
   5188 		return 0
   5189 	} // can't remap to a shorter buffer!
   5190 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = data
   5191 	v2 = data_size
   5192 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = v2
   5193 	(*MemBuffer)(unsafe.Pointer(mem)).Fend = v2
   5194 	DoRemap(tls, idec, int64((*MemBuffer)(unsafe.Pointer(mem)).Fbuf+uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart))-int64(old_start))
   5195 	return int32(1)
   5196 }
   5197 
   5198 func InitMemBuffer(tls *libc.TLS, mem uintptr) {
   5199 	(*MemBuffer)(unsafe.Pointer(mem)).Fmode = int32(MEM_MODE_NONE)
   5200 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf = libc.UintptrFromInt32(0)
   5201 	(*MemBuffer)(unsafe.Pointer(mem)).Fbuf_size = uint64(0)
   5202 	(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf = libc.UintptrFromInt32(0)
   5203 	(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_size = uint64(0)
   5204 }
   5205 
   5206 func ClearMemBuffer(tls *libc.TLS, mem uintptr) {
   5207 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_APPEND) {
   5208 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fbuf)
   5209 		WebPSafeFree(tls, (*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf)
   5210 	}
   5211 }
   5212 
   5213 func CheckMemBufferMode(tls *libc.TLS, mem uintptr, expected MemBufferMode) (r int32) {
   5214 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_NONE) {
   5215 		(*MemBuffer)(unsafe.Pointer(mem)).Fmode = expected // switch to the expected mode
   5216 	} else {
   5217 		if (*MemBuffer)(unsafe.Pointer(mem)).Fmode != expected {
   5218 			return 0 // we mixed the modes => error
   5219 		}
   5220 	}
   5221 	// mode is ok
   5222 	return int32(1)
   5223 }
   5224 
   5225 // C documentation
   5226 //
   5227 //	// To be called last.
   5228 func FinishDecoding(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5229 	var options, output uintptr
   5230 	var status, status1 VP8StatusCode1
   5231 	_, _, _, _ = options, output, status, status1
   5232 	options = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foptions
   5233 	output = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput
   5234 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_DONE)
   5235 	if options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fflip != 0 {
   5236 		status = WebPFlipBuffer(tls, output)
   5237 		if status != int32(VP8_STATUS_OK) {
   5238 			return status
   5239 		}
   5240 	}
   5241 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output != libc.UintptrFromInt32(0) {
   5242 		status1 = WebPCopyDecBufferPixels(tls, output, (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output) // do the slow-copy
   5243 		WebPFreeDecBuffer(tls, idec+352)
   5244 		if status1 != int32(VP8_STATUS_OK) {
   5245 			return status1
   5246 		}
   5247 		**(**WebPDecBuffer)(__ccgo_up(output)) = **(**WebPDecBuffer)(__ccgo_up((*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output))
   5248 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = libc.UintptrFromInt32(0)
   5249 	}
   5250 	return int32(VP8_STATUS_OK)
   5251 }
   5252 
   5253 //------------------------------------------------------------------------------
   5254 // Macroblock-decoding contexts
   5255 
   5256 func SaveContext(tls *libc.TLS, dec uintptr, token_br uintptr, context uintptr) {
   5257 	(*MBContext)(unsafe.Pointer(context)).Fleft = **(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr(-libc.Int32FromInt32(1))*2))
   5258 	(*MBContext)(unsafe.Pointer(context)).Finfo = **(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2))
   5259 	(*MBContext)(unsafe.Pointer(context)).Ftoken_br = **(**VP8BitReader)(__ccgo_up(token_br))
   5260 }
   5261 
   5262 func RestoreContext(tls *libc.TLS, context uintptr, dec uintptr, token_br uintptr) {
   5263 	**(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr(-libc.Int32FromInt32(1))*2)) = (*MBContext)(unsafe.Pointer(context)).Fleft
   5264 	**(**VP8MB)(__ccgo_up((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2)) = (*MBContext)(unsafe.Pointer(context)).Finfo
   5265 	**(**VP8BitReader)(__ccgo_up(token_br)) = (*MBContext)(unsafe.Pointer(context)).Ftoken_br
   5266 }
   5267 
   5268 //------------------------------------------------------------------------------
   5269 
   5270 func IDecError(tls *libc.TLS, idec uintptr, error1 VP8StatusCode1) (r VP8StatusCode1) {
   5271 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5272 		// Synchronize the thread, clean-up and check for errors.
   5273 		VP8ExitCritical(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec, idec+136)
   5274 	}
   5275 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_ERROR)
   5276 	return error1
   5277 }
   5278 
   5279 func ChangeState(tls *libc.TLS, idec uintptr, new_state DecState, consumed_bytes size_t) {
   5280 	var mem uintptr
   5281 	_ = mem
   5282 	mem = idec + 296
   5283 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = new_state
   5284 	**(**size_t)(__ccgo_up(mem + 8)) += consumed_bytes
   5285 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5286 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = MemDataSize(tls, mem)
   5287 }
   5288 
   5289 // C documentation
   5290 //
   5291 //	// Headers
   5292 func DecodeWebPHeaders(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5293 	bp := tls.Alloc(80)
   5294 	defer tls.Free(80)
   5295 	var curr_size size_t
   5296 	var data, dec, dec1, mem uintptr
   5297 	var status VP8StatusCode1
   5298 	var _ /* headers at bp+0 */ WebPHeaderStructure
   5299 	_, _, _, _, _, _ = curr_size, data, dec, dec1, mem, status
   5300 	mem = idec + 296
   5301 	data = (*MemBuffer)(unsafe.Pointer(mem)).Fbuf + uintptr((*MemBuffer)(unsafe.Pointer(mem)).Fstart)
   5302 	curr_size = MemDataSize(tls, mem)
   5303 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fdata = data
   5304 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fdata_size = curr_size
   5305 	(**(**WebPHeaderStructure)(__ccgo_up(bp))).Fhave_all_data = 0
   5306 	status = WebPParseHeaders(tls, bp)
   5307 	if status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5308 		return int32(VP8_STATUS_SUSPENDED) // We haven't found a VP8 chunk yet.
   5309 	} else {
   5310 		if status != int32(VP8_STATUS_OK) {
   5311 			return IDecError(tls, idec, status)
   5312 		}
   5313 	}
   5314 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Fcompressed_size
   5315 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Fis_lossless
   5316 	if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5317 		dec = VP8New(tls)
   5318 		if dec == libc.UintptrFromInt32(0) {
   5319 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5320 		}
   5321 		(*VP8Decoder)(unsafe.Pointer(dec)).Fincremental = int32(1)
   5322 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fdec = dec
   5323 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Falpha_data
   5324 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size = (**(**WebPHeaderStructure)(__ccgo_up(bp))).Falpha_data_size
   5325 		ChangeState(tls, idec, int32(STATE_VP8_HEADER), (**(**WebPHeaderStructure)(__ccgo_up(bp))).Foffset)
   5326 	} else {
   5327 		dec1 = VP8LNew(tls)
   5328 		if dec1 == libc.UintptrFromInt32(0) {
   5329 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5330 		}
   5331 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fdec = dec1
   5332 		ChangeState(tls, idec, int32(STATE_VP8L_HEADER), (**(**WebPHeaderStructure)(__ccgo_up(bp))).Foffset)
   5333 	}
   5334 	return int32(VP8_STATUS_OK)
   5335 }
   5336 
   5337 func DecodeVP8FrameHeader(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5338 	bp := tls.Alloc(16)
   5339 	defer tls.Free(16)
   5340 	var bits uint32_t
   5341 	var curr_size size_t
   5342 	var data uintptr
   5343 	var _ /* height at bp+4 */ int32
   5344 	var _ /* width at bp+0 */ int32
   5345 	_, _, _ = bits, curr_size, data
   5346 	data = (*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fbuf + uintptr((*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fstart)
   5347 	curr_size = MemDataSize(tls, idec+296)
   5348 	if curr_size < uint64(VP8_FRAME_HEADER_SIZE) {
   5349 		// Not enough data bytes to extract VP8 Frame Header.
   5350 		return int32(VP8_STATUS_SUSPENDED)
   5351 	}
   5352 	if !(VP8GetInfo(tls, data, curr_size, (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size, bp, bp+4) != 0) {
   5353 		return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5354 	}
   5355 	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))
   5356 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fpart0_size = uint64(bits>>libc.Int32FromInt32(5) + uint32(VP8_FRAME_HEADER_SIZE))
   5357 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata = data
   5358 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fdata_size = curr_size
   5359 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8_PARTS0)
   5360 	return int32(VP8_STATUS_OK)
   5361 }
   5362 
   5363 // C documentation
   5364 //
   5365 //	// Partition #0
   5366 func CopyParts0Data(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5367 	var br, dec, mem, part0_buf uintptr
   5368 	var part_size size_t
   5369 	_, _, _, _, _ = br, dec, mem, part0_buf, part_size
   5370 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5371 	br = dec + 16
   5372 	part_size = libc.Uint64FromInt64(int64((*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end) - int64((*VP8BitReader)(unsafe.Pointer(br)).Fbuf))
   5373 	mem = idec + 296
   5374 	// the following is a format limitation, no need for runtime check:
   5375 	if part_size == uint64(0) { // can't have zero-size partition #0
   5376 		return int32(VP8_STATUS_BITSTREAM_ERROR)
   5377 	}
   5378 	if (*MemBuffer)(unsafe.Pointer(mem)).Fmode == int32(MEM_MODE_APPEND) {
   5379 		// We copy and grab ownership of the partition #0 data.
   5380 		part0_buf = WebPSafeMalloc(tls, uint64(1), part_size)
   5381 		if part0_buf == libc.UintptrFromInt32(0) {
   5382 			return int32(VP8_STATUS_OUT_OF_MEMORY)
   5383 		}
   5384 		libc.X__builtin___memcpy_chk(tls, part0_buf, (*VP8BitReader)(unsafe.Pointer(br)).Fbuf, part_size, ^__predefined_size_t(0))
   5385 		(*MemBuffer)(unsafe.Pointer(mem)).Fpart0_buf = part0_buf
   5386 		VP8BitReaderSetBuffer(tls, br, part0_buf, part_size)
   5387 	} else {
   5388 		// Else: just keep pointers to the partition #0's data in dec->br.
   5389 	}
   5390 	**(**size_t)(__ccgo_up(mem + 8)) += part_size
   5391 	return int32(VP8_STATUS_OK)
   5392 }
   5393 
   5394 func DecodePartition0(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5395 	var dec, io, output, params uintptr
   5396 	var status VP8StatusCode1
   5397 	_, _, _, _, _ = dec, io, output, params, status
   5398 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5399 	io = idec + 136
   5400 	params = idec + 8
   5401 	output = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
   5402 	// Wait till we have enough data for the whole partition #0
   5403 	if MemDataSize(tls, idec+296) < (*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fpart0_size {
   5404 		return int32(VP8_STATUS_SUSPENDED)
   5405 	}
   5406 	if !(VP8GetHeaders(tls, dec, io) != 0) {
   5407 		status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
   5408 		if status == int32(VP8_STATUS_SUSPENDED) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5409 			// treating NOT_ENOUGH_DATA as SUSPENDED state
   5410 			return int32(VP8_STATUS_SUSPENDED)
   5411 		}
   5412 		return IDecError(tls, idec, status)
   5413 	}
   5414 	// Allocate/Verify output buffer now
   5415 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = WebPAllocateDecBuffer(tls, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, output)
   5416 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5417 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5418 	}
   5419 	// This change must be done before calling VP8InitFrame()
   5420 	(*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)
   5421 	VP8InitDithering(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, dec)
   5422 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = CopyParts0Data(tls, idec)
   5423 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5424 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5425 	}
   5426 	// Finish setting up the decoding parameters. Will call io->setup().
   5427 	if VP8EnterCritical(tls, dec, io) != int32(VP8_STATUS_OK) {
   5428 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5429 	}
   5430 	// Note: past this point, teardown() must always be called
   5431 	// in case of error.
   5432 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8_DATA)
   5433 	// Allocate memory and prepare everything.
   5434 	if !(VP8InitFrame(tls, dec, io) != 0) {
   5435 		return IDecError(tls, idec, (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus)
   5436 	}
   5437 	return int32(VP8_STATUS_OK)
   5438 }
   5439 
   5440 // C documentation
   5441 //
   5442 //	// Remaining partitions
   5443 func DecodeRemaining(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5444 	bp := tls.Alloc(64)
   5445 	defer tls.Free(64)
   5446 	var dec, io, token_br uintptr
   5447 	var _ /* context at bp+0 */ MBContext
   5448 	_, _, _ = dec, io, token_br
   5449 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5450 	io = idec + 136
   5451 	// Make sure partition #0 has been read before, to set dec to ready.
   5452 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fready != 0) {
   5453 		return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5454 	}
   5455 	for {
   5456 		if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h) {
   5457 			break
   5458 		}
   5459 		if (*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y != (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y {
   5460 			if !(VP8ParseIntraModeRow(tls, dec+16, dec) != 0) {
   5461 				// note: normally, error shouldn't occur since we already have the whole
   5462 				// partition0 available here in DecodeRemaining(). Reaching EOF while
   5463 				// reading intra modes really means a BITSTREAM_ERROR.
   5464 				return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5465 			}
   5466 			(*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y
   5467 		}
   5468 		for {
   5469 			if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
   5470 				break
   5471 			}
   5472 			token_br = dec + 440 + uintptr(libc.Uint32FromInt32((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y)&(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)*48
   5473 			SaveContext(tls, dec, token_br, bp)
   5474 			if !(VP8DecodeMB(tls, dec, token_br) != 0) {
   5475 				// We shouldn't fail when MAX_MB data was available
   5476 				if (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one == uint32(0) && MemDataSize(tls, idec+296) > uint64(MAX_MB_SIZE) {
   5477 					return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5478 				}
   5479 				// Synchronize the threads.
   5480 				if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
   5481 					if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152) != 0) {
   5482 						return IDecError(tls, idec, int32(VP8_STATUS_BITSTREAM_ERROR))
   5483 					}
   5484 				}
   5485 				RestoreContext(tls, bp, dec, token_br)
   5486 				return int32(VP8_STATUS_SUSPENDED)
   5487 			}
   5488 			// Release buffer only if there is only one partition
   5489 			if (*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one == uint32(0) {
   5490 				(*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fstart = libc.Uint64FromInt64(int64((*VP8BitReader)(unsafe.Pointer(token_br)).Fbuf) - int64((*WebPIDecoder)(unsafe.Pointer(idec)).Fmem.Fbuf))
   5491 			}
   5492 			goto _2
   5493 		_2:
   5494 			;
   5495 			(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x + 1
   5496 		}
   5497 		VP8InitScanline(tls, dec) // Prepare for next scanline
   5498 		// Reconstruct, filter and emit the row.
   5499 		if !(VP8ProcessRow(tls, dec, io) != 0) {
   5500 			return IDecError(tls, idec, int32(VP8_STATUS_USER_ABORT))
   5501 		}
   5502 		goto _1
   5503 	_1:
   5504 		;
   5505 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y + 1
   5506 	}
   5507 	// Synchronize the thread and check for errors.
   5508 	if !(VP8ExitCritical(tls, dec, io) != 0) {
   5509 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_ERROR) // prevent re-entry in IDecError
   5510 		return IDecError(tls, idec, int32(VP8_STATUS_USER_ABORT))
   5511 	}
   5512 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
   5513 	return FinishDecoding(tls, idec)
   5514 }
   5515 
   5516 func ErrorStatusLossless(tls *libc.TLS, idec uintptr, status VP8StatusCode1) (r VP8StatusCode1) {
   5517 	if status == int32(VP8_STATUS_SUSPENDED) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
   5518 		return int32(VP8_STATUS_SUSPENDED)
   5519 	}
   5520 	return IDecError(tls, idec, status)
   5521 }
   5522 
   5523 func DecodeVP8LHeader(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5524 	var curr_size size_t
   5525 	var dec, io, output, params uintptr
   5526 	_, _, _, _, _ = curr_size, dec, io, output, params
   5527 	io = idec + 136
   5528 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5529 	params = idec + 8
   5530 	output = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
   5531 	curr_size = MemDataSize(tls, idec+296)
   5532 	// Wait until there's enough data for decoding header.
   5533 	if curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size>>libc.Int32FromInt32(3) {
   5534 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
   5535 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5536 	}
   5537 	if !(VP8LDecodeHeader(tls, dec, io) != 0) {
   5538 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_BITSTREAM_ERROR) && curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size {
   5539 			(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
   5540 		}
   5541 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5542 	}
   5543 	// Allocate/verify output buffer now.
   5544 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = WebPAllocateDecBuffer(tls, (*VP8Io)(unsafe.Pointer(io)).Fwidth, (*VP8Io)(unsafe.Pointer(io)).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, output)
   5545 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus != int32(VP8_STATUS_OK) {
   5546 		return IDecError(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5547 	}
   5548 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_VP8L_DATA)
   5549 	return int32(VP8_STATUS_OK)
   5550 }
   5551 
   5552 func DecodeVP8LData(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5553 	var curr_size size_t
   5554 	var dec uintptr
   5555 	var v1 int32
   5556 	_, _, _ = curr_size, dec, v1
   5557 	dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5558 	curr_size = MemDataSize(tls, idec+296)
   5559 	// Switch to incremental decoding if we don't have all the bytes available.
   5560 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental = libc.BoolInt32(curr_size < (*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size)
   5561 	if !(VP8LDecodeImage(tls, dec) != 0) {
   5562 		return ErrorStatusLossless(tls, idec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus)
   5563 	}
   5564 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_SUSPENDED) {
   5565 		v1 = (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus
   5566 	} else {
   5567 		v1 = FinishDecoding(tls, idec)
   5568 	}
   5569 	return v1
   5570 }
   5571 
   5572 // C documentation
   5573 //
   5574 //	// Main decoding loop
   5575 func IDecode(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5576 	var dec uintptr
   5577 	var status VP8StatusCode1
   5578 	_, _ = dec, status
   5579 	status = int32(VP8_STATUS_SUSPENDED)
   5580 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_WEBP_HEADER) {
   5581 		status = DecodeWebPHeaders(tls, idec)
   5582 	} else {
   5583 		if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec == libc.UintptrFromInt32(0) {
   5584 			return int32(VP8_STATUS_SUSPENDED) // can't continue if we have no decoder.
   5585 		}
   5586 	}
   5587 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_HEADER) {
   5588 		status = DecodeVP8FrameHeader(tls, idec)
   5589 	}
   5590 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_PARTS0) {
   5591 		status = DecodePartition0(tls, idec)
   5592 	}
   5593 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5594 		dec = (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec
   5595 		if dec == libc.UintptrFromInt32(0) {
   5596 			return int32(VP8_STATUS_SUSPENDED) // can't continue if we have no decoder.
   5597 		}
   5598 		status = DecodeRemaining(tls, idec)
   5599 	}
   5600 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8L_HEADER) {
   5601 		status = DecodeVP8LHeader(tls, idec)
   5602 	}
   5603 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8L_DATA) {
   5604 		status = DecodeVP8LData(tls, idec)
   5605 	}
   5606 	return status
   5607 }
   5608 
   5609 // ------------------------------------------------------------------------------
   5610 // Internal constructor
   5611 func NewDecoder(tls *libc.TLS, output_buffer uintptr, features uintptr) (r uintptr) {
   5612 	var idec uintptr
   5613 	var v1, v3 int32
   5614 	var v5 bool
   5615 	_, _, _, _ = idec, v1, v3, v5
   5616 	idec = WebPSafeCalloc(tls, uint64(1), uint64(496))
   5617 	if idec == libc.UintptrFromInt32(0) {
   5618 		return libc.UintptrFromInt32(0)
   5619 	}
   5620 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fstate = int32(STATE_WEBP_HEADER)
   5621 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fchunk_size = uint64(0)
   5622 	(*WebPIDecoder)(unsafe.Pointer(idec)).Flast_mb_y = -int32(1)
   5623 	InitMemBuffer(tls, idec+296)
   5624 	v1 = WebPInitDecBufferInternal(tls, idec+352, int32(WEBP_DECODER_ABI_VERSION))
   5625 	goto _2
   5626 _2:
   5627 	;
   5628 	if v5 = !(v1 != 0); !v5 {
   5629 		v3 = VP8InitIoInternal(tls, idec+136, int32(WEBP_DECODER_ABI_VERSION))
   5630 		goto _4
   5631 	_4:
   5632 	}
   5633 	if v5 || !(v3 != 0) {
   5634 		WebPSafeFree(tls, idec)
   5635 		return libc.UintptrFromInt32(0)
   5636 	}
   5637 	WebPResetDecParams(tls, idec+8)
   5638 	if output_buffer == libc.UintptrFromInt32(0) || WebPAvoidSlowMemory(tls, output_buffer, features) != 0 {
   5639 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput = idec + 352
   5640 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = output_buffer
   5641 		if output_buffer != libc.UintptrFromInt32(0) {
   5642 			(*WebPDecBuffer)(unsafe.Pointer((*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput)).Fcolorspace = (*WebPDecBuffer)(unsafe.Pointer(output_buffer)).Fcolorspace
   5643 		}
   5644 	} else {
   5645 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput = output_buffer
   5646 		(*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output = libc.UintptrFromInt32(0)
   5647 	}
   5648 	WebPInitCustomIo(tls, idec+8, idec+136) // Plug the I/O functions.
   5649 	return idec
   5650 }
   5651 
   5652 //------------------------------------------------------------------------------
   5653 // Public functions
   5654 
   5655 func WebPINewDecoder(tls *libc.TLS, output_buffer uintptr) (r uintptr) {
   5656 	return NewDecoder(tls, output_buffer, libc.UintptrFromInt32(0))
   5657 }
   5658 
   5659 func WebPIDecode(tls *libc.TLS, data1 uintptr, data_size1 size_t, config uintptr) (r uintptr) {
   5660 	bp := tls.Alloc(48)
   5661 	defer tls.Free(48)
   5662 	var features1, idec, v1 uintptr
   5663 	var v2 VP8StatusCode1
   5664 	var _ /* tmp_features at bp+0 */ WebPBitstreamFeatures
   5665 	_, _, _, _ = features1, idec, v1, v2
   5666 	if config == libc.UintptrFromInt32(0) {
   5667 		v1 = bp
   5668 	} else {
   5669 		v1 = config
   5670 	}
   5671 	features1 = v1
   5672 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(40), ^__predefined_size_t(0))
   5673 	// Parse the bitstream's features, if requested:
   5674 	if data1 != libc.UintptrFromInt32(0) && data_size1 > uint64(0) {
   5675 		v2 = WebPGetFeaturesInternal(tls, data1, data_size1, features1, int32(WEBP_DECODER_ABI_VERSION))
   5676 		goto _3
   5677 	_3:
   5678 		if v2 != int32(VP8_STATUS_OK) {
   5679 			return libc.UintptrFromInt32(0)
   5680 		}
   5681 	}
   5682 	// Create an instance of the incremental decoder
   5683 	if config != libc.UintptrFromInt32(0) {
   5684 		v1 = NewDecoder(tls, config+40, features1)
   5685 	} else {
   5686 		v1 = NewDecoder(tls, libc.UintptrFromInt32(0), features1)
   5687 	}
   5688 	idec = v1
   5689 	if idec == libc.UintptrFromInt32(0) {
   5690 		return libc.UintptrFromInt32(0)
   5691 	}
   5692 	// Finish initialization
   5693 	if config != libc.UintptrFromInt32(0) {
   5694 		(*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foptions = config + 160
   5695 	}
   5696 	return idec
   5697 }
   5698 
   5699 func WebPIDelete(tls *libc.TLS, idec uintptr) {
   5700 	if idec == libc.UintptrFromInt32(0) {
   5701 		return
   5702 	}
   5703 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec != libc.UintptrFromInt32(0) {
   5704 		if !((*WebPIDecoder)(unsafe.Pointer(idec)).Fis_lossless != 0) {
   5705 			if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_VP8_DATA) {
   5706 				// Synchronize the thread, clean-up and check for errors.
   5707 				// TODO(vrabaud) do we care about the return result?
   5708 				VP8ExitCritical(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec, idec+136)
   5709 			}
   5710 			VP8Delete(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec)
   5711 		} else {
   5712 			VP8LDelete(tls, (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec)
   5713 		}
   5714 	}
   5715 	ClearMemBuffer(tls, idec+296)
   5716 	WebPFreeDecBuffer(tls, idec+352)
   5717 	WebPSafeFree(tls, idec)
   5718 }
   5719 
   5720 //------------------------------------------------------------------------------
   5721 // Wrapper toward WebPINewDecoder
   5722 
   5723 func WebPINewRGB(tls *libc.TLS, csp WEBP_CSP_MODE1, output_buffer uintptr, output_buffer_size size_t, output_stride int32) (r uintptr) {
   5724 	var idec uintptr
   5725 	var is_external_memory, v1 int32
   5726 	_, _, _ = idec, is_external_memory, v1
   5727 	if output_buffer != libc.UintptrFromInt32(0) {
   5728 		v1 = int32(1)
   5729 	} else {
   5730 		v1 = 0
   5731 	}
   5732 	is_external_memory = v1
   5733 	if csp >= int32(MODE_YUV) {
   5734 		return libc.UintptrFromInt32(0)
   5735 	}
   5736 	if is_external_memory == 0 { // Overwrite parameters to sane values.
   5737 		output_buffer_size = uint64(0)
   5738 		output_stride = 0
   5739 	} else { // A buffer was passed. Validate the other params.
   5740 		if output_stride == 0 || output_buffer_size == uint64(0) {
   5741 			return libc.UintptrFromInt32(0) // invalid parameter.
   5742 		}
   5743 	}
   5744 	idec = WebPINewDecoder(tls, libc.UintptrFromInt32(0))
   5745 	if idec == libc.UintptrFromInt32(0) {
   5746 		return libc.UintptrFromInt32(0)
   5747 	}
   5748 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fcolorspace = csp
   5749 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fis_external_memory = is_external_memory
   5750 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16)) = output_buffer
   5751 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 8)) = output_stride
   5752 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 16)) = output_buffer_size
   5753 	return idec
   5754 }
   5755 
   5756 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) {
   5757 	var colorspace WEBP_CSP_MODE1
   5758 	var idec, v8, v9 uintptr
   5759 	var is_external_memory, v1, v5, v6 int32
   5760 	var v2, v3, v4 size_t
   5761 	_, _, _, _, _, _, _, _, _, _, _ = colorspace, idec, is_external_memory, v1, v2, v3, v4, v5, v6, v8, v9
   5762 	if luma != libc.UintptrFromInt32(0) {
   5763 		v1 = int32(1)
   5764 	} else {
   5765 		v1 = 0
   5766 	}
   5767 	is_external_memory = v1
   5768 	if is_external_memory == 0 { // Overwrite parameters to sane values.
   5769 		v4 = libc.Uint64FromInt32(0)
   5770 		a_size = v4
   5771 		v3 = v4
   5772 		v_size = v3
   5773 		v2 = v3
   5774 		u_size = v2
   5775 		luma_size = v2
   5776 		v6 = libc.Int32FromInt32(0)
   5777 		a_stride = v6
   5778 		v5 = v6
   5779 		v_stride = v5
   5780 		v1 = v5
   5781 		u_stride = v1
   5782 		luma_stride = v1
   5783 		v9 = libc.UintptrFromInt32(0)
   5784 		a = v9
   5785 		v8 = v9
   5786 		v = v8
   5787 		u = v8
   5788 		colorspace = int32(MODE_YUVA)
   5789 	} else { // A luma buffer was passed. Validate the other parameters.
   5790 		if u == libc.UintptrFromInt32(0) || v == libc.UintptrFromInt32(0) {
   5791 			return libc.UintptrFromInt32(0)
   5792 		}
   5793 		if luma_size == uint64(0) || u_size == uint64(0) || v_size == uint64(0) {
   5794 			return libc.UintptrFromInt32(0)
   5795 		}
   5796 		if luma_stride == 0 || u_stride == 0 || v_stride == 0 {
   5797 			return libc.UintptrFromInt32(0)
   5798 		}
   5799 		if a != libc.UintptrFromInt32(0) {
   5800 			if a_size == uint64(0) || a_stride == 0 {
   5801 				return libc.UintptrFromInt32(0)
   5802 			}
   5803 		}
   5804 		if a == libc.UintptrFromInt32(0) {
   5805 			v1 = int32(MODE_YUV)
   5806 		} else {
   5807 			v1 = int32(MODE_YUVA)
   5808 		}
   5809 		colorspace = v1
   5810 	}
   5811 	idec = WebPINewDecoder(tls, libc.UintptrFromInt32(0))
   5812 	if idec == libc.UintptrFromInt32(0) {
   5813 		return libc.UintptrFromInt32(0)
   5814 	}
   5815 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fcolorspace = colorspace
   5816 	(*WebPIDecoder)(unsafe.Pointer(idec)).Foutput.Fis_external_memory = is_external_memory
   5817 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16)) = luma
   5818 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 32)) = luma_stride
   5819 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 48)) = luma_size
   5820 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 8)) = u
   5821 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 36)) = u_stride
   5822 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 56)) = u_size
   5823 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 16)) = v
   5824 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 40)) = v_stride
   5825 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 64)) = v_size
   5826 	*(*uintptr)(unsafe.Pointer(idec + 352 + 16 + 24)) = a
   5827 	*(*int32)(unsafe.Pointer(idec + 352 + 16 + 44)) = a_stride
   5828 	*(*size_t)(unsafe.Pointer(idec + 352 + 16 + 72)) = a_size
   5829 	return idec
   5830 }
   5831 
   5832 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) {
   5833 	return WebPINewYUVA(tls, luma, luma_size, luma_stride, u, u_size, u_stride, v, v_size, v_stride, libc.UintptrFromInt32(0), uint64(0), 0)
   5834 }
   5835 
   5836 //------------------------------------------------------------------------------
   5837 
   5838 func IDecCheckStatus(tls *libc.TLS, idec uintptr) (r VP8StatusCode1) {
   5839 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_ERROR) {
   5840 		return int32(VP8_STATUS_BITSTREAM_ERROR)
   5841 	}
   5842 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate == int32(STATE_DONE) {
   5843 		return int32(VP8_STATUS_OK)
   5844 	}
   5845 	return int32(VP8_STATUS_SUSPENDED)
   5846 }
   5847 
   5848 func WebPIAppend(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r VP8StatusCode1) {
   5849 	var status VP8StatusCode1
   5850 	_ = status
   5851 	if idec == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
   5852 		return int32(VP8_STATUS_INVALID_PARAM)
   5853 	}
   5854 	status = IDecCheckStatus(tls, idec)
   5855 	if status != int32(VP8_STATUS_SUSPENDED) {
   5856 		return status
   5857 	}
   5858 	// Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
   5859 	if !(CheckMemBufferMode(tls, idec+296, int32(MEM_MODE_APPEND)) != 0) {
   5860 		return int32(VP8_STATUS_INVALID_PARAM)
   5861 	}
   5862 	// Append data to memory buffer
   5863 	if !(AppendToMemBuffer(tls, idec, data, data_size) != 0) {
   5864 		return int32(VP8_STATUS_OUT_OF_MEMORY)
   5865 	}
   5866 	return IDecode(tls, idec)
   5867 }
   5868 
   5869 func WebPIUpdate(tls *libc.TLS, idec uintptr, data uintptr, data_size size_t) (r VP8StatusCode1) {
   5870 	var status VP8StatusCode1
   5871 	_ = status
   5872 	if idec == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
   5873 		return int32(VP8_STATUS_INVALID_PARAM)
   5874 	}
   5875 	status = IDecCheckStatus(tls, idec)
   5876 	if status != int32(VP8_STATUS_SUSPENDED) {
   5877 		return status
   5878 	}
   5879 	// Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
   5880 	if !(CheckMemBufferMode(tls, idec+296, int32(MEM_MODE_MAP)) != 0) {
   5881 		return int32(VP8_STATUS_INVALID_PARAM)
   5882 	}
   5883 	// Make the memory buffer point to the new buffer
   5884 	if !(RemapMemBuffer(tls, idec, data, data_size) != 0) {
   5885 		return int32(VP8_STATUS_INVALID_PARAM)
   5886 	}
   5887 	return IDecode(tls, idec)
   5888 }
   5889 
   5890 //------------------------------------------------------------------------------
   5891 
   5892 func GetOutputBuffer(tls *libc.TLS, idec uintptr) (r uintptr) {
   5893 	if idec == libc.UintptrFromInt32(0) || (*WebPIDecoder)(unsafe.Pointer(idec)).Fdec == libc.UintptrFromInt32(0) {
   5894 		return libc.UintptrFromInt32(0)
   5895 	}
   5896 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate <= int32(STATE_VP8_PARTS0) {
   5897 		return libc.UintptrFromInt32(0)
   5898 	}
   5899 	if (*WebPIDecoder)(unsafe.Pointer(idec)).Ffinal_output != libc.UintptrFromInt32(0) {
   5900 		return libc.UintptrFromInt32(0) // not yet slow-copied
   5901 	}
   5902 	return (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Foutput
   5903 }
   5904 
   5905 func WebPIDecodedArea(tls *libc.TLS, idec uintptr, left uintptr, top uintptr, width uintptr, height uintptr) (r uintptr) {
   5906 	var src uintptr
   5907 	_ = src
   5908 	src = GetOutputBuffer(tls, idec)
   5909 	if left != libc.UintptrFromInt32(0) {
   5910 		**(**int32)(__ccgo_up(left)) = 0
   5911 	}
   5912 	if top != libc.UintptrFromInt32(0) {
   5913 		**(**int32)(__ccgo_up(top)) = 0
   5914 	}
   5915 	if src != libc.UintptrFromInt32(0) {
   5916 		if width != libc.UintptrFromInt32(0) {
   5917 			**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5918 		}
   5919 		if height != libc.UintptrFromInt32(0) {
   5920 			**(**int32)(__ccgo_up(height)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5921 		}
   5922 	} else {
   5923 		if width != libc.UintptrFromInt32(0) {
   5924 			**(**int32)(__ccgo_up(width)) = 0
   5925 		}
   5926 		if height != libc.UintptrFromInt32(0) {
   5927 			**(**int32)(__ccgo_up(height)) = 0
   5928 		}
   5929 	}
   5930 	return src
   5931 }
   5932 
   5933 func WebPIDecGetRGB(tls *libc.TLS, idec uintptr, last_y uintptr, width uintptr, height uintptr, stride uintptr) (r uintptr) {
   5934 	var src uintptr
   5935 	_ = src
   5936 	src = GetOutputBuffer(tls, idec)
   5937 	if src == libc.UintptrFromInt32(0) {
   5938 		return libc.UintptrFromInt32(0)
   5939 	}
   5940 	if (*WebPDecBuffer)(unsafe.Pointer(src)).Fcolorspace >= int32(MODE_YUV) {
   5941 		return libc.UintptrFromInt32(0)
   5942 	}
   5943 	if last_y != libc.UintptrFromInt32(0) {
   5944 		**(**int32)(__ccgo_up(last_y)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5945 	}
   5946 	if width != libc.UintptrFromInt32(0) {
   5947 		**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5948 	}
   5949 	if height != libc.UintptrFromInt32(0) {
   5950 		**(**int32)(__ccgo_up(height)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fheight
   5951 	}
   5952 	if stride != libc.UintptrFromInt32(0) {
   5953 		**(**int32)(__ccgo_up(stride)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fu.FRGBA.Fstride
   5954 	}
   5955 	return (*WebPDecBuffer)(unsafe.Pointer(src)).Fu.FRGBA.Frgba
   5956 }
   5957 
   5958 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) {
   5959 	var src uintptr
   5960 	_ = src
   5961 	src = GetOutputBuffer(tls, idec)
   5962 	if src == libc.UintptrFromInt32(0) {
   5963 		return libc.UintptrFromInt32(0)
   5964 	}
   5965 	if (*WebPDecBuffer)(unsafe.Pointer(src)).Fcolorspace < int32(MODE_YUV) {
   5966 		return libc.UintptrFromInt32(0)
   5967 	}
   5968 	if last_y != libc.UintptrFromInt32(0) {
   5969 		**(**int32)(__ccgo_up(last_y)) = (*WebPIDecoder)(unsafe.Pointer(idec)).Fparams.Flast_y
   5970 	}
   5971 	if u != libc.UintptrFromInt32(0) {
   5972 		**(**uintptr)(__ccgo_up(u)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fu
   5973 	}
   5974 	if v != libc.UintptrFromInt32(0) {
   5975 		**(**uintptr)(__ccgo_up(v)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fv
   5976 	}
   5977 	if a != libc.UintptrFromInt32(0) {
   5978 		**(**uintptr)(__ccgo_up(a)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fa
   5979 	}
   5980 	if width != libc.UintptrFromInt32(0) {
   5981 		**(**int32)(__ccgo_up(width)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fwidth
   5982 	}
   5983 	if height != libc.UintptrFromInt32(0) {
   5984 		**(**int32)(__ccgo_up(height)) = (*WebPDecBuffer)(unsafe.Pointer(src)).Fheight
   5985 	}
   5986 	if stride != libc.UintptrFromInt32(0) {
   5987 		**(**int32)(__ccgo_up(stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fy_stride
   5988 	}
   5989 	if uv_stride != libc.UintptrFromInt32(0) {
   5990 		**(**int32)(__ccgo_up(uv_stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fu_stride
   5991 	}
   5992 	if a_stride != libc.UintptrFromInt32(0) {
   5993 		**(**int32)(__ccgo_up(a_stride)) = (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fa_stride
   5994 	}
   5995 	return (*(*WebPYUVABuffer)(unsafe.Pointer(src + 16))).Fy
   5996 }
   5997 
   5998 type __ccgo_fp__XWebPISetIOHooks_1 = func(*libc.TLS, uintptr) int32
   5999 
   6000 type __ccgo_fp__XWebPISetIOHooks_2 = func(*libc.TLS, uintptr) int32
   6001 
   6002 type __ccgo_fp__XWebPISetIOHooks_3 = func(*libc.TLS, uintptr)
   6003 
   6004 func WebPISetIOHooks(tls *libc.TLS, idec uintptr, __ccgo_fp_put VP8IoPutHook, __ccgo_fp_setup VP8IoSetupHook, __ccgo_fp_teardown VP8IoTeardownHook, user_data uintptr) (r int32) {
   6005 	if idec == libc.UintptrFromInt32(0) || (*WebPIDecoder)(unsafe.Pointer(idec)).Fstate > int32(STATE_WEBP_HEADER) {
   6006 		return 0
   6007 	}
   6008 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fput = __ccgo_fp_put
   6009 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fsetup = __ccgo_fp_setup
   6010 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fteardown = __ccgo_fp_teardown
   6011 	(*WebPIDecoder)(unsafe.Pointer(idec)).Fio.Fopaque = user_data
   6012 	return int32(1)
   6013 }
   6014 
   6015 var kHashMul4 = uint32(0x1e35a7bd)
   6016 
   6017 const YUV_FIX = 16
   6018 const YUV_HALF = 32768
   6019 const YUV_FIX2 = 6
   6020 const YUV_MASK2 = 16383
   6021 
   6022 //------------------------------------------------------------------------------
   6023 
   6024 // Copyright 2010 Google Inc. All Rights Reserved.
   6025 //
   6026 // Use of this source code is governed by a BSD-style license
   6027 // that can be found in the COPYING file in the root of the source
   6028 // tree. An additional intellectual property rights grant can be found
   6029 // in the file PATENTS. All contributing project authors may
   6030 // be found in the AUTHORS file in the root of the source tree.
   6031 // -----------------------------------------------------------------------------
   6032 //
   6033 //  Main decoding functions for WebP images.
   6034 //
   6035 // Author: Skal (pascal.massimino@gmail.com)
   6036 
   6037 //------------------------------------------------------------------------------
   6038 // Main YUV<->RGB conversion functions
   6039 
   6040 func EmitYUV(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6041 	var buf, output, u_dst, v_dst, y_dst uintptr
   6042 	var mb_h, mb_w, uv_h, uv_w int32
   6043 	_, _, _, _, _, _, _, _, _ = buf, mb_h, mb_w, output, u_dst, uv_h, uv_w, v_dst, y_dst
   6044 	output = (*WebPDecParams)(unsafe.Pointer(p)).Foutput
   6045 	buf = output + 16
   6046 	y_dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride))
   6047 	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))
   6048 	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))
   6049 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6050 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6051 	uv_w = (mb_w + int32(1)) / int32(2)
   6052 	uv_h = (mb_h + int32(1)) / int32(2)
   6053 	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)
   6054 	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)
   6055 	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)
   6056 	return (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6057 }
   6058 
   6059 // C documentation
   6060 //
   6061 //	// Point-sampling U/V sampler.
   6062 func EmitSampledRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6063 	var buf, dst, output uintptr
   6064 	_, _, _ = buf, dst, output
   6065 	output = (*WebPDecParams)(unsafe.Pointer(p)).Foutput
   6066 	buf = output + 16
   6067 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6068 	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])
   6069 	return (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6070 }
   6071 
   6072 //------------------------------------------------------------------------------
   6073 // Fancy upsampling
   6074 
   6075 func EmitFancyRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6076 	var buf, cur_u, cur_v, cur_y, dst, top_u, top_v uintptr
   6077 	var mb_w, num_lines_out, uv_w, y, y_end int32
   6078 	var upsample WebPUpsampleLinePairFunc
   6079 	_, _, _, _, _, _, _, _, _, _, _, _, _ = buf, cur_u, cur_v, cur_y, dst, mb_w, num_lines_out, top_u, top_v, upsample, uv_w, y, y_end
   6080 	num_lines_out = (*VP8Io)(unsafe.Pointer(io)).Fmb_h // a priori guess
   6081 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6082 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6083 	upsample = WebPUpsamplers[(*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace]
   6084 	cur_y = (*VP8Io)(unsafe.Pointer(io)).Fy
   6085 	cur_u = (*VP8Io)(unsafe.Pointer(io)).Fu
   6086 	cur_v = (*VP8Io)(unsafe.Pointer(io)).Fv
   6087 	top_u = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u
   6088 	top_v = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v
   6089 	y = (*VP8Io)(unsafe.Pointer(io)).Fmb_y
   6090 	y_end = (*VP8Io)(unsafe.Pointer(io)).Fmb_y + (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6091 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6092 	uv_w = (mb_w + int32(1)) / int32(2)
   6093 	if y == 0 {
   6094 		// First line is special cased. We mirror the u/v samples at boundary.
   6095 		(*(*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)
   6096 	} else {
   6097 		// We can finish the left-over line from previous call.
   6098 		(*(*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)
   6099 		num_lines_out = num_lines_out + 1
   6100 	}
   6101 	// Loop over each output pairs of row.
   6102 	for {
   6103 		if !(y+int32(2) < y_end) {
   6104 			break
   6105 		}
   6106 		top_u = cur_u
   6107 		top_v = cur_v
   6108 		cur_u = cur_u + uintptr((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6109 		cur_v = cur_v + uintptr((*VP8Io)(unsafe.Pointer(io)).Fuv_stride)
   6110 		dst = dst + uintptr(int32(2)*(*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6111 		cur_y = cur_y + uintptr(int32(2)*(*VP8Io)(unsafe.Pointer(io)).Fy_stride)
   6112 		(*(*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)
   6113 		goto _1
   6114 	_1:
   6115 		;
   6116 		y = y + int32(2)
   6117 	}
   6118 	// move to last row
   6119 	cur_y = cur_y + uintptr((*VP8Io)(unsafe.Pointer(io)).Fy_stride)
   6120 	if (*VP8Io)(unsafe.Pointer(io)).Fcrop_top+y_end < (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
   6121 		// Save the unfinished samples for next call (as we're not done yet).
   6122 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y, cur_y, libc.Uint64FromInt32(mb_w)*uint64(1), ^__predefined_size_t(0))
   6123 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u, cur_u, libc.Uint64FromInt32(uv_w)*uint64(1), ^__predefined_size_t(0))
   6124 		libc.X__builtin___memcpy_chk(tls, (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v, cur_v, libc.Uint64FromInt32(uv_w)*uint64(1), ^__predefined_size_t(0))
   6125 		// The fancy upsampler leaves a row unfinished behind
   6126 		// (except for the very last row)
   6127 		num_lines_out = num_lines_out - 1
   6128 	} else {
   6129 		// Process the very last row of even-sized picture
   6130 		if !(y_end&libc.Int32FromInt32(1) != 0) {
   6131 			(*(*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)
   6132 		}
   6133 	}
   6134 	return num_lines_out
   6135 }
   6136 
   6137 //------------------------------------------------------------------------------
   6138 
   6139 func FillAlphaPlane(tls *libc.TLS, dst uintptr, w int32, h int32, stride int32) {
   6140 	var j int32
   6141 	_ = j
   6142 	j = 0
   6143 	for {
   6144 		if !(j < h) {
   6145 			break
   6146 		}
   6147 		libc.X__builtin___memset_chk(tls, dst, int32(0xff), libc.Uint64FromInt32(w)*uint64(1), ^__predefined_size_t(0))
   6148 		dst = dst + uintptr(stride)
   6149 		goto _1
   6150 	_1:
   6151 		;
   6152 		j = j + 1
   6153 	}
   6154 }
   6155 
   6156 func EmitAlphaYUV(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6157 	var alpha, buf, dst uintptr
   6158 	var j, mb_h, mb_w int32
   6159 	_, _, _, _, _, _ = alpha, buf, dst, j, mb_h, mb_w
   6160 	alpha = (*VP8Io)(unsafe.Pointer(io)).Fa
   6161 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6162 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6163 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6164 	dst = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride))
   6165 	_ = expected_num_lines_out
   6166 	if alpha != libc.UintptrFromInt32(0) {
   6167 		j = 0
   6168 		for {
   6169 			if !(j < mb_h) {
   6170 				break
   6171 			}
   6172 			libc.X__builtin___memcpy_chk(tls, dst, alpha, libc.Uint64FromInt32(mb_w)*uint64(1), ^__predefined_size_t(0))
   6173 			alpha = alpha + uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6174 			dst = dst + uintptr((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6175 			goto _1
   6176 		_1:
   6177 			;
   6178 			j = j + 1
   6179 		}
   6180 	} else {
   6181 		if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
   6182 			// the user requested alpha, but there is none, set it to opaque.
   6183 			FillAlphaPlane(tls, dst, mb_w, mb_h, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6184 		}
   6185 	}
   6186 	return 0
   6187 }
   6188 
   6189 func GetAlphaSourceRow(tls *libc.TLS, io uintptr, alpha uintptr, num_rows uintptr) (r int32) {
   6190 	var start_y int32
   6191 	_ = start_y
   6192 	start_y = (*VP8Io)(unsafe.Pointer(io)).Fmb_y
   6193 	**(**int32)(__ccgo_up(num_rows)) = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6194 	// Compensate for the 1-line delay of the fancy upscaler.
   6195 	// This is similar to EmitFancyRGB().
   6196 	if (*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling != 0 {
   6197 		if start_y == 0 {
   6198 			// We don't process the last row yet. It'll be done during the next call.
   6199 			**(**int32)(__ccgo_up(num_rows)) = **(**int32)(__ccgo_up(num_rows)) - 1
   6200 		} else {
   6201 			start_y = start_y - 1
   6202 			// Fortunately, *alpha data is persistent, so we can go back
   6203 			// one row and finish alpha blending, now that the fancy upscaler
   6204 			// completed the YUV->RGB interpolation.
   6205 			**(**uintptr)(__ccgo_up(alpha)) -= uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6206 		}
   6207 		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 {
   6208 			// If it's the very last call, we process all the remaining rows!
   6209 			**(**int32)(__ccgo_up(num_rows)) = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - start_y
   6210 		}
   6211 	}
   6212 	return start_y
   6213 }
   6214 
   6215 func EmitAlphaRGB(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6216 	bp := tls.Alloc(16)
   6217 	defer tls.Free(16)
   6218 	var alpha_first, has_alpha, mb_w, start_y, v1 int32
   6219 	var base_rgba, buf, dst uintptr
   6220 	var colorspace, v2 WEBP_CSP_MODE1
   6221 	var v5 bool
   6222 	var _ /* alpha at bp+0 */ uintptr
   6223 	var _ /* num_rows at bp+8 */ int32
   6224 	_, _, _, _, _, _, _, _, _, _, _ = alpha_first, base_rgba, buf, colorspace, dst, has_alpha, mb_w, start_y, v1, v2, v5
   6225 	**(**uintptr)(__ccgo_up(bp)) = (*VP8Io)(unsafe.Pointer(io)).Fa
   6226 	if **(**uintptr)(__ccgo_up(bp)) != libc.UintptrFromInt32(0) {
   6227 		mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6228 		colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6229 		alpha_first = libc.BoolInt32(colorspace == int32(MODE_ARGB) || colorspace == int32(MODE_Argb))
   6230 		buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6231 		start_y = GetAlphaSourceRow(tls, io, bp, bp+8)
   6232 		base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(start_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6233 		if alpha_first != 0 {
   6234 			v1 = 0
   6235 		} else {
   6236 			v1 = int32(3)
   6237 		}
   6238 		dst = base_rgba + uintptr(v1)
   6239 		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)
   6240 		_ = expected_num_lines_out
   6241 		// has_alpha is true if there's non-trivial alpha to premultiply with.
   6242 		if v5 = has_alpha != 0; v5 {
   6243 			v2 = colorspace
   6244 			v1 = libc.BoolInt32(v2 == int32(MODE_rgbA) || v2 == int32(MODE_bgrA) || v2 == int32(MODE_Argb) || v2 == int32(MODE_rgbA_4444))
   6245 			goto _4
   6246 		_4:
   6247 		}
   6248 		if v5 && v1 != 0 {
   6249 			(*(*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)
   6250 		}
   6251 	}
   6252 	return 0
   6253 }
   6254 
   6255 func EmitAlphaRGBA4444(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6256 	bp := tls.Alloc(16)
   6257 	defer tls.Free(16)
   6258 	var alpha_dst, base_rgba, buf uintptr
   6259 	var alpha_mask, alpha_value uint32_t
   6260 	var colorspace, v3 WEBP_CSP_MODE1
   6261 	var i, j, mb_w, start_y, v4 int32
   6262 	var v6 bool
   6263 	var _ /* alpha at bp+0 */ uintptr
   6264 	var _ /* num_rows at bp+8 */ int32
   6265 	_, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_dst, alpha_mask, alpha_value, base_rgba, buf, colorspace, i, j, mb_w, start_y, v3, v4, v6
   6266 	**(**uintptr)(__ccgo_up(bp)) = (*VP8Io)(unsafe.Pointer(io)).Fa
   6267 	if **(**uintptr)(__ccgo_up(bp)) != libc.UintptrFromInt32(0) {
   6268 		mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6269 		colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6270 		buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6271 		start_y = GetAlphaSourceRow(tls, io, bp, bp+8)
   6272 		base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(start_y)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6273 		alpha_dst = base_rgba + uintptr(1)
   6274 		alpha_mask = uint32(0x0f)
   6275 		j = 0
   6276 		for {
   6277 			if !(j < **(**int32)(__ccgo_up(bp + 8))) {
   6278 				break
   6279 			}
   6280 			i = 0
   6281 			for {
   6282 				if !(i < mb_w) {
   6283 					break
   6284 				}
   6285 				// Fill in the alpha value (converted to 4 bits).
   6286 				alpha_value = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)))) >> int32(4))
   6287 				**(**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)
   6288 				alpha_mask = alpha_mask & alpha_value
   6289 				goto _2
   6290 			_2:
   6291 				;
   6292 				i = i + 1
   6293 			}
   6294 			**(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr((*VP8Io)(unsafe.Pointer(io)).Fwidth)
   6295 			alpha_dst = alpha_dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6296 			goto _1
   6297 		_1:
   6298 			;
   6299 			j = j + 1
   6300 		}
   6301 		_ = expected_num_lines_out
   6302 		if v6 = alpha_mask != uint32(0x0f); v6 {
   6303 			v3 = colorspace
   6304 			v4 = libc.BoolInt32(v3 == int32(MODE_rgbA) || v3 == int32(MODE_bgrA) || v3 == int32(MODE_Argb) || v3 == int32(MODE_rgbA_4444))
   6305 			goto _5
   6306 		_5:
   6307 		}
   6308 		if v6 && v4 != 0 {
   6309 			(*(*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)
   6310 		}
   6311 	}
   6312 	return 0
   6313 }
   6314 
   6315 //------------------------------------------------------------------------------
   6316 // YUV rescaling (no final RGB conversion needed)
   6317 
   6318 func Rescale(tls *libc.TLS, src uintptr, src_stride int32, new_lines int32, wrk uintptr) (r int32) {
   6319 	var lines_in, num_lines_out int32
   6320 	_, _ = lines_in, num_lines_out
   6321 	num_lines_out = 0
   6322 	for new_lines > 0 { // import new contributions of source rows.
   6323 		lines_in = WebPRescalerImport(tls, wrk, new_lines, src, src_stride)
   6324 		src = src + uintptr(lines_in*src_stride)
   6325 		new_lines = new_lines - lines_in
   6326 		num_lines_out = num_lines_out + WebPRescalerExport(tls, wrk) // emit output row(s)
   6327 	}
   6328 	return num_lines_out
   6329 }
   6330 
   6331 func EmitRescaledYUV(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6332 	var mb_h, num_lines_out, uv_mb_h, v2, v5 int32
   6333 	var scaler uintptr
   6334 	var v1, v4 WEBP_CSP_MODE1
   6335 	var v7 bool
   6336 	_, _, _, _, _, _, _, _, _ = mb_h, num_lines_out, scaler, uv_mb_h, v1, v2, v4, v5, v7
   6337 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6338 	uv_mb_h = (mb_h + int32(1)) >> int32(1)
   6339 	scaler = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y
   6340 	num_lines_out = 0
   6341 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6342 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6343 		v4 = v1
   6344 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6345 		goto _6
   6346 	_6:
   6347 	}
   6348 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6349 	goto _3
   6350 _3:
   6351 	;
   6352 	if v2 != 0 && (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6353 		// Before rescaling, we premultiply the luma directly into the io->y
   6354 		// internal buffer. This is OK since these samples are not used for
   6355 		// intra-prediction (the top samples are saved in cache_y/u/v).
   6356 		// But we need to cast the const away, though.
   6357 		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)
   6358 	}
   6359 	num_lines_out = Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fy, (*VP8Io)(unsafe.Pointer(io)).Fy_stride, mb_h, scaler)
   6360 	Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fu, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, uv_mb_h, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u)
   6361 	Rescale(tls, (*VP8Io)(unsafe.Pointer(io)).Fv, (*VP8Io)(unsafe.Pointer(io)).Fuv_stride, uv_mb_h, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v)
   6362 	return num_lines_out
   6363 }
   6364 
   6365 func EmitRescaledAlphaYUV(tls *libc.TLS, io uintptr, p uintptr, expected_num_lines_out int32) (r int32) {
   6366 	var buf, dst_a, dst_y uintptr
   6367 	var num_lines_out int32
   6368 	_, _, _, _ = buf, dst_a, dst_y, num_lines_out
   6369 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6370 	dst_a = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(int64((*WebPDecParams)(unsafe.Pointer(p)).Flast_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride))
   6371 	if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6372 		dst_y = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy + uintptr(int64((*WebPDecParams)(unsafe.Pointer(p)).Flast_y)*int64((*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride))
   6373 		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)
   6374 		if num_lines_out > 0 { // unmultiply the Y
   6375 			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))
   6376 		}
   6377 	} else {
   6378 		if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
   6379 			// the user requested alpha, but there is none, set it to opaque.
   6380 			FillAlphaPlane(tls, dst_a, (*VP8Io)(unsafe.Pointer(io)).Fscaled_width, expected_num_lines_out, (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
   6381 		}
   6382 	}
   6383 	return 0
   6384 }
   6385 
   6386 func InitYUVRescaler(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6387 	var buf, scalers, work, v12 uintptr
   6388 	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
   6389 	var rescaler_size, uv_work_size, work_size size_t
   6390 	var total_size, v9 uint64_t
   6391 	var v1, v4 WEBP_CSP_MODE1
   6392 	var v7 bool
   6393 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   6394 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6395 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6396 		v4 = v1
   6397 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6398 		goto _6
   6399 	_6:
   6400 	}
   6401 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6402 	goto _3
   6403 _3:
   6404 	has_alpha = v2
   6405 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6406 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
   6407 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
   6408 	uv_out_width = (out_width + int32(1)) >> int32(1)
   6409 	uv_out_height = (out_height + int32(1)) >> int32(1)
   6410 	uv_in_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6411 	uv_in_height = ((*VP8Io)(unsafe.Pointer(io)).Fmb_h + int32(1)) >> int32(1)
   6412 	// scratch memory for luma rescaler
   6413 	work_size = uint64(2) * libc.Uint64FromInt32(out_width)
   6414 	uv_work_size = libc.Uint64FromInt32(int32(2) * uv_out_width)
   6415 	if has_alpha != 0 {
   6416 		v8 = int32(4)
   6417 	} else {
   6418 		v8 = int32(3)
   6419 	}
   6420 	num_rescalers = v8
   6421 	total_size = (work_size + uint64(2)*uv_work_size) * uint64(4)
   6422 	if has_alpha != 0 {
   6423 		total_size = total_size + work_size*uint64(4)
   6424 	}
   6425 	rescaler_size = libc.Uint64FromInt32(num_rescalers)*uint64(104) + uint64(WEBP_ALIGN_CST)
   6426 	total_size = total_size + rescaler_size
   6427 	v9 = total_size
   6428 	v2 = libc.BoolInt32(v9 == v9)
   6429 	goto _11
   6430 _11:
   6431 	if !(v2 != 0) {
   6432 		return 0
   6433 	}
   6434 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), total_size)
   6435 	if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6436 		return 0 // memory error
   6437 	}
   6438 	work = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6439 	scalers = uintptr((uint64(work+uintptr(total_size)-uintptr(rescaler_size)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   6440 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y = scalers
   6441 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u = scalers + 1*104
   6442 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v = scalers + 2*104
   6443 	if has_alpha != 0 {
   6444 		v12 = scalers + 3*104
   6445 	} else {
   6446 		v12 = libc.UintptrFromInt32(0)
   6447 	}
   6448 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a = v12
   6449 	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) {
   6450 		return 0
   6451 	}
   6452 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitRescaledYUV)
   6453 	if has_alpha != 0 {
   6454 		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) {
   6455 			return 0
   6456 		}
   6457 		(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = __ccgo_fp(EmitRescaledAlphaYUV)
   6458 		WebPInitAlphaProcessing(tls)
   6459 	}
   6460 	return int32(1)
   6461 }
   6462 
   6463 //------------------------------------------------------------------------------
   6464 // RGBA rescaling
   6465 
   6466 func ExportRGB(tls *libc.TLS, p uintptr, y_pos int32) (r int32) {
   6467 	var buf, dst, v1, v10, v4, v7 uintptr
   6468 	var convert WebPYUV444Converter
   6469 	var num_lines_out, v11, v2, v5, v8 int32
   6470 	var v13 bool
   6471 	_, _, _, _, _, _, _, _, _, _, _, _, _ = buf, convert, dst, num_lines_out, v1, v10, v11, v13, v2, v4, v5, v7, v8
   6472 	convert = WebPYUV444Converters[(*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace]
   6473 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6474 	dst = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6475 	num_lines_out = 0
   6476 	// For RGB rescaling, because of the YUV420, current scan position
   6477 	// U/V can be +1/-1 line from the Y one.  Hence the double test.
   6478 	for {
   6479 		v1 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y
   6480 		v4 = v1
   6481 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
   6482 		goto _6
   6483 	_6:
   6484 		;
   6485 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
   6486 		goto _3
   6487 	_3:
   6488 		;
   6489 		if v13 = v2 != 0; v13 {
   6490 			v7 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u
   6491 			v10 = v7
   6492 			v11 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v10)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v10)).Fdst_height)
   6493 			goto _12
   6494 		_12:
   6495 			;
   6496 			v8 = libc.BoolInt32(!(v11 != 0) && (*WebPRescaler)(unsafe.Pointer(v7)).Fy_accum <= 0)
   6497 			goto _9
   6498 		_9:
   6499 		}
   6500 		if !(v13 && v8 != 0) {
   6501 			break
   6502 		}
   6503 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y)
   6504 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u)
   6505 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v)
   6506 		(*(*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)
   6507 		dst = dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6508 		num_lines_out = num_lines_out + 1
   6509 	}
   6510 	return num_lines_out
   6511 }
   6512 
   6513 func EmitRescaledRGB(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6514 	var j, mb_h, num_lines_out, u_lines_in, uv_j, uv_mb_h, v_lines_in, y_lines_in int32
   6515 	_, _, _, _, _, _, _, _ = j, mb_h, num_lines_out, u_lines_in, uv_j, uv_mb_h, v_lines_in, y_lines_in
   6516 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6517 	uv_mb_h = (mb_h + int32(1)) >> int32(1)
   6518 	j = 0
   6519 	uv_j = 0
   6520 	num_lines_out = 0
   6521 	for j < mb_h {
   6522 		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)
   6523 		j = j + y_lines_in
   6524 		if WebPRescaleNeededLines(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u, uv_mb_h-uv_j) != 0 {
   6525 			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)
   6526 			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)
   6527 			_ = v_lines_in // remove a gcc warning
   6528 			uv_j = uv_j + u_lines_in
   6529 		}
   6530 		num_lines_out = num_lines_out + ExportRGB(tls, p, (*WebPDecParams)(unsafe.Pointer(p)).Flast_y+num_lines_out)
   6531 	}
   6532 	return num_lines_out
   6533 }
   6534 
   6535 func ExportAlpha(tls *libc.TLS, p uintptr, y_pos int32, max_lines_out int32) (r int32) {
   6536 	var alpha_first, is_premult_alpha, num_lines_out, width, v1, v3, v6, v9 int32
   6537 	var base_rgba, buf, dst, v5, v8 uintptr
   6538 	var colorspace, v2 WEBP_CSP_MODE1
   6539 	var non_opaque uint32_t
   6540 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_first, base_rgba, buf, colorspace, dst, is_premult_alpha, non_opaque, num_lines_out, width, v1, v2, v3, v5, v6, v8, v9
   6541 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6542 	base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6543 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6544 	alpha_first = libc.BoolInt32(colorspace == int32(MODE_ARGB) || colorspace == int32(MODE_Argb))
   6545 	if alpha_first != 0 {
   6546 		v1 = 0
   6547 	} else {
   6548 		v1 = int32(3)
   6549 	}
   6550 	dst = base_rgba + uintptr(v1)
   6551 	num_lines_out = 0
   6552 	v2 = colorspace
   6553 	v3 = libc.BoolInt32(v2 == int32(MODE_rgbA) || v2 == int32(MODE_bgrA) || v2 == int32(MODE_Argb) || v2 == int32(MODE_rgbA_4444))
   6554 	goto _4
   6555 _4:
   6556 	is_premult_alpha = v3
   6557 	non_opaque = uint32(0)
   6558 	width = (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst_width
   6559 	for {
   6560 		v5 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6561 		v8 = v5
   6562 		v9 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v8)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v8)).Fdst_height)
   6563 		goto _10
   6564 	_10:
   6565 		;
   6566 		v6 = libc.BoolInt32(!(v9 != 0) && (*WebPRescaler)(unsafe.Pointer(v5)).Fy_accum <= 0)
   6567 		goto _7
   6568 	_7:
   6569 		;
   6570 		if !(v6 != 0 && num_lines_out < max_lines_out) {
   6571 			break
   6572 		}
   6573 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)
   6574 		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))
   6575 		dst = dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6576 		num_lines_out = num_lines_out + 1
   6577 	}
   6578 	if is_premult_alpha != 0 && non_opaque != 0 {
   6579 		(*(*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)
   6580 	}
   6581 	return num_lines_out
   6582 }
   6583 
   6584 func ExportAlphaRGBA4444(tls *libc.TLS, p uintptr, y_pos int32, max_lines_out int32) (r int32) {
   6585 	var alpha_dst, base_rgba, buf, v4, v7 uintptr
   6586 	var alpha_mask, alpha_value uint32_t
   6587 	var colorspace, v1 WEBP_CSP_MODE1
   6588 	var i, is_premult_alpha, num_lines_out, width, v2, v5, v8 int32
   6589 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_dst, alpha_mask, alpha_value, base_rgba, buf, colorspace, i, is_premult_alpha, num_lines_out, width, v1, v2, v4, v5, v7, v8
   6590 	buf = (*WebPDecParams)(unsafe.Pointer(p)).Foutput + 16
   6591 	base_rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64(y_pos)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
   6592 	alpha_dst = base_rgba + uintptr(1)
   6593 	num_lines_out = 0
   6594 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6595 	width = (*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst_width
   6596 	v1 = colorspace
   6597 	v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
   6598 	goto _3
   6599 _3:
   6600 	is_premult_alpha = v2
   6601 	alpha_mask = uint32(0x0f)
   6602 	for {
   6603 		v4 = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6604 		v7 = v4
   6605 		v8 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v7)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v7)).Fdst_height)
   6606 		goto _9
   6607 	_9:
   6608 		;
   6609 		v5 = libc.BoolInt32(!(v8 != 0) && (*WebPRescaler)(unsafe.Pointer(v4)).Fy_accum <= 0)
   6610 		goto _6
   6611 	_6:
   6612 		;
   6613 		if !(v5 != 0 && num_lines_out < max_lines_out) {
   6614 			break
   6615 		}
   6616 		WebPRescalerExportRow(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)
   6617 		i = 0
   6618 		for {
   6619 			if !(i < width) {
   6620 				break
   6621 			}
   6622 			// Fill in the alpha value (converted to 4 bits).
   6623 			alpha_value = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a)).Fdst + uintptr(i)))) >> int32(4))
   6624 			**(**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)
   6625 			alpha_mask = alpha_mask & alpha_value
   6626 			goto _10
   6627 		_10:
   6628 			;
   6629 			i = i + 1
   6630 		}
   6631 		alpha_dst = alpha_dst + uintptr((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6632 		num_lines_out = num_lines_out + 1
   6633 	}
   6634 	if is_premult_alpha != 0 && alpha_mask != uint32(0x0f) {
   6635 		(*(*func(*libc.TLS, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply4444})))(tls, base_rgba, width, num_lines_out, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
   6636 	}
   6637 	return num_lines_out
   6638 }
   6639 
   6640 func EmitRescaledAlphaRGB(tls *libc.TLS, io uintptr, p uintptr, expected_num_out_lines int32) (r int32) {
   6641 	var lines_left, y_end int32
   6642 	var row_offset int64_t
   6643 	var scaler uintptr
   6644 	_, _, _, _ = lines_left, row_offset, scaler, y_end
   6645 	if (*VP8Io)(unsafe.Pointer(io)).Fa != libc.UintptrFromInt32(0) {
   6646 		scaler = (*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a
   6647 		lines_left = expected_num_out_lines
   6648 		y_end = (*WebPDecParams)(unsafe.Pointer(p)).Flast_y + lines_left
   6649 		for lines_left > 0 {
   6650 			row_offset = int64((*WebPRescaler)(unsafe.Pointer(scaler)).Fsrc_y) - int64((*VP8Io)(unsafe.Pointer(io)).Fmb_y)
   6651 			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)
   6652 			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)
   6653 		}
   6654 	}
   6655 	return 0
   6656 }
   6657 
   6658 func InitRGBRescaler(tls *libc.TLS, io uintptr, p uintptr) (r int32) {
   6659 	var has_alpha, num_rescalers, out_height, out_width, uv_in_height, uv_in_width, v2, v5, v8 int32
   6660 	var rescaler_size, work_size size_t
   6661 	var scalers, tmp, work, v12 uintptr
   6662 	var tmp_size1, tmp_size2, total_size, v9 uint64_t
   6663 	var v1, v4 WEBP_CSP_MODE1
   6664 	var v7 bool
   6665 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   6666 	v1 = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6667 	if v7 = v1 == int32(MODE_RGBA) || v1 == int32(MODE_BGRA) || v1 == int32(MODE_ARGB) || v1 == int32(MODE_RGBA_4444) || v1 == int32(MODE_YUVA); !v7 {
   6668 		v4 = v1
   6669 		v5 = libc.BoolInt32(v4 == int32(MODE_rgbA) || v4 == int32(MODE_bgrA) || v4 == int32(MODE_Argb) || v4 == int32(MODE_rgbA_4444))
   6670 		goto _6
   6671 	_6:
   6672 	}
   6673 	v2 = libc.BoolInt32(v7 || v5 != 0)
   6674 	goto _3
   6675 _3:
   6676 	has_alpha = v2
   6677 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
   6678 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
   6679 	uv_in_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6680 	uv_in_height = ((*VP8Io)(unsafe.Pointer(io)).Fmb_h + int32(1)) >> int32(1)
   6681 	// scratch memory for one rescaler
   6682 	work_size = uint64(2) * libc.Uint64FromInt32(out_width)
   6683 	if has_alpha != 0 {
   6684 		v8 = int32(4)
   6685 	} else {
   6686 		v8 = int32(3)
   6687 	}
   6688 	num_rescalers = v8
   6689 	tmp_size1 = libc.Uint64FromInt32(num_rescalers) * work_size
   6690 	tmp_size2 = libc.Uint64FromInt32(num_rescalers) * libc.Uint64FromInt32(out_width)
   6691 	total_size = tmp_size1*uint64(4) + tmp_size2*uint64(1)
   6692 	rescaler_size = libc.Uint64FromInt32(num_rescalers)*uint64(104) + uint64(WEBP_ALIGN_CST)
   6693 	total_size = total_size + rescaler_size
   6694 	v9 = total_size
   6695 	v2 = libc.BoolInt32(v9 == v9)
   6696 	goto _11
   6697 _11:
   6698 	if !(v2 != 0) {
   6699 		return 0
   6700 	}
   6701 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), total_size)
   6702 	if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6703 		return 0 // memory error
   6704 	}
   6705 	work = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6706 	tmp = work + uintptr(tmp_size1)*4
   6707 	scalers = uintptr((uint64(work+uintptr(total_size)-uintptr(rescaler_size)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
   6708 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_y = scalers
   6709 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_u = scalers + 1*104
   6710 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_v = scalers + 2*104
   6711 	if has_alpha != 0 {
   6712 		v12 = scalers + 3*104
   6713 	} else {
   6714 		v12 = libc.UintptrFromInt32(0)
   6715 	}
   6716 	(*WebPDecParams)(unsafe.Pointer(p)).Fscaler_a = v12
   6717 	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) {
   6718 		return 0
   6719 	}
   6720 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitRescaledRGB)
   6721 	WebPInitYUV444Converters(tls)
   6722 	if has_alpha != 0 {
   6723 		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) {
   6724 			return 0
   6725 		}
   6726 		(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = __ccgo_fp(EmitRescaledAlphaRGB)
   6727 		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) {
   6728 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = __ccgo_fp(ExportAlphaRGBA4444)
   6729 		} else {
   6730 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = __ccgo_fp(ExportAlpha)
   6731 		}
   6732 		WebPInitAlphaProcessing(tls)
   6733 	}
   6734 	return int32(1)
   6735 }
   6736 
   6737 //------------------------------------------------------------------------------
   6738 // Default custom functions
   6739 
   6740 func CustomSetup(tls *libc.TLS, io uintptr) (r int32) {
   6741 	var colorspace, v3, v6 WEBP_CSP_MODE1
   6742 	var is_alpha, is_rgb, ok, uv_width, v1, v4, v7 int32
   6743 	var p, v16, v17 uintptr
   6744 	var v9 bool
   6745 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = colorspace, is_alpha, is_rgb, ok, p, uv_width, v1, v16, v17, v3, v4, v6, v7, v9
   6746 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6747 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(p)).Foutput)).Fcolorspace
   6748 	v1 = libc.BoolInt32(colorspace < int32(MODE_YUV))
   6749 	goto _2
   6750 _2:
   6751 	is_rgb = v1
   6752 	v3 = colorspace
   6753 	if v9 = v3 == int32(MODE_RGBA) || v3 == int32(MODE_BGRA) || v3 == int32(MODE_ARGB) || v3 == int32(MODE_RGBA_4444) || v3 == int32(MODE_YUVA); !v9 {
   6754 		v6 = v3
   6755 		v7 = libc.BoolInt32(v6 == int32(MODE_rgbA) || v6 == int32(MODE_bgrA) || v6 == int32(MODE_Argb) || v6 == int32(MODE_rgbA_4444))
   6756 		goto _8
   6757 	_8:
   6758 	}
   6759 	v4 = libc.BoolInt32(v9 || v7 != 0)
   6760 	goto _5
   6761 _5:
   6762 	is_alpha = v4
   6763 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = libc.UintptrFromInt32(0)
   6764 	(*WebPDecParams)(unsafe.Pointer(p)).Femit = libc.UintptrFromInt32(0)
   6765 	(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = libc.UintptrFromInt32(0)
   6766 	(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha_row = libc.UintptrFromInt32(0)
   6767 	if is_alpha != 0 {
   6768 		v1 = int32(MODE_YUV)
   6769 	} else {
   6770 		v1 = int32(MODE_YUVA)
   6771 	}
   6772 	if !(WebPIoInitFromOptions(tls, (*WebPDecParams)(unsafe.Pointer(p)).Foptions, io, v1) != 0) {
   6773 		return 0
   6774 	}
   6775 	if v9 = is_alpha != 0; v9 {
   6776 		v3 = colorspace
   6777 		v1 = libc.BoolInt32(v3 == int32(MODE_rgbA) || v3 == int32(MODE_bgrA) || v3 == int32(MODE_Argb) || v3 == int32(MODE_rgbA_4444))
   6778 		goto _13
   6779 	_13:
   6780 	}
   6781 	if v9 && v1 != 0 {
   6782 		WebPInitUpsamplers(tls)
   6783 	}
   6784 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
   6785 		if is_rgb != 0 {
   6786 			v1 = InitRGBRescaler(tls, io, p)
   6787 		} else {
   6788 			v1 = InitYUVRescaler(tls, io, p)
   6789 		}
   6790 		ok = v1
   6791 		if !(ok != 0) {
   6792 			return 0 // memory error
   6793 		}
   6794 	} else {
   6795 		if is_rgb != 0 {
   6796 			WebPInitSamplers(tls)
   6797 			(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitSampledRGB) // default
   6798 			if (*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling != 0 {
   6799 				uv_width = ((*VP8Io)(unsafe.Pointer(io)).Fmb_w + int32(1)) >> int32(1)
   6800 				(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = WebPSafeMalloc(tls, uint64(1), libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fmb_w+libc.Int32FromInt32(2)*uv_width))
   6801 				if (*WebPDecParams)(unsafe.Pointer(p)).Fmemory == libc.UintptrFromInt32(0) {
   6802 					return 0 // memory error.
   6803 				}
   6804 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y = (*WebPDecParams)(unsafe.Pointer(p)).Fmemory
   6805 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_y + uintptr((*VP8Io)(unsafe.Pointer(io)).Fmb_w)
   6806 				(*WebPDecParams)(unsafe.Pointer(p)).Ftmp_v = (*WebPDecParams)(unsafe.Pointer(p)).Ftmp_u + uintptr(uv_width)
   6807 				(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitFancyRGB)
   6808 				WebPInitUpsamplers(tls)
   6809 			}
   6810 		} else {
   6811 			(*WebPDecParams)(unsafe.Pointer(p)).Femit = __ccgo_fp(EmitYUV)
   6812 		}
   6813 		if is_alpha != 0 { // need transparency output
   6814 			if colorspace == int32(MODE_RGBA_4444) || colorspace == int32(MODE_rgbA_4444) {
   6815 				v16 = __ccgo_fp(EmitAlphaRGBA4444)
   6816 			} else {
   6817 				if is_rgb != 0 {
   6818 					v17 = __ccgo_fp(EmitAlphaRGB)
   6819 				} else {
   6820 					v17 = __ccgo_fp(EmitAlphaYUV)
   6821 				}
   6822 				v16 = v17
   6823 			}
   6824 			(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha = v16
   6825 			if is_rgb != 0 {
   6826 				WebPInitAlphaProcessing(tls)
   6827 			}
   6828 		}
   6829 	}
   6830 	return int32(1)
   6831 }
   6832 
   6833 //------------------------------------------------------------------------------
   6834 
   6835 func CustomPut(tls *libc.TLS, io uintptr) (r int32) {
   6836 	var mb_h, mb_w, num_lines_out int32
   6837 	var p uintptr
   6838 	_, _, _, _ = mb_h, mb_w, num_lines_out, p
   6839 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6840 	mb_w = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
   6841 	mb_h = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
   6842 	if mb_w <= 0 || mb_h <= 0 {
   6843 		return 0
   6844 	}
   6845 	num_lines_out = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPDecParams)(unsafe.Pointer(p)).Femit})))(tls, io, p)
   6846 	if (*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha != libc.UintptrFromInt32(0) {
   6847 		(*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPDecParams)(unsafe.Pointer(p)).Femit_alpha})))(tls, io, p, num_lines_out)
   6848 	}
   6849 	**(**int32)(__ccgo_up(p + 32)) += num_lines_out
   6850 	return int32(1)
   6851 }
   6852 
   6853 //------------------------------------------------------------------------------
   6854 
   6855 func CustomTeardown(tls *libc.TLS, io uintptr) {
   6856 	var p uintptr
   6857 	_ = p
   6858 	p = (*VP8Io)(unsafe.Pointer(io)).Fopaque
   6859 	WebPSafeFree(tls, (*WebPDecParams)(unsafe.Pointer(p)).Fmemory)
   6860 	(*WebPDecParams)(unsafe.Pointer(p)).Fmemory = libc.UintptrFromInt32(0)
   6861 }
   6862 
   6863 //------------------------------------------------------------------------------
   6864 // Main entry point
   6865 
   6866 func WebPInitCustomIo(tls *libc.TLS, params uintptr, io uintptr) {
   6867 	(*VP8Io)(unsafe.Pointer(io)).Fput = __ccgo_fp(CustomPut)
   6868 	(*VP8Io)(unsafe.Pointer(io)).Fsetup = __ccgo_fp(CustomSetup)
   6869 	(*VP8Io)(unsafe.Pointer(io)).Fteardown = __ccgo_fp(CustomTeardown)
   6870 	(*VP8Io)(unsafe.Pointer(io)).Fopaque = params
   6871 }
   6872 
   6873 var kHashMul5 = uint32(0x1e35a7bd)
   6874 
   6875 //------------------------------------------------------------------------------
   6876 
   6877 // Copyright 2010 Google Inc. All Rights Reserved.
   6878 //
   6879 // Use of this source code is governed by a BSD-style license
   6880 // that can be found in the COPYING file in the root of the source
   6881 // tree. An additional intellectual property rights grant can be found
   6882 // in the file PATENTS. All contributing project authors may
   6883 // be found in the AUTHORS file in the root of the source tree.
   6884 // -----------------------------------------------------------------------------
   6885 //
   6886 // Boolean decoder
   6887 //
   6888 // Author: Skal (pascal.massimino@gmail.com)
   6889 //         Vikas Arora (vikaas.arora@gmail.com)
   6890 
   6891 // Copyright 2010 Google Inc. All Rights Reserved.
   6892 //
   6893 // Use of this source code is governed by a BSD-style license
   6894 // that can be found in the COPYING file in the root of the source
   6895 // tree. An additional intellectual property rights grant can be found
   6896 // in the file PATENTS. All contributing project authors may
   6897 // be found in the AUTHORS file in the root of the source tree.
   6898 // -----------------------------------------------------------------------------
   6899 //
   6900 //  Common types + memory wrappers
   6901 //
   6902 // Author: Skal (pascal.massimino@gmail.com)
   6903 
   6904 func clip(tls *libc.TLS, v int32, M int32) (r int32) {
   6905 	var v1, v2 int32
   6906 	_, _ = v1, v2
   6907 	if v < 0 {
   6908 		v1 = 0
   6909 	} else {
   6910 		if v > M {
   6911 			v2 = M
   6912 		} else {
   6913 			v2 = v
   6914 		}
   6915 		v1 = v2
   6916 	}
   6917 	return v1
   6918 }
   6919 
   6920 // C documentation
   6921 //
   6922 //	// Paragraph 14.1
   6923 var kDcTable = [128]uint8_t{
   6924 	0:   uint8(4),
   6925 	1:   uint8(5),
   6926 	2:   uint8(6),
   6927 	3:   uint8(7),
   6928 	4:   uint8(8),
   6929 	5:   uint8(9),
   6930 	6:   uint8(10),
   6931 	7:   uint8(10),
   6932 	8:   uint8(11),
   6933 	9:   uint8(12),
   6934 	10:  uint8(13),
   6935 	11:  uint8(14),
   6936 	12:  uint8(15),
   6937 	13:  uint8(16),
   6938 	14:  uint8(17),
   6939 	15:  uint8(17),
   6940 	16:  uint8(18),
   6941 	17:  uint8(19),
   6942 	18:  uint8(20),
   6943 	19:  uint8(20),
   6944 	20:  uint8(21),
   6945 	21:  uint8(21),
   6946 	22:  uint8(22),
   6947 	23:  uint8(22),
   6948 	24:  uint8(23),
   6949 	25:  uint8(23),
   6950 	26:  uint8(24),
   6951 	27:  uint8(25),
   6952 	28:  uint8(25),
   6953 	29:  uint8(26),
   6954 	30:  uint8(27),
   6955 	31:  uint8(28),
   6956 	32:  uint8(29),
   6957 	33:  uint8(30),
   6958 	34:  uint8(31),
   6959 	35:  uint8(32),
   6960 	36:  uint8(33),
   6961 	37:  uint8(34),
   6962 	38:  uint8(35),
   6963 	39:  uint8(36),
   6964 	40:  uint8(37),
   6965 	41:  uint8(37),
   6966 	42:  uint8(38),
   6967 	43:  uint8(39),
   6968 	44:  uint8(40),
   6969 	45:  uint8(41),
   6970 	46:  uint8(42),
   6971 	47:  uint8(43),
   6972 	48:  uint8(44),
   6973 	49:  uint8(45),
   6974 	50:  uint8(46),
   6975 	51:  uint8(46),
   6976 	52:  uint8(47),
   6977 	53:  uint8(48),
   6978 	54:  uint8(49),
   6979 	55:  uint8(50),
   6980 	56:  uint8(51),
   6981 	57:  uint8(52),
   6982 	58:  uint8(53),
   6983 	59:  uint8(54),
   6984 	60:  uint8(55),
   6985 	61:  uint8(56),
   6986 	62:  uint8(57),
   6987 	63:  uint8(58),
   6988 	64:  uint8(59),
   6989 	65:  uint8(60),
   6990 	66:  uint8(61),
   6991 	67:  uint8(62),
   6992 	68:  uint8(63),
   6993 	69:  uint8(64),
   6994 	70:  uint8(65),
   6995 	71:  uint8(66),
   6996 	72:  uint8(67),
   6997 	73:  uint8(68),
   6998 	74:  uint8(69),
   6999 	75:  uint8(70),
   7000 	76:  uint8(71),
   7001 	77:  uint8(72),
   7002 	78:  uint8(73),
   7003 	79:  uint8(74),
   7004 	80:  uint8(75),
   7005 	81:  uint8(76),
   7006 	82:  uint8(76),
   7007 	83:  uint8(77),
   7008 	84:  uint8(78),
   7009 	85:  uint8(79),
   7010 	86:  uint8(80),
   7011 	87:  uint8(81),
   7012 	88:  uint8(82),
   7013 	89:  uint8(83),
   7014 	90:  uint8(84),
   7015 	91:  uint8(85),
   7016 	92:  uint8(86),
   7017 	93:  uint8(87),
   7018 	94:  uint8(88),
   7019 	95:  uint8(89),
   7020 	96:  uint8(91),
   7021 	97:  uint8(93),
   7022 	98:  uint8(95),
   7023 	99:  uint8(96),
   7024 	100: uint8(98),
   7025 	101: uint8(100),
   7026 	102: uint8(101),
   7027 	103: uint8(102),
   7028 	104: uint8(104),
   7029 	105: uint8(106),
   7030 	106: uint8(108),
   7031 	107: uint8(110),
   7032 	108: uint8(112),
   7033 	109: uint8(114),
   7034 	110: uint8(116),
   7035 	111: uint8(118),
   7036 	112: uint8(122),
   7037 	113: uint8(124),
   7038 	114: uint8(126),
   7039 	115: uint8(128),
   7040 	116: uint8(130),
   7041 	117: uint8(132),
   7042 	118: uint8(134),
   7043 	119: uint8(136),
   7044 	120: uint8(138),
   7045 	121: uint8(140),
   7046 	122: uint8(143),
   7047 	123: uint8(145),
   7048 	124: uint8(148),
   7049 	125: uint8(151),
   7050 	126: uint8(154),
   7051 	127: uint8(157),
   7052 }
   7053 
   7054 var kAcTable = [128]uint16_t{
   7055 	0:   uint16(4),
   7056 	1:   uint16(5),
   7057 	2:   uint16(6),
   7058 	3:   uint16(7),
   7059 	4:   uint16(8),
   7060 	5:   uint16(9),
   7061 	6:   uint16(10),
   7062 	7:   uint16(11),
   7063 	8:   uint16(12),
   7064 	9:   uint16(13),
   7065 	10:  uint16(14),
   7066 	11:  uint16(15),
   7067 	12:  uint16(16),
   7068 	13:  uint16(17),
   7069 	14:  uint16(18),
   7070 	15:  uint16(19),
   7071 	16:  uint16(20),
   7072 	17:  uint16(21),
   7073 	18:  uint16(22),
   7074 	19:  uint16(23),
   7075 	20:  uint16(24),
   7076 	21:  uint16(25),
   7077 	22:  uint16(26),
   7078 	23:  uint16(27),
   7079 	24:  uint16(28),
   7080 	25:  uint16(29),
   7081 	26:  uint16(30),
   7082 	27:  uint16(31),
   7083 	28:  uint16(32),
   7084 	29:  uint16(33),
   7085 	30:  uint16(34),
   7086 	31:  uint16(35),
   7087 	32:  uint16(36),
   7088 	33:  uint16(37),
   7089 	34:  uint16(38),
   7090 	35:  uint16(39),
   7091 	36:  uint16(40),
   7092 	37:  uint16(41),
   7093 	38:  uint16(42),
   7094 	39:  uint16(43),
   7095 	40:  uint16(44),
   7096 	41:  uint16(45),
   7097 	42:  uint16(46),
   7098 	43:  uint16(47),
   7099 	44:  uint16(48),
   7100 	45:  uint16(49),
   7101 	46:  uint16(50),
   7102 	47:  uint16(51),
   7103 	48:  uint16(52),
   7104 	49:  uint16(53),
   7105 	50:  uint16(54),
   7106 	51:  uint16(55),
   7107 	52:  uint16(56),
   7108 	53:  uint16(57),
   7109 	54:  uint16(58),
   7110 	55:  uint16(60),
   7111 	56:  uint16(62),
   7112 	57:  uint16(64),
   7113 	58:  uint16(66),
   7114 	59:  uint16(68),
   7115 	60:  uint16(70),
   7116 	61:  uint16(72),
   7117 	62:  uint16(74),
   7118 	63:  uint16(76),
   7119 	64:  uint16(78),
   7120 	65:  uint16(80),
   7121 	66:  uint16(82),
   7122 	67:  uint16(84),
   7123 	68:  uint16(86),
   7124 	69:  uint16(88),
   7125 	70:  uint16(90),
   7126 	71:  uint16(92),
   7127 	72:  uint16(94),
   7128 	73:  uint16(96),
   7129 	74:  uint16(98),
   7130 	75:  uint16(100),
   7131 	76:  uint16(102),
   7132 	77:  uint16(104),
   7133 	78:  uint16(106),
   7134 	79:  uint16(108),
   7135 	80:  uint16(110),
   7136 	81:  uint16(112),
   7137 	82:  uint16(114),
   7138 	83:  uint16(116),
   7139 	84:  uint16(119),
   7140 	85:  uint16(122),
   7141 	86:  uint16(125),
   7142 	87:  uint16(128),
   7143 	88:  uint16(131),
   7144 	89:  uint16(134),
   7145 	90:  uint16(137),
   7146 	91:  uint16(140),
   7147 	92:  uint16(143),
   7148 	93:  uint16(146),
   7149 	94:  uint16(149),
   7150 	95:  uint16(152),
   7151 	96:  uint16(155),
   7152 	97:  uint16(158),
   7153 	98:  uint16(161),
   7154 	99:  uint16(164),
   7155 	100: uint16(167),
   7156 	101: uint16(170),
   7157 	102: uint16(173),
   7158 	103: uint16(177),
   7159 	104: uint16(181),
   7160 	105: uint16(185),
   7161 	106: uint16(189),
   7162 	107: uint16(193),
   7163 	108: uint16(197),
   7164 	109: uint16(201),
   7165 	110: uint16(205),
   7166 	111: uint16(209),
   7167 	112: uint16(213),
   7168 	113: uint16(217),
   7169 	114: uint16(221),
   7170 	115: uint16(225),
   7171 	116: uint16(229),
   7172 	117: uint16(234),
   7173 	118: uint16(239),
   7174 	119: uint16(245),
   7175 	120: uint16(249),
   7176 	121: uint16(254),
   7177 	122: uint16(259),
   7178 	123: uint16(264),
   7179 	124: uint16(269),
   7180 	125: uint16(274),
   7181 	126: uint16(279),
   7182 	127: uint16(284),
   7183 }
   7184 
   7185 //------------------------------------------------------------------------------
   7186 // Paragraph 9.6
   7187 
   7188 func VP8ParseQuant(tls *libc.TLS, dec uintptr) {
   7189 	var base_q0, dquv_ac, dquv_dc, dqy1_dc, dqy2_ac, dqy2_dc, i, q, v1, v2, v3, v4, v5 int32
   7190 	var br, hdr, m uintptr
   7191 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base_q0, br, dquv_ac, dquv_dc, dqy1_dc, dqy2_ac, dqy2_dc, hdr, i, m, q, v1, v2, v3, v4, v5
   7192 	br = dec + 16
   7193 	base_q0 = libc.Int32FromUint32(VP8GetValue(tls, br, int32(7)))
   7194 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7195 		v1 = VP8GetSignedValue(tls, br, int32(4))
   7196 	} else {
   7197 		v1 = 0
   7198 	}
   7199 	dqy1_dc = v1
   7200 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7201 		v2 = VP8GetSignedValue(tls, br, int32(4))
   7202 	} else {
   7203 		v2 = 0
   7204 	}
   7205 	dqy2_dc = v2
   7206 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7207 		v3 = VP8GetSignedValue(tls, br, int32(4))
   7208 	} else {
   7209 		v3 = 0
   7210 	}
   7211 	dqy2_ac = v3
   7212 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7213 		v4 = VP8GetSignedValue(tls, br, int32(4))
   7214 	} else {
   7215 		v4 = 0
   7216 	}
   7217 	dquv_dc = v4
   7218 	if VP8GetValue(tls, br, int32(1)) != 0 {
   7219 		v5 = VP8GetSignedValue(tls, br, int32(4))
   7220 	} else {
   7221 		v5 = 0
   7222 	}
   7223 	dquv_ac = v5
   7224 	hdr = dec + 132
   7225 	i = 0
   7226 	for {
   7227 		if !(i < int32(NUM_MB_SEGMENTS)) {
   7228 			break
   7229 		}
   7230 		if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment != 0 {
   7231 			q = int32(**(**int8_t)(__ccgo_up(hdr + 12 + uintptr(i))))
   7232 			if !((*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta != 0) {
   7233 				q = q + base_q0
   7234 			}
   7235 		} else {
   7236 			if i > 0 {
   7237 				**(**VP8QuantMatrix)(__ccgo_up(dec + 1060 + uintptr(i)*32)) = **(**VP8QuantMatrix)(__ccgo_up(dec + 1060))
   7238 				goto _6
   7239 			} else {
   7240 				q = base_q0
   7241 			}
   7242 		}
   7243 		m = dec + 1060 + uintptr(i)*32
   7244 		**(**int32)(__ccgo_up(m)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dqy1_dc, int32(127))])
   7245 		**(**int32)(__ccgo_up(m + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+0, int32(127))])
   7246 		**(**int32)(__ccgo_up(m + 8)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dqy2_dc, int32(127))]) * int32(2)
   7247 		// For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
   7248 		// The smallest precision for that is '(x*6349) >> 12' but 16 is a good
   7249 		// word size.
   7250 		**(**int32)(__ccgo_up(m + 8 + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+dqy2_ac, int32(127))]) * int32(101581) >> int32(16)
   7251 		if **(**int32)(__ccgo_up(m + 8 + 1*4)) < int32(8) {
   7252 			**(**int32)(__ccgo_up(m + 8 + 1*4)) = int32(8)
   7253 		}
   7254 		**(**int32)(__ccgo_up(m + 16)) = libc.Int32FromUint8(kDcTable[clip(tls, q+dquv_dc, int32(117))])
   7255 		**(**int32)(__ccgo_up(m + 16 + 1*4)) = libc.Int32FromUint16(kAcTable[clip(tls, q+dquv_ac, int32(127))])
   7256 		(*VP8QuantMatrix)(unsafe.Pointer(m)).Fuv_quant = q + dquv_ac // for dithering strength evaluation
   7257 		goto _6
   7258 	_6:
   7259 		;
   7260 		i = i + 1
   7261 	}
   7262 }
   7263 
   7264 const USE_GENERIC_TREE = 1
   7265 
   7266 var kHashMul6 = uint32(0x1e35a7bd)
   7267 
   7268 type lbit_t = uint64
   7269 
   7270 // Copyright 2010 Google Inc. All Rights Reserved.
   7271 //
   7272 // Use of this source code is governed by a BSD-style license
   7273 // that can be found in the COPYING file in the root of the source
   7274 // tree. An additional intellectual property rights grant can be found
   7275 // in the file PATENTS. All contributing project authors may
   7276 // be found in the AUTHORS file in the root of the source tree.
   7277 // -----------------------------------------------------------------------------
   7278 //
   7279 // Boolean decoder
   7280 //
   7281 // Author: Skal (pascal.massimino@gmail.com)
   7282 //         Vikas Arora (vikaas.arora@gmail.com)
   7283 
   7284 // using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
   7285 
   7286 var kYModesIntra4 = [18]int8_t{
   7287 	1:  int8(1),
   7288 	2:  int8(-int32(B_TM_PRED)),
   7289 	3:  int8(2),
   7290 	4:  int8(-int32(B_VE_PRED)),
   7291 	5:  int8(3),
   7292 	6:  int8(4),
   7293 	7:  int8(6),
   7294 	8:  int8(-int32(B_HE_PRED)),
   7295 	9:  int8(5),
   7296 	10: int8(-int32(B_RD_PRED)),
   7297 	11: int8(-int32(B_VR_PRED)),
   7298 	12: int8(-int32(B_LD_PRED)),
   7299 	13: int8(7),
   7300 	14: int8(-int32(B_VL_PRED)),
   7301 	15: int8(8),
   7302 	16: int8(-int32(B_HD_PRED)),
   7303 	17: int8(-int32(B_HU_PRED)),
   7304 }
   7305 
   7306 //------------------------------------------------------------------------------
   7307 // Default probabilities
   7308 
   7309 // C documentation
   7310 //
   7311 //	// Paragraph 13.5
   7312 
   7313 var CoeffsProba0 = [4][8][3][11]uint8_t{
   7314 	0: {
   7315 		0: {
   7316 			0: {
   7317 				0:  uint8(128),
   7318 				1:  uint8(128),
   7319 				2:  uint8(128),
   7320 				3:  uint8(128),
   7321 				4:  uint8(128),
   7322 				5:  uint8(128),
   7323 				6:  uint8(128),
   7324 				7:  uint8(128),
   7325 				8:  uint8(128),
   7326 				9:  uint8(128),
   7327 				10: uint8(128),
   7328 			},
   7329 			1: {
   7330 				0:  uint8(128),
   7331 				1:  uint8(128),
   7332 				2:  uint8(128),
   7333 				3:  uint8(128),
   7334 				4:  uint8(128),
   7335 				5:  uint8(128),
   7336 				6:  uint8(128),
   7337 				7:  uint8(128),
   7338 				8:  uint8(128),
   7339 				9:  uint8(128),
   7340 				10: uint8(128),
   7341 			},
   7342 			2: {
   7343 				0:  uint8(128),
   7344 				1:  uint8(128),
   7345 				2:  uint8(128),
   7346 				3:  uint8(128),
   7347 				4:  uint8(128),
   7348 				5:  uint8(128),
   7349 				6:  uint8(128),
   7350 				7:  uint8(128),
   7351 				8:  uint8(128),
   7352 				9:  uint8(128),
   7353 				10: uint8(128),
   7354 			},
   7355 		},
   7356 		1: {
   7357 			0: {
   7358 				0:  uint8(253),
   7359 				1:  uint8(136),
   7360 				2:  uint8(254),
   7361 				3:  uint8(255),
   7362 				4:  uint8(228),
   7363 				5:  uint8(219),
   7364 				6:  uint8(128),
   7365 				7:  uint8(128),
   7366 				8:  uint8(128),
   7367 				9:  uint8(128),
   7368 				10: uint8(128),
   7369 			},
   7370 			1: {
   7371 				0:  uint8(189),
   7372 				1:  uint8(129),
   7373 				2:  uint8(242),
   7374 				3:  uint8(255),
   7375 				4:  uint8(227),
   7376 				5:  uint8(213),
   7377 				6:  uint8(255),
   7378 				7:  uint8(219),
   7379 				8:  uint8(128),
   7380 				9:  uint8(128),
   7381 				10: uint8(128),
   7382 			},
   7383 			2: {
   7384 				0:  uint8(106),
   7385 				1:  uint8(126),
   7386 				2:  uint8(227),
   7387 				3:  uint8(252),
   7388 				4:  uint8(214),
   7389 				5:  uint8(209),
   7390 				6:  uint8(255),
   7391 				7:  uint8(255),
   7392 				8:  uint8(128),
   7393 				9:  uint8(128),
   7394 				10: uint8(128),
   7395 			},
   7396 		},
   7397 		2: {
   7398 			0: {
   7399 				0:  uint8(1),
   7400 				1:  uint8(98),
   7401 				2:  uint8(248),
   7402 				3:  uint8(255),
   7403 				4:  uint8(236),
   7404 				5:  uint8(226),
   7405 				6:  uint8(255),
   7406 				7:  uint8(255),
   7407 				8:  uint8(128),
   7408 				9:  uint8(128),
   7409 				10: uint8(128),
   7410 			},
   7411 			1: {
   7412 				0:  uint8(181),
   7413 				1:  uint8(133),
   7414 				2:  uint8(238),
   7415 				3:  uint8(254),
   7416 				4:  uint8(221),
   7417 				5:  uint8(234),
   7418 				6:  uint8(255),
   7419 				7:  uint8(154),
   7420 				8:  uint8(128),
   7421 				9:  uint8(128),
   7422 				10: uint8(128),
   7423 			},
   7424 			2: {
   7425 				0:  uint8(78),
   7426 				1:  uint8(134),
   7427 				2:  uint8(202),
   7428 				3:  uint8(247),
   7429 				4:  uint8(198),
   7430 				5:  uint8(180),
   7431 				6:  uint8(255),
   7432 				7:  uint8(219),
   7433 				8:  uint8(128),
   7434 				9:  uint8(128),
   7435 				10: uint8(128),
   7436 			},
   7437 		},
   7438 		3: {
   7439 			0: {
   7440 				0:  uint8(1),
   7441 				1:  uint8(185),
   7442 				2:  uint8(249),
   7443 				3:  uint8(255),
   7444 				4:  uint8(243),
   7445 				5:  uint8(255),
   7446 				6:  uint8(128),
   7447 				7:  uint8(128),
   7448 				8:  uint8(128),
   7449 				9:  uint8(128),
   7450 				10: uint8(128),
   7451 			},
   7452 			1: {
   7453 				0:  uint8(184),
   7454 				1:  uint8(150),
   7455 				2:  uint8(247),
   7456 				3:  uint8(255),
   7457 				4:  uint8(236),
   7458 				5:  uint8(224),
   7459 				6:  uint8(128),
   7460 				7:  uint8(128),
   7461 				8:  uint8(128),
   7462 				9:  uint8(128),
   7463 				10: uint8(128),
   7464 			},
   7465 			2: {
   7466 				0:  uint8(77),
   7467 				1:  uint8(110),
   7468 				2:  uint8(216),
   7469 				3:  uint8(255),
   7470 				4:  uint8(236),
   7471 				5:  uint8(230),
   7472 				6:  uint8(128),
   7473 				7:  uint8(128),
   7474 				8:  uint8(128),
   7475 				9:  uint8(128),
   7476 				10: uint8(128),
   7477 			},
   7478 		},
   7479 		4: {
   7480 			0: {
   7481 				0:  uint8(1),
   7482 				1:  uint8(101),
   7483 				2:  uint8(251),
   7484 				3:  uint8(255),
   7485 				4:  uint8(241),
   7486 				5:  uint8(255),
   7487 				6:  uint8(128),
   7488 				7:  uint8(128),
   7489 				8:  uint8(128),
   7490 				9:  uint8(128),
   7491 				10: uint8(128),
   7492 			},
   7493 			1: {
   7494 				0:  uint8(170),
   7495 				1:  uint8(139),
   7496 				2:  uint8(241),
   7497 				3:  uint8(252),
   7498 				4:  uint8(236),
   7499 				5:  uint8(209),
   7500 				6:  uint8(255),
   7501 				7:  uint8(255),
   7502 				8:  uint8(128),
   7503 				9:  uint8(128),
   7504 				10: uint8(128),
   7505 			},
   7506 			2: {
   7507 				0:  uint8(37),
   7508 				1:  uint8(116),
   7509 				2:  uint8(196),
   7510 				3:  uint8(243),
   7511 				4:  uint8(228),
   7512 				5:  uint8(255),
   7513 				6:  uint8(255),
   7514 				7:  uint8(255),
   7515 				8:  uint8(128),
   7516 				9:  uint8(128),
   7517 				10: uint8(128),
   7518 			},
   7519 		},
   7520 		5: {
   7521 			0: {
   7522 				0:  uint8(1),
   7523 				1:  uint8(204),
   7524 				2:  uint8(254),
   7525 				3:  uint8(255),
   7526 				4:  uint8(245),
   7527 				5:  uint8(255),
   7528 				6:  uint8(128),
   7529 				7:  uint8(128),
   7530 				8:  uint8(128),
   7531 				9:  uint8(128),
   7532 				10: uint8(128),
   7533 			},
   7534 			1: {
   7535 				0:  uint8(207),
   7536 				1:  uint8(160),
   7537 				2:  uint8(250),
   7538 				3:  uint8(255),
   7539 				4:  uint8(238),
   7540 				5:  uint8(128),
   7541 				6:  uint8(128),
   7542 				7:  uint8(128),
   7543 				8:  uint8(128),
   7544 				9:  uint8(128),
   7545 				10: uint8(128),
   7546 			},
   7547 			2: {
   7548 				0:  uint8(102),
   7549 				1:  uint8(103),
   7550 				2:  uint8(231),
   7551 				3:  uint8(255),
   7552 				4:  uint8(211),
   7553 				5:  uint8(171),
   7554 				6:  uint8(128),
   7555 				7:  uint8(128),
   7556 				8:  uint8(128),
   7557 				9:  uint8(128),
   7558 				10: uint8(128),
   7559 			},
   7560 		},
   7561 		6: {
   7562 			0: {
   7563 				0:  uint8(1),
   7564 				1:  uint8(152),
   7565 				2:  uint8(252),
   7566 				3:  uint8(255),
   7567 				4:  uint8(240),
   7568 				5:  uint8(255),
   7569 				6:  uint8(128),
   7570 				7:  uint8(128),
   7571 				8:  uint8(128),
   7572 				9:  uint8(128),
   7573 				10: uint8(128),
   7574 			},
   7575 			1: {
   7576 				0:  uint8(177),
   7577 				1:  uint8(135),
   7578 				2:  uint8(243),
   7579 				3:  uint8(255),
   7580 				4:  uint8(234),
   7581 				5:  uint8(225),
   7582 				6:  uint8(128),
   7583 				7:  uint8(128),
   7584 				8:  uint8(128),
   7585 				9:  uint8(128),
   7586 				10: uint8(128),
   7587 			},
   7588 			2: {
   7589 				0:  uint8(80),
   7590 				1:  uint8(129),
   7591 				2:  uint8(211),
   7592 				3:  uint8(255),
   7593 				4:  uint8(194),
   7594 				5:  uint8(224),
   7595 				6:  uint8(128),
   7596 				7:  uint8(128),
   7597 				8:  uint8(128),
   7598 				9:  uint8(128),
   7599 				10: uint8(128),
   7600 			},
   7601 		},
   7602 		7: {
   7603 			0: {
   7604 				0:  uint8(1),
   7605 				1:  uint8(1),
   7606 				2:  uint8(255),
   7607 				3:  uint8(128),
   7608 				4:  uint8(128),
   7609 				5:  uint8(128),
   7610 				6:  uint8(128),
   7611 				7:  uint8(128),
   7612 				8:  uint8(128),
   7613 				9:  uint8(128),
   7614 				10: uint8(128),
   7615 			},
   7616 			1: {
   7617 				0:  uint8(246),
   7618 				1:  uint8(1),
   7619 				2:  uint8(255),
   7620 				3:  uint8(128),
   7621 				4:  uint8(128),
   7622 				5:  uint8(128),
   7623 				6:  uint8(128),
   7624 				7:  uint8(128),
   7625 				8:  uint8(128),
   7626 				9:  uint8(128),
   7627 				10: uint8(128),
   7628 			},
   7629 			2: {
   7630 				0:  uint8(255),
   7631 				1:  uint8(128),
   7632 				2:  uint8(128),
   7633 				3:  uint8(128),
   7634 				4:  uint8(128),
   7635 				5:  uint8(128),
   7636 				6:  uint8(128),
   7637 				7:  uint8(128),
   7638 				8:  uint8(128),
   7639 				9:  uint8(128),
   7640 				10: uint8(128),
   7641 			},
   7642 		},
   7643 	},
   7644 	1: {
   7645 		0: {
   7646 			0: {
   7647 				0:  uint8(198),
   7648 				1:  uint8(35),
   7649 				2:  uint8(237),
   7650 				3:  uint8(223),
   7651 				4:  uint8(193),
   7652 				5:  uint8(187),
   7653 				6:  uint8(162),
   7654 				7:  uint8(160),
   7655 				8:  uint8(145),
   7656 				9:  uint8(155),
   7657 				10: uint8(62),
   7658 			},
   7659 			1: {
   7660 				0:  uint8(131),
   7661 				1:  uint8(45),
   7662 				2:  uint8(198),
   7663 				3:  uint8(221),
   7664 				4:  uint8(172),
   7665 				5:  uint8(176),
   7666 				6:  uint8(220),
   7667 				7:  uint8(157),
   7668 				8:  uint8(252),
   7669 				9:  uint8(221),
   7670 				10: uint8(1),
   7671 			},
   7672 			2: {
   7673 				0:  uint8(68),
   7674 				1:  uint8(47),
   7675 				2:  uint8(146),
   7676 				3:  uint8(208),
   7677 				4:  uint8(149),
   7678 				5:  uint8(167),
   7679 				6:  uint8(221),
   7680 				7:  uint8(162),
   7681 				8:  uint8(255),
   7682 				9:  uint8(223),
   7683 				10: uint8(128),
   7684 			},
   7685 		},
   7686 		1: {
   7687 			0: {
   7688 				0:  uint8(1),
   7689 				1:  uint8(149),
   7690 				2:  uint8(241),
   7691 				3:  uint8(255),
   7692 				4:  uint8(221),
   7693 				5:  uint8(224),
   7694 				6:  uint8(255),
   7695 				7:  uint8(255),
   7696 				8:  uint8(128),
   7697 				9:  uint8(128),
   7698 				10: uint8(128),
   7699 			},
   7700 			1: {
   7701 				0:  uint8(184),
   7702 				1:  uint8(141),
   7703 				2:  uint8(234),
   7704 				3:  uint8(253),
   7705 				4:  uint8(222),
   7706 				5:  uint8(220),
   7707 				6:  uint8(255),
   7708 				7:  uint8(199),
   7709 				8:  uint8(128),
   7710 				9:  uint8(128),
   7711 				10: uint8(128),
   7712 			},
   7713 			2: {
   7714 				0:  uint8(81),
   7715 				1:  uint8(99),
   7716 				2:  uint8(181),
   7717 				3:  uint8(242),
   7718 				4:  uint8(176),
   7719 				5:  uint8(190),
   7720 				6:  uint8(249),
   7721 				7:  uint8(202),
   7722 				8:  uint8(255),
   7723 				9:  uint8(255),
   7724 				10: uint8(128),
   7725 			},
   7726 		},
   7727 		2: {
   7728 			0: {
   7729 				0:  uint8(1),
   7730 				1:  uint8(129),
   7731 				2:  uint8(232),
   7732 				3:  uint8(253),
   7733 				4:  uint8(214),
   7734 				5:  uint8(197),
   7735 				6:  uint8(242),
   7736 				7:  uint8(196),
   7737 				8:  uint8(255),
   7738 				9:  uint8(255),
   7739 				10: uint8(128),
   7740 			},
   7741 			1: {
   7742 				0:  uint8(99),
   7743 				1:  uint8(121),
   7744 				2:  uint8(210),
   7745 				3:  uint8(250),
   7746 				4:  uint8(201),
   7747 				5:  uint8(198),
   7748 				6:  uint8(255),
   7749 				7:  uint8(202),
   7750 				8:  uint8(128),
   7751 				9:  uint8(128),
   7752 				10: uint8(128),
   7753 			},
   7754 			2: {
   7755 				0:  uint8(23),
   7756 				1:  uint8(91),
   7757 				2:  uint8(163),
   7758 				3:  uint8(242),
   7759 				4:  uint8(170),
   7760 				5:  uint8(187),
   7761 				6:  uint8(247),
   7762 				7:  uint8(210),
   7763 				8:  uint8(255),
   7764 				9:  uint8(255),
   7765 				10: uint8(128),
   7766 			},
   7767 		},
   7768 		3: {
   7769 			0: {
   7770 				0:  uint8(1),
   7771 				1:  uint8(200),
   7772 				2:  uint8(246),
   7773 				3:  uint8(255),
   7774 				4:  uint8(234),
   7775 				5:  uint8(255),
   7776 				6:  uint8(128),
   7777 				7:  uint8(128),
   7778 				8:  uint8(128),
   7779 				9:  uint8(128),
   7780 				10: uint8(128),
   7781 			},
   7782 			1: {
   7783 				0:  uint8(109),
   7784 				1:  uint8(178),
   7785 				2:  uint8(241),
   7786 				3:  uint8(255),
   7787 				4:  uint8(231),
   7788 				5:  uint8(245),
   7789 				6:  uint8(255),
   7790 				7:  uint8(255),
   7791 				8:  uint8(128),
   7792 				9:  uint8(128),
   7793 				10: uint8(128),
   7794 			},
   7795 			2: {
   7796 				0:  uint8(44),
   7797 				1:  uint8(130),
   7798 				2:  uint8(201),
   7799 				3:  uint8(253),
   7800 				4:  uint8(205),
   7801 				5:  uint8(192),
   7802 				6:  uint8(255),
   7803 				7:  uint8(255),
   7804 				8:  uint8(128),
   7805 				9:  uint8(128),
   7806 				10: uint8(128),
   7807 			},
   7808 		},
   7809 		4: {
   7810 			0: {
   7811 				0:  uint8(1),
   7812 				1:  uint8(132),
   7813 				2:  uint8(239),
   7814 				3:  uint8(251),
   7815 				4:  uint8(219),
   7816 				5:  uint8(209),
   7817 				6:  uint8(255),
   7818 				7:  uint8(165),
   7819 				8:  uint8(128),
   7820 				9:  uint8(128),
   7821 				10: uint8(128),
   7822 			},
   7823 			1: {
   7824 				0:  uint8(94),
   7825 				1:  uint8(136),
   7826 				2:  uint8(225),
   7827 				3:  uint8(251),
   7828 				4:  uint8(218),
   7829 				5:  uint8(190),
   7830 				6:  uint8(255),
   7831 				7:  uint8(255),
   7832 				8:  uint8(128),
   7833 				9:  uint8(128),
   7834 				10: uint8(128),
   7835 			},
   7836 			2: {
   7837 				0:  uint8(22),
   7838 				1:  uint8(100),
   7839 				2:  uint8(174),
   7840 				3:  uint8(245),
   7841 				4:  uint8(186),
   7842 				5:  uint8(161),
   7843 				6:  uint8(255),
   7844 				7:  uint8(199),
   7845 				8:  uint8(128),
   7846 				9:  uint8(128),
   7847 				10: uint8(128),
   7848 			},
   7849 		},
   7850 		5: {
   7851 			0: {
   7852 				0:  uint8(1),
   7853 				1:  uint8(182),
   7854 				2:  uint8(249),
   7855 				3:  uint8(255),
   7856 				4:  uint8(232),
   7857 				5:  uint8(235),
   7858 				6:  uint8(128),
   7859 				7:  uint8(128),
   7860 				8:  uint8(128),
   7861 				9:  uint8(128),
   7862 				10: uint8(128),
   7863 			},
   7864 			1: {
   7865 				0:  uint8(124),
   7866 				1:  uint8(143),
   7867 				2:  uint8(241),
   7868 				3:  uint8(255),
   7869 				4:  uint8(227),
   7870 				5:  uint8(234),
   7871 				6:  uint8(128),
   7872 				7:  uint8(128),
   7873 				8:  uint8(128),
   7874 				9:  uint8(128),
   7875 				10: uint8(128),
   7876 			},
   7877 			2: {
   7878 				0:  uint8(35),
   7879 				1:  uint8(77),
   7880 				2:  uint8(181),
   7881 				3:  uint8(251),
   7882 				4:  uint8(193),
   7883 				5:  uint8(211),
   7884 				6:  uint8(255),
   7885 				7:  uint8(205),
   7886 				8:  uint8(128),
   7887 				9:  uint8(128),
   7888 				10: uint8(128),
   7889 			},
   7890 		},
   7891 		6: {
   7892 			0: {
   7893 				0:  uint8(1),
   7894 				1:  uint8(157),
   7895 				2:  uint8(247),
   7896 				3:  uint8(255),
   7897 				4:  uint8(236),
   7898 				5:  uint8(231),
   7899 				6:  uint8(255),
   7900 				7:  uint8(255),
   7901 				8:  uint8(128),
   7902 				9:  uint8(128),
   7903 				10: uint8(128),
   7904 			},
   7905 			1: {
   7906 				0:  uint8(121),
   7907 				1:  uint8(141),
   7908 				2:  uint8(235),
   7909 				3:  uint8(255),
   7910 				4:  uint8(225),
   7911 				5:  uint8(227),
   7912 				6:  uint8(255),
   7913 				7:  uint8(255),
   7914 				8:  uint8(128),
   7915 				9:  uint8(128),
   7916 				10: uint8(128),
   7917 			},
   7918 			2: {
   7919 				0:  uint8(45),
   7920 				1:  uint8(99),
   7921 				2:  uint8(188),
   7922 				3:  uint8(251),
   7923 				4:  uint8(195),
   7924 				5:  uint8(217),
   7925 				6:  uint8(255),
   7926 				7:  uint8(224),
   7927 				8:  uint8(128),
   7928 				9:  uint8(128),
   7929 				10: uint8(128),
   7930 			},
   7931 		},
   7932 		7: {
   7933 			0: {
   7934 				0:  uint8(1),
   7935 				1:  uint8(1),
   7936 				2:  uint8(251),
   7937 				3:  uint8(255),
   7938 				4:  uint8(213),
   7939 				5:  uint8(255),
   7940 				6:  uint8(128),
   7941 				7:  uint8(128),
   7942 				8:  uint8(128),
   7943 				9:  uint8(128),
   7944 				10: uint8(128),
   7945 			},
   7946 			1: {
   7947 				0:  uint8(203),
   7948 				1:  uint8(1),
   7949 				2:  uint8(248),
   7950 				3:  uint8(255),
   7951 				4:  uint8(255),
   7952 				5:  uint8(128),
   7953 				6:  uint8(128),
   7954 				7:  uint8(128),
   7955 				8:  uint8(128),
   7956 				9:  uint8(128),
   7957 				10: uint8(128),
   7958 			},
   7959 			2: {
   7960 				0:  uint8(137),
   7961 				1:  uint8(1),
   7962 				2:  uint8(177),
   7963 				3:  uint8(255),
   7964 				4:  uint8(224),
   7965 				5:  uint8(255),
   7966 				6:  uint8(128),
   7967 				7:  uint8(128),
   7968 				8:  uint8(128),
   7969 				9:  uint8(128),
   7970 				10: uint8(128),
   7971 			},
   7972 		},
   7973 	},
   7974 	2: {
   7975 		0: {
   7976 			0: {
   7977 				0:  uint8(253),
   7978 				1:  uint8(9),
   7979 				2:  uint8(248),
   7980 				3:  uint8(251),
   7981 				4:  uint8(207),
   7982 				5:  uint8(208),
   7983 				6:  uint8(255),
   7984 				7:  uint8(192),
   7985 				8:  uint8(128),
   7986 				9:  uint8(128),
   7987 				10: uint8(128),
   7988 			},
   7989 			1: {
   7990 				0:  uint8(175),
   7991 				1:  uint8(13),
   7992 				2:  uint8(224),
   7993 				3:  uint8(243),
   7994 				4:  uint8(193),
   7995 				5:  uint8(185),
   7996 				6:  uint8(249),
   7997 				7:  uint8(198),
   7998 				8:  uint8(255),
   7999 				9:  uint8(255),
   8000 				10: uint8(128),
   8001 			},
   8002 			2: {
   8003 				0:  uint8(73),
   8004 				1:  uint8(17),
   8005 				2:  uint8(171),
   8006 				3:  uint8(221),
   8007 				4:  uint8(161),
   8008 				5:  uint8(179),
   8009 				6:  uint8(236),
   8010 				7:  uint8(167),
   8011 				8:  uint8(255),
   8012 				9:  uint8(234),
   8013 				10: uint8(128),
   8014 			},
   8015 		},
   8016 		1: {
   8017 			0: {
   8018 				0:  uint8(1),
   8019 				1:  uint8(95),
   8020 				2:  uint8(247),
   8021 				3:  uint8(253),
   8022 				4:  uint8(212),
   8023 				5:  uint8(183),
   8024 				6:  uint8(255),
   8025 				7:  uint8(255),
   8026 				8:  uint8(128),
   8027 				9:  uint8(128),
   8028 				10: uint8(128),
   8029 			},
   8030 			1: {
   8031 				0:  uint8(239),
   8032 				1:  uint8(90),
   8033 				2:  uint8(244),
   8034 				3:  uint8(250),
   8035 				4:  uint8(211),
   8036 				5:  uint8(209),
   8037 				6:  uint8(255),
   8038 				7:  uint8(255),
   8039 				8:  uint8(128),
   8040 				9:  uint8(128),
   8041 				10: uint8(128),
   8042 			},
   8043 			2: {
   8044 				0:  uint8(155),
   8045 				1:  uint8(77),
   8046 				2:  uint8(195),
   8047 				3:  uint8(248),
   8048 				4:  uint8(188),
   8049 				5:  uint8(195),
   8050 				6:  uint8(255),
   8051 				7:  uint8(255),
   8052 				8:  uint8(128),
   8053 				9:  uint8(128),
   8054 				10: uint8(128),
   8055 			},
   8056 		},
   8057 		2: {
   8058 			0: {
   8059 				0:  uint8(1),
   8060 				1:  uint8(24),
   8061 				2:  uint8(239),
   8062 				3:  uint8(251),
   8063 				4:  uint8(218),
   8064 				5:  uint8(219),
   8065 				6:  uint8(255),
   8066 				7:  uint8(205),
   8067 				8:  uint8(128),
   8068 				9:  uint8(128),
   8069 				10: uint8(128),
   8070 			},
   8071 			1: {
   8072 				0:  uint8(201),
   8073 				1:  uint8(51),
   8074 				2:  uint8(219),
   8075 				3:  uint8(255),
   8076 				4:  uint8(196),
   8077 				5:  uint8(186),
   8078 				6:  uint8(128),
   8079 				7:  uint8(128),
   8080 				8:  uint8(128),
   8081 				9:  uint8(128),
   8082 				10: uint8(128),
   8083 			},
   8084 			2: {
   8085 				0:  uint8(69),
   8086 				1:  uint8(46),
   8087 				2:  uint8(190),
   8088 				3:  uint8(239),
   8089 				4:  uint8(201),
   8090 				5:  uint8(218),
   8091 				6:  uint8(255),
   8092 				7:  uint8(228),
   8093 				8:  uint8(128),
   8094 				9:  uint8(128),
   8095 				10: uint8(128),
   8096 			},
   8097 		},
   8098 		3: {
   8099 			0: {
   8100 				0:  uint8(1),
   8101 				1:  uint8(191),
   8102 				2:  uint8(251),
   8103 				3:  uint8(255),
   8104 				4:  uint8(255),
   8105 				5:  uint8(128),
   8106 				6:  uint8(128),
   8107 				7:  uint8(128),
   8108 				8:  uint8(128),
   8109 				9:  uint8(128),
   8110 				10: uint8(128),
   8111 			},
   8112 			1: {
   8113 				0:  uint8(223),
   8114 				1:  uint8(165),
   8115 				2:  uint8(249),
   8116 				3:  uint8(255),
   8117 				4:  uint8(213),
   8118 				5:  uint8(255),
   8119 				6:  uint8(128),
   8120 				7:  uint8(128),
   8121 				8:  uint8(128),
   8122 				9:  uint8(128),
   8123 				10: uint8(128),
   8124 			},
   8125 			2: {
   8126 				0:  uint8(141),
   8127 				1:  uint8(124),
   8128 				2:  uint8(248),
   8129 				3:  uint8(255),
   8130 				4:  uint8(255),
   8131 				5:  uint8(128),
   8132 				6:  uint8(128),
   8133 				7:  uint8(128),
   8134 				8:  uint8(128),
   8135 				9:  uint8(128),
   8136 				10: uint8(128),
   8137 			},
   8138 		},
   8139 		4: {
   8140 			0: {
   8141 				0:  uint8(1),
   8142 				1:  uint8(16),
   8143 				2:  uint8(248),
   8144 				3:  uint8(255),
   8145 				4:  uint8(255),
   8146 				5:  uint8(128),
   8147 				6:  uint8(128),
   8148 				7:  uint8(128),
   8149 				8:  uint8(128),
   8150 				9:  uint8(128),
   8151 				10: uint8(128),
   8152 			},
   8153 			1: {
   8154 				0:  uint8(190),
   8155 				1:  uint8(36),
   8156 				2:  uint8(230),
   8157 				3:  uint8(255),
   8158 				4:  uint8(236),
   8159 				5:  uint8(255),
   8160 				6:  uint8(128),
   8161 				7:  uint8(128),
   8162 				8:  uint8(128),
   8163 				9:  uint8(128),
   8164 				10: uint8(128),
   8165 			},
   8166 			2: {
   8167 				0:  uint8(149),
   8168 				1:  uint8(1),
   8169 				2:  uint8(255),
   8170 				3:  uint8(128),
   8171 				4:  uint8(128),
   8172 				5:  uint8(128),
   8173 				6:  uint8(128),
   8174 				7:  uint8(128),
   8175 				8:  uint8(128),
   8176 				9:  uint8(128),
   8177 				10: uint8(128),
   8178 			},
   8179 		},
   8180 		5: {
   8181 			0: {
   8182 				0:  uint8(1),
   8183 				1:  uint8(226),
   8184 				2:  uint8(255),
   8185 				3:  uint8(128),
   8186 				4:  uint8(128),
   8187 				5:  uint8(128),
   8188 				6:  uint8(128),
   8189 				7:  uint8(128),
   8190 				8:  uint8(128),
   8191 				9:  uint8(128),
   8192 				10: uint8(128),
   8193 			},
   8194 			1: {
   8195 				0:  uint8(247),
   8196 				1:  uint8(192),
   8197 				2:  uint8(255),
   8198 				3:  uint8(128),
   8199 				4:  uint8(128),
   8200 				5:  uint8(128),
   8201 				6:  uint8(128),
   8202 				7:  uint8(128),
   8203 				8:  uint8(128),
   8204 				9:  uint8(128),
   8205 				10: uint8(128),
   8206 			},
   8207 			2: {
   8208 				0:  uint8(240),
   8209 				1:  uint8(128),
   8210 				2:  uint8(255),
   8211 				3:  uint8(128),
   8212 				4:  uint8(128),
   8213 				5:  uint8(128),
   8214 				6:  uint8(128),
   8215 				7:  uint8(128),
   8216 				8:  uint8(128),
   8217 				9:  uint8(128),
   8218 				10: uint8(128),
   8219 			},
   8220 		},
   8221 		6: {
   8222 			0: {
   8223 				0:  uint8(1),
   8224 				1:  uint8(134),
   8225 				2:  uint8(252),
   8226 				3:  uint8(255),
   8227 				4:  uint8(255),
   8228 				5:  uint8(128),
   8229 				6:  uint8(128),
   8230 				7:  uint8(128),
   8231 				8:  uint8(128),
   8232 				9:  uint8(128),
   8233 				10: uint8(128),
   8234 			},
   8235 			1: {
   8236 				0:  uint8(213),
   8237 				1:  uint8(62),
   8238 				2:  uint8(250),
   8239 				3:  uint8(255),
   8240 				4:  uint8(255),
   8241 				5:  uint8(128),
   8242 				6:  uint8(128),
   8243 				7:  uint8(128),
   8244 				8:  uint8(128),
   8245 				9:  uint8(128),
   8246 				10: uint8(128),
   8247 			},
   8248 			2: {
   8249 				0:  uint8(55),
   8250 				1:  uint8(93),
   8251 				2:  uint8(255),
   8252 				3:  uint8(128),
   8253 				4:  uint8(128),
   8254 				5:  uint8(128),
   8255 				6:  uint8(128),
   8256 				7:  uint8(128),
   8257 				8:  uint8(128),
   8258 				9:  uint8(128),
   8259 				10: uint8(128),
   8260 			},
   8261 		},
   8262 		7: {
   8263 			0: {
   8264 				0:  uint8(128),
   8265 				1:  uint8(128),
   8266 				2:  uint8(128),
   8267 				3:  uint8(128),
   8268 				4:  uint8(128),
   8269 				5:  uint8(128),
   8270 				6:  uint8(128),
   8271 				7:  uint8(128),
   8272 				8:  uint8(128),
   8273 				9:  uint8(128),
   8274 				10: uint8(128),
   8275 			},
   8276 			1: {
   8277 				0:  uint8(128),
   8278 				1:  uint8(128),
   8279 				2:  uint8(128),
   8280 				3:  uint8(128),
   8281 				4:  uint8(128),
   8282 				5:  uint8(128),
   8283 				6:  uint8(128),
   8284 				7:  uint8(128),
   8285 				8:  uint8(128),
   8286 				9:  uint8(128),
   8287 				10: uint8(128),
   8288 			},
   8289 			2: {
   8290 				0:  uint8(128),
   8291 				1:  uint8(128),
   8292 				2:  uint8(128),
   8293 				3:  uint8(128),
   8294 				4:  uint8(128),
   8295 				5:  uint8(128),
   8296 				6:  uint8(128),
   8297 				7:  uint8(128),
   8298 				8:  uint8(128),
   8299 				9:  uint8(128),
   8300 				10: uint8(128),
   8301 			},
   8302 		},
   8303 	},
   8304 	3: {
   8305 		0: {
   8306 			0: {
   8307 				0:  uint8(202),
   8308 				1:  uint8(24),
   8309 				2:  uint8(213),
   8310 				3:  uint8(235),
   8311 				4:  uint8(186),
   8312 				5:  uint8(191),
   8313 				6:  uint8(220),
   8314 				7:  uint8(160),
   8315 				8:  uint8(240),
   8316 				9:  uint8(175),
   8317 				10: uint8(255),
   8318 			},
   8319 			1: {
   8320 				0:  uint8(126),
   8321 				1:  uint8(38),
   8322 				2:  uint8(182),
   8323 				3:  uint8(232),
   8324 				4:  uint8(169),
   8325 				5:  uint8(184),
   8326 				6:  uint8(228),
   8327 				7:  uint8(174),
   8328 				8:  uint8(255),
   8329 				9:  uint8(187),
   8330 				10: uint8(128),
   8331 			},
   8332 			2: {
   8333 				0:  uint8(61),
   8334 				1:  uint8(46),
   8335 				2:  uint8(138),
   8336 				3:  uint8(219),
   8337 				4:  uint8(151),
   8338 				5:  uint8(178),
   8339 				6:  uint8(240),
   8340 				7:  uint8(170),
   8341 				8:  uint8(255),
   8342 				9:  uint8(216),
   8343 				10: uint8(128),
   8344 			},
   8345 		},
   8346 		1: {
   8347 			0: {
   8348 				0:  uint8(1),
   8349 				1:  uint8(112),
   8350 				2:  uint8(230),
   8351 				3:  uint8(250),
   8352 				4:  uint8(199),
   8353 				5:  uint8(191),
   8354 				6:  uint8(247),
   8355 				7:  uint8(159),
   8356 				8:  uint8(255),
   8357 				9:  uint8(255),
   8358 				10: uint8(128),
   8359 			},
   8360 			1: {
   8361 				0:  uint8(166),
   8362 				1:  uint8(109),
   8363 				2:  uint8(228),
   8364 				3:  uint8(252),
   8365 				4:  uint8(211),
   8366 				5:  uint8(215),
   8367 				6:  uint8(255),
   8368 				7:  uint8(174),
   8369 				8:  uint8(128),
   8370 				9:  uint8(128),
   8371 				10: uint8(128),
   8372 			},
   8373 			2: {
   8374 				0:  uint8(39),
   8375 				1:  uint8(77),
   8376 				2:  uint8(162),
   8377 				3:  uint8(232),
   8378 				4:  uint8(172),
   8379 				5:  uint8(180),
   8380 				6:  uint8(245),
   8381 				7:  uint8(178),
   8382 				8:  uint8(255),
   8383 				9:  uint8(255),
   8384 				10: uint8(128),
   8385 			},
   8386 		},
   8387 		2: {
   8388 			0: {
   8389 				0:  uint8(1),
   8390 				1:  uint8(52),
   8391 				2:  uint8(220),
   8392 				3:  uint8(246),
   8393 				4:  uint8(198),
   8394 				5:  uint8(199),
   8395 				6:  uint8(249),
   8396 				7:  uint8(220),
   8397 				8:  uint8(255),
   8398 				9:  uint8(255),
   8399 				10: uint8(128),
   8400 			},
   8401 			1: {
   8402 				0:  uint8(124),
   8403 				1:  uint8(74),
   8404 				2:  uint8(191),
   8405 				3:  uint8(243),
   8406 				4:  uint8(183),
   8407 				5:  uint8(193),
   8408 				6:  uint8(250),
   8409 				7:  uint8(221),
   8410 				8:  uint8(255),
   8411 				9:  uint8(255),
   8412 				10: uint8(128),
   8413 			},
   8414 			2: {
   8415 				0:  uint8(24),
   8416 				1:  uint8(71),
   8417 				2:  uint8(130),
   8418 				3:  uint8(219),
   8419 				4:  uint8(154),
   8420 				5:  uint8(170),
   8421 				6:  uint8(243),
   8422 				7:  uint8(182),
   8423 				8:  uint8(255),
   8424 				9:  uint8(255),
   8425 				10: uint8(128),
   8426 			},
   8427 		},
   8428 		3: {
   8429 			0: {
   8430 				0:  uint8(1),
   8431 				1:  uint8(182),
   8432 				2:  uint8(225),
   8433 				3:  uint8(249),
   8434 				4:  uint8(219),
   8435 				5:  uint8(240),
   8436 				6:  uint8(255),
   8437 				7:  uint8(224),
   8438 				8:  uint8(128),
   8439 				9:  uint8(128),
   8440 				10: uint8(128),
   8441 			},
   8442 			1: {
   8443 				0:  uint8(149),
   8444 				1:  uint8(150),
   8445 				2:  uint8(226),
   8446 				3:  uint8(252),
   8447 				4:  uint8(216),
   8448 				5:  uint8(205),
   8449 				6:  uint8(255),
   8450 				7:  uint8(171),
   8451 				8:  uint8(128),
   8452 				9:  uint8(128),
   8453 				10: uint8(128),
   8454 			},
   8455 			2: {
   8456 				0:  uint8(28),
   8457 				1:  uint8(108),
   8458 				2:  uint8(170),
   8459 				3:  uint8(242),
   8460 				4:  uint8(183),
   8461 				5:  uint8(194),
   8462 				6:  uint8(254),
   8463 				7:  uint8(223),
   8464 				8:  uint8(255),
   8465 				9:  uint8(255),
   8466 				10: uint8(128),
   8467 			},
   8468 		},
   8469 		4: {
   8470 			0: {
   8471 				0:  uint8(1),
   8472 				1:  uint8(81),
   8473 				2:  uint8(230),
   8474 				3:  uint8(252),
   8475 				4:  uint8(204),
   8476 				5:  uint8(203),
   8477 				6:  uint8(255),
   8478 				7:  uint8(192),
   8479 				8:  uint8(128),
   8480 				9:  uint8(128),
   8481 				10: uint8(128),
   8482 			},
   8483 			1: {
   8484 				0:  uint8(123),
   8485 				1:  uint8(102),
   8486 				2:  uint8(209),
   8487 				3:  uint8(247),
   8488 				4:  uint8(188),
   8489 				5:  uint8(196),
   8490 				6:  uint8(255),
   8491 				7:  uint8(233),
   8492 				8:  uint8(128),
   8493 				9:  uint8(128),
   8494 				10: uint8(128),
   8495 			},
   8496 			2: {
   8497 				0:  uint8(20),
   8498 				1:  uint8(95),
   8499 				2:  uint8(153),
   8500 				3:  uint8(243),
   8501 				4:  uint8(164),
   8502 				5:  uint8(173),
   8503 				6:  uint8(255),
   8504 				7:  uint8(203),
   8505 				8:  uint8(128),
   8506 				9:  uint8(128),
   8507 				10: uint8(128),
   8508 			},
   8509 		},
   8510 		5: {
   8511 			0: {
   8512 				0:  uint8(1),
   8513 				1:  uint8(222),
   8514 				2:  uint8(248),
   8515 				3:  uint8(255),
   8516 				4:  uint8(216),
   8517 				5:  uint8(213),
   8518 				6:  uint8(128),
   8519 				7:  uint8(128),
   8520 				8:  uint8(128),
   8521 				9:  uint8(128),
   8522 				10: uint8(128),
   8523 			},
   8524 			1: {
   8525 				0:  uint8(168),
   8526 				1:  uint8(175),
   8527 				2:  uint8(246),
   8528 				3:  uint8(252),
   8529 				4:  uint8(235),
   8530 				5:  uint8(205),
   8531 				6:  uint8(255),
   8532 				7:  uint8(255),
   8533 				8:  uint8(128),
   8534 				9:  uint8(128),
   8535 				10: uint8(128),
   8536 			},
   8537 			2: {
   8538 				0:  uint8(47),
   8539 				1:  uint8(116),
   8540 				2:  uint8(215),
   8541 				3:  uint8(255),
   8542 				4:  uint8(211),
   8543 				5:  uint8(212),
   8544 				6:  uint8(255),
   8545 				7:  uint8(255),
   8546 				8:  uint8(128),
   8547 				9:  uint8(128),
   8548 				10: uint8(128),
   8549 			},
   8550 		},
   8551 		6: {
   8552 			0: {
   8553 				0:  uint8(1),
   8554 				1:  uint8(121),
   8555 				2:  uint8(236),
   8556 				3:  uint8(253),
   8557 				4:  uint8(212),
   8558 				5:  uint8(214),
   8559 				6:  uint8(255),
   8560 				7:  uint8(255),
   8561 				8:  uint8(128),
   8562 				9:  uint8(128),
   8563 				10: uint8(128),
   8564 			},
   8565 			1: {
   8566 				0:  uint8(141),
   8567 				1:  uint8(84),
   8568 				2:  uint8(213),
   8569 				3:  uint8(252),
   8570 				4:  uint8(201),
   8571 				5:  uint8(202),
   8572 				6:  uint8(255),
   8573 				7:  uint8(219),
   8574 				8:  uint8(128),
   8575 				9:  uint8(128),
   8576 				10: uint8(128),
   8577 			},
   8578 			2: {
   8579 				0:  uint8(42),
   8580 				1:  uint8(80),
   8581 				2:  uint8(160),
   8582 				3:  uint8(240),
   8583 				4:  uint8(162),
   8584 				5:  uint8(185),
   8585 				6:  uint8(255),
   8586 				7:  uint8(205),
   8587 				8:  uint8(128),
   8588 				9:  uint8(128),
   8589 				10: uint8(128),
   8590 			},
   8591 		},
   8592 		7: {
   8593 			0: {
   8594 				0:  uint8(1),
   8595 				1:  uint8(1),
   8596 				2:  uint8(255),
   8597 				3:  uint8(128),
   8598 				4:  uint8(128),
   8599 				5:  uint8(128),
   8600 				6:  uint8(128),
   8601 				7:  uint8(128),
   8602 				8:  uint8(128),
   8603 				9:  uint8(128),
   8604 				10: uint8(128),
   8605 			},
   8606 			1: {
   8607 				0:  uint8(244),
   8608 				1:  uint8(1),
   8609 				2:  uint8(255),
   8610 				3:  uint8(128),
   8611 				4:  uint8(128),
   8612 				5:  uint8(128),
   8613 				6:  uint8(128),
   8614 				7:  uint8(128),
   8615 				8:  uint8(128),
   8616 				9:  uint8(128),
   8617 				10: uint8(128),
   8618 			},
   8619 			2: {
   8620 				0:  uint8(238),
   8621 				1:  uint8(1),
   8622 				2:  uint8(255),
   8623 				3:  uint8(128),
   8624 				4:  uint8(128),
   8625 				5:  uint8(128),
   8626 				6:  uint8(128),
   8627 				7:  uint8(128),
   8628 				8:  uint8(128),
   8629 				9:  uint8(128),
   8630 				10: uint8(128),
   8631 			},
   8632 		},
   8633 	},
   8634 }
   8635 
   8636 // C documentation
   8637 //
   8638 //	// Paragraph 11.5
   8639 var kBModesProba = [10][10][9]uint8_t{
   8640 	0: {
   8641 		0: {
   8642 			0: uint8(231),
   8643 			1: uint8(120),
   8644 			2: uint8(48),
   8645 			3: uint8(89),
   8646 			4: uint8(115),
   8647 			5: uint8(113),
   8648 			6: uint8(120),
   8649 			7: uint8(152),
   8650 			8: uint8(112),
   8651 		},
   8652 		1: {
   8653 			0: uint8(152),
   8654 			1: uint8(179),
   8655 			2: uint8(64),
   8656 			3: uint8(126),
   8657 			4: uint8(170),
   8658 			5: uint8(118),
   8659 			6: uint8(46),
   8660 			7: uint8(70),
   8661 			8: uint8(95),
   8662 		},
   8663 		2: {
   8664 			0: uint8(175),
   8665 			1: uint8(69),
   8666 			2: uint8(143),
   8667 			3: uint8(80),
   8668 			4: uint8(85),
   8669 			5: uint8(82),
   8670 			6: uint8(72),
   8671 			7: uint8(155),
   8672 			8: uint8(103),
   8673 		},
   8674 		3: {
   8675 			0: uint8(56),
   8676 			1: uint8(58),
   8677 			2: uint8(10),
   8678 			3: uint8(171),
   8679 			4: uint8(218),
   8680 			5: uint8(189),
   8681 			6: uint8(17),
   8682 			7: uint8(13),
   8683 			8: uint8(152),
   8684 		},
   8685 		4: {
   8686 			0: uint8(114),
   8687 			1: uint8(26),
   8688 			2: uint8(17),
   8689 			3: uint8(163),
   8690 			4: uint8(44),
   8691 			5: uint8(195),
   8692 			6: uint8(21),
   8693 			7: uint8(10),
   8694 			8: uint8(173),
   8695 		},
   8696 		5: {
   8697 			0: uint8(121),
   8698 			1: uint8(24),
   8699 			2: uint8(80),
   8700 			3: uint8(195),
   8701 			4: uint8(26),
   8702 			5: uint8(62),
   8703 			6: uint8(44),
   8704 			7: uint8(64),
   8705 			8: uint8(85),
   8706 		},
   8707 		6: {
   8708 			0: uint8(144),
   8709 			1: uint8(71),
   8710 			2: uint8(10),
   8711 			3: uint8(38),
   8712 			4: uint8(171),
   8713 			5: uint8(213),
   8714 			6: uint8(144),
   8715 			7: uint8(34),
   8716 			8: uint8(26),
   8717 		},
   8718 		7: {
   8719 			0: uint8(170),
   8720 			1: uint8(46),
   8721 			2: uint8(55),
   8722 			3: uint8(19),
   8723 			4: uint8(136),
   8724 			5: uint8(160),
   8725 			6: uint8(33),
   8726 			7: uint8(206),
   8727 			8: uint8(71),
   8728 		},
   8729 		8: {
   8730 			0: uint8(63),
   8731 			1: uint8(20),
   8732 			2: uint8(8),
   8733 			3: uint8(114),
   8734 			4: uint8(114),
   8735 			5: uint8(208),
   8736 			6: uint8(12),
   8737 			7: uint8(9),
   8738 			8: uint8(226),
   8739 		},
   8740 		9: {
   8741 			0: uint8(81),
   8742 			1: uint8(40),
   8743 			2: uint8(11),
   8744 			3: uint8(96),
   8745 			4: uint8(182),
   8746 			5: uint8(84),
   8747 			6: uint8(29),
   8748 			7: uint8(16),
   8749 			8: uint8(36),
   8750 		},
   8751 	},
   8752 	1: {
   8753 		0: {
   8754 			0: uint8(134),
   8755 			1: uint8(183),
   8756 			2: uint8(89),
   8757 			3: uint8(137),
   8758 			4: uint8(98),
   8759 			5: uint8(101),
   8760 			6: uint8(106),
   8761 			7: uint8(165),
   8762 			8: uint8(148),
   8763 		},
   8764 		1: {
   8765 			0: uint8(72),
   8766 			1: uint8(187),
   8767 			2: uint8(100),
   8768 			3: uint8(130),
   8769 			4: uint8(157),
   8770 			5: uint8(111),
   8771 			6: uint8(32),
   8772 			7: uint8(75),
   8773 			8: uint8(80),
   8774 		},
   8775 		2: {
   8776 			0: uint8(66),
   8777 			1: uint8(102),
   8778 			2: uint8(167),
   8779 			3: uint8(99),
   8780 			4: uint8(74),
   8781 			5: uint8(62),
   8782 			6: uint8(40),
   8783 			7: uint8(234),
   8784 			8: uint8(128),
   8785 		},
   8786 		3: {
   8787 			0: uint8(41),
   8788 			1: uint8(53),
   8789 			2: uint8(9),
   8790 			3: uint8(178),
   8791 			4: uint8(241),
   8792 			5: uint8(141),
   8793 			6: uint8(26),
   8794 			7: uint8(8),
   8795 			8: uint8(107),
   8796 		},
   8797 		4: {
   8798 			0: uint8(74),
   8799 			1: uint8(43),
   8800 			2: uint8(26),
   8801 			3: uint8(146),
   8802 			4: uint8(73),
   8803 			5: uint8(166),
   8804 			6: uint8(49),
   8805 			7: uint8(23),
   8806 			8: uint8(157),
   8807 		},
   8808 		5: {
   8809 			0: uint8(65),
   8810 			1: uint8(38),
   8811 			2: uint8(105),
   8812 			3: uint8(160),
   8813 			4: uint8(51),
   8814 			5: uint8(52),
   8815 			6: uint8(31),
   8816 			7: uint8(115),
   8817 			8: uint8(128),
   8818 		},
   8819 		6: {
   8820 			0: uint8(104),
   8821 			1: uint8(79),
   8822 			2: uint8(12),
   8823 			3: uint8(27),
   8824 			4: uint8(217),
   8825 			5: uint8(255),
   8826 			6: uint8(87),
   8827 			7: uint8(17),
   8828 			8: uint8(7),
   8829 		},
   8830 		7: {
   8831 			0: uint8(87),
   8832 			1: uint8(68),
   8833 			2: uint8(71),
   8834 			3: uint8(44),
   8835 			4: uint8(114),
   8836 			5: uint8(51),
   8837 			6: uint8(15),
   8838 			7: uint8(186),
   8839 			8: uint8(23),
   8840 		},
   8841 		8: {
   8842 			0: uint8(47),
   8843 			1: uint8(41),
   8844 			2: uint8(14),
   8845 			3: uint8(110),
   8846 			4: uint8(182),
   8847 			5: uint8(183),
   8848 			6: uint8(21),
   8849 			7: uint8(17),
   8850 			8: uint8(194),
   8851 		},
   8852 		9: {
   8853 			0: uint8(66),
   8854 			1: uint8(45),
   8855 			2: uint8(25),
   8856 			3: uint8(102),
   8857 			4: uint8(197),
   8858 			5: uint8(189),
   8859 			6: uint8(23),
   8860 			7: uint8(18),
   8861 			8: uint8(22),
   8862 		},
   8863 	},
   8864 	2: {
   8865 		0: {
   8866 			0: uint8(88),
   8867 			1: uint8(88),
   8868 			2: uint8(147),
   8869 			3: uint8(150),
   8870 			4: uint8(42),
   8871 			5: uint8(46),
   8872 			6: uint8(45),
   8873 			7: uint8(196),
   8874 			8: uint8(205),
   8875 		},
   8876 		1: {
   8877 			0: uint8(43),
   8878 			1: uint8(97),
   8879 			2: uint8(183),
   8880 			3: uint8(117),
   8881 			4: uint8(85),
   8882 			5: uint8(38),
   8883 			6: uint8(35),
   8884 			7: uint8(179),
   8885 			8: uint8(61),
   8886 		},
   8887 		2: {
   8888 			0: uint8(39),
   8889 			1: uint8(53),
   8890 			2: uint8(200),
   8891 			3: uint8(87),
   8892 			4: uint8(26),
   8893 			5: uint8(21),
   8894 			6: uint8(43),
   8895 			7: uint8(232),
   8896 			8: uint8(171),
   8897 		},
   8898 		3: {
   8899 			0: uint8(56),
   8900 			1: uint8(34),
   8901 			2: uint8(51),
   8902 			3: uint8(104),
   8903 			4: uint8(114),
   8904 			5: uint8(102),
   8905 			6: uint8(29),
   8906 			7: uint8(93),
   8907 			8: uint8(77),
   8908 		},
   8909 		4: {
   8910 			0: uint8(39),
   8911 			1: uint8(28),
   8912 			2: uint8(85),
   8913 			3: uint8(171),
   8914 			4: uint8(58),
   8915 			5: uint8(165),
   8916 			6: uint8(90),
   8917 			7: uint8(98),
   8918 			8: uint8(64),
   8919 		},
   8920 		5: {
   8921 			0: uint8(34),
   8922 			1: uint8(22),
   8923 			2: uint8(116),
   8924 			3: uint8(206),
   8925 			4: uint8(23),
   8926 			5: uint8(34),
   8927 			6: uint8(43),
   8928 			7: uint8(166),
   8929 			8: uint8(73),
   8930 		},
   8931 		6: {
   8932 			0: uint8(107),
   8933 			1: uint8(54),
   8934 			2: uint8(32),
   8935 			3: uint8(26),
   8936 			4: uint8(51),
   8937 			5: uint8(1),
   8938 			6: uint8(81),
   8939 			7: uint8(43),
   8940 			8: uint8(31),
   8941 		},
   8942 		7: {
   8943 			0: uint8(68),
   8944 			1: uint8(25),
   8945 			2: uint8(106),
   8946 			3: uint8(22),
   8947 			4: uint8(64),
   8948 			5: uint8(171),
   8949 			6: uint8(36),
   8950 			7: uint8(225),
   8951 			8: uint8(114),
   8952 		},
   8953 		8: {
   8954 			0: uint8(34),
   8955 			1: uint8(19),
   8956 			2: uint8(21),
   8957 			3: uint8(102),
   8958 			4: uint8(132),
   8959 			5: uint8(188),
   8960 			6: uint8(16),
   8961 			7: uint8(76),
   8962 			8: uint8(124),
   8963 		},
   8964 		9: {
   8965 			0: uint8(62),
   8966 			1: uint8(18),
   8967 			2: uint8(78),
   8968 			3: uint8(95),
   8969 			4: uint8(85),
   8970 			5: uint8(57),
   8971 			6: uint8(50),
   8972 			7: uint8(48),
   8973 			8: uint8(51),
   8974 		},
   8975 	},
   8976 	3: {
   8977 		0: {
   8978 			0: uint8(193),
   8979 			1: uint8(101),
   8980 			2: uint8(35),
   8981 			3: uint8(159),
   8982 			4: uint8(215),
   8983 			5: uint8(111),
   8984 			6: uint8(89),
   8985 			7: uint8(46),
   8986 			8: uint8(111),
   8987 		},
   8988 		1: {
   8989 			0: uint8(60),
   8990 			1: uint8(148),
   8991 			2: uint8(31),
   8992 			3: uint8(172),
   8993 			4: uint8(219),
   8994 			5: uint8(228),
   8995 			6: uint8(21),
   8996 			7: uint8(18),
   8997 			8: uint8(111),
   8998 		},
   8999 		2: {
   9000 			0: uint8(112),
   9001 			1: uint8(113),
   9002 			2: uint8(77),
   9003 			3: uint8(85),
   9004 			4: uint8(179),
   9005 			5: uint8(255),
   9006 			6: uint8(38),
   9007 			7: uint8(120),
   9008 			8: uint8(114),
   9009 		},
   9010 		3: {
   9011 			0: uint8(40),
   9012 			1: uint8(42),
   9013 			2: uint8(1),
   9014 			3: uint8(196),
   9015 			4: uint8(245),
   9016 			5: uint8(209),
   9017 			6: uint8(10),
   9018 			7: uint8(25),
   9019 			8: uint8(109),
   9020 		},
   9021 		4: {
   9022 			0: uint8(88),
   9023 			1: uint8(43),
   9024 			2: uint8(29),
   9025 			3: uint8(140),
   9026 			4: uint8(166),
   9027 			5: uint8(213),
   9028 			6: uint8(37),
   9029 			7: uint8(43),
   9030 			8: uint8(154),
   9031 		},
   9032 		5: {
   9033 			0: uint8(61),
   9034 			1: uint8(63),
   9035 			2: uint8(30),
   9036 			3: uint8(155),
   9037 			4: uint8(67),
   9038 			5: uint8(45),
   9039 			6: uint8(68),
   9040 			7: uint8(1),
   9041 			8: uint8(209),
   9042 		},
   9043 		6: {
   9044 			0: uint8(100),
   9045 			1: uint8(80),
   9046 			2: uint8(8),
   9047 			3: uint8(43),
   9048 			4: uint8(154),
   9049 			5: uint8(1),
   9050 			6: uint8(51),
   9051 			7: uint8(26),
   9052 			8: uint8(71),
   9053 		},
   9054 		7: {
   9055 			0: uint8(142),
   9056 			1: uint8(78),
   9057 			2: uint8(78),
   9058 			3: uint8(16),
   9059 			4: uint8(255),
   9060 			5: uint8(128),
   9061 			6: uint8(34),
   9062 			7: uint8(197),
   9063 			8: uint8(171),
   9064 		},
   9065 		8: {
   9066 			0: uint8(41),
   9067 			1: uint8(40),
   9068 			2: uint8(5),
   9069 			3: uint8(102),
   9070 			4: uint8(211),
   9071 			5: uint8(183),
   9072 			6: uint8(4),
   9073 			7: uint8(1),
   9074 			8: uint8(221),
   9075 		},
   9076 		9: {
   9077 			0: uint8(51),
   9078 			1: uint8(50),
   9079 			2: uint8(17),
   9080 			3: uint8(168),
   9081 			4: uint8(209),
   9082 			5: uint8(192),
   9083 			6: uint8(23),
   9084 			7: uint8(25),
   9085 			8: uint8(82),
   9086 		},
   9087 	},
   9088 	4: {
   9089 		0: {
   9090 			0: uint8(138),
   9091 			1: uint8(31),
   9092 			2: uint8(36),
   9093 			3: uint8(171),
   9094 			4: uint8(27),
   9095 			5: uint8(166),
   9096 			6: uint8(38),
   9097 			7: uint8(44),
   9098 			8: uint8(229),
   9099 		},
   9100 		1: {
   9101 			0: uint8(67),
   9102 			1: uint8(87),
   9103 			2: uint8(58),
   9104 			3: uint8(169),
   9105 			4: uint8(82),
   9106 			5: uint8(115),
   9107 			6: uint8(26),
   9108 			7: uint8(59),
   9109 			8: uint8(179),
   9110 		},
   9111 		2: {
   9112 			0: uint8(63),
   9113 			1: uint8(59),
   9114 			2: uint8(90),
   9115 			3: uint8(180),
   9116 			4: uint8(59),
   9117 			5: uint8(166),
   9118 			6: uint8(93),
   9119 			7: uint8(73),
   9120 			8: uint8(154),
   9121 		},
   9122 		3: {
   9123 			0: uint8(40),
   9124 			1: uint8(40),
   9125 			2: uint8(21),
   9126 			3: uint8(116),
   9127 			4: uint8(143),
   9128 			5: uint8(209),
   9129 			6: uint8(34),
   9130 			7: uint8(39),
   9131 			8: uint8(175),
   9132 		},
   9133 		4: {
   9134 			0: uint8(47),
   9135 			1: uint8(15),
   9136 			2: uint8(16),
   9137 			3: uint8(183),
   9138 			4: uint8(34),
   9139 			5: uint8(223),
   9140 			6: uint8(49),
   9141 			7: uint8(45),
   9142 			8: uint8(183),
   9143 		},
   9144 		5: {
   9145 			0: uint8(46),
   9146 			1: uint8(17),
   9147 			2: uint8(33),
   9148 			3: uint8(183),
   9149 			4: uint8(6),
   9150 			5: uint8(98),
   9151 			6: uint8(15),
   9152 			7: uint8(32),
   9153 			8: uint8(183),
   9154 		},
   9155 		6: {
   9156 			0: uint8(57),
   9157 			1: uint8(46),
   9158 			2: uint8(22),
   9159 			3: uint8(24),
   9160 			4: uint8(128),
   9161 			5: uint8(1),
   9162 			6: uint8(54),
   9163 			7: uint8(17),
   9164 			8: uint8(37),
   9165 		},
   9166 		7: {
   9167 			0: uint8(65),
   9168 			1: uint8(32),
   9169 			2: uint8(73),
   9170 			3: uint8(115),
   9171 			4: uint8(28),
   9172 			5: uint8(128),
   9173 			6: uint8(23),
   9174 			7: uint8(128),
   9175 			8: uint8(205),
   9176 		},
   9177 		8: {
   9178 			0: uint8(40),
   9179 			1: uint8(3),
   9180 			2: uint8(9),
   9181 			3: uint8(115),
   9182 			4: uint8(51),
   9183 			5: uint8(192),
   9184 			6: uint8(18),
   9185 			7: uint8(6),
   9186 			8: uint8(223),
   9187 		},
   9188 		9: {
   9189 			0: uint8(87),
   9190 			1: uint8(37),
   9191 			2: uint8(9),
   9192 			3: uint8(115),
   9193 			4: uint8(59),
   9194 			5: uint8(77),
   9195 			6: uint8(64),
   9196 			7: uint8(21),
   9197 			8: uint8(47),
   9198 		},
   9199 	},
   9200 	5: {
   9201 		0: {
   9202 			0: uint8(104),
   9203 			1: uint8(55),
   9204 			2: uint8(44),
   9205 			3: uint8(218),
   9206 			4: uint8(9),
   9207 			5: uint8(54),
   9208 			6: uint8(53),
   9209 			7: uint8(130),
   9210 			8: uint8(226),
   9211 		},
   9212 		1: {
   9213 			0: uint8(64),
   9214 			1: uint8(90),
   9215 			2: uint8(70),
   9216 			3: uint8(205),
   9217 			4: uint8(40),
   9218 			5: uint8(41),
   9219 			6: uint8(23),
   9220 			7: uint8(26),
   9221 			8: uint8(57),
   9222 		},
   9223 		2: {
   9224 			0: uint8(54),
   9225 			1: uint8(57),
   9226 			2: uint8(112),
   9227 			3: uint8(184),
   9228 			4: uint8(5),
   9229 			5: uint8(41),
   9230 			6: uint8(38),
   9231 			7: uint8(166),
   9232 			8: uint8(213),
   9233 		},
   9234 		3: {
   9235 			0: uint8(30),
   9236 			1: uint8(34),
   9237 			2: uint8(26),
   9238 			3: uint8(133),
   9239 			4: uint8(152),
   9240 			5: uint8(116),
   9241 			6: uint8(10),
   9242 			7: uint8(32),
   9243 			8: uint8(134),
   9244 		},
   9245 		4: {
   9246 			0: uint8(39),
   9247 			1: uint8(19),
   9248 			2: uint8(53),
   9249 			3: uint8(221),
   9250 			4: uint8(26),
   9251 			5: uint8(114),
   9252 			6: uint8(32),
   9253 			7: uint8(73),
   9254 			8: uint8(255),
   9255 		},
   9256 		5: {
   9257 			0: uint8(31),
   9258 			1: uint8(9),
   9259 			2: uint8(65),
   9260 			3: uint8(234),
   9261 			4: uint8(2),
   9262 			5: uint8(15),
   9263 			6: uint8(1),
   9264 			7: uint8(118),
   9265 			8: uint8(73),
   9266 		},
   9267 		6: {
   9268 			0: uint8(75),
   9269 			1: uint8(32),
   9270 			2: uint8(12),
   9271 			3: uint8(51),
   9272 			4: uint8(192),
   9273 			5: uint8(255),
   9274 			6: uint8(160),
   9275 			7: uint8(43),
   9276 			8: uint8(51),
   9277 		},
   9278 		7: {
   9279 			0: uint8(88),
   9280 			1: uint8(31),
   9281 			2: uint8(35),
   9282 			3: uint8(67),
   9283 			4: uint8(102),
   9284 			5: uint8(85),
   9285 			6: uint8(55),
   9286 			7: uint8(186),
   9287 			8: uint8(85),
   9288 		},
   9289 		8: {
   9290 			0: uint8(56),
   9291 			1: uint8(21),
   9292 			2: uint8(23),
   9293 			3: uint8(111),
   9294 			4: uint8(59),
   9295 			5: uint8(205),
   9296 			6: uint8(45),
   9297 			7: uint8(37),
   9298 			8: uint8(192),
   9299 		},
   9300 		9: {
   9301 			0: uint8(55),
   9302 			1: uint8(38),
   9303 			2: uint8(70),
   9304 			3: uint8(124),
   9305 			4: uint8(73),
   9306 			5: uint8(102),
   9307 			6: uint8(1),
   9308 			7: uint8(34),
   9309 			8: uint8(98),
   9310 		},
   9311 	},
   9312 	6: {
   9313 		0: {
   9314 			0: uint8(125),
   9315 			1: uint8(98),
   9316 			2: uint8(42),
   9317 			3: uint8(88),
   9318 			4: uint8(104),
   9319 			5: uint8(85),
   9320 			6: uint8(117),
   9321 			7: uint8(175),
   9322 			8: uint8(82),
   9323 		},
   9324 		1: {
   9325 			0: uint8(95),
   9326 			1: uint8(84),
   9327 			2: uint8(53),
   9328 			3: uint8(89),
   9329 			4: uint8(128),
   9330 			5: uint8(100),
   9331 			6: uint8(113),
   9332 			7: uint8(101),
   9333 			8: uint8(45),
   9334 		},
   9335 		2: {
   9336 			0: uint8(75),
   9337 			1: uint8(79),
   9338 			2: uint8(123),
   9339 			3: uint8(47),
   9340 			4: uint8(51),
   9341 			5: uint8(128),
   9342 			6: uint8(81),
   9343 			7: uint8(171),
   9344 			8: uint8(1),
   9345 		},
   9346 		3: {
   9347 			0: uint8(57),
   9348 			1: uint8(17),
   9349 			2: uint8(5),
   9350 			3: uint8(71),
   9351 			4: uint8(102),
   9352 			5: uint8(57),
   9353 			6: uint8(53),
   9354 			7: uint8(41),
   9355 			8: uint8(49),
   9356 		},
   9357 		4: {
   9358 			0: uint8(38),
   9359 			1: uint8(33),
   9360 			2: uint8(13),
   9361 			3: uint8(121),
   9362 			4: uint8(57),
   9363 			5: uint8(73),
   9364 			6: uint8(26),
   9365 			7: uint8(1),
   9366 			8: uint8(85),
   9367 		},
   9368 		5: {
   9369 			0: uint8(41),
   9370 			1: uint8(10),
   9371 			2: uint8(67),
   9372 			3: uint8(138),
   9373 			4: uint8(77),
   9374 			5: uint8(110),
   9375 			6: uint8(90),
   9376 			7: uint8(47),
   9377 			8: uint8(114),
   9378 		},
   9379 		6: {
   9380 			0: uint8(115),
   9381 			1: uint8(21),
   9382 			2: uint8(2),
   9383 			3: uint8(10),
   9384 			4: uint8(102),
   9385 			5: uint8(255),
   9386 			6: uint8(166),
   9387 			7: uint8(23),
   9388 			8: uint8(6),
   9389 		},
   9390 		7: {
   9391 			0: uint8(101),
   9392 			1: uint8(29),
   9393 			2: uint8(16),
   9394 			3: uint8(10),
   9395 			4: uint8(85),
   9396 			5: uint8(128),
   9397 			6: uint8(101),
   9398 			7: uint8(196),
   9399 			8: uint8(26),
   9400 		},
   9401 		8: {
   9402 			0: uint8(57),
   9403 			1: uint8(18),
   9404 			2: uint8(10),
   9405 			3: uint8(102),
   9406 			4: uint8(102),
   9407 			5: uint8(213),
   9408 			6: uint8(34),
   9409 			7: uint8(20),
   9410 			8: uint8(43),
   9411 		},
   9412 		9: {
   9413 			0: uint8(117),
   9414 			1: uint8(20),
   9415 			2: uint8(15),
   9416 			3: uint8(36),
   9417 			4: uint8(163),
   9418 			5: uint8(128),
   9419 			6: uint8(68),
   9420 			7: uint8(1),
   9421 			8: uint8(26),
   9422 		},
   9423 	},
   9424 	7: {
   9425 		0: {
   9426 			0: uint8(102),
   9427 			1: uint8(61),
   9428 			2: uint8(71),
   9429 			3: uint8(37),
   9430 			4: uint8(34),
   9431 			5: uint8(53),
   9432 			6: uint8(31),
   9433 			7: uint8(243),
   9434 			8: uint8(192),
   9435 		},
   9436 		1: {
   9437 			0: uint8(69),
   9438 			1: uint8(60),
   9439 			2: uint8(71),
   9440 			3: uint8(38),
   9441 			4: uint8(73),
   9442 			5: uint8(119),
   9443 			6: uint8(28),
   9444 			7: uint8(222),
   9445 			8: uint8(37),
   9446 		},
   9447 		2: {
   9448 			0: uint8(68),
   9449 			1: uint8(45),
   9450 			2: uint8(128),
   9451 			3: uint8(34),
   9452 			4: uint8(1),
   9453 			5: uint8(47),
   9454 			6: uint8(11),
   9455 			7: uint8(245),
   9456 			8: uint8(171),
   9457 		},
   9458 		3: {
   9459 			0: uint8(62),
   9460 			1: uint8(17),
   9461 			2: uint8(19),
   9462 			3: uint8(70),
   9463 			4: uint8(146),
   9464 			5: uint8(85),
   9465 			6: uint8(55),
   9466 			7: uint8(62),
   9467 			8: uint8(70),
   9468 		},
   9469 		4: {
   9470 			0: uint8(37),
   9471 			1: uint8(43),
   9472 			2: uint8(37),
   9473 			3: uint8(154),
   9474 			4: uint8(100),
   9475 			5: uint8(163),
   9476 			6: uint8(85),
   9477 			7: uint8(160),
   9478 			8: uint8(1),
   9479 		},
   9480 		5: {
   9481 			0: uint8(63),
   9482 			1: uint8(9),
   9483 			2: uint8(92),
   9484 			3: uint8(136),
   9485 			4: uint8(28),
   9486 			5: uint8(64),
   9487 			6: uint8(32),
   9488 			7: uint8(201),
   9489 			8: uint8(85),
   9490 		},
   9491 		6: {
   9492 			0: uint8(75),
   9493 			1: uint8(15),
   9494 			2: uint8(9),
   9495 			3: uint8(9),
   9496 			4: uint8(64),
   9497 			5: uint8(255),
   9498 			6: uint8(184),
   9499 			7: uint8(119),
   9500 			8: uint8(16),
   9501 		},
   9502 		7: {
   9503 			0: uint8(86),
   9504 			1: uint8(6),
   9505 			2: uint8(28),
   9506 			3: uint8(5),
   9507 			4: uint8(64),
   9508 			5: uint8(255),
   9509 			6: uint8(25),
   9510 			7: uint8(248),
   9511 			8: uint8(1),
   9512 		},
   9513 		8: {
   9514 			0: uint8(56),
   9515 			1: uint8(8),
   9516 			2: uint8(17),
   9517 			3: uint8(132),
   9518 			4: uint8(137),
   9519 			5: uint8(255),
   9520 			6: uint8(55),
   9521 			7: uint8(116),
   9522 			8: uint8(128),
   9523 		},
   9524 		9: {
   9525 			0: uint8(58),
   9526 			1: uint8(15),
   9527 			2: uint8(20),
   9528 			3: uint8(82),
   9529 			4: uint8(135),
   9530 			5: uint8(57),
   9531 			6: uint8(26),
   9532 			7: uint8(121),
   9533 			8: uint8(40),
   9534 		},
   9535 	},
   9536 	8: {
   9537 		0: {
   9538 			0: uint8(164),
   9539 			1: uint8(50),
   9540 			2: uint8(31),
   9541 			3: uint8(137),
   9542 			4: uint8(154),
   9543 			5: uint8(133),
   9544 			6: uint8(25),
   9545 			7: uint8(35),
   9546 			8: uint8(218),
   9547 		},
   9548 		1: {
   9549 			0: uint8(51),
   9550 			1: uint8(103),
   9551 			2: uint8(44),
   9552 			3: uint8(131),
   9553 			4: uint8(131),
   9554 			5: uint8(123),
   9555 			6: uint8(31),
   9556 			7: uint8(6),
   9557 			8: uint8(158),
   9558 		},
   9559 		2: {
   9560 			0: uint8(86),
   9561 			1: uint8(40),
   9562 			2: uint8(64),
   9563 			3: uint8(135),
   9564 			4: uint8(148),
   9565 			5: uint8(224),
   9566 			6: uint8(45),
   9567 			7: uint8(183),
   9568 			8: uint8(128),
   9569 		},
   9570 		3: {
   9571 			0: uint8(22),
   9572 			1: uint8(26),
   9573 			2: uint8(17),
   9574 			3: uint8(131),
   9575 			4: uint8(240),
   9576 			5: uint8(154),
   9577 			6: uint8(14),
   9578 			7: uint8(1),
   9579 			8: uint8(209),
   9580 		},
   9581 		4: {
   9582 			0: uint8(45),
   9583 			1: uint8(16),
   9584 			2: uint8(21),
   9585 			3: uint8(91),
   9586 			4: uint8(64),
   9587 			5: uint8(222),
   9588 			6: uint8(7),
   9589 			7: uint8(1),
   9590 			8: uint8(197),
   9591 		},
   9592 		5: {
   9593 			0: uint8(56),
   9594 			1: uint8(21),
   9595 			2: uint8(39),
   9596 			3: uint8(155),
   9597 			4: uint8(60),
   9598 			5: uint8(138),
   9599 			6: uint8(23),
   9600 			7: uint8(102),
   9601 			8: uint8(213),
   9602 		},
   9603 		6: {
   9604 			0: uint8(83),
   9605 			1: uint8(12),
   9606 			2: uint8(13),
   9607 			3: uint8(54),
   9608 			4: uint8(192),
   9609 			5: uint8(255),
   9610 			6: uint8(68),
   9611 			7: uint8(47),
   9612 			8: uint8(28),
   9613 		},
   9614 		7: {
   9615 			0: uint8(85),
   9616 			1: uint8(26),
   9617 			2: uint8(85),
   9618 			3: uint8(85),
   9619 			4: uint8(128),
   9620 			5: uint8(128),
   9621 			6: uint8(32),
   9622 			7: uint8(146),
   9623 			8: uint8(171),
   9624 		},
   9625 		8: {
   9626 			0: uint8(18),
   9627 			1: uint8(11),
   9628 			2: uint8(7),
   9629 			3: uint8(63),
   9630 			4: uint8(144),
   9631 			5: uint8(171),
   9632 			6: uint8(4),
   9633 			7: uint8(4),
   9634 			8: uint8(246),
   9635 		},
   9636 		9: {
   9637 			0: uint8(35),
   9638 			1: uint8(27),
   9639 			2: uint8(10),
   9640 			3: uint8(146),
   9641 			4: uint8(174),
   9642 			5: uint8(171),
   9643 			6: uint8(12),
   9644 			7: uint8(26),
   9645 			8: uint8(128),
   9646 		},
   9647 	},
   9648 	9: {
   9649 		0: {
   9650 			0: uint8(190),
   9651 			1: uint8(80),
   9652 			2: uint8(35),
   9653 			3: uint8(99),
   9654 			4: uint8(180),
   9655 			5: uint8(80),
   9656 			6: uint8(126),
   9657 			7: uint8(54),
   9658 			8: uint8(45),
   9659 		},
   9660 		1: {
   9661 			0: uint8(85),
   9662 			1: uint8(126),
   9663 			2: uint8(47),
   9664 			3: uint8(87),
   9665 			4: uint8(176),
   9666 			5: uint8(51),
   9667 			6: uint8(41),
   9668 			7: uint8(20),
   9669 			8: uint8(32),
   9670 		},
   9671 		2: {
   9672 			0: uint8(101),
   9673 			1: uint8(75),
   9674 			2: uint8(128),
   9675 			3: uint8(139),
   9676 			4: uint8(118),
   9677 			5: uint8(146),
   9678 			6: uint8(116),
   9679 			7: uint8(128),
   9680 			8: uint8(85),
   9681 		},
   9682 		3: {
   9683 			0: uint8(56),
   9684 			1: uint8(41),
   9685 			2: uint8(15),
   9686 			3: uint8(176),
   9687 			4: uint8(236),
   9688 			5: uint8(85),
   9689 			6: uint8(37),
   9690 			7: uint8(9),
   9691 			8: uint8(62),
   9692 		},
   9693 		4: {
   9694 			0: uint8(71),
   9695 			1: uint8(30),
   9696 			2: uint8(17),
   9697 			3: uint8(119),
   9698 			4: uint8(118),
   9699 			5: uint8(255),
   9700 			6: uint8(17),
   9701 			7: uint8(18),
   9702 			8: uint8(138),
   9703 		},
   9704 		5: {
   9705 			0: uint8(101),
   9706 			1: uint8(38),
   9707 			2: uint8(60),
   9708 			3: uint8(138),
   9709 			4: uint8(55),
   9710 			5: uint8(70),
   9711 			6: uint8(43),
   9712 			7: uint8(26),
   9713 			8: uint8(142),
   9714 		},
   9715 		6: {
   9716 			0: uint8(146),
   9717 			1: uint8(36),
   9718 			2: uint8(19),
   9719 			3: uint8(30),
   9720 			4: uint8(171),
   9721 			5: uint8(255),
   9722 			6: uint8(97),
   9723 			7: uint8(27),
   9724 			8: uint8(20),
   9725 		},
   9726 		7: {
   9727 			0: uint8(138),
   9728 			1: uint8(45),
   9729 			2: uint8(61),
   9730 			3: uint8(62),
   9731 			4: uint8(219),
   9732 			5: uint8(1),
   9733 			6: uint8(81),
   9734 			7: uint8(188),
   9735 			8: uint8(64),
   9736 		},
   9737 		8: {
   9738 			0: uint8(32),
   9739 			1: uint8(41),
   9740 			2: uint8(20),
   9741 			3: uint8(117),
   9742 			4: uint8(151),
   9743 			5: uint8(142),
   9744 			6: uint8(20),
   9745 			7: uint8(21),
   9746 			8: uint8(163),
   9747 		},
   9748 		9: {
   9749 			0: uint8(112),
   9750 			1: uint8(19),
   9751 			2: uint8(12),
   9752 			3: uint8(61),
   9753 			4: uint8(195),
   9754 			5: uint8(128),
   9755 			6: uint8(48),
   9756 			7: uint8(4),
   9757 			8: uint8(24),
   9758 		},
   9759 	},
   9760 }
   9761 
   9762 func VP8ResetProba(tls *libc.TLS, proba uintptr) {
   9763 	libc.X__builtin___memset_chk(tls, proba, libc.Int32FromUint32(255), uint64(3), ^__predefined_size_t(0))
   9764 	// proba->bands[][] is initialized later
   9765 }
   9766 
   9767 func ParseIntraMode(tls *libc.TLS, br2 uintptr, dec uintptr, mb_x int32) {
   9768 	bp := tls.Alloc(16)
   9769 	defer tls.Free(16)
   9770 	var bit, i, pos, shift, x1, y, ymode, ymode1, v1, v14, v16, v22, v24, v30, v32, v6, v8 int32
   9771 	var bits bit_t
   9772 	var block, left, modes, prob1, top, v10, v11, v18, v19, v2, v3 uintptr
   9773 	var range1, split, value range_t
   9774 	var v12, v20, v4 uint64_t
   9775 	var _ /* in_bits at bp+0 */ lbit_t
   9776 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
   9777 	top = (*VP8Decoder)(unsafe.Pointer(dec)).Fintra_t + uintptr(int32(4)*mb_x)
   9778 	left = dec + 2816
   9779 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr(mb_x)*800
   9780 	// Note: we don't save segment map (yet), as we don't expect
   9781 	// to decode more than 1 keyframe.
   9782 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fsegment_hdr.Fupdate_map != 0 {
   9783 		// Hardcoded tree parsing
   9784 		v2 = br2
   9785 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9786 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9787 			v3 = v2
   9788 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9789 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9790 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9791 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9792 				goto _5
   9793 			_5:
   9794 				bits = v4
   9795 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9796 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9797 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9798 			} else {
   9799 				VP8LoadFinalBytes(tls, v3)
   9800 			}
   9801 		}
   9802 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9803 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192)))) >> int32(8)
   9804 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9805 		bit = libc.BoolInt32(value > split)
   9806 		if bit != 0 {
   9807 			range1 = range1 - split
   9808 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9809 		} else {
   9810 			range1 = split + uint32(1)
   9811 		}
   9812 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9813 		goto _7
   9814 	_7:
   9815 		shift = int32(7) ^ v6
   9816 		range1 = range1 << libc.Uint32FromInt32(shift)
   9817 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9818 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9819 		v8 = bit
   9820 		goto _9
   9821 	_9:
   9822 		if !(v8 != 0) {
   9823 			v10 = br2
   9824 			range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
   9825 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
   9826 				v11 = v10
   9827 				if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
   9828 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9829 					**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9830 					v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9831 					goto _13
   9832 				_13:
   9833 					bits = v12
   9834 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9835 					(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
   9836 					**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
   9837 				} else {
   9838 					VP8LoadFinalBytes(tls, v11)
   9839 				}
   9840 			}
   9841 			pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
   9842 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192 + 1)))) >> int32(8)
   9843 			value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
   9844 			bit = libc.BoolInt32(value > split)
   9845 			if bit != 0 {
   9846 				range1 = range1 - split
   9847 				**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9848 			} else {
   9849 				range1 = split + uint32(1)
   9850 			}
   9851 			v14 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9852 			goto _15
   9853 		_15:
   9854 			shift = int32(7) ^ v14
   9855 			range1 = range1 << libc.Uint32FromInt32(shift)
   9856 			**(**int32)(__ccgo_up(v10 + 12)) -= shift
   9857 			(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
   9858 			v16 = bit
   9859 			goto _17
   9860 		_17:
   9861 			v1 = v16
   9862 		} else {
   9863 			v18 = br2
   9864 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
   9865 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
   9866 				v19 = v18
   9867 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
   9868 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9869 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9870 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9871 					goto _21
   9872 				_21:
   9873 					bits = v20
   9874 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9875 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
   9876 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
   9877 				} else {
   9878 					VP8LoadFinalBytes(tls, v19)
   9879 				}
   9880 			}
   9881 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
   9882 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dec + 1192 + 2)))) >> int32(8)
   9883 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
   9884 			bit = libc.BoolInt32(value > split)
   9885 			if bit != 0 {
   9886 				range1 = range1 - split
   9887 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9888 			} else {
   9889 				range1 = split + uint32(1)
   9890 			}
   9891 			v22 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9892 			goto _23
   9893 		_23:
   9894 			shift = int32(7) ^ v22
   9895 			range1 = range1 << libc.Uint32FromInt32(shift)
   9896 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
   9897 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
   9898 			v24 = bit
   9899 			goto _25
   9900 		_25:
   9901 			v1 = v24 + int32(2)
   9902 		}
   9903 		(*VP8MBData)(unsafe.Pointer(block)).Fsegment = libc.Uint8FromInt32(v1)
   9904 	} else {
   9905 		(*VP8MBData)(unsafe.Pointer(block)).Fsegment = uint8(0) // default for intra
   9906 	}
   9907 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
   9908 		v2 = br2
   9909 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9910 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9911 			v3 = v2
   9912 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9913 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9914 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9915 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9916 				goto _29
   9917 			_29:
   9918 				bits = v4
   9919 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9920 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9921 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9922 			} else {
   9923 				VP8LoadFinalBytes(tls, v3)
   9924 			}
   9925 		}
   9926 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9927 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8((*VP8Decoder)(unsafe.Pointer(dec)).Fskip_p)) >> int32(8)
   9928 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9929 		bit = libc.BoolInt32(value > split)
   9930 		if bit != 0 {
   9931 			range1 = range1 - split
   9932 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9933 		} else {
   9934 			range1 = split + uint32(1)
   9935 		}
   9936 		v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9937 		goto _31
   9938 	_31:
   9939 		shift = int32(7) ^ v1
   9940 		range1 = range1 << libc.Uint32FromInt32(shift)
   9941 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9942 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9943 		v6 = bit
   9944 		goto _33
   9945 	_33:
   9946 		(*VP8MBData)(unsafe.Pointer(block)).Fskip = libc.Uint8FromInt32(v6)
   9947 	}
   9948 	v2 = br2
   9949 	range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9950 	if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9951 		v3 = v2
   9952 		if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9953 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9954 			**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9955 			v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9956 			goto _37
   9957 		_37:
   9958 			bits = v4
   9959 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
   9960 			(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
   9961 			**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
   9962 		} else {
   9963 			VP8LoadFinalBytes(tls, v3)
   9964 		}
   9965 	}
   9966 	pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
   9967 	split = range1 * libc.Uint32FromInt32(int32(145)) >> int32(8)
   9968 	value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
   9969 	bit = libc.BoolInt32(value > split)
   9970 	if bit != 0 {
   9971 		range1 = range1 - split
   9972 		**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
   9973 	} else {
   9974 		range1 = split + uint32(1)
   9975 	}
   9976 	v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
   9977 	goto _39
   9978 _39:
   9979 	shift = int32(7) ^ v1
   9980 	range1 = range1 << libc.Uint32FromInt32(shift)
   9981 	**(**int32)(__ccgo_up(v2 + 12)) -= shift
   9982 	(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
   9983 	v6 = bit
   9984 	goto _41
   9985 _41:
   9986 	(*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 = libc.BoolUint8(!(v6 != 0))
   9987 	if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) {
   9988 		v2 = br2
   9989 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
   9990 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
   9991 			v3 = v2
   9992 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
   9993 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
   9994 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
   9995 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
   9996 				goto _46
   9997 			_46:
   9998 				bits = v4
   9999 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10000 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10001 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10002 			} else {
  10003 				VP8LoadFinalBytes(tls, v3)
  10004 			}
  10005 		}
  10006 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10007 		split = range1 * libc.Uint32FromInt32(int32(156)) >> int32(8)
  10008 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10009 		bit = libc.BoolInt32(value > split)
  10010 		if bit != 0 {
  10011 			range1 = range1 - split
  10012 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10013 		} else {
  10014 			range1 = split + uint32(1)
  10015 		}
  10016 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10017 		goto _48
  10018 	_48:
  10019 		shift = int32(7) ^ v6
  10020 		range1 = range1 << libc.Uint32FromInt32(shift)
  10021 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10022 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10023 		v8 = bit
  10024 		goto _50
  10025 	_50:
  10026 		if v8 != 0 {
  10027 			v10 = br2
  10028 			range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10029 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10030 				v11 = v10
  10031 				if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10032 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10033 					**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10034 					v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10035 					goto _55
  10036 				_55:
  10037 					bits = v12
  10038 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10039 					(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10040 					**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10041 				} else {
  10042 					VP8LoadFinalBytes(tls, v11)
  10043 				}
  10044 			}
  10045 			pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10046 			split = range1 * libc.Uint32FromInt32(int32(128)) >> int32(8)
  10047 			value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10048 			bit = libc.BoolInt32(value > split)
  10049 			if bit != 0 {
  10050 				range1 = range1 - split
  10051 				**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10052 			} else {
  10053 				range1 = split + uint32(1)
  10054 			}
  10055 			v16 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10056 			goto _57
  10057 		_57:
  10058 			shift = int32(7) ^ v16
  10059 			range1 = range1 << libc.Uint32FromInt32(shift)
  10060 			**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10061 			(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10062 			v22 = bit
  10063 			goto _59
  10064 		_59:
  10065 			if v22 != 0 {
  10066 				v14 = int32(TM_PRED)
  10067 			} else {
  10068 				v14 = int32(H_PRED)
  10069 			}
  10070 			v1 = v14
  10071 		} else {
  10072 			v18 = br2
  10073 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
  10074 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
  10075 				v19 = v18
  10076 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
  10077 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10078 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10079 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10080 					goto _64
  10081 				_64:
  10082 					bits = v20
  10083 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10084 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
  10085 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
  10086 				} else {
  10087 					VP8LoadFinalBytes(tls, v19)
  10088 				}
  10089 			}
  10090 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
  10091 			split = range1 * libc.Uint32FromInt32(int32(163)) >> int32(8)
  10092 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
  10093 			bit = libc.BoolInt32(value > split)
  10094 			if bit != 0 {
  10095 				range1 = range1 - split
  10096 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10097 			} else {
  10098 				range1 = split + uint32(1)
  10099 			}
  10100 			v30 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10101 			goto _66
  10102 		_66:
  10103 			shift = int32(7) ^ v30
  10104 			range1 = range1 << libc.Uint32FromInt32(shift)
  10105 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
  10106 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
  10107 			v32 = bit
  10108 			goto _68
  10109 		_68:
  10110 			if v32 != 0 {
  10111 				v24 = int32(V_PRED)
  10112 			} else {
  10113 				v24 = int32(DC_PRED)
  10114 			}
  10115 			v1 = v24
  10116 		}
  10117 		// Hardcoded 16x16 intra-mode decision tree.
  10118 		ymode = v1
  10119 		**(**uint8_t)(__ccgo_up(block + 769)) = libc.Uint8FromInt32(ymode)
  10120 		libc.X__builtin___memset_chk(tls, top, ymode, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10121 		libc.X__builtin___memset_chk(tls, left, ymode, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10122 	} else {
  10123 		modes = block + 769
  10124 		y = 0
  10125 		for {
  10126 			if !(y < int32(4)) {
  10127 				break
  10128 			}
  10129 			ymode1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(y))))
  10130 			x1 = 0
  10131 			for {
  10132 				if !(x1 < int32(4)) {
  10133 					break
  10134 				}
  10135 				prob1 = uintptr(unsafe.Pointer(&kBModesProba)) + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x1))))*90 + uintptr(ymode1)*9
  10136 				v2 = br2
  10137 				range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  10138 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  10139 					v3 = v2
  10140 					if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  10141 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10142 						**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10143 						v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10144 						goto _74
  10145 					_74:
  10146 						bits = v4
  10147 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10148 						(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10149 						**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10150 					} else {
  10151 						VP8LoadFinalBytes(tls, v3)
  10152 					}
  10153 				}
  10154 				pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10155 				split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob1)))) >> int32(8)
  10156 				value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10157 				bit = libc.BoolInt32(value > split)
  10158 				if bit != 0 {
  10159 					range1 = range1 - split
  10160 					**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10161 				} else {
  10162 					range1 = split + uint32(1)
  10163 				}
  10164 				v1 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10165 				goto _76
  10166 			_76:
  10167 				shift = int32(7) ^ v1
  10168 				range1 = range1 << libc.Uint32FromInt32(shift)
  10169 				**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10170 				(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10171 				v6 = bit
  10172 				goto _78
  10173 			_78:
  10174 				// Generic tree-parsing
  10175 				i = int32(kYModesIntra4[v6])
  10176 				for i > 0 {
  10177 					v10 = br2
  10178 					range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10179 					if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10180 						v11 = v10
  10181 						if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10182 							libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10183 							**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10184 							v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10185 							goto _82
  10186 						_82:
  10187 							bits = v12
  10188 							bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10189 							(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10190 							**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10191 						} else {
  10192 							VP8LoadFinalBytes(tls, v11)
  10193 						}
  10194 					}
  10195 					pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10196 					split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob1 + uintptr(i))))) >> int32(8)
  10197 					value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10198 					bit = libc.BoolInt32(value > split)
  10199 					if bit != 0 {
  10200 						range1 = range1 - split
  10201 						**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10202 					} else {
  10203 						range1 = split + uint32(1)
  10204 					}
  10205 					v8 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10206 					goto _84
  10207 				_84:
  10208 					shift = int32(7) ^ v8
  10209 					range1 = range1 << libc.Uint32FromInt32(shift)
  10210 					**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10211 					(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10212 					v14 = bit
  10213 					goto _86
  10214 				_86:
  10215 					i = int32(kYModesIntra4[int32(2)*i+v14])
  10216 				}
  10217 				ymode1 = -i
  10218 				**(**uint8_t)(__ccgo_up(top + uintptr(x1))) = libc.Uint8FromInt32(ymode1)
  10219 				goto _70
  10220 			_70:
  10221 				;
  10222 				x1 = x1 + 1
  10223 			}
  10224 			libc.X__builtin___memcpy_chk(tls, modes, top, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  10225 			modes = modes + uintptr(4)
  10226 			**(**uint8_t)(__ccgo_up(left + uintptr(y))) = libc.Uint8FromInt32(ymode1)
  10227 			goto _69
  10228 		_69:
  10229 			;
  10230 			y = y + 1
  10231 		}
  10232 	}
  10233 	// Hardcoded UVMode decision tree
  10234 	v2 = br2
  10235 	range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  10236 	if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  10237 		v3 = v2
  10238 		if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  10239 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10240 			**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10241 			v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10242 			goto _91
  10243 		_91:
  10244 			bits = v4
  10245 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10246 			(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  10247 			**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  10248 		} else {
  10249 			VP8LoadFinalBytes(tls, v3)
  10250 		}
  10251 	}
  10252 	pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  10253 	split = range1 * libc.Uint32FromInt32(int32(142)) >> int32(8)
  10254 	value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  10255 	bit = libc.BoolInt32(value > split)
  10256 	if bit != 0 {
  10257 		range1 = range1 - split
  10258 		**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10259 	} else {
  10260 		range1 = split + uint32(1)
  10261 	}
  10262 	v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10263 	goto _93
  10264 _93:
  10265 	shift = int32(7) ^ v6
  10266 	range1 = range1 << libc.Uint32FromInt32(shift)
  10267 	**(**int32)(__ccgo_up(v2 + 12)) -= shift
  10268 	(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  10269 	v8 = bit
  10270 	goto _95
  10271 _95:
  10272 	if !(v8 != 0) {
  10273 		v1 = int32(DC_PRED)
  10274 	} else {
  10275 		v10 = br2
  10276 		range1 = (*VP8BitReader)(unsafe.Pointer(v10)).Frange1
  10277 		if (*VP8BitReader)(unsafe.Pointer(v10)).Fbits < libc.Int32FromInt32(0) {
  10278 			v11 = v10
  10279 			if (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf_max {
  10280 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v11)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10281 				**(**uintptr)(__ccgo_up(v11 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10282 				v12 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10283 				goto _100
  10284 			_100:
  10285 				bits = v12
  10286 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10287 				(*VP8BitReader)(unsafe.Pointer(v11)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v11)).Fvalue<<libc.Int32FromInt32(BITS)
  10288 				**(**int32)(__ccgo_up(v11 + 12)) += int32(BITS)
  10289 			} else {
  10290 				VP8LoadFinalBytes(tls, v11)
  10291 			}
  10292 		}
  10293 		pos = (*VP8BitReader)(unsafe.Pointer(v10)).Fbits
  10294 		split = range1 * libc.Uint32FromInt32(int32(114)) >> int32(8)
  10295 		value = uint32((*VP8BitReader)(unsafe.Pointer(v10)).Fvalue >> pos)
  10296 		bit = libc.BoolInt32(value > split)
  10297 		if bit != 0 {
  10298 			range1 = range1 - split
  10299 			**(**bit_t)(__ccgo_up(v10)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10300 		} else {
  10301 			range1 = split + uint32(1)
  10302 		}
  10303 		v16 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10304 		goto _102
  10305 	_102:
  10306 		shift = int32(7) ^ v16
  10307 		range1 = range1 << libc.Uint32FromInt32(shift)
  10308 		**(**int32)(__ccgo_up(v10 + 12)) -= shift
  10309 		(*VP8BitReader)(unsafe.Pointer(v10)).Frange1 = range1 - uint32(1)
  10310 		v22 = bit
  10311 		goto _104
  10312 	_104:
  10313 		if !(v22 != 0) {
  10314 			v14 = int32(V_PRED)
  10315 		} else {
  10316 			v18 = br2
  10317 			range1 = (*VP8BitReader)(unsafe.Pointer(v18)).Frange1
  10318 			if (*VP8BitReader)(unsafe.Pointer(v18)).Fbits < libc.Int32FromInt32(0) {
  10319 				v19 = v18
  10320 				if (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf_max {
  10321 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v19)).Fbuf, uint64(8), ^__predefined_size_t(0))
  10322 					**(**uintptr)(__ccgo_up(v19 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  10323 					v20 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  10324 					goto _109
  10325 				_109:
  10326 					bits = v20
  10327 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  10328 					(*VP8BitReader)(unsafe.Pointer(v19)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v19)).Fvalue<<libc.Int32FromInt32(BITS)
  10329 					**(**int32)(__ccgo_up(v19 + 12)) += int32(BITS)
  10330 				} else {
  10331 					VP8LoadFinalBytes(tls, v19)
  10332 				}
  10333 			}
  10334 			pos = (*VP8BitReader)(unsafe.Pointer(v18)).Fbits
  10335 			split = range1 * libc.Uint32FromInt32(int32(183)) >> int32(8)
  10336 			value = uint32((*VP8BitReader)(unsafe.Pointer(v18)).Fvalue >> pos)
  10337 			bit = libc.BoolInt32(value > split)
  10338 			if bit != 0 {
  10339 				range1 = range1 - split
  10340 				**(**bit_t)(__ccgo_up(v18)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  10341 			} else {
  10342 				range1 = split + uint32(1)
  10343 			}
  10344 			v30 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  10345 			goto _111
  10346 		_111:
  10347 			shift = int32(7) ^ v30
  10348 			range1 = range1 << libc.Uint32FromInt32(shift)
  10349 			**(**int32)(__ccgo_up(v18 + 12)) -= shift
  10350 			(*VP8BitReader)(unsafe.Pointer(v18)).Frange1 = range1 - uint32(1)
  10351 			v32 = bit
  10352 			goto _113
  10353 		_113:
  10354 			if v32 != 0 {
  10355 				v24 = int32(TM_PRED)
  10356 			} else {
  10357 				v24 = int32(H_PRED)
  10358 			}
  10359 			v14 = v24
  10360 		}
  10361 		v1 = v14
  10362 	}
  10363 	(*VP8MBData)(unsafe.Pointer(block)).Fuvmode = libc.Uint8FromInt32(v1)
  10364 }
  10365 
  10366 func VP8ParseIntraModeRow(tls *libc.TLS, br uintptr, dec uintptr) (r int32) {
  10367 	var mb_x int32
  10368 	_ = mb_x
  10369 	mb_x = 0
  10370 	for {
  10371 		if !(mb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
  10372 			break
  10373 		}
  10374 		ParseIntraMode(tls, br, dec, mb_x)
  10375 		goto _1
  10376 	_1:
  10377 		;
  10378 		mb_x = mb_x + 1
  10379 	}
  10380 	return libc.BoolInt32(!((*VP8Decoder)(unsafe.Pointer(dec)).Fbr.Feof != 0))
  10381 }
  10382 
  10383 //------------------------------------------------------------------------------
  10384 // Paragraph 13
  10385 
  10386 var CoeffsUpdateProba = [4][8][3][11]uint8_t{
  10387 	0: {
  10388 		0: {
  10389 			0: {
  10390 				0:  uint8(255),
  10391 				1:  uint8(255),
  10392 				2:  uint8(255),
  10393 				3:  uint8(255),
  10394 				4:  uint8(255),
  10395 				5:  uint8(255),
  10396 				6:  uint8(255),
  10397 				7:  uint8(255),
  10398 				8:  uint8(255),
  10399 				9:  uint8(255),
  10400 				10: uint8(255),
  10401 			},
  10402 			1: {
  10403 				0:  uint8(255),
  10404 				1:  uint8(255),
  10405 				2:  uint8(255),
  10406 				3:  uint8(255),
  10407 				4:  uint8(255),
  10408 				5:  uint8(255),
  10409 				6:  uint8(255),
  10410 				7:  uint8(255),
  10411 				8:  uint8(255),
  10412 				9:  uint8(255),
  10413 				10: uint8(255),
  10414 			},
  10415 			2: {
  10416 				0:  uint8(255),
  10417 				1:  uint8(255),
  10418 				2:  uint8(255),
  10419 				3:  uint8(255),
  10420 				4:  uint8(255),
  10421 				5:  uint8(255),
  10422 				6:  uint8(255),
  10423 				7:  uint8(255),
  10424 				8:  uint8(255),
  10425 				9:  uint8(255),
  10426 				10: uint8(255),
  10427 			},
  10428 		},
  10429 		1: {
  10430 			0: {
  10431 				0:  uint8(176),
  10432 				1:  uint8(246),
  10433 				2:  uint8(255),
  10434 				3:  uint8(255),
  10435 				4:  uint8(255),
  10436 				5:  uint8(255),
  10437 				6:  uint8(255),
  10438 				7:  uint8(255),
  10439 				8:  uint8(255),
  10440 				9:  uint8(255),
  10441 				10: uint8(255),
  10442 			},
  10443 			1: {
  10444 				0:  uint8(223),
  10445 				1:  uint8(241),
  10446 				2:  uint8(252),
  10447 				3:  uint8(255),
  10448 				4:  uint8(255),
  10449 				5:  uint8(255),
  10450 				6:  uint8(255),
  10451 				7:  uint8(255),
  10452 				8:  uint8(255),
  10453 				9:  uint8(255),
  10454 				10: uint8(255),
  10455 			},
  10456 			2: {
  10457 				0:  uint8(249),
  10458 				1:  uint8(253),
  10459 				2:  uint8(253),
  10460 				3:  uint8(255),
  10461 				4:  uint8(255),
  10462 				5:  uint8(255),
  10463 				6:  uint8(255),
  10464 				7:  uint8(255),
  10465 				8:  uint8(255),
  10466 				9:  uint8(255),
  10467 				10: uint8(255),
  10468 			},
  10469 		},
  10470 		2: {
  10471 			0: {
  10472 				0:  uint8(255),
  10473 				1:  uint8(244),
  10474 				2:  uint8(252),
  10475 				3:  uint8(255),
  10476 				4:  uint8(255),
  10477 				5:  uint8(255),
  10478 				6:  uint8(255),
  10479 				7:  uint8(255),
  10480 				8:  uint8(255),
  10481 				9:  uint8(255),
  10482 				10: uint8(255),
  10483 			},
  10484 			1: {
  10485 				0:  uint8(234),
  10486 				1:  uint8(254),
  10487 				2:  uint8(254),
  10488 				3:  uint8(255),
  10489 				4:  uint8(255),
  10490 				5:  uint8(255),
  10491 				6:  uint8(255),
  10492 				7:  uint8(255),
  10493 				8:  uint8(255),
  10494 				9:  uint8(255),
  10495 				10: uint8(255),
  10496 			},
  10497 			2: {
  10498 				0:  uint8(253),
  10499 				1:  uint8(255),
  10500 				2:  uint8(255),
  10501 				3:  uint8(255),
  10502 				4:  uint8(255),
  10503 				5:  uint8(255),
  10504 				6:  uint8(255),
  10505 				7:  uint8(255),
  10506 				8:  uint8(255),
  10507 				9:  uint8(255),
  10508 				10: uint8(255),
  10509 			},
  10510 		},
  10511 		3: {
  10512 			0: {
  10513 				0:  uint8(255),
  10514 				1:  uint8(246),
  10515 				2:  uint8(254),
  10516 				3:  uint8(255),
  10517 				4:  uint8(255),
  10518 				5:  uint8(255),
  10519 				6:  uint8(255),
  10520 				7:  uint8(255),
  10521 				8:  uint8(255),
  10522 				9:  uint8(255),
  10523 				10: uint8(255),
  10524 			},
  10525 			1: {
  10526 				0:  uint8(239),
  10527 				1:  uint8(253),
  10528 				2:  uint8(254),
  10529 				3:  uint8(255),
  10530 				4:  uint8(255),
  10531 				5:  uint8(255),
  10532 				6:  uint8(255),
  10533 				7:  uint8(255),
  10534 				8:  uint8(255),
  10535 				9:  uint8(255),
  10536 				10: uint8(255),
  10537 			},
  10538 			2: {
  10539 				0:  uint8(254),
  10540 				1:  uint8(255),
  10541 				2:  uint8(254),
  10542 				3:  uint8(255),
  10543 				4:  uint8(255),
  10544 				5:  uint8(255),
  10545 				6:  uint8(255),
  10546 				7:  uint8(255),
  10547 				8:  uint8(255),
  10548 				9:  uint8(255),
  10549 				10: uint8(255),
  10550 			},
  10551 		},
  10552 		4: {
  10553 			0: {
  10554 				0:  uint8(255),
  10555 				1:  uint8(248),
  10556 				2:  uint8(254),
  10557 				3:  uint8(255),
  10558 				4:  uint8(255),
  10559 				5:  uint8(255),
  10560 				6:  uint8(255),
  10561 				7:  uint8(255),
  10562 				8:  uint8(255),
  10563 				9:  uint8(255),
  10564 				10: uint8(255),
  10565 			},
  10566 			1: {
  10567 				0:  uint8(251),
  10568 				1:  uint8(255),
  10569 				2:  uint8(254),
  10570 				3:  uint8(255),
  10571 				4:  uint8(255),
  10572 				5:  uint8(255),
  10573 				6:  uint8(255),
  10574 				7:  uint8(255),
  10575 				8:  uint8(255),
  10576 				9:  uint8(255),
  10577 				10: uint8(255),
  10578 			},
  10579 			2: {
  10580 				0:  uint8(255),
  10581 				1:  uint8(255),
  10582 				2:  uint8(255),
  10583 				3:  uint8(255),
  10584 				4:  uint8(255),
  10585 				5:  uint8(255),
  10586 				6:  uint8(255),
  10587 				7:  uint8(255),
  10588 				8:  uint8(255),
  10589 				9:  uint8(255),
  10590 				10: uint8(255),
  10591 			},
  10592 		},
  10593 		5: {
  10594 			0: {
  10595 				0:  uint8(255),
  10596 				1:  uint8(253),
  10597 				2:  uint8(254),
  10598 				3:  uint8(255),
  10599 				4:  uint8(255),
  10600 				5:  uint8(255),
  10601 				6:  uint8(255),
  10602 				7:  uint8(255),
  10603 				8:  uint8(255),
  10604 				9:  uint8(255),
  10605 				10: uint8(255),
  10606 			},
  10607 			1: {
  10608 				0:  uint8(251),
  10609 				1:  uint8(254),
  10610 				2:  uint8(254),
  10611 				3:  uint8(255),
  10612 				4:  uint8(255),
  10613 				5:  uint8(255),
  10614 				6:  uint8(255),
  10615 				7:  uint8(255),
  10616 				8:  uint8(255),
  10617 				9:  uint8(255),
  10618 				10: uint8(255),
  10619 			},
  10620 			2: {
  10621 				0:  uint8(254),
  10622 				1:  uint8(255),
  10623 				2:  uint8(254),
  10624 				3:  uint8(255),
  10625 				4:  uint8(255),
  10626 				5:  uint8(255),
  10627 				6:  uint8(255),
  10628 				7:  uint8(255),
  10629 				8:  uint8(255),
  10630 				9:  uint8(255),
  10631 				10: uint8(255),
  10632 			},
  10633 		},
  10634 		6: {
  10635 			0: {
  10636 				0:  uint8(255),
  10637 				1:  uint8(254),
  10638 				2:  uint8(253),
  10639 				3:  uint8(255),
  10640 				4:  uint8(254),
  10641 				5:  uint8(255),
  10642 				6:  uint8(255),
  10643 				7:  uint8(255),
  10644 				8:  uint8(255),
  10645 				9:  uint8(255),
  10646 				10: uint8(255),
  10647 			},
  10648 			1: {
  10649 				0:  uint8(250),
  10650 				1:  uint8(255),
  10651 				2:  uint8(254),
  10652 				3:  uint8(255),
  10653 				4:  uint8(254),
  10654 				5:  uint8(255),
  10655 				6:  uint8(255),
  10656 				7:  uint8(255),
  10657 				8:  uint8(255),
  10658 				9:  uint8(255),
  10659 				10: uint8(255),
  10660 			},
  10661 			2: {
  10662 				0:  uint8(254),
  10663 				1:  uint8(255),
  10664 				2:  uint8(255),
  10665 				3:  uint8(255),
  10666 				4:  uint8(255),
  10667 				5:  uint8(255),
  10668 				6:  uint8(255),
  10669 				7:  uint8(255),
  10670 				8:  uint8(255),
  10671 				9:  uint8(255),
  10672 				10: uint8(255),
  10673 			},
  10674 		},
  10675 		7: {
  10676 			0: {
  10677 				0:  uint8(255),
  10678 				1:  uint8(255),
  10679 				2:  uint8(255),
  10680 				3:  uint8(255),
  10681 				4:  uint8(255),
  10682 				5:  uint8(255),
  10683 				6:  uint8(255),
  10684 				7:  uint8(255),
  10685 				8:  uint8(255),
  10686 				9:  uint8(255),
  10687 				10: uint8(255),
  10688 			},
  10689 			1: {
  10690 				0:  uint8(255),
  10691 				1:  uint8(255),
  10692 				2:  uint8(255),
  10693 				3:  uint8(255),
  10694 				4:  uint8(255),
  10695 				5:  uint8(255),
  10696 				6:  uint8(255),
  10697 				7:  uint8(255),
  10698 				8:  uint8(255),
  10699 				9:  uint8(255),
  10700 				10: uint8(255),
  10701 			},
  10702 			2: {
  10703 				0:  uint8(255),
  10704 				1:  uint8(255),
  10705 				2:  uint8(255),
  10706 				3:  uint8(255),
  10707 				4:  uint8(255),
  10708 				5:  uint8(255),
  10709 				6:  uint8(255),
  10710 				7:  uint8(255),
  10711 				8:  uint8(255),
  10712 				9:  uint8(255),
  10713 				10: uint8(255),
  10714 			},
  10715 		},
  10716 	},
  10717 	1: {
  10718 		0: {
  10719 			0: {
  10720 				0:  uint8(217),
  10721 				1:  uint8(255),
  10722 				2:  uint8(255),
  10723 				3:  uint8(255),
  10724 				4:  uint8(255),
  10725 				5:  uint8(255),
  10726 				6:  uint8(255),
  10727 				7:  uint8(255),
  10728 				8:  uint8(255),
  10729 				9:  uint8(255),
  10730 				10: uint8(255),
  10731 			},
  10732 			1: {
  10733 				0:  uint8(225),
  10734 				1:  uint8(252),
  10735 				2:  uint8(241),
  10736 				3:  uint8(253),
  10737 				4:  uint8(255),
  10738 				5:  uint8(255),
  10739 				6:  uint8(254),
  10740 				7:  uint8(255),
  10741 				8:  uint8(255),
  10742 				9:  uint8(255),
  10743 				10: uint8(255),
  10744 			},
  10745 			2: {
  10746 				0:  uint8(234),
  10747 				1:  uint8(250),
  10748 				2:  uint8(241),
  10749 				3:  uint8(250),
  10750 				4:  uint8(253),
  10751 				5:  uint8(255),
  10752 				6:  uint8(253),
  10753 				7:  uint8(254),
  10754 				8:  uint8(255),
  10755 				9:  uint8(255),
  10756 				10: uint8(255),
  10757 			},
  10758 		},
  10759 		1: {
  10760 			0: {
  10761 				0:  uint8(255),
  10762 				1:  uint8(254),
  10763 				2:  uint8(255),
  10764 				3:  uint8(255),
  10765 				4:  uint8(255),
  10766 				5:  uint8(255),
  10767 				6:  uint8(255),
  10768 				7:  uint8(255),
  10769 				8:  uint8(255),
  10770 				9:  uint8(255),
  10771 				10: uint8(255),
  10772 			},
  10773 			1: {
  10774 				0:  uint8(223),
  10775 				1:  uint8(254),
  10776 				2:  uint8(254),
  10777 				3:  uint8(255),
  10778 				4:  uint8(255),
  10779 				5:  uint8(255),
  10780 				6:  uint8(255),
  10781 				7:  uint8(255),
  10782 				8:  uint8(255),
  10783 				9:  uint8(255),
  10784 				10: uint8(255),
  10785 			},
  10786 			2: {
  10787 				0:  uint8(238),
  10788 				1:  uint8(253),
  10789 				2:  uint8(254),
  10790 				3:  uint8(254),
  10791 				4:  uint8(255),
  10792 				5:  uint8(255),
  10793 				6:  uint8(255),
  10794 				7:  uint8(255),
  10795 				8:  uint8(255),
  10796 				9:  uint8(255),
  10797 				10: uint8(255),
  10798 			},
  10799 		},
  10800 		2: {
  10801 			0: {
  10802 				0:  uint8(255),
  10803 				1:  uint8(248),
  10804 				2:  uint8(254),
  10805 				3:  uint8(255),
  10806 				4:  uint8(255),
  10807 				5:  uint8(255),
  10808 				6:  uint8(255),
  10809 				7:  uint8(255),
  10810 				8:  uint8(255),
  10811 				9:  uint8(255),
  10812 				10: uint8(255),
  10813 			},
  10814 			1: {
  10815 				0:  uint8(249),
  10816 				1:  uint8(254),
  10817 				2:  uint8(255),
  10818 				3:  uint8(255),
  10819 				4:  uint8(255),
  10820 				5:  uint8(255),
  10821 				6:  uint8(255),
  10822 				7:  uint8(255),
  10823 				8:  uint8(255),
  10824 				9:  uint8(255),
  10825 				10: uint8(255),
  10826 			},
  10827 			2: {
  10828 				0:  uint8(255),
  10829 				1:  uint8(255),
  10830 				2:  uint8(255),
  10831 				3:  uint8(255),
  10832 				4:  uint8(255),
  10833 				5:  uint8(255),
  10834 				6:  uint8(255),
  10835 				7:  uint8(255),
  10836 				8:  uint8(255),
  10837 				9:  uint8(255),
  10838 				10: uint8(255),
  10839 			},
  10840 		},
  10841 		3: {
  10842 			0: {
  10843 				0:  uint8(255),
  10844 				1:  uint8(253),
  10845 				2:  uint8(255),
  10846 				3:  uint8(255),
  10847 				4:  uint8(255),
  10848 				5:  uint8(255),
  10849 				6:  uint8(255),
  10850 				7:  uint8(255),
  10851 				8:  uint8(255),
  10852 				9:  uint8(255),
  10853 				10: uint8(255),
  10854 			},
  10855 			1: {
  10856 				0:  uint8(247),
  10857 				1:  uint8(254),
  10858 				2:  uint8(255),
  10859 				3:  uint8(255),
  10860 				4:  uint8(255),
  10861 				5:  uint8(255),
  10862 				6:  uint8(255),
  10863 				7:  uint8(255),
  10864 				8:  uint8(255),
  10865 				9:  uint8(255),
  10866 				10: uint8(255),
  10867 			},
  10868 			2: {
  10869 				0:  uint8(255),
  10870 				1:  uint8(255),
  10871 				2:  uint8(255),
  10872 				3:  uint8(255),
  10873 				4:  uint8(255),
  10874 				5:  uint8(255),
  10875 				6:  uint8(255),
  10876 				7:  uint8(255),
  10877 				8:  uint8(255),
  10878 				9:  uint8(255),
  10879 				10: uint8(255),
  10880 			},
  10881 		},
  10882 		4: {
  10883 			0: {
  10884 				0:  uint8(255),
  10885 				1:  uint8(253),
  10886 				2:  uint8(254),
  10887 				3:  uint8(255),
  10888 				4:  uint8(255),
  10889 				5:  uint8(255),
  10890 				6:  uint8(255),
  10891 				7:  uint8(255),
  10892 				8:  uint8(255),
  10893 				9:  uint8(255),
  10894 				10: uint8(255),
  10895 			},
  10896 			1: {
  10897 				0:  uint8(252),
  10898 				1:  uint8(255),
  10899 				2:  uint8(255),
  10900 				3:  uint8(255),
  10901 				4:  uint8(255),
  10902 				5:  uint8(255),
  10903 				6:  uint8(255),
  10904 				7:  uint8(255),
  10905 				8:  uint8(255),
  10906 				9:  uint8(255),
  10907 				10: uint8(255),
  10908 			},
  10909 			2: {
  10910 				0:  uint8(255),
  10911 				1:  uint8(255),
  10912 				2:  uint8(255),
  10913 				3:  uint8(255),
  10914 				4:  uint8(255),
  10915 				5:  uint8(255),
  10916 				6:  uint8(255),
  10917 				7:  uint8(255),
  10918 				8:  uint8(255),
  10919 				9:  uint8(255),
  10920 				10: uint8(255),
  10921 			},
  10922 		},
  10923 		5: {
  10924 			0: {
  10925 				0:  uint8(255),
  10926 				1:  uint8(254),
  10927 				2:  uint8(254),
  10928 				3:  uint8(255),
  10929 				4:  uint8(255),
  10930 				5:  uint8(255),
  10931 				6:  uint8(255),
  10932 				7:  uint8(255),
  10933 				8:  uint8(255),
  10934 				9:  uint8(255),
  10935 				10: uint8(255),
  10936 			},
  10937 			1: {
  10938 				0:  uint8(253),
  10939 				1:  uint8(255),
  10940 				2:  uint8(255),
  10941 				3:  uint8(255),
  10942 				4:  uint8(255),
  10943 				5:  uint8(255),
  10944 				6:  uint8(255),
  10945 				7:  uint8(255),
  10946 				8:  uint8(255),
  10947 				9:  uint8(255),
  10948 				10: uint8(255),
  10949 			},
  10950 			2: {
  10951 				0:  uint8(255),
  10952 				1:  uint8(255),
  10953 				2:  uint8(255),
  10954 				3:  uint8(255),
  10955 				4:  uint8(255),
  10956 				5:  uint8(255),
  10957 				6:  uint8(255),
  10958 				7:  uint8(255),
  10959 				8:  uint8(255),
  10960 				9:  uint8(255),
  10961 				10: uint8(255),
  10962 			},
  10963 		},
  10964 		6: {
  10965 			0: {
  10966 				0:  uint8(255),
  10967 				1:  uint8(254),
  10968 				2:  uint8(253),
  10969 				3:  uint8(255),
  10970 				4:  uint8(255),
  10971 				5:  uint8(255),
  10972 				6:  uint8(255),
  10973 				7:  uint8(255),
  10974 				8:  uint8(255),
  10975 				9:  uint8(255),
  10976 				10: uint8(255),
  10977 			},
  10978 			1: {
  10979 				0:  uint8(250),
  10980 				1:  uint8(255),
  10981 				2:  uint8(255),
  10982 				3:  uint8(255),
  10983 				4:  uint8(255),
  10984 				5:  uint8(255),
  10985 				6:  uint8(255),
  10986 				7:  uint8(255),
  10987 				8:  uint8(255),
  10988 				9:  uint8(255),
  10989 				10: uint8(255),
  10990 			},
  10991 			2: {
  10992 				0:  uint8(254),
  10993 				1:  uint8(255),
  10994 				2:  uint8(255),
  10995 				3:  uint8(255),
  10996 				4:  uint8(255),
  10997 				5:  uint8(255),
  10998 				6:  uint8(255),
  10999 				7:  uint8(255),
  11000 				8:  uint8(255),
  11001 				9:  uint8(255),
  11002 				10: uint8(255),
  11003 			},
  11004 		},
  11005 		7: {
  11006 			0: {
  11007 				0:  uint8(255),
  11008 				1:  uint8(255),
  11009 				2:  uint8(255),
  11010 				3:  uint8(255),
  11011 				4:  uint8(255),
  11012 				5:  uint8(255),
  11013 				6:  uint8(255),
  11014 				7:  uint8(255),
  11015 				8:  uint8(255),
  11016 				9:  uint8(255),
  11017 				10: uint8(255),
  11018 			},
  11019 			1: {
  11020 				0:  uint8(255),
  11021 				1:  uint8(255),
  11022 				2:  uint8(255),
  11023 				3:  uint8(255),
  11024 				4:  uint8(255),
  11025 				5:  uint8(255),
  11026 				6:  uint8(255),
  11027 				7:  uint8(255),
  11028 				8:  uint8(255),
  11029 				9:  uint8(255),
  11030 				10: uint8(255),
  11031 			},
  11032 			2: {
  11033 				0:  uint8(255),
  11034 				1:  uint8(255),
  11035 				2:  uint8(255),
  11036 				3:  uint8(255),
  11037 				4:  uint8(255),
  11038 				5:  uint8(255),
  11039 				6:  uint8(255),
  11040 				7:  uint8(255),
  11041 				8:  uint8(255),
  11042 				9:  uint8(255),
  11043 				10: uint8(255),
  11044 			},
  11045 		},
  11046 	},
  11047 	2: {
  11048 		0: {
  11049 			0: {
  11050 				0:  uint8(186),
  11051 				1:  uint8(251),
  11052 				2:  uint8(250),
  11053 				3:  uint8(255),
  11054 				4:  uint8(255),
  11055 				5:  uint8(255),
  11056 				6:  uint8(255),
  11057 				7:  uint8(255),
  11058 				8:  uint8(255),
  11059 				9:  uint8(255),
  11060 				10: uint8(255),
  11061 			},
  11062 			1: {
  11063 				0:  uint8(234),
  11064 				1:  uint8(251),
  11065 				2:  uint8(244),
  11066 				3:  uint8(254),
  11067 				4:  uint8(255),
  11068 				5:  uint8(255),
  11069 				6:  uint8(255),
  11070 				7:  uint8(255),
  11071 				8:  uint8(255),
  11072 				9:  uint8(255),
  11073 				10: uint8(255),
  11074 			},
  11075 			2: {
  11076 				0:  uint8(251),
  11077 				1:  uint8(251),
  11078 				2:  uint8(243),
  11079 				3:  uint8(253),
  11080 				4:  uint8(254),
  11081 				5:  uint8(255),
  11082 				6:  uint8(254),
  11083 				7:  uint8(255),
  11084 				8:  uint8(255),
  11085 				9:  uint8(255),
  11086 				10: uint8(255),
  11087 			},
  11088 		},
  11089 		1: {
  11090 			0: {
  11091 				0:  uint8(255),
  11092 				1:  uint8(253),
  11093 				2:  uint8(254),
  11094 				3:  uint8(255),
  11095 				4:  uint8(255),
  11096 				5:  uint8(255),
  11097 				6:  uint8(255),
  11098 				7:  uint8(255),
  11099 				8:  uint8(255),
  11100 				9:  uint8(255),
  11101 				10: uint8(255),
  11102 			},
  11103 			1: {
  11104 				0:  uint8(236),
  11105 				1:  uint8(253),
  11106 				2:  uint8(254),
  11107 				3:  uint8(255),
  11108 				4:  uint8(255),
  11109 				5:  uint8(255),
  11110 				6:  uint8(255),
  11111 				7:  uint8(255),
  11112 				8:  uint8(255),
  11113 				9:  uint8(255),
  11114 				10: uint8(255),
  11115 			},
  11116 			2: {
  11117 				0:  uint8(251),
  11118 				1:  uint8(253),
  11119 				2:  uint8(253),
  11120 				3:  uint8(254),
  11121 				4:  uint8(254),
  11122 				5:  uint8(255),
  11123 				6:  uint8(255),
  11124 				7:  uint8(255),
  11125 				8:  uint8(255),
  11126 				9:  uint8(255),
  11127 				10: uint8(255),
  11128 			},
  11129 		},
  11130 		2: {
  11131 			0: {
  11132 				0:  uint8(255),
  11133 				1:  uint8(254),
  11134 				2:  uint8(254),
  11135 				3:  uint8(255),
  11136 				4:  uint8(255),
  11137 				5:  uint8(255),
  11138 				6:  uint8(255),
  11139 				7:  uint8(255),
  11140 				8:  uint8(255),
  11141 				9:  uint8(255),
  11142 				10: uint8(255),
  11143 			},
  11144 			1: {
  11145 				0:  uint8(254),
  11146 				1:  uint8(254),
  11147 				2:  uint8(254),
  11148 				3:  uint8(255),
  11149 				4:  uint8(255),
  11150 				5:  uint8(255),
  11151 				6:  uint8(255),
  11152 				7:  uint8(255),
  11153 				8:  uint8(255),
  11154 				9:  uint8(255),
  11155 				10: uint8(255),
  11156 			},
  11157 			2: {
  11158 				0:  uint8(255),
  11159 				1:  uint8(255),
  11160 				2:  uint8(255),
  11161 				3:  uint8(255),
  11162 				4:  uint8(255),
  11163 				5:  uint8(255),
  11164 				6:  uint8(255),
  11165 				7:  uint8(255),
  11166 				8:  uint8(255),
  11167 				9:  uint8(255),
  11168 				10: uint8(255),
  11169 			},
  11170 		},
  11171 		3: {
  11172 			0: {
  11173 				0:  uint8(255),
  11174 				1:  uint8(254),
  11175 				2:  uint8(255),
  11176 				3:  uint8(255),
  11177 				4:  uint8(255),
  11178 				5:  uint8(255),
  11179 				6:  uint8(255),
  11180 				7:  uint8(255),
  11181 				8:  uint8(255),
  11182 				9:  uint8(255),
  11183 				10: uint8(255),
  11184 			},
  11185 			1: {
  11186 				0:  uint8(254),
  11187 				1:  uint8(254),
  11188 				2:  uint8(255),
  11189 				3:  uint8(255),
  11190 				4:  uint8(255),
  11191 				5:  uint8(255),
  11192 				6:  uint8(255),
  11193 				7:  uint8(255),
  11194 				8:  uint8(255),
  11195 				9:  uint8(255),
  11196 				10: uint8(255),
  11197 			},
  11198 			2: {
  11199 				0:  uint8(254),
  11200 				1:  uint8(255),
  11201 				2:  uint8(255),
  11202 				3:  uint8(255),
  11203 				4:  uint8(255),
  11204 				5:  uint8(255),
  11205 				6:  uint8(255),
  11206 				7:  uint8(255),
  11207 				8:  uint8(255),
  11208 				9:  uint8(255),
  11209 				10: uint8(255),
  11210 			},
  11211 		},
  11212 		4: {
  11213 			0: {
  11214 				0:  uint8(255),
  11215 				1:  uint8(255),
  11216 				2:  uint8(255),
  11217 				3:  uint8(255),
  11218 				4:  uint8(255),
  11219 				5:  uint8(255),
  11220 				6:  uint8(255),
  11221 				7:  uint8(255),
  11222 				8:  uint8(255),
  11223 				9:  uint8(255),
  11224 				10: uint8(255),
  11225 			},
  11226 			1: {
  11227 				0:  uint8(254),
  11228 				1:  uint8(255),
  11229 				2:  uint8(255),
  11230 				3:  uint8(255),
  11231 				4:  uint8(255),
  11232 				5:  uint8(255),
  11233 				6:  uint8(255),
  11234 				7:  uint8(255),
  11235 				8:  uint8(255),
  11236 				9:  uint8(255),
  11237 				10: uint8(255),
  11238 			},
  11239 			2: {
  11240 				0:  uint8(255),
  11241 				1:  uint8(255),
  11242 				2:  uint8(255),
  11243 				3:  uint8(255),
  11244 				4:  uint8(255),
  11245 				5:  uint8(255),
  11246 				6:  uint8(255),
  11247 				7:  uint8(255),
  11248 				8:  uint8(255),
  11249 				9:  uint8(255),
  11250 				10: uint8(255),
  11251 			},
  11252 		},
  11253 		5: {
  11254 			0: {
  11255 				0:  uint8(255),
  11256 				1:  uint8(255),
  11257 				2:  uint8(255),
  11258 				3:  uint8(255),
  11259 				4:  uint8(255),
  11260 				5:  uint8(255),
  11261 				6:  uint8(255),
  11262 				7:  uint8(255),
  11263 				8:  uint8(255),
  11264 				9:  uint8(255),
  11265 				10: uint8(255),
  11266 			},
  11267 			1: {
  11268 				0:  uint8(255),
  11269 				1:  uint8(255),
  11270 				2:  uint8(255),
  11271 				3:  uint8(255),
  11272 				4:  uint8(255),
  11273 				5:  uint8(255),
  11274 				6:  uint8(255),
  11275 				7:  uint8(255),
  11276 				8:  uint8(255),
  11277 				9:  uint8(255),
  11278 				10: uint8(255),
  11279 			},
  11280 			2: {
  11281 				0:  uint8(255),
  11282 				1:  uint8(255),
  11283 				2:  uint8(255),
  11284 				3:  uint8(255),
  11285 				4:  uint8(255),
  11286 				5:  uint8(255),
  11287 				6:  uint8(255),
  11288 				7:  uint8(255),
  11289 				8:  uint8(255),
  11290 				9:  uint8(255),
  11291 				10: uint8(255),
  11292 			},
  11293 		},
  11294 		6: {
  11295 			0: {
  11296 				0:  uint8(255),
  11297 				1:  uint8(255),
  11298 				2:  uint8(255),
  11299 				3:  uint8(255),
  11300 				4:  uint8(255),
  11301 				5:  uint8(255),
  11302 				6:  uint8(255),
  11303 				7:  uint8(255),
  11304 				8:  uint8(255),
  11305 				9:  uint8(255),
  11306 				10: uint8(255),
  11307 			},
  11308 			1: {
  11309 				0:  uint8(255),
  11310 				1:  uint8(255),
  11311 				2:  uint8(255),
  11312 				3:  uint8(255),
  11313 				4:  uint8(255),
  11314 				5:  uint8(255),
  11315 				6:  uint8(255),
  11316 				7:  uint8(255),
  11317 				8:  uint8(255),
  11318 				9:  uint8(255),
  11319 				10: uint8(255),
  11320 			},
  11321 			2: {
  11322 				0:  uint8(255),
  11323 				1:  uint8(255),
  11324 				2:  uint8(255),
  11325 				3:  uint8(255),
  11326 				4:  uint8(255),
  11327 				5:  uint8(255),
  11328 				6:  uint8(255),
  11329 				7:  uint8(255),
  11330 				8:  uint8(255),
  11331 				9:  uint8(255),
  11332 				10: uint8(255),
  11333 			},
  11334 		},
  11335 		7: {
  11336 			0: {
  11337 				0:  uint8(255),
  11338 				1:  uint8(255),
  11339 				2:  uint8(255),
  11340 				3:  uint8(255),
  11341 				4:  uint8(255),
  11342 				5:  uint8(255),
  11343 				6:  uint8(255),
  11344 				7:  uint8(255),
  11345 				8:  uint8(255),
  11346 				9:  uint8(255),
  11347 				10: uint8(255),
  11348 			},
  11349 			1: {
  11350 				0:  uint8(255),
  11351 				1:  uint8(255),
  11352 				2:  uint8(255),
  11353 				3:  uint8(255),
  11354 				4:  uint8(255),
  11355 				5:  uint8(255),
  11356 				6:  uint8(255),
  11357 				7:  uint8(255),
  11358 				8:  uint8(255),
  11359 				9:  uint8(255),
  11360 				10: uint8(255),
  11361 			},
  11362 			2: {
  11363 				0:  uint8(255),
  11364 				1:  uint8(255),
  11365 				2:  uint8(255),
  11366 				3:  uint8(255),
  11367 				4:  uint8(255),
  11368 				5:  uint8(255),
  11369 				6:  uint8(255),
  11370 				7:  uint8(255),
  11371 				8:  uint8(255),
  11372 				9:  uint8(255),
  11373 				10: uint8(255),
  11374 			},
  11375 		},
  11376 	},
  11377 	3: {
  11378 		0: {
  11379 			0: {
  11380 				0:  uint8(248),
  11381 				1:  uint8(255),
  11382 				2:  uint8(255),
  11383 				3:  uint8(255),
  11384 				4:  uint8(255),
  11385 				5:  uint8(255),
  11386 				6:  uint8(255),
  11387 				7:  uint8(255),
  11388 				8:  uint8(255),
  11389 				9:  uint8(255),
  11390 				10: uint8(255),
  11391 			},
  11392 			1: {
  11393 				0:  uint8(250),
  11394 				1:  uint8(254),
  11395 				2:  uint8(252),
  11396 				3:  uint8(254),
  11397 				4:  uint8(255),
  11398 				5:  uint8(255),
  11399 				6:  uint8(255),
  11400 				7:  uint8(255),
  11401 				8:  uint8(255),
  11402 				9:  uint8(255),
  11403 				10: uint8(255),
  11404 			},
  11405 			2: {
  11406 				0:  uint8(248),
  11407 				1:  uint8(254),
  11408 				2:  uint8(249),
  11409 				3:  uint8(253),
  11410 				4:  uint8(255),
  11411 				5:  uint8(255),
  11412 				6:  uint8(255),
  11413 				7:  uint8(255),
  11414 				8:  uint8(255),
  11415 				9:  uint8(255),
  11416 				10: uint8(255),
  11417 			},
  11418 		},
  11419 		1: {
  11420 			0: {
  11421 				0:  uint8(255),
  11422 				1:  uint8(253),
  11423 				2:  uint8(253),
  11424 				3:  uint8(255),
  11425 				4:  uint8(255),
  11426 				5:  uint8(255),
  11427 				6:  uint8(255),
  11428 				7:  uint8(255),
  11429 				8:  uint8(255),
  11430 				9:  uint8(255),
  11431 				10: uint8(255),
  11432 			},
  11433 			1: {
  11434 				0:  uint8(246),
  11435 				1:  uint8(253),
  11436 				2:  uint8(253),
  11437 				3:  uint8(255),
  11438 				4:  uint8(255),
  11439 				5:  uint8(255),
  11440 				6:  uint8(255),
  11441 				7:  uint8(255),
  11442 				8:  uint8(255),
  11443 				9:  uint8(255),
  11444 				10: uint8(255),
  11445 			},
  11446 			2: {
  11447 				0:  uint8(252),
  11448 				1:  uint8(254),
  11449 				2:  uint8(251),
  11450 				3:  uint8(254),
  11451 				4:  uint8(254),
  11452 				5:  uint8(255),
  11453 				6:  uint8(255),
  11454 				7:  uint8(255),
  11455 				8:  uint8(255),
  11456 				9:  uint8(255),
  11457 				10: uint8(255),
  11458 			},
  11459 		},
  11460 		2: {
  11461 			0: {
  11462 				0:  uint8(255),
  11463 				1:  uint8(254),
  11464 				2:  uint8(252),
  11465 				3:  uint8(255),
  11466 				4:  uint8(255),
  11467 				5:  uint8(255),
  11468 				6:  uint8(255),
  11469 				7:  uint8(255),
  11470 				8:  uint8(255),
  11471 				9:  uint8(255),
  11472 				10: uint8(255),
  11473 			},
  11474 			1: {
  11475 				0:  uint8(248),
  11476 				1:  uint8(254),
  11477 				2:  uint8(253),
  11478 				3:  uint8(255),
  11479 				4:  uint8(255),
  11480 				5:  uint8(255),
  11481 				6:  uint8(255),
  11482 				7:  uint8(255),
  11483 				8:  uint8(255),
  11484 				9:  uint8(255),
  11485 				10: uint8(255),
  11486 			},
  11487 			2: {
  11488 				0:  uint8(253),
  11489 				1:  uint8(255),
  11490 				2:  uint8(254),
  11491 				3:  uint8(254),
  11492 				4:  uint8(255),
  11493 				5:  uint8(255),
  11494 				6:  uint8(255),
  11495 				7:  uint8(255),
  11496 				8:  uint8(255),
  11497 				9:  uint8(255),
  11498 				10: uint8(255),
  11499 			},
  11500 		},
  11501 		3: {
  11502 			0: {
  11503 				0:  uint8(255),
  11504 				1:  uint8(251),
  11505 				2:  uint8(254),
  11506 				3:  uint8(255),
  11507 				4:  uint8(255),
  11508 				5:  uint8(255),
  11509 				6:  uint8(255),
  11510 				7:  uint8(255),
  11511 				8:  uint8(255),
  11512 				9:  uint8(255),
  11513 				10: uint8(255),
  11514 			},
  11515 			1: {
  11516 				0:  uint8(245),
  11517 				1:  uint8(251),
  11518 				2:  uint8(254),
  11519 				3:  uint8(255),
  11520 				4:  uint8(255),
  11521 				5:  uint8(255),
  11522 				6:  uint8(255),
  11523 				7:  uint8(255),
  11524 				8:  uint8(255),
  11525 				9:  uint8(255),
  11526 				10: uint8(255),
  11527 			},
  11528 			2: {
  11529 				0:  uint8(253),
  11530 				1:  uint8(253),
  11531 				2:  uint8(254),
  11532 				3:  uint8(255),
  11533 				4:  uint8(255),
  11534 				5:  uint8(255),
  11535 				6:  uint8(255),
  11536 				7:  uint8(255),
  11537 				8:  uint8(255),
  11538 				9:  uint8(255),
  11539 				10: uint8(255),
  11540 			},
  11541 		},
  11542 		4: {
  11543 			0: {
  11544 				0:  uint8(255),
  11545 				1:  uint8(251),
  11546 				2:  uint8(253),
  11547 				3:  uint8(255),
  11548 				4:  uint8(255),
  11549 				5:  uint8(255),
  11550 				6:  uint8(255),
  11551 				7:  uint8(255),
  11552 				8:  uint8(255),
  11553 				9:  uint8(255),
  11554 				10: uint8(255),
  11555 			},
  11556 			1: {
  11557 				0:  uint8(252),
  11558 				1:  uint8(253),
  11559 				2:  uint8(254),
  11560 				3:  uint8(255),
  11561 				4:  uint8(255),
  11562 				5:  uint8(255),
  11563 				6:  uint8(255),
  11564 				7:  uint8(255),
  11565 				8:  uint8(255),
  11566 				9:  uint8(255),
  11567 				10: uint8(255),
  11568 			},
  11569 			2: {
  11570 				0:  uint8(255),
  11571 				1:  uint8(254),
  11572 				2:  uint8(255),
  11573 				3:  uint8(255),
  11574 				4:  uint8(255),
  11575 				5:  uint8(255),
  11576 				6:  uint8(255),
  11577 				7:  uint8(255),
  11578 				8:  uint8(255),
  11579 				9:  uint8(255),
  11580 				10: uint8(255),
  11581 			},
  11582 		},
  11583 		5: {
  11584 			0: {
  11585 				0:  uint8(255),
  11586 				1:  uint8(252),
  11587 				2:  uint8(255),
  11588 				3:  uint8(255),
  11589 				4:  uint8(255),
  11590 				5:  uint8(255),
  11591 				6:  uint8(255),
  11592 				7:  uint8(255),
  11593 				8:  uint8(255),
  11594 				9:  uint8(255),
  11595 				10: uint8(255),
  11596 			},
  11597 			1: {
  11598 				0:  uint8(249),
  11599 				1:  uint8(255),
  11600 				2:  uint8(254),
  11601 				3:  uint8(255),
  11602 				4:  uint8(255),
  11603 				5:  uint8(255),
  11604 				6:  uint8(255),
  11605 				7:  uint8(255),
  11606 				8:  uint8(255),
  11607 				9:  uint8(255),
  11608 				10: uint8(255),
  11609 			},
  11610 			2: {
  11611 				0:  uint8(255),
  11612 				1:  uint8(255),
  11613 				2:  uint8(254),
  11614 				3:  uint8(255),
  11615 				4:  uint8(255),
  11616 				5:  uint8(255),
  11617 				6:  uint8(255),
  11618 				7:  uint8(255),
  11619 				8:  uint8(255),
  11620 				9:  uint8(255),
  11621 				10: uint8(255),
  11622 			},
  11623 		},
  11624 		6: {
  11625 			0: {
  11626 				0:  uint8(255),
  11627 				1:  uint8(255),
  11628 				2:  uint8(253),
  11629 				3:  uint8(255),
  11630 				4:  uint8(255),
  11631 				5:  uint8(255),
  11632 				6:  uint8(255),
  11633 				7:  uint8(255),
  11634 				8:  uint8(255),
  11635 				9:  uint8(255),
  11636 				10: uint8(255),
  11637 			},
  11638 			1: {
  11639 				0:  uint8(250),
  11640 				1:  uint8(255),
  11641 				2:  uint8(255),
  11642 				3:  uint8(255),
  11643 				4:  uint8(255),
  11644 				5:  uint8(255),
  11645 				6:  uint8(255),
  11646 				7:  uint8(255),
  11647 				8:  uint8(255),
  11648 				9:  uint8(255),
  11649 				10: uint8(255),
  11650 			},
  11651 			2: {
  11652 				0:  uint8(255),
  11653 				1:  uint8(255),
  11654 				2:  uint8(255),
  11655 				3:  uint8(255),
  11656 				4:  uint8(255),
  11657 				5:  uint8(255),
  11658 				6:  uint8(255),
  11659 				7:  uint8(255),
  11660 				8:  uint8(255),
  11661 				9:  uint8(255),
  11662 				10: uint8(255),
  11663 			},
  11664 		},
  11665 		7: {
  11666 			0: {
  11667 				0:  uint8(255),
  11668 				1:  uint8(255),
  11669 				2:  uint8(255),
  11670 				3:  uint8(255),
  11671 				4:  uint8(255),
  11672 				5:  uint8(255),
  11673 				6:  uint8(255),
  11674 				7:  uint8(255),
  11675 				8:  uint8(255),
  11676 				9:  uint8(255),
  11677 				10: uint8(255),
  11678 			},
  11679 			1: {
  11680 				0:  uint8(254),
  11681 				1:  uint8(255),
  11682 				2:  uint8(255),
  11683 				3:  uint8(255),
  11684 				4:  uint8(255),
  11685 				5:  uint8(255),
  11686 				6:  uint8(255),
  11687 				7:  uint8(255),
  11688 				8:  uint8(255),
  11689 				9:  uint8(255),
  11690 				10: uint8(255),
  11691 			},
  11692 			2: {
  11693 				0:  uint8(255),
  11694 				1:  uint8(255),
  11695 				2:  uint8(255),
  11696 				3:  uint8(255),
  11697 				4:  uint8(255),
  11698 				5:  uint8(255),
  11699 				6:  uint8(255),
  11700 				7:  uint8(255),
  11701 				8:  uint8(255),
  11702 				9:  uint8(255),
  11703 				10: uint8(255),
  11704 			},
  11705 		},
  11706 	},
  11707 }
  11708 
  11709 // Paragraph 9.9
  11710 
  11711 var kBands = [17]uint8_t{
  11712 	1:  uint8(1),
  11713 	2:  uint8(2),
  11714 	3:  uint8(3),
  11715 	4:  uint8(6),
  11716 	5:  uint8(4),
  11717 	6:  uint8(5),
  11718 	7:  uint8(6),
  11719 	8:  uint8(6),
  11720 	9:  uint8(6),
  11721 	10: uint8(6),
  11722 	11: uint8(6),
  11723 	12: uint8(6),
  11724 	13: uint8(6),
  11725 	14: uint8(6),
  11726 	15: uint8(7),
  11727 }
  11728 
  11729 func VP8ParseProba(tls *libc.TLS, br2 uintptr, dec uintptr) {
  11730 	bp := tls.Alloc(16)
  11731 	defer tls.Free(16)
  11732 	var b, bit, c, p, pos, shift, t, v, v10, v12 int32
  11733 	var bits bit_t
  11734 	var proba, v6, v7 uintptr
  11735 	var range1, split, value range_t
  11736 	var v5 uint32
  11737 	var v8 uint64_t
  11738 	var _ /* in_bits at bp+0 */ lbit_t
  11739 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, bit, bits, c, p, pos, proba, range1, shift, split, t, v, value, v10, v12, v5, v6, v7, v8
  11740 	proba = dec + 1192
  11741 	t = 0
  11742 	for {
  11743 		if !(t < int32(NUM_TYPES)) {
  11744 			break
  11745 		}
  11746 		b = 0
  11747 		for {
  11748 			if !(b < int32(NUM_BANDS)) {
  11749 				break
  11750 			}
  11751 			c = 0
  11752 			for {
  11753 				if !(c < int32(NUM_CTX)) {
  11754 					break
  11755 				}
  11756 				p = 0
  11757 				for {
  11758 					if !(p < int32(NUM_PROBAS)) {
  11759 						break
  11760 					}
  11761 					v6 = br2
  11762 					range1 = (*VP8BitReader)(unsafe.Pointer(v6)).Frange1
  11763 					if (*VP8BitReader)(unsafe.Pointer(v6)).Fbits < libc.Int32FromInt32(0) {
  11764 						v7 = v6
  11765 						if (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf_max {
  11766 							libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v7)).Fbuf, uint64(8), ^__predefined_size_t(0))
  11767 							**(**uintptr)(__ccgo_up(v7 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  11768 							v8 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  11769 							goto _9
  11770 						_9:
  11771 							bits = v8
  11772 							bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  11773 							(*VP8BitReader)(unsafe.Pointer(v7)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v7)).Fvalue<<libc.Int32FromInt32(BITS)
  11774 							**(**int32)(__ccgo_up(v7 + 12)) += int32(BITS)
  11775 						} else {
  11776 							VP8LoadFinalBytes(tls, v7)
  11777 						}
  11778 					}
  11779 					pos = (*VP8BitReader)(unsafe.Pointer(v6)).Fbits
  11780 					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)
  11781 					value = uint32((*VP8BitReader)(unsafe.Pointer(v6)).Fvalue >> pos)
  11782 					bit = libc.BoolInt32(value > split)
  11783 					if bit != 0 {
  11784 						range1 = range1 - split
  11785 						**(**bit_t)(__ccgo_up(v6)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  11786 					} else {
  11787 						range1 = split + uint32(1)
  11788 					}
  11789 					v10 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  11790 					goto _11
  11791 				_11:
  11792 					shift = int32(7) ^ v10
  11793 					range1 = range1 << libc.Uint32FromInt32(shift)
  11794 					**(**int32)(__ccgo_up(v6 + 12)) -= shift
  11795 					(*VP8BitReader)(unsafe.Pointer(v6)).Frange1 = range1 - uint32(1)
  11796 					v12 = bit
  11797 					goto _13
  11798 				_13:
  11799 					if v12 != 0 {
  11800 						v5 = VP8GetValue(tls, br2, int32(8))
  11801 					} else {
  11802 						v5 = uint32(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&CoeffsProba0)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  11803 					}
  11804 					v = libc.Int32FromUint32(v5)
  11805 					**(**uint8_t)(__ccgo_up(proba + 3 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(v)
  11806 					goto _4
  11807 				_4:
  11808 					;
  11809 					p = p + 1
  11810 				}
  11811 				goto _3
  11812 			_3:
  11813 				;
  11814 				c = c + 1
  11815 			}
  11816 			goto _2
  11817 		_2:
  11818 			;
  11819 			b = b + 1
  11820 		}
  11821 		b = 0
  11822 		for {
  11823 			if !(b < libc.Int32FromInt32(16)+libc.Int32FromInt32(1)) {
  11824 				break
  11825 			}
  11826 			**(**uintptr)(__ccgo_up(proba + 1064 + uintptr(t)*136 + uintptr(b)*8)) = proba + 3 + uintptr(t)*264 + uintptr(kBands[b])*33
  11827 			goto _14
  11828 		_14:
  11829 			;
  11830 			b = b + 1
  11831 		}
  11832 		goto _1
  11833 	_1:
  11834 		;
  11835 		t = t + 1
  11836 	}
  11837 	(*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba = libc.Int32FromUint32(VP8GetValue(tls, br2, int32(1)))
  11838 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
  11839 		(*VP8Decoder)(unsafe.Pointer(dec)).Fskip_p = uint8(VP8GetValue(tls, br2, int32(8)))
  11840 	}
  11841 }
  11842 
  11843 var kHashMul7 = uint32(0x1e35a7bd)
  11844 
  11845 // Copyright 2010 Google Inc. All Rights Reserved.
  11846 //
  11847 // Use of this source code is governed by a BSD-style license
  11848 // that can be found in the COPYING file in the root of the source
  11849 // tree. An additional intellectual property rights grant can be found
  11850 // in the file PATENTS. All contributing project authors may
  11851 // be found in the AUTHORS file in the root of the source tree.
  11852 // -----------------------------------------------------------------------------
  11853 //
  11854 // Boolean decoder
  11855 //
  11856 // Author: Skal (pascal.massimino@gmail.com)
  11857 //         Vikas Arora (vikaas.arora@gmail.com)
  11858 
  11859 // Copyright 2011 Google Inc. All Rights Reserved.
  11860 //
  11861 // Use of this source code is governed by a BSD-style license
  11862 // that can be found in the COPYING file in the root of the source
  11863 // tree. An additional intellectual property rights grant can be found
  11864 // in the file PATENTS. All contributing project authors may
  11865 // be found in the AUTHORS file in the root of the source tree.
  11866 // -----------------------------------------------------------------------------
  11867 //
  11868 // Multi-threaded worker
  11869 //
  11870 // Author: Skal (pascal.massimino@gmail.com)
  11871 
  11872 // Copyright 2012 Google Inc. All Rights Reserved.
  11873 //
  11874 // Use of this source code is governed by a BSD-style license
  11875 // that can be found in the COPYING file in the root of the source
  11876 // tree. An additional intellectual property rights grant can be found
  11877 // in the file PATENTS. All contributing project authors may
  11878 // be found in the AUTHORS file in the root of the source tree.
  11879 // -----------------------------------------------------------------------------
  11880 //
  11881 // Misc. common utility functions
  11882 //
  11883 // Authors: Skal (pascal.massimino@gmail.com)
  11884 //          Urvang (urvang@google.com)
  11885 
  11886 // Copyright 2010 Google Inc. All Rights Reserved.
  11887 //
  11888 // Use of this source code is governed by a BSD-style license
  11889 // that can be found in the COPYING file in the root of the source
  11890 // tree. An additional intellectual property rights grant can be found
  11891 // in the file PATENTS. All contributing project authors may
  11892 // be found in the AUTHORS file in the root of the source tree.
  11893 // -----------------------------------------------------------------------------
  11894 //
  11895 //  Main decoding functions for WebP images.
  11896 //
  11897 // Author: Skal (pascal.massimino@gmail.com)
  11898 
  11899 // Copyright 2012 Google Inc. All Rights Reserved.
  11900 //
  11901 // Use of this source code is governed by a BSD-style license
  11902 // that can be found in the COPYING file in the root of the source
  11903 // tree. An additional intellectual property rights grant can be found
  11904 // in the file PATENTS. All contributing project authors may
  11905 // be found in the AUTHORS file in the root of the source tree.
  11906 // -----------------------------------------------------------------------------
  11907 //
  11908 //  Internal header for constants related to WebP file format.
  11909 //
  11910 // Author: Urvang (urvang@google.com)
  11911 
  11912 // Copyright 2010 Google Inc. All Rights Reserved.
  11913 //
  11914 // Use of this source code is governed by a BSD-style license
  11915 // that can be found in the COPYING file in the root of the source
  11916 // tree. An additional intellectual property rights grant can be found
  11917 // in the file PATENTS. All contributing project authors may
  11918 // be found in the AUTHORS file in the root of the source tree.
  11919 // -----------------------------------------------------------------------------
  11920 //
  11921 //  Common types + memory wrappers
  11922 //
  11923 // Author: Skal (pascal.massimino@gmail.com)
  11924 
  11925 //------------------------------------------------------------------------------
  11926 
  11927 func WebPGetDecoderVersion(tls *libc.TLS) (r int32) {
  11928 	return libc.Int32FromInt32(DEC_MAJ_VERSION)<<libc.Int32FromInt32(16) | libc.Int32FromInt32(DEC_MIN_VERSION)<<libc.Int32FromInt32(8) | libc.Int32FromInt32(DEC_REV_VERSION)
  11929 }
  11930 
  11931 //------------------------------------------------------------------------------
  11932 // Signature and pointer-to-function for GetCoeffs() variants below.
  11933 
  11934 type GetCoeffsFunc = uintptr
  11935 
  11936 var GetCoeffs = uintptr(0)
  11937 
  11938 func init() {
  11939 	p := unsafe.Pointer(&GetCoeffs)
  11940 	*(*uintptr)(unsafe.Add(p, 0)) = libc.UintptrFromInt32(0)
  11941 }
  11942 
  11943 //------------------------------------------------------------------------------
  11944 // VP8Decoder
  11945 
  11946 func SetOk(tls *libc.TLS, dec uintptr) {
  11947 	(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  11948 	(*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg = __ccgo_ts + 154
  11949 }
  11950 
  11951 func VP8InitIoInternal(tls *libc.TLS, io uintptr, version int32) (r int32) {
  11952 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  11953 		return 0 // mismatch error
  11954 	}
  11955 	if io != libc.UintptrFromInt32(0) {
  11956 		libc.X__builtin___memset_chk(tls, io, 0, uint64(160), ^__predefined_size_t(0))
  11957 	}
  11958 	return int32(1)
  11959 }
  11960 
  11961 func VP8New(tls *libc.TLS) (r uintptr) {
  11962 	var dec uintptr
  11963 	_ = dec
  11964 	dec = WebPSafeCalloc(tls, uint64(1), uint64(3024))
  11965 	if dec != libc.UintptrFromInt32(0) {
  11966 		SetOk(tls, dec)
  11967 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, dec+152)
  11968 		(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  11969 		(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one = uint32(0)
  11970 		InitGetCoeffs(tls)
  11971 	}
  11972 	return dec
  11973 }
  11974 
  11975 func VP8Status(tls *libc.TLS, dec uintptr) (r VP8StatusCode1) {
  11976 	if !(dec != 0) {
  11977 		return int32(VP8_STATUS_INVALID_PARAM)
  11978 	}
  11979 	return (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
  11980 }
  11981 
  11982 func VP8StatusMessage(tls *libc.TLS, dec uintptr) (r uintptr) {
  11983 	if dec == libc.UintptrFromInt32(0) {
  11984 		return __ccgo_ts + 157
  11985 	}
  11986 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg != 0) {
  11987 		return __ccgo_ts + 154
  11988 	}
  11989 	return (*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg
  11990 }
  11991 
  11992 func VP8Delete(tls *libc.TLS, dec uintptr) {
  11993 	if dec != libc.UintptrFromInt32(0) {
  11994 		VP8Clear(tls, dec)
  11995 		WebPSafeFree(tls, dec)
  11996 	}
  11997 }
  11998 
  11999 func VP8SetError(tls *libc.TLS, dec uintptr, error1 VP8StatusCode1, msg uintptr) (r int32) {
  12000 	// VP8_STATUS_SUSPENDED is only meaningful in incremental decoding.
  12001 	// The oldest error reported takes precedence over the new one.
  12002 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_OK) {
  12003 		(*VP8Decoder)(unsafe.Pointer(dec)).Fstatus = error1
  12004 		(*VP8Decoder)(unsafe.Pointer(dec)).Ferror_msg = msg
  12005 		(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  12006 	}
  12007 	return 0
  12008 }
  12009 
  12010 //------------------------------------------------------------------------------
  12011 
  12012 func VP8CheckSignature(tls *libc.TLS, data uintptr, data_size size_t) (r int32) {
  12013 	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))
  12014 }
  12015 
  12016 func VP8GetInfo(tls *libc.TLS, data uintptr, data_size size_t, chunk_size size_t, width uintptr, height uintptr) (r int32) {
  12017 	var bits uint32_t
  12018 	var h, key_frame, w int32
  12019 	_, _, _, _ = bits, h, key_frame, w
  12020 	if data == libc.UintptrFromInt32(0) || data_size < uint64(VP8_FRAME_HEADER_SIZE) {
  12021 		return 0 // not enough data
  12022 	}
  12023 	// check signature
  12024 	if !(VP8CheckSignature(tls, data+uintptr(3), data_size-uint64(3)) != 0) {
  12025 		return 0 // Wrong signature.
  12026 	} else {
  12027 		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))
  12028 		key_frame = libc.BoolInt32(!(bits&libc.Uint32FromInt32(1) != 0))
  12029 		w = (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 7)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 6)))) & int32(0x3fff)
  12030 		h = (libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 9)))<<int32(8) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + 8)))) & int32(0x3fff)
  12031 		if !(key_frame != 0) { // Not a keyframe.
  12032 			return 0
  12033 		}
  12034 		if bits>>libc.Int32FromInt32(1)&uint32(7) > uint32(3) {
  12035 			return 0 // unknown profile
  12036 		}
  12037 		if !(bits>>libc.Int32FromInt32(4)&libc.Uint32FromInt32(1) != 0) {
  12038 			return 0 // first frame is invisible!
  12039 		}
  12040 		if uint64(bits>>libc.Int32FromInt32(5)) >= chunk_size { // partition_length
  12041 			return 0 // inconsistent size information.
  12042 		}
  12043 		if w == 0 || h == 0 {
  12044 			return 0 // We don't support both width and height to be zero.
  12045 		}
  12046 		if width != 0 {
  12047 			**(**int32)(__ccgo_up(width)) = w
  12048 		}
  12049 		if height != 0 {
  12050 			**(**int32)(__ccgo_up(height)) = h
  12051 		}
  12052 		return int32(1)
  12053 	}
  12054 	return r
  12055 }
  12056 
  12057 //------------------------------------------------------------------------------
  12058 // Header parsing
  12059 
  12060 func ResetSegmentHeader(tls *libc.TLS, hdr uintptr) {
  12061 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment = 0
  12062 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = 0
  12063 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta = int32(1)
  12064 	libc.X__builtin___memset_chk(tls, hdr+12, 0, uint64(4), ^__predefined_size_t(0))
  12065 	libc.X__builtin___memset_chk(tls, hdr+16, 0, uint64(4), ^__predefined_size_t(0))
  12066 }
  12067 
  12068 // C documentation
  12069 //
  12070 //	// Paragraph 9.3
  12071 func ParseSegmentHeader(tls *libc.TLS, br uintptr, hdr uintptr, proba uintptr) (r int32) {
  12072 	var s, s1, v2 int32
  12073 	var v6 uint32
  12074 	_, _, _, _ = s, s1, v2, v6
  12075 	(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12076 	if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fuse_segment != 0 {
  12077 		(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12078 		if VP8GetValue(tls, br, int32(1)) != 0 {
  12079 			(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fabsolute_delta = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12080 			s = 0
  12081 			for {
  12082 				if !(s < int32(NUM_MB_SEGMENTS)) {
  12083 					break
  12084 				}
  12085 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12086 					v2 = VP8GetSignedValue(tls, br, int32(7))
  12087 				} else {
  12088 					v2 = 0
  12089 				}
  12090 				**(**int8_t)(__ccgo_up(hdr + 12 + uintptr(s))) = int8(v2)
  12091 				goto _1
  12092 			_1:
  12093 				;
  12094 				s = s + 1
  12095 			}
  12096 			s = 0
  12097 			for {
  12098 				if !(s < int32(NUM_MB_SEGMENTS)) {
  12099 					break
  12100 				}
  12101 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12102 					v2 = VP8GetSignedValue(tls, br, int32(6))
  12103 				} else {
  12104 					v2 = 0
  12105 				}
  12106 				**(**int8_t)(__ccgo_up(hdr + 16 + uintptr(s))) = int8(v2)
  12107 				goto _3
  12108 			_3:
  12109 				;
  12110 				s = s + 1
  12111 			}
  12112 		}
  12113 		if (*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map != 0 {
  12114 			s1 = 0
  12115 			for {
  12116 				if !(s1 < int32(MB_FEATURE_TREE_PROBS)) {
  12117 					break
  12118 				}
  12119 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12120 					v6 = VP8GetValue(tls, br, int32(8))
  12121 				} else {
  12122 					v6 = uint32(255)
  12123 				}
  12124 				**(**uint8_t)(__ccgo_up(proba + uintptr(s1))) = uint8(v6)
  12125 				goto _5
  12126 			_5:
  12127 				;
  12128 				s1 = s1 + 1
  12129 			}
  12130 		}
  12131 	} else {
  12132 		(*VP8SegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = 0
  12133 	}
  12134 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0))
  12135 }
  12136 
  12137 // C documentation
  12138 //
  12139 //	// Paragraph 9.5
  12140 //	// If we don't have all the necessary data in 'buf', this function returns
  12141 //	// VP8_STATUS_SUSPENDED in incremental decoding, VP8_STATUS_NOT_ENOUGH_DATA
  12142 //	// otherwise.
  12143 //	// In incremental decoding, this case is not necessarily an error. Still, no
  12144 //	// bitreader is ever initialized to make it possible to read unavailable memory.
  12145 //	// If we don't even have the partitions' sizes, then VP8_STATUS_NOT_ENOUGH_DATA
  12146 //	// is returned, and this is an unrecoverable error.
  12147 //	// If the partitions were positioned ok, VP8_STATUS_OK is returned.
  12148 func ParsePartitions(tls *libc.TLS, dec uintptr, buf uintptr, size size_t) (r VP8StatusCode1) {
  12149 	var br, buf_end, part_start, sz uintptr
  12150 	var last_part, p, psize, size_left size_t
  12151 	var v2 int32
  12152 	_, _, _, _, _, _, _, _, _ = br, buf_end, last_part, p, part_start, psize, size_left, sz, v2
  12153 	br = dec + 16
  12154 	sz = buf
  12155 	buf_end = buf + uintptr(size)
  12156 	size_left = size
  12157 	(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one = libc.Uint32FromInt32(int32(1)<<VP8GetValue(tls, br, int32(2)) - int32(1))
  12158 	last_part = uint64((*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)
  12159 	if size < uint64(3)*last_part {
  12160 		// we can't even read the sizes with sz[]! That's a failure.
  12161 		return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  12162 	}
  12163 	part_start = buf + uintptr(last_part*uint64(3))
  12164 	size_left = size_left - last_part*uint64(3)
  12165 	p = uint64(0)
  12166 	for {
  12167 		if !(p < last_part) {
  12168 			break
  12169 		}
  12170 		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))
  12171 		if psize > size_left {
  12172 			psize = size_left
  12173 		}
  12174 		VP8InitBitReader(tls, dec+440+uintptr(p)*48, part_start, psize)
  12175 		part_start = part_start + uintptr(psize)
  12176 		size_left = size_left - psize
  12177 		sz = sz + uintptr(3)
  12178 		goto _1
  12179 	_1:
  12180 		;
  12181 		p = p + 1
  12182 	}
  12183 	VP8InitBitReader(tls, dec+440+uintptr(last_part)*48, part_start, size_left)
  12184 	if part_start < buf_end {
  12185 		return int32(VP8_STATUS_OK)
  12186 	}
  12187 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  12188 		v2 = int32(VP8_STATUS_SUSPENDED)
  12189 	} else {
  12190 		v2 = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  12191 	}
  12192 	return v2
  12193 }
  12194 
  12195 // C documentation
  12196 //
  12197 //	// Paragraph 9.4
  12198 func ParseFilterHeader(tls *libc.TLS, br uintptr, dec uintptr) (r int32) {
  12199 	var hdr uintptr
  12200 	var i, v3, v4 int32
  12201 	_, _, _, _ = hdr, i, v3, v4
  12202 	hdr = dec + 84
  12203 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsimple = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12204 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel = libc.Int32FromUint32(VP8GetValue(tls, br, int32(6)))
  12205 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsharpness = libc.Int32FromUint32(VP8GetValue(tls, br, int32(3)))
  12206 	(*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta = libc.Int32FromUint32(VP8GetValue(tls, br, int32(1)))
  12207 	if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fuse_lf_delta != 0 {
  12208 		if VP8GetValue(tls, br, int32(1)) != 0 {
  12209 			i = 0
  12210 			for {
  12211 				if !(i < int32(NUM_REF_LF_DELTAS)) {
  12212 					break
  12213 				}
  12214 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12215 					**(**int32)(__ccgo_up(hdr + 16 + uintptr(i)*4)) = VP8GetSignedValue(tls, br, int32(6))
  12216 				}
  12217 				goto _1
  12218 			_1:
  12219 				;
  12220 				i = i + 1
  12221 			}
  12222 			i = 0
  12223 			for {
  12224 				if !(i < int32(NUM_MODE_LF_DELTAS)) {
  12225 					break
  12226 				}
  12227 				if VP8GetValue(tls, br, int32(1)) != 0 {
  12228 					**(**int32)(__ccgo_up(hdr + 32 + uintptr(i)*4)) = VP8GetSignedValue(tls, br, int32(6))
  12229 				}
  12230 				goto _2
  12231 			_2:
  12232 				;
  12233 				i = i + 1
  12234 			}
  12235 		}
  12236 	}
  12237 	if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Flevel == 0 {
  12238 		v3 = 0
  12239 	} else {
  12240 		if (*VP8FilterHeader)(unsafe.Pointer(hdr)).Fsimple != 0 {
  12241 			v4 = int32(1)
  12242 		} else {
  12243 			v4 = int32(2)
  12244 		}
  12245 		v3 = v4
  12246 	}
  12247 	(*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type = v3
  12248 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0))
  12249 }
  12250 
  12251 // C documentation
  12252 //
  12253 //	// Topmost call
  12254 func VP8GetHeaders(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  12255 	var bits uint32_t
  12256 	var br, buf, frm_hdr, pic_hdr uintptr
  12257 	var buf_size size_t
  12258 	var status VP8StatusCode1
  12259 	_, _, _, _, _, _, _ = bits, br, buf, buf_size, frm_hdr, pic_hdr, status
  12260 	if dec == libc.UintptrFromInt32(0) {
  12261 		return 0
  12262 	}
  12263 	SetOk(tls, dec)
  12264 	if io == libc.UintptrFromInt32(0) {
  12265 		return VP8SetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM), __ccgo_ts+167)
  12266 	}
  12267 	buf = (*VP8Io)(unsafe.Pointer(io)).Fdata
  12268 	buf_size = (*VP8Io)(unsafe.Pointer(io)).Fdata_size
  12269 	if buf_size < uint64(4) {
  12270 		return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+204)
  12271 	}
  12272 	// Paragraph 9.1
  12273 	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))
  12274 	frm_hdr = dec + 68
  12275 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame = libc.BoolUint8(!(bits&libc.Uint32FromInt32(1) != 0))
  12276 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fprofile = uint8(bits >> libc.Int32FromInt32(1) & uint32(7))
  12277 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fshow = uint8(bits >> libc.Int32FromInt32(4) & uint32(1))
  12278 	(*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length = bits >> libc.Int32FromInt32(5)
  12279 	if libc.Int32FromUint8((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fprofile) > int32(3) {
  12280 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+222)
  12281 	}
  12282 	if !((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fshow != 0) {
  12283 		return VP8SetError(tls, dec, int32(VP8_STATUS_UNSUPPORTED_FEATURE), __ccgo_ts+253)
  12284 	}
  12285 	buf = buf + uintptr(3)
  12286 	buf_size = buf_size - uint64(3)
  12287 	pic_hdr = dec + 76
  12288 	if (*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0 {
  12289 		// Paragraph 9.2
  12290 		if buf_size < uint64(7) {
  12291 			return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+276)
  12292 		}
  12293 		if !(VP8CheckSignature(tls, buf, buf_size) != 0) {
  12294 			return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+304)
  12295 		}
  12296 		(*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))
  12297 		(*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
  12298 		(*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))
  12299 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fyscale = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(buf + 6))) >> int32(6))
  12300 		buf = buf + uintptr(7)
  12301 		buf_size = buf_size - uint64(7)
  12302 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w = (libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fwidth) + int32(15)) >> int32(4)
  12303 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_h = (libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fheight) + int32(15)) >> int32(4)
  12304 		// Setup default output area (can be later modified during io->setup())
  12305 		(*VP8Io)(unsafe.Pointer(io)).Fwidth = libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fwidth)
  12306 		(*VP8Io)(unsafe.Pointer(io)).Fheight = libc.Int32FromUint16((*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fheight)
  12307 		// IMPORTANT! use some sane dimensions in crop* and scaled* fields.
  12308 		// So they can be used interchangeably without always testing for
  12309 		// 'use_cropping'.
  12310 		(*VP8Io)(unsafe.Pointer(io)).Fuse_cropping = 0
  12311 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_top = 0
  12312 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_left = 0
  12313 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_right = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  12314 		(*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom = (*VP8Io)(unsafe.Pointer(io)).Fheight
  12315 		(*VP8Io)(unsafe.Pointer(io)).Fuse_scaling = 0
  12316 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_width = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  12317 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_height = (*VP8Io)(unsafe.Pointer(io)).Fheight
  12318 		(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fwidth  // for soundness
  12319 		(*VP8Io)(unsafe.Pointer(io)).Fmb_h = (*VP8Io)(unsafe.Pointer(io)).Fheight // ditto
  12320 		VP8ResetProba(tls, dec+1192)
  12321 		ResetSegmentHeader(tls, dec+132)
  12322 	}
  12323 	// Check if we have all the partition #0 available, and initialize dec->br
  12324 	// to read this partition (and this partition only).
  12325 	if uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length) > buf_size {
  12326 		return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+318)
  12327 	}
  12328 	br = dec + 16
  12329 	VP8InitBitReader(tls, br, buf, uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length))
  12330 	buf = buf + uintptr((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length)
  12331 	buf_size = buf_size - uint64((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fpartition_length)
  12332 	if (*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0 {
  12333 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fcolorspace = uint8(VP8GetValue(tls, br, int32(1)))
  12334 		(*VP8PictureHeader)(unsafe.Pointer(pic_hdr)).Fclamp_type = uint8(VP8GetValue(tls, br, int32(1)))
  12335 	}
  12336 	if !(ParseSegmentHeader(tls, br, dec+132, dec+1192) != 0) {
  12337 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+339)
  12338 	}
  12339 	// Filter specs
  12340 	if !(ParseFilterHeader(tls, br, dec) != 0) {
  12341 		return VP8SetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR), __ccgo_ts+367)
  12342 	}
  12343 	status = ParsePartitions(tls, dec, buf, buf_size)
  12344 	if status != int32(VP8_STATUS_OK) {
  12345 		return VP8SetError(tls, dec, status, __ccgo_ts+394)
  12346 	}
  12347 	// quantizer change
  12348 	VP8ParseQuant(tls, dec)
  12349 	// Frame buffer marking
  12350 	if !((*VP8FrameHeader)(unsafe.Pointer(frm_hdr)).Fkey_frame != 0) {
  12351 		return VP8SetError(tls, dec, int32(VP8_STATUS_UNSUPPORTED_FEATURE), __ccgo_ts+418)
  12352 	}
  12353 	VP8GetValue(tls, br, int32(1)) // ignore the value of 'update_proba'
  12354 	VP8ParseProba(tls, br, dec)
  12355 	// sanitized state
  12356 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = int32(1)
  12357 	return int32(1)
  12358 }
  12359 
  12360 //------------------------------------------------------------------------------
  12361 // Residual decoding (Paragraph 13.2 / 13.3)
  12362 
  12363 var kCat3 = [4]uint8_t{
  12364 	0: uint8(173),
  12365 	1: uint8(148),
  12366 	2: uint8(140),
  12367 }
  12368 var kCat4 = [5]uint8_t{
  12369 	0: uint8(176),
  12370 	1: uint8(155),
  12371 	2: uint8(140),
  12372 	3: uint8(135),
  12373 }
  12374 var kCat5 = [6]uint8_t{
  12375 	0: uint8(180),
  12376 	1: uint8(157),
  12377 	2: uint8(141),
  12378 	3: uint8(134),
  12379 	4: uint8(130),
  12380 }
  12381 var kCat6 = [12]uint8_t{
  12382 	0:  uint8(254),
  12383 	1:  uint8(254),
  12384 	2:  uint8(243),
  12385 	3:  uint8(230),
  12386 	4:  uint8(196),
  12387 	5:  uint8(177),
  12388 	6:  uint8(153),
  12389 	7:  uint8(140),
  12390 	8:  uint8(133),
  12391 	9:  uint8(130),
  12392 	10: uint8(129),
  12393 }
  12394 var kCat3456 = [4]uintptr{
  12395 	0: uintptr(unsafe.Pointer(&kCat3)),
  12396 	1: uintptr(unsafe.Pointer(&kCat4)),
  12397 	2: uintptr(unsafe.Pointer(&kCat5)),
  12398 	3: uintptr(unsafe.Pointer(&kCat6)),
  12399 }
  12400 var kZigzag = [16]uint8_t{
  12401 	1:  uint8(1),
  12402 	2:  uint8(4),
  12403 	3:  uint8(8),
  12404 	4:  uint8(5),
  12405 	5:  uint8(2),
  12406 	6:  uint8(3),
  12407 	7:  uint8(6),
  12408 	8:  uint8(9),
  12409 	9:  uint8(12),
  12410 	10: uint8(13),
  12411 	11: uint8(10),
  12412 	12: uint8(7),
  12413 	13: uint8(11),
  12414 	14: uint8(14),
  12415 	15: uint8(15),
  12416 }
  12417 
  12418 // C documentation
  12419 //
  12420 //	// See section 13-2: https://datatracker.ietf.org/doc/html/rfc6386#section-13.2
  12421 func GetLargeValue(tls *libc.TLS, br2 uintptr, p uintptr) (r int32) {
  12422 	bp := tls.Alloc(16)
  12423 	defer tls.Free(16)
  12424 	var bit, bit0, bit1, cat, pos, shift, v, v13, v15, v21, v23, v5, v7 int32
  12425 	var bits bit_t
  12426 	var range1, split, value range_t
  12427 	var tab, v1, v10, v17, v18, v2, v9 uintptr
  12428 	var v11, v19, v3 uint64_t
  12429 	var _ /* in_bits at bp+0 */ lbit_t
  12430 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  12431 	v1 = br2
  12432 	range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12433 	if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12434 		v2 = v1
  12435 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12436 			libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12437 			**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12438 			v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12439 			goto _4
  12440 		_4:
  12441 			bits = v3
  12442 			bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12443 			(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12444 			**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12445 		} else {
  12446 			VP8LoadFinalBytes(tls, v2)
  12447 		}
  12448 	}
  12449 	pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12450 	split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 3)))) >> int32(8)
  12451 	value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12452 	bit = libc.BoolInt32(value > split)
  12453 	if bit != 0 {
  12454 		range1 = range1 - split
  12455 		**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12456 	} else {
  12457 		range1 = split + uint32(1)
  12458 	}
  12459 	v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12460 	goto _6
  12461 _6:
  12462 	shift = int32(7) ^ v5
  12463 	range1 = range1 << libc.Uint32FromInt32(shift)
  12464 	**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12465 	(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12466 	v7 = bit
  12467 	goto _8
  12468 _8:
  12469 	if !(v7 != 0) {
  12470 		v9 = br2
  12471 		range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12472 		if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12473 			v10 = v9
  12474 			if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12475 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12476 				**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12477 				v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12478 				goto _12
  12479 			_12:
  12480 				bits = v11
  12481 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12482 				(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12483 				**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12484 			} else {
  12485 				VP8LoadFinalBytes(tls, v10)
  12486 			}
  12487 		}
  12488 		pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12489 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 4)))) >> int32(8)
  12490 		value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12491 		bit = libc.BoolInt32(value > split)
  12492 		if bit != 0 {
  12493 			range1 = range1 - split
  12494 			**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12495 		} else {
  12496 			range1 = split + uint32(1)
  12497 		}
  12498 		v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12499 		goto _14
  12500 	_14:
  12501 		shift = int32(7) ^ v13
  12502 		range1 = range1 << libc.Uint32FromInt32(shift)
  12503 		**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12504 		(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12505 		v15 = bit
  12506 		goto _16
  12507 	_16:
  12508 		if !(v15 != 0) {
  12509 			v = int32(2)
  12510 		} else {
  12511 			v1 = br2
  12512 			range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12513 			if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12514 				v2 = v1
  12515 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12516 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12517 					**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12518 					v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12519 					goto _20
  12520 				_20:
  12521 					bits = v3
  12522 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12523 					(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12524 					**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12525 				} else {
  12526 					VP8LoadFinalBytes(tls, v2)
  12527 				}
  12528 			}
  12529 			pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12530 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 5)))) >> int32(8)
  12531 			value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12532 			bit = libc.BoolInt32(value > split)
  12533 			if bit != 0 {
  12534 				range1 = range1 - split
  12535 				**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12536 			} else {
  12537 				range1 = split + uint32(1)
  12538 			}
  12539 			v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12540 			goto _22
  12541 		_22:
  12542 			shift = int32(7) ^ v5
  12543 			range1 = range1 << libc.Uint32FromInt32(shift)
  12544 			**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12545 			(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12546 			v7 = bit
  12547 			goto _24
  12548 		_24:
  12549 			v = int32(3) + v7
  12550 		}
  12551 	} else {
  12552 		v1 = br2
  12553 		range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12554 		if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12555 			v2 = v1
  12556 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12557 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12558 				**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12559 				v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12560 				goto _28
  12561 			_28:
  12562 				bits = v3
  12563 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12564 				(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12565 				**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12566 			} else {
  12567 				VP8LoadFinalBytes(tls, v2)
  12568 			}
  12569 		}
  12570 		pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12571 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 6)))) >> int32(8)
  12572 		value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12573 		bit = libc.BoolInt32(value > split)
  12574 		if bit != 0 {
  12575 			range1 = range1 - split
  12576 			**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12577 		} else {
  12578 			range1 = split + uint32(1)
  12579 		}
  12580 		v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12581 		goto _30
  12582 	_30:
  12583 		shift = int32(7) ^ v5
  12584 		range1 = range1 << libc.Uint32FromInt32(shift)
  12585 		**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12586 		(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12587 		v7 = bit
  12588 		goto _32
  12589 	_32:
  12590 		if !(v7 != 0) {
  12591 			v9 = br2
  12592 			range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12593 			if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12594 				v10 = v9
  12595 				if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12596 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12597 					**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12598 					v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12599 					goto _36
  12600 				_36:
  12601 					bits = v11
  12602 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12603 					(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12604 					**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12605 				} else {
  12606 					VP8LoadFinalBytes(tls, v10)
  12607 				}
  12608 			}
  12609 			pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12610 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 7)))) >> int32(8)
  12611 			value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12612 			bit = libc.BoolInt32(value > split)
  12613 			if bit != 0 {
  12614 				range1 = range1 - split
  12615 				**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12616 			} else {
  12617 				range1 = split + uint32(1)
  12618 			}
  12619 			v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12620 			goto _38
  12621 		_38:
  12622 			shift = int32(7) ^ v13
  12623 			range1 = range1 << libc.Uint32FromInt32(shift)
  12624 			**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12625 			(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12626 			v15 = bit
  12627 			goto _40
  12628 		_40:
  12629 			if !(v15 != 0) {
  12630 				v17 = br2
  12631 				range1 = (*VP8BitReader)(unsafe.Pointer(v17)).Frange1
  12632 				if (*VP8BitReader)(unsafe.Pointer(v17)).Fbits < libc.Int32FromInt32(0) {
  12633 					v18 = v17
  12634 					if (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf_max {
  12635 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v18)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12636 						**(**uintptr)(__ccgo_up(v18 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12637 						v19 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12638 						goto _44
  12639 					_44:
  12640 						bits = v19
  12641 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12642 						(*VP8BitReader)(unsafe.Pointer(v18)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v18)).Fvalue<<libc.Int32FromInt32(BITS)
  12643 						**(**int32)(__ccgo_up(v18 + 12)) += int32(BITS)
  12644 					} else {
  12645 						VP8LoadFinalBytes(tls, v18)
  12646 					}
  12647 				}
  12648 				pos = (*VP8BitReader)(unsafe.Pointer(v17)).Fbits
  12649 				split = range1 * libc.Uint32FromInt32(int32(159)) >> int32(8)
  12650 				value = uint32((*VP8BitReader)(unsafe.Pointer(v17)).Fvalue >> pos)
  12651 				bit = libc.BoolInt32(value > split)
  12652 				if bit != 0 {
  12653 					range1 = range1 - split
  12654 					**(**bit_t)(__ccgo_up(v17)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12655 				} else {
  12656 					range1 = split + uint32(1)
  12657 				}
  12658 				v21 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12659 				goto _46
  12660 			_46:
  12661 				shift = int32(7) ^ v21
  12662 				range1 = range1 << libc.Uint32FromInt32(shift)
  12663 				**(**int32)(__ccgo_up(v17 + 12)) -= shift
  12664 				(*VP8BitReader)(unsafe.Pointer(v17)).Frange1 = range1 - uint32(1)
  12665 				v23 = bit
  12666 				goto _48
  12667 			_48:
  12668 				v = int32(5) + v23
  12669 			} else {
  12670 				v1 = br2
  12671 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12672 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12673 					v2 = v1
  12674 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12675 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12676 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12677 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12678 						goto _52
  12679 					_52:
  12680 						bits = v3
  12681 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12682 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12683 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12684 					} else {
  12685 						VP8LoadFinalBytes(tls, v2)
  12686 					}
  12687 				}
  12688 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12689 				split = range1 * libc.Uint32FromInt32(int32(165)) >> int32(8)
  12690 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12691 				bit = libc.BoolInt32(value > split)
  12692 				if bit != 0 {
  12693 					range1 = range1 - split
  12694 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12695 				} else {
  12696 					range1 = split + uint32(1)
  12697 				}
  12698 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12699 				goto _54
  12700 			_54:
  12701 				shift = int32(7) ^ v5
  12702 				range1 = range1 << libc.Uint32FromInt32(shift)
  12703 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12704 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12705 				v7 = bit
  12706 				goto _56
  12707 			_56:
  12708 				v = int32(7) + int32(2)*v7
  12709 				v1 = br2
  12710 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12711 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12712 					v2 = v1
  12713 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12714 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12715 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12716 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12717 						goto _60
  12718 					_60:
  12719 						bits = v3
  12720 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12721 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12722 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12723 					} else {
  12724 						VP8LoadFinalBytes(tls, v2)
  12725 					}
  12726 				}
  12727 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12728 				split = range1 * libc.Uint32FromInt32(int32(145)) >> int32(8)
  12729 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12730 				bit = libc.BoolInt32(value > split)
  12731 				if bit != 0 {
  12732 					range1 = range1 - split
  12733 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12734 				} else {
  12735 					range1 = split + uint32(1)
  12736 				}
  12737 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12738 				goto _62
  12739 			_62:
  12740 				shift = int32(7) ^ v5
  12741 				range1 = range1 << libc.Uint32FromInt32(shift)
  12742 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12743 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12744 				v7 = bit
  12745 				goto _64
  12746 			_64:
  12747 				v = v + v7
  12748 			}
  12749 		} else {
  12750 			v1 = br2
  12751 			range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12752 			if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12753 				v2 = v1
  12754 				if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12755 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12756 					**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12757 					v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12758 					goto _68
  12759 				_68:
  12760 					bits = v3
  12761 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12762 					(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12763 					**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12764 				} else {
  12765 					VP8LoadFinalBytes(tls, v2)
  12766 				}
  12767 			}
  12768 			pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12769 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8)))) >> int32(8)
  12770 			value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12771 			bit = libc.BoolInt32(value > split)
  12772 			if bit != 0 {
  12773 				range1 = range1 - split
  12774 				**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12775 			} else {
  12776 				range1 = split + uint32(1)
  12777 			}
  12778 			v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12779 			goto _70
  12780 		_70:
  12781 			shift = int32(7) ^ v5
  12782 			range1 = range1 << libc.Uint32FromInt32(shift)
  12783 			**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12784 			(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12785 			v7 = bit
  12786 			goto _72
  12787 		_72:
  12788 			bit1 = v7
  12789 			v9 = br2
  12790 			range1 = (*VP8BitReader)(unsafe.Pointer(v9)).Frange1
  12791 			if (*VP8BitReader)(unsafe.Pointer(v9)).Fbits < libc.Int32FromInt32(0) {
  12792 				v10 = v9
  12793 				if (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf_max {
  12794 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v10)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12795 					**(**uintptr)(__ccgo_up(v10 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12796 					v11 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12797 					goto _76
  12798 				_76:
  12799 					bits = v11
  12800 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12801 					(*VP8BitReader)(unsafe.Pointer(v10)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v10)).Fvalue<<libc.Int32FromInt32(BITS)
  12802 					**(**int32)(__ccgo_up(v10 + 12)) += int32(BITS)
  12803 				} else {
  12804 					VP8LoadFinalBytes(tls, v10)
  12805 				}
  12806 			}
  12807 			pos = (*VP8BitReader)(unsafe.Pointer(v9)).Fbits
  12808 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(9)+bit1))))) >> int32(8)
  12809 			value = uint32((*VP8BitReader)(unsafe.Pointer(v9)).Fvalue >> pos)
  12810 			bit = libc.BoolInt32(value > split)
  12811 			if bit != 0 {
  12812 				range1 = range1 - split
  12813 				**(**bit_t)(__ccgo_up(v9)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12814 			} else {
  12815 				range1 = split + uint32(1)
  12816 			}
  12817 			v13 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12818 			goto _78
  12819 		_78:
  12820 			shift = int32(7) ^ v13
  12821 			range1 = range1 << libc.Uint32FromInt32(shift)
  12822 			**(**int32)(__ccgo_up(v9 + 12)) -= shift
  12823 			(*VP8BitReader)(unsafe.Pointer(v9)).Frange1 = range1 - uint32(1)
  12824 			v15 = bit
  12825 			goto _80
  12826 		_80:
  12827 			bit0 = v15
  12828 			cat = int32(2)*bit1 + bit0
  12829 			v = 0
  12830 			tab = kCat3456[cat]
  12831 			for {
  12832 				if !(**(**uint8_t)(__ccgo_up(tab)) != 0) {
  12833 					break
  12834 				}
  12835 				v1 = br2
  12836 				range1 = (*VP8BitReader)(unsafe.Pointer(v1)).Frange1
  12837 				if (*VP8BitReader)(unsafe.Pointer(v1)).Fbits < libc.Int32FromInt32(0) {
  12838 					v2 = v1
  12839 					if (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf_max {
  12840 						libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v2)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12841 						**(**uintptr)(__ccgo_up(v2 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12842 						v3 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12843 						goto _85
  12844 					_85:
  12845 						bits = v3
  12846 						bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12847 						(*VP8BitReader)(unsafe.Pointer(v2)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v2)).Fvalue<<libc.Int32FromInt32(BITS)
  12848 						**(**int32)(__ccgo_up(v2 + 12)) += int32(BITS)
  12849 					} else {
  12850 						VP8LoadFinalBytes(tls, v2)
  12851 					}
  12852 				}
  12853 				pos = (*VP8BitReader)(unsafe.Pointer(v1)).Fbits
  12854 				split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(tab)))) >> int32(8)
  12855 				value = uint32((*VP8BitReader)(unsafe.Pointer(v1)).Fvalue >> pos)
  12856 				bit = libc.BoolInt32(value > split)
  12857 				if bit != 0 {
  12858 					range1 = range1 - split
  12859 					**(**bit_t)(__ccgo_up(v1)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12860 				} else {
  12861 					range1 = split + uint32(1)
  12862 				}
  12863 				v5 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12864 				goto _87
  12865 			_87:
  12866 				shift = int32(7) ^ v5
  12867 				range1 = range1 << libc.Uint32FromInt32(shift)
  12868 				**(**int32)(__ccgo_up(v1 + 12)) -= shift
  12869 				(*VP8BitReader)(unsafe.Pointer(v1)).Frange1 = range1 - uint32(1)
  12870 				v7 = bit
  12871 				goto _89
  12872 			_89:
  12873 				v = v + (v + v7)
  12874 				goto _81
  12875 			_81:
  12876 				;
  12877 				tab = tab + 1
  12878 			}
  12879 			v = v + (int32(3) + int32(8)<<cat)
  12880 		}
  12881 	}
  12882 	return v
  12883 }
  12884 
  12885 // C documentation
  12886 //
  12887 //	// Returns the position of the last non-zero coeff plus one
  12888 func GetCoeffsFast(tls *libc.TLS, br3 uintptr, prob1 uintptr, ctx int32, dq uintptr, n1 int32, out uintptr) (r int32) {
  12889 	bp := tls.Alloc(16)
  12890 	defer tls.Free(16)
  12891 	var bit, pos, pos1, shift, v1, v14, v6, v8 int32
  12892 	var bits bit_t
  12893 	var mask int32_t
  12894 	var p, p_ctx, v2, v3 uintptr
  12895 	var range1, split, split1, value, value1 range_t
  12896 	var v4 uint64_t
  12897 	var _ /* in_bits at bp+0 */ lbit_t
  12898 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, mask, p, p_ctx, pos, pos1, range1, shift, split, split1, v1, value, value1, v14, v2, v3, v4, v6, v8
  12899 	p = **(**uintptr)(__ccgo_up(prob1 + uintptr(n1)*8)) + uintptr(ctx)*11
  12900 	for {
  12901 		if !(n1 < int32(16)) {
  12902 			break
  12903 		}
  12904 		v2 = br3
  12905 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12906 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  12907 			v3 = v2
  12908 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  12909 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12910 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12911 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12912 				goto _5
  12913 			_5:
  12914 				bits = v4
  12915 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12916 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  12917 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  12918 			} else {
  12919 				VP8LoadFinalBytes(tls, v3)
  12920 			}
  12921 		}
  12922 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  12923 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) >> int32(8)
  12924 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  12925 		bit = libc.BoolInt32(value > split)
  12926 		if bit != 0 {
  12927 			range1 = range1 - split
  12928 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12929 		} else {
  12930 			range1 = split + uint32(1)
  12931 		}
  12932 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12933 		goto _7
  12934 	_7:
  12935 		shift = int32(7) ^ v6
  12936 		range1 = range1 << libc.Uint32FromInt32(shift)
  12937 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  12938 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  12939 		v8 = bit
  12940 		goto _9
  12941 	_9:
  12942 		if !(v8 != 0) {
  12943 			return n1 // previous coeff was last non-zero coeff
  12944 		}
  12945 		for {
  12946 			v2 = br3
  12947 			range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12948 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  12949 				v3 = v2
  12950 				if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  12951 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  12952 					**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  12953 					v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  12954 					goto _13
  12955 				_13:
  12956 					bits = v4
  12957 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  12958 					(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  12959 					**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  12960 				} else {
  12961 					VP8LoadFinalBytes(tls, v3)
  12962 				}
  12963 			}
  12964 			pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  12965 			split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) >> int32(8)
  12966 			value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  12967 			bit = libc.BoolInt32(value > split)
  12968 			if bit != 0 {
  12969 				range1 = range1 - split
  12970 				**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  12971 			} else {
  12972 				range1 = split + uint32(1)
  12973 			}
  12974 			v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  12975 			goto _15
  12976 		_15:
  12977 			shift = int32(7) ^ v6
  12978 			range1 = range1 << libc.Uint32FromInt32(shift)
  12979 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  12980 			(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  12981 			v8 = bit
  12982 			goto _17
  12983 		_17:
  12984 			if !!(v8 != 0) {
  12985 				break
  12986 			} // sequence of zero coeffs
  12987 			n1 = n1 + 1
  12988 			v14 = n1
  12989 			p = **(**uintptr)(__ccgo_up(prob1 + uintptr(v14)*8))
  12990 			if n1 == int32(16) {
  12991 				return int32(16)
  12992 			}
  12993 		}
  12994 		// non zero coeff
  12995 		p_ctx = **(**uintptr)(__ccgo_up(prob1 + uintptr(n1+int32(1))*8))
  12996 		v2 = br3
  12997 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  12998 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  12999 			v3 = v2
  13000 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13001 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13002 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13003 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13004 				goto _22
  13005 			_22:
  13006 				bits = v4
  13007 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13008 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13009 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13010 			} else {
  13011 				VP8LoadFinalBytes(tls, v3)
  13012 			}
  13013 		}
  13014 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13015 		split = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) >> int32(8)
  13016 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  13017 		bit = libc.BoolInt32(value > split)
  13018 		if bit != 0 {
  13019 			range1 = range1 - split
  13020 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  13021 		} else {
  13022 			range1 = split + uint32(1)
  13023 		}
  13024 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  13025 		goto _24
  13026 	_24:
  13027 		shift = int32(7) ^ v6
  13028 		range1 = range1 << libc.Uint32FromInt32(shift)
  13029 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13030 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  13031 		v8 = bit
  13032 		goto _26
  13033 	_26:
  13034 		if !(v8 != 0) {
  13035 			v1 = int32(1)
  13036 			p = p_ctx + 1*11
  13037 		} else {
  13038 			v1 = GetLargeValue(tls, br3, p)
  13039 			p = p_ctx + 2*11
  13040 		}
  13041 		v2 = br3
  13042 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13043 			v3 = v2
  13044 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13045 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13046 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13047 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13048 				goto _30
  13049 			_30:
  13050 				bits = v4
  13051 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13052 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13053 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13054 			} else {
  13055 				VP8LoadFinalBytes(tls, v3)
  13056 			}
  13057 		}
  13058 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13059 		split1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1 >> int32(1)
  13060 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13061 		mask = libc.Int32FromUint32(split1-value1) >> int32(31)
  13062 		**(**int32)(__ccgo_up(v2 + 12)) -= int32(1)
  13063 		**(**range_t)(__ccgo_up(v2 + 8)) += libc.Uint32FromInt32(mask)
  13064 		**(**range_t)(__ccgo_up(v2 + 8)) |= uint32(1)
  13065 		**(**bit_t)(__ccgo_up(v2)) -= uint64((split1+libc.Uint32FromInt32(1))&libc.Uint32FromInt32(mask)) << pos1
  13066 		v6 = v1 ^ mask - mask
  13067 		goto _32
  13068 	_32:
  13069 		**(**int16_t)(__ccgo_up(out + uintptr(kZigzag[n1])*2)) = int16(v6 * **(**int32)(__ccgo_up(dq + libc.BoolUintptr(n1 > 0)*4)))
  13070 		goto _1
  13071 	_1:
  13072 		;
  13073 		n1 = n1 + 1
  13074 	}
  13075 	return int32(16)
  13076 }
  13077 
  13078 // C documentation
  13079 //
  13080 //	// This version of GetCoeffs() uses VP8GetBitAlt() which is an alternate version
  13081 //	// of VP8GetBitAlt() targeting specific platforms.
  13082 func GetCoeffsAlt(tls *libc.TLS, br3 uintptr, prob1 uintptr, ctx int32, dq uintptr, n int32, out uintptr) (r int32) {
  13083 	bp := tls.Alloc(16)
  13084 	defer tls.Free(16)
  13085 	var bit, pos, pos1, shift, v1, v12, v6 int32
  13086 	var bits bit_t
  13087 	var mask int32_t
  13088 	var p, p_ctx, v2, v3 uintptr
  13089 	var range1, split, split1, value, value1 range_t
  13090 	var v4 uint64_t
  13091 	var _ /* in_bits at bp+0 */ lbit_t
  13092 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, mask, p, p_ctx, pos, pos1, range1, shift, split, split1, v1, value, value1, v12, v2, v3, v4, v6
  13093 	p = **(**uintptr)(__ccgo_up(prob1 + uintptr(n)*8)) + uintptr(ctx)*11
  13094 	for {
  13095 		if !(n < int32(16)) {
  13096 			break
  13097 		}
  13098 		v2 = br3
  13099 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13100 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13101 			v3 = v2
  13102 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13103 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13104 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13105 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13106 				goto _5
  13107 			_5:
  13108 				bits = v4
  13109 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13110 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13111 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13112 			} else {
  13113 				VP8LoadFinalBytes(tls, v3)
  13114 			}
  13115 		}
  13116 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13117 		split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) >> int32(8)
  13118 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13119 		if value1 > split1 {
  13120 			range1 = range1 - (split1 + uint32(1))
  13121 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13122 			bit = int32(1)
  13123 		} else {
  13124 			range1 = split1
  13125 			bit = 0
  13126 		}
  13127 		if range1 <= libc.Uint32FromInt32(0x7e) {
  13128 			shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13129 			range1 = uint32(kVP8NewRange[range1])
  13130 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13131 		}
  13132 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13133 		v6 = bit
  13134 		goto _7
  13135 	_7:
  13136 		if !(v6 != 0) {
  13137 			return n // previous coeff was last non-zero coeff
  13138 		}
  13139 		for {
  13140 			v2 = br3
  13141 			range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13142 			if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13143 				v3 = v2
  13144 				if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13145 					libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13146 					**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13147 					v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13148 					goto _11
  13149 				_11:
  13150 					bits = v4
  13151 					bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13152 					(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13153 					**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13154 				} else {
  13155 					VP8LoadFinalBytes(tls, v3)
  13156 				}
  13157 			}
  13158 			pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13159 			split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) >> int32(8)
  13160 			value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13161 			if value1 > split1 {
  13162 				range1 = range1 - (split1 + uint32(1))
  13163 				**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13164 				bit = int32(1)
  13165 			} else {
  13166 				range1 = split1
  13167 				bit = 0
  13168 			}
  13169 			if range1 <= libc.Uint32FromInt32(0x7e) {
  13170 				shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13171 				range1 = uint32(kVP8NewRange[range1])
  13172 				**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13173 			}
  13174 			(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13175 			v6 = bit
  13176 			goto _13
  13177 		_13:
  13178 			if !!(v6 != 0) {
  13179 				break
  13180 			} // sequence of zero coeffs
  13181 			n = n + 1
  13182 			v12 = n
  13183 			p = **(**uintptr)(__ccgo_up(prob1 + uintptr(v12)*8))
  13184 			if n == int32(16) {
  13185 				return int32(16)
  13186 			}
  13187 		}
  13188 		// non zero coeff
  13189 		p_ctx = **(**uintptr)(__ccgo_up(prob1 + uintptr(n+int32(1))*8))
  13190 		v2 = br3
  13191 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  13192 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13193 			v3 = v2
  13194 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13195 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13196 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13197 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13198 				goto _18
  13199 			_18:
  13200 				bits = v4
  13201 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13202 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13203 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13204 			} else {
  13205 				VP8LoadFinalBytes(tls, v3)
  13206 			}
  13207 		}
  13208 		pos1 = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13209 		split1 = range1 * libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) >> int32(8)
  13210 		value1 = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos1)
  13211 		if value1 > split1 {
  13212 			range1 = range1 - (split1 + uint32(1))
  13213 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split1+libc.Uint32FromInt32(1)) << pos1
  13214 			bit = int32(1)
  13215 		} else {
  13216 			range1 = split1
  13217 			bit = 0
  13218 		}
  13219 		if range1 <= libc.Uint32FromInt32(0x7e) {
  13220 			shift = libc.Int32FromUint8(kVP8Log2Range[range1])
  13221 			range1 = uint32(kVP8NewRange[range1])
  13222 			**(**int32)(__ccgo_up(v2 + 12)) -= shift
  13223 		}
  13224 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1
  13225 		v6 = bit
  13226 		goto _20
  13227 	_20:
  13228 		if !(v6 != 0) {
  13229 			v1 = int32(1)
  13230 			p = p_ctx + 1*11
  13231 		} else {
  13232 			v1 = GetLargeValue(tls, br3, p)
  13233 			p = p_ctx + 2*11
  13234 		}
  13235 		v2 = br3
  13236 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  13237 			v3 = v2
  13238 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  13239 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  13240 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  13241 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  13242 				goto _24
  13243 			_24:
  13244 				bits = v4
  13245 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  13246 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  13247 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  13248 			} else {
  13249 				VP8LoadFinalBytes(tls, v3)
  13250 			}
  13251 		}
  13252 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  13253 		split = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1 >> int32(1)
  13254 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  13255 		mask = libc.Int32FromUint32(split-value) >> int32(31)
  13256 		**(**int32)(__ccgo_up(v2 + 12)) -= int32(1)
  13257 		**(**range_t)(__ccgo_up(v2 + 8)) += libc.Uint32FromInt32(mask)
  13258 		**(**range_t)(__ccgo_up(v2 + 8)) |= uint32(1)
  13259 		**(**bit_t)(__ccgo_up(v2)) -= uint64((split+libc.Uint32FromInt32(1))&libc.Uint32FromInt32(mask)) << pos
  13260 		v6 = v1 ^ mask - mask
  13261 		goto _26
  13262 	_26:
  13263 		**(**int16_t)(__ccgo_up(out + uintptr(kZigzag[n])*2)) = int16(v6 * **(**int32)(__ccgo_up(dq + libc.BoolUintptr(n > 0)*4)))
  13264 		goto _1
  13265 	_1:
  13266 		;
  13267 		n = n + 1
  13268 	}
  13269 	return int32(16)
  13270 }
  13271 
  13272 func InitGetCoeffs(tls *libc.TLS) {
  13273 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  13274 		goto _1
  13275 	}
  13276 	InitGetCoeffs_body(tls)
  13277 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used)), VP8GetCPUInfo)
  13278 	goto _2
  13279 _2:
  13280 	;
  13281 	goto _1
  13282 _1: /**/ //
  13283 }
  13284 
  13285 var InitGetCoeffs_body_last_cpuinfo_used = uintptr(0)
  13286 
  13287 func init() {
  13288 	p := unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used)
  13289 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&InitGetCoeffs_body_last_cpuinfo_used))
  13290 }
  13291 
  13292 func InitGetCoeffs_body(tls *libc.TLS) {
  13293 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) && (*(*func(*libc.TLS, CPUFeature) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetCPUInfo})))(tls, int32(kSlowSSSE3)) != 0 {
  13294 		GetCoeffs = __ccgo_fp(GetCoeffsAlt)
  13295 	} else {
  13296 		GetCoeffs = __ccgo_fp(GetCoeffsFast)
  13297 	}
  13298 }
  13299 
  13300 func NzCodeBits(tls *libc.TLS, nz_coeffs uint32_t, nz int32, dc_nz int32) (r uint32_t) {
  13301 	var v1, v2 int32
  13302 	_, _ = v1, v2
  13303 	nz_coeffs = nz_coeffs << uint32(2)
  13304 	if nz > int32(3) {
  13305 		v1 = int32(3)
  13306 	} else {
  13307 		if nz > int32(1) {
  13308 			v2 = int32(2)
  13309 		} else {
  13310 			v2 = dc_nz
  13311 		}
  13312 		v1 = v2
  13313 	}
  13314 	nz_coeffs = nz_coeffs | libc.Uint32FromInt32(v1)
  13315 	return nz_coeffs
  13316 }
  13317 
  13318 func ParseResiduals(tls *libc.TLS, dec uintptr, mb uintptr, token_br uintptr) (r int32) {
  13319 	bp := tls.Alloc(32)
  13320 	defer tls.Free(32)
  13321 	var ac_proba, bands, block, dst, left_mb, q uintptr
  13322 	var ch, ctx, ctx1, ctx2, dc0, first, i, l, l1, nz, nz1, nz2, x, y, v8 int32
  13323 	var lnz, tnz, v1 uint8_t
  13324 	var non_zero_uv, non_zero_y, nz_coeffs, nz_coeffs1, out_l_nz, out_t_nz uint32_t
  13325 	var _ /* dc at bp+0 */ [16]int16_t
  13326 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  13327 	bands = dec + 1192 + 1064
  13328 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*800
  13329 	q = dec + 1060 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fsegment)*32
  13330 	dst = block
  13331 	left_mb = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13332 	non_zero_y = uint32(0)
  13333 	non_zero_uv = uint32(0)
  13334 	libc.X__builtin___memset_chk(tls, dst, 0, libc.Uint64FromInt32(384)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  13335 	if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) { // parse DC
  13336 		**(**[16]int16_t)(__ccgo_up(bp)) = [16]int16_t{}
  13337 		ctx = libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz_dc) + libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz_dc)
  13338 		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)
  13339 		v1 = libc.BoolUint8(nz > libc.Int32FromInt32(0))
  13340 		(*VP8MB)(unsafe.Pointer(left_mb)).Fnz_dc = v1
  13341 		(*VP8MB)(unsafe.Pointer(mb)).Fnz_dc = v1
  13342 		if nz > int32(1) { // more than just the DC -> perform the full transform
  13343 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformWHT})))(tls, bp, dst)
  13344 		} else {
  13345 			dc0 = (int32((**(**[16]int16_t)(__ccgo_up(bp)))[0]) + int32(3)) >> int32(3)
  13346 			i = 0
  13347 			for {
  13348 				if !(i < libc.Int32FromInt32(16)*libc.Int32FromInt32(16)) {
  13349 					break
  13350 				}
  13351 				**(**int16_t)(__ccgo_up(dst + uintptr(i)*2)) = int16(dc0)
  13352 				goto _2
  13353 			_2:
  13354 				;
  13355 				i = i + int32(16)
  13356 			}
  13357 		}
  13358 		first = int32(1)
  13359 		ac_proba = bands
  13360 	} else {
  13361 		first = 0
  13362 		ac_proba = bands + 3*136
  13363 	}
  13364 	tnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz) & int32(0x0f))
  13365 	lnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz) & int32(0x0f))
  13366 	y = 0
  13367 	for {
  13368 		if !(y < int32(4)) {
  13369 			break
  13370 		}
  13371 		l = libc.Int32FromUint8(lnz) & int32(1)
  13372 		nz_coeffs = uint32(0)
  13373 		x = 0
  13374 		for {
  13375 			if !(x < int32(4)) {
  13376 				break
  13377 			}
  13378 			ctx1 = l + libc.Int32FromUint8(tnz)&int32(1)
  13379 			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)
  13380 			l = libc.BoolInt32(nz1 > first)
  13381 			tnz = libc.Uint8FromInt32(libc.Int32FromUint8(tnz)>>int32(1) | l<<int32(7))
  13382 			nz_coeffs = NzCodeBits(tls, nz_coeffs, nz1, libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(dst))) != 0))
  13383 			dst = dst + uintptr(16)*2
  13384 			goto _4
  13385 		_4:
  13386 			;
  13387 			x = x + 1
  13388 		}
  13389 		tnz = libc.Uint8FromInt32(int32(tnz) >> libc.Int32FromInt32(4))
  13390 		lnz = libc.Uint8FromInt32(libc.Int32FromUint8(lnz)>>int32(1) | l<<int32(7))
  13391 		non_zero_y = non_zero_y<<libc.Int32FromInt32(8) | nz_coeffs
  13392 		goto _3
  13393 	_3:
  13394 		;
  13395 		y = y + 1
  13396 	}
  13397 	out_t_nz = uint32(tnz)
  13398 	out_l_nz = libc.Uint32FromInt32(libc.Int32FromUint8(lnz) >> int32(4))
  13399 	ch = 0
  13400 	for {
  13401 		if !(ch < int32(4)) {
  13402 			break
  13403 		}
  13404 		nz_coeffs1 = uint32(0)
  13405 		tnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(mb)).Fnz) >> (int32(4) + ch))
  13406 		lnz = libc.Uint8FromInt32(libc.Int32FromUint8((*VP8MB)(unsafe.Pointer(left_mb)).Fnz) >> (int32(4) + ch))
  13407 		y = 0
  13408 		for {
  13409 			if !(y < int32(2)) {
  13410 				break
  13411 			}
  13412 			l1 = libc.Int32FromUint8(lnz) & int32(1)
  13413 			x = 0
  13414 			for {
  13415 				if !(x < int32(2)) {
  13416 					break
  13417 				}
  13418 				ctx2 = l1 + libc.Int32FromUint8(tnz)&int32(1)
  13419 				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)
  13420 				l1 = libc.BoolInt32(nz2 > 0)
  13421 				tnz = libc.Uint8FromInt32(libc.Int32FromUint8(tnz)>>int32(1) | l1<<int32(3))
  13422 				nz_coeffs1 = NzCodeBits(tls, nz_coeffs1, nz2, libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(dst))) != 0))
  13423 				dst = dst + uintptr(16)*2
  13424 				goto _7
  13425 			_7:
  13426 				;
  13427 				x = x + 1
  13428 			}
  13429 			tnz = libc.Uint8FromInt32(int32(tnz) >> libc.Int32FromInt32(2))
  13430 			lnz = libc.Uint8FromInt32(libc.Int32FromUint8(lnz)>>int32(1) | l1<<int32(5))
  13431 			goto _6
  13432 		_6:
  13433 			;
  13434 			y = y + 1
  13435 		}
  13436 		// Note: we don't really need the per-4x4 details for U/V blocks.
  13437 		non_zero_uv = non_zero_uv | nz_coeffs1<<(int32(4)*ch)
  13438 		out_t_nz = out_t_nz | libc.Uint32FromInt32(libc.Int32FromUint8(tnz)<<int32(4)<<ch)
  13439 		out_l_nz = out_l_nz | libc.Uint32FromInt32(libc.Int32FromUint8(lnz)&int32(0xf0)<<ch)
  13440 		goto _5
  13441 	_5:
  13442 		;
  13443 		ch = ch + int32(2)
  13444 	}
  13445 	(*VP8MB)(unsafe.Pointer(mb)).Fnz = uint8(out_t_nz)
  13446 	(*VP8MB)(unsafe.Pointer(left_mb)).Fnz = uint8(out_l_nz)
  13447 	(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y = non_zero_y
  13448 	(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv = non_zero_uv
  13449 	// We look at the mode-code of each block and check if some blocks have less
  13450 	// than three non-zero coeffs (code < 2). This is to avoid dithering flat and
  13451 	// empty blocks.
  13452 	if non_zero_uv&uint32(0xaaaa) != 0 {
  13453 		v8 = 0
  13454 	} else {
  13455 		v8 = (*VP8QuantMatrix)(unsafe.Pointer(q)).Fdither
  13456 	}
  13457 	(*VP8MBData)(unsafe.Pointer(block)).Fdither = libc.Uint8FromInt32(v8)
  13458 	return libc.BoolInt32(!(non_zero_y|non_zero_uv != 0)) // will be used for further optimization
  13459 }
  13460 
  13461 //------------------------------------------------------------------------------
  13462 // Main loop
  13463 
  13464 func VP8DecodeMB(tls *libc.TLS, dec uintptr, token_br uintptr) (r int32) {
  13465 	var block, finfo, left, mb, v4 uintptr
  13466 	var skip, v1 int32
  13467 	var v2 uint8_t
  13468 	_, _, _, _, _, _, _, _ = block, finfo, left, mb, skip, v1, v2, v4
  13469 	left = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13470 	mb = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*2
  13471 	block = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_data + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*800
  13472 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fuse_skip_proba != 0 {
  13473 		v1 = libc.Int32FromUint8((*VP8MBData)(unsafe.Pointer(block)).Fskip)
  13474 	} else {
  13475 		v1 = 0
  13476 	}
  13477 	skip = v1
  13478 	if !(skip != 0) {
  13479 		skip = ParseResiduals(tls, dec, mb, token_br)
  13480 	} else {
  13481 		v2 = libc.Uint8FromInt32(0)
  13482 		(*VP8MB)(unsafe.Pointer(mb)).Fnz = v2
  13483 		(*VP8MB)(unsafe.Pointer(left)).Fnz = v2
  13484 		if !((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4 != 0) {
  13485 			v2 = libc.Uint8FromInt32(0)
  13486 			(*VP8MB)(unsafe.Pointer(mb)).Fnz_dc = v2
  13487 			(*VP8MB)(unsafe.Pointer(left)).Fnz_dc = v2
  13488 		}
  13489 		(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_y = uint32(0)
  13490 		(*VP8MBData)(unsafe.Pointer(block)).Fnon_zero_uv = uint32(0)
  13491 		(*VP8MBData)(unsafe.Pointer(block)).Fdither = uint8(0)
  13492 	}
  13493 	if (*VP8Decoder)(unsafe.Pointer(dec)).Ffilter_type > 0 { // store filter info
  13494 		finfo = (*VP8Decoder)(unsafe.Pointer(dec)).Ff_info + uintptr((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x)*4
  13495 		**(**VP8FInfo)(__ccgo_up(finfo)) = **(**VP8FInfo)(__ccgo_up(dec + 2924 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fsegment)*8 + uintptr((*VP8MBData)(unsafe.Pointer(block)).Fis_i4x4)*4))
  13496 		v4 = finfo + 2
  13497 		*(*uint8_t)(unsafe.Pointer(v4)) = uint8_t(int32(*(*uint8_t)(unsafe.Pointer(v4))) | libc.BoolInt32(!(skip != 0)))
  13498 	}
  13499 	return libc.BoolInt32(!((*VP8BitReader)(unsafe.Pointer(token_br)).Feof != 0))
  13500 }
  13501 
  13502 func VP8InitScanline(tls *libc.TLS, dec uintptr) {
  13503 	var left uintptr
  13504 	_ = left
  13505 	left = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_info - uintptr(1)*2
  13506 	(*VP8MB)(unsafe.Pointer(left)).Fnz = uint8(0)
  13507 	(*VP8MB)(unsafe.Pointer(left)).Fnz_dc = uint8(0)
  13508 	libc.X__builtin___memset_chk(tls, dec+2816, int32(B_DC_PRED), uint64(4), ^__predefined_size_t(0))
  13509 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = 0
  13510 }
  13511 
  13512 func ParseFrame(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  13513 	var token_br uintptr
  13514 	_ = token_br
  13515 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = 0
  13516 	for {
  13517 		if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y < (*VP8Decoder)(unsafe.Pointer(dec)).Fbr_mb_y) {
  13518 			break
  13519 		}
  13520 		// Parse bitstream for this row.
  13521 		token_br = dec + 440 + uintptr(libc.Uint32FromInt32((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y)&(*VP8Decoder)(unsafe.Pointer(dec)).Fnum_parts_minus_one)*48
  13522 		if !(VP8ParseIntraModeRow(tls, dec+16, dec) != 0) {
  13523 			return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+435)
  13524 		}
  13525 		for {
  13526 			if !((*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x < (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_w) {
  13527 				break
  13528 			}
  13529 			if !(VP8DecodeMB(tls, dec, token_br) != 0) {
  13530 				return VP8SetError(tls, dec, int32(VP8_STATUS_NOT_ENOUGH_DATA), __ccgo_ts+476)
  13531 			}
  13532 			goto _2
  13533 		_2:
  13534 			;
  13535 			(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_x + 1
  13536 		}
  13537 		VP8InitScanline(tls, dec) // Prepare for next scanline
  13538 		// Reconstruct, filter and emit the row.
  13539 		if !(VP8ProcessRow(tls, dec, io) != 0) {
  13540 			return VP8SetError(tls, dec, int32(VP8_STATUS_USER_ABORT), __ccgo_ts+511)
  13541 		}
  13542 		goto _1
  13543 	_1:
  13544 		;
  13545 		(*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y = (*VP8Decoder)(unsafe.Pointer(dec)).Fmb_y + 1
  13546 	}
  13547 	if (*VP8Decoder)(unsafe.Pointer(dec)).Fmt_method > 0 {
  13548 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, dec+152) != 0) {
  13549 			return 0
  13550 		}
  13551 	}
  13552 	return int32(1)
  13553 }
  13554 
  13555 // C documentation
  13556 //
  13557 //	// Main entry point
  13558 func VP8Decode(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  13559 	var ok int32
  13560 	_ = ok
  13561 	ok = 0
  13562 	if dec == libc.UintptrFromInt32(0) {
  13563 		return 0
  13564 	}
  13565 	if io == libc.UintptrFromInt32(0) {
  13566 		return VP8SetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM), __ccgo_ts+527)
  13567 	}
  13568 	if !((*VP8Decoder)(unsafe.Pointer(dec)).Fready != 0) {
  13569 		if !(VP8GetHeaders(tls, dec, io) != 0) {
  13570 			return 0
  13571 		}
  13572 	}
  13573 	// Finish setting up the decoding parameter. Will call io->setup().
  13574 	ok = libc.BoolInt32(VP8EnterCritical(tls, dec, io) == int32(VP8_STATUS_OK))
  13575 	if ok != 0 { // good to go.
  13576 		// Will allocate memory and prepare everything.
  13577 		if ok != 0 {
  13578 			ok = VP8InitFrame(tls, dec, io)
  13579 		}
  13580 		// Main decoding loop
  13581 		if ok != 0 {
  13582 			ok = ParseFrame(tls, dec, io)
  13583 		}
  13584 		// Exit.
  13585 		ok = ok & VP8ExitCritical(tls, dec, io)
  13586 	}
  13587 	if !(ok != 0) {
  13588 		VP8Clear(tls, dec)
  13589 		return 0
  13590 	}
  13591 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  13592 	return ok
  13593 }
  13594 
  13595 func VP8Clear(tls *libc.TLS, dec uintptr) {
  13596 	if dec == libc.UintptrFromInt32(0) {
  13597 		return
  13598 	}
  13599 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FEnd})))(tls, dec+152)
  13600 	WebPDeallocateAlphaMemory(tls, dec)
  13601 	WebPSafeFree(tls, (*VP8Decoder)(unsafe.Pointer(dec)).Fmem)
  13602 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmem = libc.UintptrFromInt32(0)
  13603 	(*VP8Decoder)(unsafe.Pointer(dec)).Fmem_size = uint64(0)
  13604 	libc.X__builtin___memset_chk(tls, dec+16, 0, uint64(48), ^__predefined_size_t(0))
  13605 	(*VP8Decoder)(unsafe.Pointer(dec)).Fready = 0
  13606 }
  13607 
  13608 const APPROX_LOG_MAX = 4096
  13609 const APPROX_LOG_WITH_CORRECTION_MAX = 65536
  13610 const BITS_SPECIAL_MARKER = 256
  13611 const CODE_TO_PLANE_CODES = 120
  13612 const LOG_2_PRECISION_BITS = 23
  13613 const LOG_2_RECIPROCAL = 1.44269504088896338700465094007086
  13614 const LOG_2_RECIPROCAL_FIXED_DOUBLE = 12102203.161561485379934310913085937500
  13615 const LOG_LOOKUP_IDX_MAX = 256
  13616 const NUM_ARGB_CACHE_ROWS = 16
  13617 const NUM_CODE_LENGTH_CODES = 19
  13618 const PACKED_NON_LITERAL_CODE = 0
  13619 const PREFIX_LOOKUP_IDX_MAX = 512
  13620 const SYNC_EVERY_N_ROWS = 8
  13621 const VP8L_MAGIC_BYTE1 = 47
  13622 
  13623 var kHashMul8 = uint32(0x1e35a7bd)
  13624 
  13625 type VP8LPredictorFunc = uintptr
  13626 
  13627 type VP8LPredictorAddSubFunc = uintptr
  13628 
  13629 type VP8LProcessDecBlueAndRedFunc = uintptr
  13630 
  13631 type VP8LMultipliers = struct {
  13632 	Fgreen_to_red  uint8_t
  13633 	Fgreen_to_blue uint8_t
  13634 	Fred_to_blue   uint8_t
  13635 }
  13636 
  13637 type VP8LTransformColorInverseFunc = uintptr
  13638 
  13639 type VP8LConvertFunc = uintptr
  13640 
  13641 type VP8LMapARGBFunc = uintptr
  13642 
  13643 type VP8LMapAlphaFunc = uintptr
  13644 
  13645 type VP8LProcessEncBlueAndRedFunc = uintptr
  13646 
  13647 type VP8LTransformColorFunc = uintptr
  13648 
  13649 type VP8LCollectColorBlueTransformsFunc = uintptr
  13650 
  13651 type VP8LCollectColorRedTransformsFunc = uintptr
  13652 
  13653 type VP8LCostFunc = uintptr
  13654 
  13655 type VP8LCombinedShannonEntropyFunc = uintptr
  13656 
  13657 type VP8LShannonEntropyFunc = uintptr
  13658 
  13659 type VP8LStreaks = struct {
  13660 	Fcounts  [2]int32
  13661 	Fstreaks [2][2]int32
  13662 }
  13663 
  13664 type VP8LBitEntropy = struct {
  13665 	Fentropy      uint64_t
  13666 	Fsum          uint32_t
  13667 	Fnonzeros     int32
  13668 	Fmax_val      uint32_t
  13669 	Fnonzero_code uint32_t
  13670 }
  13671 
  13672 type VP8LGetCombinedEntropyUnrefinedFunc = uintptr
  13673 
  13674 type VP8LGetEntropyUnrefinedFunc = uintptr
  13675 
  13676 type VP8LAddVectorFunc = uintptr
  13677 
  13678 type VP8LAddVectorEqFunc = uintptr
  13679 
  13680 type VP8LVectorMismatchFunc = uintptr
  13681 
  13682 type VP8LBundleColorMapFunc = uintptr
  13683 
  13684 type VP8LFastLog2SlowFunc = uintptr
  13685 
  13686 type VP8LFastSLog2SlowFunc = uintptr
  13687 
  13688 type VP8LPrefixCode = struct {
  13689 	Fcode       int8_t
  13690 	Fextra_bits int8_t
  13691 }
  13692 
  13693 //------------------------------------------------------------------------------
  13694 // Transform-related functions used in both encoding and decoding.
  13695 
  13696 // Macros used to create a batch predictor that iteratively uses a
  13697 // one-pixel predictor.
  13698 
  13699 // The predictor is added to the output pixel (which
  13700 // is therefore considered as a residual) to get the final prediction.
  13701 
  13702 // Copyright 2010 Google Inc. All Rights Reserved.
  13703 //
  13704 // Use of this source code is governed by a BSD-style license
  13705 // that can be found in the COPYING file in the root of the source
  13706 // tree. An additional intellectual property rights grant can be found
  13707 // in the file PATENTS. All contributing project authors may
  13708 // be found in the AUTHORS file in the root of the source tree.
  13709 // -----------------------------------------------------------------------------
  13710 //
  13711 // Boolean decoder
  13712 //
  13713 // Author: Skal (pascal.massimino@gmail.com)
  13714 //         Vikas Arora (vikaas.arora@gmail.com)
  13715 
  13716 // Copyright 2012 Google Inc. All Rights Reserved.
  13717 //
  13718 // Use of this source code is governed by a BSD-style license
  13719 // that can be found in the COPYING file in the root of the source
  13720 // tree. An additional intellectual property rights grant can be found
  13721 // in the file PATENTS. All contributing project authors may
  13722 // be found in the AUTHORS file in the root of the source tree.
  13723 // -----------------------------------------------------------------------------
  13724 //
  13725 // Color Cache for WebP Lossless
  13726 //
  13727 // Authors: Jyrki Alakuijala (jyrki@google.com)
  13728 //          Urvang Joshi (urvang@google.com)
  13729 
  13730 // Copyright 2012 Google Inc. All Rights Reserved.
  13731 //
  13732 // Use of this source code is governed by a BSD-style license
  13733 // that can be found in the COPYING file in the root of the source
  13734 // tree. An additional intellectual property rights grant can be found
  13735 // in the file PATENTS. All contributing project authors may
  13736 // be found in the AUTHORS file in the root of the source tree.
  13737 // -----------------------------------------------------------------------------
  13738 //
  13739 // Utilities for building and looking up Huffman trees.
  13740 //
  13741 // Author: Urvang Joshi (urvang@google.com)
  13742 
  13743 // Copyright 2012 Google Inc. All Rights Reserved.
  13744 //
  13745 // Use of this source code is governed by a BSD-style license
  13746 // that can be found in the COPYING file in the root of the source
  13747 // tree. An additional intellectual property rights grant can be found
  13748 // in the file PATENTS. All contributing project authors may
  13749 // be found in the AUTHORS file in the root of the source tree.
  13750 // -----------------------------------------------------------------------------
  13751 //
  13752 // Rescaling functions
  13753 //
  13754 // Author: Skal (pascal.massimino@gmail.com)
  13755 
  13756 // Copyright 2012 Google Inc. All Rights Reserved.
  13757 //
  13758 // Use of this source code is governed by a BSD-style license
  13759 // that can be found in the COPYING file in the root of the source
  13760 // tree. An additional intellectual property rights grant can be found
  13761 // in the file PATENTS. All contributing project authors may
  13762 // be found in the AUTHORS file in the root of the source tree.
  13763 // -----------------------------------------------------------------------------
  13764 //
  13765 // Misc. common utility functions
  13766 //
  13767 // Authors: Skal (pascal.massimino@gmail.com)
  13768 //          Urvang (urvang@google.com)
  13769 
  13770 // Copyright 2010 Google Inc. All Rights Reserved.
  13771 //
  13772 // Use of this source code is governed by a BSD-style license
  13773 // that can be found in the COPYING file in the root of the source
  13774 // tree. An additional intellectual property rights grant can be found
  13775 // in the file PATENTS. All contributing project authors may
  13776 // be found in the AUTHORS file in the root of the source tree.
  13777 // -----------------------------------------------------------------------------
  13778 //
  13779 //  Main decoding functions for WebP images.
  13780 //
  13781 // Author: Skal (pascal.massimino@gmail.com)
  13782 
  13783 // Copyright 2012 Google Inc. All Rights Reserved.
  13784 //
  13785 // Use of this source code is governed by a BSD-style license
  13786 // that can be found in the COPYING file in the root of the source
  13787 // tree. An additional intellectual property rights grant can be found
  13788 // in the file PATENTS. All contributing project authors may
  13789 // be found in the AUTHORS file in the root of the source tree.
  13790 // -----------------------------------------------------------------------------
  13791 //
  13792 //  Internal header for constants related to WebP file format.
  13793 //
  13794 // Author: Urvang (urvang@google.com)
  13795 
  13796 // Copyright 2010 Google Inc. All Rights Reserved.
  13797 //
  13798 // Use of this source code is governed by a BSD-style license
  13799 // that can be found in the COPYING file in the root of the source
  13800 // tree. An additional intellectual property rights grant can be found
  13801 // in the file PATENTS. All contributing project authors may
  13802 // be found in the AUTHORS file in the root of the source tree.
  13803 // -----------------------------------------------------------------------------
  13804 //
  13805 //  Common types + memory wrappers
  13806 //
  13807 // Author: Skal (pascal.massimino@gmail.com)
  13808 
  13809 var kCodeLengthLiterals = int32(16)
  13810 var kCodeLengthRepeatCode = int32(16)
  13811 var kCodeLengthExtraBits = [3]uint8_t{
  13812 	0: uint8(2),
  13813 	1: uint8(3),
  13814 	2: uint8(7),
  13815 }
  13816 var kCodeLengthRepeatOffsets = [3]uint8_t{
  13817 	0: uint8(3),
  13818 	1: uint8(3),
  13819 	2: uint8(11),
  13820 }
  13821 
  13822 // C documentation
  13823 //
  13824 //	// -----------------------------------------------------------------------------
  13825 //	//  Five Huffman codes are used at each meta code:
  13826 //	//  1. green + length prefix codes + color cache codes,
  13827 //	//  2. alpha,
  13828 //	//  3. red,
  13829 //	//  4. blue, and,
  13830 //	//  5. distance prefix codes.
  13831 type HuffIndex = int32
  13832 
  13833 const GREEN = 0
  13834 const RED = 1
  13835 const BLUE = 2
  13836 const ALPHA = 3
  13837 const DIST = 4
  13838 
  13839 var kAlphabetSize = [5]uint16_t{
  13840 	0: libc.Uint16FromInt32(libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)),
  13841 	1: uint16(NUM_LITERAL_CODES),
  13842 	2: uint16(NUM_LITERAL_CODES),
  13843 	3: uint16(NUM_LITERAL_CODES),
  13844 	4: uint16(NUM_DISTANCE_CODES),
  13845 }
  13846 
  13847 var kLiteralMap = [5]uint8_t{
  13848 	1: uint8(1),
  13849 	2: uint8(1),
  13850 	3: uint8(1),
  13851 }
  13852 
  13853 var kCodeLengthCodeOrder = [19]uint8_t{
  13854 	0:  uint8(17),
  13855 	1:  uint8(18),
  13856 	3:  uint8(1),
  13857 	4:  uint8(2),
  13858 	5:  uint8(3),
  13859 	6:  uint8(4),
  13860 	7:  uint8(5),
  13861 	8:  uint8(16),
  13862 	9:  uint8(6),
  13863 	10: uint8(7),
  13864 	11: uint8(8),
  13865 	12: uint8(9),
  13866 	13: uint8(10),
  13867 	14: uint8(11),
  13868 	15: uint8(12),
  13869 	16: uint8(13),
  13870 	17: uint8(14),
  13871 	18: uint8(15),
  13872 }
  13873 
  13874 var kCodeToPlane = [120]uint8_t{
  13875 	0:   uint8(0x18),
  13876 	1:   uint8(0x07),
  13877 	2:   uint8(0x17),
  13878 	3:   uint8(0x19),
  13879 	4:   uint8(0x28),
  13880 	5:   uint8(0x06),
  13881 	6:   uint8(0x27),
  13882 	7:   uint8(0x29),
  13883 	8:   uint8(0x16),
  13884 	9:   uint8(0x1a),
  13885 	10:  uint8(0x26),
  13886 	11:  uint8(0x2a),
  13887 	12:  uint8(0x38),
  13888 	13:  uint8(0x05),
  13889 	14:  uint8(0x37),
  13890 	15:  uint8(0x39),
  13891 	16:  uint8(0x15),
  13892 	17:  uint8(0x1b),
  13893 	18:  uint8(0x36),
  13894 	19:  uint8(0x3a),
  13895 	20:  uint8(0x25),
  13896 	21:  uint8(0x2b),
  13897 	22:  uint8(0x48),
  13898 	23:  uint8(0x04),
  13899 	24:  uint8(0x47),
  13900 	25:  uint8(0x49),
  13901 	26:  uint8(0x14),
  13902 	27:  uint8(0x1c),
  13903 	28:  uint8(0x35),
  13904 	29:  uint8(0x3b),
  13905 	30:  uint8(0x46),
  13906 	31:  uint8(0x4a),
  13907 	32:  uint8(0x24),
  13908 	33:  uint8(0x2c),
  13909 	34:  uint8(0x58),
  13910 	35:  uint8(0x45),
  13911 	36:  uint8(0x4b),
  13912 	37:  uint8(0x34),
  13913 	38:  uint8(0x3c),
  13914 	39:  uint8(0x03),
  13915 	40:  uint8(0x57),
  13916 	41:  uint8(0x59),
  13917 	42:  uint8(0x13),
  13918 	43:  uint8(0x1d),
  13919 	44:  uint8(0x56),
  13920 	45:  uint8(0x5a),
  13921 	46:  uint8(0x23),
  13922 	47:  uint8(0x2d),
  13923 	48:  uint8(0x44),
  13924 	49:  uint8(0x4c),
  13925 	50:  uint8(0x55),
  13926 	51:  uint8(0x5b),
  13927 	52:  uint8(0x33),
  13928 	53:  uint8(0x3d),
  13929 	54:  uint8(0x68),
  13930 	55:  uint8(0x02),
  13931 	56:  uint8(0x67),
  13932 	57:  uint8(0x69),
  13933 	58:  uint8(0x12),
  13934 	59:  uint8(0x1e),
  13935 	60:  uint8(0x66),
  13936 	61:  uint8(0x6a),
  13937 	62:  uint8(0x22),
  13938 	63:  uint8(0x2e),
  13939 	64:  uint8(0x54),
  13940 	65:  uint8(0x5c),
  13941 	66:  uint8(0x43),
  13942 	67:  uint8(0x4d),
  13943 	68:  uint8(0x65),
  13944 	69:  uint8(0x6b),
  13945 	70:  uint8(0x32),
  13946 	71:  uint8(0x3e),
  13947 	72:  uint8(0x78),
  13948 	73:  uint8(0x01),
  13949 	74:  uint8(0x77),
  13950 	75:  uint8(0x79),
  13951 	76:  uint8(0x53),
  13952 	77:  uint8(0x5d),
  13953 	78:  uint8(0x11),
  13954 	79:  uint8(0x1f),
  13955 	80:  uint8(0x64),
  13956 	81:  uint8(0x6c),
  13957 	82:  uint8(0x42),
  13958 	83:  uint8(0x4e),
  13959 	84:  uint8(0x76),
  13960 	85:  uint8(0x7a),
  13961 	86:  uint8(0x21),
  13962 	87:  uint8(0x2f),
  13963 	88:  uint8(0x75),
  13964 	89:  uint8(0x7b),
  13965 	90:  uint8(0x31),
  13966 	91:  uint8(0x3f),
  13967 	92:  uint8(0x63),
  13968 	93:  uint8(0x6d),
  13969 	94:  uint8(0x52),
  13970 	95:  uint8(0x5e),
  13971 	97:  uint8(0x74),
  13972 	98:  uint8(0x7c),
  13973 	99:  uint8(0x41),
  13974 	100: uint8(0x4f),
  13975 	101: uint8(0x10),
  13976 	102: uint8(0x20),
  13977 	103: uint8(0x62),
  13978 	104: uint8(0x6e),
  13979 	105: uint8(0x30),
  13980 	106: uint8(0x73),
  13981 	107: uint8(0x7d),
  13982 	108: uint8(0x51),
  13983 	109: uint8(0x5f),
  13984 	110: uint8(0x40),
  13985 	111: uint8(0x72),
  13986 	112: uint8(0x7e),
  13987 	113: uint8(0x61),
  13988 	114: uint8(0x6f),
  13989 	115: uint8(0x50),
  13990 	116: uint8(0x71),
  13991 	117: uint8(0x7f),
  13992 	118: uint8(0x60),
  13993 	119: uint8(0x70),
  13994 }
  13995 
  13996 // C documentation
  13997 //
  13998 //	// Memory needed for lookup tables of one Huffman tree group. Red, blue, alpha
  13999 //	// and distance alphabets are constant (256 for red, blue and alpha, 40 for
  14000 //	// distance) and lookup table sizes for them in worst case are 630 and 410
  14001 //	// respectively. Size of green alphabet depends on color cache size and is equal
  14002 //	// to 256 (green component values) + 24 (length prefix values)
  14003 //	// + color_cache_size (between 0 and 2048).
  14004 //	// All values computed for 8-bit first level lookup with Mark Adler's tool:
  14005 //	// https://github.com/madler/zlib/blob/v1.2.5/examples/enough.c
  14006 var kTableSize = [12]uint16_t{
  14007 	0:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(654)),
  14008 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(656)),
  14009 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(658)),
  14010 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(662)),
  14011 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(670)),
  14012 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(686)),
  14013 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(718)),
  14014 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(782)),
  14015 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(912)),
  14016 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(1168)),
  14017 	10: libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(1680)),
  14018 	11: libc.Uint16FromInt32(libc.Int32FromInt32(630)*libc.Int32FromInt32(3) + libc.Int32FromInt32(410) + libc.Int32FromInt32(2704)),
  14019 }
  14020 
  14021 func VP8LSetError(tls *libc.TLS, dec uintptr, error1 VP8StatusCode1) (r int32) {
  14022 	// The oldest error reported takes precedence over the new one.
  14023 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_OK) || (*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus == int32(VP8_STATUS_SUSPENDED) {
  14024 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = error1
  14025 	}
  14026 	return 0
  14027 }
  14028 
  14029 //------------------------------------------------------------------------------
  14030 
  14031 func VP8LCheckSignature(tls *libc.TLS, data uintptr, size size_t) (r int32) {
  14032 	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
  14033 }
  14034 
  14035 func ReadImageInfo(tls *libc.TLS, br uintptr, width uintptr, height uintptr, has_alpha uintptr) (r int32) {
  14036 	if VP8LReadBits(tls, br, int32(8)) != uint32(VP8L_MAGIC_BYTE1) {
  14037 		return 0
  14038 	}
  14039 	**(**int32)(__ccgo_up(width)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(VP8L_IMAGE_SIZE_BITS)) + uint32(1))
  14040 	**(**int32)(__ccgo_up(height)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(VP8L_IMAGE_SIZE_BITS)) + uint32(1))
  14041 	**(**int32)(__ccgo_up(has_alpha)) = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14042 	if VP8LReadBits(tls, br, int32(VP8L_VERSION_BITS)) != uint32(0) {
  14043 		return 0
  14044 	}
  14045 	return libc.BoolInt32(!((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  14046 }
  14047 
  14048 func VP8LGetInfo(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr, has_alpha uintptr) (r int32) {
  14049 	bp := tls.Alloc(64)
  14050 	defer tls.Free(64)
  14051 	var _ /* a at bp+8 */ int32
  14052 	var _ /* br at bp+16 */ VP8LBitReader
  14053 	var _ /* h at bp+4 */ int32
  14054 	var _ /* w at bp+0 */ int32
  14055 	if data == libc.UintptrFromInt32(0) || data_size < uint64(VP8L_FRAME_HEADER_SIZE) {
  14056 		return 0 // not enough data
  14057 	} else {
  14058 		if !(VP8LCheckSignature(tls, data, data_size) != 0) {
  14059 			return 0 // bad signature
  14060 		} else {
  14061 			VP8LInitBitReader(tls, bp+16, data, data_size)
  14062 			if !(ReadImageInfo(tls, bp+16, bp, bp+4, bp+8) != 0) {
  14063 				return 0
  14064 			}
  14065 			if width != libc.UintptrFromInt32(0) {
  14066 				**(**int32)(__ccgo_up(width)) = **(**int32)(__ccgo_up(bp))
  14067 			}
  14068 			if height != libc.UintptrFromInt32(0) {
  14069 				**(**int32)(__ccgo_up(height)) = **(**int32)(__ccgo_up(bp + 4))
  14070 			}
  14071 			if has_alpha != libc.UintptrFromInt32(0) {
  14072 				**(**int32)(__ccgo_up(has_alpha)) = **(**int32)(__ccgo_up(bp + 8))
  14073 			}
  14074 			return int32(1)
  14075 		}
  14076 	}
  14077 	return r
  14078 }
  14079 
  14080 //------------------------------------------------------------------------------
  14081 
  14082 func GetCopyDistance(tls *libc.TLS, distance_symbol int32, br uintptr) (r int32) {
  14083 	var extra_bits, offset int32
  14084 	_, _ = extra_bits, offset
  14085 	if distance_symbol < int32(4) {
  14086 		return distance_symbol + int32(1)
  14087 	}
  14088 	extra_bits = (distance_symbol - int32(2)) >> int32(1)
  14089 	offset = (int32(2) + distance_symbol&int32(1)) << extra_bits
  14090 	return libc.Int32FromUint32(libc.Uint32FromInt32(offset) + VP8LReadBits(tls, br, extra_bits) + uint32(1))
  14091 }
  14092 
  14093 func GetCopyLength(tls *libc.TLS, length_symbol int32, br uintptr) (r int32) {
  14094 	// Length and distance prefixes are encoded the same way.
  14095 	return GetCopyDistance(tls, length_symbol, br)
  14096 }
  14097 
  14098 func PlaneCodeToDistance(tls *libc.TLS, xsize int32, plane_code int32) (r int32) {
  14099 	var dist, dist_code, xoffset, yoffset, v1 int32
  14100 	_, _, _, _, _ = dist, dist_code, xoffset, yoffset, v1
  14101 	if plane_code > int32(CODE_TO_PLANE_CODES) {
  14102 		return plane_code - int32(CODE_TO_PLANE_CODES)
  14103 	} else {
  14104 		dist_code = libc.Int32FromUint8(kCodeToPlane[plane_code-int32(1)])
  14105 		yoffset = dist_code >> int32(4)
  14106 		xoffset = int32(8) - dist_code&int32(0xf)
  14107 		dist = yoffset*xsize + xoffset
  14108 		if dist >= int32(1) {
  14109 			v1 = dist
  14110 		} else {
  14111 			v1 = int32(1)
  14112 		}
  14113 		return v1 // dist<1 can happen if xsize is very small
  14114 	}
  14115 	return r
  14116 }
  14117 
  14118 // C documentation
  14119 //
  14120 //	//------------------------------------------------------------------------------
  14121 //	// Decodes the next Huffman code from bit-stream.
  14122 //	// VP8LFillBitWindow(br) needs to be called at minimum every second call
  14123 //	// to ReadSymbol, in order to pre-fetch enough bits.
  14124 func ReadSymbol(tls *libc.TLS, table uintptr, br2 uintptr) (r int32) {
  14125 	var nbits int32
  14126 	var val1, v2 uint32_t
  14127 	var v1 uintptr
  14128 	_, _, _, _ = nbits, val1, v1, v2
  14129 	v1 = br2
  14130 	v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14131 	goto _3
  14132 _3:
  14133 	val1 = v2
  14134 	table = table + uintptr(val1&libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(HUFFMAN_TABLE_BITS)-libc.Int32FromInt32(1)))*4
  14135 	nbits = libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(table)).Fbits) - int32(HUFFMAN_TABLE_BITS)
  14136 	if nbits > 0 {
  14137 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + int32(HUFFMAN_TABLE_BITS)
  14138 		v1 = br2
  14139 		v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14140 		goto _6
  14141 	_6:
  14142 		val1 = v2
  14143 		table = table + uintptr((*HuffmanCode)(unsafe.Pointer(table)).Fvalue)*4
  14144 		table = table + uintptr(val1&libc.Uint32FromInt32(libc.Int32FromInt32(1)<<nbits-libc.Int32FromInt32(1)))*4
  14145 	}
  14146 	(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(table)).Fbits)
  14147 	return libc.Int32FromUint16((*HuffmanCode)(unsafe.Pointer(table)).Fvalue)
  14148 }
  14149 
  14150 // C documentation
  14151 //
  14152 //	// Reads packed symbol depending on GREEN channel
  14153 func ReadPackedSymbols(tls *libc.TLS, group uintptr, br2 uintptr, dst uintptr) (r int32) {
  14154 	var code HuffmanCode32
  14155 	var val1, v2 uint32_t
  14156 	var v1 uintptr
  14157 	_, _, _, _ = code, val1, v1, v2
  14158 	v1 = br2
  14159 	v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14160 	goto _3
  14161 _3:
  14162 	val1 = v2 & (libc.Uint32FromUint32(1)<<libc.Int32FromInt32(HUFFMAN_PACKED_BITS) - libc.Uint32FromInt32(1))
  14163 	code = **(**HuffmanCode32)(__ccgo_up(group + 56 + uintptr(val1)*8))
  14164 	if code.Fbits < int32(BITS_SPECIAL_MARKER) {
  14165 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + code.Fbits
  14166 		**(**uint32_t)(__ccgo_up(dst)) = code.Fvalue
  14167 		return PACKED_NON_LITERAL_CODE
  14168 	} else {
  14169 		(*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br2)).Fbit_pos + code.Fbits - int32(BITS_SPECIAL_MARKER)
  14170 		return libc.Int32FromUint32(code.Fvalue)
  14171 	}
  14172 	return r
  14173 }
  14174 
  14175 func AccumulateHCode(tls *libc.TLS, hcode HuffmanCode, shift int32, huff uintptr) (r int32) {
  14176 	**(**int32)(__ccgo_up(huff)) += libc.Int32FromUint8(hcode.Fbits)
  14177 	**(**uint32_t)(__ccgo_up(huff + 4)) |= uint32(hcode.Fvalue) << shift
  14178 	return libc.Int32FromUint8(hcode.Fbits)
  14179 }
  14180 
  14181 func BuildPackedTable(tls *libc.TLS, htree_group uintptr) {
  14182 	var bits, code uint32_t
  14183 	var hcode HuffmanCode
  14184 	var huff uintptr
  14185 	_, _, _, _ = bits, code, hcode, huff
  14186 	code = uint32(0)
  14187 	for {
  14188 		if !(code < libc.Uint32FromUint32(1)<<libc.Int32FromInt32(HUFFMAN_PACKED_BITS)) {
  14189 			break
  14190 		}
  14191 		bits = code
  14192 		huff = htree_group + 56 + uintptr(bits)*8
  14193 		hcode = **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)) + uintptr(bits)*4))
  14194 		if libc.Int32FromUint16(hcode.Fvalue) >= int32(NUM_LITERAL_CODES) {
  14195 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fbits = libc.Int32FromUint8(hcode.Fbits) + int32(BITS_SPECIAL_MARKER)
  14196 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fvalue = uint32(hcode.Fvalue)
  14197 		} else {
  14198 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fbits = 0
  14199 			(*HuffmanCode32)(unsafe.Pointer(huff)).Fvalue = uint32(0)
  14200 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, hcode, int32(8), huff))
  14201 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(RED)*8)) + uintptr(bits)*4)), int32(16), huff))
  14202 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(BLUE)*8)) + uintptr(bits)*4)), 0, huff))
  14203 			bits = bits >> libc.Uint32FromInt32(AccumulateHCode(tls, **(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htree_group + uintptr(ALPHA)*8)) + uintptr(bits)*4)), int32(24), huff))
  14204 			_ = bits
  14205 		}
  14206 		goto _1
  14207 	_1:
  14208 		;
  14209 		code = code + 1
  14210 	}
  14211 }
  14212 
  14213 func ReadHuffmanCodeLengths(tls *libc.TLS, dec uintptr, code_length_code_lengths uintptr, num_symbols int32, code_lengths uintptr) (r int32) {
  14214 	bp := tls.Alloc(48)
  14215 	defer tls.Free(48)
  14216 	var br3, p, v2 uintptr
  14217 	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
  14218 	var v4 uint32_t
  14219 	var _ /* tables at bp+0 */ HuffmanTables
  14220 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  14221 	ok = 0
  14222 	br3 = dec + 40
  14223 	prev_code_len = int32(DEFAULT_CODE_LENGTH)
  14224 	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) {
  14225 		goto End
  14226 	}
  14227 	if VP8LReadBits(tls, br3, int32(1)) != 0 { // use length
  14228 		length_nbits = libc.Int32FromUint32(uint32(2) + uint32(2)*VP8LReadBits(tls, br3, int32(3)))
  14229 		max_symbol = libc.Int32FromUint32(uint32(2) + VP8LReadBits(tls, br3, length_nbits))
  14230 		if max_symbol > num_symbols {
  14231 			goto End
  14232 		}
  14233 	} else {
  14234 		max_symbol = num_symbols
  14235 	}
  14236 	symbol = 0
  14237 	for symbol < num_symbols {
  14238 		v1 = max_symbol
  14239 		max_symbol = max_symbol - 1
  14240 		if v1 == 0 {
  14241 			break
  14242 		}
  14243 		v2 = br3
  14244 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  14245 			VP8LDoFillBitWindow(tls, v2)
  14246 		}
  14247 		v2 = br3
  14248 		v4 = uint32((*VP8LBitReader)(unsafe.Pointer(v2)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  14249 		goto _5
  14250 	_5:
  14251 		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
  14252 		(*VP8LBitReader)(unsafe.Pointer(br3)).Fbit_pos = (*VP8LBitReader)(unsafe.Pointer(br3)).Fbit_pos + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(p)).Fbits)
  14253 		code_len = libc.Int32FromUint16((*HuffmanCode)(unsafe.Pointer(p)).Fvalue)
  14254 		if code_len < kCodeLengthLiterals {
  14255 			v1 = symbol
  14256 			symbol = symbol + 1
  14257 			**(**int32)(__ccgo_up(code_lengths + uintptr(v1)*4)) = code_len
  14258 			if code_len != 0 {
  14259 				prev_code_len = code_len
  14260 			}
  14261 		} else {
  14262 			use_prev = libc.BoolInt32(code_len == kCodeLengthRepeatCode)
  14263 			slot = code_len - kCodeLengthLiterals
  14264 			extra_bits = libc.Int32FromUint8(kCodeLengthExtraBits[slot])
  14265 			repeat_offset = libc.Int32FromUint8(kCodeLengthRepeatOffsets[slot])
  14266 			repeat = libc.Int32FromUint32(VP8LReadBits(tls, br3, extra_bits) + libc.Uint32FromInt32(repeat_offset))
  14267 			if symbol+repeat > num_symbols {
  14268 				goto End
  14269 			} else {
  14270 				if use_prev != 0 {
  14271 					v1 = prev_code_len
  14272 				} else {
  14273 					v1 = 0
  14274 				}
  14275 				length = v1
  14276 				for {
  14277 					v6 = repeat
  14278 					repeat = repeat - 1
  14279 					if !(v6 > 0) {
  14280 						break
  14281 					}
  14282 					v7 = symbol
  14283 					symbol = symbol + 1
  14284 					**(**int32)(__ccgo_up(code_lengths + uintptr(v7)*4)) = length
  14285 				}
  14286 			}
  14287 		}
  14288 	}
  14289 	ok = int32(1)
  14290 	goto End
  14291 End:
  14292 	;
  14293 	VP8LHuffmanTablesDeallocate(tls, bp)
  14294 	if !(ok != 0) {
  14295 		return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  14296 	}
  14297 	return ok
  14298 }
  14299 
  14300 // C documentation
  14301 //
  14302 //	// 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman
  14303 //	// tree.
  14304 func ReadHuffmanCode(tls *libc.TLS, alphabet_size int32, dec uintptr, code_lengths uintptr, table uintptr) (r int32) {
  14305 	bp := tls.Alloc(80)
  14306 	defer tls.Free(80)
  14307 	var br uintptr
  14308 	var first_symbol_len_code, i, num_codes, num_symbols, ok, simple_code, size, symbol, v1 int32
  14309 	var _ /* code_length_code_lengths at bp+0 */ [19]int32
  14310 	_, _, _, _, _, _, _, _, _, _ = br, first_symbol_len_code, i, num_codes, num_symbols, ok, simple_code, size, symbol, v1
  14311 	ok = 0
  14312 	size = 0
  14313 	br = dec + 40
  14314 	simple_code = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14315 	libc.X__builtin___memset_chk(tls, code_lengths, 0, libc.Uint64FromInt32(alphabet_size)*uint64(4), ^__predefined_size_t(0))
  14316 	if simple_code != 0 { // Read symbols, codes & code lengths directly.
  14317 		num_symbols = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)) + uint32(1))
  14318 		first_symbol_len_code = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(1)))
  14319 		if first_symbol_len_code == 0 {
  14320 			v1 = int32(1)
  14321 		} else {
  14322 			v1 = int32(8)
  14323 		}
  14324 		// The first code is either 1 bit or 8 bit code.
  14325 		symbol = libc.Int32FromUint32(VP8LReadBits(tls, br, v1))
  14326 		**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) = int32(1)
  14327 		// The second code (if present), is always 8 bits long.
  14328 		if num_symbols == int32(2) {
  14329 			symbol = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(8)))
  14330 			**(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) = int32(1)
  14331 		}
  14332 		ok = int32(1)
  14333 	} else {
  14334 		**(**[19]int32)(__ccgo_up(bp)) = [19]int32{}
  14335 		num_codes = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(4)) + uint32(4))
  14336 		i = 0
  14337 		for {
  14338 			if !(i < num_codes) {
  14339 				break
  14340 			}
  14341 			(**(**[19]int32)(__ccgo_up(bp)))[kCodeLengthCodeOrder[i]] = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(3)))
  14342 			goto _2
  14343 		_2:
  14344 			;
  14345 			i = i + 1
  14346 		}
  14347 		ok = ReadHuffmanCodeLengths(tls, dec, bp, alphabet_size, code_lengths)
  14348 	}
  14349 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  14350 	if ok != 0 {
  14351 		size = VP8LBuildHuffmanTable(tls, table, int32(HUFFMAN_TABLE_BITS), code_lengths, alphabet_size)
  14352 	}
  14353 	if !(ok != 0) || size == 0 {
  14354 		return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  14355 	}
  14356 	return size
  14357 }
  14358 
  14359 func ReadHuffmanCodes(tls *libc.TLS, dec uintptr, xsize int32, ysize int32, color_cache_bits int32, allow_recursion int32) (r int32) {
  14360 	bp := tls.Alloc(16)
  14361 	defer tls.Free(16)
  14362 	var br, hdr, huffman_tables, mapped_group, mapping uintptr
  14363 	var group, huffman_pixs, huffman_precision, huffman_xsize, huffman_ysize, i, num_htree_groups, num_htree_groups_max, ok, v9 int32
  14364 	var v1, v2, v4, v5 uint32_t
  14365 	var _ /* htree_groups at bp+8 */ uintptr
  14366 	var _ /* huffman_image at bp+0 */ uintptr
  14367 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  14368 	br = dec + 40
  14369 	hdr = dec + 152
  14370 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  14371 	**(**uintptr)(__ccgo_up(bp + 8)) = libc.UintptrFromInt32(0)
  14372 	huffman_tables = hdr + 80
  14373 	num_htree_groups = int32(1)
  14374 	num_htree_groups_max = int32(1)
  14375 	mapping = libc.UintptrFromInt32(0)
  14376 	ok = 0
  14377 	// Check the table has been 0 initialized (through InitMetadata).
  14378 	if allow_recursion != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  14379 		// use meta Huffman codes.
  14380 		huffman_precision = libc.Int32FromUint32(uint32(MIN_HUFFMAN_BITS) + VP8LReadBits(tls, br, int32(NUM_HUFFMAN_BITS)))
  14381 		v1 = libc.Uint32FromInt32(huffman_precision)
  14382 		v2 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  14383 		goto _3
  14384 	_3:
  14385 		huffman_xsize = libc.Int32FromUint32(v2)
  14386 		v4 = libc.Uint32FromInt32(huffman_precision)
  14387 		v5 = (libc.Uint32FromInt32(ysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  14388 		goto _6
  14389 	_6:
  14390 		huffman_ysize = libc.Int32FromUint32(v5)
  14391 		huffman_pixs = huffman_xsize * huffman_ysize
  14392 		if !(DecodeImageStream(tls, huffman_xsize, huffman_ysize, 0, dec, bp) != 0) {
  14393 			goto Error
  14394 		}
  14395 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_subsample_bits = huffman_precision
  14396 		i = 0
  14397 		for {
  14398 			if !(i < huffman_pixs) {
  14399 				break
  14400 			}
  14401 			// The huffman data is stored in red and green bytes.
  14402 			group = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) >> libc.Int32FromInt32(8) & uint32(0xffff))
  14403 			**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) = libc.Uint32FromInt32(group)
  14404 			if group >= num_htree_groups_max {
  14405 				num_htree_groups_max = group + int32(1)
  14406 			}
  14407 			goto _7
  14408 		_7:
  14409 			;
  14410 			i = i + 1
  14411 		}
  14412 		// Check the validity of num_htree_groups_max. If it seems too big, use a
  14413 		// smaller value for later. This will prevent big memory allocations to end
  14414 		// up with a bad bitstream anyway.
  14415 		// The value of 1000 is totally arbitrary. We know that num_htree_groups_max
  14416 		// is smaller than (1 << 16) and should be smaller than the number of pixels
  14417 		// (though the format allows it to be bigger).
  14418 		if num_htree_groups_max > int32(1000) || num_htree_groups_max > xsize*ysize {
  14419 			// Create a mapping from the used indices to the minimal set of used
  14420 			// values [0, num_htree_groups)
  14421 			mapping = WebPSafeMalloc(tls, libc.Uint64FromInt32(num_htree_groups_max), uint64(4))
  14422 			if mapping == libc.UintptrFromInt32(0) {
  14423 				VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14424 				goto Error
  14425 			}
  14426 			// -1 means a value is unmapped, and therefore unused in the Huffman
  14427 			// image.
  14428 			libc.X__builtin___memset_chk(tls, mapping, int32(0xff), libc.Uint64FromInt32(num_htree_groups_max)*uint64(4), ^__predefined_size_t(0))
  14429 			num_htree_groups = 0
  14430 			i = libc.Int32FromInt32(0)
  14431 			for {
  14432 				if !(i < huffman_pixs) {
  14433 					break
  14434 				}
  14435 				// Get the current mapping for the group and remap the Huffman image.
  14436 				mapped_group = mapping + uintptr(**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)))*4
  14437 				if **(**int32)(__ccgo_up(mapped_group)) == -int32(1) {
  14438 					v9 = num_htree_groups
  14439 					num_htree_groups = num_htree_groups + 1
  14440 					**(**int32)(__ccgo_up(mapped_group)) = v9
  14441 				}
  14442 				**(**uint32_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i)*4)) = libc.Uint32FromInt32(**(**int32)(__ccgo_up(mapped_group)))
  14443 				goto _8
  14444 			_8:
  14445 				;
  14446 				i = i + 1
  14447 			}
  14448 		} else {
  14449 			num_htree_groups = num_htree_groups_max
  14450 		}
  14451 	}
  14452 	if (*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0 {
  14453 		goto Error
  14454 	}
  14455 	if !(ReadHuffmanCodesHelper(tls, color_cache_bits, num_htree_groups, num_htree_groups_max, mapping, dec, huffman_tables, bp+8) != 0) {
  14456 		goto Error
  14457 	}
  14458 	ok = int32(1)
  14459 	// All OK. Finalize pointers.
  14460 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_image = **(**uintptr)(__ccgo_up(bp))
  14461 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fnum_htree_groups = num_htree_groups
  14462 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups = **(**uintptr)(__ccgo_up(bp + 8))
  14463 	goto Error
  14464 Error:
  14465 	;
  14466 	WebPSafeFree(tls, mapping)
  14467 	if !(ok != 0) {
  14468 		WebPSafeFree(tls, **(**uintptr)(__ccgo_up(bp)))
  14469 		VP8LHuffmanTablesDeallocate(tls, huffman_tables)
  14470 		VP8LHtreeGroupsFree(tls, **(**uintptr)(__ccgo_up(bp + 8)))
  14471 	}
  14472 	return ok
  14473 }
  14474 
  14475 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) {
  14476 	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
  14477 	var code_lengths, htree_group, htrees uintptr
  14478 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  14479 	ok = 0
  14480 	if color_cache_bits > 0 {
  14481 		v1 = int32(1) << color_cache_bits
  14482 	} else {
  14483 		v1 = 0
  14484 	}
  14485 	max_alphabet_size = libc.Int32FromUint16(kAlphabetSize[0]) + v1
  14486 	table_size = libc.Int32FromUint16(kTableSize[color_cache_bits])
  14487 	code_lengths = libc.UintptrFromInt32(0)
  14488 	if mapping == libc.UintptrFromInt32(0) && num_htree_groups != num_htree_groups_max || num_htree_groups > num_htree_groups_max {
  14489 		goto Error
  14490 	}
  14491 	code_lengths = WebPSafeCalloc(tls, libc.Uint64FromInt32(max_alphabet_size), uint64(4))
  14492 	**(**uintptr)(__ccgo_up(htree_groups)) = VP8LHtreeGroupsNew(tls, num_htree_groups)
  14493 	if **(**uintptr)(__ccgo_up(htree_groups)) == libc.UintptrFromInt32(0) || code_lengths == libc.UintptrFromInt32(0) || !(VP8LHuffmanTablesAllocate(tls, num_htree_groups*table_size, huffman_tables) != 0) {
  14494 		VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14495 		goto Error
  14496 	}
  14497 	i = 0
  14498 	for {
  14499 		if !(i < num_htree_groups_max) {
  14500 			break
  14501 		}
  14502 		// If the index "i" is unused in the Huffman image, just make sure the
  14503 		// coefficients are valid but do not store them.
  14504 		if mapping != libc.UintptrFromInt32(0) && **(**int32)(__ccgo_up(mapping + uintptr(i)*4)) == -int32(1) {
  14505 			j = 0
  14506 			for {
  14507 				if !(j < int32(HUFFMAN_CODES_PER_META_CODE)) {
  14508 					break
  14509 				}
  14510 				alphabet_size = libc.Int32FromUint16(kAlphabetSize[j])
  14511 				if j == 0 && color_cache_bits > 0 {
  14512 					alphabet_size = alphabet_size + int32(1)<<color_cache_bits
  14513 				}
  14514 				// Passing in NULL so that nothing gets filled.
  14515 				if !(ReadHuffmanCode(tls, alphabet_size, dec, code_lengths, libc.UintptrFromInt32(0)) != 0) {
  14516 					goto Error
  14517 				}
  14518 				goto _3
  14519 			_3:
  14520 				;
  14521 				j = j + 1
  14522 			}
  14523 		} else {
  14524 			if mapping == libc.UintptrFromInt32(0) {
  14525 				v1 = i
  14526 			} else {
  14527 				v1 = **(**int32)(__ccgo_up(mapping + uintptr(i)*4))
  14528 			}
  14529 			htree_group = **(**uintptr)(__ccgo_up(htree_groups)) + uintptr(v1)*568
  14530 			htrees = htree_group
  14531 			total_size = 0
  14532 			is_trivial_literal = int32(1)
  14533 			max_bits = 0
  14534 			j = 0
  14535 			for {
  14536 				if !(j < int32(HUFFMAN_CODES_PER_META_CODE)) {
  14537 					break
  14538 				}
  14539 				alphabet_size1 = libc.Int32FromUint16(kAlphabetSize[j])
  14540 				if j == 0 && color_cache_bits > 0 {
  14541 					alphabet_size1 = alphabet_size1 + int32(1)<<color_cache_bits
  14542 				}
  14543 				size = ReadHuffmanCode(tls, alphabet_size1, dec, code_lengths, huffman_tables)
  14544 				**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)) = (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment)).Fcurr_table
  14545 				if size == 0 {
  14546 					goto Error
  14547 				}
  14548 				if is_trivial_literal != 0 && libc.Int32FromUint8(kLiteralMap[j]) == int32(1) {
  14549 					is_trivial_literal = libc.BoolInt32(libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)))).Fbits) == 0)
  14550 				}
  14551 				total_size = total_size + libc.Int32FromUint8((*HuffmanCode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(htrees + uintptr(j)*8)))).Fbits)
  14552 				**(**uintptr)(__ccgo_up((*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment + 8)) += uintptr(size) * 4
  14553 				if j <= int32(ALPHA) {
  14554 					local_max_bits = **(**int32)(__ccgo_up(code_lengths))
  14555 					k = int32(1)
  14556 					for {
  14557 						if !(k < alphabet_size1) {
  14558 							break
  14559 						}
  14560 						if **(**int32)(__ccgo_up(code_lengths + uintptr(k)*4)) > local_max_bits {
  14561 							local_max_bits = **(**int32)(__ccgo_up(code_lengths + uintptr(k)*4))
  14562 						}
  14563 						goto _6
  14564 					_6:
  14565 						;
  14566 						k = k + 1
  14567 					}
  14568 					max_bits = max_bits + local_max_bits
  14569 				}
  14570 				goto _5
  14571 			_5:
  14572 				;
  14573 				j = j + 1
  14574 			}
  14575 			(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_literal = is_trivial_literal
  14576 			(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code = 0
  14577 			if is_trivial_literal != 0 {
  14578 				red = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(RED)*8))))).Fvalue)
  14579 				blue = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(BLUE)*8))))).Fvalue)
  14580 				alpha = libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(ALPHA)*8))))).Fvalue)
  14581 				(*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb = libc.Uint32FromInt32(alpha)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(blue)
  14582 				if total_size == 0 && libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(GREEN)*8))))).Fvalue) < int32(NUM_LITERAL_CODES) {
  14583 					(*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code = int32(1)
  14584 					**(**uint32_t)(__ccgo_up(htree_group + 44)) |= libc.Uint32FromInt32(libc.Int32FromUint16((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(GREEN)*8))))).Fvalue) << int32(8))
  14585 				}
  14586 			}
  14587 			(*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))
  14588 			if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fuse_packed_table != 0 {
  14589 				BuildPackedTable(tls, htree_group)
  14590 			}
  14591 		}
  14592 		goto _2
  14593 	_2:
  14594 		;
  14595 		i = i + 1
  14596 	}
  14597 	ok = int32(1)
  14598 	goto Error
  14599 Error:
  14600 	;
  14601 	WebPSafeFree(tls, code_lengths)
  14602 	if !(ok != 0) {
  14603 		VP8LHuffmanTablesDeallocate(tls, huffman_tables)
  14604 		VP8LHtreeGroupsFree(tls, **(**uintptr)(__ccgo_up(htree_groups)))
  14605 		**(**uintptr)(__ccgo_up(htree_groups)) = libc.UintptrFromInt32(0)
  14606 	}
  14607 	return ok
  14608 }
  14609 
  14610 //------------------------------------------------------------------------------
  14611 // Scaling.
  14612 
  14613 func AllocateAndInitRescaler(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  14614 	var in_height, in_width, num_channels, out_height, out_width int32
  14615 	var memory, scaled_data, work uintptr
  14616 	var memory_size, scaled_data_size, work_size uint64_t
  14617 	_, _, _, _, _, _, _, _, _, _, _ = in_height, in_width, memory, memory_size, num_channels, out_height, out_width, scaled_data, scaled_data_size, work, work_size
  14618 	num_channels = int32(4)
  14619 	in_width = (*VP8Io)(unsafe.Pointer(io)).Fmb_w
  14620 	out_width = (*VP8Io)(unsafe.Pointer(io)).Fscaled_width
  14621 	in_height = (*VP8Io)(unsafe.Pointer(io)).Fmb_h
  14622 	out_height = (*VP8Io)(unsafe.Pointer(io)).Fscaled_height
  14623 	work_size = libc.Uint64FromInt32(int32(2)*num_channels) * libc.Uint64FromInt32(out_width) // Rescaler work area.
  14624 	scaled_data_size = libc.Uint64FromInt32(out_width)                                        // Temporary storage for scaled BGRA data.
  14625 	memory_size = uint64(104) + work_size*uint64(4) + scaled_data_size*uint64(4)
  14626 	memory = WebPSafeMalloc(tls, memory_size, uint64(1))
  14627 	if memory == libc.UintptrFromInt32(0) {
  14628 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  14629 	}
  14630 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory = memory
  14631 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler = memory
  14632 	memory = memory + uintptr(104)
  14633 	work = memory
  14634 	memory = memory + uintptr(work_size*uint64(4))
  14635 	scaled_data = memory
  14636 	if !(WebPRescalerInit(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, in_width, in_height, scaled_data, out_width, out_height, 0, num_channels, work) != 0) {
  14637 		return 0
  14638 	}
  14639 	return int32(1)
  14640 }
  14641 
  14642 //------------------------------------------------------------------------------
  14643 // Export to ARGB
  14644 
  14645 // C documentation
  14646 //
  14647 //	// We have special "export" function since we need to convert from BGRA
  14648 func Export(tls *libc.TLS, rescaler2 uintptr, colorspace WEBP_CSP_MODE1, rgba_stride int32, rgba uintptr) (r int32) {
  14649 	var dst, src, v1, v4 uintptr
  14650 	var dst_width, num_lines_out, v2, v5 int32
  14651 	_, _, _, _, _, _, _, _ = dst, dst_width, num_lines_out, src, v1, v2, v4, v5
  14652 	src = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst
  14653 	dst = rgba
  14654 	dst_width = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width
  14655 	num_lines_out = 0
  14656 	for {
  14657 		v1 = rescaler2
  14658 		v4 = v1
  14659 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  14660 		goto _6
  14661 	_6:
  14662 		;
  14663 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  14664 		goto _3
  14665 	_3:
  14666 		if !(v2 != 0) {
  14667 			break
  14668 		}
  14669 		WebPRescalerExportRow(tls, rescaler2)
  14670 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, src, dst_width, int32(1))
  14671 		VP8LConvertFromBGRA(tls, src, dst_width, colorspace, dst)
  14672 		dst = dst + uintptr(rgba_stride)
  14673 		num_lines_out = num_lines_out + 1
  14674 	}
  14675 	return num_lines_out
  14676 }
  14677 
  14678 // C documentation
  14679 //
  14680 //	// Emit scaled rows.
  14681 func EmitRescaledRowsRGBA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_h int32, out uintptr, out_stride int32) (r int32) {
  14682 	var colorspace WEBP_CSP_MODE1
  14683 	var lines_imported, lines_left, needed_lines, num_lines_in, num_lines_out int32
  14684 	var row_in, row_out uintptr
  14685 	_, _, _, _, _, _, _, _ = colorspace, lines_imported, lines_left, needed_lines, num_lines_in, num_lines_out, row_in, row_out
  14686 	colorspace = (*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace
  14687 	num_lines_in = 0
  14688 	num_lines_out = 0
  14689 	for num_lines_in < mb_h {
  14690 		row_in = in + uintptr(int64(num_lines_in)*int64(in_stride))
  14691 		row_out = out + uintptr(int64(num_lines_out)*int64(out_stride))
  14692 		lines_left = mb_h - num_lines_in
  14693 		needed_lines = WebPRescaleNeededLines(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left)
  14694 		WebPMultARGBRows(tls, row_in, in_stride, (*WebPRescaler)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler)).Fsrc_width, needed_lines, 0)
  14695 		lines_imported = WebPRescalerImport(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left, row_in, in_stride)
  14696 		num_lines_in = num_lines_in + lines_imported
  14697 		num_lines_out = num_lines_out + Export(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, colorspace, out_stride, row_out)
  14698 	}
  14699 	return num_lines_out
  14700 }
  14701 
  14702 // C documentation
  14703 //
  14704 //	// Emit rows without any scaling.
  14705 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) {
  14706 	var lines, v1 int32
  14707 	var row_out uintptr
  14708 	_, _, _ = lines, row_out, v1
  14709 	lines = mb_h
  14710 	row_out = out
  14711 	for {
  14712 		v1 = lines
  14713 		lines = lines - 1
  14714 		if !(v1 > 0) {
  14715 			break
  14716 		}
  14717 		VP8LConvertFromBGRA(tls, row_in, mb_w, colorspace, row_out)
  14718 		row_in = row_in + uintptr(in_stride)
  14719 		row_out = row_out + uintptr(out_stride)
  14720 	}
  14721 	return mb_h // Num rows out == num rows in.
  14722 }
  14723 
  14724 //------------------------------------------------------------------------------
  14725 // Export to YUVA
  14726 
  14727 func ConvertToYUVA(tls *libc.TLS, src uintptr, width int32, y_pos int32, output uintptr) {
  14728 	var a, buf, u, v uintptr
  14729 	_, _, _, _ = a, buf, u, v
  14730 	buf = output + 16
  14731 	// first, the luma plane
  14732 	(*(*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)
  14733 	// then U/V planes
  14734 	u = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu + uintptr(y_pos>>int32(1)*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride)
  14735 	v = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv + uintptr(y_pos>>int32(1)*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv_stride)
  14736 	// even lines: store values
  14737 	// odd lines: average with previous values
  14738 	(*(*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)))
  14739 	// Lastly, store alpha if needed.
  14740 	if (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa != libc.UintptrFromInt32(0) {
  14741 		a = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa + uintptr(y_pos*(*WebPYUVABuffer)(unsafe.Pointer(buf)).Fa_stride)
  14742 		(*(*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)
  14743 	}
  14744 }
  14745 
  14746 func ExportYUVA(tls *libc.TLS, dec uintptr, y_pos int32) (r int32) {
  14747 	var dst_width, num_lines_out, v2, v5 int32
  14748 	var rescaler2, src, v1, v4 uintptr
  14749 	_, _, _, _, _, _, _, _ = dst_width, num_lines_out, rescaler2, src, v1, v2, v4, v5
  14750 	rescaler2 = (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler
  14751 	src = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst
  14752 	dst_width = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width
  14753 	num_lines_out = 0
  14754 	for {
  14755 		v1 = rescaler2
  14756 		v4 = v1
  14757 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  14758 		goto _6
  14759 	_6:
  14760 		;
  14761 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  14762 		goto _3
  14763 	_3:
  14764 		if !(v2 != 0) {
  14765 			break
  14766 		}
  14767 		WebPRescalerExportRow(tls, rescaler2)
  14768 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, src, dst_width, int32(1))
  14769 		ConvertToYUVA(tls, src, dst_width, y_pos, (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)
  14770 		y_pos = y_pos + 1
  14771 		num_lines_out = num_lines_out + 1
  14772 	}
  14773 	return num_lines_out
  14774 }
  14775 
  14776 func EmitRescaledRowsYUVA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_h int32) (r int32) {
  14777 	var lines_imported, lines_left, needed_lines, num_lines_in, y_pos int32
  14778 	_, _, _, _, _ = lines_imported, lines_left, needed_lines, num_lines_in, y_pos
  14779 	num_lines_in = 0
  14780 	y_pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  14781 	for num_lines_in < mb_h {
  14782 		lines_left = mb_h - num_lines_in
  14783 		needed_lines = WebPRescaleNeededLines(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left)
  14784 		WebPMultARGBRows(tls, in, in_stride, (*WebPRescaler)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler)).Fsrc_width, needed_lines, 0)
  14785 		lines_imported = WebPRescalerImport(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler, lines_left, in, in_stride)
  14786 		num_lines_in = num_lines_in + lines_imported
  14787 		in = in + uintptr(needed_lines*in_stride)
  14788 		y_pos = y_pos + ExportYUVA(tls, dec, y_pos)
  14789 	}
  14790 	return y_pos
  14791 }
  14792 
  14793 func EmitRowsYUVA(tls *libc.TLS, dec uintptr, in uintptr, in_stride int32, mb_w int32, num_rows int32) (r int32) {
  14794 	var y_pos, v1 int32
  14795 	_, _ = y_pos, v1
  14796 	y_pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  14797 	for {
  14798 		v1 = num_rows
  14799 		num_rows = num_rows - 1
  14800 		if !(v1 > 0) {
  14801 			break
  14802 		}
  14803 		ConvertToYUVA(tls, in, mb_w, y_pos, (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)
  14804 		in = in + uintptr(in_stride)
  14805 		y_pos = y_pos + 1
  14806 	}
  14807 	return y_pos
  14808 }
  14809 
  14810 //------------------------------------------------------------------------------
  14811 // Cropping.
  14812 
  14813 // C documentation
  14814 //
  14815 //	// Sets io->mb_y, io->mb_h & io->mb_w according to start row, end row and
  14816 //	// crop options. Also updates the input data pointer, so that it points to the
  14817 //	// start of the cropped window. Note that pixels are in ARGB format even if
  14818 //	// 'in_data' is uint8_t*.
  14819 //	// Returns true if the crop window is not empty.
  14820 func SetCropWindow(tls *libc.TLS, io uintptr, y_start int32, y_end int32, in_data uintptr, pixel_stride int32) (r int32) {
  14821 	var delta int32
  14822 	_ = delta
  14823 	if y_end > (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom {
  14824 		y_end = (*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom // make sure we don't overflow on last row.
  14825 	}
  14826 	if y_start < (*VP8Io)(unsafe.Pointer(io)).Fcrop_top {
  14827 		delta = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top - y_start
  14828 		y_start = (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
  14829 		**(**uintptr)(__ccgo_up(in_data)) += uintptr(delta * pixel_stride)
  14830 	}
  14831 	if y_start >= y_end {
  14832 		return 0
  14833 	} // Crop window is empty.
  14834 	**(**uintptr)(__ccgo_up(in_data)) += uintptr(libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fcrop_left) * uint64(4))
  14835 	(*VP8Io)(unsafe.Pointer(io)).Fmb_y = y_start - (*VP8Io)(unsafe.Pointer(io)).Fcrop_top
  14836 	(*VP8Io)(unsafe.Pointer(io)).Fmb_w = (*VP8Io)(unsafe.Pointer(io)).Fcrop_right - (*VP8Io)(unsafe.Pointer(io)).Fcrop_left
  14837 	(*VP8Io)(unsafe.Pointer(io)).Fmb_h = y_end - y_start
  14838 	return int32(1) // Non-empty crop window.
  14839 }
  14840 
  14841 //------------------------------------------------------------------------------
  14842 
  14843 func GetMetaIndex(tls *libc.TLS, image uintptr, xsize int32, bits int32, x int32, y int32) (r int32) {
  14844 	if bits == 0 {
  14845 		return 0
  14846 	}
  14847 	return libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(image + uintptr(xsize*(y>>bits)+x>>bits)*4)))
  14848 }
  14849 
  14850 func GetHtreeGroupForPos(tls *libc.TLS, hdr uintptr, x int32, y int32) (r uintptr) {
  14851 	var meta_index int32
  14852 	_ = meta_index
  14853 	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)
  14854 	return (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups + uintptr(meta_index)*568
  14855 }
  14856 
  14857 //------------------------------------------------------------------------------
  14858 // Main loop, with custom row-processing function
  14859 
  14860 type ProcessRowsFunc = uintptr
  14861 
  14862 func ApplyInverseTransforms(tls *libc.TLS, dec uintptr, start_row int32, num_rows int32, rows uintptr) {
  14863 	var cache_pixs, end_row, n, v1 int32
  14864 	var rows_in, rows_out, transform uintptr
  14865 	_, _, _, _, _, _, _ = cache_pixs, end_row, n, rows_in, rows_out, transform, v1
  14866 	n = (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform
  14867 	cache_pixs = (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth * num_rows
  14868 	end_row = start_row + num_rows
  14869 	rows_in = rows
  14870 	rows_out = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  14871 	// Inverse transforms.
  14872 	for {
  14873 		v1 = n
  14874 		n = n - 1
  14875 		if !(v1 > 0) {
  14876 			break
  14877 		}
  14878 		transform = dec + 280 + uintptr(n)*24
  14879 		VP8LInverseTransform(tls, transform, start_row, end_row, rows_in, rows_out)
  14880 		rows_in = rows_out
  14881 	}
  14882 	if rows_in != rows_out {
  14883 		// No transform called, hence just copy.
  14884 		libc.X__builtin___memcpy_chk(tls, rows_out, rows_in, libc.Uint64FromInt32(cache_pixs)*uint64(4), ^__predefined_size_t(0))
  14885 	}
  14886 }
  14887 
  14888 // C documentation
  14889 //
  14890 //	// Processes (transforms, scales & color-converts) the rows decoded after the
  14891 //	// last call.
  14892 func ProcessRows(tls *libc.TLS, dec uintptr, row int32) {
  14893 	bp := tls.Alloc(16)
  14894 	defer tls.Free(16)
  14895 	var buf, io, output, rgba, rows uintptr
  14896 	var in_stride, num_rows, num_rows_out, v1, v3 int32
  14897 	var _ /* rows_data at bp+0 */ uintptr
  14898 	_, _, _, _, _, _, _, _, _, _ = buf, in_stride, io, num_rows, num_rows_out, output, rgba, rows, v1, v3
  14899 	rows = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row)*4
  14900 	num_rows = row - (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  14901 	// We can't process more than NUM_ARGB_CACHE_ROWS at a time (that's the size
  14902 	// of argb_cache), but we currently don't need more than that.
  14903 	if num_rows > 0 { // Emit output.
  14904 		io = (*VP8LDecoder)(unsafe.Pointer(dec)).Fio
  14905 		**(**uintptr)(__ccgo_up(bp)) = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  14906 		in_stride = libc.Int32FromUint64(libc.Uint64FromInt32((*VP8Io)(unsafe.Pointer(io)).Fwidth) * uint64(4)) // in unit of RGBA
  14907 		ApplyInverseTransforms(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row, num_rows, rows)
  14908 		if !(SetCropWindow(tls, io, (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row, row, bp, in_stride) != 0) {
  14909 			// Nothing to output (this time).
  14910 		} else {
  14911 			output = (*VP8LDecoder)(unsafe.Pointer(dec)).Foutput
  14912 			v1 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer(output)).Fcolorspace < int32(MODE_YUV))
  14913 			goto _2
  14914 		_2:
  14915 			if v1 != 0 { // convert to RGBA
  14916 				buf = output + 16
  14917 				rgba = (*WebPRGBABuffer)(unsafe.Pointer(buf)).Frgba + uintptr(int64((*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row)*int64((*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride))
  14918 				if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  14919 					v3 = EmitRescaledRowsRGBA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_h, rgba, (*WebPRGBABuffer)(unsafe.Pointer(buf)).Fstride)
  14920 				} else {
  14921 					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)
  14922 				}
  14923 				num_rows_out = v3
  14924 				// Update 'last_out_row'.
  14925 				**(**int32)(__ccgo_up(dec + 148)) += num_rows_out
  14926 			} else { // convert to YUVA
  14927 				if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  14928 					v1 = EmitRescaledRowsYUVA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_h)
  14929 				} else {
  14930 					v1 = EmitRowsYUVA(tls, dec, **(**uintptr)(__ccgo_up(bp)), in_stride, (*VP8Io)(unsafe.Pointer(io)).Fmb_w, (*VP8Io)(unsafe.Pointer(io)).Fmb_h)
  14931 				}
  14932 				(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  14933 			}
  14934 		}
  14935 	}
  14936 	// Update 'last_row'.
  14937 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = row
  14938 }
  14939 
  14940 // C documentation
  14941 //
  14942 //	// Row-processing for the special case when alpha data contains only one
  14943 //	// transform (color indexing), and trivial non-green literals.
  14944 func Is8bOptimizable(tls *libc.TLS, hdr uintptr) (r int32) {
  14945 	var htrees uintptr
  14946 	var i int32
  14947 	_, _ = htrees, i
  14948 	if (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size > 0 {
  14949 		return 0
  14950 	}
  14951 	// When the Huffman tree contains only one symbol, we can skip the
  14952 	// call to ReadSymbol() for red/blue/alpha channels.
  14953 	i = 0
  14954 	for {
  14955 		if !(i < (*VP8LMetadata)(unsafe.Pointer(hdr)).Fnum_htree_groups) {
  14956 			break
  14957 		}
  14958 		htrees = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups + uintptr(i)*568
  14959 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(RED)*8))))).Fbits) > 0 {
  14960 			return 0
  14961 		}
  14962 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(BLUE)*8))))).Fbits) > 0 {
  14963 			return 0
  14964 		}
  14965 		if libc.Int32FromUint8((**(**HuffmanCode)(__ccgo_up(**(**uintptr)(__ccgo_up(htrees + uintptr(ALPHA)*8))))).Fbits) > 0 {
  14966 			return 0
  14967 		}
  14968 		goto _1
  14969 	_1:
  14970 		;
  14971 		i = i + 1
  14972 	}
  14973 	return int32(1)
  14974 }
  14975 
  14976 func AlphaApplyFilter(tls *libc.TLS, alph_dec uintptr, first_row int32, last_row int32, out uintptr, stride int32) {
  14977 	var prev_line uintptr
  14978 	var y int32
  14979 	_, _ = prev_line, y
  14980 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter != int32(WEBP_FILTER_NONE) {
  14981 		prev_line = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fprev_line
  14982 		y = first_row
  14983 		for {
  14984 			if !(y < last_row) {
  14985 				break
  14986 			}
  14987 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPUnfilters[(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter]})))(tls, prev_line, out, out, stride)
  14988 			prev_line = out
  14989 			out = out + uintptr(stride)
  14990 			goto _1
  14991 		_1:
  14992 			;
  14993 			y = y + 1
  14994 		}
  14995 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fprev_line = prev_line
  14996 	}
  14997 }
  14998 
  14999 func ExtractPalettedAlphaRows(tls *libc.TLS, dec uintptr, last_row int32) {
  15000 	var alph_dec, in, out, transform uintptr
  15001 	var first_row, top_row, width, v1, v2 int32
  15002 	_, _, _, _, _, _, _, _, _ = alph_dec, first_row, in, out, top_row, transform, width, v1, v2
  15003 	// For vertical and gradient filtering, we need to decode the part above the
  15004 	// crop_top row, in order to have the correct spatial predictors.
  15005 	alph_dec = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque
  15006 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter == int32(WEBP_FILTER_NONE) || (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Ffilter == int32(WEBP_FILTER_HORIZONTAL) {
  15007 		v1 = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fcrop_top
  15008 	} else {
  15009 		v1 = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15010 	}
  15011 	top_row = v1
  15012 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row < top_row {
  15013 		v2 = top_row
  15014 	} else {
  15015 		v2 = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15016 	}
  15017 	first_row = v2
  15018 	if last_row > first_row {
  15019 		// Special method for paletted alpha data. We only process the cropped area.
  15020 		width = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth
  15021 		out = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Foutput + uintptr(width*first_row)
  15022 		in = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*first_row)
  15023 		transform = dec + 280
  15024 		VP8LColorIndexInverseTransformAlpha(tls, transform, first_row, last_row, in, out)
  15025 		AlphaApplyFilter(tls, alph_dec, first_row, last_row, out, width)
  15026 	}
  15027 	v1 = last_row
  15028 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  15029 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = v1
  15030 }
  15031 
  15032 //------------------------------------------------------------------------------
  15033 // Helper functions for fast pattern copy (8b and 32b)
  15034 
  15035 // C documentation
  15036 //
  15037 //	// cyclic rotation of pattern word
  15038 func Rotate8b(tls *libc.TLS, V uint32_t) (r uint32_t) {
  15039 	return V&uint32(0xff)<<int32(24) | V>>libc.Int32FromInt32(8)
  15040 }
  15041 
  15042 // C documentation
  15043 //
  15044 //	// copy 1, 2 or 4-bytes pattern
  15045 func CopySmallPattern8b(tls *libc.TLS, src uintptr, dst uintptr, length int32, pattern uint32_t) {
  15046 	var i int32
  15047 	var v1, v2 uintptr
  15048 	_, _, _ = i, v1, v2
  15049 	// align 'dst' to 4-bytes boundary. Adjust the pattern along the way.
  15050 	for uint64(dst)&uint64(3) != 0 {
  15051 		v1 = dst
  15052 		dst = dst + 1
  15053 		v2 = src
  15054 		src = src + 1
  15055 		**(**uint8_t)(__ccgo_up(v1)) = **(**uint8_t)(__ccgo_up(v2))
  15056 		pattern = Rotate8b(tls, pattern)
  15057 		length = length - 1
  15058 	}
  15059 	// Copy the pattern 4 bytes at a time.
  15060 	i = 0
  15061 	for {
  15062 		if !(i < length>>int32(2)) {
  15063 			break
  15064 		}
  15065 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = pattern
  15066 		goto _3
  15067 	_3:
  15068 		;
  15069 		i = i + 1
  15070 	}
  15071 	// Finish with left-overs. 'pattern' is still correctly positioned,
  15072 	// so no Rotate8b() call is needed.
  15073 	i = i << int32(2)
  15074 	for {
  15075 		if !(i < length) {
  15076 			break
  15077 		}
  15078 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src + uintptr(i)))
  15079 		goto _4
  15080 	_4:
  15081 		;
  15082 		i = i + 1
  15083 	}
  15084 }
  15085 
  15086 func CopyBlock8b(tls *libc.TLS, dst uintptr, dist int32, length int32) {
  15087 	bp := tls.Alloc(16)
  15088 	defer tls.Free(16)
  15089 	var i int32
  15090 	var src uintptr
  15091 	var _ /* pattern at bp+0 */ uint32_t
  15092 	_, _ = i, src
  15093 	src = dst - uintptr(dist)
  15094 	if length >= int32(8) {
  15095 		**(**uint32_t)(__ccgo_up(bp)) = uint32(0)
  15096 		switch dist {
  15097 		case int32(1):
  15098 			**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(src)))
  15099 			**(**uint32_t)(__ccgo_up(bp)) = uint32(0x01010101) * **(**uint32_t)(__ccgo_up(bp))
  15100 		case int32(2):
  15101 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(2), ^__predefined_size_t(0))
  15102 			**(**uint32_t)(__ccgo_up(bp)) = uint32(0x00010001) * **(**uint32_t)(__ccgo_up(bp))
  15103 		case int32(4):
  15104 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(4), ^__predefined_size_t(0))
  15105 		default:
  15106 			goto Copy
  15107 		}
  15108 		CopySmallPattern8b(tls, src, dst, length, **(**uint32_t)(__ccgo_up(bp)))
  15109 		return
  15110 	}
  15111 	goto Copy
  15112 Copy:
  15113 	;
  15114 	if dist >= length { // no overlap -> use memcpy()
  15115 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(length)*uint64(1), ^__predefined_size_t(0))
  15116 	} else {
  15117 		i = 0
  15118 		for {
  15119 			if !(i < length) {
  15120 				break
  15121 			}
  15122 			**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src + uintptr(i)))
  15123 			goto _1
  15124 		_1:
  15125 			;
  15126 			i = i + 1
  15127 		}
  15128 	}
  15129 }
  15130 
  15131 // C documentation
  15132 //
  15133 //	// copy pattern of 1 or 2 uint32_t's
  15134 func CopySmallPattern32b(tls *libc.TLS, src uintptr, dst uintptr, length int32, pattern uint64_t) {
  15135 	var i int32
  15136 	var v1, v2 uintptr
  15137 	_, _, _ = i, v1, v2
  15138 	if uint64(dst)&uint64(4) != 0 { // Align 'dst' to 8-bytes boundary.
  15139 		v1 = dst
  15140 		dst += 4
  15141 		v2 = src
  15142 		src += 4
  15143 		**(**uint32_t)(__ccgo_up(v1)) = **(**uint32_t)(__ccgo_up(v2))
  15144 		pattern = pattern>>libc.Int32FromInt32(32) | pattern<<libc.Int32FromInt32(32)
  15145 		length = length - 1
  15146 	}
  15147 	i = 0
  15148 	for {
  15149 		if !(i < length>>int32(1)) {
  15150 			break
  15151 		}
  15152 		**(**uint64_t)(__ccgo_up(dst + uintptr(i)*8)) = pattern // Copy the pattern 8 bytes at a time.
  15153 		goto _3
  15154 	_3:
  15155 		;
  15156 		i = i + 1
  15157 	}
  15158 	if length&int32(1) != 0 { // Finish with left-over.
  15159 		**(**uint32_t)(__ccgo_up(dst + uintptr(i<<int32(1))*4)) = **(**uint32_t)(__ccgo_up(src + uintptr(i<<int32(1))*4))
  15160 	}
  15161 }
  15162 
  15163 func CopyBlock32b(tls *libc.TLS, dst uintptr, dist int32, length int32) {
  15164 	bp := tls.Alloc(16)
  15165 	defer tls.Free(16)
  15166 	var i int32
  15167 	var src uintptr
  15168 	var _ /* pattern at bp+0 */ uint64_t
  15169 	_, _ = i, src
  15170 	src = dst - uintptr(dist)*4
  15171 	if dist <= int32(2) && length >= int32(4) && uint64(dst)&uint64(3) == uint64(0) {
  15172 		if dist == int32(1) {
  15173 			**(**uint64_t)(__ccgo_up(bp)) = uint64(**(**uint32_t)(__ccgo_up(src)))
  15174 			**(**uint64_t)(__ccgo_up(bp)) = **(**uint64_t)(__ccgo_up(bp)) | **(**uint64_t)(__ccgo_up(bp))<<int32(32)
  15175 		} else {
  15176 			libc.X__builtin___memcpy_chk(tls, bp, src, uint64(8), ^__predefined_size_t(0))
  15177 		}
  15178 		CopySmallPattern32b(tls, src, dst, length, **(**uint64_t)(__ccgo_up(bp)))
  15179 	} else {
  15180 		if dist >= length { // no overlap
  15181 			libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(length)*uint64(4), ^__predefined_size_t(0))
  15182 		} else {
  15183 			i = 0
  15184 			for {
  15185 				if !(i < length) {
  15186 					break
  15187 				}
  15188 				**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  15189 				goto _1
  15190 			_1:
  15191 				;
  15192 				i = i + 1
  15193 			}
  15194 		}
  15195 	}
  15196 }
  15197 
  15198 //------------------------------------------------------------------------------
  15199 
  15200 func DecodeAlphaData(tls *libc.TLS, dec uintptr, data uintptr, width int32, height int32, last_row int32) (r int32) {
  15201 	var br2, hdr, htree_group, v1 uintptr
  15202 	var code, col, dist, dist_code, dist_symbol, end, last, len_code_limit, length, length_sym, mask, ok, pos, row, v5 int32
  15203 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  15204 	ok = int32(1)
  15205 	row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel / width
  15206 	col = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel % width
  15207 	br2 = dec + 40
  15208 	hdr = dec + 152
  15209 	pos = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel // current position
  15210 	end = width * height                                  // End of data
  15211 	last = width * last_row                               // Last pixel to decode
  15212 	len_code_limit = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)
  15213 	mask = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask
  15214 	if pos < last {
  15215 		v1 = GetHtreeGroupForPos(tls, hdr, col, row)
  15216 	} else {
  15217 		v1 = libc.UintptrFromInt32(0)
  15218 	}
  15219 	htree_group = v1
  15220 	for !((*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0) && pos < last {
  15221 		// Only update when changing tile.
  15222 		if col&mask == 0 {
  15223 			htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15224 		}
  15225 		v1 = br2
  15226 		if (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15227 			VP8LDoFillBitWindow(tls, v1)
  15228 		}
  15229 		code = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)), br2)
  15230 		if code < int32(NUM_LITERAL_CODES) { // Literal
  15231 			**(**uint8_t)(__ccgo_up(data + uintptr(pos))) = libc.Uint8FromInt32(code)
  15232 			pos = pos + 1
  15233 			col = col + 1
  15234 			if col >= width {
  15235 				col = 0
  15236 				row = row + 1
  15237 				if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15238 					ExtractPalettedAlphaRows(tls, dec, row)
  15239 				}
  15240 			}
  15241 		} else {
  15242 			if code < len_code_limit {
  15243 				length_sym = code - int32(NUM_LITERAL_CODES)
  15244 				length = GetCopyLength(tls, length_sym, br2)
  15245 				dist_symbol = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(DIST)*8)), br2)
  15246 				v1 = br2
  15247 				if (*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15248 					VP8LDoFillBitWindow(tls, v1)
  15249 				}
  15250 				dist_code = GetCopyDistance(tls, dist_symbol, br2)
  15251 				dist = PlaneCodeToDistance(tls, width, dist_code)
  15252 				if pos >= dist && end-pos >= length {
  15253 					CopyBlock8b(tls, data+uintptr(pos), dist, length)
  15254 				} else {
  15255 					ok = 0
  15256 					goto End
  15257 				}
  15258 				pos = pos + length
  15259 				col = col + length
  15260 				for col >= width {
  15261 					col = col - width
  15262 					row = row + 1
  15263 					if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15264 						ExtractPalettedAlphaRows(tls, dec, row)
  15265 					}
  15266 				}
  15267 				if pos < last && col&mask != 0 {
  15268 					htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15269 				}
  15270 			} else { // Not reached
  15271 				ok = 0
  15272 				goto End
  15273 			}
  15274 		}
  15275 		v1 = br2
  15276 		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))
  15277 		goto _6
  15278 	_6:
  15279 		(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v5
  15280 	}
  15281 	// Process the remaining rows corresponding to last row-block.
  15282 	if row > last_row {
  15283 		v5 = last_row
  15284 	} else {
  15285 		v5 = row
  15286 	}
  15287 	ExtractPalettedAlphaRows(tls, dec, v5)
  15288 	goto End
  15289 End:
  15290 	;
  15291 	v1 = br2
  15292 	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))
  15293 	goto _10
  15294 _10:
  15295 	(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v5
  15296 	if !(ok != 0) || (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 && pos < end {
  15297 		if (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 {
  15298 			v5 = int32(VP8_STATUS_SUSPENDED)
  15299 		} else {
  15300 			v5 = int32(VP8_STATUS_BITSTREAM_ERROR)
  15301 		}
  15302 		return VP8LSetError(tls, dec, v5)
  15303 	}
  15304 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = pos
  15305 	return ok
  15306 }
  15307 
  15308 func SaveState(tls *libc.TLS, dec uintptr, last_pixel int32) {
  15309 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_br = (*VP8LDecoder)(unsafe.Pointer(dec)).Fbr
  15310 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_last_pixel = last_pixel
  15311 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 {
  15312 		VP8LColorCacheCopy(tls, dec+152+8, dec+152+24)
  15313 	}
  15314 }
  15315 
  15316 func RestoreState(tls *libc.TLS, dec uintptr) {
  15317 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_SUSPENDED)
  15318 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fbr = (*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_br
  15319 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = (*VP8LDecoder)(unsafe.Pointer(dec)).Fsaved_last_pixel
  15320 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 {
  15321 		VP8LColorCacheCopy(tls, dec+152+24, dec+152+8)
  15322 	}
  15323 }
  15324 
  15325 func DecodeImageData(tls *libc.TLS, dec uintptr, data uintptr, width int32, height int32, last_row int32, __ccgo_fp_process_func ProcessRowsFunc) (r int32) {
  15326 	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
  15327 	var br2, color_cache, hdr, htree_group, last_cached, src, src_end, src_last, v2, v3 uintptr
  15328 	var v21 uint32_t
  15329 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  15330 	row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel / width
  15331 	col = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel % width
  15332 	br2 = dec + 40
  15333 	hdr = dec + 152
  15334 	src = data + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel)*4
  15335 	last_cached = src
  15336 	src_end = data + uintptr(width*height)*4    // End of data
  15337 	src_last = data + uintptr(width*last_row)*4 // Last pixel to decode
  15338 	len_code_limit = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES)
  15339 	color_cache_limit = len_code_limit + (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size
  15340 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  15341 		v1 = row
  15342 	} else {
  15343 		v1 = libc.Int32FromInt32(1) << libc.Int32FromInt32(24)
  15344 	}
  15345 	next_sync_row = v1
  15346 	if (*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size > 0 {
  15347 		v2 = hdr + 8
  15348 	} else {
  15349 		v2 = libc.UintptrFromInt32(0)
  15350 	}
  15351 	color_cache = v2
  15352 	mask = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask
  15353 	if src < src_last {
  15354 		v3 = GetHtreeGroupForPos(tls, hdr, col, row)
  15355 	} else {
  15356 		v3 = libc.UintptrFromInt32(0)
  15357 	}
  15358 	htree_group = v3
  15359 _5:
  15360 	;
  15361 	if !(src < src_last) {
  15362 		goto _4
  15363 	}
  15364 	if row >= next_sync_row {
  15365 		SaveState(tls, dec, int32((int64(src)-int64(data))/4))
  15366 		next_sync_row = row + int32(SYNC_EVERY_N_ROWS)
  15367 	}
  15368 	// Only update when changing tile. Note we could use this test:
  15369 	// if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed
  15370 	// but that's actually slower and needs storing the previous col/row.
  15371 	if col&mask == 0 {
  15372 		htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15373 	}
  15374 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_code != 0 {
  15375 		**(**uint32_t)(__ccgo_up(src)) = (*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb
  15376 		goto AdvanceByOne
  15377 	}
  15378 	v2 = br2
  15379 	if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15380 		VP8LDoFillBitWindow(tls, v2)
  15381 	}
  15382 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fuse_packed_table != 0 {
  15383 		code = ReadPackedSymbols(tls, htree_group, br2, src)
  15384 		v2 = br2
  15385 		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))
  15386 		goto _9
  15387 	_9:
  15388 		if v1 != 0 {
  15389 			goto _4
  15390 		}
  15391 		if code == PACKED_NON_LITERAL_CODE {
  15392 			goto AdvanceByOne
  15393 		}
  15394 	} else {
  15395 		code = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(GREEN)*8)), br2)
  15396 	}
  15397 	v2 = br2
  15398 	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))
  15399 	goto _12
  15400 _12:
  15401 	if v1 != 0 {
  15402 		goto _4
  15403 	}
  15404 	if !(code < int32(NUM_LITERAL_CODES)) {
  15405 		goto _13
  15406 	} // Literal
  15407 	if (*HTreeGroup)(unsafe.Pointer(htree_group)).Fis_trivial_literal != 0 {
  15408 		**(**uint32_t)(__ccgo_up(src)) = (*HTreeGroup)(unsafe.Pointer(htree_group)).Fliteral_arb | libc.Uint32FromInt32(code<<libc.Int32FromInt32(8))
  15409 	} else {
  15410 		red = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(RED)*8)), br2)
  15411 		v2 = br2
  15412 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15413 			VP8LDoFillBitWindow(tls, v2)
  15414 		}
  15415 		blue = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(BLUE)*8)), br2)
  15416 		alpha = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(ALPHA)*8)), br2)
  15417 		v2 = br2
  15418 		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))
  15419 		goto _18
  15420 	_18:
  15421 		if v1 != 0 {
  15422 			goto _4
  15423 		}
  15424 		**(**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)
  15425 	}
  15426 	goto AdvanceByOne
  15427 AdvanceByOne:
  15428 	;
  15429 	src += 4
  15430 	col = col + 1
  15431 	if col >= width {
  15432 		col = 0
  15433 		row = row + 1
  15434 		if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15435 			if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15436 				(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, row)
  15437 			}
  15438 		}
  15439 		if color_cache != libc.UintptrFromInt32(0) {
  15440 			for last_cached < src {
  15441 				v2 = last_cached
  15442 				last_cached += 4
  15443 				v3 = color_cache
  15444 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15445 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15446 				goto _23
  15447 			_23:
  15448 				key1 = v1
  15449 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15450 			}
  15451 		}
  15452 	}
  15453 	goto _14
  15454 _13:
  15455 	;
  15456 	if code < len_code_limit {
  15457 		length_sym = code - int32(NUM_LITERAL_CODES)
  15458 		length = GetCopyLength(tls, length_sym, br2)
  15459 		dist_symbol = ReadSymbol(tls, **(**uintptr)(__ccgo_up(htree_group + uintptr(DIST)*8)), br2)
  15460 		v2 = br2
  15461 		if (*VP8LBitReader)(unsafe.Pointer(v2)).Fbit_pos >= libc.Int32FromInt32(VP8L_WBITS) {
  15462 			VP8LDoFillBitWindow(tls, v2)
  15463 		}
  15464 		dist_code = GetCopyDistance(tls, dist_symbol, br2)
  15465 		dist = PlaneCodeToDistance(tls, width, dist_code)
  15466 		v2 = br2
  15467 		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))
  15468 		goto _27
  15469 	_27:
  15470 		if v1 != 0 {
  15471 			goto _4
  15472 		}
  15473 		if (int64(src)-int64(data))/4 < int64(dist) || (int64(src_end)-int64(src))/4 < int64(length) {
  15474 			goto Error
  15475 		} else {
  15476 			CopyBlock32b(tls, src, dist, length)
  15477 		}
  15478 		src = src + uintptr(length)*4
  15479 		col = col + length
  15480 		for col >= width {
  15481 			col = col - width
  15482 			row = row + 1
  15483 			if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15484 				if row <= last_row && row%int32(NUM_ARGB_CACHE_ROWS) == 0 {
  15485 					(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, row)
  15486 				}
  15487 			}
  15488 		}
  15489 		// Because of the check done above (before 'src' was incremented by
  15490 		// 'length'), the following holds true.
  15491 		if col&mask != 0 {
  15492 			htree_group = GetHtreeGroupForPos(tls, hdr, col, row)
  15493 		}
  15494 		if color_cache != libc.UintptrFromInt32(0) {
  15495 			for last_cached < src {
  15496 				v2 = last_cached
  15497 				last_cached += 4
  15498 				v3 = color_cache
  15499 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15500 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15501 				goto _32
  15502 			_32:
  15503 				key1 = v1
  15504 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15505 			}
  15506 		}
  15507 	} else {
  15508 		if code < color_cache_limit { // Color cache
  15509 			key2 = code - len_code_limit
  15510 			for last_cached < src {
  15511 				v2 = last_cached
  15512 				last_cached += 4
  15513 				v3 = color_cache
  15514 				v21 = **(**uint32_t)(__ccgo_up(v2))
  15515 				v1 = libc.Int32FromUint32(v21 * kHashMul8 >> (*VP8LColorCache)(unsafe.Pointer(v3)).Fhash_shift)
  15516 				goto _37
  15517 			_37:
  15518 				key1 = v1
  15519 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v3)).Fcolors + uintptr(key1)*4)) = v21
  15520 			}
  15521 			v21 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4))
  15522 			goto _39
  15523 		_39:
  15524 			**(**uint32_t)(__ccgo_up(src)) = v21
  15525 			goto AdvanceByOne
  15526 		} else { // Not reached
  15527 			goto Error
  15528 		}
  15529 	}
  15530 _14:
  15531 	;
  15532 	goto _5
  15533 _4:
  15534 	;
  15535 	v2 = br2
  15536 	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))
  15537 	goto _42
  15538 _42:
  15539 	(*VP8LBitReader)(unsafe.Pointer(br2)).Feos = v1
  15540 	// In incremental decoding:
  15541 	// br->eos && src < src_last: if 'br' reached the end of the buffer and
  15542 	// 'src_last' has not been reached yet, there is not enough data. 'dec' has to
  15543 	// be reset until there is more data.
  15544 	// !br->eos && src < src_last: this cannot happen as either the buffer is
  15545 	// fully read, either enough has been read to reach 'src_last'.
  15546 	// src >= src_last: 'src_last' is reached, all is fine. 'src' can actually go
  15547 	// beyond 'src_last' in case the image is cropped and an LZ77 goes further.
  15548 	// The buffer might have been enough or there is some left. 'br->eos' does
  15549 	// not matter.
  15550 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 && (*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0 && src < src_last {
  15551 		RestoreState(tls, dec)
  15552 	} else {
  15553 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 && src >= src_last || !((*VP8LBitReader)(unsafe.Pointer(br2)).Feos != 0) {
  15554 			// Process the remaining rows corresponding to last row-block.
  15555 			if __ccgo_fp_process_func != libc.UintptrFromInt32(0) {
  15556 				if row > last_row {
  15557 					v1 = last_row
  15558 				} else {
  15559 					v1 = row
  15560 				}
  15561 				(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_process_func})))(tls, dec, v1)
  15562 			}
  15563 			(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15564 			(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = int32((int64(src) - int64(data)) / 4) // end-of-scan marker
  15565 		} else {
  15566 			// if not incremental, and we are past the end of buffer (eos=1), then this
  15567 			// is a real bitstream error.
  15568 			goto Error
  15569 		}
  15570 	}
  15571 	return int32(1)
  15572 	goto Error
  15573 Error:
  15574 	;
  15575 	return VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15576 	return r
  15577 }
  15578 
  15579 // -----------------------------------------------------------------------------
  15580 // VP8LTransform
  15581 
  15582 func ClearTransform(tls *libc.TLS, transform uintptr) {
  15583 	WebPSafeFree(tls, (*VP8LTransform)(unsafe.Pointer(transform)).Fdata)
  15584 	(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = libc.UintptrFromInt32(0)
  15585 }
  15586 
  15587 // C documentation
  15588 //
  15589 //	// For security reason, we need to remap the color map to span
  15590 //	// the total possible bundled values, and not just the num_colors.
  15591 func ExpandColorMap(tls *libc.TLS, num_colors int32, transform uintptr) (r int32) {
  15592 	var data, new_color_map, new_data uintptr
  15593 	var final_num_colors, i int32
  15594 	_, _, _, _, _ = data, final_num_colors, i, new_color_map, new_data
  15595 	final_num_colors = int32(1) << (int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15596 	new_color_map = WebPSafeMalloc(tls, libc.Uint64FromInt32(final_num_colors), uint64(4))
  15597 	if new_color_map == libc.UintptrFromInt32(0) {
  15598 		return 0
  15599 	} else {
  15600 		data = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  15601 		new_data = new_color_map
  15602 		**(**uint32_t)(__ccgo_up(new_color_map)) = **(**uint32_t)(__ccgo_up((*VP8LTransform)(unsafe.Pointer(transform)).Fdata))
  15603 		i = int32(4)
  15604 		for {
  15605 			if !(i < int32(4)*num_colors) {
  15606 				break
  15607 			}
  15608 			// Equivalent to VP8LAddPixels(), on a byte-basis.
  15609 			**(**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))
  15610 			goto _1
  15611 		_1:
  15612 			;
  15613 			i = i + 1
  15614 		}
  15615 		for {
  15616 			if !(i < int32(4)*final_num_colors) {
  15617 				break
  15618 			}
  15619 			**(**uint8_t)(__ccgo_up(new_data + uintptr(i))) = uint8(0) // black tail.
  15620 			goto _2
  15621 		_2:
  15622 			;
  15623 			i = i + 1
  15624 		}
  15625 		WebPSafeFree(tls, (*VP8LTransform)(unsafe.Pointer(transform)).Fdata)
  15626 		(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = new_color_map
  15627 	}
  15628 	return int32(1)
  15629 }
  15630 
  15631 func ReadTransform(tls *libc.TLS, xsize uintptr, ysize uintptr, dec uintptr) (r int32) {
  15632 	var bits, num_colors, ok, v7, v8, v9 int32
  15633 	var br, transform uintptr
  15634 	var type1 VP8LImageTransformType
  15635 	var v1, v2, v4, v5 uint32_t
  15636 	_, _, _, _, _, _, _, _, _, _, _, _, _ = bits, br, num_colors, ok, transform, type1, v1, v2, v4, v5, v7, v8, v9
  15637 	ok = int32(1)
  15638 	br = dec + 40
  15639 	transform = dec + 280 + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform)*24
  15640 	type1 = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(2)))
  15641 	// Each transform type can only be present once in the stream.
  15642 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Ftransforms_seen&(uint32(1)<<type1) != 0 {
  15643 		return 0 // Already there, let's not accept the second same transform.
  15644 	}
  15645 	**(**uint32_t)(__ccgo_up(dec + 376)) |= uint32(1) << type1
  15646 	(*VP8LTransform)(unsafe.Pointer(transform)).Ftype1 = type1
  15647 	(*VP8LTransform)(unsafe.Pointer(transform)).Fxsize = **(**int32)(__ccgo_up(xsize))
  15648 	(*VP8LTransform)(unsafe.Pointer(transform)).Fysize = **(**int32)(__ccgo_up(ysize))
  15649 	(*VP8LTransform)(unsafe.Pointer(transform)).Fdata = libc.UintptrFromInt32(0)
  15650 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform = (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform + 1
  15651 	switch type1 {
  15652 	case int32(PREDICTOR_TRANSFORM):
  15653 		fallthrough
  15654 	case int32(CROSS_COLOR_TRANSFORM):
  15655 		(*VP8LTransform)(unsafe.Pointer(transform)).Fbits = libc.Int32FromUint32(uint32(MIN_TRANSFORM_BITS) + VP8LReadBits(tls, br, int32(NUM_TRANSFORM_BITS)))
  15656 		v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15657 		v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15658 		goto _3
  15659 	_3:
  15660 		v4 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  15661 		v5 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  15662 		goto _6
  15663 	_6:
  15664 		ok = DecodeImageStream(tls, libc.Int32FromUint32(v2), libc.Int32FromUint32(v5), 0, dec, transform+16)
  15665 	case int32(COLOR_INDEXING_TRANSFORM):
  15666 		num_colors = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(8)) + uint32(1))
  15667 		if num_colors > int32(16) {
  15668 			v7 = 0
  15669 		} else {
  15670 			if num_colors > int32(4) {
  15671 				v8 = int32(1)
  15672 			} else {
  15673 				if num_colors > int32(2) {
  15674 					v9 = int32(2)
  15675 				} else {
  15676 					v9 = int32(3)
  15677 				}
  15678 				v8 = v9
  15679 			}
  15680 			v7 = v8
  15681 		}
  15682 		bits = v7
  15683 		v1 = libc.Uint32FromInt32(bits)
  15684 		v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15685 		goto _12
  15686 	_12:
  15687 		**(**int32)(__ccgo_up(xsize)) = libc.Int32FromUint32(v2)
  15688 		(*VP8LTransform)(unsafe.Pointer(transform)).Fbits = bits
  15689 		ok = DecodeImageStream(tls, num_colors, int32(1), 0, dec, transform+16)
  15690 		if ok != 0 && !(ExpandColorMap(tls, num_colors, transform) != 0) {
  15691 			return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15692 		}
  15693 	case int32(SUBTRACT_GREEN_TRANSFORM):
  15694 	default:
  15695 		// can't happen
  15696 		break
  15697 	}
  15698 	return ok
  15699 }
  15700 
  15701 // -----------------------------------------------------------------------------
  15702 // VP8LMetadata
  15703 
  15704 func InitMetadata(tls *libc.TLS, hdr uintptr) {
  15705 	libc.X__builtin___memset_chk(tls, hdr, 0, uint64(120), ^__predefined_size_t(0))
  15706 }
  15707 
  15708 func ClearMetadata(tls *libc.TLS, hdr uintptr) {
  15709 	WebPSafeFree(tls, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_image)
  15710 	VP8LHuffmanTablesDeallocate(tls, hdr+80)
  15711 	VP8LHtreeGroupsFree(tls, (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhtree_groups)
  15712 	VP8LColorCacheClear(tls, hdr+8)
  15713 	VP8LColorCacheClear(tls, hdr+24)
  15714 	InitMetadata(tls, hdr)
  15715 }
  15716 
  15717 // -----------------------------------------------------------------------------
  15718 // VP8LDecoder
  15719 
  15720 func VP8LNew(tls *libc.TLS) (r uintptr) {
  15721 	var dec uintptr
  15722 	_ = dec
  15723 	dec = WebPSafeCalloc(tls, uint64(1), uint64(400))
  15724 	if dec == libc.UintptrFromInt32(0) {
  15725 		return libc.UintptrFromInt32(0)
  15726 	}
  15727 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15728 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DIM)
  15729 	VP8LDspInit(tls) // Init critical function pointers.
  15730 	return dec
  15731 }
  15732 
  15733 // C documentation
  15734 //
  15735 //	// Resets the decoder in its initial state, reclaiming memory.
  15736 //	// Preserves the dec->status value.
  15737 func VP8LClear(tls *libc.TLS, dec uintptr) {
  15738 	var i int32
  15739 	_ = i
  15740 	if dec == libc.UintptrFromInt32(0) {
  15741 		return
  15742 	}
  15743 	ClearMetadata(tls, dec+152)
  15744 	WebPSafeFree(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels)
  15745 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = libc.UintptrFromInt32(0)
  15746 	i = 0
  15747 	for {
  15748 		if !(i < (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform) {
  15749 			break
  15750 		}
  15751 		ClearTransform(tls, dec+280+uintptr(i)*24)
  15752 		goto _1
  15753 	_1:
  15754 		;
  15755 		i = i + 1
  15756 	}
  15757 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform = 0
  15758 	(*VP8LDecoder)(unsafe.Pointer(dec)).Ftransforms_seen = uint32(0)
  15759 	WebPSafeFree(tls, (*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory)
  15760 	(*VP8LDecoder)(unsafe.Pointer(dec)).Frescaler_memory = libc.UintptrFromInt32(0)
  15761 	(*VP8LDecoder)(unsafe.Pointer(dec)).Foutput = libc.UintptrFromInt32(0) // leave no trace behind
  15762 }
  15763 
  15764 func VP8LDelete(tls *libc.TLS, dec uintptr) {
  15765 	if dec != libc.UintptrFromInt32(0) {
  15766 		VP8LClear(tls, dec)
  15767 		WebPSafeFree(tls, dec)
  15768 	}
  15769 }
  15770 
  15771 func UpdateDecoder(tls *libc.TLS, dec uintptr, width int32, height int32) {
  15772 	var hdr uintptr
  15773 	var num_bits, v4 int32
  15774 	var v1, v2 uint32_t
  15775 	_, _, _, _, _ = hdr, num_bits, v1, v2, v4
  15776 	hdr = dec + 152
  15777 	num_bits = (*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_subsample_bits
  15778 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth = width
  15779 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fheight = height
  15780 	v1 = libc.Uint32FromInt32(num_bits)
  15781 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  15782 	goto _3
  15783 _3:
  15784 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_xsize = libc.Int32FromUint32(v2)
  15785 	if num_bits == 0 {
  15786 		v4 = ^libc.Int32FromInt32(0)
  15787 	} else {
  15788 		v4 = int32(1)<<num_bits - int32(1)
  15789 	}
  15790 	(*VP8LMetadata)(unsafe.Pointer(hdr)).Fhuffman_mask = v4
  15791 }
  15792 
  15793 func DecodeImageStream(tls *libc.TLS, xsize int32, ysize int32, is_level0 int32, dec uintptr, decoded_data uintptr) (r int32) {
  15794 	bp := tls.Alloc(16)
  15795 	defer tls.Free(16)
  15796 	var br, data, hdr uintptr
  15797 	var color_cache_bits, ok int32
  15798 	var total_size uint64_t
  15799 	var _ /* transform_xsize at bp+0 */ int32
  15800 	var _ /* transform_ysize at bp+4 */ int32
  15801 	_, _, _, _, _, _ = br, color_cache_bits, data, hdr, ok, total_size
  15802 	ok = int32(1)
  15803 	**(**int32)(__ccgo_up(bp)) = xsize
  15804 	**(**int32)(__ccgo_up(bp + 4)) = ysize
  15805 	br = dec + 40
  15806 	hdr = dec + 152
  15807 	data = libc.UintptrFromInt32(0)
  15808 	color_cache_bits = 0
  15809 	// Read the transforms (may recurse).
  15810 	if is_level0 != 0 {
  15811 		for ok != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  15812 			ok = ReadTransform(tls, bp, bp+4, dec)
  15813 		}
  15814 	}
  15815 	// Color cache
  15816 	if ok != 0 && VP8LReadBits(tls, br, int32(1)) != 0 {
  15817 		color_cache_bits = libc.Int32FromUint32(VP8LReadBits(tls, br, int32(4)))
  15818 		ok = libc.BoolInt32(color_cache_bits >= int32(1) && color_cache_bits <= int32(MAX_CACHE_BITS))
  15819 		if !(ok != 0) {
  15820 			VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15821 			goto End
  15822 		}
  15823 	}
  15824 	// Read the Huffman codes (may recurse).
  15825 	ok = libc.BoolInt32(ok != 0 && ReadHuffmanCodes(tls, dec, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), color_cache_bits, is_level0) != 0)
  15826 	if !(ok != 0) {
  15827 		VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  15828 		goto End
  15829 	}
  15830 	// Finish setting up the color-cache
  15831 	if color_cache_bits > 0 {
  15832 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size = int32(1) << color_cache_bits
  15833 		if !(VP8LColorCacheInit(tls, hdr+8, color_cache_bits) != 0) {
  15834 			ok = VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15835 			goto End
  15836 		}
  15837 	} else {
  15838 		(*VP8LMetadata)(unsafe.Pointer(hdr)).Fcolor_cache_size = 0
  15839 	}
  15840 	UpdateDecoder(tls, dec, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)))
  15841 	if is_level0 != 0 { // level 0 complete
  15842 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_HDR)
  15843 		goto End
  15844 	}
  15845 	total_size = libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))) * libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))
  15846 	data = WebPSafeMalloc(tls, total_size, uint64(4))
  15847 	if data == libc.UintptrFromInt32(0) {
  15848 		ok = VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15849 		goto End
  15850 	}
  15851 	// Use the Huffman trees to decode the LZ77 encoded data.
  15852 	ok = DecodeImageData(tls, dec, data, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), **(**int32)(__ccgo_up(bp + 4)), libc.UintptrFromInt32(0))
  15853 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitReader)(unsafe.Pointer(br)).Feos != 0))
  15854 	goto End
  15855 End:
  15856 	;
  15857 	if !(ok != 0) {
  15858 		WebPSafeFree(tls, data)
  15859 		ClearMetadata(tls, hdr)
  15860 	} else {
  15861 		if decoded_data != libc.UintptrFromInt32(0) {
  15862 			**(**uintptr)(__ccgo_up(decoded_data)) = data
  15863 		} else {
  15864 			// We allocate image data in this function only for transforms. At level 0
  15865 			// (that is: not the transforms), we shouldn't have allocated anything.
  15866 		}
  15867 		(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_pixel = 0 // Reset for future DECODE_DATA_FUNC() calls.
  15868 		if !(is_level0 != 0) {
  15869 			ClearMetadata(tls, hdr)
  15870 		} // Clean up temporary data behind.
  15871 	}
  15872 	return ok
  15873 }
  15874 
  15875 // C documentation
  15876 //
  15877 //	//------------------------------------------------------------------------------
  15878 //	// Allocate internal buffers dec->pixels and dec->argb_cache.
  15879 func AllocateInternalBuffers32b(tls *libc.TLS, dec uintptr, final_width int32) (r int32) {
  15880 	var cache_pixels, cache_top_pixels, num_pixels, total_num_pixels uint64_t
  15881 	_, _, _, _ = cache_pixels, cache_top_pixels, num_pixels, total_num_pixels
  15882 	num_pixels = libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth) * libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fheight)
  15883 	// Scratch buffer corresponding to top-prediction row for transforming the
  15884 	// first row in the row-blocks. Not needed for paletted alpha.
  15885 	cache_top_pixels = uint64(libc.Uint16FromInt32(final_width))
  15886 	// Scratch buffer for temporary BGRA storage. Not needed for paletted alpha.
  15887 	cache_pixels = libc.Uint64FromInt32(final_width) * uint64(NUM_ARGB_CACHE_ROWS)
  15888 	total_num_pixels = num_pixels + cache_top_pixels + cache_pixels
  15889 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = WebPSafeMalloc(tls, total_num_pixels, uint64(4))
  15890 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels == libc.UintptrFromInt32(0) {
  15891 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = libc.UintptrFromInt32(0) // for soundness
  15892 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15893 	}
  15894 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr(num_pixels)*4 + uintptr(cache_top_pixels)*4
  15895 	return int32(1)
  15896 }
  15897 
  15898 func AllocateInternalBuffers8b(tls *libc.TLS, dec uintptr) (r int32) {
  15899 	var total_num_pixels uint64_t
  15900 	_ = total_num_pixels
  15901 	total_num_pixels = libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth) * libc.Uint64FromInt32((*VP8LDecoder)(unsafe.Pointer(dec)).Fheight)
  15902 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache = libc.UintptrFromInt32(0) // for soundness
  15903 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels = WebPSafeMalloc(tls, total_num_pixels, uint64(1))
  15904 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels == libc.UintptrFromInt32(0) {
  15905 		return VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  15906 	}
  15907 	return int32(1)
  15908 }
  15909 
  15910 //------------------------------------------------------------------------------
  15911 
  15912 // C documentation
  15913 //
  15914 //	// Special row-processing that only stores the alpha data.
  15915 func ExtractAlphaRows(tls *libc.TLS, dec uintptr, last_row int32) {
  15916 	var alph_dec, dst, in, output, src uintptr
  15917 	var cache_pixs, cur_row, num_rows, num_rows_to_process, width, v1 int32
  15918 	_, _, _, _, _, _, _, _, _, _, _ = alph_dec, cache_pixs, cur_row, dst, in, num_rows, num_rows_to_process, output, src, width, v1
  15919 	cur_row = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row
  15920 	num_rows = last_row - cur_row
  15921 	in = (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels + uintptr((*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth*cur_row)*4
  15922 	for num_rows > 0 {
  15923 		if num_rows > int32(NUM_ARGB_CACHE_ROWS) {
  15924 			v1 = int32(NUM_ARGB_CACHE_ROWS)
  15925 		} else {
  15926 			v1 = num_rows
  15927 		}
  15928 		num_rows_to_process = v1
  15929 		// Extract alpha (which is stored in the green plane).
  15930 		alph_dec = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque
  15931 		output = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Foutput
  15932 		width = (*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth // the final width (!= dec->width)
  15933 		cache_pixs = width * num_rows_to_process
  15934 		dst = output + uintptr(width*cur_row)
  15935 		src = (*VP8LDecoder)(unsafe.Pointer(dec)).Fargb_cache
  15936 		ApplyInverseTransforms(tls, dec, cur_row, num_rows_to_process, in)
  15937 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPExtractGreen})))(tls, src, dst, cache_pixs)
  15938 		AlphaApplyFilter(tls, alph_dec, cur_row, cur_row+num_rows_to_process, dst, width)
  15939 		num_rows = num_rows - num_rows_to_process
  15940 		in = in + uintptr(num_rows_to_process*(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth)*4
  15941 		cur_row = cur_row + num_rows_to_process
  15942 	}
  15943 	v1 = last_row
  15944 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row = v1
  15945 	(*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row = v1
  15946 }
  15947 
  15948 func VP8LDecodeAlphaHeader(tls *libc.TLS, alph_dec uintptr, data uintptr, data_size size_t) (r int32) {
  15949 	var dec uintptr
  15950 	var ok int32
  15951 	_, _ = dec, ok
  15952 	ok = 0
  15953 	dec = VP8LNew(tls)
  15954 	if dec == libc.UintptrFromInt32(0) {
  15955 		return 0
  15956 	}
  15957 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
  15958 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fheight = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight
  15959 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fio = alph_dec + 32
  15960 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fopaque = alph_dec
  15961 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fwidth = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth
  15962 	(*VP8Io)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Fio)).Fheight = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight
  15963 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  15964 	VP8LInitBitReader(tls, dec+40, data, data_size)
  15965 	if !(DecodeImageStream(tls, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fheight, int32(1), dec, libc.UintptrFromInt32(0)) != 0) {
  15966 		goto Err
  15967 	}
  15968 	// Special case: if alpha data uses only the color indexing transform and
  15969 	// doesn't use color cache (a frequent case), we will use DecodeAlphaData()
  15970 	// method that only needs allocation of 1 byte per pixel (alpha channel).
  15971 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fnext_transform == int32(1) && (**(**VP8LTransform)(__ccgo_up(dec + 280))).Ftype1 == int32(COLOR_INDEXING_TRANSFORM) && Is8bOptimizable(tls, dec+152) != 0 {
  15972 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode = int32(1)
  15973 		ok = AllocateInternalBuffers8b(tls, dec)
  15974 	} else {
  15975 		// Allocate internal buffers (note that dec->width may have changed here).
  15976 		(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode = 0
  15977 		ok = AllocateInternalBuffers32b(tls, dec, (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fwidth)
  15978 	}
  15979 	if !(ok != 0) {
  15980 		goto Err
  15981 	}
  15982 	// Only set here, once we are sure it is valid (to avoid thread races).
  15983 	(*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec = dec
  15984 	return int32(1)
  15985 	goto Err
  15986 Err:
  15987 	;
  15988 	VP8LDelete(tls, dec)
  15989 	return 0
  15990 }
  15991 
  15992 func VP8LDecodeAlphaImageStream(tls *libc.TLS, alph_dec uintptr, last_row int32) (r int32) {
  15993 	var dec uintptr
  15994 	var v1 int32
  15995 	_, _ = dec, v1
  15996 	dec = (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fvp8l_dec
  15997 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_row >= last_row {
  15998 		return int32(1) // done
  15999 	}
  16000 	if !((*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode != 0) {
  16001 		WebPInitAlphaProcessing(tls)
  16002 	}
  16003 	// Decode (with special row processing).
  16004 	if (*ALPHDecoder)(unsafe.Pointer(alph_dec)).Fuse_8b_decode != 0 {
  16005 		v1 = DecodeAlphaData(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels, (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth, (*VP8LDecoder)(unsafe.Pointer(dec)).Fheight, last_row)
  16006 	} else {
  16007 		v1 = DecodeImageData(tls, dec, (*VP8LDecoder)(unsafe.Pointer(dec)).Fpixels, (*VP8LDecoder)(unsafe.Pointer(dec)).Fwidth, (*VP8LDecoder)(unsafe.Pointer(dec)).Fheight, last_row, __ccgo_fp(ExtractAlphaRows))
  16008 	}
  16009 	return v1
  16010 }
  16011 
  16012 //------------------------------------------------------------------------------
  16013 
  16014 func VP8LDecodeHeader(tls *libc.TLS, dec uintptr, io uintptr) (r int32) {
  16015 	bp := tls.Alloc(16)
  16016 	defer tls.Free(16)
  16017 	var _ /* has_alpha at bp+8 */ int32
  16018 	var _ /* height at bp+4 */ int32
  16019 	var _ /* width at bp+0 */ int32
  16020 	if dec == libc.UintptrFromInt32(0) {
  16021 		return 0
  16022 	}
  16023 	if io == libc.UintptrFromInt32(0) {
  16024 		return VP8LSetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM))
  16025 	}
  16026 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fio = io
  16027 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstatus = int32(VP8_STATUS_OK)
  16028 	VP8LInitBitReader(tls, dec+40, (*VP8Io)(unsafe.Pointer(io)).Fdata, (*VP8Io)(unsafe.Pointer(io)).Fdata_size)
  16029 	if !(ReadImageInfo(tls, dec+40, bp, bp+4, bp+8) != 0) {
  16030 		VP8LSetError(tls, dec, int32(VP8_STATUS_BITSTREAM_ERROR))
  16031 		goto Error
  16032 	}
  16033 	(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DIM)
  16034 	(*VP8Io)(unsafe.Pointer(io)).Fwidth = **(**int32)(__ccgo_up(bp))
  16035 	(*VP8Io)(unsafe.Pointer(io)).Fheight = **(**int32)(__ccgo_up(bp + 4))
  16036 	if !(DecodeImageStream(tls, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), int32(1), dec, libc.UintptrFromInt32(0)) != 0) {
  16037 		goto Error
  16038 	}
  16039 	return int32(1)
  16040 	goto Error
  16041 Error:
  16042 	;
  16043 	VP8LClear(tls, dec)
  16044 	return 0
  16045 }
  16046 
  16047 func VP8LDecodeImage(tls *libc.TLS, dec uintptr) (r int32) {
  16048 	var io, params uintptr
  16049 	var v1 WEBP_CSP_MODE1
  16050 	var v2 int32
  16051 	var v4 bool
  16052 	_, _, _, _, _ = io, params, v1, v2, v4
  16053 	io = libc.UintptrFromInt32(0)
  16054 	params = libc.UintptrFromInt32(0)
  16055 	if dec == libc.UintptrFromInt32(0) {
  16056 		return 0
  16057 	}
  16058 	io = (*VP8LDecoder)(unsafe.Pointer(dec)).Fio
  16059 	params = (*VP8Io)(unsafe.Pointer(io)).Fopaque
  16060 	// Initialization.
  16061 	if (*VP8LDecoder)(unsafe.Pointer(dec)).Fstate != int32(READ_DATA) {
  16062 		(*VP8LDecoder)(unsafe.Pointer(dec)).Foutput = (*WebPDecParams)(unsafe.Pointer(params)).Foutput
  16063 		if !(WebPIoInitFromOptions(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, io, int32(MODE_BGRA)) != 0) {
  16064 			VP8LSetError(tls, dec, int32(VP8_STATUS_INVALID_PARAM))
  16065 			goto Err
  16066 		}
  16067 		if !(AllocateInternalBuffers32b(tls, dec, (*VP8Io)(unsafe.Pointer(io)).Fwidth) != 0) {
  16068 			goto Err
  16069 		}
  16070 		if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 && !(AllocateAndInitRescaler(tls, dec, io) != 0) {
  16071 			goto Err
  16072 		}
  16073 		if v4 = (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0; !v4 {
  16074 			v1 = (*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace
  16075 			v2 = libc.BoolInt32(v1 == int32(MODE_rgbA) || v1 == int32(MODE_bgrA) || v1 == int32(MODE_Argb) || v1 == int32(MODE_rgbA_4444))
  16076 			goto _3
  16077 		_3:
  16078 		}
  16079 		if v4 || v2 != 0 {
  16080 			// need the alpha-multiply functions for premultiplied output or rescaling
  16081 			WebPInitAlphaProcessing(tls)
  16082 		}
  16083 		v2 = libc.BoolInt32((*WebPDecBuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput)).Fcolorspace < int32(MODE_YUV))
  16084 		goto _6
  16085 	_6:
  16086 		if !(v2 != 0) {
  16087 			WebPInitConvertARGBToYUV(tls)
  16088 			if (*(*WebPYUVABuffer)(unsafe.Pointer((*VP8LDecoder)(unsafe.Pointer(dec)).Foutput + 16))).Fa != libc.UintptrFromInt32(0) {
  16089 				WebPInitAlphaProcessing(tls)
  16090 			}
  16091 		}
  16092 		if (*VP8LDecoder)(unsafe.Pointer(dec)).Fincremental != 0 {
  16093 			if (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache_size > 0 && (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fsaved_color_cache.Fcolors == libc.UintptrFromInt32(0) {
  16094 				if !(VP8LColorCacheInit(tls, dec+152+24, (*VP8LDecoder)(unsafe.Pointer(dec)).Fhdr.Fcolor_cache.Fhash_bits) != 0) {
  16095 					VP8LSetError(tls, dec, int32(VP8_STATUS_OUT_OF_MEMORY))
  16096 					goto Err
  16097 				}
  16098 			}
  16099 		}
  16100 		(*VP8LDecoder)(unsafe.Pointer(dec)).Fstate = int32(READ_DATA)
  16101 	}
  16102 	// Decode.
  16103 	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) {
  16104 		goto Err
  16105 	}
  16106 	(*WebPDecParams)(unsafe.Pointer(params)).Flast_y = (*VP8LDecoder)(unsafe.Pointer(dec)).Flast_out_row
  16107 	return int32(1)
  16108 	goto Err
  16109 Err:
  16110 	;
  16111 	VP8LClear(tls, dec)
  16112 	return 0
  16113 }
  16114 
  16115 const VP8L_MAGIC_BYTE2 = 0x2f
  16116 
  16117 var kHashMul9 = uint32(0x1e35a7bd)
  16118 
  16119 type WebPData = struct {
  16120 	Fbytes uintptr
  16121 	Fsize  size_t
  16122 }
  16123 
  16124 type WebPFeatureFlags1 = int32
  16125 
  16126 type WebPFeatureFlags = int32
  16127 
  16128 const ANIMATION_FLAG = 2
  16129 const XMP_FLAG = 4
  16130 const EXIF_FLAG = 8
  16131 const ALPHA_FLAG = 16
  16132 const ICCP_FLAG = 32
  16133 const ALL_VALID_FLAGS = 62
  16134 
  16135 type WebPMuxAnimDispose1 = int32
  16136 
  16137 type WebPMuxAnimDispose = int32
  16138 
  16139 const WEBP_MUX_DISPOSE_NONE = 0
  16140 const WEBP_MUX_DISPOSE_BACKGROUND = 1
  16141 
  16142 type WebPMuxAnimBlend1 = int32
  16143 
  16144 type WebPMuxAnimBlend = int32
  16145 
  16146 const WEBP_MUX_BLEND = 0
  16147 const WEBP_MUX_NO_BLEND = 1
  16148 
  16149 // Copyright 2010 Google Inc. All Rights Reserved.
  16150 //
  16151 // Use of this source code is governed by a BSD-style license
  16152 // that can be found in the COPYING file in the root of the source
  16153 // tree. An additional intellectual property rights grant can be found
  16154 // in the file PATENTS. All contributing project authors may
  16155 // be found in the AUTHORS file in the root of the source tree.
  16156 // -----------------------------------------------------------------------------
  16157 //
  16158 //  Common types + memory wrappers
  16159 //
  16160 // Author: Skal (pascal.massimino@gmail.com)
  16161 
  16162 //------------------------------------------------------------------------------
  16163 // RIFF layout is:
  16164 //   Offset  tag
  16165 //   0...3   "RIFF" 4-byte tag
  16166 //   4...7   size of image data (including metadata) starting at offset 8
  16167 //   8...11  "WEBP"   our form-type signature
  16168 // The RIFF container (12 bytes) is followed by appropriate chunks:
  16169 //   12..15  "VP8 ": 4-bytes tags, signaling the use of VP8 video format
  16170 //   16..19  size of the raw VP8 image data, starting at offset 20
  16171 //   20....  the VP8 bytes
  16172 // Or,
  16173 //   12..15  "VP8L": 4-bytes tags, signaling the use of VP8L lossless format
  16174 //   16..19  size of the raw VP8L image data, starting at offset 20
  16175 //   20....  the VP8L bytes
  16176 // Or,
  16177 //   12..15  "VP8X": 4-bytes tags, describing the extended-VP8 chunk.
  16178 //   16..19  size of the VP8X chunk starting at offset 20.
  16179 //   20..23  VP8X flags bit-map corresponding to the chunk-types present.
  16180 //   24..26  Width of the Canvas Image.
  16181 //   27..29  Height of the Canvas Image.
  16182 // There can be extra chunks after the "VP8X" chunk (ICCP, ANMF, VP8, VP8L,
  16183 // XMP, EXIF  ...)
  16184 // All sizes are in little-endian order.
  16185 // Note: chunk data size must be padded to multiple of 2 when written.
  16186 
  16187 // C documentation
  16188 //
  16189 //	// Validates the RIFF container (if detected) and skips over it.
  16190 //	// If a RIFF container is detected, returns:
  16191 //	//     VP8_STATUS_BITSTREAM_ERROR for invalid header,
  16192 //	//     VP8_STATUS_NOT_ENOUGH_DATA for truncated data if have_all_data is true,
  16193 //	// and VP8_STATUS_OK otherwise.
  16194 //	// In case there are not enough bytes (partial RIFF container), return 0 for
  16195 //	// *riff_size. Else return the RIFF size extracted from the header.
  16196 func ParseRIFF(tls *libc.TLS, data2 uintptr, data_size uintptr, have_all_data int32, riff_size uintptr) (r VP8StatusCode1) {
  16197 	var size, v2 uint32_t
  16198 	var v1, v4, v7 uintptr
  16199 	var v5, v8 int32
  16200 	_, _, _, _, _, _, _ = size, v1, v2, v4, v5, v7, v8
  16201 	**(**size_t)(__ccgo_up(riff_size)) = uint64(0) // Default: no RIFF present.
  16202 	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) {
  16203 		if libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(data2))+uintptr(8), __ccgo_ts+569, uint64(TAG_SIZE)) != 0 {
  16204 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Wrong image file signature.
  16205 		} else {
  16206 			v1 = **(**uintptr)(__ccgo_up(data2)) + uintptr(TAG_SIZE)
  16207 			v4 = v1
  16208 			v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16209 			goto _6
  16210 		_6:
  16211 			v7 = v1 + uintptr(2)
  16212 			v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16213 			goto _9
  16214 		_9:
  16215 			v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16216 			goto _3
  16217 		_3:
  16218 			size = v2
  16219 			// Check that we have at least one chunk (i.e "WEBP" + "VP8?nnnn").
  16220 			if size < libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) {
  16221 				return int32(VP8_STATUS_BITSTREAM_ERROR)
  16222 			}
  16223 			if size > ^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1) {
  16224 				return int32(VP8_STATUS_BITSTREAM_ERROR)
  16225 			}
  16226 			if have_all_data != 0 && uint64(size) > **(**size_t)(__ccgo_up(data_size))-uint64(CHUNK_HEADER_SIZE) {
  16227 				return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Truncated bitstream.
  16228 			}
  16229 			// We have a RIFF container. Skip it.
  16230 			**(**size_t)(__ccgo_up(riff_size)) = uint64(size)
  16231 			**(**uintptr)(__ccgo_up(data2)) += uintptr(RIFF_HEADER_SIZE)
  16232 			**(**size_t)(__ccgo_up(data_size)) -= uint64(RIFF_HEADER_SIZE)
  16233 		}
  16234 	}
  16235 	return int32(VP8_STATUS_OK)
  16236 }
  16237 
  16238 // C documentation
  16239 //
  16240 //	// Validates the VP8X header and skips over it.
  16241 //	// Returns VP8_STATUS_BITSTREAM_ERROR for invalid VP8X header,
  16242 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16243 //	//         VP8_STATUS_OK otherwise.
  16244 //	// If a VP8X chunk is found, found_vp8x is set to true and *width_ptr,
  16245 //	// *height_ptr and *flags_ptr are set to the corresponding values extracted
  16246 //	// from the VP8X chunk.
  16247 func ParseVP8X(tls *libc.TLS, data3 uintptr, data_size uintptr, found_vp8x uintptr, width_ptr uintptr, height_ptr uintptr, flags_ptr uintptr) (r VP8StatusCode1) {
  16248 	var chunk_size, flags, vp8x_size, v2 uint32_t
  16249 	var height, width, v5, v8 int32
  16250 	var v1, v4, v7 uintptr
  16251 	_, _, _, _, _, _, _, _, _, _, _ = chunk_size, flags, height, vp8x_size, width, v1, v2, v4, v5, v7, v8
  16252 	vp8x_size = libc.Uint32FromInt32(libc.Int32FromInt32(CHUNK_HEADER_SIZE) + libc.Int32FromInt32(VP8X_CHUNK_SIZE))
  16253 	**(**int32)(__ccgo_up(found_vp8x)) = 0
  16254 	if **(**size_t)(__ccgo_up(data_size)) < uint64(CHUNK_HEADER_SIZE) {
  16255 		return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16256 	}
  16257 	if !(libc.Xmemcmp(tls, **(**uintptr)(__ccgo_up(data3)), __ccgo_ts+574, uint64(TAG_SIZE)) != 0) {
  16258 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(TAG_SIZE)
  16259 		v4 = v1
  16260 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16261 		goto _6
  16262 	_6:
  16263 		v7 = v1 + uintptr(2)
  16264 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16265 		goto _9
  16266 	_9:
  16267 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16268 		goto _3
  16269 	_3:
  16270 		chunk_size = v2
  16271 		if chunk_size != uint32(VP8X_CHUNK_SIZE) {
  16272 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Wrong chunk size.
  16273 		}
  16274 		// Verify if enough data is available to validate the VP8X chunk.
  16275 		if **(**size_t)(__ccgo_up(data_size)) < uint64(vp8x_size) {
  16276 			return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16277 		}
  16278 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(8)
  16279 		v4 = v1
  16280 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16281 		goto _15
  16282 	_15:
  16283 		v7 = v1 + uintptr(2)
  16284 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16285 		goto _18
  16286 	_18:
  16287 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16288 		goto _12
  16289 	_12:
  16290 		flags = v2
  16291 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(12)
  16292 		v4 = v1
  16293 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16294 		goto _24
  16295 	_24:
  16296 		v5 = v8 | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + 2)))<<int32(16)
  16297 		goto _21
  16298 	_21:
  16299 		width = int32(1) + v5
  16300 		v1 = **(**uintptr)(__ccgo_up(data3)) + uintptr(15)
  16301 		v4 = v1
  16302 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16303 		goto _30
  16304 	_30:
  16305 		v5 = v8 | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + 2)))<<int32(16)
  16306 		goto _27
  16307 	_27:
  16308 		height = int32(1) + v5
  16309 		if libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height) >= libc.Uint64FromUint64(1)<<libc.Int32FromInt32(32) {
  16310 			return int32(VP8_STATUS_BITSTREAM_ERROR) // image is too large
  16311 		}
  16312 		if flags_ptr != libc.UintptrFromInt32(0) {
  16313 			**(**uint32_t)(__ccgo_up(flags_ptr)) = flags
  16314 		}
  16315 		if width_ptr != libc.UintptrFromInt32(0) {
  16316 			**(**int32)(__ccgo_up(width_ptr)) = width
  16317 		}
  16318 		if height_ptr != libc.UintptrFromInt32(0) {
  16319 			**(**int32)(__ccgo_up(height_ptr)) = height
  16320 		}
  16321 		// Skip over VP8X header bytes.
  16322 		**(**uintptr)(__ccgo_up(data3)) += uintptr(vp8x_size)
  16323 		**(**size_t)(__ccgo_up(data_size)) -= uint64(vp8x_size)
  16324 		**(**int32)(__ccgo_up(found_vp8x)) = int32(1)
  16325 	}
  16326 	return int32(VP8_STATUS_OK)
  16327 }
  16328 
  16329 // C documentation
  16330 //
  16331 //	// Skips to the next VP8/VP8L chunk header in the data given the size of the
  16332 //	// RIFF chunk 'riff_size'.
  16333 //	// Returns VP8_STATUS_BITSTREAM_ERROR if any invalid chunk size is encountered,
  16334 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16335 //	//         VP8_STATUS_OK otherwise.
  16336 //	// If an alpha chunk is found, *alpha_data and *alpha_size are set
  16337 //	// appropriately.
  16338 func ParseOptionalChunks(tls *libc.TLS, data2 uintptr, data_size uintptr, riff_size size_t, alpha_data uintptr, alpha_size uintptr) (r VP8StatusCode1) {
  16339 	var buf, v1, v4, v7 uintptr
  16340 	var buf_size size_t
  16341 	var chunk_size, disk_chunk_size, total_size, v2 uint32_t
  16342 	var v5, v8 int32
  16343 	_, _, _, _, _, _, _, _, _, _, _ = buf, buf_size, chunk_size, disk_chunk_size, total_size, v1, v2, v4, v5, v7, v8
  16344 	total_size = libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE) + libc.Int32FromInt32(CHUNK_HEADER_SIZE) + libc.Int32FromInt32(VP8X_CHUNK_SIZE)) // data.
  16345 	buf = **(**uintptr)(__ccgo_up(data2))
  16346 	buf_size = **(**size_t)(__ccgo_up(data_size))
  16347 	**(**uintptr)(__ccgo_up(alpha_data)) = libc.UintptrFromInt32(0)
  16348 	**(**size_t)(__ccgo_up(alpha_size)) = uint64(0)
  16349 	for int32(1) != 0 { // chunk_size with padding
  16350 		**(**uintptr)(__ccgo_up(data2)) = buf
  16351 		**(**size_t)(__ccgo_up(data_size)) = buf_size
  16352 		if buf_size < uint64(CHUNK_HEADER_SIZE) { // Insufficient data.
  16353 			return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16354 		}
  16355 		v1 = buf + uintptr(TAG_SIZE)
  16356 		v4 = v1
  16357 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16358 		goto _6
  16359 	_6:
  16360 		v7 = v1 + uintptr(2)
  16361 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16362 		goto _9
  16363 	_9:
  16364 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16365 		goto _3
  16366 	_3:
  16367 		chunk_size = v2
  16368 		if chunk_size > ^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1) {
  16369 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not a valid chunk size.
  16370 		}
  16371 		// For odd-sized chunk-payload, there's one byte padding at the end.
  16372 		disk_chunk_size = (uint32(CHUNK_HEADER_SIZE) + chunk_size + uint32(1)) & ^libc.Uint32FromUint32(1)
  16373 		total_size = total_size + disk_chunk_size
  16374 		// Check that total bytes skipped so far does not exceed riff_size.
  16375 		if riff_size > uint64(0) && uint64(total_size) > riff_size {
  16376 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not a valid chunk size.
  16377 		}
  16378 		// Start of a (possibly incomplete) VP8/VP8L chunk implies that we have
  16379 		// parsed all the optional chunks.
  16380 		// Note: This check must occur before the check 'buf_size < disk_chunk_size'
  16381 		// below to allow incomplete VP8/VP8L chunks.
  16382 		if !(libc.Xmemcmp(tls, buf, __ccgo_ts+579, uint64(TAG_SIZE)) != 0) || !(libc.Xmemcmp(tls, buf, __ccgo_ts+584, uint64(TAG_SIZE)) != 0) {
  16383 			return int32(VP8_STATUS_OK)
  16384 		}
  16385 		if buf_size < uint64(disk_chunk_size) { // Insufficient data.
  16386 			return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16387 		}
  16388 		if !(libc.Xmemcmp(tls, buf, __ccgo_ts+589, uint64(TAG_SIZE)) != 0) { // A valid ALPH header.
  16389 			**(**uintptr)(__ccgo_up(alpha_data)) = buf + uintptr(CHUNK_HEADER_SIZE)
  16390 			**(**size_t)(__ccgo_up(alpha_size)) = uint64(chunk_size)
  16391 		}
  16392 		// We have a full and valid chunk; skip it.
  16393 		buf = buf + uintptr(disk_chunk_size)
  16394 		buf_size = buf_size - uint64(disk_chunk_size)
  16395 	}
  16396 	return r
  16397 }
  16398 
  16399 // C documentation
  16400 //
  16401 //	// Validates the VP8/VP8L Header ("VP8 nnnn" or "VP8L nnnn") and skips over it.
  16402 //	// Returns VP8_STATUS_BITSTREAM_ERROR for invalid (chunk larger than
  16403 //	//         riff_size) VP8/VP8L header,
  16404 //	//         VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
  16405 //	//         VP8_STATUS_OK otherwise.
  16406 //	// If a VP8/VP8L chunk is found, *chunk_size is set to the total number of bytes
  16407 //	// extracted from the VP8/VP8L chunk header.
  16408 //	// The flag '*is_lossless' is set to 1 in case of VP8L chunk / raw VP8L data.
  16409 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) {
  16410 	var data2, v1, v4, v7 uintptr
  16411 	var is_vp8, is_vp8l, v5, v8 int32
  16412 	var minimal_size, size, v2 uint32_t
  16413 	_, _, _, _, _, _, _, _, _, _, _ = data2, is_vp8, is_vp8l, minimal_size, size, v1, v2, v4, v5, v7, v8
  16414 	data2 = **(**uintptr)(__ccgo_up(data_ptr))
  16415 	is_vp8 = libc.BoolInt32(!(libc.Xmemcmp(tls, data2, __ccgo_ts+579, uint64(TAG_SIZE)) != 0))
  16416 	is_vp8l = libc.BoolInt32(!(libc.Xmemcmp(tls, data2, __ccgo_ts+584, uint64(TAG_SIZE)) != 0))
  16417 	minimal_size = libc.Uint32FromInt32(libc.Int32FromInt32(TAG_SIZE) + libc.Int32FromInt32(CHUNK_HEADER_SIZE)) // "WEBP" + "VP8 nnnn" OR
  16418 	// "WEBP" + "VP8Lnnnn"
  16419 	if **(**size_t)(__ccgo_up(data_size)) < uint64(CHUNK_HEADER_SIZE) {
  16420 		return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Insufficient data.
  16421 	}
  16422 	if is_vp8 != 0 || is_vp8l != 0 {
  16423 		v1 = data2 + uintptr(TAG_SIZE)
  16424 		v4 = v1
  16425 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v4 + 1)))<<int32(8)
  16426 		goto _6
  16427 	_6:
  16428 		v7 = v1 + uintptr(2)
  16429 		v8 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7)))<<libc.Int32FromInt32(0) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v7 + 1)))<<int32(8)
  16430 		goto _9
  16431 	_9:
  16432 		v2 = libc.Uint32FromInt32(v5) | libc.Uint32FromInt32(v8)<<libc.Int32FromInt32(16)
  16433 		goto _3
  16434 	_3:
  16435 		// Bitstream contains VP8/VP8L header.
  16436 		size = v2
  16437 		if riff_size >= uint64(minimal_size) && uint64(size) > riff_size-uint64(minimal_size) {
  16438 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Inconsistent size information.
  16439 		}
  16440 		if have_all_data != 0 && uint64(size) > **(**size_t)(__ccgo_up(data_size))-uint64(CHUNK_HEADER_SIZE) {
  16441 			return int32(VP8_STATUS_NOT_ENOUGH_DATA) // Truncated bitstream.
  16442 		}
  16443 		// Skip over CHUNK_HEADER_SIZE bytes from VP8/VP8L Header.
  16444 		**(**size_t)(__ccgo_up(chunk_size)) = uint64(size)
  16445 		**(**uintptr)(__ccgo_up(data_ptr)) += uintptr(CHUNK_HEADER_SIZE)
  16446 		**(**size_t)(__ccgo_up(data_size)) -= uint64(CHUNK_HEADER_SIZE)
  16447 		**(**int32)(__ccgo_up(is_lossless)) = is_vp8l
  16448 	} else {
  16449 		// Raw VP8/VP8L bitstream (no header).
  16450 		**(**int32)(__ccgo_up(is_lossless)) = VP8LCheckSignature(tls, data2, **(**size_t)(__ccgo_up(data_size)))
  16451 		**(**size_t)(__ccgo_up(chunk_size)) = **(**size_t)(__ccgo_up(data_size))
  16452 	}
  16453 	return int32(VP8_STATUS_OK)
  16454 }
  16455 
  16456 //------------------------------------------------------------------------------
  16457 
  16458 // C documentation
  16459 //
  16460 //	// Fetch '*width', '*height', '*has_alpha' and fill out 'headers' based on
  16461 //	// 'data'. All the output parameters may be NULL. If 'headers' is NULL only the
  16462 //	// minimal amount will be read to fetch the remaining parameters.
  16463 //	// If 'headers' is non-NULL this function will attempt to locate both alpha
  16464 //	// data (with or without a VP8X chunk) and the bitstream chunk (VP8/VP8L).
  16465 //	// Note: The following chunk sequences (before the raw VP8/VP8L data) are
  16466 //	// considered valid by this function:
  16467 //	// RIFF + VP8(L)
  16468 //	// RIFF + VP8X + (optional chunks) + VP8(L)
  16469 //	// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
  16470 //	// VP8(L)     <-- Not a valid WebP format: only allowed for internal purpose.
  16471 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) {
  16472 	bp := tls.Alloc(128)
  16473 	defer tls.Free(128)
  16474 	*(*uintptr)(unsafe.Pointer(bp)) = _data
  16475 	*(*size_t)(unsafe.Pointer(bp + 8)) = _data_size
  16476 	var animation_present, found_riff, have_all_data, v1 int32
  16477 	var status VP8StatusCode1
  16478 	var _ /* canvas_height at bp+20 */ int32
  16479 	var _ /* canvas_width at bp+16 */ int32
  16480 	var _ /* flags at bp+112 */ uint32_t
  16481 	var _ /* found_vp8x at bp+32 */ int32
  16482 	var _ /* hdrs at bp+40 */ WebPHeaderStructure
  16483 	var _ /* image_height at bp+28 */ int32
  16484 	var _ /* image_width at bp+24 */ int32
  16485 	_, _, _, _, _ = animation_present, found_riff, have_all_data, status, v1
  16486 	**(**int32)(__ccgo_up(bp + 16)) = 0
  16487 	**(**int32)(__ccgo_up(bp + 20)) = 0
  16488 	**(**int32)(__ccgo_up(bp + 24)) = 0
  16489 	**(**int32)(__ccgo_up(bp + 28)) = 0
  16490 	found_riff = 0
  16491 	**(**int32)(__ccgo_up(bp + 32)) = 0
  16492 	animation_present = 0
  16493 	if headers != libc.UintptrFromInt32(0) {
  16494 		v1 = (*WebPHeaderStructure)(unsafe.Pointer(headers)).Fhave_all_data
  16495 	} else {
  16496 		v1 = 0
  16497 	}
  16498 	have_all_data = v1
  16499 	if **(**uintptr)(__ccgo_up(bp)) == libc.UintptrFromInt32(0) || **(**size_t)(__ccgo_up(bp + 8)) < uint64(RIFF_HEADER_SIZE) {
  16500 		return int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16501 	}
  16502 	libc.X__builtin___memset_chk(tls, bp+40, 0, uint64(72), ^__predefined_size_t(0))
  16503 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fdata = **(**uintptr)(__ccgo_up(bp))
  16504 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fdata_size = **(**size_t)(__ccgo_up(bp + 8))
  16505 	// Skip over RIFF header.
  16506 	status = ParseRIFF(tls, bp, bp+8, have_all_data, bp+40+56)
  16507 	if status != int32(VP8_STATUS_OK) {
  16508 		return status // Wrong RIFF header / insufficient data.
  16509 	}
  16510 	found_riff = libc.BoolInt32((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size > uint64(0))
  16511 	// Skip over VP8X.
  16512 	**(**uint32_t)(__ccgo_up(bp + 112)) = uint32(0)
  16513 	status = ParseVP8X(tls, bp, bp+8, bp+32, bp+16, bp+20, bp+112)
  16514 	if status != int32(VP8_STATUS_OK) {
  16515 		return status // Wrong VP8X / insufficient data.
  16516 	}
  16517 	animation_present = libc.BoolInt32(!!(**(**uint32_t)(__ccgo_up(bp + 112))&uint32(ANIMATION_FLAG) != 0))
  16518 	if !(found_riff != 0) && **(**int32)(__ccgo_up(bp + 32)) != 0 {
  16519 		// Note: This restriction may be removed in the future, if it becomes
  16520 		// necessary to send VP8X chunk to the decoder.
  16521 		return int32(VP8_STATUS_BITSTREAM_ERROR)
  16522 	}
  16523 	if has_alpha != libc.UintptrFromInt32(0) {
  16524 		**(**int32)(__ccgo_up(has_alpha)) = libc.BoolInt32(!!(**(**uint32_t)(__ccgo_up(bp + 112))&uint32(ALPHA_FLAG) != 0))
  16525 	}
  16526 	if has_animation != libc.UintptrFromInt32(0) {
  16527 		**(**int32)(__ccgo_up(has_animation)) = animation_present
  16528 	}
  16529 	if format != libc.UintptrFromInt32(0) {
  16530 		**(**int32)(__ccgo_up(format)) = 0
  16531 	} // default = undefined
  16532 	**(**int32)(__ccgo_up(bp + 24)) = **(**int32)(__ccgo_up(bp + 16))
  16533 	**(**int32)(__ccgo_up(bp + 28)) = **(**int32)(__ccgo_up(bp + 20))
  16534 	if **(**int32)(__ccgo_up(bp + 32)) != 0 && animation_present != 0 && headers == libc.UintptrFromInt32(0) {
  16535 		status = int32(VP8_STATUS_OK)
  16536 		goto ReturnWidthHeight // Just return features from VP8X header.
  16537 	}
  16538 	if **(**size_t)(__ccgo_up(bp + 8)) < uint64(TAG_SIZE) {
  16539 		status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16540 		goto ReturnWidthHeight
  16541 	}
  16542 	// Skip over optional chunks if data started with "RIFF + VP8X" or "ALPH".
  16543 	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) {
  16544 		status = ParseOptionalChunks(tls, bp, bp+8, (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size, bp+40+32, bp+40+40)
  16545 		if status != int32(VP8_STATUS_OK) {
  16546 			goto ReturnWidthHeight // Invalid chunk size / insufficient data.
  16547 		}
  16548 	}
  16549 	// Skip over VP8/VP8L header.
  16550 	status = ParseVP8Header(tls, bp, bp+8, have_all_data, (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Friff_size, bp+40+48, bp+40+64)
  16551 	if status != int32(VP8_STATUS_OK) {
  16552 		goto ReturnWidthHeight // Wrong VP8/VP8L chunk-header / insufficient data.
  16553 	}
  16554 	if (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fcompressed_size > uint64(^libc.Uint32FromUint32(0)-libc.Uint32FromInt32(CHUNK_HEADER_SIZE)-libc.Uint32FromInt32(1)) {
  16555 		return int32(VP8_STATUS_BITSTREAM_ERROR)
  16556 	}
  16557 	if format != libc.UintptrFromInt32(0) && !(animation_present != 0) {
  16558 		if (**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fis_lossless != 0 {
  16559 			v1 = int32(2)
  16560 		} else {
  16561 			v1 = int32(1)
  16562 		}
  16563 		**(**int32)(__ccgo_up(format)) = v1
  16564 	}
  16565 	if !((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Fis_lossless != 0) {
  16566 		if **(**size_t)(__ccgo_up(bp + 8)) < uint64(VP8_FRAME_HEADER_SIZE) {
  16567 			status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16568 			goto ReturnWidthHeight
  16569 		}
  16570 		// Validates raw VP8 data.
  16571 		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) {
  16572 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16573 		}
  16574 	} else {
  16575 		if **(**size_t)(__ccgo_up(bp + 8)) < uint64(VP8L_FRAME_HEADER_SIZE) {
  16576 			status = int32(VP8_STATUS_NOT_ENOUGH_DATA)
  16577 			goto ReturnWidthHeight
  16578 		}
  16579 		// Validates raw VP8L data.
  16580 		if !(VP8LGetInfo(tls, **(**uintptr)(__ccgo_up(bp)), **(**size_t)(__ccgo_up(bp + 8)), bp+24, bp+28, has_alpha) != 0) {
  16581 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16582 		}
  16583 	}
  16584 	// Validates image size coherency.
  16585 	if **(**int32)(__ccgo_up(bp + 32)) != 0 {
  16586 		if **(**int32)(__ccgo_up(bp + 16)) != **(**int32)(__ccgo_up(bp + 24)) || **(**int32)(__ccgo_up(bp + 20)) != **(**int32)(__ccgo_up(bp + 28)) {
  16587 			return int32(VP8_STATUS_BITSTREAM_ERROR)
  16588 		}
  16589 	}
  16590 	if headers != libc.UintptrFromInt32(0) {
  16591 		**(**WebPHeaderStructure)(__ccgo_up(headers)) = **(**WebPHeaderStructure)(__ccgo_up(bp + 40))
  16592 		(*WebPHeaderStructure)(unsafe.Pointer(headers)).Foffset = libc.Uint64FromInt64(int64(**(**uintptr)(__ccgo_up(bp))) - int64((*WebPHeaderStructure)(unsafe.Pointer(headers)).Fdata))
  16593 	}
  16594 	goto ReturnWidthHeight
  16595 ReturnWidthHeight:
  16596 	;
  16597 	if status == int32(VP8_STATUS_OK) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) && **(**int32)(__ccgo_up(bp + 32)) != 0 && headers == libc.UintptrFromInt32(0) {
  16598 		if has_alpha != libc.UintptrFromInt32(0) {
  16599 			// If the data did not contain a VP8X/VP8L chunk the only definitive way
  16600 			// to set this is by looking for alpha data (from an ALPH chunk).
  16601 			**(**int32)(__ccgo_up(has_alpha)) |= libc.BoolInt32((**(**WebPHeaderStructure)(__ccgo_up(bp + 40))).Falpha_data != libc.UintptrFromInt32(0))
  16602 		}
  16603 		if width != libc.UintptrFromInt32(0) {
  16604 			**(**int32)(__ccgo_up(width)) = **(**int32)(__ccgo_up(bp + 24))
  16605 		}
  16606 		if height != libc.UintptrFromInt32(0) {
  16607 			**(**int32)(__ccgo_up(height)) = **(**int32)(__ccgo_up(bp + 28))
  16608 		}
  16609 		return int32(VP8_STATUS_OK)
  16610 	} else {
  16611 		return status
  16612 	}
  16613 	return r
  16614 }
  16615 
  16616 func WebPParseHeaders(tls *libc.TLS, headers uintptr) (r VP8StatusCode1) {
  16617 	bp := tls.Alloc(16)
  16618 	defer tls.Free(16)
  16619 	var status VP8StatusCode1
  16620 	var _ /* has_animation at bp+0 */ int32
  16621 	_ = status
  16622 	**(**int32)(__ccgo_up(bp)) = 0
  16623 	// fill out headers, ignore width/height/has_alpha.
  16624 	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)
  16625 	if status == int32(VP8_STATUS_OK) || status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
  16626 		// The WebPDemux API + libwebp can be used to decode individual
  16627 		// uncomposited frames or the WebPAnimDecoder can be used to fully
  16628 		// reconstruct them (see webp/demux.h).
  16629 		if **(**int32)(__ccgo_up(bp)) != 0 {
  16630 			status = int32(VP8_STATUS_UNSUPPORTED_FEATURE)
  16631 		}
  16632 	}
  16633 	return status
  16634 }
  16635 
  16636 //------------------------------------------------------------------------------
  16637 // WebPDecParams
  16638 
  16639 func WebPResetDecParams(tls *libc.TLS, params uintptr) {
  16640 	if params != libc.UintptrFromInt32(0) {
  16641 		libc.X__builtin___memset_chk(tls, params, 0, uint64(112), ^__predefined_size_t(0))
  16642 	}
  16643 }
  16644 
  16645 //------------------------------------------------------------------------------
  16646 // "Into" decoding variants
  16647 
  16648 // C documentation
  16649 //
  16650 //	// Main flow
  16651 func DecodeInto(tls *libc.TLS, data uintptr, data_size size_t, params uintptr) (r VP8StatusCode1) {
  16652 	bp := tls.Alloc(240)
  16653 	defer tls.Free(240)
  16654 	var dec, dec1 uintptr
  16655 	var status VP8StatusCode1
  16656 	var v1 int32
  16657 	var _ /* headers at bp+160 */ WebPHeaderStructure
  16658 	var _ /* io at bp+0 */ VP8Io
  16659 	_, _, _, _ = dec, dec1, status, v1
  16660 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata = data
  16661 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata_size = data_size
  16662 	(**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fhave_all_data = int32(1)
  16663 	status = WebPParseHeaders(tls, bp+160) // Process Pre-VP8 chunks.
  16664 	if status != int32(VP8_STATUS_OK) {
  16665 		return status
  16666 	}
  16667 	v1 = VP8InitIoInternal(tls, bp, int32(WEBP_DECODER_ABI_VERSION))
  16668 	goto _2
  16669 _2:
  16670 	if !(v1 != 0) {
  16671 		return int32(VP8_STATUS_INVALID_PARAM)
  16672 	}
  16673 	(**(**VP8Io)(__ccgo_up(bp))).Fdata = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata + uintptr((**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Foffset)
  16674 	(**(**VP8Io)(__ccgo_up(bp))).Fdata_size = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fdata_size - (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Foffset
  16675 	WebPInitCustomIo(tls, params, bp) // Plug the I/O functions.
  16676 	if !((**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Fis_lossless != 0) {
  16677 		dec = VP8New(tls)
  16678 		if dec == libc.UintptrFromInt32(0) {
  16679 			return int32(VP8_STATUS_OUT_OF_MEMORY)
  16680 		}
  16681 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Falpha_data
  16682 		(*VP8Decoder)(unsafe.Pointer(dec)).Falpha_data_size = (**(**WebPHeaderStructure)(__ccgo_up(bp + 160))).Falpha_data_size
  16683 		// Decode bitstream header, update io->width/io->height.
  16684 		if !(VP8GetHeaders(tls, dec, bp) != 0) {
  16685 			status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus // An error occurred. Grab error status.
  16686 		} else {
  16687 			// Allocate/check output buffers.
  16688 			status = WebPAllocateDecBuffer(tls, (**(**VP8Io)(__ccgo_up(bp))).Fwidth, (**(**VP8Io)(__ccgo_up(bp))).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16689 			if status == int32(VP8_STATUS_OK) { // Decode
  16690 				// This change must be done before calling VP8Decode()
  16691 				(*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)
  16692 				VP8InitDithering(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, dec)
  16693 				if !(VP8Decode(tls, dec, bp) != 0) {
  16694 					status = (*VP8Decoder)(unsafe.Pointer(dec)).Fstatus
  16695 				}
  16696 			}
  16697 		}
  16698 		VP8Delete(tls, dec)
  16699 	} else {
  16700 		dec1 = VP8LNew(tls)
  16701 		if dec1 == libc.UintptrFromInt32(0) {
  16702 			return int32(VP8_STATUS_OUT_OF_MEMORY)
  16703 		}
  16704 		if !(VP8LDecodeHeader(tls, dec1, bp) != 0) {
  16705 			status = (*VP8LDecoder)(unsafe.Pointer(dec1)).Fstatus // An error occurred. Grab error status.
  16706 		} else {
  16707 			// Allocate/check output buffers.
  16708 			status = WebPAllocateDecBuffer(tls, (**(**VP8Io)(__ccgo_up(bp))).Fwidth, (**(**VP8Io)(__ccgo_up(bp))).Fheight, (*WebPDecParams)(unsafe.Pointer(params)).Foptions, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16709 			if status == int32(VP8_STATUS_OK) { // Decode
  16710 				if !(VP8LDecodeImage(tls, dec1) != 0) {
  16711 					status = (*VP8LDecoder)(unsafe.Pointer(dec1)).Fstatus
  16712 				}
  16713 			}
  16714 		}
  16715 		VP8LDelete(tls, dec1)
  16716 	}
  16717 	if status != int32(VP8_STATUS_OK) {
  16718 		WebPFreeDecBuffer(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16719 	} else {
  16720 		if (*WebPDecParams)(unsafe.Pointer(params)).Foptions != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer((*WebPDecParams)(unsafe.Pointer(params)).Foptions)).Fflip != 0 {
  16721 			// This restores the original stride values if options->flip was used
  16722 			// during the call to WebPAllocateDecBuffer above.
  16723 			status = WebPFlipBuffer(tls, (*WebPDecParams)(unsafe.Pointer(params)).Foutput)
  16724 		}
  16725 	}
  16726 	return status
  16727 }
  16728 
  16729 // C documentation
  16730 //
  16731 //	// Helpers
  16732 func DecodeIntoRGBABuffer(tls *libc.TLS, colorspace WEBP_CSP_MODE1, data uintptr, data_size size_t, rgba uintptr, stride int32, size size_t) (r uintptr) {
  16733 	bp := tls.Alloc(240)
  16734 	defer tls.Free(240)
  16735 	var v1 int32
  16736 	var v3 bool
  16737 	var _ /* buf at bp+112 */ WebPDecBuffer
  16738 	var _ /* params at bp+0 */ WebPDecParams
  16739 	_, _ = v1, v3
  16740 	if v3 = rgba == libc.UintptrFromInt32(0); !v3 {
  16741 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16742 		goto _2
  16743 	_2:
  16744 	}
  16745 	if v3 || !(v1 != 0) {
  16746 		return libc.UintptrFromInt32(0)
  16747 	}
  16748 	WebPResetDecParams(tls, bp)
  16749 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16750 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = colorspace
  16751 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = rgba
  16752 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 8)) = stride
  16753 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 16)) = size
  16754 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fis_external_memory = int32(1)
  16755 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16756 		return libc.UintptrFromInt32(0)
  16757 	}
  16758 	return rgba
  16759 }
  16760 
  16761 func WebPDecodeRGBInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16762 	return DecodeIntoRGBABuffer(tls, int32(MODE_RGB), data, data_size, output, stride, size)
  16763 }
  16764 
  16765 func WebPDecodeRGBAInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16766 	return DecodeIntoRGBABuffer(tls, int32(MODE_RGBA), data, data_size, output, stride, size)
  16767 }
  16768 
  16769 func WebPDecodeARGBInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16770 	return DecodeIntoRGBABuffer(tls, int32(MODE_ARGB), data, data_size, output, stride, size)
  16771 }
  16772 
  16773 func WebPDecodeBGRInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16774 	return DecodeIntoRGBABuffer(tls, int32(MODE_BGR), data, data_size, output, stride, size)
  16775 }
  16776 
  16777 func WebPDecodeBGRAInto(tls *libc.TLS, data uintptr, data_size size_t, output uintptr, size size_t, stride int32) (r uintptr) {
  16778 	return DecodeIntoRGBABuffer(tls, int32(MODE_BGRA), data, data_size, output, stride, size)
  16779 }
  16780 
  16781 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) {
  16782 	bp := tls.Alloc(240)
  16783 	defer tls.Free(240)
  16784 	var v1 int32
  16785 	var v3 bool
  16786 	var _ /* output at bp+112 */ WebPDecBuffer
  16787 	var _ /* params at bp+0 */ WebPDecParams
  16788 	_, _ = v1, v3
  16789 	if v3 = luma == libc.UintptrFromInt32(0); !v3 {
  16790 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16791 		goto _2
  16792 	_2:
  16793 	}
  16794 	if v3 || !(v1 != 0) {
  16795 		return libc.UintptrFromInt32(0)
  16796 	}
  16797 	WebPResetDecParams(tls, bp)
  16798 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16799 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = int32(MODE_YUV)
  16800 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = luma
  16801 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 32)) = luma_stride
  16802 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 48)) = luma_size
  16803 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16 + 8)) = u
  16804 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 36)) = u_stride
  16805 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 56)) = u_size
  16806 	*(*uintptr)(unsafe.Pointer(bp + 112 + 16 + 16)) = v
  16807 	*(*int32)(unsafe.Pointer(bp + 112 + 16 + 40)) = v_stride
  16808 	*(*size_t)(unsafe.Pointer(bp + 112 + 16 + 64)) = v_size
  16809 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fis_external_memory = int32(1)
  16810 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16811 		return libc.UintptrFromInt32(0)
  16812 	}
  16813 	return luma
  16814 }
  16815 
  16816 // ------------------------------------------------------------------------------
  16817 func Decode(tls *libc.TLS, mode1 WEBP_CSP_MODE1, data uintptr, data_size size_t, width uintptr, height uintptr, keep_info uintptr) (r uintptr) {
  16818 	bp := tls.Alloc(240)
  16819 	defer tls.Free(240)
  16820 	var v1 int32
  16821 	var v3 uintptr
  16822 	var _ /* output at bp+112 */ WebPDecBuffer
  16823 	var _ /* params at bp+0 */ WebPDecParams
  16824 	_, _ = v1, v3
  16825 	v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  16826 	goto _2
  16827 _2:
  16828 	if !(v1 != 0) {
  16829 		return libc.UintptrFromInt32(0)
  16830 	}
  16831 	WebPResetDecParams(tls, bp)
  16832 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  16833 	(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = mode1
  16834 	// Retrieve (and report back) the required dimensions from bitstream.
  16835 	if !(WebPGetInfo(tls, data, data_size, bp+112+4, bp+112+8) != 0) {
  16836 		return libc.UintptrFromInt32(0)
  16837 	}
  16838 	if width != libc.UintptrFromInt32(0) {
  16839 		**(**int32)(__ccgo_up(width)) = (**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fwidth
  16840 	}
  16841 	if height != libc.UintptrFromInt32(0) {
  16842 		**(**int32)(__ccgo_up(height)) = (**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fheight
  16843 	}
  16844 	// Decode
  16845 	if DecodeInto(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16846 		return libc.UintptrFromInt32(0)
  16847 	}
  16848 	if keep_info != libc.UintptrFromInt32(0) { // keep track of the side-info
  16849 		WebPCopyDecBuffer(tls, bp+112, keep_info)
  16850 	}
  16851 	// return decoded samples (don't clear 'output'!)
  16852 	v1 = libc.BoolInt32(mode1 < int32(MODE_YUV))
  16853 	goto _5
  16854 _5:
  16855 	if v1 != 0 {
  16856 		v3 = *(*uintptr)(unsafe.Pointer(bp + 112 + 16))
  16857 	} else {
  16858 		v3 = *(*uintptr)(unsafe.Pointer(bp + 112 + 16))
  16859 	}
  16860 	return v3
  16861 }
  16862 
  16863 func WebPDecodeRGB(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16864 	return Decode(tls, int32(MODE_RGB), data, data_size, width, height, libc.UintptrFromInt32(0))
  16865 }
  16866 
  16867 func WebPDecodeRGBA(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16868 	return Decode(tls, int32(MODE_RGBA), data, data_size, width, height, libc.UintptrFromInt32(0))
  16869 }
  16870 
  16871 func WebPDecodeARGB(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16872 	return Decode(tls, int32(MODE_ARGB), data, data_size, width, height, libc.UintptrFromInt32(0))
  16873 }
  16874 
  16875 func WebPDecodeBGR(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16876 	return Decode(tls, int32(MODE_BGR), data, data_size, width, height, libc.UintptrFromInt32(0))
  16877 }
  16878 
  16879 func WebPDecodeBGRA(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r uintptr) {
  16880 	return Decode(tls, int32(MODE_BGRA), data, data_size, width, height, libc.UintptrFromInt32(0))
  16881 }
  16882 
  16883 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) {
  16884 	bp := tls.Alloc(128)
  16885 	defer tls.Free(128)
  16886 	var buf, out uintptr
  16887 	var _ /* output at bp+0 */ WebPDecBuffer
  16888 	_, _ = buf, out
  16889 	// data, width and height are checked by Decode().
  16890 	if u == libc.UintptrFromInt32(0) || v == libc.UintptrFromInt32(0) || stride == libc.UintptrFromInt32(0) || uv_stride == libc.UintptrFromInt32(0) {
  16891 		return libc.UintptrFromInt32(0)
  16892 	}
  16893 	// only to preserve the side-infos
  16894 	out = Decode(tls, int32(MODE_YUV), data, data_size, width, height, bp)
  16895 	if out != libc.UintptrFromInt32(0) {
  16896 		buf = bp + 16
  16897 		**(**uintptr)(__ccgo_up(u)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu
  16898 		**(**uintptr)(__ccgo_up(v)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fv
  16899 		**(**int32)(__ccgo_up(stride)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fy_stride
  16900 		**(**int32)(__ccgo_up(uv_stride)) = (*WebPYUVABuffer)(unsafe.Pointer(buf)).Fu_stride
  16901 	}
  16902 	return out
  16903 	return r
  16904 }
  16905 
  16906 func DefaultFeatures(tls *libc.TLS, features uintptr) {
  16907 	libc.X__builtin___memset_chk(tls, features, 0, uint64(40), ^__predefined_size_t(0))
  16908 }
  16909 
  16910 func GetFeatures(tls *libc.TLS, data uintptr, data_size size_t, features uintptr) (r VP8StatusCode1) {
  16911 	if features == libc.UintptrFromInt32(0) || data == libc.UintptrFromInt32(0) {
  16912 		return int32(VP8_STATUS_INVALID_PARAM)
  16913 	}
  16914 	DefaultFeatures(tls, features)
  16915 	// Only parse enough of the data to retrieve the features.
  16916 	return ParseHeadersInternal(tls, data, data_size, features, features+4, features+8, features+12, features+16, libc.UintptrFromInt32(0))
  16917 }
  16918 
  16919 //------------------------------------------------------------------------------
  16920 // WebPGetInfo()
  16921 
  16922 func WebPGetInfo(tls *libc.TLS, data uintptr, data_size size_t, width uintptr, height uintptr) (r int32) {
  16923 	bp := tls.Alloc(48)
  16924 	defer tls.Free(48)
  16925 	var _ /* features at bp+0 */ WebPBitstreamFeatures
  16926 	if GetFeatures(tls, data, data_size, bp) != int32(VP8_STATUS_OK) {
  16927 		return 0
  16928 	}
  16929 	if width != libc.UintptrFromInt32(0) {
  16930 		**(**int32)(__ccgo_up(width)) = (**(**WebPBitstreamFeatures)(__ccgo_up(bp))).Fwidth
  16931 	}
  16932 	if height != libc.UintptrFromInt32(0) {
  16933 		**(**int32)(__ccgo_up(height)) = (**(**WebPBitstreamFeatures)(__ccgo_up(bp))).Fheight
  16934 	}
  16935 	return int32(1)
  16936 }
  16937 
  16938 //------------------------------------------------------------------------------
  16939 // Advance decoding API
  16940 
  16941 func WebPInitDecoderConfigInternal(tls *libc.TLS, config uintptr, version int32) (r int32) {
  16942 	var v1 int32
  16943 	_ = v1
  16944 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  16945 		return 0 // version mismatch
  16946 	}
  16947 	if config == libc.UintptrFromInt32(0) {
  16948 		return 0
  16949 	}
  16950 	libc.X__builtin___memset_chk(tls, config, 0, uint64(240), ^__predefined_size_t(0))
  16951 	DefaultFeatures(tls, config)
  16952 	v1 = WebPInitDecBufferInternal(tls, config+40, int32(WEBP_DECODER_ABI_VERSION))
  16953 	goto _2
  16954 _2:
  16955 	if !(v1 != 0) {
  16956 		return 0
  16957 	}
  16958 	return int32(1)
  16959 }
  16960 
  16961 func WebPCheckCropDimensionsBasic(tls *libc.TLS, x int32, y int32, w int32, h int32) (r int32) {
  16962 	return libc.BoolInt32(!(x < 0 || y < 0 || w <= 0 || h <= 0))
  16963 }
  16964 
  16965 func WebPValidateDecoderConfig(tls *libc.TLS, config uintptr) (r int32) {
  16966 	bp := tls.Alloc(16)
  16967 	defer tls.Free(16)
  16968 	var options uintptr
  16969 	var _ /* scaled_height at bp+4 */ int32
  16970 	var _ /* scaled_width at bp+0 */ int32
  16971 	_ = options
  16972 	if config == libc.UintptrFromInt32(0) {
  16973 		return 0
  16974 	}
  16975 	if !(IsValidColorspace(tls, (*WebPDecoderConfig)(unsafe.Pointer(config)).Foutput.Fcolorspace) != 0) {
  16976 		return 0
  16977 	}
  16978 	options = config + 160
  16979 	// bypass_filtering, no_fancy_upsampling, use_cropping, use_scaling,
  16980 	// use_threads, flip can be any integer and are interpreted as boolean.
  16981 	// Check for cropping.
  16982 	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) {
  16983 		return 0
  16984 	}
  16985 	// Check for scaling.
  16986 	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) {
  16987 		return 0
  16988 	}
  16989 	// In case the WebPBitstreamFeatures has been filled in, check further.
  16990 	if (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth > 0 || (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight > 0 {
  16991 		**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
  16992 		**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
  16993 		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) {
  16994 			return 0
  16995 		}
  16996 		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) {
  16997 			return 0
  16998 		}
  16999 	}
  17000 	// Check for dithering.
  17001 	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) {
  17002 		return 0
  17003 	}
  17004 	return int32(1)
  17005 }
  17006 
  17007 func WebPGetFeaturesInternal(tls *libc.TLS, data uintptr, data_size size_t, features uintptr, version int32) (r VP8StatusCode1) {
  17008 	if version>>int32(8) != libc.Int32FromInt32(WEBP_DECODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  17009 		return int32(VP8_STATUS_INVALID_PARAM) // version mismatch
  17010 	}
  17011 	if features == libc.UintptrFromInt32(0) {
  17012 		return int32(VP8_STATUS_INVALID_PARAM)
  17013 	}
  17014 	return GetFeatures(tls, data, data_size, features)
  17015 }
  17016 
  17017 func WebPDecode(tls *libc.TLS, data uintptr, data_size size_t, config uintptr) (r VP8StatusCode1) {
  17018 	bp := tls.Alloc(240)
  17019 	defer tls.Free(240)
  17020 	var status VP8StatusCode1
  17021 	var v1 int32
  17022 	var _ /* in_mem_buffer at bp+112 */ WebPDecBuffer
  17023 	var _ /* params at bp+0 */ WebPDecParams
  17024 	_, _ = status, v1
  17025 	if config == libc.UintptrFromInt32(0) {
  17026 		return int32(VP8_STATUS_INVALID_PARAM)
  17027 	}
  17028 	status = GetFeatures(tls, data, data_size, config)
  17029 	if status != int32(VP8_STATUS_OK) {
  17030 		if status == int32(VP8_STATUS_NOT_ENOUGH_DATA) {
  17031 			return int32(VP8_STATUS_BITSTREAM_ERROR) // Not-enough-data treated as error.
  17032 		}
  17033 		return status
  17034 	}
  17035 	WebPResetDecParams(tls, bp)
  17036 	(**(**WebPDecParams)(__ccgo_up(bp))).Foptions = config + 160
  17037 	(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = config + 40
  17038 	if WebPAvoidSlowMemory(tls, (**(**WebPDecParams)(__ccgo_up(bp))).Foutput, config) != 0 {
  17039 		v1 = WebPInitDecBufferInternal(tls, bp+112, int32(WEBP_DECODER_ABI_VERSION))
  17040 		goto _2
  17041 	_2:
  17042 		if !(v1 != 0) {
  17043 			return int32(VP8_STATUS_INVALID_PARAM)
  17044 		}
  17045 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fcolorspace = (*WebPDecoderConfig)(unsafe.Pointer(config)).Foutput.Fcolorspace
  17046 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fwidth = (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fwidth
  17047 		(**(**WebPDecBuffer)(__ccgo_up(bp + 112))).Fheight = (*WebPDecoderConfig)(unsafe.Pointer(config)).Finput.Fheight
  17048 		(**(**WebPDecParams)(__ccgo_up(bp))).Foutput = bp + 112
  17049 		status = DecodeInto(tls, data, data_size, bp)
  17050 		if status == int32(VP8_STATUS_OK) { // do the slow-copy
  17051 			status = WebPCopyDecBufferPixels(tls, bp+112, config+40)
  17052 		}
  17053 		WebPFreeDecBuffer(tls, bp+112)
  17054 	} else {
  17055 		status = DecodeInto(tls, data, data_size, bp)
  17056 	}
  17057 	return status
  17058 }
  17059 
  17060 //------------------------------------------------------------------------------
  17061 // Cropping and rescaling.
  17062 
  17063 func WebPCheckCropDimensions(tls *libc.TLS, image_width int32, image_height int32, x int32, y int32, w int32, h int32) (r int32) {
  17064 	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))
  17065 }
  17066 
  17067 func WebPIoInitFromOptions(tls *libc.TLS, options uintptr, io uintptr, src_colorspace WEBP_CSP_MODE1) (r int32) {
  17068 	bp := tls.Alloc(16)
  17069 	defer tls.Free(16)
  17070 	var H, W, h, w, x, y, v1 int32
  17071 	var _ /* scaled_height at bp+4 */ int32
  17072 	var _ /* scaled_width at bp+0 */ int32
  17073 	_, _, _, _, _, _, _ = H, W, h, w, x, y, v1
  17074 	W = (*VP8Io)(unsafe.Pointer(io)).Fwidth
  17075 	H = (*VP8Io)(unsafe.Pointer(io)).Fheight
  17076 	x = 0
  17077 	y = 0
  17078 	w = W
  17079 	h = H
  17080 	// Cropping
  17081 	(*VP8Io)(unsafe.Pointer(io)).Fuse_cropping = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_cropping != 0)
  17082 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_cropping != 0 {
  17083 		w = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_width
  17084 		h = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_height
  17085 		x = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_left
  17086 		y = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fcrop_top
  17087 		v1 = libc.BoolInt32(src_colorspace < int32(MODE_YUV))
  17088 		goto _2
  17089 	_2:
  17090 		if !(v1 != 0) { // only snap for YUV420
  17091 			x = x & ^libc.Int32FromInt32(1)
  17092 			y = y & ^libc.Int32FromInt32(1)
  17093 		}
  17094 		if !(WebPCheckCropDimensions(tls, W, H, x, y, w, h) != 0) {
  17095 			return 0 // out of frame boundary error
  17096 		}
  17097 	}
  17098 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_left = x
  17099 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_top = y
  17100 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_right = x + w
  17101 	(*VP8Io)(unsafe.Pointer(io)).Fcrop_bottom = y + h
  17102 	(*VP8Io)(unsafe.Pointer(io)).Fmb_w = w
  17103 	(*VP8Io)(unsafe.Pointer(io)).Fmb_h = h
  17104 	// Scaling
  17105 	(*VP8Io)(unsafe.Pointer(io)).Fuse_scaling = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fuse_scaling != 0)
  17106 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  17107 		**(**int32)(__ccgo_up(bp)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_width
  17108 		**(**int32)(__ccgo_up(bp + 4)) = (*WebPDecoderOptions)(unsafe.Pointer(options)).Fscaled_height
  17109 		if !(WebPRescalerGetScaledDimensions(tls, w, h, bp, bp+4) != 0) {
  17110 			return 0
  17111 		}
  17112 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_width = **(**int32)(__ccgo_up(bp))
  17113 		(*VP8Io)(unsafe.Pointer(io)).Fscaled_height = **(**int32)(__ccgo_up(bp + 4))
  17114 	}
  17115 	// Filter
  17116 	(*VP8Io)(unsafe.Pointer(io)).Fbypass_filtering = libc.BoolInt32(options != libc.UintptrFromInt32(0) && (*WebPDecoderOptions)(unsafe.Pointer(options)).Fbypass_filtering != 0)
  17117 	// Fancy upsampler
  17118 	(*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling = libc.BoolInt32(options == libc.UintptrFromInt32(0) || !((*WebPDecoderOptions)(unsafe.Pointer(options)).Fno_fancy_upsampling != 0))
  17119 	if (*VP8Io)(unsafe.Pointer(io)).Fuse_scaling != 0 {
  17120 		// disable filter (only for large downscaling ratio).
  17121 		**(**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))
  17122 		(*VP8Io)(unsafe.Pointer(io)).Ffancy_upsampling = 0
  17123 	}
  17124 	return int32(1)
  17125 }
  17126 
  17127 const ENC_MAJ_VERSION = 1
  17128 const ENC_MIN_VERSION = 6
  17129 const ENC_REV_VERSION = 0
  17130 const ERROR_DIFFUSION_QUALITY = 98
  17131 const HASH_BITS = 18
  17132 const MAX_COLOR_CACHE_BITS = 10
  17133 const MAX_LENGTH_BITS = 12
  17134 const MAX_REFS_BLOCK_PER_IMAGE = 16
  17135 const QFIX = 17
  17136 const U_OFF_ENC = 16
  17137 const VP8L_WRITER_BITS = 32
  17138 const VP8L_WRITER_BYTES = 4
  17139 const VP8L_WRITER_MAX_BITS = 64
  17140 const WEBP_ENCODER_ABI_VERSION = 528
  17141 const WEBP_MAX_DIMENSION = 16383
  17142 const WEBP_NEAR_LOSSLESS = 1
  17143 const WINDOW_SIZE_BITS = 20
  17144 const WSWAP = "HToLE32"
  17145 const Y_OFF_ENC = 0
  17146 
  17147 type VP8Matrix = struct {
  17148 	Fq       [16]uint16_t
  17149 	Fiq      [16]uint16_t
  17150 	Fbias    [16]uint32_t
  17151 	Fzthresh [16]uint32_t
  17152 	Fsharpen [16]uint16_t
  17153 }
  17154 
  17155 type VP8BitWriter = struct {
  17156 	Frange1  int32_t
  17157 	Fvalue   int32_t
  17158 	Frun     int32
  17159 	Fnb_bits int32
  17160 	Fbuf     uintptr
  17161 	Fpos     size_t
  17162 	Fmax_pos size_t
  17163 	Ferror1  int32
  17164 }
  17165 
  17166 type vp8l_atype_t = uint64
  17167 
  17168 type vp8l_wtype_t = uint32
  17169 
  17170 type VP8LBitWriter = struct {
  17171 	Fbits   vp8l_atype_t
  17172 	Fused   int32
  17173 	Fbuf    uintptr
  17174 	Fcur    uintptr
  17175 	Fend    uintptr
  17176 	Ferror1 int32
  17177 }
  17178 
  17179 type WebPPicture = struct {
  17180 	Fuse_argb        int32
  17181 	Fcolorspace      WebPEncCSP1
  17182 	Fwidth           int32
  17183 	Fheight          int32
  17184 	Fy               uintptr
  17185 	Fu               uintptr
  17186 	Fv               uintptr
  17187 	Fy_stride        int32
  17188 	Fuv_stride       int32
  17189 	Fa               uintptr
  17190 	Fa_stride        int32
  17191 	Fpad1            [2]uint32_t
  17192 	Fargb            uintptr
  17193 	Fargb_stride     int32
  17194 	Fpad2            [3]uint32_t
  17195 	Fwriter          WebPWriterFunction
  17196 	Fcustom_ptr      uintptr
  17197 	Fextra_info_type int32
  17198 	Fextra_info      uintptr
  17199 	Fstats           uintptr
  17200 	Ferror_code      WebPEncodingError1
  17201 	Fprogress_hook   WebPProgressHook
  17202 	Fuser_data       uintptr
  17203 	Fpad3            [3]uint32_t
  17204 	Fpad4            uintptr
  17205 	Fpad5            uintptr
  17206 	Fpad6            [8]uint32_t
  17207 	Fmemory_         uintptr
  17208 	Fmemory_argb_    uintptr
  17209 	Fpad7            [2]uintptr
  17210 }
  17211 
  17212 type WebPEncCSP = int32
  17213 
  17214 const WEBP_YUV420 = 0
  17215 const WEBP_YUV420A = 4
  17216 const WEBP_CSP_UV_MASK = 3
  17217 const WEBP_CSP_ALPHA_BIT = 4
  17218 
  17219 type WebPEncodingError = int32
  17220 
  17221 const VP8_ENC_OK = 0
  17222 const VP8_ENC_ERROR_OUT_OF_MEMORY = 1
  17223 const VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY = 2
  17224 const VP8_ENC_ERROR_NULL_PARAMETER = 3
  17225 const VP8_ENC_ERROR_INVALID_CONFIGURATION = 4
  17226 const VP8_ENC_ERROR_BAD_DIMENSION = 5
  17227 const VP8_ENC_ERROR_PARTITION0_OVERFLOW = 6
  17228 const VP8_ENC_ERROR_PARTITION_OVERFLOW = 7
  17229 const VP8_ENC_ERROR_BAD_WRITE = 8
  17230 const VP8_ENC_ERROR_FILE_TOO_BIG = 9
  17231 const VP8_ENC_ERROR_USER_ABORT = 10
  17232 const VP8_ENC_ERROR_LAST = 11
  17233 
  17234 type WebPConfig = struct {
  17235 	Flossless          int32
  17236 	Fquality           float32
  17237 	Fmethod            int32
  17238 	Fimage_hint        WebPImageHint1
  17239 	Ftarget_size       int32
  17240 	Ftarget_PSNR       float32
  17241 	Fsegments          int32
  17242 	Fsns_strength      int32
  17243 	Ffilter_strength   int32
  17244 	Ffilter_sharpness  int32
  17245 	Ffilter_type       int32
  17246 	Fautofilter        int32
  17247 	Falpha_compression int32
  17248 	Falpha_filtering   int32
  17249 	Falpha_quality     int32
  17250 	Fpass              int32
  17251 	Fshow_compressed   int32
  17252 	Fpreprocessing     int32
  17253 	Fpartitions        int32
  17254 	Fpartition_limit   int32
  17255 	Femulate_jpeg_size int32
  17256 	Fthread_level      int32
  17257 	Flow_memory        int32
  17258 	Fnear_lossless     int32
  17259 	Fexact             int32
  17260 	Fuse_delta_palette int32
  17261 	Fuse_sharp_yuv     int32
  17262 	Fqmin              int32
  17263 	Fqmax              int32
  17264 }
  17265 
  17266 type WebPImageHint = int32
  17267 
  17268 const WEBP_HINT_DEFAULT = 0
  17269 const WEBP_HINT_PICTURE = 1
  17270 const WEBP_HINT_PHOTO = 2
  17271 const WEBP_HINT_GRAPH = 3
  17272 const WEBP_HINT_LAST = 4
  17273 
  17274 type WebPAuxStats = struct {
  17275 	Fcoded_size                 int32
  17276 	FPSNR                       [5]float32
  17277 	Fblock_count                [3]int32
  17278 	Fheader_bytes               [2]int32
  17279 	Fresidual_bytes             [3][4]int32
  17280 	Fsegment_size               [4]int32
  17281 	Fsegment_quant              [4]int32
  17282 	Fsegment_level              [4]int32
  17283 	Falpha_data_size            int32
  17284 	Flayer_data_size            int32
  17285 	Flossless_features          uint32_t
  17286 	Fhistogram_bits             int32
  17287 	Ftransform_bits             int32
  17288 	Fcache_bits                 int32
  17289 	Fpalette_size               int32
  17290 	Flossless_size              int32
  17291 	Flossless_hdr_size          int32
  17292 	Flossless_data_size         int32
  17293 	Fcross_color_transform_bits int32
  17294 	Fpad                        [1]uint32_t
  17295 }
  17296 
  17297 type WebPMemoryWriter = struct {
  17298 	Fmem      uintptr
  17299 	Fsize     size_t
  17300 	Fmax_size size_t
  17301 	Fpad      [1]uint32_t
  17302 }
  17303 
  17304 type WebPImageHint1 = int32
  17305 
  17306 type WebPPreset1 = int32
  17307 
  17308 type WebPPreset = int32
  17309 
  17310 const WEBP_PRESET_DEFAULT = 0
  17311 const WEBP_PRESET_PICTURE = 1
  17312 const WEBP_PRESET_PHOTO = 2
  17313 const WEBP_PRESET_DRAWING = 3
  17314 const WEBP_PRESET_ICON = 4
  17315 const WEBP_PRESET_TEXT = 5
  17316 
  17317 type WebPWriterFunction = uintptr
  17318 
  17319 type WebPProgressHook = uintptr
  17320 
  17321 type WebPEncCSP1 = int32
  17322 
  17323 type WebPEncodingError1 = int32
  17324 
  17325 const MAX_LF_LEVELS = 64
  17326 const MAX_VARIABLE_LEVEL = 67
  17327 const MAX_LEVEL = 2047
  17328 
  17329 type VP8RDLevel = int32
  17330 
  17331 const RD_OPT_NONE = 0
  17332 const RD_OPT_BASIC = 1
  17333 const RD_OPT_TRELLIS = 2
  17334 const RD_OPT_TRELLIS_ALL = 3
  17335 
  17336 type score_t = int64
  17337 
  17338 type proba_t = uint32
  17339 
  17340 type ProbaArray = [3][11]uint8_t
  17341 
  17342 type StatsArray = [3][11]proba_t
  17343 
  17344 type CostArray = [3][68]uint16_t
  17345 
  17346 type CostArrayPtr = uintptr
  17347 
  17348 type CostArrayMap = [16][3]uintptr
  17349 
  17350 type LFStats = [4][64]float64
  17351 
  17352 type VP8Encoder = struct {
  17353 	Fconfig             uintptr
  17354 	Fpic                uintptr
  17355 	Ffilter_hdr         VP8EncFilterHeader
  17356 	Fsegment_hdr        VP8EncSegmentHeader
  17357 	Fprofile            int32
  17358 	Fmb_w               int32
  17359 	Fmb_h               int32
  17360 	Fpreds_w            int32
  17361 	Fnum_parts          int32
  17362 	Fbw                 VP8BitWriter
  17363 	Fparts              [8]VP8BitWriter
  17364 	Ftokens             VP8TBuffer
  17365 	Fpercent            int32
  17366 	Fhas_alpha          int32
  17367 	Falpha_data         uintptr
  17368 	Falpha_data_size    uint32_t
  17369 	Falpha_worker       WebPWorker
  17370 	Fdqm                [4]VP8SegmentInfo
  17371 	Fbase_quant         int32
  17372 	Falpha              int32
  17373 	Fuv_alpha           int32
  17374 	Fdq_y1_dc           int32
  17375 	Fdq_y2_dc           int32
  17376 	Fdq_y2_ac           int32
  17377 	Fdq_uv_dc           int32
  17378 	Fdq_uv_ac           int32
  17379 	Fproba              VP8EncProba
  17380 	Fsse                [4]uint64_t
  17381 	Fsse_count          uint64_t
  17382 	Fcoded_size         int32
  17383 	Fresidual_bytes     [3][4]int32
  17384 	Fblock_count        [3]int32
  17385 	Fmethod             int32
  17386 	Frd_opt_level       VP8RDLevel
  17387 	Fmax_i4_header_bits int32
  17388 	Fmb_header_limit    int32
  17389 	Fthread_level       int32
  17390 	Fdo_search          int32
  17391 	Fuse_tokens         int32
  17392 	Fmb_info            uintptr
  17393 	Fpreds              uintptr
  17394 	Fnz                 uintptr
  17395 	Fy_top              uintptr
  17396 	Fuv_top             uintptr
  17397 	Flf_stats           uintptr
  17398 	Ftop_derr           uintptr
  17399 }
  17400 
  17401 type VP8EncSegmentHeader = struct {
  17402 	Fnum_segments int32
  17403 	Fupdate_map   int32
  17404 	Fsize         int32
  17405 }
  17406 
  17407 type VP8EncProba = struct {
  17408 	Fsegments       [3]uint8_t
  17409 	Fskip_proba     uint8_t
  17410 	Fcoeffs         [4][8]ProbaArray
  17411 	Fstats          [4][8]StatsArray
  17412 	Flevel_cost     [4][8]CostArray
  17413 	Fremapped_costs [4]CostArrayMap
  17414 	Fdirty          int32
  17415 	Fuse_skip_proba int32
  17416 	Fnb_skip        int32
  17417 }
  17418 
  17419 type VP8EncFilterHeader = struct {
  17420 	Fsimple        int32
  17421 	Flevel         int32
  17422 	Fsharpness     int32
  17423 	Fi4x4_lf_delta int32
  17424 }
  17425 
  17426 type VP8MBInfo = struct {
  17427 	F__ccgo_align [0]uint32
  17428 	F__ccgo0      uint8
  17429 	Falpha        uint8_t
  17430 }
  17431 
  17432 type VP8SegmentInfo = struct {
  17433 	Fy1                 VP8Matrix
  17434 	Fy2                 VP8Matrix
  17435 	Fuv                 VP8Matrix
  17436 	Falpha              int32
  17437 	Fbeta               int32
  17438 	Fquant              int32
  17439 	Ffstrength          int32
  17440 	Fmax_edge           int32
  17441 	Fmin_disto          int32
  17442 	Flambda_i16         int32
  17443 	Flambda_i4          int32
  17444 	Flambda_uv          int32
  17445 	Flambda_mode        int32
  17446 	Flambda_trellis     int32
  17447 	Ftlambda            int32
  17448 	Flambda_trellis_i16 int32
  17449 	Flambda_trellis_i4  int32
  17450 	Flambda_trellis_uv  int32
  17451 	Fi4_penalty         score_t
  17452 }
  17453 
  17454 type DError = [2][2]int8_t
  17455 
  17456 type VP8ModeScore = struct {
  17457 	FD           score_t
  17458 	FSD          score_t
  17459 	FH           score_t
  17460 	FR           score_t
  17461 	Fscore       score_t
  17462 	Fy_dc_levels [16]int16_t
  17463 	Fy_ac_levels [16][16]int16_t
  17464 	Fuv_levels   [8][16]int16_t
  17465 	Fmode_i16    int32
  17466 	Fmodes_i4    [16]uint8_t
  17467 	Fmode_uv     int32
  17468 	Fnz          uint32_t
  17469 	Fderr        [2][3]int8_t
  17470 }
  17471 
  17472 type VP8EncIterator = struct {
  17473 	Fx            int32
  17474 	Fy            int32
  17475 	Fyuv_in       uintptr
  17476 	Fyuv_out      uintptr
  17477 	Fyuv_out2     uintptr
  17478 	Fyuv_p        uintptr
  17479 	Fenc          uintptr
  17480 	Fmb           uintptr
  17481 	Fbw           uintptr
  17482 	Fpreds        uintptr
  17483 	Fnz           uintptr
  17484 	Fi4_boundary  [37]uint8_t
  17485 	Fi4_top       uintptr
  17486 	Fi4           int32
  17487 	Ftop_nz       [9]int32
  17488 	Fleft_nz      [9]int32
  17489 	Fbit_count    [4][3]uint64_t
  17490 	Fluma_bits    uint64_t
  17491 	Fuv_bits      uint64_t
  17492 	Flf_stats     uintptr
  17493 	Fdo_trellis   int32
  17494 	Fcount_down   int32
  17495 	Fcount_down0  int32
  17496 	Fpercent0     int32
  17497 	Fleft_derr    DError
  17498 	Ftop_derr     uintptr
  17499 	Fy_left       uintptr
  17500 	Fu_left       uintptr
  17501 	Fv_left       uintptr
  17502 	Fy_top        uintptr
  17503 	Fuv_top       uintptr
  17504 	Fyuv_left_mem [88]uint8_t
  17505 	Fyuv_mem      [3359]uint8_t
  17506 }
  17507 
  17508 type VP8TBuffer = struct {
  17509 	Fpages     uintptr
  17510 	Flast_page uintptr
  17511 	Ftokens    uintptr
  17512 	Fleft      int32
  17513 	Fpage_size int32
  17514 	Ferror1    int32
  17515 }
  17516 
  17517 type Mode = int32
  17518 
  17519 const kLiteral = 0
  17520 const kCacheIdx = 1
  17521 const kCopy = 2
  17522 const kNone = 3
  17523 
  17524 type PixOrCopy = struct {
  17525 	Fmode             uint8_t
  17526 	Flen1             uint16_t
  17527 	Fargb_or_distance uint32_t
  17528 }
  17529 
  17530 type VP8LHashChain = struct {
  17531 	Foffset_length uintptr
  17532 	Fsize          int32
  17533 }
  17534 
  17535 type VP8LBackwardRefs = struct {
  17536 	Fblock_size  int32
  17537 	Ferror1      int32
  17538 	Frefs        uintptr
  17539 	Ftail        uintptr
  17540 	Ffree_blocks uintptr
  17541 	Flast_block  uintptr
  17542 }
  17543 
  17544 type VP8LRefsCursor = struct {
  17545 	Fcur_pos   uintptr
  17546 	Fcur_block uintptr
  17547 	Flast_pos  uintptr
  17548 }
  17549 
  17550 type VP8LLZ77Type = int32
  17551 
  17552 const kLZ77Standard = 1
  17553 const kLZ77RLE = 2
  17554 const kLZ77Box = 4
  17555 
  17556 type VP8LHistogram = struct {
  17557 	Fliteral           uintptr
  17558 	Fred               [256]uint32_t
  17559 	Fblue              [256]uint32_t
  17560 	Falpha             [256]uint32_t
  17561 	Fdistance          [40]uint32_t
  17562 	Fpalette_code_bits int32
  17563 	Ftrivial_symbol    [5]uint16_t
  17564 	Fbit_cost          uint64_t
  17565 	Fcosts             [5]uint64_t
  17566 	Fis_used           [5]uint8_t
  17567 	Fbin_id            uint16_t
  17568 }
  17569 
  17570 type VP8LHistogramSet = struct {
  17571 	Fsize       int32
  17572 	Fmax_size   int32
  17573 	Fhistograms uintptr
  17574 }
  17575 
  17576 type VP8LEncoderARGBContent = int32
  17577 
  17578 const kEncoderNone = 0
  17579 const kEncoderARGB = 1
  17580 const kEncoderNearLossless = 2
  17581 const kEncoderPalette = 3
  17582 
  17583 type VP8LEncoder = struct {
  17584 	Fconfig                     uintptr
  17585 	Fpic                        uintptr
  17586 	Fargb                       uintptr
  17587 	Fargb_content               VP8LEncoderARGBContent
  17588 	Fargb_scratch               uintptr
  17589 	Ftransform_data             uintptr
  17590 	Ftransform_mem              uintptr
  17591 	Ftransform_mem_size         size_t
  17592 	Fcurrent_width              int32
  17593 	Fhisto_bits                 int32
  17594 	Fpredictor_transform_bits   int32
  17595 	Fcross_color_transform_bits int32
  17596 	Fcache_bits                 int32
  17597 	Fuse_cross_color            int32
  17598 	Fuse_subtract_green         int32
  17599 	Fuse_predict                int32
  17600 	Fuse_palette                int32
  17601 	Fpalette_size               int32
  17602 	Fpalette                    [256]uint32_t
  17603 	Fpalette_sorted             [256]uint32_t
  17604 	Frefs                       [4]VP8LBackwardRefs
  17605 	Fhash_chain                 VP8LHashChain
  17606 }
  17607 
  17608 //------------------------------------------------------------------------------
  17609 
  17610 func EncodeLossless(tls *libc.TLS, data uintptr, width int32, height int32, effort_level int32, use_quality_100 int32, bw uintptr, stats uintptr) (r int32) {
  17611 	bp := tls.Alloc(384)
  17612 	defer tls.Free(384)
  17613 	var ok, v1 int32
  17614 	var v5 float32
  17615 	var _ /* config at bp+0 */ WebPConfig
  17616 	var _ /* picture at bp+120 */ WebPPicture
  17617 	_, _, _ = ok, v1, v5
  17618 	ok = 0
  17619 	v1 = WebPPictureInitInternal(tls, bp+120, int32(WEBP_ENCODER_ABI_VERSION))
  17620 	goto _2
  17621 _2:
  17622 	if !(v1 != 0) {
  17623 		return 0
  17624 	}
  17625 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fwidth = width
  17626 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fheight = height
  17627 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fuse_argb = int32(1)
  17628 	(**(**WebPPicture)(__ccgo_up(bp + 120))).Fstats = stats
  17629 	if !(WebPPictureAlloc(tls, bp+120) != 0) {
  17630 		return 0
  17631 	}
  17632 	// Transfer the alpha values to the green channel.
  17633 	(*(*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)
  17634 	v1 = WebPConfigInitInternal(tls, bp, int32(WEBP_PRESET_DEFAULT), libc.Float32FromFloat32(75), int32(WEBP_ENCODER_ABI_VERSION))
  17635 	goto _4
  17636 _4:
  17637 	if !(v1 != 0) {
  17638 		return 0
  17639 	}
  17640 	(**(**WebPConfig)(__ccgo_up(bp))).Flossless = int32(1)
  17641 	// Enable exact, or it would alter RGB values of transparent alpha, which is
  17642 	// normally OK but not here since we are not encoding the input image but  an
  17643 	// internal encoding-related image containing necessary exact information in
  17644 	// RGB channels.
  17645 	(**(**WebPConfig)(__ccgo_up(bp))).Fexact = int32(1)
  17646 	(**(**WebPConfig)(__ccgo_up(bp))).Fmethod = effort_level // impact is very small
  17647 	// Set a low default quality for encoding alpha. Ensure that Alpha quality at
  17648 	// lower methods (3 and below) is less than the threshold for triggering
  17649 	// costly 'BackwardReferencesTraceBackwards'.
  17650 	// If the alpha quality is set to 100 and the method to 6, allow for a high
  17651 	// lossless quality to trigger the cruncher.
  17652 	if use_quality_100 != 0 && effort_level == int32(6) {
  17653 		v5 = libc.Float32FromInt32(100)
  17654 	} else {
  17655 		v5 = float32(libc.Float32FromFloat32(8) * float32(effort_level))
  17656 	}
  17657 	(**(**WebPConfig)(__ccgo_up(bp))).Fquality = v5
  17658 	ok = VP8LEncodeStream(tls, bp, bp+120, bw)
  17659 	WebPPictureFree(tls, bp+120)
  17660 	ok = libc.BoolInt32(ok != 0 && !((*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 != 0))
  17661 	if !(ok != 0) {
  17662 		VP8LBitWriterWipeOut(tls, bw)
  17663 		return 0
  17664 	}
  17665 	return int32(1)
  17666 }
  17667 
  17668 // -----------------------------------------------------------------------------
  17669 
  17670 // C documentation
  17671 //
  17672 //	// Small struct to hold the result of a filter mode compression attempt.
  17673 type FilterTrial = struct {
  17674 	Fscore size_t
  17675 	Fbw    VP8BitWriter
  17676 	Fstats WebPAuxStats
  17677 }
  17678 
  17679 // C documentation
  17680 //
  17681 //	// This function always returns an initialized 'bw' object, even upon error.
  17682 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) {
  17683 	bp := tls.Alloc(64)
  17684 	defer tls.Free(64)
  17685 	var alpha_src, output, v1 uintptr
  17686 	var data_size, output_size, v2 size_t
  17687 	var filter_func WebPFilterFunc
  17688 	var ok int32
  17689 	var _ /* header at bp+0 */ uint8_t
  17690 	var _ /* tmp_bw at bp+8 */ VP8LBitWriter
  17691 	_, _, _, _, _, _, _, _ = alpha_src, data_size, filter_func, ok, output, output_size, v1, v2
  17692 	ok = 0
  17693 	data_size = libc.Uint64FromInt32(width * height)
  17694 	output = libc.UintptrFromInt32(0)
  17695 	output_size = uint64(0)
  17696 	// as per spec
  17697 	filter_func = WebPFilters[filter]
  17698 	if filter_func != libc.UintptrFromInt32(0) {
  17699 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{filter_func})))(tls, data, width, height, width, tmp_alpha)
  17700 		alpha_src = tmp_alpha
  17701 	} else {
  17702 		alpha_src = data
  17703 	}
  17704 	if method != ALPHA_NO_COMPRESSION {
  17705 		ok = VP8LBitWriterInit(tls, bp+8, data_size>>int32(3))
  17706 		ok = libc.BoolInt32(ok != 0 && EncodeLossless(tls, alpha_src, width, height, effort_level, libc.BoolInt32(!(reduce_levels != 0)), bp+8, result+56) != 0)
  17707 		if ok != 0 {
  17708 			output = VP8LBitWriterFinish(tls, bp+8)
  17709 			if (**(**VP8LBitWriter)(__ccgo_up(bp + 8))).Ferror1 != 0 {
  17710 				VP8LBitWriterWipeOut(tls, bp+8)
  17711 				libc.X__builtin___memset_chk(tls, result+8, 0, uint64(48), ^__predefined_size_t(0))
  17712 				return 0
  17713 			}
  17714 			v1 = bp + 8
  17715 			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)))
  17716 			goto _3
  17717 		_3:
  17718 			output_size = v2
  17719 			if output_size > data_size {
  17720 				// compressed size is larger than source! Revert to uncompressed mode.
  17721 				method = ALPHA_NO_COMPRESSION
  17722 				VP8LBitWriterWipeOut(tls, bp+8)
  17723 			}
  17724 		} else {
  17725 			VP8LBitWriterWipeOut(tls, bp+8)
  17726 			libc.X__builtin___memset_chk(tls, result+8, 0, uint64(48), ^__predefined_size_t(0))
  17727 			return 0
  17728 		}
  17729 	}
  17730 	if method == ALPHA_NO_COMPRESSION {
  17731 		output = alpha_src
  17732 		output_size = data_size
  17733 		ok = int32(1)
  17734 	}
  17735 	// Emit final result.
  17736 	**(**uint8_t)(__ccgo_up(bp)) = libc.Uint8FromInt32(method | filter<<int32(2))
  17737 	if reduce_levels != 0 {
  17738 		**(**uint8_t)(__ccgo_up(bp)) = libc.Uint8FromInt32(int32(**(**uint8_t)(__ccgo_up(bp))) | libc.Int32FromInt32(ALPHA_PREPROCESSED_LEVELS)<<libc.Int32FromInt32(4))
  17739 	}
  17740 	if !(VP8BitWriterInit(tls, result+8, uint64(ALPHA_HEADER_LEN)+output_size) != 0) {
  17741 		ok = 0
  17742 	}
  17743 	ok = libc.BoolInt32(ok != 0 && VP8BitWriterAppend(tls, result+8, bp, uint64(ALPHA_HEADER_LEN)) != 0)
  17744 	ok = libc.BoolInt32(ok != 0 && VP8BitWriterAppend(tls, result+8, output, output_size) != 0)
  17745 	if method != ALPHA_NO_COMPRESSION {
  17746 		VP8LBitWriterWipeOut(tls, bp+8)
  17747 	}
  17748 	ok = libc.BoolInt32(ok != 0 && !((*FilterTrial)(unsafe.Pointer(result)).Fbw.Ferror1 != 0))
  17749 	v2 = (*VP8BitWriter)(unsafe.Pointer(result + 8)).Fpos
  17750 	goto _5
  17751 _5:
  17752 	(*FilterTrial)(unsafe.Pointer(result)).Fscore = v2
  17753 	return ok
  17754 }
  17755 
  17756 // -----------------------------------------------------------------------------
  17757 
  17758 func GetNumColors(tls *libc.TLS, data uintptr, width int32, height int32, stride int32) (r int32) {
  17759 	var color [256]uint8_t
  17760 	var colors, i, j int32
  17761 	var p uintptr
  17762 	_, _, _, _, _ = color, colors, i, j, p
  17763 	colors = 0
  17764 	color = [256]uint8_t{}
  17765 	j = 0
  17766 	for {
  17767 		if !(j < height) {
  17768 			break
  17769 		}
  17770 		p = data + uintptr(j*stride)
  17771 		i = 0
  17772 		for {
  17773 			if !(i < width) {
  17774 				break
  17775 			}
  17776 			color[**(**uint8_t)(__ccgo_up(p + uintptr(i)))] = uint8(1)
  17777 			goto _2
  17778 		_2:
  17779 			;
  17780 			i = i + 1
  17781 		}
  17782 		goto _1
  17783 	_1:
  17784 		;
  17785 		j = j + 1
  17786 	}
  17787 	j = 0
  17788 	for {
  17789 		if !(j < int32(256)) {
  17790 			break
  17791 		}
  17792 		if libc.Int32FromUint8(color[j]) > 0 {
  17793 			colors = colors + 1
  17794 		}
  17795 		goto _3
  17796 	_3:
  17797 		;
  17798 		j = j + 1
  17799 	}
  17800 	return colors
  17801 }
  17802 
  17803 // C documentation
  17804 //
  17805 //	// Given the input 'filter' option, return an OR'd bit-set of filters to try.
  17806 func GetFilterMap(tls *libc.TLS, alpha uintptr, width int32, height int32, filter int32, effort_level int32) (r uint32_t) {
  17807 	var bit_map uint32_t
  17808 	var kMaxColorsForFilterNone, kMinColorsForFilterNone, num_colors, try_filter_none, v1 int32
  17809 	_, _, _, _, _, _ = bit_map, kMaxColorsForFilterNone, kMinColorsForFilterNone, num_colors, try_filter_none, v1
  17810 	bit_map = 0
  17811 	if filter == int32(WEBP_FILTER_FAST) {
  17812 		// Quick estimate of the best candidate.
  17813 		try_filter_none = libc.BoolInt32(effort_level > int32(3))
  17814 		kMinColorsForFilterNone = int32(16)
  17815 		kMaxColorsForFilterNone = int32(192)
  17816 		num_colors = GetNumColors(tls, alpha, width, height, width)
  17817 		// For low number of colors, NONE yields better compression.
  17818 		if num_colors <= kMinColorsForFilterNone {
  17819 			v1 = int32(WEBP_FILTER_NONE)
  17820 		} else {
  17821 			v1 = WebPEstimateBestFilter(tls, alpha, width, height, width)
  17822 		}
  17823 		filter = v1
  17824 		bit_map = bit_map | libc.Uint32FromInt32(int32(1)<<filter)
  17825 		// For large number of colors, try FILTER_NONE in addition to the best
  17826 		// filter as well.
  17827 		if try_filter_none != 0 || num_colors > kMaxColorsForFilterNone {
  17828 			bit_map = bit_map | libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_NONE))
  17829 		}
  17830 	} else {
  17831 		if filter == int32(WEBP_FILTER_NONE) {
  17832 			bit_map = libc.Uint32FromInt32(libc.Int32FromInt32(1) << int32(WEBP_FILTER_NONE))
  17833 		} else { // WEBP_FILTER_BEST -> try all
  17834 			bit_map = libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_LAST) - libc.Int32FromInt32(1))
  17835 		}
  17836 	}
  17837 	return bit_map
  17838 }
  17839 
  17840 func InitFilterTrial(tls *libc.TLS, score uintptr) {
  17841 	(*FilterTrial)(unsafe.Pointer(score)).Fscore = uint64(^libc.Uint32FromUint32(0))
  17842 	VP8BitWriterInit(tls, score+8, uint64(0))
  17843 }
  17844 
  17845 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) {
  17846 	bp := tls.Alloc(496)
  17847 	defer tls.Free(496)
  17848 	var filtered_alpha, v4 uintptr
  17849 	var ok int32
  17850 	var try_map uint32_t
  17851 	var v2 size_t
  17852 	var _ /* best at bp+0 */ FilterTrial
  17853 	var _ /* trial at bp+248 */ FilterTrial
  17854 	_, _, _, _, _ = filtered_alpha, ok, try_map, v2, v4
  17855 	ok = int32(1)
  17856 	try_map = GetFilterMap(tls, alpha, width, height, filter, effort_level)
  17857 	InitFilterTrial(tls, bp)
  17858 	if try_map != libc.Uint32FromInt32(libc.Int32FromInt32(1)<<int32(WEBP_FILTER_NONE)) {
  17859 		filtered_alpha = WebPSafeMalloc(tls, uint64(1), data_size)
  17860 		if filtered_alpha == libc.UintptrFromInt32(0) {
  17861 			return 0
  17862 		}
  17863 		filter = int32(WEBP_FILTER_NONE)
  17864 		for {
  17865 			if !(ok != 0 && try_map != 0) {
  17866 				break
  17867 			}
  17868 			if try_map&uint32(1) != 0 {
  17869 				ok = EncodeAlphaInternal(tls, alpha, width, height, method, filter, reduce_levels, effort_level, filtered_alpha, bp+248)
  17870 				if ok != 0 && (**(**FilterTrial)(__ccgo_up(bp + 248))).Fscore < (**(**FilterTrial)(__ccgo_up(bp))).Fscore {
  17871 					VP8BitWriterWipeOut(tls, bp+8)
  17872 					**(**FilterTrial)(__ccgo_up(bp)) = **(**FilterTrial)(__ccgo_up(bp + 248))
  17873 				} else {
  17874 					VP8BitWriterWipeOut(tls, bp+248+8)
  17875 				}
  17876 			}
  17877 			goto _1
  17878 		_1:
  17879 			;
  17880 			filter = filter + 1
  17881 			try_map = try_map >> uint32(1)
  17882 		}
  17883 		WebPSafeFree(tls, filtered_alpha)
  17884 	} else {
  17885 		ok = EncodeAlphaInternal(tls, alpha, width, height, method, int32(WEBP_FILTER_NONE), reduce_levels, effort_level, libc.UintptrFromInt32(0), bp)
  17886 	}
  17887 	if ok != 0 {
  17888 		if stats != libc.UintptrFromInt32(0) {
  17889 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_features = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_features
  17890 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fhistogram_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fhistogram_bits
  17891 			(*WebPAuxStats)(unsafe.Pointer(stats)).Ftransform_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Ftransform_bits
  17892 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fcross_color_transform_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fcross_color_transform_bits
  17893 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fcache_bits = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fcache_bits
  17894 			(*WebPAuxStats)(unsafe.Pointer(stats)).Fpalette_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Fpalette_size
  17895 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_size
  17896 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_hdr_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_hdr_size
  17897 			(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_data_size = (**(**FilterTrial)(__ccgo_up(bp))).Fstats.Flossless_data_size
  17898 		}
  17899 		v2 = (*VP8BitWriter)(unsafe.Pointer(bp + 8)).Fpos
  17900 		goto _3
  17901 	_3:
  17902 		**(**size_t)(__ccgo_up(output_size)) = v2
  17903 		v4 = (*VP8BitWriter)(unsafe.Pointer(bp + 8)).Fbuf
  17904 		goto _5
  17905 	_5:
  17906 		**(**uintptr)(__ccgo_up(output)) = v4
  17907 	} else {
  17908 		VP8BitWriterWipeOut(tls, bp+8)
  17909 	}
  17910 	return ok
  17911 }
  17912 
  17913 func EncodeAlpha(tls *libc.TLS, enc uintptr, quality int32, method int32, filter int32, effort_level int32, output uintptr, output_size uintptr) (r int32) {
  17914 	bp := tls.Alloc(16)
  17915 	defer tls.Free(16)
  17916 	var alpha_levels, height, ok, reduce_levels, width, v1 int32
  17917 	var data_size size_t
  17918 	var pic, quant_alpha uintptr
  17919 	var _ /* sse at bp+0 */ uint64_t
  17920 	_, _, _, _, _, _, _, _, _ = alpha_levels, data_size, height, ok, pic, quant_alpha, reduce_levels, width, v1
  17921 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  17922 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  17923 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  17924 	quant_alpha = libc.UintptrFromInt32(0)
  17925 	data_size = libc.Uint64FromInt32(width * height)
  17926 	**(**uint64_t)(__ccgo_up(bp)) = uint64(0)
  17927 	ok = int32(1)
  17928 	reduce_levels = libc.BoolInt32(quality < libc.Int32FromInt32(100))
  17929 	// quick correctness checks
  17930 	// as per spec
  17931 	if quality < 0 || quality > int32(100) {
  17932 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  17933 	}
  17934 	if method < ALPHA_NO_COMPRESSION || method > int32(ALPHA_LOSSLESS_COMPRESSION) {
  17935 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  17936 	}
  17937 	if method == ALPHA_NO_COMPRESSION {
  17938 		// Don't filter, as filtering will make no impact on compressed size.
  17939 		filter = int32(WEBP_FILTER_NONE)
  17940 	}
  17941 	quant_alpha = WebPSafeMalloc(tls, uint64(1), data_size)
  17942 	if quant_alpha == libc.UintptrFromInt32(0) {
  17943 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  17944 	}
  17945 	// Extract alpha data (width x height) from raw_data (stride x height).
  17946 	WebPCopyPlane(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fa, (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride, quant_alpha, width, width, height)
  17947 	if reduce_levels != 0 {
  17948 		if quality <= int32(70) {
  17949 			v1 = int32(2) + quality/int32(5)
  17950 		} else {
  17951 			v1 = int32(16) + (quality-int32(70))*int32(8)
  17952 		} // No Quantization required for 'quality = 100'.
  17953 		// 16 alpha levels gives quite a low MSE w.r.t original alpha plane hence
  17954 		// mapped to moderate quality 70. Hence Quality:[0, 70] -> Levels:[2, 16]
  17955 		// and Quality:]70, 100] -> Levels:]16, 256].
  17956 		alpha_levels = v1
  17957 		ok = QuantizeLevels(tls, quant_alpha, width, height, alpha_levels, bp)
  17958 	}
  17959 	if ok != 0 {
  17960 		VP8FiltersInit(tls)
  17961 		ok = ApplyFiltersAndEncode(tls, quant_alpha, width, height, data_size, method, filter, reduce_levels, effort_level, output, output_size, (*WebPPicture)(unsafe.Pointer(pic)).Fstats)
  17962 		if !(ok != 0) {
  17963 			WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY)) // imprecise
  17964 		}
  17965 		if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) { // need stats?
  17966 			**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer(pic)).Fstats)) += libc.Int32FromUint64(**(**size_t)(__ccgo_up(output_size)))
  17967 			**(**uint64_t)(__ccgo_up(enc + 23512 + 3*8)) = **(**uint64_t)(__ccgo_up(bp))
  17968 		}
  17969 	}
  17970 	WebPSafeFree(tls, quant_alpha)
  17971 	return ok
  17972 }
  17973 
  17974 //------------------------------------------------------------------------------
  17975 // Main calls
  17976 
  17977 func CompressAlphaJob(tls *libc.TLS, arg1 uintptr, unused uintptr) (r int32) {
  17978 	bp := tls.Alloc(16)
  17979 	defer tls.Free(16)
  17980 	var config, enc uintptr
  17981 	var effort_level, v1, v2 int32
  17982 	var filter WEBP_FILTER_TYPE
  17983 	var _ /* alpha_data at bp+0 */ uintptr
  17984 	var _ /* alpha_size at bp+8 */ size_t
  17985 	_, _, _, _, _, _ = config, effort_level, enc, filter, v1, v2
  17986 	enc = arg1
  17987 	config = (*VP8Encoder)(unsafe.Pointer(enc)).Fconfig
  17988 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  17989 	**(**size_t)(__ccgo_up(bp + 8)) = uint64(0)
  17990 	effort_level = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  17991 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering == 0 {
  17992 		v1 = int32(WEBP_FILTER_NONE)
  17993 	} else {
  17994 		if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering == int32(1) {
  17995 			v2 = int32(WEBP_FILTER_FAST)
  17996 		} else {
  17997 			v2 = int32(WEBP_FILTER_BEST)
  17998 		}
  17999 		v1 = v2
  18000 	} // maps to [0..6]
  18001 	filter = v1
  18002 	if !(EncodeAlpha(tls, enc, (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality, (*WebPConfig)(unsafe.Pointer(config)).Falpha_compression, filter, effort_level, bp, bp+8) != 0) {
  18003 		return 0
  18004 	}
  18005 	if **(**size_t)(__ccgo_up(bp + 8)) != uint64(uint32(**(**size_t)(__ccgo_up(bp + 8)))) { // Soundness check.
  18006 		WebPSafeFree(tls, **(**uintptr)(__ccgo_up(bp)))
  18007 		return 0
  18008 	}
  18009 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(**(**size_t)(__ccgo_up(bp + 8)))
  18010 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = **(**uintptr)(__ccgo_up(bp))
  18011 	_ = unused
  18012 	return int32(1)
  18013 }
  18014 
  18015 func VP8EncInitAlpha(tls *libc.TLS, enc uintptr) {
  18016 	var worker uintptr
  18017 	_ = worker
  18018 	WebPInitAlphaProcessing(tls)
  18019 	(*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha = WebPPictureHasTransparency(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic)
  18020 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = libc.UintptrFromInt32(0)
  18021 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(0)
  18022 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18023 		worker = enc + 560
  18024 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, worker)
  18025 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = enc
  18026 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = libc.UintptrFromInt32(0)
  18027 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(CompressAlphaJob)
  18028 	}
  18029 }
  18030 
  18031 func VP8EncStartAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18032 	var worker uintptr
  18033 	_ = worker
  18034 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  18035 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18036 			worker = enc + 560
  18037 			// Makes sure worker is good to go.
  18038 			if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FReset})))(tls, worker) != 0) {
  18039 				return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  18040 			}
  18041 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FLaunch})))(tls, worker)
  18042 			return int32(1)
  18043 		} else {
  18044 			return CompressAlphaJob(tls, enc, libc.UintptrFromInt32(0)) // just do the job right away
  18045 		}
  18046 	}
  18047 	return int32(1)
  18048 }
  18049 
  18050 func VP8EncFinishAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18051 	var worker uintptr
  18052 	_ = worker
  18053 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  18054 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18055 			worker = enc + 560
  18056 			if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker) != 0) {
  18057 				return 0
  18058 			} // error
  18059 		}
  18060 	}
  18061 	return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+int32(20), enc+536)
  18062 }
  18063 
  18064 func VP8EncDeleteAlpha(tls *libc.TLS, enc uintptr) (r int32) {
  18065 	var ok int32
  18066 	var worker uintptr
  18067 	_, _ = ok, worker
  18068 	ok = int32(1)
  18069 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level > 0 {
  18070 		worker = enc + 560
  18071 		// finish anything left in flight
  18072 		ok = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FSync})))(tls, worker)
  18073 		// still need to end the worker, even if !ok
  18074 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FEnd})))(tls, worker)
  18075 	}
  18076 	WebPSafeFree(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data)
  18077 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data = libc.UintptrFromInt32(0)
  18078 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size = uint32(0)
  18079 	(*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha = 0
  18080 	return ok
  18081 }
  18082 
  18083 const MAX_ALPHA = 255
  18084 const MAX_INTRA16_MODE = 2
  18085 const MAX_INTRA4_MODE = 2
  18086 const MAX_ITERS_K_MEANS = 6
  18087 const MAX_UV_MODE = 2
  18088 
  18089 //------------------------------------------------------------------------------
  18090 
  18091 // Copyright 2011 Google Inc. All Rights Reserved.
  18092 //
  18093 // Use of this source code is governed by a BSD-style license
  18094 // that can be found in the COPYING file in the root of the source
  18095 // tree. An additional intellectual property rights grant can be found
  18096 // in the file PATENTS. All contributing project authors may
  18097 // be found in the AUTHORS file in the root of the source tree.
  18098 // -----------------------------------------------------------------------------
  18099 //
  18100 // Multi-threaded worker
  18101 //
  18102 // Author: Skal (pascal.massimino@gmail.com)
  18103 
  18104 // Copyright 2012 Google Inc. All Rights Reserved.
  18105 //
  18106 // Use of this source code is governed by a BSD-style license
  18107 // that can be found in the COPYING file in the root of the source
  18108 // tree. An additional intellectual property rights grant can be found
  18109 // in the file PATENTS. All contributing project authors may
  18110 // be found in the AUTHORS file in the root of the source tree.
  18111 // -----------------------------------------------------------------------------
  18112 //
  18113 // Misc. common utility functions
  18114 //
  18115 // Authors: Skal (pascal.massimino@gmail.com)
  18116 //          Urvang (urvang@google.com)
  18117 
  18118 // Copyright 2011 Google Inc. All Rights Reserved.
  18119 //
  18120 // Use of this source code is governed by a BSD-style license
  18121 // that can be found in the COPYING file in the root of the source
  18122 // tree. An additional intellectual property rights grant can be found
  18123 // in the file PATENTS. All contributing project authors may
  18124 // be found in the AUTHORS file in the root of the source tree.
  18125 // -----------------------------------------------------------------------------
  18126 //
  18127 //   WebP encoder: main interface
  18128 //
  18129 // Author: Skal (pascal.massimino@gmail.com)
  18130 
  18131 // Copyright 2010 Google Inc. All Rights Reserved.
  18132 //
  18133 // Use of this source code is governed by a BSD-style license
  18134 // that can be found in the COPYING file in the root of the source
  18135 // tree. An additional intellectual property rights grant can be found
  18136 // in the file PATENTS. All contributing project authors may
  18137 // be found in the AUTHORS file in the root of the source tree.
  18138 // -----------------------------------------------------------------------------
  18139 //
  18140 //  Common types + memory wrappers
  18141 //
  18142 // Author: Skal (pascal.massimino@gmail.com)
  18143 
  18144 //------------------------------------------------------------------------------
  18145 // Smooth the segment map by replacing isolated block by the majority of its
  18146 // neighbours.
  18147 
  18148 func SmoothSegmentMap(tls *libc.TLS, enc uintptr) {
  18149 	var cnt [4]int32
  18150 	var h, majority_cnt_3_x_3_grid, majority_seg, n, w, x, y int32
  18151 	var mb, mb1, tmp uintptr
  18152 	_, _, _, _, _, _, _, _, _, _, _ = cnt, h, majority_cnt_3_x_3_grid, majority_seg, mb, mb1, n, tmp, w, x, y
  18153 	w = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w
  18154 	h = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  18155 	majority_cnt_3_x_3_grid = int32(5)
  18156 	tmp = WebPSafeMalloc(tls, libc.Uint64FromInt32(w*h), uint64(1))
  18157 	// no overflow, as per spec
  18158 	if tmp == libc.UintptrFromInt32(0) {
  18159 		return
  18160 	}
  18161 	y = int32(1)
  18162 	for {
  18163 		if !(y < h-int32(1)) {
  18164 			break
  18165 		}
  18166 		x = int32(1)
  18167 		for {
  18168 			if !(x < w-int32(1)) {
  18169 				break
  18170 			}
  18171 			cnt = [4]int32{}
  18172 			mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(x+w*y)*4
  18173 			majority_seg = int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x60 >> 5))
  18174 			// Check the 8 neighbouring segment values.
  18175 			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
  18176 			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
  18177 			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
  18178 			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
  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 // right
  18180 			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
  18181 			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
  18182 			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
  18183 			n = 0
  18184 			for {
  18185 				if !(n < int32(NUM_MB_SEGMENTS)) {
  18186 					break
  18187 				}
  18188 				if cnt[n] >= majority_cnt_3_x_3_grid {
  18189 					majority_seg = n
  18190 					break
  18191 				}
  18192 				goto _3
  18193 			_3:
  18194 				;
  18195 				n = n + 1
  18196 			}
  18197 			**(**uint8_t)(__ccgo_up(tmp + uintptr(x+y*w))) = libc.Uint8FromInt32(majority_seg)
  18198 			goto _2
  18199 		_2:
  18200 			;
  18201 			x = x + 1
  18202 		}
  18203 		goto _1
  18204 	_1:
  18205 		;
  18206 		y = y + 1
  18207 	}
  18208 	y = int32(1)
  18209 	for {
  18210 		if !(y < h-int32(1)) {
  18211 			break
  18212 		}
  18213 		x = int32(1)
  18214 		for {
  18215 			if !(x < w-int32(1)) {
  18216 				break
  18217 			}
  18218 			mb1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(x+w*y)*4
  18219 			libc.SetBitFieldPtr8Uint32(mb1+0, uint32(**(**uint8_t)(__ccgo_up(tmp + uintptr(x+y*w)))), 5, 0x60)
  18220 			goto _5
  18221 		_5:
  18222 			;
  18223 			x = x + 1
  18224 		}
  18225 		goto _4
  18226 	_4:
  18227 		;
  18228 		y = y + 1
  18229 	}
  18230 	WebPSafeFree(tls, tmp)
  18231 }
  18232 
  18233 //------------------------------------------------------------------------------
  18234 // set segment susceptibility 'alpha' / 'beta'
  18235 
  18236 func clip1(tls *libc.TLS, v int32, m int32, M int32) (r int32) {
  18237 	var v1, v2 int32
  18238 	_, _ = v1, v2
  18239 	if v < m {
  18240 		v1 = m
  18241 	} else {
  18242 		if v > M {
  18243 			v2 = M
  18244 		} else {
  18245 			v2 = v
  18246 		}
  18247 		v1 = v2
  18248 	}
  18249 	return v1
  18250 }
  18251 
  18252 func SetSegmentAlphas(tls *libc.TLS, enc uintptr, centers uintptr, mid int32) {
  18253 	var alpha, beta, max, min, n, nb int32
  18254 	_, _, _, _, _, _ = alpha, beta, max, min, n, nb
  18255 	nb = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  18256 	min = **(**int32)(__ccgo_up(centers))
  18257 	max = **(**int32)(__ccgo_up(centers))
  18258 	if nb > int32(1) {
  18259 		n = 0
  18260 		for {
  18261 			if !(n < nb) {
  18262 				break
  18263 			}
  18264 			if min > **(**int32)(__ccgo_up(centers + uintptr(n)*4)) {
  18265 				min = **(**int32)(__ccgo_up(centers + uintptr(n)*4))
  18266 			}
  18267 			if max < **(**int32)(__ccgo_up(centers + uintptr(n)*4)) {
  18268 				max = **(**int32)(__ccgo_up(centers + uintptr(n)*4))
  18269 			}
  18270 			goto _1
  18271 		_1:
  18272 			;
  18273 			n = n + 1
  18274 		}
  18275 	}
  18276 	if max == min {
  18277 		max = min + int32(1)
  18278 	}
  18279 	n = 0
  18280 	for {
  18281 		if !(n < nb) {
  18282 			break
  18283 		}
  18284 		alpha = int32(255) * (**(**int32)(__ccgo_up(centers + uintptr(n)*4)) - mid) / (max - min)
  18285 		beta = int32(255) * (**(**int32)(__ccgo_up(centers + uintptr(n)*4)) - min) / (max - min)
  18286 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(n)*744))).Falpha = clip1(tls, alpha, -int32(127), int32(127))
  18287 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(n)*744))).Fbeta = clip1(tls, beta, 0, int32(255))
  18288 		goto _2
  18289 	_2:
  18290 		;
  18291 		n = n + 1
  18292 	}
  18293 }
  18294 
  18295 //------------------------------------------------------------------------------
  18296 // Compute susceptibility based on DCT-coeff histograms:
  18297 // the higher, the "easier" the macroblock is to compress.
  18298 
  18299 func FinalAlphaValue(tls *libc.TLS, alpha int32) (r int32) {
  18300 	alpha = int32(MAX_ALPHA) - alpha
  18301 	return clip1(tls, alpha, 0, int32(MAX_ALPHA))
  18302 }
  18303 
  18304 func GetAlpha(tls *libc.TLS, histo uintptr) (r int32) {
  18305 	var alpha, last_non_zero, max_value, v1 int32
  18306 	_, _, _, _ = alpha, last_non_zero, max_value, v1
  18307 	// 'alpha' will later be clipped to [0..MAX_ALPHA] range, clamping outer
  18308 	// values which happen to be mostly noise. This leaves the maximum precision
  18309 	// for handling the useful small values which contribute most.
  18310 	max_value = (*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value
  18311 	last_non_zero = (*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero
  18312 	if max_value > int32(1) {
  18313 		v1 = libc.Int32FromInt32(2) * libc.Int32FromInt32(MAX_ALPHA) * last_non_zero / max_value
  18314 	} else {
  18315 		v1 = 0
  18316 	}
  18317 	alpha = v1
  18318 	return alpha
  18319 }
  18320 
  18321 func InitHistogram(tls *libc.TLS, histo uintptr) {
  18322 	(*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value = 0
  18323 	(*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero = int32(1)
  18324 }
  18325 
  18326 //------------------------------------------------------------------------------
  18327 // Simplified k-Means, to assign Nb segments based on alpha-histogram
  18328 
  18329 func AssignSegments(tls *libc.TLS, enc uintptr, alphas uintptr) {
  18330 	bp := tls.Alloc(48)
  18331 	defer tls.Free(48)
  18332 	var a, alpha, displaced, k, max_a, min_a, n, nb, new_center, range_a, smooth, total_weight, weighted_average, v1 int32
  18333 	var map1 [256]int32
  18334 	var mb uintptr
  18335 	var _ /* accum at bp+16 */ [4]int32
  18336 	var _ /* centers at bp+0 */ [4]int32
  18337 	var _ /* dist_accum at bp+32 */ [4]int32
  18338 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, alpha, displaced, k, map1, max_a, mb, min_a, n, nb, new_center, range_a, smooth, total_weight, weighted_average, v1
  18339 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments < int32(NUM_MB_SEGMENTS) {
  18340 		v1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  18341 	} else {
  18342 		v1 = int32(NUM_MB_SEGMENTS)
  18343 	}
  18344 	// 'num_segments' is previously validated and <= NUM_MB_SEGMENTS, but an
  18345 	// explicit check is needed to avoid spurious warning about 'n + 1' exceeding
  18346 	// array bounds of 'centers' with some compilers (noticed with gcc-4.9).
  18347 	nb = v1
  18348 	weighted_average = 0
  18349 	min_a = 0
  18350 	max_a = int32(MAX_ALPHA)
  18351 	// bracket the input
  18352 	n = 0
  18353 	for {
  18354 		if !(n <= int32(MAX_ALPHA) && **(**int32)(__ccgo_up(alphas + uintptr(n)*4)) == 0) {
  18355 			break
  18356 		}
  18357 		goto _2
  18358 	_2:
  18359 		;
  18360 		n = n + 1
  18361 	}
  18362 	min_a = n
  18363 	n = int32(MAX_ALPHA)
  18364 	for {
  18365 		if !(n > min_a && **(**int32)(__ccgo_up(alphas + uintptr(n)*4)) == 0) {
  18366 			break
  18367 		}
  18368 		goto _3
  18369 	_3:
  18370 		;
  18371 		n = n - 1
  18372 	}
  18373 	max_a = n
  18374 	range_a = max_a - min_a
  18375 	// Spread initial centers evenly
  18376 	k = 0
  18377 	n = libc.Int32FromInt32(1)
  18378 	for {
  18379 		if !(k < nb) {
  18380 			break
  18381 		}
  18382 		(**(**[4]int32)(__ccgo_up(bp)))[k] = min_a + n*range_a/(int32(2)*nb)
  18383 		goto _4
  18384 	_4:
  18385 		;
  18386 		k = k + 1
  18387 		n = n + int32(2)
  18388 	}
  18389 	k = 0
  18390 	for {
  18391 		if !(k < int32(MAX_ITERS_K_MEANS)) {
  18392 			break
  18393 		}
  18394 		// Reset stats
  18395 		n = 0
  18396 		for {
  18397 			if !(n < nb) {
  18398 				break
  18399 			}
  18400 			(**(**[4]int32)(__ccgo_up(bp + 16)))[n] = 0
  18401 			(**(**[4]int32)(__ccgo_up(bp + 32)))[n] = 0
  18402 			goto _6
  18403 		_6:
  18404 			;
  18405 			n = n + 1
  18406 		}
  18407 		// Assign nearest center for each 'a'
  18408 		n = 0 // track the nearest center for current 'a'
  18409 		a = min_a
  18410 		for {
  18411 			if !(a <= max_a) {
  18412 				break
  18413 			}
  18414 			if **(**int32)(__ccgo_up(alphas + uintptr(a)*4)) != 0 {
  18415 				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]) {
  18416 					n = n + 1
  18417 				}
  18418 				map1[a] = n
  18419 				// accumulate contribution into best centroid
  18420 				**(**int32)(__ccgo_up(bp + 32 + uintptr(n)*4)) += a * **(**int32)(__ccgo_up(alphas + uintptr(a)*4))
  18421 				**(**int32)(__ccgo_up(bp + 16 + uintptr(n)*4)) += **(**int32)(__ccgo_up(alphas + uintptr(a)*4))
  18422 			}
  18423 			goto _7
  18424 		_7:
  18425 			;
  18426 			a = a + 1
  18427 		}
  18428 		// All point are classified. Move the centroids to the
  18429 		// center of their respective cloud.
  18430 		displaced = 0
  18431 		weighted_average = 0
  18432 		total_weight = 0
  18433 		n = 0
  18434 		for {
  18435 			if !(n < nb) {
  18436 				break
  18437 			}
  18438 			if (**(**[4]int32)(__ccgo_up(bp + 16)))[n] != 0 {
  18439 				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]
  18440 				displaced = displaced + libc.Xabs(tls, (**(**[4]int32)(__ccgo_up(bp)))[n]-new_center)
  18441 				(**(**[4]int32)(__ccgo_up(bp)))[n] = new_center
  18442 				weighted_average = weighted_average + new_center*(**(**[4]int32)(__ccgo_up(bp + 16)))[n]
  18443 				total_weight = total_weight + (**(**[4]int32)(__ccgo_up(bp + 16)))[n]
  18444 			}
  18445 			goto _8
  18446 		_8:
  18447 			;
  18448 			n = n + 1
  18449 		}
  18450 		weighted_average = (weighted_average + total_weight/int32(2)) / total_weight
  18451 		if displaced < int32(5) {
  18452 			break
  18453 		} // no need to keep on looping...
  18454 		goto _5
  18455 	_5:
  18456 		;
  18457 		k = k + 1
  18458 	}
  18459 	// Map each original value to the closest centroid
  18460 	n = 0
  18461 	for {
  18462 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  18463 			break
  18464 		}
  18465 		mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(n)*4
  18466 		alpha = libc.Int32FromUint8((*VP8MBInfo)(unsafe.Pointer(mb)).Falpha)
  18467 		libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(map1[alpha]), 5, 0x60)
  18468 		(*VP8MBInfo)(unsafe.Pointer(mb)).Falpha = libc.Uint8FromInt32((**(**[4]int32)(__ccgo_up(bp)))[map1[alpha]]) // for the record.
  18469 		goto _9
  18470 	_9:
  18471 		;
  18472 		n = n + 1
  18473 	}
  18474 	if nb > int32(1) {
  18475 		smooth = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpreprocessing & libc.Int32FromInt32(1)
  18476 		if smooth != 0 {
  18477 			SmoothSegmentMap(tls, enc)
  18478 		}
  18479 	}
  18480 	SetSegmentAlphas(tls, enc, bp, weighted_average) // pick some alphas.
  18481 }
  18482 
  18483 //------------------------------------------------------------------------------
  18484 // Macroblock analysis: collect histogram for each mode, deduce the maximal
  18485 // susceptibility and set best modes for this macroblock.
  18486 // Segment assignment is done later.
  18487 
  18488 // Number of modes to inspect for 'alpha' evaluation. We don't need to test all
  18489 // the possible modes during the analysis phase: we risk falling into a local
  18490 // optimum, or be subject to boundary effect
  18491 
  18492 func MBAnalyzeBestIntra16Mode(tls *libc.TLS, it uintptr) (r int32) {
  18493 	bp := tls.Alloc(16)
  18494 	defer tls.Free(16)
  18495 	var alpha, best_alpha, best_mode, max_mode, mode int32
  18496 	var _ /* histo at bp+0 */ VP8Histogram
  18497 	_, _, _, _, _ = alpha, best_alpha, best_mode, max_mode, mode
  18498 	max_mode = int32(MAX_INTRA16_MODE)
  18499 	best_alpha = -int32(1)
  18500 	best_mode = 0
  18501 	VP8MakeLuma16Preds(tls, it)
  18502 	mode = 0
  18503 	for {
  18504 		if !(mode < max_mode) {
  18505 			break
  18506 		}
  18507 		InitHistogram(tls, bp)
  18508 		(*(*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)
  18509 		alpha = GetAlpha(tls, bp)
  18510 		if alpha > best_alpha {
  18511 			best_alpha = alpha
  18512 			best_mode = mode
  18513 		}
  18514 		goto _1
  18515 	_1:
  18516 		;
  18517 		mode = mode + 1
  18518 	}
  18519 	VP8SetIntra16Mode(tls, it, best_mode)
  18520 	return best_alpha
  18521 }
  18522 
  18523 func FastMBAnalyze(tls *libc.TLS, it uintptr) (r int32) {
  18524 	bp := tls.Alloc(80)
  18525 	defer tls.Free(80)
  18526 	var k, q int32
  18527 	var kThreshold, m, m2 uint32_t
  18528 	var _ /* dc at bp+0 */ [16]uint32_t
  18529 	var _ /* modes at bp+64 */ [16]uint8_t
  18530 	_, _, _, _, _ = k, kThreshold, m, m2, q
  18531 	// Empirical cut-off value, should be around 16 (~=block size). We use the
  18532 	// [8-17] range and favor intra4 at high quality, intra16 for low quality.
  18533 	q = int32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fconfig)).Fquality)
  18534 	kThreshold = libc.Uint32FromInt32(int32(8) + (libc.Int32FromInt32(17)-libc.Int32FromInt32(8))*q/int32(100))
  18535 	k = 0
  18536 	for {
  18537 		if !(k < int32(16)) {
  18538 			break
  18539 		}
  18540 		(*(*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)
  18541 		goto _1
  18542 	_1:
  18543 		;
  18544 		k = k + int32(4)
  18545 	}
  18546 	m = uint32(0)
  18547 	m2 = uint32(0)
  18548 	k = libc.Int32FromInt32(0)
  18549 	for {
  18550 		if !(k < int32(16)) {
  18551 			break
  18552 		}
  18553 		m = m + (**(**[16]uint32_t)(__ccgo_up(bp)))[k]
  18554 		m2 = m2 + (**(**[16]uint32_t)(__ccgo_up(bp)))[k]*(**(**[16]uint32_t)(__ccgo_up(bp)))[k]
  18555 		goto _2
  18556 	_2:
  18557 		;
  18558 		k = k + 1
  18559 	}
  18560 	if kThreshold*m2 < m*m {
  18561 		VP8SetIntra16Mode(tls, it, 0) // DC16
  18562 	} else {
  18563 		**(**[16]uint8_t)(__ccgo_up(bp + 64)) = [16]uint8_t{} // DC4
  18564 		VP8SetIntra4Mode(tls, it, bp+64)
  18565 	}
  18566 	return 0
  18567 }
  18568 
  18569 func MBAnalyzeBestUVMode(tls *libc.TLS, it uintptr) (r int32) {
  18570 	bp := tls.Alloc(16)
  18571 	defer tls.Free(16)
  18572 	var alpha, best_alpha, best_mode, max_mode, mode, smallest_alpha int32
  18573 	var _ /* histo at bp+0 */ VP8Histogram
  18574 	_, _, _, _, _, _ = alpha, best_alpha, best_mode, max_mode, mode, smallest_alpha
  18575 	best_alpha = -int32(1)
  18576 	smallest_alpha = 0
  18577 	best_mode = 0
  18578 	max_mode = int32(MAX_UV_MODE)
  18579 	VP8MakeChroma8Preds(tls, it)
  18580 	mode = 0
  18581 	for {
  18582 		if !(mode < max_mode) {
  18583 			break
  18584 		}
  18585 		InitHistogram(tls, bp)
  18586 		(*(*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)
  18587 		alpha = GetAlpha(tls, bp)
  18588 		if alpha > best_alpha {
  18589 			best_alpha = alpha
  18590 		}
  18591 		// The best prediction mode tends to be the one with the smallest alpha.
  18592 		if mode == 0 || alpha < smallest_alpha {
  18593 			smallest_alpha = alpha
  18594 			best_mode = mode
  18595 		}
  18596 		goto _1
  18597 	_1:
  18598 		;
  18599 		mode = mode + 1
  18600 	}
  18601 	VP8SetIntraUVMode(tls, it, best_mode)
  18602 	return best_alpha
  18603 }
  18604 
  18605 func MBAnalyze(tls *libc.TLS, it uintptr, alphas uintptr, alpha uintptr, uv_alpha uintptr) {
  18606 	var best_alpha, best_uv_alpha int32
  18607 	var enc uintptr
  18608 	_, _, _ = best_alpha, best_uv_alpha, enc
  18609 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  18610 	VP8SetIntra16Mode(tls, it, 0) // default: Intra16, DC_PRED
  18611 	VP8SetSkip(tls, it, 0)        // not skipped
  18612 	VP8SetSegment(tls, it, 0)     // default segment, spec-wise.
  18613 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod <= int32(1) {
  18614 		best_alpha = FastMBAnalyze(tls, it)
  18615 	} else {
  18616 		best_alpha = MBAnalyzeBestIntra16Mode(tls, it)
  18617 	}
  18618 	best_uv_alpha = MBAnalyzeBestUVMode(tls, it)
  18619 	// Final susceptibility mix
  18620 	best_alpha = (int32(3)*best_alpha + best_uv_alpha + int32(2)) >> int32(2)
  18621 	best_alpha = FinalAlphaValue(tls, best_alpha)
  18622 	**(**int32)(__ccgo_up(alphas + uintptr(best_alpha)*4)) = **(**int32)(__ccgo_up(alphas + uintptr(best_alpha)*4)) + 1
  18623 	(*VP8MBInfo)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb)).Falpha = libc.Uint8FromInt32(best_alpha) // for later remapping.
  18624 	// Accumulate for later complexity analysis.
  18625 	**(**int32)(__ccgo_up(alpha)) += best_alpha // mixed susceptibility (not just luma)
  18626 	**(**int32)(__ccgo_up(uv_alpha)) += best_uv_alpha
  18627 }
  18628 
  18629 func DefaultMBInfo(tls *libc.TLS, mb uintptr) {
  18630 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(1), 0, 0x3) // I16x16
  18631 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 2, 0xc)
  18632 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 4, 0x10) // not skipped
  18633 	libc.SetBitFieldPtr8Uint32(mb+0, libc.Uint32FromInt32(0), 5, 0x60) // default segment
  18634 	(*VP8MBInfo)(unsafe.Pointer(mb)).Falpha = uint8(0)
  18635 }
  18636 
  18637 //------------------------------------------------------------------------------
  18638 // Main analysis loop:
  18639 // Collect all susceptibilities for each macroblock and record their
  18640 // distribution in alphas[]. Segments is assigned a-posteriori, based on
  18641 // this histogram.
  18642 // We also pick an intra16 prediction mode, which shouldn't be considered
  18643 // final except for fast-encode settings. We can also pick some intra4 modes
  18644 // and decide intra4/intra16, but that's usually almost always a bad choice at
  18645 // this stage.
  18646 
  18647 func ResetAllMBInfo(tls *libc.TLS, enc uintptr) {
  18648 	var n int32
  18649 	_ = n
  18650 	n = 0
  18651 	for {
  18652 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  18653 			break
  18654 		}
  18655 		DefaultMBInfo(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info+uintptr(n)*4)
  18656 		goto _1
  18657 	_1:
  18658 		;
  18659 		n = n + 1
  18660 	}
  18661 	// Default susceptibilities.
  18662 	(**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Falpha = 0
  18663 	(**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Fbeta = 0
  18664 	// Note: we can't compute this 'alpha' / 'uv_alpha' -> set to default value.
  18665 	(*VP8Encoder)(unsafe.Pointer(enc)).Falpha = 0
  18666 	(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_alpha = 0
  18667 	WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+int32(20), enc+536)
  18668 }
  18669 
  18670 // C documentation
  18671 //
  18672 //	// struct used to collect job result
  18673 type SegmentJob = struct {
  18674 	Fworker         WebPWorker
  18675 	Falphas         [256]int32
  18676 	Falpha          int32
  18677 	Fuv_alpha       int32
  18678 	Fit             VP8EncIterator
  18679 	Fdelta_progress int32
  18680 }
  18681 
  18682 // C documentation
  18683 //
  18684 //	// main work call
  18685 func DoSegmentsJob(tls *libc.TLS, arg1 uintptr, arg2 uintptr) (r int32) {
  18686 	bp := tls.Alloc(64)
  18687 	defer tls.Free(64)
  18688 	var it, job, scratch uintptr
  18689 	var ok int32
  18690 	var _ /* tmp at bp+0 */ [63]uint8_t
  18691 	_, _, _, _ = it, job, ok, scratch
  18692 	job = arg1
  18693 	it = arg2
  18694 	ok = int32(1)
  18695 	if !(VP8IteratorIsDone(tls, it) != 0) {
  18696 		scratch = uintptr((uintptr_t(bp) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  18697 		for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, it) != 0 {
  18698 			// Let's pretend we have perfect lossless reconstruction.
  18699 			VP8IteratorImport(tls, it, scratch)
  18700 			MBAnalyze(tls, it, job+48, job+1072, job+1076)
  18701 			ok = VP8IteratorProgress(tls, it, (*SegmentJob)(unsafe.Pointer(job)).Fdelta_progress)
  18702 		}
  18703 	}
  18704 	return ok
  18705 }
  18706 
  18707 // C documentation
  18708 //
  18709 //	// initialize the job struct with some tasks to perform
  18710 func InitSegmentJob(tls *libc.TLS, enc uintptr, job uintptr, start_row int32, end_row int32) {
  18711 	var v1 int32
  18712 	_ = v1
  18713 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(WebPGetWorkerInterface(tls))).FInit})))(tls, job)
  18714 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fdata1 = job
  18715 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fdata2 = job + 1080
  18716 	(*SegmentJob)(unsafe.Pointer(job)).Fworker.Fhook = __ccgo_fp(DoSegmentsJob)
  18717 	VP8IteratorInit(tls, enc, job+1080)
  18718 	VP8IteratorSetRow(tls, job+1080, start_row)
  18719 	VP8IteratorSetCountDown(tls, job+1080, (end_row-start_row)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)
  18720 	libc.X__builtin___memset_chk(tls, job+48, 0, uint64(1024), ^__predefined_size_t(0))
  18721 	(*SegmentJob)(unsafe.Pointer(job)).Falpha = 0
  18722 	(*SegmentJob)(unsafe.Pointer(job)).Fuv_alpha = 0
  18723 	// only one of both jobs can record the progress, since we don't
  18724 	// expect the user's hook to be multi-thread safe
  18725 	if start_row == 0 {
  18726 		v1 = int32(20)
  18727 	} else {
  18728 		v1 = 0
  18729 	}
  18730 	(*SegmentJob)(unsafe.Pointer(job)).Fdelta_progress = v1
  18731 }
  18732 
  18733 // C documentation
  18734 //
  18735 //	// main entry point
  18736 func VP8EncAnalyze(tls *libc.TLS, enc uintptr) (r int32) {
  18737 	bp := tls.Alloc(4944)
  18738 	defer tls.Free(4944)
  18739 	var do_mt, do_segments, last_row, ok, total_mb int32
  18740 	var worker_interface uintptr
  18741 	var _ /* main_job at bp+0 */ SegmentJob
  18742 	_, _, _, _, _, _ = do_mt, do_segments, last_row, ok, total_mb, worker_interface
  18743 	ok = int32(1)
  18744 	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.
  18745 	if do_segments != 0 {
  18746 		last_row = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  18747 		total_mb = last_row * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w
  18748 		do_mt = 0
  18749 		worker_interface = WebPGetWorkerInterface(tls)
  18750 		if do_mt != 0 {
  18751 		} else {
  18752 			// Even for single-thread case, we use the generic Worker tools.
  18753 			InitSegmentJob(tls, enc, bp, 0, last_row)
  18754 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FExecute})))(tls, bp)
  18755 			ok = ok & (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp)
  18756 		}
  18757 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp)
  18758 		if ok != 0 {
  18759 			(*VP8Encoder)(unsafe.Pointer(enc)).Falpha = (**(**SegmentJob)(__ccgo_up(bp))).Falpha / total_mb
  18760 			(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_alpha = (**(**SegmentJob)(__ccgo_up(bp))).Fuv_alpha / total_mb
  18761 			AssignSegments(tls, enc, bp+48)
  18762 		}
  18763 	} else { // Use only one default segment.
  18764 		ResetAllMBInfo(tls, enc)
  18765 	}
  18766 	if !(ok != 0) {
  18767 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY)) // imprecise
  18768 	}
  18769 	return ok
  18770 }
  18771 
  18772 const COST_CACHE_INTERVAL_SIZE_MAX = 500
  18773 const COST_MANAGER_MAX_FREE_LIST = 10
  18774 const VALUES_IN_BYTE = 256
  18775 
  18776 var kHashMul10 = uint32(0x1e35a7bd)
  18777 
  18778 type CostModel = struct {
  18779 	Falpha    [256]uint32_t
  18780 	Fred      [256]uint32_t
  18781 	Fblue     [256]uint32_t
  18782 	Fdistance [40]uint32_t
  18783 	Fliteral  uintptr
  18784 }
  18785 
  18786 func ConvertPopulationCountTableToBitEstimates(tls *libc.TLS, num_symbols int32, population_counts uintptr, output uintptr) {
  18787 	var i, nonzeros int32
  18788 	var logsum, sum, v2, v3, v7, v8 uint32_t
  18789 	var v10, v5 uint32
  18790 	_, _, _, _, _, _, _, _, _, _ = i, logsum, nonzeros, sum, v10, v2, v3, v5, v7, v8
  18791 	sum = uint32(0)
  18792 	nonzeros = 0
  18793 	i = 0
  18794 	for {
  18795 		if !(i < num_symbols) {
  18796 			break
  18797 		}
  18798 		sum = sum + **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4))
  18799 		if **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4)) > uint32(0) {
  18800 			nonzeros = nonzeros + 1
  18801 		}
  18802 		goto _1
  18803 	_1:
  18804 		;
  18805 		i = i + 1
  18806 	}
  18807 	if nonzeros <= int32(1) {
  18808 		libc.X__builtin___memset_chk(tls, output, 0, libc.Uint64FromInt32(num_symbols)*uint64(4), ^__predefined_size_t(0))
  18809 	} else {
  18810 		v2 = sum
  18811 		if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  18812 			v5 = kLog2Table[v2]
  18813 		} else {
  18814 			v5 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v2)
  18815 		}
  18816 		v3 = v5
  18817 		goto _4
  18818 	_4:
  18819 		logsum = v3
  18820 		i = 0
  18821 		for {
  18822 			if !(i < num_symbols) {
  18823 				break
  18824 			}
  18825 			v7 = **(**uint32_t)(__ccgo_up(population_counts + uintptr(i)*4))
  18826 			if v7 < uint32(LOG_LOOKUP_IDX_MAX) {
  18827 				v10 = kLog2Table[v7]
  18828 			} else {
  18829 				v10 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v7)
  18830 			}
  18831 			v8 = v10
  18832 			goto _9
  18833 		_9:
  18834 			**(**uint32_t)(__ccgo_up(output + uintptr(i)*4)) = logsum - v8
  18835 			goto _6
  18836 		_6:
  18837 			;
  18838 			i = i + 1
  18839 		}
  18840 	}
  18841 }
  18842 
  18843 func CostModelBuild(tls *libc.TLS, m uintptr, xsize int32, cache_bits int32, refs uintptr) (r int32) {
  18844 	var histo uintptr
  18845 	var ok, v1, v2, v4 int32
  18846 	_, _, _, _, _ = histo, ok, v1, v2, v4
  18847 	ok = 0
  18848 	histo = VP8LAllocateHistogram(tls, cache_bits)
  18849 	if histo == libc.UintptrFromInt32(0) {
  18850 		goto Error
  18851 	}
  18852 	// The following code is similar to VP8LHistogramCreate but converts the
  18853 	// distance to plane code.
  18854 	VP8LHistogramInit(tls, histo, cache_bits, int32(1))
  18855 	VP8LHistogramStoreRefs(tls, refs, __ccgo_fp(VP8LDistanceToPlaneCode), xsize, histo)
  18856 	v1 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  18857 	if v1 > 0 {
  18858 		v4 = int32(1) << v1
  18859 	} else {
  18860 		v4 = 0
  18861 	}
  18862 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  18863 	goto _3
  18864 _3:
  18865 	ConvertPopulationCountTableToBitEstimates(tls, v2, (*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral, (*CostModel)(unsafe.Pointer(m)).Fliteral)
  18866 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+8, m+1024)
  18867 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+1032, m+2048)
  18868 	ConvertPopulationCountTableToBitEstimates(tls, int32(VALUES_IN_BYTE), histo+2056, m)
  18869 	ConvertPopulationCountTableToBitEstimates(tls, int32(NUM_DISTANCE_CODES), histo+3080, m+3072)
  18870 	ok = int32(1)
  18871 	goto Error
  18872 Error:
  18873 	;
  18874 	VP8LFreeHistogram(tls, histo)
  18875 	return ok
  18876 }
  18877 
  18878 func GetLiteralCost(tls *libc.TLS, m uintptr, v uint32_t) (r int64_t) {
  18879 	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)))
  18880 }
  18881 
  18882 func GetCacheCost(tls *libc.TLS, m uintptr, idx uint32_t) (r int64_t) {
  18883 	var literal_idx int32
  18884 	_ = literal_idx
  18885 	literal_idx = libc.Int32FromUint32(libc.Uint32FromInt32(libc.Int32FromInt32(VALUES_IN_BYTE)+libc.Int32FromInt32(NUM_LENGTH_CODES)) + idx)
  18886 	return libc.Int64FromUint32(**(**uint32_t)(__ccgo_up((*CostModel)(unsafe.Pointer(m)).Fliteral + uintptr(literal_idx)*4)))
  18887 }
  18888 
  18889 func GetLengthCost(tls *libc.TLS, m uintptr, length uint32_t) (r int64_t) {
  18890 	bp := tls.Alloc(16)
  18891 	defer tls.Free(16)
  18892 	var highest_bit, second_highest_bit, v1, v4, v5, v6 int32
  18893 	var prefix_code VP8LPrefixCode
  18894 	var v2, v3 uintptr
  18895 	var _ /* code at bp+0 */ int32
  18896 	var _ /* extra_bits at bp+4 */ int32
  18897 	_, _, _, _, _, _, _, _, _ = highest_bit, prefix_code, second_highest_bit, v1, v2, v3, v4, v5, v6
  18898 	v1 = libc.Int32FromUint32(length)
  18899 	v2 = bp
  18900 	v3 = bp + 4
  18901 	if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  18902 		prefix_code = kPrefixEncodeCode[v1]
  18903 		**(**int32)(__ccgo_up(v2)) = int32(prefix_code.Fcode)
  18904 		**(**int32)(__ccgo_up(v3)) = int32(prefix_code.Fextra_bits)
  18905 	} else {
  18906 		v4 = v1
  18907 		v4 = v4 - 1
  18908 		v5 = v4
  18909 		v6 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  18910 		goto _7
  18911 	_7:
  18912 		highest_bit = v6
  18913 		second_highest_bit = v4 >> (highest_bit - int32(1)) & int32(1)
  18914 		**(**int32)(__ccgo_up(v3)) = highest_bit - int32(1)
  18915 		**(**int32)(__ccgo_up(v2)) = int32(2)*highest_bit + second_highest_bit
  18916 	}
  18917 	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)
  18918 }
  18919 
  18920 func GetDistanceCost(tls *libc.TLS, m uintptr, distance2 uint32_t) (r int64_t) {
  18921 	bp := tls.Alloc(16)
  18922 	defer tls.Free(16)
  18923 	var highest_bit, second_highest_bit, v1, v4, v5, v6 int32
  18924 	var prefix_code VP8LPrefixCode
  18925 	var v2, v3 uintptr
  18926 	var _ /* code at bp+0 */ int32
  18927 	var _ /* extra_bits at bp+4 */ int32
  18928 	_, _, _, _, _, _, _, _, _ = highest_bit, prefix_code, second_highest_bit, v1, v2, v3, v4, v5, v6
  18929 	v1 = libc.Int32FromUint32(distance2)
  18930 	v2 = bp
  18931 	v3 = bp + 4
  18932 	if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  18933 		prefix_code = kPrefixEncodeCode[v1]
  18934 		**(**int32)(__ccgo_up(v2)) = int32(prefix_code.Fcode)
  18935 		**(**int32)(__ccgo_up(v3)) = int32(prefix_code.Fextra_bits)
  18936 	} else {
  18937 		v4 = v1
  18938 		v4 = v4 - 1
  18939 		v5 = v4
  18940 		v6 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  18941 		goto _7
  18942 	_7:
  18943 		highest_bit = v6
  18944 		second_highest_bit = v4 >> (highest_bit - int32(1)) & int32(1)
  18945 		**(**int32)(__ccgo_up(v3)) = highest_bit - int32(1)
  18946 		**(**int32)(__ccgo_up(v2)) = int32(2)*highest_bit + second_highest_bit
  18947 	}
  18948 	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)
  18949 }
  18950 
  18951 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) {
  18952 	var color, v3 uint32_t
  18953 	var cost_val, v10, v11, v9 int64_t
  18954 	var ix, key, key1, v1, v4, v6, v8 int32
  18955 	var v13 int64
  18956 	var v2 uintptr
  18957 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = color, cost_val, ix, key, key1, v1, v10, v11, v13, v2, v3, v4, v6, v8, v9
  18958 	cost_val = prev_cost
  18959 	color = **(**uint32_t)(__ccgo_up(argb3 + uintptr(idx)*4))
  18960 	if use_color_cache != 0 {
  18961 		v2 = hashers
  18962 		v3 = color
  18963 		v4 = libc.Int32FromUint32(v3 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  18964 		goto _5
  18965 	_5:
  18966 		key1 = v4
  18967 		if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key1)*4)) == v3 {
  18968 			v8 = key1
  18969 		} else {
  18970 			v8 = -int32(1)
  18971 		}
  18972 		v6 = v8
  18973 		goto _7
  18974 	_7:
  18975 		v1 = v6
  18976 	} else {
  18977 		v1 = -int32(1)
  18978 	}
  18979 	ix = v1
  18980 	if ix >= 0 {
  18981 		// use_color_cache is true and hashers contains color
  18982 		v9 = GetCacheCost(tls, cost_model, libc.Uint32FromInt32(ix)) * int64(68)
  18983 		v10 = int64(100)
  18984 		if libc.BoolInt32(v9 < 0) == libc.BoolInt32(v10 < 0) {
  18985 			v13 = (v9 + v10/int64(2)) / v10
  18986 		} else {
  18987 			v13 = (v9 - v10/int64(2)) / v10
  18988 		}
  18989 		v11 = v13
  18990 		goto _12
  18991 	_12:
  18992 		cost_val = cost_val + v11
  18993 	} else {
  18994 		if use_color_cache != 0 {
  18995 			v2 = hashers
  18996 			v3 = color
  18997 			v1 = libc.Int32FromUint32(v3 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  18998 			goto _17
  18999 		_17:
  19000 			key = v1
  19001 			**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key)*4)) = v3
  19002 		}
  19003 		v9 = GetLiteralCost(tls, cost_model, color) * int64(82)
  19004 		v10 = int64(100)
  19005 		if libc.BoolInt32(v9 < 0) == libc.BoolInt32(v10 < 0) {
  19006 			v13 = (v9 + v10/int64(2)) / v10
  19007 		} else {
  19008 			v13 = (v9 - v10/int64(2)) / v10
  19009 		}
  19010 		v11 = v13
  19011 		goto _21
  19012 	_21:
  19013 		cost_val = cost_val + v11
  19014 	}
  19015 	if **(**int64_t)(__ccgo_up(cost + uintptr(idx)*8)) > cost_val {
  19016 		**(**int64_t)(__ccgo_up(cost + uintptr(idx)*8)) = cost_val
  19017 		**(**uint16_t)(__ccgo_up(dist_array + uintptr(idx)*2)) = uint16(1) // only one is inserted.
  19018 	}
  19019 }
  19020 
  19021 // -----------------------------------------------------------------------------
  19022 // CostManager and interval handling
  19023 
  19024 // Empirical value to avoid high memory consumption but good for performance.
  19025 
  19026 // C documentation
  19027 //
  19028 //	// To perform backward reference every pixel at index 'index' is considered and
  19029 //	// the cost for the MAX_LENGTH following pixels computed. Those following pixels
  19030 //	// at index 'index' + k (k from 0 to MAX_LENGTH) have a cost of:
  19031 //	//     cost = distance cost at index + GetLengthCost(cost_model, k)
  19032 //	// and the minimum value is kept. GetLengthCost(cost_model, k) is cached in an
  19033 //	// array of size MAX_LENGTH.
  19034 //	// Instead of performing MAX_LENGTH comparisons per pixel, we keep track of the
  19035 //	// minimal values using intervals of constant cost.
  19036 //	// An interval is defined by the 'index' of the pixel that generated it and
  19037 //	// is only useful in a range of indices from 'start' to 'end' (exclusive), i.e.
  19038 //	// it contains the minimum value for pixels between start and end.
  19039 //	// Intervals are stored in a linked list and ordered by 'start'. When a new
  19040 //	// interval has a better value, old intervals are split or removed. There are
  19041 //	// therefore no overlapping intervals.
  19042 type CostInterval = struct {
  19043 	Fcost     int64_t
  19044 	Fstart    int32
  19045 	Fend      int32
  19046 	Findex    int32
  19047 	Fprevious uintptr
  19048 	Fnext     uintptr
  19049 }
  19050 
  19051 // C documentation
  19052 //
  19053 //	// The GetLengthCost(cost_model, k) are cached in a CostCacheInterval.
  19054 type CostCacheInterval = struct {
  19055 	Fcost  int64_t
  19056 	Fstart int32
  19057 	Fend   int32
  19058 }
  19059 
  19060 // C documentation
  19061 //
  19062 //	// This structure is in charge of managing intervals and costs.
  19063 //	// It caches the different CostCacheInterval, caches the different
  19064 //	// GetLengthCost(cost_model, k) in cost_cache and the CostInterval's (whose
  19065 //	// 'count' is limited by COST_CACHE_INTERVAL_SIZE_MAX).
  19066 type CostManager = struct {
  19067 	Fhead                 uintptr
  19068 	Fcount                int32
  19069 	Fcache_intervals      uintptr
  19070 	Fcache_intervals_size size_t
  19071 	Fcost_cache           [4095]int64_t
  19072 	Fcosts                uintptr
  19073 	Fdist_array           uintptr
  19074 	Fintervals            [10]CostInterval
  19075 	Ffree_intervals       uintptr
  19076 	Frecycled_intervals   uintptr
  19077 }
  19078 
  19079 func CostIntervalAddToFreeList(tls *libc.TLS, manager uintptr, interval uintptr) {
  19080 	(*CostInterval)(unsafe.Pointer(interval)).Fnext = (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals
  19081 	(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = interval
  19082 }
  19083 
  19084 func CostIntervalIsInFreeList(tls *libc.TLS, manager uintptr, interval uintptr) (r int32) {
  19085 	return libc.BoolInt32(interval >= manager+32808 && interval <= manager+32808+uintptr(libc.Int32FromInt32(COST_MANAGER_MAX_FREE_LIST)-libc.Int32FromInt32(1))*40)
  19086 }
  19087 
  19088 func CostManagerInitFreeList(tls *libc.TLS, manager uintptr) {
  19089 	var i int32
  19090 	_ = i
  19091 	(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = libc.UintptrFromInt32(0)
  19092 	i = 0
  19093 	for {
  19094 		if !(i < int32(COST_MANAGER_MAX_FREE_LIST)) {
  19095 			break
  19096 		}
  19097 		CostIntervalAddToFreeList(tls, manager, manager+32808+uintptr(i)*40)
  19098 		goto _1
  19099 	_1:
  19100 		;
  19101 		i = i + 1
  19102 	}
  19103 }
  19104 
  19105 func DeleteIntervalList(tls *libc.TLS, manager uintptr, interval uintptr) {
  19106 	var next uintptr
  19107 	_ = next
  19108 	for interval != libc.UintptrFromInt32(0) {
  19109 		next = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19110 		if !(CostIntervalIsInFreeList(tls, manager, interval) != 0) {
  19111 			WebPSafeFree(tls, interval)
  19112 		} // else: do nothing
  19113 		interval = next
  19114 	}
  19115 }
  19116 
  19117 func CostManagerClear(tls *libc.TLS, manager uintptr) {
  19118 	if manager == libc.UintptrFromInt32(0) {
  19119 		return
  19120 	}
  19121 	WebPSafeFree(tls, (*CostManager)(unsafe.Pointer(manager)).Fcosts)
  19122 	WebPSafeFree(tls, (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals)
  19123 	// Clear the interval lists.
  19124 	DeleteIntervalList(tls, manager, (*CostManager)(unsafe.Pointer(manager)).Fhead)
  19125 	(*CostManager)(unsafe.Pointer(manager)).Fhead = libc.UintptrFromInt32(0)
  19126 	DeleteIntervalList(tls, manager, (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals)
  19127 	(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = libc.UintptrFromInt32(0)
  19128 	// Reset pointers, 'count' and 'cache_intervals_size'.
  19129 	libc.X__builtin___memset_chk(tls, manager, 0, uint64(33224), ^__predefined_size_t(0))
  19130 	CostManagerInitFreeList(tls, manager)
  19131 }
  19132 
  19133 func CostManagerInit(tls *libc.TLS, manager uintptr, dist_array uintptr, pix_count int32, cost_model uintptr) (r int32) {
  19134 	var cost_cache_size, i, v1 int32
  19135 	var cost_val int64_t
  19136 	var cur uintptr
  19137 	_, _, _, _, _ = cost_cache_size, cost_val, cur, i, v1
  19138 	if pix_count > libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  19139 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  19140 	} else {
  19141 		v1 = pix_count
  19142 	}
  19143 	cost_cache_size = v1
  19144 	(*CostManager)(unsafe.Pointer(manager)).Fcosts = libc.UintptrFromInt32(0)
  19145 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals = libc.UintptrFromInt32(0)
  19146 	(*CostManager)(unsafe.Pointer(manager)).Fhead = libc.UintptrFromInt32(0)
  19147 	(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = libc.UintptrFromInt32(0)
  19148 	(*CostManager)(unsafe.Pointer(manager)).Fcount = 0
  19149 	(*CostManager)(unsafe.Pointer(manager)).Fdist_array = dist_array
  19150 	CostManagerInitFreeList(tls, manager)
  19151 	// Fill in the 'cost_cache'.
  19152 	// Has to be done in two passes due to a GCC bug on i686
  19153 	// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
  19154 	i = 0
  19155 	for {
  19156 		if !(i < cost_cache_size) {
  19157 			break
  19158 		}
  19159 		**(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8)) = GetLengthCost(tls, cost_model, libc.Uint32FromInt32(i))
  19160 		goto _2
  19161 	_2:
  19162 		;
  19163 		i = i + 1
  19164 	}
  19165 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size = uint64(1)
  19166 	i = int32(1)
  19167 	for {
  19168 		if !(i < cost_cache_size) {
  19169 			break
  19170 		}
  19171 		// Get the number of bound intervals.
  19172 		if **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8)) != **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i-int32(1))*8)) {
  19173 			(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size + 1
  19174 		}
  19175 		goto _3
  19176 	_3:
  19177 		;
  19178 		i = i + 1
  19179 	}
  19180 	// With the current cost model, we usually have below 20 intervals.
  19181 	// The worst case scenario with a cost model would be if every length has a
  19182 	// different cost, hence MAX_LENGTH but that is impossible with the current
  19183 	// implementation that spirals around a pixel.
  19184 	(*CostManager)(unsafe.Pointer(manager)).Fcache_intervals = WebPSafeMalloc(tls, (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size, uint64(16))
  19185 	if (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals == libc.UintptrFromInt32(0) {
  19186 		CostManagerClear(tls, manager)
  19187 		return 0
  19188 	}
  19189 	// Fill in the 'cache_intervals'.
  19190 	cur = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals
  19191 	// Consecutive values in 'cost_cache' are compared and if a big enough
  19192 	// difference is found, a new interval is created and bounded.
  19193 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fstart = 0
  19194 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fend = int32(1)
  19195 	(*CostCacheInterval)(unsafe.Pointer(cur)).Fcost = **(**int64_t)(__ccgo_up(manager + 32))
  19196 	i = int32(1)
  19197 	for {
  19198 		if !(i < cost_cache_size) {
  19199 			break
  19200 		}
  19201 		cost_val = **(**int64_t)(__ccgo_up(manager + 32 + uintptr(i)*8))
  19202 		if cost_val != (*CostCacheInterval)(unsafe.Pointer(cur)).Fcost {
  19203 			cur += 16
  19204 			// Initialize an interval.
  19205 			(*CostCacheInterval)(unsafe.Pointer(cur)).Fstart = i
  19206 			(*CostCacheInterval)(unsafe.Pointer(cur)).Fcost = cost_val
  19207 		}
  19208 		(*CostCacheInterval)(unsafe.Pointer(cur)).Fend = i + int32(1)
  19209 		goto _4
  19210 	_4:
  19211 		;
  19212 		i = i + 1
  19213 	}
  19214 	(*CostManager)(unsafe.Pointer(manager)).Fcosts = WebPSafeMalloc(tls, libc.Uint64FromInt32(pix_count), uint64(8))
  19215 	if (*CostManager)(unsafe.Pointer(manager)).Fcosts == libc.UintptrFromInt32(0) {
  19216 		CostManagerClear(tls, manager)
  19217 		return 0
  19218 	}
  19219 	// Set the initial 'costs' to INT64_MAX for every pixel as we will keep the
  19220 	// minimum.
  19221 	i = 0
  19222 	for {
  19223 		if !(i < pix_count) {
  19224 			break
  19225 		}
  19226 		**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  19227 		goto _5
  19228 	_5:
  19229 		;
  19230 		i = i + 1
  19231 	}
  19232 	return int32(1)
  19233 }
  19234 
  19235 // C documentation
  19236 //
  19237 //	// Given the cost and the position that define an interval, update the cost at
  19238 //	// pixel 'i' if it is smaller than the previously computed value.
  19239 func UpdateCost(tls *libc.TLS, manager uintptr, i int32, position int32, cost int64_t) {
  19240 	var k int32
  19241 	_ = k
  19242 	k = i - position
  19243 	if **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) > cost {
  19244 		**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(i)*8)) = cost
  19245 		**(**uint16_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fdist_array + uintptr(i)*2)) = libc.Uint16FromInt32(k + int32(1))
  19246 	}
  19247 }
  19248 
  19249 // C documentation
  19250 //
  19251 //	// Given the cost and the position that define an interval, update the cost for
  19252 //	// all the pixels between 'start' and 'end' excluded.
  19253 func UpdateCostPerInterval(tls *libc.TLS, manager uintptr, start int32, end int32, position int32, cost int64_t) {
  19254 	var i int32
  19255 	_ = i
  19256 	i = start
  19257 	for {
  19258 		if !(i < end) {
  19259 			break
  19260 		}
  19261 		UpdateCost(tls, manager, i, position, cost)
  19262 		goto _1
  19263 	_1:
  19264 		;
  19265 		i = i + 1
  19266 	}
  19267 }
  19268 
  19269 // C documentation
  19270 //
  19271 //	// Given two intervals, make 'prev' be the previous one of 'next' in 'manager'.
  19272 func ConnectIntervals(tls *libc.TLS, manager uintptr, prev uintptr, next uintptr) {
  19273 	if prev != libc.UintptrFromInt32(0) {
  19274 		(*CostInterval)(unsafe.Pointer(prev)).Fnext = next
  19275 	} else {
  19276 		(*CostManager)(unsafe.Pointer(manager)).Fhead = next
  19277 	}
  19278 	if next != libc.UintptrFromInt32(0) {
  19279 		(*CostInterval)(unsafe.Pointer(next)).Fprevious = prev
  19280 	}
  19281 }
  19282 
  19283 // C documentation
  19284 //
  19285 //	// Pop an interval in the manager.
  19286 func PopInterval(tls *libc.TLS, manager uintptr, interval uintptr) {
  19287 	if interval == libc.UintptrFromInt32(0) {
  19288 		return
  19289 	}
  19290 	ConnectIntervals(tls, manager, (*CostInterval)(unsafe.Pointer(interval)).Fprevious, (*CostInterval)(unsafe.Pointer(interval)).Fnext)
  19291 	if CostIntervalIsInFreeList(tls, manager, interval) != 0 {
  19292 		CostIntervalAddToFreeList(tls, manager, interval)
  19293 	} else { // recycle regularly malloc'd intervals too
  19294 		(*CostInterval)(unsafe.Pointer(interval)).Fnext = (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals
  19295 		(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = interval
  19296 	}
  19297 	(*CostManager)(unsafe.Pointer(manager)).Fcount = (*CostManager)(unsafe.Pointer(manager)).Fcount - 1
  19298 }
  19299 
  19300 // C documentation
  19301 //
  19302 //	// Update the cost at index i by going over all the stored intervals that
  19303 //	// overlap with i.
  19304 //	// If 'do_clean_intervals' is set to something different than 0, intervals that
  19305 //	// end before 'i' will be popped.
  19306 func UpdateCostAtIndex(tls *libc.TLS, manager uintptr, i int32, do_clean_intervals int32) {
  19307 	var current, next uintptr
  19308 	_, _ = current, next
  19309 	current = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19310 	for current != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(current)).Fstart <= i {
  19311 		next = (*CostInterval)(unsafe.Pointer(current)).Fnext
  19312 		if (*CostInterval)(unsafe.Pointer(current)).Fend <= i {
  19313 			if do_clean_intervals != 0 {
  19314 				// We have an outdated interval, remove it.
  19315 				PopInterval(tls, manager, current)
  19316 			}
  19317 		} else {
  19318 			UpdateCost(tls, manager, i, (*CostInterval)(unsafe.Pointer(current)).Findex, (*CostInterval)(unsafe.Pointer(current)).Fcost)
  19319 		}
  19320 		current = next
  19321 	}
  19322 }
  19323 
  19324 // C documentation
  19325 //
  19326 //	// Given a current orphan interval and its previous interval, before
  19327 //	// it was orphaned (which can be NULL), set it at the right place in the list
  19328 //	// of intervals using the 'start' ordering and the previous interval as a hint.
  19329 func PositionOrphanInterval(tls *libc.TLS, manager uintptr, current uintptr, previous uintptr) {
  19330 	if previous == libc.UintptrFromInt32(0) {
  19331 		previous = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19332 	}
  19333 	for previous != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(current)).Fstart < (*CostInterval)(unsafe.Pointer(previous)).Fstart {
  19334 		previous = (*CostInterval)(unsafe.Pointer(previous)).Fprevious
  19335 	}
  19336 	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 {
  19337 		previous = (*CostInterval)(unsafe.Pointer(previous)).Fnext
  19338 	}
  19339 	if previous != libc.UintptrFromInt32(0) {
  19340 		ConnectIntervals(tls, manager, current, (*CostInterval)(unsafe.Pointer(previous)).Fnext)
  19341 	} else {
  19342 		ConnectIntervals(tls, manager, current, (*CostManager)(unsafe.Pointer(manager)).Fhead)
  19343 	}
  19344 	ConnectIntervals(tls, manager, previous, current)
  19345 }
  19346 
  19347 // C documentation
  19348 //
  19349 //	// Insert an interval in the list contained in the manager by starting at
  19350 //	// 'interval_in' as a hint. The intervals are sorted by 'start' value.
  19351 func InsertInterval(tls *libc.TLS, manager uintptr, interval_in uintptr, cost int64_t, position int32, start int32, end int32) {
  19352 	var interval_new uintptr
  19353 	_ = interval_new
  19354 	if start >= end {
  19355 		return
  19356 	}
  19357 	if (*CostManager)(unsafe.Pointer(manager)).Fcount >= int32(COST_CACHE_INTERVAL_SIZE_MAX) {
  19358 		// Serialize the interval if we cannot store it.
  19359 		UpdateCostPerInterval(tls, manager, start, end, position, cost)
  19360 		return
  19361 	}
  19362 	if (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals != libc.UintptrFromInt32(0) {
  19363 		interval_new = (*CostManager)(unsafe.Pointer(manager)).Ffree_intervals
  19364 		(*CostManager)(unsafe.Pointer(manager)).Ffree_intervals = (*CostInterval)(unsafe.Pointer(interval_new)).Fnext
  19365 	} else {
  19366 		if (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals != libc.UintptrFromInt32(0) {
  19367 			interval_new = (*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals
  19368 			(*CostManager)(unsafe.Pointer(manager)).Frecycled_intervals = (*CostInterval)(unsafe.Pointer(interval_new)).Fnext
  19369 		} else { // malloc for good
  19370 			interval_new = WebPSafeMalloc(tls, uint64(1), uint64(40))
  19371 			if interval_new == libc.UintptrFromInt32(0) {
  19372 				// Write down the interval if we cannot create it.
  19373 				UpdateCostPerInterval(tls, manager, start, end, position, cost)
  19374 				return
  19375 			}
  19376 		}
  19377 	}
  19378 	(*CostInterval)(unsafe.Pointer(interval_new)).Fcost = cost
  19379 	(*CostInterval)(unsafe.Pointer(interval_new)).Findex = position
  19380 	(*CostInterval)(unsafe.Pointer(interval_new)).Fstart = start
  19381 	(*CostInterval)(unsafe.Pointer(interval_new)).Fend = end
  19382 	PositionOrphanInterval(tls, manager, interval_new, interval_in)
  19383 	(*CostManager)(unsafe.Pointer(manager)).Fcount = (*CostManager)(unsafe.Pointer(manager)).Fcount + 1
  19384 }
  19385 
  19386 // C documentation
  19387 //
  19388 //	// Given a new cost interval defined by its start at position, its length value
  19389 //	// and distance_cost, add its contributions to the previous intervals and costs.
  19390 //	// If handling the interval or one of its subintervals becomes to heavy, its
  19391 //	// contribution is added to the costs right away.
  19392 func PushInterval(tls *libc.TLS, manager uintptr, distance_cost int64_t, position int32, len1 int32) {
  19393 	var cost, cost_tmp int64_t
  19394 	var cost_cache_intervals, interval, interval_next uintptr
  19395 	var end, end_original, j, k, kSkipDistance, start, start_new, v3 int32
  19396 	var i size_t
  19397 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = cost, cost_cache_intervals, cost_tmp, end, end_original, i, interval, interval_next, j, k, kSkipDistance, start, start_new, v3
  19398 	interval = (*CostManager)(unsafe.Pointer(manager)).Fhead
  19399 	cost_cache_intervals = (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals
  19400 	// If the interval is small enough, no need to deal with the heavy
  19401 	// interval logic, just serialize it right away. This constant is empirical.
  19402 	kSkipDistance = int32(10)
  19403 	if len1 < kSkipDistance {
  19404 		j = position
  19405 		for {
  19406 			if !(j < position+len1) {
  19407 				break
  19408 			}
  19409 			k = j - position
  19410 			cost_tmp = distance_cost + **(**int64_t)(__ccgo_up(manager + 32 + uintptr(k)*8))
  19411 			if **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(j)*8)) > cost_tmp {
  19412 				**(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fcosts + uintptr(j)*8)) = cost_tmp
  19413 				**(**uint16_t)(__ccgo_up((*CostManager)(unsafe.Pointer(manager)).Fdist_array + uintptr(j)*2)) = libc.Uint16FromInt32(k + int32(1))
  19414 			}
  19415 			goto _1
  19416 		_1:
  19417 			;
  19418 			j = j + 1
  19419 		}
  19420 		return
  19421 	}
  19422 	i = uint64(0)
  19423 	for {
  19424 		if !(i < (*CostManager)(unsafe.Pointer(manager)).Fcache_intervals_size && (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fstart < len1) {
  19425 			break
  19426 		}
  19427 		// Define the intersection of the ith interval with the new one.
  19428 		start = position + (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fstart
  19429 		if (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fend > len1 {
  19430 			v3 = len1
  19431 		} else {
  19432 			v3 = (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fend
  19433 		}
  19434 		end = position + v3
  19435 		cost = distance_cost + (**(**CostCacheInterval)(__ccgo_up(cost_cache_intervals + uintptr(i)*16))).Fcost
  19436 		for {
  19437 			if !(interval != libc.UintptrFromInt32(0) && (*CostInterval)(unsafe.Pointer(interval)).Fstart < end) {
  19438 				break
  19439 			}
  19440 			interval_next = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19441 			// Make sure we have some overlap
  19442 			if start >= (*CostInterval)(unsafe.Pointer(interval)).Fend {
  19443 				goto _4
  19444 			}
  19445 			if cost >= (*CostInterval)(unsafe.Pointer(interval)).Fcost {
  19446 				// When intervals are represented, the lower, the better.
  19447 				// [**********************************************************[
  19448 				// start                                                    end
  19449 				//                   [----------------------------------[
  19450 				//                   interval->start        interval->end
  19451 				// If we are worse than what we already have, add whatever we have so
  19452 				// far up to interval.
  19453 				start_new = (*CostInterval)(unsafe.Pointer(interval)).Fend
  19454 				InsertInterval(tls, manager, interval, cost, position, start, (*CostInterval)(unsafe.Pointer(interval)).Fstart)
  19455 				start = start_new
  19456 				if start >= end {
  19457 					break
  19458 				}
  19459 				goto _4
  19460 			}
  19461 			if start <= (*CostInterval)(unsafe.Pointer(interval)).Fstart {
  19462 				if (*CostInterval)(unsafe.Pointer(interval)).Fend <= end {
  19463 					//                   [----------------------------------[
  19464 					//                   interval->start        interval->end
  19465 					// [**************************************************************[
  19466 					// start                                                        end
  19467 					// We can safely remove the old interval as it is fully included.
  19468 					PopInterval(tls, manager, interval)
  19469 				} else {
  19470 					//              [------------------------------------[
  19471 					//              interval->start          interval->end
  19472 					// [*****************************[
  19473 					// start                       end
  19474 					(*CostInterval)(unsafe.Pointer(interval)).Fstart = end
  19475 					break
  19476 				}
  19477 			} else {
  19478 				if end < (*CostInterval)(unsafe.Pointer(interval)).Fend {
  19479 					// [--------------------------------------------------------------[
  19480 					// interval->start                                    interval->end
  19481 					//                     [*****************************[
  19482 					//                     start                       end
  19483 					// We have to split the old interval as it fully contains the new one.
  19484 					end_original = (*CostInterval)(unsafe.Pointer(interval)).Fend
  19485 					(*CostInterval)(unsafe.Pointer(interval)).Fend = start
  19486 					InsertInterval(tls, manager, interval, (*CostInterval)(unsafe.Pointer(interval)).Fcost, (*CostInterval)(unsafe.Pointer(interval)).Findex, end, end_original)
  19487 					interval = (*CostInterval)(unsafe.Pointer(interval)).Fnext
  19488 					break
  19489 				} else {
  19490 					// [------------------------------------[
  19491 					// interval->start          interval->end
  19492 					//                     [*****************************[
  19493 					//                     start                       end
  19494 					(*CostInterval)(unsafe.Pointer(interval)).Fend = start
  19495 				}
  19496 			}
  19497 			goto _4
  19498 		_4:
  19499 			;
  19500 			interval = interval_next
  19501 		}
  19502 		// Insert the remaining interval from start to end.
  19503 		InsertInterval(tls, manager, interval, cost, position, start, end)
  19504 		goto _2
  19505 	_2:
  19506 		;
  19507 		i = i + 1
  19508 	}
  19509 }
  19510 
  19511 func BackwardReferencesHashChainDistanceOnly(tls *libc.TLS, xsize int32, ysize int32, argb uintptr, cache_bits int32, hash_chain uintptr, refs uintptr, dist_array uintptr) (r int32) {
  19512 	bp := tls.Alloc(32)
  19513 	defer tls.Free(32)
  19514 	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
  19515 	var cost_manager, cost_model, v6 uintptr
  19516 	var cost_model_size, literal_array_size size_t
  19517 	var offset_cost, prev_cost int64_t
  19518 	var _ /* hashers at bp+0 */ VP8LColorCache
  19519 	var _ /* len at bp+20 */ int32
  19520 	var _ /* len_j at bp+28 */ int32
  19521 	var _ /* offset at bp+16 */ int32
  19522 	var _ /* offset_j at bp+24 */ int32
  19523 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  19524 	ok = 0
  19525 	cc_init = 0
  19526 	pix_count = xsize * ysize
  19527 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  19528 	v1 = cache_bits
  19529 	if v1 > 0 {
  19530 		v4 = int32(1) << v1
  19531 	} else {
  19532 		v4 = 0
  19533 	}
  19534 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  19535 	goto _3
  19536 _3:
  19537 	literal_array_size = uint64(4) * libc.Uint64FromInt32(v2)
  19538 	cost_model_size = uint64(3240) + literal_array_size
  19539 	cost_model = WebPSafeCalloc(tls, uint64(1), cost_model_size)
  19540 	cost_manager = WebPSafeCalloc(tls, uint64(1), uint64(33224))
  19541 	offset_prev = -int32(1)
  19542 	len_prev = -int32(1)
  19543 	offset_cost = int64(-int32(1))
  19544 	first_offset_is_constant = -int32(1) // initialized with 'impossible' value
  19545 	reach = 0
  19546 	if cost_model == libc.UintptrFromInt32(0) || cost_manager == libc.UintptrFromInt32(0) {
  19547 		goto Error
  19548 	}
  19549 	(*CostModel)(unsafe.Pointer(cost_model)).Fliteral = cost_model + libc.UintptrFromInt32(1)*3240
  19550 	if use_color_cache != 0 {
  19551 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  19552 		if !(cc_init != 0) {
  19553 			goto Error
  19554 		}
  19555 	}
  19556 	if !(CostModelBuild(tls, cost_model, xsize, cache_bits, refs) != 0) {
  19557 		goto Error
  19558 	}
  19559 	if !(CostManagerInit(tls, cost_manager, dist_array, pix_count, cost_model) != 0) {
  19560 		goto Error
  19561 	}
  19562 	// We loop one pixel at a time, but store all currently best points to
  19563 	// non-processed locations from this point.
  19564 	**(**uint16_t)(__ccgo_up(dist_array)) = uint16(0)
  19565 	// Add first pixel as literal.
  19566 	AddSingleLiteralWithCostModel(tls, argb, bp, cost_model, 0, use_color_cache, 0, (*CostManager)(unsafe.Pointer(cost_manager)).Fcosts, dist_array)
  19567 	i = int32(1)
  19568 	for {
  19569 		if !(i < pix_count) {
  19570 			break
  19571 		}
  19572 		prev_cost = **(**int64_t)(__ccgo_up((*CostManager)(unsafe.Pointer(cost_manager)).Fcosts + uintptr(i-int32(1))*8))
  19573 		v6 = hash_chain
  19574 		v1 = i
  19575 		v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19576 		goto _9
  19577 	_9:
  19578 		**(**int32)(__ccgo_up(bp + 16)) = v2
  19579 		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)))
  19580 		goto _11
  19581 	_11:
  19582 		**(**int32)(__ccgo_up(bp + 20)) = v4
  19583 		// Try adding the pixel as a literal.
  19584 		AddSingleLiteralWithCostModel(tls, argb, bp, cost_model, i, use_color_cache, prev_cost, (*CostManager)(unsafe.Pointer(cost_manager)).Fcosts, dist_array)
  19585 		// If we are dealing with a non-literal.
  19586 		if **(**int32)(__ccgo_up(bp + 20)) >= int32(2) {
  19587 			if **(**int32)(__ccgo_up(bp + 16)) != offset_prev {
  19588 				code = VP8LDistanceToPlaneCode(tls, xsize, **(**int32)(__ccgo_up(bp + 16)))
  19589 				offset_cost = GetDistanceCost(tls, cost_model, libc.Uint32FromInt32(code))
  19590 				first_offset_is_constant = int32(1)
  19591 				PushInterval(tls, cost_manager, prev_cost+offset_cost, i, **(**int32)(__ccgo_up(bp + 20)))
  19592 			} else {
  19593 				// Instead of considering all contributions from a pixel i by calling:
  19594 				//         PushInterval(cost_manager, prev_cost + offset_cost, i, len);
  19595 				// we optimize these contributions in case offset_cost stays the same
  19596 				// for consecutive pixels. This describes a set of pixels similar to a
  19597 				// previous set (e.g. constant color regions).
  19598 				if first_offset_is_constant != 0 {
  19599 					reach = i - int32(1) + len_prev - int32(1)
  19600 					first_offset_is_constant = 0
  19601 				}
  19602 				if i+**(**int32)(__ccgo_up(bp + 20))-int32(1) > reach {
  19603 					**(**int32)(__ccgo_up(bp + 28)) = 0
  19604 					// Figure out the last consecutive pixel within [i, reach + 1] with
  19605 					// the same offset.
  19606 					j = i
  19607 					for {
  19608 						if !(j <= reach) {
  19609 							break
  19610 						}
  19611 						v6 = hash_chain
  19612 						v1 = j + int32(1)
  19613 						v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19614 						goto _16
  19615 					_16:
  19616 						**(**int32)(__ccgo_up(bp + 24)) = v2
  19617 						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)))
  19618 						goto _18
  19619 					_18:
  19620 						**(**int32)(__ccgo_up(bp + 28)) = v4
  19621 						if **(**int32)(__ccgo_up(bp + 24)) != **(**int32)(__ccgo_up(bp + 16)) {
  19622 							v6 = hash_chain
  19623 							v1 = j
  19624 							v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v6)).Foffset_length + uintptr(v1)*4)) >> int32(MAX_LENGTH_BITS))
  19625 							goto _22
  19626 						_22:
  19627 							**(**int32)(__ccgo_up(bp + 24)) = v2
  19628 							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)))
  19629 							goto _24
  19630 						_24:
  19631 							**(**int32)(__ccgo_up(bp + 28)) = v4
  19632 							break
  19633 						}
  19634 						goto _12
  19635 					_12:
  19636 						;
  19637 						j = j + 1
  19638 					}
  19639 					// Update the cost at j - 1 and j.
  19640 					UpdateCostAtIndex(tls, cost_manager, j-int32(1), 0)
  19641 					UpdateCostAtIndex(tls, cost_manager, j, 0)
  19642 					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)))
  19643 					reach = j + **(**int32)(__ccgo_up(bp + 28)) - int32(1)
  19644 				}
  19645 			}
  19646 		}
  19647 		UpdateCostAtIndex(tls, cost_manager, i, int32(1))
  19648 		offset_prev = **(**int32)(__ccgo_up(bp + 16))
  19649 		len_prev = **(**int32)(__ccgo_up(bp + 20))
  19650 		goto _5
  19651 	_5:
  19652 		;
  19653 		i = i + 1
  19654 	}
  19655 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  19656 	goto Error
  19657 Error:
  19658 	;
  19659 	if cc_init != 0 {
  19660 		VP8LColorCacheClear(tls, bp)
  19661 	}
  19662 	CostManagerClear(tls, cost_manager)
  19663 	WebPSafeFree(tls, cost_model)
  19664 	WebPSafeFree(tls, cost_manager)
  19665 	return ok
  19666 }
  19667 
  19668 // C documentation
  19669 //
  19670 //	// We pack the path at the end of *dist_array and return
  19671 //	// a pointer to this part of the array. Example:
  19672 //	// dist_array = [1x2xx3x2] => packed [1x2x1232], chosen_path = [1232]
  19673 func TraceBackwards(tls *libc.TLS, dist_array uintptr, dist_array_size int32, chosen_path uintptr, chosen_path_size uintptr) {
  19674 	var cur, path uintptr
  19675 	var k int32
  19676 	_, _, _ = cur, k, path
  19677 	path = dist_array + uintptr(dist_array_size)*2
  19678 	cur = dist_array + uintptr(dist_array_size)*2 - uintptr(1)*2
  19679 	for cur >= dist_array {
  19680 		k = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(cur)))
  19681 		path -= 2
  19682 		**(**uint16_t)(__ccgo_up(path)) = libc.Uint16FromInt32(k)
  19683 		cur = cur - uintptr(k)*2
  19684 	}
  19685 	**(**uintptr)(__ccgo_up(chosen_path)) = path
  19686 	**(**int32)(__ccgo_up(chosen_path_size)) = int32((int64(dist_array+uintptr(dist_array_size)*2) - int64(path)) / 2)
  19687 }
  19688 
  19689 func BackwardReferencesHashChainFollowChosenPath(tls *libc.TLS, argb4 uintptr, cache_bits int32, chosen_path uintptr, chosen_path_size int32, hash_chain uintptr, refs uintptr) (r int32) {
  19690 	bp := tls.Alloc(16)
  19691 	defer tls.Free(16)
  19692 	var cc_init, i, idx1, ix, k, key, key1, len1, offset, ok, use_color_cache, v11, v14, v2, v9 int32
  19693 	var retval, retval1, retval2, v, v4 PixOrCopy
  19694 	var v7 uintptr
  19695 	var v8 uint32_t
  19696 	var _ /* hashers at bp+0 */ VP8LColorCache
  19697 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  19698 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  19699 	i = 0
  19700 	ok = 0
  19701 	cc_init = 0
  19702 	if use_color_cache != 0 {
  19703 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  19704 		if !(cc_init != 0) {
  19705 			goto Error
  19706 		}
  19707 	}
  19708 	VP8LClearBackwardRefs(tls, refs)
  19709 	ix = 0
  19710 	for {
  19711 		if !(ix < chosen_path_size) {
  19712 			break
  19713 		}
  19714 		len1 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(chosen_path + uintptr(ix)*2)))
  19715 		if len1 != int32(1) {
  19716 			v2 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(i)*4)) >> int32(MAX_LENGTH_BITS))
  19717 			goto _3
  19718 		_3:
  19719 			offset = v2
  19720 			retval.Fmode = uint8(kCopy)
  19721 			retval.Fargb_or_distance = libc.Uint32FromInt32(offset)
  19722 			retval.Flen1 = libc.Uint16FromInt32(len1)
  19723 			v4 = retval
  19724 			goto _5
  19725 		_5:
  19726 			VP8LBackwardRefsCursorAdd(tls, refs, v4)
  19727 			if use_color_cache != 0 {
  19728 				k = 0
  19729 				for {
  19730 					if !(k < len1) {
  19731 						break
  19732 					}
  19733 					v7 = bp
  19734 					v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i+k)*4))
  19735 					v2 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19736 					goto _10
  19737 				_10:
  19738 					key = v2
  19739 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  19740 					goto _6
  19741 				_6:
  19742 					;
  19743 					k = k + 1
  19744 				}
  19745 			}
  19746 			i = i + len1
  19747 		} else {
  19748 			if use_color_cache != 0 {
  19749 				v7 = bp
  19750 				v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19751 				v9 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19752 				goto _15
  19753 			_15:
  19754 				key1 = v9
  19755 				if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key1)*4)) == v8 {
  19756 					v14 = key1
  19757 				} else {
  19758 					v14 = -int32(1)
  19759 				}
  19760 				v11 = v14
  19761 				goto _17
  19762 			_17:
  19763 				v2 = v11
  19764 			} else {
  19765 				v2 = -int32(1)
  19766 			}
  19767 			idx1 = v2
  19768 			if idx1 >= 0 {
  19769 				// use_color_cache is true and hashers contains argb[i]
  19770 				// push pixel as a color cache index
  19771 				retval1.Fmode = uint8(kCacheIdx)
  19772 				retval1.Fargb_or_distance = libc.Uint32FromInt32(idx1)
  19773 				retval1.Flen1 = uint16(1)
  19774 				v4 = retval1
  19775 				goto _20
  19776 			_20:
  19777 				v = v4
  19778 			} else {
  19779 				if use_color_cache != 0 {
  19780 					v7 = bp
  19781 					v8 = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19782 					v2 = libc.Int32FromUint32(v8 * kHashMul10 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  19783 					goto _24
  19784 				_24:
  19785 					key = v2
  19786 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  19787 				}
  19788 				retval2.Fmode = uint8(kLiteral)
  19789 				retval2.Fargb_or_distance = **(**uint32_t)(__ccgo_up(argb4 + uintptr(i)*4))
  19790 				retval2.Flen1 = uint16(1)
  19791 				v4 = retval2
  19792 				goto _26
  19793 			_26:
  19794 				v = v4
  19795 			}
  19796 			VP8LBackwardRefsCursorAdd(tls, refs, v)
  19797 			i = i + 1
  19798 		}
  19799 		goto _1
  19800 	_1:
  19801 		;
  19802 		ix = ix + 1
  19803 	}
  19804 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  19805 	goto Error
  19806 Error:
  19807 	;
  19808 	if cc_init != 0 {
  19809 		VP8LColorCacheClear(tls, bp)
  19810 	}
  19811 	return ok
  19812 }
  19813 
  19814 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) {
  19815 	bp := tls.Alloc(16)
  19816 	defer tls.Free(16)
  19817 	var dist_array uintptr
  19818 	var dist_array_size, ok int32
  19819 	var _ /* chosen_path at bp+0 */ uintptr
  19820 	var _ /* chosen_path_size at bp+8 */ int32
  19821 	_, _, _ = dist_array, dist_array_size, ok
  19822 	ok = 0
  19823 	dist_array_size = xsize * ysize
  19824 	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
  19825 	**(**int32)(__ccgo_up(bp + 8)) = 0
  19826 	dist_array = WebPSafeMalloc(tls, libc.Uint64FromInt32(dist_array_size), uint64(2))
  19827 	if dist_array == libc.UintptrFromInt32(0) {
  19828 		goto Error
  19829 	}
  19830 	if !(BackwardReferencesHashChainDistanceOnly(tls, xsize, ysize, argb, cache_bits, hash_chain, refs_src, dist_array) != 0) {
  19831 		goto Error
  19832 	}
  19833 	TraceBackwards(tls, dist_array, dist_array_size, bp, bp+8)
  19834 	if !(BackwardReferencesHashChainFollowChosenPath(tls, argb, cache_bits, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), hash_chain, refs_dst) != 0) {
  19835 		goto Error
  19836 	}
  19837 	ok = int32(1)
  19838 	goto Error
  19839 Error:
  19840 	;
  19841 	WebPSafeFree(tls, dist_array)
  19842 	return ok
  19843 }
  19844 
  19845 const MIN_BLOCK_SIZE = 256
  19846 const MIN_LENGTH = 4
  19847 const WINDOW_OFFSETS_SIZE_MAX = 32
  19848 
  19849 type PixOrCopyBlock = struct {
  19850 	Fnext  uintptr
  19851 	Fstart uintptr
  19852 	Fsize  int32
  19853 }
  19854 
  19855 var kHashMul11 = uint32(0x1e35a7bd)
  19856 
  19857 //------------------------------------------------------------------------------
  19858 
  19859 // Copyright 2012 Google Inc. All Rights Reserved.
  19860 //
  19861 // Use of this source code is governed by a BSD-style license
  19862 // that can be found in the COPYING file in the root of the source
  19863 // tree. An additional intellectual property rights grant can be found
  19864 // in the file PATENTS. All contributing project authors may
  19865 // be found in the AUTHORS file in the root of the source tree.
  19866 // -----------------------------------------------------------------------------
  19867 //
  19868 // Misc. common utility functions
  19869 //
  19870 // Authors: Skal (pascal.massimino@gmail.com)
  19871 //          Urvang (urvang@google.com)
  19872 
  19873 // Copyright 2011 Google Inc. All Rights Reserved.
  19874 //
  19875 // Use of this source code is governed by a BSD-style license
  19876 // that can be found in the COPYING file in the root of the source
  19877 // tree. An additional intellectual property rights grant can be found
  19878 // in the file PATENTS. All contributing project authors may
  19879 // be found in the AUTHORS file in the root of the source tree.
  19880 // -----------------------------------------------------------------------------
  19881 //
  19882 //   WebP encoder: main interface
  19883 //
  19884 // Author: Skal (pascal.massimino@gmail.com)
  19885 
  19886 // Copyright 2012 Google Inc. All Rights Reserved.
  19887 //
  19888 // Use of this source code is governed by a BSD-style license
  19889 // that can be found in the COPYING file in the root of the source
  19890 // tree. An additional intellectual property rights grant can be found
  19891 // in the file PATENTS. All contributing project authors may
  19892 // be found in the AUTHORS file in the root of the source tree.
  19893 // -----------------------------------------------------------------------------
  19894 //
  19895 //  Internal header for constants related to WebP file format.
  19896 //
  19897 // Author: Urvang (urvang@google.com)
  19898 
  19899 // Copyright 2010 Google Inc. All Rights Reserved.
  19900 //
  19901 // Use of this source code is governed by a BSD-style license
  19902 // that can be found in the COPYING file in the root of the source
  19903 // tree. An additional intellectual property rights grant can be found
  19904 // in the file PATENTS. All contributing project authors may
  19905 // be found in the AUTHORS file in the root of the source tree.
  19906 // -----------------------------------------------------------------------------
  19907 //
  19908 //  Common types + memory wrappers
  19909 //
  19910 // Author: Skal (pascal.massimino@gmail.com)
  19911 
  19912 // 1M window (4M bytes) minus 120 special codes for short distances.
  19913 
  19914 // Minimum number of pixels for which it is cheaper to encode a
  19915 // distance + length instead of each pixel as a literal.
  19916 
  19917 // -----------------------------------------------------------------------------
  19918 
  19919 var plane_to_code_lut = [128]uint8_t{
  19920 	0:   uint8(96),
  19921 	1:   uint8(73),
  19922 	2:   uint8(55),
  19923 	3:   uint8(39),
  19924 	4:   uint8(23),
  19925 	5:   uint8(13),
  19926 	6:   uint8(5),
  19927 	7:   uint8(1),
  19928 	8:   uint8(255),
  19929 	9:   uint8(255),
  19930 	10:  uint8(255),
  19931 	11:  uint8(255),
  19932 	12:  uint8(255),
  19933 	13:  uint8(255),
  19934 	14:  uint8(255),
  19935 	15:  uint8(255),
  19936 	16:  uint8(101),
  19937 	17:  uint8(78),
  19938 	18:  uint8(58),
  19939 	19:  uint8(42),
  19940 	20:  uint8(26),
  19941 	21:  uint8(16),
  19942 	22:  uint8(8),
  19943 	23:  uint8(2),
  19944 	25:  uint8(3),
  19945 	26:  uint8(9),
  19946 	27:  uint8(17),
  19947 	28:  uint8(27),
  19948 	29:  uint8(43),
  19949 	30:  uint8(59),
  19950 	31:  uint8(79),
  19951 	32:  uint8(102),
  19952 	33:  uint8(86),
  19953 	34:  uint8(62),
  19954 	35:  uint8(46),
  19955 	36:  uint8(32),
  19956 	37:  uint8(20),
  19957 	38:  uint8(10),
  19958 	39:  uint8(6),
  19959 	40:  uint8(4),
  19960 	41:  uint8(7),
  19961 	42:  uint8(11),
  19962 	43:  uint8(21),
  19963 	44:  uint8(33),
  19964 	45:  uint8(47),
  19965 	46:  uint8(63),
  19966 	47:  uint8(87),
  19967 	48:  uint8(105),
  19968 	49:  uint8(90),
  19969 	50:  uint8(70),
  19970 	51:  uint8(52),
  19971 	52:  uint8(37),
  19972 	53:  uint8(28),
  19973 	54:  uint8(18),
  19974 	55:  uint8(14),
  19975 	56:  uint8(12),
  19976 	57:  uint8(15),
  19977 	58:  uint8(19),
  19978 	59:  uint8(29),
  19979 	60:  uint8(38),
  19980 	61:  uint8(53),
  19981 	62:  uint8(71),
  19982 	63:  uint8(91),
  19983 	64:  uint8(110),
  19984 	65:  uint8(99),
  19985 	66:  uint8(82),
  19986 	67:  uint8(66),
  19987 	68:  uint8(48),
  19988 	69:  uint8(35),
  19989 	70:  uint8(30),
  19990 	71:  uint8(24),
  19991 	72:  uint8(22),
  19992 	73:  uint8(25),
  19993 	74:  uint8(31),
  19994 	75:  uint8(36),
  19995 	76:  uint8(49),
  19996 	77:  uint8(67),
  19997 	78:  uint8(83),
  19998 	79:  uint8(100),
  19999 	80:  uint8(115),
  20000 	81:  uint8(108),
  20001 	82:  uint8(94),
  20002 	83:  uint8(76),
  20003 	84:  uint8(64),
  20004 	85:  uint8(50),
  20005 	86:  uint8(44),
  20006 	87:  uint8(40),
  20007 	88:  uint8(34),
  20008 	89:  uint8(41),
  20009 	90:  uint8(45),
  20010 	91:  uint8(51),
  20011 	92:  uint8(65),
  20012 	93:  uint8(77),
  20013 	94:  uint8(95),
  20014 	95:  uint8(109),
  20015 	96:  uint8(118),
  20016 	97:  uint8(113),
  20017 	98:  uint8(103),
  20018 	99:  uint8(92),
  20019 	100: uint8(80),
  20020 	101: uint8(68),
  20021 	102: uint8(60),
  20022 	103: uint8(56),
  20023 	104: uint8(54),
  20024 	105: uint8(57),
  20025 	106: uint8(61),
  20026 	107: uint8(69),
  20027 	108: uint8(81),
  20028 	109: uint8(93),
  20029 	110: uint8(104),
  20030 	111: uint8(114),
  20031 	112: uint8(119),
  20032 	113: uint8(116),
  20033 	114: uint8(111),
  20034 	115: uint8(106),
  20035 	116: uint8(97),
  20036 	117: uint8(88),
  20037 	118: uint8(84),
  20038 	119: uint8(74),
  20039 	120: uint8(72),
  20040 	121: uint8(75),
  20041 	122: uint8(85),
  20042 	123: uint8(89),
  20043 	124: uint8(98),
  20044 	125: uint8(107),
  20045 	126: uint8(112),
  20046 	127: uint8(117),
  20047 }
  20048 
  20049 func VP8LDistanceToPlaneCode(tls *libc.TLS, xsize int32, dist int32) (r int32) {
  20050 	var xoffset, yoffset int32
  20051 	_, _ = xoffset, yoffset
  20052 	yoffset = dist / xsize
  20053 	xoffset = dist - yoffset*xsize
  20054 	if xoffset <= int32(8) && yoffset < int32(8) {
  20055 		return libc.Int32FromUint8(plane_to_code_lut[yoffset*int32(16)+int32(8)-xoffset]) + int32(1)
  20056 	} else {
  20057 		if xoffset > xsize-int32(8) && yoffset < int32(7) {
  20058 			return libc.Int32FromUint8(plane_to_code_lut[(yoffset+int32(1))*int32(16)+int32(8)+(xsize-xoffset)]) + int32(1)
  20059 		}
  20060 	}
  20061 	return dist + int32(120)
  20062 }
  20063 
  20064 // C documentation
  20065 //
  20066 //	// Returns the exact index where array1 and array2 are different. For an index
  20067 //	// inferior or equal to best_len_match, the return value just has to be strictly
  20068 //	// inferior to best_len_match. The current behavior is to return 0 if this index
  20069 //	// is best_len_match, and the index itself otherwise.
  20070 //	// If no two elements are the same, it returns max_limit.
  20071 func FindMatchLength(tls *libc.TLS, array1 uintptr, array2 uintptr, best_len_match int32, max_limit int32) (r int32) {
  20072 	// Before 'expensive' linear match, check if the two arrays match at the
  20073 	// current best length index.
  20074 	if **(**uint32_t)(__ccgo_up(array1 + uintptr(best_len_match)*4)) != **(**uint32_t)(__ccgo_up(array2 + uintptr(best_len_match)*4)) {
  20075 		return 0
  20076 	}
  20077 	return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{VP8LVectorMismatch})))(tls, array1, array2, max_limit)
  20078 }
  20079 
  20080 func VP8LClearBackwardRefs(tls *libc.TLS, refs uintptr) {
  20081 	if (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail != libc.UintptrFromInt32(0) {
  20082 		**(**uintptr)(__ccgo_up((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail)) = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks // recycle all blocks at once
  20083 	}
  20084 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs
  20085 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = refs + 8
  20086 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block = libc.UintptrFromInt32(0)
  20087 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs = libc.UintptrFromInt32(0)
  20088 }
  20089 
  20090 func VP8LBackwardRefsClear(tls *libc.TLS, refs uintptr) {
  20091 	var next uintptr
  20092 	_ = next
  20093 	VP8LClearBackwardRefs(tls, refs)
  20094 	for (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks != libc.UintptrFromInt32(0) {
  20095 		next = (*PixOrCopyBlock)(unsafe.Pointer((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks)).Fnext
  20096 		WebPSafeFree(tls, (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks)
  20097 		(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = next
  20098 	}
  20099 }
  20100 
  20101 // C documentation
  20102 //
  20103 //	// Swaps the content of two VP8LBackwardRefs.
  20104 func BackwardRefsSwap(tls *libc.TLS, refs1 uintptr, refs2 uintptr) {
  20105 	var point_to_refs1, point_to_refs2 int32
  20106 	var tmp VP8LBackwardRefs
  20107 	_, _, _ = point_to_refs1, point_to_refs2, tmp
  20108 	point_to_refs1 = libc.BoolInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail != libc.UintptrFromInt32(0) && (*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail == refs1+8)
  20109 	point_to_refs2 = libc.BoolInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail != libc.UintptrFromInt32(0) && (*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail == refs2+8)
  20110 	tmp = **(**VP8LBackwardRefs)(__ccgo_up(refs1))
  20111 	**(**VP8LBackwardRefs)(__ccgo_up(refs1)) = **(**VP8LBackwardRefs)(__ccgo_up(refs2))
  20112 	**(**VP8LBackwardRefs)(__ccgo_up(refs2)) = tmp
  20113 	if point_to_refs2 != 0 {
  20114 		(*VP8LBackwardRefs)(unsafe.Pointer(refs1)).Ftail = refs1 + 8
  20115 	}
  20116 	if point_to_refs1 != 0 {
  20117 		(*VP8LBackwardRefs)(unsafe.Pointer(refs2)).Ftail = refs2 + 8
  20118 	}
  20119 }
  20120 
  20121 func VP8LBackwardRefsInit(tls *libc.TLS, refs uintptr, block_size int32) {
  20122 	var v1 int32
  20123 	_ = v1
  20124 	libc.X__builtin___memset_chk(tls, refs, 0, uint64(40), ^__predefined_size_t(0))
  20125 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = refs + 8
  20126 	if block_size < int32(MIN_BLOCK_SIZE) {
  20127 		v1 = int32(MIN_BLOCK_SIZE)
  20128 	} else {
  20129 		v1 = block_size
  20130 	}
  20131 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size = v1
  20132 }
  20133 
  20134 func VP8LRefsCursorInit(tls *libc.TLS, refs uintptr) (r VP8LRefsCursor) {
  20135 	var c VP8LRefsCursor
  20136 	_ = c
  20137 	c.Fcur_block = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs
  20138 	if (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Frefs != libc.UintptrFromInt32(0) {
  20139 		c.Fcur_pos = (*PixOrCopyBlock)(unsafe.Pointer(c.Fcur_block)).Fstart
  20140 		c.Flast_pos = c.Fcur_pos + uintptr((*PixOrCopyBlock)(unsafe.Pointer(c.Fcur_block)).Fsize)*8
  20141 	} else {
  20142 		c.Fcur_pos = libc.UintptrFromInt32(0)
  20143 		c.Flast_pos = libc.UintptrFromInt32(0)
  20144 	}
  20145 	return c
  20146 }
  20147 
  20148 func VP8LRefsCursorNextBlock(tls *libc.TLS, c uintptr) {
  20149 	var b, v1 uintptr
  20150 	_, _ = b, v1
  20151 	b = (*PixOrCopyBlock)(unsafe.Pointer((*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_block)).Fnext
  20152 	if b == libc.UintptrFromInt32(0) {
  20153 		v1 = libc.UintptrFromInt32(0)
  20154 	} else {
  20155 		v1 = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart
  20156 	}
  20157 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_pos = v1
  20158 	if b == libc.UintptrFromInt32(0) {
  20159 		v1 = libc.UintptrFromInt32(0)
  20160 	} else {
  20161 		v1 = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart + uintptr((*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize)*8
  20162 	}
  20163 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Flast_pos = v1
  20164 	(*VP8LRefsCursor)(unsafe.Pointer(c)).Fcur_block = b
  20165 }
  20166 
  20167 // C documentation
  20168 //
  20169 //	// Create a new block, either from the free list or allocated
  20170 func BackwardRefsNewBlock(tls *libc.TLS, refs uintptr) (r uintptr) {
  20171 	var b uintptr
  20172 	var total_size size_t
  20173 	_, _ = b, total_size
  20174 	b = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks
  20175 	if b == libc.UintptrFromInt32(0) { // allocate new memory chunk
  20176 		total_size = uint64(24) + libc.Uint64FromInt32((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size)*uint64(8)
  20177 		b = WebPSafeMalloc(tls, uint64(1), total_size)
  20178 		if b == libc.UintptrFromInt32(0) {
  20179 			**(**int32)(__ccgo_up(refs + 4)) |= int32(1)
  20180 			return libc.UintptrFromInt32(0)
  20181 		}
  20182 		(*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart = b + libc.UintptrFromInt64(24) // not always aligned
  20183 	} else { // recycle from free-list
  20184 		(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ffree_blocks = (*PixOrCopyBlock)(unsafe.Pointer(b)).Fnext
  20185 	}
  20186 	**(**uintptr)(__ccgo_up((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail)) = b
  20187 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ftail = b
  20188 	(*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block = b
  20189 	(*PixOrCopyBlock)(unsafe.Pointer(b)).Fnext = libc.UintptrFromInt32(0)
  20190 	(*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize = 0
  20191 	return b
  20192 }
  20193 
  20194 // C documentation
  20195 //
  20196 //	// Return 1 on success, 0 on error.
  20197 func BackwardRefsClone(tls *libc.TLS, from uintptr, to uintptr) (r int32) {
  20198 	var block_from, block_to uintptr
  20199 	_, _ = block_from, block_to
  20200 	block_from = (*VP8LBackwardRefs)(unsafe.Pointer(from)).Frefs
  20201 	VP8LClearBackwardRefs(tls, to)
  20202 	for block_from != libc.UintptrFromInt32(0) {
  20203 		block_to = BackwardRefsNewBlock(tls, to)
  20204 		if block_to == libc.UintptrFromInt32(0) {
  20205 			return 0
  20206 		}
  20207 		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))
  20208 		(*PixOrCopyBlock)(unsafe.Pointer(block_to)).Fsize = (*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fsize
  20209 		block_from = (*PixOrCopyBlock)(unsafe.Pointer(block_from)).Fnext
  20210 	}
  20211 	return int32(1)
  20212 }
  20213 
  20214 func VP8LBackwardRefsCursorAdd(tls *libc.TLS, refs uintptr, v PixOrCopy) {
  20215 	var b, v2 uintptr
  20216 	var v1 int32
  20217 	_, _, _ = b, v1, v2
  20218 	b = (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Flast_block
  20219 	if b == libc.UintptrFromInt32(0) || (*PixOrCopyBlock)(unsafe.Pointer(b)).Fsize == (*VP8LBackwardRefs)(unsafe.Pointer(refs)).Fblock_size {
  20220 		b = BackwardRefsNewBlock(tls, refs)
  20221 		if b == libc.UintptrFromInt32(0) {
  20222 			return
  20223 		} // refs->error is set
  20224 	}
  20225 	v2 = b + 16
  20226 	v1 = *(*int32)(unsafe.Pointer(v2))
  20227 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  20228 	**(**PixOrCopy)(__ccgo_up((*PixOrCopyBlock)(unsafe.Pointer(b)).Fstart + uintptr(v1)*8)) = v
  20229 }
  20230 
  20231 // -----------------------------------------------------------------------------
  20232 // Hash chains
  20233 
  20234 func VP8LHashChainInit(tls *libc.TLS, p uintptr, size int32) (r int32) {
  20235 	(*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length = WebPSafeMalloc(tls, libc.Uint64FromInt32(size), uint64(4))
  20236 	if (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length == libc.UintptrFromInt32(0) {
  20237 		return 0
  20238 	}
  20239 	(*VP8LHashChain)(unsafe.Pointer(p)).Fsize = size
  20240 	return int32(1)
  20241 }
  20242 
  20243 func VP8LHashChainClear(tls *libc.TLS, p uintptr) {
  20244 	WebPSafeFree(tls, (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)
  20245 	(*VP8LHashChain)(unsafe.Pointer(p)).Fsize = 0
  20246 	(*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length = libc.UintptrFromInt32(0)
  20247 }
  20248 
  20249 // -----------------------------------------------------------------------------
  20250 
  20251 var kHashMultiplierHi = uint32(0xc6a4a793)
  20252 var kHashMultiplierLo = uint32(0x5bd1e996)
  20253 
  20254 func GetPixPairHash64(tls *libc.TLS, argb uintptr) (r uint32_t) {
  20255 	var key uint32_t
  20256 	_ = key
  20257 	key = **(**uint32_t)(__ccgo_up(argb + 1*4)) * kHashMultiplierHi
  20258 	key = key + **(**uint32_t)(__ccgo_up(argb))*kHashMultiplierLo
  20259 	key = key >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(HASH_BITS))
  20260 	return key
  20261 }
  20262 
  20263 // C documentation
  20264 //
  20265 //	// Returns the maximum number of hash chain lookups to do for a
  20266 //	// given compression quality. Return value in range [8, 86].
  20267 func GetMaxItersForQuality(tls *libc.TLS, quality int32) (r int32) {
  20268 	return int32(8) + quality*quality/int32(128)
  20269 }
  20270 
  20271 func GetWindowSizeForHashChain(tls *libc.TLS, quality int32, xsize int32) (r int32) {
  20272 	var max_window_size, v1, v2, v3 int32
  20273 	_, _, _, _ = max_window_size, v1, v2, v3
  20274 	if quality > int32(75) {
  20275 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS) - libc.Int32FromInt32(120)
  20276 	} else {
  20277 		if quality > int32(50) {
  20278 			v2 = xsize << int32(8)
  20279 		} else {
  20280 			if quality > int32(25) {
  20281 				v3 = xsize << int32(6)
  20282 			} else {
  20283 				v3 = xsize << int32(4)
  20284 			}
  20285 			v2 = v3
  20286 		}
  20287 		v1 = v2
  20288 	}
  20289 	max_window_size = v1
  20290 	if max_window_size > libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS)-libc.Int32FromInt32(120) {
  20291 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(WINDOW_SIZE_BITS) - libc.Int32FromInt32(120)
  20292 	} else {
  20293 		v1 = max_window_size
  20294 	}
  20295 	return v1
  20296 }
  20297 
  20298 func MaxFindCopyLength(tls *libc.TLS, len1 int32) (r int32) {
  20299 	var v1 int32
  20300 	_ = v1
  20301 	if len1 < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20302 		v1 = len1
  20303 	} else {
  20304 		v1 = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  20305 	}
  20306 	return v1
  20307 }
  20308 
  20309 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) {
  20310 	bp := tls.Alloc(16)
  20311 	defer tls.Free(16)
  20312 	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
  20313 	var argb_start, chain, hash_to_first_index uintptr
  20314 	var base_position, best_argb, best_distance, hash_code, len1, max_base_position, window_size, v1 uint32_t
  20315 	var v12 bool
  20316 	var v8 uint32
  20317 	var _ /* tmp at bp+0 */ [2]uint32_t
  20318 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  20319 	size = xsize * ysize
  20320 	iter_max = GetMaxItersForQuality(tls, quality)
  20321 	window_size = libc.Uint32FromInt32(GetWindowSizeForHashChain(tls, quality, xsize))
  20322 	remaining_percent = percent_range
  20323 	percent_start = **(**int32)(__ccgo_up(percent))
  20324 	// Temporarily use the p->offset_length as a hash chain.
  20325 	chain = (*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length
  20326 	if size <= int32(2) {
  20327 		v1 = libc.Uint32FromInt32(0)
  20328 		**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length + uintptr(size-int32(1))*4)) = v1
  20329 		**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)) = v1
  20330 		return int32(1)
  20331 	}
  20332 	hash_to_first_index = WebPSafeMalloc(tls, libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(HASH_BITS)), uint64(4))
  20333 	if hash_to_first_index == libc.UintptrFromInt32(0) {
  20334 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  20335 	}
  20336 	percent_range = remaining_percent / int32(2)
  20337 	remaining_percent = remaining_percent - percent_range
  20338 	// Set the int32_t array to -1.
  20339 	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))
  20340 	// Fill the chain linking pixels with the same hash.
  20341 	argb_comp = libc.BoolInt32(**(**uint32_t)(__ccgo_up(argb)) == **(**uint32_t)(__ccgo_up(argb + 1*4)))
  20342 	pos = 0
  20343 	for {
  20344 		if !(pos < size-int32(2)) {
  20345 			break
  20346 		}
  20347 		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)))
  20348 		if argb_comp != 0 && argb_comp_next != 0 {
  20349 			len1 = uint32(1)
  20350 			(**(**[2]uint32_t)(__ccgo_up(bp)))[0] = **(**uint32_t)(__ccgo_up(argb + uintptr(pos)*4))
  20351 			// Figure out how far the pixels are the same.
  20352 			// The last pixel has a different 64 bit hash, as its next pixel does
  20353 			// not have the same color, so we just need to get to the last pixel equal
  20354 			// to its follower.
  20355 			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)) {
  20356 				len1 = len1 + 1
  20357 			}
  20358 			if len1 > libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1)) {
  20359 				// Skip the pixels that match for distance=1 and length>MAX_LENGTH
  20360 				// because they are linked to their predecessor and we automatically
  20361 				// check that in the main for loop below. Skipping means setting no
  20362 				// predecessor in the chain, hence -1.
  20363 				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))
  20364 				pos = libc.Int32FromUint32(uint32(pos) + (len1 - libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1))))
  20365 				len1 = libc.Uint32FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1))
  20366 			}
  20367 			// Process the rest of the hash chain.
  20368 			for len1 != 0 {
  20369 				v1 = len1
  20370 				len1 = len1 - 1
  20371 				(**(**[2]uint32_t)(__ccgo_up(bp)))[int32(1)] = v1
  20372 				hash_code = GetPixPairHash64(tls, bp)
  20373 				**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4))
  20374 				v4 = pos
  20375 				pos = pos + 1
  20376 				**(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4)) = v4
  20377 			}
  20378 			argb_comp = 0
  20379 		} else {
  20380 			// Just move one pixel forward.
  20381 			hash_code = GetPixPairHash64(tls, argb+uintptr(pos)*4)
  20382 			**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4))
  20383 			v4 = pos
  20384 			pos = pos + 1
  20385 			**(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(hash_code)*4)) = v4
  20386 			argb_comp = argb_comp_next
  20387 		}
  20388 		if !(WebPReportProgress(tls, pic, percent_start+percent_range*pos/(size-int32(2)), percent) != 0) {
  20389 			WebPSafeFree(tls, hash_to_first_index)
  20390 			return 0
  20391 		}
  20392 		goto _2
  20393 	_2:
  20394 	}
  20395 	// Process the penultimate pixel.
  20396 	**(**int32_t)(__ccgo_up(chain + uintptr(pos)*4)) = **(**int32_t)(__ccgo_up(hash_to_first_index + uintptr(GetPixPairHash64(tls, argb+uintptr(pos)*4))*4))
  20397 	WebPSafeFree(tls, hash_to_first_index)
  20398 	percent_start = percent_start + percent_range
  20399 	if !(WebPReportProgress(tls, pic, percent_start, percent) != 0) {
  20400 		return 0
  20401 	}
  20402 	percent_range = remaining_percent
  20403 	// Find the best match interval at each pixel, defined by an offset to the
  20404 	// pixel and a length. The right-most pixel cannot match anything to the right
  20405 	// (hence a best length of 0) and the left-most pixel nothing to the left
  20406 	// (hence an offset of 0).
  20407 	v1 = libc.Uint32FromInt32(0)
  20408 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length + uintptr(size-int32(1))*4)) = v1
  20409 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(p)).Foffset_length)) = v1
  20410 	base_position = libc.Uint32FromInt32(size - int32(2))
  20411 	for {
  20412 		if !(base_position > uint32(0)) {
  20413 			break
  20414 		}
  20415 		max_len = MaxFindCopyLength(tls, libc.Int32FromUint32(libc.Uint32FromInt32(size-int32(1))-base_position))
  20416 		argb_start = argb + uintptr(base_position)*4
  20417 		iter = iter_max
  20418 		best_length = 0
  20419 		best_distance = uint32(0)
  20420 		if base_position > window_size {
  20421 			v8 = base_position - window_size
  20422 		} else {
  20423 			v8 = uint32(0)
  20424 		}
  20425 		min_pos = libc.Int32FromUint32(v8)
  20426 		if max_len < int32(256) {
  20427 			v4 = max_len
  20428 		} else {
  20429 			v4 = int32(256)
  20430 		}
  20431 		length_max = v4
  20432 		pos = **(**int32_t)(__ccgo_up(chain + uintptr(base_position)*4))
  20433 		if !(low_effort != 0) {
  20434 			// Heuristic: use the comparison with the above line as an initialization.
  20435 			if base_position >= libc.Uint32FromInt32(xsize) {
  20436 				curr_length = FindMatchLength(tls, argb_start-uintptr(xsize)*4, argb_start, best_length, max_len)
  20437 				if curr_length > best_length {
  20438 					best_length = curr_length
  20439 					best_distance = libc.Uint32FromInt32(xsize)
  20440 				}
  20441 				iter = iter - 1
  20442 			}
  20443 			// Heuristic: compare to the previous pixel.
  20444 			curr_length = FindMatchLength(tls, argb_start-uintptr(1)*4, argb_start, best_length, max_len)
  20445 			if curr_length > best_length {
  20446 				best_length = curr_length
  20447 				best_distance = uint32(1)
  20448 			}
  20449 			iter = iter - 1
  20450 			// Skip the for loop if we already have the maximum.
  20451 			if best_length == libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20452 				pos = min_pos - int32(1)
  20453 			}
  20454 		}
  20455 		best_argb = **(**uint32_t)(__ccgo_up(argb_start + uintptr(best_length)*4))
  20456 		for {
  20457 			if v12 = pos >= min_pos; v12 {
  20458 				iter = iter - 1
  20459 				v4 = iter
  20460 			}
  20461 			if !(v12 && v4 != 0) {
  20462 				break
  20463 			}
  20464 			if **(**uint32_t)(__ccgo_up(argb + uintptr(pos+best_length)*4)) != best_argb {
  20465 				goto _10
  20466 			}
  20467 			curr_length1 = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{VP8LVectorMismatch})))(tls, argb+uintptr(pos)*4, argb_start, max_len)
  20468 			if best_length < curr_length1 {
  20469 				best_length = curr_length1
  20470 				best_distance = base_position - libc.Uint32FromInt32(pos)
  20471 				best_argb = **(**uint32_t)(__ccgo_up(argb_start + uintptr(best_length)*4))
  20472 				// Stop if we have reached a good enough length.
  20473 				if best_length >= length_max {
  20474 					break
  20475 				}
  20476 			}
  20477 			goto _10
  20478 		_10:
  20479 			;
  20480 			pos = **(**int32_t)(__ccgo_up(chain + uintptr(pos)*4))
  20481 		}
  20482 		// We have the best match but in case the two intervals continue matching
  20483 		// to the left, we have the best matches for the left-extended pixels.
  20484 		max_base_position = base_position
  20485 		for int32(1) != 0 {
  20486 			**(**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)
  20487 			base_position = base_position - 1
  20488 			// Stop if we don't have a match or if we are out of bounds.
  20489 			if best_distance == uint32(0) || base_position == uint32(0) {
  20490 				break
  20491 			}
  20492 			// Stop if we cannot extend the matching intervals to the left.
  20493 			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)) {
  20494 				break
  20495 			}
  20496 			// Stop if we are matching at its limit because there could be a closer
  20497 			// matching interval with the same maximum length. Then again, if the
  20498 			// matching interval is as close as possible (best_distance == 1), we will
  20499 			// never find anything better so let's continue.
  20500 			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 {
  20501 				break
  20502 			}
  20503 			if best_length < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20504 				best_length = best_length + 1
  20505 				max_base_position = base_position
  20506 			}
  20507 		}
  20508 		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) {
  20509 			return 0
  20510 		}
  20511 		goto _7
  20512 	_7:
  20513 	}
  20514 	return WebPReportProgress(tls, pic, percent_start+percent_range, percent)
  20515 }
  20516 
  20517 func AddSingleLiteral(tls *libc.TLS, pixel uint32_t, use_color_cache int32, hashers uintptr, refs uintptr) {
  20518 	var key2, v5 uint32_t
  20519 	var retval, retval1, v, v7 PixOrCopy
  20520 	var v1, v3 int32
  20521 	_, _, _, _, _, _, _, _ = key2, retval, retval1, v, v1, v3, v5, v7
  20522 	if use_color_cache != 0 {
  20523 		v3 = libc.Int32FromUint32(pixel * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(hashers)).Fhash_shift)
  20524 		goto _4
  20525 	_4:
  20526 		v1 = v3
  20527 		goto _2
  20528 	_2:
  20529 		key2 = libc.Uint32FromInt32(v1)
  20530 		v5 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(hashers)).Fcolors + uintptr(key2)*4))
  20531 		goto _6
  20532 	_6:
  20533 		if v5 == pixel {
  20534 			retval.Fmode = uint8(kCacheIdx)
  20535 			retval.Fargb_or_distance = libc.Uint32FromInt32(libc.Int32FromUint32(key2))
  20536 			retval.Flen1 = uint16(1)
  20537 			v7 = retval
  20538 			goto _8
  20539 		_8:
  20540 			v = v7
  20541 		} else {
  20542 			retval1.Fmode = uint8(kLiteral)
  20543 			retval1.Fargb_or_distance = pixel
  20544 			retval1.Flen1 = uint16(1)
  20545 			v7 = retval1
  20546 			goto _10
  20547 		_10:
  20548 			v = v7
  20549 			**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(hashers)).Fcolors + uintptr(key2)*4)) = pixel
  20550 		}
  20551 	} else {
  20552 		retval1.Fmode = uint8(kLiteral)
  20553 		retval1.Fargb_or_distance = pixel
  20554 		retval1.Flen1 = uint16(1)
  20555 		v7 = retval1
  20556 		goto _12
  20557 	_12:
  20558 		v = v7
  20559 	}
  20560 	VP8LBackwardRefsCursorAdd(tls, refs, v)
  20561 }
  20562 
  20563 func BackwardReferencesRle(tls *libc.TLS, xsize int32, ysize int32, argb2 uintptr, cache_bits int32, refs uintptr) (r int32) {
  20564 	bp := tls.Alloc(16)
  20565 	defer tls.Free(16)
  20566 	var i, k, key, max_len, pix_count, prev_row_len, rle_len, use_color_cache, v1 int32
  20567 	var retval, v2 PixOrCopy
  20568 	var v7 uintptr
  20569 	var v8 uint32_t
  20570 	var _ /* hashers at bp+0 */ VP8LColorCache
  20571 	_, _, _, _, _, _, _, _, _, _, _, _, _ = i, k, key, max_len, pix_count, prev_row_len, retval, rle_len, use_color_cache, v1, v2, v7, v8
  20572 	pix_count = xsize * ysize
  20573 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  20574 	if use_color_cache != 0 && !(VP8LColorCacheInit(tls, bp, cache_bits) != 0) {
  20575 		return 0
  20576 	}
  20577 	VP8LClearBackwardRefs(tls, refs)
  20578 	// Add first pixel as literal.
  20579 	AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2)), use_color_cache, bp, refs)
  20580 	i = int32(1)
  20581 	for i < pix_count {
  20582 		max_len = MaxFindCopyLength(tls, pix_count-i)
  20583 		rle_len = FindMatchLength(tls, argb2+uintptr(i)*4, argb2+uintptr(i)*4-uintptr(1)*4, 0, max_len)
  20584 		if i < xsize {
  20585 			v1 = 0
  20586 		} else {
  20587 			v1 = FindMatchLength(tls, argb2+uintptr(i)*4, argb2+uintptr(i)*4-uintptr(xsize)*4, 0, max_len)
  20588 		}
  20589 		prev_row_len = v1
  20590 		if rle_len >= prev_row_len && rle_len >= int32(MIN_LENGTH) {
  20591 			retval.Fmode = uint8(kCopy)
  20592 			retval.Fargb_or_distance = uint32(1)
  20593 			retval.Flen1 = libc.Uint16FromInt32(rle_len)
  20594 			v2 = retval
  20595 			goto _3
  20596 		_3:
  20597 			VP8LBackwardRefsCursorAdd(tls, refs, v2)
  20598 			// We don't need to update the color cache here since it is always the
  20599 			// same pixel being copied, and that does not change the color cache
  20600 			// state.
  20601 			i = i + rle_len
  20602 		} else {
  20603 			if prev_row_len >= int32(MIN_LENGTH) {
  20604 				retval.Fmode = uint8(kCopy)
  20605 				retval.Fargb_or_distance = libc.Uint32FromInt32(xsize)
  20606 				retval.Flen1 = libc.Uint16FromInt32(prev_row_len)
  20607 				v2 = retval
  20608 				goto _5
  20609 			_5:
  20610 				VP8LBackwardRefsCursorAdd(tls, refs, v2)
  20611 				if use_color_cache != 0 {
  20612 					k = 0
  20613 					for {
  20614 						if !(k < prev_row_len) {
  20615 							break
  20616 						}
  20617 						v7 = bp
  20618 						v8 = **(**uint32_t)(__ccgo_up(argb2 + uintptr(i+k)*4))
  20619 						v1 = libc.Int32FromUint32(v8 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v7)).Fhash_shift)
  20620 						goto _10
  20621 					_10:
  20622 						key = v1
  20623 						**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v7)).Fcolors + uintptr(key)*4)) = v8
  20624 						goto _6
  20625 					_6:
  20626 						;
  20627 						k = k + 1
  20628 					}
  20629 				}
  20630 				i = i + prev_row_len
  20631 			} else {
  20632 				AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2 + uintptr(i)*4)), use_color_cache, bp, refs)
  20633 				i = i + 1
  20634 			}
  20635 		}
  20636 	}
  20637 	if use_color_cache != 0 {
  20638 		VP8LColorCacheClear(tls, bp)
  20639 	}
  20640 	return libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  20641 }
  20642 
  20643 func BackwardReferencesLz77(tls *libc.TLS, xsize int32, ysize int32, argb2 uintptr, cache_bits int32, hash_chain uintptr, refs uintptr) (r int32) {
  20644 	bp := tls.Alloc(32)
  20645 	defer tls.Free(32)
  20646 	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
  20647 	var retval, v14 PixOrCopy
  20648 	var v2 uintptr
  20649 	var v18 uint32_t
  20650 	var _ /* hashers at bp+0 */ VP8LColorCache
  20651 	var _ /* len at bp+20 */ int32
  20652 	var _ /* offset at bp+16 */ int32
  20653 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  20654 	i_last_check = -int32(1)
  20655 	ok = 0
  20656 	cc_init = 0
  20657 	use_color_cache = libc.BoolInt32(cache_bits > libc.Int32FromInt32(0))
  20658 	pix_count = xsize * ysize
  20659 	if use_color_cache != 0 {
  20660 		cc_init = VP8LColorCacheInit(tls, bp, cache_bits)
  20661 		if !(cc_init != 0) {
  20662 			goto Error
  20663 		}
  20664 	}
  20665 	VP8LClearBackwardRefs(tls, refs)
  20666 	i = 0
  20667 	for {
  20668 		if !(i < pix_count) {
  20669 			break
  20670 		}
  20671 		// Alternative#1: Code the pixels starting at 'i' using backward reference.
  20672 		**(**int32)(__ccgo_up(bp + 16)) = 0
  20673 		**(**int32)(__ccgo_up(bp + 20)) = 0
  20674 		v2 = hash_chain
  20675 		v3 = i
  20676 		v4 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(v2)).Foffset_length + uintptr(v3)*4)) >> int32(MAX_LENGTH_BITS))
  20677 		goto _5
  20678 	_5:
  20679 		**(**int32)(__ccgo_up(bp + 16)) = v4
  20680 		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)))
  20681 		goto _7
  20682 	_7:
  20683 		**(**int32)(__ccgo_up(bp + 20)) = v6
  20684 		if **(**int32)(__ccgo_up(bp + 20)) >= int32(MIN_LENGTH) {
  20685 			len_ini = **(**int32)(__ccgo_up(bp + 20))
  20686 			max_reach = 0
  20687 			if i+len_ini >= pix_count {
  20688 				v3 = pix_count - int32(1)
  20689 			} else {
  20690 				v3 = i + len_ini
  20691 			}
  20692 			j_max = v3
  20693 			// Only start from what we have not checked already.
  20694 			if i > i_last_check {
  20695 				v4 = i
  20696 			} else {
  20697 				v4 = i_last_check
  20698 			}
  20699 			i_last_check = v4
  20700 			// We know the best match for the current pixel but we try to find the
  20701 			// best matches for the current pixel AND the next one combined.
  20702 			// The naive method would use the intervals:
  20703 			// [i,i+len) + [i+len, length of best match at i+len)
  20704 			// while we check if we can use:
  20705 			// [i,j) (where j<=i+len) + [j, length of best match at j)
  20706 			j = i_last_check + int32(1)
  20707 			for {
  20708 				if !(j <= j_max) {
  20709 					break
  20710 				}
  20711 				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)))
  20712 				goto _12
  20713 			_12:
  20714 				len_j = v3
  20715 				if len_j >= int32(MIN_LENGTH) {
  20716 					v4 = len_j
  20717 				} else {
  20718 					v4 = int32(1)
  20719 				}
  20720 				reach = j + v4 // 1 for single literal.
  20721 				if reach > max_reach {
  20722 					**(**int32)(__ccgo_up(bp + 20)) = j - i
  20723 					max_reach = reach
  20724 					if max_reach >= pix_count {
  20725 						break
  20726 					}
  20727 				}
  20728 				goto _10
  20729 			_10:
  20730 				;
  20731 				j = j + 1
  20732 			}
  20733 		} else {
  20734 			**(**int32)(__ccgo_up(bp + 20)) = int32(1)
  20735 		}
  20736 		// Go with literal or backward reference.
  20737 		if **(**int32)(__ccgo_up(bp + 20)) == int32(1) {
  20738 			AddSingleLiteral(tls, **(**uint32_t)(__ccgo_up(argb2 + uintptr(i)*4)), use_color_cache, bp, refs)
  20739 		} else {
  20740 			retval.Fmode = uint8(kCopy)
  20741 			retval.Fargb_or_distance = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 16)))
  20742 			retval.Flen1 = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp + 20)))
  20743 			v14 = retval
  20744 			goto _15
  20745 		_15:
  20746 			VP8LBackwardRefsCursorAdd(tls, refs, v14)
  20747 			if use_color_cache != 0 {
  20748 				j = i
  20749 				for {
  20750 					if !(j < i+**(**int32)(__ccgo_up(bp + 20))) {
  20751 						break
  20752 					}
  20753 					v2 = bp
  20754 					v18 = **(**uint32_t)(__ccgo_up(argb2 + uintptr(j)*4))
  20755 					v3 = libc.Int32FromUint32(v18 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v2)).Fhash_shift)
  20756 					goto _20
  20757 				_20:
  20758 					key = v3
  20759 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v2)).Fcolors + uintptr(key)*4)) = v18
  20760 					goto _16
  20761 				_16:
  20762 					;
  20763 					j = j + 1
  20764 				}
  20765 			}
  20766 		}
  20767 		i = i + **(**int32)(__ccgo_up(bp + 20))
  20768 		goto _1
  20769 	_1:
  20770 	}
  20771 	ok = libc.BoolInt32(!((*VP8LBackwardRefs)(unsafe.Pointer(refs)).Ferror1 != 0))
  20772 	goto Error
  20773 Error:
  20774 	;
  20775 	if cc_init != 0 {
  20776 		VP8LColorCacheClear(tls, bp)
  20777 	}
  20778 	return ok
  20779 }
  20780 
  20781 // C documentation
  20782 //
  20783 //	// Compute an LZ77 by forcing matches to happen within a given distance cost.
  20784 //	// We therefore limit the algorithm to the lowest 32 values in the PlaneCode
  20785 //	// definition.
  20786 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) {
  20787 	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
  20788 	var counts, counts_ini uintptr
  20789 	var window_offsets, window_offsets_new [32]int32
  20790 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  20791 	pix_count = xsize * ysize
  20792 	window_offsets = [32]int32{}
  20793 	window_offsets_new = [32]int32{}
  20794 	window_offsets_size = 0
  20795 	window_offsets_new_size = 0
  20796 	counts_ini = WebPSafeMalloc(tls, libc.Uint64FromInt32(xsize*ysize), uint64(2))
  20797 	best_offset_prev = -int32(1)
  20798 	best_length_prev = -int32(1)
  20799 	if counts_ini == libc.UintptrFromInt32(0) {
  20800 		return 0
  20801 	}
  20802 	// counts[i] counts how many times a pixel is repeated starting at position i.
  20803 	i = pix_count - int32(2)
  20804 	counts = counts_ini + uintptr(i)*2
  20805 	**(**uint16_t)(__ccgo_up(counts + 1*2)) = uint16(1)
  20806 	for {
  20807 		if !(i >= 0) {
  20808 			break
  20809 		}
  20810 		if **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) == **(**uint32_t)(__ccgo_up(argb + uintptr(i+int32(1))*4)) {
  20811 			// Max out the counts to MAX_LENGTH.
  20812 			**(**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)))
  20813 		} else {
  20814 			**(**uint16_t)(__ccgo_up(counts)) = uint16(1)
  20815 		}
  20816 		goto _1
  20817 	_1:
  20818 		;
  20819 		i = i - 1
  20820 		counts -= 2
  20821 	}
  20822 	// Figure out the window offsets around a pixel. They are stored in a
  20823 	// spiraling order around the pixel as defined by VP8LDistanceToPlaneCode.
  20824 	y = 0
  20825 	for {
  20826 		if !(y <= int32(6)) {
  20827 			break
  20828 		}
  20829 		x = -int32(6)
  20830 		for {
  20831 			if !(x <= int32(6)) {
  20832 				break
  20833 			}
  20834 			offset = y*xsize + x
  20835 			// Ignore offsets that bring us after the pixel.
  20836 			if offset <= 0 {
  20837 				goto _3
  20838 			}
  20839 			plane_code = VP8LDistanceToPlaneCode(tls, xsize, offset) - int32(1)
  20840 			if plane_code >= int32(WINDOW_OFFSETS_SIZE_MAX) {
  20841 				goto _3
  20842 			}
  20843 			window_offsets[plane_code] = offset
  20844 			goto _3
  20845 		_3:
  20846 			;
  20847 			x = x + 1
  20848 		}
  20849 		goto _2
  20850 	_2:
  20851 		;
  20852 		y = y + 1
  20853 	}
  20854 	// For narrow images, not all plane codes are reached, so remove those.
  20855 	i = 0
  20856 	for {
  20857 		if !(i < int32(WINDOW_OFFSETS_SIZE_MAX)) {
  20858 			break
  20859 		}
  20860 		if window_offsets[i] == 0 {
  20861 			goto _4
  20862 		}
  20863 		v5 = window_offsets_size
  20864 		window_offsets_size = window_offsets_size + 1
  20865 		window_offsets[v5] = window_offsets[i]
  20866 		goto _4
  20867 	_4:
  20868 		;
  20869 		i = i + 1
  20870 	}
  20871 	// Given a pixel P, find the offsets that reach pixels unreachable from P-1
  20872 	// with any of the offsets in window_offsets[].
  20873 	i = 0
  20874 	for {
  20875 		if !(i < window_offsets_size) {
  20876 			break
  20877 		}
  20878 		is_reachable = 0
  20879 		j = 0
  20880 		for {
  20881 			if !(j < window_offsets_size && !(is_reachable != 0)) {
  20882 				break
  20883 			}
  20884 			is_reachable = is_reachable | libc.BoolInt32(window_offsets[i] == window_offsets[j]+int32(1))
  20885 			goto _7
  20886 		_7:
  20887 			;
  20888 			j = j + 1
  20889 		}
  20890 		if !(is_reachable != 0) {
  20891 			window_offsets_new[window_offsets_new_size] = window_offsets[i]
  20892 			window_offsets_new_size = window_offsets_new_size + 1
  20893 		}
  20894 		goto _6
  20895 	_6:
  20896 		;
  20897 		i = i + 1
  20898 	}
  20899 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length)) = uint32(0)
  20900 	i = int32(1)
  20901 	for {
  20902 		if !(i < pix_count) {
  20903 			break
  20904 		}
  20905 		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)))
  20906 		goto _10
  20907 	_10:
  20908 		best_length = v5
  20909 		do_compute = int32(1)
  20910 		if best_length >= libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20911 			// Do not recompute the best match if we already have a maximal one in the
  20912 			// window.
  20913 			v9 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain_best)).Foffset_length + uintptr(i)*4)) >> int32(MAX_LENGTH_BITS))
  20914 			goto _12
  20915 		_12:
  20916 			best_offset = v9
  20917 			ind = 0
  20918 			for {
  20919 				if !(ind < window_offsets_size) {
  20920 					break
  20921 				}
  20922 				if best_offset == window_offsets[ind] {
  20923 					do_compute = 0
  20924 					break
  20925 				}
  20926 				goto _13
  20927 			_13:
  20928 				;
  20929 				ind = ind + 1
  20930 			}
  20931 		}
  20932 		if do_compute != 0 {
  20933 			// Figure out if we should use the offset/length from the previous pixel
  20934 			// as an initial guess and therefore only inspect the offsets in
  20935 			// window_offsets_new[].
  20936 			use_prev = libc.BoolInt32(best_length_prev > int32(1) && best_length_prev < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1))
  20937 			if use_prev != 0 {
  20938 				v5 = window_offsets_new_size
  20939 			} else {
  20940 				v5 = window_offsets_size
  20941 			}
  20942 			num_ind = v5
  20943 			if use_prev != 0 {
  20944 				v9 = best_length_prev - int32(1)
  20945 			} else {
  20946 				v9 = 0
  20947 			}
  20948 			best_length = v9
  20949 			if use_prev != 0 {
  20950 				v5 = best_offset_prev
  20951 			} else {
  20952 				v5 = 0
  20953 			}
  20954 			best_offset = v5
  20955 			// Find the longest match in a window around the pixel.
  20956 			ind = 0
  20957 			for {
  20958 				if !(ind < num_ind) {
  20959 					break
  20960 				}
  20961 				curr_length = 0
  20962 				j1 = i
  20963 				if use_prev != 0 {
  20964 					v5 = i - window_offsets_new[ind]
  20965 				} else {
  20966 					v5 = i - window_offsets[ind]
  20967 				}
  20968 				j_offset = v5
  20969 				if j_offset < 0 || **(**uint32_t)(__ccgo_up(argb + uintptr(j_offset)*4)) != **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) {
  20970 					goto _17
  20971 				}
  20972 				// The longest match is the sum of how many times each pixel is
  20973 				// repeated.
  20974 				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)) {
  20975 					counts_j_offset = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts_ini + uintptr(j_offset)*2)))
  20976 					counts_j = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(counts_ini + uintptr(j1)*2)))
  20977 					if counts_j_offset != counts_j {
  20978 						if counts_j_offset < counts_j {
  20979 							v5 = counts_j_offset
  20980 						} else {
  20981 							v5 = counts_j
  20982 						}
  20983 						curr_length = curr_length + v5
  20984 						break
  20985 					}
  20986 					// The same color is repeated counts_pos times at j_offset and j.
  20987 					curr_length = curr_length + counts_j_offset
  20988 					j_offset = j_offset + counts_j_offset
  20989 					j1 = j1 + counts_j_offset
  20990 				}
  20991 				if best_length < curr_length {
  20992 					if use_prev != 0 {
  20993 						v5 = window_offsets_new[ind]
  20994 					} else {
  20995 						v5 = window_offsets[ind]
  20996 					}
  20997 					best_offset = v5
  20998 					if curr_length >= libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS)-libc.Int32FromInt32(1) {
  20999 						best_length = libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_LENGTH_BITS) - libc.Int32FromInt32(1)
  21000 						break
  21001 					} else {
  21002 						best_length = curr_length
  21003 					}
  21004 				}
  21005 				goto _17
  21006 			_17:
  21007 				;
  21008 				ind = ind + 1
  21009 			}
  21010 		}
  21011 		if best_length <= int32(MIN_LENGTH) {
  21012 			**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length + uintptr(i)*4)) = uint32(0)
  21013 			best_offset_prev = 0
  21014 			best_length_prev = 0
  21015 		} else {
  21016 			**(**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)
  21017 			best_offset_prev = best_offset
  21018 			best_length_prev = best_length
  21019 		}
  21020 		goto _8
  21021 	_8:
  21022 		;
  21023 		i = i + 1
  21024 	}
  21025 	**(**uint32_t)(__ccgo_up((*VP8LHashChain)(unsafe.Pointer(hash_chain)).Foffset_length)) = uint32(0)
  21026 	WebPSafeFree(tls, counts_ini)
  21027 	return BackwardReferencesLz77(tls, xsize, ysize, argb, cache_bits, hash_chain, refs)
  21028 }
  21029 
  21030 // -----------------------------------------------------------------------------
  21031 
  21032 func BackwardReferences2DLocality(tls *libc.TLS, xsize int32, refs uintptr) {
  21033 	bp := tls.Alloc(32)
  21034 	defer tls.Free(32)
  21035 	var dist, transformed_dist, v1, v3 int32
  21036 	var v5, v6, v7 uintptr
  21037 	var _ /* c at bp+0 */ VP8LRefsCursor
  21038 	_, _, _, _, _, _, _ = dist, transformed_dist, v1, v3, v5, v6, v7
  21039 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  21040 	for {
  21041 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  21042 		goto _2
  21043 	_2:
  21044 		if !(v1 != 0) {
  21045 			break
  21046 		}
  21047 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fmode) == int32(kCopy))
  21048 		goto _4
  21049 	_4:
  21050 		if v3 != 0 {
  21051 			dist = libc.Int32FromUint32((*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fargb_or_distance)
  21052 			transformed_dist = VP8LDistanceToPlaneCode(tls, xsize, dist)
  21053 			(*PixOrCopy)(unsafe.Pointer((**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos)).Fargb_or_distance = libc.Uint32FromInt32(transformed_dist)
  21054 		}
  21055 		v5 = bp
  21056 		v7 = v5
  21057 		*(*uintptr)(unsafe.Pointer(v7)) += 8
  21058 		v6 = *(*uintptr)(unsafe.Pointer(v7))
  21059 		if v6 == (*VP8LRefsCursor)(unsafe.Pointer(v5)).Flast_pos {
  21060 			VP8LRefsCursorNextBlock(tls, v5)
  21061 		}
  21062 	}
  21063 }
  21064 
  21065 // C documentation
  21066 //
  21067 //	// Evaluate optimal cache bits for the local color cache.
  21068 //	// The input *best_cache_bits sets the maximum cache bits to use (passing 0
  21069 //	// implies disabling the local color cache). The local color cache is also
  21070 //	// disabled for the lower (<= 25) quality.
  21071 //	// Returns 0 in case of memory error.
  21072 func CalculateBestCacheSize(tls *libc.TLS, argb2 uintptr, quality int32, refs uintptr, best_cache_bits uintptr) (r1 int32) {
  21073 	bp := tls.Alloc(224)
  21074 	defer tls.Free(224)
  21075 	var a, argb_prev, b, g, pix, r, v11 uint32_t
  21076 	var cache_bits_max, highest_bit, i, key2, key3, len1, ok, second_highest_bit, v1, v3, v5, v8 int32
  21077 	var cc_init [11]int32
  21078 	var entropy, entropy_min uint64_t
  21079 	var histos [11]uintptr
  21080 	var prefix_code VP8LPrefixCode
  21081 	var v, v16, v17, v18, v7 uintptr
  21082 	var _ /* c at bp+176 */ VP8LRefsCursor
  21083 	var _ /* code at bp+200 */ int32
  21084 	var _ /* extra_bits at bp+204 */ int32
  21085 	var _ /* extra_bits_value at bp+208 */ int32
  21086 	var _ /* hashers at bp+0 */ [11]VP8LColorCache
  21087 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  21088 	if quality <= int32(25) {
  21089 		v1 = 0
  21090 	} else {
  21091 		v1 = **(**int32)(__ccgo_up(best_cache_bits))
  21092 	}
  21093 	cache_bits_max = v1
  21094 	entropy_min = ^libc.Uint64FromUint64(0)
  21095 	cc_init = [11]int32{}
  21096 	**(**VP8LRefsCursor)(__ccgo_up(bp + 176)) = VP8LRefsCursorInit(tls, refs)
  21097 	histos = [11]uintptr{}
  21098 	ok = 0
  21099 	if cache_bits_max == 0 {
  21100 		**(**int32)(__ccgo_up(best_cache_bits)) = 0
  21101 		// Local color cache is disabled.
  21102 		return int32(1)
  21103 	}
  21104 	// Allocate data.
  21105 	i = 0
  21106 	for {
  21107 		if !(i <= cache_bits_max) {
  21108 			break
  21109 		}
  21110 		histos[i] = VP8LAllocateHistogram(tls, i)
  21111 		if histos[i] == libc.UintptrFromInt32(0) {
  21112 			goto Error
  21113 		}
  21114 		VP8LHistogramInit(tls, histos[i], i, int32(1))
  21115 		if i == 0 {
  21116 			goto _2
  21117 		}
  21118 		cc_init[i] = VP8LColorCacheInit(tls, bp+uintptr(i)*16, i)
  21119 		if !(cc_init[i] != 0) {
  21120 			goto Error
  21121 		}
  21122 		goto _2
  21123 	_2:
  21124 		;
  21125 		i = i + 1
  21126 	}
  21127 	// Find the cache_bits giving the lowest entropy. The search is done in a
  21128 	// brute-force way as the function (entropy w.r.t cache_bits) can be
  21129 	// anything in practice.
  21130 	for {
  21131 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp+176)).Fcur_pos != libc.UintptrFromInt32(0))
  21132 		goto _4
  21133 	_4:
  21134 		if !(v1 != 0) {
  21135 			break
  21136 		}
  21137 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp + 176))).Fcur_pos
  21138 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  21139 		goto _6
  21140 	_6:
  21141 		if v3 != 0 {
  21142 			v7 = argb2
  21143 			argb2 += 4
  21144 			pix = **(**uint32_t)(__ccgo_up(v7))
  21145 			a = pix >> libc.Int32FromInt32(24) & uint32(0xff)
  21146 			r = pix >> libc.Int32FromInt32(16) & uint32(0xff)
  21147 			g = pix >> libc.Int32FromInt32(8) & uint32(0xff)
  21148 			b = pix >> libc.Int32FromInt32(0) & uint32(0xff)
  21149 			v5 = libc.Int32FromUint32(pix * kHashMul11 >> (int32(32) - cache_bits_max))
  21150 			goto _9
  21151 		_9:
  21152 			// The keys of the caches can be derived from the longest one.
  21153 			key2 = v5
  21154 			// Do not use the color cache for cache_bits = 0.
  21155 			**(**uint32_t)(__ccgo_up(histos[0] + 1032 + uintptr(b)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 1032 + uintptr(b)*4)) + 1
  21156 			**(**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
  21157 			**(**uint32_t)(__ccgo_up(histos[0] + 8 + uintptr(r)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 8 + uintptr(r)*4)) + 1
  21158 			**(**uint32_t)(__ccgo_up(histos[0] + 2056 + uintptr(a)*4)) = **(**uint32_t)(__ccgo_up(histos[0] + 2056 + uintptr(a)*4)) + 1
  21159 			// Deal with cache_bits > 0.
  21160 			i = cache_bits_max
  21161 			for {
  21162 				if !(i >= int32(1)) {
  21163 					break
  21164 				}
  21165 				v11 = **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(bp+uintptr(i)*16)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4))
  21166 				goto _12
  21167 			_12:
  21168 				if v11 == pix {
  21169 					**(**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
  21170 				} else {
  21171 					**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(bp+uintptr(i)*16)).Fcolors + uintptr(libc.Uint32FromInt32(key2))*4)) = pix
  21172 					**(**uint32_t)(__ccgo_up(histos[i] + 1032 + uintptr(b)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 1032 + uintptr(b)*4)) + 1
  21173 					**(**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
  21174 					**(**uint32_t)(__ccgo_up(histos[i] + 8 + uintptr(r)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 8 + uintptr(r)*4)) + 1
  21175 					**(**uint32_t)(__ccgo_up(histos[i] + 2056 + uintptr(a)*4)) = **(**uint32_t)(__ccgo_up(histos[i] + 2056 + uintptr(a)*4)) + 1
  21176 				}
  21177 				goto _10
  21178 			_10:
  21179 				;
  21180 				i = i - 1
  21181 				key2 = key2 >> int32(1)
  21182 			}
  21183 		} else {
  21184 			v11 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  21185 			goto _14
  21186 		_14:
  21187 			// We should compute the contribution of the (distance,length)
  21188 			// histograms but those are the same independently from the cache size.
  21189 			// As those constant contributions are in the end added to the other
  21190 			// histogram contributions, we can ignore them, except for the length
  21191 			// prefix that is part of the 'literal' histogram.
  21192 			len1 = libc.Int32FromUint32(v11)
  21193 			argb_prev = **(**uint32_t)(__ccgo_up(argb2)) ^ uint32(0xffffffff)
  21194 			v1 = len1
  21195 			v7 = bp + 200
  21196 			v16 = bp + 204
  21197 			v17 = bp + 208
  21198 			if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  21199 				prefix_code = kPrefixEncodeCode[v1]
  21200 				**(**int32)(__ccgo_up(v7)) = int32(prefix_code.Fcode)
  21201 				**(**int32)(__ccgo_up(v16)) = int32(prefix_code.Fextra_bits)
  21202 				**(**int32)(__ccgo_up(v17)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v1])
  21203 			} else {
  21204 				v3 = v1
  21205 				v18 = v16
  21206 				v3 = v3 - 1
  21207 				v5 = v3
  21208 				v8 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v5))
  21209 				goto _23
  21210 			_23:
  21211 				highest_bit = v8
  21212 				second_highest_bit = v3 >> (highest_bit - int32(1)) & int32(1)
  21213 				**(**int32)(__ccgo_up(v18)) = highest_bit - int32(1)
  21214 				**(**int32)(__ccgo_up(v17)) = v3 & (int32(1)<<**(**int32)(__ccgo_up(v18)) - int32(1))
  21215 				**(**int32)(__ccgo_up(v7)) = int32(2)*highest_bit + second_highest_bit
  21216 			}
  21217 			i = 0
  21218 			for {
  21219 				if !(i <= cache_bits_max) {
  21220 					break
  21221 				}
  21222 				**(**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
  21223 				goto _24
  21224 			_24:
  21225 				;
  21226 				i = i + 1
  21227 			}
  21228 			// Update the color caches.
  21229 			for {
  21230 				if **(**uint32_t)(__ccgo_up(argb2)) != argb_prev {
  21231 					v3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb2)) * kHashMul11 >> (int32(32) - cache_bits_max))
  21232 					goto _28
  21233 				_28:
  21234 					// Efficiency: insert only if the color changes.
  21235 					key3 = v3
  21236 					i = cache_bits_max
  21237 					for {
  21238 						if !(i >= int32(1)) {
  21239 							break
  21240 						}
  21241 						**(**uint32_t)(__ccgo_up((**(**[11]VP8LColorCache)(__ccgo_up(bp)))[i].Fcolors + uintptr(key3)*4)) = **(**uint32_t)(__ccgo_up(argb2))
  21242 						goto _29
  21243 					_29:
  21244 						;
  21245 						i = i - 1
  21246 						key3 = key3 >> int32(1)
  21247 					}
  21248 					argb_prev = **(**uint32_t)(__ccgo_up(argb2))
  21249 				}
  21250 				argb2 += 4
  21251 				goto _26
  21252 			_26:
  21253 				;
  21254 				len1 = len1 - 1
  21255 				v1 = len1
  21256 				if !(v1 != 0) {
  21257 					break
  21258 				}
  21259 			}
  21260 		}
  21261 		v7 = bp + 176
  21262 		v17 = v7
  21263 		*(*uintptr)(unsafe.Pointer(v17)) += 8
  21264 		v16 = *(*uintptr)(unsafe.Pointer(v17))
  21265 		if v16 == (*VP8LRefsCursor)(unsafe.Pointer(v7)).Flast_pos {
  21266 			VP8LRefsCursorNextBlock(tls, v7)
  21267 		}
  21268 	}
  21269 	i = 0
  21270 	for {
  21271 		if !(i <= cache_bits_max) {
  21272 			break
  21273 		}
  21274 		entropy = VP8LHistogramEstimateBits(tls, histos[i])
  21275 		if i == 0 || entropy < entropy_min {
  21276 			entropy_min = entropy
  21277 			**(**int32)(__ccgo_up(best_cache_bits)) = i
  21278 		}
  21279 		goto _33
  21280 	_33:
  21281 		;
  21282 		i = i + 1
  21283 	}
  21284 	ok = int32(1)
  21285 	goto Error
  21286 Error:
  21287 	;
  21288 	i = 0
  21289 	for {
  21290 		if !(i <= cache_bits_max) {
  21291 			break
  21292 		}
  21293 		if cc_init[i] != 0 {
  21294 			VP8LColorCacheClear(tls, bp+uintptr(i)*16)
  21295 		}
  21296 		VP8LFreeHistogram(tls, histos[i])
  21297 		goto _34
  21298 	_34:
  21299 		;
  21300 		i = i + 1
  21301 	}
  21302 	return ok
  21303 }
  21304 
  21305 // C documentation
  21306 //
  21307 //	// Update (in-place) backward references for specified cache_bits.
  21308 func BackwardRefsWithLocalCache(tls *libc.TLS, argb3 uintptr, cache_bits int32, refs uintptr) (r int32) {
  21309 	bp := tls.Alloc(48)
  21310 	defer tls.Free(48)
  21311 	var argb_literal, v6 uint32_t
  21312 	var ix, k, key, key1, pixel_index, v1, v11, v3, v7, v9 int32
  21313 	var retval, v12 PixOrCopy
  21314 	var v, v14, v20, v5 uintptr
  21315 	var _ /* c at bp+16 */ VP8LRefsCursor
  21316 	var _ /* hashers at bp+0 */ VP8LColorCache
  21317 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = argb_literal, ix, k, key, key1, pixel_index, retval, v, v1, v11, v12, v14, v20, v3, v5, v6, v7, v9
  21318 	pixel_index = 0
  21319 	**(**VP8LRefsCursor)(__ccgo_up(bp + 16)) = VP8LRefsCursorInit(tls, refs)
  21320 	if !(VP8LColorCacheInit(tls, bp, cache_bits) != 0) {
  21321 		return 0
  21322 	}
  21323 	for {
  21324 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp+16)).Fcur_pos != libc.UintptrFromInt32(0))
  21325 		goto _2
  21326 	_2:
  21327 		if !(v1 != 0) {
  21328 			break
  21329 		}
  21330 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp + 16))).Fcur_pos
  21331 		v3 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  21332 		goto _4
  21333 	_4:
  21334 		if v3 != 0 {
  21335 			argb_literal = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  21336 			v5 = bp
  21337 			v6 = argb_literal
  21338 			v7 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21339 			goto _8
  21340 		_8:
  21341 			key1 = v7
  21342 			if **(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key1)*4)) == v6 {
  21343 				v11 = key1
  21344 			} else {
  21345 				v11 = -int32(1)
  21346 			}
  21347 			v9 = v11
  21348 			goto _10
  21349 		_10:
  21350 			ix = v9
  21351 			if ix >= 0 {
  21352 				// hashers contains argb_literal
  21353 				retval.Fmode = uint8(kCacheIdx)
  21354 				retval.Fargb_or_distance = libc.Uint32FromInt32(ix)
  21355 				retval.Flen1 = uint16(1)
  21356 				v12 = retval
  21357 				goto _13
  21358 			_13:
  21359 				**(**PixOrCopy)(__ccgo_up(v)) = v12
  21360 			} else {
  21361 				v5 = bp
  21362 				v6 = argb_literal
  21363 				v1 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21364 				goto _17
  21365 			_17:
  21366 				key = v1
  21367 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key)*4)) = v6
  21368 			}
  21369 			pixel_index = pixel_index + 1
  21370 		} else {
  21371 			k = 0
  21372 			for {
  21373 				if !(k < libc.Int32FromUint16((*PixOrCopy)(unsafe.Pointer(v)).Flen1)) {
  21374 					break
  21375 				}
  21376 				v1 = pixel_index
  21377 				pixel_index = pixel_index + 1
  21378 				v5 = bp
  21379 				v6 = **(**uint32_t)(__ccgo_up(argb3 + uintptr(v1)*4))
  21380 				v3 = libc.Int32FromUint32(v6 * kHashMul11 >> (*VP8LColorCache)(unsafe.Pointer(v5)).Fhash_shift)
  21381 				goto _23
  21382 			_23:
  21383 				key = v3
  21384 				**(**uint32_t)(__ccgo_up((*VP8LColorCache)(unsafe.Pointer(v5)).Fcolors + uintptr(key)*4)) = v6
  21385 				goto _18
  21386 			_18:
  21387 				;
  21388 				k = k + 1
  21389 			}
  21390 		}
  21391 		v5 = bp + 16
  21392 		v20 = v5
  21393 		*(*uintptr)(unsafe.Pointer(v20)) += 8
  21394 		v14 = *(*uintptr)(unsafe.Pointer(v20))
  21395 		if v14 == (*VP8LRefsCursor)(unsafe.Pointer(v5)).Flast_pos {
  21396 			VP8LRefsCursorNextBlock(tls, v5)
  21397 		}
  21398 	}
  21399 	VP8LColorCacheClear(tls, bp)
  21400 	return int32(1)
  21401 }
  21402 
  21403 func GetBackwardReferencesLowEffort(tls *libc.TLS, width int32, height int32, argb uintptr, cache_bits uintptr, hash_chain uintptr, refs_lz77 uintptr) (r uintptr) {
  21404 	**(**int32)(__ccgo_up(cache_bits)) = 0
  21405 	if !(BackwardReferencesLz77(tls, width, height, argb, 0, hash_chain, refs_lz77) != 0) {
  21406 		return libc.UintptrFromInt32(0)
  21407 	}
  21408 	BackwardReferences2DLocality(tls, width, refs_lz77)
  21409 	return refs_lz77
  21410 }
  21411 
  21412 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) {
  21413 	bp := tls.Alloc(32)
  21414 	defer tls.Free(32)
  21415 	var bit_cost, bit_cost_trace uint64_t
  21416 	var bit_costs_best [2]uint64_t
  21417 	var cache_bits1, i, lz77_type, res, status, v1 int32
  21418 	var hash_chain_tmp, histo, refs_tmp, v6 uintptr
  21419 	var lz77_types_best [2]int32
  21420 	var _ /* cache_bits at bp+16 */ int32
  21421 	var _ /* hash_chain_box at bp+0 */ VP8LHashChain
  21422 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  21423 	histo = libc.UintptrFromInt32(0)
  21424 	// Index 0 is for a color cache, index 1 for no cache (if needed).
  21425 	lz77_types_best = [2]int32{}
  21426 	bit_costs_best = [2]uint64_t{
  21427 		0: ^libc.Uint64FromUint64(0),
  21428 		1: ^libc.Uint64FromUint64(0),
  21429 	}
  21430 	if do_no_cache != 0 {
  21431 		v1 = int32(2)
  21432 	} else {
  21433 		v1 = int32(1)
  21434 	}
  21435 	refs_tmp = refs + uintptr(v1)*40
  21436 	status = 0
  21437 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^__predefined_size_t(0))
  21438 	histo = VP8LAllocateHistogram(tls, int32(MAX_COLOR_CACHE_BITS))
  21439 	if histo == libc.UintptrFromInt32(0) {
  21440 		goto Error
  21441 	}
  21442 	lz77_type = int32(1)
  21443 	for {
  21444 		if !(lz77_types_to_try != 0) {
  21445 			break
  21446 		}
  21447 		res = 0
  21448 		bit_cost = 0
  21449 		if lz77_types_to_try&lz77_type == 0 {
  21450 			goto _2
  21451 		}
  21452 		switch lz77_type {
  21453 		case int32(kLZ77RLE):
  21454 			res = BackwardReferencesRle(tls, width, height, argb, 0, refs_tmp)
  21455 		case int32(kLZ77Standard):
  21456 			// Compute LZ77 with no cache (0 bits), as the ideal LZ77 with a color
  21457 			// cache is not that different in practice.
  21458 			res = BackwardReferencesLz77(tls, width, height, argb, 0, hash_chain, refs_tmp)
  21459 		case int32(kLZ77Box):
  21460 			if !(VP8LHashChainInit(tls, bp, width*height) != 0) {
  21461 				goto Error
  21462 			}
  21463 			res = BackwardReferencesLz77Box(tls, width, height, argb, 0, hash_chain, bp, refs_tmp)
  21464 		default:
  21465 		}
  21466 		if !(res != 0) {
  21467 			goto Error
  21468 		}
  21469 		// Start with the no color cache case.
  21470 		i = int32(1)
  21471 		for {
  21472 			if !(i >= 0) {
  21473 				break
  21474 			}
  21475 			if i == int32(1) {
  21476 				v1 = 0
  21477 			} else {
  21478 				v1 = cache_bits_max
  21479 			}
  21480 			**(**int32)(__ccgo_up(bp + 16)) = v1
  21481 			if i == int32(1) && !(do_no_cache != 0) {
  21482 				goto _3
  21483 			}
  21484 			if i == 0 {
  21485 				// Try with a color cache.
  21486 				if !(CalculateBestCacheSize(tls, argb, quality, refs_tmp, bp+16) != 0) {
  21487 					goto Error
  21488 				}
  21489 				if **(**int32)(__ccgo_up(bp + 16)) > 0 {
  21490 					if !(BackwardRefsWithLocalCache(tls, argb, **(**int32)(__ccgo_up(bp + 16)), refs_tmp) != 0) {
  21491 						goto Error
  21492 					}
  21493 				}
  21494 			}
  21495 			if i == 0 && do_no_cache != 0 && **(**int32)(__ccgo_up(bp + 16)) == 0 {
  21496 				// No need to re-compute bit_cost as it was computed at i == 1.
  21497 			} else {
  21498 				VP8LHistogramCreate(tls, histo, refs_tmp, **(**int32)(__ccgo_up(bp + 16)))
  21499 				bit_cost = VP8LHistogramEstimateBits(tls, histo)
  21500 			}
  21501 			if bit_cost < bit_costs_best[i] {
  21502 				if i == int32(1) {
  21503 					// Do not swap as the full cache analysis would have the wrong
  21504 					// VP8LBackwardRefs to start with.
  21505 					if !(BackwardRefsClone(tls, refs_tmp, refs+1*40) != 0) {
  21506 						goto Error
  21507 					}
  21508 				} else {
  21509 					BackwardRefsSwap(tls, refs_tmp, refs)
  21510 				}
  21511 				bit_costs_best[i] = bit_cost
  21512 				lz77_types_best[i] = lz77_type
  21513 				if i == 0 {
  21514 					**(**int32)(__ccgo_up(cache_bits_best)) = **(**int32)(__ccgo_up(bp + 16))
  21515 				}
  21516 			}
  21517 			goto _3
  21518 		_3:
  21519 			;
  21520 			i = i - 1
  21521 		}
  21522 		goto _2
  21523 	_2:
  21524 		;
  21525 		lz77_types_to_try = lz77_types_to_try & ^lz77_type
  21526 		lz77_type = lz77_type << int32(1)
  21527 	}
  21528 	// Improve on simple LZ77 but only for high quality (TraceBackwards is
  21529 	// costly).
  21530 	i = int32(1)
  21531 	for {
  21532 		if !(i >= 0) {
  21533 			break
  21534 		}
  21535 		if i == int32(1) && !(do_no_cache != 0) {
  21536 			goto _5
  21537 		}
  21538 		if (lz77_types_best[i] == int32(kLZ77Standard) || lz77_types_best[i] == int32(kLZ77Box)) && quality >= int32(25) {
  21539 			if lz77_types_best[i] == int32(kLZ77Standard) {
  21540 				v6 = hash_chain
  21541 			} else {
  21542 				v6 = bp
  21543 			}
  21544 			hash_chain_tmp = v6
  21545 			if i == int32(1) {
  21546 				v1 = 0
  21547 			} else {
  21548 				v1 = **(**int32)(__ccgo_up(cache_bits_best))
  21549 			}
  21550 			cache_bits1 = v1
  21551 			if !(VP8LBackwardReferencesTraceBackwards(tls, width, height, argb, cache_bits1, hash_chain_tmp, refs+uintptr(i)*40, refs_tmp) != 0) {
  21552 				goto Error
  21553 			}
  21554 			VP8LHistogramCreate(tls, histo, refs_tmp, cache_bits1)
  21555 			bit_cost_trace = VP8LHistogramEstimateBits(tls, histo)
  21556 			if bit_cost_trace < bit_costs_best[i] {
  21557 				BackwardRefsSwap(tls, refs_tmp, refs+uintptr(i)*40)
  21558 			}
  21559 		}
  21560 		BackwardReferences2DLocality(tls, width, refs+uintptr(i)*40)
  21561 		if i == int32(1) && lz77_types_best[0] == lz77_types_best[int32(1)] && **(**int32)(__ccgo_up(cache_bits_best)) == 0 {
  21562 			// If the best cache size is 0 and we have the same best LZ77, just copy
  21563 			// the data over and stop here.
  21564 			if !(BackwardRefsClone(tls, refs+1*40, refs) != 0) {
  21565 				goto Error
  21566 			}
  21567 			break
  21568 		}
  21569 		goto _5
  21570 	_5:
  21571 		;
  21572 		i = i - 1
  21573 	}
  21574 	status = int32(1)
  21575 	goto Error
  21576 Error:
  21577 	;
  21578 	VP8LHashChainClear(tls, bp)
  21579 	VP8LFreeHistogram(tls, histo)
  21580 	return status
  21581 }
  21582 
  21583 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) {
  21584 	var refs_best uintptr
  21585 	_ = refs_best
  21586 	if low_effort != 0 {
  21587 		**(**int32)(__ccgo_up(cache_bits_best)) = cache_bits_max
  21588 		refs_best = GetBackwardReferencesLowEffort(tls, width, height, argb, cache_bits_best, hash_chain, refs)
  21589 		if refs_best == libc.UintptrFromInt32(0) {
  21590 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  21591 		}
  21592 		// Set it in first position.
  21593 		BackwardRefsSwap(tls, refs_best, refs)
  21594 	} else {
  21595 		if !(GetBackwardReferences(tls, width, height, argb, quality, lz77_types_to_try, cache_bits_max, do_no_cache, hash_chain, refs, cache_bits_best) != 0) {
  21596 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  21597 		}
  21598 	}
  21599 	return WebPReportProgress(tls, pic, **(**int32)(__ccgo_up(percent))+percent_range, percent)
  21600 }
  21601 
  21602 const MAX_LEVEL1 = 9
  21603 
  21604 //------------------------------------------------------------------------------
  21605 
  21606 // Copyright 2010 Google Inc. All Rights Reserved.
  21607 //
  21608 // Use of this source code is governed by a BSD-style license
  21609 // that can be found in the COPYING file in the root of the source
  21610 // tree. An additional intellectual property rights grant can be found
  21611 // in the file PATENTS. All contributing project authors may
  21612 // be found in the AUTHORS file in the root of the source tree.
  21613 // -----------------------------------------------------------------------------
  21614 //
  21615 //  Common types + memory wrappers
  21616 //
  21617 // Author: Skal (pascal.massimino@gmail.com)
  21618 
  21619 //------------------------------------------------------------------------------
  21620 // WebPConfig
  21621 //------------------------------------------------------------------------------
  21622 
  21623 func WebPConfigInitInternal(tls *libc.TLS, config uintptr, preset WebPPreset1, quality float32, version int32) (r int32) {
  21624 	if version>>int32(8) != libc.Int32FromInt32(WEBP_ENCODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  21625 		return 0 // caller/system version mismatch!
  21626 	}
  21627 	if config == libc.UintptrFromInt32(0) {
  21628 		return 0
  21629 	}
  21630 	(*WebPConfig)(unsafe.Pointer(config)).Fquality = quality
  21631 	(*WebPConfig)(unsafe.Pointer(config)).Ftarget_size = 0
  21632 	(*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR = float32(0)
  21633 	(*WebPConfig)(unsafe.Pointer(config)).Fmethod = int32(4)
  21634 	(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(50)
  21635 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(60) // mid-filtering
  21636 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = 0
  21637 	(*WebPConfig)(unsafe.Pointer(config)).Ffilter_type = int32(1) // default: strong (so U/V is filtered too)
  21638 	(*WebPConfig)(unsafe.Pointer(config)).Fpartitions = 0
  21639 	(*WebPConfig)(unsafe.Pointer(config)).Fsegments = int32(4)
  21640 	(*WebPConfig)(unsafe.Pointer(config)).Fpass = int32(1)
  21641 	(*WebPConfig)(unsafe.Pointer(config)).Fqmin = 0
  21642 	(*WebPConfig)(unsafe.Pointer(config)).Fqmax = int32(100)
  21643 	(*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed = 0
  21644 	(*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing = 0
  21645 	(*WebPConfig)(unsafe.Pointer(config)).Fautofilter = 0
  21646 	(*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit = 0
  21647 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_compression = int32(1)
  21648 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering = int32(1)
  21649 	(*WebPConfig)(unsafe.Pointer(config)).Falpha_quality = int32(100)
  21650 	(*WebPConfig)(unsafe.Pointer(config)).Flossless = 0
  21651 	(*WebPConfig)(unsafe.Pointer(config)).Fexact = 0
  21652 	(*WebPConfig)(unsafe.Pointer(config)).Fimage_hint = int32(WEBP_HINT_DEFAULT)
  21653 	(*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size = 0
  21654 	(*WebPConfig)(unsafe.Pointer(config)).Fthread_level = 0
  21655 	(*WebPConfig)(unsafe.Pointer(config)).Flow_memory = 0
  21656 	(*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless = int32(100)
  21657 	(*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv = 0
  21658 	// TODO(skal): tune.
  21659 	switch preset {
  21660 	case int32(WEBP_PRESET_PICTURE):
  21661 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(80)
  21662 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(4)
  21663 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(35)
  21664 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21665 	case int32(WEBP_PRESET_PHOTO):
  21666 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(80)
  21667 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(3)
  21668 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(30)
  21669 		**(**int32)(__ccgo_up(config + 68)) |= int32(2)
  21670 	case int32(WEBP_PRESET_DRAWING):
  21671 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = int32(25)
  21672 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness = int32(6)
  21673 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = int32(10)
  21674 	case int32(WEBP_PRESET_ICON):
  21675 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = 0
  21676 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = 0     // disable filtering to retain sharpness
  21677 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21678 	case int32(WEBP_PRESET_TEXT):
  21679 		(*WebPConfig)(unsafe.Pointer(config)).Fsns_strength = 0
  21680 		(*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength = 0     // disable filtering to retain sharpness
  21681 		**(**int32)(__ccgo_up(config + 68)) &= ^libc.Int32FromInt32(2) // no dithering
  21682 		(*WebPConfig)(unsafe.Pointer(config)).Fsegments = int32(2)
  21683 	case int32(WEBP_PRESET_DEFAULT):
  21684 		fallthrough
  21685 	default:
  21686 		break
  21687 	}
  21688 	return WebPValidateConfig(tls, config)
  21689 }
  21690 
  21691 func WebPValidateConfig(tls *libc.TLS, config uintptr) (r int32) {
  21692 	if config == libc.UintptrFromInt32(0) {
  21693 		return 0
  21694 	}
  21695 	if (*WebPConfig)(unsafe.Pointer(config)).Fquality < libc.Float32FromInt32(0) || (*WebPConfig)(unsafe.Pointer(config)).Fquality > libc.Float32FromInt32(100) {
  21696 		return 0
  21697 	}
  21698 	if (*WebPConfig)(unsafe.Pointer(config)).Ftarget_size < 0 {
  21699 		return 0
  21700 	}
  21701 	if (*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR < libc.Float32FromInt32(0) {
  21702 		return 0
  21703 	}
  21704 	if (*WebPConfig)(unsafe.Pointer(config)).Fmethod < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fmethod > int32(6) {
  21705 		return 0
  21706 	}
  21707 	if (*WebPConfig)(unsafe.Pointer(config)).Fsegments < int32(1) || (*WebPConfig)(unsafe.Pointer(config)).Fsegments > int32(4) {
  21708 		return 0
  21709 	}
  21710 	if (*WebPConfig)(unsafe.Pointer(config)).Fsns_strength < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fsns_strength > int32(100) {
  21711 		return 0
  21712 	}
  21713 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength > int32(100) {
  21714 		return 0
  21715 	}
  21716 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_sharpness > int32(7) {
  21717 		return 0
  21718 	}
  21719 	if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type < 0 || (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type > int32(1) {
  21720 		return 0
  21721 	}
  21722 	if (*WebPConfig)(unsafe.Pointer(config)).Fautofilter < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fautofilter > int32(1) {
  21723 		return 0
  21724 	}
  21725 	if (*WebPConfig)(unsafe.Pointer(config)).Fpass < int32(1) || (*WebPConfig)(unsafe.Pointer(config)).Fpass > int32(10) {
  21726 		return 0
  21727 	}
  21728 	if (*WebPConfig)(unsafe.Pointer(config)).Fqmin < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fqmax > int32(100) || (*WebPConfig)(unsafe.Pointer(config)).Fqmin > (*WebPConfig)(unsafe.Pointer(config)).Fqmax {
  21729 		return 0
  21730 	}
  21731 	if (*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fshow_compressed > int32(1) {
  21732 		return 0
  21733 	}
  21734 	if (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing > int32(7) {
  21735 		return 0
  21736 	}
  21737 	if (*WebPConfig)(unsafe.Pointer(config)).Fpartitions < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpartitions > int32(3) {
  21738 		return 0
  21739 	}
  21740 	if (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit > int32(100) {
  21741 		return 0
  21742 	}
  21743 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_compression < 0 {
  21744 		return 0
  21745 	}
  21746 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_filtering < 0 {
  21747 		return 0
  21748 	}
  21749 	if (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality < 0 || (*WebPConfig)(unsafe.Pointer(config)).Falpha_quality > int32(100) {
  21750 		return 0
  21751 	}
  21752 	if (*WebPConfig)(unsafe.Pointer(config)).Flossless < 0 || (*WebPConfig)(unsafe.Pointer(config)).Flossless > int32(1) {
  21753 		return 0
  21754 	}
  21755 	if (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless > int32(100) {
  21756 		return 0
  21757 	}
  21758 	if (*WebPConfig)(unsafe.Pointer(config)).Fimage_hint >= int32(WEBP_HINT_LAST) {
  21759 		return 0
  21760 	}
  21761 	if (*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size < 0 || (*WebPConfig)(unsafe.Pointer(config)).Femulate_jpeg_size > int32(1) {
  21762 		return 0
  21763 	}
  21764 	if (*WebPConfig)(unsafe.Pointer(config)).Fthread_level < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fthread_level > int32(1) {
  21765 		return 0
  21766 	}
  21767 	if (*WebPConfig)(unsafe.Pointer(config)).Flow_memory < 0 || (*WebPConfig)(unsafe.Pointer(config)).Flow_memory > int32(1) {
  21768 		return 0
  21769 	}
  21770 	if (*WebPConfig)(unsafe.Pointer(config)).Fexact < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fexact > int32(1) {
  21771 		return 0
  21772 	}
  21773 	if (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv < 0 || (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv > int32(1) {
  21774 		return 0
  21775 	}
  21776 	return int32(1)
  21777 }
  21778 
  21779 //------------------------------------------------------------------------------
  21780 
  21781 // C documentation
  21782 //
  21783 //	// Mapping between -z level and -m / -q parameter settings.
  21784 var kLosslessPresets = [10]struct {
  21785 	Fmethod  uint8_t
  21786 	Fquality uint8_t
  21787 }{
  21788 	0: {},
  21789 	1: {
  21790 		Fmethod:  uint8(1),
  21791 		Fquality: uint8(20),
  21792 	},
  21793 	2: {
  21794 		Fmethod:  uint8(2),
  21795 		Fquality: uint8(25),
  21796 	},
  21797 	3: {
  21798 		Fmethod:  uint8(3),
  21799 		Fquality: uint8(30),
  21800 	},
  21801 	4: {
  21802 		Fmethod:  uint8(3),
  21803 		Fquality: uint8(50),
  21804 	},
  21805 	5: {
  21806 		Fmethod:  uint8(4),
  21807 		Fquality: uint8(50),
  21808 	},
  21809 	6: {
  21810 		Fmethod:  uint8(4),
  21811 		Fquality: uint8(75),
  21812 	},
  21813 	7: {
  21814 		Fmethod:  uint8(4),
  21815 		Fquality: uint8(90),
  21816 	},
  21817 	8: {
  21818 		Fmethod:  uint8(5),
  21819 		Fquality: uint8(90),
  21820 	},
  21821 	9: {
  21822 		Fmethod:  uint8(6),
  21823 		Fquality: uint8(100),
  21824 	},
  21825 }
  21826 
  21827 func WebPConfigLosslessPreset(tls *libc.TLS, config uintptr, level int32) (r int32) {
  21828 	if config == libc.UintptrFromInt32(0) || level < 0 || level > int32(MAX_LEVEL1) {
  21829 		return 0
  21830 	}
  21831 	(*WebPConfig)(unsafe.Pointer(config)).Flossless = int32(1)
  21832 	(*WebPConfig)(unsafe.Pointer(config)).Fmethod = libc.Int32FromUint8(kLosslessPresets[level].Fmethod)
  21833 	(*WebPConfig)(unsafe.Pointer(config)).Fquality = float32(kLosslessPresets[level].Fquality)
  21834 	return int32(1)
  21835 }
  21836 
  21837 type VP8Residual = struct {
  21838 	Ffirst      int32
  21839 	Flast       int32
  21840 	Fcoeffs     uintptr
  21841 	Fcoeff_type int32
  21842 	Fprob       uintptr
  21843 	Fstats      uintptr
  21844 	Fcosts      CostArrayPtr
  21845 }
  21846 
  21847 //------------------------------------------------------------------------------
  21848 
  21849 // Copyright 2011 Google Inc. All Rights Reserved.
  21850 //
  21851 // Use of this source code is governed by a BSD-style license
  21852 // that can be found in the COPYING file in the root of the source
  21853 // tree. An additional intellectual property rights grant can be found
  21854 // in the file PATENTS. All contributing project authors may
  21855 // be found in the AUTHORS file in the root of the source tree.
  21856 // -----------------------------------------------------------------------------
  21857 //
  21858 //   WebP encoder: internal header.
  21859 //
  21860 // Author: Skal (pascal.massimino@gmail.com)
  21861 
  21862 //------------------------------------------------------------------------------
  21863 // Level cost tables
  21864 
  21865 // C documentation
  21866 //
  21867 //	// For each given level, the following table gives the pattern of contexts to
  21868 //	// use for coding it (in [][0]) as well as the bit value to use for each
  21869 //	// context (in [][1]).
  21870 var VP8LevelCodes = [67][2]uint16_t{
  21871 	0: {
  21872 		0: uint16(0x001),
  21873 	},
  21874 	1: {
  21875 		0: uint16(0x007),
  21876 		1: uint16(0x001),
  21877 	},
  21878 	2: {
  21879 		0: uint16(0x00f),
  21880 		1: uint16(0x005),
  21881 	},
  21882 	3: {
  21883 		0: uint16(0x00f),
  21884 		1: uint16(0x00d),
  21885 	},
  21886 	4: {
  21887 		0: uint16(0x033),
  21888 		1: uint16(0x003),
  21889 	},
  21890 	5: {
  21891 		0: uint16(0x033),
  21892 		1: uint16(0x003),
  21893 	},
  21894 	6: {
  21895 		0: uint16(0x033),
  21896 		1: uint16(0x023),
  21897 	},
  21898 	7: {
  21899 		0: uint16(0x033),
  21900 		1: uint16(0x023),
  21901 	},
  21902 	8: {
  21903 		0: uint16(0x033),
  21904 		1: uint16(0x023),
  21905 	},
  21906 	9: {
  21907 		0: uint16(0x033),
  21908 		1: uint16(0x023),
  21909 	},
  21910 	10: {
  21911 		0: uint16(0x0d3),
  21912 		1: uint16(0x013),
  21913 	},
  21914 	11: {
  21915 		0: uint16(0x0d3),
  21916 		1: uint16(0x013),
  21917 	},
  21918 	12: {
  21919 		0: uint16(0x0d3),
  21920 		1: uint16(0x013),
  21921 	},
  21922 	13: {
  21923 		0: uint16(0x0d3),
  21924 		1: uint16(0x013),
  21925 	},
  21926 	14: {
  21927 		0: uint16(0x0d3),
  21928 		1: uint16(0x013),
  21929 	},
  21930 	15: {
  21931 		0: uint16(0x0d3),
  21932 		1: uint16(0x013),
  21933 	},
  21934 	16: {
  21935 		0: uint16(0x0d3),
  21936 		1: uint16(0x013),
  21937 	},
  21938 	17: {
  21939 		0: uint16(0x0d3),
  21940 		1: uint16(0x013),
  21941 	},
  21942 	18: {
  21943 		0: uint16(0x0d3),
  21944 		1: uint16(0x093),
  21945 	},
  21946 	19: {
  21947 		0: uint16(0x0d3),
  21948 		1: uint16(0x093),
  21949 	},
  21950 	20: {
  21951 		0: uint16(0x0d3),
  21952 		1: uint16(0x093),
  21953 	},
  21954 	21: {
  21955 		0: uint16(0x0d3),
  21956 		1: uint16(0x093),
  21957 	},
  21958 	22: {
  21959 		0: uint16(0x0d3),
  21960 		1: uint16(0x093),
  21961 	},
  21962 	23: {
  21963 		0: uint16(0x0d3),
  21964 		1: uint16(0x093),
  21965 	},
  21966 	24: {
  21967 		0: uint16(0x0d3),
  21968 		1: uint16(0x093),
  21969 	},
  21970 	25: {
  21971 		0: uint16(0x0d3),
  21972 		1: uint16(0x093),
  21973 	},
  21974 	26: {
  21975 		0: uint16(0x0d3),
  21976 		1: uint16(0x093),
  21977 	},
  21978 	27: {
  21979 		0: uint16(0x0d3),
  21980 		1: uint16(0x093),
  21981 	},
  21982 	28: {
  21983 		0: uint16(0x0d3),
  21984 		1: uint16(0x093),
  21985 	},
  21986 	29: {
  21987 		0: uint16(0x0d3),
  21988 		1: uint16(0x093),
  21989 	},
  21990 	30: {
  21991 		0: uint16(0x0d3),
  21992 		1: uint16(0x093),
  21993 	},
  21994 	31: {
  21995 		0: uint16(0x0d3),
  21996 		1: uint16(0x093),
  21997 	},
  21998 	32: {
  21999 		0: uint16(0x0d3),
  22000 		1: uint16(0x093),
  22001 	},
  22002 	33: {
  22003 		0: uint16(0x0d3),
  22004 		1: uint16(0x093),
  22005 	},
  22006 	34: {
  22007 		0: uint16(0x153),
  22008 		1: uint16(0x053),
  22009 	},
  22010 	35: {
  22011 		0: uint16(0x153),
  22012 		1: uint16(0x053),
  22013 	},
  22014 	36: {
  22015 		0: uint16(0x153),
  22016 		1: uint16(0x053),
  22017 	},
  22018 	37: {
  22019 		0: uint16(0x153),
  22020 		1: uint16(0x053),
  22021 	},
  22022 	38: {
  22023 		0: uint16(0x153),
  22024 		1: uint16(0x053),
  22025 	},
  22026 	39: {
  22027 		0: uint16(0x153),
  22028 		1: uint16(0x053),
  22029 	},
  22030 	40: {
  22031 		0: uint16(0x153),
  22032 		1: uint16(0x053),
  22033 	},
  22034 	41: {
  22035 		0: uint16(0x153),
  22036 		1: uint16(0x053),
  22037 	},
  22038 	42: {
  22039 		0: uint16(0x153),
  22040 		1: uint16(0x053),
  22041 	},
  22042 	43: {
  22043 		0: uint16(0x153),
  22044 		1: uint16(0x053),
  22045 	},
  22046 	44: {
  22047 		0: uint16(0x153),
  22048 		1: uint16(0x053),
  22049 	},
  22050 	45: {
  22051 		0: uint16(0x153),
  22052 		1: uint16(0x053),
  22053 	},
  22054 	46: {
  22055 		0: uint16(0x153),
  22056 		1: uint16(0x053),
  22057 	},
  22058 	47: {
  22059 		0: uint16(0x153),
  22060 		1: uint16(0x053),
  22061 	},
  22062 	48: {
  22063 		0: uint16(0x153),
  22064 		1: uint16(0x053),
  22065 	},
  22066 	49: {
  22067 		0: uint16(0x153),
  22068 		1: uint16(0x053),
  22069 	},
  22070 	50: {
  22071 		0: uint16(0x153),
  22072 		1: uint16(0x053),
  22073 	},
  22074 	51: {
  22075 		0: uint16(0x153),
  22076 		1: uint16(0x053),
  22077 	},
  22078 	52: {
  22079 		0: uint16(0x153),
  22080 		1: uint16(0x053),
  22081 	},
  22082 	53: {
  22083 		0: uint16(0x153),
  22084 		1: uint16(0x053),
  22085 	},
  22086 	54: {
  22087 		0: uint16(0x153),
  22088 		1: uint16(0x053),
  22089 	},
  22090 	55: {
  22091 		0: uint16(0x153),
  22092 		1: uint16(0x053),
  22093 	},
  22094 	56: {
  22095 		0: uint16(0x153),
  22096 		1: uint16(0x053),
  22097 	},
  22098 	57: {
  22099 		0: uint16(0x153),
  22100 		1: uint16(0x053),
  22101 	},
  22102 	58: {
  22103 		0: uint16(0x153),
  22104 		1: uint16(0x053),
  22105 	},
  22106 	59: {
  22107 		0: uint16(0x153),
  22108 		1: uint16(0x053),
  22109 	},
  22110 	60: {
  22111 		0: uint16(0x153),
  22112 		1: uint16(0x053),
  22113 	},
  22114 	61: {
  22115 		0: uint16(0x153),
  22116 		1: uint16(0x053),
  22117 	},
  22118 	62: {
  22119 		0: uint16(0x153),
  22120 		1: uint16(0x053),
  22121 	},
  22122 	63: {
  22123 		0: uint16(0x153),
  22124 		1: uint16(0x053),
  22125 	},
  22126 	64: {
  22127 		0: uint16(0x153),
  22128 		1: uint16(0x053),
  22129 	},
  22130 	65: {
  22131 		0: uint16(0x153),
  22132 		1: uint16(0x053),
  22133 	},
  22134 	66: {
  22135 		0: uint16(0x153),
  22136 		1: uint16(0x153),
  22137 	},
  22138 }
  22139 
  22140 func VariableLevelCost(tls *libc.TLS, level int32, probas uintptr) (r int32) {
  22141 	var bits, cost, i, pattern, v3, v5 int32
  22142 	var v2 uint8_t
  22143 	_, _, _, _, _, _, _ = bits, cost, i, pattern, v2, v3, v5
  22144 	pattern = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(level-int32(1))*4)))
  22145 	bits = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(level-int32(1))*4 + 1*2)))
  22146 	cost = 0
  22147 	i = int32(2)
  22148 	for {
  22149 		if !(pattern != 0) {
  22150 			break
  22151 		}
  22152 		if pattern&int32(1) != 0 {
  22153 			v2 = **(**uint8_t)(__ccgo_up(probas + uintptr(i)))
  22154 			if !(bits&int32(1) != 0) {
  22155 				v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  22156 			} else {
  22157 				v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  22158 			}
  22159 			v3 = v5
  22160 			goto _4
  22161 		_4:
  22162 			cost = cost + v3
  22163 		}
  22164 		bits = bits >> int32(1)
  22165 		pattern = pattern >> int32(1)
  22166 		goto _1
  22167 	_1:
  22168 		;
  22169 		i = i + 1
  22170 	}
  22171 	return cost
  22172 }
  22173 
  22174 //------------------------------------------------------------------------------
  22175 // Pre-calc level costs once for all
  22176 
  22177 func VP8CalculateLevelCosts(tls *libc.TLS, proba1 uintptr) {
  22178 	var band, cost0, cost_base, ctx, ctype, n, v, v10, v12, v14, v16, v4, v6, v8 int32
  22179 	var p, table uintptr
  22180 	var v13, v5, v9 uint8_t
  22181 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = band, cost0, cost_base, ctx, ctype, n, p, table, v, v10, v12, v13, v14, v16, v4, v5, v6, v8, v9
  22182 	if !((*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty != 0) {
  22183 		return
  22184 	} // nothing to do.
  22185 	ctype = 0
  22186 	for {
  22187 		if !(ctype < int32(NUM_TYPES)) {
  22188 			break
  22189 		}
  22190 		band = 0
  22191 		for {
  22192 			if !(band < int32(NUM_BANDS)) {
  22193 				break
  22194 			}
  22195 			ctx = 0
  22196 			for {
  22197 				if !(ctx < int32(NUM_CTX)) {
  22198 					break
  22199 				}
  22200 				p = proba1 + 4 + uintptr(ctype)*264 + uintptr(band)*33 + uintptr(ctx)*11
  22201 				table = proba1 + 5284 + uintptr(ctype)*3264 + uintptr(band)*408 + uintptr(ctx)*136
  22202 				if ctx > 0 {
  22203 					v5 = **(**uint8_t)(__ccgo_up(p))
  22204 					if !(int32(1) != 0) {
  22205 						v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  22206 					} else {
  22207 						v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  22208 					}
  22209 					v6 = v8
  22210 					goto _7
  22211 				_7:
  22212 					v4 = v6
  22213 				} else {
  22214 					v4 = 0
  22215 				}
  22216 				cost0 = v4
  22217 				v9 = **(**uint8_t)(__ccgo_up(p + 1))
  22218 				if !(int32(1) != 0) {
  22219 					v12 = libc.Int32FromUint16(VP8EntropyCost[v9])
  22220 				} else {
  22221 					v12 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v9)])
  22222 				}
  22223 				v10 = v12
  22224 				goto _11
  22225 			_11:
  22226 				cost_base = v10 + cost0
  22227 				v13 = **(**uint8_t)(__ccgo_up(p + 1))
  22228 				if !(0 != 0) {
  22229 					v16 = libc.Int32FromUint16(VP8EntropyCost[v13])
  22230 				} else {
  22231 					v16 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v13)])
  22232 				}
  22233 				v14 = v16
  22234 				goto _15
  22235 			_15:
  22236 				**(**uint16_t)(__ccgo_up(table)) = libc.Uint16FromInt32(v14 + cost0)
  22237 				v = int32(1)
  22238 				for {
  22239 					if !(v <= int32(MAX_VARIABLE_LEVEL)) {
  22240 						break
  22241 					}
  22242 					**(**uint16_t)(__ccgo_up(table + uintptr(v)*2)) = libc.Uint16FromInt32(cost_base + VariableLevelCost(tls, v, p))
  22243 					goto _17
  22244 				_17:
  22245 					;
  22246 					v = v + 1
  22247 				}
  22248 				// Starting at level 67 and up, the variable part of the cost is
  22249 				// actually constant.
  22250 				goto _3
  22251 			_3:
  22252 				;
  22253 				ctx = ctx + 1
  22254 			}
  22255 			goto _2
  22256 		_2:
  22257 			;
  22258 			band = band + 1
  22259 		}
  22260 		n = 0
  22261 		for {
  22262 			if !(n < int32(16)) {
  22263 				break
  22264 			} // replicate bands. We don't need to sentinel.
  22265 			ctx = 0
  22266 			for {
  22267 				if !(ctx < int32(NUM_CTX)) {
  22268 					break
  22269 				}
  22270 				**(**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
  22271 				goto _19
  22272 			_19:
  22273 				;
  22274 				ctx = ctx + 1
  22275 			}
  22276 			goto _18
  22277 		_18:
  22278 			;
  22279 			n = n + 1
  22280 		}
  22281 		goto _1
  22282 	_1:
  22283 		;
  22284 		ctype = ctype + 1
  22285 	}
  22286 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty = 0
  22287 }
  22288 
  22289 //------------------------------------------------------------------------------
  22290 // helper functions for residuals struct VP8Residual.
  22291 
  22292 func VP8InitResidual(tls *libc.TLS, first int32, coeff_type int32, enc uintptr, res uintptr) {
  22293 	(*VP8Residual)(unsafe.Pointer(res)).Fcoeff_type = coeff_type
  22294 	(*VP8Residual)(unsafe.Pointer(res)).Fprob = enc + 3616 + 4 + uintptr(coeff_type)*264
  22295 	(*VP8Residual)(unsafe.Pointer(res)).Fstats = enc + 3616 + 1060 + uintptr(coeff_type)*1056
  22296 	(*VP8Residual)(unsafe.Pointer(res)).Fcosts = enc + 3616 + 18344 + uintptr(coeff_type)*384
  22297 	(*VP8Residual)(unsafe.Pointer(res)).Ffirst = first
  22298 }
  22299 
  22300 //------------------------------------------------------------------------------
  22301 // Mode costs
  22302 
  22303 func VP8GetCostLuma4(tls *libc.TLS, it uintptr, levels uintptr) (r int32) {
  22304 	bp := tls.Alloc(48)
  22305 	defer tls.Free(48)
  22306 	var R, ctx, x, y int32
  22307 	var enc uintptr
  22308 	var _ /* res at bp+0 */ VP8Residual
  22309 	_, _, _, _, _ = R, ctx, enc, x, y
  22310 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & libc.Int32FromInt32(3)
  22311 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> libc.Int32FromInt32(2)
  22312 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22313 	R = 0
  22314 	VP8InitResidual(tls, 0, int32(3), enc, bp)
  22315 	ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  22316 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, levels, bp)
  22317 	R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22318 	return R
  22319 }
  22320 
  22321 func VP8GetCostLuma16(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  22322 	bp := tls.Alloc(48)
  22323 	defer tls.Free(48)
  22324 	var R, ctx, x, y, v3 int32
  22325 	var enc uintptr
  22326 	var _ /* res at bp+0 */ VP8Residual
  22327 	_, _, _, _, _, _ = R, ctx, enc, x, y, v3
  22328 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22329 	R = 0
  22330 	VP8IteratorNzToBytes(tls, it) // re-import the non-zero context
  22331 	// DC
  22332 	VP8InitResidual(tls, 0, int32(1), enc, bp)
  22333 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  22334 	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)
  22335 	// AC
  22336 	VP8InitResidual(tls, int32(1), 0, enc, bp)
  22337 	y = 0
  22338 	for {
  22339 		if !(y < int32(4)) {
  22340 			break
  22341 		}
  22342 		x = 0
  22343 		for {
  22344 			if !(x < int32(4)) {
  22345 				break
  22346 			}
  22347 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  22348 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  22349 			R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22350 			v3 = libc.BoolInt32((**(**VP8Residual)(__ccgo_up(bp))).Flast >= libc.Int32FromInt32(0))
  22351 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v3
  22352 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v3
  22353 			goto _2
  22354 		_2:
  22355 			;
  22356 			x = x + 1
  22357 		}
  22358 		goto _1
  22359 	_1:
  22360 		;
  22361 		y = y + 1
  22362 	}
  22363 	return R
  22364 }
  22365 
  22366 func VP8GetCostUV(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  22367 	bp := tls.Alloc(48)
  22368 	defer tls.Free(48)
  22369 	var R, ch, ctx, x, y, v4 int32
  22370 	var enc uintptr
  22371 	var _ /* res at bp+0 */ VP8Residual
  22372 	_, _, _, _, _, _, _ = R, ch, ctx, enc, x, y, v4
  22373 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  22374 	R = 0
  22375 	VP8IteratorNzToBytes(tls, it) // re-import the non-zero context
  22376 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  22377 	ch = 0
  22378 	for {
  22379 		if !(ch <= int32(2)) {
  22380 			break
  22381 		}
  22382 		y = 0
  22383 		for {
  22384 			if !(y < int32(2)) {
  22385 				break
  22386 			}
  22387 			x = 0
  22388 			for {
  22389 				if !(x < int32(2)) {
  22390 					break
  22391 				}
  22392 				ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  22393 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  22394 				R = R + (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8GetResidualCost})))(tls, ctx, bp)
  22395 				v4 = libc.BoolInt32((**(**VP8Residual)(__ccgo_up(bp))).Flast >= libc.Int32FromInt32(0))
  22396 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v4
  22397 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v4
  22398 				goto _3
  22399 			_3:
  22400 				;
  22401 				x = x + 1
  22402 			}
  22403 			goto _2
  22404 		_2:
  22405 			;
  22406 			y = y + 1
  22407 		}
  22408 		goto _1
  22409 	_1:
  22410 		;
  22411 		ch = ch + int32(2)
  22412 	}
  22413 	return R
  22414 }
  22415 
  22416 //------------------------------------------------------------------------------
  22417 // Recording of token probabilities.
  22418 
  22419 // We keep the table-free variant around for reference, in case.
  22420 
  22421 // C documentation
  22422 //
  22423 //	// Simulate block coding, but only record statistics.
  22424 //	// Note: no need to record the fixed probas.
  22425 func VP8RecordCoeffs(tls *libc.TLS, ctx int32, res uintptr) (r int32) {
  22426 	var bits, i, mask, n, pattern, v, v1, v4, v7 int32
  22427 	var p proba_t
  22428 	var s, v2 uintptr
  22429 	_, _, _, _, _, _, _, _, _, _, _, _ = bits, i, mask, n, p, pattern, s, v, v1, v2, v4, v7
  22430 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  22431 	// should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
  22432 	s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(n)*132 + uintptr(ctx)*44
  22433 	if (*VP8Residual)(unsafe.Pointer(res)).Flast < 0 {
  22434 		v1 = 0
  22435 		v2 = s + uintptr(0)*4
  22436 		p = **(**proba_t)(__ccgo_up(v2))
  22437 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22438 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22439 		}
  22440 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22441 		**(**proba_t)(__ccgo_up(v2)) = p
  22442 		_ = v1
  22443 		goto _3
  22444 	_3:
  22445 		;
  22446 		return 0
  22447 	}
  22448 	for n <= (*VP8Residual)(unsafe.Pointer(res)).Flast {
  22449 		v1 = int32(1)
  22450 		v2 = s + uintptr(0)*4
  22451 		p = **(**proba_t)(__ccgo_up(v2))
  22452 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22453 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22454 		}
  22455 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22456 		**(**proba_t)(__ccgo_up(v2)) = p
  22457 		_ = v1
  22458 		goto _6
  22459 	_6:
  22460 		; // order of record doesn't matter
  22461 		for {
  22462 			v4 = n
  22463 			n = n + 1
  22464 			v1 = int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(v4)*2)))
  22465 			v = v1
  22466 			if !(v1 == 0) {
  22467 				break
  22468 			}
  22469 			v7 = 0
  22470 			v2 = s + uintptr(1)*4
  22471 			p = **(**proba_t)(__ccgo_up(v2))
  22472 			if p >= libc.Uint32FromUint32(0xfffe0000) {
  22473 				p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22474 			}
  22475 			p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v7))
  22476 			**(**proba_t)(__ccgo_up(v2)) = p
  22477 			_ = v7
  22478 			goto _11
  22479 		_11:
  22480 			;
  22481 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132
  22482 		}
  22483 		v1 = int32(1)
  22484 		v2 = s + uintptr(1)*4
  22485 		p = **(**proba_t)(__ccgo_up(v2))
  22486 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22487 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22488 		}
  22489 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22490 		**(**proba_t)(__ccgo_up(v2)) = p
  22491 		_ = v1
  22492 		goto _14
  22493 	_14:
  22494 		;
  22495 		v1 = libc.BoolInt32(uint32(2) < libc.Uint32FromInt32(v+libc.Int32FromInt32(1)))
  22496 		v2 = s + uintptr(2)*4
  22497 		p = **(**proba_t)(__ccgo_up(v2))
  22498 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22499 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22500 		}
  22501 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22502 		**(**proba_t)(__ccgo_up(v2)) = p
  22503 		v4 = v1
  22504 		goto _18
  22505 	_18:
  22506 		if !(v4 != 0) { // v = -1 or 1
  22507 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 1*44
  22508 		} else {
  22509 			v = libc.Xabs(tls, v)
  22510 			if v > int32(MAX_VARIABLE_LEVEL) {
  22511 				v = int32(MAX_VARIABLE_LEVEL)
  22512 			}
  22513 			bits = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(v-int32(1))*4 + 1*2)))
  22514 			pattern = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8LevelCodes)) + uintptr(v-int32(1))*4)))
  22515 			i = 0
  22516 			for {
  22517 				pattern = pattern >> int32(1)
  22518 				if !(pattern != 0) {
  22519 					break
  22520 				}
  22521 				mask = int32(2) << i
  22522 				if pattern&int32(1) != 0 {
  22523 					v1 = libc.BoolInt32(!!(bits&mask != 0))
  22524 					v2 = s + uintptr(3)*4 + uintptr(i)*4
  22525 					p = **(**proba_t)(__ccgo_up(v2))
  22526 					if p >= libc.Uint32FromUint32(0xfffe0000) {
  22527 						p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22528 					}
  22529 					p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22530 					**(**proba_t)(__ccgo_up(v2)) = p
  22531 					_ = v1
  22532 					goto _22
  22533 				_22:
  22534 				}
  22535 				goto _19
  22536 			_19:
  22537 				;
  22538 				i = i + 1
  22539 			}
  22540 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 2*44
  22541 		}
  22542 	}
  22543 	if n < int32(16) {
  22544 		v1 = 0
  22545 		v2 = s + uintptr(0)*4
  22546 		p = **(**proba_t)(__ccgo_up(v2))
  22547 		if p >= libc.Uint32FromUint32(0xfffe0000) {
  22548 			p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  22549 		}
  22550 		p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  22551 		**(**proba_t)(__ccgo_up(v2)) = p
  22552 		_ = v1
  22553 		goto _25
  22554 	_25:
  22555 	}
  22556 	return int32(1)
  22557 }
  22558 
  22559 const MAX_DELTA_SIZE = 64
  22560 
  22561 //------------------------------------------------------------------------------
  22562 
  22563 // C documentation
  22564 //
  22565 //	// This table gives, for a given sharpness, the filtering strength to be
  22566 //	// used (at least) in order to filter a given edge step delta.
  22567 //	// This is constructed by brute force inspection: for all delta, we iterate
  22568 //	// over all possible filtering strength / thresh until needs_filter() returns
  22569 //	// true.
  22570 var kLevelsFromDelta = [8][64]uint8_t{
  22571 	0: {
  22572 		1:  uint8(1),
  22573 		2:  uint8(2),
  22574 		3:  uint8(3),
  22575 		4:  uint8(4),
  22576 		5:  uint8(5),
  22577 		6:  uint8(6),
  22578 		7:  uint8(7),
  22579 		8:  uint8(8),
  22580 		9:  uint8(9),
  22581 		10: uint8(10),
  22582 		11: uint8(11),
  22583 		12: uint8(12),
  22584 		13: uint8(13),
  22585 		14: uint8(14),
  22586 		15: uint8(15),
  22587 		16: uint8(16),
  22588 		17: uint8(17),
  22589 		18: uint8(18),
  22590 		19: uint8(19),
  22591 		20: uint8(20),
  22592 		21: uint8(21),
  22593 		22: uint8(22),
  22594 		23: uint8(23),
  22595 		24: uint8(24),
  22596 		25: uint8(25),
  22597 		26: uint8(26),
  22598 		27: uint8(27),
  22599 		28: uint8(28),
  22600 		29: uint8(29),
  22601 		30: uint8(30),
  22602 		31: uint8(31),
  22603 		32: uint8(32),
  22604 		33: uint8(33),
  22605 		34: uint8(34),
  22606 		35: uint8(35),
  22607 		36: uint8(36),
  22608 		37: uint8(37),
  22609 		38: uint8(38),
  22610 		39: uint8(39),
  22611 		40: uint8(40),
  22612 		41: uint8(41),
  22613 		42: uint8(42),
  22614 		43: uint8(43),
  22615 		44: uint8(44),
  22616 		45: uint8(45),
  22617 		46: uint8(46),
  22618 		47: uint8(47),
  22619 		48: uint8(48),
  22620 		49: uint8(49),
  22621 		50: uint8(50),
  22622 		51: uint8(51),
  22623 		52: uint8(52),
  22624 		53: uint8(53),
  22625 		54: uint8(54),
  22626 		55: uint8(55),
  22627 		56: uint8(56),
  22628 		57: uint8(57),
  22629 		58: uint8(58),
  22630 		59: uint8(59),
  22631 		60: uint8(60),
  22632 		61: uint8(61),
  22633 		62: uint8(62),
  22634 		63: uint8(63),
  22635 	},
  22636 	1: {
  22637 		1:  uint8(1),
  22638 		2:  uint8(2),
  22639 		3:  uint8(3),
  22640 		4:  uint8(5),
  22641 		5:  uint8(6),
  22642 		6:  uint8(7),
  22643 		7:  uint8(8),
  22644 		8:  uint8(9),
  22645 		9:  uint8(11),
  22646 		10: uint8(12),
  22647 		11: uint8(13),
  22648 		12: uint8(14),
  22649 		13: uint8(15),
  22650 		14: uint8(17),
  22651 		15: uint8(18),
  22652 		16: uint8(20),
  22653 		17: uint8(21),
  22654 		18: uint8(23),
  22655 		19: uint8(24),
  22656 		20: uint8(26),
  22657 		21: uint8(27),
  22658 		22: uint8(29),
  22659 		23: uint8(30),
  22660 		24: uint8(32),
  22661 		25: uint8(33),
  22662 		26: uint8(35),
  22663 		27: uint8(36),
  22664 		28: uint8(38),
  22665 		29: uint8(39),
  22666 		30: uint8(41),
  22667 		31: uint8(42),
  22668 		32: uint8(44),
  22669 		33: uint8(45),
  22670 		34: uint8(47),
  22671 		35: uint8(48),
  22672 		36: uint8(50),
  22673 		37: uint8(51),
  22674 		38: uint8(53),
  22675 		39: uint8(54),
  22676 		40: uint8(56),
  22677 		41: uint8(57),
  22678 		42: uint8(59),
  22679 		43: uint8(60),
  22680 		44: uint8(62),
  22681 		45: uint8(63),
  22682 		46: uint8(63),
  22683 		47: uint8(63),
  22684 		48: uint8(63),
  22685 		49: uint8(63),
  22686 		50: uint8(63),
  22687 		51: uint8(63),
  22688 		52: uint8(63),
  22689 		53: uint8(63),
  22690 		54: uint8(63),
  22691 		55: uint8(63),
  22692 		56: uint8(63),
  22693 		57: uint8(63),
  22694 		58: uint8(63),
  22695 		59: uint8(63),
  22696 		60: uint8(63),
  22697 		61: uint8(63),
  22698 		62: uint8(63),
  22699 		63: uint8(63),
  22700 	},
  22701 	2: {
  22702 		1:  uint8(1),
  22703 		2:  uint8(2),
  22704 		3:  uint8(3),
  22705 		4:  uint8(5),
  22706 		5:  uint8(6),
  22707 		6:  uint8(7),
  22708 		7:  uint8(8),
  22709 		8:  uint8(9),
  22710 		9:  uint8(11),
  22711 		10: uint8(12),
  22712 		11: uint8(13),
  22713 		12: uint8(14),
  22714 		13: uint8(16),
  22715 		14: uint8(17),
  22716 		15: uint8(19),
  22717 		16: uint8(20),
  22718 		17: uint8(22),
  22719 		18: uint8(23),
  22720 		19: uint8(25),
  22721 		20: uint8(26),
  22722 		21: uint8(28),
  22723 		22: uint8(29),
  22724 		23: uint8(31),
  22725 		24: uint8(32),
  22726 		25: uint8(34),
  22727 		26: uint8(35),
  22728 		27: uint8(37),
  22729 		28: uint8(38),
  22730 		29: uint8(40),
  22731 		30: uint8(41),
  22732 		31: uint8(43),
  22733 		32: uint8(44),
  22734 		33: uint8(46),
  22735 		34: uint8(47),
  22736 		35: uint8(49),
  22737 		36: uint8(50),
  22738 		37: uint8(52),
  22739 		38: uint8(53),
  22740 		39: uint8(55),
  22741 		40: uint8(56),
  22742 		41: uint8(58),
  22743 		42: uint8(59),
  22744 		43: uint8(61),
  22745 		44: uint8(62),
  22746 		45: uint8(63),
  22747 		46: uint8(63),
  22748 		47: uint8(63),
  22749 		48: uint8(63),
  22750 		49: uint8(63),
  22751 		50: uint8(63),
  22752 		51: uint8(63),
  22753 		52: uint8(63),
  22754 		53: uint8(63),
  22755 		54: uint8(63),
  22756 		55: uint8(63),
  22757 		56: uint8(63),
  22758 		57: uint8(63),
  22759 		58: uint8(63),
  22760 		59: uint8(63),
  22761 		60: uint8(63),
  22762 		61: uint8(63),
  22763 		62: uint8(63),
  22764 		63: uint8(63),
  22765 	},
  22766 	3: {
  22767 		1:  uint8(1),
  22768 		2:  uint8(2),
  22769 		3:  uint8(3),
  22770 		4:  uint8(5),
  22771 		5:  uint8(6),
  22772 		6:  uint8(7),
  22773 		7:  uint8(8),
  22774 		8:  uint8(9),
  22775 		9:  uint8(11),
  22776 		10: uint8(12),
  22777 		11: uint8(13),
  22778 		12: uint8(15),
  22779 		13: uint8(16),
  22780 		14: uint8(18),
  22781 		15: uint8(19),
  22782 		16: uint8(21),
  22783 		17: uint8(22),
  22784 		18: uint8(24),
  22785 		19: uint8(25),
  22786 		20: uint8(27),
  22787 		21: uint8(28),
  22788 		22: uint8(30),
  22789 		23: uint8(31),
  22790 		24: uint8(33),
  22791 		25: uint8(34),
  22792 		26: uint8(36),
  22793 		27: uint8(37),
  22794 		28: uint8(39),
  22795 		29: uint8(40),
  22796 		30: uint8(42),
  22797 		31: uint8(43),
  22798 		32: uint8(45),
  22799 		33: uint8(46),
  22800 		34: uint8(48),
  22801 		35: uint8(49),
  22802 		36: uint8(51),
  22803 		37: uint8(52),
  22804 		38: uint8(54),
  22805 		39: uint8(55),
  22806 		40: uint8(57),
  22807 		41: uint8(58),
  22808 		42: uint8(60),
  22809 		43: uint8(61),
  22810 		44: uint8(63),
  22811 		45: uint8(63),
  22812 		46: uint8(63),
  22813 		47: uint8(63),
  22814 		48: uint8(63),
  22815 		49: uint8(63),
  22816 		50: uint8(63),
  22817 		51: uint8(63),
  22818 		52: uint8(63),
  22819 		53: uint8(63),
  22820 		54: uint8(63),
  22821 		55: uint8(63),
  22822 		56: uint8(63),
  22823 		57: uint8(63),
  22824 		58: uint8(63),
  22825 		59: uint8(63),
  22826 		60: uint8(63),
  22827 		61: uint8(63),
  22828 		62: uint8(63),
  22829 		63: uint8(63),
  22830 	},
  22831 	4: {
  22832 		1:  uint8(1),
  22833 		2:  uint8(2),
  22834 		3:  uint8(3),
  22835 		4:  uint8(5),
  22836 		5:  uint8(6),
  22837 		6:  uint8(7),
  22838 		7:  uint8(8),
  22839 		8:  uint8(9),
  22840 		9:  uint8(11),
  22841 		10: uint8(12),
  22842 		11: uint8(14),
  22843 		12: uint8(15),
  22844 		13: uint8(17),
  22845 		14: uint8(18),
  22846 		15: uint8(20),
  22847 		16: uint8(21),
  22848 		17: uint8(23),
  22849 		18: uint8(24),
  22850 		19: uint8(26),
  22851 		20: uint8(27),
  22852 		21: uint8(29),
  22853 		22: uint8(30),
  22854 		23: uint8(32),
  22855 		24: uint8(33),
  22856 		25: uint8(35),
  22857 		26: uint8(36),
  22858 		27: uint8(38),
  22859 		28: uint8(39),
  22860 		29: uint8(41),
  22861 		30: uint8(42),
  22862 		31: uint8(44),
  22863 		32: uint8(45),
  22864 		33: uint8(47),
  22865 		34: uint8(48),
  22866 		35: uint8(50),
  22867 		36: uint8(51),
  22868 		37: uint8(53),
  22869 		38: uint8(54),
  22870 		39: uint8(56),
  22871 		40: uint8(57),
  22872 		41: uint8(59),
  22873 		42: uint8(60),
  22874 		43: uint8(62),
  22875 		44: uint8(63),
  22876 		45: uint8(63),
  22877 		46: uint8(63),
  22878 		47: uint8(63),
  22879 		48: uint8(63),
  22880 		49: uint8(63),
  22881 		50: uint8(63),
  22882 		51: uint8(63),
  22883 		52: uint8(63),
  22884 		53: uint8(63),
  22885 		54: uint8(63),
  22886 		55: uint8(63),
  22887 		56: uint8(63),
  22888 		57: uint8(63),
  22889 		58: uint8(63),
  22890 		59: uint8(63),
  22891 		60: uint8(63),
  22892 		61: uint8(63),
  22893 		62: uint8(63),
  22894 		63: uint8(63),
  22895 	},
  22896 	5: {
  22897 		1:  uint8(1),
  22898 		2:  uint8(2),
  22899 		3:  uint8(4),
  22900 		4:  uint8(5),
  22901 		5:  uint8(7),
  22902 		6:  uint8(8),
  22903 		7:  uint8(9),
  22904 		8:  uint8(11),
  22905 		9:  uint8(12),
  22906 		10: uint8(13),
  22907 		11: uint8(15),
  22908 		12: uint8(16),
  22909 		13: uint8(17),
  22910 		14: uint8(19),
  22911 		15: uint8(20),
  22912 		16: uint8(22),
  22913 		17: uint8(23),
  22914 		18: uint8(25),
  22915 		19: uint8(26),
  22916 		20: uint8(28),
  22917 		21: uint8(29),
  22918 		22: uint8(31),
  22919 		23: uint8(32),
  22920 		24: uint8(34),
  22921 		25: uint8(35),
  22922 		26: uint8(37),
  22923 		27: uint8(38),
  22924 		28: uint8(40),
  22925 		29: uint8(41),
  22926 		30: uint8(43),
  22927 		31: uint8(44),
  22928 		32: uint8(46),
  22929 		33: uint8(47),
  22930 		34: uint8(49),
  22931 		35: uint8(50),
  22932 		36: uint8(52),
  22933 		37: uint8(53),
  22934 		38: uint8(55),
  22935 		39: uint8(56),
  22936 		40: uint8(58),
  22937 		41: uint8(59),
  22938 		42: uint8(61),
  22939 		43: uint8(62),
  22940 		44: uint8(63),
  22941 		45: uint8(63),
  22942 		46: uint8(63),
  22943 		47: uint8(63),
  22944 		48: uint8(63),
  22945 		49: uint8(63),
  22946 		50: uint8(63),
  22947 		51: uint8(63),
  22948 		52: uint8(63),
  22949 		53: uint8(63),
  22950 		54: uint8(63),
  22951 		55: uint8(63),
  22952 		56: uint8(63),
  22953 		57: uint8(63),
  22954 		58: uint8(63),
  22955 		59: uint8(63),
  22956 		60: uint8(63),
  22957 		61: uint8(63),
  22958 		62: uint8(63),
  22959 		63: uint8(63),
  22960 	},
  22961 	6: {
  22962 		1:  uint8(1),
  22963 		2:  uint8(2),
  22964 		3:  uint8(4),
  22965 		4:  uint8(5),
  22966 		5:  uint8(7),
  22967 		6:  uint8(8),
  22968 		7:  uint8(9),
  22969 		8:  uint8(11),
  22970 		9:  uint8(12),
  22971 		10: uint8(13),
  22972 		11: uint8(15),
  22973 		12: uint8(16),
  22974 		13: uint8(18),
  22975 		14: uint8(19),
  22976 		15: uint8(21),
  22977 		16: uint8(22),
  22978 		17: uint8(24),
  22979 		18: uint8(25),
  22980 		19: uint8(27),
  22981 		20: uint8(28),
  22982 		21: uint8(30),
  22983 		22: uint8(31),
  22984 		23: uint8(33),
  22985 		24: uint8(34),
  22986 		25: uint8(36),
  22987 		26: uint8(37),
  22988 		27: uint8(39),
  22989 		28: uint8(40),
  22990 		29: uint8(42),
  22991 		30: uint8(43),
  22992 		31: uint8(45),
  22993 		32: uint8(46),
  22994 		33: uint8(48),
  22995 		34: uint8(49),
  22996 		35: uint8(51),
  22997 		36: uint8(52),
  22998 		37: uint8(54),
  22999 		38: uint8(55),
  23000 		39: uint8(57),
  23001 		40: uint8(58),
  23002 		41: uint8(60),
  23003 		42: uint8(61),
  23004 		43: uint8(63),
  23005 		44: uint8(63),
  23006 		45: uint8(63),
  23007 		46: uint8(63),
  23008 		47: uint8(63),
  23009 		48: uint8(63),
  23010 		49: uint8(63),
  23011 		50: uint8(63),
  23012 		51: uint8(63),
  23013 		52: uint8(63),
  23014 		53: uint8(63),
  23015 		54: uint8(63),
  23016 		55: uint8(63),
  23017 		56: uint8(63),
  23018 		57: uint8(63),
  23019 		58: uint8(63),
  23020 		59: uint8(63),
  23021 		60: uint8(63),
  23022 		61: uint8(63),
  23023 		62: uint8(63),
  23024 		63: uint8(63),
  23025 	},
  23026 	7: {
  23027 		1:  uint8(1),
  23028 		2:  uint8(2),
  23029 		3:  uint8(4),
  23030 		4:  uint8(5),
  23031 		5:  uint8(7),
  23032 		6:  uint8(8),
  23033 		7:  uint8(9),
  23034 		8:  uint8(11),
  23035 		9:  uint8(12),
  23036 		10: uint8(14),
  23037 		11: uint8(15),
  23038 		12: uint8(17),
  23039 		13: uint8(18),
  23040 		14: uint8(20),
  23041 		15: uint8(21),
  23042 		16: uint8(23),
  23043 		17: uint8(24),
  23044 		18: uint8(26),
  23045 		19: uint8(27),
  23046 		20: uint8(29),
  23047 		21: uint8(30),
  23048 		22: uint8(32),
  23049 		23: uint8(33),
  23050 		24: uint8(35),
  23051 		25: uint8(36),
  23052 		26: uint8(38),
  23053 		27: uint8(39),
  23054 		28: uint8(41),
  23055 		29: uint8(42),
  23056 		30: uint8(44),
  23057 		31: uint8(45),
  23058 		32: uint8(47),
  23059 		33: uint8(48),
  23060 		34: uint8(50),
  23061 		35: uint8(51),
  23062 		36: uint8(53),
  23063 		37: uint8(54),
  23064 		38: uint8(56),
  23065 		39: uint8(57),
  23066 		40: uint8(59),
  23067 		41: uint8(60),
  23068 		42: uint8(62),
  23069 		43: uint8(63),
  23070 		44: uint8(63),
  23071 		45: uint8(63),
  23072 		46: uint8(63),
  23073 		47: uint8(63),
  23074 		48: uint8(63),
  23075 		49: uint8(63),
  23076 		50: uint8(63),
  23077 		51: uint8(63),
  23078 		52: uint8(63),
  23079 		53: uint8(63),
  23080 		54: uint8(63),
  23081 		55: uint8(63),
  23082 		56: uint8(63),
  23083 		57: uint8(63),
  23084 		58: uint8(63),
  23085 		59: uint8(63),
  23086 		60: uint8(63),
  23087 		61: uint8(63),
  23088 		62: uint8(63),
  23089 		63: uint8(63),
  23090 	},
  23091 }
  23092 
  23093 func VP8FilterStrengthFromDelta(tls *libc.TLS, sharpness int32, delta int32) (r int32) {
  23094 	var pos, v1 int32
  23095 	_, _ = pos, v1
  23096 	if delta < int32(MAX_DELTA_SIZE) {
  23097 		v1 = delta
  23098 	} else {
  23099 		v1 = libc.Int32FromInt32(MAX_DELTA_SIZE) - libc.Int32FromInt32(1)
  23100 	}
  23101 	pos = v1
  23102 	return libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kLevelsFromDelta)) + uintptr(sharpness)*64 + uintptr(pos))))
  23103 }
  23104 
  23105 //------------------------------------------------------------------------------
  23106 // Paragraph 15.4: compute the inner-edge filtering strength
  23107 
  23108 func GetILevel(tls *libc.TLS, sharpness int32, level int32) (r int32) {
  23109 	if sharpness > 0 {
  23110 		if sharpness > int32(4) {
  23111 			level = level >> int32(2)
  23112 		} else {
  23113 			level = level >> int32(1)
  23114 		}
  23115 		if level > int32(9)-sharpness {
  23116 			level = int32(9) - sharpness
  23117 		}
  23118 	}
  23119 	if level < int32(1) {
  23120 		level = int32(1)
  23121 	}
  23122 	return level
  23123 }
  23124 
  23125 func DoFilter1(tls *libc.TLS, it uintptr, level int32) {
  23126 	var enc, u_dst, v_dst, y_dst uintptr
  23127 	var hev_thresh, ilevel, limit, v1, v2 int32
  23128 	_, _, _, _, _, _, _, _, _ = enc, hev_thresh, ilevel, limit, u_dst, v_dst, y_dst, v1, v2
  23129 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23130 	ilevel = GetILevel(tls, (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_sharpness, level)
  23131 	limit = int32(2)*level + ilevel
  23132 	y_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  23133 	u_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  23134 	v_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8))
  23135 	// copy current block to yuv_out2
  23136 	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))
  23137 	if (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsimple == int32(1) { // simple
  23138 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleHFilter16i})))(tls, y_dst, int32(BPS), limit)
  23139 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8SimpleVFilter16i})))(tls, y_dst, int32(BPS), limit)
  23140 	} else {
  23141 		if level >= int32(40) {
  23142 			v1 = int32(2)
  23143 		} else {
  23144 			if level >= int32(15) {
  23145 				v2 = int32(1)
  23146 			} else {
  23147 				v2 = 0
  23148 			}
  23149 			v1 = v2
  23150 		} // complex
  23151 		hev_thresh = v1
  23152 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8HFilter16i})))(tls, y_dst, int32(BPS), limit, ilevel, hev_thresh)
  23153 		(*(*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)
  23154 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8VFilter16i})))(tls, y_dst, int32(BPS), limit, ilevel, hev_thresh)
  23155 		(*(*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)
  23156 	}
  23157 }
  23158 
  23159 //------------------------------------------------------------------------------
  23160 // SSIM metric for one macroblock
  23161 
  23162 func GetMBSSIM(tls *libc.TLS, yuv1 uintptr, yuv2 uintptr) (r float64) {
  23163 	var sum float64
  23164 	var x, y int32
  23165 	_, _, _ = sum, x, y
  23166 	sum = float64(0)
  23167 	// compute SSIM in a 10 x 10 window
  23168 	y = int32(VP8_SSIM_KERNEL)
  23169 	for {
  23170 		if !(y < libc.Int32FromInt32(16)-libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  23171 			break
  23172 		}
  23173 		x = int32(VP8_SSIM_KERNEL)
  23174 		for {
  23175 			if !(x < libc.Int32FromInt32(16)-libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  23176 				break
  23177 			}
  23178 			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))
  23179 			goto _2
  23180 		_2:
  23181 			;
  23182 			x = x + 1
  23183 		}
  23184 		goto _1
  23185 	_1:
  23186 		;
  23187 		y = y + 1
  23188 	}
  23189 	x = int32(1)
  23190 	for {
  23191 		if !(x < int32(7)) {
  23192 			break
  23193 		}
  23194 		y = int32(1)
  23195 		for {
  23196 			if !(y < int32(7)) {
  23197 				break
  23198 			}
  23199 			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))
  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(16)+libc.Int32FromInt32(8)), int32(BPS), yuv2+uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8)), int32(BPS), x, y, int32(8), int32(8))
  23201 			goto _4
  23202 		_4:
  23203 			;
  23204 			y = y + 1
  23205 		}
  23206 		goto _3
  23207 	_3:
  23208 		;
  23209 		x = x + 1
  23210 	}
  23211 	return sum
  23212 }
  23213 
  23214 //------------------------------------------------------------------------------
  23215 // Exposed APIs: Encoder should call the following 3 functions to adjust
  23216 // loop filter strength
  23217 
  23218 func VP8InitFilter(tls *libc.TLS, it uintptr) {
  23219 	var i, s int32
  23220 	_, _ = i, s
  23221 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats != libc.UintptrFromInt32(0) {
  23222 		s = 0
  23223 		for {
  23224 			if !(s < int32(NUM_MB_SEGMENTS)) {
  23225 				break
  23226 			}
  23227 			i = 0
  23228 			for {
  23229 				if !(i < int32(MAX_LF_LEVELS)) {
  23230 					break
  23231 				}
  23232 				**(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512 + uintptr(i)*8)) = libc.Float64FromInt32(0)
  23233 				goto _2
  23234 			_2:
  23235 				;
  23236 				i = i + 1
  23237 			}
  23238 			goto _1
  23239 		_1:
  23240 			;
  23241 			s = s + 1
  23242 		}
  23243 		VP8SSIMDspInit(tls)
  23244 	}
  23245 }
  23246 
  23247 func VP8StoreFilterStats(tls *libc.TLS, it uintptr) {
  23248 	var d, delta_max, delta_min, level, level0, s, step_size, v1 int32
  23249 	var enc uintptr
  23250 	_, _, _, _, _, _, _, _, _ = d, delta_max, delta_min, enc, level, level0, s, step_size, v1
  23251 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23252 	s = int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0)) & 0x60 >> 5))
  23253 	level0 = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength
  23254 	// explore +/-quant range of values around level0
  23255 	delta_min = -(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant
  23256 	delta_max = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant
  23257 	if delta_max-delta_min >= int32(4) {
  23258 		v1 = int32(4)
  23259 	} else {
  23260 		v1 = int32(1)
  23261 	}
  23262 	step_size = v1
  23263 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats == libc.UintptrFromInt32(0) {
  23264 		return
  23265 	}
  23266 	// NOTE: Currently we are applying filter only across the sublock edges
  23267 	// There are two reasons for that.
  23268 	// 1. Applying filter on macro block edges will change the pixels in
  23269 	// the left and top macro blocks. That will be hard to restore
  23270 	// 2. Macro Blocks on the bottom and right are not yet compressed. So we
  23271 	// cannot apply filter on the right and bottom macro block edges.
  23272 	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 {
  23273 		return
  23274 	}
  23275 	// Always try filter level  zero
  23276 	**(**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)
  23277 	d = delta_min
  23278 	for {
  23279 		if !(d <= delta_max) {
  23280 			break
  23281 		}
  23282 		level = level0 + d
  23283 		if level <= 0 || level >= int32(MAX_LF_LEVELS) {
  23284 			goto _2
  23285 		}
  23286 		DoFilter1(tls, it, level)
  23287 		**(**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)
  23288 		goto _2
  23289 	_2:
  23290 		;
  23291 		d = d + step_size
  23292 	}
  23293 }
  23294 
  23295 func VP8AdjustFilterStrength(tls *libc.TLS, it uintptr) {
  23296 	var best_level, delta, i, level, max_level, s, s1 int32
  23297 	var best_v, v float64
  23298 	var dqm, enc uintptr
  23299 	_, _, _, _, _, _, _, _, _, _, _ = best_level, best_v, delta, dqm, enc, i, level, max_level, s, s1, v
  23300 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23301 	if (*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats != libc.UintptrFromInt32(0) {
  23302 		s = 0
  23303 		for {
  23304 			if !(s < int32(NUM_MB_SEGMENTS)) {
  23305 				break
  23306 			}
  23307 			best_level = 0
  23308 			// Improvement over filter level 0 should be at least 1e-5 (relatively)
  23309 			best_v = float64(float64(1.00001) * **(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512)))
  23310 			i = int32(1)
  23311 			for {
  23312 				if !(i < int32(MAX_LF_LEVELS)) {
  23313 					break
  23314 				}
  23315 				v = **(**float64)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats + uintptr(s)*512 + uintptr(i)*8))
  23316 				if v > best_v {
  23317 					best_v = v
  23318 					best_level = i
  23319 				}
  23320 				goto _2
  23321 			_2:
  23322 				;
  23323 				i = i + 1
  23324 			}
  23325 			(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength = best_level
  23326 			goto _1
  23327 		_1:
  23328 			;
  23329 			s = s + 1
  23330 		}
  23331 		return
  23332 	}
  23333 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_strength > 0 {
  23334 		max_level = 0
  23335 		s1 = 0
  23336 		for {
  23337 			if !(s1 < int32(NUM_MB_SEGMENTS)) {
  23338 				break
  23339 			}
  23340 			dqm = enc + 608 + uintptr(s1)*744
  23341 			// this '>> 3' accounts for some inverse WHT scaling
  23342 			delta = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(dqm + 224 + 1*2))) >> int32(3)
  23343 			level = VP8FilterStrengthFromDelta(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness, delta)
  23344 			if level > (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength {
  23345 				(*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength = level
  23346 			}
  23347 			if max_level < (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength {
  23348 				max_level = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ffstrength
  23349 			}
  23350 			goto _3
  23351 		_3:
  23352 			;
  23353 			s1 = s1 + 1
  23354 		}
  23355 		(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Flevel = max_level
  23356 	}
  23357 }
  23358 
  23359 const DEBUG_SEARCH = 0
  23360 const DOMAIN = 1
  23361 const DQ_LIMIT = 0.4
  23362 const FP_INFINITE = 2
  23363 const FP_NAN = 1
  23364 const FP_NORMAL = 4
  23365 const FP_QNAN = "FP_NAN"
  23366 const FP_SNAN = "FP_NAN"
  23367 const FP_SUBNORMAL = 5
  23368 const FP_SUPERNORMAL = 6
  23369 const FP_ZERO = 3
  23370 const HUGE = "MAXFLOAT"
  23371 const INFINITY = "HUGE_VALF"
  23372 const MATH_ERREXCEPT = 2
  23373 const MATH_ERRNO = 1
  23374 const MAXFLOAT = "0x1.fffffep+127f"
  23375 const MIN_COUNT = 96
  23376 const M_1_PI = 0.318309886183790671537767526745028724
  23377 const M_2_PI = 0.636619772367581343075535053490057448
  23378 const M_2_SQRTPI = 1.12837916709551257389615890312154517
  23379 const M_E = 2.71828182845904523536028747135266250
  23380 const M_LN10 = 2.30258509299404568401799145468436421
  23381 const M_LN2 = 0.693147180559945309417232121458176568
  23382 const M_LOG10E = 0.434294481903251827651128918916605082
  23383 const M_LOG2E = 1.44269504088896340735992468100189214
  23384 const M_PI = 3.14159265358979323846264338327950288
  23385 const M_PI_2 = 1.57079632679489661923132169163975144
  23386 const M_PI_4 = 0.785398163397448309615660845819875721
  23387 const M_SQRT1_2 = 0.707106781186547524400844362104849039
  23388 const M_SQRT2 = 1.41421356237309504880168872420969808
  23389 const OVERFLOW = 3
  23390 const PLOSS = 6
  23391 const SEGMENT_VISU = 0
  23392 const SING = 2
  23393 const SKIP_PROBA_THRESHOLD = 250
  23394 const TLOSS = 5
  23395 const UNDERFLOW = 4
  23396 const X_TLOSS = 1.41484755040568800000e+16
  23397 const __FLT_MIN__1 = 1.1754943508222875e-38
  23398 
  23399 type float_t = float32
  23400 
  23401 type double_t = float64
  23402 
  23403 type __float2 = struct {
  23404 	F__sinval float32
  23405 	F__cosval float32
  23406 }
  23407 
  23408 type __double2 = struct {
  23409 	F__sinval float64
  23410 	F__cosval float64
  23411 }
  23412 
  23413 type exception = struct {
  23414 	Ftype1  int32
  23415 	Fname   uintptr
  23416 	Farg1   float64
  23417 	Farg2   float64
  23418 	Fretval float64
  23419 }
  23420 
  23421 // Alpha related constants.
  23422 
  23423 // Mux related constants.
  23424 
  23425 // Maximum chunk payload is such that adding the header and padding won't
  23426 // overflow a uint32_t.
  23427 
  23428 //------------------------------------------------------------------------------
  23429 // multi-pass convergence
  23430 
  23431 // we allow 2k of extra head-room in PARTITION0 limit.
  23432 
  23433 func Clamp(tls *libc.TLS, v float32, min float32, max float32) (r float32) {
  23434 	var v1, v2 float32
  23435 	_, _ = v1, v2
  23436 	if v < min {
  23437 		v1 = min
  23438 	} else {
  23439 		if v > max {
  23440 			v2 = max
  23441 		} else {
  23442 			v2 = v
  23443 		}
  23444 		v1 = v2
  23445 	}
  23446 	return v1
  23447 }
  23448 
  23449 type PassStats = struct {
  23450 	Fis_first       int32
  23451 	Fdq             float32
  23452 	Fq              float32
  23453 	Flast_q         float32
  23454 	Fqmin           float32
  23455 	Fqmax           float32
  23456 	Fvalue          float64
  23457 	Flast_value     float64
  23458 	Ftarget         float64
  23459 	Fdo_size_search int32
  23460 }
  23461 
  23462 func InitPassStats(tls *libc.TLS, enc uintptr, s uintptr) (r int32) {
  23463 	var do_size_search int32
  23464 	var target_PSNR, v1 float32
  23465 	var target_size uint64_t
  23466 	var v2, v3 float64
  23467 	_, _, _, _, _, _ = do_size_search, target_PSNR, target_size, v1, v2, v3
  23468 	target_size = libc.Uint64FromInt32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ftarget_size)
  23469 	do_size_search = libc.BoolInt32(target_size != libc.Uint64FromInt32(0))
  23470 	target_PSNR = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ftarget_PSNR
  23471 	(*PassStats)(unsafe.Pointer(s)).Fis_first = int32(1)
  23472 	(*PassStats)(unsafe.Pointer(s)).Fdq = libc.Float32FromFloat32(10)
  23473 	(*PassStats)(unsafe.Pointer(s)).Fqmin = float32(libc.Float32FromFloat32(1) * float32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fqmin))
  23474 	(*PassStats)(unsafe.Pointer(s)).Fqmax = float32(libc.Float32FromFloat32(1) * float32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fqmax))
  23475 	v1 = Clamp(tls, (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fquality, (*PassStats)(unsafe.Pointer(s)).Fqmin, (*PassStats)(unsafe.Pointer(s)).Fqmax)
  23476 	(*PassStats)(unsafe.Pointer(s)).Flast_q = v1
  23477 	(*PassStats)(unsafe.Pointer(s)).Fq = v1
  23478 	if do_size_search != 0 {
  23479 		v2 = float64(target_size)
  23480 	} else {
  23481 		if float64(target_PSNR) > float64(0) {
  23482 			v3 = float64(target_PSNR)
  23483 		} else {
  23484 			v3 = float64(40)
  23485 		}
  23486 		v2 = v3
  23487 	}
  23488 	(*PassStats)(unsafe.Pointer(s)).Ftarget = v2 // default, just in case
  23489 	v2 = libc.Float64FromFloat64(0)
  23490 	(*PassStats)(unsafe.Pointer(s)).Flast_value = v2
  23491 	(*PassStats)(unsafe.Pointer(s)).Fvalue = v2
  23492 	(*PassStats)(unsafe.Pointer(s)).Fdo_size_search = do_size_search
  23493 	return do_size_search
  23494 }
  23495 
  23496 func ComputeNextQ(tls *libc.TLS, s uintptr) (r float32) {
  23497 	var dq, v1 float32
  23498 	var slope float64
  23499 	_, _, _ = dq, slope, v1
  23500 	if (*PassStats)(unsafe.Pointer(s)).Fis_first != 0 {
  23501 		if (*PassStats)(unsafe.Pointer(s)).Fvalue > (*PassStats)(unsafe.Pointer(s)).Ftarget {
  23502 			v1 = -(*PassStats)(unsafe.Pointer(s)).Fdq
  23503 		} else {
  23504 			v1 = (*PassStats)(unsafe.Pointer(s)).Fdq
  23505 		}
  23506 		dq = v1
  23507 		(*PassStats)(unsafe.Pointer(s)).Fis_first = 0
  23508 	} else {
  23509 		if (*PassStats)(unsafe.Pointer(s)).Fvalue != (*PassStats)(unsafe.Pointer(s)).Flast_value {
  23510 			slope = ((*PassStats)(unsafe.Pointer(s)).Ftarget - (*PassStats)(unsafe.Pointer(s)).Fvalue) / ((*PassStats)(unsafe.Pointer(s)).Flast_value - (*PassStats)(unsafe.Pointer(s)).Fvalue)
  23511 			dq = float32(float64(slope * float64((*PassStats)(unsafe.Pointer(s)).Flast_q-(*PassStats)(unsafe.Pointer(s)).Fq)))
  23512 		} else {
  23513 			dq = float32(0) // we're done?!
  23514 		}
  23515 	}
  23516 	// Limit variable to avoid large swings.
  23517 	(*PassStats)(unsafe.Pointer(s)).Fdq = Clamp(tls, dq, -libc.Float32FromFloat32(30), libc.Float32FromFloat32(30))
  23518 	(*PassStats)(unsafe.Pointer(s)).Flast_q = (*PassStats)(unsafe.Pointer(s)).Fq
  23519 	(*PassStats)(unsafe.Pointer(s)).Flast_value = (*PassStats)(unsafe.Pointer(s)).Fvalue
  23520 	(*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)
  23521 	return (*PassStats)(unsafe.Pointer(s)).Fq
  23522 }
  23523 
  23524 //------------------------------------------------------------------------------
  23525 // Reset the statistics about: number of skips, token proba, level cost,...
  23526 
  23527 func ResetStats(tls *libc.TLS, enc uintptr) {
  23528 	var proba uintptr
  23529 	_ = proba
  23530 	proba = enc + 3616
  23531 	VP8CalculateLevelCosts(tls, proba)
  23532 	(*VP8EncProba)(unsafe.Pointer(proba)).Fnb_skip = 0
  23533 }
  23534 
  23535 //------------------------------------------------------------------------------
  23536 // Skip decision probability
  23537 
  23538 func CalcSkipProba(tls *libc.TLS, nb uint64_t, total uint64_t) (r int32) {
  23539 	var v1 uint64
  23540 	_ = v1
  23541 	if total != 0 {
  23542 		v1 = (total - nb) * uint64(255) / total
  23543 	} else {
  23544 		v1 = uint64(255)
  23545 	}
  23546 	return libc.Int32FromUint64(v1)
  23547 }
  23548 
  23549 // C documentation
  23550 //
  23551 //	// Returns the bit-cost for coding the skip probability.
  23552 func FinalizeSkipProba(tls *libc.TLS, enc uintptr) (r int32) {
  23553 	var nb_events, nb_mbs, size, v2, v4, v6, v8 int32
  23554 	var proba1 uintptr
  23555 	var v1, v5 uint8_t
  23556 	_, _, _, _, _, _, _, _, _, _ = nb_events, nb_mbs, proba1, size, v1, v2, v4, v5, v6, v8
  23557 	proba1 = enc + 3616
  23558 	nb_mbs = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  23559 	nb_events = (*VP8EncProba)(unsafe.Pointer(proba1)).Fnb_skip
  23560 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba = libc.Uint8FromInt32(CalcSkipProba(tls, libc.Uint64FromInt32(nb_events), libc.Uint64FromInt32(nb_mbs)))
  23561 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fuse_skip_proba = libc.BoolInt32(libc.Int32FromUint8((*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba) < int32(SKIP_PROBA_THRESHOLD))
  23562 	size = int32(256) // 'use_skip_proba' bit
  23563 	if (*VP8EncProba)(unsafe.Pointer(proba1)).Fuse_skip_proba != 0 {
  23564 		v1 = (*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba
  23565 		if !(int32(1) != 0) {
  23566 			v4 = libc.Int32FromUint16(VP8EntropyCost[v1])
  23567 		} else {
  23568 			v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v1)])
  23569 		}
  23570 		v2 = v4
  23571 		goto _3
  23572 	_3:
  23573 		v5 = (*VP8EncProba)(unsafe.Pointer(proba1)).Fskip_proba
  23574 		if !(0 != 0) {
  23575 			v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23576 		} else {
  23577 			v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23578 		}
  23579 		v6 = v8
  23580 		goto _7
  23581 	_7:
  23582 		size = size + (nb_events*v2 + (nb_mbs-nb_events)*v6)
  23583 		size = size + libc.Int32FromInt32(8)*libc.Int32FromInt32(256) // cost of signaling the 'skip_proba' itself.
  23584 	}
  23585 	return size
  23586 }
  23587 
  23588 // C documentation
  23589 //
  23590 //	// Collect statistics and deduce probabilities for next coding pass.
  23591 //	// Return the total bit-cost for coding the probability updates.
  23592 func CalcTokenProba(tls *libc.TLS, nb int32, total int32) (r int32) {
  23593 	var v1 int32
  23594 	_ = v1
  23595 	if nb != 0 {
  23596 		v1 = int32(255) - nb*int32(255)/total
  23597 	} else {
  23598 		v1 = int32(255)
  23599 	}
  23600 	return v1
  23601 }
  23602 
  23603 // C documentation
  23604 //
  23605 //	// Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability.
  23606 func BranchCost(tls *libc.TLS, nb int32, total int32, proba1 int32) (r int32) {
  23607 	var v1, v5 uint8_t
  23608 	var v2, v4, v6, v8 int32
  23609 	_, _, _, _, _, _ = v1, v2, v4, v5, v6, v8
  23610 	v1 = libc.Uint8FromInt32(proba1)
  23611 	if !(int32(1) != 0) {
  23612 		v4 = libc.Int32FromUint16(VP8EntropyCost[v1])
  23613 	} else {
  23614 		v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v1)])
  23615 	}
  23616 	v2 = v4
  23617 	goto _3
  23618 _3:
  23619 	v5 = libc.Uint8FromInt32(proba1)
  23620 	if !(0 != 0) {
  23621 		v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23622 	} else {
  23623 		v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23624 	}
  23625 	v6 = v8
  23626 	goto _7
  23627 _7:
  23628 	return nb*v2 + (total-nb)*v6
  23629 }
  23630 
  23631 func ResetTokenStats(tls *libc.TLS, enc uintptr) {
  23632 	var proba uintptr
  23633 	_ = proba
  23634 	proba = enc + 3616
  23635 	libc.X__builtin___memset_chk(tls, proba+1060, 0, uint64(4224), ^__predefined_size_t(0))
  23636 }
  23637 
  23638 func FinalizeTokenProbas(tls *libc.TLS, proba1 uintptr) (r int32) {
  23639 	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
  23640 	var stats proba_t
  23641 	var v13, v5, v9 uint8_t
  23642 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  23643 	has_changed = 0
  23644 	size = 0
  23645 	t = 0
  23646 	for {
  23647 		if !(t < int32(NUM_TYPES)) {
  23648 			break
  23649 		}
  23650 		b = 0
  23651 		for {
  23652 			if !(b < int32(NUM_BANDS)) {
  23653 				break
  23654 			}
  23655 			c = 0
  23656 			for {
  23657 				if !(c < int32(NUM_CTX)) {
  23658 					break
  23659 				}
  23660 				p = 0
  23661 				for {
  23662 					if !(p < int32(NUM_PROBAS)) {
  23663 						break
  23664 					}
  23665 					stats = **(**proba_t)(__ccgo_up(proba1 + 1060 + uintptr(t)*1056 + uintptr(b)*132 + uintptr(c)*44 + uintptr(p)*4))
  23666 					nb = libc.Int32FromUint32(stats >> libc.Int32FromInt32(0) & uint32(0xffff))
  23667 					total = libc.Int32FromUint32(stats >> libc.Int32FromInt32(16) & uint32(0xffff))
  23668 					update_proba = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsUpdateProba)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  23669 					old_p = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&VP8CoeffsProba0)) + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))))
  23670 					new_p = CalcTokenProba(tls, nb, total)
  23671 					v5 = libc.Uint8FromInt32(update_proba)
  23672 					if !(0 != 0) {
  23673 						v8 = libc.Int32FromUint16(VP8EntropyCost[v5])
  23674 					} else {
  23675 						v8 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v5)])
  23676 					}
  23677 					v6 = v8
  23678 					goto _7
  23679 				_7:
  23680 					old_cost = BranchCost(tls, nb, total, old_p) + v6
  23681 					v9 = libc.Uint8FromInt32(update_proba)
  23682 					if !(int32(1) != 0) {
  23683 						v12 = libc.Int32FromUint16(VP8EntropyCost[v9])
  23684 					} else {
  23685 						v12 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v9)])
  23686 					}
  23687 					v10 = v12
  23688 					goto _11
  23689 				_11:
  23690 					new_cost = BranchCost(tls, nb, total, new_p) + v10 + libc.Int32FromInt32(8)*libc.Int32FromInt32(256)
  23691 					use_new_p = libc.BoolInt32(old_cost > new_cost)
  23692 					v13 = libc.Uint8FromInt32(update_proba)
  23693 					if !(use_new_p != 0) {
  23694 						v16 = libc.Int32FromUint16(VP8EntropyCost[v13])
  23695 					} else {
  23696 						v16 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v13)])
  23697 					}
  23698 					v14 = v16
  23699 					goto _15
  23700 				_15:
  23701 					size = size + v14
  23702 					if use_new_p != 0 { // only use proba that seem meaningful enough.
  23703 						**(**uint8_t)(__ccgo_up(proba1 + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(new_p)
  23704 						has_changed = has_changed | libc.BoolInt32(new_p != old_p)
  23705 						size = size + libc.Int32FromInt32(8)*libc.Int32FromInt32(256)
  23706 					} else {
  23707 						**(**uint8_t)(__ccgo_up(proba1 + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p))) = libc.Uint8FromInt32(old_p)
  23708 					}
  23709 					goto _4
  23710 				_4:
  23711 					;
  23712 					p = p + 1
  23713 				}
  23714 				goto _3
  23715 			_3:
  23716 				;
  23717 				c = c + 1
  23718 			}
  23719 			goto _2
  23720 		_2:
  23721 			;
  23722 			b = b + 1
  23723 		}
  23724 		goto _1
  23725 	_1:
  23726 		;
  23727 		t = t + 1
  23728 	}
  23729 	(*VP8EncProba)(unsafe.Pointer(proba1)).Fdirty = has_changed
  23730 	return size
  23731 }
  23732 
  23733 //------------------------------------------------------------------------------
  23734 // Finalize Segment probability based on the coding tree
  23735 
  23736 func GetProba(tls *libc.TLS, a int32, b int32) (r int32) {
  23737 	var total, v1 int32
  23738 	_, _ = total, v1
  23739 	total = a + b
  23740 	if total == 0 {
  23741 		v1 = int32(255)
  23742 	} else {
  23743 		v1 = (int32(255)*a + total/int32(2)) / total
  23744 	}
  23745 	return v1 // rounded proba
  23746 }
  23747 
  23748 func ResetSegments(tls *libc.TLS, enc uintptr) {
  23749 	var n int32
  23750 	_ = n
  23751 	n = 0
  23752 	for {
  23753 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  23754 			break
  23755 		}
  23756 		libc.SetBitFieldPtr8Uint32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info+uintptr(n)*4+0, libc.Uint32FromInt32(0), 5, 0x60)
  23757 		goto _1
  23758 	_1:
  23759 		;
  23760 		n = n + 1
  23761 	}
  23762 }
  23763 
  23764 func SetSegmentProbas(tls *libc.TLS, enc uintptr) {
  23765 	var mb, probas uintptr
  23766 	var n, v10, v12, v14, v16, v18, v20, v22, v24, v26, v28, v30, v32, v34, v4, v6, v8 int32
  23767 	var p [4]int32
  23768 	var v11, v15, v19, v23, v27, v3, v31, v7 uint8_t
  23769 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  23770 	p = [4]int32{}
  23771 	n = 0
  23772 	for {
  23773 		if !(n < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  23774 			break
  23775 		}
  23776 		mb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(n)*4
  23777 		p[int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5))] = p[int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5))] + 1
  23778 		goto _1
  23779 	_1:
  23780 		;
  23781 		n = n + 1
  23782 	}
  23783 	if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != libc.UintptrFromInt32(0) {
  23784 		n = 0
  23785 		for {
  23786 			if !(n < int32(NUM_MB_SEGMENTS)) {
  23787 				break
  23788 			}
  23789 			**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats + 92 + uintptr(n)*4)) = p[n]
  23790 			goto _2
  23791 		_2:
  23792 			;
  23793 			n = n + 1
  23794 		}
  23795 	}
  23796 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments > int32(1) {
  23797 		probas = enc + 3616
  23798 		**(**uint8_t)(__ccgo_up(probas)) = libc.Uint8FromInt32(GetProba(tls, p[0]+p[int32(1)], p[int32(2)]+p[int32(3)]))
  23799 		**(**uint8_t)(__ccgo_up(probas + 1)) = libc.Uint8FromInt32(GetProba(tls, p[0], p[int32(1)]))
  23800 		**(**uint8_t)(__ccgo_up(probas + 2)) = libc.Uint8FromInt32(GetProba(tls, p[int32(2)], p[int32(3)]))
  23801 		(*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))
  23802 		if !((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map != 0) {
  23803 			ResetSegments(tls, enc)
  23804 		}
  23805 		v3 = **(**uint8_t)(__ccgo_up(probas))
  23806 		if !(0 != 0) {
  23807 			v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  23808 		} else {
  23809 			v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  23810 		}
  23811 		v4 = v6
  23812 		goto _5
  23813 	_5:
  23814 		v7 = **(**uint8_t)(__ccgo_up(probas + 1))
  23815 		if !(0 != 0) {
  23816 			v10 = libc.Int32FromUint16(VP8EntropyCost[v7])
  23817 		} else {
  23818 			v10 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v7)])
  23819 		}
  23820 		v8 = v10
  23821 		goto _9
  23822 	_9:
  23823 		v11 = **(**uint8_t)(__ccgo_up(probas))
  23824 		if !(0 != 0) {
  23825 			v14 = libc.Int32FromUint16(VP8EntropyCost[v11])
  23826 		} else {
  23827 			v14 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v11)])
  23828 		}
  23829 		v12 = v14
  23830 		goto _13
  23831 	_13:
  23832 		v15 = **(**uint8_t)(__ccgo_up(probas + 1))
  23833 		if !(int32(1) != 0) {
  23834 			v18 = libc.Int32FromUint16(VP8EntropyCost[v15])
  23835 		} else {
  23836 			v18 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v15)])
  23837 		}
  23838 		v16 = v18
  23839 		goto _17
  23840 	_17:
  23841 		v19 = **(**uint8_t)(__ccgo_up(probas))
  23842 		if !(int32(1) != 0) {
  23843 			v22 = libc.Int32FromUint16(VP8EntropyCost[v19])
  23844 		} else {
  23845 			v22 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v19)])
  23846 		}
  23847 		v20 = v22
  23848 		goto _21
  23849 	_21:
  23850 		v23 = **(**uint8_t)(__ccgo_up(probas + 2))
  23851 		if !(0 != 0) {
  23852 			v26 = libc.Int32FromUint16(VP8EntropyCost[v23])
  23853 		} else {
  23854 			v26 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v23)])
  23855 		}
  23856 		v24 = v26
  23857 		goto _25
  23858 	_25:
  23859 		v27 = **(**uint8_t)(__ccgo_up(probas))
  23860 		if !(int32(1) != 0) {
  23861 			v30 = libc.Int32FromUint16(VP8EntropyCost[v27])
  23862 		} else {
  23863 			v30 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v27)])
  23864 		}
  23865 		v28 = v30
  23866 		goto _29
  23867 	_29:
  23868 		v31 = **(**uint8_t)(__ccgo_up(probas + 2))
  23869 		if !(int32(1) != 0) {
  23870 			v34 = libc.Int32FromUint16(VP8EntropyCost[v31])
  23871 		} else {
  23872 			v34 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v31)])
  23873 		}
  23874 		v32 = v34
  23875 		goto _33
  23876 	_33:
  23877 		(*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)
  23878 	} else {
  23879 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map = 0
  23880 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize = 0
  23881 	}
  23882 }
  23883 
  23884 //------------------------------------------------------------------------------
  23885 // Coefficient coding
  23886 
  23887 func PutCoeffs(tls *libc.TLS, bw uintptr, ctx int32, res uintptr) (r int32) {
  23888 	var c, mask, n, sign, v, v1, v2 int32
  23889 	var p, tab, v3 uintptr
  23890 	_, _, _, _, _, _, _, _, _, _ = c, mask, n, p, sign, tab, v, v1, v2, v3
  23891 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  23892 	// should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
  23893 	p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(n)*33 + uintptr(ctx)*11
  23894 	if !(VP8PutBit(tls, bw, libc.BoolInt32((*VP8Residual)(unsafe.Pointer(res)).Flast >= 0), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0) {
  23895 		return 0
  23896 	}
  23897 	for n < int32(16) {
  23898 		v1 = n
  23899 		n = n + 1
  23900 		c = int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(v1)*2)))
  23901 		sign = libc.BoolInt32(c < 0)
  23902 		if sign != 0 {
  23903 			v2 = -c
  23904 		} else {
  23905 			v2 = c
  23906 		}
  23907 		v = v2
  23908 		if !(VP8PutBit(tls, bw, libc.BoolInt32(v != 0), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1)))) != 0) {
  23909 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33
  23910 			continue
  23911 		}
  23912 		if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(1)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 2)))) != 0) {
  23913 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33 + 1*11
  23914 		} else {
  23915 			if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(4)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 3)))) != 0) {
  23916 				if VP8PutBit(tls, bw, libc.BoolInt32(v != int32(2)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 4)))) != 0 {
  23917 					VP8PutBit(tls, bw, libc.BoolInt32(v == int32(4)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 5))))
  23918 				}
  23919 			} else {
  23920 				if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(10)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 6)))) != 0) {
  23921 					if !(VP8PutBit(tls, bw, libc.BoolInt32(v > int32(6)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 7)))) != 0) {
  23922 						VP8PutBit(tls, bw, libc.BoolInt32(v == int32(6)), int32(159))
  23923 					} else {
  23924 						VP8PutBit(tls, bw, libc.BoolInt32(v >= int32(9)), int32(165))
  23925 						VP8PutBit(tls, bw, libc.BoolInt32(!(v&libc.Int32FromInt32(1) != 0)), int32(145))
  23926 					}
  23927 				} else {
  23928 					if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(1) { // VP8Cat3  (3b)
  23929 						VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23930 						VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 9))))
  23931 						v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(0))
  23932 						mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(2)
  23933 						tab = uintptr(unsafe.Pointer(&VP8Cat3))
  23934 					} else {
  23935 						if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(2) { // VP8Cat4  (4b)
  23936 							VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23937 							VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 9))))
  23938 							v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(1))
  23939 							mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(3)
  23940 							tab = uintptr(unsafe.Pointer(&VP8Cat4))
  23941 						} else {
  23942 							if v < libc.Int32FromInt32(3)+libc.Int32FromInt32(8)<<libc.Int32FromInt32(3) { // VP8Cat5  (5b)
  23943 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23944 								VP8PutBit(tls, bw, 0, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 10))))
  23945 								v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(2))
  23946 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(4)
  23947 								tab = uintptr(unsafe.Pointer(&VP8Cat5))
  23948 							} else { // VP8Cat6 (11b)
  23949 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 8))))
  23950 								VP8PutBit(tls, bw, int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 10))))
  23951 								v = v - (libc.Int32FromInt32(3) + libc.Int32FromInt32(8)<<libc.Int32FromInt32(3))
  23952 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(10)
  23953 								tab = uintptr(unsafe.Pointer(&VP8Cat6))
  23954 							}
  23955 						}
  23956 					}
  23957 					for mask != 0 {
  23958 						v3 = tab
  23959 						tab = tab + 1
  23960 						VP8PutBit(tls, bw, libc.BoolInt32(!!(v&mask != 0)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v3))))
  23961 						mask = mask >> int32(1)
  23962 					}
  23963 				}
  23964 			}
  23965 			p = (*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(VP8EncBands[n])*33 + 2*11
  23966 		}
  23967 		VP8PutBitUniform(tls, bw, sign)
  23968 		if n == int32(16) || !(VP8PutBit(tls, bw, libc.BoolInt32(n <= (*VP8Residual)(unsafe.Pointer(res)).Flast), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0) {
  23969 			return int32(1) // EOB
  23970 		}
  23971 	}
  23972 	return int32(1)
  23973 }
  23974 
  23975 func CodeResiduals(tls *libc.TLS, bw1 uintptr, it uintptr, rd uintptr) {
  23976 	bp := tls.Alloc(48)
  23977 	defer tls.Free(48)
  23978 	var ch, ctx, ctx1, i16, segment, x, y, v4 int32
  23979 	var enc, v1 uintptr
  23980 	var nb_bits, pos1, pos2, pos3, v2 uint64_t
  23981 	var _ /* res at bp+0 */ VP8Residual
  23982 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ch, ctx, ctx1, enc, i16, nb_bits, pos1, pos2, pos3, segment, x, y, v1, v2, v4
  23983 	i16 = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == libc.Int32FromInt32(1))
  23984 	segment = int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0)) & 0x60 >> 5))
  23985 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  23986 	VP8IteratorNzToBytes(tls, it)
  23987 	v1 = bw1
  23988 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  23989 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  23990 	goto _3
  23991 _3:
  23992 	pos1 = v2
  23993 	if i16 != 0 {
  23994 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  23995 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  23996 		v4 = PutCoeffs(tls, bw1, **(**int32)(__ccgo_up(it + 132 + 8*4))+**(**int32)(__ccgo_up(it + 168 + 8*4)), bp)
  23997 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v4
  23998 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v4
  23999 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24000 	} else {
  24001 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24002 	}
  24003 	// luma-AC
  24004 	y = 0
  24005 	for {
  24006 		if !(y < int32(4)) {
  24007 			break
  24008 		}
  24009 		x = 0
  24010 		for {
  24011 			if !(x < int32(4)) {
  24012 				break
  24013 			}
  24014 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24015 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24016 			v4 = PutCoeffs(tls, bw1, ctx, bp)
  24017 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v4
  24018 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v4
  24019 			goto _6
  24020 		_6:
  24021 			;
  24022 			x = x + 1
  24023 		}
  24024 		goto _5
  24025 	_5:
  24026 		;
  24027 		y = y + 1
  24028 	}
  24029 	v1 = bw1
  24030 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  24031 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  24032 	goto _10
  24033 _10:
  24034 	pos2 = v2
  24035 	// U/V
  24036 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24037 	ch = 0
  24038 	for {
  24039 		if !(ch <= int32(2)) {
  24040 			break
  24041 		}
  24042 		y = 0
  24043 		for {
  24044 			if !(y < int32(2)) {
  24045 				break
  24046 			}
  24047 			x = 0
  24048 			for {
  24049 				if !(x < int32(2)) {
  24050 					break
  24051 				}
  24052 				ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24053 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24054 				v4 = PutCoeffs(tls, bw1, ctx1, bp)
  24055 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v4
  24056 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v4
  24057 				goto _13
  24058 			_13:
  24059 				;
  24060 				x = x + 1
  24061 			}
  24062 			goto _12
  24063 		_12:
  24064 			;
  24065 			y = y + 1
  24066 		}
  24067 		goto _11
  24068 	_11:
  24069 		;
  24070 		ch = ch + int32(2)
  24071 	}
  24072 	v1 = bw1
  24073 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  24074 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  24075 	goto _17
  24076 _17:
  24077 	pos3 = v2
  24078 	(*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits = pos2 - pos1
  24079 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits = pos3 - pos2
  24080 	**(**uint64_t)(__ccgo_up(it + 208 + uintptr(segment)*24 + uintptr(i16)*8)) += (*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits
  24081 	**(**uint64_t)(__ccgo_up(it + 208 + uintptr(segment)*24 + 2*8)) += (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits
  24082 	VP8IteratorBytesToNz(tls, it)
  24083 }
  24084 
  24085 // C documentation
  24086 //
  24087 //	// Same as CodeResiduals, but doesn't actually write anything.
  24088 //	// Instead, it just records the event distribution.
  24089 func RecordResiduals(tls *libc.TLS, it uintptr, rd uintptr) {
  24090 	bp := tls.Alloc(48)
  24091 	defer tls.Free(48)
  24092 	var ch, ctx, ctx1, x, y, v1 int32
  24093 	var enc uintptr
  24094 	var _ /* res at bp+0 */ VP8Residual
  24095 	_, _, _, _, _, _, _ = ch, ctx, ctx1, enc, x, y, v1
  24096 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24097 	VP8IteratorNzToBytes(tls, it)
  24098 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) { // i16x16
  24099 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  24100 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  24101 		v1 = VP8RecordCoeffs(tls, **(**int32)(__ccgo_up(it + 132 + 8*4))+**(**int32)(__ccgo_up(it + 168 + 8*4)), bp)
  24102 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v1
  24103 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v1
  24104 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24105 	} else {
  24106 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24107 	}
  24108 	// luma-AC
  24109 	y = 0
  24110 	for {
  24111 		if !(y < int32(4)) {
  24112 			break
  24113 		}
  24114 		x = 0
  24115 		for {
  24116 			if !(x < int32(4)) {
  24117 				break
  24118 			}
  24119 			ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24120 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24121 			v1 = VP8RecordCoeffs(tls, ctx, bp)
  24122 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v1
  24123 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v1
  24124 			goto _3
  24125 		_3:
  24126 			;
  24127 			x = x + 1
  24128 		}
  24129 		goto _2
  24130 	_2:
  24131 		;
  24132 		y = y + 1
  24133 	}
  24134 	// U/V
  24135 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24136 	ch = 0
  24137 	for {
  24138 		if !(ch <= int32(2)) {
  24139 			break
  24140 		}
  24141 		y = 0
  24142 		for {
  24143 			if !(y < int32(2)) {
  24144 				break
  24145 			}
  24146 			x = 0
  24147 			for {
  24148 				if !(x < int32(2)) {
  24149 					break
  24150 				}
  24151 				ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24152 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24153 				v1 = VP8RecordCoeffs(tls, ctx1, bp)
  24154 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v1
  24155 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v1
  24156 				goto _7
  24157 			_7:
  24158 				;
  24159 				x = x + 1
  24160 			}
  24161 			goto _6
  24162 		_6:
  24163 			;
  24164 			y = y + 1
  24165 		}
  24166 		goto _5
  24167 	_5:
  24168 		;
  24169 		ch = ch + int32(2)
  24170 	}
  24171 	VP8IteratorBytesToNz(tls, it)
  24172 }
  24173 
  24174 //------------------------------------------------------------------------------
  24175 // Token buffer
  24176 
  24177 func RecordTokens(tls *libc.TLS, it uintptr, rd uintptr, tokens uintptr) (r int32) {
  24178 	bp := tls.Alloc(48)
  24179 	defer tls.Free(48)
  24180 	var ch, ctx, ctx1, ctx2, x, y, v1 int32
  24181 	var enc uintptr
  24182 	var _ /* res at bp+0 */ VP8Residual
  24183 	_, _, _, _, _, _, _, _ = ch, ctx, ctx1, ctx2, enc, x, y, v1
  24184 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24185 	VP8IteratorNzToBytes(tls, it)
  24186 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) { // i16x16
  24187 		ctx = **(**int32)(__ccgo_up(it + 132 + 8*4)) + **(**int32)(__ccgo_up(it + 168 + 8*4))
  24188 		VP8InitResidual(tls, 0, int32(1), enc, bp)
  24189 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+40, bp)
  24190 		v1 = VP8RecordCoeffTokens(tls, ctx, bp, tokens)
  24191 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = v1
  24192 		**(**int32)(__ccgo_up(it + 132 + 8*4)) = v1
  24193 		VP8InitResidual(tls, int32(1), 0, enc, bp)
  24194 	} else {
  24195 		VP8InitResidual(tls, 0, int32(3), enc, bp)
  24196 	}
  24197 	// luma-AC
  24198 	y = 0
  24199 	for {
  24200 		if !(y < int32(4)) {
  24201 			break
  24202 		}
  24203 		x = 0
  24204 		for {
  24205 			if !(x < int32(4)) {
  24206 				break
  24207 			}
  24208 			ctx1 = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  24209 			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+72+uintptr(x+y*int32(4))*32, bp)
  24210 			v1 = VP8RecordCoeffTokens(tls, ctx1, bp, tokens)
  24211 			**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v1
  24212 			**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v1
  24213 			goto _3
  24214 		_3:
  24215 			;
  24216 			x = x + 1
  24217 		}
  24218 		goto _2
  24219 	_2:
  24220 		;
  24221 		y = y + 1
  24222 	}
  24223 	// U/V
  24224 	VP8InitResidual(tls, 0, int32(2), enc, bp)
  24225 	ch = 0
  24226 	for {
  24227 		if !(ch <= int32(2)) {
  24228 			break
  24229 		}
  24230 		y = 0
  24231 		for {
  24232 			if !(y < int32(2)) {
  24233 				break
  24234 			}
  24235 			x = 0
  24236 			for {
  24237 				if !(x < int32(2)) {
  24238 					break
  24239 				}
  24240 				ctx2 = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  24241 				(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8SetResidualCoeffs})))(tls, rd+584+uintptr(ch*int32(2)+x+y*int32(2))*32, bp)
  24242 				v1 = VP8RecordCoeffTokens(tls, ctx2, bp, tokens)
  24243 				**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v1
  24244 				**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v1
  24245 				goto _7
  24246 			_7:
  24247 				;
  24248 				x = x + 1
  24249 			}
  24250 			goto _6
  24251 		_6:
  24252 			;
  24253 			y = y + 1
  24254 		}
  24255 		goto _5
  24256 	_5:
  24257 		;
  24258 		ch = ch + int32(2)
  24259 	}
  24260 	VP8IteratorBytesToNz(tls, it)
  24261 	return libc.BoolInt32(!((*VP8TBuffer)(unsafe.Pointer(tokens)).Ferror1 != 0))
  24262 }
  24263 
  24264 //------------------------------------------------------------------------------
  24265 // ExtraInfo map / Debug function
  24266 
  24267 func ResetSSE(tls *libc.TLS, enc uintptr) {
  24268 	**(**uint64_t)(__ccgo_up(enc + 23512)) = uint64(0)
  24269 	**(**uint64_t)(__ccgo_up(enc + 23512 + 1*8)) = uint64(0)
  24270 	**(**uint64_t)(__ccgo_up(enc + 23512 + 2*8)) = uint64(0)
  24271 	// Note: enc->sse[3] is managed by alpha.c
  24272 	(*VP8Encoder)(unsafe.Pointer(enc)).Fsse_count = uint64(0)
  24273 }
  24274 
  24275 func StoreSSE(tls *libc.TLS, it uintptr) {
  24276 	var enc, in, out uintptr
  24277 	_, _, _ = enc, in, out
  24278 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24279 	in = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in
  24280 	out = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out
  24281 	// Note: not totally accurate at boundary. And doesn't include in-loop filter.
  24282 	**(**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))))
  24283 	**(**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))))
  24284 	**(**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))))
  24285 	**(**uint64_t)(__ccgo_up(enc + 23544)) += libc.Uint64FromInt32(libc.Int32FromInt32(16) * libc.Int32FromInt32(16))
  24286 }
  24287 
  24288 func StoreSideInfo(tls *libc.TLS, it uintptr) {
  24289 	var b, v1 int32
  24290 	var enc, info, mb, pic uintptr
  24291 	_, _, _, _, _, _ = b, enc, info, mb, pic, v1
  24292 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24293 	mb = (*VP8EncIterator)(unsafe.Pointer(it)).Fmb
  24294 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  24295 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  24296 		StoreSSE(tls, it)
  24297 		**(**int32)(__ccgo_up(enc + 23604)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == 0)
  24298 		**(**int32)(__ccgo_up(enc + 23604 + 1*4)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == int32(1))
  24299 		**(**int32)(__ccgo_up(enc + 23604 + 2*4)) += libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x10>>4)) != 0)
  24300 	}
  24301 	if (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info != libc.UintptrFromInt32(0) {
  24302 		info = (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx+(*VP8EncIterator)(unsafe.Pointer(it)).Fy*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)
  24303 		switch (*WebPPicture)(unsafe.Pointer(pic)).Fextra_info_type {
  24304 		case int32(1):
  24305 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x3 >> 0)))
  24306 		case int32(2):
  24307 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0x60 >> 5)))
  24308 		case int32(3):
  24309 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32((**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5)))*744))).Fquant)
  24310 		case int32(4):
  24311 			if int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) == int32(1) {
  24312 				v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds)))
  24313 			} else {
  24314 				v1 = int32(0xff)
  24315 			}
  24316 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(v1)
  24317 		case int32(5):
  24318 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0)) & 0xc >> 2)))
  24319 		case int32(6):
  24320 			b = libc.Int32FromUint64(((*VP8EncIterator)(unsafe.Pointer(it)).Fluma_bits + (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_bits + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  24321 			if b > int32(255) {
  24322 				v1 = int32(255)
  24323 			} else {
  24324 				v1 = b
  24325 			}
  24326 			**(**uint8_t)(__ccgo_up(info)) = libc.Uint8FromInt32(v1)
  24327 		case int32(7):
  24328 			**(**uint8_t)(__ccgo_up(info)) = (*VP8MBInfo)(unsafe.Pointer(mb)).Falpha
  24329 		default:
  24330 			**(**uint8_t)(__ccgo_up(info)) = uint8(0)
  24331 			break
  24332 		}
  24333 	}
  24334 }
  24335 
  24336 func ResetSideInfo(tls *libc.TLS, it uintptr) {
  24337 	var enc, pic uintptr
  24338 	_, _ = enc, pic
  24339 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24340 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  24341 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  24342 		libc.X__builtin___memset_chk(tls, enc+23604, 0, uint64(12), ^__predefined_size_t(0))
  24343 	}
  24344 	ResetSSE(tls, enc)
  24345 }
  24346 
  24347 func GetPSNR(tls *libc.TLS, mse uint64_t, size uint64_t) (r float64) {
  24348 	var v1 float64
  24349 	_ = v1
  24350 	if mse > uint64(0) && size > uint64(0) {
  24351 		v1 = float64(float64(10) * libc.Xlog10(tls, float64(float64(libc.Float64FromFloat64(255)*libc.Float64FromFloat64(255))*float64(size))/float64(mse)))
  24352 	} else {
  24353 		v1 = libc.Float64FromInt32(99)
  24354 	}
  24355 	return v1
  24356 }
  24357 
  24358 //------------------------------------------------------------------------------
  24359 //  StatLoop(): only collect statistics (number of skips, token usage, ...).
  24360 //  This is used for deciding optimal probabilities. It also modifies the
  24361 //  quantizer value if some target (size, PSNR) was specified.
  24362 
  24363 func SetLoopParams(tls *libc.TLS, enc uintptr, q float32) {
  24364 	// Make sure the quality parameter is inside valid bounds
  24365 	q = Clamp(tls, q, libc.Float32FromFloat32(0), libc.Float32FromFloat32(100))
  24366 	VP8SetSegmentParams(tls, enc, q) // setup segment quantizations and filters
  24367 	SetSegmentProbas(tls, enc)       // compute segment probabilities
  24368 	ResetStats(tls, enc)
  24369 	ResetSSE(tls, enc)
  24370 }
  24371 
  24372 func OneStatPass(tls *libc.TLS, enc uintptr, rd_opt VP8RDLevel, nb_mbs int32, percent_delta int32, s uintptr) (r uint64_t) {
  24373 	bp := tls.Alloc(4736)
  24374 	defer tls.Free(4736)
  24375 	var distortion, pixel_count, size, size_p0 uint64_t
  24376 	var v1 int32
  24377 	var v2 bool
  24378 	var _ /* info at bp+3848 */ VP8ModeScore
  24379 	var _ /* it at bp+0 */ VP8EncIterator
  24380 	_, _, _, _, _, _ = distortion, pixel_count, size, size_p0, v1, v2
  24381 	size = uint64(0)
  24382 	size_p0 = uint64(0)
  24383 	distortion = uint64(0)
  24384 	pixel_count = libc.Uint64FromInt32(nb_mbs) * uint64(384)
  24385 	VP8IteratorInit(tls, enc, bp)
  24386 	SetLoopParams(tls, enc, (*PassStats)(unsafe.Pointer(s)).Fq)
  24387 	for {
  24388 		VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24389 		if VP8Decimate(tls, bp, bp+3848, rd_opt) != 0 {
  24390 			// Just record the number of skips and act like skip_proba is not used.
  24391 			(*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fnb_skip = (*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fnb_skip + 1
  24392 		}
  24393 		RecordResiduals(tls, bp, bp+3848)
  24394 		size = size + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FR+(**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FH)
  24395 		size_p0 = size_p0 + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FH)
  24396 		distortion = distortion + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3848))).FD)
  24397 		if percent_delta != 0 && !(VP8IteratorProgress(tls, bp, percent_delta) != 0) {
  24398 			return uint64(0)
  24399 		}
  24400 		VP8IteratorSaveBoundary(tls, bp)
  24401 		goto _3
  24402 	_3:
  24403 		;
  24404 		if v2 = VP8IteratorNext(tls, bp) != 0; v2 {
  24405 			nb_mbs = nb_mbs - 1
  24406 			v1 = nb_mbs
  24407 		}
  24408 		if !(v2 && v1 > 0) {
  24409 			break
  24410 		}
  24411 	}
  24412 	size_p0 = size_p0 + libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize)
  24413 	if (*PassStats)(unsafe.Pointer(s)).Fdo_size_search != 0 {
  24414 		size = size + libc.Uint64FromInt32(FinalizeSkipProba(tls, enc))
  24415 		size = size + libc.Uint64FromInt32(FinalizeTokenProbas(tls, enc+3616))
  24416 		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))
  24417 		(*PassStats)(unsafe.Pointer(s)).Fvalue = float64(size)
  24418 	} else {
  24419 		(*PassStats)(unsafe.Pointer(s)).Fvalue = GetPSNR(tls, distortion, pixel_count)
  24420 	}
  24421 	return size_p0
  24422 }
  24423 
  24424 func StatLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24425 	bp := tls.Alloc(64)
  24426 	defer tls.Free(64)
  24427 	var do_search, fast_probe, final_percent, is_last_pass, method, nb_mbs, num_pass_left, percent_per_pass, task_percent, v1 int32
  24428 	var rd_opt VP8RDLevel
  24429 	var size_p0 uint64_t
  24430 	var _ /* stats at bp+0 */ PassStats
  24431 	_, _, _, _, _, _, _, _, _, _, _, _ = 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
  24432 	method = (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod
  24433 	do_search = (*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search
  24434 	fast_probe = libc.BoolInt32((method == 0 || method == int32(3)) && !(do_search != 0))
  24435 	num_pass_left = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpass
  24436 	task_percent = int32(20)
  24437 	percent_per_pass = (task_percent + num_pass_left/int32(2)) / num_pass_left
  24438 	final_percent = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent + task_percent
  24439 	if method >= int32(3) || do_search != 0 {
  24440 		v1 = int32(RD_OPT_BASIC)
  24441 	} else {
  24442 		v1 = int32(RD_OPT_NONE)
  24443 	}
  24444 	rd_opt = v1
  24445 	nb_mbs = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  24446 	InitPassStats(tls, enc, bp)
  24447 	ResetTokenStats(tls, enc)
  24448 	// Fast mode: quick analysis pass over few mbs. Better than nothing.
  24449 	if fast_probe != 0 {
  24450 		if method == int32(3) { // we need more stats for method 3 to be reliable.
  24451 			if nb_mbs > int32(200) {
  24452 				v1 = nb_mbs >> int32(1)
  24453 			} else {
  24454 				v1 = int32(100)
  24455 			}
  24456 			nb_mbs = v1
  24457 		} else {
  24458 			if nb_mbs > int32(200) {
  24459 				v1 = nb_mbs >> int32(2)
  24460 			} else {
  24461 				v1 = int32(50)
  24462 			}
  24463 			nb_mbs = v1
  24464 		}
  24465 	}
  24466 	for {
  24467 		v1 = num_pass_left
  24468 		num_pass_left = num_pass_left - 1
  24469 		if !(v1 > 0) {
  24470 			break
  24471 		}
  24472 		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)
  24473 		size_p0 = OneStatPass(tls, enc, rd_opt, nb_mbs, percent_per_pass, bp)
  24474 		if size_p0 == uint64(0) {
  24475 			return 0
  24476 		}
  24477 		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) {
  24478 			num_pass_left = num_pass_left + 1
  24479 			**(**int32)(__ccgo_up(enc + 23624)) >>= int32(1) // strengthen header bit limitation...
  24480 			continue                                         // ...and start over
  24481 		}
  24482 		if is_last_pass != 0 {
  24483 			break
  24484 		}
  24485 		// If no target size: just do several pass without changing 'q'
  24486 		if do_search != 0 {
  24487 			ComputeNextQ(tls, bp)
  24488 			if libc.Xfabs(tls, float64((**(**PassStats)(__ccgo_up(bp))).Fdq)) <= float64(DQ_LIMIT) {
  24489 				break
  24490 			}
  24491 		}
  24492 	}
  24493 	if !(do_search != 0) || !((**(**PassStats)(__ccgo_up(bp))).Fdo_size_search != 0) {
  24494 		// Need to finalize probas now, since it wasn't done during the search.
  24495 		FinalizeSkipProba(tls, enc)
  24496 		FinalizeTokenProbas(tls, enc+3616)
  24497 	}
  24498 	VP8CalculateLevelCosts(tls, enc+3616) // finalize costs
  24499 	return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, final_percent, enc+536)
  24500 }
  24501 
  24502 //------------------------------------------------------------------------------
  24503 // Main loops
  24504 //
  24505 
  24506 var kAverageBytesPerMB = [8]uint8_t{
  24507 	0: uint8(50),
  24508 	1: uint8(24),
  24509 	2: uint8(16),
  24510 	3: uint8(9),
  24511 	4: uint8(7),
  24512 	5: uint8(5),
  24513 	6: uint8(3),
  24514 	7: uint8(2),
  24515 }
  24516 
  24517 func PreLoopInitialize(tls *libc.TLS, enc uintptr) (r int32) {
  24518 	var average_bytes_per_MB, bytes_per_parts, ok, p int32
  24519 	_, _, _, _ = average_bytes_per_MB, bytes_per_parts, ok, p
  24520 	ok = int32(1)
  24521 	average_bytes_per_MB = libc.Int32FromUint8(kAverageBytesPerMB[(*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant>>int32(4)])
  24522 	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
  24523 	// Initialize the bit-writers
  24524 	p = 0
  24525 	for {
  24526 		if !(ok != 0 && p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  24527 			break
  24528 		}
  24529 		ok = VP8BitWriterInit(tls, enc+112+uintptr(p)*48, libc.Uint64FromInt32(bytes_per_parts))
  24530 		goto _1
  24531 	_1:
  24532 		;
  24533 		p = p + 1
  24534 	}
  24535 	if !(ok != 0) {
  24536 		VP8EncFreeBitWriters(tls, enc) // malloc error occurred
  24537 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24538 	}
  24539 	return ok
  24540 }
  24541 
  24542 func PostLoopFinalize(tls *libc.TLS, it uintptr, ok int32) (r int32) {
  24543 	var enc uintptr
  24544 	var i, p, s int32
  24545 	_, _, _, _ = enc, i, p, s
  24546 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  24547 	if ok != 0 {
  24548 		p = 0
  24549 		for {
  24550 			if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  24551 				break
  24552 			}
  24553 			VP8BitWriterFinish(tls, enc+112+uintptr(p)*48)
  24554 			ok = ok & libc.BoolInt32(!((**(**VP8BitWriter)(__ccgo_up(enc + 112 + uintptr(p)*48))).Ferror1 != 0))
  24555 			goto _1
  24556 		_1:
  24557 			;
  24558 			p = p + 1
  24559 		}
  24560 	}
  24561 	if ok != 0 { // All good. Finish up.
  24562 		if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != libc.UintptrFromInt32(0) {
  24563 			i = 0
  24564 			for {
  24565 				if !(i <= int32(2)) {
  24566 					break
  24567 				}
  24568 				s = 0
  24569 				for {
  24570 					if !(s < int32(NUM_MB_SEGMENTS)) {
  24571 						break
  24572 					}
  24573 					**(**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))
  24574 					goto _3
  24575 				_3:
  24576 					;
  24577 					s = s + 1
  24578 				}
  24579 				goto _2
  24580 			_2:
  24581 				;
  24582 				i = i + 1
  24583 			}
  24584 		}
  24585 		VP8AdjustFilterStrength(tls, it) // ...and store filter stats.
  24586 	} else {
  24587 		// Something bad happened -> need to do some memory cleanup.
  24588 		VP8EncFreeBitWriters(tls, enc)
  24589 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24590 	}
  24591 	return ok
  24592 }
  24593 
  24594 //------------------------------------------------------------------------------
  24595 //  VP8EncLoop(): does the final bitstream coding.
  24596 
  24597 func ResetAfterSkip(tls *libc.TLS, it uintptr) {
  24598 	if int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1) {
  24599 		**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) = uint32(0) // reset all predictors
  24600 		**(**int32)(__ccgo_up(it + 168 + 8*4)) = 0
  24601 	} else {
  24602 		**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) &= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(24)) // preserve the dc_nz bit
  24603 	}
  24604 }
  24605 
  24606 func VP8EncLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24607 	bp := tls.Alloc(4736)
  24608 	defer tls.Free(4736)
  24609 	var dont_use_skip, ok int32
  24610 	var rd_opt VP8RDLevel
  24611 	var _ /* info at bp+3848 */ VP8ModeScore
  24612 	var _ /* it at bp+0 */ VP8EncIterator
  24613 	_, _, _ = dont_use_skip, ok, rd_opt
  24614 	ok = PreLoopInitialize(tls, enc)
  24615 	if !(ok != 0) {
  24616 		return 0
  24617 	}
  24618 	StatLoop(tls, enc) // stats-collection loop
  24619 	VP8IteratorInit(tls, enc, bp)
  24620 	VP8InitFilter(tls, bp)
  24621 	for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, bp) != 0 {
  24622 		dont_use_skip = libc.BoolInt32(!((*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fuse_skip_proba != 0))
  24623 		rd_opt = (*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level
  24624 		VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24625 		// Warning! order is important: first call VP8Decimate() and
  24626 		// *then* decide how to code the skip decision if there's one.
  24627 		if !(VP8Decimate(tls, bp, bp+3848, rd_opt) != 0) || dont_use_skip != 0 {
  24628 			CodeResiduals(tls, (**(**VP8EncIterator)(__ccgo_up(bp))).Fbw, bp, bp+3848)
  24629 			if (*VP8BitWriter)(unsafe.Pointer((**(**VP8EncIterator)(__ccgo_up(bp))).Fbw)).Ferror1 != 0 {
  24630 				// enc->pic->error_code is set in PostLoopFinalize().
  24631 				ok = 0
  24632 				break
  24633 			}
  24634 		} else { // reset predictors after a skip
  24635 			ResetAfterSkip(tls, bp)
  24636 		}
  24637 		StoreSideInfo(tls, bp)
  24638 		VP8StoreFilterStats(tls, bp)
  24639 		VP8IteratorExport(tls, bp)
  24640 		ok = VP8IteratorProgress(tls, bp, int32(20))
  24641 		VP8IteratorSaveBoundary(tls, bp)
  24642 	}
  24643 	return PostLoopFinalize(tls, bp, ok)
  24644 }
  24645 
  24646 //------------------------------------------------------------------------------
  24647 // Single pass using Token Buffer.
  24648 
  24649 func VP8EncTokenLoop(tls *libc.TLS, enc uintptr) (r int32) {
  24650 	bp := tls.Alloc(4784)
  24651 	defer tls.Free(4784)
  24652 	var cnt, do_search, is_last_pass, max_count, num_pass_left, ok, pass_progress, remaining_progress, v1 int32
  24653 	var distortion, pixel_count, size, size_p0 uint64_t
  24654 	var proba uintptr
  24655 	var rd_opt VP8RDLevel
  24656 	var v2 bool
  24657 	var _ /* info at bp+3904 */ VP8ModeScore
  24658 	var _ /* it at bp+0 */ VP8EncIterator
  24659 	var _ /* stats at bp+3848 */ PassStats
  24660 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  24661 	// Roughly refresh the proba eight times per pass
  24662 	max_count = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h >> int32(3)
  24663 	num_pass_left = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fpass
  24664 	remaining_progress = int32(40) // percents
  24665 	do_search = (*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search
  24666 	proba = enc + 3616
  24667 	rd_opt = (*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level
  24668 	pixel_count = libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w) * libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) * uint64(384)
  24669 	InitPassStats(tls, enc, bp+3848)
  24670 	ok = PreLoopInitialize(tls, enc)
  24671 	if !(ok != 0) {
  24672 		return 0
  24673 	}
  24674 	if max_count < int32(MIN_COUNT) {
  24675 		max_count = int32(MIN_COUNT)
  24676 	}
  24677 	// otherwise, token-buffer won't be useful
  24678 	for {
  24679 		if v2 = ok != 0; v2 {
  24680 			v1 = num_pass_left
  24681 			num_pass_left = num_pass_left - 1
  24682 		}
  24683 		if !(v2 && v1 > 0) {
  24684 			break
  24685 		}
  24686 		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)
  24687 		size_p0 = uint64(0)
  24688 		distortion = uint64(0)
  24689 		cnt = max_count
  24690 		// The final number of passes is not trivial to know in advance.
  24691 		pass_progress = remaining_progress / (int32(2) + num_pass_left)
  24692 		remaining_progress = remaining_progress - pass_progress
  24693 		VP8IteratorInit(tls, enc, bp)
  24694 		SetLoopParams(tls, enc, (**(**PassStats)(__ccgo_up(bp + 3848))).Fq)
  24695 		if is_last_pass != 0 {
  24696 			ResetTokenStats(tls, enc)
  24697 			VP8InitFilter(tls, bp) // don't collect stats until last pass (too costly)
  24698 		}
  24699 		VP8TBufferClear(tls, enc+496)
  24700 		for cond := true; cond; cond = ok != 0 && VP8IteratorNext(tls, bp) != 0 {
  24701 			VP8IteratorImport(tls, bp, libc.UintptrFromInt32(0))
  24702 			cnt = cnt - 1
  24703 			v1 = cnt
  24704 			if v1 < 0 {
  24705 				FinalizeTokenProbas(tls, proba)
  24706 				VP8CalculateLevelCosts(tls, proba) // refresh cost tables for rd-opt
  24707 				cnt = max_count
  24708 			}
  24709 			VP8Decimate(tls, bp, bp+3904, rd_opt)
  24710 			ok = RecordTokens(tls, bp, bp+3904, enc+496)
  24711 			if !(ok != 0) {
  24712 				WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  24713 				break
  24714 			}
  24715 			size_p0 = size_p0 + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3904))).FH)
  24716 			distortion = distortion + libc.Uint64FromInt64((**(**VP8ModeScore)(__ccgo_up(bp + 3904))).FD)
  24717 			if is_last_pass != 0 {
  24718 				StoreSideInfo(tls, bp)
  24719 				VP8StoreFilterStats(tls, bp)
  24720 				VP8IteratorExport(tls, bp)
  24721 				ok = VP8IteratorProgress(tls, bp, pass_progress)
  24722 			}
  24723 			VP8IteratorSaveBoundary(tls, bp)
  24724 		}
  24725 		if !(ok != 0) {
  24726 			break
  24727 		}
  24728 		size_p0 = size_p0 + libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fsize)
  24729 		if (**(**PassStats)(__ccgo_up(bp + 3848))).Fdo_size_search != 0 {
  24730 			size = libc.Uint64FromInt32(FinalizeTokenProbas(tls, enc+3616))
  24731 			size = size + VP8EstimateTokenSize(tls, enc+496, proba+4)
  24732 			size = (size + size_p0 + uint64(1024)) >> int32(11) // -> size in bytes
  24733 			size = size + libc.Uint64FromInt32(libc.Int32FromInt32(RIFF_HEADER_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)+libc.Int32FromInt32(VP8_FRAME_HEADER_SIZE))
  24734 			(**(**PassStats)(__ccgo_up(bp + 3848))).Fvalue = float64(size)
  24735 		} else { // compute and store PSNR
  24736 			(**(**PassStats)(__ccgo_up(bp + 3848))).Fvalue = GetPSNR(tls, distortion, pixel_count)
  24737 		}
  24738 		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) {
  24739 			num_pass_left = num_pass_left + 1
  24740 			**(**int32)(__ccgo_up(enc + 23624)) >>= int32(1) // strengthen header bit limitation...
  24741 			if is_last_pass != 0 {
  24742 				ResetSideInfo(tls, bp)
  24743 			}
  24744 			continue // ...and start over
  24745 		}
  24746 		if is_last_pass != 0 {
  24747 			break // done
  24748 		}
  24749 		if do_search != 0 {
  24750 			ComputeNextQ(tls, bp+3848) // Adjust q
  24751 		}
  24752 	}
  24753 	if ok != 0 {
  24754 		if !((**(**PassStats)(__ccgo_up(bp + 3848))).Fdo_size_search != 0) {
  24755 			FinalizeTokenProbas(tls, enc+3616)
  24756 		}
  24757 		ok = VP8EmitTokens(tls, enc+496, enc+112+uintptr(0)*48, proba+4, int32(1))
  24758 	}
  24759 	ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+remaining_progress, enc+536) != 0)
  24760 	return PostLoopFinalize(tls, bp, ok)
  24761 }
  24762 
  24763 const MAX_HISTO_GREEDY = 100
  24764 const NUM_PARTITIONS = 4
  24765 const __FLT_MIN__2 = 1.17549435082228750796873653722224568e-38
  24766 
  24767 //------------------------------------------------------------------------------
  24768 
  24769 // Copyright 2012 Google Inc. All Rights Reserved.
  24770 //
  24771 // Use of this source code is governed by a BSD-style license
  24772 // that can be found in the COPYING file in the root of the source
  24773 // tree. An additional intellectual property rights grant can be found
  24774 // in the file PATENTS. All contributing project authors may
  24775 // be found in the AUTHORS file in the root of the source tree.
  24776 // -----------------------------------------------------------------------------
  24777 //
  24778 // Misc. common utility functions
  24779 //
  24780 // Authors: Skal (pascal.massimino@gmail.com)
  24781 //          Urvang (urvang@google.com)
  24782 
  24783 // Copyright 2011 Google Inc. All Rights Reserved.
  24784 //
  24785 // Use of this source code is governed by a BSD-style license
  24786 // that can be found in the COPYING file in the root of the source
  24787 // tree. An additional intellectual property rights grant can be found
  24788 // in the file PATENTS. All contributing project authors may
  24789 // be found in the AUTHORS file in the root of the source tree.
  24790 // -----------------------------------------------------------------------------
  24791 //
  24792 //   WebP encoder: main interface
  24793 //
  24794 // Author: Skal (pascal.massimino@gmail.com)
  24795 
  24796 // Copyright 2012 Google Inc. All Rights Reserved.
  24797 //
  24798 // Use of this source code is governed by a BSD-style license
  24799 // that can be found in the COPYING file in the root of the source
  24800 // tree. An additional intellectual property rights grant can be found
  24801 // in the file PATENTS. All contributing project authors may
  24802 // be found in the AUTHORS file in the root of the source tree.
  24803 // -----------------------------------------------------------------------------
  24804 //
  24805 //  Internal header for constants related to WebP file format.
  24806 //
  24807 // Author: Urvang (urvang@google.com)
  24808 
  24809 // Copyright 2010 Google Inc. All Rights Reserved.
  24810 //
  24811 // Use of this source code is governed by a BSD-style license
  24812 // that can be found in the COPYING file in the root of the source
  24813 // tree. An additional intellectual property rights grant can be found
  24814 // in the file PATENTS. All contributing project authors may
  24815 // be found in the AUTHORS file in the root of the source tree.
  24816 // -----------------------------------------------------------------------------
  24817 //
  24818 //  Common types + memory wrappers
  24819 //
  24820 // Author: Skal (pascal.massimino@gmail.com)
  24821 
  24822 // Number of partitions for the three dominant (literal, red and blue) symbol
  24823 // costs.
  24824 // The size of the bin-hash corresponding to the three dominant costs.
  24825 // Maximum number of histograms allowed in greedy combining algorithm.
  24826 
  24827 // C documentation
  24828 //
  24829 //	// Enum to meaningfully access the elements of the Histogram arrays.
  24830 type HistogramIndex = int32
  24831 
  24832 const LITERAL = 0
  24833 const DISTANCE = 4
  24834 
  24835 // C documentation
  24836 //
  24837 //	// Return the size of the histogram for a given cache_bits.
  24838 func GetHistogramSize(tls *libc.TLS, cache_bits int32) (r int32) {
  24839 	var literal_size, v1, v2, v4 int32
  24840 	var total_size size_t
  24841 	_, _, _, _, _ = literal_size, total_size, v1, v2, v4
  24842 	v1 = cache_bits
  24843 	if v1 > 0 {
  24844 		v4 = int32(1) << v1
  24845 	} else {
  24846 		v4 = 0
  24847 	}
  24848 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  24849 	goto _3
  24850 _3:
  24851 	literal_size = v2
  24852 	total_size = uint64(3312) + uint64(4)*libc.Uint64FromInt32(literal_size)
  24853 	return libc.Int32FromUint64(total_size)
  24854 }
  24855 
  24856 func HistogramStatsClear(tls *libc.TLS, h uintptr) {
  24857 	var i int32
  24858 	_ = i
  24859 	i = 0
  24860 	for {
  24861 		if !(i < int32(5)) {
  24862 			break
  24863 		}
  24864 		**(**uint16_t)(__ccgo_up(h + 3244 + uintptr(i)*2)) = libc.Uint16FromInt32(libc.Int32FromInt32(0xffff))
  24865 		// By default, the histogram is assumed to be used.
  24866 		**(**uint8_t)(__ccgo_up(h + 3304 + uintptr(i))) = uint8(1)
  24867 		goto _1
  24868 	_1:
  24869 		;
  24870 		i = i + 1
  24871 	}
  24872 	(*VP8LHistogram)(unsafe.Pointer(h)).Fbit_cost = uint64(0)
  24873 	libc.X__builtin___memset_chk(tls, h+3264, 0, uint64(40), ^__predefined_size_t(0))
  24874 }
  24875 
  24876 func HistogramClear(tls *libc.TLS, h uintptr) {
  24877 	var cache_bits, histo_size int32
  24878 	var literal uintptr
  24879 	_, _, _ = cache_bits, histo_size, literal
  24880 	literal = (*VP8LHistogram)(unsafe.Pointer(h)).Fliteral
  24881 	cache_bits = (*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits
  24882 	histo_size = GetHistogramSize(tls, cache_bits)
  24883 	libc.X__builtin___memset_chk(tls, h, 0, libc.Uint64FromInt32(histo_size), ^__predefined_size_t(0))
  24884 	(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = cache_bits
  24885 	(*VP8LHistogram)(unsafe.Pointer(h)).Fliteral = literal
  24886 	HistogramStatsClear(tls, h)
  24887 }
  24888 
  24889 // C documentation
  24890 //
  24891 //	// Swap two histogram pointers.
  24892 func HistogramSwap(tls *libc.TLS, h1 uintptr, h2 uintptr) {
  24893 	var tmp uintptr
  24894 	_ = tmp
  24895 	tmp = **(**uintptr)(__ccgo_up(h1))
  24896 	**(**uintptr)(__ccgo_up(h1)) = **(**uintptr)(__ccgo_up(h2))
  24897 	**(**uintptr)(__ccgo_up(h2)) = tmp
  24898 }
  24899 
  24900 func HistogramCopy(tls *libc.TLS, src uintptr, dst uintptr) {
  24901 	var dst_cache_bits, histo_size, literal_size, v1, v2, v4 int32
  24902 	var dst_literal uintptr
  24903 	_, _, _, _, _, _, _ = dst_cache_bits, dst_literal, histo_size, literal_size, v1, v2, v4
  24904 	dst_literal = (*VP8LHistogram)(unsafe.Pointer(dst)).Fliteral
  24905 	dst_cache_bits = (*VP8LHistogram)(unsafe.Pointer(dst)).Fpalette_code_bits
  24906 	v1 = dst_cache_bits
  24907 	if v1 > 0 {
  24908 		v4 = int32(1) << v1
  24909 	} else {
  24910 		v4 = 0
  24911 	}
  24912 	v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  24913 	goto _3
  24914 _3:
  24915 	literal_size = v2
  24916 	histo_size = GetHistogramSize(tls, dst_cache_bits)
  24917 	libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(histo_size), ^__predefined_size_t(0))
  24918 	(*VP8LHistogram)(unsafe.Pointer(dst)).Fliteral = dst_literal
  24919 	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))
  24920 }
  24921 
  24922 func VP8LFreeHistogram(tls *libc.TLS, h uintptr) {
  24923 	WebPSafeFree(tls, h)
  24924 }
  24925 
  24926 func VP8LFreeHistogramSet(tls *libc.TLS, histograms uintptr) {
  24927 	WebPSafeFree(tls, histograms)
  24928 }
  24929 
  24930 func VP8LHistogramCreate(tls *libc.TLS, h uintptr, refs uintptr, palette_code_bits int32) {
  24931 	if palette_code_bits >= 0 {
  24932 		(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = palette_code_bits
  24933 	}
  24934 	HistogramClear(tls, h)
  24935 	VP8LHistogramStoreRefs(tls, refs, libc.UintptrFromInt32(0), 0, h)
  24936 }
  24937 
  24938 func VP8LHistogramInit(tls *libc.TLS, h uintptr, palette_code_bits int32, init_arrays int32) {
  24939 	(*VP8LHistogram)(unsafe.Pointer(h)).Fpalette_code_bits = palette_code_bits
  24940 	if init_arrays != 0 {
  24941 		HistogramClear(tls, h)
  24942 	} else {
  24943 		HistogramStatsClear(tls, h)
  24944 	}
  24945 }
  24946 
  24947 func VP8LAllocateHistogram(tls *libc.TLS, cache_bits int32) (r uintptr) {
  24948 	var histo, memory uintptr
  24949 	var total_size int32
  24950 	_, _, _ = histo, memory, total_size
  24951 	histo = libc.UintptrFromInt32(0)
  24952 	total_size = GetHistogramSize(tls, cache_bits)
  24953 	memory = WebPSafeMalloc(tls, libc.Uint64FromInt32(total_size), uint64(1))
  24954 	if memory == libc.UintptrFromInt32(0) {
  24955 		return libc.UintptrFromInt32(0)
  24956 	}
  24957 	histo = memory
  24958 	// 'literal' won't necessary be aligned.
  24959 	(*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral = memory + libc.UintptrFromInt64(3312)
  24960 	VP8LHistogramInit(tls, histo, cache_bits, 0)
  24961 	return histo
  24962 }
  24963 
  24964 // C documentation
  24965 //
  24966 //	// Resets the pointers of the histograms to point to the bit buffer in the set.
  24967 func HistogramSetResetPointers(tls *libc.TLS, set uintptr, cache_bits int32) {
  24968 	var histo_size, i int32
  24969 	var memory uintptr
  24970 	_, _, _ = histo_size, i, memory
  24971 	histo_size = GetHistogramSize(tls, cache_bits)
  24972 	memory = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms
  24973 	memory = memory + uintptr(libc.Uint64FromInt32((*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size)*uint64(8))
  24974 	i = 0
  24975 	for {
  24976 		if !(i < (*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size) {
  24977 			break
  24978 		}
  24979 		memory = uintptr((uint64(memory) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  24980 		**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)) = memory
  24981 		// 'literal' won't necessary be aligned.
  24982 		(*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)))).Fliteral = memory + libc.UintptrFromInt64(3312)
  24983 		memory = memory + uintptr(histo_size)
  24984 		goto _1
  24985 	_1:
  24986 		;
  24987 		i = i + 1
  24988 	}
  24989 }
  24990 
  24991 // C documentation
  24992 //
  24993 //	// Returns the total size of the VP8LHistogramSet.
  24994 func HistogramSetTotalSize(tls *libc.TLS, size int32, cache_bits int32) (r size_t) {
  24995 	var histo_size int32
  24996 	_ = histo_size
  24997 	histo_size = GetHistogramSize(tls, cache_bits)
  24998 	return libc.Uint64FromInt64(16) + libc.Uint64FromInt32(size)*(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(histo_size)+libc.Uint64FromInt32(WEBP_ALIGN_CST))
  24999 }
  25000 
  25001 func VP8LAllocateHistogramSet(tls *libc.TLS, size int32, cache_bits int32) (r uintptr) {
  25002 	var i int32
  25003 	var memory, set uintptr
  25004 	var total_size size_t
  25005 	_, _, _, _ = i, memory, set, total_size
  25006 	total_size = HistogramSetTotalSize(tls, size, cache_bits)
  25007 	memory = WebPSafeMalloc(tls, total_size, uint64(1))
  25008 	if memory == libc.UintptrFromInt32(0) {
  25009 		return libc.UintptrFromInt32(0)
  25010 	}
  25011 	set = memory
  25012 	memory = memory + uintptr(16)
  25013 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms = memory
  25014 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size = size
  25015 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = size
  25016 	HistogramSetResetPointers(tls, set, cache_bits)
  25017 	i = 0
  25018 	for {
  25019 		if !(i < size) {
  25020 			break
  25021 		}
  25022 		VP8LHistogramInit(tls, **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)), cache_bits, 0)
  25023 		goto _1
  25024 	_1:
  25025 		;
  25026 		i = i + 1
  25027 	}
  25028 	return set
  25029 }
  25030 
  25031 func VP8LHistogramSetClear(tls *libc.TLS, set uintptr) {
  25032 	var cache_bits, i, size int32
  25033 	var memory uintptr
  25034 	var total_size size_t
  25035 	_, _, _, _, _ = cache_bits, i, memory, size, total_size
  25036 	cache_bits = (*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms)))).Fpalette_code_bits
  25037 	size = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size
  25038 	total_size = HistogramSetTotalSize(tls, size, cache_bits)
  25039 	memory = set
  25040 	libc.X__builtin___memset_chk(tls, memory, 0, total_size, ^__predefined_size_t(0))
  25041 	memory = memory + uintptr(16)
  25042 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms = memory
  25043 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fmax_size = size
  25044 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = size
  25045 	HistogramSetResetPointers(tls, set, cache_bits)
  25046 	i = 0
  25047 	for {
  25048 		if !(i < size) {
  25049 			break
  25050 		}
  25051 		(*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(set)).Fhistograms + uintptr(i)*8)))).Fpalette_code_bits = cache_bits
  25052 		goto _1
  25053 	_1:
  25054 		;
  25055 		i = i + 1
  25056 	}
  25057 }
  25058 
  25059 // C documentation
  25060 //
  25061 //	// Removes the histogram 'i' from 'set'.
  25062 func HistogramSetRemoveHistogram(tls *libc.TLS, set uintptr, i int32) {
  25063 	**(**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))
  25064 	(*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize = (*VP8LHistogramSet)(unsafe.Pointer(set)).Fsize - 1
  25065 }
  25066 
  25067 // -----------------------------------------------------------------------------
  25068 
  25069 func HistogramAddSinglePixOrCopy(tls *libc.TLS, histo uintptr, v uintptr, __ccgo_fp_distance_modifier uintptr, distance_modifier_arg0 int32) {
  25070 	bp := tls.Alloc(16)
  25071 	defer tls.Free(16)
  25072 	var highest_bit, literal_ix, second_highest_bit, v1, v11, v17, v20 int32
  25073 	var prefix_code VP8LPrefixCode
  25074 	var v3 uint32_t
  25075 	var v18, v19 uintptr
  25076 	var _ /* code at bp+0 */ int32
  25077 	var _ /* extra_bits at bp+4 */ int32
  25078 	_, _, _, _, _, _, _, _, _, _, _ = highest_bit, literal_ix, prefix_code, second_highest_bit, v1, v11, v17, v18, v19, v20, v3
  25079 	v1 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  25080 	goto _2
  25081 _2:
  25082 	if v1 != 0 {
  25083 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(3) * libc.Int32FromInt32(8)) & uint32(0xff)
  25084 		goto _4
  25085 	_4:
  25086 		**(**uint32_t)(__ccgo_up(histo + 2056 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 2056 + uintptr(v3)*4)) + 1
  25087 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(2) * libc.Int32FromInt32(8)) & uint32(0xff)
  25088 		goto _6
  25089 	_6:
  25090 		**(**uint32_t)(__ccgo_up(histo + 8 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 8 + uintptr(v3)*4)) + 1
  25091 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (int32(1) * libc.Int32FromInt32(8)) & uint32(0xff)
  25092 		goto _8
  25093 	_8:
  25094 		**(**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
  25095 		v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (0 * libc.Int32FromInt32(8)) & uint32(0xff)
  25096 		goto _10
  25097 	_10:
  25098 		**(**uint32_t)(__ccgo_up(histo + 1032 + uintptr(v3)*4)) = **(**uint32_t)(__ccgo_up(histo + 1032 + uintptr(v3)*4)) + 1
  25099 	} else {
  25100 		v1 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kCacheIdx))
  25101 		goto _12
  25102 	_12:
  25103 		if v1 != 0 {
  25104 			v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25105 			goto _14
  25106 		_14:
  25107 			literal_ix = libc.Int32FromUint32(libc.Uint32FromInt32(libc.Int32FromInt32(NUM_LITERAL_CODES)+libc.Int32FromInt32(NUM_LENGTH_CODES)) + v3)
  25108 			**(**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
  25109 		} else {
  25110 			v3 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  25111 			goto _16
  25112 		_16:
  25113 			v1 = libc.Int32FromUint32(v3)
  25114 			v18 = bp
  25115 			v19 = bp + 4
  25116 			if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25117 				prefix_code = kPrefixEncodeCode[v1]
  25118 				**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25119 				**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25120 			} else {
  25121 				v11 = v1
  25122 				v11 = v11 - 1
  25123 				v17 = v11
  25124 				v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25125 				goto _23
  25126 			_23:
  25127 				highest_bit = v20
  25128 				second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25129 				**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25130 				**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25131 			}
  25132 			**(**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
  25133 			if __ccgo_fp_distance_modifier == libc.UintptrFromInt32(0) {
  25134 				v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25135 				goto _25
  25136 			_25:
  25137 				v1 = libc.Int32FromUint32(v3)
  25138 				v18 = bp
  25139 				v19 = bp + 4
  25140 				if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25141 					prefix_code = kPrefixEncodeCode[v1]
  25142 					**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25143 					**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25144 				} else {
  25145 					v11 = v1
  25146 					v11 = v11 - 1
  25147 					v17 = v11
  25148 					v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25149 					goto _32
  25150 				_32:
  25151 					highest_bit = v20
  25152 					second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25153 					**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25154 					**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25155 				}
  25156 			} else {
  25157 				v3 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  25158 				goto _34
  25159 			_34:
  25160 				v1 = (*(*func(*libc.TLS, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_distance_modifier})))(tls, distance_modifier_arg0, libc.Int32FromUint32(v3))
  25161 				v18 = bp
  25162 				v19 = bp + 4
  25163 				if v1 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  25164 					prefix_code = kPrefixEncodeCode[v1]
  25165 					**(**int32)(__ccgo_up(v18)) = int32(prefix_code.Fcode)
  25166 					**(**int32)(__ccgo_up(v19)) = int32(prefix_code.Fextra_bits)
  25167 				} else {
  25168 					v11 = v1
  25169 					v11 = v11 - 1
  25170 					v17 = v11
  25171 					v20 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v17))
  25172 					goto _41
  25173 				_41:
  25174 					highest_bit = v20
  25175 					second_highest_bit = v11 >> (highest_bit - int32(1)) & int32(1)
  25176 					**(**int32)(__ccgo_up(v19)) = highest_bit - int32(1)
  25177 					**(**int32)(__ccgo_up(v18)) = int32(2)*highest_bit + second_highest_bit
  25178 				}
  25179 			}
  25180 			**(**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
  25181 		}
  25182 	}
  25183 }
  25184 
  25185 type __ccgo_fp__XVP8LHistogramStoreRefs_1 = func(*libc.TLS, int32, int32) int32
  25186 
  25187 func VP8LHistogramStoreRefs(tls *libc.TLS, refs uintptr, __ccgo_fp_distance_modifier uintptr, distance_modifier_arg0 int32, histo uintptr) {
  25188 	bp := tls.Alloc(32)
  25189 	defer tls.Free(32)
  25190 	var v1 int32
  25191 	var v3, v4, v5 uintptr
  25192 	var _ /* c at bp+0 */ VP8LRefsCursor
  25193 	_, _, _, _ = v1, v3, v4, v5
  25194 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  25195 	for {
  25196 		v1 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  25197 		goto _2
  25198 	_2:
  25199 		if !(v1 != 0) {
  25200 			break
  25201 		}
  25202 		HistogramAddSinglePixOrCopy(tls, histo, (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos, __ccgo_fp_distance_modifier, distance_modifier_arg0)
  25203 		v3 = bp
  25204 		v5 = v3
  25205 		*(*uintptr)(unsafe.Pointer(v5)) += 8
  25206 		v4 = *(*uintptr)(unsafe.Pointer(v5))
  25207 		if v4 == (*VP8LRefsCursor)(unsafe.Pointer(v3)).Flast_pos {
  25208 			VP8LRefsCursorNextBlock(tls, v3)
  25209 		}
  25210 	}
  25211 }
  25212 
  25213 // -----------------------------------------------------------------------------
  25214 // Entropy-related functions.
  25215 
  25216 func BitsEntropyRefine(tls *libc.TLS, entropy uintptr) (r uint64_t) {
  25217 	var min_limit, mix uint64_t
  25218 	var v1, v2, v3 int64_t
  25219 	var v5 int64
  25220 	var v11 uint64
  25221 	_, _, _, _, _, _, _ = min_limit, mix, v1, v11, v2, v3, v5
  25222 	if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros < int32(5) {
  25223 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros <= int32(1) {
  25224 			return uint64(0)
  25225 		}
  25226 		// Two symbols, they will be 0 and 1 in a Huffman code.
  25227 		// Let's mix in a bit of entropy to favor good clustering when
  25228 		// distributions of these are combined.
  25229 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros == int32(2) {
  25230 			v1 = libc.Int64FromUint64(uint64(99)*(uint64((*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)) + (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy)
  25231 			v2 = int64(100)
  25232 			if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25233 				v5 = (v1 + v2/int64(2)) / v2
  25234 			} else {
  25235 				v5 = (v1 - v2/int64(2)) / v2
  25236 			}
  25237 			v3 = v5
  25238 			goto _4
  25239 		_4:
  25240 			return libc.Uint64FromInt64(v3)
  25241 		}
  25242 		// No matter what the entropy says, we cannot be better than min_limit
  25243 		// with Huffman coding. I am mixing a bit of entropy into the
  25244 		// min_limit since it produces much better (~0.5 %) compression results
  25245 		// perhaps because of better entropy clustering.
  25246 		if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros == int32(3) {
  25247 			mix = uint64(950)
  25248 		} else {
  25249 			mix = uint64(700) // nonzeros == 4.
  25250 		}
  25251 	} else {
  25252 		mix = uint64(627)
  25253 	}
  25254 	min_limit = uint64(libc.Uint32FromInt32(2)*(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum-(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val) << int32(LOG_2_PRECISION_BITS)
  25255 	v1 = libc.Int64FromUint64(mix*min_limit + (uint64(1000)-mix)*(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy)
  25256 	v2 = int64(1000)
  25257 	if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25258 		v5 = (v1 + v2/int64(2)) / v2
  25259 	} else {
  25260 		v5 = (v1 - v2/int64(2)) / v2
  25261 	}
  25262 	v3 = v5
  25263 	goto _9
  25264 _9:
  25265 	min_limit = libc.Uint64FromInt64(v3)
  25266 	if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy < min_limit {
  25267 		v11 = min_limit
  25268 	} else {
  25269 		v11 = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy
  25270 	}
  25271 	return v11
  25272 	return r
  25273 }
  25274 
  25275 func VP8LBitsEntropy(tls *libc.TLS, array uintptr, n int32) (r uint64_t) {
  25276 	bp := tls.Alloc(32)
  25277 	defer tls.Free(32)
  25278 	var _ /* entropy at bp+0 */ VP8LBitEntropy
  25279 	VP8LBitsEntropyUnrefined(tls, array, n, bp)
  25280 	return BitsEntropyRefine(tls, bp)
  25281 }
  25282 
  25283 func InitialHuffmanCost(tls *libc.TLS) (r uint64_t) {
  25284 	var v1, v2, v3 int64_t
  25285 	var v5 int64
  25286 	_, _, _, _ = v1, v2, v3, v5
  25287 	// Subtract a bias of 9.1.
  25288 	v1 = libc.Int64FromInt64(91) << libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  25289 	v2 = int64(10)
  25290 	if libc.BoolInt32(v1 < 0) == libc.BoolInt32(v2 < 0) {
  25291 		v5 = (v1 + v2/int64(2)) / v2
  25292 	} else {
  25293 		v5 = (v1 - v2/int64(2)) / v2
  25294 	}
  25295 	v3 = v5
  25296 	goto _4
  25297 _4:
  25298 	return kHuffmanCodeOfHuffmanCodeSize<<libc.Int32FromInt32(LOG_2_PRECISION_BITS) - libc.Uint64FromInt64(v3)
  25299 }
  25300 
  25301 // Small bias because Huffman code length is typically not stored in
  25302 // full length.
  25303 var kHuffmanCodeOfHuffmanCodeSize = libc.Uint64FromInt32(libc.Int32FromInt32(CODE_LENGTH_CODES) * libc.Int32FromInt32(3))
  25304 
  25305 // C documentation
  25306 //
  25307 //	// Finalize the Huffman cost based on streak numbers and length type (<3 or >=3)
  25308 func FinalHuffmanCost(tls *libc.TLS, stats uintptr) (r uint64_t) {
  25309 	var retval uint64_t
  25310 	var retval_extra uint32_t
  25311 	_, _ = retval, retval_extra
  25312 	// The constants in this function are empirical and got rounded from
  25313 	// their original values in 1/8 when switched to 1/1024.
  25314 	retval = InitialHuffmanCost(tls)
  25315 	// Second coefficient: Many zeros in the histogram are covered efficiently
  25316 	// by a run-length encode. Originally 2/8.
  25317 	retval_extra = libc.Uint32FromInt32(**(**int32)(__ccgo_up(stats))*int32(1600) + int32(240)***(**int32)(__ccgo_up(stats + 8 + 1*4)))
  25318 	// Second coefficient: Constant values are encoded less efficiently, but still
  25319 	// RLE'ed. Originally 6/8.
  25320 	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)))
  25321 	// 0s are usually encoded more efficiently than non-0s.
  25322 	// Originally 15/8.
  25323 	retval_extra = retval_extra + libc.Uint32FromInt32(int32(1840)***(**int32)(__ccgo_up(stats + 8)))
  25324 	// Originally 26/8.
  25325 	retval_extra = retval_extra + libc.Uint32FromInt32(int32(3360)***(**int32)(__ccgo_up(stats + 8 + 1*8)))
  25326 	return retval + uint64(retval_extra)<<(libc.Int32FromInt32(LOG_2_PRECISION_BITS)-libc.Int32FromInt32(10))
  25327 }
  25328 
  25329 // C documentation
  25330 //
  25331 //	// Get the symbol entropy for the distribution 'population'.
  25332 //	// Set 'trivial_sym', if there's only one symbol present in the distribution.
  25333 func PopulationCost(tls *libc.TLS, population uintptr, length int32, trivial_sym uintptr, is_used uintptr) (r uint64_t) {
  25334 	bp := tls.Alloc(48)
  25335 	defer tls.Free(48)
  25336 	var v1 uint32
  25337 	var _ /* bit_entropy at bp+0 */ VP8LBitEntropy
  25338 	var _ /* stats at bp+24 */ VP8LStreaks
  25339 	_ = v1
  25340 	(*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LGetEntropyUnrefined})))(tls, population, length, bp, bp+24)
  25341 	if trivial_sym != libc.UintptrFromInt32(0) {
  25342 		if (**(**VP8LBitEntropy)(__ccgo_up(bp))).Fnonzeros == int32(1) {
  25343 			v1 = (**(**VP8LBitEntropy)(__ccgo_up(bp))).Fnonzero_code
  25344 		} else {
  25345 			v1 = uint32(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  25346 		}
  25347 		**(**uint16_t)(__ccgo_up(trivial_sym)) = uint16(v1)
  25348 	}
  25349 	if is_used != libc.UintptrFromInt32(0) {
  25350 		// The histogram is used if there is at least one non-zero streak.
  25351 		**(**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)
  25352 	}
  25353 	return BitsEntropyRefine(tls, bp) + FinalHuffmanCost(tls, bp+24)
  25354 }
  25355 
  25356 func GetPopulationInfo(tls *libc.TLS, histo uintptr, index HistogramIndex, population uintptr, length uintptr) {
  25357 	var v1, v2, v4 int32
  25358 	_, _, _ = v1, v2, v4
  25359 	switch index {
  25360 	case int32(LITERAL):
  25361 		**(**uintptr)(__ccgo_up(population)) = (*VP8LHistogram)(unsafe.Pointer(histo)).Fliteral
  25362 		v1 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  25363 		if v1 > 0 {
  25364 			v4 = int32(1) << v1
  25365 		} else {
  25366 			v4 = 0
  25367 		}
  25368 		v2 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v4
  25369 		goto _3
  25370 	_3:
  25371 		**(**int32)(__ccgo_up(length)) = v2
  25372 	case int32(RED):
  25373 		**(**uintptr)(__ccgo_up(population)) = histo + 8
  25374 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25375 	case int32(BLUE):
  25376 		**(**uintptr)(__ccgo_up(population)) = histo + 1032
  25377 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25378 	case int32(ALPHA):
  25379 		**(**uintptr)(__ccgo_up(population)) = histo + 2056
  25380 		**(**int32)(__ccgo_up(length)) = int32(NUM_LITERAL_CODES)
  25381 	case int32(DISTANCE):
  25382 		**(**uintptr)(__ccgo_up(population)) = histo + 3080
  25383 		**(**int32)(__ccgo_up(length)) = int32(NUM_DISTANCE_CODES)
  25384 		break
  25385 	}
  25386 }
  25387 
  25388 // C documentation
  25389 //
  25390 //	// trivial_at_end is 1 if the two histograms only have one element that is
  25391 //	// non-zero: both the zero-th one, or both the last one.
  25392 //	// 'index' is the index of the symbol in the histogram (literal, red, blue,
  25393 //	// alpha, distance).
  25394 func GetCombinedEntropy(tls *libc.TLS, h1 uintptr, h2 uintptr, index HistogramIndex) (r uint64_t) {
  25395 	bp := tls.Alloc(80)
  25396 	defer tls.Free(80)
  25397 	var is_h1_used, is_h2_used, is_trivial int32
  25398 	var _ /* X at bp+0 */ uintptr
  25399 	var _ /* Y at bp+8 */ uintptr
  25400 	var _ /* bit_entropy at bp+48 */ VP8LBitEntropy
  25401 	var _ /* length at bp+16 */ int32
  25402 	var _ /* stats at bp+20 */ VP8LStreaks
  25403 	_, _, _ = is_h1_used, is_h2_used, is_trivial
  25404 	is_h1_used = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(index))))
  25405 	is_h2_used = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(index))))
  25406 	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))))
  25407 	if is_trivial != 0 || !(is_h1_used != 0) || !(is_h2_used != 0) {
  25408 		if is_h1_used != 0 {
  25409 			return **(**uint64_t)(__ccgo_up(h1 + 3264 + uintptr(index)*8))
  25410 		}
  25411 		return **(**uint64_t)(__ccgo_up(h2 + 3264 + uintptr(index)*8))
  25412 	}
  25413 	GetPopulationInfo(tls, h1, index, bp, bp+16)
  25414 	GetPopulationInfo(tls, h2, index, bp+8, bp+16)
  25415 	(*(*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)
  25416 	return BitsEntropyRefine(tls, bp+48) + FinalHuffmanCost(tls, bp+20)
  25417 }
  25418 
  25419 // C documentation
  25420 //
  25421 //	// Estimates the Entropy + Huffman + other block overhead size cost.
  25422 func VP8LHistogramEstimateBits(tls *libc.TLS, h uintptr) (r uint64_t) {
  25423 	bp := tls.Alloc(16)
  25424 	defer tls.Free(16)
  25425 	var cost uint64_t
  25426 	var i int32
  25427 	var _ /* length at bp+0 */ int32
  25428 	var _ /* population at bp+8 */ uintptr
  25429 	_, _ = cost, i
  25430 	cost = uint64(0)
  25431 	i = 0
  25432 	for {
  25433 		if !(i < int32(5)) {
  25434 			break
  25435 		}
  25436 		GetPopulationInfo(tls, h, i, bp+8, bp)
  25437 		cost = cost + PopulationCost(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp)), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0))
  25438 		goto _1
  25439 	_1:
  25440 		;
  25441 		i = i + 1
  25442 	}
  25443 	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)
  25444 	return cost
  25445 }
  25446 
  25447 // -----------------------------------------------------------------------------
  25448 // Various histogram combine/cost-eval functions
  25449 
  25450 // C documentation
  25451 //
  25452 //	// Set a + b in b, saturating at WEBP_INT64_MAX.
  25453 func SaturateAdd(tls *libc.TLS, a uint64_t, b uintptr) {
  25454 	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)) {
  25455 		**(**int64_t)(__ccgo_up(b)) += libc.Int64FromUint64(a)
  25456 	} else {
  25457 		**(**int64_t)(__ccgo_up(b)) = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  25458 	}
  25459 }
  25460 
  25461 // C documentation
  25462 //
  25463 //	// Returns 1 if the cost of the combined histogram is less than the threshold.
  25464 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25465 func GetCombinedHistogramEntropy(tls *libc.TLS, a uintptr, b uintptr, cost_threshold_in int64_t, cost uintptr, costs uintptr) (r int32) {
  25466 	var cost_threshold uint64_t
  25467 	var i int32
  25468 	_, _ = cost_threshold, i
  25469 	cost_threshold = libc.Uint64FromInt64(cost_threshold_in)
  25470 	if cost_threshold_in <= 0 {
  25471 		return 0
  25472 	}
  25473 	**(**uint64_t)(__ccgo_up(cost)) = uint64(0)
  25474 	// No need to add the extra cost for length and distance as it is a constant
  25475 	// that does not influence the histograms.
  25476 	i = 0
  25477 	for {
  25478 		if !(i < int32(5)) {
  25479 			break
  25480 		}
  25481 		**(**uint64_t)(__ccgo_up(costs + uintptr(i)*8)) = GetCombinedEntropy(tls, a, b, i)
  25482 		**(**uint64_t)(__ccgo_up(cost)) += **(**uint64_t)(__ccgo_up(costs + uintptr(i)*8))
  25483 		if **(**uint64_t)(__ccgo_up(cost)) >= cost_threshold {
  25484 			return 0
  25485 		}
  25486 		goto _1
  25487 	_1:
  25488 		;
  25489 		i = i + 1
  25490 	}
  25491 	return int32(1)
  25492 }
  25493 
  25494 func HistogramAdd(tls *libc.TLS, h1 uintptr, h2 uintptr, hout uintptr) {
  25495 	bp := tls.Alloc(32)
  25496 	defer tls.Free(32)
  25497 	var i, v3 int32
  25498 	var pout uintptr
  25499 	var _ /* length at bp+0 */ int32
  25500 	var _ /* p1 at bp+8 */ uintptr
  25501 	var _ /* p2 at bp+16 */ uintptr
  25502 	var _ /* pout_const at bp+24 */ uintptr
  25503 	_, _, _ = i, pout, v3
  25504 	i = 0
  25505 	for {
  25506 		if !(i < int32(5)) {
  25507 			break
  25508 		}
  25509 		GetPopulationInfo(tls, h1, i, bp+8, bp)
  25510 		GetPopulationInfo(tls, h2, i, bp+16, bp)
  25511 		GetPopulationInfo(tls, hout, i, bp+24, bp)
  25512 		pout = **(**uintptr)(__ccgo_up(bp + 24))
  25513 		if h2 == hout {
  25514 			if **(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(i))) != 0 {
  25515 				if **(**uint8_t)(__ccgo_up(hout + 3304 + uintptr(i))) != 0 {
  25516 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVectorEq})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), pout, **(**int32)(__ccgo_up(bp)))
  25517 				} else {
  25518 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 8)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25519 				}
  25520 			}
  25521 		} else {
  25522 			if **(**uint8_t)(__ccgo_up(h1 + 3304 + uintptr(i))) != 0 {
  25523 				if **(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(i))) != 0 {
  25524 					(*(*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)))
  25525 				} else {
  25526 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 8)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25527 				}
  25528 			} else {
  25529 				if **(**uint8_t)(__ccgo_up(h2 + 3304 + uintptr(i))) != 0 {
  25530 					libc.X__builtin___memcpy_chk(tls, pout, **(**uintptr)(__ccgo_up(bp + 16)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25531 				} else {
  25532 					libc.X__builtin___memset_chk(tls, pout, 0, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), ^__predefined_size_t(0))
  25533 				}
  25534 			}
  25535 		}
  25536 		goto _1
  25537 	_1:
  25538 		;
  25539 		i = i + 1
  25540 	}
  25541 	i = 0
  25542 	for {
  25543 		if !(i < int32(5)) {
  25544 			break
  25545 		}
  25546 		if libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(i)*2))) == libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h2 + 3244 + uintptr(i)*2))) {
  25547 			v3 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(h1 + 3244 + uintptr(i)*2)))
  25548 		} else {
  25549 			v3 = libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  25550 		}
  25551 		**(**uint16_t)(__ccgo_up(hout + 3244 + uintptr(i)*2)) = libc.Uint16FromInt32(v3)
  25552 		**(**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)
  25553 		goto _2
  25554 	_2:
  25555 		;
  25556 		i = i + 1
  25557 	}
  25558 }
  25559 
  25560 func UpdateHistogramCost(tls *libc.TLS, bit_cost uint64_t, costs uintptr, h uintptr) {
  25561 	var i int32
  25562 	_ = i
  25563 	(*VP8LHistogram)(unsafe.Pointer(h)).Fbit_cost = bit_cost
  25564 	i = 0
  25565 	for {
  25566 		if !(i < int32(5)) {
  25567 			break
  25568 		}
  25569 		**(**uint64_t)(__ccgo_up(h + 3264 + uintptr(i)*8)) = **(**uint64_t)(__ccgo_up(costs + uintptr(i)*8))
  25570 		goto _1
  25571 	_1:
  25572 		;
  25573 		i = i + 1
  25574 	}
  25575 }
  25576 
  25577 // C documentation
  25578 //
  25579 //	// Performs out = a + b, computing the cost C(a+b) - C(a) - C(b) while comparing
  25580 //	// to the threshold value 'cost_threshold'. The score returned is
  25581 //	//  Score = C(a+b) - C(a) - C(b), where C(a) + C(b) is known and fixed.
  25582 //	// Since the previous score passed is 'cost_threshold', we only need to compare
  25583 //	// the partial cost against 'cost_threshold + C(a) + C(b)' to possibly bail-out
  25584 //	// early.
  25585 //	// Returns 1 if the cost is less than the threshold.
  25586 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25587 func HistogramAddEval(tls *libc.TLS, a uintptr, b uintptr, out uintptr, _cost_threshold int64_t) (r int32) {
  25588 	bp := tls.Alloc(64)
  25589 	defer tls.Free(64)
  25590 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  25591 	var sum_cost uint64_t
  25592 	var _ /* bit_cost at bp+8 */ uint64_t
  25593 	var _ /* costs at bp+16 */ [5]uint64_t
  25594 	_ = sum_cost
  25595 	sum_cost = (*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost + (*VP8LHistogram)(unsafe.Pointer(b)).Fbit_cost
  25596 	SaturateAdd(tls, sum_cost, bp)
  25597 	if !(GetCombinedHistogramEntropy(tls, a, b, **(**int64_t)(__ccgo_up(bp)), bp+8, bp+16) != 0) {
  25598 		return 0
  25599 	}
  25600 	HistogramAdd(tls, a, b, out)
  25601 	UpdateHistogramCost(tls, **(**uint64_t)(__ccgo_up(bp + 8)), bp+16, out)
  25602 	return int32(1)
  25603 }
  25604 
  25605 // C documentation
  25606 //
  25607 //	// Same as HistogramAddEval(), except that the resulting histogram
  25608 //	// is not stored. Only the cost C(a+b) - C(a) is evaluated. We omit
  25609 //	// the term C(b) which is constant over all the evaluations.
  25610 //	// Returns 1 if the cost is less than the threshold.
  25611 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  25612 func HistogramAddThresh(tls *libc.TLS, a uintptr, b uintptr, _cost_threshold int64_t, cost_out uintptr) (r int32) {
  25613 	bp := tls.Alloc(64)
  25614 	defer tls.Free(64)
  25615 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  25616 	var _ /* cost at bp+8 */ uint64_t
  25617 	var _ /* costs at bp+16 */ [5]uint64_t
  25618 	SaturateAdd(tls, (*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost, bp)
  25619 	if !(GetCombinedHistogramEntropy(tls, a, b, **(**int64_t)(__ccgo_up(bp)), bp+8, bp+16) != 0) {
  25620 		return 0
  25621 	}
  25622 	**(**int64_t)(__ccgo_up(cost_out)) = libc.Int64FromUint64(**(**uint64_t)(__ccgo_up(bp + 8))) - libc.Int64FromUint64((*VP8LHistogram)(unsafe.Pointer(a)).Fbit_cost)
  25623 	return int32(1)
  25624 }
  25625 
  25626 // -----------------------------------------------------------------------------
  25627 
  25628 // C documentation
  25629 //
  25630 //	// The structure to keep track of cost range for the three dominant entropy
  25631 //	// symbols.
  25632 type DominantCostRange = struct {
  25633 	Fliteral_max uint64_t
  25634 	Fliteral_min uint64_t
  25635 	Fred_max     uint64_t
  25636 	Fred_min     uint64_t
  25637 	Fblue_max    uint64_t
  25638 	Fblue_min    uint64_t
  25639 }
  25640 
  25641 func DominantCostRangeInit(tls *libc.TLS, c uintptr) {
  25642 	(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max = uint64(0)
  25643 	(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min = ^libc.Uint64FromUint64(0)
  25644 	(*DominantCostRange)(unsafe.Pointer(c)).Fred_max = uint64(0)
  25645 	(*DominantCostRange)(unsafe.Pointer(c)).Fred_min = ^libc.Uint64FromUint64(0)
  25646 	(*DominantCostRange)(unsafe.Pointer(c)).Fblue_max = uint64(0)
  25647 	(*DominantCostRange)(unsafe.Pointer(c)).Fblue_min = ^libc.Uint64FromUint64(0)
  25648 }
  25649 
  25650 func UpdateDominantCostRange(tls *libc.TLS, h uintptr, c uintptr) {
  25651 	if (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)) {
  25652 		(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8))
  25653 	}
  25654 	if (*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8)) {
  25655 		(*DominantCostRange)(unsafe.Pointer(c)).Fliteral_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(LITERAL)*8))
  25656 	}
  25657 	if (*DominantCostRange)(unsafe.Pointer(c)).Fred_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)) {
  25658 		(*DominantCostRange)(unsafe.Pointer(c)).Fred_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8))
  25659 	}
  25660 	if (*DominantCostRange)(unsafe.Pointer(c)).Fred_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8)) {
  25661 		(*DominantCostRange)(unsafe.Pointer(c)).Fred_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(RED)*8))
  25662 	}
  25663 	if (*DominantCostRange)(unsafe.Pointer(c)).Fblue_max < **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)) {
  25664 		(*DominantCostRange)(unsafe.Pointer(c)).Fblue_max = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8))
  25665 	}
  25666 	if (*DominantCostRange)(unsafe.Pointer(c)).Fblue_min > **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8)) {
  25667 		(*DominantCostRange)(unsafe.Pointer(c)).Fblue_min = **(**uint64_t)(__ccgo_up(h + 3264 + uintptr(BLUE)*8))
  25668 	}
  25669 }
  25670 
  25671 func ComputeHistogramCost(tls *libc.TLS, h uintptr) {
  25672 	bp := tls.Alloc(16)
  25673 	defer tls.Free(16)
  25674 	var i int32
  25675 	var _ /* length at bp+8 */ int32
  25676 	var _ /* population at bp+0 */ uintptr
  25677 	_ = i
  25678 	// No need to add the extra cost for length and distance as it is a constant
  25679 	// that does not influence the histograms.
  25680 	i = 0
  25681 	for {
  25682 		if !(i < int32(5)) {
  25683 			break
  25684 		}
  25685 		GetPopulationInfo(tls, h, i, bp, bp+8)
  25686 		**(**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))
  25687 		goto _1
  25688 	_1:
  25689 		;
  25690 		i = i + 1
  25691 	}
  25692 	(*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))
  25693 }
  25694 
  25695 func GetBinIdForEntropy(tls *libc.TLS, min uint64_t, max uint64_t, val uint64_t) (r int32) {
  25696 	var delta, range1 uint64_t
  25697 	_, _ = delta, range1
  25698 	range1 = max - min
  25699 	if range1 > uint64(0) {
  25700 		delta = val - min
  25701 		return int32(float64((libc.Float64FromInt32(NUM_PARTITIONS)-libc.Float64FromFloat64(1e-06))*float64(delta)) / float64(range1))
  25702 	} else {
  25703 		return 0
  25704 	}
  25705 	return r
  25706 }
  25707 
  25708 func GetHistoBinIndex(tls *libc.TLS, h uintptr, c uintptr, low_effort int32) (r int32) {
  25709 	var bin_id int32
  25710 	_ = bin_id
  25711 	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)))
  25712 	if !(low_effort != 0) {
  25713 		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)))
  25714 		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)))
  25715 	}
  25716 	return bin_id
  25717 }
  25718 
  25719 // C documentation
  25720 //
  25721 //	// Construct the histograms from backward references.
  25722 func HistogramBuild(tls *libc.TLS, xsize int32, histo_bits int32, backward_refs uintptr, image_histo uintptr) {
  25723 	bp := tls.Alloc(32)
  25724 	defer tls.Free(32)
  25725 	var histo_xsize, ix, x, y, v4 int32
  25726 	var histograms, v, v10, v8, v9 uintptr
  25727 	var v1, v2 uint32_t
  25728 	var _ /* c at bp+0 */ VP8LRefsCursor
  25729 	_, _, _, _, _, _, _, _, _, _, _, _ = histo_xsize, histograms, ix, v, x, y, v1, v10, v2, v4, v8, v9
  25730 	x = 0
  25731 	y = 0
  25732 	v1 = libc.Uint32FromInt32(histo_bits)
  25733 	v2 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  25734 	goto _3
  25735 _3:
  25736 	histo_xsize = libc.Int32FromUint32(v2)
  25737 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25738 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, backward_refs)
  25739 	VP8LHistogramSetClear(tls, image_histo)
  25740 	for {
  25741 		v4 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  25742 		goto _5
  25743 	_5:
  25744 		if !(v4 != 0) {
  25745 			break
  25746 		}
  25747 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos
  25748 		ix = y>>histo_bits*histo_xsize + x>>histo_bits
  25749 		HistogramAddSinglePixOrCopy(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(ix)*8)), v, libc.UintptrFromInt32(0), 0)
  25750 		v1 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  25751 		goto _7
  25752 	_7:
  25753 		x = libc.Int32FromUint32(uint32(x) + v1)
  25754 		for x >= xsize {
  25755 			x = x - xsize
  25756 			y = y + 1
  25757 		}
  25758 		v8 = bp
  25759 		v10 = v8
  25760 		*(*uintptr)(unsafe.Pointer(v10)) += 8
  25761 		v9 = *(*uintptr)(unsafe.Pointer(v10))
  25762 		if v9 == (*VP8LRefsCursor)(unsafe.Pointer(v8)).Flast_pos {
  25763 			VP8LRefsCursorNextBlock(tls, v8)
  25764 		}
  25765 	}
  25766 }
  25767 
  25768 // C documentation
  25769 //
  25770 //	// Copies the histograms and computes its bit_cost.
  25771 func HistogramCopyAndAnalyze(tls *libc.TLS, orig_histo uintptr, image_histo uintptr) {
  25772 	var histo, histograms, orig_histograms uintptr
  25773 	var i int32
  25774 	_, _, _, _ = histo, histograms, i, orig_histograms
  25775 	orig_histograms = (*VP8LHistogramSet)(unsafe.Pointer(orig_histo)).Fhistograms
  25776 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25777 	(*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize = 0
  25778 	i = 0
  25779 	for {
  25780 		if !(i < (*VP8LHistogramSet)(unsafe.Pointer(orig_histo)).Fmax_size) {
  25781 			break
  25782 		}
  25783 		histo = **(**uintptr)(__ccgo_up(orig_histograms + uintptr(i)*8))
  25784 		ComputeHistogramCost(tls, histo)
  25785 		// Skip the histogram if it is completely empty, which can happen for tiles
  25786 		// with no information (when they are skipped because of LZ77).
  25787 		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) {
  25788 			// The first histogram is always used.
  25789 			**(**uintptr)(__ccgo_up(orig_histograms + uintptr(i)*8)) = libc.UintptrFromInt32(0)
  25790 		} else {
  25791 			// Copy histograms from orig_histo[] to image_histo[].
  25792 			HistogramCopy(tls, histo, **(**uintptr)(__ccgo_up(histograms + uintptr((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize)*8)))
  25793 			(*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize + 1
  25794 		}
  25795 		goto _1
  25796 	_1:
  25797 		;
  25798 		i = i + 1
  25799 	}
  25800 }
  25801 
  25802 // C documentation
  25803 //
  25804 //	// Partition histograms to different entropy bins for three dominant (literal,
  25805 //	// red and blue) symbol costs and compute the histogram aggregate bit_cost.
  25806 func HistogramAnalyzeEntropyBin(tls *libc.TLS, image_histo uintptr, low_effort int32) {
  25807 	bp := tls.Alloc(48)
  25808 	defer tls.Free(48)
  25809 	var histo_size, i int32
  25810 	var histograms uintptr
  25811 	var _ /* cost_range at bp+0 */ DominantCostRange
  25812 	_, _, _ = histo_size, histograms, i
  25813 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25814 	histo_size = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  25815 	DominantCostRangeInit(tls, bp)
  25816 	// Analyze the dominant (literal, red and blue) entropy costs.
  25817 	i = 0
  25818 	for {
  25819 		if !(i < histo_size) {
  25820 			break
  25821 		}
  25822 		UpdateDominantCostRange(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(i)*8)), bp)
  25823 		goto _1
  25824 	_1:
  25825 		;
  25826 		i = i + 1
  25827 	}
  25828 	// bin-hash histograms on three of the dominant (literal, red and blue)
  25829 	// symbol costs and store the resulting bin_id for each histogram.
  25830 	i = 0
  25831 	for {
  25832 		if !(i < histo_size) {
  25833 			break
  25834 		}
  25835 		(*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))
  25836 		goto _2
  25837 	_2:
  25838 		;
  25839 		i = i + 1
  25840 	}
  25841 }
  25842 
  25843 // C documentation
  25844 //
  25845 //	// Merges some histograms with same bin_id together if it's advantageous.
  25846 //	// Sets the remaining histograms to NULL.
  25847 //	// 'combine_cost_factor' has to be divided by 100.
  25848 func HistogramCombineEntropyBin(tls *libc.TLS, image_histo uintptr, _cur_combo uintptr, num_bins int32, combine_cost_factor int32_t, low_effort int32) {
  25849 	bp := tls.Alloc(16)
  25850 	defer tls.Free(16)
  25851 	*(*uintptr)(unsafe.Pointer(bp)) = _cur_combo
  25852 	var bin_id, first, idx, max_combine_failures, try_combine int32
  25853 	var bin_info [64]struct {
  25854 		Ffirst                int16_t
  25855 		Fnum_combine_failures uint16_t
  25856 	}
  25857 	var bit_cost uint64_t
  25858 	var bit_cost_thresh, v3, v4, v5 int64_t
  25859 	var histograms uintptr
  25860 	var v7 int64
  25861 	_, _, _, _, _, _, _, _, _, _, _, _, _ = bin_id, bin_info, bit_cost, bit_cost_thresh, first, histograms, idx, max_combine_failures, try_combine, v3, v4, v5, v7
  25862 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  25863 	idx = 0
  25864 	for {
  25865 		if !(idx < num_bins) {
  25866 			break
  25867 		}
  25868 		bin_info[idx].Ffirst = int16(-int32(1))
  25869 		bin_info[idx].Fnum_combine_failures = uint16(0)
  25870 		goto _1
  25871 	_1:
  25872 		;
  25873 		idx = idx + 1
  25874 	}
  25875 	idx = 0
  25876 	for {
  25877 		if !(idx < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  25878 			break
  25879 		}
  25880 		bin_id = libc.Int32FromUint16((*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))).Fbin_id)
  25881 		first = int32(bin_info[bin_id].Ffirst)
  25882 		if first == -int32(1) {
  25883 			bin_info[bin_id].Ffirst = int16(idx)
  25884 			idx = idx + 1
  25885 		} else {
  25886 			if low_effort != 0 {
  25887 				HistogramAdd(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(first)*8)))
  25888 				HistogramSetRemoveHistogram(tls, image_histo, idx)
  25889 			} else {
  25890 				// try to merge #idx into #first (both share the same bin_id)
  25891 				bit_cost = (*VP8LHistogram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))).Fbit_cost
  25892 				v3 = libc.Int64FromUint64(bit_cost) * int64(combine_cost_factor)
  25893 				v4 = int64(100)
  25894 				if libc.BoolInt32(v3 < 0) == libc.BoolInt32(v4 < 0) {
  25895 					v7 = (v3 + v4/int64(2)) / v4
  25896 				} else {
  25897 					v7 = (v3 - v4/int64(2)) / v4
  25898 				}
  25899 				v5 = v7
  25900 				goto _6
  25901 			_6:
  25902 				bit_cost_thresh = -v5
  25903 				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 {
  25904 					max_combine_failures = int32(32)
  25905 					// Try to merge two histograms only if the combo is a trivial one or
  25906 					// the two candidate histograms are already non-trivial.
  25907 					// For some images, 'try_combine' turns out to be false for a lot of
  25908 					// histogram pairs. In that case, we fallback to combining
  25909 					// histograms as usual to avoid increasing the header size.
  25910 					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))))
  25911 					if !(try_combine != 0) {
  25912 						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))))
  25913 						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))))
  25914 					}
  25915 					if try_combine != 0 || libc.Int32FromUint16(bin_info[bin_id].Fnum_combine_failures) >= max_combine_failures {
  25916 						// move the (better) merged histogram to its final slot
  25917 						HistogramSwap(tls, bp, histograms+uintptr(first)*8)
  25918 						HistogramSetRemoveHistogram(tls, image_histo, idx)
  25919 					} else {
  25920 						bin_info[bin_id].Fnum_combine_failures = bin_info[bin_id].Fnum_combine_failures + 1
  25921 						idx = idx + 1
  25922 					}
  25923 				} else {
  25924 					idx = idx + 1
  25925 				}
  25926 			}
  25927 		}
  25928 		goto _2
  25929 	_2:
  25930 	}
  25931 	if low_effort != 0 {
  25932 		// for low_effort case, update the final cost when everything is merged
  25933 		idx = 0
  25934 		for {
  25935 			if !(idx < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  25936 				break
  25937 			}
  25938 			ComputeHistogramCost(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx)*8)))
  25939 			goto _8
  25940 		_8:
  25941 			;
  25942 			idx = idx + 1
  25943 		}
  25944 	}
  25945 }
  25946 
  25947 // C documentation
  25948 //
  25949 //	// Implement a Lehmer random number generator with a multiplicative constant of
  25950 //	// 48271 and a modulo constant of 2^31 - 1.
  25951 func MyRand(tls *libc.TLS, seed uintptr) (r uint32_t) {
  25952 	**(**uint32_t)(__ccgo_up(seed)) = uint32(uint64(**(**uint32_t)(__ccgo_up(seed))) * libc.Uint64FromUint32(48271) % libc.Uint64FromUint32(2147483647))
  25953 	return **(**uint32_t)(__ccgo_up(seed))
  25954 }
  25955 
  25956 // -----------------------------------------------------------------------------
  25957 // Histogram pairs priority queue
  25958 
  25959 // C documentation
  25960 //
  25961 //	// Pair of histograms. Negative idx1 value means that pair is out-of-date.
  25962 type HistogramPair = struct {
  25963 	Fidx1       int32
  25964 	Fidx2       int32
  25965 	Fcost_diff  int64_t
  25966 	Fcost_combo uint64_t
  25967 	Fcosts      [5]uint64_t
  25968 }
  25969 
  25970 type HistoQueue = struct {
  25971 	Fqueue    uintptr
  25972 	Fsize     int32
  25973 	Fmax_size int32
  25974 }
  25975 
  25976 func HistoQueueInit(tls *libc.TLS, histo_queue uintptr, max_size int32) (r int32) {
  25977 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = 0
  25978 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size = max_size
  25979 	// We allocate max_size + 1 because the last element at index "size" is
  25980 	// used as temporary data (and it could be up to max_size).
  25981 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue = WebPSafeMalloc(tls, libc.Uint64FromInt32((*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size+int32(1)), uint64(64))
  25982 	return libc.BoolInt32((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue != libc.UintptrFromInt32(0))
  25983 }
  25984 
  25985 func HistoQueueClear(tls *libc.TLS, histo_queue uintptr) {
  25986 	WebPSafeFree(tls, (*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue)
  25987 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = 0
  25988 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size = 0
  25989 }
  25990 
  25991 // C documentation
  25992 //
  25993 //	// Pop a specific pair in the queue by replacing it with the last one
  25994 //	// and shrinking the queue.
  25995 func HistoQueuePopPair(tls *libc.TLS, histo_queue uintptr, pair uintptr) {
  25996 	**(**HistogramPair)(__ccgo_up(pair)) = **(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue + uintptr((*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize-int32(1))*64))
  25997 	(*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize = (*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize - 1
  25998 }
  25999 
  26000 // C documentation
  26001 //
  26002 //	// Check whether a pair in the queue should be updated as head or not.
  26003 func HistoQueueUpdateHead(tls *libc.TLS, histo_queue uintptr, pair uintptr) {
  26004 	var tmp HistogramPair
  26005 	_ = tmp
  26006 	if (*HistogramPair)(unsafe.Pointer(pair)).Fcost_diff < (**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue))).Fcost_diff {
  26007 		// Replace the best pair.
  26008 		tmp = **(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue))
  26009 		**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue)) = **(**HistogramPair)(__ccgo_up(pair))
  26010 		**(**HistogramPair)(__ccgo_up(pair)) = tmp
  26011 	}
  26012 }
  26013 
  26014 // C documentation
  26015 //
  26016 //	// Replaces the bad_id with good_id in the pair.
  26017 func HistoQueueFixPair(tls *libc.TLS, bad_id int32, good_id int32, pair uintptr) {
  26018 	var tmp int32
  26019 	_ = tmp
  26020 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx1 == bad_id {
  26021 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx1 = good_id
  26022 	}
  26023 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx2 == bad_id {
  26024 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx2 = good_id
  26025 	}
  26026 	if (*HistogramPair)(unsafe.Pointer(pair)).Fidx1 > (*HistogramPair)(unsafe.Pointer(pair)).Fidx2 {
  26027 		tmp = (*HistogramPair)(unsafe.Pointer(pair)).Fidx1
  26028 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx1 = (*HistogramPair)(unsafe.Pointer(pair)).Fidx2
  26029 		(*HistogramPair)(unsafe.Pointer(pair)).Fidx2 = tmp
  26030 	}
  26031 }
  26032 
  26033 // C documentation
  26034 //
  26035 //	// Update the cost diff and combo of a pair of histograms. This needs to be
  26036 //	// called when the histograms have been merged with a third one.
  26037 //	// Returns 1 if the cost diff is less than the threshold.
  26038 //	// Otherwise returns 0 and the cost is invalid due to early bail-out.
  26039 func HistoQueueUpdatePair(tls *libc.TLS, h1 uintptr, h2 uintptr, _cost_threshold int64_t, pair uintptr) (r int32) {
  26040 	bp := tls.Alloc(16)
  26041 	defer tls.Free(16)
  26042 	*(*int64_t)(unsafe.Pointer(bp)) = _cost_threshold
  26043 	var sum_cost int64_t
  26044 	_ = sum_cost
  26045 	sum_cost = libc.Int64FromUint64((*VP8LHistogram)(unsafe.Pointer(h1)).Fbit_cost + (*VP8LHistogram)(unsafe.Pointer(h2)).Fbit_cost)
  26046 	SaturateAdd(tls, libc.Uint64FromInt64(sum_cost), bp)
  26047 	if !(GetCombinedHistogramEntropy(tls, h1, h2, **(**int64_t)(__ccgo_up(bp)), pair+16, pair+24) != 0) {
  26048 		return 0
  26049 	}
  26050 	(*HistogramPair)(unsafe.Pointer(pair)).Fcost_diff = libc.Int64FromUint64((*HistogramPair)(unsafe.Pointer(pair)).Fcost_combo) - sum_cost
  26051 	return int32(1)
  26052 }
  26053 
  26054 // C documentation
  26055 //
  26056 //	// Create a pair from indices "idx1" and "idx2" provided its cost
  26057 //	// is inferior to "threshold", a negative entropy.
  26058 //	// It returns the cost of the pair, or 0 if it superior to threshold.
  26059 func HistoQueuePush(tls *libc.TLS, histo_queue uintptr, histograms uintptr, idx1 int32, idx2 int32, threshold int64_t) (r int64_t) {
  26060 	bp := tls.Alloc(64)
  26061 	defer tls.Free(64)
  26062 	var h1, h2, v2 uintptr
  26063 	var tmp, v1 int32
  26064 	var _ /* pair at bp+0 */ HistogramPair
  26065 	_, _, _, _, _ = h1, h2, tmp, v1, v2
  26066 	// Stop here if the queue is full.
  26067 	if (*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize == (*HistoQueue)(unsafe.Pointer(histo_queue)).Fmax_size {
  26068 		return 0
  26069 	}
  26070 	if idx1 > idx2 {
  26071 		tmp = idx2
  26072 		idx2 = idx1
  26073 		idx1 = tmp
  26074 	}
  26075 	(**(**HistogramPair)(__ccgo_up(bp))).Fidx1 = idx1
  26076 	(**(**HistogramPair)(__ccgo_up(bp))).Fidx2 = idx2
  26077 	h1 = **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8))
  26078 	h2 = **(**uintptr)(__ccgo_up(histograms + uintptr(idx2)*8))
  26079 	// Do not even consider the pair if it does not improve the entropy.
  26080 	if !(HistoQueueUpdatePair(tls, h1, h2, threshold, bp) != 0) {
  26081 		return 0
  26082 	}
  26083 	v2 = histo_queue + 8
  26084 	v1 = *(*int32)(unsafe.Pointer(v2))
  26085 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  26086 	**(**HistogramPair)(__ccgo_up((*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue + uintptr(v1)*64)) = **(**HistogramPair)(__ccgo_up(bp))
  26087 	HistoQueueUpdateHead(tls, histo_queue, (*HistoQueue)(unsafe.Pointer(histo_queue)).Fqueue+uintptr((*HistoQueue)(unsafe.Pointer(histo_queue)).Fsize-int32(1))*64)
  26088 	return (**(**HistogramPair)(__ccgo_up(bp))).Fcost_diff
  26089 }
  26090 
  26091 // -----------------------------------------------------------------------------
  26092 
  26093 // C documentation
  26094 //
  26095 //	// Combines histograms by continuously choosing the one with the highest cost
  26096 //	// reduction.
  26097 func HistogramCombineGreedy(tls *libc.TLS, image_histo uintptr) (r int32) {
  26098 	bp := tls.Alloc(16)
  26099 	defer tls.Free(16)
  26100 	var histograms, p uintptr
  26101 	var i, idx1, idx2, image_histo_size, j, ok int32
  26102 	var _ /* histo_queue at bp+0 */ HistoQueue
  26103 	_, _, _, _, _, _, _, _ = histograms, i, idx1, idx2, image_histo_size, j, ok, p
  26104 	ok = 0
  26105 	image_histo_size = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  26106 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  26107 	// image_histo_size^2 for the queue size is safe. If you look at
  26108 	// HistogramCombineGreedy, and imagine that UpdateQueueFront always pushes
  26109 	// data to the queue, you insert at most:
  26110 	// - image_histo_size*(image_histo_size-1)/2 (the first two for loops)
  26111 	// - image_histo_size - 1 in the last for loop at the first iteration of
  26112 	//   the while loop, image_histo_size - 2 at the second iteration ...
  26113 	//   therefore image_histo_size*(image_histo_size-1)/2 overall too
  26114 	if !(HistoQueueInit(tls, bp, image_histo_size*image_histo_size) != 0) {
  26115 		goto End
  26116 	}
  26117 	// Initialize the queue.
  26118 	i = 0
  26119 	for {
  26120 		if !(i < image_histo_size) {
  26121 			break
  26122 		}
  26123 		j = i + int32(1)
  26124 		for {
  26125 			if !(j < image_histo_size) {
  26126 				break
  26127 			}
  26128 			HistoQueuePush(tls, bp, histograms, i, j, 0)
  26129 			goto _2
  26130 		_2:
  26131 			;
  26132 			j = j + 1
  26133 		}
  26134 		goto _1
  26135 	_1:
  26136 		;
  26137 		i = i + 1
  26138 	}
  26139 	for (**(**HistoQueue)(__ccgo_up(bp))).Fsize > 0 {
  26140 		idx1 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp))).Fqueue))).Fidx1
  26141 		idx2 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp))).Fqueue))).Fidx2
  26142 		HistogramAdd(tls, **(**uintptr)(__ccgo_up(histograms + uintptr(idx2)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8)), **(**uintptr)(__ccgo_up(histograms + uintptr(idx1)*8)))
  26143 		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)))
  26144 		// Remove merged histogram.
  26145 		HistogramSetRemoveHistogram(tls, image_histo, idx2)
  26146 		// Remove pairs intersecting the just combined best pair.
  26147 		i = 0
  26148 		for {
  26149 			if !(i < (**(**HistoQueue)(__ccgo_up(bp))).Fsize) {
  26150 				break
  26151 			}
  26152 			p = (**(**HistoQueue)(__ccgo_up(bp))).Fqueue + uintptr(i)*64
  26153 			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 {
  26154 				HistoQueuePopPair(tls, bp, p)
  26155 			} else {
  26156 				HistoQueueFixPair(tls, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize, idx2, p)
  26157 				HistoQueueUpdateHead(tls, bp, p)
  26158 				i = i + 1
  26159 			}
  26160 			goto _3
  26161 		_3:
  26162 		}
  26163 		// Push new pairs formed with combined histogram to the queue.
  26164 		i = 0
  26165 		for {
  26166 			if !(i < (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize) {
  26167 				break
  26168 			}
  26169 			if i == idx1 {
  26170 				goto _4
  26171 			}
  26172 			HistoQueuePush(tls, bp, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms, idx1, i, 0)
  26173 			goto _4
  26174 		_4:
  26175 			;
  26176 			i = i + 1
  26177 		}
  26178 	}
  26179 	ok = int32(1)
  26180 	goto End
  26181 End:
  26182 	;
  26183 	HistoQueueClear(tls, bp)
  26184 	return ok
  26185 }
  26186 
  26187 // C documentation
  26188 //
  26189 //	// Perform histogram aggregation using a stochastic approach.
  26190 //	// 'do_greedy' is set to 1 if a greedy approach needs to be performed
  26191 //	// afterwards, 0 otherwise.
  26192 func HistogramCombineStochastic(tls *libc.TLS, image_histo uintptr, min_cluster_size int32, do_greedy uintptr) (r int32) {
  26193 	bp := tls.Alloc(32)
  26194 	defer tls.Free(32)
  26195 	var best_cost, curr_cost int64_t
  26196 	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
  26197 	var histograms, p uintptr
  26198 	var idx1, idx2, rand_range, tmp uint32_t
  26199 	var v3 bool
  26200 	var v4 int64
  26201 	var _ /* histo_queue at bp+8 */ HistoQueue
  26202 	var _ /* seed at bp+0 */ uint32_t
  26203 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  26204 	**(**uint32_t)(__ccgo_up(bp)) = uint32(1)
  26205 	tries_with_no_success = 0
  26206 	outer_iters = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize
  26207 	num_tries_no_success = outer_iters / int32(2)
  26208 	histograms = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fhistograms
  26209 	kHistoQueueSize = int32(9)
  26210 	ok = 0
  26211 	if (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize < min_cluster_size {
  26212 		**(**int32)(__ccgo_up(do_greedy)) = int32(1)
  26213 		return int32(1)
  26214 	}
  26215 	if !(HistoQueueInit(tls, bp+8, kHistoQueueSize) != 0) {
  26216 		goto End
  26217 	}
  26218 	// Collapse similar histograms in 'image_histo'.
  26219 	iter = 0
  26220 	for {
  26221 		if v3 = iter < outer_iters && (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize >= min_cluster_size; v3 {
  26222 			tries_with_no_success = tries_with_no_success + 1
  26223 			v2 = tries_with_no_success
  26224 		}
  26225 		if !(v3 && v2 < num_tries_no_success) {
  26226 			break
  26227 		}
  26228 		if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == 0 {
  26229 			v4 = 0
  26230 		} else {
  26231 			v4 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fcost_diff
  26232 		}
  26233 		best_cost = v4
  26234 		best_idx1 = -int32(1)
  26235 		best_idx2 = int32(1)
  26236 		rand_range = libc.Uint32FromInt32(((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize - int32(1)) * (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize)
  26237 		// (image_histo->size) / 2 was chosen empirically. Less means faster but
  26238 		// worse compression.
  26239 		num_tries = (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize / int32(2)
  26240 		// Pick random samples.
  26241 		j = 0
  26242 		for {
  26243 			if !((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize >= int32(2) && j < num_tries) {
  26244 				break
  26245 			}
  26246 			// Choose two different histograms at random and try to combine them.
  26247 			tmp = MyRand(tls, bp) % rand_range
  26248 			idx1 = tmp / libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize-libc.Int32FromInt32(1))
  26249 			idx2 = tmp % libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize-libc.Int32FromInt32(1))
  26250 			if idx2 >= idx1 {
  26251 				idx2 = idx2 + 1
  26252 			}
  26253 			// Calculate cost reduction on combination.
  26254 			curr_cost = HistoQueuePush(tls, bp+8, histograms, libc.Int32FromUint32(idx1), libc.Int32FromUint32(idx2), best_cost)
  26255 			if curr_cost < 0 { // found a better pair?
  26256 				best_cost = curr_cost
  26257 				// Empty the queue if we reached full capacity.
  26258 				if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == (**(**HistoQueue)(__ccgo_up(bp + 8))).Fmax_size {
  26259 					break
  26260 				}
  26261 			}
  26262 			goto _5
  26263 		_5:
  26264 			;
  26265 			j = j + 1
  26266 		}
  26267 		if (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize == 0 {
  26268 			goto _1
  26269 		}
  26270 		// Get the best histograms.
  26271 		best_idx1 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fidx1
  26272 		best_idx2 = (**(**HistogramPair)(__ccgo_up((**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue))).Fidx2
  26273 		// Merge the histograms and remove best_idx2 from the queue.
  26274 		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)))
  26275 		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)))
  26276 		HistogramSetRemoveHistogram(tls, image_histo, best_idx2)
  26277 		// Parse the queue and update each pair that deals with best_idx1,
  26278 		// best_idx2 or image_histo_size.
  26279 		j = 0
  26280 		for {
  26281 			if !(j < (**(**HistoQueue)(__ccgo_up(bp + 8))).Fsize) {
  26282 				break
  26283 			}
  26284 			p = (**(**HistoQueue)(__ccgo_up(bp + 8))).Fqueue + uintptr(j)*64
  26285 			is_idx1_best = libc.BoolInt32((*HistogramPair)(unsafe.Pointer(p)).Fidx1 == best_idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx1 == best_idx2)
  26286 			is_idx2_best = libc.BoolInt32((*HistogramPair)(unsafe.Pointer(p)).Fidx2 == best_idx1 || (*HistogramPair)(unsafe.Pointer(p)).Fidx2 == best_idx2)
  26287 			// The front pair could have been duplicated by a random pick so
  26288 			// check for it all the time nevertheless.
  26289 			if is_idx1_best != 0 && is_idx2_best != 0 {
  26290 				HistoQueuePopPair(tls, bp+8, p)
  26291 				goto _6
  26292 			}
  26293 			// Any pair containing one of the two best indices should only refer to
  26294 			// best_idx1. Its cost should also be updated.
  26295 			if is_idx1_best != 0 || is_idx2_best != 0 {
  26296 				HistoQueueFixPair(tls, best_idx2, best_idx1, p)
  26297 				// Re-evaluate the cost of an updated pair.
  26298 				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) {
  26299 					HistoQueuePopPair(tls, bp+8, p)
  26300 					goto _6
  26301 				}
  26302 			}
  26303 			HistoQueueFixPair(tls, (*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize, best_idx2, p)
  26304 			HistoQueueUpdateHead(tls, bp+8, p)
  26305 			j = j + 1
  26306 			goto _6
  26307 		_6:
  26308 		}
  26309 		tries_with_no_success = 0
  26310 		goto _1
  26311 	_1:
  26312 		;
  26313 		iter = iter + 1
  26314 	}
  26315 	**(**int32)(__ccgo_up(do_greedy)) = libc.BoolInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize <= min_cluster_size)
  26316 	ok = int32(1)
  26317 	goto End
  26318 End:
  26319 	;
  26320 	HistoQueueClear(tls, bp+8)
  26321 	return ok
  26322 }
  26323 
  26324 // -----------------------------------------------------------------------------
  26325 // Histogram refinement
  26326 
  26327 // C documentation
  26328 //
  26329 //	// Find the best 'out' histogram for each of the 'in' histograms.
  26330 //	// At call-time, 'out' contains the histograms of the clusters.
  26331 //	// Note: we assume that out[]->bit_cost is already up-to-date.
  26332 func HistogramRemap(tls *libc.TLS, in uintptr, out uintptr, symbols uintptr) {
  26333 	bp := tls.Alloc(16)
  26334 	defer tls.Free(16)
  26335 	var best_bits int64_t
  26336 	var best_out, i, idx, in_size, k, out_size int32
  26337 	var in_histo, out_histo uintptr
  26338 	var _ /* cur_bits at bp+0 */ int64_t
  26339 	_, _, _, _, _, _, _, _, _ = best_bits, best_out, i, idx, in_histo, in_size, k, out_histo, out_size
  26340 	in_histo = (*VP8LHistogramSet)(unsafe.Pointer(in)).Fhistograms
  26341 	out_histo = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fhistograms
  26342 	in_size = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fmax_size
  26343 	out_size = (*VP8LHistogramSet)(unsafe.Pointer(out)).Fsize
  26344 	if out_size > int32(1) {
  26345 		i = 0
  26346 		for {
  26347 			if !(i < in_size) {
  26348 				break
  26349 			}
  26350 			best_out = 0
  26351 			best_bits = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  26352 			if **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)) == libc.UintptrFromInt32(0) {
  26353 				// Arbitrarily set to the previous value if unused to help future LZ77.
  26354 				**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(symbols + uintptr(i-int32(1))*4))
  26355 				goto _1
  26356 			}
  26357 			k = 0
  26358 			for {
  26359 				if !(k < out_size) {
  26360 					break
  26361 				}
  26362 				if HistogramAddThresh(tls, **(**uintptr)(__ccgo_up(out_histo + uintptr(k)*8)), **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)), best_bits, bp) != 0 {
  26363 					best_bits = **(**int64_t)(__ccgo_up(bp))
  26364 					best_out = k
  26365 				}
  26366 				goto _2
  26367 			_2:
  26368 				;
  26369 				k = k + 1
  26370 			}
  26371 			**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = libc.Uint32FromInt32(best_out)
  26372 			goto _1
  26373 		_1:
  26374 			;
  26375 			i = i + 1
  26376 		}
  26377 	} else {
  26378 		i = 0
  26379 		for {
  26380 			if !(i < in_size) {
  26381 				break
  26382 			}
  26383 			**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)) = uint32(0)
  26384 			goto _3
  26385 		_3:
  26386 			;
  26387 			i = i + 1
  26388 		}
  26389 	}
  26390 	// Recompute each out based on raw and symbols.
  26391 	VP8LHistogramSetClear(tls, out)
  26392 	(*VP8LHistogramSet)(unsafe.Pointer(out)).Fsize = out_size
  26393 	i = 0
  26394 	for {
  26395 		if !(i < in_size) {
  26396 			break
  26397 		}
  26398 		if **(**uintptr)(__ccgo_up(in_histo + uintptr(i)*8)) == libc.UintptrFromInt32(0) {
  26399 			goto _4
  26400 		}
  26401 		idx = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(symbols + uintptr(i)*4)))
  26402 		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)))
  26403 		goto _4
  26404 	_4:
  26405 		;
  26406 		i = i + 1
  26407 	}
  26408 }
  26409 
  26410 func GetCombineCostFactor(tls *libc.TLS, histo_size int32, quality int32) (r int32_t) {
  26411 	var combine_cost_factor int32_t
  26412 	_ = combine_cost_factor
  26413 	combine_cost_factor = int32(16)
  26414 	if quality < int32(90) {
  26415 		if histo_size > int32(256) {
  26416 			combine_cost_factor = combine_cost_factor / int32(2)
  26417 		}
  26418 		if histo_size > int32(512) {
  26419 			combine_cost_factor = combine_cost_factor / int32(2)
  26420 		}
  26421 		if histo_size > int32(1024) {
  26422 			combine_cost_factor = combine_cost_factor / int32(2)
  26423 		}
  26424 		if quality <= int32(50) {
  26425 			combine_cost_factor = combine_cost_factor / int32(2)
  26426 		}
  26427 	}
  26428 	return combine_cost_factor
  26429 }
  26430 
  26431 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) {
  26432 	bp := tls.Alloc(16)
  26433 	defer tls.Free(16)
  26434 	var combine_cost_factor int32_t
  26435 	var entropy_combine, entropy_combine_num_bins, histo_xsize, histo_ysize, image_histo_raw_size, threshold_size, v9 int32
  26436 	var orig_histo uintptr
  26437 	var v1, v5 uint32
  26438 	var v10, v11, v12 int64_t
  26439 	var v14 int64
  26440 	var v2, v3, v6, v7 uint32_t
  26441 	var _ /* do_greedy at bp+0 */ int32
  26442 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  26443 	if histogram_bits != 0 {
  26444 		v2 = libc.Uint32FromInt32(histogram_bits)
  26445 		v3 = (libc.Uint32FromInt32(xsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  26446 		goto _4
  26447 	_4:
  26448 		v1 = v3
  26449 	} else {
  26450 		v1 = uint32(1)
  26451 	}
  26452 	histo_xsize = libc.Int32FromUint32(v1)
  26453 	if histogram_bits != 0 {
  26454 		v6 = libc.Uint32FromInt32(histogram_bits)
  26455 		v7 = (libc.Uint32FromInt32(ysize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  26456 		goto _8
  26457 	_8:
  26458 		v5 = v7
  26459 	} else {
  26460 		v5 = uint32(1)
  26461 	}
  26462 	histo_ysize = libc.Int32FromUint32(v5)
  26463 	image_histo_raw_size = histo_xsize * histo_ysize
  26464 	orig_histo = VP8LAllocateHistogramSet(tls, image_histo_raw_size, cache_bits)
  26465 	if low_effort != 0 {
  26466 		v9 = int32(NUM_PARTITIONS)
  26467 	} else {
  26468 		v9 = libc.Int32FromInt32(NUM_PARTITIONS) * libc.Int32FromInt32(NUM_PARTITIONS) * libc.Int32FromInt32(NUM_PARTITIONS)
  26469 	}
  26470 	// Don't attempt linear bin-partition heuristic for
  26471 	// histograms of small sizes (as bin_map will be very sparse) and
  26472 	// maximum quality q==100 (to preserve the compression gains at that level).
  26473 	entropy_combine_num_bins = v9
  26474 	if orig_histo == libc.UintptrFromInt32(0) {
  26475 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26476 		goto Error
  26477 	}
  26478 	// Construct the histograms from backward references.
  26479 	HistogramBuild(tls, xsize, histogram_bits, refs, orig_histo)
  26480 	HistogramCopyAndAnalyze(tls, orig_histo, image_histo)
  26481 	entropy_combine = libc.BoolInt32((*VP8LHistogramSet)(unsafe.Pointer(image_histo)).Fsize > entropy_combine_num_bins*int32(2) && quality < int32(100))
  26482 	if entropy_combine != 0 {
  26483 		combine_cost_factor = GetCombineCostFactor(tls, image_histo_raw_size, quality)
  26484 		HistogramAnalyzeEntropyBin(tls, image_histo, low_effort)
  26485 		// Collapse histograms with similar entropy.
  26486 		HistogramCombineEntropyBin(tls, image_histo, tmp_histo, entropy_combine_num_bins, combine_cost_factor, low_effort)
  26487 	}
  26488 	// Don't combine the histograms using stochastic and greedy heuristics for
  26489 	// low-effort compression mode.
  26490 	if !(low_effort != 0) || !(entropy_combine != 0) {
  26491 		v10 = int64(quality * quality * quality * (libc.Int32FromInt32(MAX_HISTO_GREEDY) - libc.Int32FromInt32(1)))
  26492 		v11 = int64(libc.Int32FromInt32(100) * libc.Int32FromInt32(100) * libc.Int32FromInt32(100))
  26493 		if libc.BoolInt32(v10 < 0) == libc.BoolInt32(v11 < 0) {
  26494 			v14 = (v10 + v11/int64(2)) / v11
  26495 		} else {
  26496 			v14 = (v10 - v11/int64(2)) / v11
  26497 		}
  26498 		v12 = v14
  26499 		goto _13
  26500 	_13:
  26501 		// cubic ramp between 1 and MAX_HISTO_GREEDY:
  26502 		threshold_size = int32(libc.Int64FromInt32(1) + v12)
  26503 		if !(HistogramCombineStochastic(tls, image_histo, threshold_size, bp) != 0) {
  26504 			WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26505 			goto Error
  26506 		}
  26507 		if **(**int32)(__ccgo_up(bp)) != 0 {
  26508 			if !(HistogramCombineGreedy(tls, image_histo) != 0) {
  26509 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  26510 				goto Error
  26511 			}
  26512 		}
  26513 	}
  26514 	// Find the optimal map from original histograms to the final ones.
  26515 	HistogramRemap(tls, orig_histo, image_histo, histogram_symbols)
  26516 	if !(WebPReportProgress(tls, pic, **(**int32)(__ccgo_up(percent))+percent_range, percent) != 0) {
  26517 		goto Error
  26518 	}
  26519 	goto Error
  26520 Error:
  26521 	;
  26522 	VP8LFreeHistogramSet(tls, orig_histo)
  26523 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  26524 }
  26525 
  26526 //------------------------------------------------------------------------------
  26527 
  26528 // Copyright 2012 Google Inc. All Rights Reserved.
  26529 //
  26530 // Use of this source code is governed by a BSD-style license
  26531 // that can be found in the COPYING file in the root of the source
  26532 // tree. An additional intellectual property rights grant can be found
  26533 // in the file PATENTS. All contributing project authors may
  26534 // be found in the AUTHORS file in the root of the source tree.
  26535 // -----------------------------------------------------------------------------
  26536 //
  26537 // Misc. common utility functions
  26538 //
  26539 // Authors: Skal (pascal.massimino@gmail.com)
  26540 //          Urvang (urvang@google.com)
  26541 
  26542 // Copyright 2010 Google Inc. All Rights Reserved.
  26543 //
  26544 // Use of this source code is governed by a BSD-style license
  26545 // that can be found in the COPYING file in the root of the source
  26546 // tree. An additional intellectual property rights grant can be found
  26547 // in the file PATENTS. All contributing project authors may
  26548 // be found in the AUTHORS file in the root of the source tree.
  26549 // -----------------------------------------------------------------------------
  26550 //
  26551 //  Common types + memory wrappers
  26552 //
  26553 // Author: Skal (pascal.massimino@gmail.com)
  26554 
  26555 //------------------------------------------------------------------------------
  26556 // VP8Iterator
  26557 //------------------------------------------------------------------------------
  26558 
  26559 func InitLeft(tls *libc.TLS, it uintptr) {
  26560 	var v1, v2 uint8_t
  26561 	var v3 int32
  26562 	_, _, _ = v1, v2, v3
  26563 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy > 0 {
  26564 		v3 = int32(129)
  26565 	} else {
  26566 		v3 = int32(127)
  26567 	}
  26568 	v2 = libc.Uint8FromInt32(v3)
  26569 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = v2
  26570 	v1 = v2
  26571 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26572 	**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26573 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left, int32(129), uint64(16), ^__predefined_size_t(0))
  26574 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left, int32(129), uint64(8), ^__predefined_size_t(0))
  26575 	libc.X__builtin___memset_chk(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fv_left, int32(129), uint64(8), ^__predefined_size_t(0))
  26576 	**(**int32)(__ccgo_up(it + 168 + 8*4)) = 0
  26577 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  26578 		libc.X__builtin___memset_chk(tls, it+344, 0, uint64(4), ^__predefined_size_t(0))
  26579 	}
  26580 }
  26581 
  26582 func InitTop(tls *libc.TLS, it uintptr) {
  26583 	var enc uintptr
  26584 	var top_size size_t
  26585 	_, _ = enc, top_size
  26586 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26587 	top_size = libc.Uint64FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * int32(16))
  26588 	libc.X__builtin___memset_chk(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top, int32(127), uint64(2)*top_size, ^__predefined_size_t(0))
  26589 	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))
  26590 	if (*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr != libc.UintptrFromInt32(0) {
  26591 		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))
  26592 	}
  26593 }
  26594 
  26595 func VP8IteratorSetRow(tls *libc.TLS, it uintptr, y int32) {
  26596 	var enc uintptr
  26597 	_ = enc
  26598 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26599 	(*VP8EncIterator)(unsafe.Pointer(it)).Fx = 0
  26600 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy = y
  26601 	(*VP8EncIterator)(unsafe.Pointer(it)).Fbw = enc + 112 + uintptr(y&((*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)))*48
  26602 	(*VP8EncIterator)(unsafe.Pointer(it)).Fpreds = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds + uintptr(y*int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  26603 	(*VP8EncIterator)(unsafe.Pointer(it)).Fnz = (*VP8Encoder)(unsafe.Pointer(enc)).Fnz
  26604 	(*VP8EncIterator)(unsafe.Pointer(it)).Fmb = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info + uintptr(y*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w)*4
  26605 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top
  26606 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fuv_top
  26607 	InitLeft(tls, it)
  26608 }
  26609 
  26610 // C documentation
  26611 //
  26612 //	// restart a scan
  26613 func VP8IteratorReset(tls *libc.TLS, it uintptr) {
  26614 	var enc uintptr
  26615 	_ = enc
  26616 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26617 	VP8IteratorSetRow(tls, it, 0)
  26618 	VP8IteratorSetCountDown(tls, it, (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) // default
  26619 	InitTop(tls, it)
  26620 	libc.X__builtin___memset_chk(tls, it+208, 0, uint64(96), ^__predefined_size_t(0))
  26621 	(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = 0
  26622 }
  26623 
  26624 func VP8IteratorSetCountDown(tls *libc.TLS, it uintptr, count_down int32) {
  26625 	var v1 int32
  26626 	_ = v1
  26627 	v1 = count_down
  26628 	(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 = v1
  26629 	(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down = v1
  26630 }
  26631 
  26632 func VP8IteratorIsDone(tls *libc.TLS, it uintptr) (r int32) {
  26633 	return libc.BoolInt32((*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down <= 0)
  26634 }
  26635 
  26636 func VP8IteratorInit(tls *libc.TLS, enc uintptr, it uintptr) {
  26637 	(*VP8EncIterator)(unsafe.Pointer(it)).Fenc = enc
  26638 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in = uintptr((uintptr_t(it+488) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  26639 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26640 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26641 	(*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(BPS)*libc.Int32FromInt32(16))
  26642 	(*VP8EncIterator)(unsafe.Pointer(it)).Flf_stats = (*VP8Encoder)(unsafe.Pointer(enc)).Flf_stats
  26643 	(*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0 = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent
  26644 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_left = uintptr((uint64(it+400+libc.UintptrFromInt32(1)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  26645 	(*VP8EncIterator)(unsafe.Pointer(it)).Fu_left = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(16) + uintptr(16)
  26646 	(*VP8EncIterator)(unsafe.Pointer(it)).Fv_left = (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(16)
  26647 	(*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr = (*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr
  26648 	VP8IteratorReset(tls, it)
  26649 }
  26650 
  26651 func VP8IteratorProgress(tls *libc.TLS, it uintptr, delta int32) (r int32) {
  26652 	var done, percent, v1 int32
  26653 	var enc uintptr
  26654 	_, _, _, _ = done, enc, percent, v1
  26655 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26656 	if delta != 0 && (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fprogress_hook != libc.UintptrFromInt32(0) {
  26657 		done = (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 - (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down
  26658 		if (*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0 <= 0 {
  26659 			v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0
  26660 		} else {
  26661 			v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fpercent0 + delta*done/(*VP8EncIterator)(unsafe.Pointer(it)).Fcount_down0
  26662 		}
  26663 		percent = v1
  26664 		return WebPReportProgress(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, percent, enc+536)
  26665 	}
  26666 	return int32(1)
  26667 }
  26668 
  26669 //------------------------------------------------------------------------------
  26670 // Import the source samples into the cache. Takes care of replicating
  26671 // boundary pixels if necessary.
  26672 
  26673 func MinSize(tls *libc.TLS, a int32, b int32) (r int32) {
  26674 	var v1 int32
  26675 	_ = v1
  26676 	if a < b {
  26677 		v1 = a
  26678 	} else {
  26679 		v1 = b
  26680 	}
  26681 	return v1
  26682 }
  26683 
  26684 func ImportBlock(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, w int32, h int32, size int32) {
  26685 	var i int32
  26686 	_ = i
  26687 	i = 0
  26688 	for {
  26689 		if !(i < h) {
  26690 			break
  26691 		}
  26692 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  26693 		if w < size {
  26694 			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))
  26695 		}
  26696 		dst = dst + uintptr(BPS)
  26697 		src = src + uintptr(src_stride)
  26698 		goto _1
  26699 	_1:
  26700 		;
  26701 		i = i + 1
  26702 	}
  26703 	i = h
  26704 	for {
  26705 		if !(i < size) {
  26706 			break
  26707 		}
  26708 		libc.X__builtin___memcpy_chk(tls, dst, dst-uintptr(BPS), libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  26709 		dst = dst + uintptr(BPS)
  26710 		goto _2
  26711 	_2:
  26712 		;
  26713 		i = i + 1
  26714 	}
  26715 }
  26716 
  26717 func ImportLine(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, len1 int32, total_len int32) {
  26718 	var i int32
  26719 	_ = i
  26720 	i = 0
  26721 	for {
  26722 		if !(i < len1) {
  26723 			break
  26724 		}
  26725 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(src))
  26726 		goto _1
  26727 	_1:
  26728 		;
  26729 		i = i + 1
  26730 		src = src + uintptr(src_stride)
  26731 	}
  26732 	for {
  26733 		if !(i < total_len) {
  26734 			break
  26735 		}
  26736 		**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = **(**uint8_t)(__ccgo_up(dst + uintptr(len1-int32(1))))
  26737 		goto _2
  26738 	_2:
  26739 		;
  26740 		i = i + 1
  26741 	}
  26742 }
  26743 
  26744 func VP8IteratorImport(tls *libc.TLS, it uintptr, tmp_32 uintptr) {
  26745 	var enc, pic, usrc, vsrc, ysrc uintptr
  26746 	var h, uv_h, uv_w, w, x, y int32
  26747 	var v1, v2 uint8_t
  26748 	_, _, _, _, _, _, _, _, _, _, _, _, _ = enc, h, pic, usrc, uv_h, uv_w, vsrc, w, x, y, ysrc, v1, v2
  26749 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26750 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26751 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26752 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  26753 	ysrc = (*WebPPicture)(unsafe.Pointer(pic)).Fy + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride+x)*int32(16))
  26754 	usrc = (*WebPPicture)(unsafe.Pointer(pic)).Fu + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26755 	vsrc = (*WebPPicture)(unsafe.Pointer(pic)).Fv + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26756 	w = MinSize(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth-x*int32(16), int32(16))
  26757 	h = MinSize(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fheight-y*int32(16), int32(16))
  26758 	uv_w = (w + int32(1)) >> int32(1)
  26759 	uv_h = (h + int32(1)) >> int32(1)
  26760 	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))
  26761 	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))
  26762 	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))
  26763 	if tmp_32 == libc.UintptrFromInt32(0) {
  26764 		return
  26765 	}
  26766 	// Import source (uncompressed) samples into boundary.
  26767 	if x == 0 {
  26768 		InitLeft(tls, it)
  26769 	} else {
  26770 		if y == 0 {
  26771 			v2 = libc.Uint8FromInt32(127)
  26772 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(-libc.Int32FromInt32(1)))) = v2
  26773 			v1 = v2
  26774 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26775 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(-libc.Int32FromInt32(1)))) = v1
  26776 		} else {
  26777 			**(**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)))
  26778 			**(**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)))
  26779 			**(**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)))
  26780 		}
  26781 		ImportLine(tls, ysrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left, h, int32(16))
  26782 		ImportLine(tls, usrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left, uv_h, int32(8))
  26783 		ImportLine(tls, vsrc-uintptr(1), (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, (*VP8EncIterator)(unsafe.Pointer(it)).Fv_left, uv_h, int32(8))
  26784 	}
  26785 	(*VP8EncIterator)(unsafe.Pointer(it)).Fy_top = tmp_32 + uintptr(0)
  26786 	(*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top = tmp_32 + uintptr(16)
  26787 	if y == 0 {
  26788 		libc.X__builtin___memset_chk(tls, tmp_32, int32(127), libc.Uint64FromInt32(32)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  26789 	} else {
  26790 		ImportLine(tls, ysrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fy_stride), int32(1), tmp_32, w, int32(16))
  26791 		ImportLine(tls, usrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride), int32(1), tmp_32+uintptr(16), uv_w, int32(8))
  26792 		ImportLine(tls, vsrc-uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride), int32(1), tmp_32+uintptr(16)+uintptr(8), uv_w, int32(8))
  26793 	}
  26794 }
  26795 
  26796 //------------------------------------------------------------------------------
  26797 // Copy back the compressed samples into user space if requested.
  26798 
  26799 func ExportBlock(tls *libc.TLS, src uintptr, dst uintptr, dst_stride int32, w int32, h int32) {
  26800 	var v1 int32
  26801 	_ = v1
  26802 	for {
  26803 		v1 = h
  26804 		h = h - 1
  26805 		if !(v1 > 0) {
  26806 			break
  26807 		}
  26808 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  26809 		dst = dst + uintptr(dst_stride)
  26810 		src = src + uintptr(BPS)
  26811 	}
  26812 }
  26813 
  26814 func VP8IteratorExport(tls *libc.TLS, it uintptr) {
  26815 	var enc, pic, udst, usrc, vdst, vsrc, ydst, ysrc uintptr
  26816 	var h, uv_h, uv_w, w, x, y int32
  26817 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc, h, pic, udst, usrc, uv_h, uv_w, vdst, vsrc, w, x, y, ydst, ysrc
  26818 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26819 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fshow_compressed != 0 {
  26820 		x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26821 		y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26822 		ysrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  26823 		usrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  26824 		vsrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(16)+libc.Int32FromInt32(8))
  26825 		pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  26826 		ydst = (*WebPPicture)(unsafe.Pointer(pic)).Fy + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride+x)*int32(16))
  26827 		udst = (*WebPPicture)(unsafe.Pointer(pic)).Fu + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26828 		vdst = (*WebPPicture)(unsafe.Pointer(pic)).Fv + uintptr((y*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride+x)*int32(8))
  26829 		w = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - x*int32(16)
  26830 		h = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - y*int32(16)
  26831 		if w > int32(16) {
  26832 			w = int32(16)
  26833 		}
  26834 		if h > int32(16) {
  26835 			h = int32(16)
  26836 		}
  26837 		// Luma plane
  26838 		ExportBlock(tls, ysrc, ydst, (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride, w, h)
  26839 		// U/V planes
  26840 		uv_w = (w + int32(1)) >> int32(1)
  26841 		uv_h = (h + int32(1)) >> int32(1)
  26842 		ExportBlock(tls, usrc, udst, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, uv_w, uv_h)
  26843 		ExportBlock(tls, vsrc, vdst, (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride, uv_w, uv_h)
  26844 	}
  26845 }
  26846 
  26847 //------------------------------------------------------------------------------
  26848 // Non-zero contexts setup/teardown
  26849 
  26850 // Nz bits:
  26851 //  0  1  2  3  Y
  26852 //  4  5  6  7
  26853 //  8  9 10 11
  26854 // 12 13 14 15
  26855 // 16 17        U
  26856 // 18 19
  26857 // 20 21        V
  26858 // 22 23
  26859 // 24           DC-intra16
  26860 
  26861 // Convert packed context to byte array
  26862 
  26863 func VP8IteratorNzToBytes(tls *libc.TLS, it uintptr) {
  26864 	var left_nz, top_nz uintptr
  26865 	var lnz, tnz int32
  26866 	_, _, _, _ = left_nz, lnz, tnz, top_nz
  26867 	tnz = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)))
  26868 	lnz = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz + uintptr(-libc.Int32FromInt32(1))*4)))
  26869 	top_nz = it + 132
  26870 	left_nz = it + 168
  26871 	// Top-Y
  26872 	**(**int32)(__ccgo_up(top_nz)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(12)) != 0))
  26873 	**(**int32)(__ccgo_up(top_nz + 1*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(13)) != 0))
  26874 	**(**int32)(__ccgo_up(top_nz + 2*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(14)) != 0))
  26875 	**(**int32)(__ccgo_up(top_nz + 3*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(15)) != 0))
  26876 	// Top-U
  26877 	**(**int32)(__ccgo_up(top_nz + 4*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(18)) != 0))
  26878 	**(**int32)(__ccgo_up(top_nz + 5*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  26879 	// Top-V
  26880 	**(**int32)(__ccgo_up(top_nz + 6*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(22)) != 0))
  26881 	**(**int32)(__ccgo_up(top_nz + 7*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(23)) != 0))
  26882 	// DC
  26883 	**(**int32)(__ccgo_up(top_nz + 8*4)) = libc.BoolInt32(!!(tnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(24)) != 0))
  26884 	// left-Y
  26885 	**(**int32)(__ccgo_up(left_nz)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(3)) != 0))
  26886 	**(**int32)(__ccgo_up(left_nz + 1*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(7)) != 0))
  26887 	**(**int32)(__ccgo_up(left_nz + 2*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(11)) != 0))
  26888 	**(**int32)(__ccgo_up(left_nz + 3*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(15)) != 0))
  26889 	// left-U
  26890 	**(**int32)(__ccgo_up(left_nz + 4*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(17)) != 0))
  26891 	**(**int32)(__ccgo_up(left_nz + 5*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  26892 	// left-V
  26893 	**(**int32)(__ccgo_up(left_nz + 6*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(21)) != 0))
  26894 	**(**int32)(__ccgo_up(left_nz + 7*4)) = libc.BoolInt32(!!(lnz&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(23)) != 0))
  26895 	// left-DC is special, iterated separately
  26896 }
  26897 
  26898 func VP8IteratorBytesToNz(tls *libc.TLS, it uintptr) {
  26899 	var left_nz, top_nz uintptr
  26900 	var nz uint32_t
  26901 	_, _, _ = left_nz, nz, top_nz
  26902 	nz = uint32(0)
  26903 	top_nz = it + 132
  26904 	left_nz = it + 168
  26905 	// top
  26906 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz))<<libc.Int32FromInt32(12)|**(**int32)(__ccgo_up(top_nz + 1*4))<<libc.Int32FromInt32(13))
  26907 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 2*4))<<libc.Int32FromInt32(14)|**(**int32)(__ccgo_up(top_nz + 3*4))<<libc.Int32FromInt32(15))
  26908 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 4*4))<<libc.Int32FromInt32(18)|**(**int32)(__ccgo_up(top_nz + 5*4))<<libc.Int32FromInt32(19))
  26909 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 6*4))<<libc.Int32FromInt32(22)|**(**int32)(__ccgo_up(top_nz + 7*4))<<libc.Int32FromInt32(23))
  26910 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(top_nz + 8*4))<<libc.Int32FromInt32(24)) // we propagate the _top_ bit, esp. for intra4
  26911 	// left
  26912 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz))<<libc.Int32FromInt32(3)|**(**int32)(__ccgo_up(left_nz + 1*4))<<libc.Int32FromInt32(7))
  26913 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz + 2*4))<<libc.Int32FromInt32(11))
  26914 	nz = nz | libc.Uint32FromInt32(**(**int32)(__ccgo_up(left_nz + 4*4))<<libc.Int32FromInt32(17)|**(**int32)(__ccgo_up(left_nz + 6*4))<<libc.Int32FromInt32(21))
  26915 	**(**uint32_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fnz)) = nz
  26916 }
  26917 
  26918 //------------------------------------------------------------------------------
  26919 // Advance to the next position, doing the bookkeeping.
  26920 
  26921 func VP8IteratorSaveBoundary(tls *libc.TLS, it uintptr) {
  26922 	var enc, uvsrc, ysrc uintptr
  26923 	var i, x, y int32
  26924 	_, _, _, _, _, _ = enc, i, uvsrc, x, y, ysrc
  26925 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  26926 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fx
  26927 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fy
  26928 	ysrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  26929 	uvsrc = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  26930 	if x < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w-int32(1) {
  26931 		i = 0
  26932 		for {
  26933 			if !(i < int32(16)) {
  26934 				break
  26935 			}
  26936 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(ysrc + uintptr(int32(15)+i*int32(BPS))))
  26937 			goto _1
  26938 		_1:
  26939 			;
  26940 			i = i + 1
  26941 		}
  26942 		i = 0
  26943 		for {
  26944 			if !(i < int32(8)) {
  26945 				break
  26946 			}
  26947 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fu_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(uvsrc + uintptr(int32(7)+i*int32(BPS))))
  26948 			**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fv_left + uintptr(i))) = **(**uint8_t)(__ccgo_up(uvsrc + uintptr(int32(15)+i*int32(BPS))))
  26949 			goto _2
  26950 		_2:
  26951 			;
  26952 			i = i + 1
  26953 		}
  26954 		// top-left (before 'top'!)
  26955 		**(**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))
  26956 		**(**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))))
  26957 		**(**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))))
  26958 	}
  26959 	if y < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h-int32(1) { // top
  26960 		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))
  26961 		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))
  26962 	}
  26963 }
  26964 
  26965 func VP8IteratorNext(tls *libc.TLS, it uintptr) (r int32) {
  26966 	var v1, v3 int32
  26967 	var v2, v4 uintptr
  26968 	_, _, _, _ = v1, v2, v3, v4
  26969 	v2 = it
  26970 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
  26971 	v1 = *(*int32)(unsafe.Pointer(v2))
  26972 	if v1 == (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmb_w {
  26973 		v4 = it + 4
  26974 		*(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1
  26975 		v3 = *(*int32)(unsafe.Pointer(v4))
  26976 		VP8IteratorSetRow(tls, it, v3)
  26977 	} else {
  26978 		**(**uintptr)(__ccgo_up(it + 64)) += uintptr(4)
  26979 		**(**uintptr)(__ccgo_up(it + 48)) += uintptr(1) * 4
  26980 		**(**uintptr)(__ccgo_up(it + 72)) += uintptr(1) * 4
  26981 		**(**uintptr)(__ccgo_up(it + 384)) += uintptr(16)
  26982 		**(**uintptr)(__ccgo_up(it + 392)) += uintptr(16)
  26983 	}
  26984 	v2 = it + 332
  26985 	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  26986 	v1 = *(*int32)(unsafe.Pointer(v2))
  26987 	return libc.BoolInt32(0 < v1)
  26988 }
  26989 
  26990 //------------------------------------------------------------------------------
  26991 // Helper function to set mode properties
  26992 
  26993 func VP8SetIntra16Mode(tls *libc.TLS, it uintptr, mode int32) {
  26994 	var preds uintptr
  26995 	var y int32
  26996 	_, _ = preds, y
  26997 	preds = (*VP8EncIterator)(unsafe.Pointer(it)).Fpreds
  26998 	y = 0
  26999 	for {
  27000 		if !(y < int32(4)) {
  27001 			break
  27002 		}
  27003 		libc.X__builtin___memset_chk(tls, preds, mode, uint64(4), ^__predefined_size_t(0))
  27004 		preds = preds + uintptr((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w)
  27005 		goto _1
  27006 	_1:
  27007 		;
  27008 		y = y + 1
  27009 	}
  27010 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(1), 0, 0x3)
  27011 }
  27012 
  27013 func VP8SetIntra4Mode(tls *libc.TLS, it uintptr, modes uintptr) {
  27014 	var preds uintptr
  27015 	var y int32
  27016 	_, _ = preds, y
  27017 	preds = (*VP8EncIterator)(unsafe.Pointer(it)).Fpreds
  27018 	y = int32(4)
  27019 	for {
  27020 		if !(y > 0) {
  27021 			break
  27022 		}
  27023 		libc.X__builtin___memcpy_chk(tls, preds, modes, libc.Uint64FromInt32(4)*libc.Uint64FromInt64(1), ^__predefined_size_t(0))
  27024 		preds = preds + uintptr((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w)
  27025 		modes = modes + uintptr(4)
  27026 		goto _1
  27027 	_1:
  27028 		;
  27029 		y = y - 1
  27030 	}
  27031 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(0), 0, 0x3)
  27032 }
  27033 
  27034 func VP8SetIntraUVMode(tls *libc.TLS, it uintptr, mode int32) {
  27035 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(mode), 2, 0xc)
  27036 }
  27037 
  27038 func VP8SetSkip(tls *libc.TLS, it uintptr, skip int32) {
  27039 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(skip), 4, 0x10)
  27040 }
  27041 
  27042 func VP8SetSegment(tls *libc.TLS, it uintptr, segment int32) {
  27043 	libc.SetBitFieldPtr8Uint32((*VP8EncIterator)(unsafe.Pointer(it)).Fmb+0, libc.Uint32FromInt32(segment), 5, 0x60)
  27044 }
  27045 
  27046 //------------------------------------------------------------------------------
  27047 // Intra4x4 sub-blocks iteration
  27048 //
  27049 //  We store and update the boundary samples into an array of 37 pixels. They
  27050 //  are updated as we iterate and reconstructs each intra4x4 blocks in turn.
  27051 //  The position of the samples has the following snake pattern:
  27052 //
  27053 // 16|17 18 19 20|21 22 23 24|25 26 27 28|29 30 31 32|33 34 35 36  <- Top-right
  27054 // --+-----------+-----------+-----------+-----------+
  27055 // 15|         19|         23|         27|         31|
  27056 // 14|         18|         22|         26|         30|
  27057 // 13|         17|         21|         25|         29|
  27058 // 12|13 14 15 16|17 18 19 20|21 22 23 24|25 26 27 28|
  27059 // --+-----------+-----------+-----------+-----------+
  27060 // 11|         15|         19|         23|         27|
  27061 // 10|         14|         18|         22|         26|
  27062 //  9|         13|         17|         21|         25|
  27063 //  8| 9 10 11 12|13 14 15 16|17 18 19 20|21 22 23 24|
  27064 // --+-----------+-----------+-----------+-----------+
  27065 //  7|         11|         15|         19|         23|
  27066 //  6|         10|         14|         18|         22|
  27067 //  5|          9|         13|         17|         21|
  27068 //  4| 5  6  7  8| 9 10 11 12|13 14 15 16|17 18 19 20|
  27069 // --+-----------+-----------+-----------+-----------+
  27070 //  3|          7|         11|         15|         19|
  27071 //  2|          6|         10|         14|         18|
  27072 //  1|          5|          9|         13|         17|
  27073 //  0| 1  2  3  4| 5  6  7  8| 9 10 11 12|13 14 15 16|
  27074 // --+-----------+-----------+-----------+-----------+
  27075 
  27076 // C documentation
  27077 //
  27078 //	// Array to record the position of the top sample to pass to the prediction
  27079 //	// functions in dsp.c.
  27080 var VP8TopLeftI4 = [16]uint8_t{
  27081 	0:  uint8(17),
  27082 	1:  uint8(21),
  27083 	2:  uint8(25),
  27084 	3:  uint8(29),
  27085 	4:  uint8(13),
  27086 	5:  uint8(17),
  27087 	6:  uint8(21),
  27088 	7:  uint8(25),
  27089 	8:  uint8(9),
  27090 	9:  uint8(13),
  27091 	10: uint8(17),
  27092 	11: uint8(21),
  27093 	12: uint8(5),
  27094 	13: uint8(9),
  27095 	14: uint8(13),
  27096 	15: uint8(17),
  27097 }
  27098 
  27099 func VP8IteratorStartI4(tls *libc.TLS, it uintptr) {
  27100 	var enc uintptr
  27101 	var i int32
  27102 	_, _ = enc, i
  27103 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  27104 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4 = 0 // first 4x4 sub-block
  27105 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top = it + 80 + uintptr(VP8TopLeftI4[0])
  27106 	// Import the boundary samples
  27107 	i = 0
  27108 	for {
  27109 		if !(i < int32(17)) {
  27110 			break
  27111 		} // left
  27112 		**(**uint8_t)(__ccgo_up(it + 80 + uintptr(i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_left + uintptr(int32(15)-i)))
  27113 		goto _1
  27114 	_1:
  27115 		;
  27116 		i = i + 1
  27117 	}
  27118 	i = 0
  27119 	for {
  27120 		if !(i < int32(16)) {
  27121 			break
  27122 		} // top
  27123 		**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_top + uintptr(i)))
  27124 		goto _2
  27125 	_2:
  27126 		;
  27127 		i = i + 1
  27128 	}
  27129 	// top-right samples have a special case on the far right of the picture
  27130 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx < (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w-int32(1) {
  27131 		i = int32(16)
  27132 		for {
  27133 			if !(i < libc.Int32FromInt32(16)+libc.Int32FromInt32(4)) {
  27134 				break
  27135 			}
  27136 			**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fy_top + uintptr(i)))
  27137 			goto _3
  27138 		_3:
  27139 			;
  27140 			i = i + 1
  27141 		}
  27142 	} else { // else, replicate the last valid pixel four times
  27143 		i = int32(16)
  27144 		for {
  27145 			if !(i < libc.Int32FromInt32(16)+libc.Int32FromInt32(4)) {
  27146 				break
  27147 			}
  27148 			**(**uint8_t)(__ccgo_up(it + 80 + uintptr(int32(17)+i))) = **(**uint8_t)(__ccgo_up(it + 80 + uintptr(libc.Int32FromInt32(17)+libc.Int32FromInt32(15))))
  27149 			goto _4
  27150 		_4:
  27151 			;
  27152 			i = i + 1
  27153 		}
  27154 	}
  27155 	VP8IteratorNzToBytes(tls, it) // import the non-zero context
  27156 }
  27157 
  27158 func VP8IteratorRotateI4(tls *libc.TLS, it uintptr, yuv_out uintptr) (r int32) {
  27159 	var blk, top uintptr
  27160 	var i int32
  27161 	_, _, _ = blk, i, top
  27162 	blk = yuv_out + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  27163 	top = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top
  27164 	// Update the cache with 7 fresh samples
  27165 	i = 0
  27166 	for {
  27167 		if !(i <= int32(3)) {
  27168 			break
  27169 		}
  27170 		**(**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
  27171 		goto _1
  27172 	_1:
  27173 		;
  27174 		i = i + 1
  27175 	}
  27176 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fi4&int32(3) != int32(3) { // if not on the right sub-blocks #3, #7, #11, #15
  27177 		i = 0
  27178 		for {
  27179 			if !(i <= int32(2)) {
  27180 				break
  27181 			} // store future left samples
  27182 			**(**uint8_t)(__ccgo_up(top + uintptr(i))) = **(**uint8_t)(__ccgo_up(blk + uintptr(int32(3)+(int32(2)-i)*int32(BPS))))
  27183 			goto _2
  27184 		_2:
  27185 			;
  27186 			i = i + 1
  27187 		}
  27188 	} else { // else replicate top-right samples, as says the specs.
  27189 		i = 0
  27190 		for {
  27191 			if !(i <= int32(3)) {
  27192 				break
  27193 			}
  27194 			**(**uint8_t)(__ccgo_up(top + uintptr(i))) = **(**uint8_t)(__ccgo_up(top + uintptr(i+int32(4))))
  27195 			goto _3
  27196 		_3:
  27197 			;
  27198 			i = i + 1
  27199 		}
  27200 	}
  27201 	// move pointers to next sub-block
  27202 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4 = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 + 1
  27203 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 == int32(16) { // we're done
  27204 		return 0
  27205 	}
  27206 	(*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top = it + 80 + uintptr(VP8TopLeftI4[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  27207 	return int32(1)
  27208 }
  27209 
  27210 const MAX_LIMIT_BITS = 5
  27211 const MIN_DIM_FOR_NEAR_LOSSLESS = 64
  27212 
  27213 //------------------------------------------------------------------------------
  27214 
  27215 // Copyright 2012 Google Inc. All Rights Reserved.
  27216 //
  27217 // Use of this source code is governed by a BSD-style license
  27218 // that can be found in the COPYING file in the root of the source
  27219 // tree. An additional intellectual property rights grant can be found
  27220 // in the file PATENTS. All contributing project authors may
  27221 // be found in the AUTHORS file in the root of the source tree.
  27222 // -----------------------------------------------------------------------------
  27223 //
  27224 // Misc. common utility functions
  27225 //
  27226 // Authors: Skal (pascal.massimino@gmail.com)
  27227 //          Urvang (urvang@google.com)
  27228 
  27229 // Copyright 2011 Google Inc. All Rights Reserved.
  27230 //
  27231 // Use of this source code is governed by a BSD-style license
  27232 // that can be found in the COPYING file in the root of the source
  27233 // tree. An additional intellectual property rights grant can be found
  27234 // in the file PATENTS. All contributing project authors may
  27235 // be found in the AUTHORS file in the root of the source tree.
  27236 // -----------------------------------------------------------------------------
  27237 //
  27238 //   WebP encoder: main interface
  27239 //
  27240 // Author: Skal (pascal.massimino@gmail.com)
  27241 
  27242 // C documentation
  27243 //
  27244 //	// Quantizes the value up or down to a multiple of 1<<bits (or to 255),
  27245 //	// choosing the closer one, resolving ties using bankers' rounding.
  27246 func FindClosestDiscretized(tls *libc.TLS, a uint32_t, bits int32) (r uint32_t) {
  27247 	var biased, mask uint32_t
  27248 	_, _ = biased, mask
  27249 	mask = uint32(1)<<bits - uint32(1)
  27250 	biased = a + mask>>libc.Int32FromInt32(1) + a>>bits&uint32(1)
  27251 	if biased > uint32(0xff) {
  27252 		return uint32(0xff)
  27253 	}
  27254 	return biased & ^mask
  27255 }
  27256 
  27257 // C documentation
  27258 //
  27259 //	// Applies FindClosestDiscretized to all channels of pixel.
  27260 func ClosestDiscretizedArgb(tls *libc.TLS, a uint32_t, bits int32) (r uint32_t) {
  27261 	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)
  27262 }
  27263 
  27264 // C documentation
  27265 //
  27266 //	// Checks if distance between corresponding channel values of pixels a and b
  27267 //	// is within the given limit.
  27268 func IsNear(tls *libc.TLS, a uint32_t, b uint32_t, limit int32) (r int32) {
  27269 	var delta, k int32
  27270 	_, _ = delta, k
  27271 	k = 0
  27272 	for {
  27273 		if !(k < int32(4)) {
  27274 			break
  27275 		}
  27276 		delta = libc.Int32FromUint32(a>>(k*libc.Int32FromInt32(8))&libc.Uint32FromInt32(0xff)) - libc.Int32FromUint32(b>>(k*libc.Int32FromInt32(8))&libc.Uint32FromInt32(0xff))
  27277 		if delta >= limit || delta <= -limit {
  27278 			return 0
  27279 		}
  27280 		goto _1
  27281 	_1:
  27282 		;
  27283 		k = k + 1
  27284 	}
  27285 	return int32(1)
  27286 }
  27287 
  27288 func IsSmooth(tls *libc.TLS, prev_row uintptr, curr_row uintptr, next_row uintptr, ix int32, limit int32) (r int32) {
  27289 	// Check that all pixels in 4-connected neighborhood are smooth.
  27290 	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)
  27291 }
  27292 
  27293 // C documentation
  27294 //
  27295 //	// Adjusts pixel values of image with given maximum error.
  27296 func NearLossless(tls *libc.TLS, xsize int32, ysize int32, argb_src uintptr, stride int32, limit_bits int32, copy_buffer uintptr, argb_dst uintptr) {
  27297 	var curr_row, next_row, prev_row, temp uintptr
  27298 	var limit, x, y int32
  27299 	_, _, _, _, _, _, _ = curr_row, limit, next_row, prev_row, temp, x, y
  27300 	limit = int32(1) << limit_bits
  27301 	prev_row = copy_buffer
  27302 	curr_row = prev_row + uintptr(xsize)*4
  27303 	next_row = curr_row + uintptr(xsize)*4
  27304 	libc.X__builtin___memcpy_chk(tls, curr_row, argb_src, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27305 	libc.X__builtin___memcpy_chk(tls, next_row, argb_src+uintptr(stride)*4, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27306 	y = 0
  27307 	for {
  27308 		if !(y < ysize) {
  27309 			break
  27310 		}
  27311 		if y == 0 || y == ysize-int32(1) {
  27312 			libc.X__builtin___memcpy_chk(tls, argb_dst, argb_src, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27313 		} else {
  27314 			libc.X__builtin___memcpy_chk(tls, next_row, argb_src+uintptr(stride)*4, libc.Uint64FromInt32(xsize)*uint64(4), ^__predefined_size_t(0))
  27315 			**(**uint32_t)(__ccgo_up(argb_dst)) = **(**uint32_t)(__ccgo_up(argb_src))
  27316 			**(**uint32_t)(__ccgo_up(argb_dst + uintptr(xsize-int32(1))*4)) = **(**uint32_t)(__ccgo_up(argb_src + uintptr(xsize-int32(1))*4))
  27317 			x = int32(1)
  27318 			for {
  27319 				if !(x < xsize-int32(1)) {
  27320 					break
  27321 				}
  27322 				if IsSmooth(tls, prev_row, curr_row, next_row, x, limit) != 0 {
  27323 					**(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4)) = **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4))
  27324 				} else {
  27325 					**(**uint32_t)(__ccgo_up(argb_dst + uintptr(x)*4)) = ClosestDiscretizedArgb(tls, **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4)), limit_bits)
  27326 				}
  27327 				goto _2
  27328 			_2:
  27329 				;
  27330 				x = x + 1
  27331 			}
  27332 		}
  27333 		// Three-way swap.
  27334 		temp = prev_row
  27335 		prev_row = curr_row
  27336 		curr_row = next_row
  27337 		next_row = temp
  27338 		goto _1
  27339 	_1:
  27340 		;
  27341 		y = y + 1
  27342 		argb_src = argb_src + uintptr(stride)*4
  27343 		argb_dst = argb_dst + uintptr(xsize)*4
  27344 	}
  27345 }
  27346 
  27347 func VP8ApplyNearLossless(tls *libc.TLS, picture uintptr, quality int32, argb_dst uintptr) (r int32) {
  27348 	var copy_buffer uintptr
  27349 	var i, limit_bits, stride, xsize, ysize, v1 int32
  27350 	_, _, _, _, _, _, _ = copy_buffer, i, limit_bits, stride, xsize, ysize, v1
  27351 	xsize = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  27352 	ysize = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  27353 	stride = (*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride
  27354 	copy_buffer = WebPSafeMalloc(tls, libc.Uint64FromInt32(xsize*int32(3)), uint64(4))
  27355 	v1 = int32(5) - quality/int32(20)
  27356 	goto _2
  27357 _2:
  27358 	limit_bits = v1
  27359 	if copy_buffer == libc.UintptrFromInt32(0) {
  27360 		return 0
  27361 	}
  27362 	// For small icon images, don't attempt to apply near-lossless compression.
  27363 	if xsize < int32(MIN_DIM_FOR_NEAR_LOSSLESS) && ysize < int32(MIN_DIM_FOR_NEAR_LOSSLESS) || ysize < int32(3) {
  27364 		i = 0
  27365 		for {
  27366 			if !(i < ysize) {
  27367 				break
  27368 			}
  27369 			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))
  27370 			goto _3
  27371 		_3:
  27372 			;
  27373 			i = i + 1
  27374 		}
  27375 		WebPSafeFree(tls, copy_buffer)
  27376 		return int32(1)
  27377 	}
  27378 	NearLossless(tls, xsize, ysize, (*WebPPicture)(unsafe.Pointer(picture)).Fargb, stride, limit_bits, copy_buffer, argb_dst)
  27379 	i = limit_bits - int32(1)
  27380 	for {
  27381 		if !(i != 0) {
  27382 			break
  27383 		}
  27384 		NearLossless(tls, xsize, ysize, argb_dst, xsize, i, copy_buffer, argb_dst)
  27385 		goto _4
  27386 	_4:
  27387 		;
  27388 		i = i - 1
  27389 	}
  27390 	WebPSafeFree(tls, copy_buffer)
  27391 	return int32(1)
  27392 }
  27393 
  27394 const GAMMA_FIX = 12
  27395 const GAMMA_TAB_FIX = 7
  27396 const SHARPYUV_INLINE = "inline"
  27397 const SHARPYUV_VERSION_MAJOR = 0
  27398 const SHARPYUV_VERSION_MINOR = 4
  27399 const SHARPYUV_VERSION_PATCH = 2
  27400 const __FLT_MIN__3 = 1.1754943508222875e-38
  27401 
  27402 type SharpYuvConversionMatrix = struct {
  27403 	Frgb_to_y [4]int32
  27404 	Frgb_to_u [4]int32
  27405 	Frgb_to_v [4]int32
  27406 }
  27407 
  27408 type SharpYuvOptions = struct {
  27409 	Fyuv_matrix    uintptr
  27410 	Ftransfer_type SharpYuvTransferFunctionType1
  27411 }
  27412 
  27413 type SharpYuvTransferFunctionType = int32
  27414 
  27415 const kSharpYuvTransferFunctionBt709 = 1
  27416 const kSharpYuvTransferFunctionBt470M = 4
  27417 const kSharpYuvTransferFunctionBt470Bg = 5
  27418 const kSharpYuvTransferFunctionBt601 = 6
  27419 const kSharpYuvTransferFunctionSmpte240 = 7
  27420 const kSharpYuvTransferFunctionLinear = 8
  27421 const kSharpYuvTransferFunctionLog100 = 9
  27422 const kSharpYuvTransferFunctionLog100_Sqrt10 = 10
  27423 const kSharpYuvTransferFunctionIec61966 = 11
  27424 const kSharpYuvTransferFunctionBt1361 = 12
  27425 const kSharpYuvTransferFunctionSrgb = 13
  27426 const kSharpYuvTransferFunctionBt2020_10Bit = 14
  27427 const kSharpYuvTransferFunctionBt2020_12Bit = 15
  27428 const kSharpYuvTransferFunctionSmpte2084 = 16
  27429 const kSharpYuvTransferFunctionSmpte428 = 17
  27430 const kSharpYuvTransferFunctionHlg = 18
  27431 const kSharpYuvTransferFunctionNum = 19
  27432 
  27433 type SharpYuvTransferFunctionType1 = int32
  27434 
  27435 type SharpYuvRange = int32
  27436 
  27437 const kSharpYuvRangeFull = 0
  27438 const kSharpYuvRangeLimited = 1
  27439 
  27440 type SharpYuvColorSpace = struct {
  27441 	Fkr        float32
  27442 	Fkb        float32
  27443 	Fbit_depth int32
  27444 	Frange1    SharpYuvRange
  27445 }
  27446 
  27447 type SharpYuvMatrixType = int32
  27448 
  27449 const kSharpYuvMatrixWebp = 0
  27450 const kSharpYuvMatrixRec601Limited = 1
  27451 const kSharpYuvMatrixRec601Full = 2
  27452 const kSharpYuvMatrixRec709Limited = 3
  27453 const kSharpYuvMatrixRec709Full = 4
  27454 const kSharpYuvMatrixNum = 5
  27455 
  27456 // Copyright 2012 Google Inc. All Rights Reserved.
  27457 //
  27458 // Use of this source code is governed by a BSD-style license
  27459 // that can be found in the COPYING file in the root of the source
  27460 // tree. An additional intellectual property rights grant can be found
  27461 // in the file PATENTS. All contributing project authors may
  27462 // be found in the AUTHORS file in the root of the source tree.
  27463 // -----------------------------------------------------------------------------
  27464 //
  27465 // Misc. common utility functions
  27466 //
  27467 // Authors: Skal (pascal.massimino@gmail.com)
  27468 //          Urvang (urvang@google.com)
  27469 
  27470 // Copyright 2011 Google Inc. All Rights Reserved.
  27471 //
  27472 // Use of this source code is governed by a BSD-style license
  27473 // that can be found in the COPYING file in the root of the source
  27474 // tree. An additional intellectual property rights grant can be found
  27475 // in the file PATENTS. All contributing project authors may
  27476 // be found in the AUTHORS file in the root of the source tree.
  27477 // -----------------------------------------------------------------------------
  27478 //
  27479 //   WebP encoder: main interface
  27480 //
  27481 // Author: Skal (pascal.massimino@gmail.com)
  27482 
  27483 // Copyright 2010 Google Inc. All Rights Reserved.
  27484 //
  27485 // Use of this source code is governed by a BSD-style license
  27486 // that can be found in the COPYING file in the root of the source
  27487 // tree. An additional intellectual property rights grant can be found
  27488 // in the file PATENTS. All contributing project authors may
  27489 // be found in the AUTHORS file in the root of the source tree.
  27490 // -----------------------------------------------------------------------------
  27491 //
  27492 //  Common types + memory wrappers
  27493 //
  27494 // Author: Skal (pascal.massimino@gmail.com)
  27495 
  27496 // Uncomment to disable gamma-compression during RGB->U/V averaging
  27497 
  27498 // If defined, use table to compute x / alpha.
  27499 
  27500 // uint32_t 0xff000000 is 0x00,00,00,ff in memory
  27501 
  27502 //------------------------------------------------------------------------------
  27503 // Detection of non-trivial transparency
  27504 
  27505 // C documentation
  27506 //
  27507 //	// Returns true if alpha[] has non-0xff values.
  27508 func CheckNonOpaque(tls *libc.TLS, alpha uintptr, width int32, height int32, x_step int32, y_step int32) (r int32) {
  27509 	var v2 int32
  27510 	_ = v2
  27511 	if alpha == libc.UintptrFromInt32(0) {
  27512 		return 0
  27513 	}
  27514 	WebPInitAlphaProcessing(tls)
  27515 	if x_step == int32(1) {
  27516 		for {
  27517 			v2 = height
  27518 			height = height - 1
  27519 			if !(v2 > 0) {
  27520 				break
  27521 			}
  27522 			if (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPHasAlpha8b})))(tls, alpha, width) != 0 {
  27523 				return int32(1)
  27524 			}
  27525 			goto _1
  27526 		_1:
  27527 			;
  27528 			alpha = alpha + uintptr(y_step)
  27529 		}
  27530 	} else {
  27531 		for {
  27532 			v2 = height
  27533 			height = height - 1
  27534 			if !(v2 > 0) {
  27535 				break
  27536 			}
  27537 			if (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{WebPHasAlpha32b})))(tls, alpha, width) != 0 {
  27538 				return int32(1)
  27539 			}
  27540 			goto _3
  27541 		_3:
  27542 			;
  27543 			alpha = alpha + uintptr(y_step)
  27544 		}
  27545 	}
  27546 	return 0
  27547 }
  27548 
  27549 // C documentation
  27550 //
  27551 //	// Checking for the presence of non-opaque alpha.
  27552 func WebPPictureHasTransparency(tls *libc.TLS, picture uintptr) (r int32) {
  27553 	if picture == libc.UintptrFromInt32(0) {
  27554 		return 0
  27555 	}
  27556 	if (*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0 {
  27557 		if (*WebPPicture)(unsafe.Pointer(picture)).Fargb != libc.UintptrFromInt32(0) {
  27558 			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)))
  27559 		}
  27560 		return 0
  27561 	}
  27562 	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)
  27563 }
  27564 
  27565 //------------------------------------------------------------------------------
  27566 // Code for gamma correction
  27567 
  27568 // C documentation
  27569 //
  27570 //	// Gamma correction compensates loss of resolution during chroma subsampling.
  27571 var kGamma = float64(0.8)
  27572 var kGammaScale = libc.Int32FromInt32(1)<<libc.Int32FromInt32(GAMMA_FIX) - libc.Int32FromInt32(1)
  27573 var kGammaTabScale = libc.Int32FromInt32(1) << libc.Int32FromInt32(GAMMA_TAB_FIX)
  27574 var kGammaTabRounder = libc.Int32FromInt32(1) << libc.Int32FromInt32(GAMMA_TAB_FIX) >> libc.Int32FromInt32(1)
  27575 
  27576 var kLinearToGammaTab [33]int32
  27577 var kGammaToLinearTab [256]uint16_t
  27578 var kGammaTablesOk = int32(0)
  27579 
  27580 func InitGammaTables(tls *libc.TLS) {
  27581 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  27582 		goto _1
  27583 	}
  27584 	InitGammaTables_body(tls)
  27585 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used)), VP8GetCPUInfo)
  27586 	goto _2
  27587 _2:
  27588 	;
  27589 	goto _1
  27590 _1: /**/ //
  27591 }
  27592 
  27593 var InitGammaTables_body_last_cpuinfo_used = uintptr(0)
  27594 
  27595 func init() {
  27596 	p := unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used)
  27597 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&InitGammaTables_body_last_cpuinfo_used))
  27598 }
  27599 
  27600 func InitGammaTables_body(tls *libc.TLS) {
  27601 	var norm, scale float64
  27602 	var v int32
  27603 	_, _, _ = norm, scale, v
  27604 	if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&kGammaTablesOk))) != 0) {
  27605 		scale = float64(libc.Int32FromInt32(1)<<libc.Int32FromInt32(GAMMA_TAB_FIX)) / float64(kGammaScale)
  27606 		norm = libc.Float64FromFloat64(1) / libc.Float64FromFloat64(255)
  27607 		v = 0
  27608 		for {
  27609 			if !(v <= int32(255)) {
  27610 				break
  27611 			}
  27612 			kGammaToLinearTab[v] = uint16(float64(libc.Xpow(tls, float64(norm*float64(v)), kGamma)*float64(kGammaScale)) + libc.Float64FromFloat64(0.5))
  27613 			goto _1
  27614 		_1:
  27615 			;
  27616 			v = v + 1
  27617 		}
  27618 		v = 0
  27619 		for {
  27620 			if !(v <= libc.Int32FromInt32(1)<<(libc.Int32FromInt32(GAMMA_FIX)-libc.Int32FromInt32(GAMMA_TAB_FIX))) {
  27621 				break
  27622 			}
  27623 			kLinearToGammaTab[v] = int32(float64(libc.Float64FromFloat64(255)*libc.Xpow(tls, float64(scale*float64(v)), float64(1)/kGamma)) + libc.Float64FromFloat64(0.5))
  27624 			goto _2
  27625 		_2:
  27626 			;
  27627 			v = v + 1
  27628 		}
  27629 		libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&kGammaTablesOk)), int32(1))
  27630 	}
  27631 }
  27632 
  27633 func GammaToLinear(tls *libc.TLS, v uint8_t) (r uint32_t) {
  27634 	return uint32(kGammaToLinearTab[v])
  27635 }
  27636 
  27637 func Interpolate(tls *libc.TLS, v int32) (r int32) {
  27638 	var tab_pos, v0, v1, x, y int32
  27639 	_, _, _, _, _ = tab_pos, v0, v1, x, y
  27640 	tab_pos = v >> (libc.Int32FromInt32(GAMMA_TAB_FIX) + libc.Int32FromInt32(2)) // integer part
  27641 	x = v & (kGammaTabScale<<libc.Int32FromInt32(2) - int32(1))                  // fractional part
  27642 	v0 = kLinearToGammaTab[tab_pos]
  27643 	v1 = kLinearToGammaTab[tab_pos+int32(1)]
  27644 	y = v1*x + v0*(kGammaTabScale<<libc.Int32FromInt32(2)-x) // interpolate
  27645 	return y
  27646 }
  27647 
  27648 // C documentation
  27649 //
  27650 //	// Convert a linear value 'v' to YUV_FIX+2 fixed-point precision
  27651 //	// U/V value, suitable for RGBToU/V calls.
  27652 func LinearToGamma(tls *libc.TLS, base_value uint32_t, shift int32) (r int32) {
  27653 	var y int32
  27654 	_ = y
  27655 	y = Interpolate(tls, libc.Int32FromUint32(base_value<<shift)) // final uplifted value
  27656 	return (y + kGammaTabRounder) >> int32(GAMMA_TAB_FIX)         // descale
  27657 }
  27658 
  27659 //------------------------------------------------------------------------------
  27660 // RGB -> YUV conversion
  27661 
  27662 func RGBToY(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27663 	var diff, luma, v1, v11, v13, v15, v2, v5, v8, v9 int32
  27664 	var v10, v12, v4, v7 uintptr
  27665 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, luma, v1, v10, v11, v12, v13, v15, v2, v4, v5, v7, v8, v9
  27666 	if rg2 == libc.UintptrFromInt32(0) {
  27667 		luma = int32(16839)*r1 + int32(33059)*g1 + int32(6420)*b1
  27668 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  27669 		goto _3
  27670 	_3:
  27671 		v1 = v2
  27672 	} else {
  27673 		v4 = rg2
  27674 		v7 = v4
  27675 		v8 = int32(YUV_FIX)
  27676 		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)))
  27677 		if diff < libc.Int32FromInt32(0) {
  27678 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27679 		}
  27680 		**(**uint32_t)(__ccgo_up(v7 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v7)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27681 		v10 = v7
  27682 		*(*int32)(unsafe.Pointer(v10)) = *(*int32)(unsafe.Pointer(v10)) + 1
  27683 		v9 = *(*int32)(unsafe.Pointer(v10))
  27684 		if v9 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27685 			(*VP8Random)(unsafe.Pointer(v7)).Findex1 = 0
  27686 		}
  27687 		v12 = v7 + 4
  27688 		*(*int32)(unsafe.Pointer(v12)) = *(*int32)(unsafe.Pointer(v12)) + 1
  27689 		v11 = *(*int32)(unsafe.Pointer(v12))
  27690 		if v11 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27691 			(*VP8Random)(unsafe.Pointer(v7)).Findex2 = 0
  27692 		}
  27693 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v8)
  27694 		diff = diff * (*VP8Random)(unsafe.Pointer(v4)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27695 		diff = diff + int32(1)<<(v8-int32(1))
  27696 		v13 = diff
  27697 		goto _14
  27698 	_14:
  27699 		v5 = v13
  27700 		goto _6
  27701 	_6:
  27702 		luma = int32(16839)*r1 + int32(33059)*g1 + int32(6420)*b1
  27703 		v15 = (luma + v5 + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  27704 		goto _16
  27705 	_16:
  27706 		v1 = v15
  27707 	}
  27708 	return v1
  27709 }
  27710 
  27711 func RGBToU(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27712 	var diff, u, v1, v10, v13, v14, v16, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8 int32
  27713 	var v12, v15, v17, v9 uintptr
  27714 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, u, v1, v10, v12, v13, v14, v15, v16, v17, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8, v9
  27715 	if rg2 == libc.UintptrFromInt32(0) {
  27716 		u = -int32(9719)*r1 - int32(19081)*g1 + int32(28800)*b1
  27717 		v4 = u
  27718 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27719 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  27720 			v7 = v4
  27721 		} else {
  27722 			if v4 < 0 {
  27723 				v8 = 0
  27724 			} else {
  27725 				v8 = int32(255)
  27726 			}
  27727 			v7 = v8
  27728 		}
  27729 		v5 = v7
  27730 		goto _6
  27731 	_6:
  27732 		v2 = v5
  27733 		goto _3
  27734 	_3:
  27735 		v1 = v2
  27736 	} else {
  27737 		v9 = rg2
  27738 		v12 = v9
  27739 		v13 = int32(YUV_FIX) + libc.Int32FromInt32(2)
  27740 		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)))
  27741 		if diff < libc.Int32FromInt32(0) {
  27742 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27743 		}
  27744 		**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27745 		v15 = v12
  27746 		*(*int32)(unsafe.Pointer(v15)) = *(*int32)(unsafe.Pointer(v15)) + 1
  27747 		v14 = *(*int32)(unsafe.Pointer(v15))
  27748 		if v14 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27749 			(*VP8Random)(unsafe.Pointer(v12)).Findex1 = 0
  27750 		}
  27751 		v17 = v12 + 4
  27752 		*(*int32)(unsafe.Pointer(v17)) = *(*int32)(unsafe.Pointer(v17)) + 1
  27753 		v16 = *(*int32)(unsafe.Pointer(v17))
  27754 		if v16 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27755 			(*VP8Random)(unsafe.Pointer(v12)).Findex2 = 0
  27756 		}
  27757 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v13)
  27758 		diff = diff * (*VP8Random)(unsafe.Pointer(v9)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27759 		diff = diff + int32(1)<<(v13-int32(1))
  27760 		v18 = diff
  27761 		goto _19
  27762 	_19:
  27763 		v10 = v18
  27764 		goto _11
  27765 	_11:
  27766 		u = -int32(9719)*r1 - int32(19081)*g1 + int32(28800)*b1
  27767 		v22 = u
  27768 		v22 = (v22 + v10 + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27769 		if v22 & ^libc.Int32FromInt32(0xff) == 0 {
  27770 			v25 = v22
  27771 		} else {
  27772 			if v22 < 0 {
  27773 				v26 = 0
  27774 			} else {
  27775 				v26 = int32(255)
  27776 			}
  27777 			v25 = v26
  27778 		}
  27779 		v23 = v25
  27780 		goto _24
  27781 	_24:
  27782 		v20 = v23
  27783 		goto _21
  27784 	_21:
  27785 		v1 = v20
  27786 	}
  27787 	return v1
  27788 }
  27789 
  27790 func RGBToV(tls *libc.TLS, r1 int32, g1 int32, b1 int32, rg2 uintptr) (r int32) {
  27791 	var diff, v, v1, v10, v13, v14, v16, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8 int32
  27792 	var v12, v15, v17, v9 uintptr
  27793 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = diff, v, v1, v10, v12, v13, v14, v15, v16, v17, v18, v2, v20, v22, v23, v25, v26, v4, v5, v7, v8, v9
  27794 	if rg2 == libc.UintptrFromInt32(0) {
  27795 		v = +libc.Int32FromInt32(28800)*r1 - int32(24116)*g1 - int32(4684)*b1
  27796 		v4 = v
  27797 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27798 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  27799 			v7 = v4
  27800 		} else {
  27801 			if v4 < 0 {
  27802 				v8 = 0
  27803 			} else {
  27804 				v8 = int32(255)
  27805 			}
  27806 			v7 = v8
  27807 		}
  27808 		v5 = v7
  27809 		goto _6
  27810 	_6:
  27811 		v2 = v5
  27812 		goto _3
  27813 	_3:
  27814 		v1 = v2
  27815 	} else {
  27816 		v9 = rg2
  27817 		v12 = v9
  27818 		v13 = int32(YUV_FIX) + libc.Int32FromInt32(2)
  27819 		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)))
  27820 		if diff < libc.Int32FromInt32(0) {
  27821 			diff = libc.Int32FromUint32(uint32(diff) + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(31))
  27822 		}
  27823 		**(**uint32_t)(__ccgo_up(v12 + 8 + uintptr((*VP8Random)(unsafe.Pointer(v12)).Findex1)*4)) = libc.Uint32FromInt32(diff)
  27824 		v15 = v12
  27825 		*(*int32)(unsafe.Pointer(v15)) = *(*int32)(unsafe.Pointer(v15)) + 1
  27826 		v14 = *(*int32)(unsafe.Pointer(v15))
  27827 		if v14 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27828 			(*VP8Random)(unsafe.Pointer(v12)).Findex1 = 0
  27829 		}
  27830 		v17 = v12 + 4
  27831 		*(*int32)(unsafe.Pointer(v17)) = *(*int32)(unsafe.Pointer(v17)) + 1
  27832 		v16 = *(*int32)(unsafe.Pointer(v17))
  27833 		if v16 == libc.Int32FromInt32(VP8_RANDOM_TABLE_SIZE) {
  27834 			(*VP8Random)(unsafe.Pointer(v12)).Findex2 = 0
  27835 		}
  27836 		diff = libc.Int32FromUint32(libc.Uint32FromInt32(diff)<<libc.Int32FromInt32(1)) >> (int32(32) - v13)
  27837 		diff = diff * (*VP8Random)(unsafe.Pointer(v9)).Famp >> int32(VP8_RANDOM_DITHER_FIX)
  27838 		diff = diff + int32(1)<<(v13-int32(1))
  27839 		v18 = diff
  27840 		goto _19
  27841 	_19:
  27842 		v10 = v18
  27843 		goto _11
  27844 	_11:
  27845 		v = +libc.Int32FromInt32(28800)*r1 - int32(24116)*g1 - int32(4684)*b1
  27846 		v22 = v
  27847 		v22 = (v22 + v10 + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  27848 		if v22 & ^libc.Int32FromInt32(0xff) == 0 {
  27849 			v25 = v22
  27850 		} else {
  27851 			if v22 < 0 {
  27852 				v26 = 0
  27853 			} else {
  27854 				v26 = int32(255)
  27855 			}
  27856 			v25 = v26
  27857 		}
  27858 		v23 = v25
  27859 		goto _24
  27860 	_24:
  27861 		v20 = v23
  27862 		goto _21
  27863 	_21:
  27864 		v1 = v20
  27865 	}
  27866 	return v1
  27867 }
  27868 
  27869 //------------------------------------------------------------------------------
  27870 // Sharp RGB->YUV conversion
  27871 
  27872 var kMinDimensionIterativeConversion = int32(4)
  27873 
  27874 //------------------------------------------------------------------------------
  27875 // Main function
  27876 
  27877 func PreprocessARGB(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, rgb_stride int32, picture uintptr) (r int32) {
  27878 	var ok int32
  27879 	_ = ok
  27880 	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)))
  27881 	if !(ok != 0) {
  27882 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  27883 	}
  27884 	return ok
  27885 }
  27886 
  27887 //------------------------------------------------------------------------------
  27888 // "Fast" regular RGB->YUV
  27889 
  27890 var kAlphaFix = int32(19)
  27891 
  27892 // C documentation
  27893 //
  27894 //	// Following table is (1 << kAlphaFix) / a. The (v * kInvAlpha[a]) >> kAlphaFix
  27895 //	// formula is then equal to v / a in most (99.6%) cases. Note that this table
  27896 //	// and constant are adjusted very tightly to fit 32b arithmetic.
  27897 //	// In particular, they use the fact that the operands for 'v / a' are actually
  27898 //	// derived as v = (a0.p0 + a1.p1 + a2.p2 + a3.p3) and a = a0 + a1 + a2 + a3
  27899 //	// with ai in [0..255] and pi in [0..1<<GAMMA_FIX). The constraint to avoid
  27900 //	// overflow is: GAMMA_FIX + kAlphaFix <= 31.
  27901 var kInvAlpha = [1021]uint32_t{
  27902 	1:    uint32(524288),
  27903 	2:    uint32(262144),
  27904 	3:    uint32(174762),
  27905 	4:    uint32(131072),
  27906 	5:    uint32(104857),
  27907 	6:    uint32(87381),
  27908 	7:    uint32(74898),
  27909 	8:    uint32(65536),
  27910 	9:    uint32(58254),
  27911 	10:   uint32(52428),
  27912 	11:   uint32(47662),
  27913 	12:   uint32(43690),
  27914 	13:   uint32(40329),
  27915 	14:   uint32(37449),
  27916 	15:   uint32(34952),
  27917 	16:   uint32(32768),
  27918 	17:   uint32(30840),
  27919 	18:   uint32(29127),
  27920 	19:   uint32(27594),
  27921 	20:   uint32(26214),
  27922 	21:   uint32(24966),
  27923 	22:   uint32(23831),
  27924 	23:   uint32(22795),
  27925 	24:   uint32(21845),
  27926 	25:   uint32(20971),
  27927 	26:   uint32(20164),
  27928 	27:   uint32(19418),
  27929 	28:   uint32(18724),
  27930 	29:   uint32(18078),
  27931 	30:   uint32(17476),
  27932 	31:   uint32(16912),
  27933 	32:   uint32(16384),
  27934 	33:   uint32(15887),
  27935 	34:   uint32(15420),
  27936 	35:   uint32(14979),
  27937 	36:   uint32(14563),
  27938 	37:   uint32(14169),
  27939 	38:   uint32(13797),
  27940 	39:   uint32(13443),
  27941 	40:   uint32(13107),
  27942 	41:   uint32(12787),
  27943 	42:   uint32(12483),
  27944 	43:   uint32(12192),
  27945 	44:   uint32(11915),
  27946 	45:   uint32(11650),
  27947 	46:   uint32(11397),
  27948 	47:   uint32(11155),
  27949 	48:   uint32(10922),
  27950 	49:   uint32(10699),
  27951 	50:   uint32(10485),
  27952 	51:   uint32(10280),
  27953 	52:   uint32(10082),
  27954 	53:   uint32(9892),
  27955 	54:   uint32(9709),
  27956 	55:   uint32(9532),
  27957 	56:   uint32(9362),
  27958 	57:   uint32(9198),
  27959 	58:   uint32(9039),
  27960 	59:   uint32(8886),
  27961 	60:   uint32(8738),
  27962 	61:   uint32(8594),
  27963 	62:   uint32(8456),
  27964 	63:   uint32(8322),
  27965 	64:   uint32(8192),
  27966 	65:   uint32(8065),
  27967 	66:   uint32(7943),
  27968 	67:   uint32(7825),
  27969 	68:   uint32(7710),
  27970 	69:   uint32(7598),
  27971 	70:   uint32(7489),
  27972 	71:   uint32(7384),
  27973 	72:   uint32(7281),
  27974 	73:   uint32(7182),
  27975 	74:   uint32(7084),
  27976 	75:   uint32(6990),
  27977 	76:   uint32(6898),
  27978 	77:   uint32(6808),
  27979 	78:   uint32(6721),
  27980 	79:   uint32(6636),
  27981 	80:   uint32(6553),
  27982 	81:   uint32(6472),
  27983 	82:   uint32(6393),
  27984 	83:   uint32(6316),
  27985 	84:   uint32(6241),
  27986 	85:   uint32(6168),
  27987 	86:   uint32(6096),
  27988 	87:   uint32(6026),
  27989 	88:   uint32(5957),
  27990 	89:   uint32(5890),
  27991 	90:   uint32(5825),
  27992 	91:   uint32(5761),
  27993 	92:   uint32(5698),
  27994 	93:   uint32(5637),
  27995 	94:   uint32(5577),
  27996 	95:   uint32(5518),
  27997 	96:   uint32(5461),
  27998 	97:   uint32(5405),
  27999 	98:   uint32(5349),
  28000 	99:   uint32(5295),
  28001 	100:  uint32(5242),
  28002 	101:  uint32(5190),
  28003 	102:  uint32(5140),
  28004 	103:  uint32(5090),
  28005 	104:  uint32(5041),
  28006 	105:  uint32(4993),
  28007 	106:  uint32(4946),
  28008 	107:  uint32(4899),
  28009 	108:  uint32(4854),
  28010 	109:  uint32(4809),
  28011 	110:  uint32(4766),
  28012 	111:  uint32(4723),
  28013 	112:  uint32(4681),
  28014 	113:  uint32(4639),
  28015 	114:  uint32(4599),
  28016 	115:  uint32(4559),
  28017 	116:  uint32(4519),
  28018 	117:  uint32(4481),
  28019 	118:  uint32(4443),
  28020 	119:  uint32(4405),
  28021 	120:  uint32(4369),
  28022 	121:  uint32(4332),
  28023 	122:  uint32(4297),
  28024 	123:  uint32(4262),
  28025 	124:  uint32(4228),
  28026 	125:  uint32(4194),
  28027 	126:  uint32(4161),
  28028 	127:  uint32(4128),
  28029 	128:  uint32(4096),
  28030 	129:  uint32(4064),
  28031 	130:  uint32(4032),
  28032 	131:  uint32(4002),
  28033 	132:  uint32(3971),
  28034 	133:  uint32(3942),
  28035 	134:  uint32(3912),
  28036 	135:  uint32(3883),
  28037 	136:  uint32(3855),
  28038 	137:  uint32(3826),
  28039 	138:  uint32(3799),
  28040 	139:  uint32(3771),
  28041 	140:  uint32(3744),
  28042 	141:  uint32(3718),
  28043 	142:  uint32(3692),
  28044 	143:  uint32(3666),
  28045 	144:  uint32(3640),
  28046 	145:  uint32(3615),
  28047 	146:  uint32(3591),
  28048 	147:  uint32(3566),
  28049 	148:  uint32(3542),
  28050 	149:  uint32(3518),
  28051 	150:  uint32(3495),
  28052 	151:  uint32(3472),
  28053 	152:  uint32(3449),
  28054 	153:  uint32(3426),
  28055 	154:  uint32(3404),
  28056 	155:  uint32(3382),
  28057 	156:  uint32(3360),
  28058 	157:  uint32(3339),
  28059 	158:  uint32(3318),
  28060 	159:  uint32(3297),
  28061 	160:  uint32(3276),
  28062 	161:  uint32(3256),
  28063 	162:  uint32(3236),
  28064 	163:  uint32(3216),
  28065 	164:  uint32(3196),
  28066 	165:  uint32(3177),
  28067 	166:  uint32(3158),
  28068 	167:  uint32(3139),
  28069 	168:  uint32(3120),
  28070 	169:  uint32(3102),
  28071 	170:  uint32(3084),
  28072 	171:  uint32(3066),
  28073 	172:  uint32(3048),
  28074 	173:  uint32(3030),
  28075 	174:  uint32(3013),
  28076 	175:  uint32(2995),
  28077 	176:  uint32(2978),
  28078 	177:  uint32(2962),
  28079 	178:  uint32(2945),
  28080 	179:  uint32(2928),
  28081 	180:  uint32(2912),
  28082 	181:  uint32(2896),
  28083 	182:  uint32(2880),
  28084 	183:  uint32(2864),
  28085 	184:  uint32(2849),
  28086 	185:  uint32(2833),
  28087 	186:  uint32(2818),
  28088 	187:  uint32(2803),
  28089 	188:  uint32(2788),
  28090 	189:  uint32(2774),
  28091 	190:  uint32(2759),
  28092 	191:  uint32(2744),
  28093 	192:  uint32(2730),
  28094 	193:  uint32(2716),
  28095 	194:  uint32(2702),
  28096 	195:  uint32(2688),
  28097 	196:  uint32(2674),
  28098 	197:  uint32(2661),
  28099 	198:  uint32(2647),
  28100 	199:  uint32(2634),
  28101 	200:  uint32(2621),
  28102 	201:  uint32(2608),
  28103 	202:  uint32(2595),
  28104 	203:  uint32(2582),
  28105 	204:  uint32(2570),
  28106 	205:  uint32(2557),
  28107 	206:  uint32(2545),
  28108 	207:  uint32(2532),
  28109 	208:  uint32(2520),
  28110 	209:  uint32(2508),
  28111 	210:  uint32(2496),
  28112 	211:  uint32(2484),
  28113 	212:  uint32(2473),
  28114 	213:  uint32(2461),
  28115 	214:  uint32(2449),
  28116 	215:  uint32(2438),
  28117 	216:  uint32(2427),
  28118 	217:  uint32(2416),
  28119 	218:  uint32(2404),
  28120 	219:  uint32(2394),
  28121 	220:  uint32(2383),
  28122 	221:  uint32(2372),
  28123 	222:  uint32(2361),
  28124 	223:  uint32(2351),
  28125 	224:  uint32(2340),
  28126 	225:  uint32(2330),
  28127 	226:  uint32(2319),
  28128 	227:  uint32(2309),
  28129 	228:  uint32(2299),
  28130 	229:  uint32(2289),
  28131 	230:  uint32(2279),
  28132 	231:  uint32(2269),
  28133 	232:  uint32(2259),
  28134 	233:  uint32(2250),
  28135 	234:  uint32(2240),
  28136 	235:  uint32(2231),
  28137 	236:  uint32(2221),
  28138 	237:  uint32(2212),
  28139 	238:  uint32(2202),
  28140 	239:  uint32(2193),
  28141 	240:  uint32(2184),
  28142 	241:  uint32(2175),
  28143 	242:  uint32(2166),
  28144 	243:  uint32(2157),
  28145 	244:  uint32(2148),
  28146 	245:  uint32(2139),
  28147 	246:  uint32(2131),
  28148 	247:  uint32(2122),
  28149 	248:  uint32(2114),
  28150 	249:  uint32(2105),
  28151 	250:  uint32(2097),
  28152 	251:  uint32(2088),
  28153 	252:  uint32(2080),
  28154 	253:  uint32(2072),
  28155 	254:  uint32(2064),
  28156 	255:  uint32(2056),
  28157 	256:  uint32(2048),
  28158 	257:  uint32(2040),
  28159 	258:  uint32(2032),
  28160 	259:  uint32(2024),
  28161 	260:  uint32(2016),
  28162 	261:  uint32(2008),
  28163 	262:  uint32(2001),
  28164 	263:  uint32(1993),
  28165 	264:  uint32(1985),
  28166 	265:  uint32(1978),
  28167 	266:  uint32(1971),
  28168 	267:  uint32(1963),
  28169 	268:  uint32(1956),
  28170 	269:  uint32(1949),
  28171 	270:  uint32(1941),
  28172 	271:  uint32(1934),
  28173 	272:  uint32(1927),
  28174 	273:  uint32(1920),
  28175 	274:  uint32(1913),
  28176 	275:  uint32(1906),
  28177 	276:  uint32(1899),
  28178 	277:  uint32(1892),
  28179 	278:  uint32(1885),
  28180 	279:  uint32(1879),
  28181 	280:  uint32(1872),
  28182 	281:  uint32(1865),
  28183 	282:  uint32(1859),
  28184 	283:  uint32(1852),
  28185 	284:  uint32(1846),
  28186 	285:  uint32(1839),
  28187 	286:  uint32(1833),
  28188 	287:  uint32(1826),
  28189 	288:  uint32(1820),
  28190 	289:  uint32(1814),
  28191 	290:  uint32(1807),
  28192 	291:  uint32(1801),
  28193 	292:  uint32(1795),
  28194 	293:  uint32(1789),
  28195 	294:  uint32(1783),
  28196 	295:  uint32(1777),
  28197 	296:  uint32(1771),
  28198 	297:  uint32(1765),
  28199 	298:  uint32(1759),
  28200 	299:  uint32(1753),
  28201 	300:  uint32(1747),
  28202 	301:  uint32(1741),
  28203 	302:  uint32(1736),
  28204 	303:  uint32(1730),
  28205 	304:  uint32(1724),
  28206 	305:  uint32(1718),
  28207 	306:  uint32(1713),
  28208 	307:  uint32(1707),
  28209 	308:  uint32(1702),
  28210 	309:  uint32(1696),
  28211 	310:  uint32(1691),
  28212 	311:  uint32(1685),
  28213 	312:  uint32(1680),
  28214 	313:  uint32(1675),
  28215 	314:  uint32(1669),
  28216 	315:  uint32(1664),
  28217 	316:  uint32(1659),
  28218 	317:  uint32(1653),
  28219 	318:  uint32(1648),
  28220 	319:  uint32(1643),
  28221 	320:  uint32(1638),
  28222 	321:  uint32(1633),
  28223 	322:  uint32(1628),
  28224 	323:  uint32(1623),
  28225 	324:  uint32(1618),
  28226 	325:  uint32(1613),
  28227 	326:  uint32(1608),
  28228 	327:  uint32(1603),
  28229 	328:  uint32(1598),
  28230 	329:  uint32(1593),
  28231 	330:  uint32(1588),
  28232 	331:  uint32(1583),
  28233 	332:  uint32(1579),
  28234 	333:  uint32(1574),
  28235 	334:  uint32(1569),
  28236 	335:  uint32(1565),
  28237 	336:  uint32(1560),
  28238 	337:  uint32(1555),
  28239 	338:  uint32(1551),
  28240 	339:  uint32(1546),
  28241 	340:  uint32(1542),
  28242 	341:  uint32(1537),
  28243 	342:  uint32(1533),
  28244 	343:  uint32(1528),
  28245 	344:  uint32(1524),
  28246 	345:  uint32(1519),
  28247 	346:  uint32(1515),
  28248 	347:  uint32(1510),
  28249 	348:  uint32(1506),
  28250 	349:  uint32(1502),
  28251 	350:  uint32(1497),
  28252 	351:  uint32(1493),
  28253 	352:  uint32(1489),
  28254 	353:  uint32(1485),
  28255 	354:  uint32(1481),
  28256 	355:  uint32(1476),
  28257 	356:  uint32(1472),
  28258 	357:  uint32(1468),
  28259 	358:  uint32(1464),
  28260 	359:  uint32(1460),
  28261 	360:  uint32(1456),
  28262 	361:  uint32(1452),
  28263 	362:  uint32(1448),
  28264 	363:  uint32(1444),
  28265 	364:  uint32(1440),
  28266 	365:  uint32(1436),
  28267 	366:  uint32(1432),
  28268 	367:  uint32(1428),
  28269 	368:  uint32(1424),
  28270 	369:  uint32(1420),
  28271 	370:  uint32(1416),
  28272 	371:  uint32(1413),
  28273 	372:  uint32(1409),
  28274 	373:  uint32(1405),
  28275 	374:  uint32(1401),
  28276 	375:  uint32(1398),
  28277 	376:  uint32(1394),
  28278 	377:  uint32(1390),
  28279 	378:  uint32(1387),
  28280 	379:  uint32(1383),
  28281 	380:  uint32(1379),
  28282 	381:  uint32(1376),
  28283 	382:  uint32(1372),
  28284 	383:  uint32(1368),
  28285 	384:  uint32(1365),
  28286 	385:  uint32(1361),
  28287 	386:  uint32(1358),
  28288 	387:  uint32(1354),
  28289 	388:  uint32(1351),
  28290 	389:  uint32(1347),
  28291 	390:  uint32(1344),
  28292 	391:  uint32(1340),
  28293 	392:  uint32(1337),
  28294 	393:  uint32(1334),
  28295 	394:  uint32(1330),
  28296 	395:  uint32(1327),
  28297 	396:  uint32(1323),
  28298 	397:  uint32(1320),
  28299 	398:  uint32(1317),
  28300 	399:  uint32(1314),
  28301 	400:  uint32(1310),
  28302 	401:  uint32(1307),
  28303 	402:  uint32(1304),
  28304 	403:  uint32(1300),
  28305 	404:  uint32(1297),
  28306 	405:  uint32(1294),
  28307 	406:  uint32(1291),
  28308 	407:  uint32(1288),
  28309 	408:  uint32(1285),
  28310 	409:  uint32(1281),
  28311 	410:  uint32(1278),
  28312 	411:  uint32(1275),
  28313 	412:  uint32(1272),
  28314 	413:  uint32(1269),
  28315 	414:  uint32(1266),
  28316 	415:  uint32(1263),
  28317 	416:  uint32(1260),
  28318 	417:  uint32(1257),
  28319 	418:  uint32(1254),
  28320 	419:  uint32(1251),
  28321 	420:  uint32(1248),
  28322 	421:  uint32(1245),
  28323 	422:  uint32(1242),
  28324 	423:  uint32(1239),
  28325 	424:  uint32(1236),
  28326 	425:  uint32(1233),
  28327 	426:  uint32(1230),
  28328 	427:  uint32(1227),
  28329 	428:  uint32(1224),
  28330 	429:  uint32(1222),
  28331 	430:  uint32(1219),
  28332 	431:  uint32(1216),
  28333 	432:  uint32(1213),
  28334 	433:  uint32(1210),
  28335 	434:  uint32(1208),
  28336 	435:  uint32(1205),
  28337 	436:  uint32(1202),
  28338 	437:  uint32(1199),
  28339 	438:  uint32(1197),
  28340 	439:  uint32(1194),
  28341 	440:  uint32(1191),
  28342 	441:  uint32(1188),
  28343 	442:  uint32(1186),
  28344 	443:  uint32(1183),
  28345 	444:  uint32(1180),
  28346 	445:  uint32(1178),
  28347 	446:  uint32(1175),
  28348 	447:  uint32(1172),
  28349 	448:  uint32(1170),
  28350 	449:  uint32(1167),
  28351 	450:  uint32(1165),
  28352 	451:  uint32(1162),
  28353 	452:  uint32(1159),
  28354 	453:  uint32(1157),
  28355 	454:  uint32(1154),
  28356 	455:  uint32(1152),
  28357 	456:  uint32(1149),
  28358 	457:  uint32(1147),
  28359 	458:  uint32(1144),
  28360 	459:  uint32(1142),
  28361 	460:  uint32(1139),
  28362 	461:  uint32(1137),
  28363 	462:  uint32(1134),
  28364 	463:  uint32(1132),
  28365 	464:  uint32(1129),
  28366 	465:  uint32(1127),
  28367 	466:  uint32(1125),
  28368 	467:  uint32(1122),
  28369 	468:  uint32(1120),
  28370 	469:  uint32(1117),
  28371 	470:  uint32(1115),
  28372 	471:  uint32(1113),
  28373 	472:  uint32(1110),
  28374 	473:  uint32(1108),
  28375 	474:  uint32(1106),
  28376 	475:  uint32(1103),
  28377 	476:  uint32(1101),
  28378 	477:  uint32(1099),
  28379 	478:  uint32(1096),
  28380 	479:  uint32(1094),
  28381 	480:  uint32(1092),
  28382 	481:  uint32(1089),
  28383 	482:  uint32(1087),
  28384 	483:  uint32(1085),
  28385 	484:  uint32(1083),
  28386 	485:  uint32(1081),
  28387 	486:  uint32(1078),
  28388 	487:  uint32(1076),
  28389 	488:  uint32(1074),
  28390 	489:  uint32(1072),
  28391 	490:  uint32(1069),
  28392 	491:  uint32(1067),
  28393 	492:  uint32(1065),
  28394 	493:  uint32(1063),
  28395 	494:  uint32(1061),
  28396 	495:  uint32(1059),
  28397 	496:  uint32(1057),
  28398 	497:  uint32(1054),
  28399 	498:  uint32(1052),
  28400 	499:  uint32(1050),
  28401 	500:  uint32(1048),
  28402 	501:  uint32(1046),
  28403 	502:  uint32(1044),
  28404 	503:  uint32(1042),
  28405 	504:  uint32(1040),
  28406 	505:  uint32(1038),
  28407 	506:  uint32(1036),
  28408 	507:  uint32(1034),
  28409 	508:  uint32(1032),
  28410 	509:  uint32(1030),
  28411 	510:  uint32(1028),
  28412 	511:  uint32(1026),
  28413 	512:  uint32(1024),
  28414 	513:  uint32(1022),
  28415 	514:  uint32(1020),
  28416 	515:  uint32(1018),
  28417 	516:  uint32(1016),
  28418 	517:  uint32(1014),
  28419 	518:  uint32(1012),
  28420 	519:  uint32(1010),
  28421 	520:  uint32(1008),
  28422 	521:  uint32(1006),
  28423 	522:  uint32(1004),
  28424 	523:  uint32(1002),
  28425 	524:  uint32(1000),
  28426 	525:  uint32(998),
  28427 	526:  uint32(996),
  28428 	527:  uint32(994),
  28429 	528:  uint32(992),
  28430 	529:  uint32(991),
  28431 	530:  uint32(989),
  28432 	531:  uint32(987),
  28433 	532:  uint32(985),
  28434 	533:  uint32(983),
  28435 	534:  uint32(981),
  28436 	535:  uint32(979),
  28437 	536:  uint32(978),
  28438 	537:  uint32(976),
  28439 	538:  uint32(974),
  28440 	539:  uint32(972),
  28441 	540:  uint32(970),
  28442 	541:  uint32(969),
  28443 	542:  uint32(967),
  28444 	543:  uint32(965),
  28445 	544:  uint32(963),
  28446 	545:  uint32(961),
  28447 	546:  uint32(960),
  28448 	547:  uint32(958),
  28449 	548:  uint32(956),
  28450 	549:  uint32(954),
  28451 	550:  uint32(953),
  28452 	551:  uint32(951),
  28453 	552:  uint32(949),
  28454 	553:  uint32(948),
  28455 	554:  uint32(946),
  28456 	555:  uint32(944),
  28457 	556:  uint32(942),
  28458 	557:  uint32(941),
  28459 	558:  uint32(939),
  28460 	559:  uint32(937),
  28461 	560:  uint32(936),
  28462 	561:  uint32(934),
  28463 	562:  uint32(932),
  28464 	563:  uint32(931),
  28465 	564:  uint32(929),
  28466 	565:  uint32(927),
  28467 	566:  uint32(926),
  28468 	567:  uint32(924),
  28469 	568:  uint32(923),
  28470 	569:  uint32(921),
  28471 	570:  uint32(919),
  28472 	571:  uint32(918),
  28473 	572:  uint32(916),
  28474 	573:  uint32(914),
  28475 	574:  uint32(913),
  28476 	575:  uint32(911),
  28477 	576:  uint32(910),
  28478 	577:  uint32(908),
  28479 	578:  uint32(907),
  28480 	579:  uint32(905),
  28481 	580:  uint32(903),
  28482 	581:  uint32(902),
  28483 	582:  uint32(900),
  28484 	583:  uint32(899),
  28485 	584:  uint32(897),
  28486 	585:  uint32(896),
  28487 	586:  uint32(894),
  28488 	587:  uint32(893),
  28489 	588:  uint32(891),
  28490 	589:  uint32(890),
  28491 	590:  uint32(888),
  28492 	591:  uint32(887),
  28493 	592:  uint32(885),
  28494 	593:  uint32(884),
  28495 	594:  uint32(882),
  28496 	595:  uint32(881),
  28497 	596:  uint32(879),
  28498 	597:  uint32(878),
  28499 	598:  uint32(876),
  28500 	599:  uint32(875),
  28501 	600:  uint32(873),
  28502 	601:  uint32(872),
  28503 	602:  uint32(870),
  28504 	603:  uint32(869),
  28505 	604:  uint32(868),
  28506 	605:  uint32(866),
  28507 	606:  uint32(865),
  28508 	607:  uint32(863),
  28509 	608:  uint32(862),
  28510 	609:  uint32(860),
  28511 	610:  uint32(859),
  28512 	611:  uint32(858),
  28513 	612:  uint32(856),
  28514 	613:  uint32(855),
  28515 	614:  uint32(853),
  28516 	615:  uint32(852),
  28517 	616:  uint32(851),
  28518 	617:  uint32(849),
  28519 	618:  uint32(848),
  28520 	619:  uint32(846),
  28521 	620:  uint32(845),
  28522 	621:  uint32(844),
  28523 	622:  uint32(842),
  28524 	623:  uint32(841),
  28525 	624:  uint32(840),
  28526 	625:  uint32(838),
  28527 	626:  uint32(837),
  28528 	627:  uint32(836),
  28529 	628:  uint32(834),
  28530 	629:  uint32(833),
  28531 	630:  uint32(832),
  28532 	631:  uint32(830),
  28533 	632:  uint32(829),
  28534 	633:  uint32(828),
  28535 	634:  uint32(826),
  28536 	635:  uint32(825),
  28537 	636:  uint32(824),
  28538 	637:  uint32(823),
  28539 	638:  uint32(821),
  28540 	639:  uint32(820),
  28541 	640:  uint32(819),
  28542 	641:  uint32(817),
  28543 	642:  uint32(816),
  28544 	643:  uint32(815),
  28545 	644:  uint32(814),
  28546 	645:  uint32(812),
  28547 	646:  uint32(811),
  28548 	647:  uint32(810),
  28549 	648:  uint32(809),
  28550 	649:  uint32(807),
  28551 	650:  uint32(806),
  28552 	651:  uint32(805),
  28553 	652:  uint32(804),
  28554 	653:  uint32(802),
  28555 	654:  uint32(801),
  28556 	655:  uint32(800),
  28557 	656:  uint32(799),
  28558 	657:  uint32(798),
  28559 	658:  uint32(796),
  28560 	659:  uint32(795),
  28561 	660:  uint32(794),
  28562 	661:  uint32(793),
  28563 	662:  uint32(791),
  28564 	663:  uint32(790),
  28565 	664:  uint32(789),
  28566 	665:  uint32(788),
  28567 	666:  uint32(787),
  28568 	667:  uint32(786),
  28569 	668:  uint32(784),
  28570 	669:  uint32(783),
  28571 	670:  uint32(782),
  28572 	671:  uint32(781),
  28573 	672:  uint32(780),
  28574 	673:  uint32(779),
  28575 	674:  uint32(777),
  28576 	675:  uint32(776),
  28577 	676:  uint32(775),
  28578 	677:  uint32(774),
  28579 	678:  uint32(773),
  28580 	679:  uint32(772),
  28581 	680:  uint32(771),
  28582 	681:  uint32(769),
  28583 	682:  uint32(768),
  28584 	683:  uint32(767),
  28585 	684:  uint32(766),
  28586 	685:  uint32(765),
  28587 	686:  uint32(764),
  28588 	687:  uint32(763),
  28589 	688:  uint32(762),
  28590 	689:  uint32(760),
  28591 	690:  uint32(759),
  28592 	691:  uint32(758),
  28593 	692:  uint32(757),
  28594 	693:  uint32(756),
  28595 	694:  uint32(755),
  28596 	695:  uint32(754),
  28597 	696:  uint32(753),
  28598 	697:  uint32(752),
  28599 	698:  uint32(751),
  28600 	699:  uint32(750),
  28601 	700:  uint32(748),
  28602 	701:  uint32(747),
  28603 	702:  uint32(746),
  28604 	703:  uint32(745),
  28605 	704:  uint32(744),
  28606 	705:  uint32(743),
  28607 	706:  uint32(742),
  28608 	707:  uint32(741),
  28609 	708:  uint32(740),
  28610 	709:  uint32(739),
  28611 	710:  uint32(738),
  28612 	711:  uint32(737),
  28613 	712:  uint32(736),
  28614 	713:  uint32(735),
  28615 	714:  uint32(734),
  28616 	715:  uint32(733),
  28617 	716:  uint32(732),
  28618 	717:  uint32(731),
  28619 	718:  uint32(730),
  28620 	719:  uint32(729),
  28621 	720:  uint32(728),
  28622 	721:  uint32(727),
  28623 	722:  uint32(726),
  28624 	723:  uint32(725),
  28625 	724:  uint32(724),
  28626 	725:  uint32(723),
  28627 	726:  uint32(722),
  28628 	727:  uint32(721),
  28629 	728:  uint32(720),
  28630 	729:  uint32(719),
  28631 	730:  uint32(718),
  28632 	731:  uint32(717),
  28633 	732:  uint32(716),
  28634 	733:  uint32(715),
  28635 	734:  uint32(714),
  28636 	735:  uint32(713),
  28637 	736:  uint32(712),
  28638 	737:  uint32(711),
  28639 	738:  uint32(710),
  28640 	739:  uint32(709),
  28641 	740:  uint32(708),
  28642 	741:  uint32(707),
  28643 	742:  uint32(706),
  28644 	743:  uint32(705),
  28645 	744:  uint32(704),
  28646 	745:  uint32(703),
  28647 	746:  uint32(702),
  28648 	747:  uint32(701),
  28649 	748:  uint32(700),
  28650 	749:  uint32(699),
  28651 	750:  uint32(699),
  28652 	751:  uint32(698),
  28653 	752:  uint32(697),
  28654 	753:  uint32(696),
  28655 	754:  uint32(695),
  28656 	755:  uint32(694),
  28657 	756:  uint32(693),
  28658 	757:  uint32(692),
  28659 	758:  uint32(691),
  28660 	759:  uint32(690),
  28661 	760:  uint32(689),
  28662 	761:  uint32(688),
  28663 	762:  uint32(688),
  28664 	763:  uint32(687),
  28665 	764:  uint32(686),
  28666 	765:  uint32(685),
  28667 	766:  uint32(684),
  28668 	767:  uint32(683),
  28669 	768:  uint32(682),
  28670 	769:  uint32(681),
  28671 	770:  uint32(680),
  28672 	771:  uint32(680),
  28673 	772:  uint32(679),
  28674 	773:  uint32(678),
  28675 	774:  uint32(677),
  28676 	775:  uint32(676),
  28677 	776:  uint32(675),
  28678 	777:  uint32(674),
  28679 	778:  uint32(673),
  28680 	779:  uint32(673),
  28681 	780:  uint32(672),
  28682 	781:  uint32(671),
  28683 	782:  uint32(670),
  28684 	783:  uint32(669),
  28685 	784:  uint32(668),
  28686 	785:  uint32(667),
  28687 	786:  uint32(667),
  28688 	787:  uint32(666),
  28689 	788:  uint32(665),
  28690 	789:  uint32(664),
  28691 	790:  uint32(663),
  28692 	791:  uint32(662),
  28693 	792:  uint32(661),
  28694 	793:  uint32(661),
  28695 	794:  uint32(660),
  28696 	795:  uint32(659),
  28697 	796:  uint32(658),
  28698 	797:  uint32(657),
  28699 	798:  uint32(657),
  28700 	799:  uint32(656),
  28701 	800:  uint32(655),
  28702 	801:  uint32(654),
  28703 	802:  uint32(653),
  28704 	803:  uint32(652),
  28705 	804:  uint32(652),
  28706 	805:  uint32(651),
  28707 	806:  uint32(650),
  28708 	807:  uint32(649),
  28709 	808:  uint32(648),
  28710 	809:  uint32(648),
  28711 	810:  uint32(647),
  28712 	811:  uint32(646),
  28713 	812:  uint32(645),
  28714 	813:  uint32(644),
  28715 	814:  uint32(644),
  28716 	815:  uint32(643),
  28717 	816:  uint32(642),
  28718 	817:  uint32(641),
  28719 	818:  uint32(640),
  28720 	819:  uint32(640),
  28721 	820:  uint32(639),
  28722 	821:  uint32(638),
  28723 	822:  uint32(637),
  28724 	823:  uint32(637),
  28725 	824:  uint32(636),
  28726 	825:  uint32(635),
  28727 	826:  uint32(634),
  28728 	827:  uint32(633),
  28729 	828:  uint32(633),
  28730 	829:  uint32(632),
  28731 	830:  uint32(631),
  28732 	831:  uint32(630),
  28733 	832:  uint32(630),
  28734 	833:  uint32(629),
  28735 	834:  uint32(628),
  28736 	835:  uint32(627),
  28737 	836:  uint32(627),
  28738 	837:  uint32(626),
  28739 	838:  uint32(625),
  28740 	839:  uint32(624),
  28741 	840:  uint32(624),
  28742 	841:  uint32(623),
  28743 	842:  uint32(622),
  28744 	843:  uint32(621),
  28745 	844:  uint32(621),
  28746 	845:  uint32(620),
  28747 	846:  uint32(619),
  28748 	847:  uint32(618),
  28749 	848:  uint32(618),
  28750 	849:  uint32(617),
  28751 	850:  uint32(616),
  28752 	851:  uint32(616),
  28753 	852:  uint32(615),
  28754 	853:  uint32(614),
  28755 	854:  uint32(613),
  28756 	855:  uint32(613),
  28757 	856:  uint32(612),
  28758 	857:  uint32(611),
  28759 	858:  uint32(611),
  28760 	859:  uint32(610),
  28761 	860:  uint32(609),
  28762 	861:  uint32(608),
  28763 	862:  uint32(608),
  28764 	863:  uint32(607),
  28765 	864:  uint32(606),
  28766 	865:  uint32(606),
  28767 	866:  uint32(605),
  28768 	867:  uint32(604),
  28769 	868:  uint32(604),
  28770 	869:  uint32(603),
  28771 	870:  uint32(602),
  28772 	871:  uint32(601),
  28773 	872:  uint32(601),
  28774 	873:  uint32(600),
  28775 	874:  uint32(599),
  28776 	875:  uint32(599),
  28777 	876:  uint32(598),
  28778 	877:  uint32(597),
  28779 	878:  uint32(597),
  28780 	879:  uint32(596),
  28781 	880:  uint32(595),
  28782 	881:  uint32(595),
  28783 	882:  uint32(594),
  28784 	883:  uint32(593),
  28785 	884:  uint32(593),
  28786 	885:  uint32(592),
  28787 	886:  uint32(591),
  28788 	887:  uint32(591),
  28789 	888:  uint32(590),
  28790 	889:  uint32(589),
  28791 	890:  uint32(589),
  28792 	891:  uint32(588),
  28793 	892:  uint32(587),
  28794 	893:  uint32(587),
  28795 	894:  uint32(586),
  28796 	895:  uint32(585),
  28797 	896:  uint32(585),
  28798 	897:  uint32(584),
  28799 	898:  uint32(583),
  28800 	899:  uint32(583),
  28801 	900:  uint32(582),
  28802 	901:  uint32(581),
  28803 	902:  uint32(581),
  28804 	903:  uint32(580),
  28805 	904:  uint32(579),
  28806 	905:  uint32(579),
  28807 	906:  uint32(578),
  28808 	907:  uint32(578),
  28809 	908:  uint32(577),
  28810 	909:  uint32(576),
  28811 	910:  uint32(576),
  28812 	911:  uint32(575),
  28813 	912:  uint32(574),
  28814 	913:  uint32(574),
  28815 	914:  uint32(573),
  28816 	915:  uint32(572),
  28817 	916:  uint32(572),
  28818 	917:  uint32(571),
  28819 	918:  uint32(571),
  28820 	919:  uint32(570),
  28821 	920:  uint32(569),
  28822 	921:  uint32(569),
  28823 	922:  uint32(568),
  28824 	923:  uint32(568),
  28825 	924:  uint32(567),
  28826 	925:  uint32(566),
  28827 	926:  uint32(566),
  28828 	927:  uint32(565),
  28829 	928:  uint32(564),
  28830 	929:  uint32(564),
  28831 	930:  uint32(563),
  28832 	931:  uint32(563),
  28833 	932:  uint32(562),
  28834 	933:  uint32(561),
  28835 	934:  uint32(561),
  28836 	935:  uint32(560),
  28837 	936:  uint32(560),
  28838 	937:  uint32(559),
  28839 	938:  uint32(558),
  28840 	939:  uint32(558),
  28841 	940:  uint32(557),
  28842 	941:  uint32(557),
  28843 	942:  uint32(556),
  28844 	943:  uint32(555),
  28845 	944:  uint32(555),
  28846 	945:  uint32(554),
  28847 	946:  uint32(554),
  28848 	947:  uint32(553),
  28849 	948:  uint32(553),
  28850 	949:  uint32(552),
  28851 	950:  uint32(551),
  28852 	951:  uint32(551),
  28853 	952:  uint32(550),
  28854 	953:  uint32(550),
  28855 	954:  uint32(549),
  28856 	955:  uint32(548),
  28857 	956:  uint32(548),
  28858 	957:  uint32(547),
  28859 	958:  uint32(547),
  28860 	959:  uint32(546),
  28861 	960:  uint32(546),
  28862 	961:  uint32(545),
  28863 	962:  uint32(544),
  28864 	963:  uint32(544),
  28865 	964:  uint32(543),
  28866 	965:  uint32(543),
  28867 	966:  uint32(542),
  28868 	967:  uint32(542),
  28869 	968:  uint32(541),
  28870 	969:  uint32(541),
  28871 	970:  uint32(540),
  28872 	971:  uint32(539),
  28873 	972:  uint32(539),
  28874 	973:  uint32(538),
  28875 	974:  uint32(538),
  28876 	975:  uint32(537),
  28877 	976:  uint32(537),
  28878 	977:  uint32(536),
  28879 	978:  uint32(536),
  28880 	979:  uint32(535),
  28881 	980:  uint32(534),
  28882 	981:  uint32(534),
  28883 	982:  uint32(533),
  28884 	983:  uint32(533),
  28885 	984:  uint32(532),
  28886 	985:  uint32(532),
  28887 	986:  uint32(531),
  28888 	987:  uint32(531),
  28889 	988:  uint32(530),
  28890 	989:  uint32(530),
  28891 	990:  uint32(529),
  28892 	991:  uint32(529),
  28893 	992:  uint32(528),
  28894 	993:  uint32(527),
  28895 	994:  uint32(527),
  28896 	995:  uint32(526),
  28897 	996:  uint32(526),
  28898 	997:  uint32(525),
  28899 	998:  uint32(525),
  28900 	999:  uint32(524),
  28901 	1000: uint32(524),
  28902 	1001: uint32(523),
  28903 	1002: uint32(523),
  28904 	1003: uint32(522),
  28905 	1004: uint32(522),
  28906 	1005: uint32(521),
  28907 	1006: uint32(521),
  28908 	1007: uint32(520),
  28909 	1008: uint32(520),
  28910 	1009: uint32(519),
  28911 	1010: uint32(519),
  28912 	1011: uint32(518),
  28913 	1012: uint32(518),
  28914 	1013: uint32(517),
  28915 	1014: uint32(517),
  28916 	1015: uint32(516),
  28917 	1016: uint32(516),
  28918 	1017: uint32(515),
  28919 	1018: uint32(515),
  28920 	1019: uint32(514),
  28921 	1020: uint32(514),
  28922 }
  28923 
  28924 // Note that LinearToGamma() expects the values to be premultiplied by 4,
  28925 // so we incorporate this factor 4 inside the DIVIDE_BY_ALPHA macro directly.
  28926 
  28927 func LinearToGammaWeighted(tls *libc.TLS, src uintptr, a_ptr uintptr, total_a uint32_t, step int32, rgb_stride int32) (r int32) {
  28928 	var sum uint32_t
  28929 	_ = sum
  28930 	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))))
  28931 	return LinearToGamma(tls, sum*kInvAlpha[total_a]>>(kAlphaFix-libc.Int32FromInt32(2)), 0)
  28932 }
  28933 
  28934 func ConvertRowToY(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, dst_y uintptr, width int32, rg uintptr) {
  28935 	var i, j int32
  28936 	_, _ = i, j
  28937 	i = 0
  28938 	j = libc.Int32FromInt32(0)
  28939 	for {
  28940 		if !(i < width) {
  28941 			break
  28942 		}
  28943 		**(**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))
  28944 		goto _1
  28945 	_1:
  28946 		;
  28947 		i = i + int32(1)
  28948 		j = j + step
  28949 	}
  28950 }
  28951 
  28952 func AccumulateRGBA(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, a_ptr uintptr, rgb_stride int32, dst uintptr, width int32) {
  28953 	var a, a1 uint32_t
  28954 	var b, b1, g, g1, i, j, r, r1 int32
  28955 	_, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, g, g1, i, j, r, r1
  28956 	// we loop over 2x2 blocks and produce one R/G/B/A value for each.
  28957 	i = 0
  28958 	j = libc.Int32FromInt32(0)
  28959 	for {
  28960 		if !(i < width>>int32(1)) {
  28961 			break
  28962 		}
  28963 		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))))))
  28964 		if a == libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(0xff)) || a == uint32(0) {
  28965 			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)
  28966 			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)
  28967 			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)
  28968 		} else {
  28969 			r = LinearToGammaWeighted(tls, r_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28970 			g = LinearToGammaWeighted(tls, g_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28971 			b = LinearToGammaWeighted(tls, b_ptr+uintptr(j), a_ptr+uintptr(j), a, int32(4), rgb_stride)
  28972 		}
  28973 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(r)
  28974 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(g)
  28975 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(b)
  28976 		**(**uint16_t)(__ccgo_up(dst + 3*2)) = uint16(a)
  28977 		goto _1
  28978 	_1:
  28979 		;
  28980 		i = i + int32(1)
  28981 		j = j + libc.Int32FromInt32(2)*libc.Int32FromInt32(4)
  28982 		dst = dst + uintptr(4)*2
  28983 	}
  28984 	if width&int32(1) != 0 {
  28985 		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)))))
  28986 		if a1 == libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(0xff)) || a1 == uint32(0) {
  28987 			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))
  28988 			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))
  28989 			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))
  28990 		} else {
  28991 			r1 = LinearToGammaWeighted(tls, r_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28992 			g1 = LinearToGammaWeighted(tls, g_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28993 			b1 = LinearToGammaWeighted(tls, b_ptr+uintptr(j), a_ptr+uintptr(j), a1, 0, rgb_stride)
  28994 		}
  28995 		**(**uint16_t)(__ccgo_up(dst)) = libc.Uint16FromInt32(r1)
  28996 		**(**uint16_t)(__ccgo_up(dst + 1*2)) = libc.Uint16FromInt32(g1)
  28997 		**(**uint16_t)(__ccgo_up(dst + 2*2)) = libc.Uint16FromInt32(b1)
  28998 		**(**uint16_t)(__ccgo_up(dst + 3*2)) = uint16(a1)
  28999 	}
  29000 }
  29001 
  29002 func AccumulateRGB(tls *libc.TLS, r_ptr uintptr, g_ptr uintptr, b_ptr uintptr, step int32, rgb_stride int32, dst uintptr, width int32) {
  29003 	var i, j int32
  29004 	_, _ = i, j
  29005 	i = 0
  29006 	j = libc.Int32FromInt32(0)
  29007 	for {
  29008 		if !(i < width>>int32(1)) {
  29009 			break
  29010 		}
  29011 		**(**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))
  29012 		**(**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))
  29013 		**(**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))
  29014 		// MemorySanitizer may raise false positives with data that passes through
  29015 		// RGBA32PackedToPlanar_16b_SSE41() due to incorrect modeling of shuffles.
  29016 		// See https://crbug.com/webp/573.
  29017 		goto _1
  29018 	_1:
  29019 		;
  29020 		i = i + int32(1)
  29021 		j = j + int32(2)*step
  29022 		dst = dst + uintptr(4)*2
  29023 	}
  29024 	if width&int32(1) != 0 {
  29025 		**(**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)))
  29026 		**(**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)))
  29027 		**(**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)))
  29028 	}
  29029 }
  29030 
  29031 func ConvertRowsToUV(tls *libc.TLS, rgb uintptr, dst_u uintptr, dst_v uintptr, width int32, rg uintptr) {
  29032 	var b, g, i, r int32
  29033 	_, _, _, _ = b, g, i, r
  29034 	i = 0
  29035 	for {
  29036 		if !(i < width) {
  29037 			break
  29038 		}
  29039 		r = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb)))
  29040 		g = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 1*2)))
  29041 		b = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 2*2)))
  29042 		**(**uint8_t)(__ccgo_up(dst_u + uintptr(i))) = libc.Uint8FromInt32(RGBToU(tls, r, g, b, rg))
  29043 		**(**uint8_t)(__ccgo_up(dst_v + uintptr(i))) = libc.Uint8FromInt32(RGBToV(tls, r, g, b, rg))
  29044 		goto _1
  29045 	_1:
  29046 		;
  29047 		i = i + int32(1)
  29048 		rgb = rgb + uintptr(4)*2
  29049 	}
  29050 }
  29051 
  29052 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) {
  29053 	bp := tls.Alloc(240)
  29054 	defer tls.Free(240)
  29055 	var dst_a, dst_u, dst_v, dst_y, rg, tmp_rgb uintptr
  29056 	var has_alpha, height, is_rgb, row_has_alpha, rows_have_alpha, use_dsp, uv_width, width, y, v1 int32
  29057 	var _ /* base_rg at bp+0 */ VP8Random
  29058 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  29059 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29060 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29061 	has_alpha = CheckNonOpaque(tls, a_ptr, width, height, step, rgb_stride)
  29062 	is_rgb = libc.BoolInt32(r_ptr < b_ptr) // otherwise it's bgr
  29063 	if has_alpha != 0 {
  29064 		v1 = int32(WEBP_YUV420A)
  29065 	} else {
  29066 		v1 = int32(WEBP_YUV420)
  29067 	}
  29068 	(*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace = v1
  29069 	(*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb = 0
  29070 	// disable smart conversion if source is too small (overkill).
  29071 	if width < kMinDimensionIterativeConversion || height < kMinDimensionIterativeConversion {
  29072 		use_iterative_conversion = 0
  29073 	}
  29074 	if !(WebPPictureAllocYUVA(tls, picture) != 0) {
  29075 		return 0
  29076 	}
  29077 	if has_alpha != 0 {
  29078 	}
  29079 	if use_iterative_conversion != 0 {
  29080 		SharpYuvInit(tls, VP8GetCPUInfo)
  29081 		if !(PreprocessARGB(tls, r_ptr, g_ptr, b_ptr, step, rgb_stride, picture) != 0) {
  29082 			return 0
  29083 		}
  29084 		if has_alpha != 0 {
  29085 			(*(*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)
  29086 		}
  29087 	} else {
  29088 		uv_width = (width + int32(1)) >> int32(1)
  29089 		use_dsp = libc.BoolInt32(step == int32(3)) // use special function in this case
  29090 		// temporary storage for accumulated R/G/B values during conversion to U/V
  29091 		tmp_rgb = WebPSafeMalloc(tls, libc.Uint64FromInt32(int32(4)*uv_width), uint64(2))
  29092 		dst_y = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  29093 		dst_u = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  29094 		dst_v = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  29095 		dst_a = (*WebPPicture)(unsafe.Pointer(picture)).Fa
  29096 		rg = libc.UintptrFromInt32(0)
  29097 		if float64(dithering) > float64(0) {
  29098 			VP8InitRandom(tls, bp, dithering)
  29099 			rg = bp
  29100 			use_dsp = 0 // can't use dsp in this case
  29101 		}
  29102 		WebPInitConvertARGBToYUV(tls)
  29103 		InitGammaTables(tls)
  29104 		if tmp_rgb == libc.UintptrFromInt32(0) {
  29105 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29106 		}
  29107 		// Downsample Y/U/V planes, two rows at a time
  29108 		y = 0
  29109 		for {
  29110 			if !(y < height>>libc.Int32FromInt32(1)) {
  29111 				break
  29112 			}
  29113 			rows_have_alpha = has_alpha
  29114 			if use_dsp != 0 {
  29115 				if is_rgb != 0 {
  29116 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGB24ToY})))(tls, r_ptr, dst_y, width)
  29117 					(*(*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)
  29118 				} else {
  29119 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertBGR24ToY})))(tls, b_ptr, dst_y, width)
  29120 					(*(*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)
  29121 				}
  29122 			} else {
  29123 				ConvertRowToY(tls, r_ptr, g_ptr, b_ptr, step, dst_y, width, rg)
  29124 				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)
  29125 			}
  29126 			dst_y = dst_y + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29127 			if has_alpha != 0 {
  29128 				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))
  29129 				dst_a = dst_a + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  29130 			}
  29131 			// Collect averaged R/G/B(/A)
  29132 			if !(rows_have_alpha != 0) {
  29133 				AccumulateRGB(tls, r_ptr, g_ptr, b_ptr, step, rgb_stride, tmp_rgb, width)
  29134 			} else {
  29135 				AccumulateRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, rgb_stride, tmp_rgb, width)
  29136 			}
  29137 			// Convert to U/V
  29138 			if rg == libc.UintptrFromInt32(0) {
  29139 				(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGBA32ToUV})))(tls, tmp_rgb, dst_u, dst_v, uv_width)
  29140 			} else {
  29141 				ConvertRowsToUV(tls, tmp_rgb, dst_u, dst_v, uv_width, rg)
  29142 			}
  29143 			dst_u = dst_u + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29144 			dst_v = dst_v + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29145 			r_ptr = r_ptr + uintptr(int32(2)*rgb_stride)
  29146 			b_ptr = b_ptr + uintptr(int32(2)*rgb_stride)
  29147 			g_ptr = g_ptr + uintptr(int32(2)*rgb_stride)
  29148 			if has_alpha != 0 {
  29149 				a_ptr = a_ptr + uintptr(int32(2)*rgb_stride)
  29150 			}
  29151 			goto _2
  29152 		_2:
  29153 			;
  29154 			y = y + 1
  29155 		}
  29156 		if height&int32(1) != 0 { // extra last row
  29157 			row_has_alpha = has_alpha
  29158 			if use_dsp != 0 {
  29159 				if r_ptr < b_ptr {
  29160 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGB24ToY})))(tls, r_ptr, dst_y, width)
  29161 				} else {
  29162 					(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertBGR24ToY})))(tls, b_ptr, dst_y, width)
  29163 				}
  29164 			} else {
  29165 				ConvertRowToY(tls, r_ptr, g_ptr, b_ptr, step, dst_y, width, rg)
  29166 			}
  29167 			if row_has_alpha != 0 {
  29168 				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))
  29169 			}
  29170 			// Collect averaged R/G/B(/A)
  29171 			if !(row_has_alpha != 0) {
  29172 				// Collect averaged R/G/B
  29173 				AccumulateRGB(tls, r_ptr, g_ptr, b_ptr, step, 0, tmp_rgb, width)
  29174 			} else {
  29175 				AccumulateRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, 0, tmp_rgb, width)
  29176 			}
  29177 			if rg == libc.UintptrFromInt32(0) {
  29178 				(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{WebPConvertRGBA32ToUV})))(tls, tmp_rgb, dst_u, dst_v, uv_width)
  29179 			} else {
  29180 				ConvertRowsToUV(tls, tmp_rgb, dst_u, dst_v, uv_width, rg)
  29181 			}
  29182 		}
  29183 		WebPSafeFree(tls, tmp_rgb)
  29184 	}
  29185 	return int32(1)
  29186 }
  29187 
  29188 //------------------------------------------------------------------------------
  29189 // call for ARGB->YUVA conversion
  29190 
  29191 func PictureARGBToYUVA(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1, dithering float32, use_iterative_conversion int32) (r1 int32) {
  29192 	var a, argb, b, g, r uintptr
  29193 	_, _, _, _, _ = a, argb, b, g, r
  29194 	if picture == libc.UintptrFromInt32(0) {
  29195 		return 0
  29196 	}
  29197 	if (*WebPPicture)(unsafe.Pointer(picture)).Fargb == libc.UintptrFromInt32(0) {
  29198 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29199 	} else {
  29200 		if colorspace&int32(WEBP_CSP_UV_MASK) != int32(WEBP_YUV420) {
  29201 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29202 		} else {
  29203 			argb = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29204 			a = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(0))
  29205 			r = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(1))
  29206 			g = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(2))
  29207 			b = argb + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(3))
  29208 			(*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace = int32(WEBP_YUV420)
  29209 			return ImportYUVAFromRGBA(tls, r, g, b, a, int32(4), int32(4)*(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride, dithering, use_iterative_conversion, picture)
  29210 		}
  29211 	}
  29212 	return r1
  29213 }
  29214 
  29215 func WebPPictureARGBToYUVADithered(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1, dithering float32) (r int32) {
  29216 	return PictureARGBToYUVA(tls, picture, colorspace, dithering, 0)
  29217 }
  29218 
  29219 func WebPPictureARGBToYUVA(tls *libc.TLS, picture uintptr, colorspace WebPEncCSP1) (r int32) {
  29220 	return PictureARGBToYUVA(tls, picture, colorspace, libc.Float32FromFloat32(0), 0)
  29221 }
  29222 
  29223 func WebPPictureSharpARGBToYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29224 	return PictureARGBToYUVA(tls, picture, int32(WEBP_YUV420), libc.Float32FromFloat32(0), int32(1))
  29225 }
  29226 
  29227 // C documentation
  29228 //
  29229 //	// for backward compatibility
  29230 func WebPPictureSmartARGBToYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29231 	return WebPPictureSharpARGBToYUVA(tls, picture)
  29232 }
  29233 
  29234 //------------------------------------------------------------------------------
  29235 // call for YUVA -> ARGB conversion
  29236 
  29237 func WebPPictureYUVAToARGB(tls *libc.TLS, picture uintptr) (r int32) {
  29238 	var argb_dst, cur_u, cur_v, cur_y, dst, src, top_u, top_v uintptr
  29239 	var argb_stride, height, width, x, y int32
  29240 	var upsample WebPUpsampleLinePairFunc
  29241 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = argb_dst, argb_stride, cur_u, cur_v, cur_y, dst, height, src, top_u, top_v, upsample, width, x, y
  29242 	if picture == libc.UintptrFromInt32(0) {
  29243 		return 0
  29244 	}
  29245 	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) {
  29246 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29247 	}
  29248 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_ALPHA_BIT) != 0 && (*WebPPicture)(unsafe.Pointer(picture)).Fa == libc.UintptrFromInt32(0) {
  29249 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  29250 	}
  29251 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_UV_MASK) != int32(WEBP_YUV420) {
  29252 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29253 	}
  29254 	// Allocate a new argb buffer (discarding the previous one).
  29255 	if !(WebPPictureAllocARGB(tls, picture) != 0) {
  29256 		return 0
  29257 	}
  29258 	(*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb = int32(1)
  29259 	// Convert
  29260 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29261 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29262 	argb_stride = int32(4) * (*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride
  29263 	dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29264 	cur_u = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  29265 	cur_v = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  29266 	cur_y = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  29267 	upsample = WebPGetLinePairConverter(tls, libc.BoolInt32(libc.Int32FromInt32(3)-libc.Int32FromInt32(0) > 0))
  29268 	// First row, with replicated top samples.
  29269 	(*(*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)
  29270 	cur_y = cur_y + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29271 	dst = dst + uintptr(argb_stride)
  29272 	// Center rows.
  29273 	y = int32(1)
  29274 	for {
  29275 		if !(y+int32(1) < height) {
  29276 			break
  29277 		}
  29278 		top_u = cur_u
  29279 		top_v = cur_v
  29280 		cur_u = cur_u + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29281 		cur_v = cur_v + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  29282 		(*(*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)
  29283 		cur_y = cur_y + uintptr(int32(2)*(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  29284 		dst = dst + uintptr(int32(2)*argb_stride)
  29285 		goto _1
  29286 	_1:
  29287 		;
  29288 		y = y + int32(2)
  29289 	}
  29290 	// Last row (if needed), with replicated bottom samples.
  29291 	if height > int32(1) && !(height&libc.Int32FromInt32(1) != 0) {
  29292 		(*(*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)
  29293 	}
  29294 	// Insert alpha values if needed, in replacement for the default 0xff ones.
  29295 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace&int32(WEBP_CSP_ALPHA_BIT) != 0 {
  29296 		y = 0
  29297 		for {
  29298 			if !(y < height) {
  29299 				break
  29300 			}
  29301 			argb_dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb + uintptr(y*(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29302 			src = (*WebPPicture)(unsafe.Pointer(picture)).Fa + uintptr(y*(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  29303 			x = 0
  29304 			for {
  29305 				if !(x < width) {
  29306 					break
  29307 				}
  29308 				**(**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)
  29309 				goto _3
  29310 			_3:
  29311 				;
  29312 				x = x + 1
  29313 			}
  29314 			goto _2
  29315 		_2:
  29316 			;
  29317 			y = y + 1
  29318 		}
  29319 	}
  29320 	return int32(1)
  29321 }
  29322 
  29323 //------------------------------------------------------------------------------
  29324 // automatic import / conversion
  29325 
  29326 func Import(tls *libc.TLS, picture uintptr, rgb uintptr, rgb_stride int32, step int32, swap_rb int32, import_alpha int32) (r int32) {
  29327 	var a_ptr, b_ptr, dst, dst1, g_ptr, r_ptr, v4 uintptr
  29328 	var do_copy, height, width, y, v1, v2, v3 int32
  29329 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a_ptr, b_ptr, do_copy, dst, dst1, g_ptr, height, r_ptr, width, y, v1, v2, v3, v4
  29330 	if swap_rb != 0 {
  29331 		v1 = int32(2)
  29332 	} else {
  29333 		v1 = 0
  29334 	}
  29335 	// swap_rb -> b,g,r,a , !swap_rb -> r,g,b,a
  29336 	r_ptr = rgb + uintptr(v1)
  29337 	g_ptr = rgb + uintptr(1)
  29338 	if swap_rb != 0 {
  29339 		v2 = 0
  29340 	} else {
  29341 		v2 = int32(2)
  29342 	}
  29343 	b_ptr = rgb + uintptr(v2)
  29344 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29345 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29346 	if import_alpha != 0 {
  29347 		v3 = int32(4)
  29348 	} else {
  29349 		v3 = int32(3)
  29350 	}
  29351 	if libc.Xabs(tls, rgb_stride) < v3*width {
  29352 		return 0
  29353 	}
  29354 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  29355 		if import_alpha != 0 {
  29356 			v4 = rgb + uintptr(3)
  29357 		} else {
  29358 			v4 = libc.UintptrFromInt32(0)
  29359 		}
  29360 		a_ptr = v4
  29361 		return ImportYUVAFromRGBA(tls, r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride, libc.Float32FromFloat32(0), 0, picture)
  29362 	}
  29363 	if !(WebPPictureAlloc(tls, picture) != 0) {
  29364 		return 0
  29365 	}
  29366 	VP8LDspInit(tls)
  29367 	WebPInitAlphaProcessing(tls)
  29368 	if import_alpha != 0 {
  29369 		// dst[] byte order is {a,r,g,b} for big-endian, {b,g,r,a} for little endian
  29370 		dst = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29371 		do_copy = libc.BoolInt32(libc.Bool(libc.Int32FromInt32(3)-libc.Int32FromInt32(0) == int32(3)) && swap_rb != 0)
  29372 		if do_copy != 0 {
  29373 			y = 0
  29374 			for {
  29375 				if !(y < height) {
  29376 					break
  29377 				}
  29378 				libc.X__builtin___memcpy_chk(tls, dst, rgb, libc.Uint64FromInt32(width*int32(4)), ^__predefined_size_t(0))
  29379 				rgb = rgb + uintptr(rgb_stride)
  29380 				dst = dst + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29381 				goto _5
  29382 			_5:
  29383 				;
  29384 				y = y + 1
  29385 			}
  29386 		} else {
  29387 			y = 0
  29388 			for {
  29389 				if !(y < height) {
  29390 					break
  29391 				}
  29392 				// RGBA input order. Need to swap R and B.
  29393 				(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, rgb, width, dst)
  29394 				rgb = rgb + uintptr(rgb_stride)
  29395 				dst = dst + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29396 				goto _6
  29397 			_6:
  29398 				;
  29399 				y = y + 1
  29400 			}
  29401 		}
  29402 	} else {
  29403 		dst1 = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  29404 		y = 0
  29405 		for {
  29406 			if !(y < height) {
  29407 				break
  29408 			}
  29409 			(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPPackRGB})))(tls, r_ptr, g_ptr, b_ptr, width, step, dst1)
  29410 			r_ptr = r_ptr + uintptr(rgb_stride)
  29411 			g_ptr = g_ptr + uintptr(rgb_stride)
  29412 			b_ptr = b_ptr + uintptr(rgb_stride)
  29413 			dst1 = dst1 + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  29414 			goto _7
  29415 		_7:
  29416 			;
  29417 			y = y + 1
  29418 		}
  29419 	}
  29420 	return int32(1)
  29421 }
  29422 
  29423 // Public API
  29424 
  29425 func WebPPictureImportBGR(tls *libc.TLS, picture uintptr, bgr uintptr, bgr_stride int32) (r int32) {
  29426 	var v1 int32
  29427 	_ = v1
  29428 	if picture != libc.UintptrFromInt32(0) && bgr != libc.UintptrFromInt32(0) {
  29429 		v1 = Import(tls, picture, bgr, bgr_stride, int32(3), int32(1), 0)
  29430 	} else {
  29431 		v1 = 0
  29432 	}
  29433 	return v1
  29434 }
  29435 
  29436 func WebPPictureImportBGRA(tls *libc.TLS, picture uintptr, bgra uintptr, bgra_stride int32) (r int32) {
  29437 	var v1 int32
  29438 	_ = v1
  29439 	if picture != libc.UintptrFromInt32(0) && bgra != libc.UintptrFromInt32(0) {
  29440 		v1 = Import(tls, picture, bgra, bgra_stride, int32(4), int32(1), int32(1))
  29441 	} else {
  29442 		v1 = 0
  29443 	}
  29444 	return v1
  29445 }
  29446 
  29447 func WebPPictureImportBGRX(tls *libc.TLS, picture uintptr, bgrx uintptr, bgrx_stride int32) (r int32) {
  29448 	var v1 int32
  29449 	_ = v1
  29450 	if picture != libc.UintptrFromInt32(0) && bgrx != libc.UintptrFromInt32(0) {
  29451 		v1 = Import(tls, picture, bgrx, bgrx_stride, int32(4), int32(1), 0)
  29452 	} else {
  29453 		v1 = 0
  29454 	}
  29455 	return v1
  29456 }
  29457 
  29458 func WebPPictureImportRGB(tls *libc.TLS, picture uintptr, rgb uintptr, rgb_stride int32) (r int32) {
  29459 	var v1 int32
  29460 	_ = v1
  29461 	if picture != libc.UintptrFromInt32(0) && rgb != libc.UintptrFromInt32(0) {
  29462 		v1 = Import(tls, picture, rgb, rgb_stride, int32(3), 0, 0)
  29463 	} else {
  29464 		v1 = 0
  29465 	}
  29466 	return v1
  29467 }
  29468 
  29469 func WebPPictureImportRGBA(tls *libc.TLS, picture uintptr, rgba uintptr, rgba_stride int32) (r int32) {
  29470 	var v1 int32
  29471 	_ = v1
  29472 	if picture != libc.UintptrFromInt32(0) && rgba != libc.UintptrFromInt32(0) {
  29473 		v1 = Import(tls, picture, rgba, rgba_stride, int32(4), 0, int32(1))
  29474 	} else {
  29475 		v1 = 0
  29476 	}
  29477 	return v1
  29478 }
  29479 
  29480 func WebPPictureImportRGBX(tls *libc.TLS, picture uintptr, rgbx uintptr, rgbx_stride int32) (r int32) {
  29481 	var v1 int32
  29482 	_ = v1
  29483 	if picture != libc.UintptrFromInt32(0) && rgbx != libc.UintptrFromInt32(0) {
  29484 		v1 = Import(tls, picture, rgbx, rgbx_stride, int32(4), 0, 0)
  29485 	} else {
  29486 		v1 = 0
  29487 	}
  29488 	return v1
  29489 }
  29490 
  29491 const BC_BASE_MAX = 99
  29492 const BC_DIM_MAX = 2048
  29493 const BC_SCALE_MAX = 99
  29494 const BC_STRING_MAX = 1000
  29495 const BITINT_MAXWIDTH = "__BITINT_MAXWIDTH__"
  29496 const BOOL_WIDTH = "__BOOL_WIDTH__"
  29497 const CHARCLASS_NAME_MAX = 14
  29498 const CHAR_WIDTH = "CHAR_BIT"
  29499 const CHILD_MAX = 266
  29500 const CLK_TCK = "__DARWIN_CLK_TCK"
  29501 const COLL_WEIGHTS_MAX = 2
  29502 const EQUIV_CLASS_MAX = 2
  29503 const EXPR_NEST_MAX = 32
  29504 const GID_MAX = 2147483647
  29505 const INT_WIDTH = "__INT_WIDTH__"
  29506 const IOV_MAX = 1024
  29507 const LINE_MAX = 2048
  29508 const LINK_MAX = 32767
  29509 const LLONG_WIDTH = "__LLONG_WIDTH__"
  29510 const LONG_BIT = 64
  29511 const LONG_WIDTH = "__LONG_WIDTH__"
  29512 const LOSSLESS_DEFAULT_QUALITY = 70
  29513 const MAX_CANON = 1024
  29514 const MAX_INPUT = 1024
  29515 const NAME_MAX = 255
  29516 const NGROUPS_MAX = 16
  29517 const NL_ARGMAX = 9
  29518 const NL_LANGMAX = 14
  29519 const NL_MSGMAX = 32767
  29520 const NL_NMAX = 1
  29521 const NL_SETMAX = 255
  29522 const NL_TEXTMAX = 2048
  29523 const NZERO = 20
  29524 const OFF_MAX = "LLONG_MAX"
  29525 const OFF_MIN = "LLONG_MIN"
  29526 const OPEN_MAX = 10240
  29527 const PASS_MAX = 128
  29528 const PATH_MAX = 1024
  29529 const PIPE_BUF = 512
  29530 const PTHREAD_DESTRUCTOR_ITERATIONS = 4
  29531 const PTHREAD_KEYS_MAX = 512
  29532 const PTHREAD_STACK_MIN = 8192
  29533 const QUAD_MAX = "LLONG_MAX"
  29534 const QUAD_MIN = "LLONG_MIN"
  29535 const RE_DUP_MAX = 255
  29536 const SCHAR_WIDTH = "CHAR_BIT"
  29537 const SHRT_WIDTH = "__SHRT_WIDTH__"
  29538 const SIZE_T_MAX = "ULONG_MAX"
  29539 const SSIZE_MAX = "LONG_MAX"
  29540 const UCHAR_WIDTH = "CHAR_BIT"
  29541 const UID_MAX = 2147483647
  29542 const UINT_WIDTH = "__INT_WIDTH__"
  29543 const ULLONG_WIDTH = "__LLONG_WIDTH__"
  29544 const ULONG_WIDTH = "__LONG_WIDTH__"
  29545 const UQUAD_MAX = "ULLONG_MAX"
  29546 const USHRT_WIDTH = "__SHRT_WIDTH__"
  29547 const WORD_BIT = 32
  29548 const _POSIX2_BC_BASE_MAX = 99
  29549 const _POSIX2_BC_DIM_MAX = 2048
  29550 const _POSIX2_BC_SCALE_MAX = 99
  29551 const _POSIX2_BC_STRING_MAX = 1000
  29552 const _POSIX2_CHARCLASS_NAME_MAX = 14
  29553 const _POSIX2_COLL_WEIGHTS_MAX = 2
  29554 const _POSIX2_EQUIV_CLASS_MAX = 2
  29555 const _POSIX2_EXPR_NEST_MAX = 32
  29556 const _POSIX2_LINE_MAX = 2048
  29557 const _POSIX2_RE_DUP_MAX = 255
  29558 const _POSIX_AIO_LISTIO_MAX = 2
  29559 const _POSIX_AIO_MAX = 1
  29560 const _POSIX_ARG_MAX = 4096
  29561 const _POSIX_CHILD_MAX = 25
  29562 const _POSIX_CLOCKRES_MIN = 20000000
  29563 const _POSIX_DELAYTIMER_MAX = 32
  29564 const _POSIX_HOST_NAME_MAX = 255
  29565 const _POSIX_LINK_MAX = 8
  29566 const _POSIX_LOGIN_NAME_MAX = 9
  29567 const _POSIX_MAX_CANON = 255
  29568 const _POSIX_MAX_INPUT = 255
  29569 const _POSIX_MQ_OPEN_MAX = 8
  29570 const _POSIX_MQ_PRIO_MAX = 32
  29571 const _POSIX_NAME_MAX = 14
  29572 const _POSIX_NGROUPS_MAX = 8
  29573 const _POSIX_OPEN_MAX = 20
  29574 const _POSIX_PATH_MAX = 256
  29575 const _POSIX_PIPE_BUF = 512
  29576 const _POSIX_RE_DUP_MAX = "_POSIX2_RE_DUP_MAX"
  29577 const _POSIX_RTSIG_MAX = 8
  29578 const _POSIX_SEM_NSEMS_MAX = 256
  29579 const _POSIX_SEM_VALUE_MAX = 32767
  29580 const _POSIX_SIGQUEUE_MAX = 32
  29581 const _POSIX_SSIZE_MAX = 32767
  29582 const _POSIX_SS_REPL_MAX = 4
  29583 const _POSIX_STREAM_MAX = 8
  29584 const _POSIX_SYMLINK_MAX = 255
  29585 const _POSIX_SYMLOOP_MAX = 8
  29586 const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4
  29587 const _POSIX_THREAD_KEYS_MAX = 128
  29588 const _POSIX_THREAD_THREADS_MAX = 64
  29589 const _POSIX_TIMER_MAX = 32
  29590 const _POSIX_TRACE_EVENT_NAME_MAX = 30
  29591 const _POSIX_TRACE_NAME_MAX = 8
  29592 const _POSIX_TRACE_SYS_MAX = 8
  29593 const _POSIX_TRACE_USER_EVENT_MAX = 32
  29594 const _POSIX_TTY_NAME_MAX = 9
  29595 const _POSIX_TZNAME_MAX = 6
  29596 const _XOPEN_IOV_MAX = 16
  29597 const _XOPEN_NAME_MAX = 255
  29598 const _XOPEN_PATH_MAX = 1024
  29599 const __DARWIN_CLK_TCK = 100
  29600 const __FLT_MIN__4 = 1.17549435082228750796873653722224568e-38
  29601 const __INT_MAX__1 = 2147483647
  29602 
  29603 //------------------------------------------------------------------------------
  29604 
  29605 // Copyright 2012 Google Inc. All Rights Reserved.
  29606 //
  29607 // Use of this source code is governed by a BSD-style license
  29608 // that can be found in the COPYING file in the root of the source
  29609 // tree. An additional intellectual property rights grant can be found
  29610 // in the file PATENTS. All contributing project authors may
  29611 // be found in the AUTHORS file in the root of the source tree.
  29612 // -----------------------------------------------------------------------------
  29613 //
  29614 // Misc. common utility functions
  29615 //
  29616 // Authors: Skal (pascal.massimino@gmail.com)
  29617 //          Urvang (urvang@google.com)
  29618 
  29619 // Copyright 2011 Google Inc. All Rights Reserved.
  29620 //
  29621 // Use of this source code is governed by a BSD-style license
  29622 // that can be found in the COPYING file in the root of the source
  29623 // tree. An additional intellectual property rights grant can be found
  29624 // in the file PATENTS. All contributing project authors may
  29625 // be found in the AUTHORS file in the root of the source tree.
  29626 // -----------------------------------------------------------------------------
  29627 //
  29628 //   WebP encoder: main interface
  29629 //
  29630 // Author: Skal (pascal.massimino@gmail.com)
  29631 
  29632 // Copyright 2010 Google Inc. All Rights Reserved.
  29633 //
  29634 // Use of this source code is governed by a BSD-style license
  29635 // that can be found in the COPYING file in the root of the source
  29636 // tree. An additional intellectual property rights grant can be found
  29637 // in the file PATENTS. All contributing project authors may
  29638 // be found in the AUTHORS file in the root of the source tree.
  29639 // -----------------------------------------------------------------------------
  29640 //
  29641 //  Common types + memory wrappers
  29642 //
  29643 // Author: Skal (pascal.massimino@gmail.com)
  29644 
  29645 //------------------------------------------------------------------------------
  29646 // WebPPicture
  29647 //------------------------------------------------------------------------------
  29648 
  29649 func DummyWriter(tls *libc.TLS, data uintptr, data_size size_t, picture uintptr) (r int32) {
  29650 	// The following are to prevent 'unused variable' error message.
  29651 	_ = data
  29652 	_ = data_size
  29653 	_ = picture
  29654 	return int32(1)
  29655 }
  29656 
  29657 func WebPPictureInitInternal(tls *libc.TLS, picture uintptr, version int32) (r int32) {
  29658 	if version>>int32(8) != libc.Int32FromInt32(WEBP_ENCODER_ABI_VERSION)>>libc.Int32FromInt32(8) {
  29659 		return 0 // caller/system version mismatch!
  29660 	}
  29661 	if picture != libc.UintptrFromInt32(0) {
  29662 		libc.X__builtin___memset_chk(tls, picture, 0, uint64(256), ^__predefined_size_t(0))
  29663 		(*WebPPicture)(unsafe.Pointer(picture)).Fwriter = __ccgo_fp(DummyWriter)
  29664 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_OK))
  29665 	}
  29666 	return int32(1)
  29667 }
  29668 
  29669 //------------------------------------------------------------------------------
  29670 
  29671 func WebPValidatePicture(tls *libc.TLS, picture uintptr) (r int32) {
  29672 	if picture == libc.UintptrFromInt32(0) {
  29673 		return 0
  29674 	}
  29675 	if (*WebPPicture)(unsafe.Pointer(picture)).Fwidth <= 0 || (*WebPPicture)(unsafe.Pointer(picture)).Fheight <= 0 {
  29676 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29677 	}
  29678 	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) {
  29679 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29680 	}
  29681 	if (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace != int32(WEBP_YUV420) && (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace != int32(WEBP_YUV420A) {
  29682 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  29683 	}
  29684 	return int32(1)
  29685 }
  29686 
  29687 func WebPPictureResetBufferARGB(tls *libc.TLS, picture uintptr) {
  29688 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ = libc.UintptrFromInt32(0)
  29689 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb = libc.UintptrFromInt32(0)
  29690 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride = 0
  29691 }
  29692 
  29693 func WebPPictureResetBufferYUVA(tls *libc.TLS, picture uintptr) {
  29694 	var v1, v2, v3 uintptr
  29695 	var v4 int32
  29696 	_, _, _, _ = v1, v2, v3, v4
  29697 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ = libc.UintptrFromInt32(0)
  29698 	v3 = libc.UintptrFromInt32(0)
  29699 	(*WebPPicture)(unsafe.Pointer(picture)).Fa = v3
  29700 	v2 = v3
  29701 	(*WebPPicture)(unsafe.Pointer(picture)).Fv = v2
  29702 	v1 = v2
  29703 	(*WebPPicture)(unsafe.Pointer(picture)).Fu = v1
  29704 	(*WebPPicture)(unsafe.Pointer(picture)).Fy = v1
  29705 	v4 = libc.Int32FromInt32(0)
  29706 	(*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride = v4
  29707 	(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride = v4
  29708 	(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride = 0
  29709 }
  29710 
  29711 func WebPPictureResetBuffers(tls *libc.TLS, picture uintptr) {
  29712 	WebPPictureResetBufferARGB(tls, picture)
  29713 	WebPPictureResetBufferYUVA(tls, picture)
  29714 }
  29715 
  29716 func WebPPictureAllocARGB(tls *libc.TLS, picture uintptr) (r int32) {
  29717 	var argb_size uint64_t
  29718 	var height, width int32
  29719 	var memory uintptr
  29720 	_, _, _, _ = argb_size, height, memory, width
  29721 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29722 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29723 	argb_size = libc.Uint64FromInt32(width) * libc.Uint64FromInt32(height)
  29724 	if !(WebPValidatePicture(tls, picture) != 0) {
  29725 		return 0
  29726 	}
  29727 	WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_)
  29728 	WebPPictureResetBufferARGB(tls, picture)
  29729 	// allocate a new buffer.
  29730 	memory = WebPSafeMalloc(tls, argb_size+uint64(WEBP_ALIGN_CST), uint64(4))
  29731 	if memory == libc.UintptrFromInt32(0) {
  29732 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29733 	}
  29734 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ = memory
  29735 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb = uintptr((uint64(memory) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  29736 	(*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride = width
  29737 	return int32(1)
  29738 }
  29739 
  29740 func WebPPictureAllocYUVA(tls *libc.TLS, picture uintptr) (r int32) {
  29741 	var a_size, total_size, uv_size, y_size uint64_t
  29742 	var a_stride, a_width, has_alpha, height, uv_height, uv_stride, uv_width, width, y_stride, v1 int32
  29743 	var mem uintptr
  29744 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  29745 	has_alpha = (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace & int32(WEBP_CSP_ALPHA_BIT)
  29746 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  29747 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  29748 	y_stride = width
  29749 	uv_width = int32((int64(width) + libc.Int64FromInt32(1)) >> libc.Int32FromInt32(1))
  29750 	uv_height = int32((int64(height) + libc.Int64FromInt32(1)) >> libc.Int32FromInt32(1))
  29751 	uv_stride = uv_width
  29752 	if !(WebPValidatePicture(tls, picture) != 0) {
  29753 		return 0
  29754 	}
  29755 	WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_)
  29756 	WebPPictureResetBufferYUVA(tls, picture)
  29757 	// alpha
  29758 	if has_alpha != 0 {
  29759 		v1 = width
  29760 	} else {
  29761 		v1 = 0
  29762 	}
  29763 	a_width = v1
  29764 	a_stride = a_width
  29765 	y_size = libc.Uint64FromInt32(y_stride) * libc.Uint64FromInt32(height)
  29766 	uv_size = libc.Uint64FromInt32(uv_stride) * libc.Uint64FromInt32(uv_height)
  29767 	a_size = libc.Uint64FromInt32(a_stride) * libc.Uint64FromInt32(height)
  29768 	total_size = y_size + a_size + uint64(2)*uv_size
  29769 	// Security and validation checks
  29770 	if width <= 0 || height <= 0 || uv_width <= 0 || uv_height <= 0 { // u/v param error
  29771 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  29772 	}
  29773 	// allocate a new buffer.
  29774 	mem = WebPSafeMalloc(tls, total_size, uint64(1))
  29775 	if mem == libc.UintptrFromInt32(0) {
  29776 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  29777 	}
  29778 	// From now on, we're in the clear, we can no longer fail...
  29779 	(*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ = mem
  29780 	(*WebPPicture)(unsafe.Pointer(picture)).Fy_stride = y_stride
  29781 	(*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride = uv_stride
  29782 	(*WebPPicture)(unsafe.Pointer(picture)).Fa_stride = a_stride
  29783 	// TODO(skal): we could align the y/u/v planes and adjust stride.
  29784 	(*WebPPicture)(unsafe.Pointer(picture)).Fy = mem
  29785 	mem = mem + uintptr(y_size)
  29786 	(*WebPPicture)(unsafe.Pointer(picture)).Fu = mem
  29787 	mem = mem + uintptr(uv_size)
  29788 	(*WebPPicture)(unsafe.Pointer(picture)).Fv = mem
  29789 	mem = mem + uintptr(uv_size)
  29790 	if a_size > uint64(0) {
  29791 		(*WebPPicture)(unsafe.Pointer(picture)).Fa = mem
  29792 		mem = mem + uintptr(a_size)
  29793 	}
  29794 	_ = mem // makes the static analyzer happy
  29795 	return int32(1)
  29796 }
  29797 
  29798 func WebPPictureAlloc(tls *libc.TLS, picture uintptr) (r int32) {
  29799 	if picture != libc.UintptrFromInt32(0) {
  29800 		WebPPictureFree(tls, picture) // erase previous buffer
  29801 		if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  29802 			return WebPPictureAllocYUVA(tls, picture)
  29803 		} else {
  29804 			return WebPPictureAllocARGB(tls, picture)
  29805 		}
  29806 	}
  29807 	return int32(1)
  29808 }
  29809 
  29810 func WebPPictureFree(tls *libc.TLS, picture uintptr) {
  29811 	if picture != libc.UintptrFromInt32(0) {
  29812 		WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_)
  29813 		WebPSafeFree(tls, (*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_)
  29814 		WebPPictureResetBuffers(tls, picture)
  29815 	}
  29816 }
  29817 
  29818 //------------------------------------------------------------------------------
  29819 // WebPMemoryWriter: Write-to-memory
  29820 
  29821 func WebPMemoryWriterInit(tls *libc.TLS, writer uintptr) {
  29822 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmem = libc.UintptrFromInt32(0)
  29823 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fsize = uint64(0)
  29824 	(*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmax_size = uint64(0)
  29825 }
  29826 
  29827 func WebPMemoryWrite(tls *libc.TLS, data uintptr, data_size size_t, picture uintptr) (r int32) {
  29828 	var new_mem, w uintptr
  29829 	var next_max_size, next_size uint64_t
  29830 	_, _, _, _ = new_mem, next_max_size, next_size, w
  29831 	w = (*WebPPicture)(unsafe.Pointer(picture)).Fcustom_ptr
  29832 	if w == libc.UintptrFromInt32(0) {
  29833 		return int32(1)
  29834 	}
  29835 	next_size = (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize + data_size
  29836 	if next_size > (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size {
  29837 		next_max_size = uint64(2) * (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size
  29838 		if next_max_size < next_size {
  29839 			next_max_size = next_size
  29840 		}
  29841 		if next_max_size < uint64(8192) {
  29842 			next_max_size = uint64(8192)
  29843 		}
  29844 		new_mem = WebPSafeMalloc(tls, next_max_size, uint64(1))
  29845 		if new_mem == libc.UintptrFromInt32(0) {
  29846 			return 0
  29847 		}
  29848 		if (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize > uint64(0) {
  29849 			libc.X__builtin___memcpy_chk(tls, new_mem, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize, ^__predefined_size_t(0))
  29850 		}
  29851 		WebPSafeFree(tls, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem)
  29852 		(*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem = new_mem
  29853 		// down-cast is ok, thanks to WebPSafeMalloc
  29854 		(*WebPMemoryWriter)(unsafe.Pointer(w)).Fmax_size = next_max_size
  29855 	}
  29856 	if data_size > uint64(0) {
  29857 		libc.X__builtin___memcpy_chk(tls, (*WebPMemoryWriter)(unsafe.Pointer(w)).Fmem+uintptr((*WebPMemoryWriter)(unsafe.Pointer(w)).Fsize), data, data_size, ^__predefined_size_t(0))
  29858 		**(**size_t)(__ccgo_up(w + 8)) += data_size
  29859 	}
  29860 	return int32(1)
  29861 }
  29862 
  29863 func WebPMemoryWriterClear(tls *libc.TLS, writer uintptr) {
  29864 	if writer != libc.UintptrFromInt32(0) {
  29865 		WebPSafeFree(tls, (*WebPMemoryWriter)(unsafe.Pointer(writer)).Fmem)
  29866 		WebPMemoryWriterInit(tls, writer)
  29867 	}
  29868 }
  29869 
  29870 //------------------------------------------------------------------------------
  29871 // Simplest high-level calls:
  29872 
  29873 type Importer = uintptr
  29874 
  29875 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) {
  29876 	bp := tls.Alloc(416)
  29877 	defer tls.Free(416)
  29878 	var ok, v1, v3 int32
  29879 	var v5 bool
  29880 	var _ /* config at bp+256 */ WebPConfig
  29881 	var _ /* pic at bp+0 */ WebPPicture
  29882 	var _ /* wrt at bp+376 */ WebPMemoryWriter
  29883 	_, _, _, _ = ok, v1, v3, v5
  29884 	if output == libc.UintptrFromInt32(0) {
  29885 		return uint64(0)
  29886 	}
  29887 	v1 = WebPConfigInitInternal(tls, bp+256, int32(WEBP_PRESET_DEFAULT), quality_factor, int32(WEBP_ENCODER_ABI_VERSION))
  29888 	goto _2
  29889 _2:
  29890 	;
  29891 	if v5 = !(v1 != 0); !v5 {
  29892 		v3 = WebPPictureInitInternal(tls, bp, int32(WEBP_ENCODER_ABI_VERSION))
  29893 		goto _4
  29894 	_4:
  29895 	}
  29896 	if v5 || !(v3 != 0) {
  29897 		return uint64(0) // shouldn't happen, except if system installation is broken
  29898 	}
  29899 	(**(**WebPConfig)(__ccgo_up(bp + 256))).Flossless = libc.BoolInt32(!!(lossless != 0))
  29900 	(**(**WebPPicture)(__ccgo_up(bp))).Fuse_argb = libc.BoolInt32(!!(lossless != 0))
  29901 	(**(**WebPPicture)(__ccgo_up(bp))).Fwidth = width
  29902 	(**(**WebPPicture)(__ccgo_up(bp))).Fheight = height
  29903 	(**(**WebPPicture)(__ccgo_up(bp))).Fwriter = __ccgo_fp(WebPMemoryWrite)
  29904 	(**(**WebPPicture)(__ccgo_up(bp))).Fcustom_ptr = bp + 376
  29905 	WebPMemoryWriterInit(tls, bp+376)
  29906 	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)
  29907 	WebPPictureFree(tls, bp)
  29908 	if !(ok != 0) {
  29909 		WebPMemoryWriterClear(tls, bp+376)
  29910 		**(**uintptr)(__ccgo_up(output)) = libc.UintptrFromInt32(0)
  29911 		return uint64(0)
  29912 	}
  29913 	**(**uintptr)(__ccgo_up(output)) = (**(**WebPMemoryWriter)(__ccgo_up(bp + 376))).Fmem
  29914 	return (**(**WebPMemoryWriter)(__ccgo_up(bp + 376))).Fsize
  29915 }
  29916 
  29917 func WebPEncodeRGB(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29918 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGB), q, 0, out)
  29919 }
  29920 
  29921 func WebPEncodeRGBA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29922 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGBA), q, 0, out)
  29923 }
  29924 
  29925 func WebPEncodeBGR(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29926 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGR), q, 0, out)
  29927 }
  29928 
  29929 func WebPEncodeBGRA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, q float32, out uintptr) (r size_t) {
  29930 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGRA), q, 0, out)
  29931 }
  29932 
  29933 func WebPEncodeLosslessRGB(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29934 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGB), float32(70), int32(1), out)
  29935 }
  29936 
  29937 func WebPEncodeLosslessRGBA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29938 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportRGBA), float32(70), int32(1), out)
  29939 }
  29940 
  29941 func WebPEncodeLosslessBGR(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29942 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGR), float32(70), int32(1), out)
  29943 }
  29944 
  29945 func WebPEncodeLosslessBGRA(tls *libc.TLS, in uintptr, w int32, h int32, bps int32, out uintptr) (r size_t) {
  29946 	return Encode(tls, in, w, h, bps, __ccgo_fp(WebPPictureImportBGRA), float32(70), int32(1), out)
  29947 }
  29948 
  29949 const __FLT_MIN__5 = 1.1754943508222875e-38
  29950 const __INT_MAX__2 = 0x7fffffff
  29951 
  29952 //------------------------------------------------------------------------------
  29953 
  29954 // Copyright 2012 Google Inc. All Rights Reserved.
  29955 //
  29956 // Use of this source code is governed by a BSD-style license
  29957 // that can be found in the COPYING file in the root of the source
  29958 // tree. An additional intellectual property rights grant can be found
  29959 // in the file PATENTS. All contributing project authors may
  29960 // be found in the AUTHORS file in the root of the source tree.
  29961 // -----------------------------------------------------------------------------
  29962 //
  29963 // Misc. common utility functions
  29964 //
  29965 // Authors: Skal (pascal.massimino@gmail.com)
  29966 //          Urvang (urvang@google.com)
  29967 
  29968 type AccumulateFunc = uintptr
  29969 
  29970 //------------------------------------------------------------------------------
  29971 // local-min distortion
  29972 //
  29973 // For every pixel in the *reference* picture, we search for the local best
  29974 // match in the compressed image. This is not a symmetrical measure.
  29975 
  29976 func AccumulateLSIM(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  29977 	var best_sse, diff, sse, total_sse, value float64
  29978 	var i, j, x, x_0, x_1, y, y_0, y_1, v2, v3, v5, v6 int32
  29979 	var s uintptr
  29980 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_sse, diff, i, j, s, sse, total_sse, value, x, x_0, x_1, y, y_0, y_1, v2, v3, v5, v6
  29981 	total_sse = float64(0)
  29982 	y = 0
  29983 	for {
  29984 		if !(y < h) {
  29985 			break
  29986 		}
  29987 		if y-int32(2) < 0 {
  29988 			v2 = 0
  29989 		} else {
  29990 			v2 = y - int32(2)
  29991 		}
  29992 		y_0 = v2
  29993 		if y+int32(2)+int32(1) >= h {
  29994 			v3 = h
  29995 		} else {
  29996 			v3 = y + int32(2) + int32(1)
  29997 		}
  29998 		y_1 = v3
  29999 		x = 0
  30000 		for {
  30001 			if !(x < w) {
  30002 				break
  30003 			}
  30004 			if x-int32(2) < 0 {
  30005 				v5 = 0
  30006 			} else {
  30007 				v5 = x - int32(2)
  30008 			}
  30009 			x_0 = v5
  30010 			if x+int32(2)+int32(1) >= w {
  30011 				v6 = w
  30012 			} else {
  30013 				v6 = x + int32(2) + int32(1)
  30014 			}
  30015 			x_1 = v6
  30016 			best_sse = float64(libc.Float64FromFloat64(255) * libc.Float64FromFloat64(255))
  30017 			value = float64(**(**uint8_t)(__ccgo_up(ref + uintptr(y*ref_stride+x))))
  30018 			j = y_0
  30019 			for {
  30020 				if !(j < y_1) {
  30021 					break
  30022 				}
  30023 				s = src + uintptr(j*src_stride)
  30024 				i = x_0
  30025 				for {
  30026 					if !(i < x_1) {
  30027 						break
  30028 					}
  30029 					diff = float64(**(**uint8_t)(__ccgo_up(s + uintptr(i)))) - value
  30030 					sse = float64(diff * diff)
  30031 					if sse < best_sse {
  30032 						best_sse = sse
  30033 					}
  30034 					goto _8
  30035 				_8:
  30036 					;
  30037 					i = i + 1
  30038 				}
  30039 				goto _7
  30040 			_7:
  30041 				;
  30042 				j = j + 1
  30043 			}
  30044 			total_sse = total_sse + best_sse
  30045 			goto _4
  30046 		_4:
  30047 			;
  30048 			x = x + 1
  30049 		}
  30050 		goto _1
  30051 	_1:
  30052 		;
  30053 		y = y + 1
  30054 	}
  30055 	return total_sse
  30056 }
  30057 
  30058 func AccumulateSSE(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  30059 	var total_sse float64
  30060 	var y int32
  30061 	_, _ = total_sse, y
  30062 	total_sse = float64(0)
  30063 	y = 0
  30064 	for {
  30065 		if !(y < h) {
  30066 			break
  30067 		}
  30068 		total_sse = total_sse + float64((*(*func(*libc.TLS, uintptr, uintptr, int32) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8AccumulateSSE})))(tls, src, ref, w))
  30069 		src = src + uintptr(src_stride)
  30070 		ref = ref + uintptr(ref_stride)
  30071 		goto _1
  30072 	_1:
  30073 		;
  30074 		y = y + 1
  30075 	}
  30076 	return total_sse
  30077 }
  30078 
  30079 //------------------------------------------------------------------------------
  30080 
  30081 func AccumulateSSIM(tls *libc.TLS, src uintptr, src_stride int32, ref uintptr, ref_stride int32, w int32, h int32) (r float64) {
  30082 	var h0, h1, off1, off2, w0, w1, x, y, v1, v2 int32
  30083 	var sum float64
  30084 	_, _, _, _, _, _, _, _, _, _, _ = h0, h1, off1, off2, sum, w0, w1, x, y, v1, v2
  30085 	if w < int32(VP8_SSIM_KERNEL) {
  30086 		v1 = w
  30087 	} else {
  30088 		v1 = int32(VP8_SSIM_KERNEL)
  30089 	}
  30090 	w0 = v1
  30091 	w1 = w - int32(VP8_SSIM_KERNEL) - int32(1)
  30092 	if h < int32(VP8_SSIM_KERNEL) {
  30093 		v2 = h
  30094 	} else {
  30095 		v2 = int32(VP8_SSIM_KERNEL)
  30096 	}
  30097 	h0 = v2
  30098 	h1 = h - int32(VP8_SSIM_KERNEL) - int32(1)
  30099 	sum = float64(0)
  30100 	y = 0
  30101 	for {
  30102 		if !(y < h0) {
  30103 			break
  30104 		}
  30105 		x = 0
  30106 		for {
  30107 			if !(x < w) {
  30108 				break
  30109 			}
  30110 			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)
  30111 			goto _4
  30112 		_4:
  30113 			;
  30114 			x = x + 1
  30115 		}
  30116 		goto _3
  30117 	_3:
  30118 		;
  30119 		y = y + 1
  30120 	}
  30121 	for {
  30122 		if !(y < h1) {
  30123 			break
  30124 		}
  30125 		x = 0
  30126 		for {
  30127 			if !(x < w0) {
  30128 				break
  30129 			}
  30130 			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)
  30131 			goto _6
  30132 		_6:
  30133 			;
  30134 			x = x + 1
  30135 		}
  30136 		for {
  30137 			if !(x < w1) {
  30138 				break
  30139 			}
  30140 			off1 = x - int32(VP8_SSIM_KERNEL) + (y-int32(VP8_SSIM_KERNEL))*src_stride
  30141 			off2 = x - int32(VP8_SSIM_KERNEL) + (y-int32(VP8_SSIM_KERNEL))*ref_stride
  30142 			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)
  30143 			goto _7
  30144 		_7:
  30145 			;
  30146 			x = x + 1
  30147 		}
  30148 		for {
  30149 			if !(x < w) {
  30150 				break
  30151 			}
  30152 			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)
  30153 			goto _8
  30154 		_8:
  30155 			;
  30156 			x = x + 1
  30157 		}
  30158 		goto _5
  30159 	_5:
  30160 		;
  30161 		y = y + 1
  30162 	}
  30163 	for {
  30164 		if !(y < h) {
  30165 			break
  30166 		}
  30167 		x = 0
  30168 		for {
  30169 			if !(x < w) {
  30170 				break
  30171 			}
  30172 			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)
  30173 			goto _10
  30174 		_10:
  30175 			;
  30176 			x = x + 1
  30177 		}
  30178 		goto _9
  30179 	_9:
  30180 		;
  30181 		y = y + 1
  30182 	}
  30183 	return sum
  30184 }
  30185 
  30186 //------------------------------------------------------------------------------
  30187 // Distortion
  30188 
  30189 // C documentation
  30190 //
  30191 //	// Max value returned in case of exact similarity.
  30192 var kMinDistortion_dB = float64(99)
  30193 
  30194 func GetPSNR1(tls *libc.TLS, v float64, size float64) (r float64) {
  30195 	var v1 float64
  30196 	_ = v1
  30197 	if v > float64(0) && size > float64(0) {
  30198 		v1 = float64(-libc.Float64FromFloat64(4.3429448) * libc.Xlog(tls, v/float64(float64(size*libc.Float64FromInt32(255))*float64(255))))
  30199 	} else {
  30200 		v1 = kMinDistortion_dB
  30201 	}
  30202 	return v1
  30203 }
  30204 
  30205 func GetLogSSIM(tls *libc.TLS, v float64, size float64) (r float64) {
  30206 	var v1 float64
  30207 	_ = v1
  30208 	if size > float64(0) {
  30209 		v1 = v / size
  30210 	} else {
  30211 		v1 = float64(1)
  30212 	}
  30213 	v = v1
  30214 	if v < float64(1) {
  30215 		v1 = float64(-libc.Float64FromFloat64(10) * libc.Xlog10(tls, float64(1)-v))
  30216 	} else {
  30217 		v1 = kMinDistortion_dB
  30218 	}
  30219 	return v1
  30220 }
  30221 
  30222 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) {
  30223 	var allocated, tmp1, tmp2, v1, v2 uintptr
  30224 	var metric AccumulateFunc
  30225 	var x, y int32
  30226 	var v5 float32
  30227 	_, _, _, _, _, _, _, _, _ = allocated, metric, tmp1, tmp2, x, y, v1, v2, v5
  30228 	allocated = libc.UintptrFromInt32(0)
  30229 	if type1 == 0 {
  30230 		v1 = __ccgo_fp(AccumulateSSE)
  30231 	} else {
  30232 		if type1 == int32(1) {
  30233 			v2 = __ccgo_fp(AccumulateSSIM)
  30234 		} else {
  30235 			v2 = __ccgo_fp(AccumulateLSIM)
  30236 		}
  30237 		v1 = v2
  30238 	}
  30239 	metric = v1
  30240 	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) {
  30241 		return 0
  30242 	}
  30243 	VP8SSIMDspInit(tls)
  30244 	if x_step != uint64(1) {
  30245 		allocated = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height), uint64(1))
  30246 		if allocated == libc.UintptrFromInt32(0) {
  30247 			return 0
  30248 		}
  30249 		tmp1 = allocated
  30250 		tmp2 = tmp1 + uintptr(libc.Uint64FromInt32(width)*libc.Uint64FromInt32(height))
  30251 		y = 0
  30252 		for {
  30253 			if !(y < height) {
  30254 				break
  30255 			}
  30256 			x = 0
  30257 			for {
  30258 				if !(x < width) {
  30259 					break
  30260 				}
  30261 				**(**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)))
  30262 				**(**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)))
  30263 				goto _4
  30264 			_4:
  30265 				;
  30266 				x = x + 1
  30267 			}
  30268 			goto _3
  30269 		_3:
  30270 			;
  30271 			y = y + 1
  30272 		}
  30273 		src = tmp1
  30274 		ref = tmp2
  30275 	}
  30276 	**(**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))
  30277 	WebPSafeFree(tls, allocated)
  30278 	if type1 == int32(1) {
  30279 		v5 = float32(GetLogSSIM(tls, float64(**(**float32)(__ccgo_up(distortion))), float64(float64(width)*float64(height))))
  30280 	} else {
  30281 		v5 = float32(GetPSNR1(tls, float64(**(**float32)(__ccgo_up(distortion))), float64(float64(width)*float64(height))))
  30282 	}
  30283 	**(**float32)(__ccgo_up(result)) = v5
  30284 	return int32(1)
  30285 }
  30286 
  30287 func WebPPictureDistortion(tls *libc.TLS, src uintptr, ref uintptr, type1 int32, results uintptr) (r int32) {
  30288 	bp := tls.Alloc(528)
  30289 	defer tls.Free(528)
  30290 	var c, h, offset, ok, w, v1, v3 int32
  30291 	var stride0, stride1 size_t
  30292 	var total_distortion, total_size float64
  30293 	var v5 bool
  30294 	var v7 float32
  30295 	var _ /* distortion at bp+512 */ float32
  30296 	var _ /* p0 at bp+0 */ WebPPicture
  30297 	var _ /* p1 at bp+256 */ WebPPicture
  30298 	_, _, _, _, _, _, _, _, _, _, _, _, _ = c, h, offset, ok, stride0, stride1, total_distortion, total_size, w, v1, v3, v5, v7
  30299 	ok = 0
  30300 	total_size = float64(0)
  30301 	total_distortion = float64(0)
  30302 	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) {
  30303 		return 0
  30304 	}
  30305 	VP8SSIMDspInit(tls)
  30306 	v1 = WebPPictureInitInternal(tls, bp, int32(WEBP_ENCODER_ABI_VERSION))
  30307 	goto _2
  30308 _2:
  30309 	;
  30310 	if v5 = !(v1 != 0); !v5 {
  30311 		v3 = WebPPictureInitInternal(tls, bp+256, int32(WEBP_ENCODER_ABI_VERSION))
  30312 		goto _4
  30313 	_4:
  30314 	}
  30315 	if v5 || !(v3 != 0) {
  30316 		return 0
  30317 	}
  30318 	w = (*WebPPicture)(unsafe.Pointer(src)).Fwidth
  30319 	h = (*WebPPicture)(unsafe.Pointer(src)).Fheight
  30320 	if !(WebPPictureView(tls, src, 0, 0, w, h, bp) != 0) {
  30321 		goto Error
  30322 	}
  30323 	if !(WebPPictureView(tls, ref, 0, 0, w, h, bp+256) != 0) {
  30324 		goto Error
  30325 	}
  30326 	// We always measure distortion in ARGB space.
  30327 	if (**(**WebPPicture)(__ccgo_up(bp))).Fuse_argb == 0 && !(WebPPictureYUVAToARGB(tls, bp) != 0) {
  30328 		goto Error
  30329 	}
  30330 	if (**(**WebPPicture)(__ccgo_up(bp + 256))).Fuse_argb == 0 && !(WebPPictureYUVAToARGB(tls, bp+256) != 0) {
  30331 		goto Error
  30332 	}
  30333 	c = 0
  30334 	for {
  30335 		if !(c < int32(4)) {
  30336 			break
  30337 		}
  30338 		stride0 = uint64(4) * libc.Uint64FromInt32((**(**WebPPicture)(__ccgo_up(bp))).Fargb_stride)
  30339 		stride1 = uint64(4) * libc.Uint64FromInt32((**(**WebPPicture)(__ccgo_up(bp + 256))).Fargb_stride)
  30340 		// results are reported as BGRA
  30341 		offset = c ^ 0
  30342 		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) {
  30343 			goto Error
  30344 		}
  30345 		total_distortion = total_distortion + float64(**(**float32)(__ccgo_up(bp + 512)))
  30346 		total_size = total_size + float64(w*h)
  30347 		goto _6
  30348 	_6:
  30349 		;
  30350 		c = c + 1
  30351 	}
  30352 	if type1 == int32(1) {
  30353 		v7 = float32(GetLogSSIM(tls, total_distortion, total_size))
  30354 	} else {
  30355 		v7 = float32(GetPSNR1(tls, total_distortion, total_size))
  30356 	}
  30357 	**(**float32)(__ccgo_up(results + 4*4)) = v7
  30358 	ok = int32(1)
  30359 	goto Error
  30360 Error:
  30361 	;
  30362 	WebPPictureFree(tls, bp)
  30363 	WebPPictureFree(tls, bp+256)
  30364 	return ok
  30365 }
  30366 
  30367 const __FLT_MIN__6 = 1.17549435082228750796873653722224568e-38
  30368 
  30369 //------------------------------------------------------------------------------
  30370 
  30371 // Copyright 2012 Google Inc. All Rights Reserved.
  30372 //
  30373 // Use of this source code is governed by a BSD-style license
  30374 // that can be found in the COPYING file in the root of the source
  30375 // tree. An additional intellectual property rights grant can be found
  30376 // in the file PATENTS. All contributing project authors may
  30377 // be found in the AUTHORS file in the root of the source tree.
  30378 // -----------------------------------------------------------------------------
  30379 //
  30380 // Misc. common utility functions
  30381 //
  30382 // Authors: Skal (pascal.massimino@gmail.com)
  30383 //          Urvang (urvang@google.com)
  30384 
  30385 // C documentation
  30386 //
  30387 //	// Grab the 'specs' (writer, *opaque, width, height...) from 'src' and copy them
  30388 //	// into 'dst'. Mark 'dst' as not owning any memory.
  30389 func PictureGrabSpecs(tls *libc.TLS, src uintptr, dst uintptr) {
  30390 	**(**WebPPicture)(__ccgo_up(dst)) = **(**WebPPicture)(__ccgo_up(src))
  30391 	WebPPictureResetBuffers(tls, dst)
  30392 }
  30393 
  30394 //------------------------------------------------------------------------------
  30395 
  30396 // C documentation
  30397 //
  30398 //	// Adjust top-left corner to chroma sample position.
  30399 func SnapTopLeftPosition(tls *libc.TLS, pic uintptr, left uintptr, top uintptr) {
  30400 	if !((*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0) {
  30401 		**(**int32)(__ccgo_up(left)) &= ^libc.Int32FromInt32(1)
  30402 		**(**int32)(__ccgo_up(top)) &= ^libc.Int32FromInt32(1)
  30403 	}
  30404 }
  30405 
  30406 // C documentation
  30407 //
  30408 //	// Adjust top-left corner and verify that the sub-rectangle is valid.
  30409 func AdjustAndCheckRectangle(tls *libc.TLS, pic uintptr, left uintptr, top uintptr, width int32, height int32) (r int32) {
  30410 	SnapTopLeftPosition(tls, pic, left, top)
  30411 	if **(**int32)(__ccgo_up(left)) < 0 || **(**int32)(__ccgo_up(top)) < 0 {
  30412 		return 0
  30413 	}
  30414 	if width <= 0 || height <= 0 {
  30415 		return 0
  30416 	}
  30417 	if **(**int32)(__ccgo_up(left))+width > (*WebPPicture)(unsafe.Pointer(pic)).Fwidth {
  30418 		return 0
  30419 	}
  30420 	if **(**int32)(__ccgo_up(top))+height > (*WebPPicture)(unsafe.Pointer(pic)).Fheight {
  30421 		return 0
  30422 	}
  30423 	return int32(1)
  30424 }
  30425 
  30426 func WebPPictureCopy(tls *libc.TLS, src uintptr, dst uintptr) (r int32) {
  30427 	if src == libc.UintptrFromInt32(0) || dst == libc.UintptrFromInt32(0) {
  30428 		return 0
  30429 	}
  30430 	if src == dst {
  30431 		return int32(1)
  30432 	}
  30433 	PictureGrabSpecs(tls, src, dst)
  30434 	if !(WebPPictureAlloc(tls, dst) != 0) {
  30435 		return 0
  30436 	}
  30437 	if !((*WebPPicture)(unsafe.Pointer(src)).Fuse_argb != 0) {
  30438 		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)
  30439 		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))
  30440 		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))
  30441 		if (*WebPPicture)(unsafe.Pointer(dst)).Fa != libc.UintptrFromInt32(0) {
  30442 			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)
  30443 		}
  30444 	} else {
  30445 		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)
  30446 	}
  30447 	return int32(1)
  30448 }
  30449 
  30450 func WebPPictureIsView(tls *libc.TLS, picture uintptr) (r int32) {
  30451 	if picture == libc.UintptrFromInt32(0) {
  30452 		return 0
  30453 	}
  30454 	if (*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0 {
  30455 		return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Fmemory_argb_ == libc.UintptrFromInt32(0))
  30456 	}
  30457 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Fmemory_ == libc.UintptrFromInt32(0))
  30458 }
  30459 
  30460 func WebPPictureView(tls *libc.TLS, src uintptr, _left int32, _top int32, width int32, height int32, dst uintptr) (r int32) {
  30461 	bp := tls.Alloc(16)
  30462 	defer tls.Free(16)
  30463 	*(*int32)(unsafe.Pointer(bp)) = _left
  30464 	*(*int32)(unsafe.Pointer(bp + 4)) = _top
  30465 	if src == libc.UintptrFromInt32(0) || dst == libc.UintptrFromInt32(0) {
  30466 		return 0
  30467 	}
  30468 	// verify rectangle position.
  30469 	if !(AdjustAndCheckRectangle(tls, src, bp, bp+4, width, height) != 0) {
  30470 		return 0
  30471 	}
  30472 	if src != dst { // beware of aliasing! We don't want to leak 'memory_'.
  30473 		PictureGrabSpecs(tls, src, dst)
  30474 	}
  30475 	(*WebPPicture)(unsafe.Pointer(dst)).Fwidth = width
  30476 	(*WebPPicture)(unsafe.Pointer(dst)).Fheight = height
  30477 	if !((*WebPPicture)(unsafe.Pointer(src)).Fuse_argb != 0) {
  30478 		(*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)))
  30479 		(*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))
  30480 		(*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))
  30481 		(*WebPPicture)(unsafe.Pointer(dst)).Fy_stride = (*WebPPicture)(unsafe.Pointer(src)).Fy_stride
  30482 		(*WebPPicture)(unsafe.Pointer(dst)).Fuv_stride = (*WebPPicture)(unsafe.Pointer(src)).Fuv_stride
  30483 		if (*WebPPicture)(unsafe.Pointer(src)).Fa != libc.UintptrFromInt32(0) {
  30484 			(*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)))
  30485 			(*WebPPicture)(unsafe.Pointer(dst)).Fa_stride = (*WebPPicture)(unsafe.Pointer(src)).Fa_stride
  30486 		}
  30487 	} else {
  30488 		(*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
  30489 		(*WebPPicture)(unsafe.Pointer(dst)).Fargb_stride = (*WebPPicture)(unsafe.Pointer(src)).Fargb_stride
  30490 	}
  30491 	return int32(1)
  30492 }
  30493 
  30494 //------------------------------------------------------------------------------
  30495 // Picture cropping
  30496 
  30497 func WebPPictureCrop(tls *libc.TLS, pic uintptr, _left int32, _top int32, width int32, height int32) (r int32) {
  30498 	bp := tls.Alloc(272)
  30499 	defer tls.Free(272)
  30500 	*(*int32)(unsafe.Pointer(bp)) = _left
  30501 	*(*int32)(unsafe.Pointer(bp + 4)) = _top
  30502 	var a_offset, uv_offset, y_offset int32
  30503 	var src uintptr
  30504 	var _ /* tmp at bp+8 */ WebPPicture
  30505 	_, _, _, _ = a_offset, src, uv_offset, y_offset
  30506 	if pic == libc.UintptrFromInt32(0) {
  30507 		return 0
  30508 	}
  30509 	if !(AdjustAndCheckRectangle(tls, pic, bp, bp+4, width, height) != 0) {
  30510 		return 0
  30511 	}
  30512 	PictureGrabSpecs(tls, pic, bp+8)
  30513 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fwidth = width
  30514 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fheight = height
  30515 	if !(WebPPictureAlloc(tls, bp+8) != 0) {
  30516 		return WebPEncodingSetError(tls, pic, (**(**WebPPicture)(__ccgo_up(bp + 8))).Ferror_code)
  30517 	}
  30518 	if !((*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0) {
  30519 		y_offset = **(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(pic)).Fy_stride + **(**int32)(__ccgo_up(bp))
  30520 		uv_offset = **(**int32)(__ccgo_up(bp + 4))/int32(2)*(*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride + **(**int32)(__ccgo_up(bp))/int32(2)
  30521 		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)
  30522 		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))
  30523 		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))
  30524 		if (**(**WebPPicture)(__ccgo_up(bp + 8))).Fa != libc.UintptrFromInt32(0) {
  30525 			a_offset = **(**int32)(__ccgo_up(bp + 4))*(*WebPPicture)(unsafe.Pointer(pic)).Fa_stride + **(**int32)(__ccgo_up(bp))
  30526 			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)
  30527 		}
  30528 	} else {
  30529 		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
  30530 		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)
  30531 	}
  30532 	WebPPictureFree(tls, pic)
  30533 	**(**WebPPicture)(__ccgo_up(pic)) = **(**WebPPicture)(__ccgo_up(bp + 8))
  30534 	return int32(1)
  30535 }
  30536 
  30537 //------------------------------------------------------------------------------
  30538 // Simple picture rescaler
  30539 
  30540 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) {
  30541 	bp := tls.Alloc(112)
  30542 	defer tls.Free(112)
  30543 	var y int32
  30544 	var _ /* rescaler at bp+0 */ WebPRescaler
  30545 	_ = y
  30546 	y = 0
  30547 	if !(WebPRescalerInit(tls, bp, src_width, src_height, dst, dst_width, dst_height, dst_stride, num_channels, work) != 0) {
  30548 		return 0
  30549 	}
  30550 	for y < src_height {
  30551 		y = y + WebPRescalerImport(tls, bp, src_height-y, src+uintptr(y*src_stride), src_stride)
  30552 		WebPRescalerExport(tls, bp)
  30553 	}
  30554 	return int32(1)
  30555 }
  30556 
  30557 func AlphaMultiplyARGB(tls *libc.TLS, pic uintptr, inverse int32) {
  30558 	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)
  30559 }
  30560 
  30561 func AlphaMultiplyY(tls *libc.TLS, pic uintptr, inverse int32) {
  30562 	if (*WebPPicture)(unsafe.Pointer(pic)).Fa != libc.UintptrFromInt32(0) {
  30563 		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)
  30564 	}
  30565 }
  30566 
  30567 func WebPPictureRescale(tls *libc.TLS, picture uintptr, _width int32, _height int32) (r int32) {
  30568 	bp := tls.Alloc(272)
  30569 	defer tls.Free(272)
  30570 	*(*int32)(unsafe.Pointer(bp)) = _width
  30571 	*(*int32)(unsafe.Pointer(bp + 4)) = _height
  30572 	var prev_height, prev_width int32
  30573 	var work uintptr
  30574 	var _ /* tmp at bp+8 */ WebPPicture
  30575 	_, _, _ = prev_height, prev_width, work
  30576 	if picture == libc.UintptrFromInt32(0) {
  30577 		return 0
  30578 	}
  30579 	prev_width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  30580 	prev_height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  30581 	if !(WebPRescalerGetScaledDimensions(tls, prev_width, prev_height, bp, bp+4) != 0) {
  30582 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30583 	}
  30584 	PictureGrabSpecs(tls, picture, bp+8)
  30585 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fwidth = **(**int32)(__ccgo_up(bp))
  30586 	(**(**WebPPicture)(__ccgo_up(bp + 8))).Fheight = **(**int32)(__ccgo_up(bp + 4))
  30587 	if !(WebPPictureAlloc(tls, bp+8) != 0) {
  30588 		return WebPEncodingSetError(tls, picture, (**(**WebPPicture)(__ccgo_up(bp + 8))).Ferror_code)
  30589 	}
  30590 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  30591 		work = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))), uint64(4))
  30592 		if work == libc.UintptrFromInt32(0) {
  30593 			WebPPictureFree(tls, bp+8)
  30594 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  30595 		}
  30596 		// If present, we need to rescale alpha first (for AlphaMultiplyY).
  30597 		if (*WebPPicture)(unsafe.Pointer(picture)).Fa != libc.UintptrFromInt32(0) {
  30598 			WebPInitAlphaProcessing(tls)
  30599 			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) {
  30600 				return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30601 			}
  30602 		}
  30603 		// We take transparency into account on the luma plane only. That's not
  30604 		// totally exact blending, but still is a good approximation.
  30605 		AlphaMultiplyY(tls, picture, 0)
  30606 		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) {
  30607 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30608 		}
  30609 		AlphaMultiplyY(tls, bp+8, int32(1))
  30610 	} else {
  30611 		work = WebPSafeMalloc(tls, uint64(2)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(4), uint64(4))
  30612 		if work == libc.UintptrFromInt32(0) {
  30613 			WebPPictureFree(tls, bp+8)
  30614 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  30615 		}
  30616 		// In order to correctly interpolate colors, we need to apply the alpha
  30617 		// weighting first (black-matting), scale the RGB values, and remove
  30618 		// the premultiplication afterward (while preserving the alpha channel).
  30619 		WebPInitAlphaProcessing(tls)
  30620 		AlphaMultiplyARGB(tls, picture, 0)
  30621 		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) {
  30622 			return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  30623 		}
  30624 		AlphaMultiplyARGB(tls, bp+8, int32(1))
  30625 	}
  30626 	WebPPictureFree(tls, picture)
  30627 	WebPSafeFree(tls, work)
  30628 	**(**WebPPicture)(__ccgo_up(picture)) = **(**WebPPicture)(__ccgo_up(bp + 8))
  30629 	return int32(1)
  30630 }
  30631 
  30632 //------------------------------------------------------------------------------
  30633 
  30634 // Copyright 2011 Google Inc. All Rights Reserved.
  30635 //
  30636 // Use of this source code is governed by a BSD-style license
  30637 // that can be found in the COPYING file in the root of the source
  30638 // tree. An additional intellectual property rights grant can be found
  30639 // in the file PATENTS. All contributing project authors may
  30640 // be found in the AUTHORS file in the root of the source tree.
  30641 // -----------------------------------------------------------------------------
  30642 //
  30643 //   WebP encoder: main interface
  30644 //
  30645 // Author: Skal (pascal.massimino@gmail.com)
  30646 
  30647 // Copyright 2010 Google Inc. All Rights Reserved.
  30648 //
  30649 // Use of this source code is governed by a BSD-style license
  30650 // that can be found in the COPYING file in the root of the source
  30651 // tree. An additional intellectual property rights grant can be found
  30652 // in the file PATENTS. All contributing project authors may
  30653 // be found in the AUTHORS file in the root of the source tree.
  30654 // -----------------------------------------------------------------------------
  30655 //
  30656 //  Common types + memory wrappers
  30657 //
  30658 // Author: Skal (pascal.massimino@gmail.com)
  30659 
  30660 //------------------------------------------------------------------------------
  30661 // Helper: clean up fully transparent area to help compressibility.
  30662 
  30663 func IsTransparentARGBArea(tls *libc.TLS, ptr uintptr, stride int32, size int32) (r int32) {
  30664 	var x, y int32
  30665 	_, _ = x, y
  30666 	y = 0
  30667 	for {
  30668 		if !(y < size) {
  30669 			break
  30670 		}
  30671 		x = 0
  30672 		for {
  30673 			if !(x < size) {
  30674 				break
  30675 			}
  30676 			if **(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4))&uint32(0xff000000) != 0 {
  30677 				return 0
  30678 			}
  30679 			goto _2
  30680 		_2:
  30681 			;
  30682 			x = x + 1
  30683 		}
  30684 		ptr = ptr + uintptr(stride)*4
  30685 		goto _1
  30686 	_1:
  30687 		;
  30688 		y = y + 1
  30689 	}
  30690 	return int32(1)
  30691 }
  30692 
  30693 func Flatten(tls *libc.TLS, ptr uintptr, v int32, stride int32, size int32) {
  30694 	var y int32
  30695 	_ = y
  30696 	y = 0
  30697 	for {
  30698 		if !(y < size) {
  30699 			break
  30700 		}
  30701 		libc.X__builtin___memset_chk(tls, ptr, v, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  30702 		ptr = ptr + uintptr(stride)
  30703 		goto _1
  30704 	_1:
  30705 		;
  30706 		y = y + 1
  30707 	}
  30708 }
  30709 
  30710 func FlattenARGB(tls *libc.TLS, ptr uintptr, v uint32_t, stride int32, size int32) {
  30711 	var x, y int32
  30712 	_, _ = x, y
  30713 	y = 0
  30714 	for {
  30715 		if !(y < size) {
  30716 			break
  30717 		}
  30718 		x = 0
  30719 		for {
  30720 			if !(x < size) {
  30721 				break
  30722 			}
  30723 			**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = v
  30724 			goto _2
  30725 		_2:
  30726 			;
  30727 			x = x + 1
  30728 		}
  30729 		ptr = ptr + uintptr(stride)*4
  30730 		goto _1
  30731 	_1:
  30732 		;
  30733 		y = y + 1
  30734 	}
  30735 }
  30736 
  30737 // C documentation
  30738 //
  30739 //	// Smoothen the luma components of transparent pixels. Return true if the whole
  30740 //	// block is transparent.
  30741 func SmoothenBlock(tls *libc.TLS, a_ptr uintptr, a_stride int32, y_ptr uintptr, y_stride int32, width int32, height int32) (r int32) {
  30742 	var alpha_ptr, luma_ptr uintptr
  30743 	var avg_u8 uint8_t
  30744 	var count, sum, x, y int32
  30745 	_, _, _, _, _, _, _ = alpha_ptr, avg_u8, count, luma_ptr, sum, x, y
  30746 	sum = 0
  30747 	count = 0
  30748 	alpha_ptr = a_ptr
  30749 	luma_ptr = y_ptr
  30750 	y = 0
  30751 	for {
  30752 		if !(y < height) {
  30753 			break
  30754 		}
  30755 		x = 0
  30756 		for {
  30757 			if !(x < width) {
  30758 				break
  30759 			}
  30760 			if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_ptr + uintptr(x)))) != 0 {
  30761 				count = count + 1
  30762 				sum = sum + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(luma_ptr + uintptr(x))))
  30763 			}
  30764 			goto _2
  30765 		_2:
  30766 			;
  30767 			x = x + 1
  30768 		}
  30769 		alpha_ptr = alpha_ptr + uintptr(a_stride)
  30770 		luma_ptr = luma_ptr + uintptr(y_stride)
  30771 		goto _1
  30772 	_1:
  30773 		;
  30774 		y = y + 1
  30775 	}
  30776 	if count > 0 && count < width*height {
  30777 		avg_u8 = libc.Uint8FromInt32(sum / count)
  30778 		alpha_ptr = a_ptr
  30779 		luma_ptr = y_ptr
  30780 		y = 0
  30781 		for {
  30782 			if !(y < height) {
  30783 				break
  30784 			}
  30785 			x = 0
  30786 			for {
  30787 				if !(x < width) {
  30788 					break
  30789 				}
  30790 				if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(alpha_ptr + uintptr(x)))) == 0 {
  30791 					**(**uint8_t)(__ccgo_up(luma_ptr + uintptr(x))) = avg_u8
  30792 				}
  30793 				goto _4
  30794 			_4:
  30795 				;
  30796 				x = x + 1
  30797 			}
  30798 			alpha_ptr = alpha_ptr + uintptr(a_stride)
  30799 			luma_ptr = luma_ptr + uintptr(y_stride)
  30800 			goto _3
  30801 		_3:
  30802 			;
  30803 			y = y + 1
  30804 		}
  30805 	}
  30806 	return libc.BoolInt32(count == 0)
  30807 }
  30808 
  30809 func WebPReplaceTransparentPixels(tls *libc.TLS, pic uintptr, color uint32_t) {
  30810 	var argb uintptr
  30811 	var y, v1 int32
  30812 	_, _, _ = argb, y, v1
  30813 	if pic != libc.UintptrFromInt32(0) && (*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0 {
  30814 		y = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  30815 		argb = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  30816 		color = color & uint32(0xffffff) // force alpha=0
  30817 		WebPInitAlphaProcessing(tls)
  30818 		for {
  30819 			v1 = y
  30820 			y = y - 1
  30821 			if !(v1 > 0) {
  30822 				break
  30823 			}
  30824 			(*(*func(*libc.TLS, uintptr, int32, uint32_t))(unsafe.Pointer(&struct{ uintptr }{WebPAlphaReplace})))(tls, argb, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, color)
  30825 			argb = argb + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  30826 		}
  30827 	}
  30828 }
  30829 
  30830 func WebPCleanupTransparentArea(tls *libc.TLS, pic uintptr) {
  30831 	var a_ptr, u_ptr, v_ptr, y_ptr uintptr
  30832 	var a_stride, h, height, need_reset, need_reset1, off, sub_height, uv_stride, w, width, x, y, y_stride int32
  30833 	var argb_value uint32_t
  30834 	var values [3]int32
  30835 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  30836 	if pic == libc.UintptrFromInt32(0) {
  30837 		return
  30838 	}
  30839 	w = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth / int32(8)
  30840 	h = (*WebPPicture)(unsafe.Pointer(pic)).Fheight / int32(8)
  30841 	// note: we ignore the left-overs on right/bottom, except for SmoothenBlock().
  30842 	if (*WebPPicture)(unsafe.Pointer(pic)).Fuse_argb != 0 {
  30843 		argb_value = uint32(0)
  30844 		y = 0
  30845 		for {
  30846 			if !(y < h) {
  30847 				break
  30848 			}
  30849 			need_reset = int32(1)
  30850 			x = 0
  30851 			for {
  30852 				if !(x < w) {
  30853 					break
  30854 				}
  30855 				off = (y*(*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride + x) * int32(8)
  30856 				if IsTransparentARGBArea(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb+uintptr(off)*4, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride, int32(8)) != 0 {
  30857 					if need_reset != 0 {
  30858 						argb_value = **(**uint32_t)(__ccgo_up((*WebPPicture)(unsafe.Pointer(pic)).Fargb + uintptr(off)*4))
  30859 						need_reset = 0
  30860 					}
  30861 					FlattenARGB(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fargb+uintptr(off)*4, argb_value, (*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride, int32(8))
  30862 				} else {
  30863 					need_reset = int32(1)
  30864 				}
  30865 				goto _2
  30866 			_2:
  30867 				;
  30868 				x = x + 1
  30869 			}
  30870 			goto _1
  30871 		_1:
  30872 			;
  30873 			y = y + 1
  30874 		}
  30875 	} else {
  30876 		width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  30877 		height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  30878 		y_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fy_stride
  30879 		uv_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fuv_stride
  30880 		a_stride = (*WebPPicture)(unsafe.Pointer(pic)).Fa_stride
  30881 		y_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fy
  30882 		u_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fu
  30883 		v_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fv
  30884 		a_ptr = (*WebPPicture)(unsafe.Pointer(pic)).Fa
  30885 		values = [3]int32{}
  30886 		if a_ptr == libc.UintptrFromInt32(0) || y_ptr == libc.UintptrFromInt32(0) || u_ptr == libc.UintptrFromInt32(0) || v_ptr == libc.UintptrFromInt32(0) {
  30887 			return
  30888 		}
  30889 		y = 0
  30890 		for {
  30891 			if !(y+int32(8) <= height) {
  30892 				break
  30893 			}
  30894 			need_reset1 = int32(1)
  30895 			x = 0
  30896 			for {
  30897 				if !(x+int32(8) <= width) {
  30898 					break
  30899 				}
  30900 				if SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, int32(8), int32(8)) != 0 {
  30901 					if need_reset1 != 0 {
  30902 						values[0] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y_ptr + uintptr(x))))
  30903 						values[int32(1)] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u_ptr + uintptr(x>>int32(1)))))
  30904 						values[int32(2)] = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v_ptr + uintptr(x>>int32(1)))))
  30905 						need_reset1 = 0
  30906 					}
  30907 					Flatten(tls, y_ptr+uintptr(x), values[0], y_stride, int32(8))
  30908 					Flatten(tls, u_ptr+uintptr(x>>libc.Int32FromInt32(1)), values[int32(1)], uv_stride, libc.Int32FromInt32(8)/libc.Int32FromInt32(2))
  30909 					Flatten(tls, v_ptr+uintptr(x>>libc.Int32FromInt32(1)), values[int32(2)], uv_stride, libc.Int32FromInt32(8)/libc.Int32FromInt32(2))
  30910 				} else {
  30911 					need_reset1 = int32(1)
  30912 				}
  30913 				goto _4
  30914 			_4:
  30915 				;
  30916 				x = x + int32(8)
  30917 			}
  30918 			if x < width {
  30919 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, width-x, int32(8))
  30920 			}
  30921 			a_ptr = a_ptr + uintptr(int32(8)*a_stride)
  30922 			y_ptr = y_ptr + uintptr(int32(8)*y_stride)
  30923 			u_ptr = u_ptr + uintptr(libc.Int32FromInt32(8)/libc.Int32FromInt32(2)*uv_stride)
  30924 			v_ptr = v_ptr + uintptr(libc.Int32FromInt32(8)/libc.Int32FromInt32(2)*uv_stride)
  30925 			goto _3
  30926 		_3:
  30927 			;
  30928 			y = y + int32(8)
  30929 		}
  30930 		if y < height {
  30931 			sub_height = height - y
  30932 			x = 0
  30933 			for {
  30934 				if !(x+int32(8) <= width) {
  30935 					break
  30936 				}
  30937 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, int32(8), sub_height)
  30938 				goto _5
  30939 			_5:
  30940 				;
  30941 				x = x + int32(8)
  30942 			}
  30943 			if x < width {
  30944 				SmoothenBlock(tls, a_ptr+uintptr(x), a_stride, y_ptr+uintptr(x), y_stride, width-x, sub_height)
  30945 			}
  30946 		}
  30947 	}
  30948 }
  30949 
  30950 //------------------------------------------------------------------------------
  30951 // Blend color and remove transparency info
  30952 
  30953 func MakeARGB32(tls *libc.TLS, r int32, g int32, b int32) (r1 uint32_t) {
  30954 	return libc.Uint32FromUint32(0xff000000) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  30955 }
  30956 
  30957 func WebPBlendAlpha(tls *libc.TLS, picture uintptr, background_rgb uint32_t) {
  30958 	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
  30959 	var a_ptr, a_ptr2, argb, u_ptr, v_ptr, y_ptr, v19 uintptr
  30960 	var alpha uint8_t
  30961 	var alpha1, alpha2, background uint32_t
  30962 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  30963 	red = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(16) & uint32(0xff))
  30964 	green = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(8) & uint32(0xff))
  30965 	blue = libc.Int32FromUint32(background_rgb >> libc.Int32FromInt32(0) & uint32(0xff))
  30966 	if picture == libc.UintptrFromInt32(0) {
  30967 		return
  30968 	}
  30969 	if !((*WebPPicture)(unsafe.Pointer(picture)).Fuse_argb != 0) {
  30970 		// omit last pixel during u/v loop
  30971 		uv_width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth >> libc.Int32FromInt32(1)
  30972 		luma = int32(16839)*red + int32(33059)*green + int32(6420)*blue
  30973 		v1 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  30974 		goto _2
  30975 	_2:
  30976 		Y0 = v1
  30977 		u = -int32(9719)*(int32(4)*red) - int32(19081)*(int32(4)*green) + int32(28800)*(int32(4)*blue)
  30978 		v5 = u
  30979 		v5 = (v5 + libc.Int32FromInt32(4)*int32(YUV_HALF) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  30980 		if v5 & ^libc.Int32FromInt32(0xff) == 0 {
  30981 			v8 = v5
  30982 		} else {
  30983 			if v5 < 0 {
  30984 				v9 = 0
  30985 			} else {
  30986 				v9 = int32(255)
  30987 			}
  30988 			v8 = v9
  30989 		}
  30990 		v6 = v8
  30991 		goto _7
  30992 	_7:
  30993 		v3 = v6
  30994 		goto _4
  30995 	_4:
  30996 		// VP8RGBToU/V expects the u/v values summed over four pixels
  30997 		U0 = v3
  30998 		v = +libc.Int32FromInt32(28800)*(int32(4)*red) - int32(24116)*(int32(4)*green) - int32(4684)*(int32(4)*blue)
  30999 		v12 = v
  31000 		v12 = (v12 + libc.Int32FromInt32(4)*int32(YUV_HALF) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  31001 		if v12 & ^libc.Int32FromInt32(0xff) == 0 {
  31002 			v15 = v12
  31003 		} else {
  31004 			if v12 < 0 {
  31005 				v16 = 0
  31006 			} else {
  31007 				v16 = int32(255)
  31008 			}
  31009 			v15 = v16
  31010 		}
  31011 		v13 = v15
  31012 		goto _14
  31013 	_14:
  31014 		v10 = v13
  31015 		goto _11
  31016 	_11:
  31017 		V0 = v10
  31018 		has_alpha = (*WebPPicture)(unsafe.Pointer(picture)).Fcolorspace & int32(WEBP_CSP_ALPHA_BIT)
  31019 		y_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fy
  31020 		u_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fu
  31021 		v_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fv
  31022 		a_ptr = (*WebPPicture)(unsafe.Pointer(picture)).Fa
  31023 		if !(has_alpha != 0) || a_ptr == libc.UintptrFromInt32(0) {
  31024 			return
  31025 		} // nothing to do
  31026 		y = 0
  31027 		for {
  31028 			if !(y < (*WebPPicture)(unsafe.Pointer(picture)).Fheight) {
  31029 				break
  31030 			}
  31031 			// Luma blending
  31032 			x = 0
  31033 			for {
  31034 				if !(x < (*WebPPicture)(unsafe.Pointer(picture)).Fwidth) {
  31035 					break
  31036 				}
  31037 				alpha = **(**uint8_t)(__ccgo_up(a_ptr + uintptr(x)))
  31038 				if libc.Int32FromUint8(alpha) < int32(0xff) {
  31039 					**(**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))
  31040 				}
  31041 				goto _18
  31042 			_18:
  31043 				;
  31044 				x = x + 1
  31045 			}
  31046 			// Chroma blending every even line
  31047 			if y&int32(1) == 0 {
  31048 				if y+int32(1) == (*WebPPicture)(unsafe.Pointer(picture)).Fheight {
  31049 					v19 = a_ptr
  31050 				} else {
  31051 					v19 = a_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  31052 				}
  31053 				a_ptr2 = v19
  31054 				x = 0
  31055 				for {
  31056 					if !(x < uv_width) {
  31057 						break
  31058 					}
  31059 					// Average four alpha values into a single blending weight.
  31060 					// TODO(skal): might lead to visible contouring. Can we do better?
  31061 					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))))))
  31062 					**(**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))
  31063 					**(**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))
  31064 					goto _20
  31065 				_20:
  31066 					;
  31067 					x = x + 1
  31068 				}
  31069 				if (*WebPPicture)(unsafe.Pointer(picture)).Fwidth&int32(1) != 0 { // rightmost pixel
  31070 					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))))))
  31071 					**(**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))
  31072 					**(**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))
  31073 				}
  31074 			} else {
  31075 				u_ptr = u_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  31076 				v_ptr = v_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fuv_stride)
  31077 			}
  31078 			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
  31079 			a_ptr = a_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fa_stride)
  31080 			y_ptr = y_ptr + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fy_stride)
  31081 			goto _17
  31082 		_17:
  31083 			;
  31084 			y = y + 1
  31085 		}
  31086 	} else {
  31087 		argb = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  31088 		background = MakeARGB32(tls, red, green, blue)
  31089 		y = 0
  31090 		for {
  31091 			if !(y < (*WebPPicture)(unsafe.Pointer(picture)).Fheight) {
  31092 				break
  31093 			}
  31094 			x = 0
  31095 			for {
  31096 				if !(x < (*WebPPicture)(unsafe.Pointer(picture)).Fwidth) {
  31097 					break
  31098 				}
  31099 				alpha3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(24) & uint32(0xff))
  31100 				if alpha3 != int32(0xff) {
  31101 					if alpha3 > 0 {
  31102 						r3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(16) & uint32(0xff))
  31103 						g3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  31104 						b3 = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) >> libc.Int32FromInt32(0) & uint32(0xff))
  31105 						r3 = ((red*(int32(255)-alpha3)+r3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31106 						g3 = ((green*(int32(255)-alpha3)+g3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31107 						b3 = ((blue*(int32(255)-alpha3)+b3*alpha3)*int32(0x101) + int32(256)) >> int32(16)
  31108 						**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) = MakeARGB32(tls, r3, g3, b3)
  31109 					} else {
  31110 						**(**uint32_t)(__ccgo_up(argb + uintptr(x)*4)) = background
  31111 					}
  31112 				}
  31113 				goto _22
  31114 			_22:
  31115 				;
  31116 				x = x + 1
  31117 			}
  31118 			argb = argb + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  31119 			goto _21
  31120 		_21:
  31121 			;
  31122 			y = y + 1
  31123 		}
  31124 	}
  31125 }
  31126 
  31127 const ARGB_BLACK1 = 4278190080
  31128 
  31129 //------------------------------------------------------------------------------
  31130 
  31131 // Copyright 2012 Google Inc. All Rights Reserved.
  31132 //
  31133 // Use of this source code is governed by a BSD-style license
  31134 // that can be found in the COPYING file in the root of the source
  31135 // tree. An additional intellectual property rights grant can be found
  31136 // in the file PATENTS. All contributing project authors may
  31137 // be found in the AUTHORS file in the root of the source tree.
  31138 // -----------------------------------------------------------------------------
  31139 //
  31140 // Misc. common utility functions
  31141 //
  31142 // Authors: Skal (pascal.massimino@gmail.com)
  31143 //          Urvang (urvang@google.com)
  31144 
  31145 // Copyright 2011 Google Inc. All Rights Reserved.
  31146 //
  31147 // Use of this source code is governed by a BSD-style license
  31148 // that can be found in the COPYING file in the root of the source
  31149 // tree. An additional intellectual property rights grant can be found
  31150 // in the file PATENTS. All contributing project authors may
  31151 // be found in the AUTHORS file in the root of the source tree.
  31152 // -----------------------------------------------------------------------------
  31153 //
  31154 //   WebP encoder: main interface
  31155 //
  31156 // Author: Skal (pascal.massimino@gmail.com)
  31157 
  31158 // Copyright 2012 Google Inc. All Rights Reserved.
  31159 //
  31160 // Use of this source code is governed by a BSD-style license
  31161 // that can be found in the COPYING file in the root of the source
  31162 // tree. An additional intellectual property rights grant can be found
  31163 // in the file PATENTS. All contributing project authors may
  31164 // be found in the AUTHORS file in the root of the source tree.
  31165 // -----------------------------------------------------------------------------
  31166 //
  31167 //  Internal header for constants related to WebP file format.
  31168 //
  31169 // Author: Urvang (urvang@google.com)
  31170 
  31171 // Copyright 2010 Google Inc. All Rights Reserved.
  31172 //
  31173 // Use of this source code is governed by a BSD-style license
  31174 // that can be found in the COPYING file in the root of the source
  31175 // tree. An additional intellectual property rights grant can be found
  31176 // in the file PATENTS. All contributing project authors may
  31177 // be found in the AUTHORS file in the root of the source tree.
  31178 // -----------------------------------------------------------------------------
  31179 //
  31180 //  Common types + memory wrappers
  31181 //
  31182 // Author: Skal (pascal.massimino@gmail.com)
  31183 
  31184 var kSpatialPredictorBias = libc.Int64FromInt64(15) << libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  31185 var kPredLowEffort = int32(11)
  31186 var kMaskAlpha = uint32(0xff000000)
  31187 var kNumPredModes = int32(14)
  31188 
  31189 // C documentation
  31190 //
  31191 //	// Mostly used to reduce code size + readability
  31192 func GetMin(tls *libc.TLS, a int32, b int32) (r int32) {
  31193 	var v1 int32
  31194 	_ = v1
  31195 	if a > b {
  31196 		v1 = b
  31197 	} else {
  31198 		v1 = a
  31199 	}
  31200 	return v1
  31201 }
  31202 
  31203 func GetMax(tls *libc.TLS, a int32, b int32) (r int32) {
  31204 	var v1 int32
  31205 	_ = v1
  31206 	if a < b {
  31207 		v1 = b
  31208 	} else {
  31209 		v1 = a
  31210 	}
  31211 	return v1
  31212 }
  31213 
  31214 //------------------------------------------------------------------------------
  31215 // Methods to calculate Entropy (Shannon).
  31216 
  31217 // C documentation
  31218 //
  31219 //	// Compute a bias for prediction entropy using a global heuristic to favor
  31220 //	// values closer to 0. Hence the final negative sign.
  31221 //	// 'exp_val' has a scaling factor of 1/100.
  31222 func PredictionCostBias(tls *libc.TLS, counts uintptr, weight_0 uint64_t, exp_val uint64_t) (r int64_t) {
  31223 	var bits, exp_decay_factor uint64_t
  31224 	var i, significant_symbols int32
  31225 	var v6 int64
  31226 	var v2, v3, v4 int64_t
  31227 	_, _, _, _, _, _, _, _ = bits, exp_decay_factor, i, significant_symbols, v2, v3, v4, v6
  31228 	significant_symbols = libc.Int32FromInt32(256) >> libc.Int32FromInt32(4)
  31229 	exp_decay_factor = uint64(6) // has a scaling factor of 1/10
  31230 	bits = weight_0 * uint64(**(**uint32_t)(__ccgo_up(counts))) << int32(LOG_2_PRECISION_BITS)
  31231 	exp_val = exp_val << uint64(LOG_2_PRECISION_BITS)
  31232 	i = int32(1)
  31233 	for {
  31234 		if !(i < significant_symbols) {
  31235 			break
  31236 		}
  31237 		v2 = libc.Int64FromUint64(exp_val * uint64(**(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))+**(**uint32_t)(__ccgo_up(counts + uintptr(int32(256)-i)*4))))
  31238 		v3 = int64(100)
  31239 		if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31240 			v6 = (v2 + v3/int64(2)) / v3
  31241 		} else {
  31242 			v6 = (v2 - v3/int64(2)) / v3
  31243 		}
  31244 		v4 = v6
  31245 		goto _5
  31246 	_5:
  31247 		bits = bits + libc.Uint64FromInt64(v4)
  31248 		v2 = libc.Int64FromUint64(exp_decay_factor * exp_val)
  31249 		v3 = int64(10)
  31250 		if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31251 			v6 = (v2 + v3/int64(2)) / v3
  31252 		} else {
  31253 			v6 = (v2 - v3/int64(2)) / v3
  31254 		}
  31255 		v4 = v6
  31256 		goto _10
  31257 	_10:
  31258 		exp_val = libc.Uint64FromInt64(v4)
  31259 		goto _1
  31260 	_1:
  31261 		;
  31262 		i = i + 1
  31263 	}
  31264 	v2 = libc.Int64FromUint64(bits)
  31265 	v3 = int64(10)
  31266 	if libc.BoolInt32(v2 < 0) == libc.BoolInt32(v3 < 0) {
  31267 		v6 = (v2 + v3/int64(2)) / v3
  31268 	} else {
  31269 		v6 = (v2 - v3/int64(2)) / v3
  31270 	}
  31271 	v4 = v6
  31272 	goto _15
  31273 _15:
  31274 	return -v4
  31275 }
  31276 
  31277 func PredictionCostSpatialHistogram(tls *libc.TLS, accumulated uintptr, tile uintptr, mode int32, left_mode int32, above_mode int32) (r int64_t) {
  31278 	var i int32
  31279 	var kExpValue uint64_t
  31280 	var retval int64_t
  31281 	_, _, _ = i, kExpValue, retval
  31282 	retval = 0
  31283 	i = 0
  31284 	for {
  31285 		if !(i < int32(4)) {
  31286 			break
  31287 		}
  31288 		kExpValue = uint64(94)
  31289 		retval = retval + PredictionCostBias(tls, tile+uintptr(i*int32(256))*4, uint64(1), kExpValue)
  31290 		// Compute the new cost if 'tile' is added to 'accumulate' but also add the
  31291 		// cost of the current histogram to guide the spatial predictor selection.
  31292 		// Basically, favor low entropy, locally and globally.
  31293 		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))
  31294 		goto _1
  31295 	_1:
  31296 		;
  31297 		i = i + 1
  31298 	}
  31299 	// Favor keeping the areas locally similar.
  31300 	if mode == left_mode {
  31301 		retval = retval - kSpatialPredictorBias
  31302 	}
  31303 	if mode == above_mode {
  31304 		retval = retval - kSpatialPredictorBias
  31305 	}
  31306 	return retval
  31307 }
  31308 
  31309 func UpdateHisto(tls *libc.TLS, histo_argb uintptr, argb uint32_t) {
  31310 	**(**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
  31311 	**(**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
  31312 	**(**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
  31313 	**(**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
  31314 }
  31315 
  31316 //------------------------------------------------------------------------------
  31317 // Spatial transform functions.
  31318 
  31319 func PredictBatch(tls *libc.TLS, mode int32, x_start int32, y int32, num_pixels int32, current uintptr, upper uintptr, out uintptr) {
  31320 	if x_start == 0 {
  31321 		if y == 0 {
  31322 			// ARGB_BLACK.
  31323 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[libc.Int32FromInt32(0)]})))(tls, current, libc.UintptrFromInt32(0), int32(1), out)
  31324 		} else {
  31325 			// Top one.
  31326 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LPredictorsSub[libc.Int32FromInt32(2)]})))(tls, current, upper, int32(1), out)
  31327 		}
  31328 		x_start = x_start + 1
  31329 		out += 4
  31330 		num_pixels = num_pixels - 1
  31331 	}
  31332 	if y == 0 {
  31333 		// Left one.
  31334 		(*(*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)
  31335 	} else {
  31336 		(*(*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)
  31337 	}
  31338 }
  31339 
  31340 func MaxDiffBetweenPixels(tls *libc.TLS, p1 uint32_t, p2 uint32_t) (r int32) {
  31341 	var diff_a, diff_b, diff_g, diff_r int32
  31342 	_, _, _, _ = diff_a, diff_b, diff_g, diff_r
  31343 	diff_a = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(24))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(24)))
  31344 	diff_r = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(16)&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(16)&libc.Uint32FromInt32(0xff)))
  31345 	diff_g = libc.Xabs(tls, libc.Int32FromUint32(p1>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0xff)))
  31346 	diff_b = libc.Xabs(tls, libc.Int32FromUint32(p1&libc.Uint32FromInt32(0xff))-libc.Int32FromUint32(p2&libc.Uint32FromInt32(0xff)))
  31347 	return GetMax(tls, GetMax(tls, diff_a, diff_r), GetMax(tls, diff_g, diff_b))
  31348 }
  31349 
  31350 func MaxDiffAroundPixel(tls *libc.TLS, current uint32_t, up uint32_t, down uint32_t, left uint32_t, right uint32_t) (r int32) {
  31351 	var diff_down, diff_left, diff_right, diff_up int32
  31352 	_, _, _, _ = diff_down, diff_left, diff_right, diff_up
  31353 	diff_up = MaxDiffBetweenPixels(tls, current, up)
  31354 	diff_down = MaxDiffBetweenPixels(tls, current, down)
  31355 	diff_left = MaxDiffBetweenPixels(tls, current, left)
  31356 	diff_right = MaxDiffBetweenPixels(tls, current, right)
  31357 	return GetMax(tls, GetMax(tls, diff_up, diff_down), GetMax(tls, diff_left, diff_right))
  31358 }
  31359 
  31360 func AddGreenToBlueAndRed(tls *libc.TLS, argb uint32_t) (r uint32_t) {
  31361 	var green, red_blue uint32_t
  31362 	_, _ = green, red_blue
  31363 	green = argb >> libc.Int32FromInt32(8) & uint32(0xff)
  31364 	red_blue = argb & uint32(0x00ff00ff)
  31365 	red_blue = red_blue + (green<<libc.Int32FromInt32(16) | green)
  31366 	red_blue = red_blue & uint32(0x00ff00ff)
  31367 	return argb&uint32(0xff00ff00) | red_blue
  31368 }
  31369 
  31370 func MaxDiffsForRow(tls *libc.TLS, width int32, stride int32, argb uintptr, max_diffs uintptr, used_subtract_green int32) {
  31371 	var current, down, left, right, up uint32_t
  31372 	var x int32
  31373 	_, _, _, _, _, _ = current, down, left, right, up, x
  31374 	if width <= int32(2) {
  31375 		return
  31376 	}
  31377 	current = **(**uint32_t)(__ccgo_up(argb))
  31378 	right = **(**uint32_t)(__ccgo_up(argb + 1*4))
  31379 	if used_subtract_green != 0 {
  31380 		current = AddGreenToBlueAndRed(tls, current)
  31381 		right = AddGreenToBlueAndRed(tls, right)
  31382 	}
  31383 	// max_diffs[0] and max_diffs[width - 1] are never used.
  31384 	x = int32(1)
  31385 	for {
  31386 		if !(x < width-int32(1)) {
  31387 			break
  31388 		}
  31389 		up = **(**uint32_t)(__ccgo_up(argb + uintptr(-stride+x)*4))
  31390 		down = **(**uint32_t)(__ccgo_up(argb + uintptr(stride+x)*4))
  31391 		left = current
  31392 		current = right
  31393 		right = **(**uint32_t)(__ccgo_up(argb + uintptr(x+int32(1))*4))
  31394 		if used_subtract_green != 0 {
  31395 			up = AddGreenToBlueAndRed(tls, up)
  31396 			down = AddGreenToBlueAndRed(tls, down)
  31397 			right = AddGreenToBlueAndRed(tls, right)
  31398 		}
  31399 		**(**uint8_t)(__ccgo_up(max_diffs + uintptr(x))) = libc.Uint8FromInt32(MaxDiffAroundPixel(tls, current, up, down, left, right))
  31400 		goto _1
  31401 	_1:
  31402 		;
  31403 		x = x + 1
  31404 	}
  31405 }
  31406 
  31407 // C documentation
  31408 //
  31409 //	// Quantize the difference between the actual component value and its prediction
  31410 //	// to a multiple of quantization, working modulo 256, taking care not to cross
  31411 //	// a boundary (inclusive upper limit).
  31412 func NearLosslessComponent(tls *libc.TLS, value uint8_t, predict uint8_t, boundary uint8_t, quantization int32) (r uint8_t) {
  31413 	var bias, boundary_residual, lower, residual, upper int32
  31414 	_, _, _, _, _ = bias, boundary_residual, lower, residual, upper
  31415 	residual = (libc.Int32FromUint8(value) - libc.Int32FromUint8(predict)) & int32(0xff)
  31416 	boundary_residual = (libc.Int32FromUint8(boundary) - libc.Int32FromUint8(predict)) & int32(0xff)
  31417 	lower = residual & ^(quantization - libc.Int32FromInt32(1))
  31418 	upper = lower + quantization
  31419 	// Resolve ties towards a value closer to the prediction (i.e. towards lower
  31420 	// if value comes after prediction and towards upper otherwise).
  31421 	bias = libc.BoolInt32((libc.Int32FromUint8(boundary)-libc.Int32FromUint8(value))&int32(0xff) < boundary_residual)
  31422 	if residual-lower < upper-residual+bias {
  31423 		// lower is closer to residual than upper.
  31424 		if residual > boundary_residual && lower <= boundary_residual {
  31425 			// Halve quantization step to avoid crossing boundary. This midpoint is
  31426 			// on the same side of boundary as residual because midpoint >= residual
  31427 			// (since lower is closer than upper) and residual is above the boundary.
  31428 			return libc.Uint8FromInt32(lower + quantization>>int32(1))
  31429 		}
  31430 		return libc.Uint8FromInt32(lower)
  31431 	} else {
  31432 		// upper is closer to residual than lower.
  31433 		if residual <= boundary_residual && upper > boundary_residual {
  31434 			// Halve quantization step to avoid crossing boundary. This midpoint is
  31435 			// on the same side of boundary as residual because midpoint <= residual
  31436 			// (since upper is closer than lower) and residual is below the boundary.
  31437 			return libc.Uint8FromInt32(lower + quantization>>int32(1))
  31438 		}
  31439 		return libc.Uint8FromInt32(upper & int32(0xff))
  31440 	}
  31441 	return r
  31442 }
  31443 
  31444 func NearLosslessDiff(tls *libc.TLS, a uint8_t, b uint8_t) (r uint8_t) {
  31445 	return libc.Uint8FromInt32((libc.Int32FromUint8(a) - libc.Int32FromUint8(b)) & libc.Int32FromInt32(0xff))
  31446 }
  31447 
  31448 // C documentation
  31449 //
  31450 //	// Quantize every component of the difference between the actual pixel value and
  31451 //	// its prediction to a multiple of a quantization (a power of 2, not larger than
  31452 //	// max_quantization which is a power of 2, smaller than max_diff). Take care if
  31453 //	// value and predict have undergone subtract green, which means that red and
  31454 //	// blue are represented as offsets from green.
  31455 func NearLossless1(tls *libc.TLS, value uint32_t, predict uint32_t, max_quantization int32, max_diff int32, used_subtract_green int32) (r1 uint32_t) {
  31456 	var a1, b1, g, green_diff, new_green, r uint8_t
  31457 	var alpha_and_green, red_and_blue, v1, v2, v3 uint32_t
  31458 	var quantization int32
  31459 	_, _, _, _, _, _, _, _, _, _, _, _ = a1, alpha_and_green, b1, g, green_diff, new_green, quantization, r, red_and_blue, v1, v2, v3
  31460 	new_green = uint8(0)
  31461 	green_diff = uint8(0)
  31462 	if max_diff <= int32(2) {
  31463 		v1 = value
  31464 		v2 = predict
  31465 		alpha_and_green = uint32(0x00ff00ff) + v1&uint32(0xff00ff00) - v2&uint32(0xff00ff00)
  31466 		red_and_blue = uint32(0xff00ff00) + v1&uint32(0x00ff00ff) - v2&uint32(0x00ff00ff)
  31467 		v3 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  31468 		goto _4
  31469 	_4:
  31470 		return v3
  31471 	}
  31472 	quantization = max_quantization
  31473 	for quantization >= max_diff {
  31474 		quantization = quantization >> int32(1)
  31475 	}
  31476 	if value>>libc.Int32FromInt32(24) == uint32(0) || value>>libc.Int32FromInt32(24) == uint32(0xff) {
  31477 		// Preserve transparency of fully transparent or fully opaque pixels.
  31478 		a1 = NearLosslessDiff(tls, uint8(value>>libc.Int32FromInt32(24)&uint32(0xff)), uint8(predict>>libc.Int32FromInt32(24)&uint32(0xff)))
  31479 	} else {
  31480 		a1 = NearLosslessComponent(tls, uint8(value>>int32(24)), uint8(predict>>int32(24)), uint8(0xff), quantization)
  31481 	}
  31482 	g = NearLosslessComponent(tls, uint8(value>>libc.Int32FromInt32(8)&uint32(0xff)), uint8(predict>>libc.Int32FromInt32(8)&uint32(0xff)), uint8(0xff), quantization)
  31483 	if used_subtract_green != 0 {
  31484 		// The green offset will be added to red and blue components during decoding
  31485 		// to obtain the actual red and blue values.
  31486 		new_green = uint8((predict>>libc.Int32FromInt32(8) + uint32(g)) & uint32(0xff))
  31487 		// The amount by which green has been adjusted during quantization. It is
  31488 		// subtracted from red and blue for compensation, to avoid accumulating two
  31489 		// quantization errors in them.
  31490 		green_diff = NearLosslessDiff(tls, new_green, uint8(value>>libc.Int32FromInt32(8)&uint32(0xff)))
  31491 	}
  31492 	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)
  31493 	b1 = NearLosslessComponent(tls, NearLosslessDiff(tls, uint8(value&uint32(0xff)), green_diff), uint8(predict&uint32(0xff)), libc.Uint8FromInt32(int32(0xff)-libc.Int32FromUint8(new_green)), quantization)
  31494 	return uint32(a1)<<libc.Int32FromInt32(24) | uint32(r)<<libc.Int32FromInt32(16) | uint32(g)<<libc.Int32FromInt32(8) | uint32(b1)
  31495 }
  31496 
  31497 // C documentation
  31498 //
  31499 //	// Stores the difference between the pixel and its prediction in "out".
  31500 //	// In case of a lossy encoding, updates the source image to avoid propagating
  31501 //	// the deviation further to pixels which depend on the current pixel for their
  31502 //	// predictions.
  31503 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) {
  31504 	var alpha_and_green, alpha_and_green1, predict, red_and_blue, red_and_blue1, residual, v3, v4, v5 uint32_t
  31505 	var pred_func VP8LPredictorFunc
  31506 	var x int32
  31507 	var v2 uint32
  31508 	_, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, alpha_and_green1, pred_func, predict, red_and_blue, red_and_blue1, residual, x, v2, v3, v4, v5
  31509 	if exact != 0 {
  31510 		PredictBatch(tls, mode, x_start, y, x_end-x_start, current_row, upper_row, out)
  31511 	} else {
  31512 		pred_func = VP8LPredictors[mode]
  31513 		x = x_start
  31514 		for {
  31515 			if !(x < x_end) {
  31516 				break
  31517 			}
  31518 			if y == 0 {
  31519 				if x == 0 {
  31520 					v2 = uint32(ARGB_BLACK1)
  31521 				} else {
  31522 					v2 = **(**uint32_t)(__ccgo_up(current_row + uintptr(x-int32(1))*4))
  31523 				}
  31524 				predict = v2 // Left.
  31525 			} else {
  31526 				if x == 0 {
  31527 					predict = **(**uint32_t)(__ccgo_up(upper_row + uintptr(x)*4)) // Top.
  31528 				} else {
  31529 					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)
  31530 				}
  31531 			}
  31532 			if max_quantization == int32(1) || mode == 0 || y == 0 || y == height-int32(1) || x == 0 || x == width-int32(1) {
  31533 				v3 = **(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4))
  31534 				v4 = predict
  31535 				alpha_and_green1 = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v4&uint32(0xff00ff00)
  31536 				red_and_blue1 = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v4&uint32(0x00ff00ff)
  31537 				v5 = alpha_and_green1&uint32(0xff00ff00) | red_and_blue1&uint32(0x00ff00ff)
  31538 				goto _6
  31539 			_6:
  31540 				residual = v5
  31541 			} else {
  31542 				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)
  31543 				// Update the source image.
  31544 				v3 = predict
  31545 				v4 = residual
  31546 				alpha_and_green = v3&uint32(0xff00ff00) + v4&uint32(0xff00ff00)
  31547 				red_and_blue = v3&uint32(0x00ff00ff) + v4&uint32(0x00ff00ff)
  31548 				v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  31549 				goto _10
  31550 			_10:
  31551 				**(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4)) = v5
  31552 				// x is never 0 here so we do not need to update upper_row like below.
  31553 			}
  31554 			if **(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4))&kMaskAlpha == uint32(0) {
  31555 				// If alpha is 0, cleanup RGB. We can choose the RGB values of the
  31556 				// residual for best compression. The prediction of alpha itself can be
  31557 				// non-zero and must be kept though. We choose RGB of the residual to be
  31558 				// 0.
  31559 				residual = residual & kMaskAlpha
  31560 				// Update the source image.
  31561 				**(**uint32_t)(__ccgo_up(current_row + uintptr(x)*4)) = predict & ^kMaskAlpha
  31562 				// The prediction for the rightmost pixel in a row uses the leftmost
  31563 				// pixel
  31564 				// in that row as its top-right context pixel. Hence if we change the
  31565 				// leftmost pixel of current_row, the corresponding change must be
  31566 				// applied
  31567 				// to upper_row as well where top-right context is being read from.
  31568 				if x == 0 && y != 0 {
  31569 					**(**uint32_t)(__ccgo_up(upper_row + uintptr(width)*4)) = **(**uint32_t)(__ccgo_up(current_row))
  31570 				}
  31571 			}
  31572 			**(**uint32_t)(__ccgo_up(out + uintptr(x-x_start)*4)) = residual
  31573 			goto _1
  31574 		_1:
  31575 			;
  31576 			x = x + 1
  31577 		}
  31578 	}
  31579 }
  31580 
  31581 // C documentation
  31582 //
  31583 //	// Accessors to residual histograms.
  31584 func GetHistoArgb(tls *libc.TLS, all_histos uintptr, subsampling_index int32, mode int32) (r uintptr) {
  31585 	return all_histos + uintptr((subsampling_index*kNumPredModes+mode)*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31586 }
  31587 
  31588 func GetHistoArgbConst(tls *libc.TLS, all_histos uintptr, subsampling_index int32, mode int32) (r uintptr) {
  31589 	return all_histos + uintptr(subsampling_index*kNumPredModes*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256))+mode*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31590 }
  31591 
  31592 // C documentation
  31593 //
  31594 //	// Accessors to accumulated residual histogram.
  31595 func GetAccumulatedHisto(tls *libc.TLS, all_accumulated uintptr, subsampling_index int32) (r uintptr) {
  31596 	return all_accumulated + uintptr(subsampling_index*(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))*4
  31597 }
  31598 
  31599 // C documentation
  31600 //
  31601 //	// Find and store the best predictor for a tile at subsampling
  31602 //	// 'subsampling_index'.
  31603 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) {
  31604 	var above_mode, left_mode, mode int32
  31605 	var accumulated_argb, best_histo, histo_argb, modes, pred_histos uintptr
  31606 	var best_diff, cur_diff int64_t
  31607 	var best_mode uint32_t
  31608 	var v1, v2 uint32
  31609 	_, _, _, _, _, _, _, _, _, _, _, _, _ = above_mode, accumulated_argb, best_diff, best_histo, best_mode, cur_diff, histo_argb, left_mode, mode, modes, pred_histos, v1, v2
  31610 	accumulated_argb = GetAccumulatedHisto(tls, all_accumulated_argb, subsampling_index)
  31611 	modes = **(**uintptr)(__ccgo_up(all_modes + uintptr(subsampling_index)*8))
  31612 	pred_histos = all_pred_histos + uintptr(subsampling_index*kNumPredModes)*4
  31613 	if tile_x > 0 {
  31614 		v1 = **(**uint32_t)(__ccgo_up(modes + uintptr(tile_y*tiles_per_row+tile_x-int32(1))*4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  31615 	} else {
  31616 		v1 = uint32(0xff)
  31617 	}
  31618 	// Prediction modes of the left and above neighbor tiles.
  31619 	left_mode = libc.Int32FromUint32(v1)
  31620 	if tile_y > 0 {
  31621 		v2 = **(**uint32_t)(__ccgo_up(modes + uintptr((tile_y-int32(1))*tiles_per_row+tile_x)*4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  31622 	} else {
  31623 		v2 = uint32(0xff)
  31624 	}
  31625 	above_mode = libc.Int32FromUint32(v2)
  31626 	best_diff = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  31627 	best_mode = uint32(0)
  31628 	best_histo = GetHistoArgbConst(tls, all_argb, 0, libc.Int32FromUint32(best_mode))
  31629 	mode = 0
  31630 	for {
  31631 		if !(mode < kNumPredModes) {
  31632 			break
  31633 		}
  31634 		histo_argb = GetHistoArgbConst(tls, all_argb, subsampling_index, mode)
  31635 		cur_diff = PredictionCostSpatialHistogram(tls, accumulated_argb, histo_argb, mode, left_mode, above_mode)
  31636 		if cur_diff < best_diff {
  31637 			best_histo = histo_argb
  31638 			best_diff = cur_diff
  31639 			best_mode = libc.Uint32FromInt32(mode)
  31640 		}
  31641 		goto _3
  31642 	_3:
  31643 		;
  31644 		mode = mode + 1
  31645 	}
  31646 	// Update the accumulated histogram.
  31647 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LAddVectorEq})))(tls, best_histo, accumulated_argb, libc.Int32FromInt32(4)*libc.Int32FromInt32(256))
  31648 	**(**uint32_t)(__ccgo_up(modes + uintptr(tile_y*tiles_per_row+tile_x)*4)) = uint32(ARGB_BLACK1) | best_mode<<libc.Int32FromInt32(8)
  31649 	**(**uint32_t)(__ccgo_up(pred_histos + uintptr(best_mode)*4)) = **(**uint32_t)(__ccgo_up(pred_histos + uintptr(best_mode)*4)) + 1
  31650 }
  31651 
  31652 // C documentation
  31653 //
  31654 //	// Computes the residuals for the different predictors.
  31655 //	// If max_quantization > 1, assumes that near lossless processing will be
  31656 //	// applied, quantizing residuals to multiples of quantization levels up to
  31657 //	// max_quantization (the actual quantization level depends on smoothness near
  31658 //	// the given pixel).
  31659 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) {
  31660 	bp := tls.Alloc(2048)
  31661 	defer tls.Free(2048)
  31662 	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
  31663 	var current_row, histo_argb, max_diffs, super_histo, tmp, upper_row uintptr
  31664 	var subsampling_index uint32_t
  31665 	var _ /* residuals at bp+0 */ [512]uint32_t
  31666 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  31667 	start_x = tile_x << min_bits
  31668 	start_y = tile_y << min_bits
  31669 	tile_size = int32(1) << min_bits
  31670 	max_y = GetMin(tls, tile_size, height-start_y)
  31671 	max_x = GetMin(tls, tile_size, width-start_x)
  31672 	// Whether there exist columns just outside the tile.
  31673 	have_left = libc.BoolInt32(start_x > libc.Int32FromInt32(0))
  31674 	// Position and size of the strip covering the tile and adjacent columns if
  31675 	// they exist.
  31676 	context_start_x = start_x - have_left
  31677 	context_width = max_x + have_left + libc.BoolInt32(max_x < width-start_x)
  31678 	// The width of upper_row and current_row is one pixel larger than image width
  31679 	// to allow the top right pixel to point to the leftmost pixel of the next row
  31680 	// when at the right edge.
  31681 	upper_row = argb_scratch
  31682 	current_row = upper_row + uintptr(width)*4 + uintptr(1)*4
  31683 	max_diffs = current_row + uintptr(width)*4 + libc.UintptrFromInt32(1)*4
  31684 	mode = 0
  31685 	for {
  31686 		if !(mode < kNumPredModes) {
  31687 			break
  31688 		}
  31689 		histo_argb = GetHistoArgb(tls, all_argb, 0, mode)
  31690 		if start_y > 0 {
  31691 			// Read the row above the tile which will become the first upper_row.
  31692 			// Include a pixel to the left if it exists; include a pixel to the right
  31693 			// in all cases (wrapping to the leftmost pixel of the next row if it does
  31694 			// not exist).
  31695 			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))
  31696 		}
  31697 		relative_y = 0
  31698 		for {
  31699 			if !(relative_y < max_y) {
  31700 				break
  31701 			}
  31702 			y = start_y + relative_y
  31703 			tmp = upper_row
  31704 			upper_row = current_row
  31705 			current_row = tmp
  31706 			// Read current_row. Include a pixel to the left if it exists; include a
  31707 			// pixel to the right in all cases except at the bottom right corner of
  31708 			// the image (wrapping to the leftmost pixel of the next row if it does
  31709 			// not exist in the current row).
  31710 			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))
  31711 			if max_quantization > int32(1) && y >= int32(1) && y+int32(1) < height {
  31712 				MaxDiffsForRow(tls, context_width, width, argb+uintptr(y*width)*4+uintptr(context_start_x)*4, max_diffs+uintptr(context_start_x), used_subtract_green)
  31713 			}
  31714 			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)
  31715 			relative_x = 0
  31716 			for {
  31717 				if !(relative_x < max_x) {
  31718 					break
  31719 				}
  31720 				UpdateHisto(tls, histo_argb, (**(**[512]uint32_t)(__ccgo_up(bp)))[relative_x])
  31721 				goto _3
  31722 			_3:
  31723 				;
  31724 				relative_x = relative_x + 1
  31725 			}
  31726 			if update_up_to_index > uint32(0) {
  31727 				subsampling_index = uint32(1)
  31728 				for {
  31729 					if !(subsampling_index <= update_up_to_index) {
  31730 						break
  31731 					}
  31732 					super_histo = GetHistoArgb(tls, all_argb, libc.Int32FromUint32(subsampling_index), mode)
  31733 					relative_x = 0
  31734 					for {
  31735 						if !(relative_x < max_x) {
  31736 							break
  31737 						}
  31738 						UpdateHisto(tls, super_histo, (**(**[512]uint32_t)(__ccgo_up(bp)))[relative_x])
  31739 						goto _5
  31740 					_5:
  31741 						;
  31742 						relative_x = relative_x + 1
  31743 					}
  31744 					goto _4
  31745 				_4:
  31746 					;
  31747 					subsampling_index = subsampling_index + 1
  31748 				}
  31749 			}
  31750 			goto _2
  31751 		_2:
  31752 			;
  31753 			relative_y = relative_y + 1
  31754 		}
  31755 		goto _1
  31756 	_1:
  31757 		;
  31758 		mode = mode + 1
  31759 	}
  31760 }
  31761 
  31762 // C documentation
  31763 //
  31764 //	// Converts pixels of the image to residuals with respect to predictions.
  31765 //	// If max_quantization > 1, applies near lossless processing, quantizing
  31766 //	// residuals to multiples of quantization levels up to max_quantization
  31767 //	// (the actual quantization level depends on smoothness near the given pixel).
  31768 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) {
  31769 	var current_max_diffs, current_row, lower_max_diffs, tmp32, tmp8, upper_row uintptr
  31770 	var mode, tiles_per_row, x, x_end, y int32
  31771 	var v1, v2 uint32_t
  31772 	_, _, _, _, _, _, _, _, _, _, _, _, _ = current_max_diffs, current_row, lower_max_diffs, mode, tiles_per_row, tmp32, tmp8, upper_row, x, x_end, y, v1, v2
  31773 	v1 = libc.Uint32FromInt32(bits)
  31774 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31775 	goto _3
  31776 _3:
  31777 	tiles_per_row = libc.Int32FromUint32(v2)
  31778 	// The width of upper_row and current_row is one pixel larger than image width
  31779 	// to allow the top right pixel to point to the leftmost pixel of the next row
  31780 	// when at the right edge.
  31781 	upper_row = argb_scratch
  31782 	current_row = upper_row + uintptr(width)*4 + uintptr(1)*4
  31783 	current_max_diffs = current_row + uintptr(width)*4 + libc.UintptrFromInt32(1)*4
  31784 	lower_max_diffs = current_max_diffs + uintptr(width)
  31785 	y = 0
  31786 	for {
  31787 		if !(y < height) {
  31788 			break
  31789 		}
  31790 		tmp32 = upper_row
  31791 		upper_row = current_row
  31792 		current_row = tmp32
  31793 		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))
  31794 		if low_effort != 0 {
  31795 			PredictBatch(tls, kPredLowEffort, 0, y, width, current_row, upper_row, argb+uintptr(y*width)*4)
  31796 		} else {
  31797 			if max_quantization > int32(1) {
  31798 				// Compute max_diffs for the lower row now, because that needs the
  31799 				// contents of argb for the current row, which we will overwrite with
  31800 				// residuals before proceeding with the next row.
  31801 				tmp8 = current_max_diffs
  31802 				current_max_diffs = lower_max_diffs
  31803 				lower_max_diffs = tmp8
  31804 				if y+int32(2) < height {
  31805 					MaxDiffsForRow(tls, width, width, argb+uintptr((y+int32(1))*width)*4, lower_max_diffs, used_subtract_green)
  31806 				}
  31807 			}
  31808 			x = 0
  31809 			for {
  31810 				if !(x < width) {
  31811 					break
  31812 				}
  31813 				mode = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(modes + uintptr(y>>bits*tiles_per_row+x>>bits)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  31814 				x_end = x + int32(1)<<bits
  31815 				if x_end > width {
  31816 					x_end = width
  31817 				}
  31818 				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)
  31819 				x = x_end
  31820 				goto _5
  31821 			_5:
  31822 			}
  31823 		}
  31824 		goto _4
  31825 	_4:
  31826 		;
  31827 		y = y + 1
  31828 	}
  31829 }
  31830 
  31831 // C documentation
  31832 //
  31833 //	// Checks whether 'image' can be subsampled by finding the biggest power of 2
  31834 //	// squares (defined by 'best_bits') of uniform value it is made out of.
  31835 func VP8LOptimizeSampling(tls *libc.TLS, image uintptr, full_width int32, full_height int32, bits int32, max_bits int32, best_bits_out uintptr) {
  31836 	var best_bits, height, i, is_good, is_good1, new_square_size, old_width, square_size, width, x, y int32
  31837 	var v1, v2, v4, v5 uint32_t
  31838 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_bits, height, i, is_good, is_good1, new_square_size, old_width, square_size, width, x, y, v1, v2, v4, v5
  31839 	v1 = libc.Uint32FromInt32(bits)
  31840 	v2 = (libc.Uint32FromInt32(full_width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31841 	goto _3
  31842 _3:
  31843 	width = libc.Int32FromUint32(v2)
  31844 	v4 = libc.Uint32FromInt32(bits)
  31845 	v5 = (libc.Uint32FromInt32(full_height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  31846 	goto _6
  31847 _6:
  31848 	height = libc.Int32FromUint32(v5)
  31849 	best_bits = bits
  31850 	**(**int32)(__ccgo_up(best_bits_out)) = bits
  31851 	// Check rows first.
  31852 	for best_bits < max_bits {
  31853 		new_square_size = int32(1) << (best_bits + int32(1) - bits)
  31854 		is_good = int32(1)
  31855 		square_size = int32(1) << (best_bits - bits)
  31856 		y = 0
  31857 		for {
  31858 			if !(y+square_size < height) {
  31859 				break
  31860 			}
  31861 			// Check the first lines of consecutive line groups.
  31862 			if libc.Xmemcmp(tls, image+uintptr(y*width)*4, image+uintptr((y+square_size)*width)*4, libc.Uint64FromInt32(width)*uint64(4)) != 0 {
  31863 				is_good = 0
  31864 				break
  31865 			}
  31866 			goto _7
  31867 		_7:
  31868 			;
  31869 			y = y + new_square_size
  31870 		}
  31871 		if is_good != 0 {
  31872 			best_bits = best_bits + 1
  31873 		} else {
  31874 			break
  31875 		}
  31876 	}
  31877 	if best_bits == bits {
  31878 		return
  31879 	}
  31880 	// Check columns.
  31881 	for best_bits > bits {
  31882 		is_good1 = int32(1)
  31883 		square_size = int32(1) << (best_bits - bits)
  31884 		y = 0
  31885 		for {
  31886 			if !(is_good1 != 0 && y < height) {
  31887 				break
  31888 			}
  31889 			x = 0
  31890 			for {
  31891 				if !(is_good1 != 0 && x < width) {
  31892 					break
  31893 				}
  31894 				i = x + int32(1)
  31895 				for {
  31896 					if !(i < GetMin(tls, x+square_size, width)) {
  31897 						break
  31898 					}
  31899 					if **(**uint32_t)(__ccgo_up(image + uintptr(y*width+i)*4)) != **(**uint32_t)(__ccgo_up(image + uintptr(y*width+x)*4)) {
  31900 						is_good1 = 0
  31901 						break
  31902 					}
  31903 					goto _10
  31904 				_10:
  31905 					;
  31906 					i = i + 1
  31907 				}
  31908 				goto _9
  31909 			_9:
  31910 				;
  31911 				x = x + square_size
  31912 			}
  31913 			goto _8
  31914 		_8:
  31915 			;
  31916 			y = y + 1
  31917 		}
  31918 		if is_good1 != 0 {
  31919 			break
  31920 		}
  31921 		best_bits = best_bits - 1
  31922 	}
  31923 	if best_bits == bits {
  31924 		return
  31925 	}
  31926 	// Subsample the image.
  31927 	old_width = width
  31928 	square_size = int32(1) << (best_bits - bits)
  31929 	v1 = libc.Uint32FromInt32(best_bits)
  31930 	v2 = (libc.Uint32FromInt32(full_width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31931 	goto _13
  31932 _13:
  31933 	width = libc.Int32FromUint32(v2)
  31934 	v1 = libc.Uint32FromInt32(best_bits)
  31935 	v2 = (libc.Uint32FromInt32(full_height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31936 	goto _16
  31937 _16:
  31938 	height = libc.Int32FromUint32(v2)
  31939 	y = 0
  31940 	for {
  31941 		if !(y < height) {
  31942 			break
  31943 		}
  31944 		x = 0
  31945 		for {
  31946 			if !(x < width) {
  31947 				break
  31948 			}
  31949 			**(**uint32_t)(__ccgo_up(image + uintptr(y*width+x)*4)) = **(**uint32_t)(__ccgo_up(image + uintptr(square_size*(y*old_width+x))*4))
  31950 			goto _18
  31951 		_18:
  31952 			;
  31953 			x = x + 1
  31954 		}
  31955 		goto _17
  31956 	_17:
  31957 		;
  31958 		y = y + 1
  31959 	}
  31960 	**(**int32)(__ccgo_up(best_bits_out)) = best_bits
  31961 }
  31962 
  31963 // C documentation
  31964 //
  31965 //	// Computes the best predictor image.
  31966 //	// Finds the best predictors per tile. Once done, finds the best predictor image
  31967 //	// sampling.
  31968 //	// best_bits is set to 0 in case of error.
  31969 //	// The following requires some glossary:
  31970 //	// - a tile is a square of side 2^min_bits pixels.
  31971 //	// - a super-tile of a tile is a square of side 2^bits pixels with bits in
  31972 //	// [min_bits+1, max_bits].
  31973 //	// - the max-tile of a tile is the square of 2^max_bits pixels containing it.
  31974 //	//   If this max-tile crosses the border of an image, it is cropped.
  31975 //	// - tile, super-tiles and max_tile are aligned on powers of 2 in the original
  31976 //	//   image.
  31977 //	// - coordinates for tile, super-tile, max-tile are respectively named
  31978 //	//   tile_x, super_tile_x, max_tile_x at their bit scale.
  31979 //	// - in the max-tile, a tile has local coordinates (local_tile_x, local_tile_y).
  31980 //	// The tiles are processed in the following zigzag order to complete the
  31981 //	// super-tiles as soon as possible:
  31982 //	//   1  2|  5  6
  31983 //	//   3  4|  7  8
  31984 //	// --------------
  31985 //	//   9 10| 13 14
  31986 //	//  11 12| 15 16
  31987 //	// When computing the residuals for a tile, the histogram of the above
  31988 //	// super-tile is updated. If this super-tile is finished, its histogram is used
  31989 //	// to update the histogram of the next super-tile and so on up to the max-tile.
  31990 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) {
  31991 	var accumulated, all_accumulated_argb, all_argb, all_pred_histos, raw_data uintptr
  31992 	var best_cost, cost int64_t
  31993 	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
  31994 	var max_tile_size, num_accumulated_rgb, num_argb, num_predictors, percent_start, plane int32
  31995 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  31996 	v1 = libc.Uint32FromInt32(min_bits)
  31997 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  31998 	goto _3
  31999 _3:
  32000 	tiles_per_row = v2
  32001 	v4 = libc.Uint32FromInt32(min_bits)
  32002 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  32003 	goto _6
  32004 _6:
  32005 	tiles_per_col = v5
  32006 	max_subsampling_index = libc.Uint32FromInt32(max_bits - min_bits)
  32007 	// Compute the needed memory size for residual histograms, accumulated
  32008 	// residual histograms and predictor histograms.
  32009 	num_argb = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(kNumPredModes) * libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))
  32010 	num_accumulated_rgb = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(libc.Int32FromInt32(4)*libc.Int32FromInt32(256)))
  32011 	num_predictors = libc.Int32FromUint32((max_subsampling_index + uint32(1)) * libc.Uint32FromInt32(kNumPredModes))
  32012 	raw_data = WebPSafeCalloc(tls, libc.Uint64FromInt32(num_argb+num_accumulated_rgb+num_predictors), uint64(4))
  32013 	all_argb = raw_data
  32014 	all_accumulated_argb = all_argb + uintptr(num_argb)*4
  32015 	all_pred_histos = all_accumulated_argb + uintptr(num_accumulated_rgb)*4
  32016 	max_tile_size = int32(1) << max_subsampling_index // in tile size
  32017 	percent_start = **(**int32)(__ccgo_up(percent))
  32018 	// When using the residuals of a tile for its super-tiles, you can either:
  32019 	// - use each residual to update the histogram of the super-tile, with a cost
  32020 	//   of 4 * (1<<n)^2 increment operations (4 for the number of channels, and
  32021 	//   (1<<n)^2 for the number of pixels in the tile)
  32022 	// - use the histogram of the tile to update the histogram of the super-tile,
  32023 	//   with a cost of HISTO_SIZE (1024)
  32024 	// The first method is therefore faster until n==4. 'update_up_to_index'
  32025 	// defines the maximum subsampling_index for which the residuals should be
  32026 	// individually added to the super-tile histogram.
  32027 	update_up_to_index = libc.Uint32FromInt32(GetMax(tls, GetMin(tls, int32(4), max_bits), min_bits) - min_bits)
  32028 	// Coordinates in the max-tile in tile units.
  32029 	local_tile_x = uint32(0)
  32030 	local_tile_y = uint32(0)
  32031 	max_tile_x = uint32(0)
  32032 	max_tile_y = uint32(0)
  32033 	tile_x = uint32(0)
  32034 	tile_y = uint32(0)
  32035 	**(**int32)(__ccgo_up(best_bits)) = 0
  32036 	**(**uintptr)(__ccgo_up(best_mode)) = libc.UintptrFromInt32(0)
  32037 	if raw_data == libc.UintptrFromInt32(0) {
  32038 		return
  32039 	}
  32040 	for tile_y < tiles_per_col {
  32041 		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)
  32042 		// Update all the super-tiles that are complete.
  32043 		subsampling_index = uint32(0)
  32044 		for int32(1) != 0 {
  32045 			super_tile_x = tile_x >> subsampling_index
  32046 			super_tile_y = tile_y >> subsampling_index
  32047 			v1 = libc.Uint32FromInt32(min_bits) + subsampling_index
  32048 			v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  32049 			goto _9
  32050 		_9:
  32051 			super_tiles_per_row = v2
  32052 			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)
  32053 			if subsampling_index == max_subsampling_index {
  32054 				break
  32055 			}
  32056 			// Update the following super-tile histogram if it has not been updated
  32057 			// yet.
  32058 			subsampling_index = subsampling_index + 1
  32059 			if subsampling_index > update_up_to_index && subsampling_index <= max_subsampling_index {
  32060 				(*(*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)
  32061 			}
  32062 			// Check whether the super-tile is not complete (if the smallest tile
  32063 			// is not at the end of a line/column or at the beginning of a super-tile
  32064 			// of size (1 << subsampling_index)).
  32065 			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))) {
  32066 				subsampling_index = subsampling_index - 1
  32067 				// subsampling_index now is the index of the last finished super-tile.
  32068 				break
  32069 			}
  32070 		}
  32071 		// Reset all the histograms belonging to finished tiles.
  32072 		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))
  32073 		if subsampling_index == max_subsampling_index {
  32074 			// If a new max-tile is started.
  32075 			if tile_x == tiles_per_row-uint32(1) {
  32076 				max_tile_x = uint32(0)
  32077 				max_tile_y = max_tile_y + 1
  32078 			} else {
  32079 				max_tile_x = max_tile_x + 1
  32080 			}
  32081 			local_tile_x = uint32(0)
  32082 			local_tile_y = uint32(0)
  32083 		} else {
  32084 			// Proceed with the Z traversal.
  32085 			coord_x = local_tile_x >> subsampling_index
  32086 			coord_y = local_tile_y >> subsampling_index
  32087 			if tile_x == tiles_per_row-uint32(1) && coord_x%uint32(2) == uint32(0) {
  32088 				coord_y = coord_y + 1
  32089 			} else {
  32090 				if coord_x%uint32(2) == uint32(0) {
  32091 					coord_x = coord_x + 1
  32092 				} else {
  32093 					// Z traversal.
  32094 					coord_y = coord_y + 1
  32095 					coord_x = coord_x - 1
  32096 				}
  32097 			}
  32098 			local_tile_x = coord_x << subsampling_index
  32099 			local_tile_y = coord_y << subsampling_index
  32100 		}
  32101 		tile_x = max_tile_x*libc.Uint32FromInt32(max_tile_size) + local_tile_x
  32102 		tile_y = max_tile_y*libc.Uint32FromInt32(max_tile_size) + local_tile_y
  32103 		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) {
  32104 			WebPSafeFree(tls, raw_data)
  32105 			return
  32106 		}
  32107 	}
  32108 	// Figure out the best sampling.
  32109 	best_cost = libc.Int64FromUint64(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(63) - libc.Uint64FromInt32(1))
  32110 	subsampling_index = uint32(0)
  32111 	for {
  32112 		if !(subsampling_index <= max_subsampling_index) {
  32113 			break
  32114 		}
  32115 		accumulated = GetAccumulatedHisto(tls, all_accumulated_argb, libc.Int32FromUint32(subsampling_index))
  32116 		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))
  32117 		plane = 0
  32118 		for {
  32119 			if !(plane < int32(4)) {
  32120 				break
  32121 			}
  32122 			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)))
  32123 			goto _11
  32124 		_11:
  32125 			;
  32126 			plane = plane + 1
  32127 		}
  32128 		if cost < best_cost {
  32129 			best_cost = cost
  32130 			**(**int32)(__ccgo_up(best_bits)) = libc.Int32FromUint32(libc.Uint32FromInt32(min_bits) + subsampling_index)
  32131 			**(**uintptr)(__ccgo_up(best_mode)) = **(**uintptr)(__ccgo_up(all_modes + uintptr(subsampling_index)*8))
  32132 		}
  32133 		goto _10
  32134 	_10:
  32135 		;
  32136 		subsampling_index = subsampling_index + 1
  32137 	}
  32138 	WebPSafeFree(tls, raw_data)
  32139 	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)
  32140 }
  32141 
  32142 // C documentation
  32143 //
  32144 //	// Finds the best predictor for each tile, and converts the image to residuals
  32145 //	// with respect to predictions. If near_lossless_quality < 100, applies
  32146 //	// near lossless processing, shaving off more bits of residuals for lower
  32147 //	// qualities.
  32148 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) {
  32149 	bp := tls.Alloc(96)
  32150 	defer tls.Free(96)
  32151 	var bits, i, max_quantization, percent_start, tiles_per_col, tiles_per_col1, tiles_per_row, tiles_per_row1, v1 int32
  32152 	var modes_raw uintptr
  32153 	var num_pixels [10]uint32_t
  32154 	var sum_num_pixels, v3, v4, v6, v7 uint32_t
  32155 	var _ /* best_mode at bp+0 */ uintptr
  32156 	var _ /* modes at bp+8 */ [10]uintptr
  32157 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  32158 	percent_start = **(**int32)(__ccgo_up(percent))
  32159 	v1 = int32(5) - near_lossless_quality1/int32(20)
  32160 	goto _2
  32161 _2:
  32162 	max_quantization = int32(1) << v1
  32163 	if low_effort != 0 {
  32164 		v3 = libc.Uint32FromInt32(max_bits)
  32165 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32166 		goto _5
  32167 	_5:
  32168 		tiles_per_row = libc.Int32FromUint32(v4)
  32169 		v6 = libc.Uint32FromInt32(max_bits)
  32170 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32171 		goto _8
  32172 	_8:
  32173 		tiles_per_col = libc.Int32FromUint32(v7)
  32174 		i = 0
  32175 		for {
  32176 			if !(i < tiles_per_row*tiles_per_col) {
  32177 				break
  32178 			}
  32179 			**(**uint32_t)(__ccgo_up(image + uintptr(i)*4)) = uint32(ARGB_BLACK1) | libc.Uint32FromInt32(kPredLowEffort<<libc.Int32FromInt32(8))
  32180 			goto _9
  32181 		_9:
  32182 			;
  32183 			i = i + 1
  32184 		}
  32185 		**(**int32)(__ccgo_up(best_bits)) = max_bits
  32186 	} else {
  32187 		sum_num_pixels = 0
  32188 		bits = min_bits
  32189 		for {
  32190 			if !(bits <= max_bits) {
  32191 				break
  32192 			}
  32193 			v3 = libc.Uint32FromInt32(bits)
  32194 			v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32195 			goto _13
  32196 		_13:
  32197 			tiles_per_row1 = libc.Int32FromUint32(v4)
  32198 			v6 = libc.Uint32FromInt32(bits)
  32199 			v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32200 			goto _16
  32201 		_16:
  32202 			tiles_per_col1 = libc.Int32FromUint32(v7)
  32203 			num_pixels[bits] = libc.Uint32FromInt32(tiles_per_row1 * tiles_per_col1)
  32204 			sum_num_pixels = sum_num_pixels + num_pixels[bits]
  32205 			goto _10
  32206 		_10:
  32207 			;
  32208 			bits = bits + 1
  32209 		}
  32210 		modes_raw = WebPSafeMalloc(tls, uint64(sum_num_pixels), uint64(4))
  32211 		if modes_raw == libc.UintptrFromInt32(0) {
  32212 			return 0
  32213 		}
  32214 		// Have modes point to the right global memory modes_raw.
  32215 		(**(**[10]uintptr)(__ccgo_up(bp + 8)))[min_bits] = modes_raw
  32216 		bits = min_bits + int32(1)
  32217 		for {
  32218 			if !(bits <= max_bits) {
  32219 				break
  32220 			}
  32221 			(**(**[10]uintptr)(__ccgo_up(bp + 8)))[bits] = (**(**[10]uintptr)(__ccgo_up(bp + 8)))[bits-int32(1)] + uintptr(num_pixels[bits-int32(1)])*4
  32222 			goto _17
  32223 		_17:
  32224 			;
  32225 			bits = bits + 1
  32226 		}
  32227 		// Find the best sampling.
  32228 		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)
  32229 		if **(**int32)(__ccgo_up(best_bits)) == 0 {
  32230 			WebPSafeFree(tls, modes_raw)
  32231 			return 0
  32232 		}
  32233 		// Keep the best predictor image.
  32234 		v3 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  32235 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  32236 		goto _20
  32237 	_20:
  32238 		v6 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  32239 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  32240 		goto _23
  32241 	_23:
  32242 		libc.X__builtin___memcpy_chk(tls, image, **(**uintptr)(__ccgo_up(bp)), uint64(v4*v7)*uint64(4), ^__predefined_size_t(0))
  32243 		WebPSafeFree(tls, modes_raw)
  32244 	}
  32245 	CopyImageWithPrediction(tls, width, height, **(**int32)(__ccgo_up(best_bits)), image, argb_scratch, argb, low_effort, max_quantization, exact, used_subtract_green)
  32246 	return WebPReportProgress(tls, pic, percent_start+percent_range, percent)
  32247 }
  32248 
  32249 //------------------------------------------------------------------------------
  32250 // Color transform functions.
  32251 
  32252 func MultipliersClear(tls *libc.TLS, m uintptr) {
  32253 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(0)
  32254 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(0)
  32255 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(0)
  32256 }
  32257 
  32258 func ColorCodeToMultipliers(tls *libc.TLS, color_code uint32_t, m uintptr) {
  32259 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(color_code >> libc.Int32FromInt32(0) & uint32(0xff))
  32260 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(color_code >> libc.Int32FromInt32(8) & uint32(0xff))
  32261 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(color_code >> libc.Int32FromInt32(16) & uint32(0xff))
  32262 }
  32263 
  32264 func MultipliersToColorCode(tls *libc.TLS, m uintptr) (r uint32_t) {
  32265 	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)
  32266 }
  32267 
  32268 func PredictionCostCrossColor(tls *libc.TLS, accumulated uintptr, counts uintptr) (r int64_t) {
  32269 	return libc.Int64FromUint64((*(*func(*libc.TLS, uintptr, uintptr) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LCombinedShannonEntropy})))(tls, counts, accumulated)) + PredictionCostBias(tls, counts, uint64(3), kExpValue)
  32270 }
  32271 
  32272 // Favor low entropy, locally and globally.
  32273 // Favor small absolute values for PredictionCostSpatial
  32274 var kExpValue = uint64(240)
  32275 
  32276 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) {
  32277 	bp := tls.Alloc(1024)
  32278 	defer tls.Free(1024)
  32279 	var cur_diff int64_t
  32280 	var _ /* histo at bp+0 */ [256]uint32_t
  32281 	_ = cur_diff
  32282 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32283 	(*(*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)
  32284 	cur_diff = PredictionCostCrossColor(tls, accumulated_red_histo, bp)
  32285 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_red)) == libc.Int32FromUint8(prev_x.Fgreen_to_red) {
  32286 		// favor keeping the areas locally similar
  32287 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32288 	}
  32289 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_red)) == libc.Int32FromUint8(prev_y.Fgreen_to_red) {
  32290 		// favor keeping the areas locally similar
  32291 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32292 	}
  32293 	if green_to_red == 0 {
  32294 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32295 	}
  32296 	return cur_diff
  32297 }
  32298 
  32299 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) {
  32300 	var best_diff, cur_diff int64_t
  32301 	var delta, green_to_red_best, green_to_red_cur, iter, kMaxIters, offset int32
  32302 	_, _, _, _, _, _, _, _ = best_diff, cur_diff, delta, green_to_red_best, green_to_red_cur, iter, kMaxIters, offset
  32303 	kMaxIters = int32(4) + int32(7)*quality>>int32(8) // in range [4..6]
  32304 	green_to_red_best = 0
  32305 	best_diff = GetPredictionCostCrossColorRed(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_red_best, accumulated_red_histo)
  32306 	iter = 0
  32307 	for {
  32308 		if !(iter < kMaxIters) {
  32309 			break
  32310 		}
  32311 		// ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to
  32312 		// one in color computation. Having initial delta here as 1 is sufficient
  32313 		// to explore the range of (-2, 2).
  32314 		delta = int32(32) >> iter
  32315 		// Try a negative and a positive delta from the best known value.
  32316 		offset = -delta
  32317 		for {
  32318 			if !(offset <= delta) {
  32319 				break
  32320 			}
  32321 			green_to_red_cur = offset + green_to_red_best
  32322 			cur_diff = GetPredictionCostCrossColorRed(tls, argb, stride, tile_width, tile_height, prev_x, prev_y, green_to_red_cur, accumulated_red_histo)
  32323 			if cur_diff < best_diff {
  32324 				best_diff = cur_diff
  32325 				green_to_red_best = green_to_red_cur
  32326 			}
  32327 			goto _2
  32328 		_2:
  32329 			;
  32330 			offset = offset + int32(2)*delta
  32331 		}
  32332 		goto _1
  32333 	_1:
  32334 		;
  32335 		iter = iter + 1
  32336 	}
  32337 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fgreen_to_red = libc.Uint8FromInt32(green_to_red_best & libc.Int32FromInt32(0xff))
  32338 }
  32339 
  32340 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) {
  32341 	bp := tls.Alloc(1024)
  32342 	defer tls.Free(1024)
  32343 	var cur_diff int64_t
  32344 	var _ /* histo at bp+0 */ [256]uint32_t
  32345 	_ = cur_diff
  32346 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32347 	(*(*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)
  32348 	cur_diff = PredictionCostCrossColor(tls, accumulated_blue_histo, bp)
  32349 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_blue)) == libc.Int32FromUint8(prev_x.Fgreen_to_blue) {
  32350 		// favor keeping the areas locally similar
  32351 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32352 	}
  32353 	if libc.Int32FromUint8(libc.Uint8FromInt32(green_to_blue)) == libc.Int32FromUint8(prev_y.Fgreen_to_blue) {
  32354 		// favor keeping the areas locally similar
  32355 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32356 	}
  32357 	if libc.Int32FromUint8(libc.Uint8FromInt32(red_to_blue)) == libc.Int32FromUint8(prev_x.Fred_to_blue) {
  32358 		// favor keeping the areas locally similar
  32359 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32360 	}
  32361 	if libc.Int32FromUint8(libc.Uint8FromInt32(red_to_blue)) == libc.Int32FromUint8(prev_y.Fred_to_blue) {
  32362 		// favor keeping the areas locally similar
  32363 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32364 	}
  32365 	if green_to_blue == 0 {
  32366 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32367 	}
  32368 	if red_to_blue == 0 {
  32369 		cur_diff = cur_diff - libc.Int64FromInt64(3)<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  32370 	}
  32371 	return cur_diff
  32372 }
  32373 
  32374 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) {
  32375 	bp := tls.Alloc(16)
  32376 	defer tls.Free(16)
  32377 	var axis, delta, green_to_blue_best, green_to_blue_cur, iter, iters, red_to_blue_best, red_to_blue_cur, v1, v2 int32
  32378 	var best_diff, cur_diff int64_t
  32379 	var delta_lut [7]int8_t
  32380 	var _ /* offset at bp+0 */ [8][2]int8_t
  32381 	_, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  32382 	**(**[8][2]int8_t)(__ccgo_up(bp)) = [8][2]int8_t{
  32383 		0: {
  32384 			1: int8(-int32(1)),
  32385 		},
  32386 		1: {
  32387 			1: int8(1),
  32388 		},
  32389 		2: {
  32390 			0: int8(-int32(1)),
  32391 		},
  32392 		3: {
  32393 			0: int8(1),
  32394 		},
  32395 		4: {
  32396 			0: int8(-int32(1)),
  32397 			1: int8(-int32(1)),
  32398 		},
  32399 		5: {
  32400 			0: int8(-int32(1)),
  32401 			1: int8(1),
  32402 		},
  32403 		6: {
  32404 			0: int8(1),
  32405 			1: int8(-int32(1)),
  32406 		},
  32407 		7: {
  32408 			0: int8(1),
  32409 			1: int8(1),
  32410 		},
  32411 	}
  32412 	delta_lut = [7]int8_t{
  32413 		0: int8(16),
  32414 		1: int8(16),
  32415 		2: int8(8),
  32416 		3: int8(4),
  32417 		4: int8(2),
  32418 		5: int8(2),
  32419 		6: int8(2),
  32420 	}
  32421 	if quality < int32(25) {
  32422 		v1 = int32(1)
  32423 	} else {
  32424 		if quality > int32(50) {
  32425 			v2 = int32(7)
  32426 		} else {
  32427 			v2 = int32(4)
  32428 		}
  32429 		v1 = v2
  32430 	}
  32431 	iters = v1
  32432 	green_to_blue_best = 0
  32433 	red_to_blue_best = 0
  32434 	// Initial value at origin:
  32435 	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)
  32436 	iter = 0
  32437 	for {
  32438 		if !(iter < iters) {
  32439 			break
  32440 		}
  32441 		delta = int32(delta_lut[iter])
  32442 		axis = 0
  32443 		for {
  32444 			if !(axis < int32(8)) {
  32445 				break
  32446 			}
  32447 			green_to_blue_cur = int32(**(**int8_t)(__ccgo_up(bp + uintptr(axis)*2)))*delta + green_to_blue_best
  32448 			red_to_blue_cur = int32(**(**int8_t)(__ccgo_up(bp + uintptr(axis)*2 + 1)))*delta + red_to_blue_best
  32449 			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)
  32450 			if cur_diff < best_diff {
  32451 				best_diff = cur_diff
  32452 				green_to_blue_best = green_to_blue_cur
  32453 				red_to_blue_best = red_to_blue_cur
  32454 			}
  32455 			if quality < int32(25) && iter == int32(4) {
  32456 				// Only axis aligned diffs for lower quality.
  32457 				break // next iter.
  32458 			}
  32459 			goto _4
  32460 		_4:
  32461 			;
  32462 			axis = axis + 1
  32463 		}
  32464 		if delta == int32(2) && green_to_blue_best == 0 && red_to_blue_best == 0 {
  32465 			// Further iterations would not help.
  32466 			break // out of iter-loop.
  32467 		}
  32468 		goto _3
  32469 	_3:
  32470 		;
  32471 		iter = iter + 1
  32472 	}
  32473 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fgreen_to_blue = libc.Uint8FromInt32(green_to_blue_best & int32(0xff))
  32474 	(*VP8LMultipliers)(unsafe.Pointer(best_tx)).Fred_to_blue = libc.Uint8FromInt32(red_to_blue_best & int32(0xff))
  32475 }
  32476 
  32477 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) {
  32478 	bp := tls.Alloc(16)
  32479 	defer tls.Free(16)
  32480 	var all_x_max, all_y_max, max_tile_size, tile_height, tile_width, tile_x_offset, tile_y_offset int32
  32481 	var tile_argb uintptr
  32482 	var _ /* best_tx at bp+0 */ VP8LMultipliers
  32483 	_, _, _, _, _, _, _, _ = all_x_max, all_y_max, max_tile_size, tile_argb, tile_height, tile_width, tile_x_offset, tile_y_offset
  32484 	max_tile_size = int32(1) << bits
  32485 	tile_y_offset = tile_y * max_tile_size
  32486 	tile_x_offset = tile_x * max_tile_size
  32487 	all_x_max = GetMin(tls, tile_x_offset+max_tile_size, xsize)
  32488 	all_y_max = GetMin(tls, tile_y_offset+max_tile_size, ysize)
  32489 	tile_width = all_x_max - tile_x_offset
  32490 	tile_height = all_y_max - tile_y_offset
  32491 	tile_argb = argb + uintptr(tile_y_offset*xsize)*4 + uintptr(tile_x_offset)*4
  32492 	MultipliersClear(tls, bp)
  32493 	GetBestGreenToRed(tls, tile_argb, xsize, tile_width, tile_height, prev_x, prev_y, quality, accumulated_red_histo, bp)
  32494 	GetBestGreenRedToBlue(tls, tile_argb, xsize, tile_width, tile_height, prev_x, prev_y, quality, accumulated_blue_histo, bp)
  32495 	return **(**VP8LMultipliers)(__ccgo_up(bp))
  32496 }
  32497 
  32498 func CopyTileWithColorTransform(tls *libc.TLS, xsize int32, ysize int32, tile_x int32, tile_y int32, max_tile_size int32, _color_transform VP8LMultipliers, argb uintptr) {
  32499 	bp := tls.Alloc(16)
  32500 	defer tls.Free(16)
  32501 	*(*VP8LMultipliers)(unsafe.Pointer(bp)) = _color_transform
  32502 	var xscan, yscan, v1 int32
  32503 	_, _, _ = xscan, yscan, v1
  32504 	xscan = GetMin(tls, max_tile_size, xsize-tile_x)
  32505 	yscan = GetMin(tls, max_tile_size, ysize-tile_y)
  32506 	argb = argb + uintptr(tile_y*xsize+tile_x)*4
  32507 	for {
  32508 		v1 = yscan
  32509 		yscan = yscan - 1
  32510 		if !(v1 > 0) {
  32511 			break
  32512 		}
  32513 		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColor})))(tls, bp, argb, xscan)
  32514 		argb = argb + uintptr(xsize)*4
  32515 	}
  32516 }
  32517 
  32518 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) {
  32519 	bp := tls.Alloc(2064)
  32520 	defer tls.Free(2064)
  32521 	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
  32522 	var pix, v1, v2, v4, v5 uint32_t
  32523 	var _ /* accumulated_blue_histo at bp+1024 */ [256]uint32_t
  32524 	var _ /* accumulated_red_histo at bp+0 */ [256]uint32_t
  32525 	var _ /* prev_x at bp+2049 */ VP8LMultipliers
  32526 	var _ /* prev_y at bp+2052 */ VP8LMultipliers
  32527 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  32528 	max_tile_size = int32(1) << bits
  32529 	v1 = libc.Uint32FromInt32(bits)
  32530 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  32531 	goto _3
  32532 _3:
  32533 	tile_xsize = libc.Int32FromUint32(v2)
  32534 	v4 = libc.Uint32FromInt32(bits)
  32535 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  32536 	goto _6
  32537 _6:
  32538 	tile_ysize = libc.Int32FromUint32(v5)
  32539 	percent_start = **(**int32)(__ccgo_up(percent))
  32540 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  32541 	**(**[256]uint32_t)(__ccgo_up(bp + 1024)) = [256]uint32_t{}
  32542 	MultipliersClear(tls, bp+2052)
  32543 	MultipliersClear(tls, bp+2049)
  32544 	tile_y = 0
  32545 	for {
  32546 		if !(tile_y < tile_ysize) {
  32547 			break
  32548 		}
  32549 		tile_x = 0
  32550 		for {
  32551 			if !(tile_x < tile_xsize) {
  32552 				break
  32553 			}
  32554 			tile_x_offset = tile_x * max_tile_size
  32555 			tile_y_offset = tile_y * max_tile_size
  32556 			all_x_max = GetMin(tls, tile_x_offset+max_tile_size, width)
  32557 			all_y_max = GetMin(tls, tile_y_offset+max_tile_size, height)
  32558 			offset = tile_y*tile_xsize + tile_x
  32559 			if tile_y != 0 {
  32560 				ColorCodeToMultipliers(tls, **(**uint32_t)(__ccgo_up(image + uintptr(offset-tile_xsize)*4)), bp+2052)
  32561 			}
  32562 			**(**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)
  32563 			**(**uint32_t)(__ccgo_up(image + uintptr(offset)*4)) = MultipliersToColorCode(tls, bp+2049)
  32564 			CopyTileWithColorTransform(tls, width, height, tile_x_offset, tile_y_offset, max_tile_size, **(**VP8LMultipliers)(__ccgo_up(bp + 2049)), argb)
  32565 			// Gather accumulated histogram data.
  32566 			y = tile_y_offset
  32567 			for {
  32568 				if !(y < all_y_max) {
  32569 					break
  32570 				}
  32571 				ix = y*width + tile_x_offset
  32572 				ix_end = ix + all_x_max - tile_x_offset
  32573 				for {
  32574 					if !(ix < ix_end) {
  32575 						break
  32576 					}
  32577 					pix = **(**uint32_t)(__ccgo_up(argb + uintptr(ix)*4))
  32578 					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)) {
  32579 						goto _10 // repeated pixels are handled by backward references
  32580 					}
  32581 					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)) {
  32582 						goto _10 // repeated pixels are handled by backward references
  32583 					}
  32584 					(**(**[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
  32585 					(**(**[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
  32586 					goto _10
  32587 				_10:
  32588 					;
  32589 					ix = ix + 1
  32590 				}
  32591 				goto _9
  32592 			_9:
  32593 				;
  32594 				y = y + 1
  32595 			}
  32596 			goto _8
  32597 		_8:
  32598 			;
  32599 			tile_x = tile_x + 1
  32600 		}
  32601 		if !(WebPReportProgress(tls, pic, percent_start+percent_range*tile_y/tile_ysize, percent) != 0) {
  32602 			return 0
  32603 		}
  32604 		goto _7
  32605 	_7:
  32606 		;
  32607 		tile_y = tile_y + 1
  32608 	}
  32609 	VP8LOptimizeSampling(tls, image, width, height, bits, libc.Int32FromInt32(MIN_TRANSFORM_BITS)+libc.Int32FromInt32(1)<<libc.Int32FromInt32(NUM_TRANSFORM_BITS)-libc.Int32FromInt32(1), best_bits)
  32610 	return int32(1)
  32611 }
  32612 
  32613 const DO_TRELLIS_I16 = 1
  32614 const DO_TRELLIS_I4 = 1
  32615 const DO_TRELLIS_UV = 0
  32616 const FLATNESS_LIMIT_I16 = 0
  32617 const FLATNESS_LIMIT_I4 = 3
  32618 const FLATNESS_LIMIT_UV = 2
  32619 const FLATNESS_PENALTY = 140
  32620 const FSTRENGTH_CUTOFF = 2
  32621 const IsFlat = "IsFlat_C"
  32622 const MAX_ALPHA1 = 100
  32623 const MAX_DELTA = 1
  32624 const MAX_DQ_UV = 6
  32625 const MID_ALPHA = 64
  32626 const MIN_ALPHA = 30
  32627 const MIN_DELTA = 0
  32628 const RD_DISTO_MULT = 256
  32629 const SHARPEN_BITS = 11
  32630 const SNS_TO_DQ = 0.9
  32631 const USE_TDISTO = 1
  32632 const __FLT_MIN__7 = 1.1754943508222875e-38
  32633 
  32634 //------------------------------------------------------------------------------
  32635 
  32636 // Copyright 2011 Google Inc. All Rights Reserved.
  32637 //
  32638 // Use of this source code is governed by a BSD-style license
  32639 // that can be found in the COPYING file in the root of the source
  32640 // tree. An additional intellectual property rights grant can be found
  32641 // in the file PATENTS. All contributing project authors may
  32642 // be found in the AUTHORS file in the root of the source tree.
  32643 // -----------------------------------------------------------------------------
  32644 //
  32645 //   WebP encoder: internal header.
  32646 //
  32647 // Author: Skal (pascal.massimino@gmail.com)
  32648 
  32649 // Copyright 2010 Google Inc. All Rights Reserved.
  32650 //
  32651 // Use of this source code is governed by a BSD-style license
  32652 // that can be found in the COPYING file in the root of the source
  32653 // tree. An additional intellectual property rights grant can be found
  32654 // in the file PATENTS. All contributing project authors may
  32655 // be found in the AUTHORS file in the root of the source tree.
  32656 // -----------------------------------------------------------------------------
  32657 //
  32658 //  Common types + memory wrappers
  32659 //
  32660 // Author: Skal (pascal.massimino@gmail.com)
  32661 
  32662 // power-law modulation. Must be strictly less than 1.
  32663 
  32664 // number of non-zero coeffs below which we consider the block very flat
  32665 // (and apply a penalty to complex predictions)
  32666 
  32667 // #define DEBUG_BLOCK
  32668 
  32669 //------------------------------------------------------------------------------
  32670 
  32671 //------------------------------------------------------------------------------
  32672 
  32673 func clip2(tls *libc.TLS, v int32, m int32, M int32) (r int32) {
  32674 	var v1, v2 int32
  32675 	_, _ = v1, v2
  32676 	if v < m {
  32677 		v1 = m
  32678 	} else {
  32679 		if v > M {
  32680 			v2 = M
  32681 		} else {
  32682 			v2 = v
  32683 		}
  32684 		v1 = v2
  32685 	}
  32686 	return v1
  32687 }
  32688 
  32689 var kZigzag1 = [16]uint8_t{
  32690 	1:  uint8(1),
  32691 	2:  uint8(4),
  32692 	3:  uint8(8),
  32693 	4:  uint8(5),
  32694 	5:  uint8(2),
  32695 	6:  uint8(3),
  32696 	7:  uint8(6),
  32697 	8:  uint8(9),
  32698 	9:  uint8(12),
  32699 	10: uint8(13),
  32700 	11: uint8(10),
  32701 	12: uint8(7),
  32702 	13: uint8(11),
  32703 	14: uint8(14),
  32704 	15: uint8(15),
  32705 }
  32706 
  32707 var kDcTable1 = [128]uint8_t{
  32708 	0:   uint8(4),
  32709 	1:   uint8(5),
  32710 	2:   uint8(6),
  32711 	3:   uint8(7),
  32712 	4:   uint8(8),
  32713 	5:   uint8(9),
  32714 	6:   uint8(10),
  32715 	7:   uint8(10),
  32716 	8:   uint8(11),
  32717 	9:   uint8(12),
  32718 	10:  uint8(13),
  32719 	11:  uint8(14),
  32720 	12:  uint8(15),
  32721 	13:  uint8(16),
  32722 	14:  uint8(17),
  32723 	15:  uint8(17),
  32724 	16:  uint8(18),
  32725 	17:  uint8(19),
  32726 	18:  uint8(20),
  32727 	19:  uint8(20),
  32728 	20:  uint8(21),
  32729 	21:  uint8(21),
  32730 	22:  uint8(22),
  32731 	23:  uint8(22),
  32732 	24:  uint8(23),
  32733 	25:  uint8(23),
  32734 	26:  uint8(24),
  32735 	27:  uint8(25),
  32736 	28:  uint8(25),
  32737 	29:  uint8(26),
  32738 	30:  uint8(27),
  32739 	31:  uint8(28),
  32740 	32:  uint8(29),
  32741 	33:  uint8(30),
  32742 	34:  uint8(31),
  32743 	35:  uint8(32),
  32744 	36:  uint8(33),
  32745 	37:  uint8(34),
  32746 	38:  uint8(35),
  32747 	39:  uint8(36),
  32748 	40:  uint8(37),
  32749 	41:  uint8(37),
  32750 	42:  uint8(38),
  32751 	43:  uint8(39),
  32752 	44:  uint8(40),
  32753 	45:  uint8(41),
  32754 	46:  uint8(42),
  32755 	47:  uint8(43),
  32756 	48:  uint8(44),
  32757 	49:  uint8(45),
  32758 	50:  uint8(46),
  32759 	51:  uint8(46),
  32760 	52:  uint8(47),
  32761 	53:  uint8(48),
  32762 	54:  uint8(49),
  32763 	55:  uint8(50),
  32764 	56:  uint8(51),
  32765 	57:  uint8(52),
  32766 	58:  uint8(53),
  32767 	59:  uint8(54),
  32768 	60:  uint8(55),
  32769 	61:  uint8(56),
  32770 	62:  uint8(57),
  32771 	63:  uint8(58),
  32772 	64:  uint8(59),
  32773 	65:  uint8(60),
  32774 	66:  uint8(61),
  32775 	67:  uint8(62),
  32776 	68:  uint8(63),
  32777 	69:  uint8(64),
  32778 	70:  uint8(65),
  32779 	71:  uint8(66),
  32780 	72:  uint8(67),
  32781 	73:  uint8(68),
  32782 	74:  uint8(69),
  32783 	75:  uint8(70),
  32784 	76:  uint8(71),
  32785 	77:  uint8(72),
  32786 	78:  uint8(73),
  32787 	79:  uint8(74),
  32788 	80:  uint8(75),
  32789 	81:  uint8(76),
  32790 	82:  uint8(76),
  32791 	83:  uint8(77),
  32792 	84:  uint8(78),
  32793 	85:  uint8(79),
  32794 	86:  uint8(80),
  32795 	87:  uint8(81),
  32796 	88:  uint8(82),
  32797 	89:  uint8(83),
  32798 	90:  uint8(84),
  32799 	91:  uint8(85),
  32800 	92:  uint8(86),
  32801 	93:  uint8(87),
  32802 	94:  uint8(88),
  32803 	95:  uint8(89),
  32804 	96:  uint8(91),
  32805 	97:  uint8(93),
  32806 	98:  uint8(95),
  32807 	99:  uint8(96),
  32808 	100: uint8(98),
  32809 	101: uint8(100),
  32810 	102: uint8(101),
  32811 	103: uint8(102),
  32812 	104: uint8(104),
  32813 	105: uint8(106),
  32814 	106: uint8(108),
  32815 	107: uint8(110),
  32816 	108: uint8(112),
  32817 	109: uint8(114),
  32818 	110: uint8(116),
  32819 	111: uint8(118),
  32820 	112: uint8(122),
  32821 	113: uint8(124),
  32822 	114: uint8(126),
  32823 	115: uint8(128),
  32824 	116: uint8(130),
  32825 	117: uint8(132),
  32826 	118: uint8(134),
  32827 	119: uint8(136),
  32828 	120: uint8(138),
  32829 	121: uint8(140),
  32830 	122: uint8(143),
  32831 	123: uint8(145),
  32832 	124: uint8(148),
  32833 	125: uint8(151),
  32834 	126: uint8(154),
  32835 	127: uint8(157),
  32836 }
  32837 
  32838 var kAcTable1 = [128]uint16_t{
  32839 	0:   uint16(4),
  32840 	1:   uint16(5),
  32841 	2:   uint16(6),
  32842 	3:   uint16(7),
  32843 	4:   uint16(8),
  32844 	5:   uint16(9),
  32845 	6:   uint16(10),
  32846 	7:   uint16(11),
  32847 	8:   uint16(12),
  32848 	9:   uint16(13),
  32849 	10:  uint16(14),
  32850 	11:  uint16(15),
  32851 	12:  uint16(16),
  32852 	13:  uint16(17),
  32853 	14:  uint16(18),
  32854 	15:  uint16(19),
  32855 	16:  uint16(20),
  32856 	17:  uint16(21),
  32857 	18:  uint16(22),
  32858 	19:  uint16(23),
  32859 	20:  uint16(24),
  32860 	21:  uint16(25),
  32861 	22:  uint16(26),
  32862 	23:  uint16(27),
  32863 	24:  uint16(28),
  32864 	25:  uint16(29),
  32865 	26:  uint16(30),
  32866 	27:  uint16(31),
  32867 	28:  uint16(32),
  32868 	29:  uint16(33),
  32869 	30:  uint16(34),
  32870 	31:  uint16(35),
  32871 	32:  uint16(36),
  32872 	33:  uint16(37),
  32873 	34:  uint16(38),
  32874 	35:  uint16(39),
  32875 	36:  uint16(40),
  32876 	37:  uint16(41),
  32877 	38:  uint16(42),
  32878 	39:  uint16(43),
  32879 	40:  uint16(44),
  32880 	41:  uint16(45),
  32881 	42:  uint16(46),
  32882 	43:  uint16(47),
  32883 	44:  uint16(48),
  32884 	45:  uint16(49),
  32885 	46:  uint16(50),
  32886 	47:  uint16(51),
  32887 	48:  uint16(52),
  32888 	49:  uint16(53),
  32889 	50:  uint16(54),
  32890 	51:  uint16(55),
  32891 	52:  uint16(56),
  32892 	53:  uint16(57),
  32893 	54:  uint16(58),
  32894 	55:  uint16(60),
  32895 	56:  uint16(62),
  32896 	57:  uint16(64),
  32897 	58:  uint16(66),
  32898 	59:  uint16(68),
  32899 	60:  uint16(70),
  32900 	61:  uint16(72),
  32901 	62:  uint16(74),
  32902 	63:  uint16(76),
  32903 	64:  uint16(78),
  32904 	65:  uint16(80),
  32905 	66:  uint16(82),
  32906 	67:  uint16(84),
  32907 	68:  uint16(86),
  32908 	69:  uint16(88),
  32909 	70:  uint16(90),
  32910 	71:  uint16(92),
  32911 	72:  uint16(94),
  32912 	73:  uint16(96),
  32913 	74:  uint16(98),
  32914 	75:  uint16(100),
  32915 	76:  uint16(102),
  32916 	77:  uint16(104),
  32917 	78:  uint16(106),
  32918 	79:  uint16(108),
  32919 	80:  uint16(110),
  32920 	81:  uint16(112),
  32921 	82:  uint16(114),
  32922 	83:  uint16(116),
  32923 	84:  uint16(119),
  32924 	85:  uint16(122),
  32925 	86:  uint16(125),
  32926 	87:  uint16(128),
  32927 	88:  uint16(131),
  32928 	89:  uint16(134),
  32929 	90:  uint16(137),
  32930 	91:  uint16(140),
  32931 	92:  uint16(143),
  32932 	93:  uint16(146),
  32933 	94:  uint16(149),
  32934 	95:  uint16(152),
  32935 	96:  uint16(155),
  32936 	97:  uint16(158),
  32937 	98:  uint16(161),
  32938 	99:  uint16(164),
  32939 	100: uint16(167),
  32940 	101: uint16(170),
  32941 	102: uint16(173),
  32942 	103: uint16(177),
  32943 	104: uint16(181),
  32944 	105: uint16(185),
  32945 	106: uint16(189),
  32946 	107: uint16(193),
  32947 	108: uint16(197),
  32948 	109: uint16(201),
  32949 	110: uint16(205),
  32950 	111: uint16(209),
  32951 	112: uint16(213),
  32952 	113: uint16(217),
  32953 	114: uint16(221),
  32954 	115: uint16(225),
  32955 	116: uint16(229),
  32956 	117: uint16(234),
  32957 	118: uint16(239),
  32958 	119: uint16(245),
  32959 	120: uint16(249),
  32960 	121: uint16(254),
  32961 	122: uint16(259),
  32962 	123: uint16(264),
  32963 	124: uint16(269),
  32964 	125: uint16(274),
  32965 	126: uint16(279),
  32966 	127: uint16(284),
  32967 }
  32968 
  32969 var kAcTable2 = [128]uint16_t{
  32970 	0:   uint16(8),
  32971 	1:   uint16(8),
  32972 	2:   uint16(9),
  32973 	3:   uint16(10),
  32974 	4:   uint16(12),
  32975 	5:   uint16(13),
  32976 	6:   uint16(15),
  32977 	7:   uint16(17),
  32978 	8:   uint16(18),
  32979 	9:   uint16(20),
  32980 	10:  uint16(21),
  32981 	11:  uint16(23),
  32982 	12:  uint16(24),
  32983 	13:  uint16(26),
  32984 	14:  uint16(27),
  32985 	15:  uint16(29),
  32986 	16:  uint16(31),
  32987 	17:  uint16(32),
  32988 	18:  uint16(34),
  32989 	19:  uint16(35),
  32990 	20:  uint16(37),
  32991 	21:  uint16(38),
  32992 	22:  uint16(40),
  32993 	23:  uint16(41),
  32994 	24:  uint16(43),
  32995 	25:  uint16(44),
  32996 	26:  uint16(46),
  32997 	27:  uint16(48),
  32998 	28:  uint16(49),
  32999 	29:  uint16(51),
  33000 	30:  uint16(52),
  33001 	31:  uint16(54),
  33002 	32:  uint16(55),
  33003 	33:  uint16(57),
  33004 	34:  uint16(58),
  33005 	35:  uint16(60),
  33006 	36:  uint16(62),
  33007 	37:  uint16(63),
  33008 	38:  uint16(65),
  33009 	39:  uint16(66),
  33010 	40:  uint16(68),
  33011 	41:  uint16(69),
  33012 	42:  uint16(71),
  33013 	43:  uint16(72),
  33014 	44:  uint16(74),
  33015 	45:  uint16(75),
  33016 	46:  uint16(77),
  33017 	47:  uint16(79),
  33018 	48:  uint16(80),
  33019 	49:  uint16(82),
  33020 	50:  uint16(83),
  33021 	51:  uint16(85),
  33022 	52:  uint16(86),
  33023 	53:  uint16(88),
  33024 	54:  uint16(89),
  33025 	55:  uint16(93),
  33026 	56:  uint16(96),
  33027 	57:  uint16(99),
  33028 	58:  uint16(102),
  33029 	59:  uint16(105),
  33030 	60:  uint16(108),
  33031 	61:  uint16(111),
  33032 	62:  uint16(114),
  33033 	63:  uint16(117),
  33034 	64:  uint16(120),
  33035 	65:  uint16(124),
  33036 	66:  uint16(127),
  33037 	67:  uint16(130),
  33038 	68:  uint16(133),
  33039 	69:  uint16(136),
  33040 	70:  uint16(139),
  33041 	71:  uint16(142),
  33042 	72:  uint16(145),
  33043 	73:  uint16(148),
  33044 	74:  uint16(151),
  33045 	75:  uint16(155),
  33046 	76:  uint16(158),
  33047 	77:  uint16(161),
  33048 	78:  uint16(164),
  33049 	79:  uint16(167),
  33050 	80:  uint16(170),
  33051 	81:  uint16(173),
  33052 	82:  uint16(176),
  33053 	83:  uint16(179),
  33054 	84:  uint16(184),
  33055 	85:  uint16(189),
  33056 	86:  uint16(193),
  33057 	87:  uint16(198),
  33058 	88:  uint16(203),
  33059 	89:  uint16(207),
  33060 	90:  uint16(212),
  33061 	91:  uint16(217),
  33062 	92:  uint16(221),
  33063 	93:  uint16(226),
  33064 	94:  uint16(230),
  33065 	95:  uint16(235),
  33066 	96:  uint16(240),
  33067 	97:  uint16(244),
  33068 	98:  uint16(249),
  33069 	99:  uint16(254),
  33070 	100: uint16(258),
  33071 	101: uint16(263),
  33072 	102: uint16(268),
  33073 	103: uint16(274),
  33074 	104: uint16(280),
  33075 	105: uint16(286),
  33076 	106: uint16(292),
  33077 	107: uint16(299),
  33078 	108: uint16(305),
  33079 	109: uint16(311),
  33080 	110: uint16(317),
  33081 	111: uint16(323),
  33082 	112: uint16(330),
  33083 	113: uint16(336),
  33084 	114: uint16(342),
  33085 	115: uint16(348),
  33086 	116: uint16(354),
  33087 	117: uint16(362),
  33088 	118: uint16(370),
  33089 	119: uint16(379),
  33090 	120: uint16(385),
  33091 	121: uint16(393),
  33092 	122: uint16(401),
  33093 	123: uint16(409),
  33094 	124: uint16(416),
  33095 	125: uint16(424),
  33096 	126: uint16(432),
  33097 	127: uint16(440),
  33098 }
  33099 
  33100 var kBiasMatrices = [3][2]uint8_t{
  33101 	0: {
  33102 		0: uint8(96),
  33103 		1: uint8(110),
  33104 	},
  33105 	1: {
  33106 		0: uint8(96),
  33107 		1: uint8(108),
  33108 	},
  33109 	2: {
  33110 		0: uint8(110),
  33111 		1: uint8(115),
  33112 	},
  33113 }
  33114 
  33115 // C documentation
  33116 //
  33117 //	// Sharpening by (slightly) raising the hi-frequency coeffs.
  33118 //	// Hack-ish but helpful for mid-bitrate range. Use with care.
  33119 var kFreqSharpening = [16]uint8_t{
  33120 	1:  uint8(30),
  33121 	2:  uint8(60),
  33122 	3:  uint8(90),
  33123 	4:  uint8(30),
  33124 	5:  uint8(60),
  33125 	6:  uint8(90),
  33126 	7:  uint8(90),
  33127 	8:  uint8(60),
  33128 	9:  uint8(90),
  33129 	10: uint8(90),
  33130 	11: uint8(90),
  33131 	12: uint8(90),
  33132 	13: uint8(90),
  33133 	14: uint8(90),
  33134 	15: uint8(90),
  33135 }
  33136 
  33137 //------------------------------------------------------------------------------
  33138 // Initialize quantization parameters in VP8Matrix
  33139 
  33140 // C documentation
  33141 //
  33142 //	// Returns the average quantizer
  33143 func ExpandMatrix(tls *libc.TLS, m uintptr, type1 int32) (r int32) {
  33144 	var bias, i, is_ac_coeff, sum int32
  33145 	_, _, _, _ = bias, i, is_ac_coeff, sum
  33146 	i = 0
  33147 	for {
  33148 		if !(i < int32(2)) {
  33149 			break
  33150 		}
  33151 		is_ac_coeff = libc.BoolInt32(i > libc.Int32FromInt32(0))
  33152 		bias = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kBiasMatrices)) + uintptr(type1)*2 + uintptr(is_ac_coeff))))
  33153 		**(**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))))
  33154 		**(**uint32_t)(__ccgo_up(m + 64 + uintptr(i)*4)) = libc.Uint32FromInt32(bias << (libc.Int32FromInt32(QFIX) - libc.Int32FromInt32(8)))
  33155 		// zthresh is the exact value such that QUANTDIV(coeff, iQ, B) is:
  33156 		//   * zero if coeff <= zthresh
  33157 		//   * non-zero if coeff > zthresh
  33158 		**(**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)))
  33159 		goto _1
  33160 	_1:
  33161 		;
  33162 		i = i + 1
  33163 	}
  33164 	i = int32(2)
  33165 	for {
  33166 		if !(i < int32(16)) {
  33167 			break
  33168 		}
  33169 		**(**uint16_t)(__ccgo_up(m + uintptr(i)*2)) = **(**uint16_t)(__ccgo_up(m + 1*2))
  33170 		**(**uint16_t)(__ccgo_up(m + 32 + uintptr(i)*2)) = **(**uint16_t)(__ccgo_up(m + 32 + 1*2))
  33171 		**(**uint32_t)(__ccgo_up(m + 64 + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(m + 64 + 1*4))
  33172 		**(**uint32_t)(__ccgo_up(m + 128 + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(m + 128 + 1*4))
  33173 		goto _2
  33174 	_2:
  33175 		;
  33176 		i = i + 1
  33177 	}
  33178 	sum = 0
  33179 	i = libc.Int32FromInt32(0)
  33180 	for {
  33181 		if !(i < int32(16)) {
  33182 			break
  33183 		}
  33184 		if type1 == 0 { // we only use sharpening for AC luma coeffs
  33185 			**(**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))
  33186 		} else {
  33187 			**(**uint16_t)(__ccgo_up(m + 192 + uintptr(i)*2)) = uint16(0)
  33188 		}
  33189 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m + uintptr(i)*2)))
  33190 		goto _3
  33191 	_3:
  33192 		;
  33193 		i = i + 1
  33194 	}
  33195 	return (sum + int32(8)) >> int32(4)
  33196 }
  33197 
  33198 func CheckLambdaValue(tls *libc.TLS, v uintptr) {
  33199 	if **(**int32)(__ccgo_up(v)) < int32(1) {
  33200 		**(**int32)(__ccgo_up(v)) = int32(1)
  33201 	}
  33202 }
  33203 
  33204 func SetupMatrices(tls *libc.TLS, enc uintptr) {
  33205 	var i, num_segments, q, q_i16, q_i4, q_uv, tlambda_scale, v1 int32
  33206 	var m uintptr
  33207 	_, _, _, _, _, _, _, _, _ = i, m, num_segments, q, q_i16, q_i4, q_uv, tlambda_scale, v1
  33208 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmethod >= int32(4) {
  33209 		v1 = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength
  33210 	} else {
  33211 		v1 = 0
  33212 	}
  33213 	tlambda_scale = v1
  33214 	num_segments = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33215 	i = 0
  33216 	for {
  33217 		if !(i < num_segments) {
  33218 			break
  33219 		}
  33220 		m = enc + 608 + uintptr(i)*744
  33221 		q = (*VP8SegmentInfo)(unsafe.Pointer(m)).Fquant
  33222 		**(**uint16_t)(__ccgo_up(m)) = uint16(kDcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc, 0, int32(127))])
  33223 		**(**uint16_t)(__ccgo_up(m + 1*2)) = kAcTable1[clip2(tls, q, 0, int32(127))]
  33224 		**(**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))
  33225 		**(**uint16_t)(__ccgo_up(m + 224 + 1*2)) = kAcTable2[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac, 0, int32(127))]
  33226 		**(**uint16_t)(__ccgo_up(m + 448)) = uint16(kDcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc, 0, int32(117))])
  33227 		**(**uint16_t)(__ccgo_up(m + 448 + 1*2)) = kAcTable1[clip2(tls, q+(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac, 0, int32(127))]
  33228 		q_i4 = ExpandMatrix(tls, m, 0)
  33229 		q_i16 = ExpandMatrix(tls, m+224, int32(1))
  33230 		q_uv = ExpandMatrix(tls, m+448, int32(2))
  33231 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_i4 = int32(3) * q_i4 * q_i4 >> int32(7)
  33232 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_i16 = int32(3) * q_i16 * q_i16
  33233 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_uv = int32(3) * q_uv * q_uv >> int32(6)
  33234 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_mode = int32(1) * q_i4 * q_i4 >> int32(7)
  33235 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_i4 = int32(7) * q_i4 * q_i4 >> int32(3)
  33236 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_i16 = q_i16 * q_i16 >> int32(2)
  33237 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Flambda_trellis_uv = q_uv * q_uv << int32(1)
  33238 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Ftlambda = tlambda_scale * q_i4 >> int32(5)
  33239 		// none of these constants should be < 1
  33240 		CheckLambdaValue(tls, m+700)
  33241 		CheckLambdaValue(tls, m+696)
  33242 		CheckLambdaValue(tls, m+704)
  33243 		CheckLambdaValue(tls, m+708)
  33244 		CheckLambdaValue(tls, m+724)
  33245 		CheckLambdaValue(tls, m+720)
  33246 		CheckLambdaValue(tls, m+728)
  33247 		CheckLambdaValue(tls, m+716)
  33248 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fmin_disto = int32(20) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(m))) // quantization-aware min disto
  33249 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fmax_edge = 0
  33250 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Fi4_penalty = int64(int32(1000) * q_i4 * q_i4)
  33251 		goto _2
  33252 	_2:
  33253 		;
  33254 		i = i + 1
  33255 	}
  33256 }
  33257 
  33258 //------------------------------------------------------------------------------
  33259 // Initialize filtering parameters
  33260 
  33261 // Very small filter-strength values have close to no visual effect. So we can
  33262 // save a little decoding-CPU by turning filtering off for these.
  33263 
  33264 func SetupFilterStrength(tls *libc.TLS, enc uintptr) {
  33265 	var base_strength, f, i, level0, qstep, v2, v3 int32
  33266 	var m uintptr
  33267 	_, _, _, _, _, _, _, _ = base_strength, f, i, level0, m, qstep, v2, v3
  33268 	// level0 is in [0..500]. Using '-f 50' as filter_strength is mid-filtering.
  33269 	level0 = int32(5) * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_strength
  33270 	i = 0
  33271 	for {
  33272 		if !(i < int32(NUM_MB_SEGMENTS)) {
  33273 			break
  33274 		}
  33275 		m = enc + 608 + uintptr(i)*744
  33276 		// We focus on the quantization of AC coeffs.
  33277 		qstep = libc.Int32FromUint16(kAcTable1[clip2(tls, (*VP8SegmentInfo)(unsafe.Pointer(m)).Fquant, 0, int32(127))]) >> int32(2)
  33278 		base_strength = VP8FilterStrengthFromDelta(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness, qstep)
  33279 		// Segments with lower complexity ('beta') will be less filtered.
  33280 		f = base_strength * level0 / (int32(256) + (*VP8SegmentInfo)(unsafe.Pointer(m)).Fbeta)
  33281 		if f < int32(FSTRENGTH_CUTOFF) {
  33282 			v2 = 0
  33283 		} else {
  33284 			if f > int32(63) {
  33285 				v3 = int32(63)
  33286 			} else {
  33287 				v3 = f
  33288 			}
  33289 			v2 = v3
  33290 		}
  33291 		(*VP8SegmentInfo)(unsafe.Pointer(m)).Ffstrength = v2
  33292 		goto _1
  33293 	_1:
  33294 		;
  33295 		i = i + 1
  33296 	}
  33297 	// We record the initial strength (mainly for the case of 1-segment only).
  33298 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Flevel = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Ffstrength
  33299 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsimple = libc.BoolInt32((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_type == 0)
  33300 	(*VP8Encoder)(unsafe.Pointer(enc)).Ffilter_hdr.Fsharpness = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Ffilter_sharpness
  33301 }
  33302 
  33303 //------------------------------------------------------------------------------
  33304 
  33305 // Note: if you change the values below, remember that the max range
  33306 // allowed by the syntax for DQ_UV is [-16,16].
  33307 
  33308 // C documentation
  33309 //
  33310 //	// We want to emulate jpeg-like behaviour where the expected "good" quality
  33311 //	// is around q=75. Internally, our "good" middle is around c=50. So we
  33312 //	// map accordingly using linear piece-wise function
  33313 func QualityToCompression(tls *libc.TLS, c float64) (r float64) {
  33314 	var linear_c, v, v1 float64
  33315 	_, _, _ = linear_c, v, v1
  33316 	if c < float64(0.75) {
  33317 		v1 = float64(c * (libc.Float64FromFloat64(2) / libc.Float64FromFloat64(3)))
  33318 	} else {
  33319 		v1 = float64(float64(2)*c) - float64(1)
  33320 	}
  33321 	linear_c = v1
  33322 	// The file size roughly scales as pow(quantizer, 3.). Actually, the
  33323 	// exponent is somewhere between 2.8 and 3.2, but we're mostly interested
  33324 	// in the mid-quant range. So we scale the compressibility inversely to
  33325 	// this power-law: quant ~= compression ^ 1/3. This law holds well for
  33326 	// low quant. Finer modeling for high-quant would make use of kAcTable[]
  33327 	// more explicitly.
  33328 	v = libc.Xpow(tls, linear_c, libc.Float64FromInt32(1)/libc.Float64FromFloat64(3))
  33329 	return v
  33330 }
  33331 
  33332 func QualityToJPEGCompression(tls *libc.TLS, c float64, alpha float64) (r float64) {
  33333 	var amax, amin, exp_max, exp_min, expn, slope, v, v1, v2 float64
  33334 	_, _, _, _, _, _, _, _, _ = amax, amin, exp_max, exp_min, expn, slope, v, v1, v2
  33335 	// We map the complexity 'alpha' and quality setting 'c' to a compression
  33336 	// exponent empirically matched to the compression curve of libjpeg6b.
  33337 	// On average, the WebP output size will be roughly similar to that of a
  33338 	// JPEG file compressed with same quality factor.
  33339 	amin = float64(0.3)
  33340 	amax = float64(0.85)
  33341 	exp_min = float64(0.4)
  33342 	exp_max = float64(0.9)
  33343 	slope = (exp_min - exp_max) / (amax - amin)
  33344 	if alpha > amax {
  33345 		v1 = exp_min
  33346 	} else {
  33347 		if alpha < amin {
  33348 			v2 = exp_max
  33349 		} else {
  33350 			v2 = exp_max + float64(slope*(alpha-amin))
  33351 		}
  33352 		v1 = v2
  33353 	}
  33354 	// Linearly interpolate 'expn' from exp_min to exp_max
  33355 	// in the [amin, amax] range.
  33356 	expn = v1
  33357 	v = libc.Xpow(tls, c, expn)
  33358 	return v
  33359 }
  33360 
  33361 func SegmentsAreEquivalent(tls *libc.TLS, S1 uintptr, S2 uintptr) (r int32) {
  33362 	return libc.BoolInt32((*VP8SegmentInfo)(unsafe.Pointer(S1)).Fquant == (*VP8SegmentInfo)(unsafe.Pointer(S2)).Fquant && (*VP8SegmentInfo)(unsafe.Pointer(S1)).Ffstrength == (*VP8SegmentInfo)(unsafe.Pointer(S2)).Ffstrength)
  33363 }
  33364 
  33365 func SimplifySegments(tls *libc.TLS, enc uintptr) {
  33366 	var S1, S2 uintptr
  33367 	var found, i, num_final_segments, num_segments, s1, s2, v1 int32
  33368 	var map1 [4]int32
  33369 	_, _, _, _, _, _, _, _, _, _ = S1, S2, found, i, map1, num_final_segments, num_segments, s1, s2, v1
  33370 	map1 = [4]int32{
  33371 		1: int32(1),
  33372 		2: int32(2),
  33373 		3: int32(3),
  33374 	}
  33375 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments < int32(NUM_MB_SEGMENTS) {
  33376 		v1 = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33377 	} else {
  33378 		v1 = int32(NUM_MB_SEGMENTS)
  33379 	}
  33380 	// 'num_segments' is previously validated and <= NUM_MB_SEGMENTS, but an
  33381 	// explicit check is needed to avoid a spurious warning about 'i' exceeding
  33382 	// array bounds of 'dqm' with some compilers (noticed with gcc-4.9).
  33383 	num_segments = v1
  33384 	num_final_segments = int32(1)
  33385 	s1 = int32(1)
  33386 	for {
  33387 		if !(s1 < num_segments) {
  33388 			break
  33389 		} // find similar segments
  33390 		S1 = enc + 608 + uintptr(s1)*744
  33391 		found = 0
  33392 		// check if we already have similar segment
  33393 		s2 = 0
  33394 		for {
  33395 			if !(s2 < num_final_segments) {
  33396 				break
  33397 			}
  33398 			S2 = enc + 608 + uintptr(s2)*744
  33399 			if SegmentsAreEquivalent(tls, S1, S2) != 0 {
  33400 				found = int32(1)
  33401 				break
  33402 			}
  33403 			goto _3
  33404 		_3:
  33405 			;
  33406 			s2 = s2 + 1
  33407 		}
  33408 		map1[s1] = s2
  33409 		if !(found != 0) {
  33410 			if num_final_segments != s1 {
  33411 				**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(num_final_segments)*744)) = **(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s1)*744))
  33412 			}
  33413 			num_final_segments = num_final_segments + 1
  33414 		}
  33415 		goto _2
  33416 	_2:
  33417 		;
  33418 		s1 = s1 + 1
  33419 	}
  33420 	if num_final_segments < num_segments { // Remap
  33421 		i = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  33422 		for {
  33423 			v1 = i
  33424 			i = i - 1
  33425 			if !(v1 > 0) {
  33426 				break
  33427 			}
  33428 			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)
  33429 		}
  33430 		(*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments = num_final_segments
  33431 		// Replicate the trailing segment infos (it's mostly cosmetics)
  33432 		i = num_final_segments
  33433 		for {
  33434 			if !(i < num_segments) {
  33435 				break
  33436 			}
  33437 			**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744)) = **(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(num_final_segments-int32(1))*744))
  33438 			goto _5
  33439 		_5:
  33440 			;
  33441 			i = i + 1
  33442 		}
  33443 	}
  33444 }
  33445 
  33446 func VP8SetSegmentParams(tls *libc.TLS, enc uintptr, quality float32) {
  33447 	var Q, amp, c, c_base, expn, v1 float64
  33448 	var dq_uv_ac, dq_uv_dc, i, num_segments, q int32
  33449 	_, _, _, _, _, _, _, _, _, _, _ = Q, amp, c, c_base, dq_uv_ac, dq_uv_dc, expn, i, num_segments, q, v1
  33450 	num_segments = (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fnum_segments
  33451 	amp = float64(float64(SNS_TO_DQ)*float64((*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength)) / float64(100) / float64(128)
  33452 	Q = float64(quality) / float64(100)
  33453 	if (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Femulate_jpeg_size != 0 {
  33454 		v1 = QualityToJPEGCompression(tls, Q, float64((*VP8Encoder)(unsafe.Pointer(enc)).Falpha)/float64(255))
  33455 	} else {
  33456 		v1 = QualityToCompression(tls, Q)
  33457 	}
  33458 	c_base = v1
  33459 	i = 0
  33460 	for {
  33461 		if !(i < num_segments) {
  33462 			break
  33463 		}
  33464 		// We modulate the base coefficient to accommodate for the quantization
  33465 		// susceptibility and allow denser segments to be quantized more.
  33466 		expn = float64(1) - float64(amp*float64((**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Falpha))
  33467 		c = libc.Xpow(tls, c_base, expn)
  33468 		q = int32(float64(libc.Float64FromFloat64(127) * (libc.Float64FromFloat64(1) - c)))
  33469 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant = clip2(tls, q, 0, int32(127))
  33470 		goto _2
  33471 	_2:
  33472 		;
  33473 		i = i + 1
  33474 	}
  33475 	// purely indicative in the bitstream (except for the 1-segment case)
  33476 	(*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608))).Fquant
  33477 	// fill-in values for the unused segments (required by the syntax)
  33478 	i = num_segments
  33479 	for {
  33480 		if !(i < int32(NUM_MB_SEGMENTS)) {
  33481 			break
  33482 		}
  33483 		(**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant = (*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant
  33484 		goto _3
  33485 	_3:
  33486 		;
  33487 		i = i + 1
  33488 	}
  33489 	// uv_alpha is normally spread around ~60. The useful range is
  33490 	// typically ~30 (quite bad) to ~100 (ok to decimate UV more).
  33491 	// We map it to the safe maximal range of MAX/MIN_DQ_UV for dq_uv.
  33492 	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))
  33493 	// we rescale by the user-defined strength of adaptation
  33494 	dq_uv_ac = dq_uv_ac * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength / int32(100)
  33495 	// and make it safe.
  33496 	dq_uv_ac = clip2(tls, dq_uv_ac, -int32(4), int32(MAX_DQ_UV))
  33497 	// We also boost the dc-uv-quant a little, based on sns-strength, since
  33498 	// U/V channels are quite more reactive to high quants (flat DC-blocks
  33499 	// tend to appear, and are unpleasant).
  33500 	dq_uv_dc = -int32(4) * (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsns_strength / int32(100)
  33501 	dq_uv_dc = clip2(tls, dq_uv_dc, -int32(15), int32(15)) // 4bit-signed max allowed
  33502 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc = 0       // TODO(skal): dq-lum
  33503 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_dc = 0
  33504 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac = 0
  33505 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc = dq_uv_dc
  33506 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac = dq_uv_ac
  33507 	SetupFilterStrength(tls, enc) // initialize segments' filtering, eventually
  33508 	if num_segments > int32(1) {
  33509 		SimplifySegments(tls, enc)
  33510 	}
  33511 	SetupMatrices(tls, enc) // finalize quantization matrices
  33512 }
  33513 
  33514 // C documentation
  33515 //
  33516 //	// Must be indexed using {B_DC_PRED -> B_HU_PRED} as index
  33517 var VP8I4ModeOffsets = [10]uint16_t{
  33518 	0: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0)),
  33519 	1: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(4)),
  33520 	2: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(8)),
  33521 	3: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(12)),
  33522 	4: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(16)),
  33523 	5: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(20)),
  33524 	6: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(24)),
  33525 	7: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(0) + libc.Int32FromInt32(28)),
  33526 	8: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33527 	9: libc.Uint16FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(4)),
  33528 }
  33529 
  33530 func VP8MakeLuma16Preds(tls *libc.TLS, it uintptr) {
  33531 	var left, top, v1, v2 uintptr
  33532 	_, _, _, _ = left, top, v1, v2
  33533 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx != 0 {
  33534 		v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_left
  33535 	} else {
  33536 		v1 = libc.UintptrFromInt32(0)
  33537 	}
  33538 	left = v1
  33539 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy != 0 {
  33540 		v2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fy_top
  33541 	} else {
  33542 		v2 = libc.UintptrFromInt32(0)
  33543 	}
  33544 	top = v2
  33545 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredLuma16})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, left, top)
  33546 }
  33547 
  33548 func VP8MakeChroma8Preds(tls *libc.TLS, it uintptr) {
  33549 	var left, top, v1, v2 uintptr
  33550 	_, _, _, _ = left, top, v1, v2
  33551 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fx != 0 {
  33552 		v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fu_left
  33553 	} else {
  33554 		v1 = libc.UintptrFromInt32(0)
  33555 	}
  33556 	left = v1
  33557 	if (*VP8EncIterator)(unsafe.Pointer(it)).Fy != 0 {
  33558 		v2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fuv_top
  33559 	} else {
  33560 		v2 = libc.UintptrFromInt32(0)
  33561 	}
  33562 	top = v2
  33563 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredChroma8})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, left, top)
  33564 }
  33565 
  33566 // C documentation
  33567 //
  33568 //	// Form all the ten Intra4x4 predictions in the 'yuv_p' cache
  33569 //	// for the 4x4 block it->i4
  33570 func MakeIntra4Preds(tls *libc.TLS, it uintptr) {
  33571 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8EncPredLuma4})))(tls, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p, (*VP8EncIterator)(unsafe.Pointer(it)).Fi4_top)
  33572 }
  33573 
  33574 var VP8ScanUV = [8]uint16_t{
  33575 	1: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33576 	2: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33577 	3: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33578 	4: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33579 	5: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  33580 	6: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33581 	7: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  33582 }
  33583 
  33584 //------------------------------------------------------------------------------
  33585 // Distortion measurement
  33586 
  33587 var kWeightY = [16]uint16_t{
  33588 	0:  uint16(38),
  33589 	1:  uint16(32),
  33590 	2:  uint16(20),
  33591 	3:  uint16(9),
  33592 	4:  uint16(32),
  33593 	5:  uint16(28),
  33594 	6:  uint16(17),
  33595 	7:  uint16(7),
  33596 	8:  uint16(20),
  33597 	9:  uint16(17),
  33598 	10: uint16(10),
  33599 	11: uint16(4),
  33600 	12: uint16(9),
  33601 	13: uint16(7),
  33602 	14: uint16(4),
  33603 	15: uint16(2),
  33604 }
  33605 
  33606 var kWeightTrellis = [16]uint16_t{
  33607 	0:  uint16(30),
  33608 	1:  uint16(27),
  33609 	2:  uint16(19),
  33610 	3:  uint16(11),
  33611 	4:  uint16(27),
  33612 	5:  uint16(24),
  33613 	6:  uint16(17),
  33614 	7:  uint16(10),
  33615 	8:  uint16(19),
  33616 	9:  uint16(17),
  33617 	10: uint16(12),
  33618 	11: uint16(8),
  33619 	12: uint16(11),
  33620 	13: uint16(10),
  33621 	14: uint16(8),
  33622 	15: uint16(6),
  33623 }
  33624 
  33625 // C documentation
  33626 //
  33627 //	// Init/Copy the common fields in score.
  33628 func InitScore(tls *libc.TLS, rd uintptr) {
  33629 	(*VP8ModeScore)(unsafe.Pointer(rd)).FD = 0
  33630 	(*VP8ModeScore)(unsafe.Pointer(rd)).FSD = 0
  33631 	(*VP8ModeScore)(unsafe.Pointer(rd)).FR = 0
  33632 	(*VP8ModeScore)(unsafe.Pointer(rd)).FH = 0
  33633 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = uint32(0)
  33634 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fscore = libc.Int64FromInt64(0x7fffffffffffff)
  33635 }
  33636 
  33637 func CopyScore(tls *libc.TLS, dst uintptr, src uintptr) {
  33638 	(*VP8ModeScore)(unsafe.Pointer(dst)).FD = (*VP8ModeScore)(unsafe.Pointer(src)).FD
  33639 	(*VP8ModeScore)(unsafe.Pointer(dst)).FSD = (*VP8ModeScore)(unsafe.Pointer(src)).FSD
  33640 	(*VP8ModeScore)(unsafe.Pointer(dst)).FR = (*VP8ModeScore)(unsafe.Pointer(src)).FR
  33641 	(*VP8ModeScore)(unsafe.Pointer(dst)).FH = (*VP8ModeScore)(unsafe.Pointer(src)).FH
  33642 	(*VP8ModeScore)(unsafe.Pointer(dst)).Fnz = (*VP8ModeScore)(unsafe.Pointer(src)).Fnz // note that nz is not accumulated, but just copied.
  33643 	(*VP8ModeScore)(unsafe.Pointer(dst)).Fscore = (*VP8ModeScore)(unsafe.Pointer(src)).Fscore
  33644 }
  33645 
  33646 func AddScore(tls *libc.TLS, dst uintptr, src uintptr) {
  33647 	**(**score_t)(__ccgo_up(dst)) += (*VP8ModeScore)(unsafe.Pointer(src)).FD
  33648 	**(**score_t)(__ccgo_up(dst + 8)) += (*VP8ModeScore)(unsafe.Pointer(src)).FSD
  33649 	**(**score_t)(__ccgo_up(dst + 24)) += (*VP8ModeScore)(unsafe.Pointer(src)).FR
  33650 	**(**score_t)(__ccgo_up(dst + 16)) += (*VP8ModeScore)(unsafe.Pointer(src)).FH
  33651 	**(**uint32_t)(__ccgo_up(dst + 864)) |= (*VP8ModeScore)(unsafe.Pointer(src)).Fnz // here, new nz bits are accumulated.
  33652 	**(**score_t)(__ccgo_up(dst + 32)) += (*VP8ModeScore)(unsafe.Pointer(src)).Fscore
  33653 }
  33654 
  33655 //------------------------------------------------------------------------------
  33656 // Performs trellis-optimized quantization.
  33657 
  33658 // C documentation
  33659 //
  33660 //	// Trellis node
  33661 type Node = struct {
  33662 	Fprev  int8_t
  33663 	Fsign  int8_t
  33664 	Flevel int16_t
  33665 }
  33666 
  33667 // C documentation
  33668 //
  33669 //	// Score state
  33670 type ScoreState = struct {
  33671 	Fscore score_t
  33672 	Fcosts uintptr
  33673 }
  33674 
  33675 // If a coefficient was quantized to a value Q (using a neutral bias),
  33676 // we test all alternate possibilities between [Q-MIN_DELTA, Q+MAX_DELTA]
  33677 // We don't test negative values though.
  33678 
  33679 func SetRDScore(tls *libc.TLS, lambda int32, rd uintptr) {
  33680 	(*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)
  33681 }
  33682 
  33683 func RDScoreTrellis(tls *libc.TLS, lambda int32, rate score_t, distortion score_t) (r score_t) {
  33684 	return rate*int64(lambda) + int64(RD_DISTO_MULT)*distortion
  33685 }
  33686 
  33687 const TYPE_I16_AC = 0
  33688 const TYPE_I16_DC = 1
  33689 const TYPE_CHROMA_A = 2
  33690 const TYPE_I4_AC = 3
  33691 
  33692 func TrellisQuantizeBlock(tls *libc.TLS, enc uintptr, in uintptr, out uintptr, ctx0 int32, coeff_type int32, mtx uintptr, lambda int32) (r int32) {
  33693 	bp := tls.Alloc(192)
  33694 	defer tls.Free(192)
  33695 	var B1, Q, coeff0, iQ1 uint32_t
  33696 	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
  33697 	var base_score, best_cur_score, best_score, cost, cost1, last_pos_cost, last_pos_score, rate, score score_t
  33698 	var best_path [3]int32
  33699 	var costs CostArrayPtr
  33700 	var cur, node, probas, ss_cur, ss_prev, tmp uintptr
  33701 	var v3 uint8_t
  33702 	var _ /* nodes at bp+0 */ [16][2]Node
  33703 	var _ /* score_states at bp+128 */ [2][2]ScoreState
  33704 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  33705 	probas = enc + 3616 + 4 + uintptr(coeff_type)*264
  33706 	costs = enc + 3616 + 18344 + uintptr(coeff_type)*384
  33707 	if coeff_type == int32(TYPE_I16_AC) {
  33708 		v1 = int32(1)
  33709 	} else {
  33710 		v1 = 0
  33711 	}
  33712 	first = v1
  33713 	ss_cur = bp + 128 + uintptr(libc.Int32FromInt32(MIN_DELTA)+libc.Int32FromInt32(MIN_DELTA))*16
  33714 	ss_prev = bp + 128 + 1*32 + uintptr(libc.Int32FromInt32(MIN_DELTA)+libc.Int32FromInt32(MIN_DELTA))*16
  33715 	best_path = [3]int32{
  33716 		0: -int32(1),
  33717 		1: -int32(1),
  33718 		2: -int32(1),
  33719 	}
  33720 	thresh = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 1*2))) * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 1*2))) / int32(4)
  33721 	last_proba = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + uintptr(VP8EncBands[first])*33 + uintptr(ctx0)*11)))
  33722 	// compute the position of the last interesting coefficient
  33723 	last = first - int32(1)
  33724 	n1 = int32(15)
  33725 	for {
  33726 		if !(n1 >= first) {
  33727 			break
  33728 		}
  33729 		j = libc.Int32FromUint8(kZigzag1[n1])
  33730 		err = int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2))) * int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  33731 		if err > thresh {
  33732 			last = n1
  33733 			break
  33734 		}
  33735 		goto _2
  33736 	_2:
  33737 		;
  33738 		n1 = n1 - 1
  33739 	}
  33740 	// we don't need to go inspect up to n = 16 coeffs. We can just go up
  33741 	// to last + 1 (inclusive) without losing much.
  33742 	if last < int32(15) {
  33743 		last = last + 1
  33744 	}
  33745 	// compute 'skip' score. This is the max score one can do.
  33746 	v3 = libc.Uint8FromInt32(last_proba)
  33747 	if !(0 != 0) {
  33748 		v4 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33749 	} else {
  33750 		v4 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33751 	}
  33752 	v1 = v4
  33753 	goto _5
  33754 _5:
  33755 	cost = int64(v1)
  33756 	best_score = RDScoreTrellis(tls, lambda, cost, 0)
  33757 	// initialize source node.
  33758 	m = -MIN_DELTA
  33759 	for {
  33760 		if !(m <= int32(MAX_DELTA)) {
  33761 			break
  33762 		}
  33763 		if ctx0 == 0 {
  33764 			v3 = libc.Uint8FromInt32(last_proba)
  33765 			if !(int32(1) != 0) {
  33766 				v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33767 			} else {
  33768 				v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33769 			}
  33770 			v4 = v6
  33771 			goto _11
  33772 		_11:
  33773 			v1 = v4
  33774 		} else {
  33775 			v1 = 0
  33776 		}
  33777 		rate = int64(v1)
  33778 		(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = RDScoreTrellis(tls, lambda, rate, 0)
  33779 		(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fcosts = **(**uintptr)(__ccgo_up(costs + uintptr(first)*24 + uintptr(ctx0)*8))
  33780 		goto _7
  33781 	_7:
  33782 		;
  33783 		m = m + 1
  33784 	}
  33785 	// traverse trellis.
  33786 	n1 = first
  33787 	for {
  33788 		if !(n1 <= last) {
  33789 			break
  33790 		}
  33791 		j1 = libc.Int32FromUint8(kZigzag1[n1])
  33792 		Q = uint32(**(**uint16_t)(__ccgo_up(mtx + uintptr(j1)*2)))
  33793 		iQ1 = uint32(**(**uint16_t)(__ccgo_up(mtx + 32 + uintptr(j1)*2)))
  33794 		B1 = libc.Uint32FromInt32(libc.Int32FromInt32(0x00) << (libc.Int32FromInt32(QFIX) - libc.Int32FromInt32(8))) // neutral bias
  33795 		// note: it's important to take sign of the _original_ coeff,
  33796 		// so we don't have to consider level < 0 afterward.
  33797 		sign = libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2))) < libc.Int32FromInt32(0))
  33798 		if sign != 0 {
  33799 			v1 = -int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2)))
  33800 		} else {
  33801 			v1 = int32(**(**int16_t)(__ccgo_up(in + uintptr(j1)*2)))
  33802 		}
  33803 		coeff0 = libc.Uint32FromInt32(v1 + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 192 + uintptr(j1)*2))))
  33804 		v4 = libc.Int32FromUint32((coeff0*iQ1 + B1) >> libc.Int32FromInt32(QFIX))
  33805 		goto _16
  33806 	_16:
  33807 		level0 = v4
  33808 		v6 = libc.Int32FromUint32((coeff0*iQ1 + libc.Uint32FromInt32(libc.Int32FromInt32(0x80)<<(libc.Int32FromInt32(QFIX)-libc.Int32FromInt32(8)))) >> libc.Int32FromInt32(QFIX))
  33809 		goto _18
  33810 	_18:
  33811 		thresh_level = v6
  33812 		if thresh_level > int32(MAX_LEVEL) {
  33813 			thresh_level = int32(MAX_LEVEL)
  33814 		}
  33815 		if level0 > int32(MAX_LEVEL) {
  33816 			level0 = int32(MAX_LEVEL)
  33817 		}
  33818 		// Swap current and previous score states
  33819 		tmp = ss_cur
  33820 		ss_cur = ss_prev
  33821 		ss_prev = tmp
  33822 		// test all alternate level values around level0.
  33823 		m = -MIN_DELTA
  33824 		for {
  33825 			if !(m <= int32(MAX_DELTA)) {
  33826 				break
  33827 			}
  33828 			cur = bp + uintptr(n1)*8 + uintptr(m+MIN_DELTA)*4
  33829 			level1 = level0 + m
  33830 			if level1 > int32(2) {
  33831 				v1 = int32(2)
  33832 			} else {
  33833 				v1 = level1
  33834 			}
  33835 			ctx = v1
  33836 			band = libc.Int32FromUint8(VP8EncBands[n1+int32(1)])
  33837 			(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fcosts = **(**uintptr)(__ccgo_up(costs + uintptr(n1+int32(1))*24 + uintptr(ctx)*8))
  33838 			if level1 < 0 || level1 > thresh_level {
  33839 				(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = libc.Int64FromInt64(0x7fffffffffffff)
  33840 				// Node is dead.
  33841 				goto _19
  33842 			}
  33843 			// Compute delta_error = how much coding this level will
  33844 			// subtract to max_error as distortion.
  33845 			// Here, distortion = sum of (|coeff_i| - level_i * Q_i)^2
  33846 			new_error = libc.Int32FromUint32(coeff0 - libc.Uint32FromInt32(level1)*Q)
  33847 			delta_error = libc.Int32FromUint32(uint32(kWeightTrellis[j1]) * (libc.Uint32FromInt32(new_error*new_error) - coeff0*coeff0))
  33848 			base_score = RDScoreTrellis(tls, lambda, 0, int64(delta_error))
  33849 			// Inspect all possible non-dead predecessors. Retain only the best one.
  33850 			// The base_score is added to all scores so it is only added for the final
  33851 			// value after the loop.
  33852 			v1 = level1
  33853 			if v1 > int32(MAX_VARIABLE_LEVEL) {
  33854 				v6 = int32(MAX_VARIABLE_LEVEL)
  33855 			} else {
  33856 				v6 = v1
  33857 			}
  33858 			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)))
  33859 			goto _23
  33860 		_23:
  33861 			cost1 = int64(v4)
  33862 			best_cur_score = (**(**ScoreState)(__ccgo_up(ss_prev + uintptr(-libc.Int32FromInt32(MIN_DELTA))*16))).Fscore + RDScoreTrellis(tls, lambda, cost1, 0)
  33863 			best_prev = -MIN_DELTA
  33864 			p = -libc.Int32FromInt32(MIN_DELTA) + libc.Int32FromInt32(1)
  33865 			for {
  33866 				if !(p <= int32(MAX_DELTA)) {
  33867 					break
  33868 				}
  33869 				// Dead nodes (with ss_prev[p].score >= MAX_COST) are automatically
  33870 				// eliminated since their score can't be better than the current best.
  33871 				v1 = level1
  33872 				if v1 > int32(MAX_VARIABLE_LEVEL) {
  33873 					v6 = int32(MAX_VARIABLE_LEVEL)
  33874 				} else {
  33875 					v6 = v1
  33876 				}
  33877 				v4 = libc.Int32FromUint16(VP8LevelFixedCosts[v1]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((**(**ScoreState)(__ccgo_up(ss_prev + uintptr(p)*16))).Fcosts + uintptr(v6)*2)))
  33878 				goto _28
  33879 			_28:
  33880 				cost1 = int64(v4)
  33881 				// Examine node assuming it's a non-terminal one.
  33882 				score = (**(**ScoreState)(__ccgo_up(ss_prev + uintptr(p)*16))).Fscore + RDScoreTrellis(tls, lambda, cost1, 0)
  33883 				if score < best_cur_score {
  33884 					best_cur_score = score
  33885 					best_prev = p
  33886 				}
  33887 				goto _25
  33888 			_25:
  33889 				;
  33890 				p = p + 1
  33891 			}
  33892 			best_cur_score = best_cur_score + base_score
  33893 			// Store best finding in current node.
  33894 			(*Node)(unsafe.Pointer(cur)).Fsign = int8(sign)
  33895 			(*Node)(unsafe.Pointer(cur)).Flevel = int16(level1)
  33896 			(*Node)(unsafe.Pointer(cur)).Fprev = int8(best_prev)
  33897 			(**(**ScoreState)(__ccgo_up(ss_cur + uintptr(m)*16))).Fscore = best_cur_score
  33898 			// Now, record best terminal node (and thus best entry in the graph).
  33899 			if level1 != 0 && best_cur_score < best_score {
  33900 				if n1 < int32(15) {
  33901 					v3 = **(**uint8_t)(__ccgo_up(probas + uintptr(band)*33 + uintptr(ctx)*11))
  33902 					if !(0 != 0) {
  33903 						v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  33904 					} else {
  33905 						v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  33906 					}
  33907 					v4 = v6
  33908 					goto _33
  33909 				_33:
  33910 					v1 = v4
  33911 				} else {
  33912 					v1 = 0
  33913 				}
  33914 				last_pos_cost = int64(v1)
  33915 				last_pos_score = RDScoreTrellis(tls, lambda, last_pos_cost, 0)
  33916 				score = best_cur_score + last_pos_score
  33917 				if score < best_score {
  33918 					best_score = score
  33919 					best_path[0] = n1               // best eob position
  33920 					best_path[int32(1)] = m         // best node index
  33921 					best_path[int32(2)] = best_prev // best predecessor
  33922 				}
  33923 			}
  33924 			goto _19
  33925 		_19:
  33926 			;
  33927 			m = m + 1
  33928 		}
  33929 		goto _13
  33930 	_13:
  33931 		;
  33932 		n1 = n1 + 1
  33933 	}
  33934 	// Fresh start
  33935 	// Beware! We must preserve in[0]/out[0] value for TYPE_I16_AC case.
  33936 	if coeff_type == int32(TYPE_I16_AC) {
  33937 		libc.X__builtin___memset_chk(tls, in+uintptr(1)*2, 0, libc.Uint64FromInt32(15)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33938 		libc.X__builtin___memset_chk(tls, out+uintptr(1)*2, 0, libc.Uint64FromInt32(15)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33939 	} else {
  33940 		libc.X__builtin___memset_chk(tls, in, 0, libc.Uint64FromInt32(16)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33941 		libc.X__builtin___memset_chk(tls, out, 0, libc.Uint64FromInt32(16)*libc.Uint64FromInt64(2), ^__predefined_size_t(0))
  33942 	}
  33943 	if best_path[0] == -int32(1) {
  33944 		return 0 // skip!
  33945 	}
  33946 	// Unwind the best path.
  33947 	// Note: best-prev on terminal node is not necessarily equal to the
  33948 	// best_prev for non-terminal. So we patch best_path[2] in.
  33949 	nz = 0
  33950 	best_node = best_path[int32(1)]
  33951 	n1 = best_path[0]
  33952 	(**(**Node)(__ccgo_up(bp + uintptr(n1)*8 + uintptr(best_node+MIN_DELTA)*4))).Fprev = int8(best_path[int32(2)]) // force best-prev for terminal
  33953 	for {
  33954 		if !(n1 >= first) {
  33955 			break
  33956 		}
  33957 		node = bp + uintptr(n1)*8 + uintptr(best_node+MIN_DELTA)*4
  33958 		j2 = libc.Int32FromUint8(kZigzag1[n1])
  33959 		if (*Node)(unsafe.Pointer(node)).Fsign != 0 {
  33960 			v1 = -int32((*Node)(unsafe.Pointer(node)).Flevel)
  33961 		} else {
  33962 			v1 = int32((*Node)(unsafe.Pointer(node)).Flevel)
  33963 		}
  33964 		**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = int16(v1)
  33965 		nz = nz | int32((*Node)(unsafe.Pointer(node)).Flevel)
  33966 		**(**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))))
  33967 		best_node = int32((*Node)(unsafe.Pointer(node)).Fprev)
  33968 		goto _35
  33969 	_35:
  33970 		;
  33971 		n1 = n1 - 1
  33972 	}
  33973 	return libc.BoolInt32(nz != 0)
  33974 	return r
  33975 }
  33976 
  33977 //------------------------------------------------------------------------------
  33978 // Performs: difference, transform, quantize, back-transform, add
  33979 // all at once. Output is the reconstructed block in *yuv_out, and the
  33980 // quantized levels in *levels.
  33981 
  33982 func ReconstructIntra16(tls *libc.TLS, it uintptr, rd uintptr, yuv_out uintptr, mode int32) (r int32) {
  33983 	bp := tls.Alloc(544)
  33984 	defer tls.Free(544)
  33985 	var ctx, n, non_zero, nz, x, y, v4 int32
  33986 	var dqm, enc, ref, src uintptr
  33987 	var v6 int16_t
  33988 	var _ /* dc_tmp at bp+512 */ [16]int16_t
  33989 	var _ /* tmp at bp+0 */ [16][16]int16_t
  33990 	_, _, _, _, _, _, _, _, _, _, _, _ = ctx, dqm, enc, n, non_zero, nz, ref, src, x, y, v4, v6
  33991 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  33992 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I16ModeOffsets[mode])
  33993 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  33994 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  33995 	nz = 0
  33996 	n = 0
  33997 	for {
  33998 		if !(n < int32(16)) {
  33999 			break
  34000 		}
  34001 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform2})))(tls, src+uintptr(VP8Scan[n]), ref+uintptr(VP8Scan[n]), bp+uintptr(n)*32)
  34002 		goto _1
  34003 	_1:
  34004 		;
  34005 		n = n + int32(2)
  34006 	}
  34007 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransformWHT})))(tls, bp, bp+512)
  34008 	nz = nz | (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlockWHT})))(tls, bp+512, rd+40, dqm+224)<<int32(24)
  34009 	if libc.Bool(int32(DO_TRELLIS_I16) != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34010 		VP8IteratorNzToBytes(tls, it)
  34011 		y = 0
  34012 		n = libc.Int32FromInt32(0)
  34013 		for {
  34014 			if !(y < int32(4)) {
  34015 				break
  34016 			}
  34017 			x = 0
  34018 			for {
  34019 				if !(x < int32(4)) {
  34020 					break
  34021 				}
  34022 				ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  34023 				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)
  34024 				v4 = non_zero
  34025 				**(**int32)(__ccgo_up(it + 168 + uintptr(y)*4)) = v4
  34026 				**(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) = v4
  34027 				**(**int16_t)(__ccgo_up(rd + 72 + uintptr(n)*32)) = 0
  34028 				nz = nz | non_zero<<n
  34029 				goto _3
  34030 			_3:
  34031 				;
  34032 				x = x + 1
  34033 				n = n + 1
  34034 			}
  34035 			goto _2
  34036 		_2:
  34037 			;
  34038 			y = y + 1
  34039 		}
  34040 	} else {
  34041 		n = 0
  34042 		for {
  34043 			if !(n < int32(16)) {
  34044 				break
  34045 			}
  34046 			// Zero-out the first coeff, so that: a) nz is correct below, and
  34047 			// b) finding 'last' non-zero coeffs in SetResidualCoeffs() is simplified.
  34048 			v6 = libc.Int16FromInt32(0)
  34049 			**(**int16_t)(__ccgo_up(bp + uintptr(n+int32(1))*32)) = v6
  34050 			**(**int16_t)(__ccgo_up(bp + uintptr(n)*32)) = v6
  34051 			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
  34052 			goto _5
  34053 		_5:
  34054 			;
  34055 			n = n + int32(2)
  34056 		}
  34057 	}
  34058 	// Transform back
  34059 	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformWHT})))(tls, bp+512, bp)
  34060 	n = 0
  34061 	for {
  34062 		if !(n < int32(16)) {
  34063 			break
  34064 		}
  34065 		(*(*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))
  34066 		goto _7
  34067 	_7:
  34068 		;
  34069 		n = n + int32(2)
  34070 	}
  34071 	return nz
  34072 }
  34073 
  34074 func ReconstructIntra4(tls *libc.TLS, it uintptr, levels uintptr, src uintptr, yuv_out uintptr, mode int32) (r int32) {
  34075 	bp := tls.Alloc(32)
  34076 	defer tls.Free(32)
  34077 	var ctx, nz, x, y int32
  34078 	var dqm, enc, ref uintptr
  34079 	var _ /* tmp at bp+0 */ [16]int16_t
  34080 	_, _, _, _, _, _, _ = ctx, dqm, enc, nz, ref, x, y
  34081 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34082 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I4ModeOffsets[mode])
  34083 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34084 	nz = 0
  34085 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src, ref, bp)
  34086 	if libc.Bool(int32(DO_TRELLIS_I4) != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34087 		x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & int32(3)
  34088 		y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> int32(2)
  34089 		ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(y)*4))
  34090 		nz = TrellisQuantizeBlock(tls, enc, bp, levels, ctx, int32(TYPE_I4_AC), dqm, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_trellis_i4)
  34091 	} else {
  34092 		nz = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8EncQuantizeBlock})))(tls, bp, levels, dqm)
  34093 	}
  34094 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8ITransform})))(tls, ref, bp, yuv_out, 0)
  34095 	return nz
  34096 }
  34097 
  34098 //------------------------------------------------------------------------------
  34099 // DC-error diffusion
  34100 
  34101 // Diffusion weights. We under-correct a bit (15/16th of the error is actually
  34102 // diffused) to avoid 'rainbow' chessboard pattern of blocks at q~=0.
  34103 
  34104 // C documentation
  34105 //
  34106 //	// Quantize as usual, but also compute and return the quantization error.
  34107 //	// Error is already divided by DSHIFT.
  34108 func QuantizeSingle(tls *libc.TLS, v uintptr, mtx uintptr) (r int32) {
  34109 	var V, err, qV, sign, v1, v3 int32
  34110 	_, _, _, _, _, _ = V, err, qV, sign, v1, v3
  34111 	V = int32(**(**int16_t)(__ccgo_up(v)))
  34112 	sign = libc.BoolInt32(V < libc.Int32FromInt32(0))
  34113 	if sign != 0 {
  34114 		V = -V
  34115 	}
  34116 	if V > libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(mtx + 128))) {
  34117 		v1 = libc.Int32FromUint32((libc.Uint32FromInt32(V)*uint32(**(**uint16_t)(__ccgo_up(mtx + 32))) + **(**uint32_t)(__ccgo_up(mtx + 64))) >> libc.Int32FromInt32(QFIX))
  34118 		goto _2
  34119 	_2:
  34120 		qV = v1 * libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx)))
  34121 		err = V - qV
  34122 		if sign != 0 {
  34123 			v3 = -qV
  34124 		} else {
  34125 			v3 = qV
  34126 		}
  34127 		**(**int16_t)(__ccgo_up(v)) = int16(v3)
  34128 		if sign != 0 {
  34129 			v1 = -err
  34130 		} else {
  34131 			v1 = err
  34132 		}
  34133 		return v1 >> int32(1)
  34134 	}
  34135 	**(**int16_t)(__ccgo_up(v)) = 0
  34136 	if sign != 0 {
  34137 		v1 = -V
  34138 	} else {
  34139 		v1 = V
  34140 	}
  34141 	return v1 >> int32(1)
  34142 }
  34143 
  34144 func CorrectDCValues(tls *libc.TLS, it uintptr, mtx uintptr, tmp uintptr, rd uintptr) {
  34145 	var c, left, top, v2 uintptr
  34146 	var ch, err0, err1, err2, err3 int32
  34147 	_, _, _, _, _, _, _, _, _ = c, ch, err0, err1, err2, err3, left, top, v2
  34148 	ch = 0
  34149 	for {
  34150 		if !(ch <= int32(1)) {
  34151 			break
  34152 		}
  34153 		top = (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx)*4 + uintptr(ch)*2
  34154 		left = it + 344 + uintptr(ch)*2
  34155 		c = tmp + uintptr(ch*int32(4))*32
  34156 		v2 = c
  34157 		*(*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)))
  34158 		err0 = QuantizeSingle(tls, c, mtx)
  34159 		v2 = c + 1*32
  34160 		*(*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)))
  34161 		err1 = QuantizeSingle(tls, c+1*32, mtx)
  34162 		v2 = c + 2*32
  34163 		*(*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)))
  34164 		err2 = QuantizeSingle(tls, c+2*32, mtx)
  34165 		v2 = c + 3*32
  34166 		*(*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)))
  34167 		err3 = QuantizeSingle(tls, c+3*32, mtx)
  34168 		// error 'err' is bounded by mtx->q[0] which is 132 at max. Hence
  34169 		// err >> DSCALE will fit in an int8_t type if DSCALE>=1.
  34170 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3)) = int8(err1)
  34171 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 1)) = int8(err2)
  34172 		**(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 2)) = int8(err3)
  34173 		goto _1
  34174 	_1:
  34175 		;
  34176 		ch = ch + 1
  34177 	}
  34178 }
  34179 
  34180 func StoreDiffusionErrors(tls *libc.TLS, it uintptr, rd uintptr) {
  34181 	var ch int32
  34182 	var left, top uintptr
  34183 	_, _, _ = ch, left, top
  34184 	ch = 0
  34185 	for {
  34186 		if !(ch <= int32(1)) {
  34187 			break
  34188 		}
  34189 		top = (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fx)*4 + uintptr(ch)*2
  34190 		left = it + 344 + uintptr(ch)*2
  34191 		**(**int8_t)(__ccgo_up(left)) = **(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3))                                                                // restore err1
  34192 		**(**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
  34193 		**(**int8_t)(__ccgo_up(top)) = **(**int8_t)(__ccgo_up(rd + 868 + uintptr(ch)*3 + 1))                                                             //     ... err2
  34194 		**(**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.
  34195 		goto _1
  34196 	_1:
  34197 		;
  34198 		ch = ch + 1
  34199 	}
  34200 }
  34201 
  34202 //------------------------------------------------------------------------------
  34203 
  34204 func ReconstructUV(tls *libc.TLS, it uintptr, rd uintptr, yuv_out uintptr, mode int32) (r int32) {
  34205 	bp := tls.Alloc(256)
  34206 	defer tls.Free(256)
  34207 	var ch, ctx, n, non_zero, nz, x, y, v5 int32
  34208 	var dqm, enc, ref, src uintptr
  34209 	var _ /* tmp at bp+0 */ [8][16]int16_t
  34210 	_, _, _, _, _, _, _, _, _, _, _, _ = ch, ctx, dqm, enc, n, non_zero, nz, ref, src, x, y, v5
  34211 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34212 	ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8UVModeOffsets[mode])
  34213 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34214 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34215 	nz = 0
  34216 	n = 0
  34217 	for {
  34218 		if !(n < int32(8)) {
  34219 			break
  34220 		}
  34221 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform2})))(tls, src+uintptr(VP8ScanUV[n]), ref+uintptr(VP8ScanUV[n]), bp+uintptr(n)*32)
  34222 		goto _1
  34223 	_1:
  34224 		;
  34225 		n = n + int32(2)
  34226 	}
  34227 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  34228 		CorrectDCValues(tls, it, dqm+448, bp, rd)
  34229 	}
  34230 	if libc.Bool(DO_TRELLIS_UV != 0) && (*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis != 0 {
  34231 		ch = 0
  34232 		n = libc.Int32FromInt32(0)
  34233 		for {
  34234 			if !(ch <= int32(2)) {
  34235 				break
  34236 			}
  34237 			y = 0
  34238 			for {
  34239 				if !(y < int32(2)) {
  34240 					break
  34241 				}
  34242 				x = 0
  34243 				for {
  34244 					if !(x < int32(2)) {
  34245 						break
  34246 					}
  34247 					ctx = **(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) + **(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4))
  34248 					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)
  34249 					v5 = non_zero
  34250 					**(**int32)(__ccgo_up(it + 168 + uintptr(int32(4)+ch+y)*4)) = v5
  34251 					**(**int32)(__ccgo_up(it + 132 + uintptr(int32(4)+ch+x)*4)) = v5
  34252 					nz = nz | non_zero<<n
  34253 					goto _4
  34254 				_4:
  34255 					;
  34256 					x = x + 1
  34257 					n = n + 1
  34258 				}
  34259 				goto _3
  34260 			_3:
  34261 				;
  34262 				y = y + 1
  34263 			}
  34264 			goto _2
  34265 		_2:
  34266 			;
  34267 			ch = ch + int32(2)
  34268 		}
  34269 	} else {
  34270 		n = 0
  34271 		for {
  34272 			if !(n < int32(8)) {
  34273 				break
  34274 			}
  34275 			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
  34276 			goto _6
  34277 		_6:
  34278 			;
  34279 			n = n + int32(2)
  34280 		}
  34281 	}
  34282 	n = 0
  34283 	for {
  34284 		if !(n < int32(8)) {
  34285 			break
  34286 		}
  34287 		(*(*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))
  34288 		goto _7
  34289 	_7:
  34290 		;
  34291 		n = n + int32(2)
  34292 	}
  34293 	return nz << int32(16)
  34294 }
  34295 
  34296 //------------------------------------------------------------------------------
  34297 // RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost.
  34298 // Pick the mode is lower RD-cost = Rate + lambda * Distortion.
  34299 
  34300 func StoreMaxDelta(tls *libc.TLS, dqm uintptr, DCs uintptr) {
  34301 	var max_v, v0, v1, v2, v11, v21 int32
  34302 	_, _, _, _, _, _ = max_v, v0, v1, v2, v11, v21
  34303 	// We look at the first three AC coefficients to determine what is the average
  34304 	// delta between each sub-4x4 block.
  34305 	v0 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 1*2))))
  34306 	v1 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 2*2))))
  34307 	v2 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up(DCs + 4*2))))
  34308 	if v1 > v0 {
  34309 		v11 = v1
  34310 	} else {
  34311 		v11 = v0
  34312 	}
  34313 	max_v = v11
  34314 	if v2 > max_v {
  34315 		v21 = v2
  34316 	} else {
  34317 		v21 = max_v
  34318 	}
  34319 	max_v = v21
  34320 	if max_v > (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge {
  34321 		(*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmax_edge = max_v
  34322 	}
  34323 }
  34324 
  34325 func SwapModeScore(tls *libc.TLS, a uintptr, b uintptr) {
  34326 	var tmp uintptr
  34327 	_ = tmp
  34328 	tmp = **(**uintptr)(__ccgo_up(a))
  34329 	**(**uintptr)(__ccgo_up(a)) = **(**uintptr)(__ccgo_up(b))
  34330 	**(**uintptr)(__ccgo_up(b)) = tmp
  34331 }
  34332 
  34333 func SwapPtr(tls *libc.TLS, a uintptr, b uintptr) {
  34334 	var tmp uintptr
  34335 	_ = tmp
  34336 	tmp = **(**uintptr)(__ccgo_up(a))
  34337 	**(**uintptr)(__ccgo_up(a)) = **(**uintptr)(__ccgo_up(b))
  34338 	**(**uintptr)(__ccgo_up(b)) = tmp
  34339 }
  34340 
  34341 func SwapOut(tls *libc.TLS, it uintptr) {
  34342 	SwapPtr(tls, it+16, it+24)
  34343 }
  34344 
  34345 func PickBestIntra16(tls *libc.TLS, it uintptr, rd uintptr) {
  34346 	bp := tls.Alloc(912)
  34347 	defer tls.Free(912)
  34348 	var dqm, src1, tmp_dst, v1 uintptr
  34349 	var i, i1, is_flat, kNumBlocks, lambda, mode, score, tlambda, v3, v6, v8 int32
  34350 	var _ /* rd_best at bp+896 */ uintptr
  34351 	var _ /* rd_cur at bp+888 */ uintptr
  34352 	var _ /* rd_tmp at bp+8 */ VP8ModeScore
  34353 	var _ /* v at bp+0 */ uint32_t
  34354 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = dqm, i, i1, is_flat, kNumBlocks, lambda, mode, score, src1, tlambda, tmp_dst, v1, v3, v6, v8
  34355 	kNumBlocks = int32(16)
  34356 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34357 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_i16
  34358 	tlambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ftlambda
  34359 	src1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34360 	**(**uintptr)(__ccgo_up(bp + 888)) = bp + 8
  34361 	**(**uintptr)(__ccgo_up(bp + 896)) = rd
  34362 	v1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34363 	**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(v1))) * uint32(0x01010101)
  34364 	i1 = libc.Int32FromInt32(0)
  34365 	for {
  34366 		if !(i1 < libc.Int32FromInt32(16)) {
  34367 			break
  34368 		}
  34369 		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 {
  34370 			v3 = 0
  34371 			goto _4
  34372 		}
  34373 		v1 = v1 + uintptr(BPS)
  34374 		goto _2
  34375 	_2:
  34376 		;
  34377 		i1 = i1 + 1
  34378 	}
  34379 	v3 = int32(1)
  34380 	goto _4
  34381 _4:
  34382 	is_flat = v3
  34383 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_i16 = -int32(1)
  34384 	mode = 0
  34385 	for {
  34386 		if !(mode < int32(NUM_PRED_MODES)) {
  34387 			break
  34388 		}
  34389 		tmp_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) // scratch buffer
  34390 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fmode_i16 = mode
  34391 		// Reconstruct
  34392 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fnz = libc.Uint32FromInt32(ReconstructIntra16(tls, it, **(**uintptr)(__ccgo_up(bp + 888)), tmp_dst, mode))
  34393 		// Measure RD-score
  34394 		(*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))
  34395 		if tlambda != 0 {
  34396 			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)
  34397 		} else {
  34398 			v3 = 0
  34399 		}
  34400 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FSD = int64(v3)
  34401 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FH = libc.Int64FromUint16(VP8FixedCostsI16[mode])
  34402 		(*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).FR = int64(VP8GetCostLuma16(tls, it, **(**uintptr)(__ccgo_up(bp + 888))))
  34403 		if is_flat != 0 {
  34404 			// refine the first impression (which was in pixel space)
  34405 			v1 = **(**uintptr)(__ccgo_up(bp + 888)) + 72
  34406 			v3 = kNumBlocks
  34407 			score = 0
  34408 			for {
  34409 				v6 = v3
  34410 				v3 = v3 - 1
  34411 				if !(v6 > libc.Int32FromInt32(0)) {
  34412 					break
  34413 				}
  34414 				i = libc.Int32FromInt32(1)
  34415 				for {
  34416 					if !(i < libc.Int32FromInt32(16)) {
  34417 						break
  34418 					}
  34419 					score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v1 + uintptr(i)*2))) != 0)
  34420 					if score > FLATNESS_LIMIT_I16 {
  34421 						v8 = 0
  34422 						goto _12
  34423 					}
  34424 					goto _10
  34425 				_10:
  34426 					;
  34427 					i = i + 1
  34428 				}
  34429 				v1 = v1 + uintptr(16)*2
  34430 			}
  34431 			v8 = int32(1)
  34432 			goto _12
  34433 		_12:
  34434 			is_flat = v8
  34435 			if is_flat != 0 {
  34436 				// Block is very flat. We put emphasis on the distortion being very low!
  34437 				**(**score_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 888)))) *= int64(2)
  34438 				**(**score_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 888)) + 8)) *= int64(2)
  34439 			}
  34440 		}
  34441 		// Since we always examine Intra16 first, we can overwrite *rd directly.
  34442 		SetRDScore(tls, lambda, **(**uintptr)(__ccgo_up(bp + 888)))
  34443 		if mode == 0 || (*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 888)))).Fscore < (*VP8ModeScore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 896)))).Fscore {
  34444 			SwapModeScore(tls, bp+888, bp+896)
  34445 			SwapOut(tls, it)
  34446 		}
  34447 		goto _5
  34448 	_5:
  34449 		;
  34450 		mode = mode + 1
  34451 	}
  34452 	if **(**uintptr)(__ccgo_up(bp + 896)) != rd {
  34453 		libc.X__builtin___memcpy_chk(tls, rd, **(**uintptr)(__ccgo_up(bp + 896)), uint64(880), ^__predefined_size_t(0))
  34454 	}
  34455 	SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, rd) // finalize score for mode decision.
  34456 	VP8SetIntra16Mode(tls, it, (*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_i16)
  34457 	// we have a blocky macroblock (only DCs are non-zero) with fairly high
  34458 	// distortion, record max delta so we can later adjust the minimal filtering
  34459 	// strength needed to smooth these blocks out.
  34460 	if (*VP8ModeScore)(unsafe.Pointer(rd)).Fnz&uint32(0x100ffff) == uint32(0x1000000) && (*VP8ModeScore)(unsafe.Pointer(rd)).FD > int64((*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fmin_disto) {
  34461 		StoreMaxDelta(tls, dqm, rd+40)
  34462 	}
  34463 }
  34464 
  34465 //------------------------------------------------------------------------------
  34466 
  34467 // C documentation
  34468 //
  34469 //	// return the cost array corresponding to the surrounding prediction modes.
  34470 func GetCostModeI4(tls *libc.TLS, it uintptr, modes uintptr) (r uintptr) {
  34471 	var left, preds_w, top, x, y, v1, v2 int32
  34472 	_, _, _, _, _, _, _ = left, preds_w, top, x, y, v1, v2
  34473 	preds_w = (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fpreds_w
  34474 	x = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 & libc.Int32FromInt32(3)
  34475 	y = (*VP8EncIterator)(unsafe.Pointer(it)).Fi4 >> int32(2)
  34476 	if x == 0 {
  34477 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds + uintptr(y*preds_w-int32(1)))))
  34478 	} else {
  34479 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(modes + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4-int32(1)))))
  34480 	}
  34481 	left = v1
  34482 	if y == 0 {
  34483 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8EncIterator)(unsafe.Pointer(it)).Fpreds + uintptr(-preds_w+x))))
  34484 	} else {
  34485 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(modes + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4-int32(4)))))
  34486 	}
  34487 	top = v2
  34488 	return uintptr(unsafe.Pointer(&VP8FixedCostsI4)) + uintptr(top)*200 + uintptr(left)*20
  34489 }
  34490 
  34491 func PickBestIntra4(tls *libc.TLS, it uintptr, rd uintptr) (r int32) {
  34492 	bp := tls.Alloc(2688)
  34493 	defer tls.Free(2688)
  34494 	var best_blocks, dqm, enc, mode_costs, src, src0, v3 uintptr
  34495 	var best_mode, i, kNumBlocks, lambda, mode, score, tlambda, total_header_bits, v2, v4, v5 int32
  34496 	var v9 bool
  34497 	var _ /* best_block at bp+1760 */ uintptr
  34498 	var _ /* rd_best at bp+0 */ VP8ModeScore
  34499 	var _ /* rd_i4 at bp+880 */ VP8ModeScore
  34500 	var _ /* rd_tmp at bp+1776 */ VP8ModeScore
  34501 	var _ /* tmp_dst at bp+1768 */ uintptr
  34502 	var _ /* tmp_levels at bp+2656 */ [16]int16_t
  34503 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = best_blocks, best_mode, dqm, enc, i, kNumBlocks, lambda, mode, mode_costs, score, src, src0, tlambda, total_header_bits, v2, v3, v4, v5, v9
  34504 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34505 	dqm = enc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34506 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_i4
  34507 	tlambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Ftlambda
  34508 	src0 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34509 	best_blocks = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34510 	total_header_bits = 0
  34511 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits == 0 {
  34512 		return 0
  34513 	}
  34514 	InitScore(tls, bp)
  34515 	(**(**VP8ModeScore)(__ccgo_up(bp))).FH = int64(211) // '211' is the value of VP8BitCost(0, 145)
  34516 	SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, bp)
  34517 	VP8IteratorStartI4(tls, it)
  34518 	for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, best_blocks) != 0 {
  34519 		kNumBlocks = int32(1)
  34520 		best_mode = -int32(1)
  34521 		src = src0 + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34522 		mode_costs = GetCostModeI4(tls, it, rd+844)
  34523 		**(**uintptr)(__ccgo_up(bp + 1760)) = best_blocks + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34524 		**(**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.
  34525 		InitScore(tls, bp+880)
  34526 		MakeIntra4Preds(tls, it)
  34527 		mode = 0
  34528 		for {
  34529 			if !(mode < int32(NUM_BMODES)) {
  34530 				break
  34531 			}
  34532 			// Reconstruct
  34533 			(**(**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)
  34534 			// Compute RD-score
  34535 			(**(**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))))
  34536 			if tlambda != 0 {
  34537 				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)
  34538 			} else {
  34539 				v2 = 0
  34540 			}
  34541 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FSD = int64(v2)
  34542 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FH = libc.Int64FromUint16(**(**uint16_t)(__ccgo_up(mode_costs + uintptr(mode)*2)))
  34543 			// Add flatness penalty, to avoid flat area to be mispredicted
  34544 			// by a complex mode.
  34545 			if v9 = mode > 0; v9 {
  34546 				v3 = bp + 2656
  34547 				v2 = kNumBlocks
  34548 				score = 0
  34549 				for {
  34550 					v4 = v2
  34551 					v2 = v2 - 1
  34552 					if !(v4 > libc.Int32FromInt32(0)) {
  34553 						break
  34554 					}
  34555 					i = libc.Int32FromInt32(1)
  34556 					for {
  34557 						if !(i < libc.Int32FromInt32(16)) {
  34558 							break
  34559 						}
  34560 						score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v3 + uintptr(i)*2))) != 0)
  34561 						if score > int32(FLATNESS_LIMIT_I4) {
  34562 							v5 = 0
  34563 							goto _8
  34564 						}
  34565 						goto _6
  34566 					_6:
  34567 						;
  34568 						i = i + 1
  34569 					}
  34570 					v3 = v3 + uintptr(16)*2
  34571 				}
  34572 				v5 = int32(1)
  34573 				goto _8
  34574 			_8:
  34575 			}
  34576 			if v9 && v5 != 0 {
  34577 				(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR = int64(int32(FLATNESS_PENALTY) * kNumBlocks)
  34578 			} else {
  34579 				(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR = 0
  34580 			}
  34581 			// early-out check
  34582 			SetRDScore(tls, lambda, bp+1776)
  34583 			if best_mode >= 0 && (**(**VP8ModeScore)(__ccgo_up(bp + 1776))).Fscore >= (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fscore {
  34584 				goto _1
  34585 			}
  34586 			// finish computing score
  34587 			(**(**VP8ModeScore)(__ccgo_up(bp + 1776))).FR += int64(VP8GetCostLuma4(tls, it, bp+2656))
  34588 			SetRDScore(tls, lambda, bp+1776)
  34589 			if best_mode < 0 || (**(**VP8ModeScore)(__ccgo_up(bp + 1776))).Fscore < (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fscore {
  34590 				CopyScore(tls, bp+880, bp+1776)
  34591 				best_mode = mode
  34592 				SwapPtr(tls, bp+1768, bp+1760)
  34593 				libc.X__builtin___memcpy_chk(tls, bp+72+uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4)*32, bp+2656, uint64(32), ^__predefined_size_t(0))
  34594 			}
  34595 			goto _1
  34596 		_1:
  34597 			;
  34598 			mode = mode + 1
  34599 		}
  34600 		SetRDScore(tls, (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_mode, bp+880)
  34601 		AddScore(tls, bp, bp+880)
  34602 		if (**(**VP8ModeScore)(__ccgo_up(bp))).Fscore >= (*VP8ModeScore)(unsafe.Pointer(rd)).Fscore {
  34603 			return 0
  34604 		}
  34605 		total_header_bits = total_header_bits + int32((**(**VP8ModeScore)(__ccgo_up(bp + 880))).FH) // <- equal to mode_costs[best_mode];
  34606 		if total_header_bits > (*VP8Encoder)(unsafe.Pointer(enc)).Fmax_i4_header_bits {
  34607 			return 0
  34608 		}
  34609 		// Copy selected samples if not in the right place already.
  34610 		if **(**uintptr)(__ccgo_up(bp + 1760)) != best_blocks+uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4]) {
  34611 			(*(*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]))
  34612 		}
  34613 		**(**uint8_t)(__ccgo_up(rd + 844 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4))) = libc.Uint8FromInt32(best_mode)
  34614 		if (**(**VP8ModeScore)(__ccgo_up(bp + 880))).Fnz != 0 {
  34615 			v4 = int32(1)
  34616 		} else {
  34617 			v4 = 0
  34618 		}
  34619 		v2 = v4
  34620 		**(**int32)(__ccgo_up(it + 168 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4>>int32(2))*4)) = v2
  34621 		**(**int32)(__ccgo_up(it + 132 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4&int32(3))*4)) = v2
  34622 	}
  34623 	// finalize state
  34624 	CopyScore(tls, rd, bp)
  34625 	VP8SetIntra4Mode(tls, it, rd+844)
  34626 	SwapOut(tls, it)
  34627 	libc.X__builtin___memcpy_chk(tls, rd+72, bp+72, uint64(512), ^__predefined_size_t(0))
  34628 	return int32(1) // select intra4x4 over intra16x16
  34629 }
  34630 
  34631 //------------------------------------------------------------------------------
  34632 
  34633 func PickBestUV(tls *libc.TLS, it uintptr, rd uintptr) {
  34634 	bp := tls.Alloc(1776)
  34635 	defer tls.Free(1776)
  34636 	var dqm, dst0, src, v2 uintptr
  34637 	var i, kNumBlocks, lambda, mode, score, v3, v4, v6 int32
  34638 	var v8 bool
  34639 	var _ /* dst at bp+8 */ uintptr
  34640 	var _ /* rd_best at bp+16 */ VP8ModeScore
  34641 	var _ /* rd_uv at bp+896 */ VP8ModeScore
  34642 	var _ /* tmp_dst at bp+0 */ uintptr
  34643 	_, _, _, _, _, _, _, _, _, _, _, _, _ = dqm, dst0, i, kNumBlocks, lambda, mode, score, src, v2, v3, v4, v6, v8
  34644 	kNumBlocks = int32(8)
  34645 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34646 	lambda = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Flambda_uv
  34647 	src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34648 	**(**uintptr)(__ccgo_up(bp)) = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(U_OFF_ENC)) // scratch buffer
  34649 	dst0 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34650 	**(**uintptr)(__ccgo_up(bp + 8)) = dst0
  34651 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv = -int32(1)
  34652 	InitScore(tls, bp+16)
  34653 	mode = 0
  34654 	for {
  34655 		if !(mode < int32(NUM_PRED_MODES)) {
  34656 			break
  34657 		}
  34658 		// Reconstruct
  34659 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).Fnz = libc.Uint32FromInt32(ReconstructUV(tls, it, bp+896, **(**uintptr)(__ccgo_up(bp)), mode))
  34660 		// Compute RD-score
  34661 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FD = int64((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{VP8SSE16x8})))(tls, src, **(**uintptr)(__ccgo_up(bp))))
  34662 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FSD = 0 // not calling TDisto here: it tends to flatten areas.
  34663 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FH = libc.Int64FromUint16(VP8FixedCostsUV[mode])
  34664 		(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FR = int64(VP8GetCostUV(tls, it, bp+896))
  34665 		if v8 = mode > 0; v8 {
  34666 			v2 = bp + 896 + 584
  34667 			v3 = kNumBlocks
  34668 			score = 0
  34669 			for {
  34670 				v4 = v3
  34671 				v3 = v3 - 1
  34672 				if !(v4 > libc.Int32FromInt32(0)) {
  34673 					break
  34674 				}
  34675 				i = libc.Int32FromInt32(1)
  34676 				for {
  34677 					if !(i < libc.Int32FromInt32(16)) {
  34678 						break
  34679 					}
  34680 					score = score + libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(v2 + uintptr(i)*2))) != 0)
  34681 					if score > int32(FLATNESS_LIMIT_UV) {
  34682 						v6 = 0
  34683 						goto _7
  34684 					}
  34685 					goto _5
  34686 				_5:
  34687 					;
  34688 					i = i + 1
  34689 				}
  34690 				v2 = v2 + uintptr(16)*2
  34691 			}
  34692 			v6 = int32(1)
  34693 			goto _7
  34694 		_7:
  34695 		}
  34696 		if v8 && v6 != 0 {
  34697 			(**(**VP8ModeScore)(__ccgo_up(bp + 896))).FR += int64(int32(FLATNESS_PENALTY) * kNumBlocks)
  34698 		}
  34699 		SetRDScore(tls, lambda, bp+896)
  34700 		if mode == 0 || (**(**VP8ModeScore)(__ccgo_up(bp + 896))).Fscore < (**(**VP8ModeScore)(__ccgo_up(bp + 16))).Fscore {
  34701 			CopyScore(tls, bp+16, bp+896)
  34702 			(*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv = mode
  34703 			libc.X__builtin___memcpy_chk(tls, rd+584, bp+896+584, uint64(256), ^__predefined_size_t(0))
  34704 			if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) {
  34705 				libc.X__builtin___memcpy_chk(tls, rd+868, bp+896+868, uint64(6), ^__predefined_size_t(0))
  34706 			}
  34707 			SwapPtr(tls, bp+8, bp)
  34708 		}
  34709 		goto _1
  34710 	_1:
  34711 		;
  34712 		mode = mode + 1
  34713 	}
  34714 	VP8SetIntraUVMode(tls, it, (*VP8ModeScore)(unsafe.Pointer(rd)).Fmode_uv)
  34715 	AddScore(tls, rd, bp+16)
  34716 	if **(**uintptr)(__ccgo_up(bp + 8)) != dst0 { // copy 16x8 block if needed
  34717 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8Copy16x8})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), dst0)
  34718 	}
  34719 	if (*VP8EncIterator)(unsafe.Pointer(it)).Ftop_derr != libc.UintptrFromInt32(0) { // store diffusion errors for next block
  34720 		StoreDiffusionErrors(tls, it, rd)
  34721 	}
  34722 }
  34723 
  34724 //------------------------------------------------------------------------------
  34725 // Final reconstruction and quantization.
  34726 
  34727 func SimpleQuantize(tls *libc.TLS, it uintptr, rd uintptr) {
  34728 	var dst, enc, src uintptr
  34729 	var is_i16, mode, nz int32
  34730 	_, _, _, _, _, _ = dst, enc, is_i16, mode, nz, src
  34731 	enc = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc
  34732 	is_i16 = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == libc.Int32FromInt32(1))
  34733 	nz = 0
  34734 	if is_i16 != 0 {
  34735 		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))))
  34736 	} else {
  34737 		VP8IteratorStartI4(tls, it)
  34738 		for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out+uintptr(libc.Int32FromInt32(Y_OFF_ENC))) != 0 {
  34739 			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))))
  34740 			src = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34741 			dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34742 			MakeIntra4Preds(tls, it)
  34743 			nz = nz | ReconstructIntra4(tls, it, rd+72+uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4)*32, src, dst, mode)<<(*VP8EncIterator)(unsafe.Pointer(it)).Fi4
  34744 		}
  34745 	}
  34746 	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)))
  34747 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = libc.Uint32FromInt32(nz)
  34748 }
  34749 
  34750 // C documentation
  34751 //
  34752 //	// Refine intra16/intra4 sub-modes based on distortion only (not rate).
  34753 func RefineUsingDistortion(tls *libc.TLS, it uintptr, try_both_modes int32, refine_uv_mode int32, rd uintptr) {
  34754 	bp := tls.Alloc(16)
  34755 	defer tls.Free(16)
  34756 	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
  34757 	var best_i4_score, best_score, best_uv_score, bit_limit, i4_bit_sum, score, score1, score2, score_i4 score_t
  34758 	var dqm, mode_costs, ref, ref1, ref2, src1, src2, src3, tmp_dst, v3 uintptr
  34759 	var v1 int64
  34760 	var _ /* v at bp+0 */ uint32_t
  34761 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  34762 	best_score = libc.Int64FromInt64(0x7fffffffffffff)
  34763 	nz = 0
  34764 	is_i16 = libc.BoolInt32(try_both_modes != 0 || int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x3>>0)) == int32(1))
  34765 	dqm = (*VP8EncIterator)(unsafe.Pointer(it)).Fenc + 608 + uintptr(int32(uint32(*(*uint8)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fmb + 0))&0x60>>5)))*744
  34766 	// Some empiric constants, of approximate order of magnitude.
  34767 	lambda_d_i16 = int32(106)
  34768 	lambda_d_i4 = int32(11)
  34769 	lambda_d_uv = int32(120)
  34770 	score_i4 = (*VP8SegmentInfo)(unsafe.Pointer(dqm)).Fi4_penalty
  34771 	i4_bit_sum = 0
  34772 	if try_both_modes != 0 {
  34773 		v1 = int64((*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmb_header_limit)
  34774 	} else {
  34775 		v1 = libc.Int64FromInt64(0x7fffffffffffff)
  34776 	}
  34777 	bit_limit = v1   // no early-out allowed
  34778 	if is_i16 != 0 { // First, evaluate Intra16 distortion
  34779 		best_mode = -int32(1)
  34780 		src1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC))
  34781 		mode = 0
  34782 		for {
  34783 			if !(mode < int32(NUM_PRED_MODES)) {
  34784 				break
  34785 			}
  34786 			ref = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I16ModeOffsets[mode])
  34787 			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)
  34788 			if mode > 0 && libc.Int64FromUint16(VP8FixedCostsI16[mode]) > bit_limit {
  34789 				goto _2
  34790 			}
  34791 			if score < best_score {
  34792 				best_mode = mode
  34793 				best_score = score
  34794 			}
  34795 			goto _2
  34796 		_2:
  34797 			;
  34798 			mode = mode + 1
  34799 		}
  34800 		if (*VP8EncIterator)(unsafe.Pointer(it)).Fx == 0 || (*VP8EncIterator)(unsafe.Pointer(it)).Fy == 0 {
  34801 			// avoid starting a checkerboard resonance from the border. See bug #432.
  34802 			v3 = src1
  34803 			**(**uint32_t)(__ccgo_up(bp)) = uint32(**(**uint8_t)(__ccgo_up(v3))) * uint32(0x01010101)
  34804 			i = libc.Int32FromInt32(0)
  34805 			for {
  34806 				if !(i < libc.Int32FromInt32(16)) {
  34807 					break
  34808 				}
  34809 				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 {
  34810 					v5 = 0
  34811 					goto _6
  34812 				}
  34813 				v3 = v3 + uintptr(BPS)
  34814 				goto _4
  34815 			_4:
  34816 				;
  34817 				i = i + 1
  34818 			}
  34819 			v5 = int32(1)
  34820 			goto _6
  34821 		_6:
  34822 			if v5 != 0 {
  34823 				if (*VP8EncIterator)(unsafe.Pointer(it)).Fx == 0 {
  34824 					v7 = 0
  34825 				} else {
  34826 					v7 = int32(2)
  34827 				}
  34828 				best_mode = v7
  34829 				try_both_modes = 0 // stick to i16
  34830 			}
  34831 		}
  34832 		VP8SetIntra16Mode(tls, it, best_mode)
  34833 		// we'll reconstruct later, if i16 mode actually gets selected
  34834 	}
  34835 	// Next, evaluate Intra4
  34836 	if try_both_modes != 0 || !(is_i16 != 0) {
  34837 		// We don't evaluate the rate here, but just account for it through a
  34838 		// constant penalty (i4 mode usually needs more bits compared to i16).
  34839 		is_i16 = 0
  34840 		VP8IteratorStartI4(tls, it)
  34841 		for cond := true; cond; cond = VP8IteratorRotateI4(tls, it, (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2+uintptr(libc.Int32FromInt32(Y_OFF_ENC))) != 0 {
  34842 			best_i4_mode = -int32(1)
  34843 			best_i4_score = libc.Int64FromInt64(0x7fffffffffffff)
  34844 			src2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34845 			mode_costs = GetCostModeI4(tls, it, rd+844)
  34846 			MakeIntra4Preds(tls, it)
  34847 			mode = 0
  34848 			for {
  34849 				if !(mode < int32(NUM_BMODES)) {
  34850 					break
  34851 				}
  34852 				ref1 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8I4ModeOffsets[mode])
  34853 				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)
  34854 				if score1 < best_i4_score {
  34855 					best_i4_mode = mode
  34856 					best_i4_score = score1
  34857 				}
  34858 				goto _8
  34859 			_8:
  34860 				;
  34861 				mode = mode + 1
  34862 			}
  34863 			i4_bit_sum = i4_bit_sum + libc.Int64FromUint16(**(**uint16_t)(__ccgo_up(mode_costs + uintptr(best_i4_mode)*2)))
  34864 			**(**uint8_t)(__ccgo_up(rd + 844 + uintptr((*VP8EncIterator)(unsafe.Pointer(it)).Fi4))) = libc.Uint8FromInt32(best_i4_mode)
  34865 			score_i4 = score_i4 + best_i4_score
  34866 			if score_i4 >= best_score || i4_bit_sum > bit_limit {
  34867 				// Intra4 won't be better than Intra16. Bail out and pick Intra16.
  34868 				is_i16 = int32(1)
  34869 				break
  34870 			} else { // reconstruct partial block inside yuv_out2 buffer
  34871 				tmp_dst = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_out2 + uintptr(libc.Int32FromInt32(Y_OFF_ENC)) + uintptr(VP8Scan[(*VP8EncIterator)(unsafe.Pointer(it)).Fi4])
  34872 				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
  34873 			}
  34874 		}
  34875 	}
  34876 	// Final reconstruction, depending on which mode is selected.
  34877 	if !(is_i16 != 0) {
  34878 		VP8SetIntra4Mode(tls, it, rd+844)
  34879 		SwapOut(tls, it)
  34880 		best_score = score_i4
  34881 	} else {
  34882 		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))))
  34883 	}
  34884 	// ... and UV!
  34885 	if refine_uv_mode != 0 {
  34886 		best_mode1 = -int32(1)
  34887 		best_uv_score = libc.Int64FromInt64(0x7fffffffffffff)
  34888 		src3 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_in + uintptr(libc.Int32FromInt32(U_OFF_ENC))
  34889 		mode = 0
  34890 		for {
  34891 			if !(mode < int32(NUM_PRED_MODES)) {
  34892 				break
  34893 			}
  34894 			ref2 = (*VP8EncIterator)(unsafe.Pointer(it)).Fyuv_p + uintptr(VP8UVModeOffsets[mode])
  34895 			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)
  34896 			if score2 < best_uv_score {
  34897 				best_mode1 = mode
  34898 				best_uv_score = score2
  34899 			}
  34900 			goto _9
  34901 		_9:
  34902 			;
  34903 			mode = mode + 1
  34904 		}
  34905 		VP8SetIntraUVMode(tls, it, best_mode1)
  34906 	}
  34907 	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)))
  34908 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fnz = libc.Uint32FromInt32(nz)
  34909 	(*VP8ModeScore)(unsafe.Pointer(rd)).Fscore = best_score
  34910 }
  34911 
  34912 //------------------------------------------------------------------------------
  34913 // Entry point
  34914 
  34915 func VP8Decimate(tls *libc.TLS, it uintptr, rd uintptr, rd_opt VP8RDLevel) (r int32) {
  34916 	var is_skipped, method int32
  34917 	_, _ = is_skipped, method
  34918 	method = (*VP8Encoder)(unsafe.Pointer((*VP8EncIterator)(unsafe.Pointer(it)).Fenc)).Fmethod
  34919 	InitScore(tls, rd)
  34920 	// We can perform predictions for Luma16x16 and Chroma8x8 already.
  34921 	// Luma4x4 predictions needs to be done as-we-go.
  34922 	VP8MakeLuma16Preds(tls, it)
  34923 	VP8MakeChroma8Preds(tls, it)
  34924 	if rd_opt > int32(RD_OPT_NONE) {
  34925 		(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = libc.BoolInt32(rd_opt >= int32(RD_OPT_TRELLIS_ALL))
  34926 		PickBestIntra16(tls, it, rd)
  34927 		if method >= int32(2) {
  34928 			PickBestIntra4(tls, it, rd)
  34929 		}
  34930 		PickBestUV(tls, it, rd)
  34931 		if rd_opt == int32(RD_OPT_TRELLIS) { // finish off with trellis-optim now
  34932 			(*VP8EncIterator)(unsafe.Pointer(it)).Fdo_trellis = int32(1)
  34933 			SimpleQuantize(tls, it, rd)
  34934 		}
  34935 	} else {
  34936 		// At this point we have heuristically decided intra16 / intra4.
  34937 		// For method >= 2, pick the best intra4/intra16 based on SSE (~tad slower).
  34938 		// For method <= 1, we don't re-examine the decision but just go ahead with
  34939 		// quantization/reconstruction.
  34940 		RefineUsingDistortion(tls, it, libc.BoolInt32(method >= int32(2)), libc.BoolInt32(method >= int32(1)), rd)
  34941 	}
  34942 	is_skipped = libc.BoolInt32((*VP8ModeScore)(unsafe.Pointer(rd)).Fnz == uint32(0))
  34943 	VP8SetSkip(tls, it, is_skipped)
  34944 	return is_skipped
  34945 }
  34946 
  34947 const ARGB_BLACK2 = 0xff000000
  34948 const VP8_SIGNATURE1 = 10289450
  34949 const __FLT_MIN__8 = 1.17549435082228750796873653722224568e-38
  34950 
  34951 //------------------------------------------------------------------------------
  34952 // Helper functions
  34953 
  34954 func IsVP8XNeeded(tls *libc.TLS, enc uintptr) (r int32) {
  34955 	return libc.BoolInt32(!!((*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0)) // Currently the only case when VP8X is needed.
  34956 	// This could change in the future.
  34957 }
  34958 
  34959 func PutPaddingByte(tls *libc.TLS, pic uintptr) (r int32) {
  34960 	bp := tls.Alloc(16)
  34961 	defer tls.Free(16)
  34962 	var _ /* pad_byte at bp+0 */ [1]uint8_t
  34963 	**(**[1]uint8_t)(__ccgo_up(bp)) = [1]uint8_t{}
  34964 	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))
  34965 }
  34966 
  34967 //------------------------------------------------------------------------------
  34968 // Writers for header's various pieces (in order of appearance)
  34969 
  34970 func PutRIFFHeader(tls *libc.TLS, enc uintptr, riff_size size_t) (r WebPEncodingError1) {
  34971 	bp := tls.Alloc(16)
  34972 	defer tls.Free(16)
  34973 	var pic, v1, v3, v5 uintptr
  34974 	var v2 uint32_t
  34975 	var v4, v6 int32
  34976 	var _ /* riff at bp+0 */ [12]uint8_t
  34977 	_, _, _, _, _, _, _ = pic, v1, v2, v3, v4, v5, v6
  34978 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  34979 	**(**[12]uint8_t)(__ccgo_up(bp)) = [12]uint8_t{
  34980 		0:  uint8('R'),
  34981 		1:  uint8('I'),
  34982 		2:  uint8('F'),
  34983 		3:  uint8('F'),
  34984 		8:  uint8('W'),
  34985 		9:  uint8('E'),
  34986 		10: uint8('B'),
  34987 		11: uint8('P'),
  34988 	}
  34989 	v1 = bp + uintptr(TAG_SIZE)
  34990 	v2 = uint32(riff_size)
  34991 	v3 = v1
  34992 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  34993 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  34994 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  34995 	v5 = v1 + uintptr(2)
  34996 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  34997 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  34998 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  34999 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(12), pic) != 0) {
  35000 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35001 	}
  35002 	return int32(VP8_ENC_OK)
  35003 }
  35004 
  35005 func PutVP8XHeader(tls *libc.TLS, enc uintptr) (r WebPEncodingError1) {
  35006 	bp := tls.Alloc(32)
  35007 	defer tls.Free(32)
  35008 	var flags, v2 uint32_t
  35009 	var pic, v1, v3, v5 uintptr
  35010 	var v4, v6 int32
  35011 	var _ /* vp8x at bp+0 */ [18]uint8_t
  35012 	_, _, _, _, _, _, _, _ = flags, pic, v1, v2, v3, v4, v5, v6
  35013 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35014 	**(**[18]uint8_t)(__ccgo_up(bp)) = [18]uint8_t{
  35015 		0: uint8('V'),
  35016 		1: uint8('P'),
  35017 		2: uint8('8'),
  35018 		3: uint8('X'),
  35019 	}
  35020 	flags = uint32(0)
  35021 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  35022 		flags = flags | uint32(ALPHA_FLAG)
  35023 	}
  35024 	v1 = bp + uintptr(TAG_SIZE)
  35025 	v2 = uint32(VP8X_CHUNK_SIZE)
  35026 	v3 = v1
  35027 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35028 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35029 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35030 	v5 = v1 + uintptr(2)
  35031 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35032 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35033 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35034 	v1 = bp + uintptr(CHUNK_HEADER_SIZE)
  35035 	v2 = flags
  35036 	v3 = v1
  35037 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35038 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35039 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35040 	v5 = v1 + uintptr(2)
  35041 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35042 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35043 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35044 	v1 = bp + uintptr(CHUNK_HEADER_SIZE) + uintptr(4)
  35045 	v4 = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - int32(1)
  35046 	v3 = v1
  35047 	v6 = v4 & int32(0xffff)
  35048 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35049 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35050 	**(**uint8_t)(__ccgo_up(v1 + 2)) = libc.Uint8FromInt32(v4 >> int32(16) & int32(0xff))
  35051 	v1 = bp + uintptr(CHUNK_HEADER_SIZE) + uintptr(7)
  35052 	v4 = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - int32(1)
  35053 	v3 = v1
  35054 	v6 = v4 & int32(0xffff)
  35055 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35056 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35057 	**(**uint8_t)(__ccgo_up(v1 + 2)) = libc.Uint8FromInt32(v4 >> int32(16) & int32(0xff))
  35058 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(18), pic) != 0) {
  35059 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35060 	}
  35061 	return int32(VP8_ENC_OK)
  35062 }
  35063 
  35064 func PutAlphaChunk(tls *libc.TLS, enc uintptr) (r WebPEncodingError1) {
  35065 	bp := tls.Alloc(16)
  35066 	defer tls.Free(16)
  35067 	var pic, v1, v3, v5 uintptr
  35068 	var v2 uint32_t
  35069 	var v4, v6 int32
  35070 	var _ /* alpha_chunk_hdr at bp+0 */ [8]uint8_t
  35071 	_, _, _, _, _, _, _ = pic, v1, v2, v3, v4, v5, v6
  35072 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35073 	**(**[8]uint8_t)(__ccgo_up(bp)) = [8]uint8_t{
  35074 		0: uint8('A'),
  35075 		1: uint8('L'),
  35076 		2: uint8('P'),
  35077 		3: uint8('H'),
  35078 	}
  35079 	// Alpha chunk header.
  35080 	v1 = bp + uintptr(TAG_SIZE)
  35081 	v2 = (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size
  35082 	v3 = v1
  35083 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35084 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35085 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35086 	v5 = v1 + uintptr(2)
  35087 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35088 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35089 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35090 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(8), pic) != 0) {
  35091 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35092 	}
  35093 	// Alpha chunk data.
  35094 	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) {
  35095 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35096 	}
  35097 	// Padding.
  35098 	if (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size&uint32(1) != 0 && !(PutPaddingByte(tls, pic) != 0) {
  35099 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35100 	}
  35101 	return int32(VP8_ENC_OK)
  35102 }
  35103 
  35104 func PutVP8Header(tls *libc.TLS, pic uintptr, vp8_size size_t) (r WebPEncodingError1) {
  35105 	bp := tls.Alloc(16)
  35106 	defer tls.Free(16)
  35107 	var v1, v3, v5 uintptr
  35108 	var v2 uint32_t
  35109 	var v4, v6 int32
  35110 	var _ /* vp8_chunk_hdr at bp+0 */ [8]uint8_t
  35111 	_, _, _, _, _, _ = v1, v2, v3, v4, v5, v6
  35112 	**(**[8]uint8_t)(__ccgo_up(bp)) = [8]uint8_t{
  35113 		0: uint8('V'),
  35114 		1: uint8('P'),
  35115 		2: uint8('8'),
  35116 		3: uint8(' '),
  35117 	}
  35118 	v1 = bp + uintptr(TAG_SIZE)
  35119 	v2 = uint32(vp8_size)
  35120 	v3 = v1
  35121 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  35122 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  35123 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  35124 	v5 = v1 + uintptr(2)
  35125 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  35126 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  35127 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  35128 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(8), pic) != 0) {
  35129 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35130 	}
  35131 	return int32(VP8_ENC_OK)
  35132 }
  35133 
  35134 func PutVP8FrameHeader(tls *libc.TLS, pic uintptr, profile int32, size0 size_t) (r WebPEncodingError1) {
  35135 	bp := tls.Alloc(16)
  35136 	defer tls.Free(16)
  35137 	var bits uint32_t
  35138 	var _ /* vp8_frm_hdr at bp+0 */ [10]uint8_t
  35139 	_ = bits
  35140 	if size0 >= libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) { // partition #0 is too big to fit
  35141 		return int32(VP8_ENC_ERROR_PARTITION0_OVERFLOW)
  35142 	}
  35143 	// Paragraph 9.1.
  35144 	bits = libc.Uint32FromInt32(0|profile<<int32(1)|libc.Int32FromInt32(1)<<libc.Int32FromInt32(4)) | uint32(size0)<<libc.Int32FromInt32(5) // partition length (19b)
  35145 	(**(**[10]uint8_t)(__ccgo_up(bp)))[0] = uint8(bits >> libc.Int32FromInt32(0) & uint32(0xff))
  35146 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(1)] = uint8(bits >> libc.Int32FromInt32(8) & uint32(0xff))
  35147 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(2)] = uint8(bits >> libc.Int32FromInt32(16) & uint32(0xff))
  35148 	// signature
  35149 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(3)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(16) & libc.Int32FromInt32(0xff))
  35150 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(4)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(8) & libc.Int32FromInt32(0xff))
  35151 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(5)] = libc.Uint8FromInt32(libc.Int32FromInt32(VP8_SIGNATURE1) >> libc.Int32FromInt32(0) & libc.Int32FromInt32(0xff))
  35152 	// dimensions
  35153 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(6)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fwidth & int32(0xff))
  35154 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(7)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fwidth >> int32(8))
  35155 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(8)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fheight & int32(0xff))
  35156 	(**(**[10]uint8_t)(__ccgo_up(bp)))[int32(9)] = libc.Uint8FromInt32((*WebPPicture)(unsafe.Pointer(pic)).Fheight >> int32(8))
  35157 	if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(10), pic) != 0) {
  35158 		return int32(VP8_ENC_ERROR_BAD_WRITE)
  35159 	}
  35160 	return int32(VP8_ENC_OK)
  35161 }
  35162 
  35163 // C documentation
  35164 //
  35165 //	// WebP Headers.
  35166 func PutWebPHeaders(tls *libc.TLS, enc uintptr, size0 size_t, vp8_size size_t, riff_size size_t) (r int32) {
  35167 	var err WebPEncodingError1
  35168 	var pic uintptr
  35169 	_, _ = err, pic
  35170 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35171 	err = int32(VP8_ENC_OK)
  35172 	// RIFF header.
  35173 	err = PutRIFFHeader(tls, enc, riff_size)
  35174 	if err != int32(VP8_ENC_OK) {
  35175 		goto Error
  35176 	}
  35177 	// VP8X.
  35178 	if IsVP8XNeeded(tls, enc) != 0 {
  35179 		err = PutVP8XHeader(tls, enc)
  35180 		if err != int32(VP8_ENC_OK) {
  35181 			goto Error
  35182 		}
  35183 	}
  35184 	// Alpha.
  35185 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 {
  35186 		err = PutAlphaChunk(tls, enc)
  35187 		if err != int32(VP8_ENC_OK) {
  35188 			goto Error
  35189 		}
  35190 	}
  35191 	// VP8 header.
  35192 	err = PutVP8Header(tls, pic, vp8_size)
  35193 	if err != int32(VP8_ENC_OK) {
  35194 		goto Error
  35195 	}
  35196 	// VP8 frame header.
  35197 	err = PutVP8FrameHeader(tls, pic, (*VP8Encoder)(unsafe.Pointer(enc)).Fprofile, size0)
  35198 	if err != int32(VP8_ENC_OK) {
  35199 		goto Error
  35200 	}
  35201 	// All OK.
  35202 	return int32(1)
  35203 	// Error.
  35204 	goto Error
  35205 Error:
  35206 	;
  35207 	return WebPEncodingSetError(tls, pic, err)
  35208 	return r
  35209 }
  35210 
  35211 // C documentation
  35212 //
  35213 //	// Segmentation header
  35214 func PutSegmentHeader(tls *libc.TLS, bw uintptr, enc uintptr) {
  35215 	var hdr, proba uintptr
  35216 	var s, update_data int32
  35217 	_, _, _, _ = hdr, proba, s, update_data
  35218 	hdr = enc + 32
  35219 	proba = enc + 3616
  35220 	if VP8PutBitUniform(tls, bw, libc.BoolInt32((*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments > int32(1))) != 0 {
  35221 		// We always 'update' the quant and filter strength values
  35222 		update_data = int32(1)
  35223 		VP8PutBitUniform(tls, bw, (*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map)
  35224 		if VP8PutBitUniform(tls, bw, update_data) != 0 {
  35225 			// we always use absolute values, not relative ones
  35226 			VP8PutBitUniform(tls, bw, int32(1)) // (segment_feature_mode = 1. Paragraph 9.3.)
  35227 			s = 0
  35228 			for {
  35229 				if !(s < int32(NUM_MB_SEGMENTS)) {
  35230 					break
  35231 				}
  35232 				VP8PutSignedBits(tls, bw, (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Fquant, int32(7))
  35233 				goto _1
  35234 			_1:
  35235 				;
  35236 				s = s + 1
  35237 			}
  35238 			s = 0
  35239 			for {
  35240 				if !(s < int32(NUM_MB_SEGMENTS)) {
  35241 					break
  35242 				}
  35243 				VP8PutSignedBits(tls, bw, (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(s)*744))).Ffstrength, int32(6))
  35244 				goto _2
  35245 			_2:
  35246 				;
  35247 				s = s + 1
  35248 			}
  35249 		}
  35250 		if (*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map != 0 {
  35251 			s = 0
  35252 			for {
  35253 				if !(s < int32(3)) {
  35254 					break
  35255 				}
  35256 				if VP8PutBitUniform(tls, bw, libc.BoolInt32(uint32(**(**uint8_t)(__ccgo_up(proba + uintptr(s)))) != uint32(255))) != 0 {
  35257 					VP8PutBits(tls, bw, uint32(**(**uint8_t)(__ccgo_up(proba + uintptr(s)))), int32(8))
  35258 				}
  35259 				goto _3
  35260 			_3:
  35261 				;
  35262 				s = s + 1
  35263 			}
  35264 		}
  35265 	}
  35266 }
  35267 
  35268 // C documentation
  35269 //
  35270 //	// Filtering parameters header
  35271 func PutFilterHeader(tls *libc.TLS, bw uintptr, hdr uintptr) {
  35272 	var need_update, use_lf_delta int32
  35273 	_, _ = need_update, use_lf_delta
  35274 	use_lf_delta = libc.BoolInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta != libc.Int32FromInt32(0))
  35275 	VP8PutBitUniform(tls, bw, (*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsimple)
  35276 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Flevel), int32(6))
  35277 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsharpness), int32(3))
  35278 	if VP8PutBitUniform(tls, bw, use_lf_delta) != 0 {
  35279 		// '0' is the default value for i4x4_lf_delta at frame #0.
  35280 		need_update = libc.BoolInt32((*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta != libc.Int32FromInt32(0))
  35281 		if VP8PutBitUniform(tls, bw, need_update) != 0 {
  35282 			// we don't use ref_lf_delta => emit four 0 bits
  35283 			VP8PutBits(tls, bw, uint32(0), int32(4))
  35284 			// we use mode_lf_delta for i4x4
  35285 			VP8PutSignedBits(tls, bw, (*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta, int32(6))
  35286 			VP8PutBits(tls, bw, uint32(0), int32(3)) // all others unused
  35287 		}
  35288 	}
  35289 }
  35290 
  35291 // C documentation
  35292 //
  35293 //	// Nominal quantization parameters
  35294 func PutQuant(tls *libc.TLS, bw uintptr, enc uintptr) {
  35295 	VP8PutBits(tls, bw, libc.Uint32FromInt32((*VP8Encoder)(unsafe.Pointer(enc)).Fbase_quant), int32(7))
  35296 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y1_dc, int32(4))
  35297 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_dc, int32(4))
  35298 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_y2_ac, int32(4))
  35299 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_dc, int32(4))
  35300 	VP8PutSignedBits(tls, bw, (*VP8Encoder)(unsafe.Pointer(enc)).Fdq_uv_ac, int32(4))
  35301 }
  35302 
  35303 // C documentation
  35304 //
  35305 //	// Partition sizes
  35306 func EmitPartitionsSize(tls *libc.TLS, enc uintptr, pic uintptr) (r int32) {
  35307 	bp := tls.Alloc(32)
  35308 	defer tls.Free(32)
  35309 	var p int32
  35310 	var part_size, v2 size_t
  35311 	var _ /* buf at bp+0 */ [21]uint8_t
  35312 	_, _, _ = p, part_size, v2
  35313 	p = 0
  35314 	for {
  35315 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)) {
  35316 			break
  35317 		}
  35318 		v2 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35319 		goto _3
  35320 	_3:
  35321 		part_size = v2
  35322 		if part_size >= libc.Uint64FromInt32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(24)) {
  35323 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_PARTITION_OVERFLOW))
  35324 		}
  35325 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+0] = uint8(part_size >> libc.Int32FromInt32(0) & uint64(0xff))
  35326 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+int32(1)] = uint8(part_size >> libc.Int32FromInt32(8) & uint64(0xff))
  35327 		(**(**[21]uint8_t)(__ccgo_up(bp)))[int32(3)*p+int32(2)] = uint8(part_size >> libc.Int32FromInt32(16) & uint64(0xff))
  35328 		goto _1
  35329 	_1:
  35330 		;
  35331 		p = p + 1
  35332 	}
  35333 	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) {
  35334 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  35335 	}
  35336 	return int32(1)
  35337 }
  35338 
  35339 //------------------------------------------------------------------------------
  35340 
  35341 func GeneratePartition0(tls *libc.TLS, enc uintptr) (r int32) {
  35342 	var bw1, v1 uintptr
  35343 	var mb_size, v4, v5, v6 int32
  35344 	var nb_bits, pos1, pos2, pos3, v2 uint64_t
  35345 	_, _, _, _, _, _, _, _, _, _, _ = bw1, mb_size, nb_bits, pos1, pos2, pos3, v1, v2, v4, v5, v6
  35346 	bw1 = enc + 64
  35347 	mb_size = (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w * (*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h
  35348 	v1 = bw1
  35349 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35350 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35351 	goto _3
  35352 _3:
  35353 	pos1 = v2
  35354 	if !(VP8BitWriterInit(tls, bw1, libc.Uint64FromInt32(mb_size*int32(7)/int32(8))) != 0) { // ~7 bits per macroblock
  35355 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  35356 	}
  35357 	VP8PutBitUniform(tls, bw1, 0) // colorspace
  35358 	VP8PutBitUniform(tls, bw1, 0) // clamp type
  35359 	PutSegmentHeader(tls, bw1, enc)
  35360 	PutFilterHeader(tls, bw1, enc+16)
  35361 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(8) {
  35362 		v4 = int32(3)
  35363 	} else {
  35364 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(4) {
  35365 			v5 = int32(2)
  35366 		} else {
  35367 			if (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts == int32(2) {
  35368 				v6 = int32(1)
  35369 			} else {
  35370 				v6 = 0
  35371 			}
  35372 			v5 = v6
  35373 		}
  35374 		v4 = v5
  35375 	}
  35376 	VP8PutBits(tls, bw1, libc.Uint32FromInt32(v4), int32(2))
  35377 	PutQuant(tls, bw1, enc)
  35378 	VP8PutBitUniform(tls, bw1, 0) // no proba update
  35379 	VP8WriteProbas(tls, bw1, enc+3616)
  35380 	v1 = bw1
  35381 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35382 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35383 	goto _9
  35384 _9:
  35385 	pos2 = v2
  35386 	VP8CodeIntraModes(tls, enc)
  35387 	VP8BitWriterFinish(tls, bw1)
  35388 	v1 = bw1
  35389 	nb_bits = libc.Uint64FromInt32(int32(8) + (*VP8BitWriter)(unsafe.Pointer(v1)).Fnb_bits)
  35390 	v2 = uint64(((*VP8BitWriter)(unsafe.Pointer(v1)).Fpos+libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(v1)).Frun))*uint64(8)) + nb_bits
  35391 	goto _12
  35392 _12:
  35393 	pos3 = v2
  35394 	if (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats != 0 {
  35395 		**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats + 36)) = libc.Int32FromUint64((pos2 - pos1 + libc.Uint64FromInt32(7)) >> libc.Int32FromInt32(3))
  35396 		**(**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))
  35397 		(*WebPAuxStats)(unsafe.Pointer((*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats)).Falpha_data_size = libc.Int32FromUint32((*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size)
  35398 	}
  35399 	if (*VP8BitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  35400 		return WebPEncodingSetError(tls, (*VP8Encoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  35401 	}
  35402 	return int32(1)
  35403 }
  35404 
  35405 func VP8EncFreeBitWriters(tls *libc.TLS, enc uintptr) {
  35406 	var p int32
  35407 	_ = p
  35408 	VP8BitWriterWipeOut(tls, enc+64)
  35409 	p = 0
  35410 	for {
  35411 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35412 			break
  35413 		}
  35414 		VP8BitWriterWipeOut(tls, enc+112+uintptr(p)*48)
  35415 		goto _1
  35416 	_1:
  35417 		;
  35418 		p = p + 1
  35419 	}
  35420 }
  35421 
  35422 func VP8EncWrite(tls *libc.TLS, enc uintptr) (r int32) {
  35423 	var buf, bw2, part0, pic, v6 uintptr
  35424 	var final_percent, ok, p, percent_per_part, task_percent int32
  35425 	var pad, riff_size, size, size0, vp8_size, v1 size_t
  35426 	var padded_alpha_size uint32_t
  35427 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  35428 	pic = (*VP8Encoder)(unsafe.Pointer(enc)).Fpic
  35429 	bw2 = enc + 64
  35430 	task_percent = int32(19)
  35431 	percent_per_part = task_percent / (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts
  35432 	final_percent = (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent + task_percent
  35433 	ok = 0
  35434 	// Partition #0 with header and partition sizes
  35435 	ok = GeneratePartition0(tls, enc)
  35436 	if !(ok != 0) {
  35437 		return 0
  35438 	}
  35439 	// Compute VP8 size
  35440 	v1 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fpos
  35441 	goto _2
  35442 _2:
  35443 	vp8_size = uint64(VP8_FRAME_HEADER_SIZE) + v1 + libc.Uint64FromInt32(int32(3)*((*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts-int32(1)))
  35444 	p = 0
  35445 	for {
  35446 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35447 			break
  35448 		}
  35449 		v1 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35450 		goto _5
  35451 	_5:
  35452 		vp8_size = vp8_size + v1
  35453 		goto _3
  35454 	_3:
  35455 		;
  35456 		p = p + 1
  35457 	}
  35458 	pad = vp8_size & uint64(1)
  35459 	vp8_size = vp8_size + pad
  35460 	// Compute RIFF size
  35461 	// At the minimum it is: "WEBPVP8 nnnn" + VP8 data size.
  35462 	riff_size = libc.Uint64FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) + vp8_size
  35463 	if IsVP8XNeeded(tls, enc) != 0 { // Add size for: VP8X header + data.
  35464 		riff_size = riff_size + libc.Uint64FromInt32(libc.Int32FromInt32(CHUNK_HEADER_SIZE)+libc.Int32FromInt32(VP8X_CHUNK_SIZE))
  35465 	}
  35466 	if (*VP8Encoder)(unsafe.Pointer(enc)).Fhas_alpha != 0 { // Add size for: ALPH header + data.
  35467 		padded_alpha_size = (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size + (*VP8Encoder)(unsafe.Pointer(enc)).Falpha_data_size&uint32(1)
  35468 		riff_size = riff_size + uint64(uint32(CHUNK_HEADER_SIZE)+padded_alpha_size)
  35469 	}
  35470 	// RIFF size should fit in 32-bits.
  35471 	if riff_size > uint64(0xfffffffe) {
  35472 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_FILE_TOO_BIG))
  35473 	}
  35474 	// Emit headers and partition #0
  35475 	v6 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fbuf
  35476 	goto _7
  35477 _7:
  35478 	part0 = v6
  35479 	v1 = (*VP8BitWriter)(unsafe.Pointer(bw2)).Fpos
  35480 	goto _9
  35481 _9:
  35482 	size0 = v1
  35483 	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)
  35484 	VP8BitWriterWipeOut(tls, bw2) // will free the internal buffer.
  35485 	// Token partitions
  35486 	p = 0
  35487 	for {
  35488 		if !(p < (*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts) {
  35489 			break
  35490 		}
  35491 		v6 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fbuf
  35492 		goto _12
  35493 	_12:
  35494 		buf = v6
  35495 		v1 = (*VP8BitWriter)(unsafe.Pointer(enc + 112 + uintptr(p)*48)).Fpos
  35496 		goto _14
  35497 	_14:
  35498 		size = v1
  35499 		if size != 0 {
  35500 			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)
  35501 		}
  35502 		VP8BitWriterWipeOut(tls, enc+112+uintptr(p)*48) // will free the internal buffer.
  35503 		ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, pic, (*VP8Encoder)(unsafe.Pointer(enc)).Fpercent+percent_per_part, enc+536) != 0)
  35504 		goto _10
  35505 	_10:
  35506 		;
  35507 		p = p + 1
  35508 	}
  35509 	// Padding byte
  35510 	if ok != 0 && pad != 0 {
  35511 		ok = PutPaddingByte(tls, pic)
  35512 	}
  35513 	(*VP8Encoder)(unsafe.Pointer(enc)).Fcoded_size = libc.Int32FromUint64(libc.Uint64FromInt32(CHUNK_HEADER_SIZE) + riff_size)
  35514 	ok = libc.BoolInt32(ok != 0 && WebPReportProgress(tls, pic, final_percent, enc+536) != 0)
  35515 	if !(ok != 0) {
  35516 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  35517 	}
  35518 	return ok
  35519 }
  35520 
  35521 const MIN_PAGE_SIZE = 8192
  35522 
  35523 type VP8Tokens = struct {
  35524 	Fnext uintptr
  35525 }
  35526 
  35527 //------------------------------------------------------------------------------
  35528 
  35529 // Copyright 2011 Google Inc. All Rights Reserved.
  35530 //
  35531 // Use of this source code is governed by a BSD-style license
  35532 // that can be found in the COPYING file in the root of the source
  35533 // tree. An additional intellectual property rights grant can be found
  35534 // in the file PATENTS. All contributing project authors may
  35535 // be found in the AUTHORS file in the root of the source tree.
  35536 // -----------------------------------------------------------------------------
  35537 //
  35538 //   WebP encoder: internal header.
  35539 //
  35540 // Author: Skal (pascal.massimino@gmail.com)
  35541 
  35542 // Copyright 2011 Google Inc. All Rights Reserved.
  35543 //
  35544 // Use of this source code is governed by a BSD-style license
  35545 // that can be found in the COPYING file in the root of the source
  35546 // tree. An additional intellectual property rights grant can be found
  35547 // in the file PATENTS. All contributing project authors may
  35548 // be found in the AUTHORS file in the root of the source tree.
  35549 // -----------------------------------------------------------------------------
  35550 //
  35551 // Bit writing and boolean coder
  35552 //
  35553 // Author: Skal (pascal.massimino@gmail.com)
  35554 
  35555 // Copyright 2012 Google Inc. All Rights Reserved.
  35556 //
  35557 // Use of this source code is governed by a BSD-style license
  35558 // that can be found in the COPYING file in the root of the source
  35559 // tree. An additional intellectual property rights grant can be found
  35560 // in the file PATENTS. All contributing project authors may
  35561 // be found in the AUTHORS file in the root of the source tree.
  35562 // -----------------------------------------------------------------------------
  35563 //
  35564 // Misc. common utility functions
  35565 //
  35566 // Authors: Skal (pascal.massimino@gmail.com)
  35567 //          Urvang (urvang@google.com)
  35568 
  35569 // Copyright 2010 Google Inc. All Rights Reserved.
  35570 //
  35571 // Use of this source code is governed by a BSD-style license
  35572 // that can be found in the COPYING file in the root of the source
  35573 // tree. An additional intellectual property rights grant can be found
  35574 // in the file PATENTS. All contributing project authors may
  35575 // be found in the AUTHORS file in the root of the source tree.
  35576 // -----------------------------------------------------------------------------
  35577 //
  35578 //  Common types + memory wrappers
  35579 //
  35580 // Author: Skal (pascal.massimino@gmail.com)
  35581 
  35582 // we use pages to reduce the number of memcpy()
  35583 
  35584 type token_t = uint16
  35585 
  35586 // Token data is located in memory just after the 'next' field.
  35587 // This macro is used to return their address and hide the trick.
  35588 
  35589 //------------------------------------------------------------------------------
  35590 
  35591 func VP8TBufferInit(tls *libc.TLS, b uintptr, page_size int32) {
  35592 	var v1 int32
  35593 	_ = v1
  35594 	(*VP8TBuffer)(unsafe.Pointer(b)).Ftokens = libc.UintptrFromInt32(0)
  35595 	(*VP8TBuffer)(unsafe.Pointer(b)).Fpages = libc.UintptrFromInt32(0)
  35596 	(*VP8TBuffer)(unsafe.Pointer(b)).Flast_page = b
  35597 	(*VP8TBuffer)(unsafe.Pointer(b)).Fleft = 0
  35598 	if page_size < int32(MIN_PAGE_SIZE) {
  35599 		v1 = int32(MIN_PAGE_SIZE)
  35600 	} else {
  35601 		v1 = page_size
  35602 	}
  35603 	(*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size = v1
  35604 	(*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 = 0
  35605 }
  35606 
  35607 func VP8TBufferClear(tls *libc.TLS, b uintptr) {
  35608 	var next, p uintptr
  35609 	_, _ = next, p
  35610 	if b != libc.UintptrFromInt32(0) {
  35611 		p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35612 		for p != libc.UintptrFromInt32(0) {
  35613 			next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35614 			WebPSafeFree(tls, p)
  35615 			p = next
  35616 		}
  35617 		VP8TBufferInit(tls, b, (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size)
  35618 	}
  35619 }
  35620 
  35621 func TBufferNewPage(tls *libc.TLS, b uintptr) (r int32) {
  35622 	var page uintptr
  35623 	var size size_t
  35624 	_, _ = page, size
  35625 	page = libc.UintptrFromInt32(0)
  35626 	if !((*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 != 0) {
  35627 		size = uint64(8) + libc.Uint64FromInt32((*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size)*uint64(2)
  35628 		page = WebPSafeMalloc(tls, uint64(1), size)
  35629 	}
  35630 	if page == libc.UintptrFromInt32(0) {
  35631 		(*VP8TBuffer)(unsafe.Pointer(b)).Ferror1 = int32(1)
  35632 		return 0
  35633 	}
  35634 	(*VP8Tokens)(unsafe.Pointer(page)).Fnext = libc.UintptrFromInt32(0)
  35635 	**(**uintptr)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Flast_page)) = page
  35636 	(*VP8TBuffer)(unsafe.Pointer(b)).Flast_page = page
  35637 	(*VP8TBuffer)(unsafe.Pointer(b)).Fleft = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35638 	(*VP8TBuffer)(unsafe.Pointer(b)).Ftokens = page + 1*8
  35639 	return int32(1)
  35640 }
  35641 
  35642 //------------------------------------------------------------------------------
  35643 
  35644 func AddToken(tls *libc.TLS, b uintptr, bit1 uint32_t, proba_idx uint32_t, stats1 uintptr) (r uint32_t) {
  35645 	var p proba_t
  35646 	var slot, v1 int32
  35647 	var v2 uintptr
  35648 	_, _, _, _ = p, slot, v1, v2
  35649 	if (*VP8TBuffer)(unsafe.Pointer(b)).Fleft > 0 || TBufferNewPage(tls, b) != 0 {
  35650 		v2 = b + 24
  35651 		*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  35652 		v1 = *(*int32)(unsafe.Pointer(v2))
  35653 		slot = v1
  35654 		**(**uint16_t)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Ftokens + uintptr(slot)*2)) = uint16(bit1<<libc.Int32FromInt32(15) | proba_idx)
  35655 	}
  35656 	v1 = libc.Int32FromUint32(bit1)
  35657 	v2 = stats1
  35658 	p = **(**proba_t)(__ccgo_up(v2))
  35659 	if p >= libc.Uint32FromUint32(0xfffe0000) {
  35660 		p = (p + uint32(1)) >> int32(1) & uint32(0x7fff7fff)
  35661 	}
  35662 	p = p + (uint32(0x00010000) + libc.Uint32FromInt32(v1))
  35663 	**(**proba_t)(__ccgo_up(v2)) = p
  35664 	_ = v1
  35665 	goto _5
  35666 _5:
  35667 	;
  35668 	return bit1
  35669 }
  35670 
  35671 func AddConstantToken(tls *libc.TLS, b uintptr, bit uint32_t, proba uint32_t) {
  35672 	var slot, v1 int32
  35673 	var v2 uintptr
  35674 	_, _, _ = slot, v1, v2
  35675 	if (*VP8TBuffer)(unsafe.Pointer(b)).Fleft > 0 || TBufferNewPage(tls, b) != 0 {
  35676 		v2 = b + 24
  35677 		*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1
  35678 		v1 = *(*int32)(unsafe.Pointer(v2))
  35679 		slot = v1
  35680 		**(**uint16_t)(__ccgo_up((*VP8TBuffer)(unsafe.Pointer(b)).Ftokens + uintptr(slot)*2)) = uint16(bit<<libc.Int32FromInt32(15) | libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14) | proba)
  35681 	}
  35682 }
  35683 
  35684 func VP8RecordCoeffTokens(tls *libc.TLS, ctx int32, res uintptr, tokens uintptr) (r int32) {
  35685 	var base_id, residue, v uint32_t
  35686 	var c, coeff_type, last, mask, n, sign, v1, v2 int32
  35687 	var coeffs, s, tab, v3 uintptr
  35688 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base_id, c, coeff_type, coeffs, last, mask, n, residue, s, sign, tab, v, v1, v2, v3
  35689 	coeffs = (*VP8Residual)(unsafe.Pointer(res)).Fcoeffs
  35690 	coeff_type = (*VP8Residual)(unsafe.Pointer(res)).Fcoeff_type
  35691 	last = (*VP8Residual)(unsafe.Pointer(res)).Flast
  35692 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  35693 	base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (ctx + int32(NUM_CTX)*(n+int32(NUM_BANDS)*coeff_type)))
  35694 	// should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
  35695 	s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(n)*132 + uintptr(ctx)*44
  35696 	if !(AddToken(tls, tokens, libc.BoolUint32(last >= 0), base_id+uint32(0), s+uintptr(0)*4) != 0) {
  35697 		return 0
  35698 	}
  35699 	for n < int32(16) {
  35700 		v1 = n
  35701 		n = n + 1
  35702 		c = int32(**(**int16_t)(__ccgo_up(coeffs + uintptr(v1)*2)))
  35703 		sign = libc.BoolInt32(c < 0)
  35704 		if sign != 0 {
  35705 			v2 = -c
  35706 		} else {
  35707 			v2 = c
  35708 		}
  35709 		v = libc.Uint32FromInt32(v2)
  35710 		if !(AddToken(tls, tokens, libc.BoolUint32(v != uint32(0)), base_id+uint32(1), s+uintptr(1)*4) != 0) {
  35711 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(0) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=0
  35712 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132
  35713 			continue
  35714 		}
  35715 		if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(1)), base_id+uint32(2), s+uintptr(2)*4) != 0) {
  35716 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(1) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=1
  35717 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 1*44
  35718 		} else {
  35719 			if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(4)), base_id+uint32(3), s+uintptr(3)*4) != 0) {
  35720 				if AddToken(tls, tokens, libc.BoolUint32(v != uint32(2)), base_id+uint32(4), s+uintptr(4)*4) != 0 {
  35721 					AddToken(tls, tokens, libc.BoolUint32(v == uint32(4)), base_id+uint32(5), s+uintptr(5)*4)
  35722 				}
  35723 			} else {
  35724 				if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(10)), base_id+uint32(6), s+uintptr(6)*4) != 0) {
  35725 					if !(AddToken(tls, tokens, libc.BoolUint32(v > uint32(6)), base_id+uint32(7), s+uintptr(7)*4) != 0) {
  35726 						AddConstantToken(tls, tokens, libc.BoolUint32(v == uint32(6)), uint32(159))
  35727 					} else {
  35728 						AddConstantToken(tls, tokens, libc.BoolUint32(v >= uint32(9)), uint32(165))
  35729 						AddConstantToken(tls, tokens, libc.BoolUint32(!(v&libc.Uint32FromInt32(1) != 0)), uint32(145))
  35730 					}
  35731 				} else {
  35732 					residue = v - uint32(3)
  35733 					if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(1)) { // VP8Cat3  (3b)
  35734 						AddToken(tls, tokens, uint32(0), base_id+uint32(8), s+uintptr(8)*4)
  35735 						AddToken(tls, tokens, uint32(0), base_id+uint32(9), s+uintptr(9)*4)
  35736 						residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(0))
  35737 						mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(2)
  35738 						tab = uintptr(unsafe.Pointer(&VP8Cat3))
  35739 					} else {
  35740 						if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(2)) { // VP8Cat4  (4b)
  35741 							AddToken(tls, tokens, uint32(0), base_id+uint32(8), s+uintptr(8)*4)
  35742 							AddToken(tls, tokens, uint32(1), base_id+uint32(9), s+uintptr(9)*4)
  35743 							residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(1))
  35744 							mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(3)
  35745 							tab = uintptr(unsafe.Pointer(&VP8Cat4))
  35746 						} else {
  35747 							if residue < libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(3)) { // VP8Cat5  (5b)
  35748 								AddToken(tls, tokens, uint32(1), base_id+uint32(8), s+uintptr(8)*4)
  35749 								AddToken(tls, tokens, uint32(0), base_id+uint32(10), s+uintptr(9)*4)
  35750 								residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(2))
  35751 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(4)
  35752 								tab = uintptr(unsafe.Pointer(&VP8Cat5))
  35753 							} else { // VP8Cat6 (11b)
  35754 								AddToken(tls, tokens, uint32(1), base_id+uint32(8), s+uintptr(8)*4)
  35755 								AddToken(tls, tokens, uint32(1), base_id+uint32(10), s+uintptr(9)*4)
  35756 								residue = residue - libc.Uint32FromInt32(libc.Int32FromInt32(8)<<libc.Int32FromInt32(3))
  35757 								mask = libc.Int32FromInt32(1) << libc.Int32FromInt32(10)
  35758 								tab = uintptr(unsafe.Pointer(&VP8Cat6))
  35759 							}
  35760 						}
  35761 					}
  35762 					for mask != 0 {
  35763 						v3 = tab
  35764 						tab = tab + 1
  35765 						AddConstantToken(tls, tokens, libc.BoolUint32(!!(residue&libc.Uint32FromInt32(mask) != 0)), uint32(**(**uint8_t)(__ccgo_up(v3))))
  35766 						mask = mask >> int32(1)
  35767 					}
  35768 				}
  35769 			}
  35770 			base_id = libc.Uint32FromInt32(int32(NUM_PROBAS) * (libc.Int32FromInt32(2) + int32(NUM_CTX)*(libc.Int32FromUint8(VP8EncBands[n])+int32(NUM_BANDS)*coeff_type))) // ctx=2
  35771 			s = (*VP8Residual)(unsafe.Pointer(res)).Fstats + uintptr(VP8EncBands[n])*132 + 2*44
  35772 		}
  35773 		AddConstantToken(tls, tokens, libc.Uint32FromInt32(sign), uint32(128))
  35774 		if n == int32(16) || !(AddToken(tls, tokens, libc.BoolUint32(n <= last), base_id+uint32(0), s+uintptr(0)*4) != 0) {
  35775 			return int32(1) // EOB
  35776 		}
  35777 	}
  35778 	return int32(1)
  35779 }
  35780 
  35781 //------------------------------------------------------------------------------
  35782 // Final coding pass, with known probabilities
  35783 
  35784 func VP8EmitTokens(tls *libc.TLS, b uintptr, bw uintptr, probas uintptr, final_pass int32) (r int32) {
  35785 	var N, bit, n, v1, v2 int32
  35786 	var next, p, tokens uintptr
  35787 	var token token_t
  35788 	_, _, _, _, _, _, _, _, _ = N, bit, n, next, p, token, tokens, v1, v2
  35789 	p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35790 	for p != libc.UintptrFromInt32(0) {
  35791 		next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35792 		if next == libc.UintptrFromInt32(0) {
  35793 			v1 = (*VP8TBuffer)(unsafe.Pointer(b)).Fleft
  35794 		} else {
  35795 			v1 = 0
  35796 		}
  35797 		N = v1
  35798 		n = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35799 		tokens = p + 1*8
  35800 		for {
  35801 			v2 = n
  35802 			n = n - 1
  35803 			if !(v2 > N) {
  35804 				break
  35805 			}
  35806 			token = **(**token_t)(__ccgo_up(tokens + uintptr(n)*2))
  35807 			bit = libc.Int32FromUint16(token) >> int32(15) & int32(1)
  35808 			if uint32(token)&(libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14)) != 0 {
  35809 				VP8PutBit(tls, bw, bit, libc.Int32FromUint32(uint32(token)&uint32(0xff))) // constant proba
  35810 			} else {
  35811 				VP8PutBit(tls, bw, bit, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(probas + uintptr(uint32(token)&uint32(0x3fff))))))
  35812 			}
  35813 		}
  35814 		if final_pass != 0 {
  35815 			WebPSafeFree(tls, p)
  35816 		}
  35817 		p = next
  35818 	}
  35819 	if final_pass != 0 {
  35820 		(*VP8TBuffer)(unsafe.Pointer(b)).Fpages = libc.UintptrFromInt32(0)
  35821 	}
  35822 	return int32(1)
  35823 }
  35824 
  35825 // C documentation
  35826 //
  35827 //	// Size estimation
  35828 func VP8EstimateTokenSize(tls *libc.TLS, b uintptr, probas uintptr) (r size_t) {
  35829 	var N, bit1, n, v1, v2, v4, v6 int32
  35830 	var next, p, tokens uintptr
  35831 	var size size_t
  35832 	var token token_t
  35833 	var v3 uint8_t
  35834 	_, _, _, _, _, _, _, _, _, _, _, _, _ = N, bit1, n, next, p, size, token, tokens, v1, v2, v3, v4, v6
  35835 	size = uint64(0)
  35836 	p = (*VP8TBuffer)(unsafe.Pointer(b)).Fpages
  35837 	for p != libc.UintptrFromInt32(0) {
  35838 		next = (*VP8Tokens)(unsafe.Pointer(p)).Fnext
  35839 		if next == libc.UintptrFromInt32(0) {
  35840 			v1 = (*VP8TBuffer)(unsafe.Pointer(b)).Fleft
  35841 		} else {
  35842 			v1 = 0
  35843 		}
  35844 		N = v1
  35845 		n = (*VP8TBuffer)(unsafe.Pointer(b)).Fpage_size
  35846 		tokens = p + 1*8
  35847 		for {
  35848 			v2 = n
  35849 			n = n - 1
  35850 			if !(v2 > N) {
  35851 				break
  35852 			}
  35853 			token = **(**token_t)(__ccgo_up(tokens + uintptr(n)*2))
  35854 			bit1 = libc.Int32FromUint16(token) & (libc.Int32FromInt32(1) << libc.Int32FromInt32(15))
  35855 			if uint32(token)&(libc.Uint32FromUint32(1)<<libc.Int32FromInt32(14)) != 0 {
  35856 				v3 = uint8(uint32(token) & uint32(0xff))
  35857 				if !(bit1 != 0) {
  35858 					v6 = libc.Int32FromUint16(VP8EntropyCost[v3])
  35859 				} else {
  35860 					v6 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  35861 				}
  35862 				v4 = v6
  35863 				goto _5
  35864 			_5:
  35865 				size = size + libc.Uint64FromInt32(v4)
  35866 			} else {
  35867 				v3 = **(**uint8_t)(__ccgo_up(probas + uintptr(uint32(token)&uint32(0x3fff))))
  35868 				if !(bit1 != 0) {
  35869 					v2 = libc.Int32FromUint16(VP8EntropyCost[v3])
  35870 				} else {
  35871 					v2 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v3)])
  35872 				}
  35873 				v1 = v2
  35874 				goto _9
  35875 			_9:
  35876 				size = size + libc.Uint64FromInt32(v1)
  35877 			}
  35878 		}
  35879 		p = next
  35880 	}
  35881 	return size
  35882 }
  35883 
  35884 func VP8DefaultProbas(tls *libc.TLS, enc uintptr) {
  35885 	var probas uintptr
  35886 	_ = probas
  35887 	probas = enc + 3616
  35888 	(*VP8EncProba)(unsafe.Pointer(probas)).Fuse_skip_proba = 0
  35889 	libc.X__builtin___memset_chk(tls, probas, libc.Int32FromUint32(255), uint64(3), ^__predefined_size_t(0))
  35890 	libc.X__builtin___memcpy_chk(tls, probas+4, uintptr(unsafe.Pointer(&VP8CoeffsProba0)), uint64(1056), ^__predefined_size_t(0))
  35891 	// Note: we could hard-code the level_costs corresponding to VP8CoeffsProba0,
  35892 	// but that's ~11k of static data. Better call VP8CalculateLevelCosts() later.
  35893 	(*VP8EncProba)(unsafe.Pointer(probas)).Fdirty = int32(1)
  35894 }
  35895 
  35896 // C documentation
  35897 //
  35898 //	// Paragraph 11.5.  900bytes.
  35899 var kBModesProba1 = [10][10][9]uint8_t{
  35900 	0: {
  35901 		0: {
  35902 			0: uint8(231),
  35903 			1: uint8(120),
  35904 			2: uint8(48),
  35905 			3: uint8(89),
  35906 			4: uint8(115),
  35907 			5: uint8(113),
  35908 			6: uint8(120),
  35909 			7: uint8(152),
  35910 			8: uint8(112),
  35911 		},
  35912 		1: {
  35913 			0: uint8(152),
  35914 			1: uint8(179),
  35915 			2: uint8(64),
  35916 			3: uint8(126),
  35917 			4: uint8(170),
  35918 			5: uint8(118),
  35919 			6: uint8(46),
  35920 			7: uint8(70),
  35921 			8: uint8(95),
  35922 		},
  35923 		2: {
  35924 			0: uint8(175),
  35925 			1: uint8(69),
  35926 			2: uint8(143),
  35927 			3: uint8(80),
  35928 			4: uint8(85),
  35929 			5: uint8(82),
  35930 			6: uint8(72),
  35931 			7: uint8(155),
  35932 			8: uint8(103),
  35933 		},
  35934 		3: {
  35935 			0: uint8(56),
  35936 			1: uint8(58),
  35937 			2: uint8(10),
  35938 			3: uint8(171),
  35939 			4: uint8(218),
  35940 			5: uint8(189),
  35941 			6: uint8(17),
  35942 			7: uint8(13),
  35943 			8: uint8(152),
  35944 		},
  35945 		4: {
  35946 			0: uint8(114),
  35947 			1: uint8(26),
  35948 			2: uint8(17),
  35949 			3: uint8(163),
  35950 			4: uint8(44),
  35951 			5: uint8(195),
  35952 			6: uint8(21),
  35953 			7: uint8(10),
  35954 			8: uint8(173),
  35955 		},
  35956 		5: {
  35957 			0: uint8(121),
  35958 			1: uint8(24),
  35959 			2: uint8(80),
  35960 			3: uint8(195),
  35961 			4: uint8(26),
  35962 			5: uint8(62),
  35963 			6: uint8(44),
  35964 			7: uint8(64),
  35965 			8: uint8(85),
  35966 		},
  35967 		6: {
  35968 			0: uint8(144),
  35969 			1: uint8(71),
  35970 			2: uint8(10),
  35971 			3: uint8(38),
  35972 			4: uint8(171),
  35973 			5: uint8(213),
  35974 			6: uint8(144),
  35975 			7: uint8(34),
  35976 			8: uint8(26),
  35977 		},
  35978 		7: {
  35979 			0: uint8(170),
  35980 			1: uint8(46),
  35981 			2: uint8(55),
  35982 			3: uint8(19),
  35983 			4: uint8(136),
  35984 			5: uint8(160),
  35985 			6: uint8(33),
  35986 			7: uint8(206),
  35987 			8: uint8(71),
  35988 		},
  35989 		8: {
  35990 			0: uint8(63),
  35991 			1: uint8(20),
  35992 			2: uint8(8),
  35993 			3: uint8(114),
  35994 			4: uint8(114),
  35995 			5: uint8(208),
  35996 			6: uint8(12),
  35997 			7: uint8(9),
  35998 			8: uint8(226),
  35999 		},
  36000 		9: {
  36001 			0: uint8(81),
  36002 			1: uint8(40),
  36003 			2: uint8(11),
  36004 			3: uint8(96),
  36005 			4: uint8(182),
  36006 			5: uint8(84),
  36007 			6: uint8(29),
  36008 			7: uint8(16),
  36009 			8: uint8(36),
  36010 		},
  36011 	},
  36012 	1: {
  36013 		0: {
  36014 			0: uint8(134),
  36015 			1: uint8(183),
  36016 			2: uint8(89),
  36017 			3: uint8(137),
  36018 			4: uint8(98),
  36019 			5: uint8(101),
  36020 			6: uint8(106),
  36021 			7: uint8(165),
  36022 			8: uint8(148),
  36023 		},
  36024 		1: {
  36025 			0: uint8(72),
  36026 			1: uint8(187),
  36027 			2: uint8(100),
  36028 			3: uint8(130),
  36029 			4: uint8(157),
  36030 			5: uint8(111),
  36031 			6: uint8(32),
  36032 			7: uint8(75),
  36033 			8: uint8(80),
  36034 		},
  36035 		2: {
  36036 			0: uint8(66),
  36037 			1: uint8(102),
  36038 			2: uint8(167),
  36039 			3: uint8(99),
  36040 			4: uint8(74),
  36041 			5: uint8(62),
  36042 			6: uint8(40),
  36043 			7: uint8(234),
  36044 			8: uint8(128),
  36045 		},
  36046 		3: {
  36047 			0: uint8(41),
  36048 			1: uint8(53),
  36049 			2: uint8(9),
  36050 			3: uint8(178),
  36051 			4: uint8(241),
  36052 			5: uint8(141),
  36053 			6: uint8(26),
  36054 			7: uint8(8),
  36055 			8: uint8(107),
  36056 		},
  36057 		4: {
  36058 			0: uint8(74),
  36059 			1: uint8(43),
  36060 			2: uint8(26),
  36061 			3: uint8(146),
  36062 			4: uint8(73),
  36063 			5: uint8(166),
  36064 			6: uint8(49),
  36065 			7: uint8(23),
  36066 			8: uint8(157),
  36067 		},
  36068 		5: {
  36069 			0: uint8(65),
  36070 			1: uint8(38),
  36071 			2: uint8(105),
  36072 			3: uint8(160),
  36073 			4: uint8(51),
  36074 			5: uint8(52),
  36075 			6: uint8(31),
  36076 			7: uint8(115),
  36077 			8: uint8(128),
  36078 		},
  36079 		6: {
  36080 			0: uint8(104),
  36081 			1: uint8(79),
  36082 			2: uint8(12),
  36083 			3: uint8(27),
  36084 			4: uint8(217),
  36085 			5: uint8(255),
  36086 			6: uint8(87),
  36087 			7: uint8(17),
  36088 			8: uint8(7),
  36089 		},
  36090 		7: {
  36091 			0: uint8(87),
  36092 			1: uint8(68),
  36093 			2: uint8(71),
  36094 			3: uint8(44),
  36095 			4: uint8(114),
  36096 			5: uint8(51),
  36097 			6: uint8(15),
  36098 			7: uint8(186),
  36099 			8: uint8(23),
  36100 		},
  36101 		8: {
  36102 			0: uint8(47),
  36103 			1: uint8(41),
  36104 			2: uint8(14),
  36105 			3: uint8(110),
  36106 			4: uint8(182),
  36107 			5: uint8(183),
  36108 			6: uint8(21),
  36109 			7: uint8(17),
  36110 			8: uint8(194),
  36111 		},
  36112 		9: {
  36113 			0: uint8(66),
  36114 			1: uint8(45),
  36115 			2: uint8(25),
  36116 			3: uint8(102),
  36117 			4: uint8(197),
  36118 			5: uint8(189),
  36119 			6: uint8(23),
  36120 			7: uint8(18),
  36121 			8: uint8(22),
  36122 		},
  36123 	},
  36124 	2: {
  36125 		0: {
  36126 			0: uint8(88),
  36127 			1: uint8(88),
  36128 			2: uint8(147),
  36129 			3: uint8(150),
  36130 			4: uint8(42),
  36131 			5: uint8(46),
  36132 			6: uint8(45),
  36133 			7: uint8(196),
  36134 			8: uint8(205),
  36135 		},
  36136 		1: {
  36137 			0: uint8(43),
  36138 			1: uint8(97),
  36139 			2: uint8(183),
  36140 			3: uint8(117),
  36141 			4: uint8(85),
  36142 			5: uint8(38),
  36143 			6: uint8(35),
  36144 			7: uint8(179),
  36145 			8: uint8(61),
  36146 		},
  36147 		2: {
  36148 			0: uint8(39),
  36149 			1: uint8(53),
  36150 			2: uint8(200),
  36151 			3: uint8(87),
  36152 			4: uint8(26),
  36153 			5: uint8(21),
  36154 			6: uint8(43),
  36155 			7: uint8(232),
  36156 			8: uint8(171),
  36157 		},
  36158 		3: {
  36159 			0: uint8(56),
  36160 			1: uint8(34),
  36161 			2: uint8(51),
  36162 			3: uint8(104),
  36163 			4: uint8(114),
  36164 			5: uint8(102),
  36165 			6: uint8(29),
  36166 			7: uint8(93),
  36167 			8: uint8(77),
  36168 		},
  36169 		4: {
  36170 			0: uint8(39),
  36171 			1: uint8(28),
  36172 			2: uint8(85),
  36173 			3: uint8(171),
  36174 			4: uint8(58),
  36175 			5: uint8(165),
  36176 			6: uint8(90),
  36177 			7: uint8(98),
  36178 			8: uint8(64),
  36179 		},
  36180 		5: {
  36181 			0: uint8(34),
  36182 			1: uint8(22),
  36183 			2: uint8(116),
  36184 			3: uint8(206),
  36185 			4: uint8(23),
  36186 			5: uint8(34),
  36187 			6: uint8(43),
  36188 			7: uint8(166),
  36189 			8: uint8(73),
  36190 		},
  36191 		6: {
  36192 			0: uint8(107),
  36193 			1: uint8(54),
  36194 			2: uint8(32),
  36195 			3: uint8(26),
  36196 			4: uint8(51),
  36197 			5: uint8(1),
  36198 			6: uint8(81),
  36199 			7: uint8(43),
  36200 			8: uint8(31),
  36201 		},
  36202 		7: {
  36203 			0: uint8(68),
  36204 			1: uint8(25),
  36205 			2: uint8(106),
  36206 			3: uint8(22),
  36207 			4: uint8(64),
  36208 			5: uint8(171),
  36209 			6: uint8(36),
  36210 			7: uint8(225),
  36211 			8: uint8(114),
  36212 		},
  36213 		8: {
  36214 			0: uint8(34),
  36215 			1: uint8(19),
  36216 			2: uint8(21),
  36217 			3: uint8(102),
  36218 			4: uint8(132),
  36219 			5: uint8(188),
  36220 			6: uint8(16),
  36221 			7: uint8(76),
  36222 			8: uint8(124),
  36223 		},
  36224 		9: {
  36225 			0: uint8(62),
  36226 			1: uint8(18),
  36227 			2: uint8(78),
  36228 			3: uint8(95),
  36229 			4: uint8(85),
  36230 			5: uint8(57),
  36231 			6: uint8(50),
  36232 			7: uint8(48),
  36233 			8: uint8(51),
  36234 		},
  36235 	},
  36236 	3: {
  36237 		0: {
  36238 			0: uint8(193),
  36239 			1: uint8(101),
  36240 			2: uint8(35),
  36241 			3: uint8(159),
  36242 			4: uint8(215),
  36243 			5: uint8(111),
  36244 			6: uint8(89),
  36245 			7: uint8(46),
  36246 			8: uint8(111),
  36247 		},
  36248 		1: {
  36249 			0: uint8(60),
  36250 			1: uint8(148),
  36251 			2: uint8(31),
  36252 			3: uint8(172),
  36253 			4: uint8(219),
  36254 			5: uint8(228),
  36255 			6: uint8(21),
  36256 			7: uint8(18),
  36257 			8: uint8(111),
  36258 		},
  36259 		2: {
  36260 			0: uint8(112),
  36261 			1: uint8(113),
  36262 			2: uint8(77),
  36263 			3: uint8(85),
  36264 			4: uint8(179),
  36265 			5: uint8(255),
  36266 			6: uint8(38),
  36267 			7: uint8(120),
  36268 			8: uint8(114),
  36269 		},
  36270 		3: {
  36271 			0: uint8(40),
  36272 			1: uint8(42),
  36273 			2: uint8(1),
  36274 			3: uint8(196),
  36275 			4: uint8(245),
  36276 			5: uint8(209),
  36277 			6: uint8(10),
  36278 			7: uint8(25),
  36279 			8: uint8(109),
  36280 		},
  36281 		4: {
  36282 			0: uint8(88),
  36283 			1: uint8(43),
  36284 			2: uint8(29),
  36285 			3: uint8(140),
  36286 			4: uint8(166),
  36287 			5: uint8(213),
  36288 			6: uint8(37),
  36289 			7: uint8(43),
  36290 			8: uint8(154),
  36291 		},
  36292 		5: {
  36293 			0: uint8(61),
  36294 			1: uint8(63),
  36295 			2: uint8(30),
  36296 			3: uint8(155),
  36297 			4: uint8(67),
  36298 			5: uint8(45),
  36299 			6: uint8(68),
  36300 			7: uint8(1),
  36301 			8: uint8(209),
  36302 		},
  36303 		6: {
  36304 			0: uint8(100),
  36305 			1: uint8(80),
  36306 			2: uint8(8),
  36307 			3: uint8(43),
  36308 			4: uint8(154),
  36309 			5: uint8(1),
  36310 			6: uint8(51),
  36311 			7: uint8(26),
  36312 			8: uint8(71),
  36313 		},
  36314 		7: {
  36315 			0: uint8(142),
  36316 			1: uint8(78),
  36317 			2: uint8(78),
  36318 			3: uint8(16),
  36319 			4: uint8(255),
  36320 			5: uint8(128),
  36321 			6: uint8(34),
  36322 			7: uint8(197),
  36323 			8: uint8(171),
  36324 		},
  36325 		8: {
  36326 			0: uint8(41),
  36327 			1: uint8(40),
  36328 			2: uint8(5),
  36329 			3: uint8(102),
  36330 			4: uint8(211),
  36331 			5: uint8(183),
  36332 			6: uint8(4),
  36333 			7: uint8(1),
  36334 			8: uint8(221),
  36335 		},
  36336 		9: {
  36337 			0: uint8(51),
  36338 			1: uint8(50),
  36339 			2: uint8(17),
  36340 			3: uint8(168),
  36341 			4: uint8(209),
  36342 			5: uint8(192),
  36343 			6: uint8(23),
  36344 			7: uint8(25),
  36345 			8: uint8(82),
  36346 		},
  36347 	},
  36348 	4: {
  36349 		0: {
  36350 			0: uint8(138),
  36351 			1: uint8(31),
  36352 			2: uint8(36),
  36353 			3: uint8(171),
  36354 			4: uint8(27),
  36355 			5: uint8(166),
  36356 			6: uint8(38),
  36357 			7: uint8(44),
  36358 			8: uint8(229),
  36359 		},
  36360 		1: {
  36361 			0: uint8(67),
  36362 			1: uint8(87),
  36363 			2: uint8(58),
  36364 			3: uint8(169),
  36365 			4: uint8(82),
  36366 			5: uint8(115),
  36367 			6: uint8(26),
  36368 			7: uint8(59),
  36369 			8: uint8(179),
  36370 		},
  36371 		2: {
  36372 			0: uint8(63),
  36373 			1: uint8(59),
  36374 			2: uint8(90),
  36375 			3: uint8(180),
  36376 			4: uint8(59),
  36377 			5: uint8(166),
  36378 			6: uint8(93),
  36379 			7: uint8(73),
  36380 			8: uint8(154),
  36381 		},
  36382 		3: {
  36383 			0: uint8(40),
  36384 			1: uint8(40),
  36385 			2: uint8(21),
  36386 			3: uint8(116),
  36387 			4: uint8(143),
  36388 			5: uint8(209),
  36389 			6: uint8(34),
  36390 			7: uint8(39),
  36391 			8: uint8(175),
  36392 		},
  36393 		4: {
  36394 			0: uint8(47),
  36395 			1: uint8(15),
  36396 			2: uint8(16),
  36397 			3: uint8(183),
  36398 			4: uint8(34),
  36399 			5: uint8(223),
  36400 			6: uint8(49),
  36401 			7: uint8(45),
  36402 			8: uint8(183),
  36403 		},
  36404 		5: {
  36405 			0: uint8(46),
  36406 			1: uint8(17),
  36407 			2: uint8(33),
  36408 			3: uint8(183),
  36409 			4: uint8(6),
  36410 			5: uint8(98),
  36411 			6: uint8(15),
  36412 			7: uint8(32),
  36413 			8: uint8(183),
  36414 		},
  36415 		6: {
  36416 			0: uint8(57),
  36417 			1: uint8(46),
  36418 			2: uint8(22),
  36419 			3: uint8(24),
  36420 			4: uint8(128),
  36421 			5: uint8(1),
  36422 			6: uint8(54),
  36423 			7: uint8(17),
  36424 			8: uint8(37),
  36425 		},
  36426 		7: {
  36427 			0: uint8(65),
  36428 			1: uint8(32),
  36429 			2: uint8(73),
  36430 			3: uint8(115),
  36431 			4: uint8(28),
  36432 			5: uint8(128),
  36433 			6: uint8(23),
  36434 			7: uint8(128),
  36435 			8: uint8(205),
  36436 		},
  36437 		8: {
  36438 			0: uint8(40),
  36439 			1: uint8(3),
  36440 			2: uint8(9),
  36441 			3: uint8(115),
  36442 			4: uint8(51),
  36443 			5: uint8(192),
  36444 			6: uint8(18),
  36445 			7: uint8(6),
  36446 			8: uint8(223),
  36447 		},
  36448 		9: {
  36449 			0: uint8(87),
  36450 			1: uint8(37),
  36451 			2: uint8(9),
  36452 			3: uint8(115),
  36453 			4: uint8(59),
  36454 			5: uint8(77),
  36455 			6: uint8(64),
  36456 			7: uint8(21),
  36457 			8: uint8(47),
  36458 		},
  36459 	},
  36460 	5: {
  36461 		0: {
  36462 			0: uint8(104),
  36463 			1: uint8(55),
  36464 			2: uint8(44),
  36465 			3: uint8(218),
  36466 			4: uint8(9),
  36467 			5: uint8(54),
  36468 			6: uint8(53),
  36469 			7: uint8(130),
  36470 			8: uint8(226),
  36471 		},
  36472 		1: {
  36473 			0: uint8(64),
  36474 			1: uint8(90),
  36475 			2: uint8(70),
  36476 			3: uint8(205),
  36477 			4: uint8(40),
  36478 			5: uint8(41),
  36479 			6: uint8(23),
  36480 			7: uint8(26),
  36481 			8: uint8(57),
  36482 		},
  36483 		2: {
  36484 			0: uint8(54),
  36485 			1: uint8(57),
  36486 			2: uint8(112),
  36487 			3: uint8(184),
  36488 			4: uint8(5),
  36489 			5: uint8(41),
  36490 			6: uint8(38),
  36491 			7: uint8(166),
  36492 			8: uint8(213),
  36493 		},
  36494 		3: {
  36495 			0: uint8(30),
  36496 			1: uint8(34),
  36497 			2: uint8(26),
  36498 			3: uint8(133),
  36499 			4: uint8(152),
  36500 			5: uint8(116),
  36501 			6: uint8(10),
  36502 			7: uint8(32),
  36503 			8: uint8(134),
  36504 		},
  36505 		4: {
  36506 			0: uint8(39),
  36507 			1: uint8(19),
  36508 			2: uint8(53),
  36509 			3: uint8(221),
  36510 			4: uint8(26),
  36511 			5: uint8(114),
  36512 			6: uint8(32),
  36513 			7: uint8(73),
  36514 			8: uint8(255),
  36515 		},
  36516 		5: {
  36517 			0: uint8(31),
  36518 			1: uint8(9),
  36519 			2: uint8(65),
  36520 			3: uint8(234),
  36521 			4: uint8(2),
  36522 			5: uint8(15),
  36523 			6: uint8(1),
  36524 			7: uint8(118),
  36525 			8: uint8(73),
  36526 		},
  36527 		6: {
  36528 			0: uint8(75),
  36529 			1: uint8(32),
  36530 			2: uint8(12),
  36531 			3: uint8(51),
  36532 			4: uint8(192),
  36533 			5: uint8(255),
  36534 			6: uint8(160),
  36535 			7: uint8(43),
  36536 			8: uint8(51),
  36537 		},
  36538 		7: {
  36539 			0: uint8(88),
  36540 			1: uint8(31),
  36541 			2: uint8(35),
  36542 			3: uint8(67),
  36543 			4: uint8(102),
  36544 			5: uint8(85),
  36545 			6: uint8(55),
  36546 			7: uint8(186),
  36547 			8: uint8(85),
  36548 		},
  36549 		8: {
  36550 			0: uint8(56),
  36551 			1: uint8(21),
  36552 			2: uint8(23),
  36553 			3: uint8(111),
  36554 			4: uint8(59),
  36555 			5: uint8(205),
  36556 			6: uint8(45),
  36557 			7: uint8(37),
  36558 			8: uint8(192),
  36559 		},
  36560 		9: {
  36561 			0: uint8(55),
  36562 			1: uint8(38),
  36563 			2: uint8(70),
  36564 			3: uint8(124),
  36565 			4: uint8(73),
  36566 			5: uint8(102),
  36567 			6: uint8(1),
  36568 			7: uint8(34),
  36569 			8: uint8(98),
  36570 		},
  36571 	},
  36572 	6: {
  36573 		0: {
  36574 			0: uint8(125),
  36575 			1: uint8(98),
  36576 			2: uint8(42),
  36577 			3: uint8(88),
  36578 			4: uint8(104),
  36579 			5: uint8(85),
  36580 			6: uint8(117),
  36581 			7: uint8(175),
  36582 			8: uint8(82),
  36583 		},
  36584 		1: {
  36585 			0: uint8(95),
  36586 			1: uint8(84),
  36587 			2: uint8(53),
  36588 			3: uint8(89),
  36589 			4: uint8(128),
  36590 			5: uint8(100),
  36591 			6: uint8(113),
  36592 			7: uint8(101),
  36593 			8: uint8(45),
  36594 		},
  36595 		2: {
  36596 			0: uint8(75),
  36597 			1: uint8(79),
  36598 			2: uint8(123),
  36599 			3: uint8(47),
  36600 			4: uint8(51),
  36601 			5: uint8(128),
  36602 			6: uint8(81),
  36603 			7: uint8(171),
  36604 			8: uint8(1),
  36605 		},
  36606 		3: {
  36607 			0: uint8(57),
  36608 			1: uint8(17),
  36609 			2: uint8(5),
  36610 			3: uint8(71),
  36611 			4: uint8(102),
  36612 			5: uint8(57),
  36613 			6: uint8(53),
  36614 			7: uint8(41),
  36615 			8: uint8(49),
  36616 		},
  36617 		4: {
  36618 			0: uint8(38),
  36619 			1: uint8(33),
  36620 			2: uint8(13),
  36621 			3: uint8(121),
  36622 			4: uint8(57),
  36623 			5: uint8(73),
  36624 			6: uint8(26),
  36625 			7: uint8(1),
  36626 			8: uint8(85),
  36627 		},
  36628 		5: {
  36629 			0: uint8(41),
  36630 			1: uint8(10),
  36631 			2: uint8(67),
  36632 			3: uint8(138),
  36633 			4: uint8(77),
  36634 			5: uint8(110),
  36635 			6: uint8(90),
  36636 			7: uint8(47),
  36637 			8: uint8(114),
  36638 		},
  36639 		6: {
  36640 			0: uint8(115),
  36641 			1: uint8(21),
  36642 			2: uint8(2),
  36643 			3: uint8(10),
  36644 			4: uint8(102),
  36645 			5: uint8(255),
  36646 			6: uint8(166),
  36647 			7: uint8(23),
  36648 			8: uint8(6),
  36649 		},
  36650 		7: {
  36651 			0: uint8(101),
  36652 			1: uint8(29),
  36653 			2: uint8(16),
  36654 			3: uint8(10),
  36655 			4: uint8(85),
  36656 			5: uint8(128),
  36657 			6: uint8(101),
  36658 			7: uint8(196),
  36659 			8: uint8(26),
  36660 		},
  36661 		8: {
  36662 			0: uint8(57),
  36663 			1: uint8(18),
  36664 			2: uint8(10),
  36665 			3: uint8(102),
  36666 			4: uint8(102),
  36667 			5: uint8(213),
  36668 			6: uint8(34),
  36669 			7: uint8(20),
  36670 			8: uint8(43),
  36671 		},
  36672 		9: {
  36673 			0: uint8(117),
  36674 			1: uint8(20),
  36675 			2: uint8(15),
  36676 			3: uint8(36),
  36677 			4: uint8(163),
  36678 			5: uint8(128),
  36679 			6: uint8(68),
  36680 			7: uint8(1),
  36681 			8: uint8(26),
  36682 		},
  36683 	},
  36684 	7: {
  36685 		0: {
  36686 			0: uint8(102),
  36687 			1: uint8(61),
  36688 			2: uint8(71),
  36689 			3: uint8(37),
  36690 			4: uint8(34),
  36691 			5: uint8(53),
  36692 			6: uint8(31),
  36693 			7: uint8(243),
  36694 			8: uint8(192),
  36695 		},
  36696 		1: {
  36697 			0: uint8(69),
  36698 			1: uint8(60),
  36699 			2: uint8(71),
  36700 			3: uint8(38),
  36701 			4: uint8(73),
  36702 			5: uint8(119),
  36703 			6: uint8(28),
  36704 			7: uint8(222),
  36705 			8: uint8(37),
  36706 		},
  36707 		2: {
  36708 			0: uint8(68),
  36709 			1: uint8(45),
  36710 			2: uint8(128),
  36711 			3: uint8(34),
  36712 			4: uint8(1),
  36713 			5: uint8(47),
  36714 			6: uint8(11),
  36715 			7: uint8(245),
  36716 			8: uint8(171),
  36717 		},
  36718 		3: {
  36719 			0: uint8(62),
  36720 			1: uint8(17),
  36721 			2: uint8(19),
  36722 			3: uint8(70),
  36723 			4: uint8(146),
  36724 			5: uint8(85),
  36725 			6: uint8(55),
  36726 			7: uint8(62),
  36727 			8: uint8(70),
  36728 		},
  36729 		4: {
  36730 			0: uint8(37),
  36731 			1: uint8(43),
  36732 			2: uint8(37),
  36733 			3: uint8(154),
  36734 			4: uint8(100),
  36735 			5: uint8(163),
  36736 			6: uint8(85),
  36737 			7: uint8(160),
  36738 			8: uint8(1),
  36739 		},
  36740 		5: {
  36741 			0: uint8(63),
  36742 			1: uint8(9),
  36743 			2: uint8(92),
  36744 			3: uint8(136),
  36745 			4: uint8(28),
  36746 			5: uint8(64),
  36747 			6: uint8(32),
  36748 			7: uint8(201),
  36749 			8: uint8(85),
  36750 		},
  36751 		6: {
  36752 			0: uint8(75),
  36753 			1: uint8(15),
  36754 			2: uint8(9),
  36755 			3: uint8(9),
  36756 			4: uint8(64),
  36757 			5: uint8(255),
  36758 			6: uint8(184),
  36759 			7: uint8(119),
  36760 			8: uint8(16),
  36761 		},
  36762 		7: {
  36763 			0: uint8(86),
  36764 			1: uint8(6),
  36765 			2: uint8(28),
  36766 			3: uint8(5),
  36767 			4: uint8(64),
  36768 			5: uint8(255),
  36769 			6: uint8(25),
  36770 			7: uint8(248),
  36771 			8: uint8(1),
  36772 		},
  36773 		8: {
  36774 			0: uint8(56),
  36775 			1: uint8(8),
  36776 			2: uint8(17),
  36777 			3: uint8(132),
  36778 			4: uint8(137),
  36779 			5: uint8(255),
  36780 			6: uint8(55),
  36781 			7: uint8(116),
  36782 			8: uint8(128),
  36783 		},
  36784 		9: {
  36785 			0: uint8(58),
  36786 			1: uint8(15),
  36787 			2: uint8(20),
  36788 			3: uint8(82),
  36789 			4: uint8(135),
  36790 			5: uint8(57),
  36791 			6: uint8(26),
  36792 			7: uint8(121),
  36793 			8: uint8(40),
  36794 		},
  36795 	},
  36796 	8: {
  36797 		0: {
  36798 			0: uint8(164),
  36799 			1: uint8(50),
  36800 			2: uint8(31),
  36801 			3: uint8(137),
  36802 			4: uint8(154),
  36803 			5: uint8(133),
  36804 			6: uint8(25),
  36805 			7: uint8(35),
  36806 			8: uint8(218),
  36807 		},
  36808 		1: {
  36809 			0: uint8(51),
  36810 			1: uint8(103),
  36811 			2: uint8(44),
  36812 			3: uint8(131),
  36813 			4: uint8(131),
  36814 			5: uint8(123),
  36815 			6: uint8(31),
  36816 			7: uint8(6),
  36817 			8: uint8(158),
  36818 		},
  36819 		2: {
  36820 			0: uint8(86),
  36821 			1: uint8(40),
  36822 			2: uint8(64),
  36823 			3: uint8(135),
  36824 			4: uint8(148),
  36825 			5: uint8(224),
  36826 			6: uint8(45),
  36827 			7: uint8(183),
  36828 			8: uint8(128),
  36829 		},
  36830 		3: {
  36831 			0: uint8(22),
  36832 			1: uint8(26),
  36833 			2: uint8(17),
  36834 			3: uint8(131),
  36835 			4: uint8(240),
  36836 			5: uint8(154),
  36837 			6: uint8(14),
  36838 			7: uint8(1),
  36839 			8: uint8(209),
  36840 		},
  36841 		4: {
  36842 			0: uint8(45),
  36843 			1: uint8(16),
  36844 			2: uint8(21),
  36845 			3: uint8(91),
  36846 			4: uint8(64),
  36847 			5: uint8(222),
  36848 			6: uint8(7),
  36849 			7: uint8(1),
  36850 			8: uint8(197),
  36851 		},
  36852 		5: {
  36853 			0: uint8(56),
  36854 			1: uint8(21),
  36855 			2: uint8(39),
  36856 			3: uint8(155),
  36857 			4: uint8(60),
  36858 			5: uint8(138),
  36859 			6: uint8(23),
  36860 			7: uint8(102),
  36861 			8: uint8(213),
  36862 		},
  36863 		6: {
  36864 			0: uint8(83),
  36865 			1: uint8(12),
  36866 			2: uint8(13),
  36867 			3: uint8(54),
  36868 			4: uint8(192),
  36869 			5: uint8(255),
  36870 			6: uint8(68),
  36871 			7: uint8(47),
  36872 			8: uint8(28),
  36873 		},
  36874 		7: {
  36875 			0: uint8(85),
  36876 			1: uint8(26),
  36877 			2: uint8(85),
  36878 			3: uint8(85),
  36879 			4: uint8(128),
  36880 			5: uint8(128),
  36881 			6: uint8(32),
  36882 			7: uint8(146),
  36883 			8: uint8(171),
  36884 		},
  36885 		8: {
  36886 			0: uint8(18),
  36887 			1: uint8(11),
  36888 			2: uint8(7),
  36889 			3: uint8(63),
  36890 			4: uint8(144),
  36891 			5: uint8(171),
  36892 			6: uint8(4),
  36893 			7: uint8(4),
  36894 			8: uint8(246),
  36895 		},
  36896 		9: {
  36897 			0: uint8(35),
  36898 			1: uint8(27),
  36899 			2: uint8(10),
  36900 			3: uint8(146),
  36901 			4: uint8(174),
  36902 			5: uint8(171),
  36903 			6: uint8(12),
  36904 			7: uint8(26),
  36905 			8: uint8(128),
  36906 		},
  36907 	},
  36908 	9: {
  36909 		0: {
  36910 			0: uint8(190),
  36911 			1: uint8(80),
  36912 			2: uint8(35),
  36913 			3: uint8(99),
  36914 			4: uint8(180),
  36915 			5: uint8(80),
  36916 			6: uint8(126),
  36917 			7: uint8(54),
  36918 			8: uint8(45),
  36919 		},
  36920 		1: {
  36921 			0: uint8(85),
  36922 			1: uint8(126),
  36923 			2: uint8(47),
  36924 			3: uint8(87),
  36925 			4: uint8(176),
  36926 			5: uint8(51),
  36927 			6: uint8(41),
  36928 			7: uint8(20),
  36929 			8: uint8(32),
  36930 		},
  36931 		2: {
  36932 			0: uint8(101),
  36933 			1: uint8(75),
  36934 			2: uint8(128),
  36935 			3: uint8(139),
  36936 			4: uint8(118),
  36937 			5: uint8(146),
  36938 			6: uint8(116),
  36939 			7: uint8(128),
  36940 			8: uint8(85),
  36941 		},
  36942 		3: {
  36943 			0: uint8(56),
  36944 			1: uint8(41),
  36945 			2: uint8(15),
  36946 			3: uint8(176),
  36947 			4: uint8(236),
  36948 			5: uint8(85),
  36949 			6: uint8(37),
  36950 			7: uint8(9),
  36951 			8: uint8(62),
  36952 		},
  36953 		4: {
  36954 			0: uint8(71),
  36955 			1: uint8(30),
  36956 			2: uint8(17),
  36957 			3: uint8(119),
  36958 			4: uint8(118),
  36959 			5: uint8(255),
  36960 			6: uint8(17),
  36961 			7: uint8(18),
  36962 			8: uint8(138),
  36963 		},
  36964 		5: {
  36965 			0: uint8(101),
  36966 			1: uint8(38),
  36967 			2: uint8(60),
  36968 			3: uint8(138),
  36969 			4: uint8(55),
  36970 			5: uint8(70),
  36971 			6: uint8(43),
  36972 			7: uint8(26),
  36973 			8: uint8(142),
  36974 		},
  36975 		6: {
  36976 			0: uint8(146),
  36977 			1: uint8(36),
  36978 			2: uint8(19),
  36979 			3: uint8(30),
  36980 			4: uint8(171),
  36981 			5: uint8(255),
  36982 			6: uint8(97),
  36983 			7: uint8(27),
  36984 			8: uint8(20),
  36985 		},
  36986 		7: {
  36987 			0: uint8(138),
  36988 			1: uint8(45),
  36989 			2: uint8(61),
  36990 			3: uint8(62),
  36991 			4: uint8(219),
  36992 			5: uint8(1),
  36993 			6: uint8(81),
  36994 			7: uint8(188),
  36995 			8: uint8(64),
  36996 		},
  36997 		8: {
  36998 			0: uint8(32),
  36999 			1: uint8(41),
  37000 			2: uint8(20),
  37001 			3: uint8(117),
  37002 			4: uint8(151),
  37003 			5: uint8(142),
  37004 			6: uint8(20),
  37005 			7: uint8(21),
  37006 			8: uint8(163),
  37007 		},
  37008 		9: {
  37009 			0: uint8(112),
  37010 			1: uint8(19),
  37011 			2: uint8(12),
  37012 			3: uint8(61),
  37013 			4: uint8(195),
  37014 			5: uint8(128),
  37015 			6: uint8(48),
  37016 			7: uint8(4),
  37017 			8: uint8(24),
  37018 		},
  37019 	},
  37020 }
  37021 
  37022 func PutI4Mode(tls *libc.TLS, bw uintptr, mode int32, prob uintptr) (r int32) {
  37023 	if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_DC_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob)))) != 0 {
  37024 		if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_TM_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 1)))) != 0 {
  37025 			if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_VE_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 2)))) != 0 {
  37026 				if !(VP8PutBit(tls, bw, libc.BoolInt32(mode >= int32(B_LD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 3)))) != 0) {
  37027 					if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_HE_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 4)))) != 0 {
  37028 						VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_RD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 5))))
  37029 					}
  37030 				} else {
  37031 					if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_LD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 6)))) != 0 {
  37032 						if VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_VL_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 7)))) != 0 {
  37033 							VP8PutBit(tls, bw, libc.BoolInt32(mode != int32(B_HD_PRED)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prob + 8))))
  37034 						}
  37035 					}
  37036 				}
  37037 			}
  37038 		}
  37039 	}
  37040 	return mode
  37041 }
  37042 
  37043 func PutI16Mode(tls *libc.TLS, bw uintptr, mode int32) {
  37044 	if VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(TM_PRED) || mode == int32(H_PRED)), int32(156)) != 0 {
  37045 		VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(TM_PRED)), int32(128)) // TM or HE
  37046 	} else {
  37047 		VP8PutBit(tls, bw, libc.BoolInt32(mode == int32(V_PRED)), int32(163)) // VE or DC
  37048 	}
  37049 }
  37050 
  37051 func PutUVMode(tls *libc.TLS, bw uintptr, uv_mode int32) {
  37052 	if VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(DC_PRED)), int32(142)) != 0 {
  37053 		if VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(V_PRED)), int32(114)) != 0 {
  37054 			VP8PutBit(tls, bw, libc.BoolInt32(uv_mode != int32(H_PRED)), int32(183)) // else: TM_PRED
  37055 		}
  37056 	}
  37057 }
  37058 
  37059 func PutSegment(tls *libc.TLS, bw uintptr, s int32, p uintptr) {
  37060 	if VP8PutBit(tls, bw, libc.BoolInt32(s >= int32(2)), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))) != 0 {
  37061 		p = p + uintptr(1)
  37062 	}
  37063 	VP8PutBit(tls, bw, s&int32(1), libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + 1))))
  37064 }
  37065 
  37066 func VP8CodeIntraModes(tls *libc.TLS, enc uintptr) {
  37067 	bp := tls.Alloc(3856)
  37068 	defer tls.Free(3856)
  37069 	var bw, mb, preds, probas, top_pred uintptr
  37070 	var left, preds_w, x, y int32
  37071 	var _ /* it at bp+0 */ VP8EncIterator
  37072 	_, _, _, _, _, _, _, _, _ = bw, left, mb, preds, preds_w, probas, top_pred, x, y
  37073 	bw = enc + 64
  37074 	VP8IteratorInit(tls, enc, bp)
  37075 	for cond := true; cond; cond = VP8IteratorNext(tls, bp) != 0 {
  37076 		mb = (**(**VP8EncIterator)(__ccgo_up(bp))).Fmb
  37077 		preds = (**(**VP8EncIterator)(__ccgo_up(bp))).Fpreds
  37078 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fsegment_hdr.Fupdate_map != 0 {
  37079 			PutSegment(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x60>>5)), enc+3616)
  37080 		}
  37081 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fuse_skip_proba != 0 {
  37082 			VP8PutBit(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x10>>4)), libc.Int32FromUint8((*VP8Encoder)(unsafe.Pointer(enc)).Fproba.Fskip_proba))
  37083 		}
  37084 		if VP8PutBit(tls, bw, libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0x3>>0)) != 0), int32(145)) != 0 { // i16x16
  37085 			PutI16Mode(tls, bw, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds))))
  37086 		} else {
  37087 			preds_w = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w
  37088 			top_pred = preds - uintptr(preds_w)
  37089 			y = 0
  37090 			for {
  37091 				if !(y < int32(4)) {
  37092 					break
  37093 				}
  37094 				left = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds + uintptr(-libc.Int32FromInt32(1)))))
  37095 				x = 0
  37096 				for {
  37097 					if !(x < int32(4)) {
  37098 						break
  37099 					}
  37100 					probas = uintptr(unsafe.Pointer(&kBModesProba1)) + uintptr(**(**uint8_t)(__ccgo_up(top_pred + uintptr(x))))*90 + uintptr(left)*9
  37101 					left = PutI4Mode(tls, bw, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(preds + uintptr(x)))), probas)
  37102 					goto _2
  37103 				_2:
  37104 					;
  37105 					x = x + 1
  37106 				}
  37107 				top_pred = preds
  37108 				preds = preds + uintptr(preds_w)
  37109 				goto _1
  37110 			_1:
  37111 				;
  37112 				y = y + 1
  37113 			}
  37114 		}
  37115 		PutUVMode(tls, bw, int32(uint32(*(*uint8)(unsafe.Pointer(mb + 0))&0xc>>2)))
  37116 	}
  37117 }
  37118 
  37119 func VP8WriteProbas(tls *libc.TLS, bw uintptr, probas uintptr) {
  37120 	var b, c, p, t, update int32
  37121 	var p0 uint8_t
  37122 	_, _, _, _, _, _ = b, c, p, p0, t, update
  37123 	t = 0
  37124 	for {
  37125 		if !(t < int32(NUM_TYPES)) {
  37126 			break
  37127 		}
  37128 		b = 0
  37129 		for {
  37130 			if !(b < int32(NUM_BANDS)) {
  37131 				break
  37132 			}
  37133 			c = 0
  37134 			for {
  37135 				if !(c < int32(NUM_CTX)) {
  37136 					break
  37137 				}
  37138 				p = 0
  37139 				for {
  37140 					if !(p < int32(NUM_PROBAS)) {
  37141 						break
  37142 					}
  37143 					p0 = **(**uint8_t)(__ccgo_up(probas + 4 + uintptr(t)*264 + uintptr(b)*33 + uintptr(c)*11 + uintptr(p)))
  37144 					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)))))
  37145 					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 {
  37146 						VP8PutBits(tls, bw, uint32(p0), int32(8))
  37147 					}
  37148 					goto _4
  37149 				_4:
  37150 					;
  37151 					p = p + 1
  37152 				}
  37153 				goto _3
  37154 			_3:
  37155 				;
  37156 				c = c + 1
  37157 			}
  37158 			goto _2
  37159 		_2:
  37160 			;
  37161 			b = b + 1
  37162 		}
  37163 		goto _1
  37164 	_1:
  37165 		;
  37166 		t = t + 1
  37167 	}
  37168 	if VP8PutBitUniform(tls, bw, (*VP8EncProba)(unsafe.Pointer(probas)).Fuse_skip_proba) != 0 {
  37169 		VP8PutBits(tls, bw, uint32((*VP8EncProba)(unsafe.Pointer(probas)).Fskip_proba), int32(8))
  37170 	}
  37171 }
  37172 
  37173 const MAX_HUFF_IMAGE_SIZE = 2600
  37174 const NUM_BUCKETS = 256
  37175 const VP8L_MAGIC_BYTE3 = 47
  37176 const VP8_SIGNATURE2 = 0x9d012a
  37177 
  37178 type HuffmanTreeToken = struct {
  37179 	Fcode       uint8_t
  37180 	Fextra_bits uint8_t
  37181 }
  37182 
  37183 type HuffmanTreeCode = struct {
  37184 	Fnum_symbols  int32
  37185 	Fcode_lengths uintptr
  37186 	Fcodes        uintptr
  37187 }
  37188 
  37189 type HuffmanTree = struct {
  37190 	Ftotal_count      uint32_t
  37191 	Fvalue            int32
  37192 	Fpool_index_left  int32
  37193 	Fpool_index_right int32
  37194 }
  37195 
  37196 type PaletteSorting1 = int32
  37197 
  37198 type PaletteSorting = int32
  37199 
  37200 const kSortedDefault = 0
  37201 const kMinimizeDelta = 1
  37202 const kModifiedZeng = 2
  37203 const kUnusedPalette = 3
  37204 const kPaletteSortingNum = 4
  37205 
  37206 // Copyright 2011 Google Inc. All Rights Reserved.
  37207 //
  37208 // Use of this source code is governed by a BSD-style license
  37209 // that can be found in the COPYING file in the root of the source
  37210 // tree. An additional intellectual property rights grant can be found
  37211 // in the file PATENTS. All contributing project authors may
  37212 // be found in the AUTHORS file in the root of the source tree.
  37213 // -----------------------------------------------------------------------------
  37214 //
  37215 // Multi-threaded worker
  37216 //
  37217 // Author: Skal (pascal.massimino@gmail.com)
  37218 
  37219 // Copyright 2012 Google Inc. All Rights Reserved.
  37220 //
  37221 // Use of this source code is governed by a BSD-style license
  37222 // that can be found in the COPYING file in the root of the source
  37223 // tree. An additional intellectual property rights grant can be found
  37224 // in the file PATENTS. All contributing project authors may
  37225 // be found in the AUTHORS file in the root of the source tree.
  37226 // -----------------------------------------------------------------------------
  37227 //
  37228 // Misc. common utility functions
  37229 //
  37230 // Authors: Skal (pascal.massimino@gmail.com)
  37231 //          Urvang (urvang@google.com)
  37232 
  37233 // Copyright 2011 Google Inc. All Rights Reserved.
  37234 //
  37235 // Use of this source code is governed by a BSD-style license
  37236 // that can be found in the COPYING file in the root of the source
  37237 // tree. An additional intellectual property rights grant can be found
  37238 // in the file PATENTS. All contributing project authors may
  37239 // be found in the AUTHORS file in the root of the source tree.
  37240 // -----------------------------------------------------------------------------
  37241 //
  37242 //   WebP encoder: main interface
  37243 //
  37244 // Author: Skal (pascal.massimino@gmail.com)
  37245 
  37246 // Copyright 2012 Google Inc. All Rights Reserved.
  37247 //
  37248 // Use of this source code is governed by a BSD-style license
  37249 // that can be found in the COPYING file in the root of the source
  37250 // tree. An additional intellectual property rights grant can be found
  37251 // in the file PATENTS. All contributing project authors may
  37252 // be found in the AUTHORS file in the root of the source tree.
  37253 // -----------------------------------------------------------------------------
  37254 //
  37255 //  Internal header for constants related to WebP file format.
  37256 //
  37257 // Author: Urvang (urvang@google.com)
  37258 
  37259 // Copyright 2010 Google Inc. All Rights Reserved.
  37260 //
  37261 // Use of this source code is governed by a BSD-style license
  37262 // that can be found in the COPYING file in the root of the source
  37263 // tree. An additional intellectual property rights grant can be found
  37264 // in the file PATENTS. All contributing project authors may
  37265 // be found in the AUTHORS file in the root of the source tree.
  37266 // -----------------------------------------------------------------------------
  37267 //
  37268 //  Common types + memory wrappers
  37269 //
  37270 // Author: Skal (pascal.massimino@gmail.com)
  37271 
  37272 // Maximum number of histogram images (sub-blocks).
  37273 // Empirical value for which it becomes too computationally expensive to
  37274 // compute the best predictor image.
  37275 
  37276 // -----------------------------------------------------------------------------
  37277 // Palette
  37278 
  37279 // C documentation
  37280 //
  37281 //	// These five modes are evaluated and their respective entropy is computed.
  37282 type EntropyIx = int32
  37283 
  37284 const kDirect = 0
  37285 const kSpatial = 1
  37286 const kSubGreen = 2
  37287 const kSpatialSubGreen = 3
  37288 const kPalette = 4
  37289 const kPaletteAndSpatial = 5
  37290 const kNumEntropyIx = 6
  37291 
  37292 type HistoIx = int32
  37293 
  37294 const kHistoAlpha = 0
  37295 const kHistoAlphaPred = 1
  37296 const kHistoGreen = 2
  37297 const kHistoGreenPred = 3
  37298 const kHistoRed = 4
  37299 const kHistoRedPred = 5
  37300 const kHistoBlue = 6
  37301 const kHistoBluePred = 7
  37302 const kHistoRedSubGreen = 8
  37303 const kHistoRedPredSubGreen = 9
  37304 const kHistoBlueSubGreen = 10
  37305 const kHistoBluePredSubGreen = 11
  37306 const kHistoPalette = 12
  37307 const kHistoTotal = 13
  37308 
  37309 type HistogramBuckets = [256]uint32_t
  37310 
  37311 // C documentation
  37312 //
  37313 //	// Keeping track of histograms, indexed by HistoIx.
  37314 //	// Ideally, this would just be a struct with meaningful fields, but the
  37315 //	// calculation of `entropy_comp` uses the index. One refactoring at a time :)
  37316 type Histograms = struct {
  37317 	Fcategory [13]HistogramBuckets
  37318 }
  37319 
  37320 func AddSingleSubGreen(tls *libc.TLS, p uint32_t, r uintptr, b uintptr) {
  37321 	var green int32
  37322 	_ = green
  37323 	green = libc.Int32FromUint32(p) >> int32(8) // The upper bits are masked away later.
  37324 	**(**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
  37325 	**(**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
  37326 }
  37327 
  37328 func AddSingle(tls *libc.TLS, p uint32_t, a uintptr, r uintptr, g uintptr, b uintptr) {
  37329 	**(**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
  37330 	**(**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
  37331 	**(**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
  37332 	**(**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
  37333 }
  37334 
  37335 func HashPix(tls *libc.TLS, pix uint32_t) (r uint8_t) {
  37336 	// Note that masking with 0xffffffffu is for preventing an
  37337 	// 'unsigned int overflow' warning. Doesn't impact the compiled code.
  37338 	return uint8((uint64(pix) + uint64(pix>>libc.Int32FromInt32(19))) * uint64(0x39c5fba7) & uint64(0xffffffff) >> int32(24))
  37339 }
  37340 
  37341 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) {
  37342 	bp := tls.Alloc(48)
  37343 	defer tls.Free(48)
  37344 	var alpha_and_green, pix, pix_diff, pix_prev, red_and_blue, v10, v12, v3, v4, v5, v9 uint32_t
  37345 	var blue_histo, curr_row, histo, prev_row, red_histo uintptr
  37346 	var entropy_comp [13]uint64_t
  37347 	var hash uint8_t
  37348 	var i, j, k, last_mode_to_analyze, x, y, v7 int32
  37349 	var v18 uint32
  37350 	var _ /* entropy at bp+0 */ [6]uint64_t
  37351 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  37352 	if use_palette != 0 && palette_size <= int32(16) {
  37353 		// In the case of small palettes, we pack 2, 4 or 8 pixels together. In
  37354 		// practice, small palettes are better than any other transform.
  37355 		**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = int32(kPalette)
  37356 		**(**int32)(__ccgo_up(red_and_blue_always_zero)) = int32(1)
  37357 		return int32(1)
  37358 	}
  37359 	histo = WebPSafeCalloc(tls, uint64(1), uint64(13312))
  37360 	if histo != libc.UintptrFromInt32(0) {
  37361 		prev_row = libc.UintptrFromInt32(0)
  37362 		curr_row = argb
  37363 		pix_prev = **(**uint32_t)(__ccgo_up(argb)) // Skip the first pixel.
  37364 		y = 0
  37365 		for {
  37366 			if !(y < height) {
  37367 				break
  37368 			}
  37369 			x = 0
  37370 			for {
  37371 				if !(x < width) {
  37372 					break
  37373 				}
  37374 				pix = **(**uint32_t)(__ccgo_up(curr_row + uintptr(x)*4))
  37375 				v3 = pix
  37376 				v4 = pix_prev
  37377 				alpha_and_green = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v4&uint32(0xff00ff00)
  37378 				red_and_blue = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v4&uint32(0x00ff00ff)
  37379 				v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  37380 				goto _6
  37381 			_6:
  37382 				pix_diff = v5
  37383 				pix_prev = pix
  37384 				if pix_diff == uint32(0) || prev_row != libc.UintptrFromInt32(0) && pix == **(**uint32_t)(__ccgo_up(prev_row + uintptr(x)*4)) {
  37385 					goto _2
  37386 				}
  37387 				AddSingle(tls, pix, histo+uintptr(kHistoAlpha)*1024, histo+uintptr(kHistoRed)*1024, histo+uintptr(kHistoGreen)*1024, histo+uintptr(kHistoBlue)*1024)
  37388 				AddSingle(tls, pix_diff, histo+uintptr(kHistoAlphaPred)*1024, histo+uintptr(kHistoRedPred)*1024, histo+uintptr(kHistoGreenPred)*1024, histo+uintptr(kHistoBluePred)*1024)
  37389 				AddSingleSubGreen(tls, pix, histo+uintptr(kHistoRedSubGreen)*1024, histo+uintptr(kHistoBlueSubGreen)*1024)
  37390 				AddSingleSubGreen(tls, pix_diff, histo+uintptr(kHistoRedPredSubGreen)*1024, histo+uintptr(kHistoBluePredSubGreen)*1024)
  37391 				// Approximate the palette by the entropy of the multiplicative hash.
  37392 				hash = HashPix(tls, pix)
  37393 				**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoPalette)*1024 + uintptr(hash)*4)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoPalette)*1024 + uintptr(hash)*4)) + 1
  37394 				goto _2
  37395 			_2:
  37396 				;
  37397 				x = x + 1
  37398 			}
  37399 			prev_row = curr_row
  37400 			curr_row = curr_row + uintptr(argb_stride)*4
  37401 			goto _1
  37402 		_1:
  37403 			;
  37404 			y = y + 1
  37405 		}
  37406 		if use_palette != 0 {
  37407 			v7 = int32(kPalette)
  37408 		} else {
  37409 			v7 = int32(kSpatialSubGreen)
  37410 		}
  37411 		last_mode_to_analyze = v7
  37412 		// Let's add one zero to the predicted histograms. The zeros are removed
  37413 		// too efficiently by the pix_diff == 0 comparison, at least one of the
  37414 		// zeros is likely to exist.
  37415 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPredSubGreen)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPredSubGreen)*1024)) + 1
  37416 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePredSubGreen)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePredSubGreen)*1024)) + 1
  37417 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoRedPred)*1024)) + 1
  37418 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoGreenPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoGreenPred)*1024)) + 1
  37419 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoBluePred)*1024)) + 1
  37420 		**(**uint32_t)(__ccgo_up(histo + uintptr(kHistoAlphaPred)*1024)) = **(**uint32_t)(__ccgo_up(histo + uintptr(kHistoAlphaPred)*1024)) + 1
  37421 		j = 0
  37422 		for {
  37423 			if !(j < int32(kHistoTotal)) {
  37424 				break
  37425 			}
  37426 			entropy_comp[j] = VP8LBitsEntropy(tls, histo+uintptr(j)*1024, int32(NUM_BUCKETS))
  37427 			goto _8
  37428 		_8:
  37429 			;
  37430 			j = j + 1
  37431 		}
  37432 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kDirect)] = entropy_comp[int32(kHistoAlpha)] + entropy_comp[int32(kHistoRed)] + entropy_comp[int32(kHistoGreen)] + entropy_comp[int32(kHistoBlue)]
  37433 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSpatial)] = entropy_comp[int32(kHistoAlphaPred)] + entropy_comp[int32(kHistoRedPred)] + entropy_comp[int32(kHistoGreenPred)] + entropy_comp[int32(kHistoBluePred)]
  37434 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSubGreen)] = entropy_comp[int32(kHistoAlpha)] + entropy_comp[int32(kHistoRedSubGreen)] + entropy_comp[int32(kHistoGreen)] + entropy_comp[int32(kHistoBlueSubGreen)]
  37435 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kSpatialSubGreen)] = entropy_comp[int32(kHistoAlphaPred)] + entropy_comp[int32(kHistoRedPredSubGreen)] + entropy_comp[int32(kHistoGreenPred)] + entropy_comp[int32(kHistoBluePredSubGreen)]
  37436 		(**(**[6]uint64_t)(__ccgo_up(bp)))[int32(kPalette)] = entropy_comp[int32(kHistoPalette)]
  37437 		// When including transforms, there is an overhead in bits from
  37438 		// storing them. This overhead is small but matters for small images.
  37439 		// For spatial, there are 14 transformations.
  37440 		v3 = libc.Uint32FromInt32(transform_bits)
  37441 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37442 		goto _11
  37443 	_11:
  37444 		v5 = libc.Uint32FromInt32(transform_bits)
  37445 		v9 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v5) - uint32(1)) >> v5
  37446 		goto _14
  37447 	_14:
  37448 		v10 = uint32(14)
  37449 		if v10 < uint32(LOG_LOOKUP_IDX_MAX) {
  37450 			v18 = kLog2Table[v10]
  37451 		} else {
  37452 			v18 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v10)
  37453 		}
  37454 		v12 = v18
  37455 		goto _17
  37456 	_17:
  37457 		**(**uint64_t)(__ccgo_up(bp + uintptr(kSpatial)*8)) += uint64(v4) * uint64(v9) * uint64(v12)
  37458 		// For color transforms: 24 as only 3 channels are considered in a
  37459 		// ColorTransformElement.
  37460 		v3 = libc.Uint32FromInt32(transform_bits)
  37461 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37462 		goto _21
  37463 	_21:
  37464 		v5 = libc.Uint32FromInt32(transform_bits)
  37465 		v9 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v5) - uint32(1)) >> v5
  37466 		goto _24
  37467 	_24:
  37468 		v10 = uint32(24)
  37469 		if v10 < uint32(LOG_LOOKUP_IDX_MAX) {
  37470 			v18 = kLog2Table[v10]
  37471 		} else {
  37472 			v18 = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastLog2Slow})))(tls, v10)
  37473 		}
  37474 		v12 = v18
  37475 		goto _27
  37476 	_27:
  37477 		**(**uint64_t)(__ccgo_up(bp + uintptr(kSpatialSubGreen)*8)) += uint64(v4) * uint64(v9) * uint64(v12)
  37478 		// For palettes, add the cost of storing the palette.
  37479 		// We empirically estimate the cost of a compressed entry as 8 bits.
  37480 		// The palette is differential-coded when compressed hence a much
  37481 		// lower cost than sizeof(uint32_t)*8.
  37482 		**(**uint64_t)(__ccgo_up(bp + uintptr(kPalette)*8)) += libc.Uint64FromInt32(palette_size) * uint64(8) << int32(LOG_2_PRECISION_BITS)
  37483 		**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = int32(kDirect)
  37484 		k = int32(kDirect) + libc.Int32FromInt32(1)
  37485 		for {
  37486 			if !(k <= last_mode_to_analyze) {
  37487 				break
  37488 			}
  37489 			if (**(**[6]uint64_t)(__ccgo_up(bp)))[**(**EntropyIx)(__ccgo_up(min_entropy_ix))] > (**(**[6]uint64_t)(__ccgo_up(bp)))[k] {
  37490 				**(**EntropyIx)(__ccgo_up(min_entropy_ix)) = k
  37491 			}
  37492 			goto _29
  37493 		_29:
  37494 			;
  37495 			k = k + 1
  37496 		}
  37497 		**(**int32)(__ccgo_up(red_and_blue_always_zero)) = int32(1)
  37498 		red_histo = histo + uintptr(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kHistoPairs)) + uintptr(**(**EntropyIx)(__ccgo_up(min_entropy_ix)))*2)))*1024
  37499 		blue_histo = histo + uintptr(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&kHistoPairs)) + uintptr(**(**EntropyIx)(__ccgo_up(min_entropy_ix)))*2 + 1)))*1024
  37500 		i = int32(1)
  37501 		for {
  37502 			if !(i < int32(NUM_BUCKETS)) {
  37503 				break
  37504 			}
  37505 			if **(**uint32_t)(__ccgo_up(red_histo + uintptr(i)*4))|**(**uint32_t)(__ccgo_up(blue_histo + uintptr(i)*4)) != uint32(0) {
  37506 				**(**int32)(__ccgo_up(red_and_blue_always_zero)) = 0
  37507 				break
  37508 			}
  37509 			goto _30
  37510 		_30:
  37511 			;
  37512 			i = i + 1
  37513 		}
  37514 		WebPSafeFree(tls, histo)
  37515 		return int32(1)
  37516 	} else {
  37517 		return 0
  37518 	}
  37519 	return r
  37520 }
  37521 
  37522 // Let's check if the histogram of the chosen entropy mode has
  37523 // non-zero red and blue values. If all are zero, we can later skip
  37524 // the cross color optimization.
  37525 
  37526 var kHistoPairs = [5][2]uint8_t{
  37527 	0: {
  37528 		0: uint8(kHistoRed),
  37529 		1: uint8(kHistoBlue),
  37530 	},
  37531 	1: {
  37532 		0: uint8(kHistoRedPred),
  37533 		1: uint8(kHistoBluePred),
  37534 	},
  37535 	2: {
  37536 		0: uint8(kHistoRedSubGreen),
  37537 		1: uint8(kHistoBlueSubGreen),
  37538 	},
  37539 	3: {
  37540 		0: uint8(kHistoRedPredSubGreen),
  37541 		1: uint8(kHistoBluePredSubGreen),
  37542 	},
  37543 	4: {
  37544 		0: uint8(kHistoRed),
  37545 		1: uint8(kHistoBlue),
  37546 	},
  37547 }
  37548 
  37549 // C documentation
  37550 //
  37551 //	// Clamp histogram and transform bits.
  37552 func ClampBits(tls *libc.TLS, width int32, height int32, bits int32, min_bits int32, max_bits int32, image_size_max int32) (r int32) {
  37553 	var image_size, v1, v2 int32
  37554 	var v3, v4, v6, v7 uint32_t
  37555 	_, _, _, _, _, _, _ = image_size, v1, v2, v3, v4, v6, v7
  37556 	if bits < min_bits {
  37557 		v1 = min_bits
  37558 	} else {
  37559 		if bits > max_bits {
  37560 			v2 = max_bits
  37561 		} else {
  37562 			v2 = bits
  37563 		}
  37564 		v1 = v2
  37565 	}
  37566 	bits = v1
  37567 	v3 = libc.Uint32FromInt32(bits)
  37568 	v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37569 	goto _5
  37570 _5:
  37571 	v6 = libc.Uint32FromInt32(bits)
  37572 	v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37573 	goto _8
  37574 _8:
  37575 	image_size = libc.Int32FromUint32(v4 * v7)
  37576 	for bits < max_bits && image_size > image_size_max {
  37577 		bits = bits + 1
  37578 		v3 = libc.Uint32FromInt32(bits)
  37579 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37580 		goto _11
  37581 	_11:
  37582 		v6 = libc.Uint32FromInt32(bits)
  37583 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37584 		goto _14
  37585 	_14:
  37586 		image_size = libc.Int32FromUint32(v4 * v7)
  37587 	}
  37588 	// In case the bits reduce the image too much, choose the smallest value
  37589 	// setting the histogram image size to 1.
  37590 	for bits > min_bits && image_size == int32(1) {
  37591 		v3 = libc.Uint32FromInt32(bits - int32(1))
  37592 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  37593 		goto _17
  37594 	_17:
  37595 		v6 = libc.Uint32FromInt32(bits - int32(1))
  37596 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  37597 		goto _20
  37598 	_20:
  37599 		image_size = libc.Int32FromUint32(v4 * v7)
  37600 		if image_size != int32(1) {
  37601 			break
  37602 		}
  37603 		bits = bits - 1
  37604 	}
  37605 	return bits
  37606 }
  37607 
  37608 func GetHistoBits(tls *libc.TLS, method int32, use_palette int32, width int32, height int32) (r int32) {
  37609 	var histo_bits, v1 int32
  37610 	_, _ = histo_bits, v1
  37611 	if use_palette != 0 {
  37612 		v1 = int32(9)
  37613 	} else {
  37614 		v1 = int32(7)
  37615 	}
  37616 	// Make tile size a function of encoding method (Range: 0 to 6).
  37617 	histo_bits = v1 - method
  37618 	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))
  37619 }
  37620 
  37621 func GetTransformBits(tls *libc.TLS, method int32, histo_bits int32) (r int32) {
  37622 	var max_transform_bits, res, v1, v2, v3 int32
  37623 	_, _, _, _, _ = max_transform_bits, res, v1, v2, v3
  37624 	if method < int32(4) {
  37625 		v1 = int32(6)
  37626 	} else {
  37627 		if method > int32(4) {
  37628 			v2 = int32(4)
  37629 		} else {
  37630 			v2 = int32(5)
  37631 		}
  37632 		v1 = v2
  37633 	}
  37634 	max_transform_bits = v1
  37635 	if histo_bits > max_transform_bits {
  37636 		v3 = max_transform_bits
  37637 	} else {
  37638 		v3 = histo_bits
  37639 	}
  37640 	res = v3
  37641 	return res
  37642 }
  37643 
  37644 // C documentation
  37645 //
  37646 //	// Set of parameters to be used in each iteration of the cruncher.
  37647 type CrunchSubConfig = struct {
  37648 	Flz77        int32
  37649 	Fdo_no_cache int32
  37650 }
  37651 
  37652 type CrunchConfig = struct {
  37653 	Fentropy_idx          int32
  37654 	Fpalette_sorting_type PaletteSorting1
  37655 	Fsub_configs          [2]CrunchSubConfig
  37656 	Fsub_configs_size     int32
  37657 }
  37658 
  37659 // +2 because we add a palette sorting configuration for kPalette and
  37660 // kPaletteAndSpatial.
  37661 
  37662 func EncoderAnalyze(tls *libc.TLS, enc uintptr, crunch_configs uintptr, crunch_configs_size uintptr, red_and_blue_always_zero uintptr) (r int32) {
  37663 	bp := tls.Alloc(16)
  37664 	defer tls.Free(16)
  37665 	var config, pic uintptr
  37666 	var do_no_cache, height, i, j, low_effort, method, n_lz77s, sorting_method, transform_bits, use_palette, width, v1 int32
  37667 	var typed_sorting_method PaletteSorting1
  37668 	var _ /* min_entropy_ix at bp+0 */ EntropyIx
  37669 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = config, do_no_cache, height, i, j, low_effort, method, n_lz77s, pic, sorting_method, transform_bits, typed_sorting_method, use_palette, width, v1
  37670 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  37671 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  37672 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  37673 	config = (*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig
  37674 	method = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  37675 	low_effort = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Fmethod == libc.Int32FromInt32(0))
  37676 	// If set to 0, analyze the cache with the computed cache value. If 1, also
  37677 	// analyze with no-cache.
  37678 	do_no_cache = 0
  37679 	// Check whether a palette is possible.
  37680 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size = GetColorPalette(tls, pic, enc+1128)
  37681 	use_palette = libc.BoolInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size <= int32(MAX_PALETTE_SIZE))
  37682 	if !(use_palette != 0) {
  37683 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size = 0
  37684 	}
  37685 	// Empirical bit sizes.
  37686 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits = GetHistoBits(tls, method, use_palette, (*WebPPicture)(unsafe.Pointer(pic)).Fwidth, (*WebPPicture)(unsafe.Pointer(pic)).Fheight)
  37687 	transform_bits = GetTransformBits(tls, method, (*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits)
  37688 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpredictor_transform_bits = transform_bits
  37689 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fcross_color_transform_bits = transform_bits
  37690 	if low_effort != 0 {
  37691 		// AnalyzeEntropy is somewhat slow.
  37692 		if use_palette != 0 {
  37693 			v1 = int32(kPalette)
  37694 		} else {
  37695 			v1 = int32(kSpatialSubGreen)
  37696 		}
  37697 		(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fentropy_idx = v1
  37698 		if use_palette != 0 {
  37699 			v1 = int32(kSortedDefault)
  37700 		} else {
  37701 			v1 = int32(kUnusedPalette)
  37702 		}
  37703 		(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fpalette_sorting_type = v1
  37704 		n_lz77s = int32(1)
  37705 		**(**int32)(__ccgo_up(crunch_configs_size)) = int32(1)
  37706 	} else {
  37707 		// Try out multiple LZ77 on images with few colors.
  37708 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size > 0 && (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size <= int32(16) {
  37709 			v1 = int32(2)
  37710 		} else {
  37711 			v1 = int32(1)
  37712 		}
  37713 		n_lz77s = v1
  37714 		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) {
  37715 			return 0
  37716 		}
  37717 		if method == int32(6) && (*WebPConfig)(unsafe.Pointer(config)).Fquality == libc.Float32FromInt32(100) {
  37718 			do_no_cache = int32(1)
  37719 			// Go brute force on all transforms.
  37720 			**(**int32)(__ccgo_up(crunch_configs_size)) = 0
  37721 			i = 0
  37722 			for {
  37723 				if !(i < int32(kNumEntropyIx)) {
  37724 					break
  37725 				}
  37726 				// We can only apply kPalette or kPaletteAndSpatial if we can indeed use
  37727 				// a palette.
  37728 				if i != int32(kPalette) && i != int32(kPaletteAndSpatial) || use_palette != 0 {
  37729 					if use_palette != 0 && (i == int32(kPalette) || i == int32(kPaletteAndSpatial)) {
  37730 						sorting_method = 0
  37731 						for {
  37732 							if !(sorting_method < int32(kPaletteSortingNum)) {
  37733 								break
  37734 							}
  37735 							typed_sorting_method = sorting_method
  37736 							// TODO(vrabaud) kSortedDefault should be tested. It is omitted
  37737 							// for now for backward compatibility.
  37738 							if typed_sorting_method == int32(kUnusedPalette) || typed_sorting_method == int32(kSortedDefault) {
  37739 								goto _5
  37740 							}
  37741 							(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fentropy_idx = i
  37742 							(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fpalette_sorting_type = typed_sorting_method
  37743 							**(**int32)(__ccgo_up(crunch_configs_size)) = **(**int32)(__ccgo_up(crunch_configs_size)) + 1
  37744 							goto _5
  37745 						_5:
  37746 							;
  37747 							sorting_method = sorting_method + 1
  37748 						}
  37749 					} else {
  37750 						(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fentropy_idx = i
  37751 						(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(**(**int32)(__ccgo_up(crunch_configs_size)))*28))).Fpalette_sorting_type = int32(kUnusedPalette)
  37752 						**(**int32)(__ccgo_up(crunch_configs_size)) = **(**int32)(__ccgo_up(crunch_configs_size)) + 1
  37753 					}
  37754 				}
  37755 				goto _4
  37756 			_4:
  37757 				;
  37758 				i = i + 1
  37759 			}
  37760 		} else {
  37761 			// Only choose the guessed best transform.
  37762 			**(**int32)(__ccgo_up(crunch_configs_size)) = int32(1)
  37763 			(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fentropy_idx = **(**EntropyIx)(__ccgo_up(bp))
  37764 			if use_palette != 0 {
  37765 				v1 = int32(kMinimizeDelta)
  37766 			} else {
  37767 				v1 = int32(kUnusedPalette)
  37768 			}
  37769 			(**(**CrunchConfig)(__ccgo_up(crunch_configs))).Fpalette_sorting_type = v1
  37770 			if (*WebPConfig)(unsafe.Pointer(config)).Fquality >= libc.Float32FromInt32(75) && method == int32(5) {
  37771 				// Test with and without color cache.
  37772 				do_no_cache = int32(1)
  37773 				// If we have a palette, also check in combination with spatial.
  37774 				if **(**EntropyIx)(__ccgo_up(bp)) == int32(kPalette) {
  37775 					**(**int32)(__ccgo_up(crunch_configs_size)) = int32(2)
  37776 					(**(**CrunchConfig)(__ccgo_up(crunch_configs + 1*28))).Fentropy_idx = int32(kPaletteAndSpatial)
  37777 					(**(**CrunchConfig)(__ccgo_up(crunch_configs + 1*28))).Fpalette_sorting_type = int32(kMinimizeDelta)
  37778 				}
  37779 			}
  37780 		}
  37781 	}
  37782 	// Fill in the different LZ77s.
  37783 	i = 0
  37784 	for {
  37785 		if !(i < **(**int32)(__ccgo_up(crunch_configs_size))) {
  37786 			break
  37787 		}
  37788 		j = 0
  37789 		for {
  37790 			if !(j < n_lz77s) {
  37791 				break
  37792 			}
  37793 			if j == 0 {
  37794 				v1 = int32(kLZ77Standard) | int32(kLZ77RLE)
  37795 			} else {
  37796 				v1 = int32(kLZ77Box)
  37797 			}
  37798 			(**(**CrunchSubConfig)(__ccgo_up(crunch_configs + uintptr(i)*28 + 8 + uintptr(j)*8))).Flz77 = v1
  37799 			(**(**CrunchSubConfig)(__ccgo_up(crunch_configs + uintptr(i)*28 + 8 + uintptr(j)*8))).Fdo_no_cache = do_no_cache
  37800 			goto _8
  37801 		_8:
  37802 			;
  37803 			j = j + 1
  37804 		}
  37805 		(**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(i)*28))).Fsub_configs_size = n_lz77s
  37806 		goto _7
  37807 	_7:
  37808 		;
  37809 		i = i + 1
  37810 	}
  37811 	return int32(1)
  37812 }
  37813 
  37814 func EncoderInit(tls *libc.TLS, enc uintptr) (r int32) {
  37815 	var height, i, pix_cnt, refs_block_size, width int32
  37816 	var pic uintptr
  37817 	_, _, _, _, _, _ = height, i, pic, pix_cnt, refs_block_size, width
  37818 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  37819 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  37820 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  37821 	pix_cnt = width * height
  37822 	// we round the block size up, so we're guaranteed to have
  37823 	// at most MAX_REFS_BLOCK_PER_IMAGE blocks used:
  37824 	refs_block_size = (pix_cnt-int32(1))/int32(MAX_REFS_BLOCK_PER_IMAGE) + int32(1)
  37825 	if !(VP8LHashChainInit(tls, enc+2312, pix_cnt) != 0) {
  37826 		return 0
  37827 	}
  37828 	i = 0
  37829 	for {
  37830 		if !(i < int32(4)) {
  37831 			break
  37832 		}
  37833 		VP8LBackwardRefsInit(tls, enc+2152+uintptr(i)*40, refs_block_size)
  37834 		goto _1
  37835 	_1:
  37836 		;
  37837 		i = i + 1
  37838 	}
  37839 	return int32(1)
  37840 }
  37841 
  37842 // C documentation
  37843 //
  37844 //	// Returns false in case of memory error.
  37845 func GetHuffBitLengthsAndCodes(tls *libc.TLS, histogram_image uintptr, huffman_codes uintptr) (r int32) {
  37846 	var bit_length, histogram_image_size, i, k, max_num_symbols, num_symbols, ok, v3, v4, v5, v7, v8 int32
  37847 	var buf_rle, codes, codes1, codes2, histo, histo1, huff_tree, lengths, mem_buf uintptr
  37848 	var total_length_size uint64_t
  37849 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  37850 	ok = 0
  37851 	total_length_size = uint64(0)
  37852 	mem_buf = libc.UintptrFromInt32(0)
  37853 	histogram_image_size = (*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fsize
  37854 	max_num_symbols = 0
  37855 	buf_rle = libc.UintptrFromInt32(0)
  37856 	huff_tree = libc.UintptrFromInt32(0)
  37857 	// Iterate over all histograms and get the aggregate number of codes used.
  37858 	i = 0
  37859 	for {
  37860 		if !(i < histogram_image_size) {
  37861 			break
  37862 		}
  37863 		histo = **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms + uintptr(i)*8))
  37864 		codes = huffman_codes + uintptr(int32(5)*i)*24
  37865 		k = 0
  37866 		for {
  37867 			if !(k < int32(5)) {
  37868 				break
  37869 			}
  37870 			if k == 0 {
  37871 				v4 = (*VP8LHistogram)(unsafe.Pointer(histo)).Fpalette_code_bits
  37872 				if v4 > 0 {
  37873 					v7 = int32(1) << v4
  37874 				} else {
  37875 					v7 = 0
  37876 				}
  37877 				v5 = libc.Int32FromInt32(NUM_LITERAL_CODES) + libc.Int32FromInt32(NUM_LENGTH_CODES) + v7
  37878 				goto _6
  37879 			_6:
  37880 				v3 = v5
  37881 			} else {
  37882 				if k == int32(4) {
  37883 					v8 = int32(NUM_DISTANCE_CODES)
  37884 				} else {
  37885 					v8 = int32(256)
  37886 				}
  37887 				v3 = v8
  37888 			}
  37889 			num_symbols = v3
  37890 			(**(**HuffmanTreeCode)(__ccgo_up(codes + uintptr(k)*24))).Fnum_symbols = num_symbols
  37891 			total_length_size = total_length_size + libc.Uint64FromInt32(num_symbols)
  37892 			goto _2
  37893 		_2:
  37894 			;
  37895 			k = k + 1
  37896 		}
  37897 		goto _1
  37898 	_1:
  37899 		;
  37900 		i = i + 1
  37901 	}
  37902 	// Allocate and Set Huffman codes.
  37903 	mem_buf = WebPSafeCalloc(tls, total_length_size, libc.Uint64FromInt64(1)+libc.Uint64FromInt64(2))
  37904 	if mem_buf == libc.UintptrFromInt32(0) {
  37905 		goto End
  37906 	}
  37907 	codes1 = mem_buf
  37908 	lengths = codes1 + uintptr(total_length_size)*2
  37909 	i = 0
  37910 	for {
  37911 		if !(i < int32(5)*histogram_image_size) {
  37912 			break
  37913 		}
  37914 		bit_length = (**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fnum_symbols
  37915 		(**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fcodes = codes1
  37916 		(**(**HuffmanTreeCode)(__ccgo_up(huffman_codes + uintptr(i)*24))).Fcode_lengths = lengths
  37917 		codes1 = codes1 + uintptr(bit_length)*2
  37918 		lengths = lengths + uintptr(bit_length)
  37919 		if max_num_symbols < bit_length {
  37920 			max_num_symbols = bit_length
  37921 		}
  37922 		goto _9
  37923 	_9:
  37924 		;
  37925 		i = i + 1
  37926 	}
  37927 	buf_rle = WebPSafeMalloc(tls, uint64(1), libc.Uint64FromInt32(max_num_symbols))
  37928 	huff_tree = WebPSafeMalloc(tls, uint64(3)*libc.Uint64FromInt32(max_num_symbols), uint64(16))
  37929 	if buf_rle == libc.UintptrFromInt32(0) || huff_tree == libc.UintptrFromInt32(0) {
  37930 		goto End
  37931 	}
  37932 	// Create Huffman trees.
  37933 	i = 0
  37934 	for {
  37935 		if !(i < histogram_image_size) {
  37936 			break
  37937 		}
  37938 		codes2 = huffman_codes + uintptr(int32(5)*i)*24
  37939 		histo1 = **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms + uintptr(i)*8))
  37940 		VP8LCreateHuffmanTree(tls, (*VP8LHistogram)(unsafe.Pointer(histo1)).Fliteral, int32(15), buf_rle, huff_tree, codes2+uintptr(0)*24)
  37941 		VP8LCreateHuffmanTree(tls, histo1+8, int32(15), buf_rle, huff_tree, codes2+uintptr(1)*24)
  37942 		VP8LCreateHuffmanTree(tls, histo1+1032, int32(15), buf_rle, huff_tree, codes2+uintptr(2)*24)
  37943 		VP8LCreateHuffmanTree(tls, histo1+2056, int32(15), buf_rle, huff_tree, codes2+uintptr(3)*24)
  37944 		VP8LCreateHuffmanTree(tls, histo1+3080, int32(15), buf_rle, huff_tree, codes2+uintptr(4)*24)
  37945 		goto _10
  37946 	_10:
  37947 		;
  37948 		i = i + 1
  37949 	}
  37950 	ok = int32(1)
  37951 	goto End
  37952 End:
  37953 	;
  37954 	WebPSafeFree(tls, huff_tree)
  37955 	WebPSafeFree(tls, buf_rle)
  37956 	if !(ok != 0) {
  37957 		WebPSafeFree(tls, mem_buf)
  37958 		libc.X__builtin___memset_chk(tls, huffman_codes, 0, libc.Uint64FromInt32(int32(5)*histogram_image_size)*uint64(24), ^__predefined_size_t(0))
  37959 	}
  37960 	return ok
  37961 }
  37962 
  37963 func StoreHuffmanTreeOfHuffmanTreeToBitMask(tls *libc.TLS, bw1 uintptr, code_length_bitdepth uintptr) {
  37964 	var codes_to_store, i, v4 int32
  37965 	var v2 uintptr
  37966 	var v3 uint32_t
  37967 	_, _, _, _, _ = codes_to_store, i, v2, v3, v4
  37968 	// Throw away trailing zeros:
  37969 	codes_to_store = int32(CODE_LENGTH_CODES)
  37970 	for {
  37971 		if !(codes_to_store > int32(4)) {
  37972 			break
  37973 		}
  37974 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(code_length_bitdepth + uintptr(kStorageOrder[codes_to_store-int32(1)])))) != 0 {
  37975 			break
  37976 		}
  37977 		goto _1
  37978 	_1:
  37979 		;
  37980 		codes_to_store = codes_to_store - 1
  37981 	}
  37982 	v2 = bw1
  37983 	v3 = libc.Uint32FromInt32(codes_to_store - int32(4))
  37984 	v4 = int32(4)
  37985 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  37986 		if v4 > libc.Int32FromInt32(0) {
  37987 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  37988 				VP8LPutBitsFlushBits(tls, v2)
  37989 			}
  37990 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  37991 			**(**int32)(__ccgo_up(v2 + 8)) += v4
  37992 		}
  37993 	} else {
  37994 		VP8LPutBitsInternal(tls, v2, v3, v4)
  37995 	}
  37996 	i = 0
  37997 	for {
  37998 		if !(i < codes_to_store) {
  37999 			break
  38000 		}
  38001 		v2 = bw1
  38002 		v3 = uint32(**(**uint8_t)(__ccgo_up(code_length_bitdepth + uintptr(kStorageOrder[i]))))
  38003 		v4 = int32(3)
  38004 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38005 			if v4 > libc.Int32FromInt32(0) {
  38006 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38007 					VP8LPutBitsFlushBits(tls, v2)
  38008 				}
  38009 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38010 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38011 			}
  38012 		} else {
  38013 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38014 		}
  38015 		goto _5
  38016 	_5:
  38017 		;
  38018 		i = i + 1
  38019 	}
  38020 }
  38021 
  38022 // RFC 1951 will calm you down if you are worried about this funny sequence.
  38023 // This sequence is tuned from that, but more weighted for lower symbol count,
  38024 // and more spiking histograms.
  38025 var kStorageOrder = [19]uint8_t{
  38026 	0:  uint8(17),
  38027 	1:  uint8(18),
  38028 	3:  uint8(1),
  38029 	4:  uint8(2),
  38030 	5:  uint8(3),
  38031 	6:  uint8(4),
  38032 	7:  uint8(5),
  38033 	8:  uint8(16),
  38034 	9:  uint8(6),
  38035 	10: uint8(7),
  38036 	11: uint8(8),
  38037 	12: uint8(9),
  38038 	13: uint8(10),
  38039 	14: uint8(11),
  38040 	15: uint8(12),
  38041 	16: uint8(13),
  38042 	17: uint8(14),
  38043 	18: uint8(15),
  38044 }
  38045 
  38046 func ClearHuffmanTreeIfOnlyOneSymbol(tls *libc.TLS, huffman_code uintptr) {
  38047 	var count, k int32
  38048 	_, _ = count, k
  38049 	count = 0
  38050 	k = 0
  38051 	for {
  38052 		if !(k < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols) {
  38053 			break
  38054 		}
  38055 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(k)))) != 0 {
  38056 			count = count + 1
  38057 			if count > int32(1) {
  38058 				return
  38059 			}
  38060 		}
  38061 		goto _1
  38062 	_1:
  38063 		;
  38064 		k = k + 1
  38065 	}
  38066 	k = 0
  38067 	for {
  38068 		if !(k < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols) {
  38069 			break
  38070 		}
  38071 		**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(k))) = uint8(0)
  38072 		**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcodes + uintptr(k)*2)) = uint16(0)
  38073 		goto _2
  38074 	_2:
  38075 		;
  38076 		k = k + 1
  38077 	}
  38078 }
  38079 
  38080 func StoreHuffmanTreeToBitMask(tls *libc.TLS, bw1 uintptr, tokens uintptr, num_tokens int32, huffman_code uintptr) {
  38081 	var extra_bits, i, ix, v4 int32
  38082 	var v2 uintptr
  38083 	var v3 uint32_t
  38084 	_, _, _, _, _, _ = extra_bits, i, ix, v2, v3, v4
  38085 	i = 0
  38086 	for {
  38087 		if !(i < num_tokens) {
  38088 			break
  38089 		}
  38090 		ix = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fcode)
  38091 		extra_bits = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i)*2))).Fextra_bits)
  38092 		v2 = bw1
  38093 		v3 = uint32(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcodes + uintptr(ix)*2)))
  38094 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(ix))))
  38095 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38096 			if v4 > libc.Int32FromInt32(0) {
  38097 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38098 					VP8LPutBitsFlushBits(tls, v2)
  38099 				}
  38100 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38101 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38102 			}
  38103 		} else {
  38104 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38105 		}
  38106 		switch ix {
  38107 		case int32(16):
  38108 			v2 = bw1
  38109 			v3 = libc.Uint32FromInt32(extra_bits)
  38110 			v4 = int32(2)
  38111 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38112 				if v4 > libc.Int32FromInt32(0) {
  38113 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38114 						VP8LPutBitsFlushBits(tls, v2)
  38115 					}
  38116 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38117 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38118 				}
  38119 			} else {
  38120 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38121 			}
  38122 		case int32(17):
  38123 			v2 = bw1
  38124 			v3 = libc.Uint32FromInt32(extra_bits)
  38125 			v4 = int32(3)
  38126 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38127 				if v4 > libc.Int32FromInt32(0) {
  38128 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38129 						VP8LPutBitsFlushBits(tls, v2)
  38130 					}
  38131 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38132 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38133 				}
  38134 			} else {
  38135 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38136 			}
  38137 		case int32(18):
  38138 			v2 = bw1
  38139 			v3 = libc.Uint32FromInt32(extra_bits)
  38140 			v4 = int32(7)
  38141 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38142 				if v4 > libc.Int32FromInt32(0) {
  38143 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38144 						VP8LPutBitsFlushBits(tls, v2)
  38145 					}
  38146 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38147 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38148 				}
  38149 			} else {
  38150 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38151 			}
  38152 			break
  38153 		}
  38154 		goto _1
  38155 	_1:
  38156 		;
  38157 		i = i + 1
  38158 	}
  38159 }
  38160 
  38161 // C documentation
  38162 //
  38163 //	// 'huff_tree' and 'tokens' are pre-alloacted buffers.
  38164 func StoreFullHuffmanCode(tls *libc.TLS, bw1 uintptr, huff_tree uintptr, tokens uintptr, tree uintptr) {
  38165 	bp := tls.Alloc(192)
  38166 	defer tls.Free(192)
  38167 	var i, i1, ix, length, max_tokens, nbitpairs, nbits, num_tokens, trailing_zero_bits, trimmed_length, write_trimmed_length, v3 int32
  38168 	var v1 uintptr
  38169 	var v2 uint32_t
  38170 	var _ /* buf_rle at bp+164 */ [19]uint8_t
  38171 	var _ /* code_length_bitdepth at bp+0 */ [19]uint8_t
  38172 	var _ /* code_length_bitdepth_symbols at bp+20 */ [19]uint16_t
  38173 	var _ /* histogram at bp+88 */ [19]uint32_t
  38174 	var _ /* huffman_code at bp+64 */ HuffmanTreeCode
  38175 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, i1, ix, length, max_tokens, nbitpairs, nbits, num_tokens, trailing_zero_bits, trimmed_length, write_trimmed_length, v1, v2, v3
  38176 	**(**[19]uint8_t)(__ccgo_up(bp)) = [19]uint8_t{}
  38177 	**(**[19]uint16_t)(__ccgo_up(bp + 20)) = [19]uint16_t{}
  38178 	max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  38179 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fnum_symbols = int32(CODE_LENGTH_CODES)
  38180 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fcode_lengths = bp
  38181 	(**(**HuffmanTreeCode)(__ccgo_up(bp + 64))).Fcodes = bp + 20
  38182 	v1 = bw1
  38183 	v2 = uint32(0)
  38184 	v3 = int32(1)
  38185 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38186 		if v3 > libc.Int32FromInt32(0) {
  38187 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38188 				VP8LPutBitsFlushBits(tls, v1)
  38189 			}
  38190 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38191 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38192 		}
  38193 	} else {
  38194 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38195 	}
  38196 	num_tokens = VP8LCreateCompressedHuffmanTree(tls, tree, tokens, max_tokens)
  38197 	**(**[19]uint32_t)(__ccgo_up(bp + 88)) = [19]uint32_t{}
  38198 	**(**[19]uint8_t)(__ccgo_up(bp + 164)) = [19]uint8_t{}
  38199 	i = 0
  38200 	for {
  38201 		if !(i < num_tokens) {
  38202 			break
  38203 		}
  38204 		(**(**[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
  38205 		goto _4
  38206 	_4:
  38207 		;
  38208 		i = i + 1
  38209 	}
  38210 	VP8LCreateHuffmanTree(tls, bp+88, int32(7), bp+164, huff_tree, bp+64)
  38211 	StoreHuffmanTreeOfHuffmanTreeToBitMask(tls, bw1, bp)
  38212 	ClearHuffmanTreeIfOnlyOneSymbol(tls, bp+64)
  38213 	trailing_zero_bits = 0
  38214 	trimmed_length = num_tokens
  38215 	i1 = num_tokens
  38216 	for {
  38217 		v3 = i1
  38218 		i1 = i1 - 1
  38219 		if !(v3 > 0) {
  38220 			break
  38221 		}
  38222 		ix = libc.Int32FromUint8((**(**HuffmanTreeToken)(__ccgo_up(tokens + uintptr(i1)*2))).Fcode)
  38223 		if ix == 0 || ix == int32(17) || ix == int32(18) {
  38224 			trimmed_length = trimmed_length - 1 // discount trailing zeros
  38225 			trailing_zero_bits = trailing_zero_bits + libc.Int32FromUint8((**(**[19]uint8_t)(__ccgo_up(bp)))[ix])
  38226 			if ix == int32(17) {
  38227 				trailing_zero_bits = trailing_zero_bits + int32(3)
  38228 			} else {
  38229 				if ix == int32(18) {
  38230 					trailing_zero_bits = trailing_zero_bits + int32(7)
  38231 				}
  38232 			}
  38233 		} else {
  38234 			break
  38235 		}
  38236 	}
  38237 	write_trimmed_length = libc.BoolInt32(trimmed_length > int32(1) && trailing_zero_bits > int32(12))
  38238 	if write_trimmed_length != 0 {
  38239 		v3 = trimmed_length
  38240 	} else {
  38241 		v3 = num_tokens
  38242 	}
  38243 	length = v3
  38244 	v1 = bw1
  38245 	v2 = libc.Uint32FromInt32(write_trimmed_length)
  38246 	v3 = int32(1)
  38247 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38248 		if v3 > libc.Int32FromInt32(0) {
  38249 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38250 				VP8LPutBitsFlushBits(tls, v1)
  38251 			}
  38252 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38253 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38254 		}
  38255 	} else {
  38256 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38257 	}
  38258 	if write_trimmed_length != 0 {
  38259 		if trimmed_length == int32(2) {
  38260 			v1 = bw1
  38261 			v2 = uint32(0)
  38262 			v3 = libc.Int32FromInt32(3) + libc.Int32FromInt32(2)
  38263 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38264 				if v3 > libc.Int32FromInt32(0) {
  38265 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38266 						VP8LPutBitsFlushBits(tls, v1)
  38267 					}
  38268 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38269 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38270 				}
  38271 			} else {
  38272 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38273 			} // nbitpairs=1, trimmed_length=2
  38274 		} else {
  38275 			v3 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(trimmed_length-int32(2)))
  38276 			goto _14
  38277 		_14:
  38278 			nbits = v3
  38279 			nbitpairs = nbits/int32(2) + int32(1)
  38280 			v1 = bw1
  38281 			v2 = libc.Uint32FromInt32(nbitpairs - int32(1))
  38282 			v3 = int32(3)
  38283 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38284 				if v3 > libc.Int32FromInt32(0) {
  38285 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38286 						VP8LPutBitsFlushBits(tls, v1)
  38287 					}
  38288 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38289 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38290 				}
  38291 			} else {
  38292 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38293 			}
  38294 			v1 = bw1
  38295 			v2 = libc.Uint32FromInt32(trimmed_length - int32(2))
  38296 			v3 = nbitpairs * int32(2)
  38297 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38298 				if v3 > libc.Int32FromInt32(0) {
  38299 					if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38300 						VP8LPutBitsFlushBits(tls, v1)
  38301 					}
  38302 					**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38303 					**(**int32)(__ccgo_up(v1 + 8)) += v3
  38304 				}
  38305 			} else {
  38306 				VP8LPutBitsInternal(tls, v1, v2, v3)
  38307 			}
  38308 		}
  38309 	}
  38310 	StoreHuffmanTreeToBitMask(tls, bw1, tokens, length, bp+64)
  38311 }
  38312 
  38313 // C documentation
  38314 //
  38315 //	// 'huff_tree' and 'tokens' are pre-alloacted buffers.
  38316 func StoreHuffmanCode(tls *libc.TLS, bw1 uintptr, huff_tree uintptr, tokens uintptr, huffman_code uintptr) {
  38317 	var count, i, kMaxBits, kMaxSymbol, v4 int32
  38318 	var symbols [2]int32
  38319 	var v2 uintptr
  38320 	var v3 uint32_t
  38321 	_, _, _, _, _, _, _, _ = count, i, kMaxBits, kMaxSymbol, symbols, v2, v3, v4
  38322 	count = 0
  38323 	symbols = [2]int32{}
  38324 	kMaxBits = int32(8)
  38325 	kMaxSymbol = int32(1) << kMaxBits
  38326 	// Check whether it's a small tree.
  38327 	i = 0
  38328 	for {
  38329 		if !(i < (*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fnum_symbols && count < int32(3)) {
  38330 			break
  38331 		}
  38332 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(huffman_code)).Fcode_lengths + uintptr(i)))) != 0 {
  38333 			if count < int32(2) {
  38334 				symbols[count] = i
  38335 			}
  38336 			count = count + 1
  38337 		}
  38338 		goto _1
  38339 	_1:
  38340 		;
  38341 		i = i + 1
  38342 	}
  38343 	if count == 0 { // emit minimal tree for empty cases
  38344 		// bits: small tree marker: 1, count-1: 0, large 8-bit code: 0, code: 0
  38345 		v2 = bw1
  38346 		v3 = uint32(0x01)
  38347 		v4 = int32(4)
  38348 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38349 			if v4 > libc.Int32FromInt32(0) {
  38350 				if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38351 					VP8LPutBitsFlushBits(tls, v2)
  38352 				}
  38353 				**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38354 				**(**int32)(__ccgo_up(v2 + 8)) += v4
  38355 			}
  38356 		} else {
  38357 			VP8LPutBitsInternal(tls, v2, v3, v4)
  38358 		}
  38359 	} else {
  38360 		if count <= int32(2) && symbols[0] < kMaxSymbol && symbols[int32(1)] < kMaxSymbol {
  38361 			v2 = bw1
  38362 			v3 = uint32(1)
  38363 			v4 = int32(1)
  38364 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38365 				if v4 > libc.Int32FromInt32(0) {
  38366 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38367 						VP8LPutBitsFlushBits(tls, v2)
  38368 					}
  38369 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38370 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38371 				}
  38372 			} else {
  38373 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38374 			} // Small tree marker to encode 1 or 2 symbols.
  38375 			v2 = bw1
  38376 			v3 = libc.Uint32FromInt32(count - int32(1))
  38377 			v4 = int32(1)
  38378 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38379 				if v4 > libc.Int32FromInt32(0) {
  38380 					if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38381 						VP8LPutBitsFlushBits(tls, v2)
  38382 					}
  38383 					**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38384 					**(**int32)(__ccgo_up(v2 + 8)) += v4
  38385 				}
  38386 			} else {
  38387 				VP8LPutBitsInternal(tls, v2, v3, v4)
  38388 			}
  38389 			if symbols[0] <= int32(1) {
  38390 				v2 = bw1
  38391 				v3 = uint32(0)
  38392 				v4 = int32(1)
  38393 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38394 					if v4 > libc.Int32FromInt32(0) {
  38395 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38396 							VP8LPutBitsFlushBits(tls, v2)
  38397 						}
  38398 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38399 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38400 					}
  38401 				} else {
  38402 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38403 				} // Code bit for small (1 bit) symbol value.
  38404 				v2 = bw1
  38405 				v3 = libc.Uint32FromInt32(symbols[0])
  38406 				v4 = int32(1)
  38407 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38408 					if v4 > libc.Int32FromInt32(0) {
  38409 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38410 							VP8LPutBitsFlushBits(tls, v2)
  38411 						}
  38412 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38413 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38414 					}
  38415 				} else {
  38416 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38417 				}
  38418 			} else {
  38419 				v2 = bw1
  38420 				v3 = uint32(1)
  38421 				v4 = int32(1)
  38422 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38423 					if v4 > libc.Int32FromInt32(0) {
  38424 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38425 							VP8LPutBitsFlushBits(tls, v2)
  38426 						}
  38427 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38428 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38429 					}
  38430 				} else {
  38431 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38432 				}
  38433 				v2 = bw1
  38434 				v3 = libc.Uint32FromInt32(symbols[0])
  38435 				v4 = int32(8)
  38436 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38437 					if v4 > libc.Int32FromInt32(0) {
  38438 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38439 							VP8LPutBitsFlushBits(tls, v2)
  38440 						}
  38441 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38442 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38443 					}
  38444 				} else {
  38445 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38446 				}
  38447 			}
  38448 			if count == int32(2) {
  38449 				v2 = bw1
  38450 				v3 = libc.Uint32FromInt32(symbols[int32(1)])
  38451 				v4 = int32(8)
  38452 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38453 					if v4 > libc.Int32FromInt32(0) {
  38454 						if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  38455 							VP8LPutBitsFlushBits(tls, v2)
  38456 						}
  38457 						**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  38458 						**(**int32)(__ccgo_up(v2 + 8)) += v4
  38459 					}
  38460 				} else {
  38461 					VP8LPutBitsInternal(tls, v2, v3, v4)
  38462 				}
  38463 			}
  38464 		} else {
  38465 			StoreFullHuffmanCode(tls, bw1, huff_tree, tokens, huffman_code)
  38466 		}
  38467 	}
  38468 }
  38469 
  38470 func WriteHuffmanCode(tls *libc.TLS, bw1 uintptr, code uintptr, code_index int32) {
  38471 	var depth, symbol, v3 int32
  38472 	var v1 uintptr
  38473 	var v2 uint32_t
  38474 	_, _, _, _, _ = depth, symbol, v1, v2, v3
  38475 	depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcode_lengths + uintptr(code_index))))
  38476 	symbol = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcodes + uintptr(code_index)*2)))
  38477 	v1 = bw1
  38478 	v2 = libc.Uint32FromInt32(symbol)
  38479 	v3 = depth
  38480 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38481 		if v3 > libc.Int32FromInt32(0) {
  38482 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38483 				VP8LPutBitsFlushBits(tls, v1)
  38484 			}
  38485 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38486 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38487 		}
  38488 	} else {
  38489 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38490 	}
  38491 }
  38492 
  38493 func WriteHuffmanCodeWithExtraBits(tls *libc.TLS, bw1 uintptr, code uintptr, code_index int32, bits1 int32, n_bits1 int32) {
  38494 	var depth, symbol, v3 int32
  38495 	var v1 uintptr
  38496 	var v2 uint32_t
  38497 	_, _, _, _, _ = depth, symbol, v1, v2, v3
  38498 	depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcode_lengths + uintptr(code_index))))
  38499 	symbol = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(code)).Fcodes + uintptr(code_index)*2)))
  38500 	v1 = bw1
  38501 	v2 = libc.Uint32FromInt32(bits1<<depth | symbol)
  38502 	v3 = depth + n_bits1
  38503 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38504 		if v3 > libc.Int32FromInt32(0) {
  38505 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38506 				VP8LPutBitsFlushBits(tls, v1)
  38507 			}
  38508 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38509 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38510 		}
  38511 	} else {
  38512 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38513 	}
  38514 }
  38515 
  38516 func StoreImageToBitMask(tls *libc.TLS, bw1 uintptr, width int32, histo_bits int32, refs uintptr, histogram_symbols uintptr, huffman_codes uintptr, pic uintptr) (r int32) {
  38517 	bp := tls.Alloc(48)
  38518 	defer tls.Free(48)
  38519 	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
  38520 	var codes, v, v20, v21, v22, v24 uintptr
  38521 	var prefix_code VP8LPrefixCode
  38522 	var v1 uint32
  38523 	var v2, v3 uint32_t
  38524 	var _ /* bits at bp+24 */ int32
  38525 	var _ /* c at bp+0 */ VP8LRefsCursor
  38526 	var _ /* code at bp+32 */ int32
  38527 	var _ /* n_bits at bp+28 */ int32
  38528 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  38529 	if histo_bits != 0 {
  38530 		v2 = libc.Uint32FromInt32(histo_bits)
  38531 		v3 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  38532 		goto _4
  38533 	_4:
  38534 		v1 = v3
  38535 	} else {
  38536 		v1 = uint32(1)
  38537 	}
  38538 	histo_xsize = libc.Int32FromUint32(v1)
  38539 	if histo_bits == 0 {
  38540 		v5 = 0
  38541 	} else {
  38542 		v5 = -(int32(1) << histo_bits)
  38543 	}
  38544 	tile_mask = v5
  38545 	// x and y trace the position in the image.
  38546 	x = 0
  38547 	y = 0
  38548 	tile_x = x & tile_mask
  38549 	tile_y = y & tile_mask
  38550 	histogram_ix = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(histogram_symbols)) >> libc.Int32FromInt32(8) & uint32(0xffff))
  38551 	codes = huffman_codes + uintptr(int32(5)*histogram_ix)*24
  38552 	**(**VP8LRefsCursor)(__ccgo_up(bp)) = VP8LRefsCursorInit(tls, refs)
  38553 	for {
  38554 		v6 = libc.BoolInt32((*VP8LRefsCursor)(unsafe.Pointer(bp)).Fcur_pos != libc.UintptrFromInt32(0))
  38555 		goto _7
  38556 	_7:
  38557 		if !(v6 != 0) {
  38558 			break
  38559 		}
  38560 		v = (**(**VP8LRefsCursor)(__ccgo_up(bp))).Fcur_pos
  38561 		if tile_x != x&tile_mask || tile_y != y&tile_mask {
  38562 			tile_x = x & tile_mask
  38563 			tile_y = y & tile_mask
  38564 			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))
  38565 			codes = huffman_codes + uintptr(int32(5)*histogram_ix)*24
  38566 		}
  38567 		v5 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kLiteral))
  38568 		goto _9
  38569 	_9:
  38570 		if v5 != 0 {
  38571 			k = 0
  38572 			for {
  38573 				if !(k < int32(4)) {
  38574 					break
  38575 				}
  38576 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance >> (libc.Int32FromUint8(order[k]) * libc.Int32FromInt32(8)) & uint32(0xff)
  38577 				goto _12
  38578 			_12:
  38579 				code2 = libc.Int32FromUint32(v2)
  38580 				WriteHuffmanCode(tls, bw1, codes+uintptr(k)*24, code2)
  38581 				goto _10
  38582 			_10:
  38583 				;
  38584 				k = k + 1
  38585 			}
  38586 		} else {
  38587 			v5 = libc.BoolInt32(libc.Int32FromUint8((*PixOrCopy)(unsafe.Pointer(v)).Fmode) == int32(kCacheIdx))
  38588 			goto _14
  38589 		_14:
  38590 			if v5 != 0 {
  38591 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  38592 				goto _16
  38593 			_16:
  38594 				code3 = libc.Int32FromUint32(v2)
  38595 				literal_ix = libc.Int32FromInt32(256) + libc.Int32FromInt32(NUM_LENGTH_CODES) + code3
  38596 				WriteHuffmanCode(tls, bw1, codes, literal_ix)
  38597 			} else {
  38598 				v2 = (*PixOrCopy)(unsafe.Pointer(v)).Fargb_or_distance
  38599 				goto _18
  38600 			_18:
  38601 				distance2 = libc.Int32FromUint32(v2)
  38602 				v5 = libc.Int32FromUint16((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  38603 				v20 = bp + 32
  38604 				v21 = bp + 28
  38605 				v22 = bp + 24
  38606 				if v5 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  38607 					prefix_code = kPrefixEncodeCode[v5]
  38608 					**(**int32)(__ccgo_up(v20)) = int32(prefix_code.Fcode)
  38609 					**(**int32)(__ccgo_up(v21)) = int32(prefix_code.Fextra_bits)
  38610 					**(**int32)(__ccgo_up(v22)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v5])
  38611 				} else {
  38612 					v6 = v5
  38613 					v24 = v21
  38614 					v6 = v6 - 1
  38615 					v8 = v6
  38616 					v13 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v8))
  38617 					goto _27
  38618 				_27:
  38619 					highest_bit = v13
  38620 					second_highest_bit = v6 >> (highest_bit - int32(1)) & int32(1)
  38621 					**(**int32)(__ccgo_up(v24)) = highest_bit - int32(1)
  38622 					**(**int32)(__ccgo_up(v22)) = v6 & (int32(1)<<**(**int32)(__ccgo_up(v24)) - int32(1))
  38623 					**(**int32)(__ccgo_up(v20)) = int32(2)*highest_bit + second_highest_bit
  38624 				}
  38625 				WriteHuffmanCodeWithExtraBits(tls, bw1, codes, int32(256)+**(**int32)(__ccgo_up(bp + 32)), **(**int32)(__ccgo_up(bp + 24)), **(**int32)(__ccgo_up(bp + 28)))
  38626 				// Don't write the distance with the extra bits code since
  38627 				// the distance can be up to 18 bits of extra bits, and the prefix
  38628 				// 15 bits, totaling to 33, and our PutBits only supports up to 32 bits.
  38629 				v5 = distance2
  38630 				v20 = bp + 32
  38631 				v21 = bp + 28
  38632 				v22 = bp + 24
  38633 				if v5 < libc.Int32FromInt32(PREFIX_LOOKUP_IDX_MAX) {
  38634 					prefix_code = kPrefixEncodeCode[v5]
  38635 					**(**int32)(__ccgo_up(v20)) = int32(prefix_code.Fcode)
  38636 					**(**int32)(__ccgo_up(v21)) = int32(prefix_code.Fextra_bits)
  38637 					**(**int32)(__ccgo_up(v22)) = libc.Int32FromUint8(kPrefixEncodeExtraBitsValue[v5])
  38638 				} else {
  38639 					v6 = v5
  38640 					v24 = v21
  38641 					v6 = v6 - 1
  38642 					v8 = v6
  38643 					v13 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32(v8))
  38644 					goto _36
  38645 				_36:
  38646 					highest_bit = v13
  38647 					second_highest_bit = v6 >> (highest_bit - int32(1)) & int32(1)
  38648 					**(**int32)(__ccgo_up(v24)) = highest_bit - int32(1)
  38649 					**(**int32)(__ccgo_up(v22)) = v6 & (int32(1)<<**(**int32)(__ccgo_up(v24)) - int32(1))
  38650 					**(**int32)(__ccgo_up(v20)) = int32(2)*highest_bit + second_highest_bit
  38651 				}
  38652 				WriteHuffmanCode(tls, bw1, codes+uintptr(4)*24, **(**int32)(__ccgo_up(bp + 32)))
  38653 				v20 = bw1
  38654 				v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 24)))
  38655 				v5 = **(**int32)(__ccgo_up(bp + 28))
  38656 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38657 					if v5 > libc.Int32FromInt32(0) {
  38658 						if (*VP8LBitWriter)(unsafe.Pointer(v20)).Fused >= libc.Int32FromInt32(32) {
  38659 							VP8LPutBitsFlushBits(tls, v20)
  38660 						}
  38661 						**(**vp8l_atype_t)(__ccgo_up(v20)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v20)).Fused
  38662 						**(**int32)(__ccgo_up(v20 + 8)) += v5
  38663 					}
  38664 				} else {
  38665 					VP8LPutBitsInternal(tls, v20, v2, v5)
  38666 				}
  38667 			}
  38668 		}
  38669 		v2 = uint32((*PixOrCopy)(unsafe.Pointer(v)).Flen1)
  38670 		goto _41
  38671 	_41:
  38672 		x = libc.Int32FromUint32(uint32(x) + v2)
  38673 		for x >= width {
  38674 			x = x - width
  38675 			y = y + 1
  38676 		}
  38677 		v20 = bp
  38678 		v22 = v20
  38679 		*(*uintptr)(unsafe.Pointer(v22)) += 8
  38680 		v21 = *(*uintptr)(unsafe.Pointer(v22))
  38681 		if v21 == (*VP8LRefsCursor)(unsafe.Pointer(v20)).Flast_pos {
  38682 			VP8LRefsCursorNextBlock(tls, v20)
  38683 		}
  38684 	}
  38685 	if (*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  38686 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38687 	}
  38688 	return int32(1)
  38689 }
  38690 
  38691 var order = [4]uint8_t{
  38692 	0: uint8(1),
  38693 	1: uint8(2),
  38694 	3: uint8(3),
  38695 }
  38696 
  38697 // C documentation
  38698 //
  38699 //	// Special case of EncodeImageInternal() for cache-bits=0, histo_bits=31.
  38700 //	// pic and percent are for progress.
  38701 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) {
  38702 	bp := tls.Alloc(128)
  38703 	defer tls.Free(128)
  38704 	var codes, codes1, histogram_image, huff_tree, refs, tokens, v1 uintptr
  38705 	var i, max_tokens, v3 int32
  38706 	var v2 uint32_t
  38707 	var _ /* cache_bits at bp+124 */ int32
  38708 	var _ /* histogram_symbols at bp+120 */ [1]uint32_t
  38709 	var _ /* huffman_codes at bp+0 */ [5]HuffmanTreeCode
  38710 	_, _, _, _, _, _, _, _, _, _, _ = codes, codes1, histogram_image, huff_tree, i, max_tokens, refs, tokens, v1, v2, v3
  38711 	max_tokens = 0
  38712 	tokens = libc.UintptrFromInt32(0)
  38713 	**(**[5]HuffmanTreeCode)(__ccgo_up(bp)) = [5]HuffmanTreeCode{}
  38714 	**(**[1]uint32_t)(__ccgo_up(bp + 120)) = [1]uint32_t{} // only one tree, one symbol
  38715 	**(**int32)(__ccgo_up(bp + 124)) = 0
  38716 	histogram_image = libc.UintptrFromInt32(0)
  38717 	huff_tree = WebPSafeMalloc(tls, libc.Uint64FromUint64(3)*libc.Uint64FromInt32(CODE_LENGTH_CODES), uint64(16))
  38718 	if huff_tree == libc.UintptrFromInt32(0) {
  38719 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38720 		goto Error
  38721 	}
  38722 	// Calculate backward references from ARGB image.
  38723 	if !(VP8LHashChainFill(tls, hash_chain, quality, argb, width, height, low_effort, pic, percent_range/int32(2), percent) != 0) {
  38724 		goto Error
  38725 	}
  38726 	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) {
  38727 		goto Error
  38728 	}
  38729 	refs = refs_array
  38730 	histogram_image = VP8LAllocateHistogramSet(tls, int32(1), **(**int32)(__ccgo_up(bp + 124)))
  38731 	if histogram_image == libc.UintptrFromInt32(0) {
  38732 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38733 		goto Error
  38734 	}
  38735 	VP8LHistogramSetClear(tls, histogram_image)
  38736 	// Build histogram image and symbols from backward references.
  38737 	VP8LHistogramStoreRefs(tls, refs, libc.UintptrFromInt32(0), 0, **(**uintptr)(__ccgo_up((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fhistograms)))
  38738 	// Create Huffman bit lengths and codes for each histogram image.
  38739 	if !(GetHuffBitLengthsAndCodes(tls, histogram_image, bp) != 0) {
  38740 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38741 		goto Error
  38742 	}
  38743 	// No color cache, no Huffman image.
  38744 	v1 = bw1
  38745 	v2 = uint32(0)
  38746 	v3 = int32(1)
  38747 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38748 		if v3 > libc.Int32FromInt32(0) {
  38749 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  38750 				VP8LPutBitsFlushBits(tls, v1)
  38751 			}
  38752 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  38753 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  38754 		}
  38755 	} else {
  38756 		VP8LPutBitsInternal(tls, v1, v2, v3)
  38757 	}
  38758 	// Find maximum number of symbols for the huffman tree-set.
  38759 	i = 0
  38760 	for {
  38761 		if !(i < int32(5)) {
  38762 			break
  38763 		}
  38764 		codes = bp + uintptr(i)*24
  38765 		if max_tokens < (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols {
  38766 			max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols
  38767 		}
  38768 		goto _4
  38769 	_4:
  38770 		;
  38771 		i = i + 1
  38772 	}
  38773 	tokens = WebPSafeMalloc(tls, libc.Uint64FromInt32(max_tokens), uint64(2))
  38774 	if tokens == libc.UintptrFromInt32(0) {
  38775 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38776 		goto Error
  38777 	}
  38778 	// Store Huffman codes.
  38779 	i = 0
  38780 	for {
  38781 		if !(i < int32(5)) {
  38782 			break
  38783 		}
  38784 		codes1 = bp + uintptr(i)*24
  38785 		StoreHuffmanCode(tls, bw1, huff_tree, tokens, codes1)
  38786 		ClearHuffmanTreeIfOnlyOneSymbol(tls, codes1)
  38787 		goto _5
  38788 	_5:
  38789 		;
  38790 		i = i + 1
  38791 	}
  38792 	// Store actual literals.
  38793 	if !(StoreImageToBitMask(tls, bw1, width, 0, refs, bp+120, bp, pic) != 0) {
  38794 		goto Error
  38795 	}
  38796 	goto Error
  38797 Error:
  38798 	;
  38799 	WebPSafeFree(tls, tokens)
  38800 	WebPSafeFree(tls, huff_tree)
  38801 	VP8LFreeHistogramSet(tls, histogram_image)
  38802 	WebPSafeFree(tls, (**(**[5]HuffmanTreeCode)(__ccgo_up(bp)))[0].Fcodes)
  38803 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  38804 }
  38805 
  38806 // C documentation
  38807 //
  38808 //	// pic and percent are for progress.
  38809 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) {
  38810 	bp := tls.Alloc(128)
  38811 	defer tls.Free(128)
  38812 	var bit_array_size, bw_size_best, v37, v40 size_t
  38813 	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
  38814 	var codes, codes1, histogram_argb, histogram_image, huff_tree, huffman_codes, sub_config, tmp_histo, tokens, v12, v15 uintptr
  38815 	var histogram_image_size, histogram_image_xysize, i, v1, v2, v4, v5 uint32_t
  38816 	var _ /* bw_best at bp+48 */ VP8LBitWriter
  38817 	var _ /* bw_init at bp+0 */ VP8LBitWriter
  38818 	var _ /* cache_bits_best at bp+112 */ int32
  38819 	var _ /* hash_chain_histogram at bp+96 */ VP8LHashChain
  38820 	var _ /* histogram_bits at bp+116 */ int32
  38821 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  38822 	v1 = libc.Uint32FromInt32(histogram_bits_in)
  38823 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  38824 	goto _3
  38825 _3:
  38826 	v4 = libc.Uint32FromInt32(histogram_bits_in)
  38827 	v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  38828 	goto _6
  38829 _6:
  38830 	histogram_image_xysize = v2 * v5
  38831 	remaining_percent = percent_range
  38832 	percent_start = **(**int32)(__ccgo_up(percent))
  38833 	histogram_image = libc.UintptrFromInt32(0)
  38834 	tmp_histo = libc.UintptrFromInt32(0)
  38835 	histogram_image_size = uint32(0)
  38836 	bit_array_size = uint64(0)
  38837 	huff_tree = WebPSafeMalloc(tls, libc.Uint64FromUint64(3)*libc.Uint64FromInt32(CODE_LENGTH_CODES), uint64(16))
  38838 	tokens = libc.UintptrFromInt32(0)
  38839 	huffman_codes = libc.UintptrFromInt32(0)
  38840 	histogram_argb = WebPSafeMalloc(tls, uint64(histogram_image_xysize), uint64(4))
  38841 	**(**VP8LBitWriter)(__ccgo_up(bp)) = **(**VP8LBitWriter)(__ccgo_up(bw2)) // histogram image hash chain
  38842 	bw_size_best = ^libc.Uint64FromInt32(0)
  38843 	libc.X__builtin___memset_chk(tls, bp+96, 0, uint64(16), ^__predefined_size_t(0))
  38844 	if !(VP8LBitWriterInit(tls, bp+48, uint64(0)) != 0) {
  38845 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38846 		goto Error
  38847 	}
  38848 	// Make sure we can allocate the different objects.
  38849 	if huff_tree == libc.UintptrFromInt32(0) || histogram_argb == libc.UintptrFromInt32(0) || !(VP8LHashChainInit(tls, bp+96, libc.Int32FromUint32(histogram_image_xysize)) != 0) {
  38850 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38851 		goto Error
  38852 	}
  38853 	percent_range = remaining_percent / int32(5)
  38854 	if !(VP8LHashChainFill(tls, hash_chain, quality, argb, width, height, low_effort, pic, percent_range, percent) != 0) {
  38855 		goto Error
  38856 	}
  38857 	percent_start = percent_start + percent_range
  38858 	remaining_percent = remaining_percent - percent_range
  38859 	// If the value is different from zero, it has been set during the palette
  38860 	// analysis.
  38861 	if **(**int32)(__ccgo_up(cache_bits)) == 0 {
  38862 		v7 = int32(MAX_COLOR_CACHE_BITS)
  38863 	} else {
  38864 		v7 = **(**int32)(__ccgo_up(cache_bits))
  38865 	}
  38866 	cache_bits_init = v7
  38867 	// If several iterations will happen, clone into bw_best.
  38868 	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) {
  38869 		WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38870 		goto Error
  38871 	}
  38872 	sub_configs_idx = 0
  38873 	for {
  38874 		if !(sub_configs_idx < (*CrunchConfig)(unsafe.Pointer(config)).Fsub_configs_size) {
  38875 			break
  38876 		}
  38877 		sub_config = config + 8 + uintptr(sub_configs_idx)*8
  38878 		i_remaining_percent = remaining_percent / (*CrunchConfig)(unsafe.Pointer(config)).Fsub_configs_size
  38879 		i_percent_range = i_remaining_percent / int32(4)
  38880 		i_remaining_percent = i_remaining_percent - i_percent_range
  38881 		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) {
  38882 			goto Error
  38883 		}
  38884 		i_cache = 0
  38885 		for {
  38886 			if (*CrunchSubConfig)(unsafe.Pointer(sub_config)).Fdo_no_cache != 0 {
  38887 				v7 = int32(2)
  38888 			} else {
  38889 				v7 = int32(1)
  38890 			}
  38891 			if !(i_cache < v7) {
  38892 				break
  38893 			}
  38894 			if i_cache == 0 {
  38895 				v10 = **(**int32)(__ccgo_up(bp + 112))
  38896 			} else {
  38897 				v10 = 0
  38898 			}
  38899 			cache_bits_tmp = v10
  38900 			**(**int32)(__ccgo_up(bp + 116)) = histogram_bits_in
  38901 			// Speed-up: no need to study the no-cache case if it was already studied
  38902 			// in i_cache == 0.
  38903 			if i_cache == int32(1) && **(**int32)(__ccgo_up(bp + 112)) == 0 {
  38904 				break
  38905 			}
  38906 			// Reset the bit writer for this iteration.
  38907 			VP8LBitWriterReset(tls, bp, bw2)
  38908 			// Build histogram image and symbols from backward references.
  38909 			histogram_image = VP8LAllocateHistogramSet(tls, libc.Int32FromUint32(histogram_image_xysize), cache_bits_tmp)
  38910 			tmp_histo = VP8LAllocateHistogram(tls, cache_bits_tmp)
  38911 			if histogram_image == libc.UintptrFromInt32(0) || tmp_histo == libc.UintptrFromInt32(0) {
  38912 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38913 				goto Error
  38914 			}
  38915 			i_percent_range = i_remaining_percent / int32(3)
  38916 			i_remaining_percent = i_remaining_percent - i_percent_range
  38917 			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) {
  38918 				goto Error
  38919 			}
  38920 			// Create Huffman bit lengths and codes for each histogram image.
  38921 			histogram_image_size = libc.Uint32FromInt32((*VP8LHistogramSet)(unsafe.Pointer(histogram_image)).Fsize)
  38922 			bit_array_size = uint64(uint32(5) * histogram_image_size)
  38923 			huffman_codes = WebPSafeCalloc(tls, bit_array_size, uint64(24))
  38924 			// Note: some histogram_image entries may point to tmp_histos[], so the
  38925 			// latter need to outlive the following call to
  38926 			// GetHuffBitLengthsAndCodes().
  38927 			if huffman_codes == libc.UintptrFromInt32(0) || !(GetHuffBitLengthsAndCodes(tls, histogram_image, huffman_codes) != 0) {
  38928 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  38929 				goto Error
  38930 			}
  38931 			// Free combined histograms.
  38932 			VP8LFreeHistogramSet(tls, histogram_image)
  38933 			histogram_image = libc.UintptrFromInt32(0)
  38934 			// Free scratch histograms.
  38935 			VP8LFreeHistogram(tls, tmp_histo)
  38936 			tmp_histo = libc.UintptrFromInt32(0)
  38937 			// Color Cache parameters.
  38938 			if cache_bits_tmp > 0 {
  38939 				v12 = bw2
  38940 				v1 = uint32(1)
  38941 				v7 = int32(1)
  38942 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38943 					if v7 > libc.Int32FromInt32(0) {
  38944 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38945 							VP8LPutBitsFlushBits(tls, v12)
  38946 						}
  38947 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38948 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38949 					}
  38950 				} else {
  38951 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38952 				}
  38953 				v12 = bw2
  38954 				v1 = libc.Uint32FromInt32(cache_bits_tmp)
  38955 				v7 = int32(4)
  38956 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38957 					if v7 > libc.Int32FromInt32(0) {
  38958 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38959 							VP8LPutBitsFlushBits(tls, v12)
  38960 						}
  38961 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38962 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38963 					}
  38964 				} else {
  38965 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38966 				}
  38967 			} else {
  38968 				v12 = bw2
  38969 				v1 = uint32(0)
  38970 				v7 = int32(1)
  38971 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  38972 					if v7 > libc.Int32FromInt32(0) {
  38973 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  38974 							VP8LPutBitsFlushBits(tls, v12)
  38975 						}
  38976 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  38977 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  38978 					}
  38979 				} else {
  38980 					VP8LPutBitsInternal(tls, v12, v1, v7)
  38981 				}
  38982 			}
  38983 			// Huffman image + meta huffman.
  38984 			histogram_image_size = uint32(0)
  38985 			i = uint32(0)
  38986 			for {
  38987 				if !(i < histogram_image_xysize) {
  38988 					break
  38989 				}
  38990 				if **(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) >= histogram_image_size {
  38991 					histogram_image_size = **(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) + uint32(1)
  38992 				}
  38993 				**(**uint32_t)(__ccgo_up(histogram_argb + uintptr(i)*4)) <<= uint32(8)
  38994 				goto _21
  38995 			_21:
  38996 				;
  38997 				i = i + 1
  38998 			}
  38999 			write_histogram_image = libc.BoolInt32(histogram_image_size > uint32(1))
  39000 			v12 = bw2
  39001 			v1 = libc.Uint32FromInt32(write_histogram_image)
  39002 			v7 = int32(1)
  39003 			if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39004 				if v7 > libc.Int32FromInt32(0) {
  39005 					if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  39006 						VP8LPutBitsFlushBits(tls, v12)
  39007 					}
  39008 					**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  39009 					**(**int32)(__ccgo_up(v12 + 8)) += v7
  39010 				}
  39011 			} else {
  39012 				VP8LPutBitsInternal(tls, v12, v1, v7)
  39013 			}
  39014 			if write_histogram_image != 0 {
  39015 				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)
  39016 				v12 = bw2
  39017 				v1 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)) - int32(2))
  39018 				v7 = int32(3)
  39019 				if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39020 					if v7 > libc.Int32FromInt32(0) {
  39021 						if (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused >= libc.Int32FromInt32(32) {
  39022 							VP8LPutBitsFlushBits(tls, v12)
  39023 						}
  39024 						**(**vp8l_atype_t)(__ccgo_up(v12)) |= uint64(v1) << (*VP8LBitWriter)(unsafe.Pointer(v12)).Fused
  39025 						**(**int32)(__ccgo_up(v12 + 8)) += v7
  39026 					}
  39027 				} else {
  39028 					VP8LPutBitsInternal(tls, v12, v1, v7)
  39029 				}
  39030 				i_percent_range = i_remaining_percent / int32(2)
  39031 				i_remaining_percent = i_remaining_percent - i_percent_range
  39032 				v1 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)))
  39033 				v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  39034 				goto _30
  39035 			_30:
  39036 				v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 116)))
  39037 				v5 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  39038 				goto _33
  39039 			_33:
  39040 				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) {
  39041 					goto Error
  39042 				}
  39043 			}
  39044 			// Store Huffman codes.
  39045 			max_tokens = 0
  39046 			// Find maximum number of symbols for the huffman tree-set.
  39047 			i = uint32(0)
  39048 			for {
  39049 				if !(i < uint32(5)*histogram_image_size) {
  39050 					break
  39051 				}
  39052 				codes = huffman_codes + uintptr(i)*24
  39053 				if max_tokens < (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols {
  39054 					max_tokens = (*HuffmanTreeCode)(unsafe.Pointer(codes)).Fnum_symbols
  39055 				}
  39056 				goto _34
  39057 			_34:
  39058 				;
  39059 				i = i + 1
  39060 			}
  39061 			tokens = WebPSafeMalloc(tls, libc.Uint64FromInt32(max_tokens), uint64(2))
  39062 			if tokens == libc.UintptrFromInt32(0) {
  39063 				WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39064 				goto Error
  39065 			}
  39066 			i = uint32(0)
  39067 			for {
  39068 				if !(i < uint32(5)*histogram_image_size) {
  39069 					break
  39070 				}
  39071 				codes1 = huffman_codes + uintptr(i)*24
  39072 				StoreHuffmanCode(tls, bw2, huff_tree, tokens, codes1)
  39073 				ClearHuffmanTreeIfOnlyOneSymbol(tls, codes1)
  39074 				goto _35
  39075 			_35:
  39076 				;
  39077 				i = i + 1
  39078 			}
  39079 			// Store actual literals.
  39080 			v12 = bw2
  39081 			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)))
  39082 			goto _38
  39083 		_38:
  39084 			hdr_size_tmp = libc.Int32FromUint64(v37 - init_byte_position)
  39085 			if !(StoreImageToBitMask(tls, bw2, width, **(**int32)(__ccgo_up(bp + 116)), refs_array+uintptr(i_cache)*40, histogram_argb, huffman_codes, pic) != 0) {
  39086 				goto Error
  39087 			}
  39088 			// Keep track of the smallest image so far.
  39089 			v12 = bw2
  39090 			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)))
  39091 			goto _41
  39092 		_41:
  39093 			if v37 < bw_size_best {
  39094 				v15 = bw2
  39095 				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)))
  39096 				goto _44
  39097 			_44:
  39098 				bw_size_best = v40
  39099 				**(**int32)(__ccgo_up(cache_bits)) = cache_bits_tmp
  39100 				**(**int32)(__ccgo_up(hdr_size)) = hdr_size_tmp
  39101 				v12 = bw2
  39102 				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)))
  39103 				goto _47
  39104 			_47:
  39105 				**(**int32)(__ccgo_up(data_size)) = libc.Int32FromUint64(v37 - init_byte_position - libc.Uint64FromInt32(**(**int32)(__ccgo_up(hdr_size))))
  39106 				VP8LBitWriterSwap(tls, bw2, bp+48)
  39107 			}
  39108 			WebPSafeFree(tls, tokens)
  39109 			tokens = libc.UintptrFromInt32(0)
  39110 			if huffman_codes != libc.UintptrFromInt32(0) {
  39111 				WebPSafeFree(tls, (*HuffmanTreeCode)(unsafe.Pointer(huffman_codes)).Fcodes)
  39112 				WebPSafeFree(tls, huffman_codes)
  39113 				huffman_codes = libc.UintptrFromInt32(0)
  39114 			}
  39115 			goto _9
  39116 		_9:
  39117 			;
  39118 			i_cache = i_cache + 1
  39119 		}
  39120 		goto _8
  39121 	_8:
  39122 		;
  39123 		sub_configs_idx = sub_configs_idx + 1
  39124 	}
  39125 	VP8LBitWriterSwap(tls, bw2, bp+48)
  39126 	if !(WebPReportProgress(tls, pic, percent_start+remaining_percent, percent) != 0) {
  39127 		goto Error
  39128 	}
  39129 	goto Error
  39130 Error:
  39131 	;
  39132 	WebPSafeFree(tls, tokens)
  39133 	WebPSafeFree(tls, huff_tree)
  39134 	VP8LFreeHistogramSet(tls, histogram_image)
  39135 	VP8LFreeHistogram(tls, tmp_histo)
  39136 	VP8LHashChainClear(tls, bp+96)
  39137 	if huffman_codes != libc.UintptrFromInt32(0) {
  39138 		WebPSafeFree(tls, (*HuffmanTreeCode)(unsafe.Pointer(huffman_codes)).Fcodes)
  39139 		WebPSafeFree(tls, huffman_codes)
  39140 	}
  39141 	WebPSafeFree(tls, histogram_argb)
  39142 	VP8LBitWriterWipeOut(tls, bp+48)
  39143 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK))
  39144 }
  39145 
  39146 // -----------------------------------------------------------------------------
  39147 // Transforms
  39148 
  39149 func ApplySubtractGreen(tls *libc.TLS, enc uintptr, width int32, height int32, bw1 uintptr) {
  39150 	var v1 uintptr
  39151 	var v2 uint32_t
  39152 	var v3 int32
  39153 	_, _, _ = v1, v2, v3
  39154 	v1 = bw1
  39155 	v2 = uint32(TRANSFORM_PRESENT)
  39156 	v3 = int32(1)
  39157 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39158 		if v3 > libc.Int32FromInt32(0) {
  39159 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39160 				VP8LPutBitsFlushBits(tls, v1)
  39161 			}
  39162 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39163 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39164 		}
  39165 	} else {
  39166 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39167 	}
  39168 	v1 = bw1
  39169 	v2 = uint32(SUBTRACT_GREEN_TRANSFORM)
  39170 	v3 = int32(2)
  39171 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39172 		if v3 > libc.Int32FromInt32(0) {
  39173 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39174 				VP8LPutBitsFlushBits(tls, v1)
  39175 			}
  39176 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39177 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39178 		}
  39179 	} else {
  39180 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39181 	}
  39182 	(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LSubtractGreenFromBlueAndRed})))(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb, width*height)
  39183 }
  39184 
  39185 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) {
  39186 	var max_bits, min_bits, near_lossless_strength, v1, v2 int32
  39187 	var v10, v12, v4, v7 uint32_t
  39188 	var v3 uintptr
  39189 	_, _, _, _, _, _, _, _, _, _ = max_bits, min_bits, near_lossless_strength, v1, v10, v12, v2, v3, v4, v7
  39190 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  39191 		v1 = int32(100)
  39192 	} else {
  39193 		v1 = (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fnear_lossless
  39194 	}
  39195 	near_lossless_strength = v1
  39196 	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))
  39197 	if (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fmethod > int32(4) {
  39198 		v2 = (*WebPConfig)(unsafe.Pointer((*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig)).Fmethod - int32(4)
  39199 	} else {
  39200 		v2 = 0
  39201 	}
  39202 	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))
  39203 	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) {
  39204 		return 0
  39205 	}
  39206 	v3 = bw1
  39207 	v4 = uint32(TRANSFORM_PRESENT)
  39208 	v1 = int32(1)
  39209 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39210 		if v1 > libc.Int32FromInt32(0) {
  39211 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39212 				VP8LPutBitsFlushBits(tls, v3)
  39213 			}
  39214 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39215 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39216 		}
  39217 	} else {
  39218 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39219 	}
  39220 	v3 = bw1
  39221 	v4 = uint32(PREDICTOR_TRANSFORM)
  39222 	v1 = int32(2)
  39223 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39224 		if v1 > libc.Int32FromInt32(0) {
  39225 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39226 				VP8LPutBitsFlushBits(tls, v3)
  39227 			}
  39228 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39229 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39230 		}
  39231 	} else {
  39232 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39233 	}
  39234 	v3 = bw1
  39235 	v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)) - int32(MIN_TRANSFORM_BITS))
  39236 	v1 = int32(NUM_TRANSFORM_BITS)
  39237 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39238 		if v1 > libc.Int32FromInt32(0) {
  39239 			if (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused >= libc.Int32FromInt32(32) {
  39240 				VP8LPutBitsFlushBits(tls, v3)
  39241 			}
  39242 			**(**vp8l_atype_t)(__ccgo_up(v3)) |= uint64(v4) << (*VP8LBitWriter)(unsafe.Pointer(v3)).Fused
  39243 			**(**int32)(__ccgo_up(v3 + 8)) += v1
  39244 		}
  39245 	} else {
  39246 		VP8LPutBitsInternal(tls, v3, v4, v1)
  39247 	}
  39248 	v4 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39249 	v7 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v4) - uint32(1)) >> v4
  39250 	goto _14
  39251 _14:
  39252 	v10 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39253 	v12 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v10) - uint32(1)) >> v10
  39254 	goto _17
  39255 _17:
  39256 	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)
  39257 }
  39258 
  39259 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) {
  39260 	var min_bits, v3 int32
  39261 	var v1 uintptr
  39262 	var v10, v2, v5, v8 uint32_t
  39263 	_, _, _, _, _, _, _ = min_bits, v1, v10, v2, v3, v5, v8
  39264 	min_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fcross_color_transform_bits
  39265 	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) {
  39266 		return 0
  39267 	}
  39268 	v1 = bw1
  39269 	v2 = uint32(TRANSFORM_PRESENT)
  39270 	v3 = int32(1)
  39271 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39272 		if v3 > libc.Int32FromInt32(0) {
  39273 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39274 				VP8LPutBitsFlushBits(tls, v1)
  39275 			}
  39276 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39277 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39278 		}
  39279 	} else {
  39280 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39281 	}
  39282 	v1 = bw1
  39283 	v2 = uint32(CROSS_COLOR_TRANSFORM)
  39284 	v3 = int32(2)
  39285 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39286 		if v3 > libc.Int32FromInt32(0) {
  39287 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39288 				VP8LPutBitsFlushBits(tls, v1)
  39289 			}
  39290 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39291 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39292 		}
  39293 	} else {
  39294 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39295 	}
  39296 	v1 = bw1
  39297 	v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)) - int32(MIN_TRANSFORM_BITS))
  39298 	v3 = int32(NUM_TRANSFORM_BITS)
  39299 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39300 		if v3 > libc.Int32FromInt32(0) {
  39301 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39302 				VP8LPutBitsFlushBits(tls, v1)
  39303 			}
  39304 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39305 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39306 		}
  39307 	} else {
  39308 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39309 	}
  39310 	v2 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39311 	v5 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v2) - uint32(1)) >> v2
  39312 	goto _12
  39313 _12:
  39314 	v8 = libc.Uint32FromInt32(**(**int32)(__ccgo_up(best_bits)))
  39315 	v10 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v8) - uint32(1)) >> v8
  39316 	goto _15
  39317 _15:
  39318 	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)
  39319 }
  39320 
  39321 // -----------------------------------------------------------------------------
  39322 
  39323 func WriteRiffHeader(tls *libc.TLS, pic uintptr, riff_size size_t, vp8l_size size_t) (r int32) {
  39324 	bp := tls.Alloc(32)
  39325 	defer tls.Free(32)
  39326 	var v1, v3, v5 uintptr
  39327 	var v4, v6 int32
  39328 	var v2 uint32_t
  39329 	var _ /* riff at bp+0 */ [21]uint8_t
  39330 	_, _, _, _, _, _ = v1, v2, v3, v4, v5, v6
  39331 	**(**[21]uint8_t)(__ccgo_up(bp)) = [21]uint8_t{
  39332 		0:  uint8('R'),
  39333 		1:  uint8('I'),
  39334 		2:  uint8('F'),
  39335 		3:  uint8('F'),
  39336 		8:  uint8('W'),
  39337 		9:  uint8('E'),
  39338 		10: uint8('B'),
  39339 		11: uint8('P'),
  39340 		12: uint8('V'),
  39341 		13: uint8('P'),
  39342 		14: uint8('8'),
  39343 		15: uint8('L'),
  39344 		20: uint8(VP8L_MAGIC_BYTE3),
  39345 	}
  39346 	v1 = bp + uintptr(TAG_SIZE)
  39347 	v2 = uint32(riff_size)
  39348 	v3 = v1
  39349 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  39350 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  39351 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  39352 	v5 = v1 + uintptr(2)
  39353 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  39354 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  39355 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  39356 	v1 = bp + uintptr(RIFF_HEADER_SIZE) + uintptr(TAG_SIZE)
  39357 	v2 = uint32(vp8l_size)
  39358 	v3 = v1
  39359 	v4 = libc.Int32FromUint32(v2 & libc.Uint32FromInt32(0xffff))
  39360 	**(**uint8_t)(__ccgo_up(v3)) = libc.Uint8FromInt32(v4 >> 0 & int32(0xff))
  39361 	**(**uint8_t)(__ccgo_up(v3 + 1)) = libc.Uint8FromInt32(v4 >> int32(8) & int32(0xff))
  39362 	v5 = v1 + uintptr(2)
  39363 	v6 = libc.Int32FromUint32(v2 >> libc.Int32FromInt32(16))
  39364 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6 >> 0 & int32(0xff))
  39365 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v6 >> int32(8) & int32(0xff))
  39366 	return (*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(21), pic)
  39367 }
  39368 
  39369 func WriteImageSize(tls *libc.TLS, pic uintptr, bw1 uintptr) (r int32) {
  39370 	var height, width, v3 int32
  39371 	var v1 uintptr
  39372 	var v2 uint32_t
  39373 	_, _, _, _, _ = height, width, v1, v2, v3
  39374 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth - int32(1)
  39375 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight - int32(1)
  39376 	v1 = bw1
  39377 	v2 = libc.Uint32FromInt32(width)
  39378 	v3 = int32(VP8L_IMAGE_SIZE_BITS)
  39379 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39380 		if v3 > libc.Int32FromInt32(0) {
  39381 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39382 				VP8LPutBitsFlushBits(tls, v1)
  39383 			}
  39384 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39385 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39386 		}
  39387 	} else {
  39388 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39389 	}
  39390 	v1 = bw1
  39391 	v2 = libc.Uint32FromInt32(height)
  39392 	v3 = int32(VP8L_IMAGE_SIZE_BITS)
  39393 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39394 		if v3 > libc.Int32FromInt32(0) {
  39395 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39396 				VP8LPutBitsFlushBits(tls, v1)
  39397 			}
  39398 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39399 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39400 		}
  39401 	} else {
  39402 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39403 	}
  39404 	return libc.BoolInt32(!((*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0))
  39405 }
  39406 
  39407 func WriteRealAlphaAndVersion(tls *libc.TLS, bw1 uintptr, has_alpha int32) (r int32) {
  39408 	var v1 uintptr
  39409 	var v2 uint32_t
  39410 	var v3 int32
  39411 	_, _, _ = v1, v2, v3
  39412 	v1 = bw1
  39413 	v2 = libc.Uint32FromInt32(has_alpha)
  39414 	v3 = int32(1)
  39415 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39416 		if v3 > libc.Int32FromInt32(0) {
  39417 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39418 				VP8LPutBitsFlushBits(tls, v1)
  39419 			}
  39420 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39421 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39422 		}
  39423 	} else {
  39424 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39425 	}
  39426 	v1 = bw1
  39427 	v2 = uint32(VP8L_VERSION)
  39428 	v3 = int32(VP8L_VERSION_BITS)
  39429 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39430 		if v3 > libc.Int32FromInt32(0) {
  39431 			if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  39432 				VP8LPutBitsFlushBits(tls, v1)
  39433 			}
  39434 			**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v2) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  39435 			**(**int32)(__ccgo_up(v1 + 8)) += v3
  39436 		}
  39437 	} else {
  39438 		VP8LPutBitsInternal(tls, v1, v2, v3)
  39439 	}
  39440 	return libc.BoolInt32(!((*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0))
  39441 }
  39442 
  39443 func WriteImage(tls *libc.TLS, pic uintptr, bw1 uintptr, coded_size uintptr) (r int32) {
  39444 	bp := tls.Alloc(16)
  39445 	defer tls.Free(16)
  39446 	var pad, riff_size, vp8l_size, webpll_size, v2 size_t
  39447 	var webpll_data, v1 uintptr
  39448 	var _ /* pad_byte at bp+0 */ [1]uint8_t
  39449 	_, _, _, _, _, _, _ = pad, riff_size, vp8l_size, webpll_data, webpll_size, v1, v2
  39450 	webpll_data = VP8LBitWriterFinish(tls, bw1)
  39451 	v1 = bw1
  39452 	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)))
  39453 	goto _3
  39454 _3:
  39455 	webpll_size = v2
  39456 	vp8l_size = uint64(VP8L_SIGNATURE_SIZE) + webpll_size
  39457 	pad = vp8l_size & uint64(1)
  39458 	riff_size = libc.Uint64FromInt32(libc.Int32FromInt32(TAG_SIZE)+libc.Int32FromInt32(CHUNK_HEADER_SIZE)) + vp8l_size + pad
  39459 	**(**size_t)(__ccgo_up(coded_size)) = uint64(0)
  39460 	if (*VP8LBitWriter)(unsafe.Pointer(bw1)).Ferror1 != 0 {
  39461 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39462 	}
  39463 	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) {
  39464 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  39465 	}
  39466 	if pad != 0 {
  39467 		**(**[1]uint8_t)(__ccgo_up(bp)) = [1]uint8_t{}
  39468 		if !((*(*func(*libc.TLS, uintptr, size_t, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPPicture)(unsafe.Pointer(pic)).Fwriter})))(tls, bp, uint64(1), pic) != 0) {
  39469 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_WRITE))
  39470 		}
  39471 	}
  39472 	**(**size_t)(__ccgo_up(coded_size)) = uint64(CHUNK_HEADER_SIZE) + riff_size
  39473 	return int32(1)
  39474 }
  39475 
  39476 // -----------------------------------------------------------------------------
  39477 
  39478 func ClearTransformBuffer(tls *libc.TLS, enc uintptr) {
  39479 	WebPSafeFree(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem)
  39480 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem = libc.UintptrFromInt32(0)
  39481 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size = uint64(0)
  39482 }
  39483 
  39484 // C documentation
  39485 //
  39486 //	// Allocates the memory for argb (W x H) buffer, 2 rows of context for
  39487 //	// prediction and transform data.
  39488 //	// Flags influencing the memory allocated:
  39489 //	//  enc->transform_bits
  39490 //	//  enc->use_predict, enc->use_cross_color
  39491 func AllocateTransformBuffer(tls *libc.TLS, enc uintptr, width int32, height int32) (r int32) {
  39492 	var argb_scratch_size, image_size, max_alignment_in_words, mem_size, transform_data_size uint64_t
  39493 	var mem uintptr
  39494 	var v1, v2 uint64
  39495 	var v3, v4, v6, v7 uint32_t
  39496 	_, _, _, _, _, _, _, _, _, _, _, _ = argb_scratch_size, image_size, max_alignment_in_words, mem, mem_size, transform_data_size, v1, v2, v3, v4, v6, v7
  39497 	image_size = libc.Uint64FromInt32(width) * libc.Uint64FromInt32(height)
  39498 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  39499 		v1 = libc.Uint64FromInt32((width+int32(1))*int32(2)) + (libc.Uint64FromInt32(width*int32(2))+uint64(4)-uint64(1))/uint64(4)
  39500 	} else {
  39501 		v1 = uint64(0)
  39502 	}
  39503 	// VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra
  39504 	// pixel in each, plus 2 regular scanlines of bytes.
  39505 	// TODO(skal): Clean up by using arithmetic in bytes instead of words.
  39506 	argb_scratch_size = v1
  39507 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 || (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  39508 		v3 = uint32(MIN_TRANSFORM_BITS)
  39509 		v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  39510 		goto _5
  39511 	_5:
  39512 		v6 = uint32(MIN_TRANSFORM_BITS)
  39513 		v7 = (libc.Uint32FromInt32(height) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v6) - uint32(1)) >> v6
  39514 		goto _8
  39515 	_8:
  39516 		v2 = uint64(v4) * uint64(v7)
  39517 	} else {
  39518 		v2 = uint64(0)
  39519 	}
  39520 	transform_data_size = v2
  39521 	max_alignment_in_words = uint64((libc.Uint64FromInt32(WEBP_ALIGN_CST) + libc.Uint64FromInt64(4) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt64(4))
  39522 	mem_size = image_size + max_alignment_in_words + argb_scratch_size + max_alignment_in_words + transform_data_size
  39523 	mem = (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem
  39524 	if mem == libc.UintptrFromInt32(0) || mem_size > (*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size {
  39525 		ClearTransformBuffer(tls, enc)
  39526 		mem = WebPSafeMalloc(tls, mem_size, uint64(4))
  39527 		if mem == libc.UintptrFromInt32(0) {
  39528 			return WebPEncodingSetError(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39529 		}
  39530 		(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem = mem
  39531 		(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_mem_size = mem_size
  39532 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  39533 	}
  39534 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb = mem
  39535 	mem = uintptr((uint64(mem+uintptr(image_size)*4) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  39536 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_scratch = mem
  39537 	mem = uintptr((uint64(mem+uintptr(argb_scratch_size)*4) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  39538 	(*VP8LEncoder)(unsafe.Pointer(enc)).Ftransform_data = mem
  39539 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width = width
  39540 	return int32(1)
  39541 }
  39542 
  39543 func MakeInputImageCopy(tls *libc.TLS, enc uintptr) (r int32) {
  39544 	var dst, picture, src uintptr
  39545 	var height, width, y int32
  39546 	_, _, _, _, _, _ = dst, height, picture, src, width, y
  39547 	picture = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  39548 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  39549 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  39550 	if !(AllocateTransformBuffer(tls, enc, width, height) != 0) {
  39551 		return 0
  39552 	}
  39553 	if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content == int32(kEncoderARGB) {
  39554 		return int32(1)
  39555 	}
  39556 	dst = (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb
  39557 	src = (*WebPPicture)(unsafe.Pointer(picture)).Fargb
  39558 	y = 0
  39559 	for {
  39560 		if !(y < height) {
  39561 			break
  39562 		}
  39563 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(width)*uint64(4), ^__predefined_size_t(0))
  39564 		dst = dst + uintptr(width)*4
  39565 		src = src + uintptr((*WebPPicture)(unsafe.Pointer(picture)).Fargb_stride)*4
  39566 		goto _1
  39567 	_1:
  39568 		;
  39569 		y = y + 1
  39570 	}
  39571 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderARGB)
  39572 	return int32(1)
  39573 }
  39574 
  39575 // -----------------------------------------------------------------------------
  39576 
  39577 func SearchColorGreedy(tls *libc.TLS, palette uintptr, palette_size int32, color uint32_t) (r uint32_t) {
  39578 	_ = palette_size
  39579 	if color == **(**uint32_t)(__ccgo_up(palette)) {
  39580 		return uint32(0)
  39581 	}
  39582 	if color == **(**uint32_t)(__ccgo_up(palette + 1*4)) {
  39583 		return uint32(1)
  39584 	}
  39585 	if color == **(**uint32_t)(__ccgo_up(palette + 2*4)) {
  39586 		return uint32(2)
  39587 	}
  39588 	return uint32(3)
  39589 }
  39590 
  39591 func ApplyPaletteHash0(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39592 	// Focus on the green color.
  39593 	return color >> libc.Int32FromInt32(8) & uint32(0xff)
  39594 }
  39595 
  39596 func ApplyPaletteHash1(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39597 	// Forget about alpha.
  39598 	return uint32(uint64(color&libc.Uint32FromUint32(0x00ffffff))*libc.Uint64FromUint64(4222244071)) >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(11))
  39599 }
  39600 
  39601 func ApplyPaletteHash2(tls *libc.TLS, color uint32_t) (r uint32_t) {
  39602 	// Forget about alpha.
  39603 	return uint32(uint64(color&libc.Uint32FromUint32(0x00ffffff))*(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(31)-libc.Uint64FromInt32(1))) >> (libc.Int32FromInt32(32) - libc.Int32FromInt32(11))
  39604 }
  39605 
  39606 // Use 1 pixel cache for ARGB pixels.
  39607 
  39608 // C documentation
  39609 //
  39610 //	// Remap argb values in src[] to packed palettes entries in dst[]
  39611 //	// using 'row' as a temporary buffer of size 'width'.
  39612 //	// We assume that all src[] values have a corresponding entry in the palette.
  39613 //	// Note: src[] can be the same as dst[]
  39614 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) {
  39615 	bp := tls.Alloc(6144)
  39616 	defer tls.Free(6144)
  39617 	var hash_functions [3]uintptr
  39618 	var i, j, use_LUT, x, y int32
  39619 	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
  39620 	var tmp_row uintptr
  39621 	var _ /* buffer at bp+0 */ [2048]uint16_t
  39622 	var _ /* idx_map at bp+4096 */ [256]uint32_t
  39623 	var _ /* palette_sorted at bp+5120 */ [256]uint32_t
  39624 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  39625 	// TODO(skal): this tmp buffer is not needed if VP8LBundleColorMap() can be
  39626 	// made to work in-place.
  39627 	tmp_row = WebPSafeMalloc(tls, libc.Uint64FromInt32(width), uint64(1))
  39628 	if tmp_row == libc.UintptrFromInt32(0) {
  39629 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39630 	}
  39631 	if palette_size < int32(4) {
  39632 		prev_pix = **(**uint32_t)(__ccgo_up(palette))
  39633 		prev_idx = uint32(0)
  39634 		y = 0
  39635 		for {
  39636 			if !(y < height) {
  39637 				break
  39638 			}
  39639 			x = 0
  39640 			for {
  39641 				if !(x < width) {
  39642 					break
  39643 				}
  39644 				pix = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39645 				if pix != prev_pix {
  39646 					prev_idx = SearchColorGreedy(tls, palette, palette_size, pix)
  39647 					prev_pix = pix
  39648 				}
  39649 				**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx)
  39650 				goto _2
  39651 			_2:
  39652 				;
  39653 				x = x + 1
  39654 			}
  39655 			(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39656 			src = src + uintptr(src_stride)*4
  39657 			dst = dst + uintptr(dst_stride)*4
  39658 			goto _1
  39659 		_1:
  39660 			;
  39661 			y = y + 1
  39662 		}
  39663 	} else {
  39664 		hash_functions = [3]uintptr{
  39665 			0: __ccgo_fp(ApplyPaletteHash0),
  39666 			1: __ccgo_fp(ApplyPaletteHash1),
  39667 			2: __ccgo_fp(ApplyPaletteHash2),
  39668 		}
  39669 		// Try to find a perfect hash function able to go from a color to an index
  39670 		// within 1 << PALETTE_INV_SIZE_BITS in order to build a hash map to go
  39671 		// from color to index in palette.
  39672 		i = 0
  39673 		for {
  39674 			if !(i < int32(3)) {
  39675 				break
  39676 			}
  39677 			use_LUT = int32(1)
  39678 			// Set each element in buffer to max uint16_t.
  39679 			libc.X__builtin___memset_chk(tls, bp, int32(0xff), uint64(4096), ^__predefined_size_t(0))
  39680 			j = 0
  39681 			for {
  39682 				if !(j < palette_size) {
  39683 					break
  39684 				}
  39685 				ind = (*(*func(*libc.TLS, uint32_t) uint32_t)(unsafe.Pointer(&struct{ uintptr }{hash_functions[i]})))(tls, **(**uint32_t)(__ccgo_up(palette + uintptr(j)*4)))
  39686 				if uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ind]) != uint32(0xffff) {
  39687 					use_LUT = 0
  39688 					break
  39689 				} else {
  39690 					(**(**[2048]uint16_t)(__ccgo_up(bp)))[ind] = libc.Uint16FromInt32(j)
  39691 				}
  39692 				goto _4
  39693 			_4:
  39694 				;
  39695 				j = j + 1
  39696 			}
  39697 			if use_LUT != 0 {
  39698 				break
  39699 			}
  39700 			goto _3
  39701 		_3:
  39702 			;
  39703 			i = i + 1
  39704 		}
  39705 		if i == 0 {
  39706 			prev_pix1 = **(**uint32_t)(__ccgo_up(palette))
  39707 			prev_idx1 = uint32(0)
  39708 			y = 0
  39709 			for {
  39710 				if !(y < height) {
  39711 					break
  39712 				}
  39713 				x = 0
  39714 				for {
  39715 					if !(x < width) {
  39716 						break
  39717 					}
  39718 					pix1 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39719 					if pix1 != prev_pix1 {
  39720 						prev_idx1 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash0(tls, pix1)])
  39721 						prev_pix1 = pix1
  39722 					}
  39723 					**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx1)
  39724 					goto _6
  39725 				_6:
  39726 					;
  39727 					x = x + 1
  39728 				}
  39729 				(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39730 				src = src + uintptr(src_stride)*4
  39731 				dst = dst + uintptr(dst_stride)*4
  39732 				goto _5
  39733 			_5:
  39734 				;
  39735 				y = y + 1
  39736 			}
  39737 		} else {
  39738 			if i == int32(1) {
  39739 				prev_pix2 = **(**uint32_t)(__ccgo_up(palette))
  39740 				prev_idx2 = uint32(0)
  39741 				y = 0
  39742 				for {
  39743 					if !(y < height) {
  39744 						break
  39745 					}
  39746 					x = 0
  39747 					for {
  39748 						if !(x < width) {
  39749 							break
  39750 						}
  39751 						pix2 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39752 						if pix2 != prev_pix2 {
  39753 							prev_idx2 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash1(tls, pix2)])
  39754 							prev_pix2 = pix2
  39755 						}
  39756 						**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx2)
  39757 						goto _8
  39758 					_8:
  39759 						;
  39760 						x = x + 1
  39761 					}
  39762 					(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39763 					src = src + uintptr(src_stride)*4
  39764 					dst = dst + uintptr(dst_stride)*4
  39765 					goto _7
  39766 				_7:
  39767 					;
  39768 					y = y + 1
  39769 				}
  39770 			} else {
  39771 				if i == int32(2) {
  39772 					prev_pix3 = **(**uint32_t)(__ccgo_up(palette))
  39773 					prev_idx3 = uint32(0)
  39774 					y = 0
  39775 					for {
  39776 						if !(y < height) {
  39777 							break
  39778 						}
  39779 						x = 0
  39780 						for {
  39781 							if !(x < width) {
  39782 								break
  39783 							}
  39784 							pix3 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39785 							if pix3 != prev_pix3 {
  39786 								prev_idx3 = uint32((**(**[2048]uint16_t)(__ccgo_up(bp)))[ApplyPaletteHash2(tls, pix3)])
  39787 								prev_pix3 = pix3
  39788 							}
  39789 							**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx3)
  39790 							goto _10
  39791 						_10:
  39792 							;
  39793 							x = x + 1
  39794 						}
  39795 						(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39796 						src = src + uintptr(src_stride)*4
  39797 						dst = dst + uintptr(dst_stride)*4
  39798 						goto _9
  39799 					_9:
  39800 						;
  39801 						y = y + 1
  39802 					}
  39803 				} else {
  39804 					PrepareMapToPalette(tls, palette, libc.Uint32FromInt32(palette_size), bp+5120, bp+4096)
  39805 					prev_pix4 = **(**uint32_t)(__ccgo_up(palette))
  39806 					prev_idx4 = uint32(0)
  39807 					y = 0
  39808 					for {
  39809 						if !(y < height) {
  39810 							break
  39811 						}
  39812 						x = 0
  39813 						for {
  39814 							if !(x < width) {
  39815 								break
  39816 							}
  39817 							pix4 = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  39818 							if pix4 != prev_pix4 {
  39819 								prev_idx4 = (**(**[256]uint32_t)(__ccgo_up(bp + 4096)))[SearchColorNoIdx(tls, bp+5120, pix4, palette_size)]
  39820 								prev_pix4 = pix4
  39821 							}
  39822 							**(**uint8_t)(__ccgo_up(tmp_row + uintptr(x))) = uint8(prev_idx4)
  39823 							goto _12
  39824 						_12:
  39825 							;
  39826 							x = x + 1
  39827 						}
  39828 						(*(*func(*libc.TLS, uintptr, int32, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LBundleColorMap})))(tls, tmp_row, width, xbits, dst)
  39829 						src = src + uintptr(src_stride)*4
  39830 						dst = dst + uintptr(dst_stride)*4
  39831 						goto _11
  39832 					_11:
  39833 						;
  39834 						y = y + 1
  39835 					}
  39836 				}
  39837 			}
  39838 		}
  39839 	}
  39840 	WebPSafeFree(tls, tmp_row)
  39841 	return int32(1)
  39842 }
  39843 
  39844 // C documentation
  39845 //
  39846 //	// Note: Expects "enc->palette" to be set properly.
  39847 func MapImageFromPalette(tls *libc.TLS, enc uintptr) (r int32) {
  39848 	var height, palette_size, width, xbits, v1 int32
  39849 	var palette, pic uintptr
  39850 	var v3, v4 uint32_t
  39851 	_, _, _, _, _, _, _, _, _ = height, palette, palette_size, pic, width, xbits, v1, v3, v4
  39852 	pic = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic
  39853 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  39854 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  39855 	palette = enc + 104
  39856 	palette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  39857 	// Replace each input pixel by corresponding palette index.
  39858 	// This is done line by line.
  39859 	if palette_size <= int32(4) {
  39860 		if palette_size <= int32(2) {
  39861 			v1 = int32(3)
  39862 		} else {
  39863 			v1 = int32(2)
  39864 		}
  39865 		xbits = v1
  39866 	} else {
  39867 		if palette_size <= int32(16) {
  39868 			v1 = int32(1)
  39869 		} else {
  39870 			v1 = 0
  39871 		}
  39872 		xbits = v1
  39873 	}
  39874 	v3 = libc.Uint32FromInt32(xbits)
  39875 	v4 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v3) - uint32(1)) >> v3
  39876 	goto _5
  39877 _5:
  39878 	if !(AllocateTransformBuffer(tls, enc, libc.Int32FromUint32(v4), height) != 0) {
  39879 		return 0
  39880 	}
  39881 	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) {
  39882 		return 0
  39883 	}
  39884 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderPalette)
  39885 	return int32(1)
  39886 }
  39887 
  39888 // C documentation
  39889 //
  39890 //	// Save palette[] to bitstream.
  39891 func EncodePalette(tls *libc.TLS, bw1 uintptr, low_effort int32, enc uintptr, percent_range int32, percent uintptr) (r int32) {
  39892 	bp := tls.Alloc(1024)
  39893 	defer tls.Free(1024)
  39894 	var alpha_and_green, encoded_palette_size, red_and_blue, v3, v6, v9 uint32_t
  39895 	var i, palette_size, v1, v4 int32
  39896 	var palette, v2 uintptr
  39897 	var _ /* tmp_palette at bp+0 */ [256]uint32_t
  39898 	_, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, encoded_palette_size, i, palette, palette_size, red_and_blue, v1, v2, v3, v4, v6, v9
  39899 	palette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  39900 	palette = enc + 104
  39901 	if **(**uint32_t)(__ccgo_up(enc + 104 + uintptr(palette_size-int32(1))*4)) == uint32(0) && palette_size > int32(17) {
  39902 		v1 = palette_size - int32(1)
  39903 	} else {
  39904 		v1 = palette_size
  39905 	}
  39906 	// If the last element is 0, do not store it and count on automatic palette
  39907 	// 0-filling. This can only happen if there is no pixel packing, hence if
  39908 	// there are strictly more than 16 colors (after 0 is removed).
  39909 	encoded_palette_size = libc.Uint32FromInt32(v1)
  39910 	v2 = bw1
  39911 	v3 = uint32(TRANSFORM_PRESENT)
  39912 	v4 = int32(1)
  39913 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39914 		if v4 > libc.Int32FromInt32(0) {
  39915 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39916 				VP8LPutBitsFlushBits(tls, v2)
  39917 			}
  39918 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39919 			**(**int32)(__ccgo_up(v2 + 8)) += v4
  39920 		}
  39921 	} else {
  39922 		VP8LPutBitsInternal(tls, v2, v3, v4)
  39923 	}
  39924 	v2 = bw1
  39925 	v3 = uint32(COLOR_INDEXING_TRANSFORM)
  39926 	v1 = int32(2)
  39927 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39928 		if v1 > libc.Int32FromInt32(0) {
  39929 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39930 				VP8LPutBitsFlushBits(tls, v2)
  39931 			}
  39932 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39933 			**(**int32)(__ccgo_up(v2 + 8)) += v1
  39934 		}
  39935 	} else {
  39936 		VP8LPutBitsInternal(tls, v2, v3, v1)
  39937 	}
  39938 	v2 = bw1
  39939 	v3 = encoded_palette_size - uint32(1)
  39940 	v1 = int32(8)
  39941 	if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  39942 		if v1 > libc.Int32FromInt32(0) {
  39943 			if (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused >= libc.Int32FromInt32(32) {
  39944 				VP8LPutBitsFlushBits(tls, v2)
  39945 			}
  39946 			**(**vp8l_atype_t)(__ccgo_up(v2)) |= uint64(v3) << (*VP8LBitWriter)(unsafe.Pointer(v2)).Fused
  39947 			**(**int32)(__ccgo_up(v2 + 8)) += v1
  39948 		}
  39949 	} else {
  39950 		VP8LPutBitsInternal(tls, v2, v3, v1)
  39951 	}
  39952 	i = libc.Int32FromUint32(encoded_palette_size - uint32(1))
  39953 	for {
  39954 		if !(i >= int32(1)) {
  39955 			break
  39956 		}
  39957 		v3 = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  39958 		v6 = **(**uint32_t)(__ccgo_up(palette + uintptr(i-int32(1))*4))
  39959 		alpha_and_green = uint32(0x00ff00ff) + v3&uint32(0xff00ff00) - v6&uint32(0xff00ff00)
  39960 		red_and_blue = uint32(0xff00ff00) + v3&uint32(0x00ff00ff) - v6&uint32(0x00ff00ff)
  39961 		v9 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  39962 		goto _15
  39963 	_15:
  39964 		(**(**[256]uint32_t)(__ccgo_up(bp)))[i] = v9
  39965 		goto _11
  39966 	_11:
  39967 		;
  39968 		i = i - 1
  39969 	}
  39970 	(**(**[256]uint32_t)(__ccgo_up(bp)))[0] = **(**uint32_t)(__ccgo_up(palette))
  39971 	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)
  39972 }
  39973 
  39974 // -----------------------------------------------------------------------------
  39975 // VP8LEncoder
  39976 
  39977 func VP8LEncoderNew(tls *libc.TLS, config uintptr, picture uintptr) (r uintptr) {
  39978 	var enc uintptr
  39979 	_ = enc
  39980 	enc = WebPSafeCalloc(tls, uint64(1), uint64(2328))
  39981 	if enc == libc.UintptrFromInt32(0) {
  39982 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  39983 		return libc.UintptrFromInt32(0)
  39984 	}
  39985 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fconfig = config
  39986 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fpic = picture
  39987 	(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  39988 	VP8LEncDspInit(tls)
  39989 	return enc
  39990 }
  39991 
  39992 func VP8LEncoderDelete(tls *libc.TLS, enc uintptr) {
  39993 	var i int32
  39994 	_ = i
  39995 	if enc != libc.UintptrFromInt32(0) {
  39996 		VP8LHashChainClear(tls, enc+2312)
  39997 		i = 0
  39998 		for {
  39999 			if !(i < int32(4)) {
  40000 				break
  40001 			}
  40002 			VP8LBackwardRefsClear(tls, enc+2152+uintptr(i)*40)
  40003 			goto _1
  40004 		_1:
  40005 			;
  40006 			i = i + 1
  40007 		}
  40008 		ClearTransformBuffer(tls, enc)
  40009 		WebPSafeFree(tls, enc)
  40010 	}
  40011 }
  40012 
  40013 // -----------------------------------------------------------------------------
  40014 // Main call
  40015 
  40016 type StreamEncodeContext = struct {
  40017 	Fconfig                   uintptr
  40018 	Fpicture                  uintptr
  40019 	Fbw                       uintptr
  40020 	Fenc                      uintptr
  40021 	Fcrunch_configs           [14]CrunchConfig
  40022 	Fnum_crunch_configs       int32
  40023 	Fred_and_blue_always_zero int32
  40024 	Fstats                    uintptr
  40025 }
  40026 
  40027 func EncodeStreamHook(tls *libc.TLS, input uintptr, data2 uintptr) (r int32) {
  40028 	bp := tls.Alloc(128)
  40029 	defer tls.Free(128)
  40030 	var best_size, byte_position, v12, v2 size_t
  40031 	var bw2, config, crunch_configs, enc, params, picture, stats, v1, v8 uintptr
  40032 	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
  40033 	var v9 uint32_t
  40034 	var _ /* bw_best at bp+64 */ VP8LBitWriter
  40035 	var _ /* bw_init at bp+16 */ VP8LBitWriter
  40036 	var _ /* cross_color_transform_bits at bp+116 */ int32
  40037 	var _ /* data_size at bp+8 */ int32
  40038 	var _ /* hdr_size at bp+4 */ int32
  40039 	var _ /* percent at bp+0 */ int32
  40040 	var _ /* predictor_transform_bits at bp+112 */ int32
  40041 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  40042 	params = input
  40043 	config = (*StreamEncodeContext)(unsafe.Pointer(params)).Fconfig
  40044 	picture = (*StreamEncodeContext)(unsafe.Pointer(params)).Fpicture
  40045 	bw2 = (*StreamEncodeContext)(unsafe.Pointer(params)).Fbw
  40046 	enc = (*StreamEncodeContext)(unsafe.Pointer(params)).Fenc
  40047 	crunch_configs = params + 32
  40048 	num_crunch_configs = (*StreamEncodeContext)(unsafe.Pointer(params)).Fnum_crunch_configs
  40049 	red_and_blue_always_zero = (*StreamEncodeContext)(unsafe.Pointer(params)).Fred_and_blue_always_zero
  40050 	stats = (*StreamEncodeContext)(unsafe.Pointer(params)).Fstats
  40051 	quality = int32((*WebPConfig)(unsafe.Pointer(config)).Fquality)
  40052 	low_effort = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Fmethod == libc.Int32FromInt32(0))
  40053 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  40054 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  40055 	v1 = bw2
  40056 	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)))
  40057 	goto _3
  40058 _3:
  40059 	byte_position = v2
  40060 	**(**int32)(__ccgo_up(bp)) = int32(2) // for WebPProgressHook
  40061 	use_near_lossless = 0
  40062 	**(**int32)(__ccgo_up(bp + 4)) = 0
  40063 	**(**int32)(__ccgo_up(bp + 8)) = 0
  40064 	best_size = ^libc.Uint64FromInt32(0)
  40065 	**(**VP8LBitWriter)(__ccgo_up(bp + 16)) = **(**VP8LBitWriter)(__ccgo_up(bw2))
  40066 	_ = data2
  40067 	if !(VP8LBitWriterInit(tls, bp+64, uint64(0)) != 0) || num_crunch_configs > int32(1) && !(VP8LBitWriterClone(tls, bw2, bp+64) != 0) {
  40068 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40069 		goto Error
  40070 	}
  40071 	idx = 0
  40072 	for {
  40073 		if !(idx < num_crunch_configs) {
  40074 			break
  40075 		}
  40076 		entropy_idx = (**(**CrunchConfig)(__ccgo_up(crunch_configs + uintptr(idx)*28))).Fentropy_idx
  40077 		remaining_percent = int32(97) / num_crunch_configs
  40078 		**(**int32)(__ccgo_up(bp + 112)) = 0
  40079 		**(**int32)(__ccgo_up(bp + 116)) = 0
  40080 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette = libc.BoolInt32(entropy_idx == int32(kPalette) || entropy_idx == int32(kPaletteAndSpatial))
  40081 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green = libc.BoolInt32(entropy_idx == int32(kSubGreen) || entropy_idx == int32(kSpatialSubGreen))
  40082 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict = libc.BoolInt32(entropy_idx == int32(kSpatial) || entropy_idx == int32(kSpatialSubGreen) || entropy_idx == int32(kPaletteAndSpatial))
  40083 		// When using a palette, R/B==0, hence no need to test for cross-color.
  40084 		if low_effort != 0 || (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40085 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color = 0
  40086 		} else {
  40087 			if red_and_blue_always_zero != 0 {
  40088 				v5 = 0
  40089 			} else {
  40090 				v5 = (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict
  40091 			}
  40092 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color = v5
  40093 		}
  40094 		// Reset any parameter in the encoder that is set in the previous iteration.
  40095 		(*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits = 0
  40096 		VP8LBackwardRefsClear(tls, enc+2152)
  40097 		VP8LBackwardRefsClear(tls, enc+2152+1*40)
  40098 		// Apply near-lossless preprocessing.
  40099 		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))
  40100 		if use_near_lossless != 0 {
  40101 			if !(AllocateTransformBuffer(tls, enc, width, height) != 0) {
  40102 				goto Error
  40103 			}
  40104 			if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderNearLossless) && !(VP8ApplyNearLossless(tls, picture, (*WebPConfig)(unsafe.Pointer(config)).Fnear_lossless, (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb) != 0) {
  40105 				WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40106 				goto Error
  40107 			}
  40108 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNearLossless)
  40109 		} else {
  40110 			(*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content = int32(kEncoderNone)
  40111 		}
  40112 		// Encode palette
  40113 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40114 			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) {
  40115 				WebPEncodingSetError(tls, (*VP8LEncoder)(unsafe.Pointer(enc)).Fpic, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40116 				goto Error
  40117 			}
  40118 			percent_range = remaining_percent / int32(4)
  40119 			if !(EncodePalette(tls, bw2, low_effort, enc, percent_range, bp) != 0) {
  40120 				goto Error
  40121 			}
  40122 			remaining_percent = remaining_percent - percent_range
  40123 			if !(MapImageFromPalette(tls, enc) != 0) {
  40124 				goto Error
  40125 			}
  40126 			// If using a color cache, do not have it bigger than the number of
  40127 			// colors.
  40128 			if (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size < libc.Int32FromInt32(1)<<libc.Int32FromInt32(MAX_COLOR_CACHE_BITS) {
  40129 				v5 = int32(31) ^ libc.X__builtin_clz(tls, libc.Uint32FromInt32((*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size))
  40130 				goto _7
  40131 			_7:
  40132 				(*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits = v5 + int32(1)
  40133 			}
  40134 		}
  40135 		// In case image is not packed.
  40136 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderNearLossless) && (*VP8LEncoder)(unsafe.Pointer(enc)).Fargb_content != int32(kEncoderPalette) {
  40137 			if !(MakeInputImageCopy(tls, enc) != 0) {
  40138 				goto Error
  40139 			}
  40140 		}
  40141 		// -------------------------------------------------------------------------
  40142 		// Apply transforms and write transform data.
  40143 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green != 0 {
  40144 			ApplySubtractGreen(tls, enc, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, bw2)
  40145 		}
  40146 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  40147 			percent_range = remaining_percent / int32(3)
  40148 			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) {
  40149 				goto Error
  40150 			}
  40151 			remaining_percent = remaining_percent - percent_range
  40152 		}
  40153 		if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  40154 			percent_range = remaining_percent / int32(2)
  40155 			if !(ApplyCrossColorFilter(tls, enc, (*VP8LEncoder)(unsafe.Pointer(enc)).Fcurrent_width, height, quality, low_effort, bw2, percent_range, bp, bp+116) != 0) {
  40156 				goto Error
  40157 			}
  40158 			remaining_percent = remaining_percent - percent_range
  40159 		}
  40160 		v1 = bw2
  40161 		v9 = libc.BoolUint32(!(libc.Int32FromInt32(TRANSFORM_PRESENT) != 0))
  40162 		v5 = int32(1)
  40163 		if libc.Uint64FromInt64(4) == libc.Uint64FromInt32(4) {
  40164 			if v5 > libc.Int32FromInt32(0) {
  40165 				if (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused >= libc.Int32FromInt32(32) {
  40166 					VP8LPutBitsFlushBits(tls, v1)
  40167 				}
  40168 				**(**vp8l_atype_t)(__ccgo_up(v1)) |= uint64(v9) << (*VP8LBitWriter)(unsafe.Pointer(v1)).Fused
  40169 				**(**int32)(__ccgo_up(v1 + 8)) += v5
  40170 			}
  40171 		} else {
  40172 			VP8LPutBitsInternal(tls, v1, v9, v5)
  40173 		} // No more transforms.
  40174 		// -------------------------------------------------------------------------
  40175 		// Encode and write the transformed image.
  40176 		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) {
  40177 			goto Error
  40178 		}
  40179 		// If we are better than what we already have.
  40180 		v1 = bw2
  40181 		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)))
  40182 		goto _13
  40183 	_13:
  40184 		if v2 < best_size {
  40185 			v8 = bw2
  40186 			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)))
  40187 			goto _16
  40188 		_16:
  40189 			best_size = v12
  40190 			// Store the BitWriter.
  40191 			VP8LBitWriterSwap(tls, bw2, bp+64)
  40192 			// Update the stats.
  40193 			if stats != libc.UintptrFromInt32(0) {
  40194 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_features = uint32(0)
  40195 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_predict != 0 {
  40196 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(1)
  40197 				}
  40198 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_cross_color != 0 {
  40199 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(2)
  40200 				}
  40201 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_subtract_green != 0 {
  40202 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(4)
  40203 				}
  40204 				if (*VP8LEncoder)(unsafe.Pointer(enc)).Fuse_palette != 0 {
  40205 					**(**uint32_t)(__ccgo_up(stats + 148)) |= uint32(8)
  40206 				}
  40207 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fhistogram_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fhisto_bits
  40208 				(*WebPAuxStats)(unsafe.Pointer(stats)).Ftransform_bits = **(**int32)(__ccgo_up(bp + 112))
  40209 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fcross_color_transform_bits = **(**int32)(__ccgo_up(bp + 116))
  40210 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fcache_bits = (*VP8LEncoder)(unsafe.Pointer(enc)).Fcache_bits
  40211 				(*WebPAuxStats)(unsafe.Pointer(stats)).Fpalette_size = (*VP8LEncoder)(unsafe.Pointer(enc)).Fpalette_size
  40212 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_size = libc.Int32FromUint64(best_size - byte_position)
  40213 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_hdr_size = **(**int32)(__ccgo_up(bp + 4))
  40214 				(*WebPAuxStats)(unsafe.Pointer(stats)).Flossless_data_size = **(**int32)(__ccgo_up(bp + 8))
  40215 			}
  40216 		}
  40217 		// Reset the bit writer for the following iteration if any.
  40218 		if num_crunch_configs > int32(1) {
  40219 			VP8LBitWriterReset(tls, bp+16, bw2)
  40220 		}
  40221 		goto _4
  40222 	_4:
  40223 		;
  40224 		idx = idx + 1
  40225 	}
  40226 	VP8LBitWriterSwap(tls, bp+64, bw2)
  40227 	goto Error
  40228 Error:
  40229 	;
  40230 	VP8LBitWriterWipeOut(tls, bp+64)
  40231 	// The hook should return false in case of error.
  40232 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer((*StreamEncodeContext)(unsafe.Pointer(params)).Fpicture)).Ferror_code == int32(VP8_ENC_OK))
  40233 }
  40234 
  40235 func VP8LEncodeStream(tls *libc.TLS, config uintptr, picture1 uintptr, bw_main uintptr) (r int32) {
  40236 	bp := tls.Alloc(1872)
  40237 	defer tls.Free(1872)
  40238 	var enc_main, enc_side, param, worker, worker_interface, v7, v8 uintptr
  40239 	var idx, num_crunch_configs_side, ok_main, ok_side, params_size, v1 int32
  40240 	var v11, v14 size_t
  40241 	var _ /* bw_side at bp+1568 */ VP8LBitWriter
  40242 	var _ /* crunch_configs at bp+0 */ [14]CrunchConfig
  40243 	var _ /* num_crunch_configs_main at bp+392 */ int32
  40244 	var _ /* params_main at bp+496 */ StreamEncodeContext
  40245 	var _ /* params_side at bp+936 */ StreamEncodeContext
  40246 	var _ /* picture_side at bp+1616 */ WebPPicture
  40247 	var _ /* red_and_blue_always_zero at bp+396 */ int32
  40248 	var _ /* stats_side at bp+1376 */ WebPAuxStats
  40249 	var _ /* worker_main at bp+400 */ WebPWorker
  40250 	var _ /* worker_side at bp+448 */ WebPWorker
  40251 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc_main, enc_side, idx, num_crunch_configs_side, ok_main, ok_side, param, params_size, worker, worker_interface, v1, v11, v14, v7, v8
  40252 	enc_main = VP8LEncoderNew(tls, config, picture1)
  40253 	enc_side = libc.UintptrFromInt32(0)
  40254 	num_crunch_configs_side = 0
  40255 	**(**int32)(__ccgo_up(bp + 396)) = 0
  40256 	worker_interface = WebPGetWorkerInterface(tls)
  40257 	if enc_main == libc.UintptrFromInt32(0) || !(VP8LBitWriterInit(tls, bp+1568, uint64(0)) != 0) {
  40258 		VP8LEncoderDelete(tls, enc_main)
  40259 		return WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40260 	}
  40261 	// Avoid "garbage value" error from Clang's static analysis tool.
  40262 	v1 = WebPPictureInitInternal(tls, bp+1616, int32(WEBP_ENCODER_ABI_VERSION))
  40263 	goto _2
  40264 _2:
  40265 	if !(v1 != 0) {
  40266 		goto Error
  40267 	}
  40268 	// Analyze image (entropy, num_palettes etc)
  40269 	if !(EncoderAnalyze(tls, enc_main, bp, bp+392, bp+396) != 0) || !(EncoderInit(tls, enc_main) != 0) {
  40270 		WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40271 		goto Error
  40272 	}
  40273 	// Split the configs between the main and side threads (if any).
  40274 	if (*WebPConfig)(unsafe.Pointer(config)).Fthread_level > 0 {
  40275 		num_crunch_configs_side = **(**int32)(__ccgo_up(bp + 392)) / int32(2)
  40276 		idx = 0
  40277 		for {
  40278 			if !(idx < num_crunch_configs_side) {
  40279 				break
  40280 			}
  40281 			**(**CrunchConfig)(__ccgo_up(bp + 936 + 32 + uintptr(idx)*28)) = (**(**[14]CrunchConfig)(__ccgo_up(bp)))[**(**int32)(__ccgo_up(bp + 392))-num_crunch_configs_side+idx]
  40282 			goto _3
  40283 		_3:
  40284 			;
  40285 			idx = idx + 1
  40286 		}
  40287 		(**(**StreamEncodeContext)(__ccgo_up(bp + 936))).Fnum_crunch_configs = num_crunch_configs_side
  40288 	}
  40289 	**(**int32)(__ccgo_up(bp + 392)) = **(**int32)(__ccgo_up(bp + 392)) - num_crunch_configs_side
  40290 	idx = 0
  40291 	for {
  40292 		if !(idx < **(**int32)(__ccgo_up(bp + 392))) {
  40293 			break
  40294 		}
  40295 		**(**CrunchConfig)(__ccgo_up(bp + 496 + 32 + uintptr(idx)*28)) = (**(**[14]CrunchConfig)(__ccgo_up(bp)))[idx]
  40296 		goto _4
  40297 	_4:
  40298 		;
  40299 		idx = idx + 1
  40300 	}
  40301 	(**(**StreamEncodeContext)(__ccgo_up(bp + 496))).Fnum_crunch_configs = **(**int32)(__ccgo_up(bp + 392))
  40302 	// Fill in the parameters for the thread workers.
  40303 	if num_crunch_configs_side > 0 {
  40304 		v1 = int32(2)
  40305 	} else {
  40306 		v1 = int32(1)
  40307 	}
  40308 	params_size = v1
  40309 	idx = 0
  40310 	for {
  40311 		if !(idx < params_size) {
  40312 			break
  40313 		}
  40314 		if idx == 0 {
  40315 			v7 = bp + 400
  40316 		} else {
  40317 			v7 = bp + 448
  40318 		}
  40319 		// Create the parameters for each worker.
  40320 		worker = v7
  40321 		if idx == 0 {
  40322 			v8 = bp + 496
  40323 		} else {
  40324 			v8 = bp + 936
  40325 		}
  40326 		param = v8
  40327 		(*StreamEncodeContext)(unsafe.Pointer(param)).Fconfig = config
  40328 		(*StreamEncodeContext)(unsafe.Pointer(param)).Fred_and_blue_always_zero = **(**int32)(__ccgo_up(bp + 396))
  40329 		if idx == 0 {
  40330 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fpicture = picture1
  40331 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fstats = (*WebPPicture)(unsafe.Pointer(picture1)).Fstats
  40332 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fbw = bw_main
  40333 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fenc = enc_main
  40334 		} else {
  40335 			// Create a side picture (error_code is not thread-safe).
  40336 			if !(WebPPictureView(tls, picture1, 0, 0, (*WebPPicture)(unsafe.Pointer(picture1)).Fwidth, (*WebPPicture)(unsafe.Pointer(picture1)).Fheight, bp+1616) != 0) {
  40337 			}
  40338 			(**(**WebPPicture)(__ccgo_up(bp + 1616))).Fprogress_hook = libc.UintptrFromInt32(0) // Progress hook is not thread-safe.
  40339 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fpicture = bp + 1616                  // No need to free a view afterwards.
  40340 			if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats == libc.UintptrFromInt32(0) {
  40341 				v7 = libc.UintptrFromInt32(0)
  40342 			} else {
  40343 				v7 = bp + 1376
  40344 			}
  40345 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fstats = v7
  40346 			// Create a side bit writer.
  40347 			if !(VP8LBitWriterClone(tls, bw_main, bp+1568) != 0) {
  40348 				WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40349 				goto Error
  40350 			}
  40351 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fbw = bp + 1568
  40352 			// Create a side encoder.
  40353 			enc_side = VP8LEncoderNew(tls, config, bp+1616)
  40354 			if enc_side == libc.UintptrFromInt32(0) || !(EncoderInit(tls, enc_side) != 0) {
  40355 				WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40356 				goto Error
  40357 			}
  40358 			// Copy the values that were computed for the main encoder.
  40359 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fhisto_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fhisto_bits
  40360 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fpredictor_transform_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fpredictor_transform_bits
  40361 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fcross_color_transform_bits = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fcross_color_transform_bits
  40362 			(*VP8LEncoder)(unsafe.Pointer(enc_side)).Fpalette_size = (*VP8LEncoder)(unsafe.Pointer(enc_main)).Fpalette_size
  40363 			libc.X__builtin___memcpy_chk(tls, enc_side+104, enc_main+104, uint64(1024), ^__predefined_size_t(0))
  40364 			libc.X__builtin___memcpy_chk(tls, enc_side+1128, enc_main+1128, uint64(1024), ^__predefined_size_t(0))
  40365 			(*StreamEncodeContext)(unsafe.Pointer(param)).Fenc = enc_side
  40366 		}
  40367 		// Create the workers.
  40368 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FInit})))(tls, worker)
  40369 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata1 = param
  40370 		(*WebPWorker)(unsafe.Pointer(worker)).Fdata2 = libc.UintptrFromInt32(0)
  40371 		(*WebPWorker)(unsafe.Pointer(worker)).Fhook = __ccgo_fp(EncodeStreamHook)
  40372 		goto _6
  40373 	_6:
  40374 		;
  40375 		idx = idx + 1
  40376 	}
  40377 	// Start the second thread if needed.
  40378 	if num_crunch_configs_side != 0 {
  40379 		if !((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FReset})))(tls, bp+448) != 0) {
  40380 			WebPEncodingSetError(tls, picture1, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40381 			goto Error
  40382 		}
  40383 		// This line is here and not in the param initialization above to remove a
  40384 		// Clang static analyzer warning.
  40385 		if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats != libc.UintptrFromInt32(0) {
  40386 			libc.X__builtin___memcpy_chk(tls, bp+1376, (*WebPPicture)(unsafe.Pointer(picture1)).Fstats, uint64(188), ^__predefined_size_t(0))
  40387 		}
  40388 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FLaunch})))(tls, bp+448)
  40389 	}
  40390 	// Execute the main thread.
  40391 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FExecute})))(tls, bp+400)
  40392 	ok_main = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp+400)
  40393 	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp+400)
  40394 	if num_crunch_configs_side != 0 {
  40395 		// Wait for the second thread.
  40396 		ok_side = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FSync})))(tls, bp+448)
  40397 		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*WebPWorkerInterface)(unsafe.Pointer(worker_interface)).FEnd})))(tls, bp+448)
  40398 		if !(ok_main != 0) || !(ok_side != 0) {
  40399 			if (*WebPPicture)(unsafe.Pointer(picture1)).Ferror_code == int32(VP8_ENC_OK) {
  40400 				WebPEncodingSetError(tls, picture1, (**(**WebPPicture)(__ccgo_up(bp + 1616))).Ferror_code)
  40401 			}
  40402 			goto Error
  40403 		}
  40404 		v7 = bp + 1568
  40405 		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)))
  40406 		goto _12
  40407 	_12:
  40408 		v8 = bw_main
  40409 		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)))
  40410 		goto _15
  40411 	_15:
  40412 		if v11 < v14 {
  40413 			VP8LBitWriterSwap(tls, bw_main, bp+1568)
  40414 			if (*WebPPicture)(unsafe.Pointer(picture1)).Fstats != libc.UintptrFromInt32(0) {
  40415 				libc.X__builtin___memcpy_chk(tls, (*WebPPicture)(unsafe.Pointer(picture1)).Fstats, bp+1376, uint64(188), ^__predefined_size_t(0))
  40416 			}
  40417 		}
  40418 	}
  40419 	goto Error
  40420 Error:
  40421 	;
  40422 	VP8LBitWriterWipeOut(tls, bp+1568)
  40423 	VP8LEncoderDelete(tls, enc_main)
  40424 	VP8LEncoderDelete(tls, enc_side)
  40425 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture1)).Ferror_code == int32(VP8_ENC_OK))
  40426 }
  40427 
  40428 func VP8LEncodeImage(tls *libc.TLS, config uintptr, picture uintptr) (r int32) {
  40429 	bp := tls.Alloc(64)
  40430 	defer tls.Free(64)
  40431 	var has_alpha, height, initial_size, mb_h, mb_w, width, v1 int32
  40432 	var stats uintptr
  40433 	var _ /* bw at bp+16 */ VP8LBitWriter
  40434 	var _ /* coded_size at bp+0 */ size_t
  40435 	var _ /* percent at bp+8 */ int32
  40436 	_, _, _, _, _, _, _, _ = has_alpha, height, initial_size, mb_h, mb_w, stats, width, v1
  40437 	**(**int32)(__ccgo_up(bp + 8)) = 0
  40438 	if picture == libc.UintptrFromInt32(0) {
  40439 		return 0
  40440 	}
  40441 	if config == libc.UintptrFromInt32(0) || (*WebPPicture)(unsafe.Pointer(picture)).Fargb == libc.UintptrFromInt32(0) {
  40442 		return WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  40443 	}
  40444 	width = (*WebPPicture)(unsafe.Pointer(picture)).Fwidth
  40445 	height = (*WebPPicture)(unsafe.Pointer(picture)).Fheight
  40446 	// Initialize BitWriter with size corresponding to 16 bpp to photo images and
  40447 	// 8 bpp for graphical images.
  40448 	if (*WebPConfig)(unsafe.Pointer(config)).Fimage_hint == int32(WEBP_HINT_GRAPH) {
  40449 		v1 = width * height
  40450 	} else {
  40451 		v1 = width * height * int32(2)
  40452 	}
  40453 	initial_size = v1
  40454 	if !(VP8LBitWriterInit(tls, bp+16, libc.Uint64FromInt32(initial_size)) != 0) {
  40455 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40456 		goto Error
  40457 	}
  40458 	if !!(WebPReportProgress(tls, picture, int32(1), bp+8) != 0) {
  40459 		goto _2
  40460 	}
  40461 	goto UserAbort
  40462 UserAbort:
  40463 	;
  40464 	WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_USER_ABORT))
  40465 	goto Error
  40466 _2:
  40467 	;
  40468 	// Reset stats (for pure lossless coding)
  40469 	if (*WebPPicture)(unsafe.Pointer(picture)).Fstats != libc.UintptrFromInt32(0) {
  40470 		stats = (*WebPPicture)(unsafe.Pointer(picture)).Fstats
  40471 		libc.X__builtin___memset_chk(tls, stats, 0, uint64(188), ^__predefined_size_t(0))
  40472 		**(**float32)(__ccgo_up(stats + 4)) = libc.Float32FromFloat32(99)
  40473 		**(**float32)(__ccgo_up(stats + 4 + 1*4)) = libc.Float32FromFloat32(99)
  40474 		**(**float32)(__ccgo_up(stats + 4 + 2*4)) = libc.Float32FromFloat32(99)
  40475 		**(**float32)(__ccgo_up(stats + 4 + 3*4)) = libc.Float32FromFloat32(99)
  40476 		**(**float32)(__ccgo_up(stats + 4 + 4*4)) = libc.Float32FromFloat32(99)
  40477 	}
  40478 	// Write image size.
  40479 	if !(WriteImageSize(tls, picture, bp+16) != 0) {
  40480 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40481 		goto Error
  40482 	}
  40483 	has_alpha = WebPPictureHasTransparency(tls, picture)
  40484 	// Write the non-trivial Alpha flag and lossless version.
  40485 	if !(WriteRealAlphaAndVersion(tls, bp+16, has_alpha) != 0) {
  40486 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40487 		goto Error
  40488 	}
  40489 	if !(WebPReportProgress(tls, picture, int32(2), bp+8) != 0) {
  40490 		goto UserAbort
  40491 	}
  40492 	// Encode main image stream.
  40493 	if !(VP8LEncodeStream(tls, config, picture, bp+16) != 0) {
  40494 		goto Error
  40495 	}
  40496 	if !(WebPReportProgress(tls, picture, int32(99), bp+8) != 0) {
  40497 		goto UserAbort
  40498 	}
  40499 	// Finish the RIFF chunk.
  40500 	if !(WriteImage(tls, picture, bp+16, bp) != 0) {
  40501 		goto Error
  40502 	}
  40503 	if !(WebPReportProgress(tls, picture, int32(100), bp+8) != 0) {
  40504 		goto UserAbort
  40505 	}
  40506 	// Save size.
  40507 	if (*WebPPicture)(unsafe.Pointer(picture)).Fstats != libc.UintptrFromInt32(0) {
  40508 		**(**int32)(__ccgo_up((*WebPPicture)(unsafe.Pointer(picture)).Fstats)) += libc.Int32FromUint64(**(**size_t)(__ccgo_up(bp)))
  40509 		(*WebPAuxStats)(unsafe.Pointer((*WebPPicture)(unsafe.Pointer(picture)).Fstats)).Flossless_size = libc.Int32FromUint64(**(**size_t)(__ccgo_up(bp)))
  40510 	}
  40511 	if (*WebPPicture)(unsafe.Pointer(picture)).Fextra_info != libc.UintptrFromInt32(0) {
  40512 		mb_w = (width + int32(15)) >> int32(4)
  40513 		mb_h = (height + int32(15)) >> int32(4)
  40514 		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))
  40515 	}
  40516 	goto Error
  40517 Error:
  40518 	;
  40519 	if (**(**VP8LBitWriter)(__ccgo_up(bp + 16))).Ferror1 != 0 {
  40520 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40521 	}
  40522 	VP8LBitWriterWipeOut(tls, bp+16)
  40523 	return libc.BoolInt32((*WebPPicture)(unsafe.Pointer(picture)).Ferror_code == int32(VP8_ENC_OK))
  40524 }
  40525 
  40526 const VP8L_MAGIC_BYTE4 = 0x2f
  40527 const __FLT_MIN__9 = 1.1754943508222875e-38
  40528 
  40529 //------------------------------------------------------------------------------
  40530 
  40531 // Copyright 2012 Google Inc. All Rights Reserved.
  40532 //
  40533 // Use of this source code is governed by a BSD-style license
  40534 // that can be found in the COPYING file in the root of the source
  40535 // tree. An additional intellectual property rights grant can be found
  40536 // in the file PATENTS. All contributing project authors may
  40537 // be found in the AUTHORS file in the root of the source tree.
  40538 // -----------------------------------------------------------------------------
  40539 //
  40540 // Misc. common utility functions
  40541 //
  40542 // Authors: Skal (pascal.massimino@gmail.com)
  40543 //          Urvang (urvang@google.com)
  40544 
  40545 // Copyright 2011 Google Inc. All Rights Reserved.
  40546 //
  40547 // Use of this source code is governed by a BSD-style license
  40548 // that can be found in the COPYING file in the root of the source
  40549 // tree. An additional intellectual property rights grant can be found
  40550 // in the file PATENTS. All contributing project authors may
  40551 // be found in the AUTHORS file in the root of the source tree.
  40552 // -----------------------------------------------------------------------------
  40553 //
  40554 //   WebP encoder: main interface
  40555 //
  40556 // Author: Skal (pascal.massimino@gmail.com)
  40557 
  40558 // #define PRINT_MEMORY_INFO
  40559 
  40560 //------------------------------------------------------------------------------
  40561 
  40562 func WebPGetEncoderVersion(tls *libc.TLS) (r int32) {
  40563 	return libc.Int32FromInt32(ENC_MAJ_VERSION)<<libc.Int32FromInt32(16) | libc.Int32FromInt32(ENC_MIN_VERSION)<<libc.Int32FromInt32(8) | libc.Int32FromInt32(ENC_REV_VERSION)
  40564 }
  40565 
  40566 //------------------------------------------------------------------------------
  40567 // VP8Encoder
  40568 //------------------------------------------------------------------------------
  40569 
  40570 func ResetSegmentHeader1(tls *libc.TLS, enc uintptr) {
  40571 	var hdr uintptr
  40572 	_ = hdr
  40573 	hdr = enc + 32
  40574 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments = (*WebPConfig)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fconfig)).Fsegments
  40575 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fupdate_map = libc.BoolInt32((*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fnum_segments > int32(1))
  40576 	(*VP8EncSegmentHeader)(unsafe.Pointer(hdr)).Fsize = 0
  40577 }
  40578 
  40579 func ResetFilterHeader(tls *libc.TLS, enc uintptr) {
  40580 	var hdr uintptr
  40581 	_ = hdr
  40582 	hdr = enc + 16
  40583 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsimple = int32(1)
  40584 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Flevel = 0
  40585 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fsharpness = 0
  40586 	(*VP8EncFilterHeader)(unsafe.Pointer(hdr)).Fi4x4_lf_delta = 0
  40587 }
  40588 
  40589 func ResetBoundaryPredictions(tls *libc.TLS, enc uintptr) {
  40590 	var i int32
  40591 	var left, top uintptr
  40592 	_, _, _ = i, left, top
  40593 	top = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds - uintptr((*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  40594 	left = (*VP8Encoder)(unsafe.Pointer(enc)).Fpreds - uintptr(1)
  40595 	i = -int32(1)
  40596 	for {
  40597 		if !(i < int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w) {
  40598 			break
  40599 		}
  40600 		**(**uint8_t)(__ccgo_up(top + uintptr(i))) = uint8(B_DC_PRED)
  40601 		goto _1
  40602 	_1:
  40603 		;
  40604 		i = i + 1
  40605 	}
  40606 	i = 0
  40607 	for {
  40608 		if !(i < int32(4)*(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h) {
  40609 			break
  40610 		}
  40611 		**(**uint8_t)(__ccgo_up(left + uintptr(i*(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w))) = uint8(B_DC_PRED)
  40612 		goto _2
  40613 	_2:
  40614 		;
  40615 		i = i + 1
  40616 	}
  40617 	**(**uint32_t)(__ccgo_up((*VP8Encoder)(unsafe.Pointer(enc)).Fnz + uintptr(-libc.Int32FromInt32(1))*4)) = uint32(0) // constant
  40618 }
  40619 
  40620 // Mapping from config->method to coding tools used.
  40621 //-------------------+---+---+---+---+---+---+---+
  40622 //   Method          | 0 | 1 | 2 | 3 |(4)| 5 | 6 |
  40623 //-------------------+---+---+---+---+---+---+---+
  40624 // fast probe        | x |   |   | x |   |   |   |
  40625 //-------------------+---+---+---+---+---+---+---+
  40626 // dynamic proba     | ~ | x | x | x | x | x | x |
  40627 //-------------------+---+---+---+---+---+---+---+
  40628 // fast mode analysis|[x]|[x]|   |   | x | x | x |
  40629 //-------------------+---+---+---+---+---+---+---+
  40630 // basic rd-opt      |   |   |   | x | x | x | x |
  40631 //-------------------+---+---+---+---+---+---+---+
  40632 // disto-refine i4/16| x | x | x |   |   |   |   |
  40633 //-------------------+---+---+---+---+---+---+---+
  40634 // disto-refine uv   |   | x | x |   |   |   |   |
  40635 //-------------------+---+---+---+---+---+---+---+
  40636 // rd-opt i4/16      |   |   | ~ | x | x | x | x |
  40637 //-------------------+---+---+---+---+---+---+---+
  40638 // token buffer (opt)|   |   |   | x | x | x | x |
  40639 //-------------------+---+---+---+---+---+---+---+
  40640 // Trellis           |   |   |   |   |   | x |Ful|
  40641 //-------------------+---+---+---+---+---+---+---+
  40642 // full-SNS          |   |   |   |   | x | x | x |
  40643 //-------------------+---+---+---+---+---+---+---+
  40644 
  40645 func MapConfigToTools(tls *libc.TLS, enc uintptr) {
  40646 	var config uintptr
  40647 	var limit, method, v1, v2, v3 int32
  40648 	_, _, _, _, _, _ = config, limit, method, v1, v2, v3
  40649 	config = (*VP8Encoder)(unsafe.Pointer(enc)).Fconfig
  40650 	method = (*WebPConfig)(unsafe.Pointer(config)).Fmethod
  40651 	limit = int32(100) - (*WebPConfig)(unsafe.Pointer(config)).Fpartition_limit
  40652 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmethod = method
  40653 	if method >= int32(6) {
  40654 		v1 = int32(RD_OPT_TRELLIS_ALL)
  40655 	} else {
  40656 		if method >= int32(5) {
  40657 			v2 = int32(RD_OPT_TRELLIS)
  40658 		} else {
  40659 			if method >= int32(3) {
  40660 				v3 = int32(RD_OPT_BASIC)
  40661 			} else {
  40662 				v3 = int32(RD_OPT_NONE)
  40663 			}
  40664 			v2 = v3
  40665 		}
  40666 		v1 = v2
  40667 	}
  40668 	(*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level = v1
  40669 	(*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.
  40670 	// partition0 = 512k max.
  40671 	(*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))
  40672 	(*VP8Encoder)(unsafe.Pointer(enc)).Fthread_level = (*WebPConfig)(unsafe.Pointer(config)).Fthread_level
  40673 	(*VP8Encoder)(unsafe.Pointer(enc)).Fdo_search = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Ftarget_size > 0 || (*WebPConfig)(unsafe.Pointer(config)).Ftarget_PSNR > libc.Float32FromInt32(0))
  40674 	if !((*WebPConfig)(unsafe.Pointer(config)).Flow_memory != 0) {
  40675 		(*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens = libc.BoolInt32((*VP8Encoder)(unsafe.Pointer(enc)).Frd_opt_level >= int32(RD_OPT_BASIC)) // need rd stats
  40676 		if (*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens != 0 {
  40677 			(*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts = int32(1) // doesn't work with multi-partition
  40678 		}
  40679 	}
  40680 }
  40681 
  40682 // Memory scaling with dimensions:
  40683 //  memory (bytes) ~= 2.25 * w + 0.0625 * w * h
  40684 //
  40685 // Typical memory footprint (614x440 picture)
  40686 //              encoder: 22111
  40687 //                 info: 4368
  40688 //                preds: 17741
  40689 //          top samples: 1263
  40690 //             non-zero: 175
  40691 //             lf-stats: 0
  40692 //                total: 45658
  40693 // Transient object sizes:
  40694 //       VP8EncIterator: 3360
  40695 //         VP8ModeScore: 872
  40696 //       VP8SegmentInfo: 732
  40697 //          VP8EncProba: 18352
  40698 //              LFStats: 2048
  40699 // Picture size (yuv): 419328
  40700 
  40701 func InitVP8Encoder(tls *libc.TLS, config uintptr, picture uintptr) (r uintptr) {
  40702 	var enc, mem, v3 uintptr
  40703 	var info_size, lf_stats_size, nz_size, preds_size, samples_size, top_derr_size size_t
  40704 	var mb_h, mb_w, preds_h, preds_w, top_stride, use_filter, v5, v6 int32
  40705 	var scale float32
  40706 	var size uint64_t
  40707 	var v1, v2 uint64
  40708 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  40709 	use_filter = libc.BoolInt32((*WebPConfig)(unsafe.Pointer(config)).Ffilter_strength > 0 || (*WebPConfig)(unsafe.Pointer(config)).Fautofilter > 0)
  40710 	mb_w = ((*WebPPicture)(unsafe.Pointer(picture)).Fwidth + int32(15)) >> int32(4)
  40711 	mb_h = ((*WebPPicture)(unsafe.Pointer(picture)).Fheight + int32(15)) >> int32(4)
  40712 	preds_w = int32(4)*mb_w + int32(1)
  40713 	preds_h = int32(4)*mb_h + int32(1)
  40714 	preds_size = libc.Uint64FromInt32(preds_w*preds_h) * uint64(1)
  40715 	top_stride = mb_w * int32(16)
  40716 	nz_size = libc.Uint64FromInt32(mb_w+libc.Int32FromInt32(1))*uint64(4) + uint64(WEBP_ALIGN_CST)
  40717 	info_size = libc.Uint64FromInt32(mb_w*mb_h) * uint64(4)
  40718 	samples_size = libc.Uint64FromInt32(int32(2)*top_stride)*uint64(1) + uint64(WEBP_ALIGN_CST)
  40719 	if (*WebPConfig)(unsafe.Pointer(config)).Fautofilter != 0 {
  40720 		v1 = libc.Uint64FromInt64(2048) + libc.Uint64FromInt32(WEBP_ALIGN_CST)
  40721 	} else {
  40722 		v1 = uint64(0)
  40723 	} // align all
  40724 	lf_stats_size = v1
  40725 	if (*WebPConfig)(unsafe.Pointer(config)).Fquality <= libc.Float32FromInt32(ERROR_DIFFUSION_QUALITY) || (*WebPConfig)(unsafe.Pointer(config)).Fpass > int32(1) {
  40726 		v2 = libc.Uint64FromInt32(mb_w) * uint64(4)
  40727 	} else {
  40728 		v2 = uint64(0)
  40729 	}
  40730 	top_derr_size = v2
  40731 	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
  40732 	mem = WebPSafeMalloc(tls, size, uint64(1))
  40733 	if mem == libc.UintptrFromInt32(0) {
  40734 		WebPEncodingSetError(tls, picture, int32(VP8_ENC_ERROR_OUT_OF_MEMORY))
  40735 		return libc.UintptrFromInt32(0)
  40736 	}
  40737 	enc = mem
  40738 	mem = uintptr((uint64(mem+libc.UintptrFromInt64(23704)) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40739 	libc.X__builtin___memset_chk(tls, enc, 0, uint64(23704), ^__predefined_size_t(0))
  40740 	(*VP8Encoder)(unsafe.Pointer(enc)).Fnum_parts = int32(1) << (*WebPConfig)(unsafe.Pointer(config)).Fpartitions
  40741 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_w = mb_w
  40742 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_h = mb_h
  40743 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w = preds_w
  40744 	(*VP8Encoder)(unsafe.Pointer(enc)).Fmb_info = mem
  40745 	mem = mem + uintptr(info_size)
  40746 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpreds = mem + uintptr(1) + uintptr((*VP8Encoder)(unsafe.Pointer(enc)).Fpreds_w)
  40747 	mem = mem + uintptr(preds_size)
  40748 	(*VP8Encoder)(unsafe.Pointer(enc)).Fnz = uintptr(1)*4 + uintptr((uint64(mem)+libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40749 	mem = mem + uintptr(nz_size)
  40750 	if lf_stats_size != 0 {
  40751 		v3 = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40752 	} else {
  40753 		v3 = libc.UintptrFromInt32(0)
  40754 	}
  40755 	(*VP8Encoder)(unsafe.Pointer(enc)).Flf_stats = v3
  40756 	mem = mem + uintptr(lf_stats_size)
  40757 	// top samples (all 16-aligned)
  40758 	mem = uintptr((uint64(mem) + libc.Uint64FromInt32(WEBP_ALIGN_CST)) & ^libc.Uint64FromInt32(WEBP_ALIGN_CST))
  40759 	(*VP8Encoder)(unsafe.Pointer(enc)).Fy_top = mem
  40760 	(*VP8Encoder)(unsafe.Pointer(enc)).Fuv_top = (*VP8Encoder)(unsafe.Pointer(enc)).Fy_top + uintptr(top_stride)
  40761 	mem = mem + uintptr(int32(2)*top_stride)
  40762 	if top_derr_size != 0 {
  40763 		v3 = mem
  40764 	} else {
  40765 		v3 = libc.UintptrFromInt32(0)
  40766 	}
  40767 	(*VP8Encoder)(unsafe.Pointer(enc)).Ftop_derr = v3
  40768 	mem = mem + uintptr(top_derr_size)
  40769 	(*VP8Encoder)(unsafe.Pointer(enc)).Fconfig = config
  40770 	if use_filter != 0 {
  40771 		if (*WebPConfig)(unsafe.Pointer(config)).Ffilter_type == int32(1) {
  40772 			v6 = 0
  40773 		} else {
  40774 			v6 = int32(1)
  40775 		}
  40776 		v5 = v6
  40777 	} else {
  40778 		v5 = int32(2)
  40779 	}
  40780 	(*VP8Encoder)(unsafe.Pointer(enc)).Fprofile = v5
  40781 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpic = picture
  40782 	(*VP8Encoder)(unsafe.Pointer(enc)).Fpercent = 0
  40783 	MapConfigToTools(tls, enc)
  40784 	VP8EncDspInit(tls)
  40785 	VP8DefaultProbas(tls, enc)
  40786 	ResetSegmentHeader1(tls, enc)
  40787 	ResetFilterHeader(tls, enc)
  40788 	ResetBoundaryPredictions(tls, enc)
  40789 	VP8EncDspCostInit(tls)
  40790 	VP8EncInitAlpha(tls, enc)
  40791 	// lower quality means smaller output -> we modulate a little the page
  40792 	// size based on quality. This is just a crude 1rst-order prediction.
  40793 	scale = libc.Float32FromFloat32(1) + float32((*WebPConfig)(unsafe.Pointer(config)).Fquality*libc.Float32FromFloat32(5))/libc.Float32FromFloat32(100) // in [1,6]
  40794 	VP8TBufferInit(tls, enc+496, int32(float32(float32(mb_w*mb_h*libc.Int32FromInt32(4))*scale)))
  40795 	return enc
  40796 }
  40797 
  40798 func DeleteVP8Encoder(tls *libc.TLS, enc uintptr) (r int32) {
  40799 	var ok int32
  40800 	_ = ok
  40801 	ok = int32(1)
  40802 	if enc != libc.UintptrFromInt32(0) {
  40803 		ok = VP8EncDeleteAlpha(tls, enc)
  40804 		VP8TBufferClear(tls, enc+496)
  40805 		WebPSafeFree(tls, enc)
  40806 	}
  40807 	return ok
  40808 }
  40809 
  40810 //------------------------------------------------------------------------------
  40811 
  40812 func GetPSNR2(tls *libc.TLS, err uint64_t, size uint64_t) (r float64) {
  40813 	var v1 float64
  40814 	_ = v1
  40815 	if err > uint64(0) && size > uint64(0) {
  40816 		v1 = float64(float64(10) * libc.Xlog10(tls, float64(float64(libc.Float64FromFloat64(255)*libc.Float64FromFloat64(255))*float64(size))/float64(err)))
  40817 	} else {
  40818 		v1 = float64(99)
  40819 	}
  40820 	return v1
  40821 }
  40822 
  40823 func FinalizePSNR(tls *libc.TLS, enc uintptr) {
  40824 	var size uint64_t
  40825 	var sse, stats uintptr
  40826 	_, _, _ = size, sse, stats
  40827 	stats = (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats
  40828 	size = (*VP8Encoder)(unsafe.Pointer(enc)).Fsse_count
  40829 	sse = enc + 23512
  40830 	**(**float32)(__ccgo_up(stats + 4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse)), size))
  40831 	**(**float32)(__ccgo_up(stats + 4 + 1*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 1*8)), size/uint64(4)))
  40832 	**(**float32)(__ccgo_up(stats + 4 + 2*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 2*8)), size/uint64(4)))
  40833 	**(**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)))
  40834 	**(**float32)(__ccgo_up(stats + 4 + 4*4)) = float32(GetPSNR2(tls, **(**uint64_t)(__ccgo_up(sse + 3*8)), size))
  40835 }
  40836 
  40837 func StoreStats(tls *libc.TLS, enc uintptr) {
  40838 	var i, s int32
  40839 	var stats uintptr
  40840 	_, _, _ = i, s, stats
  40841 	stats = (*WebPPicture)(unsafe.Pointer((*VP8Encoder)(unsafe.Pointer(enc)).Fpic)).Fstats
  40842 	if stats != libc.UintptrFromInt32(0) {
  40843 		i = 0
  40844 		for {
  40845 			if !(i < int32(NUM_MB_SEGMENTS)) {
  40846 				break
  40847 			}
  40848 			**(**int32)(__ccgo_up(stats + 124 + uintptr(i)*4)) = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Ffstrength
  40849 			**(**int32)(__ccgo_up(stats + 108 + uintptr(i)*4)) = (**(**VP8SegmentInfo)(__ccgo_up(enc + 608 + uintptr(i)*744))).Fquant
  40850 			s = 0
  40851 			for {
  40852 				if !(s <= int32(2)) {
  40853 					break
  40854 				}
  40855 				**(**int32)(__ccgo_up(stats + 44 + uintptr(s)*16 + uintptr(i)*4)) = **(**int32)(__ccgo_up(enc + 23556 + uintptr(s)*16 + uintptr(i)*4))
  40856 				goto _2
  40857 			_2:
  40858 				;
  40859 				s = s + 1
  40860 			}
  40861 			goto _1
  40862 		_1:
  40863 			;
  40864 			i = i + 1
  40865 		}
  40866 		FinalizePSNR(tls, enc)
  40867 		(*WebPAuxStats)(unsafe.Pointer(stats)).Fcoded_size = (*VP8Encoder)(unsafe.Pointer(enc)).Fcoded_size
  40868 		i = 0
  40869 		for {
  40870 			if !(i < int32(3)) {
  40871 				break
  40872 			}
  40873 			**(**int32)(__ccgo_up(stats + 24 + uintptr(i)*4)) = **(**int32)(__ccgo_up(enc + 23604 + uintptr(i)*4))
  40874 			goto _3
  40875 		_3:
  40876 			;
  40877 			i = i + 1
  40878 		}
  40879 	}
  40880 }
  40881 
  40882 func WebPEncodingSetError(tls *libc.TLS, pic uintptr, error1 WebPEncodingError1) (r int32) {
  40883 	// The oldest error reported takes precedence over the new one.
  40884 	if (*WebPPicture)(unsafe.Pointer(pic)).Ferror_code == int32(VP8_ENC_OK) {
  40885 		(*WebPPicture)(unsafe.Pointer(pic)).Ferror_code = error1
  40886 	}
  40887 	return 0
  40888 }
  40889 
  40890 func WebPReportProgress(tls *libc.TLS, pic uintptr, percent int32, percent_store uintptr) (r int32) {
  40891 	if percent_store != libc.UintptrFromInt32(0) && percent != **(**int32)(__ccgo_up(percent_store)) {
  40892 		**(**int32)(__ccgo_up(percent_store)) = percent
  40893 		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) {
  40894 			// user abort requested
  40895 			return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_USER_ABORT))
  40896 		}
  40897 	}
  40898 	return int32(1) // ok
  40899 }
  40900 
  40901 //------------------------------------------------------------------------------
  40902 
  40903 func WebPEncode(tls *libc.TLS, config uintptr, pic uintptr) (r int32) {
  40904 	var dithering, x, x2 float32
  40905 	var enc uintptr
  40906 	var ok int32
  40907 	_, _, _, _, _ = dithering, enc, ok, x, x2
  40908 	ok = 0
  40909 	if pic == libc.UintptrFromInt32(0) {
  40910 		return 0
  40911 	}
  40912 	(*WebPPicture)(unsafe.Pointer(pic)).Ferror_code = int32(VP8_ENC_OK) // all ok so far
  40913 	if config == libc.UintptrFromInt32(0) {                             // bad params
  40914 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_NULL_PARAMETER))
  40915 	}
  40916 	if !(WebPValidateConfig(tls, config) != 0) {
  40917 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_INVALID_CONFIGURATION))
  40918 	}
  40919 	if !(WebPValidatePicture(tls, pic) != 0) {
  40920 		return 0
  40921 	}
  40922 	if (*WebPPicture)(unsafe.Pointer(pic)).Fwidth > int32(WEBP_MAX_DIMENSION) || (*WebPPicture)(unsafe.Pointer(pic)).Fheight > int32(WEBP_MAX_DIMENSION) {
  40923 		return WebPEncodingSetError(tls, pic, int32(VP8_ENC_ERROR_BAD_DIMENSION))
  40924 	}
  40925 	if (*WebPPicture)(unsafe.Pointer(pic)).Fstats != libc.UintptrFromInt32(0) {
  40926 		libc.X__builtin___memset_chk(tls, (*WebPPicture)(unsafe.Pointer(pic)).Fstats, 0, uint64(188), ^__predefined_size_t(0))
  40927 	}
  40928 	if !((*WebPConfig)(unsafe.Pointer(config)).Flossless != 0) {
  40929 		enc = libc.UintptrFromInt32(0)
  40930 		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) {
  40931 			// Make sure we have YUVA samples.
  40932 			if (*WebPConfig)(unsafe.Pointer(config)).Fuse_sharp_yuv != 0 || (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing&int32(4) != 0 {
  40933 				if !(WebPPictureSharpARGBToYUVA(tls, pic) != 0) {
  40934 					return 0
  40935 				}
  40936 			} else {
  40937 				dithering = libc.Float32FromFloat32(0)
  40938 				if (*WebPConfig)(unsafe.Pointer(config)).Fpreprocessing&int32(2) != 0 {
  40939 					x = (*WebPConfig)(unsafe.Pointer(config)).Fquality / libc.Float32FromFloat32(100)
  40940 					x2 = float32(x * x)
  40941 					// slowly decreasing from max dithering at low quality (q->0)
  40942 					// to 0.5 dithering amplitude at high quality (q->100)
  40943 					dithering = libc.Float32FromFloat32(1) + float32(float32((libc.Float32FromFloat32(0.5)-libc.Float32FromFloat32(1))*x2)*x2)
  40944 				}
  40945 				if !(WebPPictureARGBToYUVADithered(tls, pic, int32(WEBP_YUV420), dithering) != 0) {
  40946 					return 0
  40947 				}
  40948 			}
  40949 		}
  40950 		if !((*WebPConfig)(unsafe.Pointer(config)).Fexact != 0) {
  40951 			WebPCleanupTransparentArea(tls, pic)
  40952 		}
  40953 		enc = InitVP8Encoder(tls, config, pic)
  40954 		if enc == libc.UintptrFromInt32(0) {
  40955 			return 0
  40956 		} // pic->error is already set.
  40957 		// Note: each of the tasks below account for 20% in the progress report.
  40958 		ok = VP8EncAnalyze(tls, enc)
  40959 		// Analysis is done, proceed to actual coding.
  40960 		ok = libc.BoolInt32(ok != 0 && VP8EncStartAlpha(tls, enc) != 0) // possibly done in parallel
  40961 		if !((*VP8Encoder)(unsafe.Pointer(enc)).Fuse_tokens != 0) {
  40962 			ok = libc.BoolInt32(ok != 0 && VP8EncLoop(tls, enc) != 0)
  40963 		} else {
  40964 			ok = libc.BoolInt32(ok != 0 && VP8EncTokenLoop(tls, enc) != 0)
  40965 		}
  40966 		ok = libc.BoolInt32(ok != 0 && VP8EncFinishAlpha(tls, enc) != 0)
  40967 		ok = libc.BoolInt32(ok != 0 && VP8EncWrite(tls, enc) != 0)
  40968 		StoreStats(tls, enc)
  40969 		if !(ok != 0) {
  40970 			VP8EncFreeBitWriters(tls, enc)
  40971 		}
  40972 		ok = ok & DeleteVP8Encoder(tls, enc) // must always be called, even if !ok
  40973 	} else {
  40974 		// Make sure we have ARGB samples.
  40975 		if (*WebPPicture)(unsafe.Pointer(pic)).Fargb == libc.UintptrFromInt32(0) && !(WebPPictureYUVAToARGB(tls, pic) != 0) {
  40976 			return 0
  40977 		}
  40978 		if !((*WebPConfig)(unsafe.Pointer(config)).Fexact != 0) {
  40979 			WebPReplaceTransparentPixels(tls, pic, uint32(0x000000))
  40980 		}
  40981 		ok = VP8LEncodeImage(tls, config, pic) // Sets pic->error in case of problem.
  40982 	}
  40983 	return ok
  40984 }
  40985 
  40986 const VP8L_LOG8_WBITS = 4
  40987 const __FLT_MIN__10 = 1.17549435082228750796873653722224568e-38
  40988 
  40989 // Copyright 2010 Google Inc. All Rights Reserved.
  40990 //
  40991 // Use of this source code is governed by a BSD-style license
  40992 // that can be found in the COPYING file in the root of the source
  40993 // tree. An additional intellectual property rights grant can be found
  40994 // in the file PATENTS. All contributing project authors may
  40995 // be found in the AUTHORS file in the root of the source tree.
  40996 // -----------------------------------------------------------------------------
  40997 //
  40998 // Boolean decoder
  40999 //
  41000 // Author: Skal (pascal.massimino@gmail.com)
  41001 //         Vikas Arora (vikaas.arora@gmail.com)
  41002 
  41003 // Copyright 2014 Google Inc. All Rights Reserved.
  41004 //
  41005 // Use of this source code is governed by a BSD-style license
  41006 // that can be found in the COPYING file in the root of the source
  41007 // tree. An additional intellectual property rights grant can be found
  41008 // in the file PATENTS. All contributing project authors may
  41009 // be found in the AUTHORS file in the root of the source tree.
  41010 // -----------------------------------------------------------------------------
  41011 //
  41012 // Endian related functions.
  41013 
  41014 // Copyright 2012 Google Inc. All Rights Reserved.
  41015 //
  41016 // Use of this source code is governed by a BSD-style license
  41017 // that can be found in the COPYING file in the root of the source
  41018 // tree. An additional intellectual property rights grant can be found
  41019 // in the file PATENTS. All contributing project authors may
  41020 // be found in the AUTHORS file in the root of the source tree.
  41021 // -----------------------------------------------------------------------------
  41022 //
  41023 // Misc. common utility functions
  41024 //
  41025 // Authors: Skal (pascal.massimino@gmail.com)
  41026 //          Urvang (urvang@google.com)
  41027 
  41028 //------------------------------------------------------------------------------
  41029 // VP8BitReader
  41030 
  41031 func VP8BitReaderSetBuffer(tls *libc.TLS, br uintptr, start uintptr, size size_t) {
  41032 	var v1 uintptr
  41033 	_ = v1
  41034 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf = start
  41035 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end = start + uintptr(size)
  41036 	if size >= uint64(8) {
  41037 		v1 = start + uintptr(size) - uintptr(8) + uintptr(1)
  41038 	} else {
  41039 		v1 = start
  41040 	}
  41041 	(*VP8BitReader)(unsafe.Pointer(br)).Fbuf_max = v1
  41042 }
  41043 
  41044 func VP8InitBitReader(tls *libc.TLS, br1 uintptr, start uintptr, size size_t) {
  41045 	bp := tls.Alloc(16)
  41046 	defer tls.Free(16)
  41047 	var bits bit_t
  41048 	var v1 uintptr
  41049 	var v2 uint64_t
  41050 	var _ /* in_bits at bp+0 */ lbit_t
  41051 	_, _, _ = bits, v1, v2
  41052 	// limit ensured by format and upstream checks
  41053 	(*VP8BitReader)(unsafe.Pointer(br1)).Frange1 = libc.Uint32FromInt32(libc.Int32FromInt32(255) - libc.Int32FromInt32(1))
  41054 	(*VP8BitReader)(unsafe.Pointer(br1)).Fvalue = uint64(0)
  41055 	(*VP8BitReader)(unsafe.Pointer(br1)).Fbits = -int32(8) // to load the very first 8bits
  41056 	(*VP8BitReader)(unsafe.Pointer(br1)).Feof = 0
  41057 	VP8BitReaderSetBuffer(tls, br1, start, size)
  41058 	v1 = br1
  41059 	if (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf_max {
  41060 		libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v1)).Fbuf, uint64(8), ^__predefined_size_t(0))
  41061 		**(**uintptr)(__ccgo_up(v1 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  41062 		v2 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  41063 		goto _3
  41064 	_3:
  41065 		bits = v2
  41066 		bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  41067 		(*VP8BitReader)(unsafe.Pointer(v1)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v1)).Fvalue<<libc.Int32FromInt32(BITS)
  41068 		**(**int32)(__ccgo_up(v1 + 12)) += int32(BITS)
  41069 	} else {
  41070 		VP8LoadFinalBytes(tls, v1)
  41071 	}
  41072 }
  41073 
  41074 func VP8RemapBitReader(tls *libc.TLS, br uintptr, offset ptrdiff_t) {
  41075 	if (*VP8BitReader)(unsafe.Pointer(br)).Fbuf != libc.UintptrFromInt32(0) {
  41076 		**(**uintptr)(__ccgo_up(br + 16)) += uintptr(offset)
  41077 		**(**uintptr)(__ccgo_up(br + 24)) += uintptr(offset)
  41078 		**(**uintptr)(__ccgo_up(br + 32)) += uintptr(offset)
  41079 	}
  41080 }
  41081 
  41082 func VP8LoadFinalBytes(tls *libc.TLS, br uintptr) {
  41083 	var v1, v2 uintptr
  41084 	_, _ = v1, v2
  41085 	// Only read 8bits at a time
  41086 	if (*VP8BitReader)(unsafe.Pointer(br)).Fbuf < (*VP8BitReader)(unsafe.Pointer(br)).Fbuf_end {
  41087 		**(**int32)(__ccgo_up(br + 12)) += int32(8)
  41088 		v2 = br + 16
  41089 		v1 = *(*uintptr)(unsafe.Pointer(v2))
  41090 		*(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1
  41091 		(*VP8BitReader)(unsafe.Pointer(br)).Fvalue = uint64(**(**uint8_t)(__ccgo_up(v1))) | (*VP8BitReader)(unsafe.Pointer(br)).Fvalue<<libc.Int32FromInt32(8)
  41092 	} else {
  41093 		if !((*VP8BitReader)(unsafe.Pointer(br)).Feof != 0) {
  41094 			**(**bit_t)(__ccgo_up(br)) <<= uint64(8)
  41095 			**(**int32)(__ccgo_up(br + 12)) += int32(8)
  41096 			(*VP8BitReader)(unsafe.Pointer(br)).Feof = int32(1)
  41097 		} else {
  41098 			(*VP8BitReader)(unsafe.Pointer(br)).Fbits = 0 // This is to avoid undefined behaviour with shifts.
  41099 		}
  41100 	}
  41101 }
  41102 
  41103 //------------------------------------------------------------------------------
  41104 // Higher-level calls
  41105 
  41106 func VP8GetValue(tls *libc.TLS, br2 uintptr, bits1 int32) (r uint32_t) {
  41107 	bp := tls.Alloc(16)
  41108 	defer tls.Free(16)
  41109 	var bit, pos, shift, v1, v6, v8 int32
  41110 	var bits bit_t
  41111 	var range1, split, value range_t
  41112 	var v uint32_t
  41113 	var v2, v3 uintptr
  41114 	var v4 uint64_t
  41115 	var _ /* in_bits at bp+0 */ lbit_t
  41116 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = bit, bits, pos, range1, shift, split, v, value, v1, v2, v3, v4, v6, v8
  41117 	v = uint32(0)
  41118 	for {
  41119 		v1 = bits1
  41120 		bits1 = bits1 - 1
  41121 		if !(v1 > 0) {
  41122 			break
  41123 		}
  41124 		v2 = br2
  41125 		range1 = (*VP8BitReader)(unsafe.Pointer(v2)).Frange1
  41126 		if (*VP8BitReader)(unsafe.Pointer(v2)).Fbits < libc.Int32FromInt32(0) {
  41127 			v3 = v2
  41128 			if (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf < (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf_max {
  41129 				libc.X__builtin___memcpy_chk(tls, bp, (*VP8BitReader)(unsafe.Pointer(v3)).Fbuf, uint64(8), ^__predefined_size_t(0))
  41130 				**(**uintptr)(__ccgo_up(v3 + 16)) += uintptr(libc.Int32FromInt32(BITS) >> libc.Int32FromInt32(3))
  41131 				v4 = uint64(libc.X__builtin_bswap64(tls, uint64(**(**lbit_t)(__ccgo_up(bp)))))
  41132 				goto _5
  41133 			_5:
  41134 				bits = v4
  41135 				bits = bits >> libc.Uint64FromInt32(libc.Int32FromInt32(64)-libc.Int32FromInt32(BITS))
  41136 				(*VP8BitReader)(unsafe.Pointer(v3)).Fvalue = bits | (*VP8BitReader)(unsafe.Pointer(v3)).Fvalue<<libc.Int32FromInt32(BITS)
  41137 				**(**int32)(__ccgo_up(v3 + 12)) += int32(BITS)
  41138 			} else {
  41139 				VP8LoadFinalBytes(tls, v3)
  41140 			}
  41141 		}
  41142 		pos = (*VP8BitReader)(unsafe.Pointer(v2)).Fbits
  41143 		split = range1 * libc.Uint32FromInt32(int32(0x80)) >> int32(8)
  41144 		value = uint32((*VP8BitReader)(unsafe.Pointer(v2)).Fvalue >> pos)
  41145 		bit = libc.BoolInt32(value > split)
  41146 		if bit != 0 {
  41147 			range1 = range1 - split
  41148 			**(**bit_t)(__ccgo_up(v2)) -= uint64(split+libc.Uint32FromInt32(1)) << pos
  41149 		} else {
  41150 			range1 = split + uint32(1)
  41151 		}
  41152 		v6 = int32(31) ^ libc.X__builtin_clz(tls, range1)
  41153 		goto _7
  41154 	_7:
  41155 		shift = int32(7) ^ v6
  41156 		range1 = range1 << libc.Uint32FromInt32(shift)
  41157 		**(**int32)(__ccgo_up(v2 + 12)) -= shift
  41158 		(*VP8BitReader)(unsafe.Pointer(v2)).Frange1 = range1 - uint32(1)
  41159 		v8 = bit
  41160 		goto _9
  41161 	_9:
  41162 		v = v | libc.Uint32FromInt32(v8<<bits1)
  41163 	}
  41164 	return v
  41165 }
  41166 
  41167 func VP8GetSignedValue(tls *libc.TLS, br uintptr, bits int32) (r int32_t) {
  41168 	var value, v1 int32
  41169 	_, _ = value, v1
  41170 	value = libc.Int32FromUint32(VP8GetValue(tls, br, bits))
  41171 	if VP8GetValue(tls, br, int32(1)) != 0 {
  41172 		v1 = -value
  41173 	} else {
  41174 		v1 = value
  41175 	}
  41176 	return v1
  41177 }
  41178 
  41179 //------------------------------------------------------------------------------
  41180 // VP8LBitReader
  41181 
  41182 var kBitMask = [25]uint32_t{
  41183 	1:  uint32(0x000001),
  41184 	2:  uint32(0x000003),
  41185 	3:  uint32(0x000007),
  41186 	4:  uint32(0x00000f),
  41187 	5:  uint32(0x00001f),
  41188 	6:  uint32(0x00003f),
  41189 	7:  uint32(0x00007f),
  41190 	8:  uint32(0x0000ff),
  41191 	9:  uint32(0x0001ff),
  41192 	10: uint32(0x0003ff),
  41193 	11: uint32(0x0007ff),
  41194 	12: uint32(0x000fff),
  41195 	13: uint32(0x001fff),
  41196 	14: uint32(0x003fff),
  41197 	15: uint32(0x007fff),
  41198 	16: uint32(0x00ffff),
  41199 	17: uint32(0x01ffff),
  41200 	18: uint32(0x03ffff),
  41201 	19: uint32(0x07ffff),
  41202 	20: uint32(0x0fffff),
  41203 	21: uint32(0x1fffff),
  41204 	22: uint32(0x3fffff),
  41205 	23: uint32(0x7fffff),
  41206 	24: uint32(0xffffff),
  41207 }
  41208 
  41209 func VP8LInitBitReader(tls *libc.TLS, br uintptr, start uintptr, length size_t) {
  41210 	var i size_t
  41211 	var value vp8l_val_t
  41212 	_, _ = i, value
  41213 	value = uint64(0)
  41214 	// can't happen with a RIFF chunk.
  41215 	(*VP8LBitReader)(unsafe.Pointer(br)).Flen1 = length
  41216 	(*VP8LBitReader)(unsafe.Pointer(br)).Fval = uint64(0)
  41217 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbit_pos = 0
  41218 	(*VP8LBitReader)(unsafe.Pointer(br)).Feos = 0
  41219 	if length > uint64(8) {
  41220 		length = uint64(8)
  41221 	}
  41222 	i = uint64(0)
  41223 	for {
  41224 		if !(i < length) {
  41225 			break
  41226 		}
  41227 		value = value | uint64(**(**uint8_t)(__ccgo_up(start + uintptr(i))))<<(uint64(8)*i)
  41228 		goto _1
  41229 	_1:
  41230 		;
  41231 		i = i + 1
  41232 	}
  41233 	(*VP8LBitReader)(unsafe.Pointer(br)).Fval = value
  41234 	(*VP8LBitReader)(unsafe.Pointer(br)).Fpos = length
  41235 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbuf = start
  41236 }
  41237 
  41238 func VP8LBitReaderSetBuffer(tls *libc.TLS, br1 uintptr, buf uintptr, len1 size_t) {
  41239 	var v1 uintptr
  41240 	var v2 int32
  41241 	var v4 bool
  41242 	_, _, _ = v1, v2, v4
  41243 	// can't happen with a RIFF chunk.
  41244 	(*VP8LBitReader)(unsafe.Pointer(br1)).Fbuf = buf
  41245 	(*VP8LBitReader)(unsafe.Pointer(br1)).Flen1 = len1
  41246 	// 'pos' > 'len' should be considered a param error.
  41247 	if v4 = (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos > (*VP8LBitReader)(unsafe.Pointer(br1)).Flen1; !v4 {
  41248 		v1 = br1
  41249 		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))
  41250 		goto _3
  41251 	_3:
  41252 	}
  41253 	(*VP8LBitReader)(unsafe.Pointer(br1)).Feos = libc.BoolInt32(v4 || v2 != 0)
  41254 }
  41255 
  41256 func VP8LSetEndOfStream(tls *libc.TLS, br uintptr) {
  41257 	(*VP8LBitReader)(unsafe.Pointer(br)).Feos = int32(1)
  41258 	(*VP8LBitReader)(unsafe.Pointer(br)).Fbit_pos = 0 // To avoid undefined behaviour with shifts.
  41259 }
  41260 
  41261 // C documentation
  41262 //
  41263 //	// If not at EOS, reload up to VP8L_LBITS byte-by-byte
  41264 func ShiftBytes(tls *libc.TLS, br1 uintptr) {
  41265 	var v1 uintptr
  41266 	var v2 int32
  41267 	_, _ = v1, v2
  41268 	for (*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos >= int32(8) && (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos < (*VP8LBitReader)(unsafe.Pointer(br1)).Flen1 {
  41269 		**(**vp8l_val_t)(__ccgo_up(br1)) >>= uint64(8)
  41270 		**(**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))
  41271 		(*VP8LBitReader)(unsafe.Pointer(br1)).Fpos = (*VP8LBitReader)(unsafe.Pointer(br1)).Fpos + 1
  41272 		**(**int32)(__ccgo_up(br1 + 32)) -= int32(8)
  41273 	}
  41274 	v1 = br1
  41275 	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))
  41276 	goto _3
  41277 _3:
  41278 	if v2 != 0 {
  41279 		VP8LSetEndOfStream(tls, br1)
  41280 	}
  41281 }
  41282 
  41283 func VP8LDoFillBitWindow(tls *libc.TLS, br uintptr) {
  41284 	bp := tls.Alloc(16)
  41285 	defer tls.Free(16)
  41286 	var v1 uint32_t
  41287 	var _ /* A at bp+0 */ uint32_t
  41288 	_ = v1
  41289 	if (*VP8LBitReader)(unsafe.Pointer(br)).Fpos+uint64(8) < (*VP8LBitReader)(unsafe.Pointer(br)).Flen1 {
  41290 		**(**vp8l_val_t)(__ccgo_up(br)) >>= uint64(VP8L_WBITS)
  41291 		**(**int32)(__ccgo_up(br + 32)) -= int32(VP8L_WBITS)
  41292 		libc.X__builtin___memcpy_chk(tls, bp, (*VP8LBitReader)(unsafe.Pointer(br)).Fbuf+uintptr((*VP8LBitReader)(unsafe.Pointer(br)).Fpos), uint64(4), ^__predefined_size_t(0))
  41293 		v1 = **(**uint32_t)(__ccgo_up(bp))
  41294 		goto _2
  41295 	_2:
  41296 		**(**vp8l_val_t)(__ccgo_up(br)) |= uint64(v1) << (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(VP8L_WBITS))
  41297 		**(**size_t)(__ccgo_up(br + 24)) += uint64(VP8L_LOG8_WBITS)
  41298 		return
  41299 	}
  41300 	ShiftBytes(tls, br) // Slow path.
  41301 }
  41302 
  41303 func VP8LReadBits(tls *libc.TLS, br1 uintptr, n_bits int32) (r uint32_t) {
  41304 	var new_bits int32
  41305 	var val, v2 uint32_t
  41306 	var v1 uintptr
  41307 	_, _, _, _ = new_bits, val, v1, v2
  41308 	// Flag an error if end_of_stream or n_bits is more than allowed limit.
  41309 	if !((*VP8LBitReader)(unsafe.Pointer(br1)).Feos != 0) && n_bits <= int32(VP8L_MAX_NUM_BIT_READ) {
  41310 		v1 = br1
  41311 		v2 = uint32((*VP8LBitReader)(unsafe.Pointer(v1)).Fval >> ((*VP8LBitReader)(unsafe.Pointer(v1)).Fbit_pos & (libc.Int32FromInt32(VP8L_LBITS) - libc.Int32FromInt32(1))))
  41312 		goto _3
  41313 	_3:
  41314 		val = v2 & kBitMask[n_bits]
  41315 		new_bits = (*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos + n_bits
  41316 		(*VP8LBitReader)(unsafe.Pointer(br1)).Fbit_pos = new_bits
  41317 		ShiftBytes(tls, br1)
  41318 		return val
  41319 	} else {
  41320 		VP8LSetEndOfStream(tls, br1)
  41321 		return uint32(0)
  41322 	}
  41323 	return r
  41324 }
  41325 
  41326 const MIN_EXTRA_SIZE = 32768
  41327 
  41328 //------------------------------------------------------------------------------
  41329 
  41330 //------------------------------------------------------------------------------
  41331 // VP8BitWriter
  41332 
  41333 func BitWriterResize(tls *libc.TLS, bw uintptr, extra_size size_t) (r int32) {
  41334 	var needed_size, new_size size_t
  41335 	var needed_size_64b uint64_t
  41336 	var new_buf uintptr
  41337 	_, _, _, _ = needed_size, needed_size_64b, new_buf, new_size
  41338 	needed_size_64b = (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos + extra_size
  41339 	needed_size = needed_size_64b
  41340 	if needed_size_64b != needed_size {
  41341 		(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41342 		return 0
  41343 	}
  41344 	if needed_size <= (*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos {
  41345 		return int32(1)
  41346 	}
  41347 	// If the following line wraps over 32bit, the test just after will catch it.
  41348 	new_size = uint64(2) * (*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos
  41349 	if new_size < needed_size {
  41350 		new_size = needed_size
  41351 	}
  41352 	if new_size < uint64(1024) {
  41353 		new_size = uint64(1024)
  41354 	}
  41355 	new_buf = WebPSafeMalloc(tls, uint64(1), new_size)
  41356 	if new_buf == libc.UintptrFromInt32(0) {
  41357 		(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41358 		return 0
  41359 	}
  41360 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos > uint64(0) {
  41361 		libc.X__builtin___memcpy_chk(tls, new_buf, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf, (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos, ^__predefined_size_t(0))
  41362 	}
  41363 	WebPSafeFree(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf)
  41364 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf = new_buf
  41365 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos = new_size
  41366 	return int32(1)
  41367 }
  41368 
  41369 func Flush(tls *libc.TLS, bw uintptr) {
  41370 	var bits int32_t
  41371 	var pos, v3 size_t
  41372 	var s, value, v1 int32
  41373 	_, _, _, _, _, _ = bits, pos, s, value, v1, v3
  41374 	s = int32(8) + (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits
  41375 	bits = (*VP8BitWriter)(unsafe.Pointer(bw)).Fvalue >> s
  41376 	**(**int32_t)(__ccgo_up(bw + 4)) -= bits << s
  41377 	**(**int32)(__ccgo_up(bw + 12)) -= int32(8)
  41378 	if bits&int32(0xff) != int32(0xff) {
  41379 		pos = (*VP8BitWriter)(unsafe.Pointer(bw)).Fpos
  41380 		if !(BitWriterResize(tls, bw, libc.Uint64FromInt32((*VP8BitWriter)(unsafe.Pointer(bw)).Frun+int32(1))) != 0) {
  41381 			return
  41382 		}
  41383 		if bits&int32(0x100) != 0 { // overflow -> propagate carry over pending 0xff's
  41384 			if pos > uint64(0) {
  41385 				**(**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
  41386 			}
  41387 		}
  41388 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Frun > 0 {
  41389 			if bits&int32(0x100) != 0 {
  41390 				v1 = 0x00
  41391 			} else {
  41392 				v1 = int32(0xff)
  41393 			}
  41394 			value = v1
  41395 			for {
  41396 				if !((*VP8BitWriter)(unsafe.Pointer(bw)).Frun > 0) {
  41397 					break
  41398 				}
  41399 				v3 = pos
  41400 				pos = pos + 1
  41401 				**(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(v3))) = libc.Uint8FromInt32(value)
  41402 				goto _2
  41403 			_2:
  41404 				;
  41405 				(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = (*VP8BitWriter)(unsafe.Pointer(bw)).Frun - 1
  41406 			}
  41407 		}
  41408 		v3 = pos
  41409 		pos = pos + 1
  41410 		**(**uint8_t)(__ccgo_up((*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(v3))) = libc.Uint8FromInt32(bits & int32(0xff))
  41411 		(*VP8BitWriter)(unsafe.Pointer(bw)).Fpos = pos
  41412 	} else {
  41413 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = (*VP8BitWriter)(unsafe.Pointer(bw)).Frun + 1 // delay writing of bytes 0xff, pending eventual carry.
  41414 	}
  41415 }
  41416 
  41417 //------------------------------------------------------------------------------
  41418 // renormalization
  41419 
  41420 var kNorm = [128]uint8_t{
  41421 	0:   uint8(7),
  41422 	1:   uint8(6),
  41423 	2:   uint8(6),
  41424 	3:   uint8(5),
  41425 	4:   uint8(5),
  41426 	5:   uint8(5),
  41427 	6:   uint8(5),
  41428 	7:   uint8(4),
  41429 	8:   uint8(4),
  41430 	9:   uint8(4),
  41431 	10:  uint8(4),
  41432 	11:  uint8(4),
  41433 	12:  uint8(4),
  41434 	13:  uint8(4),
  41435 	14:  uint8(4),
  41436 	15:  uint8(3),
  41437 	16:  uint8(3),
  41438 	17:  uint8(3),
  41439 	18:  uint8(3),
  41440 	19:  uint8(3),
  41441 	20:  uint8(3),
  41442 	21:  uint8(3),
  41443 	22:  uint8(3),
  41444 	23:  uint8(3),
  41445 	24:  uint8(3),
  41446 	25:  uint8(3),
  41447 	26:  uint8(3),
  41448 	27:  uint8(3),
  41449 	28:  uint8(3),
  41450 	29:  uint8(3),
  41451 	30:  uint8(3),
  41452 	31:  uint8(2),
  41453 	32:  uint8(2),
  41454 	33:  uint8(2),
  41455 	34:  uint8(2),
  41456 	35:  uint8(2),
  41457 	36:  uint8(2),
  41458 	37:  uint8(2),
  41459 	38:  uint8(2),
  41460 	39:  uint8(2),
  41461 	40:  uint8(2),
  41462 	41:  uint8(2),
  41463 	42:  uint8(2),
  41464 	43:  uint8(2),
  41465 	44:  uint8(2),
  41466 	45:  uint8(2),
  41467 	46:  uint8(2),
  41468 	47:  uint8(2),
  41469 	48:  uint8(2),
  41470 	49:  uint8(2),
  41471 	50:  uint8(2),
  41472 	51:  uint8(2),
  41473 	52:  uint8(2),
  41474 	53:  uint8(2),
  41475 	54:  uint8(2),
  41476 	55:  uint8(2),
  41477 	56:  uint8(2),
  41478 	57:  uint8(2),
  41479 	58:  uint8(2),
  41480 	59:  uint8(2),
  41481 	60:  uint8(2),
  41482 	61:  uint8(2),
  41483 	62:  uint8(2),
  41484 	63:  uint8(1),
  41485 	64:  uint8(1),
  41486 	65:  uint8(1),
  41487 	66:  uint8(1),
  41488 	67:  uint8(1),
  41489 	68:  uint8(1),
  41490 	69:  uint8(1),
  41491 	70:  uint8(1),
  41492 	71:  uint8(1),
  41493 	72:  uint8(1),
  41494 	73:  uint8(1),
  41495 	74:  uint8(1),
  41496 	75:  uint8(1),
  41497 	76:  uint8(1),
  41498 	77:  uint8(1),
  41499 	78:  uint8(1),
  41500 	79:  uint8(1),
  41501 	80:  uint8(1),
  41502 	81:  uint8(1),
  41503 	82:  uint8(1),
  41504 	83:  uint8(1),
  41505 	84:  uint8(1),
  41506 	85:  uint8(1),
  41507 	86:  uint8(1),
  41508 	87:  uint8(1),
  41509 	88:  uint8(1),
  41510 	89:  uint8(1),
  41511 	90:  uint8(1),
  41512 	91:  uint8(1),
  41513 	92:  uint8(1),
  41514 	93:  uint8(1),
  41515 	94:  uint8(1),
  41516 	95:  uint8(1),
  41517 	96:  uint8(1),
  41518 	97:  uint8(1),
  41519 	98:  uint8(1),
  41520 	99:  uint8(1),
  41521 	100: uint8(1),
  41522 	101: uint8(1),
  41523 	102: uint8(1),
  41524 	103: uint8(1),
  41525 	104: uint8(1),
  41526 	105: uint8(1),
  41527 	106: uint8(1),
  41528 	107: uint8(1),
  41529 	108: uint8(1),
  41530 	109: uint8(1),
  41531 	110: uint8(1),
  41532 	111: uint8(1),
  41533 	112: uint8(1),
  41534 	113: uint8(1),
  41535 	114: uint8(1),
  41536 	115: uint8(1),
  41537 	116: uint8(1),
  41538 	117: uint8(1),
  41539 	118: uint8(1),
  41540 	119: uint8(1),
  41541 	120: uint8(1),
  41542 	121: uint8(1),
  41543 	122: uint8(1),
  41544 	123: uint8(1),
  41545 	124: uint8(1),
  41546 	125: uint8(1),
  41547 	126: uint8(1),
  41548 }
  41549 
  41550 // C documentation
  41551 //
  41552 //	// range = ((range + 1) << kVP8Log2Range[range]) - 1
  41553 var kNewRange = [128]uint8_t{
  41554 	0:   uint8(127),
  41555 	1:   uint8(127),
  41556 	2:   uint8(191),
  41557 	3:   uint8(127),
  41558 	4:   uint8(159),
  41559 	5:   uint8(191),
  41560 	6:   uint8(223),
  41561 	7:   uint8(127),
  41562 	8:   uint8(143),
  41563 	9:   uint8(159),
  41564 	10:  uint8(175),
  41565 	11:  uint8(191),
  41566 	12:  uint8(207),
  41567 	13:  uint8(223),
  41568 	14:  uint8(239),
  41569 	15:  uint8(127),
  41570 	16:  uint8(135),
  41571 	17:  uint8(143),
  41572 	18:  uint8(151),
  41573 	19:  uint8(159),
  41574 	20:  uint8(167),
  41575 	21:  uint8(175),
  41576 	22:  uint8(183),
  41577 	23:  uint8(191),
  41578 	24:  uint8(199),
  41579 	25:  uint8(207),
  41580 	26:  uint8(215),
  41581 	27:  uint8(223),
  41582 	28:  uint8(231),
  41583 	29:  uint8(239),
  41584 	30:  uint8(247),
  41585 	31:  uint8(127),
  41586 	32:  uint8(131),
  41587 	33:  uint8(135),
  41588 	34:  uint8(139),
  41589 	35:  uint8(143),
  41590 	36:  uint8(147),
  41591 	37:  uint8(151),
  41592 	38:  uint8(155),
  41593 	39:  uint8(159),
  41594 	40:  uint8(163),
  41595 	41:  uint8(167),
  41596 	42:  uint8(171),
  41597 	43:  uint8(175),
  41598 	44:  uint8(179),
  41599 	45:  uint8(183),
  41600 	46:  uint8(187),
  41601 	47:  uint8(191),
  41602 	48:  uint8(195),
  41603 	49:  uint8(199),
  41604 	50:  uint8(203),
  41605 	51:  uint8(207),
  41606 	52:  uint8(211),
  41607 	53:  uint8(215),
  41608 	54:  uint8(219),
  41609 	55:  uint8(223),
  41610 	56:  uint8(227),
  41611 	57:  uint8(231),
  41612 	58:  uint8(235),
  41613 	59:  uint8(239),
  41614 	60:  uint8(243),
  41615 	61:  uint8(247),
  41616 	62:  uint8(251),
  41617 	63:  uint8(127),
  41618 	64:  uint8(129),
  41619 	65:  uint8(131),
  41620 	66:  uint8(133),
  41621 	67:  uint8(135),
  41622 	68:  uint8(137),
  41623 	69:  uint8(139),
  41624 	70:  uint8(141),
  41625 	71:  uint8(143),
  41626 	72:  uint8(145),
  41627 	73:  uint8(147),
  41628 	74:  uint8(149),
  41629 	75:  uint8(151),
  41630 	76:  uint8(153),
  41631 	77:  uint8(155),
  41632 	78:  uint8(157),
  41633 	79:  uint8(159),
  41634 	80:  uint8(161),
  41635 	81:  uint8(163),
  41636 	82:  uint8(165),
  41637 	83:  uint8(167),
  41638 	84:  uint8(169),
  41639 	85:  uint8(171),
  41640 	86:  uint8(173),
  41641 	87:  uint8(175),
  41642 	88:  uint8(177),
  41643 	89:  uint8(179),
  41644 	90:  uint8(181),
  41645 	91:  uint8(183),
  41646 	92:  uint8(185),
  41647 	93:  uint8(187),
  41648 	94:  uint8(189),
  41649 	95:  uint8(191),
  41650 	96:  uint8(193),
  41651 	97:  uint8(195),
  41652 	98:  uint8(197),
  41653 	99:  uint8(199),
  41654 	100: uint8(201),
  41655 	101: uint8(203),
  41656 	102: uint8(205),
  41657 	103: uint8(207),
  41658 	104: uint8(209),
  41659 	105: uint8(211),
  41660 	106: uint8(213),
  41661 	107: uint8(215),
  41662 	108: uint8(217),
  41663 	109: uint8(219),
  41664 	110: uint8(221),
  41665 	111: uint8(223),
  41666 	112: uint8(225),
  41667 	113: uint8(227),
  41668 	114: uint8(229),
  41669 	115: uint8(231),
  41670 	116: uint8(233),
  41671 	117: uint8(235),
  41672 	118: uint8(237),
  41673 	119: uint8(239),
  41674 	120: uint8(241),
  41675 	121: uint8(243),
  41676 	122: uint8(245),
  41677 	123: uint8(247),
  41678 	124: uint8(249),
  41679 	125: uint8(251),
  41680 	126: uint8(253),
  41681 	127: uint8(127),
  41682 }
  41683 
  41684 func VP8PutBit(tls *libc.TLS, bw uintptr, bit int32, prob int32) (r int32) {
  41685 	var shift, split int32
  41686 	_, _ = shift, split
  41687 	split = (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 * prob >> int32(8)
  41688 	if bit != 0 {
  41689 		**(**int32_t)(__ccgo_up(bw + 4)) += split + int32(1)
  41690 		**(**int32_t)(__ccgo_up(bw)) -= split + int32(1)
  41691 	} else {
  41692 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = split
  41693 	}
  41694 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 < int32(127) { // emit 'shift' bits out and renormalize
  41695 		shift = libc.Int32FromUint8(kNorm[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41696 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromUint8(kNewRange[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41697 		**(**int32_t)(__ccgo_up(bw + 4)) <<= shift
  41698 		**(**int32)(__ccgo_up(bw + 12)) += shift
  41699 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits > 0 {
  41700 			Flush(tls, bw)
  41701 		}
  41702 	}
  41703 	return bit
  41704 }
  41705 
  41706 func VP8PutBitUniform(tls *libc.TLS, bw uintptr, bit int32) (r int32) {
  41707 	var split int32
  41708 	_ = split
  41709 	split = (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 >> int32(1)
  41710 	if bit != 0 {
  41711 		**(**int32_t)(__ccgo_up(bw + 4)) += split + int32(1)
  41712 		**(**int32_t)(__ccgo_up(bw)) -= split + int32(1)
  41713 	} else {
  41714 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = split
  41715 	}
  41716 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 < int32(127) {
  41717 		(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromUint8(kNewRange[(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1])
  41718 		**(**int32_t)(__ccgo_up(bw + 4)) <<= int32(1)
  41719 		**(**int32)(__ccgo_up(bw + 12)) += int32(1)
  41720 		if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits > 0 {
  41721 			Flush(tls, bw)
  41722 		}
  41723 	}
  41724 	return bit
  41725 }
  41726 
  41727 func VP8PutBits(tls *libc.TLS, bw uintptr, value uint32_t, nb_bits int32) {
  41728 	var mask uint32_t
  41729 	_ = mask
  41730 	mask = uint32(1) << (nb_bits - int32(1))
  41731 	for {
  41732 		if !(mask != 0) {
  41733 			break
  41734 		}
  41735 		VP8PutBitUniform(tls, bw, libc.Int32FromUint32(value&mask))
  41736 		goto _1
  41737 	_1:
  41738 		;
  41739 		mask = mask >> uint32(1)
  41740 	}
  41741 }
  41742 
  41743 func VP8PutSignedBits(tls *libc.TLS, bw uintptr, value int32, nb_bits int32) {
  41744 	if !(VP8PutBitUniform(tls, bw, libc.BoolInt32(value != 0)) != 0) {
  41745 		return
  41746 	}
  41747 	if value < 0 {
  41748 		VP8PutBits(tls, bw, libc.Uint32FromInt32(-value<<int32(1)|int32(1)), nb_bits+int32(1))
  41749 	} else {
  41750 		VP8PutBits(tls, bw, libc.Uint32FromInt32(value<<int32(1)), nb_bits+int32(1))
  41751 	}
  41752 }
  41753 
  41754 //------------------------------------------------------------------------------
  41755 
  41756 func VP8BitWriterInit(tls *libc.TLS, bw uintptr, expected_size size_t) (r int32) {
  41757 	var v1 int32
  41758 	_ = v1
  41759 	(*VP8BitWriter)(unsafe.Pointer(bw)).Frange1 = libc.Int32FromInt32(255) - libc.Int32FromInt32(1)
  41760 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fvalue = 0
  41761 	(*VP8BitWriter)(unsafe.Pointer(bw)).Frun = 0
  41762 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits = -int32(8)
  41763 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fpos = uint64(0)
  41764 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fmax_pos = uint64(0)
  41765 	(*VP8BitWriter)(unsafe.Pointer(bw)).Ferror1 = 0
  41766 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf = libc.UintptrFromInt32(0)
  41767 	if expected_size > uint64(0) {
  41768 		v1 = BitWriterResize(tls, bw, expected_size)
  41769 	} else {
  41770 		v1 = int32(1)
  41771 	}
  41772 	return v1
  41773 }
  41774 
  41775 func VP8BitWriterFinish(tls *libc.TLS, bw uintptr) (r uintptr) {
  41776 	VP8PutBits(tls, bw, uint32(0), int32(9)-(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits)
  41777 	(*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits = 0 // pad with zeroes
  41778 	Flush(tls, bw)
  41779 	return (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf
  41780 }
  41781 
  41782 func VP8BitWriterAppend(tls *libc.TLS, bw uintptr, data uintptr, size size_t) (r int32) {
  41783 	if (*VP8BitWriter)(unsafe.Pointer(bw)).Fnb_bits != -int32(8) {
  41784 		return 0
  41785 	} // Flush() must have been called
  41786 	if !(BitWriterResize(tls, bw, size) != 0) {
  41787 		return 0
  41788 	}
  41789 	libc.X__builtin___memcpy_chk(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf+uintptr((*VP8BitWriter)(unsafe.Pointer(bw)).Fpos), data, size, ^__predefined_size_t(0))
  41790 	**(**size_t)(__ccgo_up(bw + 24)) += size
  41791 	return int32(1)
  41792 }
  41793 
  41794 func VP8BitWriterWipeOut(tls *libc.TLS, bw uintptr) {
  41795 	if bw != libc.UintptrFromInt32(0) {
  41796 		WebPSafeFree(tls, (*VP8BitWriter)(unsafe.Pointer(bw)).Fbuf)
  41797 		libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41798 	}
  41799 }
  41800 
  41801 //------------------------------------------------------------------------------
  41802 // VP8LBitWriter
  41803 
  41804 // This is the minimum amount of size the memory buffer is guaranteed to grow
  41805 // when extra space is needed.
  41806 
  41807 // C documentation
  41808 //
  41809 //	// Returns 1 on success.
  41810 func VP8LBitWriterResize(tls *libc.TLS, bw uintptr, extra_size size_t) (r int32) {
  41811 	var allocated_buf uintptr
  41812 	var allocated_size, current_size, max_bytes, size_required size_t
  41813 	var size_required_64b uint64_t
  41814 	_, _, _, _, _, _ = allocated_buf, allocated_size, current_size, max_bytes, size_required, size_required_64b
  41815 	max_bytes = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend) - int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf))
  41816 	current_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf))
  41817 	size_required_64b = current_size + extra_size
  41818 	size_required = size_required_64b
  41819 	if size_required != size_required_64b {
  41820 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41821 		return 0
  41822 	}
  41823 	if max_bytes > uint64(0) && size_required <= max_bytes {
  41824 		return int32(1)
  41825 	}
  41826 	allocated_size = uint64(3) * max_bytes >> int32(1)
  41827 	if allocated_size < size_required {
  41828 		allocated_size = size_required
  41829 	}
  41830 	// make allocated size multiple of 1k
  41831 	allocated_size = (allocated_size>>libc.Int32FromInt32(10) + libc.Uint64FromInt32(1)) << libc.Int32FromInt32(10)
  41832 	allocated_buf = WebPSafeMalloc(tls, uint64(1), allocated_size)
  41833 	if allocated_buf == libc.UintptrFromInt32(0) {
  41834 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41835 		return 0
  41836 	}
  41837 	if current_size > uint64(0) {
  41838 		libc.X__builtin___memcpy_chk(tls, allocated_buf, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf, current_size, ^__predefined_size_t(0))
  41839 	}
  41840 	WebPSafeFree(tls, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)
  41841 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf = allocated_buf
  41842 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(current_size)
  41843 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fend = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf + uintptr(allocated_size)
  41844 	return int32(1)
  41845 }
  41846 
  41847 func VP8LBitWriterInit(tls *libc.TLS, bw uintptr, expected_size size_t) (r int32) {
  41848 	libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41849 	return VP8LBitWriterResize(tls, bw, expected_size)
  41850 }
  41851 
  41852 func VP8LBitWriterClone(tls *libc.TLS, src uintptr, dst uintptr) (r int32) {
  41853 	var current_size size_t
  41854 	_ = current_size
  41855 	current_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(src)).Fcur) - int64((*VP8LBitWriter)(unsafe.Pointer(src)).Fbuf))
  41856 	if !(VP8LBitWriterResize(tls, dst, current_size) != 0) {
  41857 		return 0
  41858 	}
  41859 	libc.X__builtin___memcpy_chk(tls, (*VP8LBitWriter)(unsafe.Pointer(dst)).Fbuf, (*VP8LBitWriter)(unsafe.Pointer(src)).Fbuf, current_size, ^__predefined_size_t(0))
  41860 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fbits = (*VP8LBitWriter)(unsafe.Pointer(src)).Fbits
  41861 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fused = (*VP8LBitWriter)(unsafe.Pointer(src)).Fused
  41862 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Ferror1 = (*VP8LBitWriter)(unsafe.Pointer(src)).Ferror1
  41863 	(*VP8LBitWriter)(unsafe.Pointer(dst)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(dst)).Fbuf + uintptr(current_size)
  41864 	return int32(1)
  41865 }
  41866 
  41867 func VP8LBitWriterWipeOut(tls *libc.TLS, bw uintptr) {
  41868 	if bw != libc.UintptrFromInt32(0) {
  41869 		WebPSafeFree(tls, (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)
  41870 		libc.X__builtin___memset_chk(tls, bw, 0, uint64(48), ^__predefined_size_t(0))
  41871 	}
  41872 }
  41873 
  41874 func VP8LBitWriterReset(tls *libc.TLS, bw_init uintptr, bw uintptr) {
  41875 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fbits
  41876 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Fused
  41877 	(*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))
  41878 	(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = (*VP8LBitWriter)(unsafe.Pointer(bw_init)).Ferror1
  41879 }
  41880 
  41881 func VP8LBitWriterSwap(tls *libc.TLS, src uintptr, dst uintptr) {
  41882 	var tmp VP8LBitWriter
  41883 	_ = tmp
  41884 	tmp = **(**VP8LBitWriter)(__ccgo_up(src))
  41885 	**(**VP8LBitWriter)(__ccgo_up(src)) = **(**VP8LBitWriter)(__ccgo_up(dst))
  41886 	**(**VP8LBitWriter)(__ccgo_up(dst)) = tmp
  41887 }
  41888 
  41889 func VP8LPutBitsFlushBits(tls *libc.TLS, bw uintptr) {
  41890 	var extra_size, v1 uint64_t
  41891 	var v2 int32
  41892 	_, _, _ = extra_size, v1, v2
  41893 	// If needed, make some room by flushing some bits out.
  41894 	if (*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur+uintptr(VP8L_WRITER_BYTES) > (*VP8LBitWriter)(unsafe.Pointer(bw)).Fend {
  41895 		extra_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend)-int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)) + uint64(32768)
  41896 		v1 = extra_size
  41897 		v2 = libc.BoolInt32(v1 == v1)
  41898 		goto _3
  41899 	_3:
  41900 		;
  41901 		if !(v2 != 0) || !(VP8LBitWriterResize(tls, bw, extra_size) != 0) {
  41902 			(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41903 			(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41904 			return
  41905 		}
  41906 	}
  41907 	**(**vp8l_wtype_t)(__ccgo_up((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur)) = uint32((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits)
  41908 	**(**uintptr)(__ccgo_up(bw + 24)) += uintptr(VP8L_WRITER_BYTES)
  41909 	**(**vp8l_atype_t)(__ccgo_up(bw)) >>= uint64(VP8L_WRITER_BITS)
  41910 	**(**int32)(__ccgo_up(bw + 8)) -= int32(VP8L_WRITER_BITS)
  41911 }
  41912 
  41913 func VP8LPutBitsInternal(tls *libc.TLS, bw uintptr, bits uint32_t, n_bits int32) {
  41914 	var extra_size, v1 uint64_t
  41915 	var lbits vp8l_atype_t
  41916 	var used, v2 int32
  41917 	_, _, _, _, _ = extra_size, lbits, used, v1, v2
  41918 	// That's the max we can handle:
  41919 	if n_bits > 0 {
  41920 		lbits = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits
  41921 		used = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fused
  41922 		// Special case of overflow handling for 32bit accumulator (2-steps flush).
  41923 		// If needed, make some room by flushing some bits out.
  41924 		for used >= int32(VP8L_WRITER_BITS) {
  41925 			if (*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur+uintptr(VP8L_WRITER_BYTES) > (*VP8LBitWriter)(unsafe.Pointer(bw)).Fend {
  41926 				extra_size = libc.Uint64FromInt64(int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fend)-int64((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf)) + uint64(32768)
  41927 				v1 = extra_size
  41928 				v2 = libc.BoolInt32(v1 == v1)
  41929 				goto _3
  41930 			_3:
  41931 				;
  41932 				if !(v2 != 0) || !(VP8LBitWriterResize(tls, bw, extra_size) != 0) {
  41933 					(*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur = (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41934 					(*VP8LBitWriter)(unsafe.Pointer(bw)).Ferror1 = int32(1)
  41935 					return
  41936 				}
  41937 			}
  41938 			**(**vp8l_wtype_t)(__ccgo_up((*VP8LBitWriter)(unsafe.Pointer(bw)).Fcur)) = uint32(lbits)
  41939 			**(**uintptr)(__ccgo_up(bw + 24)) += uintptr(VP8L_WRITER_BYTES)
  41940 			lbits = lbits >> uint64(VP8L_WRITER_BITS)
  41941 			used = used - int32(VP8L_WRITER_BITS)
  41942 		}
  41943 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits = lbits | uint64(bits)<<used
  41944 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = used + n_bits
  41945 	}
  41946 }
  41947 
  41948 func VP8LBitWriterFinish(tls *libc.TLS, bw uintptr) (r uintptr) {
  41949 	var v1, v2 uintptr
  41950 	_, _ = v1, v2
  41951 	// flush leftover bits
  41952 	if VP8LBitWriterResize(tls, bw, libc.Uint64FromInt32(((*VP8LBitWriter)(unsafe.Pointer(bw)).Fused+int32(7))>>int32(3))) != 0 {
  41953 		for (*VP8LBitWriter)(unsafe.Pointer(bw)).Fused > 0 {
  41954 			v2 = bw + 24
  41955 			v1 = *(*uintptr)(unsafe.Pointer(v2))
  41956 			*(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1
  41957 			**(**uint8_t)(__ccgo_up(v1)) = uint8((*VP8LBitWriter)(unsafe.Pointer(bw)).Fbits)
  41958 			**(**vp8l_atype_t)(__ccgo_up(bw)) >>= uint64(8)
  41959 			**(**int32)(__ccgo_up(bw + 8)) -= int32(8)
  41960 		}
  41961 		(*VP8LBitWriter)(unsafe.Pointer(bw)).Fused = 0
  41962 	}
  41963 	return (*VP8LBitWriter)(unsafe.Pointer(bw)).Fbuf
  41964 }
  41965 
  41966 var kHashMul12 = uint32(0x1e35a7bd)
  41967 
  41968 //------------------------------------------------------------------------------
  41969 
  41970 //------------------------------------------------------------------------------
  41971 // VP8LColorCache.
  41972 
  41973 func VP8LColorCacheInit(tls *libc.TLS, color_cache uintptr, hash_bits int32) (r int32) {
  41974 	var hash_size int32
  41975 	_ = hash_size
  41976 	hash_size = int32(1) << hash_bits
  41977 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors = WebPSafeCalloc(tls, libc.Uint64FromInt32(hash_size), uint64(4))
  41978 	if (*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors == libc.UintptrFromInt32(0) {
  41979 		return 0
  41980 	}
  41981 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fhash_shift = int32(32) - hash_bits
  41982 	(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fhash_bits = hash_bits
  41983 	return int32(1)
  41984 }
  41985 
  41986 func VP8LColorCacheClear(tls *libc.TLS, color_cache uintptr) {
  41987 	if color_cache != libc.UintptrFromInt32(0) {
  41988 		WebPSafeFree(tls, (*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors)
  41989 		(*VP8LColorCache)(unsafe.Pointer(color_cache)).Fcolors = libc.UintptrFromInt32(0)
  41990 	}
  41991 }
  41992 
  41993 func VP8LColorCacheCopy(tls *libc.TLS, src uintptr, dst uintptr) {
  41994 	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))
  41995 }
  41996 
  41997 // -----------------------------------------------------------------------------
  41998 // Quick estimate of a potentially interesting filter mode to try.
  41999 
  42000 func GradientPredictor(tls *libc.TLS, a uint8_t, b uint8_t, c uint8_t) (r int32) {
  42001 	var g, v1, v2 int32
  42002 	_, _, _ = g, v1, v2
  42003 	g = libc.Int32FromUint8(a) + libc.Int32FromUint8(b) - libc.Int32FromUint8(c)
  42004 	if g & ^libc.Int32FromInt32(0xff) == 0 {
  42005 		v1 = g
  42006 	} else {
  42007 		if g < 0 {
  42008 			v2 = 0
  42009 		} else {
  42010 			v2 = int32(255)
  42011 		}
  42012 		v1 = v2
  42013 	}
  42014 	return v1 // clip to 8bit
  42015 }
  42016 
  42017 func WebPEstimateBestFilter(tls *libc.TLS, data uintptr, width int32, height int32, stride int32) (r WEBP_FILTER_TYPE) {
  42018 	bp := tls.Alloc(256)
  42019 	defer tls.Free(256)
  42020 	var best_filter WEBP_FILTER_TYPE
  42021 	var best_score, diff0, diff1, diff2, diff3, filter, grad_pred, i, j, mean, score int32
  42022 	var p uintptr
  42023 	var _ /* bins at bp+0 */ [4][16]int32
  42024 	_, _, _, _, _, _, _, _, _, _, _, _, _ = best_filter, best_score, diff0, diff1, diff2, diff3, filter, grad_pred, i, j, mean, p, score
  42025 	libc.X__builtin___memset_chk(tls, bp, 0, uint64(256), ^__predefined_size_t(0))
  42026 	// We only sample every other pixels. That's enough.
  42027 	j = int32(2)
  42028 	for {
  42029 		if !(j < height-int32(1)) {
  42030 			break
  42031 		}
  42032 		p = data + uintptr(j*stride)
  42033 		mean = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  42034 		i = int32(2)
  42035 		for {
  42036 			if !(i < width-int32(1)) {
  42037 				break
  42038 			}
  42039 			diff0 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-mean) >> libc.Int32FromInt32(4)
  42040 			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)
  42041 			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)
  42042 			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)))))
  42043 			diff3 = libc.Xabs(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i))))-grad_pred) >> libc.Int32FromInt32(4)
  42044 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_NONE)*64 + uintptr(diff0)*4)) = int32(1)
  42045 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_HORIZONTAL)*64 + uintptr(diff1)*4)) = int32(1)
  42046 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_VERTICAL)*64 + uintptr(diff2)*4)) = int32(1)
  42047 			**(**int32)(__ccgo_up(bp + uintptr(WEBP_FILTER_GRADIENT)*64 + uintptr(diff3)*4)) = int32(1)
  42048 			mean = (int32(3)*mean + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(i)))) + int32(2)) >> int32(2)
  42049 			goto _2
  42050 		_2:
  42051 			;
  42052 			i = i + int32(2)
  42053 		}
  42054 		goto _1
  42055 	_1:
  42056 		;
  42057 		j = j + int32(2)
  42058 	}
  42059 	best_filter = int32(WEBP_FILTER_NONE)
  42060 	best_score = int32(0x7fffffff)
  42061 	filter = int32(WEBP_FILTER_NONE)
  42062 	for {
  42063 		if !(filter < int32(WEBP_FILTER_LAST)) {
  42064 			break
  42065 		}
  42066 		score = 0
  42067 		i = 0
  42068 		for {
  42069 			if !(i < int32(16)) {
  42070 				break
  42071 			}
  42072 			if **(**int32)(__ccgo_up(bp + uintptr(filter)*64 + uintptr(i)*4)) > 0 {
  42073 				score = score + i
  42074 			}
  42075 			goto _4
  42076 		_4:
  42077 			;
  42078 			i = i + 1
  42079 		}
  42080 		if score < best_score {
  42081 			best_score = score
  42082 			best_filter = filter
  42083 		}
  42084 		goto _3
  42085 	_3:
  42086 		;
  42087 		filter = filter + 1
  42088 	}
  42089 	return best_filter
  42090 	return r
  42091 }
  42092 
  42093 // Alpha related constants.
  42094 
  42095 // Mux related constants.
  42096 
  42097 // Maximum chunk payload is such that adding the header and padding won't
  42098 // overflow a uint32_t.
  42099 
  42100 // -----------------------------------------------------------------------------
  42101 // Util function to optimize the symbol map for RLE coding
  42102 
  42103 // C documentation
  42104 //
  42105 //	// Heuristics for selecting the stride ranges to collapse.
  42106 func ValuesShouldBeCollapsedToStrideAverage(tls *libc.TLS, a int32, b int32) (r int32) {
  42107 	return libc.BoolInt32(libc.Xabs(tls, a-b) < int32(4))
  42108 }
  42109 
  42110 // C documentation
  42111 //
  42112 //	// Change the population counts in a way that the consequent
  42113 //	// Huffman tree compression, especially its RLE-part, give smaller output.
  42114 func OptimizeHuffmanForRle(tls *libc.TLS, length int32, good_for_rle uintptr, counts uintptr) {
  42115 	var count, k1, limit, stride1, sum, symbol uint32_t
  42116 	var i, k, stride int32
  42117 	_, _, _, _, _, _, _, _, _ = count, i, k, k1, limit, stride, stride1, sum, symbol
  42118 	for {
  42119 		if !(length >= 0) {
  42120 			break
  42121 		}
  42122 		if length == 0 {
  42123 			return // All zeros.
  42124 		}
  42125 		if **(**uint32_t)(__ccgo_up(counts + uintptr(length-int32(1))*4)) != uint32(0) {
  42126 			// Now counts[0..length - 1] does not have trailing zeros.
  42127 			break
  42128 		}
  42129 		goto _1
  42130 	_1:
  42131 		;
  42132 		length = length - 1
  42133 	}
  42134 	// 2) Let's mark all population counts that already can be encoded
  42135 	// with an rle code.
  42136 	// Let's not spoil any of the existing good rle codes.
  42137 	// Mark any seq of 0's that is longer as 5 as a good_for_rle.
  42138 	// Mark any seq of non-0's that is longer as 7 as a good_for_rle.
  42139 	symbol = **(**uint32_t)(__ccgo_up(counts))
  42140 	stride = 0
  42141 	i = 0
  42142 	for {
  42143 		if !(i < length+int32(1)) {
  42144 			break
  42145 		}
  42146 		if i == length || **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4)) != symbol {
  42147 			if symbol == uint32(0) && stride >= int32(5) || symbol != uint32(0) && stride >= int32(7) {
  42148 				k = 0
  42149 				for {
  42150 					if !(k < stride) {
  42151 						break
  42152 					}
  42153 					**(**uint8_t)(__ccgo_up(good_for_rle + uintptr(i-k-int32(1)))) = uint8(1)
  42154 					goto _3
  42155 				_3:
  42156 					;
  42157 					k = k + 1
  42158 				}
  42159 			}
  42160 			stride = int32(1)
  42161 			if i != length {
  42162 				symbol = **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42163 			}
  42164 		} else {
  42165 			stride = stride + 1
  42166 		}
  42167 		goto _2
  42168 	_2:
  42169 		;
  42170 		i = i + 1
  42171 	}
  42172 	// 3) Let's replace those population counts that lead to more rle codes.
  42173 	stride1 = uint32(0)
  42174 	limit = **(**uint32_t)(__ccgo_up(counts))
  42175 	sum = uint32(0)
  42176 	i = 0
  42177 	for {
  42178 		if !(i < length+int32(1)) {
  42179 			break
  42180 		}
  42181 		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) {
  42182 			if stride1 >= uint32(4) || stride1 >= uint32(3) && sum == uint32(0) {
  42183 				// The stride must end, collapse what we have, if we have enough (4).
  42184 				count = (sum + stride1/uint32(2)) / stride1
  42185 				if count < uint32(1) {
  42186 					count = uint32(1)
  42187 				}
  42188 				if sum == uint32(0) {
  42189 					// Don't make an all zeros stride to be upgraded to ones.
  42190 					count = uint32(0)
  42191 				}
  42192 				k1 = uint32(0)
  42193 				for {
  42194 					if !(k1 < stride1) {
  42195 						break
  42196 					}
  42197 					// We don't want to change value at counts[i],
  42198 					// that is already belonging to the next stride. Thus - 1.
  42199 					**(**uint32_t)(__ccgo_up(counts + uintptr(libc.Uint32FromInt32(i)-k1-uint32(1))*4)) = count
  42200 					goto _5
  42201 				_5:
  42202 					;
  42203 					k1 = k1 + 1
  42204 				}
  42205 			}
  42206 			stride1 = uint32(0)
  42207 			sum = uint32(0)
  42208 			if i < length-int32(3) {
  42209 				// All interesting strides have a count of at least 4,
  42210 				// at least when non-zeros.
  42211 				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)
  42212 			} else {
  42213 				if i < length {
  42214 					limit = **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42215 				} else {
  42216 					limit = uint32(0)
  42217 				}
  42218 			}
  42219 		}
  42220 		stride1 = stride1 + 1
  42221 		if i != length {
  42222 			sum = sum + **(**uint32_t)(__ccgo_up(counts + uintptr(i)*4))
  42223 			if stride1 >= uint32(4) {
  42224 				limit = (sum + stride1/uint32(2)) / stride1
  42225 			}
  42226 		}
  42227 		goto _4
  42228 	_4:
  42229 		;
  42230 		i = i + 1
  42231 	}
  42232 }
  42233 
  42234 // C documentation
  42235 //
  42236 //	// A comparer function for two Huffman trees: sorts first by 'total count'
  42237 //	// (more comes first), and then by 'value' (more comes first).
  42238 func CompareHuffmanTrees(tls *libc.TLS, ptr1 uintptr, ptr2 uintptr) (r int32) {
  42239 	var t1, t2 uintptr
  42240 	var v1 int32
  42241 	_, _, _ = t1, t2, v1
  42242 	t1 = ptr1
  42243 	t2 = ptr2
  42244 	if (*HuffmanTree)(unsafe.Pointer(t1)).Ftotal_count > (*HuffmanTree)(unsafe.Pointer(t2)).Ftotal_count {
  42245 		return -int32(1)
  42246 	} else {
  42247 		if (*HuffmanTree)(unsafe.Pointer(t1)).Ftotal_count < (*HuffmanTree)(unsafe.Pointer(t2)).Ftotal_count {
  42248 			return int32(1)
  42249 		} else {
  42250 			if (*HuffmanTree)(unsafe.Pointer(t1)).Fvalue < (*HuffmanTree)(unsafe.Pointer(t2)).Fvalue {
  42251 				v1 = -int32(1)
  42252 			} else {
  42253 				v1 = int32(1)
  42254 			}
  42255 			return v1
  42256 		}
  42257 	}
  42258 	return r
  42259 }
  42260 
  42261 func SetBitDepths(tls *libc.TLS, tree uintptr, pool uintptr, bit_depths uintptr, level int32) {
  42262 	if (*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_left >= 0 {
  42263 		SetBitDepths(tls, pool+uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_left)*16, pool, bit_depths, level+int32(1))
  42264 		SetBitDepths(tls, pool+uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fpool_index_right)*16, pool, bit_depths, level+int32(1))
  42265 	} else {
  42266 		**(**uint8_t)(__ccgo_up(bit_depths + uintptr((*HuffmanTree)(unsafe.Pointer(tree)).Fvalue))) = libc.Uint8FromInt32(level)
  42267 	}
  42268 }
  42269 
  42270 // C documentation
  42271 //
  42272 //	// Create an optimal Huffman tree.
  42273 //	//
  42274 //	// (data,length): population counts.
  42275 //	// tree_limit: maximum bit depth (inclusive) of the codes.
  42276 //	// bit_depths[]: how many bits are used for the symbol.
  42277 //	//
  42278 //	// Returns 0 when an error has occurred.
  42279 //	//
  42280 //	// The catch here is that the tree cannot be arbitrarily deep
  42281 //	//
  42282 //	// count_limit is the value that is to be faked as the minimum value
  42283 //	// and this minimum value is raised until the tree matches the
  42284 //	// maximum length requirement.
  42285 //	//
  42286 //	// This algorithm is not of excellent performance for very long data blocks,
  42287 //	// especially when population counts are longer than 2**tree_limit, but
  42288 //	// we are not planning to use this with extremely long blocks.
  42289 //	//
  42290 //	// See https://en.wikipedia.org/wiki/Huffman_coding
  42291 func GenerateOptimalTree(tls *libc.TLS, histogram uintptr, histogram_size int32, tree uintptr, tree_depth_limit int32, bit_depths uintptr) {
  42292 	var count, count1, count_min uint32_t
  42293 	var i, idx, j, k, max_depth, tree_pool_size, tree_size, tree_size_orig, v5 int32
  42294 	var tree_pool uintptr
  42295 	var v4 uint32
  42296 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, count1, count_min, i, idx, j, k, max_depth, tree_pool, tree_pool_size, tree_size, tree_size_orig, v4, v5
  42297 	tree_size_orig = 0
  42298 	i = 0
  42299 	for {
  42300 		if !(i < histogram_size) {
  42301 			break
  42302 		}
  42303 		if **(**uint32_t)(__ccgo_up(histogram + uintptr(i)*4)) != uint32(0) {
  42304 			tree_size_orig = tree_size_orig + 1
  42305 		}
  42306 		goto _1
  42307 	_1:
  42308 		;
  42309 		i = i + 1
  42310 	}
  42311 	if tree_size_orig == 0 { // pretty optimal already!
  42312 		return
  42313 	}
  42314 	tree_pool = tree + uintptr(tree_size_orig)*16
  42315 	// For block sizes with less than 64k symbols we never need to do a
  42316 	// second iteration of this loop.
  42317 	// If we actually start running inside this loop a lot, we would perhaps
  42318 	// be better off with the Katajainen algorithm.
  42319 	count_min = uint32(1)
  42320 	for {
  42321 		tree_size = tree_size_orig
  42322 		// We need to pack the Huffman tree in tree_depth_limit bits.
  42323 		// So, we try by faking histogram entries to be at least 'count_min'.
  42324 		idx = 0
  42325 		j = 0
  42326 		for {
  42327 			if !(j < histogram_size) {
  42328 				break
  42329 			}
  42330 			if **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4)) != uint32(0) {
  42331 				if **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4)) < count_min {
  42332 					v4 = count_min
  42333 				} else {
  42334 					v4 = **(**uint32_t)(__ccgo_up(histogram + uintptr(j)*4))
  42335 				}
  42336 				count = v4
  42337 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Ftotal_count = count
  42338 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fvalue = j
  42339 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fpool_index_left = -int32(1)
  42340 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(idx)*16))).Fpool_index_right = -int32(1)
  42341 				idx = idx + 1
  42342 			}
  42343 			goto _3
  42344 		_3:
  42345 			;
  42346 			j = j + 1
  42347 		}
  42348 		// Build the Huffman tree.
  42349 		libc.Xqsort(tls, tree, libc.Uint64FromInt32(tree_size), uint64(16), __ccgo_fp(CompareHuffmanTrees))
  42350 		if tree_size > int32(1) { // Normal case.
  42351 			tree_pool_size = 0
  42352 			for tree_size > int32(1) {
  42353 				v5 = tree_pool_size
  42354 				tree_pool_size = tree_pool_size + 1
  42355 				**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(v5)*16)) = **(**HuffmanTree)(__ccgo_up(tree + uintptr(tree_size-int32(1))*16))
  42356 				v5 = tree_pool_size
  42357 				tree_pool_size = tree_pool_size + 1
  42358 				**(**HuffmanTree)(__ccgo_up(tree_pool + uintptr(v5)*16)) = **(**HuffmanTree)(__ccgo_up(tree + uintptr(tree_size-int32(2))*16))
  42359 				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
  42360 				tree_size = tree_size - int32(2)
  42361 				k = 0
  42362 				for {
  42363 					if !(k < tree_size) {
  42364 						break
  42365 					}
  42366 					if (**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Ftotal_count <= count1 {
  42367 						break
  42368 					}
  42369 					goto _7
  42370 				_7:
  42371 					;
  42372 					k = k + 1
  42373 				}
  42374 				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))
  42375 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Ftotal_count = count1
  42376 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fvalue = -int32(1)
  42377 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fpool_index_left = tree_pool_size - int32(1)
  42378 				(**(**HuffmanTree)(__ccgo_up(tree + uintptr(k)*16))).Fpool_index_right = tree_pool_size - int32(2)
  42379 				tree_size = tree_size + int32(1)
  42380 			}
  42381 			SetBitDepths(tls, tree, tree_pool, bit_depths, 0)
  42382 		} else {
  42383 			if tree_size == int32(1) { // Trivial case: only one element.
  42384 				**(**uint8_t)(__ccgo_up(bit_depths + uintptr((**(**HuffmanTree)(__ccgo_up(tree))).Fvalue))) = uint8(1)
  42385 			}
  42386 		}
  42387 		// Test if this Huffman tree satisfies our 'tree_depth_limit' criteria.
  42388 		max_depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths)))
  42389 		j = int32(1)
  42390 		for {
  42391 			if !(j < histogram_size) {
  42392 				break
  42393 			}
  42394 			if max_depth < libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths + uintptr(j)))) {
  42395 				max_depth = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bit_depths + uintptr(j))))
  42396 			}
  42397 			goto _8
  42398 		_8:
  42399 			;
  42400 			j = j + 1
  42401 		}
  42402 		if max_depth <= tree_depth_limit {
  42403 			break
  42404 		}
  42405 		goto _2
  42406 	_2:
  42407 		;
  42408 		count_min = count_min * uint32(2)
  42409 	}
  42410 }
  42411 
  42412 // -----------------------------------------------------------------------------
  42413 // Coding of the Huffman tree values
  42414 
  42415 func CodeRepeatedValues(tls *libc.TLS, repetitions int32, tokens uintptr, value int32, prev_value int32) (r uintptr) {
  42416 	var i int32
  42417 	_ = i
  42418 	if value != prev_value {
  42419 		(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = libc.Uint8FromInt32(value)
  42420 		(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42421 		tokens += 2
  42422 		repetitions = repetitions - 1
  42423 	}
  42424 	for repetitions >= int32(1) {
  42425 		if repetitions < int32(3) {
  42426 			i = 0
  42427 			for {
  42428 				if !(i < repetitions) {
  42429 					break
  42430 				}
  42431 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = libc.Uint8FromInt32(value)
  42432 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42433 				tokens += 2
  42434 				goto _1
  42435 			_1:
  42436 				;
  42437 				i = i + 1
  42438 			}
  42439 			break
  42440 		} else {
  42441 			if repetitions < int32(7) {
  42442 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(16)
  42443 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(3))
  42444 				tokens += 2
  42445 				break
  42446 			} else {
  42447 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(16)
  42448 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(3)
  42449 				tokens += 2
  42450 				repetitions = repetitions - int32(6)
  42451 			}
  42452 		}
  42453 	}
  42454 	return tokens
  42455 }
  42456 
  42457 func CodeRepeatedZeros(tls *libc.TLS, repetitions int32, tokens uintptr) (r uintptr) {
  42458 	var i int32
  42459 	_ = i
  42460 	for repetitions >= int32(1) {
  42461 		if repetitions < int32(3) {
  42462 			i = 0
  42463 			for {
  42464 				if !(i < repetitions) {
  42465 					break
  42466 				}
  42467 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(0) // 0-value
  42468 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0)
  42469 				tokens += 2
  42470 				goto _1
  42471 			_1:
  42472 				;
  42473 				i = i + 1
  42474 			}
  42475 			break
  42476 		} else {
  42477 			if repetitions < int32(11) {
  42478 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(17)
  42479 				(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(3))
  42480 				tokens += 2
  42481 				break
  42482 			} else {
  42483 				if repetitions < int32(139) {
  42484 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(18)
  42485 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = libc.Uint8FromInt32(repetitions - int32(11))
  42486 					tokens += 2
  42487 					break
  42488 				} else {
  42489 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fcode = uint8(18)
  42490 					(*HuffmanTreeToken)(unsafe.Pointer(tokens)).Fextra_bits = uint8(0x7f) // 138 repeated 0s
  42491 					tokens += 2
  42492 					repetitions = repetitions - int32(138)
  42493 				}
  42494 			}
  42495 		}
  42496 	}
  42497 	return tokens
  42498 }
  42499 
  42500 func VP8LCreateCompressedHuffmanTree(tls *libc.TLS, tree uintptr, tokens uintptr, max_tokens int32) (r int32) {
  42501 	var depth_size, i, k, prev_value, runs, value int32
  42502 	var ending_token, starting_token uintptr
  42503 	_, _, _, _, _, _, _, _ = depth_size, ending_token, i, k, prev_value, runs, starting_token, value
  42504 	starting_token = tokens
  42505 	ending_token = tokens + uintptr(max_tokens)*2
  42506 	depth_size = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  42507 	prev_value = int32(8) // 8 is the initial value for rle.
  42508 	i = 0
  42509 	for i < depth_size {
  42510 		value = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42511 		k = i + int32(1)
  42512 		for k < depth_size && libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(k)))) == value {
  42513 			k = k + 1
  42514 		}
  42515 		runs = k - i
  42516 		if value == 0 {
  42517 			tokens = CodeRepeatedZeros(tls, runs, tokens)
  42518 		} else {
  42519 			tokens = CodeRepeatedValues(tls, runs, tokens, value, prev_value)
  42520 			prev_value = value
  42521 		}
  42522 		i = i + runs
  42523 	}
  42524 	_ = ending_token // suppress 'unused variable' warning
  42525 	return int32((int64(tokens) - int64(starting_token)) / 2)
  42526 }
  42527 
  42528 // -----------------------------------------------------------------------------
  42529 
  42530 // C documentation
  42531 //
  42532 //	// Pre-reversed 4-bit values.
  42533 var kReversedBits = [16]uint8_t{
  42534 	1:  uint8(0x8),
  42535 	2:  uint8(0x4),
  42536 	3:  uint8(0xc),
  42537 	4:  uint8(0x2),
  42538 	5:  uint8(0xa),
  42539 	6:  uint8(0x6),
  42540 	7:  uint8(0xe),
  42541 	8:  uint8(0x1),
  42542 	9:  uint8(0x9),
  42543 	10: uint8(0x5),
  42544 	11: uint8(0xd),
  42545 	12: uint8(0x3),
  42546 	13: uint8(0xb),
  42547 	14: uint8(0x7),
  42548 	15: uint8(0xf),
  42549 }
  42550 
  42551 func ReverseBits(tls *libc.TLS, num_bits int32, bits uint32_t) (r uint32_t) {
  42552 	var i int32
  42553 	var retval uint32_t
  42554 	_, _ = i, retval
  42555 	retval = uint32(0)
  42556 	i = 0
  42557 	for i < num_bits {
  42558 		i = i + int32(4)
  42559 		retval = retval | libc.Uint32FromInt32(libc.Int32FromUint8(kReversedBits[bits&uint32(0xf)])<<(libc.Int32FromInt32(MAX_ALLOWED_CODE_LENGTH)+libc.Int32FromInt32(1)-i))
  42560 		bits = bits >> uint32(4)
  42561 	}
  42562 	retval = retval >> libc.Uint32FromInt32(libc.Int32FromInt32(MAX_ALLOWED_CODE_LENGTH)+libc.Int32FromInt32(1)-num_bits)
  42563 	return retval
  42564 }
  42565 
  42566 // C documentation
  42567 //
  42568 //	// Get the actual bit values for a tree of bit depths.
  42569 func ConvertBitDepthsToSymbols(tls *libc.TLS, tree uintptr) {
  42570 	bp := tls.Alloc(64)
  42571 	defer tls.Free(64)
  42572 	var code, v4 uint32_t
  42573 	var code_length, code_length1, i, len1 int32
  42574 	var depth_count [16]int32
  42575 	var v5 uintptr
  42576 	var _ /* next_code at bp+0 */ [16]uint32_t
  42577 	_, _, _, _, _, _, _, _ = code, code_length, code_length1, depth_count, i, len1, v4, v5
  42578 	depth_count = [16]int32{}
  42579 	len1 = (*HuffmanTreeCode)(unsafe.Pointer(tree)).Fnum_symbols
  42580 	i = 0
  42581 	for {
  42582 		if !(i < len1) {
  42583 			break
  42584 		}
  42585 		code_length = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42586 		depth_count[code_length] = depth_count[code_length] + 1
  42587 		goto _1
  42588 	_1:
  42589 		;
  42590 		i = i + 1
  42591 	}
  42592 	depth_count[0] = 0 // ignore unused symbol
  42593 	(**(**[16]uint32_t)(__ccgo_up(bp)))[0] = uint32(0)
  42594 	code = uint32(0)
  42595 	i = int32(1)
  42596 	for {
  42597 		if !(i <= int32(MAX_ALLOWED_CODE_LENGTH)) {
  42598 			break
  42599 		}
  42600 		code = (code + libc.Uint32FromInt32(depth_count[i-int32(1)])) << int32(1)
  42601 		(**(**[16]uint32_t)(__ccgo_up(bp)))[i] = code
  42602 		goto _2
  42603 	_2:
  42604 		;
  42605 		i = i + 1
  42606 	}
  42607 	i = 0
  42608 	for {
  42609 		if !(i < len1) {
  42610 			break
  42611 		}
  42612 		code_length1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcode_lengths + uintptr(i))))
  42613 		v5 = bp + uintptr(code_length1)*4
  42614 		v4 = *(*uint32_t)(unsafe.Pointer(v5))
  42615 		*(*uint32_t)(unsafe.Pointer(v5)) = *(*uint32_t)(unsafe.Pointer(v5)) + 1
  42616 		**(**uint16_t)(__ccgo_up((*HuffmanTreeCode)(unsafe.Pointer(tree)).Fcodes + uintptr(i)*2)) = uint16(ReverseBits(tls, code_length1, v4))
  42617 		goto _3
  42618 	_3:
  42619 		;
  42620 		i = i + 1
  42621 	}
  42622 }
  42623 
  42624 // -----------------------------------------------------------------------------
  42625 // Main entry point
  42626 
  42627 func VP8LCreateHuffmanTree(tls *libc.TLS, histogram uintptr, tree_depth_limit int32, buf_rle uintptr, huff_tree uintptr, huff_code uintptr) {
  42628 	var num_symbols int32
  42629 	_ = num_symbols
  42630 	num_symbols = (*HuffmanTreeCode)(unsafe.Pointer(huff_code)).Fnum_symbols
  42631 	libc.X__builtin___memset_chk(tls, buf_rle, 0, libc.Uint64FromInt32(num_symbols)*uint64(1), ^__predefined_size_t(0))
  42632 	OptimizeHuffmanForRle(tls, num_symbols, buf_rle, histogram)
  42633 	GenerateOptimalTree(tls, histogram, num_symbols, huff_tree, tree_depth_limit, (*HuffmanTreeCode)(unsafe.Pointer(huff_code)).Fcode_lengths)
  42634 	// Create the actual bit codes for the bit lengths.
  42635 	ConvertBitDepthsToSymbols(tls, huff_code)
  42636 }
  42637 
  42638 const MAX_HTREE_GROUPS = 0x10000
  42639 const SORTED_SIZE_CUTOFF = 512
  42640 
  42641 //------------------------------------------------------------------------------
  42642 
  42643 // Copyright 2012 Google Inc. All Rights Reserved.
  42644 //
  42645 // Use of this source code is governed by a BSD-style license
  42646 // that can be found in the COPYING file in the root of the source
  42647 // tree. An additional intellectual property rights grant can be found
  42648 // in the file PATENTS. All contributing project authors may
  42649 // be found in the AUTHORS file in the root of the source tree.
  42650 // -----------------------------------------------------------------------------
  42651 //
  42652 //  Internal header for constants related to WebP file format.
  42653 //
  42654 // Author: Urvang (urvang@google.com)
  42655 
  42656 // Copyright 2010 Google Inc. All Rights Reserved.
  42657 //
  42658 // Use of this source code is governed by a BSD-style license
  42659 // that can be found in the COPYING file in the root of the source
  42660 // tree. An additional intellectual property rights grant can be found
  42661 // in the file PATENTS. All contributing project authors may
  42662 // be found in the AUTHORS file in the root of the source tree.
  42663 // -----------------------------------------------------------------------------
  42664 //
  42665 //  Common types + memory wrappers
  42666 //
  42667 // Author: Skal (pascal.massimino@gmail.com)
  42668 
  42669 // Huffman data read via DecodeImageStream is represented in two (red and green)
  42670 // bytes.
  42671 
  42672 func VP8LHtreeGroupsNew(tls *libc.TLS, num_htree_groups int32) (r uintptr) {
  42673 	var htree_groups uintptr
  42674 	_ = htree_groups
  42675 	htree_groups = WebPSafeMalloc(tls, libc.Uint64FromInt32(num_htree_groups), uint64(568))
  42676 	if htree_groups == libc.UintptrFromInt32(0) {
  42677 		return libc.UintptrFromInt32(0)
  42678 	}
  42679 	return htree_groups
  42680 }
  42681 
  42682 func VP8LHtreeGroupsFree(tls *libc.TLS, htree_groups uintptr) {
  42683 	if htree_groups != libc.UintptrFromInt32(0) {
  42684 		WebPSafeFree(tls, htree_groups)
  42685 	}
  42686 }
  42687 
  42688 // C documentation
  42689 //
  42690 //	// Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the
  42691 //	// bit-wise reversal of the len least significant bits of key.
  42692 func GetNextKey(tls *libc.TLS, key uint32_t, len1 int32) (r uint32_t) {
  42693 	var step uint32_t
  42694 	var v1 uint32
  42695 	_, _ = step, v1
  42696 	step = libc.Uint32FromInt32(int32(1) << (len1 - int32(1)))
  42697 	for key&step != 0 {
  42698 		step = step >> uint32(1)
  42699 	}
  42700 	if step != 0 {
  42701 		v1 = key&(step-uint32(1)) + step
  42702 	} else {
  42703 		v1 = key
  42704 	}
  42705 	return v1
  42706 }
  42707 
  42708 // C documentation
  42709 //
  42710 //	// Stores code in table[0], table[step], table[2*step], ..., table[end].
  42711 //	// Assumes that end is an integer multiple of step.
  42712 func ReplicateValue(tls *libc.TLS, table uintptr, step int32, end int32, code HuffmanCode) {
  42713 	for cond := true; cond; cond = end > 0 {
  42714 		end = end - step
  42715 		**(**HuffmanCode)(__ccgo_up(table + uintptr(end)*4)) = code
  42716 	}
  42717 }
  42718 
  42719 // C documentation
  42720 //
  42721 //	// Returns the table width of the next 2nd level table. count is the histogram
  42722 //	// of bit lengths for the remaining symbols, len is the code length of the next
  42723 //	// processed symbol
  42724 func NextTableBitSize(tls *libc.TLS, count uintptr, len1 int32, root_bits int32) (r int32) {
  42725 	var left int32
  42726 	_ = left
  42727 	left = int32(1) << (len1 - root_bits)
  42728 	for len1 < int32(MAX_ALLOWED_CODE_LENGTH) {
  42729 		left = left - **(**int32)(__ccgo_up(count + uintptr(len1)*4))
  42730 		if left <= 0 {
  42731 			break
  42732 		}
  42733 		len1 = len1 + 1
  42734 		left = left << int32(1)
  42735 	}
  42736 	return len1 - root_bits
  42737 }
  42738 
  42739 // C documentation
  42740 //
  42741 //	// sorted[code_lengths_size] is a pre-allocated array for sorting symbols
  42742 //	// by code length.
  42743 func BuildHuffmanTable(tls *libc.TLS, root_table uintptr, root_bits int32, code_lengths uintptr, code_lengths_size int32, sorted uintptr) (r int32) {
  42744 	bp := tls.Alloc(128)
  42745 	defer tls.Free(128)
  42746 	var code, code1, code2 HuffmanCode
  42747 	var key, low, mask uint32_t
  42748 	var len1, num_nodes, num_open, step, symbol, symbol_code_length, table_bits, table_size, total_size, v4 int32
  42749 	var table, v5 uintptr
  42750 	var _ /* count at bp+0 */ [16]int32
  42751 	var _ /* offset at bp+64 */ [16]int32
  42752 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  42753 	table = root_table                 // next available space in table
  42754 	total_size = int32(1) << root_bits // symbol index in original or sorted table
  42755 	// number of codes of each length:
  42756 	**(**[16]int32)(__ccgo_up(bp)) = [16]int32{}
  42757 	// Build histogram of code lengths.
  42758 	symbol = 0
  42759 	for {
  42760 		if !(symbol < code_lengths_size) {
  42761 			break
  42762 		}
  42763 		if **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) > int32(MAX_ALLOWED_CODE_LENGTH) {
  42764 			return 0
  42765 		}
  42766 		(**(**[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
  42767 		goto _1
  42768 	_1:
  42769 		;
  42770 		symbol = symbol + 1
  42771 	}
  42772 	// Error, all code lengths are zeros.
  42773 	if (**(**[16]int32)(__ccgo_up(bp)))[0] == code_lengths_size {
  42774 		return 0
  42775 	}
  42776 	// Generate offsets into sorted symbol table by code length.
  42777 	(**(**[16]int32)(__ccgo_up(bp + 64)))[int32(1)] = 0
  42778 	len1 = int32(1)
  42779 	for {
  42780 		if !(len1 < int32(MAX_ALLOWED_CODE_LENGTH)) {
  42781 			break
  42782 		}
  42783 		if (**(**[16]int32)(__ccgo_up(bp)))[len1] > int32(1)<<len1 {
  42784 			return 0
  42785 		}
  42786 		(**(**[16]int32)(__ccgo_up(bp + 64)))[len1+int32(1)] = (**(**[16]int32)(__ccgo_up(bp + 64)))[len1] + (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42787 		goto _2
  42788 	_2:
  42789 		;
  42790 		len1 = len1 + 1
  42791 	}
  42792 	// Sort symbols by length, by symbol order within each length.
  42793 	symbol = 0
  42794 	for {
  42795 		if !(symbol < code_lengths_size) {
  42796 			break
  42797 		}
  42798 		symbol_code_length = **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4))
  42799 		if **(**int32)(__ccgo_up(code_lengths + uintptr(symbol)*4)) > 0 {
  42800 			if sorted != libc.UintptrFromInt32(0) {
  42801 				if (**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] >= code_lengths_size {
  42802 					return 0
  42803 				}
  42804 				v5 = bp + 64 + uintptr(symbol_code_length)*4
  42805 				v4 = *(*int32)(unsafe.Pointer(v5))
  42806 				*(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1
  42807 				**(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2)) = libc.Uint16FromInt32(symbol)
  42808 			} else {
  42809 				(**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] = (**(**[16]int32)(__ccgo_up(bp + 64)))[symbol_code_length] + 1
  42810 			}
  42811 		}
  42812 		goto _3
  42813 	_3:
  42814 		;
  42815 		symbol = symbol + 1
  42816 	}
  42817 	// Special case code with only one value.
  42818 	if (**(**[16]int32)(__ccgo_up(bp + 64)))[int32(MAX_ALLOWED_CODE_LENGTH)] == int32(1) {
  42819 		if sorted != libc.UintptrFromInt32(0) {
  42820 			code.Fbits = uint8(0)
  42821 			code.Fvalue = **(**uint16_t)(__ccgo_up(sorted))
  42822 			ReplicateValue(tls, table, int32(1), total_size, code)
  42823 		}
  42824 		return total_size
  42825 	}
  42826 	// step size to replicate values in current table
  42827 	low = uint32(0xffffffff)                           // low bits for current root entry
  42828 	mask = libc.Uint32FromInt32(total_size - int32(1)) // mask for low bits
  42829 	key = uint32(0)                                    // reversed prefix code
  42830 	num_nodes = int32(1)                               // number of Huffman tree nodes
  42831 	num_open = int32(1)                                // number of open branches in current tree level
  42832 	table_bits = root_bits                             // key length of current table
  42833 	table_size = int32(1) << table_bits                // size of current table
  42834 	symbol = 0
  42835 	// Fill in root table.
  42836 	len1 = int32(1)
  42837 	step = libc.Int32FromInt32(2)
  42838 	for {
  42839 		if !(len1 <= root_bits) {
  42840 			break
  42841 		}
  42842 		num_open = num_open << int32(1)
  42843 		num_nodes = num_nodes + num_open
  42844 		num_open = num_open - (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42845 		if num_open < 0 {
  42846 			return 0
  42847 		}
  42848 		if root_table == libc.UintptrFromInt32(0) {
  42849 			goto _6
  42850 		}
  42851 		for {
  42852 			if !((**(**[16]int32)(__ccgo_up(bp)))[len1] > 0) {
  42853 				break
  42854 			}
  42855 			code1.Fbits = libc.Uint8FromInt32(len1)
  42856 			v4 = symbol
  42857 			symbol = symbol + 1
  42858 			code1.Fvalue = **(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2))
  42859 			ReplicateValue(tls, table+uintptr(key)*4, step, table_size, code1)
  42860 			key = GetNextKey(tls, key, len1)
  42861 			goto _7
  42862 		_7:
  42863 			;
  42864 			(**(**[16]int32)(__ccgo_up(bp)))[len1] = (**(**[16]int32)(__ccgo_up(bp)))[len1] - 1
  42865 		}
  42866 		goto _6
  42867 	_6:
  42868 		;
  42869 		len1 = len1 + 1
  42870 		step = step << int32(1)
  42871 	}
  42872 	// Fill in 2nd level tables and add pointers to root table.
  42873 	len1 = root_bits + int32(1)
  42874 	step = libc.Int32FromInt32(2)
  42875 	for {
  42876 		if !(len1 <= int32(MAX_ALLOWED_CODE_LENGTH)) {
  42877 			break
  42878 		}
  42879 		num_open = num_open << int32(1)
  42880 		num_nodes = num_nodes + num_open
  42881 		num_open = num_open - (**(**[16]int32)(__ccgo_up(bp)))[len1]
  42882 		if num_open < 0 {
  42883 			return 0
  42884 		}
  42885 		for {
  42886 			if !((**(**[16]int32)(__ccgo_up(bp)))[len1] > 0) {
  42887 				break
  42888 			}
  42889 			if key&mask != low {
  42890 				if root_table != libc.UintptrFromInt32(0) {
  42891 					table = table + uintptr(table_size)*4
  42892 				}
  42893 				table_bits = NextTableBitSize(tls, bp, len1, root_bits)
  42894 				table_size = int32(1) << table_bits
  42895 				total_size = total_size + table_size
  42896 				low = key & mask
  42897 				if root_table != libc.UintptrFromInt32(0) {
  42898 					(**(**HuffmanCode)(__ccgo_up(root_table + uintptr(low)*4))).Fbits = libc.Uint8FromInt32(table_bits + root_bits)
  42899 					(**(**HuffmanCode)(__ccgo_up(root_table + uintptr(low)*4))).Fvalue = libc.Uint16FromInt64((int64(table)-int64(root_table))/4 - libc.Int64FromUint32(low))
  42900 				}
  42901 			}
  42902 			if root_table != libc.UintptrFromInt32(0) {
  42903 				code2.Fbits = libc.Uint8FromInt32(len1 - root_bits)
  42904 				v4 = symbol
  42905 				symbol = symbol + 1
  42906 				code2.Fvalue = **(**uint16_t)(__ccgo_up(sorted + uintptr(v4)*2))
  42907 				ReplicateValue(tls, table+uintptr(key>>root_bits)*4, step, table_size, code2)
  42908 			}
  42909 			key = GetNextKey(tls, key, len1)
  42910 			goto _10
  42911 		_10:
  42912 			;
  42913 			(**(**[16]int32)(__ccgo_up(bp)))[len1] = (**(**[16]int32)(__ccgo_up(bp)))[len1] - 1
  42914 		}
  42915 		goto _9
  42916 	_9:
  42917 		;
  42918 		len1 = len1 + 1
  42919 		step = step << int32(1)
  42920 	}
  42921 	// Check if tree is full.
  42922 	if num_nodes != int32(2)*(**(**[16]int32)(__ccgo_up(bp + 64)))[int32(MAX_ALLOWED_CODE_LENGTH)]-int32(1) {
  42923 		return 0
  42924 	}
  42925 	return total_size
  42926 }
  42927 
  42928 // C documentation
  42929 //
  42930 //	// Maximum code_lengths_size is 2328 (reached for 11-bit color_cache_bits).
  42931 //	// More commonly, the value is around ~280.
  42932 //	// Cut-off value for switching between heap and stack allocation.
  42933 func VP8LBuildHuffmanTable(tls *libc.TLS, root_table uintptr, root_bits int32, code_lengths uintptr, code_lengths_size int32) (r int32) {
  42934 	bp := tls.Alloc(1024)
  42935 	defer tls.Free(1024)
  42936 	var next, sorted1 uintptr
  42937 	var segment_size, total_size, v1 int32
  42938 	var _ /* sorted at bp+0 */ [512]uint16_t
  42939 	_, _, _, _, _ = next, segment_size, sorted1, total_size, v1
  42940 	total_size = BuildHuffmanTable(tls, libc.UintptrFromInt32(0), root_bits, code_lengths, code_lengths_size, libc.UintptrFromInt32(0))
  42941 	if total_size == 0 || root_table == libc.UintptrFromInt32(0) {
  42942 		return total_size
  42943 	}
  42944 	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 {
  42945 		// If 'root_table' does not have enough memory, allocate a new segment.
  42946 		// The available part of root_table->curr_segment is left unused because we
  42947 		// need a contiguous buffer.
  42948 		segment_size = (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fsize
  42949 		next = WebPSafeMalloc(tls, uint64(1), uint64(32))
  42950 		if next == libc.UintptrFromInt32(0) {
  42951 			return 0
  42952 		}
  42953 		// Fill the new segment.
  42954 		// We need at least 'total_size' but if that value is small, it is better to
  42955 		// allocate a big chunk to prevent more allocations later. 'segment_size' is
  42956 		// therefore chosen (any other arbitrary value could be chosen).
  42957 		if total_size > segment_size {
  42958 			v1 = total_size
  42959 		} else {
  42960 			v1 = segment_size
  42961 		}
  42962 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fsize = v1
  42963 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart = WebPSafeMalloc(tls, libc.Uint64FromInt32((*HuffmanTablesSegment)(unsafe.Pointer(next)).Fsize), uint64(4))
  42964 		if (*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart == libc.UintptrFromInt32(0) {
  42965 			WebPSafeFree(tls, next)
  42966 			return 0
  42967 		}
  42968 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fcurr_table = (*HuffmanTablesSegment)(unsafe.Pointer(next)).Fstart
  42969 		(*HuffmanTablesSegment)(unsafe.Pointer(next)).Fnext = libc.UintptrFromInt32(0)
  42970 		// Point to the new segment.
  42971 		(*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fnext = next
  42972 		(*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment = next
  42973 	}
  42974 	if code_lengths_size <= int32(SORTED_SIZE_CUTOFF) {
  42975 		BuildHuffmanTable(tls, (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fcurr_table, root_bits, code_lengths, code_lengths_size, bp)
  42976 	} else { // rare case. Use heap allocation.
  42977 		sorted1 = WebPSafeMalloc(tls, libc.Uint64FromInt32(code_lengths_size), uint64(2))
  42978 		if sorted1 == libc.UintptrFromInt32(0) {
  42979 			return 0
  42980 		}
  42981 		BuildHuffmanTable(tls, (*HuffmanTablesSegment)(unsafe.Pointer((*HuffmanTables)(unsafe.Pointer(root_table)).Fcurr_segment)).Fcurr_table, root_bits, code_lengths, code_lengths_size, sorted1)
  42982 		WebPSafeFree(tls, sorted1)
  42983 	}
  42984 	return total_size
  42985 }
  42986 
  42987 func VP8LHuffmanTablesAllocate(tls *libc.TLS, size int32, huffman_tables uintptr) (r int32) {
  42988 	var root uintptr
  42989 	_ = root
  42990 	// Have 'segment' point to the first segment for now, 'root'.
  42991 	root = huffman_tables
  42992 	(*HuffmanTables)(unsafe.Pointer(huffman_tables)).Fcurr_segment = root
  42993 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fnext = libc.UintptrFromInt32(0)
  42994 	// Allocate root.
  42995 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart = WebPSafeMalloc(tls, libc.Uint64FromInt32(size), uint64(4))
  42996 	if (*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart == libc.UintptrFromInt32(0) {
  42997 		return 0
  42998 	}
  42999 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fcurr_table = (*HuffmanTablesSegment)(unsafe.Pointer(root)).Fstart
  43000 	(*HuffmanTablesSegment)(unsafe.Pointer(root)).Fsize = size
  43001 	return int32(1)
  43002 }
  43003 
  43004 func VP8LHuffmanTablesDeallocate(tls *libc.TLS, huffman_tables uintptr) {
  43005 	var current, next uintptr
  43006 	_, _ = current, next
  43007 	if huffman_tables == libc.UintptrFromInt32(0) {
  43008 		return
  43009 	}
  43010 	// Free the root node.
  43011 	current = huffman_tables
  43012 	next = (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext
  43013 	WebPSafeFree(tls, (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart)
  43014 	(*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart = libc.UintptrFromInt32(0)
  43015 	(*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext = libc.UintptrFromInt32(0)
  43016 	current = next
  43017 	// Free the following nodes.
  43018 	for current != libc.UintptrFromInt32(0) {
  43019 		next = (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fnext
  43020 		WebPSafeFree(tls, (*HuffmanTablesSegment)(unsafe.Pointer(current)).Fstart)
  43021 		WebPSafeFree(tls, current)
  43022 		current = next
  43023 	}
  43024 }
  43025 
  43026 var kHashMul13 = uint32(0x1e35a7bd)
  43027 
  43028 // Alpha related constants.
  43029 
  43030 // Mux related constants.
  43031 
  43032 // Maximum chunk payload is such that adding the header and padding won't
  43033 // overflow a uint32_t.
  43034 
  43035 // Copyright 2010 Google Inc. All Rights Reserved.
  43036 //
  43037 // Use of this source code is governed by a BSD-style license
  43038 // that can be found in the COPYING file in the root of the source
  43039 // tree. An additional intellectual property rights grant can be found
  43040 // in the file PATENTS. All contributing project authors may
  43041 // be found in the AUTHORS file in the root of the source tree.
  43042 // -----------------------------------------------------------------------------
  43043 //
  43044 //  Common types + memory wrappers
  43045 //
  43046 // Author: Skal (pascal.massimino@gmail.com)
  43047 
  43048 // -----------------------------------------------------------------------------
  43049 
  43050 // Palette reordering for smaller sum of deltas (and for smaller storage).
  43051 
  43052 func PaletteCompareColorsForQsort(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) {
  43053 	bp := tls.Alloc(16)
  43054 	defer tls.Free(16)
  43055 	var a, b, v1, v3 uint32_t
  43056 	var v5 int32
  43057 	var _ /* A at bp+0 */ uint32_t
  43058 	_, _, _, _, _ = a, b, v1, v3, v5
  43059 	libc.X__builtin___memcpy_chk(tls, bp, p1, uint64(4), ^__predefined_size_t(0))
  43060 	v1 = **(**uint32_t)(__ccgo_up(bp))
  43061 	goto _2
  43062 _2:
  43063 	a = v1
  43064 	libc.X__builtin___memcpy_chk(tls, bp, p2, uint64(4), ^__predefined_size_t(0))
  43065 	v3 = **(**uint32_t)(__ccgo_up(bp))
  43066 	goto _4
  43067 _4:
  43068 	b = v3
  43069 	if a < b {
  43070 		v5 = -int32(1)
  43071 	} else {
  43072 		v5 = int32(1)
  43073 	}
  43074 	return v5
  43075 }
  43076 
  43077 func PaletteComponentDistance(tls *libc.TLS, v uint32_t) (r uint32_t) {
  43078 	var v1 uint32
  43079 	_ = v1
  43080 	if v <= uint32(128) {
  43081 		v1 = v
  43082 	} else {
  43083 		v1 = uint32(256) - v
  43084 	}
  43085 	return v1
  43086 }
  43087 
  43088 // C documentation
  43089 //
  43090 //	// Computes a value that is related to the entropy created by the
  43091 //	// palette entry diff.
  43092 //	//
  43093 //	// Note that the last & 0xff is a no-operation in the next statement, but
  43094 //	// removed by most compilers and is here only for regularity of the code.
  43095 func PaletteColorDistance(tls *libc.TLS, col1 uint32_t, col2 uint32_t) (r uint32_t) {
  43096 	var alpha_and_green, diff, red_and_blue, score, v1, v2, v3 uint32_t
  43097 	var kMoreWeightForRGBThanForAlpha int32
  43098 	_, _, _, _, _, _, _, _ = alpha_and_green, diff, kMoreWeightForRGBThanForAlpha, red_and_blue, score, v1, v2, v3
  43099 	v1 = col1
  43100 	v2 = col2
  43101 	alpha_and_green = uint32(0x00ff00ff) + v1&uint32(0xff00ff00) - v2&uint32(0xff00ff00)
  43102 	red_and_blue = uint32(0xff00ff00) + v1&uint32(0x00ff00ff) - v2&uint32(0x00ff00ff)
  43103 	v3 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  43104 	goto _4
  43105 _4:
  43106 	diff = v3
  43107 	kMoreWeightForRGBThanForAlpha = int32(9)
  43108 	score = PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(0)&uint32(0xff))
  43109 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(8)&uint32(0xff))
  43110 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(16)&uint32(0xff))
  43111 	score = score * libc.Uint32FromInt32(kMoreWeightForRGBThanForAlpha)
  43112 	score = score + PaletteComponentDistance(tls, diff>>libc.Int32FromInt32(24)&uint32(0xff))
  43113 	return score
  43114 }
  43115 
  43116 func SwapColor(tls *libc.TLS, col1 uintptr, col2 uintptr) {
  43117 	var tmp uint32_t
  43118 	_ = tmp
  43119 	tmp = **(**uint32_t)(__ccgo_up(col1))
  43120 	**(**uint32_t)(__ccgo_up(col1)) = **(**uint32_t)(__ccgo_up(col2))
  43121 	**(**uint32_t)(__ccgo_up(col2)) = tmp
  43122 }
  43123 
  43124 func SearchColorNoIdx(tls *libc.TLS, sorted uintptr, color uint32_t, num_colors int32) (r int32) {
  43125 	var hi, low, mid int32
  43126 	_, _, _ = hi, low, mid
  43127 	low = 0
  43128 	hi = num_colors
  43129 	if **(**uint32_t)(__ccgo_up(sorted + uintptr(low)*4)) == color {
  43130 		return low
  43131 	} // loop invariant: sorted[low] != color
  43132 	for int32(1) != 0 {
  43133 		mid = (low + hi) >> int32(1)
  43134 		if **(**uint32_t)(__ccgo_up(sorted + uintptr(mid)*4)) == color {
  43135 			return mid
  43136 		} else {
  43137 			if **(**uint32_t)(__ccgo_up(sorted + uintptr(mid)*4)) < color {
  43138 				low = mid
  43139 			} else {
  43140 				hi = mid
  43141 			}
  43142 		}
  43143 	}
  43144 	return 0
  43145 }
  43146 
  43147 func PrepareMapToPalette(tls *libc.TLS, palette uintptr, num_colors uint32_t, sorted uintptr, idx_map uintptr) {
  43148 	var i uint32_t
  43149 	_ = i
  43150 	libc.X__builtin___memcpy_chk(tls, sorted, palette, uint64(num_colors)*uint64(4), ^__predefined_size_t(0))
  43151 	libc.Xqsort(tls, sorted, uint64(num_colors), uint64(4), __ccgo_fp(PaletteCompareColorsForQsort))
  43152 	i = uint32(0)
  43153 	for {
  43154 		if !(i < num_colors) {
  43155 			break
  43156 		}
  43157 		**(**uint32_t)(__ccgo_up(idx_map + uintptr(SearchColorNoIdx(tls, sorted, **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4)), libc.Int32FromUint32(num_colors)))*4)) = i
  43158 		goto _1
  43159 	_1:
  43160 		;
  43161 		i = i + 1
  43162 	}
  43163 }
  43164 
  43165 //------------------------------------------------------------------------------
  43166 
  43167 func GetColorPalette(tls *libc.TLS, pic uintptr, palette uintptr) (r int32) {
  43168 	var argb1 uintptr
  43169 	var colors [1024]uint32_t
  43170 	var height, i, key, num_colors, width, x, y, v3 int32
  43171 	var in_use [1024]uint8_t
  43172 	var last_pix uint32_t
  43173 	_, _, _, _, _, _, _, _, _, _, _, _ = argb1, colors, height, i, in_use, key, last_pix, num_colors, width, x, y, v3
  43174 	num_colors = 0
  43175 	in_use = [1024]uint8_t{}
  43176 	colors = [1024]uint32_t{}
  43177 	argb1 = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  43178 	width = (*WebPPicture)(unsafe.Pointer(pic)).Fwidth
  43179 	height = (*WebPPicture)(unsafe.Pointer(pic)).Fheight
  43180 	last_pix = ^**(**uint32_t)(__ccgo_up(argb1)) // so we're sure that last_pix != argb[0]
  43181 	y = 0
  43182 	for {
  43183 		if !(y < height) {
  43184 			break
  43185 		}
  43186 		x = 0
  43187 		for {
  43188 			if !(x < width) {
  43189 				break
  43190 			}
  43191 			if **(**uint32_t)(__ccgo_up(argb1 + uintptr(x)*4)) == last_pix {
  43192 				goto _2
  43193 			}
  43194 			last_pix = **(**uint32_t)(__ccgo_up(argb1 + uintptr(x)*4))
  43195 			v3 = libc.Int32FromUint32(last_pix * kHashMul13 >> int32(22))
  43196 			goto _4
  43197 		_4:
  43198 			key = v3
  43199 			for int32(1) != 0 {
  43200 				if !(in_use[key] != 0) {
  43201 					colors[key] = last_pix
  43202 					in_use[key] = uint8(1)
  43203 					num_colors = num_colors + 1
  43204 					if num_colors > int32(MAX_PALETTE_SIZE) {
  43205 						return libc.Int32FromInt32(MAX_PALETTE_SIZE) + libc.Int32FromInt32(1) // Exact count not needed.
  43206 					}
  43207 					break
  43208 				} else {
  43209 					if colors[key] == last_pix {
  43210 						break // The color is already there.
  43211 					} else {
  43212 						// Some other color sits here, so do linear conflict resolution.
  43213 						key = key + 1
  43214 						key = key & (libc.Int32FromInt32(MAX_PALETTE_SIZE)*libc.Int32FromInt32(4) - libc.Int32FromInt32(1)) // Key mask.
  43215 					}
  43216 				}
  43217 			}
  43218 			goto _2
  43219 		_2:
  43220 			;
  43221 			x = x + 1
  43222 		}
  43223 		argb1 = argb1 + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  43224 		goto _1
  43225 	_1:
  43226 		;
  43227 		y = y + 1
  43228 	}
  43229 	if palette != libc.UintptrFromInt32(0) { // Fill the colors into palette.
  43230 		num_colors = 0
  43231 		i = 0
  43232 		for {
  43233 			if !(i < libc.Int32FromInt32(MAX_PALETTE_SIZE)*libc.Int32FromInt32(4)) {
  43234 				break
  43235 			}
  43236 			if in_use[i] != 0 {
  43237 				**(**uint32_t)(__ccgo_up(palette + uintptr(num_colors)*4)) = colors[i]
  43238 				num_colors = num_colors + 1
  43239 			}
  43240 			goto _5
  43241 		_5:
  43242 			;
  43243 			i = i + 1
  43244 		}
  43245 		libc.Xqsort(tls, palette, libc.Uint64FromInt32(num_colors), uint64(4), __ccgo_fp(PaletteCompareColorsForQsort))
  43246 	}
  43247 	return num_colors
  43248 }
  43249 
  43250 // -----------------------------------------------------------------------------
  43251 
  43252 // C documentation
  43253 //
  43254 //	// The palette has been sorted by alpha. This function checks if the other
  43255 //	// components of the palette have a monotonic development with regards to
  43256 //	// position in the palette. If all have monotonic development, there is
  43257 //	// no benefit to re-organize them greedily. A monotonic development
  43258 //	// would be spotted in green-only situations (like lossy alpha) or gray-scale
  43259 //	// images.
  43260 func PaletteHasNonMonotonousDeltas(tls *libc.TLS, palette uintptr, num_colors int32) (r int32) {
  43261 	var alpha_and_green, diff, predict, red_and_blue, v2, v3, v4 uint32_t
  43262 	var bd, gd, rd, sign_found uint8_t
  43263 	var i, v6 int32
  43264 	_, _, _, _, _, _, _, _, _, _, _, _, _ = alpha_and_green, bd, diff, gd, i, predict, rd, red_and_blue, sign_found, v2, v3, v4, v6
  43265 	predict = uint32(0x000000)
  43266 	sign_found = uint8(0x00)
  43267 	i = 0
  43268 	for {
  43269 		if !(i < num_colors) {
  43270 			break
  43271 		}
  43272 		v2 = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43273 		v3 = predict
  43274 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  43275 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  43276 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  43277 		goto _5
  43278 	_5:
  43279 		diff = v4
  43280 		rd = uint8(diff >> libc.Int32FromInt32(16) & uint32(0xff))
  43281 		gd = uint8(diff >> libc.Int32FromInt32(8) & uint32(0xff))
  43282 		bd = uint8(diff >> libc.Int32FromInt32(0) & uint32(0xff))
  43283 		if libc.Int32FromUint8(rd) != 0x00 {
  43284 			if libc.Int32FromUint8(rd) < int32(0x80) {
  43285 				v6 = int32(1)
  43286 			} else {
  43287 				v6 = int32(2)
  43288 			}
  43289 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43290 		}
  43291 		if libc.Int32FromUint8(gd) != 0x00 {
  43292 			if libc.Int32FromUint8(gd) < int32(0x80) {
  43293 				v6 = int32(8)
  43294 			} else {
  43295 				v6 = int32(16)
  43296 			}
  43297 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43298 		}
  43299 		if libc.Int32FromUint8(bd) != 0x00 {
  43300 			if libc.Int32FromUint8(bd) < int32(0x80) {
  43301 				v6 = int32(64)
  43302 			} else {
  43303 				v6 = int32(128)
  43304 			}
  43305 			sign_found = libc.Uint8FromInt32(int32(sign_found) | v6)
  43306 		}
  43307 		predict = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43308 		goto _1
  43309 	_1:
  43310 		;
  43311 		i = i + 1
  43312 	}
  43313 	return libc.BoolInt32(libc.Int32FromUint8(sign_found)&(libc.Int32FromUint8(sign_found)<<int32(1)) != 0) // two consequent signs.
  43314 }
  43315 
  43316 func PaletteSortMinimizeDeltas(tls *libc.TLS, palette_sorted uintptr, num_colors int32, palette uintptr) {
  43317 	var best_ix, i, k int32
  43318 	var best_score, cur_score, predict uint32_t
  43319 	_, _, _, _, _, _ = best_ix, best_score, cur_score, i, k, predict
  43320 	predict = uint32(0x00000000)
  43321 	libc.X__builtin___memcpy_chk(tls, palette, palette_sorted, libc.Uint64FromInt32(num_colors)*uint64(4), ^__predefined_size_t(0))
  43322 	if !(PaletteHasNonMonotonousDeltas(tls, palette_sorted, num_colors) != 0) {
  43323 		return
  43324 	}
  43325 	// Find greedily always the closest color of the predicted color to minimize
  43326 	// deltas in the palette. This reduces storage needs since the
  43327 	// palette is stored with delta encoding.
  43328 	if num_colors > int32(17) {
  43329 		if **(**uint32_t)(__ccgo_up(palette)) == uint32(0) {
  43330 			num_colors = num_colors - 1
  43331 			SwapColor(tls, palette+uintptr(num_colors)*4, palette)
  43332 		}
  43333 	}
  43334 	i = 0
  43335 	for {
  43336 		if !(i < num_colors) {
  43337 			break
  43338 		}
  43339 		best_ix = i
  43340 		best_score = ^libc.Uint32FromUint32(0)
  43341 		k = i
  43342 		for {
  43343 			if !(k < num_colors) {
  43344 				break
  43345 			}
  43346 			cur_score = PaletteColorDistance(tls, **(**uint32_t)(__ccgo_up(palette + uintptr(k)*4)), predict)
  43347 			if best_score > cur_score {
  43348 				best_score = cur_score
  43349 				best_ix = k
  43350 			}
  43351 			goto _2
  43352 		_2:
  43353 			;
  43354 			k = k + 1
  43355 		}
  43356 		SwapColor(tls, palette+uintptr(best_ix)*4, palette+uintptr(i)*4)
  43357 		predict = **(**uint32_t)(__ccgo_up(palette + uintptr(i)*4))
  43358 		goto _1
  43359 	_1:
  43360 		;
  43361 		i = i + 1
  43362 	}
  43363 }
  43364 
  43365 // -----------------------------------------------------------------------------
  43366 // Modified Zeng method from "A Survey on Palette Reordering
  43367 // Methods for Improving the Compression of Color-Indexed Images" by Armando J.
  43368 // Pinho and Antonio J. R. Neves.
  43369 
  43370 // C documentation
  43371 //
  43372 //	// Finds the biggest cooccurrence in the matrix.
  43373 func CoOccurrenceFindMax(tls *libc.TLS, cooccurrence uintptr, num_colors uint32_t, c1 uintptr, c2 uintptr) {
  43374 	var best_cooccurrence, best_sum, i, j, sum uint32_t
  43375 	_, _, _, _, _ = best_cooccurrence, best_sum, i, j, sum
  43376 	// Find the index that is most frequently located adjacent to other
  43377 	// (different) indexes.
  43378 	best_sum = 0
  43379 	**(**uint8_t)(__ccgo_up(c1)) = 0
  43380 	i = uint32(0)
  43381 	for {
  43382 		if !(i < num_colors) {
  43383 			break
  43384 		}
  43385 		sum = uint32(0)
  43386 		j = uint32(0)
  43387 		for {
  43388 			if !(j < num_colors) {
  43389 				break
  43390 			}
  43391 			sum = sum + **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(i*num_colors+j)*4))
  43392 			goto _2
  43393 		_2:
  43394 			;
  43395 			j = j + 1
  43396 		}
  43397 		if sum > best_sum {
  43398 			best_sum = sum
  43399 			**(**uint8_t)(__ccgo_up(c1)) = uint8(i)
  43400 		}
  43401 		goto _1
  43402 	_1:
  43403 		;
  43404 		i = i + 1
  43405 	}
  43406 	// Find the index that is most frequently found adjacent to *c1.
  43407 	**(**uint8_t)(__ccgo_up(c2)) = 0
  43408 	best_cooccurrence = 0
  43409 	i = uint32(0)
  43410 	for {
  43411 		if !(i < num_colors) {
  43412 			break
  43413 		}
  43414 		if **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(**(**uint8_t)(__ccgo_up(c1)))*num_colors+i)*4)) > best_cooccurrence {
  43415 			best_cooccurrence = **(**uint32_t)(__ccgo_up(cooccurrence + uintptr(uint32(**(**uint8_t)(__ccgo_up(c1)))*num_colors+i)*4))
  43416 			**(**uint8_t)(__ccgo_up(c2)) = uint8(i)
  43417 		}
  43418 		goto _3
  43419 	_3:
  43420 		;
  43421 		i = i + 1
  43422 	}
  43423 }
  43424 
  43425 // C documentation
  43426 //
  43427 //	// Builds the cooccurrence matrix
  43428 func CoOccurrenceBuild(tls *libc.TLS, pic uintptr, palette uintptr, num_colors uint32_t, cooccurrence uintptr) (r int32) {
  43429 	bp := tls.Alloc(2048)
  43430 	defer tls.Free(2048)
  43431 	var left_idx, pix, prev_idx, prev_pix, top_idx uint32_t
  43432 	var line_current, line_tmp, line_top, lines, src uintptr
  43433 	var x, y int32
  43434 	var _ /* idx_map at bp+0 */ [256]uint32_t
  43435 	var _ /* palette_sorted at bp+1024 */ [256]uint32_t
  43436 	_, _, _, _, _, _, _, _, _, _, _, _ = left_idx, line_current, line_tmp, line_top, lines, pix, prev_idx, prev_pix, src, top_idx, x, y
  43437 	src = (*WebPPicture)(unsafe.Pointer(pic)).Fargb
  43438 	prev_pix = ^**(**uint32_t)(__ccgo_up(src))
  43439 	prev_idx = 0
  43440 	**(**[256]uint32_t)(__ccgo_up(bp)) = [256]uint32_t{}
  43441 	lines = WebPSafeMalloc(tls, libc.Uint64FromInt32(int32(2)*(*WebPPicture)(unsafe.Pointer(pic)).Fwidth), uint64(4))
  43442 	if lines == libc.UintptrFromInt32(0) {
  43443 		return 0
  43444 	}
  43445 	line_top = lines
  43446 	line_current = lines + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fwidth)*4
  43447 	PrepareMapToPalette(tls, palette, num_colors, bp+1024, bp)
  43448 	y = 0
  43449 	for {
  43450 		if !(y < (*WebPPicture)(unsafe.Pointer(pic)).Fheight) {
  43451 			break
  43452 		}
  43453 		x = 0
  43454 		for {
  43455 			if !(x < (*WebPPicture)(unsafe.Pointer(pic)).Fwidth) {
  43456 				break
  43457 			}
  43458 			pix = **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))
  43459 			if pix != prev_pix {
  43460 				prev_idx = (**(**[256]uint32_t)(__ccgo_up(bp)))[SearchColorNoIdx(tls, bp+1024, pix, libc.Int32FromUint32(num_colors))]
  43461 				prev_pix = pix
  43462 			}
  43463 			**(**uint32_t)(__ccgo_up(line_current + uintptr(x)*4)) = prev_idx
  43464 			// 4-connectivity is what works best as mentioned in "On the relation
  43465 			// between Memon's and the modified Zeng's palette reordering methods".
  43466 			if x > 0 && prev_idx != **(**uint32_t)(__ccgo_up(line_current + uintptr(x-int32(1))*4)) {
  43467 				left_idx = **(**uint32_t)(__ccgo_up(line_current + uintptr(x-int32(1))*4))
  43468 				**(**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
  43469 				**(**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
  43470 			}
  43471 			if y > 0 && prev_idx != **(**uint32_t)(__ccgo_up(line_top + uintptr(x)*4)) {
  43472 				top_idx = **(**uint32_t)(__ccgo_up(line_top + uintptr(x)*4))
  43473 				**(**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
  43474 				**(**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
  43475 			}
  43476 			goto _2
  43477 		_2:
  43478 			;
  43479 			x = x + 1
  43480 		}
  43481 		line_tmp = line_top
  43482 		line_top = line_current
  43483 		line_current = line_tmp
  43484 		src = src + uintptr((*WebPPicture)(unsafe.Pointer(pic)).Fargb_stride)*4
  43485 		goto _1
  43486 	_1:
  43487 		;
  43488 		y = y + 1
  43489 	}
  43490 	WebPSafeFree(tls, lines)
  43491 	return int32(1)
  43492 }
  43493 
  43494 type Sum = struct {
  43495 	Findex uint8_t
  43496 	Fsum   uint32_t
  43497 }
  43498 
  43499 func PaletteSortModifiedZeng(tls *libc.TLS, pic uintptr, palette_in uintptr, num_colors uint32_t, palette uintptr) (r int32) {
  43500 	bp := tls.Alloc(2304)
  43501 	defer tls.Free(2304)
  43502 	var best_index uint8_t
  43503 	var best_sum, cooccurrence uintptr
  43504 	var delta, n int32_t
  43505 	var first, i, ind, j, last, num_sums uint32_t
  43506 	var l_j uint16_t
  43507 	var v3 uint32
  43508 	var _ /* remapping at bp+0 */ [256]uint8_t
  43509 	var _ /* sums at bp+256 */ [256]Sum
  43510 	_, _, _, _, _, _, _, _, _, _, _, _, _ = best_index, best_sum, cooccurrence, delta, first, i, ind, j, l_j, last, n, num_sums, v3
  43511 	// TODO(vrabaud) check whether one color images should use palette or not.
  43512 	if num_colors <= uint32(1) {
  43513 		return int32(1)
  43514 	}
  43515 	// Build the co-occurrence matrix.
  43516 	cooccurrence = WebPSafeCalloc(tls, uint64(num_colors*num_colors), uint64(4))
  43517 	if cooccurrence == libc.UintptrFromInt32(0) {
  43518 		return 0
  43519 	}
  43520 	if !(CoOccurrenceBuild(tls, pic, palette_in, num_colors, cooccurrence) != 0) {
  43521 		WebPSafeFree(tls, cooccurrence)
  43522 		return 0
  43523 	}
  43524 	// Initialize the mapping list with the two best indices.
  43525 	CoOccurrenceFindMax(tls, cooccurrence, num_colors, bp, bp+1)
  43526 	// We need to append and prepend to the list of remapping. To this end, we
  43527 	// actually define the next start/end of the list as indices in a vector (with
  43528 	// a wrap around when the end is reached).
  43529 	first = uint32(0)
  43530 	last = uint32(1)
  43531 	num_sums = num_colors - uint32(2) // -2 because we know the first two values
  43532 	if num_sums > uint32(0) {
  43533 		// Initialize the sums with the first two remappings and find the best one
  43534 		best_sum = bp + 256
  43535 		(*Sum)(unsafe.Pointer(best_sum)).Findex = 0
  43536 		(*Sum)(unsafe.Pointer(best_sum)).Fsum = 0
  43537 		i = uint32(0)
  43538 		j = libc.Uint32FromInt32(0)
  43539 		for {
  43540 			if !(i < num_colors) {
  43541 				break
  43542 			}
  43543 			if i == uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[0]) || i == uint32((**(**[256]uint8_t)(__ccgo_up(bp)))[int32(1)]) {
  43544 				goto _1
  43545 			}
  43546 			(**(**[256]Sum)(__ccgo_up(bp + 256)))[j].Findex = uint8(i)
  43547 			(**(**[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))
  43548 			if (**(**[256]Sum)(__ccgo_up(bp + 256)))[j].Fsum > (*Sum)(unsafe.Pointer(best_sum)).Fsum {
  43549 				best_sum = bp + 256 + uintptr(j)*8
  43550 			}
  43551 			j = j + 1
  43552 			goto _1
  43553 		_1:
  43554 			;
  43555 			i = i + 1
  43556 		}
  43557 		for num_sums > uint32(0) {
  43558 			best_index = (*Sum)(unsafe.Pointer(best_sum)).Findex
  43559 			// Compute delta to know if we need to prepend or append the best index.
  43560 			delta = 0
  43561 			n = libc.Int32FromUint32(num_colors - num_sums)
  43562 			ind = first
  43563 			j = libc.Uint32FromInt32(0)
  43564 			for {
  43565 				if !((ind+j)%num_colors != last+uint32(1)) {
  43566 					break
  43567 				}
  43568 				l_j = uint16((**(**[256]uint8_t)(__ccgo_up(bp)))[(ind+j)%num_colors])
  43569 				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)))
  43570 				goto _2
  43571 			_2:
  43572 				;
  43573 				j = j + 1
  43574 			}
  43575 			if delta > 0 {
  43576 				if first == uint32(0) {
  43577 					v3 = num_colors - uint32(1)
  43578 				} else {
  43579 					v3 = first - uint32(1)
  43580 				}
  43581 				first = v3
  43582 				(**(**[256]uint8_t)(__ccgo_up(bp)))[first] = best_index
  43583 			} else {
  43584 				last = last + 1
  43585 				(**(**[256]uint8_t)(__ccgo_up(bp)))[last] = best_index
  43586 			}
  43587 			// Remove best_sum from sums.
  43588 			**(**Sum)(__ccgo_up(best_sum)) = (**(**[256]Sum)(__ccgo_up(bp + 256)))[num_sums-uint32(1)]
  43589 			num_sums = num_sums - 1
  43590 			// Update all the sums and find the best one.
  43591 			best_sum = bp + 256
  43592 			i = uint32(0)
  43593 			for {
  43594 				if !(i < num_sums) {
  43595 					break
  43596 				}
  43597 				(**(**[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))
  43598 				if (**(**[256]Sum)(__ccgo_up(bp + 256)))[i].Fsum > (*Sum)(unsafe.Pointer(best_sum)).Fsum {
  43599 					best_sum = bp + 256 + uintptr(i)*8
  43600 				}
  43601 				goto _4
  43602 			_4:
  43603 				;
  43604 				i = i + 1
  43605 			}
  43606 		}
  43607 	}
  43608 	WebPSafeFree(tls, cooccurrence)
  43609 	// Re-map the palette.
  43610 	i = uint32(0)
  43611 	for {
  43612 		if !(i < num_colors) {
  43613 			break
  43614 		}
  43615 		**(**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))
  43616 		goto _5
  43617 	_5:
  43618 		;
  43619 		i = i + 1
  43620 	}
  43621 	return int32(1)
  43622 }
  43623 
  43624 // -----------------------------------------------------------------------------
  43625 
  43626 func PaletteSort(tls *libc.TLS, method PaletteSorting1, pic uintptr, palette_sorted uintptr, num_colors uint32_t, palette uintptr) (r int32) {
  43627 	switch method {
  43628 	case int32(kSortedDefault):
  43629 		if **(**uint32_t)(__ccgo_up(palette_sorted)) == uint32(0) && num_colors > uint32(17) {
  43630 			libc.X__builtin___memcpy_chk(tls, palette, palette_sorted+uintptr(1)*4, uint64(num_colors-libc.Uint32FromInt32(1))*uint64(4), ^__predefined_size_t(0))
  43631 			**(**uint32_t)(__ccgo_up(palette + uintptr(num_colors-uint32(1))*4)) = uint32(0)
  43632 		} else {
  43633 			libc.X__builtin___memcpy_chk(tls, palette, palette_sorted, uint64(num_colors)*uint64(4), ^__predefined_size_t(0))
  43634 		}
  43635 		return int32(1)
  43636 	case int32(kMinimizeDelta):
  43637 		PaletteSortMinimizeDeltas(tls, palette_sorted, libc.Int32FromUint32(num_colors), palette)
  43638 		return int32(1)
  43639 	case int32(kModifiedZeng):
  43640 		return PaletteSortModifiedZeng(tls, pic, palette_sorted, num_colors, palette)
  43641 	case int32(kUnusedPalette):
  43642 		fallthrough
  43643 	case int32(kPaletteSortingNum):
  43644 		break
  43645 	}
  43646 	return 0
  43647 }
  43648 
  43649 const DFIX = 0
  43650 const FIX = 16
  43651 const LFIX = 2
  43652 
  43653 //------------------------------------------------------------------------------
  43654 
  43655 // Copyright 2010 Google Inc. All Rights Reserved.
  43656 //
  43657 // Use of this source code is governed by a BSD-style license
  43658 // that can be found in the COPYING file in the root of the source
  43659 // tree. An additional intellectual property rights grant can be found
  43660 // in the file PATENTS. All contributing project authors may
  43661 // be found in the AUTHORS file in the root of the source tree.
  43662 // -----------------------------------------------------------------------------
  43663 //
  43664 //  Common types + memory wrappers
  43665 //
  43666 // Author: Skal (pascal.massimino@gmail.com)
  43667 
  43668 // #define USE_DITHERING   // uncomment to enable ordered dithering (not vital)
  43669 
  43670 type SmoothParams = struct {
  43671 	Fwidth          int32
  43672 	Fheight         int32
  43673 	Fstride         int32
  43674 	Frow            int32
  43675 	Fsrc            uintptr
  43676 	Fdst            uintptr
  43677 	Fradius         int32
  43678 	Fscale          int32
  43679 	Fmem            uintptr
  43680 	Fstart          uintptr
  43681 	Fcur            uintptr
  43682 	Fend            uintptr
  43683 	Ftop            uintptr
  43684 	Faverage        uintptr
  43685 	Fnum_levels     int32
  43686 	Fmin            int32
  43687 	Fmax            int32
  43688 	Fmin_level_dist int32
  43689 	Fcorrection     uintptr
  43690 }
  43691 
  43692 //------------------------------------------------------------------------------
  43693 
  43694 func clip_8b(tls *libc.TLS, v int32) (r uint8_t) {
  43695 	var v1, v2 uint32
  43696 	_, _ = v1, v2
  43697 	if !(v&libc.Int32FromUint32(^libc.Uint32FromUint32(0)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(DFIX))) != 0) {
  43698 		v1 = uint32(libc.Uint8FromInt32(v >> libc.Int32FromInt32(DFIX)))
  43699 	} else {
  43700 		if v < 0 {
  43701 			v2 = 0
  43702 		} else {
  43703 			v2 = uint32(255)
  43704 		}
  43705 		v1 = v2
  43706 	}
  43707 	return uint8(v1)
  43708 }
  43709 
  43710 // C documentation
  43711 //
  43712 //	// vertical accumulation
  43713 func VFilter(tls *libc.TLS, p uintptr) {
  43714 	var cur, out, src, top uintptr
  43715 	var new_value, sum uint16_t
  43716 	var w, x int32
  43717 	_, _, _, _, _, _, _, _ = cur, new_value, out, src, sum, top, w, x
  43718 	src = (*SmoothParams)(unsafe.Pointer(p)).Fsrc
  43719 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43720 	cur = (*SmoothParams)(unsafe.Pointer(p)).Fcur
  43721 	top = (*SmoothParams)(unsafe.Pointer(p)).Ftop
  43722 	out = (*SmoothParams)(unsafe.Pointer(p)).Fend
  43723 	sum = uint16(0)
  43724 	x = 0
  43725 	for {
  43726 		if !(x < w) {
  43727 			break
  43728 		}
  43729 		sum = libc.Uint16FromInt32(int32(sum) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + uintptr(x)))))
  43730 		new_value = libc.Uint16FromInt32(libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(top + uintptr(x)*2))) + libc.Int32FromUint16(sum))
  43731 		**(**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.
  43732 		**(**uint16_t)(__ccgo_up(cur + uintptr(x)*2)) = new_value
  43733 		goto _1
  43734 	_1:
  43735 		;
  43736 		x = x + 1
  43737 	}
  43738 	// move input pointers one row down
  43739 	(*SmoothParams)(unsafe.Pointer(p)).Ftop = (*SmoothParams)(unsafe.Pointer(p)).Fcur
  43740 	**(**uintptr)(__ccgo_up(p + 56)) += uintptr(w) * 2
  43741 	if (*SmoothParams)(unsafe.Pointer(p)).Fcur == (*SmoothParams)(unsafe.Pointer(p)).Fend {
  43742 		(*SmoothParams)(unsafe.Pointer(p)).Fcur = (*SmoothParams)(unsafe.Pointer(p)).Fstart
  43743 	} // roll-over
  43744 	// We replicate edges, as it's somewhat easier as a boundary condition.
  43745 	// That's why we don't update the 'src' pointer on top/bottom area:
  43746 	if (*SmoothParams)(unsafe.Pointer(p)).Frow >= 0 && (*SmoothParams)(unsafe.Pointer(p)).Frow < (*SmoothParams)(unsafe.Pointer(p)).Fheight-int32(1) {
  43747 		**(**uintptr)(__ccgo_up(p + 16)) += uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride)
  43748 	}
  43749 }
  43750 
  43751 // C documentation
  43752 //
  43753 //	// horizontal accumulation. We use mirror replication of missing pixels, as it's
  43754 //	// a little easier to implement (surprisingly).
  43755 func HFilter(tls *libc.TLS, p uintptr) {
  43756 	var delta, delta1, delta2 uint16_t
  43757 	var in, out uintptr
  43758 	var r, w, x int32
  43759 	var scale uint32_t
  43760 	_, _, _, _, _, _, _, _, _ = delta, delta1, delta2, in, out, r, scale, w, x
  43761 	in = (*SmoothParams)(unsafe.Pointer(p)).Fend
  43762 	out = (*SmoothParams)(unsafe.Pointer(p)).Faverage
  43763 	scale = libc.Uint32FromInt32((*SmoothParams)(unsafe.Pointer(p)).Fscale)
  43764 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43765 	r = (*SmoothParams)(unsafe.Pointer(p)).Fradius
  43766 	x = 0
  43767 	for {
  43768 		if !(x <= r) {
  43769 			break
  43770 		} // left mirroring
  43771 		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))))
  43772 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta) * scale >> int32(FIX))
  43773 		goto _1
  43774 	_1:
  43775 		;
  43776 		x = x + 1
  43777 	}
  43778 	for {
  43779 		if !(x < w-r) {
  43780 			break
  43781 		} // bulk middle run
  43782 		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))))
  43783 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta1) * scale >> int32(FIX))
  43784 		goto _2
  43785 	_2:
  43786 		;
  43787 		x = x + 1
  43788 	}
  43789 	for {
  43790 		if !(x < w) {
  43791 			break
  43792 		} // right mirroring
  43793 		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))))
  43794 		**(**uint16_t)(__ccgo_up(out + uintptr(x)*2)) = uint16(uint32(delta2) * scale >> int32(FIX))
  43795 		goto _3
  43796 	_3:
  43797 		;
  43798 		x = x + 1
  43799 	}
  43800 }
  43801 
  43802 // C documentation
  43803 //
  43804 //	// emit one filtered output row
  43805 func ApplyFilter(tls *libc.TLS, p uintptr) {
  43806 	var average, correction, dst uintptr
  43807 	var c, v, w, x int32
  43808 	_, _, _, _, _, _, _ = average, c, correction, dst, v, w, x
  43809 	average = (*SmoothParams)(unsafe.Pointer(p)).Faverage
  43810 	w = (*SmoothParams)(unsafe.Pointer(p)).Fwidth
  43811 	correction = (*SmoothParams)(unsafe.Pointer(p)).Fcorrection
  43812 	dst = (*SmoothParams)(unsafe.Pointer(p)).Fdst
  43813 	x = 0
  43814 	for {
  43815 		if !(x < w) {
  43816 			break
  43817 		}
  43818 		v = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(x))))
  43819 		if v < (*SmoothParams)(unsafe.Pointer(p)).Fmax && v > (*SmoothParams)(unsafe.Pointer(p)).Fmin {
  43820 			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)))
  43821 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = clip_8b(tls, c)
  43822 		}
  43823 		goto _1
  43824 	_1:
  43825 		;
  43826 		x = x + 1
  43827 	}
  43828 	**(**uintptr)(__ccgo_up(p + 24)) += uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride) // advance output pointer
  43829 }
  43830 
  43831 //------------------------------------------------------------------------------
  43832 // Initialize correction table
  43833 
  43834 func InitCorrectionLUT(tls *libc.TLS, lut uintptr, min_dist int32) {
  43835 	var c, delta, i, max_threshold, threshold1, threshold2, v2, v3 int32
  43836 	_, _, _, _, _, _, _, _ = c, delta, i, max_threshold, threshold1, threshold2, v2, v3
  43837 	// The correction curve is:
  43838 	//   f(x) = x for x <= threshold2
  43839 	//   f(x) = 0 for x >= threshold1
  43840 	// and a linear interpolation for range x=[threshold2, threshold1]
  43841 	// (along with f(-x) = -f(x) symmetry).
  43842 	// Note that: threshold2 = 3/4 * threshold1
  43843 	threshold1 = min_dist << int32(LFIX)
  43844 	threshold2 = int32(3) * threshold1 >> int32(2)
  43845 	max_threshold = threshold2 << DFIX
  43846 	delta = threshold1 - threshold2
  43847 	i = int32(1)
  43848 	for {
  43849 		if !(i <= libc.Int32FromInt32(1)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(LFIX))-libc.Int32FromInt32(1)) {
  43850 			break
  43851 		}
  43852 		if i <= threshold2 {
  43853 			v2 = i << DFIX
  43854 		} else {
  43855 			if i < threshold1 {
  43856 				v3 = max_threshold * (threshold1 - i) / delta
  43857 			} else {
  43858 				v3 = 0
  43859 			}
  43860 			v2 = v3
  43861 		}
  43862 		c = v2
  43863 		c = c >> int32(LFIX)
  43864 		**(**int16_t)(__ccgo_up(lut + uintptr(+i)*2)) = int16(+c)
  43865 		**(**int16_t)(__ccgo_up(lut + uintptr(-i)*2)) = int16(-c)
  43866 		goto _1
  43867 	_1:
  43868 		;
  43869 		i = i + 1
  43870 	}
  43871 	**(**int16_t)(__ccgo_up(lut)) = 0
  43872 }
  43873 
  43874 func CountLevels(tls *libc.TLS, p uintptr) {
  43875 	var data uintptr
  43876 	var i, j, last_level, level_dist, v int32
  43877 	var used_levels [256]uint8_t
  43878 	_, _, _, _, _, _, _ = data, i, j, last_level, level_dist, used_levels, v
  43879 	used_levels = [256]uint8_t{}
  43880 	data = (*SmoothParams)(unsafe.Pointer(p)).Fsrc
  43881 	(*SmoothParams)(unsafe.Pointer(p)).Fmin = int32(255)
  43882 	(*SmoothParams)(unsafe.Pointer(p)).Fmax = 0
  43883 	j = 0
  43884 	for {
  43885 		if !(j < (*SmoothParams)(unsafe.Pointer(p)).Fheight) {
  43886 			break
  43887 		}
  43888 		i = 0
  43889 		for {
  43890 			if !(i < (*SmoothParams)(unsafe.Pointer(p)).Fwidth) {
  43891 				break
  43892 			}
  43893 			v = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(i))))
  43894 			if v < (*SmoothParams)(unsafe.Pointer(p)).Fmin {
  43895 				(*SmoothParams)(unsafe.Pointer(p)).Fmin = v
  43896 			}
  43897 			if v > (*SmoothParams)(unsafe.Pointer(p)).Fmax {
  43898 				(*SmoothParams)(unsafe.Pointer(p)).Fmax = v
  43899 			}
  43900 			used_levels[v] = uint8(1)
  43901 			goto _2
  43902 		_2:
  43903 			;
  43904 			i = i + 1
  43905 		}
  43906 		data = data + uintptr((*SmoothParams)(unsafe.Pointer(p)).Fstride)
  43907 		goto _1
  43908 	_1:
  43909 		;
  43910 		j = j + 1
  43911 	}
  43912 	// Compute the mininum distance between two non-zero levels.
  43913 	(*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist = (*SmoothParams)(unsafe.Pointer(p)).Fmax - (*SmoothParams)(unsafe.Pointer(p)).Fmin
  43914 	last_level = -int32(1)
  43915 	i = 0
  43916 	for {
  43917 		if !(i < int32(256)) {
  43918 			break
  43919 		}
  43920 		if used_levels[i] != 0 {
  43921 			(*SmoothParams)(unsafe.Pointer(p)).Fnum_levels = (*SmoothParams)(unsafe.Pointer(p)).Fnum_levels + 1
  43922 			if last_level >= 0 {
  43923 				level_dist = i - last_level
  43924 				if level_dist < (*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist {
  43925 					(*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist = level_dist
  43926 				}
  43927 			}
  43928 			last_level = i
  43929 		}
  43930 		goto _3
  43931 	_3:
  43932 		;
  43933 		i = i + 1
  43934 	}
  43935 }
  43936 
  43937 // C documentation
  43938 //
  43939 //	// Initialize all params.
  43940 func InitParams(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, radius int32, p uintptr) (r int32) {
  43941 	var R int32
  43942 	var mem uintptr
  43943 	var size_lut, size_m, size_scratch_m, total_size size_t
  43944 	_, _, _, _, _, _ = R, mem, size_lut, size_m, size_scratch_m, total_size
  43945 	R = int32(2)*radius + int32(1) // total size of the kernel
  43946 	size_scratch_m = libc.Uint64FromInt32((R+int32(1))*width) * uint64(2)
  43947 	size_m = libc.Uint64FromInt32(width) * uint64(2)
  43948 	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)
  43949 	total_size = size_scratch_m + size_m + size_lut
  43950 	mem = WebPSafeMalloc(tls, uint64(1), total_size)
  43951 	if mem == libc.UintptrFromInt32(0) {
  43952 		return 0
  43953 	}
  43954 	(*SmoothParams)(unsafe.Pointer(p)).Fmem = mem
  43955 	(*SmoothParams)(unsafe.Pointer(p)).Fstart = mem
  43956 	(*SmoothParams)(unsafe.Pointer(p)).Fcur = (*SmoothParams)(unsafe.Pointer(p)).Fstart
  43957 	(*SmoothParams)(unsafe.Pointer(p)).Fend = (*SmoothParams)(unsafe.Pointer(p)).Fstart + uintptr(R*width)*2
  43958 	(*SmoothParams)(unsafe.Pointer(p)).Ftop = (*SmoothParams)(unsafe.Pointer(p)).Fend - uintptr(width)*2
  43959 	libc.X__builtin___memset_chk(tls, (*SmoothParams)(unsafe.Pointer(p)).Ftop, 0, libc.Uint64FromInt32(width)*uint64(2), ^__predefined_size_t(0))
  43960 	mem = mem + uintptr(size_scratch_m)
  43961 	(*SmoothParams)(unsafe.Pointer(p)).Faverage = mem
  43962 	mem = mem + uintptr(size_m)
  43963 	(*SmoothParams)(unsafe.Pointer(p)).Fwidth = width
  43964 	(*SmoothParams)(unsafe.Pointer(p)).Fheight = height
  43965 	(*SmoothParams)(unsafe.Pointer(p)).Fstride = stride
  43966 	(*SmoothParams)(unsafe.Pointer(p)).Fsrc = data
  43967 	(*SmoothParams)(unsafe.Pointer(p)).Fdst = data
  43968 	(*SmoothParams)(unsafe.Pointer(p)).Fradius = radius
  43969 	(*SmoothParams)(unsafe.Pointer(p)).Fscale = libc.Int32FromInt32(1) << (libc.Int32FromInt32(FIX) + libc.Int32FromInt32(LFIX)) / (R * R) // normalization constant
  43970 	(*SmoothParams)(unsafe.Pointer(p)).Frow = -radius
  43971 	// analyze the input distribution so we can best-fit the threshold
  43972 	CountLevels(tls, p)
  43973 	// correction table
  43974 	(*SmoothParams)(unsafe.Pointer(p)).Fcorrection = mem + uintptr(libc.Int32FromInt32(1)<<(libc.Int32FromInt32(8)+libc.Int32FromInt32(LFIX))-libc.Int32FromInt32(1))*2
  43975 	InitCorrectionLUT(tls, (*SmoothParams)(unsafe.Pointer(p)).Fcorrection, (*SmoothParams)(unsafe.Pointer(p)).Fmin_level_dist)
  43976 	return int32(1)
  43977 }
  43978 
  43979 func CleanupParams(tls *libc.TLS, p uintptr) {
  43980 	WebPSafeFree(tls, (*SmoothParams)(unsafe.Pointer(p)).Fmem)
  43981 }
  43982 
  43983 func WebPDequantizeLevels(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, strength int32) (r int32) {
  43984 	bp := tls.Alloc(112)
  43985 	defer tls.Free(112)
  43986 	var radius int32
  43987 	var _ /* p at bp+0 */ SmoothParams
  43988 	_ = radius
  43989 	radius = int32(4) * strength / int32(100)
  43990 	if strength < 0 || strength > int32(100) {
  43991 		return 0
  43992 	}
  43993 	if data == libc.UintptrFromInt32(0) || width <= 0 || height <= 0 {
  43994 		return 0
  43995 	} // bad params
  43996 	// limit the filter size to not exceed the image dimensions
  43997 	if int32(2)*radius+int32(1) > width {
  43998 		radius = (width - int32(1)) >> int32(1)
  43999 	}
  44000 	if int32(2)*radius+int32(1) > height {
  44001 		radius = (height - int32(1)) >> int32(1)
  44002 	}
  44003 	if radius > 0 {
  44004 		libc.X__builtin___memset_chk(tls, bp, 0, uint64(112), ^__predefined_size_t(0))
  44005 		if !(InitParams(tls, data, width, height, stride, radius, bp) != 0) {
  44006 			return 0
  44007 		}
  44008 		if (**(**SmoothParams)(__ccgo_up(bp))).Fnum_levels > int32(2) {
  44009 			for {
  44010 				if !((**(**SmoothParams)(__ccgo_up(bp))).Frow < (**(**SmoothParams)(__ccgo_up(bp))).Fheight) {
  44011 					break
  44012 				}
  44013 				VFilter(tls, bp) // accumulate average of input
  44014 				// Need to wait few rows in order to prime the filter,
  44015 				// before emitting some output.
  44016 				if (**(**SmoothParams)(__ccgo_up(bp))).Frow >= (**(**SmoothParams)(__ccgo_up(bp))).Fradius {
  44017 					HFilter(tls, bp)
  44018 					ApplyFilter(tls, bp)
  44019 				}
  44020 				goto _1
  44021 			_1:
  44022 				;
  44023 				(**(**SmoothParams)(__ccgo_up(bp))).Frow = (**(**SmoothParams)(__ccgo_up(bp))).Frow + 1
  44024 			}
  44025 		}
  44026 		CleanupParams(tls, bp)
  44027 	}
  44028 	return int32(1)
  44029 }
  44030 
  44031 const ERROR_THRESHOLD = 0.0001
  44032 const MAX_ITER = 6
  44033 const NUM_SYMBOLS = 256
  44034 
  44035 // -----------------------------------------------------------------------------
  44036 // Quantize levels.
  44037 
  44038 func QuantizeLevels(tls *libc.TLS, data uintptr, width int32, height int32, num_levels int32, sse uintptr) (r int32) {
  44039 	bp := tls.Alloc(4096)
  44040 	defer tls.Free(4096)
  44041 	var count, err, err_threshold, error1, last_err float64
  44042 	var data_size, n, n1 size_t
  44043 	var freq, q_level [256]int32
  44044 	var i, iter, max_s, min_s, num_levels_in, s, s1, slot, slot1 int32
  44045 	var inv_q_level [256]float64
  44046 	var map1 [256]uint8_t
  44047 	var _ /* q_count at bp+2048 */ [256]float64
  44048 	var _ /* q_sum at bp+0 */ [256]float64
  44049 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  44050 	freq = [256]int32{}
  44051 	q_level = [256]int32{}
  44052 	inv_q_level = [256]float64{}
  44053 	min_s = int32(255)
  44054 	max_s = 0
  44055 	data_size = libc.Uint64FromInt32(height * width)
  44056 	last_err = float64(1e+38)
  44057 	err = float64(0)
  44058 	err_threshold = float64(float64(0.0001) * float64(data_size))
  44059 	if data == libc.UintptrFromInt32(0) {
  44060 		return 0
  44061 	}
  44062 	if width <= 0 || height <= 0 {
  44063 		return 0
  44064 	}
  44065 	if num_levels < int32(2) || num_levels > int32(256) {
  44066 		return 0
  44067 	}
  44068 	num_levels_in = 0
  44069 	n = uint64(0)
  44070 	for {
  44071 		if !(n < data_size) {
  44072 			break
  44073 		}
  44074 		num_levels_in = num_levels_in + libc.BoolInt32(freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] == 0)
  44075 		if min_s > libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n)))) {
  44076 			min_s = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n))))
  44077 		}
  44078 		if max_s < libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n)))) {
  44079 			max_s = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(data + uintptr(n))))
  44080 		}
  44081 		freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] = freq[**(**uint8_t)(__ccgo_up(data + uintptr(n)))] + 1
  44082 		goto _1
  44083 	_1:
  44084 		;
  44085 		n = n + 1
  44086 	}
  44087 	if num_levels_in <= num_levels {
  44088 		goto End
  44089 	} // nothing to do!
  44090 	// Start with uniformly spread centroids.
  44091 	i = 0
  44092 	for {
  44093 		if !(i < num_levels) {
  44094 			break
  44095 		}
  44096 		inv_q_level[i] = float64(min_s) + float64(float64(max_s-min_s)*float64(i))/float64(num_levels-libc.Int32FromInt32(1))
  44097 		goto _2
  44098 	_2:
  44099 		;
  44100 		i = i + 1
  44101 	}
  44102 	// Fixed values. Won't be changed.
  44103 	q_level[min_s] = 0
  44104 	q_level[max_s] = num_levels - int32(1)
  44105 	// k-Means iterations.
  44106 	iter = 0
  44107 	for {
  44108 		if !(iter < int32(MAX_ITER)) {
  44109 			break
  44110 		}
  44111 		**(**[256]float64)(__ccgo_up(bp)) = [256]float64{}
  44112 		**(**[256]float64)(__ccgo_up(bp + 2048)) = [256]float64{}
  44113 		slot = 0
  44114 		// Assign classes to representatives.
  44115 		s = min_s
  44116 		for {
  44117 			if !(s <= max_s) {
  44118 				break
  44119 			}
  44120 			// Keep track of the nearest neighbour 'slot'
  44121 			for slot < num_levels-int32(1) && float64(int32(2)*s) > inv_q_level[slot]+inv_q_level[slot+int32(1)] {
  44122 				slot = slot + 1
  44123 			}
  44124 			if freq[s] > 0 {
  44125 				**(**float64)(__ccgo_up(bp + uintptr(slot)*8)) += float64(s * freq[s])
  44126 				**(**float64)(__ccgo_up(bp + 2048 + uintptr(slot)*8)) += float64(freq[s])
  44127 			}
  44128 			q_level[s] = slot
  44129 			goto _4
  44130 		_4:
  44131 			;
  44132 			s = s + 1
  44133 		}
  44134 		// Assign new representatives to classes.
  44135 		if num_levels > int32(2) {
  44136 			slot = int32(1)
  44137 			for {
  44138 				if !(slot < num_levels-int32(1)) {
  44139 					break
  44140 				}
  44141 				count = (**(**[256]float64)(__ccgo_up(bp + 2048)))[slot]
  44142 				if count > float64(0) {
  44143 					inv_q_level[slot] = (**(**[256]float64)(__ccgo_up(bp)))[slot] / count
  44144 				}
  44145 				goto _5
  44146 			_5:
  44147 				;
  44148 				slot = slot + 1
  44149 			}
  44150 		}
  44151 		// Compute convergence error.
  44152 		err = float64(0)
  44153 		s = min_s
  44154 		for {
  44155 			if !(s <= max_s) {
  44156 				break
  44157 			}
  44158 			error1 = float64(s) - inv_q_level[q_level[s]]
  44159 			err = err + float64(float64(float64(freq[s])*error1)*error1)
  44160 			goto _6
  44161 		_6:
  44162 			;
  44163 			s = s + 1
  44164 		}
  44165 		// Check for convergence: we stop as soon as the error is no
  44166 		// longer improving.
  44167 		if last_err-err < err_threshold {
  44168 			break
  44169 		}
  44170 		last_err = err
  44171 		goto _3
  44172 	_3:
  44173 		;
  44174 		iter = iter + 1
  44175 	}
  44176 	// Remap the alpha plane to quantized values.
  44177 	s1 = min_s
  44178 	for {
  44179 		if !(s1 <= max_s) {
  44180 			break
  44181 		}
  44182 		slot1 = q_level[s1]
  44183 		map1[s1] = uint8(inv_q_level[slot1] + libc.Float64FromFloat64(0.5))
  44184 		goto _7
  44185 	_7:
  44186 		;
  44187 		s1 = s1 + 1
  44188 	}
  44189 	// Final pass.
  44190 	n1 = uint64(0)
  44191 	for {
  44192 		if !(n1 < data_size) {
  44193 			break
  44194 		}
  44195 		**(**uint8_t)(__ccgo_up(data + uintptr(n1))) = map1[**(**uint8_t)(__ccgo_up(data + uintptr(n1)))]
  44196 		goto _8
  44197 	_8:
  44198 		;
  44199 		n1 = n1 + 1
  44200 	}
  44201 	goto End
  44202 End:
  44203 	;
  44204 	// Store sum of squared error if needed.
  44205 	if sse != libc.UintptrFromInt32(0) {
  44206 		**(**uint64_t)(__ccgo_up(sse)) = uint64(err)
  44207 	}
  44208 	return int32(1)
  44209 }
  44210 
  44211 //------------------------------------------------------------------------------
  44212 
  44213 // C documentation
  44214 //
  44215 //	// 31b-range values
  44216 var kRandomTable = [55]uint32_t{
  44217 	0:  uint32(0x0de15230),
  44218 	1:  uint32(0x03b31886),
  44219 	2:  uint32(0x775faccb),
  44220 	3:  uint32(0x1c88626a),
  44221 	4:  uint32(0x68385c55),
  44222 	5:  uint32(0x14b3b828),
  44223 	6:  uint32(0x4a85fef8),
  44224 	7:  uint32(0x49ddb84b),
  44225 	8:  uint32(0x64fcf397),
  44226 	9:  uint32(0x5c550289),
  44227 	10: uint32(0x4a290000),
  44228 	11: uint32(0x0d7ec1da),
  44229 	12: uint32(0x5940b7ab),
  44230 	13: uint32(0x5492577d),
  44231 	14: uint32(0x4e19ca72),
  44232 	15: uint32(0x38d38c69),
  44233 	16: uint32(0x0c01ee65),
  44234 	17: uint32(0x32a1755f),
  44235 	18: uint32(0x5437f652),
  44236 	19: uint32(0x5abb2c32),
  44237 	20: uint32(0x0faa57b1),
  44238 	21: uint32(0x73f533e7),
  44239 	22: uint32(0x685feeda),
  44240 	23: uint32(0x7563cce2),
  44241 	24: uint32(0x6e990e83),
  44242 	25: uint32(0x4730a7ed),
  44243 	26: uint32(0x4fc0d9c6),
  44244 	27: uint32(0x496b153c),
  44245 	28: uint32(0x4f1403fa),
  44246 	29: uint32(0x541afb0c),
  44247 	30: uint32(0x73990b32),
  44248 	31: uint32(0x26d7cb1c),
  44249 	32: uint32(0x6fcc3706),
  44250 	33: uint32(0x2cbb77d8),
  44251 	34: uint32(0x75762f2a),
  44252 	35: uint32(0x6425ccdd),
  44253 	36: uint32(0x24b35461),
  44254 	37: uint32(0x0a7d8715),
  44255 	38: uint32(0x220414a8),
  44256 	39: uint32(0x141ebf67),
  44257 	40: uint32(0x56b41583),
  44258 	41: uint32(0x73e502e3),
  44259 	42: uint32(0x44cab16f),
  44260 	43: uint32(0x28264d42),
  44261 	44: uint32(0x73baaefb),
  44262 	45: uint32(0x0a50ebed),
  44263 	46: uint32(0x1d6ab6fb),
  44264 	47: uint32(0x0d3ad40b),
  44265 	48: uint32(0x35db3b68),
  44266 	49: uint32(0x2b081e83),
  44267 	50: uint32(0x77ce6b95),
  44268 	51: uint32(0x5181e5f0),
  44269 	52: uint32(0x78853bbc),
  44270 	53: uint32(0x009f9494),
  44271 	54: uint32(0x27e5ed3c),
  44272 }
  44273 
  44274 func VP8InitRandom(tls *libc.TLS, rg uintptr, dithering float32) {
  44275 	var v1, v2 uint32
  44276 	_, _ = v1, v2
  44277 	libc.X__builtin___memcpy_chk(tls, rg+8, uintptr(unsafe.Pointer(&kRandomTable)), uint64(220), ^__predefined_size_t(0))
  44278 	(*VP8Random)(unsafe.Pointer(rg)).Findex1 = 0
  44279 	(*VP8Random)(unsafe.Pointer(rg)).Findex2 = int32(31)
  44280 	if float64(dithering) < float64(0) {
  44281 		v1 = uint32(0)
  44282 	} else {
  44283 		if float64(dithering) > float64(1) {
  44284 			v2 = libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX))
  44285 		} else {
  44286 			v2 = uint32(float32(float32(libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_RANDOM_DITHER_FIX)) * dithering))
  44287 		}
  44288 		v1 = v2
  44289 	}
  44290 	(*VP8Random)(unsafe.Pointer(rg)).Famp = libc.Int32FromUint32(v1)
  44291 }
  44292 
  44293 const __INT_MAX__3 = 2147483647
  44294 
  44295 //------------------------------------------------------------------------------
  44296 
  44297 //------------------------------------------------------------------------------
  44298 
  44299 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) {
  44300 	var den, num, ratio, total_size, v1 uint64_t
  44301 	var x_add, x_sub, y_add, y_sub, v2 int32
  44302 	_, _, _, _, _, _, _, _, _, _ = den, num, ratio, total_size, x_add, x_sub, y_add, y_sub, v1, v2
  44303 	x_add = src_width
  44304 	x_sub = dst_width
  44305 	y_add = src_height
  44306 	y_sub = dst_height
  44307 	total_size = uint64(2) * libc.Uint64FromInt32(dst_width) * libc.Uint64FromInt32(num_channels) * uint64(4)
  44308 	v1 = total_size
  44309 	v2 = libc.BoolInt32(v1 == v1)
  44310 	goto _3
  44311 _3:
  44312 	if !(v2 != 0) {
  44313 		return 0
  44314 	}
  44315 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand = libc.BoolInt32(src_width < dst_width)
  44316 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand = libc.BoolInt32(src_height < dst_height)
  44317 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_width = src_width
  44318 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_height = src_height
  44319 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_width = dst_width
  44320 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_height = dst_height
  44321 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fsrc_y = 0
  44322 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_y = 0
  44323 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst = dst
  44324 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fdst_stride = dst_stride
  44325 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fnum_channels = num_channels
  44326 	// for 'x_expand', we use bilinear interpolation
  44327 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0 {
  44328 		v2 = x_sub - int32(1)
  44329 	} else {
  44330 		v2 = x_add
  44331 	}
  44332 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_add = v2
  44333 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0 {
  44334 		v2 = x_add - int32(1)
  44335 	} else {
  44336 		v2 = x_sub
  44337 	}
  44338 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_sub = v2
  44339 	if !((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_expand != 0) { // fx_scale is not used otherwise
  44340 		(*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))
  44341 	}
  44342 	// vertical scaling parameters
  44343 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44344 		v2 = y_add - int32(1)
  44345 	} else {
  44346 		v2 = y_add
  44347 	}
  44348 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add = v2
  44349 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44350 		v2 = y_sub - int32(1)
  44351 	} else {
  44352 		v2 = y_sub
  44353 	}
  44354 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub = v2
  44355 	if (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0 {
  44356 		v2 = (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub
  44357 	} else {
  44358 		v2 = (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add
  44359 	}
  44360 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_accum = v2
  44361 	if !((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_expand != 0) {
  44362 		// This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
  44363 		// Its value is <= WEBP_RESCALER_ONE, because dst_height <= rescaler->y_add
  44364 		// and rescaler->x_add >= 1;
  44365 		num = libc.Uint64FromInt32(dst_height) * (libc.Uint64FromUint64(1) << libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  44366 		den = libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fx_add) * libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_add)
  44367 		ratio = num / den
  44368 		if ratio != uint64(uint32(ratio)) {
  44369 			// When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
  44370 			// current fixed-point precision. This happens when src_height ==
  44371 			// rescaler->y_add (which == src_height), and rescaler->x_add == 1.
  44372 			// => We special-case fxy_scale = 0, in WebPRescalerExportRow().
  44373 			(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffxy_scale = uint32(0)
  44374 		} else {
  44375 			(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffxy_scale = uint32(ratio)
  44376 		}
  44377 		(*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))
  44378 	} else {
  44379 		(*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))
  44380 		// rescaler->fxy_scale is unused here.
  44381 	}
  44382 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Firow = work
  44383 	(*WebPRescaler)(unsafe.Pointer(rescaler)).Ffrow = work + uintptr(num_channels*dst_width)*4
  44384 	libc.X__builtin___memset_chk(tls, work, 0, total_size, ^__predefined_size_t(0))
  44385 	WebPRescalerDspInit(tls)
  44386 	return int32(1)
  44387 }
  44388 
  44389 func WebPRescalerGetScaledDimensions(tls *libc.TLS, src_width int32, src_height int32, scaled_width uintptr, scaled_height uintptr) (r int32) {
  44390 	var height, max_size, width int32
  44391 	_, _, _ = height, max_size, width
  44392 	width = **(**int32)(__ccgo_up(scaled_width))
  44393 	height = **(**int32)(__ccgo_up(scaled_height))
  44394 	max_size = libc.Int32FromInt32(__INT_MAX__3) / libc.Int32FromInt32(2)
  44395 	// if width is unspecified, scale original proportionally to height ratio.
  44396 	if width == 0 && src_height > 0 {
  44397 		width = libc.Int32FromUint64((libc.Uint64FromInt32(src_width)*libc.Uint64FromInt32(height) + libc.Uint64FromInt32(src_height) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt32(src_height))
  44398 	}
  44399 	// if height is unspecified, scale original proportionally to width ratio.
  44400 	if height == 0 && src_width > 0 {
  44401 		height = libc.Int32FromUint64((libc.Uint64FromInt32(src_height)*libc.Uint64FromInt32(width) + libc.Uint64FromInt32(src_width) - libc.Uint64FromInt32(1)) / libc.Uint64FromInt32(src_width))
  44402 	}
  44403 	// Check if the overall dimensions still make sense.
  44404 	if width <= 0 || height <= 0 || width > max_size || height > max_size {
  44405 		return 0
  44406 	}
  44407 	**(**int32)(__ccgo_up(scaled_width)) = width
  44408 	**(**int32)(__ccgo_up(scaled_height)) = height
  44409 	return int32(1)
  44410 	return r
  44411 }
  44412 
  44413 //------------------------------------------------------------------------------
  44414 // all-in-one calls
  44415 
  44416 func WebPRescaleNeededLines(tls *libc.TLS, rescaler uintptr, max_num_lines int32) (r int32) {
  44417 	var num_lines, v1 int32
  44418 	_, _ = num_lines, v1
  44419 	num_lines = ((*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_accum + (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub - int32(1)) / (*WebPRescaler)(unsafe.Pointer(rescaler)).Fy_sub
  44420 	if num_lines > max_num_lines {
  44421 		v1 = max_num_lines
  44422 	} else {
  44423 		v1 = num_lines
  44424 	}
  44425 	return v1
  44426 }
  44427 
  44428 func WebPRescalerImport(tls *libc.TLS, rescaler2 uintptr, num_lines int32, src uintptr, src_stride int32) (r int32) {
  44429 	var tmp, v1, v4 uintptr
  44430 	var total_imported, x, v2, v5 int32
  44431 	var v7 bool
  44432 	_, _, _, _, _, _, _, _ = tmp, total_imported, x, v1, v2, v4, v5, v7
  44433 	total_imported = 0
  44434 	for {
  44435 		if v7 = total_imported < num_lines; v7 {
  44436 			v1 = rescaler2
  44437 			v4 = v1
  44438 			v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  44439 			goto _6
  44440 		_6:
  44441 			;
  44442 			v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  44443 			goto _3
  44444 		_3:
  44445 		}
  44446 		if !(v7 && !(v2 != 0)) {
  44447 			break
  44448 		}
  44449 		if (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_expand != 0 {
  44450 			tmp = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow
  44451 			(*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow
  44452 			(*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow = tmp
  44453 		}
  44454 		WebPRescalerImportRow(tls, rescaler2, src)
  44455 		if !((*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_expand != 0) {
  44456 			x = 0
  44457 			for {
  44458 				if !(x < (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fnum_channels*(*WebPRescaler)(unsafe.Pointer(rescaler2)).Fdst_width) {
  44459 					break
  44460 				}
  44461 				**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(rescaler2)).Firow + uintptr(x)*4)) += **(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(rescaler2)).Ffrow + uintptr(x)*4))
  44462 				goto _8
  44463 			_8:
  44464 				;
  44465 				x = x + 1
  44466 			}
  44467 		}
  44468 		(*WebPRescaler)(unsafe.Pointer(rescaler2)).Fsrc_y = (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fsrc_y + 1
  44469 		src = src + uintptr(src_stride)
  44470 		total_imported = total_imported + 1
  44471 		**(**int32)(__ccgo_up(rescaler2 + 24)) -= (*WebPRescaler)(unsafe.Pointer(rescaler2)).Fy_sub
  44472 	}
  44473 	return total_imported
  44474 }
  44475 
  44476 func WebPRescalerExport(tls *libc.TLS, rescaler2 uintptr) (r int32) {
  44477 	var total_exported, v2, v5 int32
  44478 	var v1, v4 uintptr
  44479 	_, _, _, _, _ = total_exported, v1, v2, v4, v5
  44480 	total_exported = 0
  44481 	for {
  44482 		v1 = rescaler2
  44483 		v4 = v1
  44484 		v5 = libc.BoolInt32((*WebPRescaler)(unsafe.Pointer(v4)).Fdst_y >= (*WebPRescaler)(unsafe.Pointer(v4)).Fdst_height)
  44485 		goto _6
  44486 	_6:
  44487 		;
  44488 		v2 = libc.BoolInt32(!(v5 != 0) && (*WebPRescaler)(unsafe.Pointer(v1)).Fy_accum <= 0)
  44489 		goto _3
  44490 	_3:
  44491 		if !(v2 != 0) {
  44492 			break
  44493 		}
  44494 		WebPRescalerExportRow(tls, rescaler2)
  44495 		total_exported = total_exported + 1
  44496 	}
  44497 	return total_exported
  44498 }
  44499 
  44500 const __INT_MAX__4 = 0x7fffffff
  44501 
  44502 //------------------------------------------------------------------------------
  44503 
  44504 //------------------------------------------------------------------------------
  44505 
  44506 func Init(tls *libc.TLS, worker uintptr) {
  44507 	libc.X__builtin___memset_chk(tls, worker, 0, uint64(48), ^__predefined_size_t(0))
  44508 	(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(NOT_OK)
  44509 }
  44510 
  44511 func Sync(tls *libc.TLS, worker uintptr) (r int32) {
  44512 	return libc.BoolInt32(!((*WebPWorker)(unsafe.Pointer(worker)).Fhad_error != 0))
  44513 }
  44514 
  44515 func Reset(tls *libc.TLS, worker uintptr) (r int32) {
  44516 	var ok int32
  44517 	_ = ok
  44518 	ok = int32(1)
  44519 	(*WebPWorker)(unsafe.Pointer(worker)).Fhad_error = 0
  44520 	if (*WebPWorker)(unsafe.Pointer(worker)).Fstatus < int32(OK) {
  44521 		(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(OK)
  44522 	} else {
  44523 		if (*WebPWorker)(unsafe.Pointer(worker)).Fstatus > int32(OK) {
  44524 			ok = Sync(tls, worker)
  44525 		}
  44526 	}
  44527 	return ok
  44528 }
  44529 
  44530 func Execute(tls *libc.TLS, worker uintptr) {
  44531 	if (*WebPWorker)(unsafe.Pointer(worker)).Fhook != libc.UintptrFromInt32(0) {
  44532 		**(**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))
  44533 	}
  44534 }
  44535 
  44536 func Launch(tls *libc.TLS, worker uintptr) {
  44537 	Execute(tls, worker)
  44538 }
  44539 
  44540 func End(tls *libc.TLS, worker uintptr) {
  44541 	(*WebPWorker)(unsafe.Pointer(worker)).Fstatus = int32(NOT_OK)
  44542 }
  44543 
  44544 //------------------------------------------------------------------------------
  44545 
  44546 var g_worker_interface = WebPWorkerInterface{}
  44547 
  44548 func init() {
  44549 	p := unsafe.Pointer(&g_worker_interface)
  44550 	*(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(Init)
  44551 	*(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(Reset)
  44552 	*(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(Sync)
  44553 	*(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(Launch)
  44554 	*(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(Execute)
  44555 	*(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(End)
  44556 }
  44557 
  44558 func WebPSetWorkerInterface(tls *libc.TLS, winterface uintptr) (r int32) {
  44559 	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) {
  44560 		return 0
  44561 	}
  44562 	g_worker_interface = **(**WebPWorkerInterface)(__ccgo_up(winterface))
  44563 	return int32(1)
  44564 }
  44565 
  44566 func WebPGetWorkerInterface(tls *libc.TLS) (r uintptr) {
  44567 	return uintptr(unsafe.Pointer(&g_worker_interface))
  44568 }
  44569 
  44570 //------------------------------------------------------------------------------
  44571 
  44572 // If PRINT_MEM_INFO is defined, extra info (like total memory used, number of
  44573 // alloc/free etc) is printed. For debugging/tuning purpose only (it's slow,
  44574 // and not multi-thread safe!).
  44575 // An interesting alternative is valgrind's 'massif' tool:
  44576 //    https://valgrind.org/docs/manual/ms-manual.html
  44577 // Here is an example command line:
  44578 /*    valgrind --tool=massif --massif-out-file=massif.out                --stacks=yes --alloc-fn=WebPSafeMalloc --alloc-fn=WebPSafeCalloc
  44579       ms_print massif.out
  44580 */
  44581 // In addition:
  44582 // * if PRINT_MEM_TRAFFIC is defined, all the details of the malloc/free cycles
  44583 //   are printed.
  44584 // * if MALLOC_FAIL_AT is defined, the global environment variable
  44585 //   $MALLOC_FAIL_AT is used to simulate a memory error when calloc or malloc
  44586 //   is called for the nth time. Example usage:
  44587 //   export MALLOC_FAIL_AT=50 && ./examples/cwebp input.png
  44588 // * if MALLOC_LIMIT is defined, the global environment variable $MALLOC_LIMIT
  44589 //   sets the maximum amount of memory (in bytes) made available to libwebp.
  44590 //   This can be used to emulate environment with very limited memory.
  44591 //   Example: export MALLOC_LIMIT=64000000 && ./examples/dwebp picture.webp
  44592 
  44593 // #define PRINT_MEM_INFO
  44594 // #define PRINT_MEM_TRAFFIC
  44595 // #define MALLOC_FAIL_AT
  44596 // #define MALLOC_LIMIT
  44597 
  44598 //------------------------------------------------------------------------------
  44599 // Checked memory allocation
  44600 
  44601 // C documentation
  44602 //
  44603 //	// Returns 0 in case of overflow of nmemb * size.
  44604 func CheckSizeArgumentsOverflow(tls *libc.TLS, nmemb uint64_t, size1 size_t) (r int32) {
  44605 	var total_size, v1 uint64_t
  44606 	var v2 int32
  44607 	_, _, _ = total_size, v1, v2
  44608 	total_size = nmemb * size1
  44609 	if nmemb == uint64(0) {
  44610 		return int32(1)
  44611 	}
  44612 	if size1 > libc.Uint64FromUint64(1)<<libc.Int32FromInt32(34)/nmemb {
  44613 		return 0
  44614 	}
  44615 	v1 = total_size
  44616 	v2 = libc.BoolInt32(v1 == v1)
  44617 	goto _3
  44618 _3:
  44619 	if !(v2 != 0) {
  44620 		return 0
  44621 	}
  44622 	return int32(1)
  44623 }
  44624 
  44625 func WebPSafeMalloc(tls *libc.TLS, nmemb uint64_t, size size_t) (r uintptr) {
  44626 	var ptr uintptr
  44627 	_ = ptr
  44628 	if !(CheckSizeArgumentsOverflow(tls, nmemb, size) != 0) {
  44629 		return libc.UintptrFromInt32(0)
  44630 	}
  44631 	ptr = libc.Xmalloc(tls, nmemb*size)
  44632 	return ptr
  44633 }
  44634 
  44635 func WebPSafeCalloc(tls *libc.TLS, nmemb uint64_t, size size_t) (r uintptr) {
  44636 	var ptr uintptr
  44637 	_ = ptr
  44638 	if !(CheckSizeArgumentsOverflow(tls, nmemb, size) != 0) {
  44639 		return libc.UintptrFromInt32(0)
  44640 	}
  44641 	ptr = libc.Xcalloc(tls, nmemb, size)
  44642 	return ptr
  44643 }
  44644 
  44645 func WebPSafeFree(tls *libc.TLS, ptr uintptr) {
  44646 	if ptr != libc.UintptrFromInt32(0) {
  44647 	}
  44648 	libc.Xfree(tls, ptr)
  44649 }
  44650 
  44651 // Public API functions.
  44652 
  44653 func WebPMalloc(tls *libc.TLS, size size_t) (r uintptr) {
  44654 	return WebPSafeMalloc(tls, uint64(1), size)
  44655 }
  44656 
  44657 func WebPFree(tls *libc.TLS, ptr uintptr) {
  44658 	WebPSafeFree(tls, ptr)
  44659 }
  44660 
  44661 //------------------------------------------------------------------------------
  44662 
  44663 func WebPCopyPlane(tls *libc.TLS, src uintptr, src_stride int32, dst uintptr, dst_stride int32, width int32, height int32) {
  44664 	var v1 int32
  44665 	_ = v1
  44666 	for {
  44667 		v1 = height
  44668 		height = height - 1
  44669 		if !(v1 > 0) {
  44670 			break
  44671 		}
  44672 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(width), ^__predefined_size_t(0))
  44673 		src = src + uintptr(src_stride)
  44674 		dst = dst + uintptr(dst_stride)
  44675 	}
  44676 }
  44677 
  44678 func WebPCopyPixels(tls *libc.TLS, src uintptr, dst uintptr) {
  44679 	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)
  44680 }
  44681 
  44682 //------------------------------------------------------------------------------
  44683 
  44684 func WebPGetColorPalette(tls *libc.TLS, pic uintptr, palette uintptr) (r int32) {
  44685 	return GetColorPalette(tls, pic, palette)
  44686 }
  44687 
  44688 const USE_TABLES_FOR_ALPHA_MULT = 0
  44689 
  44690 // Copyright 2010 Google Inc. All Rights Reserved.
  44691 //
  44692 // Use of this source code is governed by a BSD-style license
  44693 // that can be found in the COPYING file in the root of the source
  44694 // tree. An additional intellectual property rights grant can be found
  44695 // in the file PATENTS. All contributing project authors may
  44696 // be found in the AUTHORS file in the root of the source tree.
  44697 // -----------------------------------------------------------------------------
  44698 //
  44699 //  Common types + memory wrappers
  44700 //
  44701 // Author: Skal (pascal.massimino@gmail.com)
  44702 
  44703 // Tables can be faster on some platform but incur some extra binary size (~2k).
  44704 
  44705 // -----------------------------------------------------------------------------
  44706 
  44707 func Mult(tls *libc.TLS, x uint8_t, mult uint32_t) (r uint32_t) {
  44708 	var v uint32_t
  44709 	_ = v
  44710 	v = (uint32(x)*mult + libc.Uint32FromUint32(1)<<libc.Int32FromInt32(24)>>libc.Int32FromInt32(1)) >> int32(24)
  44711 	// <- 24bit precision is enough to ensure that.
  44712 	return v
  44713 }
  44714 
  44715 func GetScale(tls *libc.TLS, a uint32_t, inverse int32) (r uint32_t) {
  44716 	var v1 uint32
  44717 	_ = v1
  44718 	if inverse != 0 {
  44719 		v1 = libc.Uint32FromUint32(255) << libc.Int32FromInt32(24) / a
  44720 	} else {
  44721 		v1 = a * (libc.Uint32FromUint32(1) << libc.Int32FromInt32(24) / libc.Uint32FromUint32(255))
  44722 	}
  44723 	return v1
  44724 }
  44725 
  44726 func WebPMultARGBRow_C(tls *libc.TLS, ptr uintptr, width int32, inverse int32) {
  44727 	var alpha, argb, out, scale uint32_t
  44728 	var x int32
  44729 	_, _, _, _, _ = alpha, argb, out, scale, x
  44730 	x = 0
  44731 	for {
  44732 		if !(x < width) {
  44733 			break
  44734 		}
  44735 		argb = **(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4))
  44736 		if argb < uint32(0xff000000) { // alpha < 255
  44737 			if argb <= uint32(0x00ffffff) { // alpha == 0
  44738 				**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = uint32(0)
  44739 			} else {
  44740 				alpha = argb >> libc.Int32FromInt32(24) & uint32(0xff)
  44741 				scale = GetScale(tls, alpha, inverse)
  44742 				out = argb & uint32(0xff000000)
  44743 				out = out | Mult(tls, uint8(argb>>0), scale)<<0
  44744 				out = out | Mult(tls, uint8(argb>>int32(8)), scale)<<int32(8)
  44745 				out = out | Mult(tls, uint8(argb>>int32(16)), scale)<<int32(16)
  44746 				**(**uint32_t)(__ccgo_up(ptr + uintptr(x)*4)) = out
  44747 			}
  44748 		}
  44749 		goto _1
  44750 	_1:
  44751 		;
  44752 		x = x + 1
  44753 	}
  44754 }
  44755 
  44756 func WebPMultRow_C(tls *libc.TLS, ptr uintptr, alpha uintptr, width int32, inverse int32) {
  44757 	var a, scale uint32_t
  44758 	var x int32
  44759 	_, _, _ = a, scale, x
  44760 	x = 0
  44761 	for {
  44762 		if !(x < width) {
  44763 			break
  44764 		}
  44765 		a = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(x))))
  44766 		if a != uint32(255) {
  44767 			if a == uint32(0) {
  44768 				**(**uint8_t)(__ccgo_up(ptr + uintptr(x))) = uint8(0)
  44769 			} else {
  44770 				scale = GetScale(tls, a, inverse)
  44771 				**(**uint8_t)(__ccgo_up(ptr + uintptr(x))) = uint8(Mult(tls, **(**uint8_t)(__ccgo_up(ptr + uintptr(x))), scale))
  44772 			}
  44773 		}
  44774 		goto _1
  44775 	_1:
  44776 		;
  44777 		x = x + 1
  44778 	}
  44779 }
  44780 
  44781 //------------------------------------------------------------------------------
  44782 // Generic per-plane calls
  44783 
  44784 func WebPMultARGBRows(tls *libc.TLS, ptr uintptr, stride int32, width int32, num_rows int32, inverse int32) {
  44785 	var n int32
  44786 	_ = n
  44787 	n = 0
  44788 	for {
  44789 		if !(n < num_rows) {
  44790 			break
  44791 		}
  44792 		(*(*func(*libc.TLS, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultARGBRow})))(tls, ptr, width, inverse)
  44793 		ptr = ptr + uintptr(stride)
  44794 		goto _1
  44795 	_1:
  44796 		;
  44797 		n = n + 1
  44798 	}
  44799 }
  44800 
  44801 func WebPMultRows(tls *libc.TLS, ptr uintptr, stride int32, alpha uintptr, alpha_stride int32, width int32, num_rows int32, inverse int32) {
  44802 	var n int32
  44803 	_ = n
  44804 	n = 0
  44805 	for {
  44806 		if !(n < num_rows) {
  44807 			break
  44808 		}
  44809 		(*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPMultRow})))(tls, ptr, alpha, width, inverse)
  44810 		ptr = ptr + uintptr(stride)
  44811 		alpha = alpha + uintptr(alpha_stride)
  44812 		goto _1
  44813 	_1:
  44814 		;
  44815 		n = n + 1
  44816 	}
  44817 }
  44818 
  44819 //------------------------------------------------------------------------------
  44820 // Premultiplied modes
  44821 
  44822 // non dithered-modes
  44823 
  44824 // (x * a * 32897) >> 23 is bit-wise equivalent to (int)(x * a / 255.)
  44825 // for all 8bit x or a. For bit-wise equivalence to (int)(x * a / 255. + .5),
  44826 // one can use instead: (x * a * 65793 + (1 << 23)) >> 24
  44827 
  44828 func ApplyAlphaMultiply_C(tls *libc.TLS, rgba uintptr, alpha_first int32, w int32, h int32, stride int32) {
  44829 	var a, mult uint32_t
  44830 	var alpha, rgb uintptr
  44831 	var i, v1, v2, v3 int32
  44832 	_, _, _, _, _, _, _, _ = a, alpha, i, mult, rgb, v1, v2, v3
  44833 	for {
  44834 		v1 = h
  44835 		h = h - 1
  44836 		if !(v1 > 0) {
  44837 			break
  44838 		}
  44839 		if alpha_first != 0 {
  44840 			v2 = int32(1)
  44841 		} else {
  44842 			v2 = 0
  44843 		}
  44844 		rgb = rgba + uintptr(v2)
  44845 		if alpha_first != 0 {
  44846 			v3 = 0
  44847 		} else {
  44848 			v3 = int32(3)
  44849 		}
  44850 		alpha = rgba + uintptr(v3)
  44851 		i = 0
  44852 		for {
  44853 			if !(i < w) {
  44854 				break
  44855 			}
  44856 			a = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(int32(4)*i))))
  44857 			if a != uint32(0xff) {
  44858 				mult = a * libc.Uint32FromUint32(32897)
  44859 				**(**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))
  44860 				**(**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))
  44861 				**(**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))
  44862 			}
  44863 			goto _4
  44864 		_4:
  44865 			;
  44866 			i = i + 1
  44867 		}
  44868 		rgba = rgba + uintptr(stride)
  44869 	}
  44870 }
  44871 
  44872 // rgbA4444
  44873 
  44874 func dither_hi(tls *libc.TLS, x uint8_t) (r uint8_t) {
  44875 	return libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0xf0) | libc.Int32FromUint8(x)>>int32(4))
  44876 }
  44877 
  44878 func dither_lo(tls *libc.TLS, x uint8_t) (r uint8_t) {
  44879 	return libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0x0f) | libc.Int32FromUint8(x)<<int32(4))
  44880 }
  44881 
  44882 func multiply(tls *libc.TLS, x uint8_t, m uint32_t) (r uint8_t) {
  44883 	return uint8(uint32(x) * m >> int32(16))
  44884 }
  44885 
  44886 func ApplyAlphaMultiply4444_C(tls *libc.TLS, rgba4444 uintptr, w int32, h int32, stride int32, rg_byte_pos int32) {
  44887 	var a, b, g, r uint8_t
  44888 	var ba, mult, rg uint32_t
  44889 	var i, v1 int32
  44890 	_, _, _, _, _, _, _, _, _ = a, b, ba, g, i, mult, r, rg, v1
  44891 	for {
  44892 		v1 = h
  44893 		h = h - 1
  44894 		if !(v1 > 0) {
  44895 			break
  44896 		}
  44897 		i = 0
  44898 		for {
  44899 			if !(i < w) {
  44900 				break
  44901 			}
  44902 			rg = uint32(**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+rg_byte_pos))))
  44903 			ba = uint32(**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+(rg_byte_pos^int32(1))))))
  44904 			a = uint8(ba & uint32(0x0f))
  44905 			mult = libc.Uint32FromInt32(libc.Int32FromUint8(a) * libc.Int32FromInt32(0x1111))
  44906 			r = multiply(tls, dither_hi(tls, uint8(rg)), mult)
  44907 			g = multiply(tls, dither_lo(tls, uint8(rg)), mult)
  44908 			b = multiply(tls, dither_hi(tls, uint8(ba)), mult)
  44909 			**(**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))
  44910 			**(**uint8_t)(__ccgo_up(rgba4444 + uintptr(int32(2)*i+(rg_byte_pos^int32(1))))) = libc.Uint8FromInt32(libc.Int32FromUint8(b)&int32(0xf0) | libc.Int32FromUint8(a))
  44911 			goto _2
  44912 		_2:
  44913 			;
  44914 			i = i + 1
  44915 		}
  44916 		rgba4444 = rgba4444 + uintptr(stride)
  44917 	}
  44918 }
  44919 
  44920 func ApplyAlphaMultiply_16b_C(tls *libc.TLS, rgba4444 uintptr, w int32, h int32, stride int32) {
  44921 	ApplyAlphaMultiply4444_C(tls, rgba4444, w, h, stride, 0)
  44922 }
  44923 
  44924 func DispatchAlpha_C(tls *libc.TLS, alpha uintptr, alpha_stride int32, width int32, height int32, dst uintptr, dst_stride int32) (r int32) {
  44925 	var alpha_mask, alpha_value uint32_t
  44926 	var i, j int32
  44927 	_, _, _, _ = alpha_mask, alpha_value, i, j
  44928 	alpha_mask = uint32(0xff)
  44929 	j = 0
  44930 	for {
  44931 		if !(j < height) {
  44932 			break
  44933 		}
  44934 		i = 0
  44935 		for {
  44936 			if !(i < width) {
  44937 				break
  44938 			}
  44939 			alpha_value = uint32(**(**uint8_t)(__ccgo_up(alpha + uintptr(i))))
  44940 			**(**uint8_t)(__ccgo_up(dst + uintptr(int32(4)*i))) = uint8(alpha_value)
  44941 			alpha_mask = alpha_mask & alpha_value
  44942 			goto _2
  44943 		_2:
  44944 			;
  44945 			i = i + 1
  44946 		}
  44947 		alpha = alpha + uintptr(alpha_stride)
  44948 		dst = dst + uintptr(dst_stride)
  44949 		goto _1
  44950 	_1:
  44951 		;
  44952 		j = j + 1
  44953 	}
  44954 	return libc.BoolInt32(alpha_mask != uint32(0xff))
  44955 }
  44956 
  44957 func DispatchAlphaToGreen_C(tls *libc.TLS, alpha uintptr, alpha_stride int32, width int32, height int32, dst uintptr, dst_stride int32) {
  44958 	var i, j int32
  44959 	_, _ = i, j
  44960 	j = 0
  44961 	for {
  44962 		if !(j < height) {
  44963 			break
  44964 		}
  44965 		i = 0
  44966 		for {
  44967 			if !(i < width) {
  44968 				break
  44969 			}
  44970 			**(**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.
  44971 			goto _2
  44972 		_2:
  44973 			;
  44974 			i = i + 1
  44975 		}
  44976 		alpha = alpha + uintptr(alpha_stride)
  44977 		dst = dst + uintptr(dst_stride)*4
  44978 		goto _1
  44979 	_1:
  44980 		;
  44981 		j = j + 1
  44982 	}
  44983 }
  44984 
  44985 func ExtractAlpha_C(tls *libc.TLS, argb uintptr, argb_stride int32, width int32, height int32, alpha uintptr, alpha_stride int32) (r int32) {
  44986 	var alpha_mask, alpha_value uint8_t
  44987 	var i, j int32
  44988 	_, _, _, _ = alpha_mask, alpha_value, i, j
  44989 	alpha_mask = uint8(0xff)
  44990 	j = 0
  44991 	for {
  44992 		if !(j < height) {
  44993 			break
  44994 		}
  44995 		i = 0
  44996 		for {
  44997 			if !(i < width) {
  44998 				break
  44999 			}
  45000 			alpha_value = **(**uint8_t)(__ccgo_up(argb + uintptr(int32(4)*i)))
  45001 			**(**uint8_t)(__ccgo_up(alpha + uintptr(i))) = alpha_value
  45002 			alpha_mask = libc.Uint8FromInt32(int32(alpha_mask) & libc.Int32FromUint8(alpha_value))
  45003 			goto _2
  45004 		_2:
  45005 			;
  45006 			i = i + 1
  45007 		}
  45008 		argb = argb + uintptr(argb_stride)
  45009 		alpha = alpha + uintptr(alpha_stride)
  45010 		goto _1
  45011 	_1:
  45012 		;
  45013 		j = j + 1
  45014 	}
  45015 	return libc.BoolInt32(libc.Int32FromUint8(alpha_mask) == int32(0xff))
  45016 }
  45017 
  45018 func ExtractGreen_C(tls *libc.TLS, argb uintptr, alpha uintptr, size int32) {
  45019 	var i int32
  45020 	_ = i
  45021 	i = 0
  45022 	for {
  45023 		if !(i < size) {
  45024 			break
  45025 		}
  45026 		**(**uint8_t)(__ccgo_up(alpha + uintptr(i))) = uint8(**(**uint32_t)(__ccgo_up(argb + uintptr(i)*4)) >> int32(8))
  45027 		goto _1
  45028 	_1:
  45029 		;
  45030 		i = i + 1
  45031 	}
  45032 }
  45033 
  45034 //------------------------------------------------------------------------------
  45035 
  45036 func HasAlpha8b_C(tls *libc.TLS, src uintptr, length int32) (r int32) {
  45037 	var v1 int32
  45038 	var v2 uintptr
  45039 	_, _ = v1, v2
  45040 	for {
  45041 		v1 = length
  45042 		length = length - 1
  45043 		if !(v1 > 0) {
  45044 			break
  45045 		}
  45046 		v2 = src
  45047 		src = src + 1
  45048 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v2))) != int32(0xff) {
  45049 			return int32(1)
  45050 		}
  45051 	}
  45052 	return 0
  45053 }
  45054 
  45055 func HasAlpha32b_C(tls *libc.TLS, src uintptr, length int32) (r int32) {
  45056 	var x, v2 int32
  45057 	_, _ = x, v2
  45058 	x = 0
  45059 	for {
  45060 		v2 = length
  45061 		length = length - 1
  45062 		if !(v2 > 0) {
  45063 			break
  45064 		}
  45065 		if libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + uintptr(x)))) != int32(0xff) {
  45066 			return int32(1)
  45067 		}
  45068 		goto _1
  45069 	_1:
  45070 		;
  45071 		x = x + int32(4)
  45072 	}
  45073 	return 0
  45074 }
  45075 
  45076 func AlphaReplace_C(tls *libc.TLS, src uintptr, length int32, color uint32_t) {
  45077 	var x int32
  45078 	_ = x
  45079 	x = 0
  45080 	for {
  45081 		if !(x < length) {
  45082 			break
  45083 		}
  45084 		if **(**uint32_t)(__ccgo_up(src + uintptr(x)*4))>>libc.Int32FromInt32(24) == uint32(0) {
  45085 			**(**uint32_t)(__ccgo_up(src + uintptr(x)*4)) = color
  45086 		}
  45087 		goto _1
  45088 	_1:
  45089 		;
  45090 		x = x + 1
  45091 	}
  45092 }
  45093 
  45094 //------------------------------------------------------------------------------
  45095 // Simple channel manipulations.
  45096 
  45097 func MakeARGB321(tls *libc.TLS, a int32, r int32, g int32, b int32) (r1 uint32_t) {
  45098 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  45099 }
  45100 
  45101 func PackRGB_C(tls *libc.TLS, r uintptr, g uintptr, b uintptr, len1 int32, step int32, out uintptr) {
  45102 	var i, offset int32
  45103 	_, _ = i, offset
  45104 	offset = 0
  45105 	i = 0
  45106 	for {
  45107 		if !(i < len1) {
  45108 			break
  45109 		}
  45110 		**(**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)))))
  45111 		offset = offset + step
  45112 		goto _1
  45113 	_1:
  45114 		;
  45115 		i = i + 1
  45116 	}
  45117 }
  45118 
  45119 func WebPInitAlphaProcessing(tls *libc.TLS) {
  45120 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  45121 		goto _1
  45122 	}
  45123 	WebPInitAlphaProcessing_body(tls)
  45124 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used)), VP8GetCPUInfo)
  45125 	goto _2
  45126 _2:
  45127 	;
  45128 	goto _1
  45129 _1: /**/ //
  45130 }
  45131 
  45132 var WebPInitAlphaProcessing_body_last_cpuinfo_used = uintptr(0)
  45133 
  45134 func init() {
  45135 	p := unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used)
  45136 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitAlphaProcessing_body_last_cpuinfo_used))
  45137 }
  45138 
  45139 func WebPInitAlphaProcessing_body(tls *libc.TLS) {
  45140 	WebPMultARGBRow = __ccgo_fp(WebPMultARGBRow_C)
  45141 	WebPMultRow = __ccgo_fp(WebPMultRow_C)
  45142 	WebPApplyAlphaMultiply4444 = __ccgo_fp(ApplyAlphaMultiply_16b_C)
  45143 	WebPPackRGB = __ccgo_fp(PackRGB_C)
  45144 	WebPApplyAlphaMultiply = __ccgo_fp(ApplyAlphaMultiply_C)
  45145 	WebPDispatchAlpha = __ccgo_fp(DispatchAlpha_C)
  45146 	WebPDispatchAlphaToGreen = __ccgo_fp(DispatchAlphaToGreen_C)
  45147 	WebPExtractAlpha = __ccgo_fp(ExtractAlpha_C)
  45148 	WebPExtractGreen = __ccgo_fp(ExtractGreen_C)
  45149 	WebPHasAlpha8b = __ccgo_fp(HasAlpha8b_C)
  45150 	WebPHasAlpha32b = __ccgo_fp(HasAlpha32b_C)
  45151 	WebPAlphaReplace = __ccgo_fp(AlphaReplace_C)
  45152 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  45153 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  45154 	}
  45155 }
  45156 
  45157 func WebPInitAlphaProcessingMIPSdspR2(tls *libc.TLS) {
  45158 }
  45159 
  45160 func WebPInitAlphaProcessingNEON(tls *libc.TLS) {
  45161 }
  45162 
  45163 func WebPInitAlphaProcessingSSE2(tls *libc.TLS) {
  45164 }
  45165 
  45166 func WebPInitAlphaProcessingSSE41(tls *libc.TLS) {
  45167 }
  45168 
  45169 //------------------------------------------------------------------------------
  45170 // Mode costs
  45171 
  45172 func GetResidualCost_C(tls *libc.TLS, ctx0 int32, res uintptr) (r int32) {
  45173 	var b, cost, ctx, ctx1, last_p0, n, p0, v, v1, v11, v3, v5, v7, v9 int32
  45174 	var costs CostArrayPtr
  45175 	var t uintptr
  45176 	var v2, v6 uint8_t
  45177 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, cost, costs, ctx, ctx1, last_p0, n, p0, t, v, v1, v11, v2, v3, v5, v6, v7, v9
  45178 	n = (*VP8Residual)(unsafe.Pointer(res)).Ffirst
  45179 	// should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
  45180 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(n)*33 + uintptr(ctx0)*11)))
  45181 	costs = (*VP8Residual)(unsafe.Pointer(res)).Fcosts
  45182 	t = **(**uintptr)(__ccgo_up(costs + uintptr(n)*24 + uintptr(ctx0)*8))
  45183 	if ctx0 == 0 {
  45184 		v2 = libc.Uint8FromInt32(p0)
  45185 		if !(int32(1) != 0) {
  45186 			v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  45187 		} else {
  45188 			v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  45189 		}
  45190 		v3 = v5
  45191 		goto _4
  45192 	_4:
  45193 		v11 = v3
  45194 	} else {
  45195 		v11 = 0
  45196 	}
  45197 	// bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
  45198 	// (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
  45199 	// be missing during the loop.
  45200 	cost = v11
  45201 	if (*VP8Residual)(unsafe.Pointer(res)).Flast < 0 {
  45202 		v6 = libc.Uint8FromInt32(p0)
  45203 		if !(0 != 0) {
  45204 			v9 = libc.Int32FromUint16(VP8EntropyCost[v6])
  45205 		} else {
  45206 			v9 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v6)])
  45207 		}
  45208 		v7 = v9
  45209 		goto _8
  45210 	_8:
  45211 		return v7
  45212 	}
  45213 	for {
  45214 		if !(n < (*VP8Residual)(unsafe.Pointer(res)).Flast) {
  45215 			break
  45216 		}
  45217 		v = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(n)*2))))
  45218 		if v >= int32(2) {
  45219 			v11 = int32(2)
  45220 		} else {
  45221 			v11 = v
  45222 		}
  45223 		ctx = v11
  45224 		v3 = v
  45225 		if v3 > int32(MAX_VARIABLE_LEVEL) {
  45226 			v7 = int32(MAX_VARIABLE_LEVEL)
  45227 		} else {
  45228 			v7 = v3
  45229 		}
  45230 		v5 = libc.Int32FromUint16(VP8LevelFixedCosts[v3]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(t + uintptr(v7)*2)))
  45231 		goto _14
  45232 	_14:
  45233 		cost = cost + v5
  45234 		t = **(**uintptr)(__ccgo_up(costs + uintptr(n+int32(1))*24 + uintptr(ctx)*8))
  45235 		goto _10
  45236 	_10:
  45237 		;
  45238 		n = n + 1
  45239 	}
  45240 	// Last coefficient is always non-zero
  45241 	v1 = libc.Xabs(tls, int32(**(**int16_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fcoeffs + uintptr(n)*2))))
  45242 	v11 = v1
  45243 	if v11 > int32(MAX_VARIABLE_LEVEL) {
  45244 		v5 = int32(MAX_VARIABLE_LEVEL)
  45245 	} else {
  45246 		v5 = v11
  45247 	}
  45248 	v3 = libc.Int32FromUint16(VP8LevelFixedCosts[v11]) + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(t + uintptr(v5)*2)))
  45249 	goto _18
  45250 _18:
  45251 	cost = cost + v3
  45252 	if n < int32(15) {
  45253 		b = libc.Int32FromUint8(VP8EncBands[n+int32(1)])
  45254 		if v1 == int32(1) {
  45255 			v11 = int32(1)
  45256 		} else {
  45257 			v11 = int32(2)
  45258 		}
  45259 		ctx1 = v11
  45260 		last_p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up((*VP8Residual)(unsafe.Pointer(res)).Fprob + uintptr(b)*33 + uintptr(ctx1)*11)))
  45261 		v2 = libc.Uint8FromInt32(last_p0)
  45262 		if !(0 != 0) {
  45263 			v5 = libc.Int32FromUint16(VP8EntropyCost[v2])
  45264 		} else {
  45265 			v5 = libc.Int32FromUint16(VP8EntropyCost[int32(255)-libc.Int32FromUint8(v2)])
  45266 		}
  45267 		v3 = v5
  45268 		goto _23
  45269 	_23:
  45270 		cost = cost + v3
  45271 	}
  45272 	return cost
  45273 }
  45274 
  45275 func SetResidualCoeffs_C(tls *libc.TLS, coeffs uintptr, res uintptr) {
  45276 	var n int32
  45277 	_ = n
  45278 	(*VP8Residual)(unsafe.Pointer(res)).Flast = -int32(1)
  45279 	n = int32(15)
  45280 	for {
  45281 		if !(n >= 0) {
  45282 			break
  45283 		}
  45284 		if **(**int16_t)(__ccgo_up(coeffs + uintptr(n)*2)) != 0 {
  45285 			(*VP8Residual)(unsafe.Pointer(res)).Flast = n
  45286 			break
  45287 		}
  45288 		goto _1
  45289 	_1:
  45290 		;
  45291 		n = n - 1
  45292 	}
  45293 	(*VP8Residual)(unsafe.Pointer(res)).Fcoeffs = coeffs
  45294 }
  45295 
  45296 func VP8EncDspCostInit(tls *libc.TLS) {
  45297 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  45298 		goto _1
  45299 	}
  45300 	VP8EncDspCostInit_body(tls)
  45301 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  45302 	goto _2
  45303 _2:
  45304 	;
  45305 	goto _1
  45306 _1: /**/ //
  45307 }
  45308 
  45309 var VP8EncDspCostInit_body_last_cpuinfo_used = uintptr(0)
  45310 
  45311 func init() {
  45312 	p := unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used)
  45313 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8EncDspCostInit_body_last_cpuinfo_used))
  45314 }
  45315 
  45316 func VP8EncDspCostInit_body(tls *libc.TLS) {
  45317 	VP8GetResidualCost = __ccgo_fp(GetResidualCost_C)
  45318 	VP8SetResidualCoeffs = __ccgo_fp(SetResidualCoeffs_C)
  45319 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  45320 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  45321 	}
  45322 }
  45323 
  45324 func VP8EncDspCostInitMIPS32(tls *libc.TLS) {
  45325 }
  45326 
  45327 func VP8EncDspCostInitMIPSdspR2(tls *libc.TLS) {
  45328 }
  45329 
  45330 func VP8EncDspCostInitNEON(tls *libc.TLS) {
  45331 }
  45332 
  45333 func VP8EncDspCostInitSSE2(tls *libc.TLS) {
  45334 }
  45335 
  45336 /*===---- __stddef_wchar.h - Definition of wchar_t -------------------------===
  45337  *
  45338  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45339  * See https://llvm.org/LICENSE.txt for license information.
  45340  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45341  *
  45342  *===-----------------------------------------------------------------------===
  45343  */
  45344 
  45345 /*
  45346  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45347  * and needs to behave as if it was textual.
  45348  */
  45349 
  45350 /*===---- __stddef_nullptr_t.h - Definition of nullptr_t -------------------===
  45351  *
  45352  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45353  * See https://llvm.org/LICENSE.txt for license information.
  45354  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45355  *
  45356  *===-----------------------------------------------------------------------===
  45357  */
  45358 
  45359 /*
  45360  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45361  * and needs to behave as if it was textual.
  45362  */
  45363 
  45364 /*===---- __stddef_unreachable.h - Definition of unreachable ---------------===
  45365  *
  45366  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45367  * See https://llvm.org/LICENSE.txt for license information.
  45368  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45369  *
  45370  *===-----------------------------------------------------------------------===
  45371  */
  45372 
  45373 /*
  45374  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45375  * and needs to behave as if it was textual.
  45376  */
  45377 
  45378 /*===---- __stddef_max_align_t.h - Definition of max_align_t ---------------===
  45379  *
  45380  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45381  * See https://llvm.org/LICENSE.txt for license information.
  45382  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45383  *
  45384  *===-----------------------------------------------------------------------===
  45385  */
  45386 
  45387 /*===---- __stddef_offsetof.h - Definition of offsetof ---------------------===
  45388  *
  45389  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  45390  * See https://llvm.org/LICENSE.txt for license information.
  45391  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  45392  *
  45393  *===-----------------------------------------------------------------------===
  45394  */
  45395 
  45396 /*
  45397  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  45398  * and needs to behave as if it was textual.
  45399  */
  45400 
  45401 /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
  45402 __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
  45403 
  45404 // Copyright 2010 Google Inc. All Rights Reserved.
  45405 //
  45406 // Use of this source code is governed by a BSD-style license
  45407 // that can be found in the COPYING file in the root of the source
  45408 // tree. An additional intellectual property rights grant can be found
  45409 // in the file PATENTS. All contributing project authors may
  45410 // be found in the AUTHORS file in the root of the source tree.
  45411 // -----------------------------------------------------------------------------
  45412 //
  45413 //  Common types + memory wrappers
  45414 //
  45415 // Author: Skal (pascal.massimino@gmail.com)
  45416 
  45417 //------------------------------------------------------------------------------
  45418 // SSE2 detection.
  45419 //
  45420 
  45421 // C documentation
  45422 //
  45423 //	// apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC.
  45424 func GetCPUInfo(tls *libc.TLS, cpu_info uintptr, info_type int32) {
  45425 	//   __asm__ volatile (
  45426 	//     "cpuid\n"
  45427 	//     : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
  45428 	//     : "a"(info_type), "c"(0));
  45429 	libc.X__assert_fail(tls, __ccgo_ts+594, __ccgo_ts+629, 45, __ccgo_ts+635)
  45430 }
  45431 
  45432 // C documentation
  45433 //
  45434 //	// NaCl has no support for xgetbv or the raw opcode.
  45435 func xgetbv(tls *libc.TLS) (r uint64_t) {
  45436 	var eax, ecx, edx uint32_t
  45437 	_, _, _ = eax, ecx, edx
  45438 	ecx = uint32(0)
  45439 	// Use the raw opcode for xgetbv for compatibility with older toolchains.
  45440 	//   // Use the raw opcode for xgetbv for compatibility with older toolchains.
  45441 	//   __asm__ volatile (
  45442 	//     ".byte 0x0f, 0x01, 0xd0\n"
  45443 	//     : "=a"(eax), "=d"(edx) : "c" (ecx));
  45444 	libc.X__assert_fail(tls, __ccgo_ts+594, __ccgo_ts+629, 70, __ccgo_ts+646)
  45445 	return uint64(edx)<<libc.Int32FromInt32(32) | uint64(eax)
  45446 }
  45447 
  45448 // C documentation
  45449 //
  45450 //	// helper function for run-time detection of slow SSSE3 platforms
  45451 func CheckSlowModel(tls *libc.TLS, info int32) (r int32) {
  45452 	var family, model uint32_t
  45453 	var i size_t
  45454 	_, _, _ = family, i, model
  45455 	model = libc.Uint32FromInt32(info&int32(0xf0000)>>int32(12) | info>>int32(4)&int32(0xf))
  45456 	family = libc.Uint32FromInt32(info >> int32(8) & int32(0xf))
  45457 	if family == uint32(0x06) {
  45458 		i = uint64(0)
  45459 		for {
  45460 			if !(i < libc.Uint64FromInt64(6)/libc.Uint64FromInt64(1)) {
  45461 				break
  45462 			}
  45463 			if model == uint32(kSlowModels[i]) {
  45464 				return int32(1)
  45465 			}
  45466 			goto _1
  45467 		_1:
  45468 			;
  45469 			i = i + 1
  45470 		}
  45471 	}
  45472 	return 0
  45473 }
  45474 
  45475 // Table listing display models with longer latencies for the bsr instruction
  45476 // (ie 2 cycles vs 10/16 cycles) and some SSSE3 instructions like pshufb.
  45477 // Refer to Intel 64 and IA-32 Architectures Optimization Reference Manual.
  45478 var kSlowModels = [6]uint8_t{
  45479 	0: uint8(0x37),
  45480 	1: uint8(0x4a),
  45481 	2: uint8(0x4d),
  45482 	3: uint8(0x1c),
  45483 	4: uint8(0x26),
  45484 	5: uint8(0x27),
  45485 }
  45486 
  45487 func x86CPUInfo(tls *libc.TLS, feature CPUFeature) (r int32) {
  45488 	bp := tls.Alloc(16)
  45489 	defer tls.Free(16)
  45490 	var VENDOR_ID_INTEL_EBX, VENDOR_ID_INTEL_ECX, VENDOR_ID_INTEL_EDX, is_intel, max_cpuid_value int32
  45491 	var _ /* cpu_info at bp+0 */ [4]int32
  45492 	_, _, _, _, _ = VENDOR_ID_INTEL_EBX, VENDOR_ID_INTEL_ECX, VENDOR_ID_INTEL_EDX, is_intel, max_cpuid_value
  45493 	is_intel = 0
  45494 	// get the highest feature value cpuid supports
  45495 	GetCPUInfo(tls, bp, 0)
  45496 	max_cpuid_value = (**(**[4]int32)(__ccgo_up(bp)))[0]
  45497 	if max_cpuid_value < int32(1) {
  45498 		return 0
  45499 	} else {
  45500 		VENDOR_ID_INTEL_EBX = int32(0x756e6547)                                                                                                                                                                                             // uneG
  45501 		VENDOR_ID_INTEL_EDX = int32(0x49656e69)                                                                                                                                                                                             // Ieni
  45502 		VENDOR_ID_INTEL_ECX = int32(0x6c65746e)                                                                                                                                                                                             // letn
  45503 		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?
  45504 	}
  45505 	GetCPUInfo(tls, bp, int32(1))
  45506 	if feature == int32(kSSE2) {
  45507 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(3)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(26)) != 0))
  45508 	}
  45509 	if feature == int32(kSSE3) {
  45510 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(0)) != 0))
  45511 	}
  45512 	if feature == int32(kSlowSSSE3) {
  45513 		if is_intel != 0 && (**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(9)) != 0 { // SSSE3?
  45514 			return CheckSlowModel(tls, (**(**[4]int32)(__ccgo_up(bp)))[0])
  45515 		}
  45516 		return 0
  45517 	}
  45518 	if feature == int32(kSSE4_1) {
  45519 		return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(19)) != 0))
  45520 	}
  45521 	if feature == int32(kAVX) {
  45522 		// bits 27 (OSXSAVE) & 28 (256-bit AVX)
  45523 		if (**(**[4]int32)(__ccgo_up(bp)))[int32(2)]&int32(0x18000000) == int32(0x18000000) {
  45524 			// XMM state and YMM state enabled by the OS.
  45525 			return libc.BoolInt32(xgetbv(tls)&uint64(0x6) == uint64(0x6))
  45526 		}
  45527 	}
  45528 	if feature == int32(kAVX2) {
  45529 		if x86CPUInfo(tls, int32(kAVX)) != 0 && max_cpuid_value >= int32(7) {
  45530 			GetCPUInfo(tls, bp, int32(7))
  45531 			return libc.BoolInt32(!!((**(**[4]int32)(__ccgo_up(bp)))[int32(1)]&(libc.Int32FromInt32(1)<<libc.Int32FromInt32(5)) != 0))
  45532 		}
  45533 	}
  45534 	return 0
  45535 }
  45536 
  45537 func init() {
  45538 	p := unsafe.Pointer(&VP8GetCPUInfo)
  45539 	*(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(x86CPUInfo)
  45540 }
  45541 
  45542 var kHashMul14 = uint32(0x1e35a7bd)
  45543 
  45544 //------------------------------------------------------------------------------
  45545 
  45546 // Copyright 2010 Google Inc. All Rights Reserved.
  45547 //
  45548 // Use of this source code is governed by a BSD-style license
  45549 // that can be found in the COPYING file in the root of the source
  45550 // tree. An additional intellectual property rights grant can be found
  45551 // in the file PATENTS. All contributing project authors may
  45552 // be found in the AUTHORS file in the root of the source tree.
  45553 // -----------------------------------------------------------------------------
  45554 //
  45555 //  Common types + memory wrappers
  45556 //
  45557 // Author: Skal (pascal.massimino@gmail.com)
  45558 
  45559 //------------------------------------------------------------------------------
  45560 
  45561 func clip_8b1(tls *libc.TLS, v int32) (r uint8_t) {
  45562 	var v1, v2 int32
  45563 	_, _ = v1, v2
  45564 	if !(v & ^libc.Int32FromInt32(0xff) != 0) {
  45565 		v1 = v
  45566 	} else {
  45567 		if v < 0 {
  45568 			v2 = 0
  45569 		} else {
  45570 			v2 = int32(255)
  45571 		}
  45572 		v1 = v2
  45573 	}
  45574 	return libc.Uint8FromInt32(v1)
  45575 }
  45576 
  45577 //------------------------------------------------------------------------------
  45578 // Transforms (Paragraph 14.4)
  45579 
  45580 func TransformOne_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45581 	bp := tls.Alloc(64)
  45582 	defer tls.Free(64)
  45583 	var a, a1, b, b1, c, c1, d, d1, dc, i int32
  45584 	var tmp uintptr
  45585 	var _ /* C at bp+0 */ [16]int32
  45586 	_, _, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, c, c1, d, d1, dc, i, tmp
  45587 	tmp = bp
  45588 	i = 0
  45589 	for {
  45590 		if !(i < int32(4)) {
  45591 			break
  45592 		} // vertical pass
  45593 		a = int32(**(**int16_t)(__ccgo_up(in))) + int32(**(**int16_t)(__ccgo_up(in + 8*2)))                                                                                                                                       // [-4096, 4094]
  45594 		b = int32(**(**int16_t)(__ccgo_up(in))) - int32(**(**int16_t)(__ccgo_up(in + 8*2)))                                                                                                                                       // [-4095, 4095]
  45595 		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]
  45596 		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]
  45597 		**(**int32)(__ccgo_up(tmp)) = a + d                                                                                                                                                                                       // [-7881, 7875]
  45598 		**(**int32)(__ccgo_up(tmp + 1*4)) = b + c                                                                                                                                                                                 // [-7878, 7878]
  45599 		**(**int32)(__ccgo_up(tmp + 2*4)) = b - c                                                                                                                                                                                 // [-7878, 7878]
  45600 		**(**int32)(__ccgo_up(tmp + 3*4)) = a - d                                                                                                                                                                                 // [-7877, 7879]
  45601 		tmp = tmp + uintptr(4)*4
  45602 		in += 2
  45603 		goto _1
  45604 	_1:
  45605 		;
  45606 		i = i + 1
  45607 	}
  45608 	// Each pass is expanding the dynamic range by ~3.85 (upper bound).
  45609 	// The exact value is (2. + (20091 + 35468) / 65536).
  45610 	// After the second pass, maximum interval is [-3794, 3794], assuming
  45611 	// an input in [-2048, 2047] interval. We then need to add a dst value
  45612 	// in the [0, 255] range.
  45613 	// In the worst case scenario, the input to clip_8b() can be as large as
  45614 	// [-60713, 60968].
  45615 	tmp = bp
  45616 	i = 0
  45617 	for {
  45618 		if !(i < int32(4)) {
  45619 			break
  45620 		} // horizontal pass
  45621 		dc = **(**int32)(__ccgo_up(tmp)) + int32(4)
  45622 		a1 = dc + **(**int32)(__ccgo_up(tmp + 8*4))
  45623 		b1 = dc - **(**int32)(__ccgo_up(tmp + 8*4))
  45624 		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)))
  45625 		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)
  45626 		**(**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))
  45627 		**(**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))
  45628 		**(**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))
  45629 		**(**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))
  45630 		tmp += 4
  45631 		dst = dst + uintptr(BPS)
  45632 		goto _2
  45633 	_2:
  45634 		;
  45635 		i = i + 1
  45636 	}
  45637 }
  45638 
  45639 // C documentation
  45640 //
  45641 //	// Simplified transform when only in[0], in[1] and in[4] are non-zero
  45642 func TransformAC3_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45643 	var DC, DC1, DC2, DC3, a, c1, c4, d1, d4 int32
  45644 	_, _, _, _, _, _, _, _, _ = DC, DC1, DC2, DC3, a, c1, c4, d1, d4
  45645 	a = int32(**(**int16_t)(__ccgo_up(in))) + int32(4)
  45646 	c4 = int32(**(**int16_t)(__ccgo_up(in + 4*2))) * libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C2) >> libc.Int32FromInt32(16)
  45647 	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)))
  45648 	c1 = int32(**(**int16_t)(__ccgo_up(in + 1*2))) * libc.Int32FromInt32(WEBP_TRANSFORM_AC3_C2) >> libc.Int32FromInt32(16)
  45649 	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)))
  45650 	DC = a + d4
  45651 	**(**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))
  45652 	**(**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))
  45653 	**(**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))
  45654 	**(**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))
  45655 	DC1 = a + c4
  45656 	**(**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))
  45657 	**(**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))
  45658 	**(**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))
  45659 	**(**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))
  45660 	DC2 = a - c4
  45661 	**(**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))
  45662 	**(**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))
  45663 	**(**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))
  45664 	**(**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))
  45665 	DC3 = a - d4
  45666 	**(**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))
  45667 	**(**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))
  45668 	**(**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))
  45669 	**(**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))
  45670 }
  45671 
  45672 func TransformTwo_C(tls *libc.TLS, in uintptr, dst uintptr, do_two int32) {
  45673 	TransformOne_C(tls, in, dst)
  45674 	if do_two != 0 {
  45675 		TransformOne_C(tls, in+uintptr(16)*2, dst+uintptr(4))
  45676 	}
  45677 }
  45678 
  45679 func TransformUV_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45680 	(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{VP8Transform})))(tls, in+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, dst, int32(1))
  45681 	(*(*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))
  45682 }
  45683 
  45684 func TransformDC_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45685 	var DC, i, j int32
  45686 	_, _, _ = DC, i, j
  45687 	DC = int32(**(**int16_t)(__ccgo_up(in))) + int32(4)
  45688 	j = 0
  45689 	for {
  45690 		if !(j < int32(4)) {
  45691 			break
  45692 		}
  45693 		i = 0
  45694 		for {
  45695 			if !(i < int32(4)) {
  45696 				break
  45697 			}
  45698 			**(**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))
  45699 			goto _2
  45700 		_2:
  45701 			;
  45702 			i = i + 1
  45703 		}
  45704 		goto _1
  45705 	_1:
  45706 		;
  45707 		j = j + 1
  45708 	}
  45709 }
  45710 
  45711 func TransformDCUV_C(tls *libc.TLS, in uintptr, dst uintptr) {
  45712 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2)) != 0 {
  45713 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16))*2, dst)
  45714 	}
  45715 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2)) != 0 {
  45716 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8TransformDC})))(tls, in+uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16))*2, dst+uintptr(4))
  45717 	}
  45718 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16))*2)) != 0 {
  45719 		(*(*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)))
  45720 	}
  45721 	if **(**int16_t)(__ccgo_up(in + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16))*2)) != 0 {
  45722 		(*(*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))
  45723 	}
  45724 }
  45725 
  45726 //------------------------------------------------------------------------------
  45727 // Paragraph 14.3
  45728 
  45729 func TransformWHT_C(tls *libc.TLS, in uintptr, out uintptr) {
  45730 	var a0, a01, a1, a11, a2, a21, a3, a31, dc, i int32
  45731 	var tmp [16]int32
  45732 	_, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, dc, i, tmp
  45733 	i = 0
  45734 	for {
  45735 		if !(i < int32(4)) {
  45736 			break
  45737 		}
  45738 		a0 = int32(**(**int16_t)(__ccgo_up(in + uintptr(0+i)*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(12)+i)*2)))
  45739 		a1 = int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(4)+i)*2))) + int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(8)+i)*2)))
  45740 		a2 = int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(4)+i)*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(8)+i)*2)))
  45741 		a3 = int32(**(**int16_t)(__ccgo_up(in + uintptr(0+i)*2))) - int32(**(**int16_t)(__ccgo_up(in + uintptr(int32(12)+i)*2)))
  45742 		tmp[0+i] = a0 + a1
  45743 		tmp[int32(8)+i] = a0 - a1
  45744 		tmp[int32(4)+i] = a3 + a2
  45745 		tmp[int32(12)+i] = a3 - a2
  45746 		goto _1
  45747 	_1:
  45748 		;
  45749 		i = i + 1
  45750 	}
  45751 	i = 0
  45752 	for {
  45753 		if !(i < int32(4)) {
  45754 			break
  45755 		}
  45756 		dc = tmp[0+i*int32(4)] + int32(3) // w/ rounder
  45757 		a01 = dc + tmp[int32(3)+i*int32(4)]
  45758 		a11 = tmp[int32(1)+i*int32(4)] + tmp[int32(2)+i*int32(4)]
  45759 		a21 = tmp[int32(1)+i*int32(4)] - tmp[int32(2)+i*int32(4)]
  45760 		a31 = dc - tmp[int32(3)+i*int32(4)]
  45761 		**(**int16_t)(__ccgo_up(out)) = int16((a01 + a11) >> int32(3))
  45762 		**(**int16_t)(__ccgo_up(out + 16*2)) = int16((a31 + a21) >> int32(3))
  45763 		**(**int16_t)(__ccgo_up(out + 32*2)) = int16((a01 - a11) >> int32(3))
  45764 		**(**int16_t)(__ccgo_up(out + 48*2)) = int16((a31 - a21) >> int32(3))
  45765 		out = out + uintptr(64)*2
  45766 		goto _2
  45767 	_2:
  45768 		;
  45769 		i = i + 1
  45770 	}
  45771 }
  45772 
  45773 //------------------------------------------------------------------------------
  45774 // Intra predictions
  45775 
  45776 func TrueMotion(tls *libc.TLS, dst uintptr, size int32) {
  45777 	var clip, clip0, top uintptr
  45778 	var x, y int32
  45779 	_, _, _, _, _ = clip, clip0, top, x, y
  45780 	top = dst - uintptr(BPS)
  45781 	clip0 = VP8kclip1 - uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  45782 	y = 0
  45783 	for {
  45784 		if !(y < size) {
  45785 			break
  45786 		}
  45787 		clip = clip0 + uintptr(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)))))
  45788 		x = 0
  45789 		for {
  45790 			if !(x < size) {
  45791 				break
  45792 			}
  45793 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  45794 			goto _2
  45795 		_2:
  45796 			;
  45797 			x = x + 1
  45798 		}
  45799 		dst = dst + uintptr(BPS)
  45800 		goto _1
  45801 	_1:
  45802 		;
  45803 		y = y + 1
  45804 	}
  45805 }
  45806 
  45807 func TM4_C(tls *libc.TLS, dst uintptr) {
  45808 	TrueMotion(tls, dst, int32(4))
  45809 }
  45810 
  45811 func TM8uv_C(tls *libc.TLS, dst uintptr) {
  45812 	TrueMotion(tls, dst, int32(8))
  45813 }
  45814 
  45815 func TM16_C(tls *libc.TLS, dst uintptr) {
  45816 	TrueMotion(tls, dst, int32(16))
  45817 }
  45818 
  45819 //------------------------------------------------------------------------------
  45820 // 16x16
  45821 
  45822 func VE16_C(tls *libc.TLS, dst uintptr) {
  45823 	var j int32
  45824 	_ = j
  45825 	j = 0
  45826 	for {
  45827 		if !(j < int32(16)) {
  45828 			break
  45829 		}
  45830 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), dst-uintptr(BPS), uint64(16), ^__predefined_size_t(0))
  45831 		goto _1
  45832 	_1:
  45833 		;
  45834 		j = j + 1
  45835 	}
  45836 }
  45837 
  45838 func HE16_C(tls *libc.TLS, dst uintptr) {
  45839 	var j int32
  45840 	_ = j
  45841 	j = int32(16)
  45842 	for {
  45843 		if !(j > 0) {
  45844 			break
  45845 		}
  45846 		libc.X__builtin___memset_chk(tls, dst, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1))))), uint64(16), ^__predefined_size_t(0))
  45847 		dst = dst + uintptr(BPS)
  45848 		goto _1
  45849 	_1:
  45850 		;
  45851 		j = j - 1
  45852 	}
  45853 }
  45854 
  45855 func Put16(tls *libc.TLS, v int32, dst uintptr) {
  45856 	var j int32
  45857 	_ = j
  45858 	j = 0
  45859 	for {
  45860 		if !(j < int32(16)) {
  45861 			break
  45862 		}
  45863 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), v, uint64(16), ^__predefined_size_t(0))
  45864 		goto _1
  45865 	_1:
  45866 		;
  45867 		j = j + 1
  45868 	}
  45869 }
  45870 
  45871 func DC16_C(tls *libc.TLS, dst uintptr) {
  45872 	var DC, j int32
  45873 	_, _ = DC, j // DC
  45874 	DC = int32(16)
  45875 	j = 0
  45876 	for {
  45877 		if !(j < int32(16)) {
  45878 			break
  45879 		}
  45880 		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))))))
  45881 		goto _1
  45882 	_1:
  45883 		;
  45884 		j = j + 1
  45885 	}
  45886 	Put16(tls, DC>>int32(5), dst)
  45887 }
  45888 
  45889 func DC16NoTop_C(tls *libc.TLS, dst uintptr) {
  45890 	var DC, j int32
  45891 	_, _ = DC, j // DC with top samples not available
  45892 	DC = int32(8)
  45893 	j = 0
  45894 	for {
  45895 		if !(j < int32(16)) {
  45896 			break
  45897 		}
  45898 		DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+j*int32(BPS)))))
  45899 		goto _1
  45900 	_1:
  45901 		;
  45902 		j = j + 1
  45903 	}
  45904 	Put16(tls, DC>>int32(4), dst)
  45905 }
  45906 
  45907 func DC16NoLeft_C(tls *libc.TLS, dst uintptr) {
  45908 	var DC, i int32
  45909 	_, _ = DC, i // DC with left samples not available
  45910 	DC = int32(8)
  45911 	i = 0
  45912 	for {
  45913 		if !(i < int32(16)) {
  45914 			break
  45915 		}
  45916 		DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS)))))
  45917 		goto _1
  45918 	_1:
  45919 		;
  45920 		i = i + 1
  45921 	}
  45922 	Put16(tls, DC>>int32(4), dst)
  45923 }
  45924 
  45925 func DC16NoTopLeft_C(tls *libc.TLS, dst uintptr) {
  45926 	// DC with no top and left samples
  45927 	Put16(tls, int32(0x80), dst)
  45928 }
  45929 
  45930 //------------------------------------------------------------------------------
  45931 // 4x4
  45932 
  45933 func VE4_C(tls *libc.TLS, dst uintptr) {
  45934 	bp := tls.Alloc(16)
  45935 	defer tls.Free(16)
  45936 	var i int32
  45937 	var top uintptr
  45938 	var _ /* vals at bp+0 */ [4]uint8_t
  45939 	_, _ = i, top // vertical
  45940 	top = dst - uintptr(BPS)
  45941 	**(**[4]uint8_t)(__ccgo_up(bp)) = [4]uint8_t{
  45942 		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)),
  45943 		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)),
  45944 		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)),
  45945 		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)),
  45946 	}
  45947 	i = 0
  45948 	for {
  45949 		if !(i < int32(4)) {
  45950 			break
  45951 		}
  45952 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(i*int32(BPS)), bp, uint64(4), ^__predefined_size_t(0))
  45953 		goto _1
  45954 	_1:
  45955 		;
  45956 		i = i + 1
  45957 	}
  45958 }
  45959 
  45960 func HE4_C(tls *libc.TLS, dst uintptr) {
  45961 	bp := tls.Alloc(16)
  45962 	defer tls.Free(16)
  45963 	var A, B, C, D, E int32
  45964 	var v1 uintptr
  45965 	var v2 uint32_t
  45966 	_, _, _, _, _, _, _ = A, B, C, D, E, v1, v2 // horizontal
  45967 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  45968 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)))))
  45969 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(BPS)))))
  45970 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  45971 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  45972 	v1 = dst + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS))
  45973 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((A+libc.Int32FromInt32(2)*B+C+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45974 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45975 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45976 	v1 = dst + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS))
  45977 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((B+libc.Int32FromInt32(2)*C+D+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45978 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45979 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45980 	v1 = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))
  45981 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((C+libc.Int32FromInt32(2)*D+E+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45982 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45983 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45984 	v1 = dst + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))
  45985 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((D+libc.Int32FromInt32(2)*E+E+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  45986 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  45987 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  45988 }
  45989 
  45990 func DC4_C(tls *libc.TLS, dst uintptr) {
  45991 	var dc uint32_t
  45992 	var i int32
  45993 	_, _ = dc, i // DC
  45994 	dc = uint32(4)
  45995 	i = 0
  45996 	for {
  45997 		if !(i < int32(4)) {
  45998 			break
  45999 		}
  46000 		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))))))
  46001 		goto _1
  46002 	_1:
  46003 		;
  46004 		i = i + 1
  46005 	}
  46006 	dc = dc >> uint32(3)
  46007 	i = 0
  46008 	for {
  46009 		if !(i < int32(4)) {
  46010 			break
  46011 		}
  46012 		libc.X__builtin___memset_chk(tls, dst+uintptr(i*int32(BPS)), libc.Int32FromUint32(dc), uint64(4), ^__predefined_size_t(0))
  46013 		goto _2
  46014 	_2:
  46015 		;
  46016 		i = i + 1
  46017 	}
  46018 }
  46019 
  46020 func RD4_C(tls *libc.TLS, dst uintptr) {
  46021 	var A, B, C, D, I, J, K, L, X int32
  46022 	var v1, v2, v3 uint8_t
  46023 	_, _, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, L, X, v1, v2, v3 // Down-right
  46024 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46025 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46026 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46027 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46028 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46029 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46030 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46031 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46032 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46033 	**(**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))
  46034 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46035 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46036 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46037 	v2 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*I + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46038 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v2
  46039 	v1 = v2
  46040 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46041 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46042 	v3 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*X + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46043 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v3
  46044 	v2 = v3
  46045 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v2
  46046 	v1 = v2
  46047 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46048 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46049 	v2 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*A + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46050 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v2
  46051 	v1 = v2
  46052 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46053 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46054 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*B + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46055 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46056 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46057 	**(**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))
  46058 }
  46059 
  46060 func LD4_C(tls *libc.TLS, dst uintptr) {
  46061 	var A, B, C, D, E, F, G, H int32
  46062 	var v1, v2, v3 uint8_t
  46063 	_, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1, v2, v3 // Down-Left
  46064 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46065 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46066 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46067 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46068 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(4)-libc.Int32FromInt32(BPS)))))
  46069 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(5)-libc.Int32FromInt32(BPS)))))
  46070 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(6)-libc.Int32FromInt32(BPS)))))
  46071 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(7)-libc.Int32FromInt32(BPS)))))
  46072 	**(**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))
  46073 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46074 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46075 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46076 	v2 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46077 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  46078 	v1 = v2
  46079 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46080 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46081 	v3 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46082 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  46083 	v2 = v3
  46084 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  46085 	v1 = v2
  46086 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46087 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46088 	v2 = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46089 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  46090 	v1 = v2
  46091 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46092 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46093 	v1 = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46094 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46095 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46096 	**(**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))
  46097 }
  46098 
  46099 func VR4_C(tls *libc.TLS, dst uintptr) {
  46100 	var A, B, C, D, I, J, K, X int32
  46101 	var v1 uint8_t
  46102 	_, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, X, v1 // Vertical-Right
  46103 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46104 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46105 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46106 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46107 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46108 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46109 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46110 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46111 	v1 = libc.Uint8FromInt32((X + A + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46112 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46113 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46114 	v1 = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46115 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46116 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46117 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46118 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46119 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46120 	**(**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))
  46121 	**(**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))
  46122 	**(**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))
  46123 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46124 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46125 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46126 	v1 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46127 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46128 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46129 	v1 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46130 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46131 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46132 	**(**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))
  46133 }
  46134 
  46135 func VL4_C(tls *libc.TLS, dst uintptr) {
  46136 	var A, B, C, D, E, F, G, H int32
  46137 	var v1 uint8_t
  46138 	_, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1 // Vertical-Left
  46139 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46140 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46141 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46142 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)-libc.Int32FromInt32(BPS)))))
  46143 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(4)-libc.Int32FromInt32(BPS)))))
  46144 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(5)-libc.Int32FromInt32(BPS)))))
  46145 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(6)-libc.Int32FromInt32(BPS)))))
  46146 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(7)-libc.Int32FromInt32(BPS)))))
  46147 	**(**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))
  46148 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46149 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46150 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46151 	v1 = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46152 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46153 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46154 	v1 = libc.Uint8FromInt32((D + E + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46155 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46156 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46157 	**(**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))
  46158 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46159 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46160 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46161 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46162 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46163 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46164 	v1 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46165 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46166 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46167 	**(**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))
  46168 	**(**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))
  46169 }
  46170 
  46171 func HU4_C(tls *libc.TLS, dst uintptr) {
  46172 	var I, J, K, L int32
  46173 	var v1, v2, v3, v4, v5 uint8_t
  46174 	_, _, _, _, _, _, _, _, _ = I, J, K, L, v1, v2, v3, v4, v5 // Horizontal-Up
  46175 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46176 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46177 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46178 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46179 	**(**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))
  46180 	v1 = libc.Uint8FromInt32((J + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46181 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46182 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46183 	v1 = libc.Uint8FromInt32((K + L + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46184 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46185 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46186 	**(**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))
  46187 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46188 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46189 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46190 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*L + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46191 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46192 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46193 	v5 = libc.Uint8FromInt32(L)
  46194 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v5
  46195 	v4 = v5
  46196 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v4
  46197 	v3 = v4
  46198 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  46199 	v2 = v3
  46200 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  46201 	v1 = v2
  46202 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46203 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46204 }
  46205 
  46206 func HD4_C(tls *libc.TLS, dst uintptr) {
  46207 	var A, B, C, I, J, K, L, X int32
  46208 	var v1 uint8_t
  46209 	_, _, _, _, _, _, _, _, _ = A, B, C, I, J, K, L, X, v1 // Horizontal-Down
  46210 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))))
  46211 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))))
  46212 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))))
  46213 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))))
  46214 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46215 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)-libc.Int32FromInt32(BPS)))))
  46216 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)-libc.Int32FromInt32(BPS)))))
  46217 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)-libc.Int32FromInt32(BPS)))))
  46218 	v1 = libc.Uint8FromInt32((I + X + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46219 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46220 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46221 	v1 = libc.Uint8FromInt32((J + I + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46222 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46223 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46224 	v1 = libc.Uint8FromInt32((K + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  46225 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46226 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46227 	**(**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))
  46228 	**(**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))
  46229 	**(**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))
  46230 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46231 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46232 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  46233 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46234 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46235 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  46236 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  46237 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  46238 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  46239 	**(**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))
  46240 }
  46241 
  46242 //------------------------------------------------------------------------------
  46243 // Chroma
  46244 
  46245 func VE8uv_C(tls *libc.TLS, dst uintptr) {
  46246 	var j int32
  46247 	_ = j
  46248 	j = 0
  46249 	for {
  46250 		if !(j < int32(8)) {
  46251 			break
  46252 		}
  46253 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), dst-uintptr(BPS), uint64(8), ^__predefined_size_t(0))
  46254 		goto _1
  46255 	_1:
  46256 		;
  46257 		j = j + 1
  46258 	}
  46259 }
  46260 
  46261 func HE8uv_C(tls *libc.TLS, dst uintptr) {
  46262 	var j int32
  46263 	_ = j
  46264 	j = 0
  46265 	for {
  46266 		if !(j < int32(8)) {
  46267 			break
  46268 		}
  46269 		libc.X__builtin___memset_chk(tls, dst, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-libc.Int32FromInt32(1))))), uint64(8), ^__predefined_size_t(0))
  46270 		dst = dst + uintptr(BPS)
  46271 		goto _1
  46272 	_1:
  46273 		;
  46274 		j = j + 1
  46275 	}
  46276 }
  46277 
  46278 // C documentation
  46279 //
  46280 //	// helper for chroma-DC predictions
  46281 func Put8x8uv(tls *libc.TLS, value uint8_t, dst uintptr) {
  46282 	var j int32
  46283 	_ = j
  46284 	j = 0
  46285 	for {
  46286 		if !(j < int32(8)) {
  46287 			break
  46288 		}
  46289 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), libc.Int32FromUint8(value), uint64(8), ^__predefined_size_t(0))
  46290 		goto _1
  46291 	_1:
  46292 		;
  46293 		j = j + 1
  46294 	}
  46295 }
  46296 
  46297 func DC8uv_C(tls *libc.TLS, dst uintptr) {
  46298 	var dc0, i int32
  46299 	_, _ = dc0, i // DC
  46300 	dc0 = int32(8)
  46301 	i = 0
  46302 	for {
  46303 		if !(i < int32(8)) {
  46304 			break
  46305 		}
  46306 		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))))))
  46307 		goto _1
  46308 	_1:
  46309 		;
  46310 		i = i + 1
  46311 	}
  46312 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(4)), dst)
  46313 }
  46314 
  46315 func DC8uvNoLeft_C(tls *libc.TLS, dst uintptr) {
  46316 	var dc0, i int32
  46317 	_, _ = dc0, i // DC with no left samples
  46318 	dc0 = int32(4)
  46319 	i = 0
  46320 	for {
  46321 		if !(i < int32(8)) {
  46322 			break
  46323 		}
  46324 		dc0 = dc0 + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i-int32(BPS)))))
  46325 		goto _1
  46326 	_1:
  46327 		;
  46328 		i = i + 1
  46329 	}
  46330 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(3)), dst)
  46331 }
  46332 
  46333 func DC8uvNoTop_C(tls *libc.TLS, dst uintptr) {
  46334 	var dc0, i int32
  46335 	_, _ = dc0, i // DC with no top samples
  46336 	dc0 = int32(4)
  46337 	i = 0
  46338 	for {
  46339 		if !(i < int32(8)) {
  46340 			break
  46341 		}
  46342 		dc0 = dc0 + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(-int32(1)+i*int32(BPS)))))
  46343 		goto _1
  46344 	_1:
  46345 		;
  46346 		i = i + 1
  46347 	}
  46348 	Put8x8uv(tls, libc.Uint8FromInt32(dc0>>int32(3)), dst)
  46349 }
  46350 
  46351 func DC8uvNoTopLeft_C(tls *libc.TLS, dst uintptr) {
  46352 	// DC with nothing
  46353 	Put8x8uv(tls, uint8(0x80), dst)
  46354 }
  46355 
  46356 //------------------------------------------------------------------------------
  46357 // Edge filtering functions
  46358 
  46359 // C documentation
  46360 //
  46361 //	// 4 pixels in, 2 pixels out
  46362 func DoFilter2_C(tls *libc.TLS, p uintptr, step int32) {
  46363 	var a, a1, a2, p0, p1, q0, q1 int32
  46364 	_, _, _, _, _, _, _ = a, a1, a2, p0, p1, q0, q1
  46365 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46366 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46367 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46368 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46369 	a = int32(3)*(q0-p0) + int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(p1-q1)))) // in [-893,892]
  46370 	a1 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(4))>>int32(3)))))  // in [-16,15]
  46371 	a2 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(3))>>int32(3)))))
  46372 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a2)))
  46373 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46374 }
  46375 
  46376 // C documentation
  46377 //
  46378 //	// 4 pixels in, 4 pixels out
  46379 func DoFilter4_C(tls *libc.TLS, p uintptr, step int32) {
  46380 	var a, a1, a2, a3, p0, p1, q0, q1 int32
  46381 	_, _, _, _, _, _, _, _ = a, a1, a2, a3, p0, p1, q0, q1
  46382 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46383 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46384 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46385 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46386 	a = int32(3) * (q0 - p0)
  46387 	a1 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(4))>>int32(3)))))
  46388 	a2 = int32(**(**int8_t)(__ccgo_up(VP8ksclip2 + uintptr((a+int32(3))>>int32(3)))))
  46389 	a3 = (a1 + int32(1)) >> int32(1)
  46390 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p1+a3)))
  46391 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a2)))
  46392 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46393 	**(**uint8_t)(__ccgo_up(p + uintptr(step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q1-a3)))
  46394 }
  46395 
  46396 // C documentation
  46397 //
  46398 //	// 6 pixels in, 6 pixels out
  46399 func DoFilter6_C(tls *libc.TLS, p uintptr, step int32) {
  46400 	var a, a1, a2, a3, p0, p1, p2, q0, q1, q2 int32
  46401 	_, _, _, _, _, _, _, _, _, _ = a, a1, a2, a3, p0, p1, p2, q0, q1, q2
  46402 	p2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))))
  46403 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46404 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46405 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46406 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46407 	q2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))))
  46408 	a = int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(int32(3)*(q0-p0)+int32(**(**int8_t)(__ccgo_up(VP8ksclip1 + uintptr(p1-q1))))))))
  46409 	// a is in [-128,127], a1 in [-27,27], a2 in [-18,18] and a3 in [-9,9]
  46410 	a1 = (int32(27)*a + int32(63)) >> int32(7) // eq. to ((3 * a + 7) * 9) >> 7
  46411 	a2 = (int32(18)*a + int32(63)) >> int32(7) // eq. to ((2 * a + 7) * 9) >> 7
  46412 	a3 = (int32(9)*a + int32(63)) >> int32(7)  // eq. to ((1 * a + 7) * 9) >> 7
  46413 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p2+a3)))
  46414 	**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p1+a2)))
  46415 	**(**uint8_t)(__ccgo_up(p + uintptr(-step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(p0+a1)))
  46416 	**(**uint8_t)(__ccgo_up(p)) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q0-a1)))
  46417 	**(**uint8_t)(__ccgo_up(p + uintptr(step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q1-a2)))
  46418 	**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))) = **(**uint8_t)(__ccgo_up(VP8kclip1 + uintptr(q2-a3)))
  46419 }
  46420 
  46421 func Hev(tls *libc.TLS, p uintptr, step int32, thresh int32) (r int32) {
  46422 	var p0, p1, q0, q1 int32
  46423 	_, _, _, _ = p0, p1, q0, q1
  46424 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46425 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46426 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46427 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46428 	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)
  46429 }
  46430 
  46431 func NeedsFilter_C(tls *libc.TLS, p uintptr, step int32, t int32) (r int32) {
  46432 	var p0, p1, q0, q1 int32
  46433 	_, _, _, _ = p0, p1, q0, q1
  46434 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46435 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46436 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46437 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46438 	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)
  46439 }
  46440 
  46441 func NeedsFilter2_C(tls *libc.TLS, p uintptr, step int32, t int32, it int32) (r int32) {
  46442 	var p0, p1, p2, p3, q0, q1, q2, q3 int32
  46443 	_, _, _, _, _, _, _, _ = p0, p1, p2, p3, q0, q1, q2, q3
  46444 	p3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(4)*step))))
  46445 	p2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(3)*step))))
  46446 	p1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-int32(2)*step))))
  46447 	p0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(-step))))
  46448 	q0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p)))
  46449 	q1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(step))))
  46450 	q2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(2)*step))))
  46451 	q3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(p + uintptr(int32(3)*step))))
  46452 	if int32(4)*libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p0-q0))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(VP8kabs0 + uintptr(p1-q1)))) > t {
  46453 		return 0
  46454 	}
  46455 	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)
  46456 }
  46457 
  46458 //------------------------------------------------------------------------------
  46459 // Simple In-loop filtering (Paragraph 15.2)
  46460 
  46461 func SimpleVFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46462 	var i, thresh2 int32
  46463 	_, _ = i, thresh2
  46464 	thresh2 = int32(2)*thresh + int32(1)
  46465 	i = 0
  46466 	for {
  46467 		if !(i < int32(16)) {
  46468 			break
  46469 		}
  46470 		if NeedsFilter_C(tls, p+uintptr(i), stride, thresh2) != 0 {
  46471 			DoFilter2_C(tls, p+uintptr(i), stride)
  46472 		}
  46473 		goto _1
  46474 	_1:
  46475 		;
  46476 		i = i + 1
  46477 	}
  46478 }
  46479 
  46480 func SimpleHFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46481 	var i, thresh2 int32
  46482 	_, _ = i, thresh2
  46483 	thresh2 = int32(2)*thresh + int32(1)
  46484 	i = 0
  46485 	for {
  46486 		if !(i < int32(16)) {
  46487 			break
  46488 		}
  46489 		if NeedsFilter_C(tls, p+uintptr(i*stride), int32(1), thresh2) != 0 {
  46490 			DoFilter2_C(tls, p+uintptr(i*stride), int32(1))
  46491 		}
  46492 		goto _1
  46493 	_1:
  46494 		;
  46495 		i = i + 1
  46496 	}
  46497 }
  46498 
  46499 func SimpleVFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46500 	var k int32
  46501 	_ = k
  46502 	k = int32(3)
  46503 	for {
  46504 		if !(k > 0) {
  46505 			break
  46506 		}
  46507 		p = p + uintptr(int32(4)*stride)
  46508 		SimpleVFilter16_C(tls, p, stride, thresh)
  46509 		goto _1
  46510 	_1:
  46511 		;
  46512 		k = k - 1
  46513 	}
  46514 }
  46515 
  46516 func SimpleHFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32) {
  46517 	var k int32
  46518 	_ = k
  46519 	k = int32(3)
  46520 	for {
  46521 		if !(k > 0) {
  46522 			break
  46523 		}
  46524 		p = p + uintptr(4)
  46525 		SimpleHFilter16_C(tls, p, stride, thresh)
  46526 		goto _1
  46527 	_1:
  46528 		;
  46529 		k = k - 1
  46530 	}
  46531 }
  46532 
  46533 //------------------------------------------------------------------------------
  46534 // Complex In-loop filtering (Paragraph 15.3)
  46535 
  46536 func FilterLoop26_C(tls *libc.TLS, p uintptr, hstride int32, vstride int32, size int32, thresh int32, ithresh int32, hev_thresh int32) {
  46537 	var thresh2, v1 int32
  46538 	_, _ = thresh2, v1
  46539 	thresh2 = int32(2)*thresh + int32(1)
  46540 	for {
  46541 		v1 = size
  46542 		size = size - 1
  46543 		if !(v1 > 0) {
  46544 			break
  46545 		}
  46546 		if NeedsFilter2_C(tls, p, hstride, thresh2, ithresh) != 0 {
  46547 			if Hev(tls, p, hstride, hev_thresh) != 0 {
  46548 				DoFilter2_C(tls, p, hstride)
  46549 			} else {
  46550 				DoFilter6_C(tls, p, hstride)
  46551 			}
  46552 		}
  46553 		p = p + uintptr(vstride)
  46554 	}
  46555 }
  46556 
  46557 func FilterLoop24_C(tls *libc.TLS, p uintptr, hstride int32, vstride int32, size int32, thresh int32, ithresh int32, hev_thresh int32) {
  46558 	var thresh2, v1 int32
  46559 	_, _ = thresh2, v1
  46560 	thresh2 = int32(2)*thresh + int32(1)
  46561 	for {
  46562 		v1 = size
  46563 		size = size - 1
  46564 		if !(v1 > 0) {
  46565 			break
  46566 		}
  46567 		if NeedsFilter2_C(tls, p, hstride, thresh2, ithresh) != 0 {
  46568 			if Hev(tls, p, hstride, hev_thresh) != 0 {
  46569 				DoFilter2_C(tls, p, hstride)
  46570 			} else {
  46571 				DoFilter4_C(tls, p, hstride)
  46572 			}
  46573 		}
  46574 		p = p + uintptr(vstride)
  46575 	}
  46576 }
  46577 
  46578 // C documentation
  46579 //
  46580 //	// on macroblock edges
  46581 func VFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46582 	FilterLoop26_C(tls, p, stride, int32(1), int32(16), thresh, ithresh, hev_thresh)
  46583 }
  46584 
  46585 func HFilter16_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46586 	FilterLoop26_C(tls, p, int32(1), stride, int32(16), thresh, ithresh, hev_thresh)
  46587 }
  46588 
  46589 // C documentation
  46590 //
  46591 //	// on three inner edges
  46592 func VFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46593 	var k int32
  46594 	_ = k
  46595 	k = int32(3)
  46596 	for {
  46597 		if !(k > 0) {
  46598 			break
  46599 		}
  46600 		p = p + uintptr(int32(4)*stride)
  46601 		FilterLoop24_C(tls, p, stride, int32(1), int32(16), thresh, ithresh, hev_thresh)
  46602 		goto _1
  46603 	_1:
  46604 		;
  46605 		k = k - 1
  46606 	}
  46607 }
  46608 
  46609 func HFilter16i_C(tls *libc.TLS, p uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46610 	var k int32
  46611 	_ = k
  46612 	k = int32(3)
  46613 	for {
  46614 		if !(k > 0) {
  46615 			break
  46616 		}
  46617 		p = p + uintptr(4)
  46618 		FilterLoop24_C(tls, p, int32(1), stride, int32(16), thresh, ithresh, hev_thresh)
  46619 		goto _1
  46620 	_1:
  46621 		;
  46622 		k = k - 1
  46623 	}
  46624 }
  46625 
  46626 // C documentation
  46627 //
  46628 //	// 8-pixels wide variant, for chroma filtering
  46629 func VFilter8_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46630 	FilterLoop26_C(tls, u, stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46631 	FilterLoop26_C(tls, v, stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46632 }
  46633 
  46634 func HFilter8_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46635 	FilterLoop26_C(tls, u, int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46636 	FilterLoop26_C(tls, v, int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46637 }
  46638 
  46639 func VFilter8i_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46640 	FilterLoop24_C(tls, u+uintptr(int32(4)*stride), stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46641 	FilterLoop24_C(tls, v+uintptr(int32(4)*stride), stride, int32(1), int32(8), thresh, ithresh, hev_thresh)
  46642 }
  46643 
  46644 func HFilter8i_C(tls *libc.TLS, u uintptr, v uintptr, stride int32, thresh int32, ithresh int32, hev_thresh int32) {
  46645 	FilterLoop24_C(tls, u+uintptr(4), int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46646 	FilterLoop24_C(tls, v+uintptr(4), int32(1), stride, int32(8), thresh, ithresh, hev_thresh)
  46647 }
  46648 
  46649 //------------------------------------------------------------------------------
  46650 
  46651 func DitherCombine8x8_C(tls *libc.TLS, dither uintptr, dst uintptr, dst_stride int32) {
  46652 	var delta0, delta1, i, j int32
  46653 	_, _, _, _ = delta0, delta1, i, j
  46654 	j = 0
  46655 	for {
  46656 		if !(j < int32(8)) {
  46657 			break
  46658 		}
  46659 		i = 0
  46660 		for {
  46661 			if !(i < int32(8)) {
  46662 				break
  46663 			}
  46664 			delta0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dither + uintptr(i)))) - libc.Int32FromInt32(1)<<libc.Int32FromInt32(VP8_DITHER_AMP_BITS)
  46665 			delta1 = (delta0 + libc.Int32FromInt32(1)<<(libc.Int32FromInt32(VP8_DITHER_DESCALE)-libc.Int32FromInt32(1))) >> int32(VP8_DITHER_DESCALE)
  46666 			**(**uint8_t)(__ccgo_up(dst + uintptr(i))) = clip_8b1(tls, libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(dst + uintptr(i))))+delta1)
  46667 			goto _2
  46668 		_2:
  46669 			;
  46670 			i = i + 1
  46671 		}
  46672 		dst = dst + uintptr(dst_stride)
  46673 		dither = dither + uintptr(8)
  46674 		goto _1
  46675 	_1:
  46676 		;
  46677 		j = j + 1
  46678 	}
  46679 }
  46680 
  46681 func VP8DspInit(tls *libc.TLS) {
  46682 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  46683 		goto _1
  46684 	}
  46685 	VP8DspInit_body(tls)
  46686 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  46687 	goto _2
  46688 _2:
  46689 	;
  46690 	goto _1
  46691 _1: /**/ //
  46692 }
  46693 
  46694 var VP8DspInit_body_last_cpuinfo_used = uintptr(0)
  46695 
  46696 func init() {
  46697 	p := unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used)
  46698 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8DspInit_body_last_cpuinfo_used))
  46699 }
  46700 
  46701 func VP8DspInit_body(tls *libc.TLS) {
  46702 	VP8InitClipTables(tls)
  46703 	VP8TransformWHT = __ccgo_fp(TransformWHT_C)
  46704 	VP8Transform = __ccgo_fp(TransformTwo_C)
  46705 	VP8TransformDC = __ccgo_fp(TransformDC_C)
  46706 	VP8TransformAC3 = __ccgo_fp(TransformAC3_C)
  46707 	VP8TransformUV = __ccgo_fp(TransformUV_C)
  46708 	VP8TransformDCUV = __ccgo_fp(TransformDCUV_C)
  46709 	VP8VFilter16 = __ccgo_fp(VFilter16_C)
  46710 	VP8VFilter16i = __ccgo_fp(VFilter16i_C)
  46711 	VP8HFilter16 = __ccgo_fp(HFilter16_C)
  46712 	VP8VFilter8 = __ccgo_fp(VFilter8_C)
  46713 	VP8VFilter8i = __ccgo_fp(VFilter8i_C)
  46714 	VP8SimpleVFilter16 = __ccgo_fp(SimpleVFilter16_C)
  46715 	VP8SimpleHFilter16 = __ccgo_fp(SimpleHFilter16_C)
  46716 	VP8SimpleVFilter16i = __ccgo_fp(SimpleVFilter16i_C)
  46717 	VP8SimpleHFilter16i = __ccgo_fp(SimpleHFilter16i_C)
  46718 	VP8HFilter16i = __ccgo_fp(HFilter16i_C)
  46719 	VP8HFilter8 = __ccgo_fp(HFilter8_C)
  46720 	VP8HFilter8i = __ccgo_fp(HFilter8i_C)
  46721 	VP8PredLuma4[0] = __ccgo_fp(DC4_C)
  46722 	VP8PredLuma4[int32(1)] = __ccgo_fp(TM4_C)
  46723 	VP8PredLuma4[int32(2)] = __ccgo_fp(VE4_C)
  46724 	VP8PredLuma4[int32(4)] = __ccgo_fp(RD4_C)
  46725 	VP8PredLuma4[int32(6)] = __ccgo_fp(LD4_C)
  46726 	VP8PredLuma4[int32(3)] = __ccgo_fp(HE4_C)
  46727 	VP8PredLuma4[int32(5)] = __ccgo_fp(VR4_C)
  46728 	VP8PredLuma4[int32(7)] = __ccgo_fp(VL4_C)
  46729 	VP8PredLuma4[int32(8)] = __ccgo_fp(HD4_C)
  46730 	VP8PredLuma4[int32(9)] = __ccgo_fp(HU4_C)
  46731 	VP8PredLuma16[0] = __ccgo_fp(DC16_C)
  46732 	VP8PredLuma16[int32(1)] = __ccgo_fp(TM16_C)
  46733 	VP8PredLuma16[int32(2)] = __ccgo_fp(VE16_C)
  46734 	VP8PredLuma16[int32(3)] = __ccgo_fp(HE16_C)
  46735 	VP8PredLuma16[int32(4)] = __ccgo_fp(DC16NoTop_C)
  46736 	VP8PredLuma16[int32(5)] = __ccgo_fp(DC16NoLeft_C)
  46737 	VP8PredLuma16[int32(6)] = __ccgo_fp(DC16NoTopLeft_C)
  46738 	VP8PredChroma8[0] = __ccgo_fp(DC8uv_C)
  46739 	VP8PredChroma8[int32(1)] = __ccgo_fp(TM8uv_C)
  46740 	VP8PredChroma8[int32(2)] = __ccgo_fp(VE8uv_C)
  46741 	VP8PredChroma8[int32(3)] = __ccgo_fp(HE8uv_C)
  46742 	VP8PredChroma8[int32(4)] = __ccgo_fp(DC8uvNoTop_C)
  46743 	VP8PredChroma8[int32(5)] = __ccgo_fp(DC8uvNoLeft_C)
  46744 	VP8PredChroma8[int32(6)] = __ccgo_fp(DC8uvNoTopLeft_C)
  46745 	VP8DitherCombine8x8 = __ccgo_fp(DitherCombine8x8_C)
  46746 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  46747 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  46748 	}
  46749 }
  46750 
  46751 const USE_STATIC_TABLES = 1
  46752 
  46753 // define to 0 to have run-time table initialization
  46754 
  46755 var abs0 = [511]uint8_t{
  46756 	0:   uint8(0xff),
  46757 	1:   uint8(0xfe),
  46758 	2:   uint8(0xfd),
  46759 	3:   uint8(0xfc),
  46760 	4:   uint8(0xfb),
  46761 	5:   uint8(0xfa),
  46762 	6:   uint8(0xf9),
  46763 	7:   uint8(0xf8),
  46764 	8:   uint8(0xf7),
  46765 	9:   uint8(0xf6),
  46766 	10:  uint8(0xf5),
  46767 	11:  uint8(0xf4),
  46768 	12:  uint8(0xf3),
  46769 	13:  uint8(0xf2),
  46770 	14:  uint8(0xf1),
  46771 	15:  uint8(0xf0),
  46772 	16:  uint8(0xef),
  46773 	17:  uint8(0xee),
  46774 	18:  uint8(0xed),
  46775 	19:  uint8(0xec),
  46776 	20:  uint8(0xeb),
  46777 	21:  uint8(0xea),
  46778 	22:  uint8(0xe9),
  46779 	23:  uint8(0xe8),
  46780 	24:  uint8(0xe7),
  46781 	25:  uint8(0xe6),
  46782 	26:  uint8(0xe5),
  46783 	27:  uint8(0xe4),
  46784 	28:  uint8(0xe3),
  46785 	29:  uint8(0xe2),
  46786 	30:  uint8(0xe1),
  46787 	31:  uint8(0xe0),
  46788 	32:  uint8(0xdf),
  46789 	33:  uint8(0xde),
  46790 	34:  uint8(0xdd),
  46791 	35:  uint8(0xdc),
  46792 	36:  uint8(0xdb),
  46793 	37:  uint8(0xda),
  46794 	38:  uint8(0xd9),
  46795 	39:  uint8(0xd8),
  46796 	40:  uint8(0xd7),
  46797 	41:  uint8(0xd6),
  46798 	42:  uint8(0xd5),
  46799 	43:  uint8(0xd4),
  46800 	44:  uint8(0xd3),
  46801 	45:  uint8(0xd2),
  46802 	46:  uint8(0xd1),
  46803 	47:  uint8(0xd0),
  46804 	48:  uint8(0xcf),
  46805 	49:  uint8(0xce),
  46806 	50:  uint8(0xcd),
  46807 	51:  uint8(0xcc),
  46808 	52:  uint8(0xcb),
  46809 	53:  uint8(0xca),
  46810 	54:  uint8(0xc9),
  46811 	55:  uint8(0xc8),
  46812 	56:  uint8(0xc7),
  46813 	57:  uint8(0xc6),
  46814 	58:  uint8(0xc5),
  46815 	59:  uint8(0xc4),
  46816 	60:  uint8(0xc3),
  46817 	61:  uint8(0xc2),
  46818 	62:  uint8(0xc1),
  46819 	63:  uint8(0xc0),
  46820 	64:  uint8(0xbf),
  46821 	65:  uint8(0xbe),
  46822 	66:  uint8(0xbd),
  46823 	67:  uint8(0xbc),
  46824 	68:  uint8(0xbb),
  46825 	69:  uint8(0xba),
  46826 	70:  uint8(0xb9),
  46827 	71:  uint8(0xb8),
  46828 	72:  uint8(0xb7),
  46829 	73:  uint8(0xb6),
  46830 	74:  uint8(0xb5),
  46831 	75:  uint8(0xb4),
  46832 	76:  uint8(0xb3),
  46833 	77:  uint8(0xb2),
  46834 	78:  uint8(0xb1),
  46835 	79:  uint8(0xb0),
  46836 	80:  uint8(0xaf),
  46837 	81:  uint8(0xae),
  46838 	82:  uint8(0xad),
  46839 	83:  uint8(0xac),
  46840 	84:  uint8(0xab),
  46841 	85:  uint8(0xaa),
  46842 	86:  uint8(0xa9),
  46843 	87:  uint8(0xa8),
  46844 	88:  uint8(0xa7),
  46845 	89:  uint8(0xa6),
  46846 	90:  uint8(0xa5),
  46847 	91:  uint8(0xa4),
  46848 	92:  uint8(0xa3),
  46849 	93:  uint8(0xa2),
  46850 	94:  uint8(0xa1),
  46851 	95:  uint8(0xa0),
  46852 	96:  uint8(0x9f),
  46853 	97:  uint8(0x9e),
  46854 	98:  uint8(0x9d),
  46855 	99:  uint8(0x9c),
  46856 	100: uint8(0x9b),
  46857 	101: uint8(0x9a),
  46858 	102: uint8(0x99),
  46859 	103: uint8(0x98),
  46860 	104: uint8(0x97),
  46861 	105: uint8(0x96),
  46862 	106: uint8(0x95),
  46863 	107: uint8(0x94),
  46864 	108: uint8(0x93),
  46865 	109: uint8(0x92),
  46866 	110: uint8(0x91),
  46867 	111: uint8(0x90),
  46868 	112: uint8(0x8f),
  46869 	113: uint8(0x8e),
  46870 	114: uint8(0x8d),
  46871 	115: uint8(0x8c),
  46872 	116: uint8(0x8b),
  46873 	117: uint8(0x8a),
  46874 	118: uint8(0x89),
  46875 	119: uint8(0x88),
  46876 	120: uint8(0x87),
  46877 	121: uint8(0x86),
  46878 	122: uint8(0x85),
  46879 	123: uint8(0x84),
  46880 	124: uint8(0x83),
  46881 	125: uint8(0x82),
  46882 	126: uint8(0x81),
  46883 	127: uint8(0x80),
  46884 	128: uint8(0x7f),
  46885 	129: uint8(0x7e),
  46886 	130: uint8(0x7d),
  46887 	131: uint8(0x7c),
  46888 	132: uint8(0x7b),
  46889 	133: uint8(0x7a),
  46890 	134: uint8(0x79),
  46891 	135: uint8(0x78),
  46892 	136: uint8(0x77),
  46893 	137: uint8(0x76),
  46894 	138: uint8(0x75),
  46895 	139: uint8(0x74),
  46896 	140: uint8(0x73),
  46897 	141: uint8(0x72),
  46898 	142: uint8(0x71),
  46899 	143: uint8(0x70),
  46900 	144: uint8(0x6f),
  46901 	145: uint8(0x6e),
  46902 	146: uint8(0x6d),
  46903 	147: uint8(0x6c),
  46904 	148: uint8(0x6b),
  46905 	149: uint8(0x6a),
  46906 	150: uint8(0x69),
  46907 	151: uint8(0x68),
  46908 	152: uint8(0x67),
  46909 	153: uint8(0x66),
  46910 	154: uint8(0x65),
  46911 	155: uint8(0x64),
  46912 	156: uint8(0x63),
  46913 	157: uint8(0x62),
  46914 	158: uint8(0x61),
  46915 	159: uint8(0x60),
  46916 	160: uint8(0x5f),
  46917 	161: uint8(0x5e),
  46918 	162: uint8(0x5d),
  46919 	163: uint8(0x5c),
  46920 	164: uint8(0x5b),
  46921 	165: uint8(0x5a),
  46922 	166: uint8(0x59),
  46923 	167: uint8(0x58),
  46924 	168: uint8(0x57),
  46925 	169: uint8(0x56),
  46926 	170: uint8(0x55),
  46927 	171: uint8(0x54),
  46928 	172: uint8(0x53),
  46929 	173: uint8(0x52),
  46930 	174: uint8(0x51),
  46931 	175: uint8(0x50),
  46932 	176: uint8(0x4f),
  46933 	177: uint8(0x4e),
  46934 	178: uint8(0x4d),
  46935 	179: uint8(0x4c),
  46936 	180: uint8(0x4b),
  46937 	181: uint8(0x4a),
  46938 	182: uint8(0x49),
  46939 	183: uint8(0x48),
  46940 	184: uint8(0x47),
  46941 	185: uint8(0x46),
  46942 	186: uint8(0x45),
  46943 	187: uint8(0x44),
  46944 	188: uint8(0x43),
  46945 	189: uint8(0x42),
  46946 	190: uint8(0x41),
  46947 	191: uint8(0x40),
  46948 	192: uint8(0x3f),
  46949 	193: uint8(0x3e),
  46950 	194: uint8(0x3d),
  46951 	195: uint8(0x3c),
  46952 	196: uint8(0x3b),
  46953 	197: uint8(0x3a),
  46954 	198: uint8(0x39),
  46955 	199: uint8(0x38),
  46956 	200: uint8(0x37),
  46957 	201: uint8(0x36),
  46958 	202: uint8(0x35),
  46959 	203: uint8(0x34),
  46960 	204: uint8(0x33),
  46961 	205: uint8(0x32),
  46962 	206: uint8(0x31),
  46963 	207: uint8(0x30),
  46964 	208: uint8(0x2f),
  46965 	209: uint8(0x2e),
  46966 	210: uint8(0x2d),
  46967 	211: uint8(0x2c),
  46968 	212: uint8(0x2b),
  46969 	213: uint8(0x2a),
  46970 	214: uint8(0x29),
  46971 	215: uint8(0x28),
  46972 	216: uint8(0x27),
  46973 	217: uint8(0x26),
  46974 	218: uint8(0x25),
  46975 	219: uint8(0x24),
  46976 	220: uint8(0x23),
  46977 	221: uint8(0x22),
  46978 	222: uint8(0x21),
  46979 	223: uint8(0x20),
  46980 	224: uint8(0x1f),
  46981 	225: uint8(0x1e),
  46982 	226: uint8(0x1d),
  46983 	227: uint8(0x1c),
  46984 	228: uint8(0x1b),
  46985 	229: uint8(0x1a),
  46986 	230: uint8(0x19),
  46987 	231: uint8(0x18),
  46988 	232: uint8(0x17),
  46989 	233: uint8(0x16),
  46990 	234: uint8(0x15),
  46991 	235: uint8(0x14),
  46992 	236: uint8(0x13),
  46993 	237: uint8(0x12),
  46994 	238: uint8(0x11),
  46995 	239: uint8(0x10),
  46996 	240: uint8(0x0f),
  46997 	241: uint8(0x0e),
  46998 	242: uint8(0x0d),
  46999 	243: uint8(0x0c),
  47000 	244: uint8(0x0b),
  47001 	245: uint8(0x0a),
  47002 	246: uint8(0x09),
  47003 	247: uint8(0x08),
  47004 	248: uint8(0x07),
  47005 	249: uint8(0x06),
  47006 	250: uint8(0x05),
  47007 	251: uint8(0x04),
  47008 	252: uint8(0x03),
  47009 	253: uint8(0x02),
  47010 	254: uint8(0x01),
  47011 	256: uint8(0x01),
  47012 	257: uint8(0x02),
  47013 	258: uint8(0x03),
  47014 	259: uint8(0x04),
  47015 	260: uint8(0x05),
  47016 	261: uint8(0x06),
  47017 	262: uint8(0x07),
  47018 	263: uint8(0x08),
  47019 	264: uint8(0x09),
  47020 	265: uint8(0x0a),
  47021 	266: uint8(0x0b),
  47022 	267: uint8(0x0c),
  47023 	268: uint8(0x0d),
  47024 	269: uint8(0x0e),
  47025 	270: uint8(0x0f),
  47026 	271: uint8(0x10),
  47027 	272: uint8(0x11),
  47028 	273: uint8(0x12),
  47029 	274: uint8(0x13),
  47030 	275: uint8(0x14),
  47031 	276: uint8(0x15),
  47032 	277: uint8(0x16),
  47033 	278: uint8(0x17),
  47034 	279: uint8(0x18),
  47035 	280: uint8(0x19),
  47036 	281: uint8(0x1a),
  47037 	282: uint8(0x1b),
  47038 	283: uint8(0x1c),
  47039 	284: uint8(0x1d),
  47040 	285: uint8(0x1e),
  47041 	286: uint8(0x1f),
  47042 	287: uint8(0x20),
  47043 	288: uint8(0x21),
  47044 	289: uint8(0x22),
  47045 	290: uint8(0x23),
  47046 	291: uint8(0x24),
  47047 	292: uint8(0x25),
  47048 	293: uint8(0x26),
  47049 	294: uint8(0x27),
  47050 	295: uint8(0x28),
  47051 	296: uint8(0x29),
  47052 	297: uint8(0x2a),
  47053 	298: uint8(0x2b),
  47054 	299: uint8(0x2c),
  47055 	300: uint8(0x2d),
  47056 	301: uint8(0x2e),
  47057 	302: uint8(0x2f),
  47058 	303: uint8(0x30),
  47059 	304: uint8(0x31),
  47060 	305: uint8(0x32),
  47061 	306: uint8(0x33),
  47062 	307: uint8(0x34),
  47063 	308: uint8(0x35),
  47064 	309: uint8(0x36),
  47065 	310: uint8(0x37),
  47066 	311: uint8(0x38),
  47067 	312: uint8(0x39),
  47068 	313: uint8(0x3a),
  47069 	314: uint8(0x3b),
  47070 	315: uint8(0x3c),
  47071 	316: uint8(0x3d),
  47072 	317: uint8(0x3e),
  47073 	318: uint8(0x3f),
  47074 	319: uint8(0x40),
  47075 	320: uint8(0x41),
  47076 	321: uint8(0x42),
  47077 	322: uint8(0x43),
  47078 	323: uint8(0x44),
  47079 	324: uint8(0x45),
  47080 	325: uint8(0x46),
  47081 	326: uint8(0x47),
  47082 	327: uint8(0x48),
  47083 	328: uint8(0x49),
  47084 	329: uint8(0x4a),
  47085 	330: uint8(0x4b),
  47086 	331: uint8(0x4c),
  47087 	332: uint8(0x4d),
  47088 	333: uint8(0x4e),
  47089 	334: uint8(0x4f),
  47090 	335: uint8(0x50),
  47091 	336: uint8(0x51),
  47092 	337: uint8(0x52),
  47093 	338: uint8(0x53),
  47094 	339: uint8(0x54),
  47095 	340: uint8(0x55),
  47096 	341: uint8(0x56),
  47097 	342: uint8(0x57),
  47098 	343: uint8(0x58),
  47099 	344: uint8(0x59),
  47100 	345: uint8(0x5a),
  47101 	346: uint8(0x5b),
  47102 	347: uint8(0x5c),
  47103 	348: uint8(0x5d),
  47104 	349: uint8(0x5e),
  47105 	350: uint8(0x5f),
  47106 	351: uint8(0x60),
  47107 	352: uint8(0x61),
  47108 	353: uint8(0x62),
  47109 	354: uint8(0x63),
  47110 	355: uint8(0x64),
  47111 	356: uint8(0x65),
  47112 	357: uint8(0x66),
  47113 	358: uint8(0x67),
  47114 	359: uint8(0x68),
  47115 	360: uint8(0x69),
  47116 	361: uint8(0x6a),
  47117 	362: uint8(0x6b),
  47118 	363: uint8(0x6c),
  47119 	364: uint8(0x6d),
  47120 	365: uint8(0x6e),
  47121 	366: uint8(0x6f),
  47122 	367: uint8(0x70),
  47123 	368: uint8(0x71),
  47124 	369: uint8(0x72),
  47125 	370: uint8(0x73),
  47126 	371: uint8(0x74),
  47127 	372: uint8(0x75),
  47128 	373: uint8(0x76),
  47129 	374: uint8(0x77),
  47130 	375: uint8(0x78),
  47131 	376: uint8(0x79),
  47132 	377: uint8(0x7a),
  47133 	378: uint8(0x7b),
  47134 	379: uint8(0x7c),
  47135 	380: uint8(0x7d),
  47136 	381: uint8(0x7e),
  47137 	382: uint8(0x7f),
  47138 	383: uint8(0x80),
  47139 	384: uint8(0x81),
  47140 	385: uint8(0x82),
  47141 	386: uint8(0x83),
  47142 	387: uint8(0x84),
  47143 	388: uint8(0x85),
  47144 	389: uint8(0x86),
  47145 	390: uint8(0x87),
  47146 	391: uint8(0x88),
  47147 	392: uint8(0x89),
  47148 	393: uint8(0x8a),
  47149 	394: uint8(0x8b),
  47150 	395: uint8(0x8c),
  47151 	396: uint8(0x8d),
  47152 	397: uint8(0x8e),
  47153 	398: uint8(0x8f),
  47154 	399: uint8(0x90),
  47155 	400: uint8(0x91),
  47156 	401: uint8(0x92),
  47157 	402: uint8(0x93),
  47158 	403: uint8(0x94),
  47159 	404: uint8(0x95),
  47160 	405: uint8(0x96),
  47161 	406: uint8(0x97),
  47162 	407: uint8(0x98),
  47163 	408: uint8(0x99),
  47164 	409: uint8(0x9a),
  47165 	410: uint8(0x9b),
  47166 	411: uint8(0x9c),
  47167 	412: uint8(0x9d),
  47168 	413: uint8(0x9e),
  47169 	414: uint8(0x9f),
  47170 	415: uint8(0xa0),
  47171 	416: uint8(0xa1),
  47172 	417: uint8(0xa2),
  47173 	418: uint8(0xa3),
  47174 	419: uint8(0xa4),
  47175 	420: uint8(0xa5),
  47176 	421: uint8(0xa6),
  47177 	422: uint8(0xa7),
  47178 	423: uint8(0xa8),
  47179 	424: uint8(0xa9),
  47180 	425: uint8(0xaa),
  47181 	426: uint8(0xab),
  47182 	427: uint8(0xac),
  47183 	428: uint8(0xad),
  47184 	429: uint8(0xae),
  47185 	430: uint8(0xaf),
  47186 	431: uint8(0xb0),
  47187 	432: uint8(0xb1),
  47188 	433: uint8(0xb2),
  47189 	434: uint8(0xb3),
  47190 	435: uint8(0xb4),
  47191 	436: uint8(0xb5),
  47192 	437: uint8(0xb6),
  47193 	438: uint8(0xb7),
  47194 	439: uint8(0xb8),
  47195 	440: uint8(0xb9),
  47196 	441: uint8(0xba),
  47197 	442: uint8(0xbb),
  47198 	443: uint8(0xbc),
  47199 	444: uint8(0xbd),
  47200 	445: uint8(0xbe),
  47201 	446: uint8(0xbf),
  47202 	447: uint8(0xc0),
  47203 	448: uint8(0xc1),
  47204 	449: uint8(0xc2),
  47205 	450: uint8(0xc3),
  47206 	451: uint8(0xc4),
  47207 	452: uint8(0xc5),
  47208 	453: uint8(0xc6),
  47209 	454: uint8(0xc7),
  47210 	455: uint8(0xc8),
  47211 	456: uint8(0xc9),
  47212 	457: uint8(0xca),
  47213 	458: uint8(0xcb),
  47214 	459: uint8(0xcc),
  47215 	460: uint8(0xcd),
  47216 	461: uint8(0xce),
  47217 	462: uint8(0xcf),
  47218 	463: uint8(0xd0),
  47219 	464: uint8(0xd1),
  47220 	465: uint8(0xd2),
  47221 	466: uint8(0xd3),
  47222 	467: uint8(0xd4),
  47223 	468: uint8(0xd5),
  47224 	469: uint8(0xd6),
  47225 	470: uint8(0xd7),
  47226 	471: uint8(0xd8),
  47227 	472: uint8(0xd9),
  47228 	473: uint8(0xda),
  47229 	474: uint8(0xdb),
  47230 	475: uint8(0xdc),
  47231 	476: uint8(0xdd),
  47232 	477: uint8(0xde),
  47233 	478: uint8(0xdf),
  47234 	479: uint8(0xe0),
  47235 	480: uint8(0xe1),
  47236 	481: uint8(0xe2),
  47237 	482: uint8(0xe3),
  47238 	483: uint8(0xe4),
  47239 	484: uint8(0xe5),
  47240 	485: uint8(0xe6),
  47241 	486: uint8(0xe7),
  47242 	487: uint8(0xe8),
  47243 	488: uint8(0xe9),
  47244 	489: uint8(0xea),
  47245 	490: uint8(0xeb),
  47246 	491: uint8(0xec),
  47247 	492: uint8(0xed),
  47248 	493: uint8(0xee),
  47249 	494: uint8(0xef),
  47250 	495: uint8(0xf0),
  47251 	496: uint8(0xf1),
  47252 	497: uint8(0xf2),
  47253 	498: uint8(0xf3),
  47254 	499: uint8(0xf4),
  47255 	500: uint8(0xf5),
  47256 	501: uint8(0xf6),
  47257 	502: uint8(0xf7),
  47258 	503: uint8(0xf8),
  47259 	504: uint8(0xf9),
  47260 	505: uint8(0xfa),
  47261 	506: uint8(0xfb),
  47262 	507: uint8(0xfc),
  47263 	508: uint8(0xfd),
  47264 	509: uint8(0xfe),
  47265 	510: uint8(0xff),
  47266 }
  47267 
  47268 var sclip1 = [2041]uint8_t{
  47269 	0:    uint8(0x80),
  47270 	1:    uint8(0x80),
  47271 	2:    uint8(0x80),
  47272 	3:    uint8(0x80),
  47273 	4:    uint8(0x80),
  47274 	5:    uint8(0x80),
  47275 	6:    uint8(0x80),
  47276 	7:    uint8(0x80),
  47277 	8:    uint8(0x80),
  47278 	9:    uint8(0x80),
  47279 	10:   uint8(0x80),
  47280 	11:   uint8(0x80),
  47281 	12:   uint8(0x80),
  47282 	13:   uint8(0x80),
  47283 	14:   uint8(0x80),
  47284 	15:   uint8(0x80),
  47285 	16:   uint8(0x80),
  47286 	17:   uint8(0x80),
  47287 	18:   uint8(0x80),
  47288 	19:   uint8(0x80),
  47289 	20:   uint8(0x80),
  47290 	21:   uint8(0x80),
  47291 	22:   uint8(0x80),
  47292 	23:   uint8(0x80),
  47293 	24:   uint8(0x80),
  47294 	25:   uint8(0x80),
  47295 	26:   uint8(0x80),
  47296 	27:   uint8(0x80),
  47297 	28:   uint8(0x80),
  47298 	29:   uint8(0x80),
  47299 	30:   uint8(0x80),
  47300 	31:   uint8(0x80),
  47301 	32:   uint8(0x80),
  47302 	33:   uint8(0x80),
  47303 	34:   uint8(0x80),
  47304 	35:   uint8(0x80),
  47305 	36:   uint8(0x80),
  47306 	37:   uint8(0x80),
  47307 	38:   uint8(0x80),
  47308 	39:   uint8(0x80),
  47309 	40:   uint8(0x80),
  47310 	41:   uint8(0x80),
  47311 	42:   uint8(0x80),
  47312 	43:   uint8(0x80),
  47313 	44:   uint8(0x80),
  47314 	45:   uint8(0x80),
  47315 	46:   uint8(0x80),
  47316 	47:   uint8(0x80),
  47317 	48:   uint8(0x80),
  47318 	49:   uint8(0x80),
  47319 	50:   uint8(0x80),
  47320 	51:   uint8(0x80),
  47321 	52:   uint8(0x80),
  47322 	53:   uint8(0x80),
  47323 	54:   uint8(0x80),
  47324 	55:   uint8(0x80),
  47325 	56:   uint8(0x80),
  47326 	57:   uint8(0x80),
  47327 	58:   uint8(0x80),
  47328 	59:   uint8(0x80),
  47329 	60:   uint8(0x80),
  47330 	61:   uint8(0x80),
  47331 	62:   uint8(0x80),
  47332 	63:   uint8(0x80),
  47333 	64:   uint8(0x80),
  47334 	65:   uint8(0x80),
  47335 	66:   uint8(0x80),
  47336 	67:   uint8(0x80),
  47337 	68:   uint8(0x80),
  47338 	69:   uint8(0x80),
  47339 	70:   uint8(0x80),
  47340 	71:   uint8(0x80),
  47341 	72:   uint8(0x80),
  47342 	73:   uint8(0x80),
  47343 	74:   uint8(0x80),
  47344 	75:   uint8(0x80),
  47345 	76:   uint8(0x80),
  47346 	77:   uint8(0x80),
  47347 	78:   uint8(0x80),
  47348 	79:   uint8(0x80),
  47349 	80:   uint8(0x80),
  47350 	81:   uint8(0x80),
  47351 	82:   uint8(0x80),
  47352 	83:   uint8(0x80),
  47353 	84:   uint8(0x80),
  47354 	85:   uint8(0x80),
  47355 	86:   uint8(0x80),
  47356 	87:   uint8(0x80),
  47357 	88:   uint8(0x80),
  47358 	89:   uint8(0x80),
  47359 	90:   uint8(0x80),
  47360 	91:   uint8(0x80),
  47361 	92:   uint8(0x80),
  47362 	93:   uint8(0x80),
  47363 	94:   uint8(0x80),
  47364 	95:   uint8(0x80),
  47365 	96:   uint8(0x80),
  47366 	97:   uint8(0x80),
  47367 	98:   uint8(0x80),
  47368 	99:   uint8(0x80),
  47369 	100:  uint8(0x80),
  47370 	101:  uint8(0x80),
  47371 	102:  uint8(0x80),
  47372 	103:  uint8(0x80),
  47373 	104:  uint8(0x80),
  47374 	105:  uint8(0x80),
  47375 	106:  uint8(0x80),
  47376 	107:  uint8(0x80),
  47377 	108:  uint8(0x80),
  47378 	109:  uint8(0x80),
  47379 	110:  uint8(0x80),
  47380 	111:  uint8(0x80),
  47381 	112:  uint8(0x80),
  47382 	113:  uint8(0x80),
  47383 	114:  uint8(0x80),
  47384 	115:  uint8(0x80),
  47385 	116:  uint8(0x80),
  47386 	117:  uint8(0x80),
  47387 	118:  uint8(0x80),
  47388 	119:  uint8(0x80),
  47389 	120:  uint8(0x80),
  47390 	121:  uint8(0x80),
  47391 	122:  uint8(0x80),
  47392 	123:  uint8(0x80),
  47393 	124:  uint8(0x80),
  47394 	125:  uint8(0x80),
  47395 	126:  uint8(0x80),
  47396 	127:  uint8(0x80),
  47397 	128:  uint8(0x80),
  47398 	129:  uint8(0x80),
  47399 	130:  uint8(0x80),
  47400 	131:  uint8(0x80),
  47401 	132:  uint8(0x80),
  47402 	133:  uint8(0x80),
  47403 	134:  uint8(0x80),
  47404 	135:  uint8(0x80),
  47405 	136:  uint8(0x80),
  47406 	137:  uint8(0x80),
  47407 	138:  uint8(0x80),
  47408 	139:  uint8(0x80),
  47409 	140:  uint8(0x80),
  47410 	141:  uint8(0x80),
  47411 	142:  uint8(0x80),
  47412 	143:  uint8(0x80),
  47413 	144:  uint8(0x80),
  47414 	145:  uint8(0x80),
  47415 	146:  uint8(0x80),
  47416 	147:  uint8(0x80),
  47417 	148:  uint8(0x80),
  47418 	149:  uint8(0x80),
  47419 	150:  uint8(0x80),
  47420 	151:  uint8(0x80),
  47421 	152:  uint8(0x80),
  47422 	153:  uint8(0x80),
  47423 	154:  uint8(0x80),
  47424 	155:  uint8(0x80),
  47425 	156:  uint8(0x80),
  47426 	157:  uint8(0x80),
  47427 	158:  uint8(0x80),
  47428 	159:  uint8(0x80),
  47429 	160:  uint8(0x80),
  47430 	161:  uint8(0x80),
  47431 	162:  uint8(0x80),
  47432 	163:  uint8(0x80),
  47433 	164:  uint8(0x80),
  47434 	165:  uint8(0x80),
  47435 	166:  uint8(0x80),
  47436 	167:  uint8(0x80),
  47437 	168:  uint8(0x80),
  47438 	169:  uint8(0x80),
  47439 	170:  uint8(0x80),
  47440 	171:  uint8(0x80),
  47441 	172:  uint8(0x80),
  47442 	173:  uint8(0x80),
  47443 	174:  uint8(0x80),
  47444 	175:  uint8(0x80),
  47445 	176:  uint8(0x80),
  47446 	177:  uint8(0x80),
  47447 	178:  uint8(0x80),
  47448 	179:  uint8(0x80),
  47449 	180:  uint8(0x80),
  47450 	181:  uint8(0x80),
  47451 	182:  uint8(0x80),
  47452 	183:  uint8(0x80),
  47453 	184:  uint8(0x80),
  47454 	185:  uint8(0x80),
  47455 	186:  uint8(0x80),
  47456 	187:  uint8(0x80),
  47457 	188:  uint8(0x80),
  47458 	189:  uint8(0x80),
  47459 	190:  uint8(0x80),
  47460 	191:  uint8(0x80),
  47461 	192:  uint8(0x80),
  47462 	193:  uint8(0x80),
  47463 	194:  uint8(0x80),
  47464 	195:  uint8(0x80),
  47465 	196:  uint8(0x80),
  47466 	197:  uint8(0x80),
  47467 	198:  uint8(0x80),
  47468 	199:  uint8(0x80),
  47469 	200:  uint8(0x80),
  47470 	201:  uint8(0x80),
  47471 	202:  uint8(0x80),
  47472 	203:  uint8(0x80),
  47473 	204:  uint8(0x80),
  47474 	205:  uint8(0x80),
  47475 	206:  uint8(0x80),
  47476 	207:  uint8(0x80),
  47477 	208:  uint8(0x80),
  47478 	209:  uint8(0x80),
  47479 	210:  uint8(0x80),
  47480 	211:  uint8(0x80),
  47481 	212:  uint8(0x80),
  47482 	213:  uint8(0x80),
  47483 	214:  uint8(0x80),
  47484 	215:  uint8(0x80),
  47485 	216:  uint8(0x80),
  47486 	217:  uint8(0x80),
  47487 	218:  uint8(0x80),
  47488 	219:  uint8(0x80),
  47489 	220:  uint8(0x80),
  47490 	221:  uint8(0x80),
  47491 	222:  uint8(0x80),
  47492 	223:  uint8(0x80),
  47493 	224:  uint8(0x80),
  47494 	225:  uint8(0x80),
  47495 	226:  uint8(0x80),
  47496 	227:  uint8(0x80),
  47497 	228:  uint8(0x80),
  47498 	229:  uint8(0x80),
  47499 	230:  uint8(0x80),
  47500 	231:  uint8(0x80),
  47501 	232:  uint8(0x80),
  47502 	233:  uint8(0x80),
  47503 	234:  uint8(0x80),
  47504 	235:  uint8(0x80),
  47505 	236:  uint8(0x80),
  47506 	237:  uint8(0x80),
  47507 	238:  uint8(0x80),
  47508 	239:  uint8(0x80),
  47509 	240:  uint8(0x80),
  47510 	241:  uint8(0x80),
  47511 	242:  uint8(0x80),
  47512 	243:  uint8(0x80),
  47513 	244:  uint8(0x80),
  47514 	245:  uint8(0x80),
  47515 	246:  uint8(0x80),
  47516 	247:  uint8(0x80),
  47517 	248:  uint8(0x80),
  47518 	249:  uint8(0x80),
  47519 	250:  uint8(0x80),
  47520 	251:  uint8(0x80),
  47521 	252:  uint8(0x80),
  47522 	253:  uint8(0x80),
  47523 	254:  uint8(0x80),
  47524 	255:  uint8(0x80),
  47525 	256:  uint8(0x80),
  47526 	257:  uint8(0x80),
  47527 	258:  uint8(0x80),
  47528 	259:  uint8(0x80),
  47529 	260:  uint8(0x80),
  47530 	261:  uint8(0x80),
  47531 	262:  uint8(0x80),
  47532 	263:  uint8(0x80),
  47533 	264:  uint8(0x80),
  47534 	265:  uint8(0x80),
  47535 	266:  uint8(0x80),
  47536 	267:  uint8(0x80),
  47537 	268:  uint8(0x80),
  47538 	269:  uint8(0x80),
  47539 	270:  uint8(0x80),
  47540 	271:  uint8(0x80),
  47541 	272:  uint8(0x80),
  47542 	273:  uint8(0x80),
  47543 	274:  uint8(0x80),
  47544 	275:  uint8(0x80),
  47545 	276:  uint8(0x80),
  47546 	277:  uint8(0x80),
  47547 	278:  uint8(0x80),
  47548 	279:  uint8(0x80),
  47549 	280:  uint8(0x80),
  47550 	281:  uint8(0x80),
  47551 	282:  uint8(0x80),
  47552 	283:  uint8(0x80),
  47553 	284:  uint8(0x80),
  47554 	285:  uint8(0x80),
  47555 	286:  uint8(0x80),
  47556 	287:  uint8(0x80),
  47557 	288:  uint8(0x80),
  47558 	289:  uint8(0x80),
  47559 	290:  uint8(0x80),
  47560 	291:  uint8(0x80),
  47561 	292:  uint8(0x80),
  47562 	293:  uint8(0x80),
  47563 	294:  uint8(0x80),
  47564 	295:  uint8(0x80),
  47565 	296:  uint8(0x80),
  47566 	297:  uint8(0x80),
  47567 	298:  uint8(0x80),
  47568 	299:  uint8(0x80),
  47569 	300:  uint8(0x80),
  47570 	301:  uint8(0x80),
  47571 	302:  uint8(0x80),
  47572 	303:  uint8(0x80),
  47573 	304:  uint8(0x80),
  47574 	305:  uint8(0x80),
  47575 	306:  uint8(0x80),
  47576 	307:  uint8(0x80),
  47577 	308:  uint8(0x80),
  47578 	309:  uint8(0x80),
  47579 	310:  uint8(0x80),
  47580 	311:  uint8(0x80),
  47581 	312:  uint8(0x80),
  47582 	313:  uint8(0x80),
  47583 	314:  uint8(0x80),
  47584 	315:  uint8(0x80),
  47585 	316:  uint8(0x80),
  47586 	317:  uint8(0x80),
  47587 	318:  uint8(0x80),
  47588 	319:  uint8(0x80),
  47589 	320:  uint8(0x80),
  47590 	321:  uint8(0x80),
  47591 	322:  uint8(0x80),
  47592 	323:  uint8(0x80),
  47593 	324:  uint8(0x80),
  47594 	325:  uint8(0x80),
  47595 	326:  uint8(0x80),
  47596 	327:  uint8(0x80),
  47597 	328:  uint8(0x80),
  47598 	329:  uint8(0x80),
  47599 	330:  uint8(0x80),
  47600 	331:  uint8(0x80),
  47601 	332:  uint8(0x80),
  47602 	333:  uint8(0x80),
  47603 	334:  uint8(0x80),
  47604 	335:  uint8(0x80),
  47605 	336:  uint8(0x80),
  47606 	337:  uint8(0x80),
  47607 	338:  uint8(0x80),
  47608 	339:  uint8(0x80),
  47609 	340:  uint8(0x80),
  47610 	341:  uint8(0x80),
  47611 	342:  uint8(0x80),
  47612 	343:  uint8(0x80),
  47613 	344:  uint8(0x80),
  47614 	345:  uint8(0x80),
  47615 	346:  uint8(0x80),
  47616 	347:  uint8(0x80),
  47617 	348:  uint8(0x80),
  47618 	349:  uint8(0x80),
  47619 	350:  uint8(0x80),
  47620 	351:  uint8(0x80),
  47621 	352:  uint8(0x80),
  47622 	353:  uint8(0x80),
  47623 	354:  uint8(0x80),
  47624 	355:  uint8(0x80),
  47625 	356:  uint8(0x80),
  47626 	357:  uint8(0x80),
  47627 	358:  uint8(0x80),
  47628 	359:  uint8(0x80),
  47629 	360:  uint8(0x80),
  47630 	361:  uint8(0x80),
  47631 	362:  uint8(0x80),
  47632 	363:  uint8(0x80),
  47633 	364:  uint8(0x80),
  47634 	365:  uint8(0x80),
  47635 	366:  uint8(0x80),
  47636 	367:  uint8(0x80),
  47637 	368:  uint8(0x80),
  47638 	369:  uint8(0x80),
  47639 	370:  uint8(0x80),
  47640 	371:  uint8(0x80),
  47641 	372:  uint8(0x80),
  47642 	373:  uint8(0x80),
  47643 	374:  uint8(0x80),
  47644 	375:  uint8(0x80),
  47645 	376:  uint8(0x80),
  47646 	377:  uint8(0x80),
  47647 	378:  uint8(0x80),
  47648 	379:  uint8(0x80),
  47649 	380:  uint8(0x80),
  47650 	381:  uint8(0x80),
  47651 	382:  uint8(0x80),
  47652 	383:  uint8(0x80),
  47653 	384:  uint8(0x80),
  47654 	385:  uint8(0x80),
  47655 	386:  uint8(0x80),
  47656 	387:  uint8(0x80),
  47657 	388:  uint8(0x80),
  47658 	389:  uint8(0x80),
  47659 	390:  uint8(0x80),
  47660 	391:  uint8(0x80),
  47661 	392:  uint8(0x80),
  47662 	393:  uint8(0x80),
  47663 	394:  uint8(0x80),
  47664 	395:  uint8(0x80),
  47665 	396:  uint8(0x80),
  47666 	397:  uint8(0x80),
  47667 	398:  uint8(0x80),
  47668 	399:  uint8(0x80),
  47669 	400:  uint8(0x80),
  47670 	401:  uint8(0x80),
  47671 	402:  uint8(0x80),
  47672 	403:  uint8(0x80),
  47673 	404:  uint8(0x80),
  47674 	405:  uint8(0x80),
  47675 	406:  uint8(0x80),
  47676 	407:  uint8(0x80),
  47677 	408:  uint8(0x80),
  47678 	409:  uint8(0x80),
  47679 	410:  uint8(0x80),
  47680 	411:  uint8(0x80),
  47681 	412:  uint8(0x80),
  47682 	413:  uint8(0x80),
  47683 	414:  uint8(0x80),
  47684 	415:  uint8(0x80),
  47685 	416:  uint8(0x80),
  47686 	417:  uint8(0x80),
  47687 	418:  uint8(0x80),
  47688 	419:  uint8(0x80),
  47689 	420:  uint8(0x80),
  47690 	421:  uint8(0x80),
  47691 	422:  uint8(0x80),
  47692 	423:  uint8(0x80),
  47693 	424:  uint8(0x80),
  47694 	425:  uint8(0x80),
  47695 	426:  uint8(0x80),
  47696 	427:  uint8(0x80),
  47697 	428:  uint8(0x80),
  47698 	429:  uint8(0x80),
  47699 	430:  uint8(0x80),
  47700 	431:  uint8(0x80),
  47701 	432:  uint8(0x80),
  47702 	433:  uint8(0x80),
  47703 	434:  uint8(0x80),
  47704 	435:  uint8(0x80),
  47705 	436:  uint8(0x80),
  47706 	437:  uint8(0x80),
  47707 	438:  uint8(0x80),
  47708 	439:  uint8(0x80),
  47709 	440:  uint8(0x80),
  47710 	441:  uint8(0x80),
  47711 	442:  uint8(0x80),
  47712 	443:  uint8(0x80),
  47713 	444:  uint8(0x80),
  47714 	445:  uint8(0x80),
  47715 	446:  uint8(0x80),
  47716 	447:  uint8(0x80),
  47717 	448:  uint8(0x80),
  47718 	449:  uint8(0x80),
  47719 	450:  uint8(0x80),
  47720 	451:  uint8(0x80),
  47721 	452:  uint8(0x80),
  47722 	453:  uint8(0x80),
  47723 	454:  uint8(0x80),
  47724 	455:  uint8(0x80),
  47725 	456:  uint8(0x80),
  47726 	457:  uint8(0x80),
  47727 	458:  uint8(0x80),
  47728 	459:  uint8(0x80),
  47729 	460:  uint8(0x80),
  47730 	461:  uint8(0x80),
  47731 	462:  uint8(0x80),
  47732 	463:  uint8(0x80),
  47733 	464:  uint8(0x80),
  47734 	465:  uint8(0x80),
  47735 	466:  uint8(0x80),
  47736 	467:  uint8(0x80),
  47737 	468:  uint8(0x80),
  47738 	469:  uint8(0x80),
  47739 	470:  uint8(0x80),
  47740 	471:  uint8(0x80),
  47741 	472:  uint8(0x80),
  47742 	473:  uint8(0x80),
  47743 	474:  uint8(0x80),
  47744 	475:  uint8(0x80),
  47745 	476:  uint8(0x80),
  47746 	477:  uint8(0x80),
  47747 	478:  uint8(0x80),
  47748 	479:  uint8(0x80),
  47749 	480:  uint8(0x80),
  47750 	481:  uint8(0x80),
  47751 	482:  uint8(0x80),
  47752 	483:  uint8(0x80),
  47753 	484:  uint8(0x80),
  47754 	485:  uint8(0x80),
  47755 	486:  uint8(0x80),
  47756 	487:  uint8(0x80),
  47757 	488:  uint8(0x80),
  47758 	489:  uint8(0x80),
  47759 	490:  uint8(0x80),
  47760 	491:  uint8(0x80),
  47761 	492:  uint8(0x80),
  47762 	493:  uint8(0x80),
  47763 	494:  uint8(0x80),
  47764 	495:  uint8(0x80),
  47765 	496:  uint8(0x80),
  47766 	497:  uint8(0x80),
  47767 	498:  uint8(0x80),
  47768 	499:  uint8(0x80),
  47769 	500:  uint8(0x80),
  47770 	501:  uint8(0x80),
  47771 	502:  uint8(0x80),
  47772 	503:  uint8(0x80),
  47773 	504:  uint8(0x80),
  47774 	505:  uint8(0x80),
  47775 	506:  uint8(0x80),
  47776 	507:  uint8(0x80),
  47777 	508:  uint8(0x80),
  47778 	509:  uint8(0x80),
  47779 	510:  uint8(0x80),
  47780 	511:  uint8(0x80),
  47781 	512:  uint8(0x80),
  47782 	513:  uint8(0x80),
  47783 	514:  uint8(0x80),
  47784 	515:  uint8(0x80),
  47785 	516:  uint8(0x80),
  47786 	517:  uint8(0x80),
  47787 	518:  uint8(0x80),
  47788 	519:  uint8(0x80),
  47789 	520:  uint8(0x80),
  47790 	521:  uint8(0x80),
  47791 	522:  uint8(0x80),
  47792 	523:  uint8(0x80),
  47793 	524:  uint8(0x80),
  47794 	525:  uint8(0x80),
  47795 	526:  uint8(0x80),
  47796 	527:  uint8(0x80),
  47797 	528:  uint8(0x80),
  47798 	529:  uint8(0x80),
  47799 	530:  uint8(0x80),
  47800 	531:  uint8(0x80),
  47801 	532:  uint8(0x80),
  47802 	533:  uint8(0x80),
  47803 	534:  uint8(0x80),
  47804 	535:  uint8(0x80),
  47805 	536:  uint8(0x80),
  47806 	537:  uint8(0x80),
  47807 	538:  uint8(0x80),
  47808 	539:  uint8(0x80),
  47809 	540:  uint8(0x80),
  47810 	541:  uint8(0x80),
  47811 	542:  uint8(0x80),
  47812 	543:  uint8(0x80),
  47813 	544:  uint8(0x80),
  47814 	545:  uint8(0x80),
  47815 	546:  uint8(0x80),
  47816 	547:  uint8(0x80),
  47817 	548:  uint8(0x80),
  47818 	549:  uint8(0x80),
  47819 	550:  uint8(0x80),
  47820 	551:  uint8(0x80),
  47821 	552:  uint8(0x80),
  47822 	553:  uint8(0x80),
  47823 	554:  uint8(0x80),
  47824 	555:  uint8(0x80),
  47825 	556:  uint8(0x80),
  47826 	557:  uint8(0x80),
  47827 	558:  uint8(0x80),
  47828 	559:  uint8(0x80),
  47829 	560:  uint8(0x80),
  47830 	561:  uint8(0x80),
  47831 	562:  uint8(0x80),
  47832 	563:  uint8(0x80),
  47833 	564:  uint8(0x80),
  47834 	565:  uint8(0x80),
  47835 	566:  uint8(0x80),
  47836 	567:  uint8(0x80),
  47837 	568:  uint8(0x80),
  47838 	569:  uint8(0x80),
  47839 	570:  uint8(0x80),
  47840 	571:  uint8(0x80),
  47841 	572:  uint8(0x80),
  47842 	573:  uint8(0x80),
  47843 	574:  uint8(0x80),
  47844 	575:  uint8(0x80),
  47845 	576:  uint8(0x80),
  47846 	577:  uint8(0x80),
  47847 	578:  uint8(0x80),
  47848 	579:  uint8(0x80),
  47849 	580:  uint8(0x80),
  47850 	581:  uint8(0x80),
  47851 	582:  uint8(0x80),
  47852 	583:  uint8(0x80),
  47853 	584:  uint8(0x80),
  47854 	585:  uint8(0x80),
  47855 	586:  uint8(0x80),
  47856 	587:  uint8(0x80),
  47857 	588:  uint8(0x80),
  47858 	589:  uint8(0x80),
  47859 	590:  uint8(0x80),
  47860 	591:  uint8(0x80),
  47861 	592:  uint8(0x80),
  47862 	593:  uint8(0x80),
  47863 	594:  uint8(0x80),
  47864 	595:  uint8(0x80),
  47865 	596:  uint8(0x80),
  47866 	597:  uint8(0x80),
  47867 	598:  uint8(0x80),
  47868 	599:  uint8(0x80),
  47869 	600:  uint8(0x80),
  47870 	601:  uint8(0x80),
  47871 	602:  uint8(0x80),
  47872 	603:  uint8(0x80),
  47873 	604:  uint8(0x80),
  47874 	605:  uint8(0x80),
  47875 	606:  uint8(0x80),
  47876 	607:  uint8(0x80),
  47877 	608:  uint8(0x80),
  47878 	609:  uint8(0x80),
  47879 	610:  uint8(0x80),
  47880 	611:  uint8(0x80),
  47881 	612:  uint8(0x80),
  47882 	613:  uint8(0x80),
  47883 	614:  uint8(0x80),
  47884 	615:  uint8(0x80),
  47885 	616:  uint8(0x80),
  47886 	617:  uint8(0x80),
  47887 	618:  uint8(0x80),
  47888 	619:  uint8(0x80),
  47889 	620:  uint8(0x80),
  47890 	621:  uint8(0x80),
  47891 	622:  uint8(0x80),
  47892 	623:  uint8(0x80),
  47893 	624:  uint8(0x80),
  47894 	625:  uint8(0x80),
  47895 	626:  uint8(0x80),
  47896 	627:  uint8(0x80),
  47897 	628:  uint8(0x80),
  47898 	629:  uint8(0x80),
  47899 	630:  uint8(0x80),
  47900 	631:  uint8(0x80),
  47901 	632:  uint8(0x80),
  47902 	633:  uint8(0x80),
  47903 	634:  uint8(0x80),
  47904 	635:  uint8(0x80),
  47905 	636:  uint8(0x80),
  47906 	637:  uint8(0x80),
  47907 	638:  uint8(0x80),
  47908 	639:  uint8(0x80),
  47909 	640:  uint8(0x80),
  47910 	641:  uint8(0x80),
  47911 	642:  uint8(0x80),
  47912 	643:  uint8(0x80),
  47913 	644:  uint8(0x80),
  47914 	645:  uint8(0x80),
  47915 	646:  uint8(0x80),
  47916 	647:  uint8(0x80),
  47917 	648:  uint8(0x80),
  47918 	649:  uint8(0x80),
  47919 	650:  uint8(0x80),
  47920 	651:  uint8(0x80),
  47921 	652:  uint8(0x80),
  47922 	653:  uint8(0x80),
  47923 	654:  uint8(0x80),
  47924 	655:  uint8(0x80),
  47925 	656:  uint8(0x80),
  47926 	657:  uint8(0x80),
  47927 	658:  uint8(0x80),
  47928 	659:  uint8(0x80),
  47929 	660:  uint8(0x80),
  47930 	661:  uint8(0x80),
  47931 	662:  uint8(0x80),
  47932 	663:  uint8(0x80),
  47933 	664:  uint8(0x80),
  47934 	665:  uint8(0x80),
  47935 	666:  uint8(0x80),
  47936 	667:  uint8(0x80),
  47937 	668:  uint8(0x80),
  47938 	669:  uint8(0x80),
  47939 	670:  uint8(0x80),
  47940 	671:  uint8(0x80),
  47941 	672:  uint8(0x80),
  47942 	673:  uint8(0x80),
  47943 	674:  uint8(0x80),
  47944 	675:  uint8(0x80),
  47945 	676:  uint8(0x80),
  47946 	677:  uint8(0x80),
  47947 	678:  uint8(0x80),
  47948 	679:  uint8(0x80),
  47949 	680:  uint8(0x80),
  47950 	681:  uint8(0x80),
  47951 	682:  uint8(0x80),
  47952 	683:  uint8(0x80),
  47953 	684:  uint8(0x80),
  47954 	685:  uint8(0x80),
  47955 	686:  uint8(0x80),
  47956 	687:  uint8(0x80),
  47957 	688:  uint8(0x80),
  47958 	689:  uint8(0x80),
  47959 	690:  uint8(0x80),
  47960 	691:  uint8(0x80),
  47961 	692:  uint8(0x80),
  47962 	693:  uint8(0x80),
  47963 	694:  uint8(0x80),
  47964 	695:  uint8(0x80),
  47965 	696:  uint8(0x80),
  47966 	697:  uint8(0x80),
  47967 	698:  uint8(0x80),
  47968 	699:  uint8(0x80),
  47969 	700:  uint8(0x80),
  47970 	701:  uint8(0x80),
  47971 	702:  uint8(0x80),
  47972 	703:  uint8(0x80),
  47973 	704:  uint8(0x80),
  47974 	705:  uint8(0x80),
  47975 	706:  uint8(0x80),
  47976 	707:  uint8(0x80),
  47977 	708:  uint8(0x80),
  47978 	709:  uint8(0x80),
  47979 	710:  uint8(0x80),
  47980 	711:  uint8(0x80),
  47981 	712:  uint8(0x80),
  47982 	713:  uint8(0x80),
  47983 	714:  uint8(0x80),
  47984 	715:  uint8(0x80),
  47985 	716:  uint8(0x80),
  47986 	717:  uint8(0x80),
  47987 	718:  uint8(0x80),
  47988 	719:  uint8(0x80),
  47989 	720:  uint8(0x80),
  47990 	721:  uint8(0x80),
  47991 	722:  uint8(0x80),
  47992 	723:  uint8(0x80),
  47993 	724:  uint8(0x80),
  47994 	725:  uint8(0x80),
  47995 	726:  uint8(0x80),
  47996 	727:  uint8(0x80),
  47997 	728:  uint8(0x80),
  47998 	729:  uint8(0x80),
  47999 	730:  uint8(0x80),
  48000 	731:  uint8(0x80),
  48001 	732:  uint8(0x80),
  48002 	733:  uint8(0x80),
  48003 	734:  uint8(0x80),
  48004 	735:  uint8(0x80),
  48005 	736:  uint8(0x80),
  48006 	737:  uint8(0x80),
  48007 	738:  uint8(0x80),
  48008 	739:  uint8(0x80),
  48009 	740:  uint8(0x80),
  48010 	741:  uint8(0x80),
  48011 	742:  uint8(0x80),
  48012 	743:  uint8(0x80),
  48013 	744:  uint8(0x80),
  48014 	745:  uint8(0x80),
  48015 	746:  uint8(0x80),
  48016 	747:  uint8(0x80),
  48017 	748:  uint8(0x80),
  48018 	749:  uint8(0x80),
  48019 	750:  uint8(0x80),
  48020 	751:  uint8(0x80),
  48021 	752:  uint8(0x80),
  48022 	753:  uint8(0x80),
  48023 	754:  uint8(0x80),
  48024 	755:  uint8(0x80),
  48025 	756:  uint8(0x80),
  48026 	757:  uint8(0x80),
  48027 	758:  uint8(0x80),
  48028 	759:  uint8(0x80),
  48029 	760:  uint8(0x80),
  48030 	761:  uint8(0x80),
  48031 	762:  uint8(0x80),
  48032 	763:  uint8(0x80),
  48033 	764:  uint8(0x80),
  48034 	765:  uint8(0x80),
  48035 	766:  uint8(0x80),
  48036 	767:  uint8(0x80),
  48037 	768:  uint8(0x80),
  48038 	769:  uint8(0x80),
  48039 	770:  uint8(0x80),
  48040 	771:  uint8(0x80),
  48041 	772:  uint8(0x80),
  48042 	773:  uint8(0x80),
  48043 	774:  uint8(0x80),
  48044 	775:  uint8(0x80),
  48045 	776:  uint8(0x80),
  48046 	777:  uint8(0x80),
  48047 	778:  uint8(0x80),
  48048 	779:  uint8(0x80),
  48049 	780:  uint8(0x80),
  48050 	781:  uint8(0x80),
  48051 	782:  uint8(0x80),
  48052 	783:  uint8(0x80),
  48053 	784:  uint8(0x80),
  48054 	785:  uint8(0x80),
  48055 	786:  uint8(0x80),
  48056 	787:  uint8(0x80),
  48057 	788:  uint8(0x80),
  48058 	789:  uint8(0x80),
  48059 	790:  uint8(0x80),
  48060 	791:  uint8(0x80),
  48061 	792:  uint8(0x80),
  48062 	793:  uint8(0x80),
  48063 	794:  uint8(0x80),
  48064 	795:  uint8(0x80),
  48065 	796:  uint8(0x80),
  48066 	797:  uint8(0x80),
  48067 	798:  uint8(0x80),
  48068 	799:  uint8(0x80),
  48069 	800:  uint8(0x80),
  48070 	801:  uint8(0x80),
  48071 	802:  uint8(0x80),
  48072 	803:  uint8(0x80),
  48073 	804:  uint8(0x80),
  48074 	805:  uint8(0x80),
  48075 	806:  uint8(0x80),
  48076 	807:  uint8(0x80),
  48077 	808:  uint8(0x80),
  48078 	809:  uint8(0x80),
  48079 	810:  uint8(0x80),
  48080 	811:  uint8(0x80),
  48081 	812:  uint8(0x80),
  48082 	813:  uint8(0x80),
  48083 	814:  uint8(0x80),
  48084 	815:  uint8(0x80),
  48085 	816:  uint8(0x80),
  48086 	817:  uint8(0x80),
  48087 	818:  uint8(0x80),
  48088 	819:  uint8(0x80),
  48089 	820:  uint8(0x80),
  48090 	821:  uint8(0x80),
  48091 	822:  uint8(0x80),
  48092 	823:  uint8(0x80),
  48093 	824:  uint8(0x80),
  48094 	825:  uint8(0x80),
  48095 	826:  uint8(0x80),
  48096 	827:  uint8(0x80),
  48097 	828:  uint8(0x80),
  48098 	829:  uint8(0x80),
  48099 	830:  uint8(0x80),
  48100 	831:  uint8(0x80),
  48101 	832:  uint8(0x80),
  48102 	833:  uint8(0x80),
  48103 	834:  uint8(0x80),
  48104 	835:  uint8(0x80),
  48105 	836:  uint8(0x80),
  48106 	837:  uint8(0x80),
  48107 	838:  uint8(0x80),
  48108 	839:  uint8(0x80),
  48109 	840:  uint8(0x80),
  48110 	841:  uint8(0x80),
  48111 	842:  uint8(0x80),
  48112 	843:  uint8(0x80),
  48113 	844:  uint8(0x80),
  48114 	845:  uint8(0x80),
  48115 	846:  uint8(0x80),
  48116 	847:  uint8(0x80),
  48117 	848:  uint8(0x80),
  48118 	849:  uint8(0x80),
  48119 	850:  uint8(0x80),
  48120 	851:  uint8(0x80),
  48121 	852:  uint8(0x80),
  48122 	853:  uint8(0x80),
  48123 	854:  uint8(0x80),
  48124 	855:  uint8(0x80),
  48125 	856:  uint8(0x80),
  48126 	857:  uint8(0x80),
  48127 	858:  uint8(0x80),
  48128 	859:  uint8(0x80),
  48129 	860:  uint8(0x80),
  48130 	861:  uint8(0x80),
  48131 	862:  uint8(0x80),
  48132 	863:  uint8(0x80),
  48133 	864:  uint8(0x80),
  48134 	865:  uint8(0x80),
  48135 	866:  uint8(0x80),
  48136 	867:  uint8(0x80),
  48137 	868:  uint8(0x80),
  48138 	869:  uint8(0x80),
  48139 	870:  uint8(0x80),
  48140 	871:  uint8(0x80),
  48141 	872:  uint8(0x80),
  48142 	873:  uint8(0x80),
  48143 	874:  uint8(0x80),
  48144 	875:  uint8(0x80),
  48145 	876:  uint8(0x80),
  48146 	877:  uint8(0x80),
  48147 	878:  uint8(0x80),
  48148 	879:  uint8(0x80),
  48149 	880:  uint8(0x80),
  48150 	881:  uint8(0x80),
  48151 	882:  uint8(0x80),
  48152 	883:  uint8(0x80),
  48153 	884:  uint8(0x80),
  48154 	885:  uint8(0x80),
  48155 	886:  uint8(0x80),
  48156 	887:  uint8(0x80),
  48157 	888:  uint8(0x80),
  48158 	889:  uint8(0x80),
  48159 	890:  uint8(0x80),
  48160 	891:  uint8(0x80),
  48161 	892:  uint8(0x80),
  48162 	893:  uint8(0x81),
  48163 	894:  uint8(0x82),
  48164 	895:  uint8(0x83),
  48165 	896:  uint8(0x84),
  48166 	897:  uint8(0x85),
  48167 	898:  uint8(0x86),
  48168 	899:  uint8(0x87),
  48169 	900:  uint8(0x88),
  48170 	901:  uint8(0x89),
  48171 	902:  uint8(0x8a),
  48172 	903:  uint8(0x8b),
  48173 	904:  uint8(0x8c),
  48174 	905:  uint8(0x8d),
  48175 	906:  uint8(0x8e),
  48176 	907:  uint8(0x8f),
  48177 	908:  uint8(0x90),
  48178 	909:  uint8(0x91),
  48179 	910:  uint8(0x92),
  48180 	911:  uint8(0x93),
  48181 	912:  uint8(0x94),
  48182 	913:  uint8(0x95),
  48183 	914:  uint8(0x96),
  48184 	915:  uint8(0x97),
  48185 	916:  uint8(0x98),
  48186 	917:  uint8(0x99),
  48187 	918:  uint8(0x9a),
  48188 	919:  uint8(0x9b),
  48189 	920:  uint8(0x9c),
  48190 	921:  uint8(0x9d),
  48191 	922:  uint8(0x9e),
  48192 	923:  uint8(0x9f),
  48193 	924:  uint8(0xa0),
  48194 	925:  uint8(0xa1),
  48195 	926:  uint8(0xa2),
  48196 	927:  uint8(0xa3),
  48197 	928:  uint8(0xa4),
  48198 	929:  uint8(0xa5),
  48199 	930:  uint8(0xa6),
  48200 	931:  uint8(0xa7),
  48201 	932:  uint8(0xa8),
  48202 	933:  uint8(0xa9),
  48203 	934:  uint8(0xaa),
  48204 	935:  uint8(0xab),
  48205 	936:  uint8(0xac),
  48206 	937:  uint8(0xad),
  48207 	938:  uint8(0xae),
  48208 	939:  uint8(0xaf),
  48209 	940:  uint8(0xb0),
  48210 	941:  uint8(0xb1),
  48211 	942:  uint8(0xb2),
  48212 	943:  uint8(0xb3),
  48213 	944:  uint8(0xb4),
  48214 	945:  uint8(0xb5),
  48215 	946:  uint8(0xb6),
  48216 	947:  uint8(0xb7),
  48217 	948:  uint8(0xb8),
  48218 	949:  uint8(0xb9),
  48219 	950:  uint8(0xba),
  48220 	951:  uint8(0xbb),
  48221 	952:  uint8(0xbc),
  48222 	953:  uint8(0xbd),
  48223 	954:  uint8(0xbe),
  48224 	955:  uint8(0xbf),
  48225 	956:  uint8(0xc0),
  48226 	957:  uint8(0xc1),
  48227 	958:  uint8(0xc2),
  48228 	959:  uint8(0xc3),
  48229 	960:  uint8(0xc4),
  48230 	961:  uint8(0xc5),
  48231 	962:  uint8(0xc6),
  48232 	963:  uint8(0xc7),
  48233 	964:  uint8(0xc8),
  48234 	965:  uint8(0xc9),
  48235 	966:  uint8(0xca),
  48236 	967:  uint8(0xcb),
  48237 	968:  uint8(0xcc),
  48238 	969:  uint8(0xcd),
  48239 	970:  uint8(0xce),
  48240 	971:  uint8(0xcf),
  48241 	972:  uint8(0xd0),
  48242 	973:  uint8(0xd1),
  48243 	974:  uint8(0xd2),
  48244 	975:  uint8(0xd3),
  48245 	976:  uint8(0xd4),
  48246 	977:  uint8(0xd5),
  48247 	978:  uint8(0xd6),
  48248 	979:  uint8(0xd7),
  48249 	980:  uint8(0xd8),
  48250 	981:  uint8(0xd9),
  48251 	982:  uint8(0xda),
  48252 	983:  uint8(0xdb),
  48253 	984:  uint8(0xdc),
  48254 	985:  uint8(0xdd),
  48255 	986:  uint8(0xde),
  48256 	987:  uint8(0xdf),
  48257 	988:  uint8(0xe0),
  48258 	989:  uint8(0xe1),
  48259 	990:  uint8(0xe2),
  48260 	991:  uint8(0xe3),
  48261 	992:  uint8(0xe4),
  48262 	993:  uint8(0xe5),
  48263 	994:  uint8(0xe6),
  48264 	995:  uint8(0xe7),
  48265 	996:  uint8(0xe8),
  48266 	997:  uint8(0xe9),
  48267 	998:  uint8(0xea),
  48268 	999:  uint8(0xeb),
  48269 	1000: uint8(0xec),
  48270 	1001: uint8(0xed),
  48271 	1002: uint8(0xee),
  48272 	1003: uint8(0xef),
  48273 	1004: uint8(0xf0),
  48274 	1005: uint8(0xf1),
  48275 	1006: uint8(0xf2),
  48276 	1007: uint8(0xf3),
  48277 	1008: uint8(0xf4),
  48278 	1009: uint8(0xf5),
  48279 	1010: uint8(0xf6),
  48280 	1011: uint8(0xf7),
  48281 	1012: uint8(0xf8),
  48282 	1013: uint8(0xf9),
  48283 	1014: uint8(0xfa),
  48284 	1015: uint8(0xfb),
  48285 	1016: uint8(0xfc),
  48286 	1017: uint8(0xfd),
  48287 	1018: uint8(0xfe),
  48288 	1019: uint8(0xff),
  48289 	1021: uint8(0x01),
  48290 	1022: uint8(0x02),
  48291 	1023: uint8(0x03),
  48292 	1024: uint8(0x04),
  48293 	1025: uint8(0x05),
  48294 	1026: uint8(0x06),
  48295 	1027: uint8(0x07),
  48296 	1028: uint8(0x08),
  48297 	1029: uint8(0x09),
  48298 	1030: uint8(0x0a),
  48299 	1031: uint8(0x0b),
  48300 	1032: uint8(0x0c),
  48301 	1033: uint8(0x0d),
  48302 	1034: uint8(0x0e),
  48303 	1035: uint8(0x0f),
  48304 	1036: uint8(0x10),
  48305 	1037: uint8(0x11),
  48306 	1038: uint8(0x12),
  48307 	1039: uint8(0x13),
  48308 	1040: uint8(0x14),
  48309 	1041: uint8(0x15),
  48310 	1042: uint8(0x16),
  48311 	1043: uint8(0x17),
  48312 	1044: uint8(0x18),
  48313 	1045: uint8(0x19),
  48314 	1046: uint8(0x1a),
  48315 	1047: uint8(0x1b),
  48316 	1048: uint8(0x1c),
  48317 	1049: uint8(0x1d),
  48318 	1050: uint8(0x1e),
  48319 	1051: uint8(0x1f),
  48320 	1052: uint8(0x20),
  48321 	1053: uint8(0x21),
  48322 	1054: uint8(0x22),
  48323 	1055: uint8(0x23),
  48324 	1056: uint8(0x24),
  48325 	1057: uint8(0x25),
  48326 	1058: uint8(0x26),
  48327 	1059: uint8(0x27),
  48328 	1060: uint8(0x28),
  48329 	1061: uint8(0x29),
  48330 	1062: uint8(0x2a),
  48331 	1063: uint8(0x2b),
  48332 	1064: uint8(0x2c),
  48333 	1065: uint8(0x2d),
  48334 	1066: uint8(0x2e),
  48335 	1067: uint8(0x2f),
  48336 	1068: uint8(0x30),
  48337 	1069: uint8(0x31),
  48338 	1070: uint8(0x32),
  48339 	1071: uint8(0x33),
  48340 	1072: uint8(0x34),
  48341 	1073: uint8(0x35),
  48342 	1074: uint8(0x36),
  48343 	1075: uint8(0x37),
  48344 	1076: uint8(0x38),
  48345 	1077: uint8(0x39),
  48346 	1078: uint8(0x3a),
  48347 	1079: uint8(0x3b),
  48348 	1080: uint8(0x3c),
  48349 	1081: uint8(0x3d),
  48350 	1082: uint8(0x3e),
  48351 	1083: uint8(0x3f),
  48352 	1084: uint8(0x40),
  48353 	1085: uint8(0x41),
  48354 	1086: uint8(0x42),
  48355 	1087: uint8(0x43),
  48356 	1088: uint8(0x44),
  48357 	1089: uint8(0x45),
  48358 	1090: uint8(0x46),
  48359 	1091: uint8(0x47),
  48360 	1092: uint8(0x48),
  48361 	1093: uint8(0x49),
  48362 	1094: uint8(0x4a),
  48363 	1095: uint8(0x4b),
  48364 	1096: uint8(0x4c),
  48365 	1097: uint8(0x4d),
  48366 	1098: uint8(0x4e),
  48367 	1099: uint8(0x4f),
  48368 	1100: uint8(0x50),
  48369 	1101: uint8(0x51),
  48370 	1102: uint8(0x52),
  48371 	1103: uint8(0x53),
  48372 	1104: uint8(0x54),
  48373 	1105: uint8(0x55),
  48374 	1106: uint8(0x56),
  48375 	1107: uint8(0x57),
  48376 	1108: uint8(0x58),
  48377 	1109: uint8(0x59),
  48378 	1110: uint8(0x5a),
  48379 	1111: uint8(0x5b),
  48380 	1112: uint8(0x5c),
  48381 	1113: uint8(0x5d),
  48382 	1114: uint8(0x5e),
  48383 	1115: uint8(0x5f),
  48384 	1116: uint8(0x60),
  48385 	1117: uint8(0x61),
  48386 	1118: uint8(0x62),
  48387 	1119: uint8(0x63),
  48388 	1120: uint8(0x64),
  48389 	1121: uint8(0x65),
  48390 	1122: uint8(0x66),
  48391 	1123: uint8(0x67),
  48392 	1124: uint8(0x68),
  48393 	1125: uint8(0x69),
  48394 	1126: uint8(0x6a),
  48395 	1127: uint8(0x6b),
  48396 	1128: uint8(0x6c),
  48397 	1129: uint8(0x6d),
  48398 	1130: uint8(0x6e),
  48399 	1131: uint8(0x6f),
  48400 	1132: uint8(0x70),
  48401 	1133: uint8(0x71),
  48402 	1134: uint8(0x72),
  48403 	1135: uint8(0x73),
  48404 	1136: uint8(0x74),
  48405 	1137: uint8(0x75),
  48406 	1138: uint8(0x76),
  48407 	1139: uint8(0x77),
  48408 	1140: uint8(0x78),
  48409 	1141: uint8(0x79),
  48410 	1142: uint8(0x7a),
  48411 	1143: uint8(0x7b),
  48412 	1144: uint8(0x7c),
  48413 	1145: uint8(0x7d),
  48414 	1146: uint8(0x7e),
  48415 	1147: uint8(0x7f),
  48416 	1148: uint8(0x7f),
  48417 	1149: uint8(0x7f),
  48418 	1150: uint8(0x7f),
  48419 	1151: uint8(0x7f),
  48420 	1152: uint8(0x7f),
  48421 	1153: uint8(0x7f),
  48422 	1154: uint8(0x7f),
  48423 	1155: uint8(0x7f),
  48424 	1156: uint8(0x7f),
  48425 	1157: uint8(0x7f),
  48426 	1158: uint8(0x7f),
  48427 	1159: uint8(0x7f),
  48428 	1160: uint8(0x7f),
  48429 	1161: uint8(0x7f),
  48430 	1162: uint8(0x7f),
  48431 	1163: uint8(0x7f),
  48432 	1164: uint8(0x7f),
  48433 	1165: uint8(0x7f),
  48434 	1166: uint8(0x7f),
  48435 	1167: uint8(0x7f),
  48436 	1168: uint8(0x7f),
  48437 	1169: uint8(0x7f),
  48438 	1170: uint8(0x7f),
  48439 	1171: uint8(0x7f),
  48440 	1172: uint8(0x7f),
  48441 	1173: uint8(0x7f),
  48442 	1174: uint8(0x7f),
  48443 	1175: uint8(0x7f),
  48444 	1176: uint8(0x7f),
  48445 	1177: uint8(0x7f),
  48446 	1178: uint8(0x7f),
  48447 	1179: uint8(0x7f),
  48448 	1180: uint8(0x7f),
  48449 	1181: uint8(0x7f),
  48450 	1182: uint8(0x7f),
  48451 	1183: uint8(0x7f),
  48452 	1184: uint8(0x7f),
  48453 	1185: uint8(0x7f),
  48454 	1186: uint8(0x7f),
  48455 	1187: uint8(0x7f),
  48456 	1188: uint8(0x7f),
  48457 	1189: uint8(0x7f),
  48458 	1190: uint8(0x7f),
  48459 	1191: uint8(0x7f),
  48460 	1192: uint8(0x7f),
  48461 	1193: uint8(0x7f),
  48462 	1194: uint8(0x7f),
  48463 	1195: uint8(0x7f),
  48464 	1196: uint8(0x7f),
  48465 	1197: uint8(0x7f),
  48466 	1198: uint8(0x7f),
  48467 	1199: uint8(0x7f),
  48468 	1200: uint8(0x7f),
  48469 	1201: uint8(0x7f),
  48470 	1202: uint8(0x7f),
  48471 	1203: uint8(0x7f),
  48472 	1204: uint8(0x7f),
  48473 	1205: uint8(0x7f),
  48474 	1206: uint8(0x7f),
  48475 	1207: uint8(0x7f),
  48476 	1208: uint8(0x7f),
  48477 	1209: uint8(0x7f),
  48478 	1210: uint8(0x7f),
  48479 	1211: uint8(0x7f),
  48480 	1212: uint8(0x7f),
  48481 	1213: uint8(0x7f),
  48482 	1214: uint8(0x7f),
  48483 	1215: uint8(0x7f),
  48484 	1216: uint8(0x7f),
  48485 	1217: uint8(0x7f),
  48486 	1218: uint8(0x7f),
  48487 	1219: uint8(0x7f),
  48488 	1220: uint8(0x7f),
  48489 	1221: uint8(0x7f),
  48490 	1222: uint8(0x7f),
  48491 	1223: uint8(0x7f),
  48492 	1224: uint8(0x7f),
  48493 	1225: uint8(0x7f),
  48494 	1226: uint8(0x7f),
  48495 	1227: uint8(0x7f),
  48496 	1228: uint8(0x7f),
  48497 	1229: uint8(0x7f),
  48498 	1230: uint8(0x7f),
  48499 	1231: uint8(0x7f),
  48500 	1232: uint8(0x7f),
  48501 	1233: uint8(0x7f),
  48502 	1234: uint8(0x7f),
  48503 	1235: uint8(0x7f),
  48504 	1236: uint8(0x7f),
  48505 	1237: uint8(0x7f),
  48506 	1238: uint8(0x7f),
  48507 	1239: uint8(0x7f),
  48508 	1240: uint8(0x7f),
  48509 	1241: uint8(0x7f),
  48510 	1242: uint8(0x7f),
  48511 	1243: uint8(0x7f),
  48512 	1244: uint8(0x7f),
  48513 	1245: uint8(0x7f),
  48514 	1246: uint8(0x7f),
  48515 	1247: uint8(0x7f),
  48516 	1248: uint8(0x7f),
  48517 	1249: uint8(0x7f),
  48518 	1250: uint8(0x7f),
  48519 	1251: uint8(0x7f),
  48520 	1252: uint8(0x7f),
  48521 	1253: uint8(0x7f),
  48522 	1254: uint8(0x7f),
  48523 	1255: uint8(0x7f),
  48524 	1256: uint8(0x7f),
  48525 	1257: uint8(0x7f),
  48526 	1258: uint8(0x7f),
  48527 	1259: uint8(0x7f),
  48528 	1260: uint8(0x7f),
  48529 	1261: uint8(0x7f),
  48530 	1262: uint8(0x7f),
  48531 	1263: uint8(0x7f),
  48532 	1264: uint8(0x7f),
  48533 	1265: uint8(0x7f),
  48534 	1266: uint8(0x7f),
  48535 	1267: uint8(0x7f),
  48536 	1268: uint8(0x7f),
  48537 	1269: uint8(0x7f),
  48538 	1270: uint8(0x7f),
  48539 	1271: uint8(0x7f),
  48540 	1272: uint8(0x7f),
  48541 	1273: uint8(0x7f),
  48542 	1274: uint8(0x7f),
  48543 	1275: uint8(0x7f),
  48544 	1276: uint8(0x7f),
  48545 	1277: uint8(0x7f),
  48546 	1278: uint8(0x7f),
  48547 	1279: uint8(0x7f),
  48548 	1280: uint8(0x7f),
  48549 	1281: uint8(0x7f),
  48550 	1282: uint8(0x7f),
  48551 	1283: uint8(0x7f),
  48552 	1284: uint8(0x7f),
  48553 	1285: uint8(0x7f),
  48554 	1286: uint8(0x7f),
  48555 	1287: uint8(0x7f),
  48556 	1288: uint8(0x7f),
  48557 	1289: uint8(0x7f),
  48558 	1290: uint8(0x7f),
  48559 	1291: uint8(0x7f),
  48560 	1292: uint8(0x7f),
  48561 	1293: uint8(0x7f),
  48562 	1294: uint8(0x7f),
  48563 	1295: uint8(0x7f),
  48564 	1296: uint8(0x7f),
  48565 	1297: uint8(0x7f),
  48566 	1298: uint8(0x7f),
  48567 	1299: uint8(0x7f),
  48568 	1300: uint8(0x7f),
  48569 	1301: uint8(0x7f),
  48570 	1302: uint8(0x7f),
  48571 	1303: uint8(0x7f),
  48572 	1304: uint8(0x7f),
  48573 	1305: uint8(0x7f),
  48574 	1306: uint8(0x7f),
  48575 	1307: uint8(0x7f),
  48576 	1308: uint8(0x7f),
  48577 	1309: uint8(0x7f),
  48578 	1310: uint8(0x7f),
  48579 	1311: uint8(0x7f),
  48580 	1312: uint8(0x7f),
  48581 	1313: uint8(0x7f),
  48582 	1314: uint8(0x7f),
  48583 	1315: uint8(0x7f),
  48584 	1316: uint8(0x7f),
  48585 	1317: uint8(0x7f),
  48586 	1318: uint8(0x7f),
  48587 	1319: uint8(0x7f),
  48588 	1320: uint8(0x7f),
  48589 	1321: uint8(0x7f),
  48590 	1322: uint8(0x7f),
  48591 	1323: uint8(0x7f),
  48592 	1324: uint8(0x7f),
  48593 	1325: uint8(0x7f),
  48594 	1326: uint8(0x7f),
  48595 	1327: uint8(0x7f),
  48596 	1328: uint8(0x7f),
  48597 	1329: uint8(0x7f),
  48598 	1330: uint8(0x7f),
  48599 	1331: uint8(0x7f),
  48600 	1332: uint8(0x7f),
  48601 	1333: uint8(0x7f),
  48602 	1334: uint8(0x7f),
  48603 	1335: uint8(0x7f),
  48604 	1336: uint8(0x7f),
  48605 	1337: uint8(0x7f),
  48606 	1338: uint8(0x7f),
  48607 	1339: uint8(0x7f),
  48608 	1340: uint8(0x7f),
  48609 	1341: uint8(0x7f),
  48610 	1342: uint8(0x7f),
  48611 	1343: uint8(0x7f),
  48612 	1344: uint8(0x7f),
  48613 	1345: uint8(0x7f),
  48614 	1346: uint8(0x7f),
  48615 	1347: uint8(0x7f),
  48616 	1348: uint8(0x7f),
  48617 	1349: uint8(0x7f),
  48618 	1350: uint8(0x7f),
  48619 	1351: uint8(0x7f),
  48620 	1352: uint8(0x7f),
  48621 	1353: uint8(0x7f),
  48622 	1354: uint8(0x7f),
  48623 	1355: uint8(0x7f),
  48624 	1356: uint8(0x7f),
  48625 	1357: uint8(0x7f),
  48626 	1358: uint8(0x7f),
  48627 	1359: uint8(0x7f),
  48628 	1360: uint8(0x7f),
  48629 	1361: uint8(0x7f),
  48630 	1362: uint8(0x7f),
  48631 	1363: uint8(0x7f),
  48632 	1364: uint8(0x7f),
  48633 	1365: uint8(0x7f),
  48634 	1366: uint8(0x7f),
  48635 	1367: uint8(0x7f),
  48636 	1368: uint8(0x7f),
  48637 	1369: uint8(0x7f),
  48638 	1370: uint8(0x7f),
  48639 	1371: uint8(0x7f),
  48640 	1372: uint8(0x7f),
  48641 	1373: uint8(0x7f),
  48642 	1374: uint8(0x7f),
  48643 	1375: uint8(0x7f),
  48644 	1376: uint8(0x7f),
  48645 	1377: uint8(0x7f),
  48646 	1378: uint8(0x7f),
  48647 	1379: uint8(0x7f),
  48648 	1380: uint8(0x7f),
  48649 	1381: uint8(0x7f),
  48650 	1382: uint8(0x7f),
  48651 	1383: uint8(0x7f),
  48652 	1384: uint8(0x7f),
  48653 	1385: uint8(0x7f),
  48654 	1386: uint8(0x7f),
  48655 	1387: uint8(0x7f),
  48656 	1388: uint8(0x7f),
  48657 	1389: uint8(0x7f),
  48658 	1390: uint8(0x7f),
  48659 	1391: uint8(0x7f),
  48660 	1392: uint8(0x7f),
  48661 	1393: uint8(0x7f),
  48662 	1394: uint8(0x7f),
  48663 	1395: uint8(0x7f),
  48664 	1396: uint8(0x7f),
  48665 	1397: uint8(0x7f),
  48666 	1398: uint8(0x7f),
  48667 	1399: uint8(0x7f),
  48668 	1400: uint8(0x7f),
  48669 	1401: uint8(0x7f),
  48670 	1402: uint8(0x7f),
  48671 	1403: uint8(0x7f),
  48672 	1404: uint8(0x7f),
  48673 	1405: uint8(0x7f),
  48674 	1406: uint8(0x7f),
  48675 	1407: uint8(0x7f),
  48676 	1408: uint8(0x7f),
  48677 	1409: uint8(0x7f),
  48678 	1410: uint8(0x7f),
  48679 	1411: uint8(0x7f),
  48680 	1412: uint8(0x7f),
  48681 	1413: uint8(0x7f),
  48682 	1414: uint8(0x7f),
  48683 	1415: uint8(0x7f),
  48684 	1416: uint8(0x7f),
  48685 	1417: uint8(0x7f),
  48686 	1418: uint8(0x7f),
  48687 	1419: uint8(0x7f),
  48688 	1420: uint8(0x7f),
  48689 	1421: uint8(0x7f),
  48690 	1422: uint8(0x7f),
  48691 	1423: uint8(0x7f),
  48692 	1424: uint8(0x7f),
  48693 	1425: uint8(0x7f),
  48694 	1426: uint8(0x7f),
  48695 	1427: uint8(0x7f),
  48696 	1428: uint8(0x7f),
  48697 	1429: uint8(0x7f),
  48698 	1430: uint8(0x7f),
  48699 	1431: uint8(0x7f),
  48700 	1432: uint8(0x7f),
  48701 	1433: uint8(0x7f),
  48702 	1434: uint8(0x7f),
  48703 	1435: uint8(0x7f),
  48704 	1436: uint8(0x7f),
  48705 	1437: uint8(0x7f),
  48706 	1438: uint8(0x7f),
  48707 	1439: uint8(0x7f),
  48708 	1440: uint8(0x7f),
  48709 	1441: uint8(0x7f),
  48710 	1442: uint8(0x7f),
  48711 	1443: uint8(0x7f),
  48712 	1444: uint8(0x7f),
  48713 	1445: uint8(0x7f),
  48714 	1446: uint8(0x7f),
  48715 	1447: uint8(0x7f),
  48716 	1448: uint8(0x7f),
  48717 	1449: uint8(0x7f),
  48718 	1450: uint8(0x7f),
  48719 	1451: uint8(0x7f),
  48720 	1452: uint8(0x7f),
  48721 	1453: uint8(0x7f),
  48722 	1454: uint8(0x7f),
  48723 	1455: uint8(0x7f),
  48724 	1456: uint8(0x7f),
  48725 	1457: uint8(0x7f),
  48726 	1458: uint8(0x7f),
  48727 	1459: uint8(0x7f),
  48728 	1460: uint8(0x7f),
  48729 	1461: uint8(0x7f),
  48730 	1462: uint8(0x7f),
  48731 	1463: uint8(0x7f),
  48732 	1464: uint8(0x7f),
  48733 	1465: uint8(0x7f),
  48734 	1466: uint8(0x7f),
  48735 	1467: uint8(0x7f),
  48736 	1468: uint8(0x7f),
  48737 	1469: uint8(0x7f),
  48738 	1470: uint8(0x7f),
  48739 	1471: uint8(0x7f),
  48740 	1472: uint8(0x7f),
  48741 	1473: uint8(0x7f),
  48742 	1474: uint8(0x7f),
  48743 	1475: uint8(0x7f),
  48744 	1476: uint8(0x7f),
  48745 	1477: uint8(0x7f),
  48746 	1478: uint8(0x7f),
  48747 	1479: uint8(0x7f),
  48748 	1480: uint8(0x7f),
  48749 	1481: uint8(0x7f),
  48750 	1482: uint8(0x7f),
  48751 	1483: uint8(0x7f),
  48752 	1484: uint8(0x7f),
  48753 	1485: uint8(0x7f),
  48754 	1486: uint8(0x7f),
  48755 	1487: uint8(0x7f),
  48756 	1488: uint8(0x7f),
  48757 	1489: uint8(0x7f),
  48758 	1490: uint8(0x7f),
  48759 	1491: uint8(0x7f),
  48760 	1492: uint8(0x7f),
  48761 	1493: uint8(0x7f),
  48762 	1494: uint8(0x7f),
  48763 	1495: uint8(0x7f),
  48764 	1496: uint8(0x7f),
  48765 	1497: uint8(0x7f),
  48766 	1498: uint8(0x7f),
  48767 	1499: uint8(0x7f),
  48768 	1500: uint8(0x7f),
  48769 	1501: uint8(0x7f),
  48770 	1502: uint8(0x7f),
  48771 	1503: uint8(0x7f),
  48772 	1504: uint8(0x7f),
  48773 	1505: uint8(0x7f),
  48774 	1506: uint8(0x7f),
  48775 	1507: uint8(0x7f),
  48776 	1508: uint8(0x7f),
  48777 	1509: uint8(0x7f),
  48778 	1510: uint8(0x7f),
  48779 	1511: uint8(0x7f),
  48780 	1512: uint8(0x7f),
  48781 	1513: uint8(0x7f),
  48782 	1514: uint8(0x7f),
  48783 	1515: uint8(0x7f),
  48784 	1516: uint8(0x7f),
  48785 	1517: uint8(0x7f),
  48786 	1518: uint8(0x7f),
  48787 	1519: uint8(0x7f),
  48788 	1520: uint8(0x7f),
  48789 	1521: uint8(0x7f),
  48790 	1522: uint8(0x7f),
  48791 	1523: uint8(0x7f),
  48792 	1524: uint8(0x7f),
  48793 	1525: uint8(0x7f),
  48794 	1526: uint8(0x7f),
  48795 	1527: uint8(0x7f),
  48796 	1528: uint8(0x7f),
  48797 	1529: uint8(0x7f),
  48798 	1530: uint8(0x7f),
  48799 	1531: uint8(0x7f),
  48800 	1532: uint8(0x7f),
  48801 	1533: uint8(0x7f),
  48802 	1534: uint8(0x7f),
  48803 	1535: uint8(0x7f),
  48804 	1536: uint8(0x7f),
  48805 	1537: uint8(0x7f),
  48806 	1538: uint8(0x7f),
  48807 	1539: uint8(0x7f),
  48808 	1540: uint8(0x7f),
  48809 	1541: uint8(0x7f),
  48810 	1542: uint8(0x7f),
  48811 	1543: uint8(0x7f),
  48812 	1544: uint8(0x7f),
  48813 	1545: uint8(0x7f),
  48814 	1546: uint8(0x7f),
  48815 	1547: uint8(0x7f),
  48816 	1548: uint8(0x7f),
  48817 	1549: uint8(0x7f),
  48818 	1550: uint8(0x7f),
  48819 	1551: uint8(0x7f),
  48820 	1552: uint8(0x7f),
  48821 	1553: uint8(0x7f),
  48822 	1554: uint8(0x7f),
  48823 	1555: uint8(0x7f),
  48824 	1556: uint8(0x7f),
  48825 	1557: uint8(0x7f),
  48826 	1558: uint8(0x7f),
  48827 	1559: uint8(0x7f),
  48828 	1560: uint8(0x7f),
  48829 	1561: uint8(0x7f),
  48830 	1562: uint8(0x7f),
  48831 	1563: uint8(0x7f),
  48832 	1564: uint8(0x7f),
  48833 	1565: uint8(0x7f),
  48834 	1566: uint8(0x7f),
  48835 	1567: uint8(0x7f),
  48836 	1568: uint8(0x7f),
  48837 	1569: uint8(0x7f),
  48838 	1570: uint8(0x7f),
  48839 	1571: uint8(0x7f),
  48840 	1572: uint8(0x7f),
  48841 	1573: uint8(0x7f),
  48842 	1574: uint8(0x7f),
  48843 	1575: uint8(0x7f),
  48844 	1576: uint8(0x7f),
  48845 	1577: uint8(0x7f),
  48846 	1578: uint8(0x7f),
  48847 	1579: uint8(0x7f),
  48848 	1580: uint8(0x7f),
  48849 	1581: uint8(0x7f),
  48850 	1582: uint8(0x7f),
  48851 	1583: uint8(0x7f),
  48852 	1584: uint8(0x7f),
  48853 	1585: uint8(0x7f),
  48854 	1586: uint8(0x7f),
  48855 	1587: uint8(0x7f),
  48856 	1588: uint8(0x7f),
  48857 	1589: uint8(0x7f),
  48858 	1590: uint8(0x7f),
  48859 	1591: uint8(0x7f),
  48860 	1592: uint8(0x7f),
  48861 	1593: uint8(0x7f),
  48862 	1594: uint8(0x7f),
  48863 	1595: uint8(0x7f),
  48864 	1596: uint8(0x7f),
  48865 	1597: uint8(0x7f),
  48866 	1598: uint8(0x7f),
  48867 	1599: uint8(0x7f),
  48868 	1600: uint8(0x7f),
  48869 	1601: uint8(0x7f),
  48870 	1602: uint8(0x7f),
  48871 	1603: uint8(0x7f),
  48872 	1604: uint8(0x7f),
  48873 	1605: uint8(0x7f),
  48874 	1606: uint8(0x7f),
  48875 	1607: uint8(0x7f),
  48876 	1608: uint8(0x7f),
  48877 	1609: uint8(0x7f),
  48878 	1610: uint8(0x7f),
  48879 	1611: uint8(0x7f),
  48880 	1612: uint8(0x7f),
  48881 	1613: uint8(0x7f),
  48882 	1614: uint8(0x7f),
  48883 	1615: uint8(0x7f),
  48884 	1616: uint8(0x7f),
  48885 	1617: uint8(0x7f),
  48886 	1618: uint8(0x7f),
  48887 	1619: uint8(0x7f),
  48888 	1620: uint8(0x7f),
  48889 	1621: uint8(0x7f),
  48890 	1622: uint8(0x7f),
  48891 	1623: uint8(0x7f),
  48892 	1624: uint8(0x7f),
  48893 	1625: uint8(0x7f),
  48894 	1626: uint8(0x7f),
  48895 	1627: uint8(0x7f),
  48896 	1628: uint8(0x7f),
  48897 	1629: uint8(0x7f),
  48898 	1630: uint8(0x7f),
  48899 	1631: uint8(0x7f),
  48900 	1632: uint8(0x7f),
  48901 	1633: uint8(0x7f),
  48902 	1634: uint8(0x7f),
  48903 	1635: uint8(0x7f),
  48904 	1636: uint8(0x7f),
  48905 	1637: uint8(0x7f),
  48906 	1638: uint8(0x7f),
  48907 	1639: uint8(0x7f),
  48908 	1640: uint8(0x7f),
  48909 	1641: uint8(0x7f),
  48910 	1642: uint8(0x7f),
  48911 	1643: uint8(0x7f),
  48912 	1644: uint8(0x7f),
  48913 	1645: uint8(0x7f),
  48914 	1646: uint8(0x7f),
  48915 	1647: uint8(0x7f),
  48916 	1648: uint8(0x7f),
  48917 	1649: uint8(0x7f),
  48918 	1650: uint8(0x7f),
  48919 	1651: uint8(0x7f),
  48920 	1652: uint8(0x7f),
  48921 	1653: uint8(0x7f),
  48922 	1654: uint8(0x7f),
  48923 	1655: uint8(0x7f),
  48924 	1656: uint8(0x7f),
  48925 	1657: uint8(0x7f),
  48926 	1658: uint8(0x7f),
  48927 	1659: uint8(0x7f),
  48928 	1660: uint8(0x7f),
  48929 	1661: uint8(0x7f),
  48930 	1662: uint8(0x7f),
  48931 	1663: uint8(0x7f),
  48932 	1664: uint8(0x7f),
  48933 	1665: uint8(0x7f),
  48934 	1666: uint8(0x7f),
  48935 	1667: uint8(0x7f),
  48936 	1668: uint8(0x7f),
  48937 	1669: uint8(0x7f),
  48938 	1670: uint8(0x7f),
  48939 	1671: uint8(0x7f),
  48940 	1672: uint8(0x7f),
  48941 	1673: uint8(0x7f),
  48942 	1674: uint8(0x7f),
  48943 	1675: uint8(0x7f),
  48944 	1676: uint8(0x7f),
  48945 	1677: uint8(0x7f),
  48946 	1678: uint8(0x7f),
  48947 	1679: uint8(0x7f),
  48948 	1680: uint8(0x7f),
  48949 	1681: uint8(0x7f),
  48950 	1682: uint8(0x7f),
  48951 	1683: uint8(0x7f),
  48952 	1684: uint8(0x7f),
  48953 	1685: uint8(0x7f),
  48954 	1686: uint8(0x7f),
  48955 	1687: uint8(0x7f),
  48956 	1688: uint8(0x7f),
  48957 	1689: uint8(0x7f),
  48958 	1690: uint8(0x7f),
  48959 	1691: uint8(0x7f),
  48960 	1692: uint8(0x7f),
  48961 	1693: uint8(0x7f),
  48962 	1694: uint8(0x7f),
  48963 	1695: uint8(0x7f),
  48964 	1696: uint8(0x7f),
  48965 	1697: uint8(0x7f),
  48966 	1698: uint8(0x7f),
  48967 	1699: uint8(0x7f),
  48968 	1700: uint8(0x7f),
  48969 	1701: uint8(0x7f),
  48970 	1702: uint8(0x7f),
  48971 	1703: uint8(0x7f),
  48972 	1704: uint8(0x7f),
  48973 	1705: uint8(0x7f),
  48974 	1706: uint8(0x7f),
  48975 	1707: uint8(0x7f),
  48976 	1708: uint8(0x7f),
  48977 	1709: uint8(0x7f),
  48978 	1710: uint8(0x7f),
  48979 	1711: uint8(0x7f),
  48980 	1712: uint8(0x7f),
  48981 	1713: uint8(0x7f),
  48982 	1714: uint8(0x7f),
  48983 	1715: uint8(0x7f),
  48984 	1716: uint8(0x7f),
  48985 	1717: uint8(0x7f),
  48986 	1718: uint8(0x7f),
  48987 	1719: uint8(0x7f),
  48988 	1720: uint8(0x7f),
  48989 	1721: uint8(0x7f),
  48990 	1722: uint8(0x7f),
  48991 	1723: uint8(0x7f),
  48992 	1724: uint8(0x7f),
  48993 	1725: uint8(0x7f),
  48994 	1726: uint8(0x7f),
  48995 	1727: uint8(0x7f),
  48996 	1728: uint8(0x7f),
  48997 	1729: uint8(0x7f),
  48998 	1730: uint8(0x7f),
  48999 	1731: uint8(0x7f),
  49000 	1732: uint8(0x7f),
  49001 	1733: uint8(0x7f),
  49002 	1734: uint8(0x7f),
  49003 	1735: uint8(0x7f),
  49004 	1736: uint8(0x7f),
  49005 	1737: uint8(0x7f),
  49006 	1738: uint8(0x7f),
  49007 	1739: uint8(0x7f),
  49008 	1740: uint8(0x7f),
  49009 	1741: uint8(0x7f),
  49010 	1742: uint8(0x7f),
  49011 	1743: uint8(0x7f),
  49012 	1744: uint8(0x7f),
  49013 	1745: uint8(0x7f),
  49014 	1746: uint8(0x7f),
  49015 	1747: uint8(0x7f),
  49016 	1748: uint8(0x7f),
  49017 	1749: uint8(0x7f),
  49018 	1750: uint8(0x7f),
  49019 	1751: uint8(0x7f),
  49020 	1752: uint8(0x7f),
  49021 	1753: uint8(0x7f),
  49022 	1754: uint8(0x7f),
  49023 	1755: uint8(0x7f),
  49024 	1756: uint8(0x7f),
  49025 	1757: uint8(0x7f),
  49026 	1758: uint8(0x7f),
  49027 	1759: uint8(0x7f),
  49028 	1760: uint8(0x7f),
  49029 	1761: uint8(0x7f),
  49030 	1762: uint8(0x7f),
  49031 	1763: uint8(0x7f),
  49032 	1764: uint8(0x7f),
  49033 	1765: uint8(0x7f),
  49034 	1766: uint8(0x7f),
  49035 	1767: uint8(0x7f),
  49036 	1768: uint8(0x7f),
  49037 	1769: uint8(0x7f),
  49038 	1770: uint8(0x7f),
  49039 	1771: uint8(0x7f),
  49040 	1772: uint8(0x7f),
  49041 	1773: uint8(0x7f),
  49042 	1774: uint8(0x7f),
  49043 	1775: uint8(0x7f),
  49044 	1776: uint8(0x7f),
  49045 	1777: uint8(0x7f),
  49046 	1778: uint8(0x7f),
  49047 	1779: uint8(0x7f),
  49048 	1780: uint8(0x7f),
  49049 	1781: uint8(0x7f),
  49050 	1782: uint8(0x7f),
  49051 	1783: uint8(0x7f),
  49052 	1784: uint8(0x7f),
  49053 	1785: uint8(0x7f),
  49054 	1786: uint8(0x7f),
  49055 	1787: uint8(0x7f),
  49056 	1788: uint8(0x7f),
  49057 	1789: uint8(0x7f),
  49058 	1790: uint8(0x7f),
  49059 	1791: uint8(0x7f),
  49060 	1792: uint8(0x7f),
  49061 	1793: uint8(0x7f),
  49062 	1794: uint8(0x7f),
  49063 	1795: uint8(0x7f),
  49064 	1796: uint8(0x7f),
  49065 	1797: uint8(0x7f),
  49066 	1798: uint8(0x7f),
  49067 	1799: uint8(0x7f),
  49068 	1800: uint8(0x7f),
  49069 	1801: uint8(0x7f),
  49070 	1802: uint8(0x7f),
  49071 	1803: uint8(0x7f),
  49072 	1804: uint8(0x7f),
  49073 	1805: uint8(0x7f),
  49074 	1806: uint8(0x7f),
  49075 	1807: uint8(0x7f),
  49076 	1808: uint8(0x7f),
  49077 	1809: uint8(0x7f),
  49078 	1810: uint8(0x7f),
  49079 	1811: uint8(0x7f),
  49080 	1812: uint8(0x7f),
  49081 	1813: uint8(0x7f),
  49082 	1814: uint8(0x7f),
  49083 	1815: uint8(0x7f),
  49084 	1816: uint8(0x7f),
  49085 	1817: uint8(0x7f),
  49086 	1818: uint8(0x7f),
  49087 	1819: uint8(0x7f),
  49088 	1820: uint8(0x7f),
  49089 	1821: uint8(0x7f),
  49090 	1822: uint8(0x7f),
  49091 	1823: uint8(0x7f),
  49092 	1824: uint8(0x7f),
  49093 	1825: uint8(0x7f),
  49094 	1826: uint8(0x7f),
  49095 	1827: uint8(0x7f),
  49096 	1828: uint8(0x7f),
  49097 	1829: uint8(0x7f),
  49098 	1830: uint8(0x7f),
  49099 	1831: uint8(0x7f),
  49100 	1832: uint8(0x7f),
  49101 	1833: uint8(0x7f),
  49102 	1834: uint8(0x7f),
  49103 	1835: uint8(0x7f),
  49104 	1836: uint8(0x7f),
  49105 	1837: uint8(0x7f),
  49106 	1838: uint8(0x7f),
  49107 	1839: uint8(0x7f),
  49108 	1840: uint8(0x7f),
  49109 	1841: uint8(0x7f),
  49110 	1842: uint8(0x7f),
  49111 	1843: uint8(0x7f),
  49112 	1844: uint8(0x7f),
  49113 	1845: uint8(0x7f),
  49114 	1846: uint8(0x7f),
  49115 	1847: uint8(0x7f),
  49116 	1848: uint8(0x7f),
  49117 	1849: uint8(0x7f),
  49118 	1850: uint8(0x7f),
  49119 	1851: uint8(0x7f),
  49120 	1852: uint8(0x7f),
  49121 	1853: uint8(0x7f),
  49122 	1854: uint8(0x7f),
  49123 	1855: uint8(0x7f),
  49124 	1856: uint8(0x7f),
  49125 	1857: uint8(0x7f),
  49126 	1858: uint8(0x7f),
  49127 	1859: uint8(0x7f),
  49128 	1860: uint8(0x7f),
  49129 	1861: uint8(0x7f),
  49130 	1862: uint8(0x7f),
  49131 	1863: uint8(0x7f),
  49132 	1864: uint8(0x7f),
  49133 	1865: uint8(0x7f),
  49134 	1866: uint8(0x7f),
  49135 	1867: uint8(0x7f),
  49136 	1868: uint8(0x7f),
  49137 	1869: uint8(0x7f),
  49138 	1870: uint8(0x7f),
  49139 	1871: uint8(0x7f),
  49140 	1872: uint8(0x7f),
  49141 	1873: uint8(0x7f),
  49142 	1874: uint8(0x7f),
  49143 	1875: uint8(0x7f),
  49144 	1876: uint8(0x7f),
  49145 	1877: uint8(0x7f),
  49146 	1878: uint8(0x7f),
  49147 	1879: uint8(0x7f),
  49148 	1880: uint8(0x7f),
  49149 	1881: uint8(0x7f),
  49150 	1882: uint8(0x7f),
  49151 	1883: uint8(0x7f),
  49152 	1884: uint8(0x7f),
  49153 	1885: uint8(0x7f),
  49154 	1886: uint8(0x7f),
  49155 	1887: uint8(0x7f),
  49156 	1888: uint8(0x7f),
  49157 	1889: uint8(0x7f),
  49158 	1890: uint8(0x7f),
  49159 	1891: uint8(0x7f),
  49160 	1892: uint8(0x7f),
  49161 	1893: uint8(0x7f),
  49162 	1894: uint8(0x7f),
  49163 	1895: uint8(0x7f),
  49164 	1896: uint8(0x7f),
  49165 	1897: uint8(0x7f),
  49166 	1898: uint8(0x7f),
  49167 	1899: uint8(0x7f),
  49168 	1900: uint8(0x7f),
  49169 	1901: uint8(0x7f),
  49170 	1902: uint8(0x7f),
  49171 	1903: uint8(0x7f),
  49172 	1904: uint8(0x7f),
  49173 	1905: uint8(0x7f),
  49174 	1906: uint8(0x7f),
  49175 	1907: uint8(0x7f),
  49176 	1908: uint8(0x7f),
  49177 	1909: uint8(0x7f),
  49178 	1910: uint8(0x7f),
  49179 	1911: uint8(0x7f),
  49180 	1912: uint8(0x7f),
  49181 	1913: uint8(0x7f),
  49182 	1914: uint8(0x7f),
  49183 	1915: uint8(0x7f),
  49184 	1916: uint8(0x7f),
  49185 	1917: uint8(0x7f),
  49186 	1918: uint8(0x7f),
  49187 	1919: uint8(0x7f),
  49188 	1920: uint8(0x7f),
  49189 	1921: uint8(0x7f),
  49190 	1922: uint8(0x7f),
  49191 	1923: uint8(0x7f),
  49192 	1924: uint8(0x7f),
  49193 	1925: uint8(0x7f),
  49194 	1926: uint8(0x7f),
  49195 	1927: uint8(0x7f),
  49196 	1928: uint8(0x7f),
  49197 	1929: uint8(0x7f),
  49198 	1930: uint8(0x7f),
  49199 	1931: uint8(0x7f),
  49200 	1932: uint8(0x7f),
  49201 	1933: uint8(0x7f),
  49202 	1934: uint8(0x7f),
  49203 	1935: uint8(0x7f),
  49204 	1936: uint8(0x7f),
  49205 	1937: uint8(0x7f),
  49206 	1938: uint8(0x7f),
  49207 	1939: uint8(0x7f),
  49208 	1940: uint8(0x7f),
  49209 	1941: uint8(0x7f),
  49210 	1942: uint8(0x7f),
  49211 	1943: uint8(0x7f),
  49212 	1944: uint8(0x7f),
  49213 	1945: uint8(0x7f),
  49214 	1946: uint8(0x7f),
  49215 	1947: uint8(0x7f),
  49216 	1948: uint8(0x7f),
  49217 	1949: uint8(0x7f),
  49218 	1950: uint8(0x7f),
  49219 	1951: uint8(0x7f),
  49220 	1952: uint8(0x7f),
  49221 	1953: uint8(0x7f),
  49222 	1954: uint8(0x7f),
  49223 	1955: uint8(0x7f),
  49224 	1956: uint8(0x7f),
  49225 	1957: uint8(0x7f),
  49226 	1958: uint8(0x7f),
  49227 	1959: uint8(0x7f),
  49228 	1960: uint8(0x7f),
  49229 	1961: uint8(0x7f),
  49230 	1962: uint8(0x7f),
  49231 	1963: uint8(0x7f),
  49232 	1964: uint8(0x7f),
  49233 	1965: uint8(0x7f),
  49234 	1966: uint8(0x7f),
  49235 	1967: uint8(0x7f),
  49236 	1968: uint8(0x7f),
  49237 	1969: uint8(0x7f),
  49238 	1970: uint8(0x7f),
  49239 	1971: uint8(0x7f),
  49240 	1972: uint8(0x7f),
  49241 	1973: uint8(0x7f),
  49242 	1974: uint8(0x7f),
  49243 	1975: uint8(0x7f),
  49244 	1976: uint8(0x7f),
  49245 	1977: uint8(0x7f),
  49246 	1978: uint8(0x7f),
  49247 	1979: uint8(0x7f),
  49248 	1980: uint8(0x7f),
  49249 	1981: uint8(0x7f),
  49250 	1982: uint8(0x7f),
  49251 	1983: uint8(0x7f),
  49252 	1984: uint8(0x7f),
  49253 	1985: uint8(0x7f),
  49254 	1986: uint8(0x7f),
  49255 	1987: uint8(0x7f),
  49256 	1988: uint8(0x7f),
  49257 	1989: uint8(0x7f),
  49258 	1990: uint8(0x7f),
  49259 	1991: uint8(0x7f),
  49260 	1992: uint8(0x7f),
  49261 	1993: uint8(0x7f),
  49262 	1994: uint8(0x7f),
  49263 	1995: uint8(0x7f),
  49264 	1996: uint8(0x7f),
  49265 	1997: uint8(0x7f),
  49266 	1998: uint8(0x7f),
  49267 	1999: uint8(0x7f),
  49268 	2000: uint8(0x7f),
  49269 	2001: uint8(0x7f),
  49270 	2002: uint8(0x7f),
  49271 	2003: uint8(0x7f),
  49272 	2004: uint8(0x7f),
  49273 	2005: uint8(0x7f),
  49274 	2006: uint8(0x7f),
  49275 	2007: uint8(0x7f),
  49276 	2008: uint8(0x7f),
  49277 	2009: uint8(0x7f),
  49278 	2010: uint8(0x7f),
  49279 	2011: uint8(0x7f),
  49280 	2012: uint8(0x7f),
  49281 	2013: uint8(0x7f),
  49282 	2014: uint8(0x7f),
  49283 	2015: uint8(0x7f),
  49284 	2016: uint8(0x7f),
  49285 	2017: uint8(0x7f),
  49286 	2018: uint8(0x7f),
  49287 	2019: uint8(0x7f),
  49288 	2020: uint8(0x7f),
  49289 	2021: uint8(0x7f),
  49290 	2022: uint8(0x7f),
  49291 	2023: uint8(0x7f),
  49292 	2024: uint8(0x7f),
  49293 	2025: uint8(0x7f),
  49294 	2026: uint8(0x7f),
  49295 	2027: uint8(0x7f),
  49296 	2028: uint8(0x7f),
  49297 	2029: uint8(0x7f),
  49298 	2030: uint8(0x7f),
  49299 	2031: uint8(0x7f),
  49300 	2032: uint8(0x7f),
  49301 	2033: uint8(0x7f),
  49302 	2034: uint8(0x7f),
  49303 	2035: uint8(0x7f),
  49304 	2036: uint8(0x7f),
  49305 	2037: uint8(0x7f),
  49306 	2038: uint8(0x7f),
  49307 	2039: uint8(0x7f),
  49308 }
  49309 
  49310 var sclip2 = [225]uint8_t{
  49311 	0:   uint8(0xf0),
  49312 	1:   uint8(0xf0),
  49313 	2:   uint8(0xf0),
  49314 	3:   uint8(0xf0),
  49315 	4:   uint8(0xf0),
  49316 	5:   uint8(0xf0),
  49317 	6:   uint8(0xf0),
  49318 	7:   uint8(0xf0),
  49319 	8:   uint8(0xf0),
  49320 	9:   uint8(0xf0),
  49321 	10:  uint8(0xf0),
  49322 	11:  uint8(0xf0),
  49323 	12:  uint8(0xf0),
  49324 	13:  uint8(0xf0),
  49325 	14:  uint8(0xf0),
  49326 	15:  uint8(0xf0),
  49327 	16:  uint8(0xf0),
  49328 	17:  uint8(0xf0),
  49329 	18:  uint8(0xf0),
  49330 	19:  uint8(0xf0),
  49331 	20:  uint8(0xf0),
  49332 	21:  uint8(0xf0),
  49333 	22:  uint8(0xf0),
  49334 	23:  uint8(0xf0),
  49335 	24:  uint8(0xf0),
  49336 	25:  uint8(0xf0),
  49337 	26:  uint8(0xf0),
  49338 	27:  uint8(0xf0),
  49339 	28:  uint8(0xf0),
  49340 	29:  uint8(0xf0),
  49341 	30:  uint8(0xf0),
  49342 	31:  uint8(0xf0),
  49343 	32:  uint8(0xf0),
  49344 	33:  uint8(0xf0),
  49345 	34:  uint8(0xf0),
  49346 	35:  uint8(0xf0),
  49347 	36:  uint8(0xf0),
  49348 	37:  uint8(0xf0),
  49349 	38:  uint8(0xf0),
  49350 	39:  uint8(0xf0),
  49351 	40:  uint8(0xf0),
  49352 	41:  uint8(0xf0),
  49353 	42:  uint8(0xf0),
  49354 	43:  uint8(0xf0),
  49355 	44:  uint8(0xf0),
  49356 	45:  uint8(0xf0),
  49357 	46:  uint8(0xf0),
  49358 	47:  uint8(0xf0),
  49359 	48:  uint8(0xf0),
  49360 	49:  uint8(0xf0),
  49361 	50:  uint8(0xf0),
  49362 	51:  uint8(0xf0),
  49363 	52:  uint8(0xf0),
  49364 	53:  uint8(0xf0),
  49365 	54:  uint8(0xf0),
  49366 	55:  uint8(0xf0),
  49367 	56:  uint8(0xf0),
  49368 	57:  uint8(0xf0),
  49369 	58:  uint8(0xf0),
  49370 	59:  uint8(0xf0),
  49371 	60:  uint8(0xf0),
  49372 	61:  uint8(0xf0),
  49373 	62:  uint8(0xf0),
  49374 	63:  uint8(0xf0),
  49375 	64:  uint8(0xf0),
  49376 	65:  uint8(0xf0),
  49377 	66:  uint8(0xf0),
  49378 	67:  uint8(0xf0),
  49379 	68:  uint8(0xf0),
  49380 	69:  uint8(0xf0),
  49381 	70:  uint8(0xf0),
  49382 	71:  uint8(0xf0),
  49383 	72:  uint8(0xf0),
  49384 	73:  uint8(0xf0),
  49385 	74:  uint8(0xf0),
  49386 	75:  uint8(0xf0),
  49387 	76:  uint8(0xf0),
  49388 	77:  uint8(0xf0),
  49389 	78:  uint8(0xf0),
  49390 	79:  uint8(0xf0),
  49391 	80:  uint8(0xf0),
  49392 	81:  uint8(0xf0),
  49393 	82:  uint8(0xf0),
  49394 	83:  uint8(0xf0),
  49395 	84:  uint8(0xf0),
  49396 	85:  uint8(0xf0),
  49397 	86:  uint8(0xf0),
  49398 	87:  uint8(0xf0),
  49399 	88:  uint8(0xf0),
  49400 	89:  uint8(0xf0),
  49401 	90:  uint8(0xf0),
  49402 	91:  uint8(0xf0),
  49403 	92:  uint8(0xf0),
  49404 	93:  uint8(0xf0),
  49405 	94:  uint8(0xf0),
  49406 	95:  uint8(0xf0),
  49407 	96:  uint8(0xf0),
  49408 	97:  uint8(0xf1),
  49409 	98:  uint8(0xf2),
  49410 	99:  uint8(0xf3),
  49411 	100: uint8(0xf4),
  49412 	101: uint8(0xf5),
  49413 	102: uint8(0xf6),
  49414 	103: uint8(0xf7),
  49415 	104: uint8(0xf8),
  49416 	105: uint8(0xf9),
  49417 	106: uint8(0xfa),
  49418 	107: uint8(0xfb),
  49419 	108: uint8(0xfc),
  49420 	109: uint8(0xfd),
  49421 	110: uint8(0xfe),
  49422 	111: uint8(0xff),
  49423 	113: uint8(0x01),
  49424 	114: uint8(0x02),
  49425 	115: uint8(0x03),
  49426 	116: uint8(0x04),
  49427 	117: uint8(0x05),
  49428 	118: uint8(0x06),
  49429 	119: uint8(0x07),
  49430 	120: uint8(0x08),
  49431 	121: uint8(0x09),
  49432 	122: uint8(0x0a),
  49433 	123: uint8(0x0b),
  49434 	124: uint8(0x0c),
  49435 	125: uint8(0x0d),
  49436 	126: uint8(0x0e),
  49437 	127: uint8(0x0f),
  49438 	128: uint8(0x0f),
  49439 	129: uint8(0x0f),
  49440 	130: uint8(0x0f),
  49441 	131: uint8(0x0f),
  49442 	132: uint8(0x0f),
  49443 	133: uint8(0x0f),
  49444 	134: uint8(0x0f),
  49445 	135: uint8(0x0f),
  49446 	136: uint8(0x0f),
  49447 	137: uint8(0x0f),
  49448 	138: uint8(0x0f),
  49449 	139: uint8(0x0f),
  49450 	140: uint8(0x0f),
  49451 	141: uint8(0x0f),
  49452 	142: uint8(0x0f),
  49453 	143: uint8(0x0f),
  49454 	144: uint8(0x0f),
  49455 	145: uint8(0x0f),
  49456 	146: uint8(0x0f),
  49457 	147: uint8(0x0f),
  49458 	148: uint8(0x0f),
  49459 	149: uint8(0x0f),
  49460 	150: uint8(0x0f),
  49461 	151: uint8(0x0f),
  49462 	152: uint8(0x0f),
  49463 	153: uint8(0x0f),
  49464 	154: uint8(0x0f),
  49465 	155: uint8(0x0f),
  49466 	156: uint8(0x0f),
  49467 	157: uint8(0x0f),
  49468 	158: uint8(0x0f),
  49469 	159: uint8(0x0f),
  49470 	160: uint8(0x0f),
  49471 	161: uint8(0x0f),
  49472 	162: uint8(0x0f),
  49473 	163: uint8(0x0f),
  49474 	164: uint8(0x0f),
  49475 	165: uint8(0x0f),
  49476 	166: uint8(0x0f),
  49477 	167: uint8(0x0f),
  49478 	168: uint8(0x0f),
  49479 	169: uint8(0x0f),
  49480 	170: uint8(0x0f),
  49481 	171: uint8(0x0f),
  49482 	172: uint8(0x0f),
  49483 	173: uint8(0x0f),
  49484 	174: uint8(0x0f),
  49485 	175: uint8(0x0f),
  49486 	176: uint8(0x0f),
  49487 	177: uint8(0x0f),
  49488 	178: uint8(0x0f),
  49489 	179: uint8(0x0f),
  49490 	180: uint8(0x0f),
  49491 	181: uint8(0x0f),
  49492 	182: uint8(0x0f),
  49493 	183: uint8(0x0f),
  49494 	184: uint8(0x0f),
  49495 	185: uint8(0x0f),
  49496 	186: uint8(0x0f),
  49497 	187: uint8(0x0f),
  49498 	188: uint8(0x0f),
  49499 	189: uint8(0x0f),
  49500 	190: uint8(0x0f),
  49501 	191: uint8(0x0f),
  49502 	192: uint8(0x0f),
  49503 	193: uint8(0x0f),
  49504 	194: uint8(0x0f),
  49505 	195: uint8(0x0f),
  49506 	196: uint8(0x0f),
  49507 	197: uint8(0x0f),
  49508 	198: uint8(0x0f),
  49509 	199: uint8(0x0f),
  49510 	200: uint8(0x0f),
  49511 	201: uint8(0x0f),
  49512 	202: uint8(0x0f),
  49513 	203: uint8(0x0f),
  49514 	204: uint8(0x0f),
  49515 	205: uint8(0x0f),
  49516 	206: uint8(0x0f),
  49517 	207: uint8(0x0f),
  49518 	208: uint8(0x0f),
  49519 	209: uint8(0x0f),
  49520 	210: uint8(0x0f),
  49521 	211: uint8(0x0f),
  49522 	212: uint8(0x0f),
  49523 	213: uint8(0x0f),
  49524 	214: uint8(0x0f),
  49525 	215: uint8(0x0f),
  49526 	216: uint8(0x0f),
  49527 	217: uint8(0x0f),
  49528 	218: uint8(0x0f),
  49529 	219: uint8(0x0f),
  49530 	220: uint8(0x0f),
  49531 	221: uint8(0x0f),
  49532 	222: uint8(0x0f),
  49533 	223: uint8(0x0f),
  49534 }
  49535 
  49536 var clip11 = [767]uint8_t{
  49537 	256: uint8(0x01),
  49538 	257: uint8(0x02),
  49539 	258: uint8(0x03),
  49540 	259: uint8(0x04),
  49541 	260: uint8(0x05),
  49542 	261: uint8(0x06),
  49543 	262: uint8(0x07),
  49544 	263: uint8(0x08),
  49545 	264: uint8(0x09),
  49546 	265: uint8(0x0a),
  49547 	266: uint8(0x0b),
  49548 	267: uint8(0x0c),
  49549 	268: uint8(0x0d),
  49550 	269: uint8(0x0e),
  49551 	270: uint8(0x0f),
  49552 	271: uint8(0x10),
  49553 	272: uint8(0x11),
  49554 	273: uint8(0x12),
  49555 	274: uint8(0x13),
  49556 	275: uint8(0x14),
  49557 	276: uint8(0x15),
  49558 	277: uint8(0x16),
  49559 	278: uint8(0x17),
  49560 	279: uint8(0x18),
  49561 	280: uint8(0x19),
  49562 	281: uint8(0x1a),
  49563 	282: uint8(0x1b),
  49564 	283: uint8(0x1c),
  49565 	284: uint8(0x1d),
  49566 	285: uint8(0x1e),
  49567 	286: uint8(0x1f),
  49568 	287: uint8(0x20),
  49569 	288: uint8(0x21),
  49570 	289: uint8(0x22),
  49571 	290: uint8(0x23),
  49572 	291: uint8(0x24),
  49573 	292: uint8(0x25),
  49574 	293: uint8(0x26),
  49575 	294: uint8(0x27),
  49576 	295: uint8(0x28),
  49577 	296: uint8(0x29),
  49578 	297: uint8(0x2a),
  49579 	298: uint8(0x2b),
  49580 	299: uint8(0x2c),
  49581 	300: uint8(0x2d),
  49582 	301: uint8(0x2e),
  49583 	302: uint8(0x2f),
  49584 	303: uint8(0x30),
  49585 	304: uint8(0x31),
  49586 	305: uint8(0x32),
  49587 	306: uint8(0x33),
  49588 	307: uint8(0x34),
  49589 	308: uint8(0x35),
  49590 	309: uint8(0x36),
  49591 	310: uint8(0x37),
  49592 	311: uint8(0x38),
  49593 	312: uint8(0x39),
  49594 	313: uint8(0x3a),
  49595 	314: uint8(0x3b),
  49596 	315: uint8(0x3c),
  49597 	316: uint8(0x3d),
  49598 	317: uint8(0x3e),
  49599 	318: uint8(0x3f),
  49600 	319: uint8(0x40),
  49601 	320: uint8(0x41),
  49602 	321: uint8(0x42),
  49603 	322: uint8(0x43),
  49604 	323: uint8(0x44),
  49605 	324: uint8(0x45),
  49606 	325: uint8(0x46),
  49607 	326: uint8(0x47),
  49608 	327: uint8(0x48),
  49609 	328: uint8(0x49),
  49610 	329: uint8(0x4a),
  49611 	330: uint8(0x4b),
  49612 	331: uint8(0x4c),
  49613 	332: uint8(0x4d),
  49614 	333: uint8(0x4e),
  49615 	334: uint8(0x4f),
  49616 	335: uint8(0x50),
  49617 	336: uint8(0x51),
  49618 	337: uint8(0x52),
  49619 	338: uint8(0x53),
  49620 	339: uint8(0x54),
  49621 	340: uint8(0x55),
  49622 	341: uint8(0x56),
  49623 	342: uint8(0x57),
  49624 	343: uint8(0x58),
  49625 	344: uint8(0x59),
  49626 	345: uint8(0x5a),
  49627 	346: uint8(0x5b),
  49628 	347: uint8(0x5c),
  49629 	348: uint8(0x5d),
  49630 	349: uint8(0x5e),
  49631 	350: uint8(0x5f),
  49632 	351: uint8(0x60),
  49633 	352: uint8(0x61),
  49634 	353: uint8(0x62),
  49635 	354: uint8(0x63),
  49636 	355: uint8(0x64),
  49637 	356: uint8(0x65),
  49638 	357: uint8(0x66),
  49639 	358: uint8(0x67),
  49640 	359: uint8(0x68),
  49641 	360: uint8(0x69),
  49642 	361: uint8(0x6a),
  49643 	362: uint8(0x6b),
  49644 	363: uint8(0x6c),
  49645 	364: uint8(0x6d),
  49646 	365: uint8(0x6e),
  49647 	366: uint8(0x6f),
  49648 	367: uint8(0x70),
  49649 	368: uint8(0x71),
  49650 	369: uint8(0x72),
  49651 	370: uint8(0x73),
  49652 	371: uint8(0x74),
  49653 	372: uint8(0x75),
  49654 	373: uint8(0x76),
  49655 	374: uint8(0x77),
  49656 	375: uint8(0x78),
  49657 	376: uint8(0x79),
  49658 	377: uint8(0x7a),
  49659 	378: uint8(0x7b),
  49660 	379: uint8(0x7c),
  49661 	380: uint8(0x7d),
  49662 	381: uint8(0x7e),
  49663 	382: uint8(0x7f),
  49664 	383: uint8(0x80),
  49665 	384: uint8(0x81),
  49666 	385: uint8(0x82),
  49667 	386: uint8(0x83),
  49668 	387: uint8(0x84),
  49669 	388: uint8(0x85),
  49670 	389: uint8(0x86),
  49671 	390: uint8(0x87),
  49672 	391: uint8(0x88),
  49673 	392: uint8(0x89),
  49674 	393: uint8(0x8a),
  49675 	394: uint8(0x8b),
  49676 	395: uint8(0x8c),
  49677 	396: uint8(0x8d),
  49678 	397: uint8(0x8e),
  49679 	398: uint8(0x8f),
  49680 	399: uint8(0x90),
  49681 	400: uint8(0x91),
  49682 	401: uint8(0x92),
  49683 	402: uint8(0x93),
  49684 	403: uint8(0x94),
  49685 	404: uint8(0x95),
  49686 	405: uint8(0x96),
  49687 	406: uint8(0x97),
  49688 	407: uint8(0x98),
  49689 	408: uint8(0x99),
  49690 	409: uint8(0x9a),
  49691 	410: uint8(0x9b),
  49692 	411: uint8(0x9c),
  49693 	412: uint8(0x9d),
  49694 	413: uint8(0x9e),
  49695 	414: uint8(0x9f),
  49696 	415: uint8(0xa0),
  49697 	416: uint8(0xa1),
  49698 	417: uint8(0xa2),
  49699 	418: uint8(0xa3),
  49700 	419: uint8(0xa4),
  49701 	420: uint8(0xa5),
  49702 	421: uint8(0xa6),
  49703 	422: uint8(0xa7),
  49704 	423: uint8(0xa8),
  49705 	424: uint8(0xa9),
  49706 	425: uint8(0xaa),
  49707 	426: uint8(0xab),
  49708 	427: uint8(0xac),
  49709 	428: uint8(0xad),
  49710 	429: uint8(0xae),
  49711 	430: uint8(0xaf),
  49712 	431: uint8(0xb0),
  49713 	432: uint8(0xb1),
  49714 	433: uint8(0xb2),
  49715 	434: uint8(0xb3),
  49716 	435: uint8(0xb4),
  49717 	436: uint8(0xb5),
  49718 	437: uint8(0xb6),
  49719 	438: uint8(0xb7),
  49720 	439: uint8(0xb8),
  49721 	440: uint8(0xb9),
  49722 	441: uint8(0xba),
  49723 	442: uint8(0xbb),
  49724 	443: uint8(0xbc),
  49725 	444: uint8(0xbd),
  49726 	445: uint8(0xbe),
  49727 	446: uint8(0xbf),
  49728 	447: uint8(0xc0),
  49729 	448: uint8(0xc1),
  49730 	449: uint8(0xc2),
  49731 	450: uint8(0xc3),
  49732 	451: uint8(0xc4),
  49733 	452: uint8(0xc5),
  49734 	453: uint8(0xc6),
  49735 	454: uint8(0xc7),
  49736 	455: uint8(0xc8),
  49737 	456: uint8(0xc9),
  49738 	457: uint8(0xca),
  49739 	458: uint8(0xcb),
  49740 	459: uint8(0xcc),
  49741 	460: uint8(0xcd),
  49742 	461: uint8(0xce),
  49743 	462: uint8(0xcf),
  49744 	463: uint8(0xd0),
  49745 	464: uint8(0xd1),
  49746 	465: uint8(0xd2),
  49747 	466: uint8(0xd3),
  49748 	467: uint8(0xd4),
  49749 	468: uint8(0xd5),
  49750 	469: uint8(0xd6),
  49751 	470: uint8(0xd7),
  49752 	471: uint8(0xd8),
  49753 	472: uint8(0xd9),
  49754 	473: uint8(0xda),
  49755 	474: uint8(0xdb),
  49756 	475: uint8(0xdc),
  49757 	476: uint8(0xdd),
  49758 	477: uint8(0xde),
  49759 	478: uint8(0xdf),
  49760 	479: uint8(0xe0),
  49761 	480: uint8(0xe1),
  49762 	481: uint8(0xe2),
  49763 	482: uint8(0xe3),
  49764 	483: uint8(0xe4),
  49765 	484: uint8(0xe5),
  49766 	485: uint8(0xe6),
  49767 	486: uint8(0xe7),
  49768 	487: uint8(0xe8),
  49769 	488: uint8(0xe9),
  49770 	489: uint8(0xea),
  49771 	490: uint8(0xeb),
  49772 	491: uint8(0xec),
  49773 	492: uint8(0xed),
  49774 	493: uint8(0xee),
  49775 	494: uint8(0xef),
  49776 	495: uint8(0xf0),
  49777 	496: uint8(0xf1),
  49778 	497: uint8(0xf2),
  49779 	498: uint8(0xf3),
  49780 	499: uint8(0xf4),
  49781 	500: uint8(0xf5),
  49782 	501: uint8(0xf6),
  49783 	502: uint8(0xf7),
  49784 	503: uint8(0xf8),
  49785 	504: uint8(0xf9),
  49786 	505: uint8(0xfa),
  49787 	506: uint8(0xfb),
  49788 	507: uint8(0xfc),
  49789 	508: uint8(0xfd),
  49790 	509: uint8(0xfe),
  49791 	510: uint8(0xff),
  49792 	511: uint8(0xff),
  49793 	512: uint8(0xff),
  49794 	513: uint8(0xff),
  49795 	514: uint8(0xff),
  49796 	515: uint8(0xff),
  49797 	516: uint8(0xff),
  49798 	517: uint8(0xff),
  49799 	518: uint8(0xff),
  49800 	519: uint8(0xff),
  49801 	520: uint8(0xff),
  49802 	521: uint8(0xff),
  49803 	522: uint8(0xff),
  49804 	523: uint8(0xff),
  49805 	524: uint8(0xff),
  49806 	525: uint8(0xff),
  49807 	526: uint8(0xff),
  49808 	527: uint8(0xff),
  49809 	528: uint8(0xff),
  49810 	529: uint8(0xff),
  49811 	530: uint8(0xff),
  49812 	531: uint8(0xff),
  49813 	532: uint8(0xff),
  49814 	533: uint8(0xff),
  49815 	534: uint8(0xff),
  49816 	535: uint8(0xff),
  49817 	536: uint8(0xff),
  49818 	537: uint8(0xff),
  49819 	538: uint8(0xff),
  49820 	539: uint8(0xff),
  49821 	540: uint8(0xff),
  49822 	541: uint8(0xff),
  49823 	542: uint8(0xff),
  49824 	543: uint8(0xff),
  49825 	544: uint8(0xff),
  49826 	545: uint8(0xff),
  49827 	546: uint8(0xff),
  49828 	547: uint8(0xff),
  49829 	548: uint8(0xff),
  49830 	549: uint8(0xff),
  49831 	550: uint8(0xff),
  49832 	551: uint8(0xff),
  49833 	552: uint8(0xff),
  49834 	553: uint8(0xff),
  49835 	554: uint8(0xff),
  49836 	555: uint8(0xff),
  49837 	556: uint8(0xff),
  49838 	557: uint8(0xff),
  49839 	558: uint8(0xff),
  49840 	559: uint8(0xff),
  49841 	560: uint8(0xff),
  49842 	561: uint8(0xff),
  49843 	562: uint8(0xff),
  49844 	563: uint8(0xff),
  49845 	564: uint8(0xff),
  49846 	565: uint8(0xff),
  49847 	566: uint8(0xff),
  49848 	567: uint8(0xff),
  49849 	568: uint8(0xff),
  49850 	569: uint8(0xff),
  49851 	570: uint8(0xff),
  49852 	571: uint8(0xff),
  49853 	572: uint8(0xff),
  49854 	573: uint8(0xff),
  49855 	574: uint8(0xff),
  49856 	575: uint8(0xff),
  49857 	576: uint8(0xff),
  49858 	577: uint8(0xff),
  49859 	578: uint8(0xff),
  49860 	579: uint8(0xff),
  49861 	580: uint8(0xff),
  49862 	581: uint8(0xff),
  49863 	582: uint8(0xff),
  49864 	583: uint8(0xff),
  49865 	584: uint8(0xff),
  49866 	585: uint8(0xff),
  49867 	586: uint8(0xff),
  49868 	587: uint8(0xff),
  49869 	588: uint8(0xff),
  49870 	589: uint8(0xff),
  49871 	590: uint8(0xff),
  49872 	591: uint8(0xff),
  49873 	592: uint8(0xff),
  49874 	593: uint8(0xff),
  49875 	594: uint8(0xff),
  49876 	595: uint8(0xff),
  49877 	596: uint8(0xff),
  49878 	597: uint8(0xff),
  49879 	598: uint8(0xff),
  49880 	599: uint8(0xff),
  49881 	600: uint8(0xff),
  49882 	601: uint8(0xff),
  49883 	602: uint8(0xff),
  49884 	603: uint8(0xff),
  49885 	604: uint8(0xff),
  49886 	605: uint8(0xff),
  49887 	606: uint8(0xff),
  49888 	607: uint8(0xff),
  49889 	608: uint8(0xff),
  49890 	609: uint8(0xff),
  49891 	610: uint8(0xff),
  49892 	611: uint8(0xff),
  49893 	612: uint8(0xff),
  49894 	613: uint8(0xff),
  49895 	614: uint8(0xff),
  49896 	615: uint8(0xff),
  49897 	616: uint8(0xff),
  49898 	617: uint8(0xff),
  49899 	618: uint8(0xff),
  49900 	619: uint8(0xff),
  49901 	620: uint8(0xff),
  49902 	621: uint8(0xff),
  49903 	622: uint8(0xff),
  49904 	623: uint8(0xff),
  49905 	624: uint8(0xff),
  49906 	625: uint8(0xff),
  49907 	626: uint8(0xff),
  49908 	627: uint8(0xff),
  49909 	628: uint8(0xff),
  49910 	629: uint8(0xff),
  49911 	630: uint8(0xff),
  49912 	631: uint8(0xff),
  49913 	632: uint8(0xff),
  49914 	633: uint8(0xff),
  49915 	634: uint8(0xff),
  49916 	635: uint8(0xff),
  49917 	636: uint8(0xff),
  49918 	637: uint8(0xff),
  49919 	638: uint8(0xff),
  49920 	639: uint8(0xff),
  49921 	640: uint8(0xff),
  49922 	641: uint8(0xff),
  49923 	642: uint8(0xff),
  49924 	643: uint8(0xff),
  49925 	644: uint8(0xff),
  49926 	645: uint8(0xff),
  49927 	646: uint8(0xff),
  49928 	647: uint8(0xff),
  49929 	648: uint8(0xff),
  49930 	649: uint8(0xff),
  49931 	650: uint8(0xff),
  49932 	651: uint8(0xff),
  49933 	652: uint8(0xff),
  49934 	653: uint8(0xff),
  49935 	654: uint8(0xff),
  49936 	655: uint8(0xff),
  49937 	656: uint8(0xff),
  49938 	657: uint8(0xff),
  49939 	658: uint8(0xff),
  49940 	659: uint8(0xff),
  49941 	660: uint8(0xff),
  49942 	661: uint8(0xff),
  49943 	662: uint8(0xff),
  49944 	663: uint8(0xff),
  49945 	664: uint8(0xff),
  49946 	665: uint8(0xff),
  49947 	666: uint8(0xff),
  49948 	667: uint8(0xff),
  49949 	668: uint8(0xff),
  49950 	669: uint8(0xff),
  49951 	670: uint8(0xff),
  49952 	671: uint8(0xff),
  49953 	672: uint8(0xff),
  49954 	673: uint8(0xff),
  49955 	674: uint8(0xff),
  49956 	675: uint8(0xff),
  49957 	676: uint8(0xff),
  49958 	677: uint8(0xff),
  49959 	678: uint8(0xff),
  49960 	679: uint8(0xff),
  49961 	680: uint8(0xff),
  49962 	681: uint8(0xff),
  49963 	682: uint8(0xff),
  49964 	683: uint8(0xff),
  49965 	684: uint8(0xff),
  49966 	685: uint8(0xff),
  49967 	686: uint8(0xff),
  49968 	687: uint8(0xff),
  49969 	688: uint8(0xff),
  49970 	689: uint8(0xff),
  49971 	690: uint8(0xff),
  49972 	691: uint8(0xff),
  49973 	692: uint8(0xff),
  49974 	693: uint8(0xff),
  49975 	694: uint8(0xff),
  49976 	695: uint8(0xff),
  49977 	696: uint8(0xff),
  49978 	697: uint8(0xff),
  49979 	698: uint8(0xff),
  49980 	699: uint8(0xff),
  49981 	700: uint8(0xff),
  49982 	701: uint8(0xff),
  49983 	702: uint8(0xff),
  49984 	703: uint8(0xff),
  49985 	704: uint8(0xff),
  49986 	705: uint8(0xff),
  49987 	706: uint8(0xff),
  49988 	707: uint8(0xff),
  49989 	708: uint8(0xff),
  49990 	709: uint8(0xff),
  49991 	710: uint8(0xff),
  49992 	711: uint8(0xff),
  49993 	712: uint8(0xff),
  49994 	713: uint8(0xff),
  49995 	714: uint8(0xff),
  49996 	715: uint8(0xff),
  49997 	716: uint8(0xff),
  49998 	717: uint8(0xff),
  49999 	718: uint8(0xff),
  50000 	719: uint8(0xff),
  50001 	720: uint8(0xff),
  50002 	721: uint8(0xff),
  50003 	722: uint8(0xff),
  50004 	723: uint8(0xff),
  50005 	724: uint8(0xff),
  50006 	725: uint8(0xff),
  50007 	726: uint8(0xff),
  50008 	727: uint8(0xff),
  50009 	728: uint8(0xff),
  50010 	729: uint8(0xff),
  50011 	730: uint8(0xff),
  50012 	731: uint8(0xff),
  50013 	732: uint8(0xff),
  50014 	733: uint8(0xff),
  50015 	734: uint8(0xff),
  50016 	735: uint8(0xff),
  50017 	736: uint8(0xff),
  50018 	737: uint8(0xff),
  50019 	738: uint8(0xff),
  50020 	739: uint8(0xff),
  50021 	740: uint8(0xff),
  50022 	741: uint8(0xff),
  50023 	742: uint8(0xff),
  50024 	743: uint8(0xff),
  50025 	744: uint8(0xff),
  50026 	745: uint8(0xff),
  50027 	746: uint8(0xff),
  50028 	747: uint8(0xff),
  50029 	748: uint8(0xff),
  50030 	749: uint8(0xff),
  50031 	750: uint8(0xff),
  50032 	751: uint8(0xff),
  50033 	752: uint8(0xff),
  50034 	753: uint8(0xff),
  50035 	754: uint8(0xff),
  50036 	755: uint8(0xff),
  50037 	756: uint8(0xff),
  50038 	757: uint8(0xff),
  50039 	758: uint8(0xff),
  50040 	759: uint8(0xff),
  50041 	760: uint8(0xff),
  50042 	761: uint8(0xff),
  50043 	762: uint8(0xff),
  50044 	763: uint8(0xff),
  50045 	764: uint8(0xff),
  50046 	765: uint8(0xff),
  50047 }
  50048 
  50049 func VP8InitClipTables(tls *libc.TLS) {
  50050 }
  50051 
  50052 func VP8DspInitMIPS32(tls *libc.TLS) {
  50053 }
  50054 
  50055 func VP8DspInitMIPSdspR2(tls *libc.TLS) {
  50056 }
  50057 
  50058 func VP8DspInitMSA(tls *libc.TLS) {
  50059 }
  50060 
  50061 func VP8DspInitNEON(tls *libc.TLS) {
  50062 }
  50063 
  50064 func VP8DspInitSSE2(tls *libc.TLS) {
  50065 }
  50066 
  50067 func VP8DspInitSSE41(tls *libc.TLS) {
  50068 }
  50069 
  50070 //------------------------------------------------------------------------------
  50071 
  50072 // Copyright 2012 Google Inc. All Rights Reserved.
  50073 //
  50074 // Use of this source code is governed by a BSD-style license
  50075 // that can be found in the COPYING file in the root of the source
  50076 // tree. An additional intellectual property rights grant can be found
  50077 // in the file PATENTS. All contributing project authors may
  50078 // be found in the AUTHORS file in the root of the source tree.
  50079 // -----------------------------------------------------------------------------
  50080 //
  50081 // Misc. common utility functions
  50082 //
  50083 // Authors: Skal (pascal.massimino@gmail.com)
  50084 //          Urvang (urvang@google.com)
  50085 
  50086 // Copyright 2010 Google Inc. All Rights Reserved.
  50087 //
  50088 // Use of this source code is governed by a BSD-style license
  50089 // that can be found in the COPYING file in the root of the source
  50090 // tree. An additional intellectual property rights grant can be found
  50091 // in the file PATENTS. All contributing project authors may
  50092 // be found in the AUTHORS file in the root of the source tree.
  50093 // -----------------------------------------------------------------------------
  50094 //
  50095 //  Common types + memory wrappers
  50096 //
  50097 // Author: Skal (pascal.massimino@gmail.com)
  50098 
  50099 func clip_8b2(tls *libc.TLS, v int32) (r uint8_t) {
  50100 	var v1, v2 int32
  50101 	_, _ = v1, v2
  50102 	if !(v & ^libc.Int32FromInt32(0xff) != 0) {
  50103 		v1 = v
  50104 	} else {
  50105 		if v < 0 {
  50106 			v2 = 0
  50107 		} else {
  50108 			v2 = int32(255)
  50109 		}
  50110 		v1 = v2
  50111 	}
  50112 	return libc.Uint8FromInt32(v1)
  50113 }
  50114 
  50115 func clip_max(tls *libc.TLS, v int32, max int32) (r int32) {
  50116 	var v1 int32
  50117 	_ = v1
  50118 	if v > max {
  50119 		v1 = max
  50120 	} else {
  50121 		v1 = v
  50122 	}
  50123 	return v1
  50124 }
  50125 
  50126 // C documentation
  50127 //
  50128 //	// general-purpose util function
  50129 func VP8SetHistogramData(tls *libc.TLS, distribution uintptr, histo uintptr) {
  50130 	var k, last_non_zero, max_value, value int32
  50131 	_, _, _, _ = k, last_non_zero, max_value, value
  50132 	max_value = 0
  50133 	last_non_zero = int32(1)
  50134 	k = 0
  50135 	for {
  50136 		if !(k <= int32(MAX_COEFF_THRESH)) {
  50137 			break
  50138 		}
  50139 		value = **(**int32)(__ccgo_up(distribution + uintptr(k)*4))
  50140 		if value > 0 {
  50141 			if value > max_value {
  50142 				max_value = value
  50143 			}
  50144 			last_non_zero = k
  50145 		}
  50146 		goto _1
  50147 	_1:
  50148 		;
  50149 		k = k + 1
  50150 	}
  50151 	(*VP8Histogram)(unsafe.Pointer(histo)).Fmax_value = max_value
  50152 	(*VP8Histogram)(unsafe.Pointer(histo)).Flast_non_zero = last_non_zero
  50153 }
  50154 
  50155 func CollectHistogram_C(tls *libc.TLS, ref uintptr, pred uintptr, start_block int32, end_block int32, histo uintptr) {
  50156 	bp := tls.Alloc(160)
  50157 	defer tls.Free(160)
  50158 	var clipped_value, j, k, v int32
  50159 	var _ /* distribution at bp+0 */ [32]int32
  50160 	var _ /* out at bp+128 */ [16]int16_t
  50161 	_, _, _, _ = clipped_value, j, k, v
  50162 	**(**[32]int32)(__ccgo_up(bp)) = [32]int32{}
  50163 	j = start_block
  50164 	for {
  50165 		if !(j < end_block) {
  50166 			break
  50167 		}
  50168 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, ref+uintptr(VP8DspScan[j]), pred+uintptr(VP8DspScan[j]), bp+128)
  50169 		// Convert coefficients to bin.
  50170 		k = 0
  50171 		for {
  50172 			if !(k < int32(16)) {
  50173 				break
  50174 			}
  50175 			v = libc.Xabs(tls, int32((**(**[16]int16_t)(__ccgo_up(bp + 128)))[k])) >> int32(3)
  50176 			clipped_value = clip_max(tls, v, int32(MAX_COEFF_THRESH))
  50177 			(**(**[32]int32)(__ccgo_up(bp)))[clipped_value] = (**(**[32]int32)(__ccgo_up(bp)))[clipped_value] + 1
  50178 			goto _2
  50179 		_2:
  50180 			;
  50181 			k = k + 1
  50182 		}
  50183 		goto _1
  50184 	_1:
  50185 		;
  50186 		j = j + 1
  50187 	}
  50188 	VP8SetHistogramData(tls, bp, histo)
  50189 }
  50190 
  50191 //------------------------------------------------------------------------------
  50192 // run-time tables (~4k)
  50193 
  50194 var clip12 [766]uint8_t // clips [-255,510] to [0,255]
  50195 
  50196 // C documentation
  50197 //
  50198 //	// We declare this variable 'volatile' to prevent instruction reordering
  50199 //	// and make sure it's set to true _last_ (so as to be thread-safe)
  50200 var tables_ok = int32(0)
  50201 
  50202 func InitTables(tls *libc.TLS) {
  50203 	var i int32
  50204 	_ = i
  50205 	if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&tables_ok))) != 0) {
  50206 		i = -int32(255)
  50207 		for {
  50208 			if !(i <= libc.Int32FromInt32(255)+libc.Int32FromInt32(255)) {
  50209 				break
  50210 			}
  50211 			clip12[int32(255)+i] = clip_8b2(tls, i)
  50212 			goto _1
  50213 		_1:
  50214 			;
  50215 			i = i + 1
  50216 		}
  50217 		libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&tables_ok)), int32(1))
  50218 	}
  50219 }
  50220 
  50221 //------------------------------------------------------------------------------
  50222 // Transforms (Paragraph 14.4)
  50223 
  50224 func ITransformOne(tls *libc.TLS, ref uintptr, in uintptr, dst uintptr) {
  50225 	bp := tls.Alloc(64)
  50226 	defer tls.Free(64)
  50227 	var a, a1, b, b1, c, c1, d, d1, dc, i int32
  50228 	var tmp uintptr
  50229 	var _ /* C at bp+0 */ [16]int32
  50230 	_, _, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, c, c1, d, d1, dc, i, tmp
  50231 	tmp = bp
  50232 	i = 0
  50233 	for {
  50234 		if !(i < int32(4)) {
  50235 			break
  50236 		} // vertical pass
  50237 		a = int32(**(**int16_t)(__ccgo_up(in))) + int32(**(**int16_t)(__ccgo_up(in + 8*2)))
  50238 		b = int32(**(**int16_t)(__ccgo_up(in))) - int32(**(**int16_t)(__ccgo_up(in + 8*2)))
  50239 		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))))
  50240 		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)
  50241 		**(**int32)(__ccgo_up(tmp)) = a + d
  50242 		**(**int32)(__ccgo_up(tmp + 1*4)) = b + c
  50243 		**(**int32)(__ccgo_up(tmp + 2*4)) = b - c
  50244 		**(**int32)(__ccgo_up(tmp + 3*4)) = a - d
  50245 		tmp = tmp + uintptr(4)*4
  50246 		in += 2
  50247 		goto _1
  50248 	_1:
  50249 		;
  50250 		i = i + 1
  50251 	}
  50252 	tmp = bp
  50253 	i = 0
  50254 	for {
  50255 		if !(i < int32(4)) {
  50256 			break
  50257 		} // horizontal pass
  50258 		dc = **(**int32)(__ccgo_up(tmp)) + int32(4)
  50259 		a1 = dc + **(**int32)(__ccgo_up(tmp + 8*4))
  50260 		b1 = dc - **(**int32)(__ccgo_up(tmp + 8*4))
  50261 		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)))
  50262 		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)
  50263 		**(**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))
  50264 		**(**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))
  50265 		**(**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))
  50266 		**(**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))
  50267 		tmp += 4
  50268 		goto _2
  50269 	_2:
  50270 		;
  50271 		i = i + 1
  50272 	}
  50273 }
  50274 
  50275 func ITransform_C(tls *libc.TLS, ref uintptr, in uintptr, dst uintptr, do_two int32) {
  50276 	ITransformOne(tls, ref, in, dst)
  50277 	if do_two != 0 {
  50278 		ITransformOne(tls, ref+uintptr(4), in+uintptr(16)*2, dst+uintptr(4))
  50279 	}
  50280 }
  50281 
  50282 func FTransform_C(tls *libc.TLS, src uintptr, ref uintptr, out uintptr) {
  50283 	var a0, a01, a1, a11, a2, a21, a3, a31, d0, d1, d2, d3, i int32
  50284 	var tmp [16]int32
  50285 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, d0, d1, d2, d3, i, tmp
  50286 	i = 0
  50287 	for {
  50288 		if !(i < int32(4)) {
  50289 			break
  50290 		}
  50291 		d0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref))) // 9bit dynamic range ([-255,255])
  50292 		d1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 1))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 1)))
  50293 		d2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 2))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 2)))
  50294 		d3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src + 3))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(ref + 3)))
  50295 		a0 = d0 + d3 // 10b                      [-510,510]
  50296 		a1 = d1 + d2
  50297 		a2 = d1 - d2
  50298 		a3 = d0 - d3
  50299 		tmp[0+i*int32(4)] = (a0 + a1) * int32(8)                                               // 14b                      [-8160,8160]
  50300 		tmp[int32(1)+i*int32(4)] = (a2*int32(2217) + a3*int32(5352) + int32(1812)) >> int32(9) // [-7536,7542]
  50301 		tmp[int32(2)+i*int32(4)] = (a0 - a1) * int32(8)
  50302 		tmp[int32(3)+i*int32(4)] = (a3*int32(2217) - a2*int32(5352) + int32(937)) >> int32(9)
  50303 		goto _1
  50304 	_1:
  50305 		;
  50306 		i = i + 1
  50307 		src = src + uintptr(BPS)
  50308 		ref = ref + uintptr(BPS)
  50309 	}
  50310 	i = 0
  50311 	for {
  50312 		if !(i < int32(4)) {
  50313 			break
  50314 		}
  50315 		a01 = tmp[0+i] + tmp[int32(12)+i] // 15b
  50316 		a11 = tmp[int32(4)+i] + tmp[int32(8)+i]
  50317 		a21 = tmp[int32(4)+i] - tmp[int32(8)+i]
  50318 		a31 = tmp[0+i] - tmp[int32(12)+i]
  50319 		**(**int16_t)(__ccgo_up(out + uintptr(0+i)*2)) = int16((a01 + a11 + int32(7)) >> int32(4)) // 12b
  50320 		**(**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))
  50321 		**(**int16_t)(__ccgo_up(out + uintptr(int32(8)+i)*2)) = int16((a01 - a11 + int32(7)) >> int32(4))
  50322 		**(**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))
  50323 		goto _2
  50324 	_2:
  50325 		;
  50326 		i = i + 1
  50327 	}
  50328 }
  50329 
  50330 func FTransform2_C(tls *libc.TLS, src uintptr, ref uintptr, out uintptr) {
  50331 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src, ref, out)
  50332 	(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8FTransform})))(tls, src+uintptr(4), ref+uintptr(4), out+uintptr(16)*2)
  50333 }
  50334 
  50335 func FTransformWHT_C(tls *libc.TLS, in uintptr, out uintptr) {
  50336 	var a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i int32
  50337 	var tmp [16]int32_t
  50338 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, tmp
  50339 	i = 0
  50340 	for {
  50341 		if !(i < int32(4)) {
  50342 			break
  50343 		}
  50344 		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
  50345 		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)))
  50346 		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)))
  50347 		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)))
  50348 		tmp[0+i*int32(4)] = a0 + a1 // 14b
  50349 		tmp[int32(1)+i*int32(4)] = a3 + a2
  50350 		tmp[int32(2)+i*int32(4)] = a3 - a2
  50351 		tmp[int32(3)+i*int32(4)] = a0 - a1
  50352 		goto _1
  50353 	_1:
  50354 		;
  50355 		i = i + 1
  50356 		in = in + uintptr(64)*2
  50357 	}
  50358 	i = 0
  50359 	for {
  50360 		if !(i < int32(4)) {
  50361 			break
  50362 		}
  50363 		a01 = tmp[0+i] + tmp[int32(8)+i] // 15b
  50364 		a11 = tmp[int32(4)+i] + tmp[int32(12)+i]
  50365 		a21 = tmp[int32(4)+i] - tmp[int32(12)+i]
  50366 		a31 = tmp[0+i] - tmp[int32(8)+i]
  50367 		b0 = a01 + a11 // 16b
  50368 		b1 = a31 + a21
  50369 		b2 = a31 - a21
  50370 		b3 = a01 - a11
  50371 		**(**int16_t)(__ccgo_up(out + uintptr(0+i)*2)) = int16(b0 >> int32(1)) // 15b
  50372 		**(**int16_t)(__ccgo_up(out + uintptr(int32(4)+i)*2)) = int16(b1 >> int32(1))
  50373 		**(**int16_t)(__ccgo_up(out + uintptr(int32(8)+i)*2)) = int16(b2 >> int32(1))
  50374 		**(**int16_t)(__ccgo_up(out + uintptr(int32(12)+i)*2)) = int16(b3 >> int32(1))
  50375 		goto _2
  50376 	_2:
  50377 		;
  50378 		i = i + 1
  50379 	}
  50380 }
  50381 
  50382 //------------------------------------------------------------------------------
  50383 // Intra predictions
  50384 
  50385 func Fill(tls *libc.TLS, dst uintptr, value int32, size int32) {
  50386 	var j int32
  50387 	_ = j
  50388 	j = 0
  50389 	for {
  50390 		if !(j < size) {
  50391 			break
  50392 		}
  50393 		libc.X__builtin___memset_chk(tls, dst+uintptr(j*int32(BPS)), value, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  50394 		goto _1
  50395 	_1:
  50396 		;
  50397 		j = j + 1
  50398 	}
  50399 }
  50400 
  50401 func VerticalPred(tls *libc.TLS, dst uintptr, top uintptr, size int32) {
  50402 	var j int32
  50403 	_ = j
  50404 	if top != libc.UintptrFromInt32(0) {
  50405 		j = 0
  50406 		for {
  50407 			if !(j < size) {
  50408 				break
  50409 			}
  50410 			libc.X__builtin___memcpy_chk(tls, dst+uintptr(j*int32(BPS)), top, libc.Uint64FromInt32(size), ^__predefined_size_t(0))
  50411 			goto _1
  50412 		_1:
  50413 			;
  50414 			j = j + 1
  50415 		}
  50416 	} else {
  50417 		Fill(tls, dst, int32(127), size)
  50418 	}
  50419 }
  50420 
  50421 func HorizontalPred(tls *libc.TLS, dst uintptr, left uintptr, size int32) {
  50422 	var j int32
  50423 	_ = j
  50424 	if left != libc.UintptrFromInt32(0) {
  50425 		j = 0
  50426 		for {
  50427 			if !(j < size) {
  50428 				break
  50429 			}
  50430 			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))
  50431 			goto _1
  50432 		_1:
  50433 			;
  50434 			j = j + 1
  50435 		}
  50436 	} else {
  50437 		Fill(tls, dst, int32(129), size)
  50438 	}
  50439 }
  50440 
  50441 func TrueMotion1(tls *libc.TLS, dst uintptr, left uintptr, top uintptr, size int32) {
  50442 	var clip, clip_table uintptr
  50443 	var x, y int32
  50444 	_, _, _, _ = clip, clip_table, x, y
  50445 	if left != libc.UintptrFromInt32(0) {
  50446 		if top != libc.UintptrFromInt32(0) {
  50447 			clip = uintptr(unsafe.Pointer(&clip12)) + uintptr(255) - uintptr(**(**uint8_t)(__ccgo_up(left + uintptr(-libc.Int32FromInt32(1)))))
  50448 			y = 0
  50449 			for {
  50450 				if !(y < size) {
  50451 					break
  50452 				}
  50453 				clip_table = clip + uintptr(**(**uint8_t)(__ccgo_up(left + uintptr(y))))
  50454 				x = 0
  50455 				for {
  50456 					if !(x < size) {
  50457 						break
  50458 					}
  50459 					**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip_table + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  50460 					goto _2
  50461 				_2:
  50462 					;
  50463 					x = x + 1
  50464 				}
  50465 				dst = dst + uintptr(BPS)
  50466 				goto _1
  50467 			_1:
  50468 				;
  50469 				y = y + 1
  50470 			}
  50471 		} else {
  50472 			HorizontalPred(tls, dst, left, size)
  50473 		}
  50474 	} else {
  50475 		// true motion without left samples (hence: with default 129 value)
  50476 		// is equivalent to VE prediction where you just copy the top samples.
  50477 		// Note that if top samples are not available, the default value is
  50478 		// then 129, and not 127 as in the VerticalPred case.
  50479 		if top != libc.UintptrFromInt32(0) {
  50480 			VerticalPred(tls, dst, top, size)
  50481 		} else {
  50482 			Fill(tls, dst, int32(129), size)
  50483 		}
  50484 	}
  50485 }
  50486 
  50487 func DCMode(tls *libc.TLS, dst uintptr, left uintptr, top uintptr, size int32, round int32, shift int32) {
  50488 	var DC, j int32
  50489 	_, _ = DC, j
  50490 	DC = 0
  50491 	if top != libc.UintptrFromInt32(0) {
  50492 		j = 0
  50493 		for {
  50494 			if !(j < size) {
  50495 				break
  50496 			}
  50497 			DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(j))))
  50498 			goto _1
  50499 		_1:
  50500 			;
  50501 			j = j + 1
  50502 		}
  50503 		if left != libc.UintptrFromInt32(0) { // top and left present
  50504 			j = 0
  50505 			for {
  50506 				if !(j < size) {
  50507 					break
  50508 				}
  50509 				DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(j))))
  50510 				goto _2
  50511 			_2:
  50512 				;
  50513 				j = j + 1
  50514 			}
  50515 		} else { // top, but no left
  50516 			DC = DC + DC
  50517 		}
  50518 		DC = (DC + round) >> shift
  50519 	} else {
  50520 		if left != libc.UintptrFromInt32(0) { // left but no top
  50521 			j = 0
  50522 			for {
  50523 				if !(j < size) {
  50524 					break
  50525 				}
  50526 				DC = DC + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(left + uintptr(j))))
  50527 				goto _3
  50528 			_3:
  50529 				;
  50530 				j = j + 1
  50531 			}
  50532 			DC = DC + DC
  50533 			DC = (DC + round) >> shift
  50534 		} else { // no top, no left, nothing.
  50535 			DC = int32(0x80)
  50536 		}
  50537 	}
  50538 	Fill(tls, dst, DC, size)
  50539 }
  50540 
  50541 //------------------------------------------------------------------------------
  50542 // Chroma 8x8 prediction (paragraph 12.2)
  50543 
  50544 func IntraChromaPreds_C(tls *libc.TLS, dst uintptr, left uintptr, top uintptr) {
  50545 	// U block
  50546 	DCMode(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(8), int32(8), int32(4))
  50547 	VerticalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS))+dst, top, int32(8))
  50548 	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))
  50549 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, top, int32(8))
  50550 	// V block
  50551 	dst = dst + uintptr(8)
  50552 	if top != libc.UintptrFromInt32(0) {
  50553 		top = top + uintptr(8)
  50554 	}
  50555 	if left != libc.UintptrFromInt32(0) {
  50556 		left = left + uintptr(16)
  50557 	}
  50558 	DCMode(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(8), int32(8), int32(4))
  50559 	VerticalPred(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS))+dst, top, int32(8))
  50560 	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))
  50561 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(1)*libc.Int32FromInt32(16))+dst, left, top, int32(8))
  50562 }
  50563 
  50564 //------------------------------------------------------------------------------
  50565 // luma 16x16 prediction (paragraph 12.3)
  50566 
  50567 func Intra16Preds_C(tls *libc.TLS, dst uintptr, left uintptr, top uintptr) {
  50568 	DCMode(tls, uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, left, top, int32(16), int32(16), int32(5))
  50569 	VerticalPred(tls, uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS))+dst, top, int32(16))
  50570 	HorizontalPred(tls, uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(16))+dst, left, int32(16))
  50571 	TrueMotion1(tls, uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(16))+dst, left, top, int32(16))
  50572 }
  50573 
  50574 //------------------------------------------------------------------------------
  50575 // luma 4x4 prediction
  50576 
  50577 // C documentation
  50578 //
  50579 //	// vertical
  50580 func VE4(tls *libc.TLS, dst uintptr, top uintptr) {
  50581 	bp := tls.Alloc(16)
  50582 	defer tls.Free(16)
  50583 	var i int32
  50584 	var _ /* vals at bp+0 */ [4]uint8_t
  50585 	_ = i
  50586 	**(**[4]uint8_t)(__ccgo_up(bp)) = [4]uint8_t{
  50587 		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)),
  50588 		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)),
  50589 		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)),
  50590 		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)),
  50591 	}
  50592 	i = 0
  50593 	for {
  50594 		if !(i < int32(4)) {
  50595 			break
  50596 		}
  50597 		libc.X__builtin___memcpy_chk(tls, dst+uintptr(i*int32(BPS)), bp, uint64(4), ^__predefined_size_t(0))
  50598 		goto _1
  50599 	_1:
  50600 		;
  50601 		i = i + 1
  50602 	}
  50603 }
  50604 
  50605 // C documentation
  50606 //
  50607 //	// horizontal
  50608 func HE4(tls *libc.TLS, dst uintptr, top uintptr) {
  50609 	bp := tls.Alloc(16)
  50610 	defer tls.Free(16)
  50611 	var I, J, K, L, X int32
  50612 	var v1 uintptr
  50613 	var v2 uint32_t
  50614 	_, _, _, _, _, _, _ = I, J, K, L, X, v1, v2
  50615 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50616 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50617 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50618 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50619 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50620 	v1 = dst + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS))
  50621 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((X+libc.Int32FromInt32(2)*I+J+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50622 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50623 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50624 	v1 = dst + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS))
  50625 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((I+libc.Int32FromInt32(2)*J+K+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50626 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50627 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50628 	v1 = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS))
  50629 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((J+libc.Int32FromInt32(2)*K+L+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50630 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50631 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50632 	v1 = dst + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS))
  50633 	v2 = uint32(0x01010101) * uint32(libc.Uint8FromInt32((K+libc.Int32FromInt32(2)*L+L+libc.Int32FromInt32(2))>>libc.Int32FromInt32(2)))
  50634 	*(*uint32_t)(unsafe.Pointer(bp)) = v2
  50635 	libc.X__builtin___memcpy_chk(tls, v1, bp, uint64(4), ^__predefined_size_t(0))
  50636 }
  50637 
  50638 func DC4(tls *libc.TLS, dst uintptr, top uintptr) {
  50639 	var dc uint32_t
  50640 	var i int32
  50641 	_, _ = dc, i
  50642 	dc = uint32(4)
  50643 	i = 0
  50644 	for {
  50645 		if !(i < int32(4)) {
  50646 			break
  50647 		}
  50648 		dc = dc + libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(i))))+libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-int32(5)+i)))))
  50649 		goto _1
  50650 	_1:
  50651 		;
  50652 		i = i + 1
  50653 	}
  50654 	Fill(tls, dst, libc.Int32FromUint32(dc>>int32(3)), int32(4))
  50655 }
  50656 
  50657 func RD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50658 	var A, B, C, D, I, J, K, L, X int32
  50659 	var v1, v2, v3 uint8_t
  50660 	_, _, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, L, X, v1, v2, v3
  50661 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50662 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50663 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50664 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50665 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50666 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50667 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50668 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50669 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50670 	**(**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))
  50671 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*J + K + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50672 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50673 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50674 	v2 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*I + J + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50675 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50676 	v1 = v2
  50677 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50678 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50679 	v3 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*X + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50680 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50681 	v2 = v3
  50682 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50683 	v1 = v2
  50684 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50685 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50686 	v2 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*A + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50687 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50688 	v1 = v2
  50689 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50690 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50691 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*B + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50692 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50693 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50694 	**(**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))
  50695 }
  50696 
  50697 func LD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50698 	var A, B, C, D, E, F, G, H int32
  50699 	var v1, v2, v3 uint8_t
  50700 	_, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1, v2, v3
  50701 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50702 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50703 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50704 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50705 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4)))
  50706 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 5)))
  50707 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 6)))
  50708 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 7)))
  50709 	**(**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))
  50710 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50711 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50712 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50713 	v2 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50714 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50715 	v1 = v2
  50716 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50717 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50718 	v3 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50719 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50720 	v2 = v3
  50721 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v2
  50722 	v1 = v2
  50723 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50724 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50725 	v2 = libc.Uint8FromInt32((E + libc.Int32FromInt32(2)*F + G + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50726 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50727 	v1 = v2
  50728 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50729 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50730 	v1 = libc.Uint8FromInt32((F + libc.Int32FromInt32(2)*G + H + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50731 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50732 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50733 	**(**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))
  50734 }
  50735 
  50736 func VR4(tls *libc.TLS, dst uintptr, top uintptr) {
  50737 	var A, B, C, D, I, J, K, X int32
  50738 	var v1 uint8_t
  50739 	_, _, _, _, _, _, _, _, _ = A, B, C, D, I, J, K, X, v1
  50740 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50741 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50742 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50743 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50744 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50745 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50746 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50747 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50748 	v1 = libc.Uint8FromInt32((X + A + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50749 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50750 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50751 	v1 = libc.Uint8FromInt32((A + B + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50752 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50753 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50754 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50755 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50756 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50757 	**(**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))
  50758 	**(**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))
  50759 	**(**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))
  50760 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50761 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50762 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50763 	v1 = libc.Uint8FromInt32((X + libc.Int32FromInt32(2)*A + B + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50764 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50765 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50766 	v1 = libc.Uint8FromInt32((A + libc.Int32FromInt32(2)*B + C + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50767 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50768 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50769 	**(**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))
  50770 }
  50771 
  50772 func VL4(tls *libc.TLS, dst uintptr, top uintptr) {
  50773 	var A, B, C, D, E, F, G, H int32
  50774 	var v1 uint8_t
  50775 	_, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, G, H, v1
  50776 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50777 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50778 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50779 	D = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 3)))
  50780 	E = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 4)))
  50781 	F = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 5)))
  50782 	G = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 6)))
  50783 	H = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 7)))
  50784 	**(**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))
  50785 	v1 = libc.Uint8FromInt32((B + C + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50786 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50787 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50788 	v1 = libc.Uint8FromInt32((C + D + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50789 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50790 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50791 	v1 = libc.Uint8FromInt32((D + E + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50792 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50793 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50794 	**(**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))
  50795 	v1 = libc.Uint8FromInt32((B + libc.Int32FromInt32(2)*C + D + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50796 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50797 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50798 	v1 = libc.Uint8FromInt32((C + libc.Int32FromInt32(2)*D + E + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50799 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50800 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50801 	v1 = libc.Uint8FromInt32((D + libc.Int32FromInt32(2)*E + F + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50802 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50803 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50804 	**(**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))
  50805 	**(**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))
  50806 }
  50807 
  50808 func HU4(tls *libc.TLS, dst uintptr, top uintptr) {
  50809 	var I, J, K, L int32
  50810 	var v1, v2, v3, v4, v5 uint8_t
  50811 	_, _, _, _, _, _, _, _, _ = I, J, K, L, v1, v2, v3, v4, v5
  50812 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50813 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50814 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50815 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50816 	**(**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))
  50817 	v1 = libc.Uint8FromInt32((J + K + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50818 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50819 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50820 	v1 = libc.Uint8FromInt32((K + L + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50821 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50822 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50823 	**(**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))
  50824 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*K + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50825 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50826 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50827 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*L + L + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50828 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50829 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50830 	v5 = libc.Uint8FromInt32(L)
  50831 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v5
  50832 	v4 = v5
  50833 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v4
  50834 	v3 = v4
  50835 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v3
  50836 	v2 = v3
  50837 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v2
  50838 	v1 = v2
  50839 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50840 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50841 }
  50842 
  50843 func HD4(tls *libc.TLS, dst uintptr, top uintptr) {
  50844 	var A, B, C, I, J, K, L, X int32
  50845 	var v1 uint8_t
  50846 	_, _, _, _, _, _, _, _, _ = A, B, C, I, J, K, L, X, v1
  50847 	X = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50848 	I = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(2)))))
  50849 	J = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(3)))))
  50850 	K = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(4)))))
  50851 	L = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(5)))))
  50852 	A = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top)))
  50853 	B = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 1)))
  50854 	C = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top + 2)))
  50855 	v1 = libc.Uint8FromInt32((I + X + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50856 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50857 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50858 	v1 = libc.Uint8FromInt32((J + I + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50859 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50860 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50861 	v1 = libc.Uint8FromInt32((K + J + libc.Int32FromInt32(1)) >> libc.Int32FromInt32(1))
  50862 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(2)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50863 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(0)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50864 	**(**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))
  50865 	**(**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))
  50866 	**(**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))
  50867 	v1 = libc.Uint8FromInt32((I + libc.Int32FromInt32(2)*X + A + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50868 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50869 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)))) = v1
  50870 	v1 = libc.Uint8FromInt32((J + libc.Int32FromInt32(2)*I + X + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50871 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50872 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(1)*libc.Int32FromInt32(BPS)))) = v1
  50873 	v1 = libc.Uint8FromInt32((K + libc.Int32FromInt32(2)*J + I + libc.Int32FromInt32(2)) >> libc.Int32FromInt32(2))
  50874 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(3)+libc.Int32FromInt32(3)*libc.Int32FromInt32(BPS)))) = v1
  50875 	**(**uint8_t)(__ccgo_up(dst + uintptr(libc.Int32FromInt32(1)+libc.Int32FromInt32(2)*libc.Int32FromInt32(BPS)))) = v1
  50876 	**(**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))
  50877 }
  50878 
  50879 func TM4(tls *libc.TLS, dst uintptr, top uintptr) {
  50880 	var clip, clip_table uintptr
  50881 	var x, y int32
  50882 	_, _, _, _ = clip, clip_table, x, y
  50883 	clip = uintptr(unsafe.Pointer(&clip12)) + uintptr(255) - uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1)))))
  50884 	y = 0
  50885 	for {
  50886 		if !(y < int32(4)) {
  50887 			break
  50888 		}
  50889 		clip_table = clip + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(-int32(2)-y))))
  50890 		x = 0
  50891 		for {
  50892 			if !(x < int32(4)) {
  50893 				break
  50894 			}
  50895 			**(**uint8_t)(__ccgo_up(dst + uintptr(x))) = **(**uint8_t)(__ccgo_up(clip_table + uintptr(**(**uint8_t)(__ccgo_up(top + uintptr(x))))))
  50896 			goto _2
  50897 		_2:
  50898 			;
  50899 			x = x + 1
  50900 		}
  50901 		dst = dst + uintptr(BPS)
  50902 		goto _1
  50903 	_1:
  50904 		;
  50905 		y = y + 1
  50906 	}
  50907 }
  50908 
  50909 // C documentation
  50910 //
  50911 //	// Left samples are top[-5 .. -2], top_left is top[-1], top are
  50912 //	// located at top[0..3], and top right is top[4..7]
  50913 func Intra4Preds_C(tls *libc.TLS, dst uintptr, top uintptr) {
  50914 	DC4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0))+dst, top)
  50915 	TM4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(4))+dst, top)
  50916 	VE4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(8))+dst, top)
  50917 	HE4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(12))+dst, top)
  50918 	RD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(16))+dst, top)
  50919 	VR4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(20))+dst, top)
  50920 	LD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(24))+dst, top)
  50921 	VL4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(0)+libc.Int32FromInt32(28))+dst, top)
  50922 	HD4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS))+dst, top)
  50923 	HU4(tls, uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)+libc.Int32FromInt32(4))+dst, top)
  50924 }
  50925 
  50926 //------------------------------------------------------------------------------
  50927 // Metric
  50928 
  50929 func GetSSE(tls *libc.TLS, a uintptr, b uintptr, w int32, h int32) (r int32) {
  50930 	var count, diff, x, y int32
  50931 	_, _, _, _ = count, diff, x, y
  50932 	count = 0
  50933 	y = 0
  50934 	for {
  50935 		if !(y < h) {
  50936 			break
  50937 		}
  50938 		x = 0
  50939 		for {
  50940 			if !(x < w) {
  50941 				break
  50942 			}
  50943 			diff = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(a + uintptr(x)))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(b + uintptr(x))))
  50944 			count = count + diff*diff
  50945 			goto _2
  50946 		_2:
  50947 			;
  50948 			x = x + 1
  50949 		}
  50950 		a = a + uintptr(BPS)
  50951 		b = b + uintptr(BPS)
  50952 		goto _1
  50953 	_1:
  50954 		;
  50955 		y = y + 1
  50956 	}
  50957 	return count
  50958 }
  50959 
  50960 func SSE16x16_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50961 	return GetSSE(tls, a, b, int32(16), int32(16))
  50962 }
  50963 
  50964 func SSE16x8_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50965 	return GetSSE(tls, a, b, int32(16), int32(8))
  50966 }
  50967 
  50968 func SSE8x8_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50969 	return GetSSE(tls, a, b, int32(8), int32(8))
  50970 }
  50971 
  50972 func SSE4x4_C(tls *libc.TLS, a uintptr, b uintptr) (r int32) {
  50973 	return GetSSE(tls, a, b, int32(4), int32(4))
  50974 }
  50975 
  50976 func Mean16x4_C(tls *libc.TLS, ref uintptr, dc uintptr) {
  50977 	var avg uint32_t
  50978 	var k, x, y int32
  50979 	_, _, _, _ = avg, k, x, y
  50980 	k = 0
  50981 	for {
  50982 		if !(k < int32(4)) {
  50983 			break
  50984 		}
  50985 		avg = uint32(0)
  50986 		y = 0
  50987 		for {
  50988 			if !(y < int32(4)) {
  50989 				break
  50990 			}
  50991 			x = 0
  50992 			for {
  50993 				if !(x < int32(4)) {
  50994 					break
  50995 				}
  50996 				avg = avg + uint32(**(**uint8_t)(__ccgo_up(ref + uintptr(x+y*int32(BPS)))))
  50997 				goto _3
  50998 			_3:
  50999 				;
  51000 				x = x + 1
  51001 			}
  51002 			goto _2
  51003 		_2:
  51004 			;
  51005 			y = y + 1
  51006 		}
  51007 		**(**uint32_t)(__ccgo_up(dc + uintptr(k)*4)) = avg
  51008 		ref = ref + uintptr(4) // go to next 4x4 block.
  51009 		goto _1
  51010 	_1:
  51011 		;
  51012 		k = k + 1
  51013 	}
  51014 }
  51015 
  51016 //------------------------------------------------------------------------------
  51017 // Texture distortion
  51018 //
  51019 // We try to match the spectral content (weighted) between source and
  51020 // reconstructed samples.
  51021 
  51022 // C documentation
  51023 //
  51024 //	// Hadamard transform
  51025 //	// Returns the weighted sum of the absolute value of transformed coefficients.
  51026 //	// w[] contains a row-major 4 by 4 symmetric matrix.
  51027 func TTransform(tls *libc.TLS, in uintptr, w uintptr) (r int32) {
  51028 	var a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, sum int32
  51029 	var tmp [16]int32
  51030 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a0, a01, a1, a11, a2, a21, a3, a31, b0, b1, b2, b3, i, sum, tmp
  51031 	sum = 0
  51032 	// horizontal pass
  51033 	i = 0
  51034 	for {
  51035 		if !(i < int32(4)) {
  51036 			break
  51037 		}
  51038 		a0 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 2)))
  51039 		a1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 1))) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 3)))
  51040 		a2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 1))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 3)))
  51041 		a3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + 2)))
  51042 		tmp[0+i*int32(4)] = a0 + a1
  51043 		tmp[int32(1)+i*int32(4)] = a3 + a2
  51044 		tmp[int32(2)+i*int32(4)] = a3 - a2
  51045 		tmp[int32(3)+i*int32(4)] = a0 - a1
  51046 		goto _1
  51047 	_1:
  51048 		;
  51049 		i = i + 1
  51050 		in = in + uintptr(BPS)
  51051 	}
  51052 	// vertical pass
  51053 	i = 0
  51054 	for {
  51055 		if !(i < int32(4)) {
  51056 			break
  51057 		}
  51058 		a01 = tmp[0+i] + tmp[int32(8)+i]
  51059 		a11 = tmp[int32(4)+i] + tmp[int32(12)+i]
  51060 		a21 = tmp[int32(4)+i] - tmp[int32(12)+i]
  51061 		a31 = tmp[0+i] - tmp[int32(8)+i]
  51062 		b0 = a01 + a11
  51063 		b1 = a31 + a21
  51064 		b2 = a31 - a21
  51065 		b3 = a01 - a11
  51066 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w)))*libc.Xabs(tls, b0)
  51067 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 4*2)))*libc.Xabs(tls, b1)
  51068 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 8*2)))*libc.Xabs(tls, b2)
  51069 		sum = sum + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(w + 12*2)))*libc.Xabs(tls, b3)
  51070 		goto _2
  51071 	_2:
  51072 		;
  51073 		i = i + 1
  51074 		w += 2
  51075 	}
  51076 	return sum
  51077 }
  51078 
  51079 func Disto4x4_C(tls *libc.TLS, a uintptr, b uintptr, w uintptr) (r int32) {
  51080 	var sum1, sum2 int32
  51081 	_, _ = sum1, sum2
  51082 	sum1 = TTransform(tls, a, w)
  51083 	sum2 = TTransform(tls, b, w)
  51084 	return libc.Xabs(tls, sum2-sum1) >> int32(5)
  51085 }
  51086 
  51087 func Disto16x16_C(tls *libc.TLS, a uintptr, b uintptr, w uintptr) (r int32) {
  51088 	var D, x, y int32
  51089 	_, _, _ = D, x, y
  51090 	D = 0
  51091 	y = 0
  51092 	for {
  51093 		if !(y < libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS)) {
  51094 			break
  51095 		}
  51096 		x = 0
  51097 		for {
  51098 			if !(x < int32(16)) {
  51099 				break
  51100 			}
  51101 			D = D + Disto4x4_C(tls, a+uintptr(x)+uintptr(y), b+uintptr(x)+uintptr(y), w)
  51102 			goto _2
  51103 		_2:
  51104 			;
  51105 			x = x + int32(4)
  51106 		}
  51107 		goto _1
  51108 	_1:
  51109 		;
  51110 		y = y + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)
  51111 	}
  51112 	return D
  51113 }
  51114 
  51115 //------------------------------------------------------------------------------
  51116 // Quantization
  51117 //
  51118 
  51119 var kZigzag2 = [16]uint8_t{
  51120 	1:  uint8(1),
  51121 	2:  uint8(4),
  51122 	3:  uint8(8),
  51123 	4:  uint8(5),
  51124 	5:  uint8(2),
  51125 	6:  uint8(3),
  51126 	7:  uint8(6),
  51127 	8:  uint8(9),
  51128 	9:  uint8(12),
  51129 	10: uint8(13),
  51130 	11: uint8(10),
  51131 	12: uint8(7),
  51132 	13: uint8(11),
  51133 	14: uint8(14),
  51134 	15: uint8(15),
  51135 }
  51136 
  51137 // C documentation
  51138 //
  51139 //	// Simple quantization
  51140 func QuantizeBlock_C(tls *libc.TLS, in uintptr, out uintptr, mtx uintptr) (r int32) {
  51141 	var B1, Q, coeff, iQ1 uint32_t
  51142 	var j, last, level, n1, sign, v2, v3 int32
  51143 	_, _, _, _, _, _, _, _, _, _, _ = B1, Q, coeff, iQ1, j, last, level, n1, sign, v2, v3
  51144 	last = -int32(1)
  51145 	n1 = 0
  51146 	for {
  51147 		if !(n1 < int32(16)) {
  51148 			break
  51149 		}
  51150 		j = libc.Int32FromUint8(kZigzag2[n1])
  51151 		sign = libc.BoolInt32(int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2))) < libc.Int32FromInt32(0))
  51152 		if sign != 0 {
  51153 			v2 = -int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  51154 		} else {
  51155 			v2 = int32(**(**int16_t)(__ccgo_up(in + uintptr(j)*2)))
  51156 		}
  51157 		coeff = libc.Uint32FromInt32(v2 + libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(mtx + 192 + uintptr(j)*2))))
  51158 		if coeff > **(**uint32_t)(__ccgo_up(mtx + 128 + uintptr(j)*4)) {
  51159 			Q = uint32(**(**uint16_t)(__ccgo_up(mtx + uintptr(j)*2)))
  51160 			iQ1 = uint32(**(**uint16_t)(__ccgo_up(mtx + 32 + uintptr(j)*2)))
  51161 			B1 = **(**uint32_t)(__ccgo_up(mtx + 64 + uintptr(j)*4))
  51162 			v3 = libc.Int32FromUint32((coeff*iQ1 + B1) >> libc.Int32FromInt32(QFIX))
  51163 			goto _4
  51164 		_4:
  51165 			level = v3
  51166 			if level > int32(MAX_LEVEL) {
  51167 				level = int32(MAX_LEVEL)
  51168 			}
  51169 			if sign != 0 {
  51170 				level = -level
  51171 			}
  51172 			**(**int16_t)(__ccgo_up(in + uintptr(j)*2)) = int16(level * libc.Int32FromUint32(Q))
  51173 			**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = int16(level)
  51174 			if level != 0 {
  51175 				last = n1
  51176 			}
  51177 		} else {
  51178 			**(**int16_t)(__ccgo_up(out + uintptr(n1)*2)) = 0
  51179 			**(**int16_t)(__ccgo_up(in + uintptr(j)*2)) = 0
  51180 		}
  51181 		goto _1
  51182 	_1:
  51183 		;
  51184 		n1 = n1 + 1
  51185 	}
  51186 	return libc.BoolInt32(last >= 0)
  51187 }
  51188 
  51189 func Quantize2Blocks_C(tls *libc.TLS, in uintptr, out uintptr, mtx uintptr) (r int32) {
  51190 	var nz int32
  51191 	_ = nz
  51192 	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
  51193 	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)
  51194 	return nz
  51195 }
  51196 
  51197 //------------------------------------------------------------------------------
  51198 // Block copy
  51199 
  51200 func Copy(tls *libc.TLS, src uintptr, dst uintptr, w int32, h int32) {
  51201 	var y int32
  51202 	_ = y
  51203 	y = 0
  51204 	for {
  51205 		if !(y < h) {
  51206 			break
  51207 		}
  51208 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(w), ^__predefined_size_t(0))
  51209 		src = src + uintptr(BPS)
  51210 		dst = dst + uintptr(BPS)
  51211 		goto _1
  51212 	_1:
  51213 		;
  51214 		y = y + 1
  51215 	}
  51216 }
  51217 
  51218 func Copy4x4_C(tls *libc.TLS, src uintptr, dst uintptr) {
  51219 	Copy(tls, src, dst, int32(4), int32(4))
  51220 }
  51221 
  51222 func Copy16x8_C(tls *libc.TLS, src uintptr, dst uintptr) {
  51223 	Copy(tls, src, dst, int32(16), int32(8))
  51224 }
  51225 
  51226 func VP8EncDspInit(tls *libc.TLS) {
  51227 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  51228 		goto _1
  51229 	}
  51230 	VP8EncDspInit_body(tls)
  51231 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  51232 	goto _2
  51233 _2:
  51234 	;
  51235 	goto _1
  51236 _1: /**/ //
  51237 }
  51238 
  51239 var VP8EncDspInit_body_last_cpuinfo_used = uintptr(0)
  51240 
  51241 func init() {
  51242 	p := unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used)
  51243 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8EncDspInit_body_last_cpuinfo_used))
  51244 }
  51245 
  51246 func VP8EncDspInit_body(tls *libc.TLS) {
  51247 	VP8DspInit(tls) // common inverse transforms
  51248 	InitTables(tls)
  51249 	// default C implementations
  51250 	VP8ITransform = __ccgo_fp(ITransform_C)
  51251 	VP8FTransform = __ccgo_fp(FTransform_C)
  51252 	VP8FTransformWHT = __ccgo_fp(FTransformWHT_C)
  51253 	VP8TDisto4x4 = __ccgo_fp(Disto4x4_C)
  51254 	VP8TDisto16x16 = __ccgo_fp(Disto16x16_C)
  51255 	VP8CollectHistogram = __ccgo_fp(CollectHistogram_C)
  51256 	VP8SSE16x16 = __ccgo_fp(SSE16x16_C)
  51257 	VP8SSE16x8 = __ccgo_fp(SSE16x8_C)
  51258 	VP8SSE8x8 = __ccgo_fp(SSE8x8_C)
  51259 	VP8SSE4x4 = __ccgo_fp(SSE4x4_C)
  51260 	VP8EncQuantizeBlock = __ccgo_fp(QuantizeBlock_C)
  51261 	VP8EncQuantize2Blocks = __ccgo_fp(Quantize2Blocks_C)
  51262 	VP8EncQuantizeBlockWHT = __ccgo_fp(QuantizeBlock_C)
  51263 	VP8EncPredLuma4 = __ccgo_fp(Intra4Preds_C)
  51264 	VP8EncPredLuma16 = __ccgo_fp(Intra16Preds_C)
  51265 	VP8FTransform2 = __ccgo_fp(FTransform2_C)
  51266 	VP8EncPredChroma8 = __ccgo_fp(IntraChromaPreds_C)
  51267 	VP8Mean16x4 = __ccgo_fp(Mean16x4_C)
  51268 	VP8Copy4x4 = __ccgo_fp(Copy4x4_C)
  51269 	VP8Copy16x8 = __ccgo_fp(Copy16x8_C)
  51270 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  51271 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  51272 	}
  51273 }
  51274 
  51275 func VP8EncDspInitMIPS32(tls *libc.TLS) {
  51276 }
  51277 
  51278 func VP8EncDspInitMIPSdspR2(tls *libc.TLS) {
  51279 }
  51280 
  51281 func VP8EncDspInitMSA(tls *libc.TLS) {
  51282 }
  51283 
  51284 func VP8EncDspInitNEON(tls *libc.TLS) {
  51285 }
  51286 
  51287 func VP8EncDspInitSSE2(tls *libc.TLS) {
  51288 }
  51289 
  51290 func VP8EncDspInitSSE41(tls *libc.TLS) {
  51291 }
  51292 
  51293 // Copyright 2010 Google Inc. All Rights Reserved.
  51294 //
  51295 // Use of this source code is governed by a BSD-style license
  51296 // that can be found in the COPYING file in the root of the source
  51297 // tree. An additional intellectual property rights grant can be found
  51298 // in the file PATENTS. All contributing project authors may
  51299 // be found in the AUTHORS file in the root of the source tree.
  51300 // -----------------------------------------------------------------------------
  51301 //
  51302 //  Common types + memory wrappers
  51303 //
  51304 // Author: Skal (pascal.massimino@gmail.com)
  51305 
  51306 //------------------------------------------------------------------------------
  51307 // Helpful macro.
  51308 
  51309 func PredictLine_C(tls *libc.TLS, src uintptr, pred uintptr, dst uintptr, length int32) {
  51310 	var i int32
  51311 	_ = i
  51312 	i = 0
  51313 	for {
  51314 		if !(i < length) {
  51315 			break
  51316 		}
  51317 		**(**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)))))
  51318 		goto _1
  51319 	_1:
  51320 		;
  51321 		i = i + 1
  51322 	}
  51323 }
  51324 
  51325 //------------------------------------------------------------------------------
  51326 // Horizontal filter.
  51327 
  51328 func DoHorizontalFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51329 	var preds uintptr
  51330 	var row int32
  51331 	_, _ = preds, row
  51332 	preds = in
  51333 	// Leftmost pixel is the same as input for topmost scanline.
  51334 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51335 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51336 	preds = preds + uintptr(stride)
  51337 	in = in + uintptr(stride)
  51338 	out = out + uintptr(stride)
  51339 	// Filter line-by-line.
  51340 	row = int32(1)
  51341 	for {
  51342 		if !(row < height) {
  51343 			break
  51344 		}
  51345 		// Leftmost pixel is predicted from above.
  51346 		PredictLine_C(tls, in, preds-uintptr(stride), out, int32(1))
  51347 		PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51348 		preds = preds + uintptr(stride)
  51349 		in = in + uintptr(stride)
  51350 		out = out + uintptr(stride)
  51351 		goto _1
  51352 	_1:
  51353 		;
  51354 		row = row + 1
  51355 	}
  51356 }
  51357 
  51358 //------------------------------------------------------------------------------
  51359 // Vertical filter.
  51360 
  51361 func DoVerticalFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51362 	var preds uintptr
  51363 	var row int32
  51364 	_, _ = preds, row
  51365 	preds = in
  51366 	// Very first top-left pixel is copied.
  51367 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51368 	// Rest of top scan-line is left-predicted.
  51369 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51370 	in = in + uintptr(stride)
  51371 	out = out + uintptr(stride)
  51372 	// Filter line-by-line.
  51373 	row = int32(1)
  51374 	for {
  51375 		if !(row < height) {
  51376 			break
  51377 		}
  51378 		PredictLine_C(tls, in, preds, out, width)
  51379 		preds = preds + uintptr(stride)
  51380 		in = in + uintptr(stride)
  51381 		out = out + uintptr(stride)
  51382 		goto _1
  51383 	_1:
  51384 		;
  51385 		row = row + 1
  51386 	}
  51387 }
  51388 
  51389 //------------------------------------------------------------------------------
  51390 // Gradient filter.
  51391 
  51392 func GradientPredictor_C(tls *libc.TLS, a uint8_t, b uint8_t, c uint8_t) (r int32) {
  51393 	var g, v1, v2 int32
  51394 	_, _, _ = g, v1, v2
  51395 	g = libc.Int32FromUint8(a) + libc.Int32FromUint8(b) - libc.Int32FromUint8(c)
  51396 	if g & ^libc.Int32FromInt32(0xff) == 0 {
  51397 		v1 = g
  51398 	} else {
  51399 		if g < 0 {
  51400 			v2 = 0
  51401 		} else {
  51402 			v2 = int32(255)
  51403 		}
  51404 		v1 = v2
  51405 	}
  51406 	return v1 // clip to 8bit
  51407 }
  51408 
  51409 func DoGradientFilter_C(tls *libc.TLS, in uintptr, width int32, height int32, stride int32, out uintptr) {
  51410 	var pred, row, w int32
  51411 	var preds uintptr
  51412 	_, _, _, _ = pred, preds, row, w
  51413 	preds = in
  51414 	// left prediction for top scan-line
  51415 	**(**uint8_t)(__ccgo_up(out)) = **(**uint8_t)(__ccgo_up(in))
  51416 	PredictLine_C(tls, in+uintptr(1), preds, out+uintptr(1), width-int32(1))
  51417 	preds = preds + uintptr(stride)
  51418 	in = in + uintptr(stride)
  51419 	out = out + uintptr(stride)
  51420 	// Filter line-by-line.
  51421 	row = int32(1)
  51422 	for {
  51423 		if !(row < height) {
  51424 			break
  51425 		}
  51426 		// leftmost pixel: predict from above.
  51427 		PredictLine_C(tls, in, preds-uintptr(stride), out, int32(1))
  51428 		w = int32(1)
  51429 		for {
  51430 			if !(w < width) {
  51431 				break
  51432 			}
  51433 			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)))))
  51434 			**(**uint8_t)(__ccgo_up(out + uintptr(w))) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(w)))) - pred)
  51435 			goto _2
  51436 		_2:
  51437 			;
  51438 			w = w + 1
  51439 		}
  51440 		preds = preds + uintptr(stride)
  51441 		in = in + uintptr(stride)
  51442 		out = out + uintptr(stride)
  51443 		goto _1
  51444 	_1:
  51445 		;
  51446 		row = row + 1
  51447 	}
  51448 }
  51449 
  51450 //------------------------------------------------------------------------------
  51451 
  51452 func HorizontalFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51453 	DoHorizontalFilter_C(tls, data, width, height, stride, filtered_data)
  51454 }
  51455 
  51456 func VerticalFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51457 	DoVerticalFilter_C(tls, data, width, height, stride, filtered_data)
  51458 }
  51459 
  51460 func GradientFilter_C(tls *libc.TLS, data uintptr, width int32, height int32, stride int32, filtered_data uintptr) {
  51461 	DoGradientFilter_C(tls, data, width, height, stride, filtered_data)
  51462 }
  51463 
  51464 //------------------------------------------------------------------------------
  51465 
  51466 func NoneUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51467 	_ = prev
  51468 	if out != in {
  51469 		libc.X__builtin___memcpy_chk(tls, out, in, libc.Uint64FromInt32(width)*uint64(1), ^__predefined_size_t(0))
  51470 	}
  51471 }
  51472 
  51473 func HorizontalUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51474 	var i, v1 int32
  51475 	var pred uint8_t
  51476 	_, _, _ = i, pred, v1
  51477 	if prev == libc.UintptrFromInt32(0) {
  51478 		v1 = 0
  51479 	} else {
  51480 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(prev)))
  51481 	}
  51482 	pred = libc.Uint8FromInt32(v1)
  51483 	i = 0
  51484 	for {
  51485 		if !(i < width) {
  51486 			break
  51487 		}
  51488 		**(**uint8_t)(__ccgo_up(out + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(pred) + libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(i)))))
  51489 		pred = **(**uint8_t)(__ccgo_up(out + uintptr(i)))
  51490 		goto _2
  51491 	_2:
  51492 		;
  51493 		i = i + 1
  51494 	}
  51495 }
  51496 
  51497 func VerticalUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51498 	var i int32
  51499 	_ = i
  51500 	if prev == libc.UintptrFromInt32(0) {
  51501 		HorizontalUnfilter_C(tls, libc.UintptrFromInt32(0), in, out, width)
  51502 	} else {
  51503 		i = 0
  51504 		for {
  51505 			if !(i < width) {
  51506 				break
  51507 			}
  51508 			**(**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)))))
  51509 			goto _1
  51510 		_1:
  51511 			;
  51512 			i = i + 1
  51513 		}
  51514 	}
  51515 }
  51516 
  51517 func GradientUnfilter_C(tls *libc.TLS, prev uintptr, in uintptr, out uintptr, width int32) {
  51518 	var i int32
  51519 	var left, top, top_left uint8_t
  51520 	_, _, _, _ = i, left, top, top_left
  51521 	if prev == libc.UintptrFromInt32(0) {
  51522 		HorizontalUnfilter_C(tls, libc.UintptrFromInt32(0), in, out, width)
  51523 	} else {
  51524 		top = **(**uint8_t)(__ccgo_up(prev))
  51525 		top_left = top
  51526 		left = top
  51527 		i = 0
  51528 		for {
  51529 			if !(i < width) {
  51530 				break
  51531 			}
  51532 			top = **(**uint8_t)(__ccgo_up(prev + uintptr(i))) // need to read this first, in case prev==out
  51533 			left = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(in + uintptr(i)))) + GradientPredictor_C(tls, left, top, top_left))
  51534 			top_left = top
  51535 			**(**uint8_t)(__ccgo_up(out + uintptr(i))) = left
  51536 			goto _1
  51537 		_1:
  51538 			;
  51539 			i = i + 1
  51540 		}
  51541 	}
  51542 }
  51543 
  51544 func VP8FiltersInit(tls *libc.TLS) {
  51545 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  51546 		goto _1
  51547 	}
  51548 	VP8FiltersInit_body(tls)
  51549 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  51550 	goto _2
  51551 _2:
  51552 	;
  51553 	goto _1
  51554 _1: /**/ //
  51555 }
  51556 
  51557 var VP8FiltersInit_body_last_cpuinfo_used = uintptr(0)
  51558 
  51559 func init() {
  51560 	p := unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used)
  51561 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8FiltersInit_body_last_cpuinfo_used))
  51562 }
  51563 
  51564 func VP8FiltersInit_body(tls *libc.TLS) {
  51565 	WebPUnfilters[int32(WEBP_FILTER_NONE)] = __ccgo_fp(NoneUnfilter_C)
  51566 	WebPUnfilters[int32(WEBP_FILTER_HORIZONTAL)] = __ccgo_fp(HorizontalUnfilter_C)
  51567 	WebPUnfilters[int32(WEBP_FILTER_VERTICAL)] = __ccgo_fp(VerticalUnfilter_C)
  51568 	WebPUnfilters[int32(WEBP_FILTER_GRADIENT)] = __ccgo_fp(GradientUnfilter_C)
  51569 	WebPFilters[int32(WEBP_FILTER_NONE)] = libc.UintptrFromInt32(0)
  51570 	WebPFilters[int32(WEBP_FILTER_HORIZONTAL)] = __ccgo_fp(HorizontalFilter_C)
  51571 	WebPFilters[int32(WEBP_FILTER_VERTICAL)] = __ccgo_fp(VerticalFilter_C)
  51572 	WebPFilters[int32(WEBP_FILTER_GRADIENT)] = __ccgo_fp(GradientFilter_C)
  51573 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  51574 	}
  51575 }
  51576 
  51577 func VP8FiltersInitMIPSdspR2(tls *libc.TLS) {
  51578 }
  51579 
  51580 func VP8FiltersInitMSA(tls *libc.TLS) {
  51581 }
  51582 
  51583 func VP8FiltersInitNEON(tls *libc.TLS) {
  51584 }
  51585 
  51586 func VP8FiltersInitSSE2(tls *libc.TLS) {
  51587 }
  51588 
  51589 func VP8LDspInitAVX2(tls *libc.TLS) {
  51590 }
  51591 
  51592 const ARGB_BLACK3 = 4278190080
  51593 
  51594 var kHashMul15 = uint32(0x1e35a7bd)
  51595 
  51596 // Copyright 2012 Google Inc. All Rights Reserved.
  51597 //
  51598 // Use of this source code is governed by a BSD-style license
  51599 // that can be found in the COPYING file in the root of the source
  51600 // tree. An additional intellectual property rights grant can be found
  51601 // in the file PATENTS. All contributing project authors may
  51602 // be found in the AUTHORS file in the root of the source tree.
  51603 // -----------------------------------------------------------------------------
  51604 //
  51605 // Misc. common utility functions
  51606 //
  51607 // Authors: Skal (pascal.massimino@gmail.com)
  51608 //          Urvang (urvang@google.com)
  51609 
  51610 // Copyright 2010 Google Inc. All Rights Reserved.
  51611 //
  51612 // Use of this source code is governed by a BSD-style license
  51613 // that can be found in the COPYING file in the root of the source
  51614 // tree. An additional intellectual property rights grant can be found
  51615 // in the file PATENTS. All contributing project authors may
  51616 // be found in the AUTHORS file in the root of the source tree.
  51617 // -----------------------------------------------------------------------------
  51618 //
  51619 //  Main decoding functions for WebP images.
  51620 //
  51621 // Author: Skal (pascal.massimino@gmail.com)
  51622 
  51623 // Copyright 2012 Google Inc. All Rights Reserved.
  51624 //
  51625 // Use of this source code is governed by a BSD-style license
  51626 // that can be found in the COPYING file in the root of the source
  51627 // tree. An additional intellectual property rights grant can be found
  51628 // in the file PATENTS. All contributing project authors may
  51629 // be found in the AUTHORS file in the root of the source tree.
  51630 // -----------------------------------------------------------------------------
  51631 //
  51632 //  Internal header for constants related to WebP file format.
  51633 //
  51634 // Author: Urvang (urvang@google.com)
  51635 
  51636 // Copyright 2010 Google Inc. All Rights Reserved.
  51637 //
  51638 // Use of this source code is governed by a BSD-style license
  51639 // that can be found in the COPYING file in the root of the source
  51640 // tree. An additional intellectual property rights grant can be found
  51641 // in the file PATENTS. All contributing project authors may
  51642 // be found in the AUTHORS file in the root of the source tree.
  51643 // -----------------------------------------------------------------------------
  51644 //
  51645 //  Common types + memory wrappers
  51646 //
  51647 // Author: Skal (pascal.massimino@gmail.com)
  51648 
  51649 //------------------------------------------------------------------------------
  51650 // Image transforms.
  51651 
  51652 func Average2(tls *libc.TLS, a0 uint32_t, a1 uint32_t) (r uint32_t) {
  51653 	return (a0^a1)&uint32(0xfefefefe)>>int32(1) + a0&a1
  51654 }
  51655 
  51656 func Average3(tls *libc.TLS, a0 uint32_t, a1 uint32_t, a2 uint32_t) (r uint32_t) {
  51657 	return Average2(tls, Average2(tls, a0, a2), a1)
  51658 }
  51659 
  51660 func Average4(tls *libc.TLS, a0 uint32_t, a1 uint32_t, a2 uint32_t, a3 uint32_t) (r uint32_t) {
  51661 	return Average2(tls, Average2(tls, a0, a1), Average2(tls, a2, a3))
  51662 }
  51663 
  51664 func Clip255(tls *libc.TLS, a uint32_t) (r uint32_t) {
  51665 	if a < uint32(256) {
  51666 		return a
  51667 	}
  51668 	// return 0, when a is a negative integer.
  51669 	// return 255, when a is positive.
  51670 	return ^a >> int32(24)
  51671 }
  51672 
  51673 func AddSubtractComponentFull(tls *libc.TLS, a int32, b int32, c int32) (r int32) {
  51674 	return libc.Int32FromUint32(Clip255(tls, libc.Uint32FromInt32(a+b-c)))
  51675 }
  51676 
  51677 func ClampedAddSubtractFull(tls *libc.TLS, c0 uint32_t, c1 uint32_t, c2 uint32_t) (r1 uint32_t) {
  51678 	var a, b, g, r int32
  51679 	_, _, _, _ = a, b, g, r
  51680 	a = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0>>int32(24)), libc.Int32FromUint32(c1>>int32(24)), libc.Int32FromUint32(c2>>int32(24)))
  51681 	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)))
  51682 	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)))
  51683 	b = AddSubtractComponentFull(tls, libc.Int32FromUint32(c0&uint32(0xff)), libc.Int32FromUint32(c1&uint32(0xff)), libc.Int32FromUint32(c2&uint32(0xff)))
  51684 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  51685 }
  51686 
  51687 func AddSubtractComponentHalf(tls *libc.TLS, a int32, b int32) (r int32) {
  51688 	return libc.Int32FromUint32(Clip255(tls, libc.Uint32FromInt32(a+(a-b)/libc.Int32FromInt32(2))))
  51689 }
  51690 
  51691 func ClampedAddSubtractHalf(tls *libc.TLS, c0 uint32_t, c1 uint32_t, c2 uint32_t) (r1 uint32_t) {
  51692 	var a, b, g, r int32
  51693 	var ave uint32_t
  51694 	_, _, _, _, _ = a, ave, b, g, r
  51695 	ave = Average2(tls, c0, c1)
  51696 	a = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>int32(24)), libc.Int32FromUint32(c2>>int32(24)))
  51697 	r = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(16)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(16)&uint32(0xff)))
  51698 	g = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(8)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(8)&uint32(0xff)))
  51699 	b = AddSubtractComponentHalf(tls, libc.Int32FromUint32(ave>>libc.Int32FromInt32(0)&uint32(0xff)), libc.Int32FromUint32(c2>>libc.Int32FromInt32(0)&uint32(0xff)))
  51700 	return libc.Uint32FromInt32(a)<<libc.Int32FromInt32(24) | libc.Uint32FromInt32(r<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(g<<libc.Int32FromInt32(8)) | libc.Uint32FromInt32(b)
  51701 }
  51702 
  51703 // gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is
  51704 // inlined.
  51705 
  51706 func Sub3(tls *libc.TLS, a int32, b int32, c int32) (r int32) {
  51707 	var pa, pb int32
  51708 	_, _ = pa, pb
  51709 	pb = b - c
  51710 	pa = a - c
  51711 	return libc.Xabs(tls, pb) - libc.Xabs(tls, pa)
  51712 }
  51713 
  51714 func Select(tls *libc.TLS, a uint32_t, b uint32_t, c uint32_t) (r uint32_t) {
  51715 	var pa_minus_pb int32
  51716 	var v1 uint32
  51717 	_, _ = pa_minus_pb, v1
  51718 	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)))
  51719 	if pa_minus_pb <= 0 {
  51720 		v1 = a
  51721 	} else {
  51722 		v1 = b
  51723 	}
  51724 	return v1
  51725 }
  51726 
  51727 //------------------------------------------------------------------------------
  51728 // Predictors
  51729 
  51730 func VP8LPredictor0_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51731 	_ = top
  51732 	_ = left
  51733 	return uint32(ARGB_BLACK3)
  51734 }
  51735 
  51736 func VP8LPredictor1_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51737 	_ = top
  51738 	return **(**uint32_t)(__ccgo_up(left))
  51739 }
  51740 
  51741 func VP8LPredictor2_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51742 	_ = left
  51743 	return **(**uint32_t)(__ccgo_up(top))
  51744 }
  51745 
  51746 func VP8LPredictor3_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51747 	_ = left
  51748 	return **(**uint32_t)(__ccgo_up(top + 1*4))
  51749 }
  51750 
  51751 func VP8LPredictor4_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51752 	_ = left
  51753 	return **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4))
  51754 }
  51755 
  51756 func VP8LPredictor5_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51757 	var pred uint32_t
  51758 	_ = pred
  51759 	pred = Average3(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + 1*4)))
  51760 	return pred
  51761 }
  51762 
  51763 func VP8LPredictor6_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51764 	var pred uint32_t
  51765 	_ = pred
  51766 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51767 	return pred
  51768 }
  51769 
  51770 func VP8LPredictor7_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51771 	var pred uint32_t
  51772 	_ = pred
  51773 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)))
  51774 	return pred
  51775 }
  51776 
  51777 func VP8LPredictor8_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51778 	var pred uint32_t
  51779 	_ = pred
  51780 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)), **(**uint32_t)(__ccgo_up(top)))
  51781 	_ = left
  51782 	return pred
  51783 }
  51784 
  51785 func VP8LPredictor9_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51786 	var pred uint32_t
  51787 	_ = pred
  51788 	pred = Average2(tls, **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + 1*4)))
  51789 	_ = left
  51790 	return pred
  51791 }
  51792 
  51793 func VP8LPredictor10_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51794 	var pred uint32_t
  51795 	_ = pred
  51796 	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)))
  51797 	return pred
  51798 }
  51799 
  51800 func VP8LPredictor11_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51801 	var pred uint32_t
  51802 	_ = pred
  51803 	pred = Select(tls, **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51804 	return pred
  51805 }
  51806 
  51807 func VP8LPredictor12_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51808 	var pred uint32_t
  51809 	_ = pred
  51810 	pred = ClampedAddSubtractFull(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51811 	return pred
  51812 }
  51813 
  51814 func VP8LPredictor13_C(tls *libc.TLS, left uintptr, top uintptr) (r uint32_t) {
  51815 	var pred uint32_t
  51816 	_ = pred
  51817 	pred = ClampedAddSubtractHalf(tls, **(**uint32_t)(__ccgo_up(left)), **(**uint32_t)(__ccgo_up(top)), **(**uint32_t)(__ccgo_up(top + uintptr(-libc.Int32FromInt32(1))*4)))
  51818 	return pred
  51819 }
  51820 
  51821 func PredictorAdd0_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51822 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  51823 	var x int32
  51824 	_, _, _, _, _, _ = alpha_and_green, red_and_blue, x, v2, v3, v4
  51825 	_ = upper
  51826 	x = 0
  51827 	for {
  51828 		if !(x < num_pixels) {
  51829 			break
  51830 		}
  51831 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51832 		v3 = uint32(ARGB_BLACK3)
  51833 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51834 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51835 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51836 		goto _5
  51837 	_5:
  51838 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51839 		goto _1
  51840 	_1:
  51841 		;
  51842 		x = x + 1
  51843 	}
  51844 }
  51845 
  51846 func PredictorAdd1_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51847 	var alpha_and_green, left, red_and_blue, v2, v3, v4, v5 uint32_t
  51848 	var i int32
  51849 	_, _, _, _, _, _, _, _ = alpha_and_green, i, left, red_and_blue, v2, v3, v4, v5
  51850 	left = **(**uint32_t)(__ccgo_up(out + uintptr(-libc.Int32FromInt32(1))*4))
  51851 	_ = upper
  51852 	i = 0
  51853 	for {
  51854 		if !(i < num_pixels) {
  51855 			break
  51856 		}
  51857 		v3 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  51858 		v4 = left
  51859 		alpha_and_green = v3&uint32(0xff00ff00) + v4&uint32(0xff00ff00)
  51860 		red_and_blue = v3&uint32(0x00ff00ff) + v4&uint32(0x00ff00ff)
  51861 		v5 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51862 		goto _6
  51863 	_6:
  51864 		v2 = v5
  51865 		left = v2
  51866 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v2
  51867 		goto _1
  51868 	_1:
  51869 		;
  51870 		i = i + 1
  51871 	}
  51872 }
  51873 
  51874 func PredictorAdd2_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51875 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51876 	var x int32
  51877 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51878 	x = 0
  51879 	for {
  51880 		if !(x < num_pixels) {
  51881 			break
  51882 		}
  51883 		pred = VP8LPredictor2_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51884 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51885 		v3 = pred
  51886 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51887 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51888 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51889 		goto _5
  51890 	_5:
  51891 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51892 		goto _1
  51893 	_1:
  51894 		;
  51895 		x = x + 1
  51896 	}
  51897 }
  51898 
  51899 func PredictorAdd3_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51900 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51901 	var x int32
  51902 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51903 	x = 0
  51904 	for {
  51905 		if !(x < num_pixels) {
  51906 			break
  51907 		}
  51908 		pred = VP8LPredictor3_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51909 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51910 		v3 = pred
  51911 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51912 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51913 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51914 		goto _5
  51915 	_5:
  51916 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51917 		goto _1
  51918 	_1:
  51919 		;
  51920 		x = x + 1
  51921 	}
  51922 }
  51923 
  51924 func PredictorAdd4_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51925 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51926 	var x int32
  51927 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51928 	x = 0
  51929 	for {
  51930 		if !(x < num_pixels) {
  51931 			break
  51932 		}
  51933 		pred = VP8LPredictor4_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51934 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51935 		v3 = pred
  51936 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51937 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51938 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51939 		goto _5
  51940 	_5:
  51941 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51942 		goto _1
  51943 	_1:
  51944 		;
  51945 		x = x + 1
  51946 	}
  51947 }
  51948 
  51949 func PredictorAdd5_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51950 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51951 	var x int32
  51952 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51953 	x = 0
  51954 	for {
  51955 		if !(x < num_pixels) {
  51956 			break
  51957 		}
  51958 		pred = VP8LPredictor5_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51959 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51960 		v3 = pred
  51961 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51962 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51963 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51964 		goto _5
  51965 	_5:
  51966 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51967 		goto _1
  51968 	_1:
  51969 		;
  51970 		x = x + 1
  51971 	}
  51972 }
  51973 
  51974 func PredictorAdd6_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  51975 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  51976 	var x int32
  51977 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  51978 	x = 0
  51979 	for {
  51980 		if !(x < num_pixels) {
  51981 			break
  51982 		}
  51983 		pred = VP8LPredictor6_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  51984 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  51985 		v3 = pred
  51986 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  51987 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  51988 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  51989 		goto _5
  51990 	_5:
  51991 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  51992 		goto _1
  51993 	_1:
  51994 		;
  51995 		x = x + 1
  51996 	}
  51997 }
  51998 
  51999 func PredictorAdd7_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52000 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52001 	var x int32
  52002 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52003 	x = 0
  52004 	for {
  52005 		if !(x < num_pixels) {
  52006 			break
  52007 		}
  52008 		pred = VP8LPredictor7_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52009 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52010 		v3 = pred
  52011 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52012 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52013 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52014 		goto _5
  52015 	_5:
  52016 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52017 		goto _1
  52018 	_1:
  52019 		;
  52020 		x = x + 1
  52021 	}
  52022 }
  52023 
  52024 func PredictorAdd8_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52025 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52026 	var x int32
  52027 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52028 	x = 0
  52029 	for {
  52030 		if !(x < num_pixels) {
  52031 			break
  52032 		}
  52033 		pred = VP8LPredictor8_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52034 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52035 		v3 = pred
  52036 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52037 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52038 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52039 		goto _5
  52040 	_5:
  52041 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52042 		goto _1
  52043 	_1:
  52044 		;
  52045 		x = x + 1
  52046 	}
  52047 }
  52048 
  52049 func PredictorAdd9_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52050 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52051 	var x int32
  52052 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52053 	x = 0
  52054 	for {
  52055 		if !(x < num_pixels) {
  52056 			break
  52057 		}
  52058 		pred = VP8LPredictor9_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52059 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52060 		v3 = pred
  52061 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52062 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52063 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52064 		goto _5
  52065 	_5:
  52066 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52067 		goto _1
  52068 	_1:
  52069 		;
  52070 		x = x + 1
  52071 	}
  52072 }
  52073 
  52074 func PredictorAdd10_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52075 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52076 	var x int32
  52077 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52078 	x = 0
  52079 	for {
  52080 		if !(x < num_pixels) {
  52081 			break
  52082 		}
  52083 		pred = VP8LPredictor10_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52084 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52085 		v3 = pred
  52086 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52087 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52088 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52089 		goto _5
  52090 	_5:
  52091 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52092 		goto _1
  52093 	_1:
  52094 		;
  52095 		x = x + 1
  52096 	}
  52097 }
  52098 
  52099 func PredictorAdd11_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52100 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52101 	var x int32
  52102 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52103 	x = 0
  52104 	for {
  52105 		if !(x < num_pixels) {
  52106 			break
  52107 		}
  52108 		pred = VP8LPredictor11_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52109 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52110 		v3 = pred
  52111 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52112 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52113 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52114 		goto _5
  52115 	_5:
  52116 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52117 		goto _1
  52118 	_1:
  52119 		;
  52120 		x = x + 1
  52121 	}
  52122 }
  52123 
  52124 func PredictorAdd12_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52125 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52126 	var x int32
  52127 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52128 	x = 0
  52129 	for {
  52130 		if !(x < num_pixels) {
  52131 			break
  52132 		}
  52133 		pred = VP8LPredictor12_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52134 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52135 		v3 = pred
  52136 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52137 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52138 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52139 		goto _5
  52140 	_5:
  52141 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52142 		goto _1
  52143 	_1:
  52144 		;
  52145 		x = x + 1
  52146 	}
  52147 }
  52148 
  52149 func PredictorAdd13_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  52150 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  52151 	var x int32
  52152 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  52153 	x = 0
  52154 	for {
  52155 		if !(x < num_pixels) {
  52156 			break
  52157 		}
  52158 		pred = VP8LPredictor13_C(tls, out+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  52159 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  52160 		v3 = pred
  52161 		alpha_and_green = v2&uint32(0xff00ff00) + v3&uint32(0xff00ff00)
  52162 		red_and_blue = v2&uint32(0x00ff00ff) + v3&uint32(0x00ff00ff)
  52163 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  52164 		goto _5
  52165 	_5:
  52166 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  52167 		goto _1
  52168 	_1:
  52169 		;
  52170 		x = x + 1
  52171 	}
  52172 }
  52173 
  52174 //------------------------------------------------------------------------------
  52175 
  52176 // C documentation
  52177 //
  52178 //	// Inverse prediction.
  52179 func PredictorInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, in uintptr, out uintptr) {
  52180 	var mask, tile_width, tiles_per_row, width, x, x_end, y int32
  52181 	var pred_func VP8LPredictorAddSubFunc
  52182 	var pred_mode_base, pred_mode_src, v4 uintptr
  52183 	var v1, v2 uint32_t
  52184 	_, _, _, _, _, _, _, _, _, _, _, _, _ = mask, pred_func, pred_mode_base, pred_mode_src, tile_width, tiles_per_row, width, x, x_end, y, v1, v2, v4
  52185 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52186 	if y_start == 0 { // First Row follows the L (mode=1) mode.
  52187 		PredictorAdd0_C(tls, in, libc.UintptrFromInt32(0), int32(1), out)
  52188 		PredictorAdd1_C(tls, in+uintptr(1)*4, libc.UintptrFromInt32(0), width-int32(1), out+uintptr(1)*4)
  52189 		in = in + uintptr(width)*4
  52190 		out = out + uintptr(width)*4
  52191 		y_start = y_start + 1
  52192 	}
  52193 	y = y_start
  52194 	tile_width = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52195 	mask = tile_width - int32(1)
  52196 	v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52197 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52198 	goto _3
  52199 _3:
  52200 	tiles_per_row = libc.Int32FromUint32(v2)
  52201 	pred_mode_base = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata + uintptr(y>>(*VP8LTransform)(unsafe.Pointer(transform)).Fbits*tiles_per_row)*4
  52202 	for y < y_end {
  52203 		pred_mode_src = pred_mode_base
  52204 		x = int32(1)
  52205 		// First pixel follows the T (mode=2) mode.
  52206 		PredictorAdd2_C(tls, in, out-uintptr(width)*4, int32(1), out)
  52207 		// .. the rest:
  52208 		for x < width {
  52209 			v4 = pred_mode_src
  52210 			pred_mode_src += 4
  52211 			pred_func = VP8LPredictorsAdd[**(**uint32_t)(__ccgo_up(v4))>>libc.Int32FromInt32(8)&uint32(0xf)]
  52212 			x_end = x & ^mask + tile_width
  52213 			if x_end > width {
  52214 				x_end = width
  52215 			}
  52216 			(*(*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)
  52217 			x = x_end
  52218 		}
  52219 		in = in + uintptr(width)*4
  52220 		out = out + uintptr(width)*4
  52221 		y = y + 1
  52222 		if y&mask == 0 { // Use the same mask, since tiles are squares.
  52223 			pred_mode_base = pred_mode_base + uintptr(tiles_per_row)*4
  52224 		}
  52225 	}
  52226 }
  52227 
  52228 // C documentation
  52229 //
  52230 //	// Add green to blue and red channels (i.e. perform the inverse transform of
  52231 //	// 'subtract green').
  52232 func VP8LAddGreenToBlueAndRed_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52233 	var argb, green, red_blue uint32_t
  52234 	var i int32
  52235 	_, _, _, _ = argb, green, i, red_blue
  52236 	i = 0
  52237 	for {
  52238 		if !(i < num_pixels) {
  52239 			break
  52240 		}
  52241 		argb = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  52242 		green = argb >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xff)
  52243 		red_blue = argb & libc.Uint32FromUint32(0x00ff00ff)
  52244 		red_blue = red_blue + (green<<libc.Int32FromInt32(16) | green)
  52245 		red_blue = red_blue & uint32(0x00ff00ff)
  52246 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = argb&uint32(0xff00ff00) | red_blue
  52247 		goto _1
  52248 	_1:
  52249 		;
  52250 		i = i + 1
  52251 	}
  52252 }
  52253 
  52254 func ColorTransformDelta(tls *libc.TLS, color_pred int8_t, color int8_t) (r int32) {
  52255 	return int32(color_pred) * int32(color) >> int32(5)
  52256 }
  52257 
  52258 func ColorCodeToMultipliers1(tls *libc.TLS, color_code uint32_t, m uintptr) {
  52259 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red = uint8(color_code >> libc.Int32FromInt32(0) & uint32(0xff))
  52260 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue = uint8(color_code >> libc.Int32FromInt32(8) & uint32(0xff))
  52261 	(*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue = uint8(color_code >> libc.Int32FromInt32(16) & uint32(0xff))
  52262 }
  52263 
  52264 func VP8LTransformColorInverse_C(tls *libc.TLS, m uintptr, src uintptr, num_pixels int32, dst uintptr) {
  52265 	var argb, red uint32_t
  52266 	var green int8_t
  52267 	var i, new_blue, new_red int32
  52268 	_, _, _, _, _, _ = argb, green, i, new_blue, new_red, red
  52269 	i = 0
  52270 	for {
  52271 		if !(i < num_pixels) {
  52272 			break
  52273 		}
  52274 		argb = **(**uint32_t)(__ccgo_up(src + uintptr(i)*4))
  52275 		green = libc.Int8FromUint32(argb >> libc.Int32FromInt32(8))
  52276 		red = argb >> int32(16)
  52277 		new_red = libc.Int32FromUint32(red & uint32(0xff))
  52278 		new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  52279 		new_red = new_red + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red), green)
  52280 		new_red = new_red & int32(0xff)
  52281 		new_blue = new_blue + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue), green)
  52282 		new_blue = new_blue + ColorTransformDelta(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue), int8(new_red))
  52283 		new_blue = new_blue & int32(0xff)
  52284 		**(**uint32_t)(__ccgo_up(dst + uintptr(i)*4)) = argb&uint32(0xff00ff00) | libc.Uint32FromInt32(new_red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(new_blue)
  52285 		goto _1
  52286 	_1:
  52287 		;
  52288 		i = i + 1
  52289 	}
  52290 }
  52291 
  52292 // C documentation
  52293 //
  52294 //	// Color space inverse transform.
  52295 func ColorSpaceInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52296 	bp := tls.Alloc(16)
  52297 	defer tls.Free(16)
  52298 	var mask, remaining_width, safe_width, tile_width, tiles_per_row, width, y int32
  52299 	var pred, pred_row, src_end, src_safe_end, v4 uintptr
  52300 	var v1, v2 uint32_t
  52301 	var _ /* m at bp+0 */ VP8LMultipliers
  52302 	_, _, _, _, _, _, _, _, _, _, _, _, _, _ = mask, pred, pred_row, remaining_width, safe_width, src_end, src_safe_end, tile_width, tiles_per_row, width, y, v1, v2, v4
  52303 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52304 	tile_width = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52305 	mask = tile_width - int32(1)
  52306 	safe_width = width & ^mask
  52307 	remaining_width = width - safe_width
  52308 	v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52309 	v2 = (libc.Uint32FromInt32(width) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52310 	goto _3
  52311 _3:
  52312 	tiles_per_row = libc.Int32FromUint32(v2)
  52313 	y = y_start
  52314 	pred_row = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata + uintptr(y>>(*VP8LTransform)(unsafe.Pointer(transform)).Fbits*tiles_per_row)*4
  52315 	for y < y_end {
  52316 		pred = pred_row
  52317 		**(**VP8LMultipliers)(__ccgo_up(bp)) = VP8LMultipliers{}
  52318 		src_safe_end = src + uintptr(safe_width)*4
  52319 		src_end = src + uintptr(width)*4
  52320 		for src < src_safe_end {
  52321 			v4 = pred
  52322 			pred += 4
  52323 			ColorCodeToMultipliers1(tls, **(**uint32_t)(__ccgo_up(v4)), bp)
  52324 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColorInverse})))(tls, bp, src, tile_width, dst)
  52325 			src = src + uintptr(tile_width)*4
  52326 			dst = dst + uintptr(tile_width)*4
  52327 		}
  52328 		if src < src_end { // Left-overs using C-version.
  52329 			v4 = pred
  52330 			pred += 4
  52331 			ColorCodeToMultipliers1(tls, **(**uint32_t)(__ccgo_up(v4)), bp)
  52332 			(*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LTransformColorInverse})))(tls, bp, src, remaining_width, dst)
  52333 			src = src + uintptr(remaining_width)*4
  52334 			dst = dst + uintptr(remaining_width)*4
  52335 		}
  52336 		y = y + 1
  52337 		if y&mask == 0 {
  52338 			pred_row = pred_row + uintptr(tiles_per_row)*4
  52339 		}
  52340 	}
  52341 }
  52342 
  52343 // Separate out pixels packed together using pixel-bundling.
  52344 // We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
  52345 func MapARGB_C(tls *libc.TLS, src uintptr, color_map uintptr, dst uintptr, y_start int32, y_end int32, width int32) {
  52346 	var x, y int32
  52347 	var v3, v4 uintptr
  52348 	var v5, v7 uint32_t
  52349 	_, _, _, _, _, _ = x, y, v3, v4, v5, v7
  52350 	y = y_start
  52351 	for {
  52352 		if !(y < y_end) {
  52353 			break
  52354 		}
  52355 		x = 0
  52356 		for {
  52357 			if !(x < width) {
  52358 				break
  52359 			}
  52360 			v3 = dst
  52361 			dst += 4
  52362 			v4 = src
  52363 			src += 4
  52364 			v5 = **(**uint32_t)(__ccgo_up(v4)) >> libc.Int32FromInt32(8) & uint32(0xff)
  52365 			goto _6
  52366 		_6:
  52367 			v7 = **(**uint32_t)(__ccgo_up(color_map + uintptr(v5)*4))
  52368 			goto _8
  52369 		_8:
  52370 			**(**uint32_t)(__ccgo_up(v3)) = v7
  52371 			goto _2
  52372 		_2:
  52373 			;
  52374 			x = x + 1
  52375 		}
  52376 		goto _1
  52377 	_1:
  52378 		;
  52379 		y = y + 1
  52380 	}
  52381 }
  52382 
  52383 func ColorIndexInverseTransform_C(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52384 	var bit_mask, packed_pixels, v4 uint32_t
  52385 	var bits_per_pixel, count_mask, pixels_per_byte, width, x, y int32
  52386 	var color_map, v3 uintptr
  52387 	_, _, _, _, _, _, _, _, _, _, _ = bit_mask, bits_per_pixel, color_map, count_mask, packed_pixels, pixels_per_byte, width, x, y, v3, v4
  52388 	bits_per_pixel = int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52389 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52390 	color_map = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  52391 	if bits_per_pixel < int32(8) {
  52392 		pixels_per_byte = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52393 		count_mask = pixels_per_byte - int32(1)
  52394 		bit_mask = libc.Uint32FromInt32(int32(1)<<bits_per_pixel - int32(1))
  52395 		y = y_start
  52396 		for {
  52397 			if !(y < y_end) {
  52398 				break
  52399 			}
  52400 			packed_pixels = uint32(0)
  52401 			x = 0
  52402 			for {
  52403 				if !(x < width) {
  52404 					break
  52405 				} /* 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.                                         */
  52406 				if x&count_mask == 0 {
  52407 					v3 = src
  52408 					src += 4
  52409 					v4 = **(**uint32_t)(__ccgo_up(v3)) >> libc.Int32FromInt32(8) & uint32(0xff)
  52410 					goto _5
  52411 				_5:
  52412 					packed_pixels = v4
  52413 				}
  52414 				v3 = dst
  52415 				dst += 4
  52416 				v4 = **(**uint32_t)(__ccgo_up(color_map + uintptr(packed_pixels&bit_mask)*4))
  52417 				goto _8
  52418 			_8:
  52419 				**(**uint32_t)(__ccgo_up(v3)) = v4
  52420 				packed_pixels = packed_pixels >> libc.Uint32FromInt32(bits_per_pixel)
  52421 				goto _2
  52422 			_2:
  52423 				;
  52424 				x = x + 1
  52425 			}
  52426 			goto _1
  52427 		_1:
  52428 			;
  52429 			y = y + 1
  52430 		}
  52431 	} else {
  52432 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LMapColor32b})))(tls, src, color_map, dst, y_start, y_end, width)
  52433 	}
  52434 }
  52435 
  52436 func MapAlpha_C(tls *libc.TLS, src uintptr, color_map uintptr, dst uintptr, y_start int32, y_end int32, width int32) {
  52437 	var x, y int32
  52438 	var v3, v4 uintptr
  52439 	var v5, v7 uint8_t
  52440 	_, _, _, _, _, _ = x, y, v3, v4, v5, v7
  52441 	y = y_start
  52442 	for {
  52443 		if !(y < y_end) {
  52444 			break
  52445 		}
  52446 		x = 0
  52447 		for {
  52448 			if !(x < width) {
  52449 				break
  52450 			}
  52451 			v3 = dst
  52452 			dst = dst + 1
  52453 			v4 = src
  52454 			src = src + 1
  52455 			v5 = **(**uint8_t)(__ccgo_up(v4))
  52456 			goto _6
  52457 		_6:
  52458 			v7 = uint8(**(**uint32_t)(__ccgo_up(color_map + uintptr(v5)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  52459 			goto _8
  52460 		_8:
  52461 			**(**uint8_t)(__ccgo_up(v3)) = v7
  52462 			goto _2
  52463 		_2:
  52464 			;
  52465 			x = x + 1
  52466 		}
  52467 		goto _1
  52468 	_1:
  52469 		;
  52470 		y = y + 1
  52471 	}
  52472 }
  52473 
  52474 func VP8LColorIndexInverseTransformAlpha(tls *libc.TLS, transform uintptr, y_start int32, y_end int32, src uintptr, dst uintptr) {
  52475 	var bit_mask, packed_pixels uint32_t
  52476 	var bits_per_pixel, count_mask, pixels_per_byte, width, x, y int32
  52477 	var color_map, v3 uintptr
  52478 	var v4 uint8_t
  52479 	_, _, _, _, _, _, _, _, _, _, _ = bit_mask, bits_per_pixel, color_map, count_mask, packed_pixels, pixels_per_byte, width, x, y, v3, v4
  52480 	bits_per_pixel = int32(8) >> (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52481 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52482 	color_map = (*VP8LTransform)(unsafe.Pointer(transform)).Fdata
  52483 	if bits_per_pixel < int32(8) {
  52484 		pixels_per_byte = int32(1) << (*VP8LTransform)(unsafe.Pointer(transform)).Fbits
  52485 		count_mask = pixels_per_byte - int32(1)
  52486 		bit_mask = libc.Uint32FromInt32(int32(1)<<bits_per_pixel - int32(1))
  52487 		y = y_start
  52488 		for {
  52489 			if !(y < y_end) {
  52490 				break
  52491 			}
  52492 			packed_pixels = uint32(0)
  52493 			x = 0
  52494 			for {
  52495 				if !(x < width) {
  52496 					break
  52497 				} /* 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.                                         */
  52498 				if x&count_mask == 0 {
  52499 					v3 = src
  52500 					src = src + 1
  52501 					v4 = **(**uint8_t)(__ccgo_up(v3))
  52502 					goto _5
  52503 				_5:
  52504 					packed_pixels = uint32(v4)
  52505 				}
  52506 				v3 = dst
  52507 				dst = dst + 1
  52508 				v4 = uint8(**(**uint32_t)(__ccgo_up(color_map + uintptr(packed_pixels&bit_mask)*4)) >> libc.Int32FromInt32(8) & uint32(0xff))
  52509 				goto _8
  52510 			_8:
  52511 				**(**uint8_t)(__ccgo_up(v3)) = v4
  52512 				packed_pixels = packed_pixels >> libc.Uint32FromInt32(bits_per_pixel)
  52513 				goto _2
  52514 			_2:
  52515 				;
  52516 				x = x + 1
  52517 			}
  52518 			goto _1
  52519 		_1:
  52520 			;
  52521 			y = y + 1
  52522 		}
  52523 	} else {
  52524 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{VP8LMapColor8b})))(tls, src, color_map, dst, y_start, y_end, width)
  52525 	}
  52526 }
  52527 
  52528 func VP8LInverseTransform(tls *libc.TLS, transform uintptr, row_start int32, row_end int32, in uintptr, out uintptr) {
  52529 	var in_stride, out_stride, width int32
  52530 	var src uintptr
  52531 	var v1, v2 uint32_t
  52532 	_, _, _, _, _, _ = in_stride, out_stride, src, width, v1, v2
  52533 	width = (*VP8LTransform)(unsafe.Pointer(transform)).Fxsize
  52534 	switch (*VP8LTransform)(unsafe.Pointer(transform)).Ftype1 {
  52535 	case int32(SUBTRACT_GREEN_TRANSFORM):
  52536 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LAddGreenToBlueAndRed})))(tls, in, (row_end-row_start)*width, out)
  52537 	case int32(PREDICTOR_TRANSFORM):
  52538 		PredictorInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52539 		if row_end != (*VP8LTransform)(unsafe.Pointer(transform)).Fysize {
  52540 			// The last predicted row in this iteration will be the top-pred row
  52541 			// for the first row in next iteration.
  52542 			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))
  52543 		}
  52544 	case int32(CROSS_COLOR_TRANSFORM):
  52545 		ColorSpaceInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52546 	case int32(COLOR_INDEXING_TRANSFORM):
  52547 		if in == out && (*VP8LTransform)(unsafe.Pointer(transform)).Fbits > 0 {
  52548 			// Move packed pixels to the end of unpacked region, so that unpacking
  52549 			// can occur seamlessly.
  52550 			// Also, note that this is the only transform that applies on
  52551 			// the effective width of VP8LSubSampleSize(xsize, bits). All other
  52552 			// transforms work on effective width of 'xsize'.
  52553 			out_stride = (row_end - row_start) * width
  52554 			v1 = libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fbits)
  52555 			v2 = (libc.Uint32FromInt32((*VP8LTransform)(unsafe.Pointer(transform)).Fxsize) + libc.Uint32FromInt32(libc.Int32FromInt32(1)<<v1) - uint32(1)) >> v1
  52556 			goto _3
  52557 		_3:
  52558 			in_stride = libc.Int32FromUint32(libc.Uint32FromInt32(row_end-row_start) * v2)
  52559 			src = out + uintptr(out_stride)*4 - uintptr(in_stride)*4
  52560 			libc.X__builtin___memmove_chk(tls, src, out, libc.Uint64FromInt32(in_stride)*uint64(4), ^__predefined_size_t(0))
  52561 			ColorIndexInverseTransform_C(tls, transform, row_start, row_end, src, out)
  52562 		} else {
  52563 			ColorIndexInverseTransform_C(tls, transform, row_start, row_end, in, out)
  52564 		}
  52565 		break
  52566 	}
  52567 }
  52568 
  52569 //------------------------------------------------------------------------------
  52570 // Color space conversion.
  52571 
  52572 func is_big_endian(tls *libc.TLS) (r int32) {
  52573 	return libc.BoolInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(uintptr(unsafe.Pointer(&tmp))))) != int32(1))
  52574 }
  52575 
  52576 var tmp = *(*struct {
  52577 	Fb [0][2]uint8_t
  52578 	Fw uint16_t
  52579 })(unsafe.Pointer(&[1]uint16{0x1}))
  52580 
  52581 func VP8LConvertBGRAToRGB_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52582 	var argb uint32_t
  52583 	var src_end, v1, v2 uintptr
  52584 	_, _, _, _ = argb, src_end, v1, v2
  52585 	src_end = src + uintptr(num_pixels)*4
  52586 	for src < src_end {
  52587 		v1 = src
  52588 		src += 4
  52589 		argb = **(**uint32_t)(__ccgo_up(v1))
  52590 		v2 = dst
  52591 		dst = dst + 1
  52592 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52593 		v1 = dst
  52594 		dst = dst + 1
  52595 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52596 		v1 = dst
  52597 		dst = dst + 1
  52598 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52599 	}
  52600 }
  52601 
  52602 func VP8LConvertBGRAToRGBA_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52603 	var argb uint32_t
  52604 	var src_end, v1, v2 uintptr
  52605 	_, _, _, _ = argb, src_end, v1, v2
  52606 	src_end = src + uintptr(num_pixels)*4
  52607 	for src < src_end {
  52608 		v1 = src
  52609 		src += 4
  52610 		argb = **(**uint32_t)(__ccgo_up(v1))
  52611 		v2 = dst
  52612 		dst = dst + 1
  52613 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52614 		v1 = dst
  52615 		dst = dst + 1
  52616 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52617 		v1 = dst
  52618 		dst = dst + 1
  52619 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52620 		v1 = dst
  52621 		dst = dst + 1
  52622 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(24) & uint32(0xff))
  52623 	}
  52624 }
  52625 
  52626 func VP8LConvertBGRAToRGBA4444_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52627 	var argb uint32_t
  52628 	var ba, rg uint8_t
  52629 	var src_end, v1, v2 uintptr
  52630 	_, _, _, _, _, _ = argb, ba, rg, src_end, v1, v2
  52631 	src_end = src + uintptr(num_pixels)*4
  52632 	for src < src_end {
  52633 		v1 = src
  52634 		src += 4
  52635 		argb = **(**uint32_t)(__ccgo_up(v1))
  52636 		rg = uint8(argb>>libc.Int32FromInt32(16)&uint32(0xf0) | argb>>libc.Int32FromInt32(12)&uint32(0xf))
  52637 		ba = uint8(argb>>libc.Int32FromInt32(0)&uint32(0xf0) | argb>>libc.Int32FromInt32(28)&uint32(0xf))
  52638 		v2 = dst
  52639 		dst = dst + 1
  52640 		**(**uint8_t)(__ccgo_up(v2)) = rg
  52641 		v1 = dst
  52642 		dst = dst + 1
  52643 		**(**uint8_t)(__ccgo_up(v1)) = ba
  52644 	}
  52645 }
  52646 
  52647 func VP8LConvertBGRAToRGB565_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52648 	var argb uint32_t
  52649 	var gb, rg uint8_t
  52650 	var src_end, v1, v2 uintptr
  52651 	_, _, _, _, _, _ = argb, gb, rg, src_end, v1, v2
  52652 	src_end = src + uintptr(num_pixels)*4
  52653 	for src < src_end {
  52654 		v1 = src
  52655 		src += 4
  52656 		argb = **(**uint32_t)(__ccgo_up(v1))
  52657 		rg = uint8(argb>>libc.Int32FromInt32(16)&uint32(0xf8) | argb>>libc.Int32FromInt32(13)&uint32(0x7))
  52658 		gb = uint8(argb>>libc.Int32FromInt32(5)&uint32(0xe0) | argb>>libc.Int32FromInt32(3)&uint32(0x1f))
  52659 		v2 = dst
  52660 		dst = dst + 1
  52661 		**(**uint8_t)(__ccgo_up(v2)) = rg
  52662 		v1 = dst
  52663 		dst = dst + 1
  52664 		**(**uint8_t)(__ccgo_up(v1)) = gb
  52665 	}
  52666 }
  52667 
  52668 func VP8LConvertBGRAToBGR_C(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr) {
  52669 	var argb uint32_t
  52670 	var src_end, v1, v2 uintptr
  52671 	_, _, _, _ = argb, src_end, v1, v2
  52672 	src_end = src + uintptr(num_pixels)*4
  52673 	for src < src_end {
  52674 		v1 = src
  52675 		src += 4
  52676 		argb = **(**uint32_t)(__ccgo_up(v1))
  52677 		v2 = dst
  52678 		dst = dst + 1
  52679 		**(**uint8_t)(__ccgo_up(v2)) = uint8(argb >> libc.Int32FromInt32(0) & uint32(0xff))
  52680 		v1 = dst
  52681 		dst = dst + 1
  52682 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(8) & uint32(0xff))
  52683 		v1 = dst
  52684 		dst = dst + 1
  52685 		**(**uint8_t)(__ccgo_up(v1)) = uint8(argb >> libc.Int32FromInt32(16) & uint32(0xff))
  52686 	}
  52687 }
  52688 
  52689 func CopyOrSwap(tls *libc.TLS, src uintptr, num_pixels int32, dst uintptr, swap_on_big_endian int32) {
  52690 	bp := tls.Alloc(16)
  52691 	defer tls.Free(16)
  52692 	var argb, v2, v5 uint32_t
  52693 	var src_end, v1, v4 uintptr
  52694 	_, _, _, _, _, _ = argb, src_end, v1, v2, v4, v5
  52695 	if is_big_endian(tls) == swap_on_big_endian {
  52696 		src_end = src + uintptr(num_pixels)*4
  52697 		for src < src_end {
  52698 			v1 = src
  52699 			src += 4
  52700 			argb = **(**uint32_t)(__ccgo_up(v1))
  52701 			v2 = libc.X__builtin_bswap32(tls, argb)
  52702 			goto _3
  52703 		_3:
  52704 			v4 = dst
  52705 			v5 = v2
  52706 			*(*uint32_t)(unsafe.Pointer(bp)) = v5
  52707 			libc.X__builtin___memcpy_chk(tls, v4, bp, uint64(4), ^__predefined_size_t(0))
  52708 			dst = dst + uintptr(4)
  52709 		}
  52710 	} else {
  52711 		libc.X__builtin___memcpy_chk(tls, dst, src, libc.Uint64FromInt32(num_pixels)*uint64(4), ^__predefined_size_t(0))
  52712 	}
  52713 }
  52714 
  52715 func VP8LConvertFromBGRA(tls *libc.TLS, in_data uintptr, num_pixels int32, out_colorspace WEBP_CSP_MODE1, rgba uintptr) {
  52716 	switch out_colorspace {
  52717 	case int32(MODE_RGB):
  52718 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGB})))(tls, in_data, num_pixels, rgba)
  52719 	case int32(MODE_RGBA):
  52720 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, in_data, num_pixels, rgba)
  52721 	case int32(MODE_rgbA):
  52722 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA})))(tls, in_data, num_pixels, rgba)
  52723 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, 0, num_pixels, int32(1), 0)
  52724 	case int32(MODE_BGR):
  52725 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToBGR})))(tls, in_data, num_pixels, rgba)
  52726 	case int32(MODE_BGRA):
  52727 		CopyOrSwap(tls, in_data, num_pixels, rgba, int32(1))
  52728 	case int32(MODE_bgrA):
  52729 		CopyOrSwap(tls, in_data, num_pixels, rgba, int32(1))
  52730 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, 0, num_pixels, int32(1), 0)
  52731 	case int32(MODE_ARGB):
  52732 		CopyOrSwap(tls, in_data, num_pixels, rgba, 0)
  52733 	case int32(MODE_Argb):
  52734 		CopyOrSwap(tls, in_data, num_pixels, rgba, 0)
  52735 		(*(*func(*libc.TLS, uintptr, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply})))(tls, rgba, int32(1), num_pixels, int32(1), 0)
  52736 	case int32(MODE_RGBA_4444):
  52737 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA4444})))(tls, in_data, num_pixels, rgba)
  52738 	case int32(MODE_rgbA_4444):
  52739 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGBA4444})))(tls, in_data, num_pixels, rgba)
  52740 		(*(*func(*libc.TLS, uintptr, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{WebPApplyAlphaMultiply4444})))(tls, rgba, num_pixels, int32(1), 0)
  52741 	case int32(MODE_RGB_565):
  52742 		(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{VP8LConvertBGRAToRGB565})))(tls, in_data, num_pixels, rgba)
  52743 	default:
  52744 		// Code flow should not reach here.
  52745 	}
  52746 }
  52747 
  52748 func VP8LDspInit(tls *libc.TLS) {
  52749 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  52750 		goto _1
  52751 	}
  52752 	VP8LDspInit_body(tls)
  52753 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  52754 	goto _2
  52755 _2:
  52756 	;
  52757 	goto _1
  52758 _1: /**/ //
  52759 }
  52760 
  52761 var VP8LDspInit_body_last_cpuinfo_used = uintptr(0)
  52762 
  52763 func init() {
  52764 	p := unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used)
  52765 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8LDspInit_body_last_cpuinfo_used))
  52766 }
  52767 
  52768 func VP8LDspInit_body(tls *libc.TLS) {
  52769 	VP8LPredictors[0] = __ccgo_fp(VP8LPredictor0_C)
  52770 	VP8LPredictors[int32(1)] = __ccgo_fp(VP8LPredictor1_C)
  52771 	VP8LPredictors[int32(2)] = __ccgo_fp(VP8LPredictor2_C)
  52772 	VP8LPredictors[int32(3)] = __ccgo_fp(VP8LPredictor3_C)
  52773 	VP8LPredictors[int32(4)] = __ccgo_fp(VP8LPredictor4_C)
  52774 	VP8LPredictors[int32(5)] = __ccgo_fp(VP8LPredictor5_C)
  52775 	VP8LPredictors[int32(6)] = __ccgo_fp(VP8LPredictor6_C)
  52776 	VP8LPredictors[int32(7)] = __ccgo_fp(VP8LPredictor7_C)
  52777 	VP8LPredictors[int32(8)] = __ccgo_fp(VP8LPredictor8_C)
  52778 	VP8LPredictors[int32(9)] = __ccgo_fp(VP8LPredictor9_C)
  52779 	VP8LPredictors[int32(10)] = __ccgo_fp(VP8LPredictor10_C)
  52780 	VP8LPredictors[int32(11)] = __ccgo_fp(VP8LPredictor11_C)
  52781 	VP8LPredictors[int32(12)] = __ccgo_fp(VP8LPredictor12_C)
  52782 	VP8LPredictors[int32(13)] = __ccgo_fp(VP8LPredictor13_C)
  52783 	VP8LPredictors[int32(14)] = __ccgo_fp(VP8LPredictor0_C) /* <- padding security sentinels*/
  52784 	VP8LPredictors[int32(15)] = __ccgo_fp(VP8LPredictor0_C)
  52785 	VP8LPredictorsAdd[0] = __ccgo_fp(PredictorAdd0_C)
  52786 	VP8LPredictorsAdd[int32(1)] = __ccgo_fp(PredictorAdd1_C)
  52787 	VP8LPredictorsAdd[int32(2)] = __ccgo_fp(PredictorAdd2_C)
  52788 	VP8LPredictorsAdd[int32(3)] = __ccgo_fp(PredictorAdd3_C)
  52789 	VP8LPredictorsAdd[int32(4)] = __ccgo_fp(PredictorAdd4_C)
  52790 	VP8LPredictorsAdd[int32(5)] = __ccgo_fp(PredictorAdd5_C)
  52791 	VP8LPredictorsAdd[int32(6)] = __ccgo_fp(PredictorAdd6_C)
  52792 	VP8LPredictorsAdd[int32(7)] = __ccgo_fp(PredictorAdd7_C)
  52793 	VP8LPredictorsAdd[int32(8)] = __ccgo_fp(PredictorAdd8_C)
  52794 	VP8LPredictorsAdd[int32(9)] = __ccgo_fp(PredictorAdd9_C)
  52795 	VP8LPredictorsAdd[int32(10)] = __ccgo_fp(PredictorAdd10_C)
  52796 	VP8LPredictorsAdd[int32(11)] = __ccgo_fp(PredictorAdd11_C)
  52797 	VP8LPredictorsAdd[int32(12)] = __ccgo_fp(PredictorAdd12_C)
  52798 	VP8LPredictorsAdd[int32(13)] = __ccgo_fp(PredictorAdd13_C)
  52799 	VP8LPredictorsAdd[int32(14)] = __ccgo_fp(PredictorAdd0_C) /* <- padding security sentinels*/
  52800 	VP8LPredictorsAdd[int32(15)] = __ccgo_fp(PredictorAdd0_C)
  52801 	VP8LPredictorsAdd_C[0] = __ccgo_fp(PredictorAdd0_C)
  52802 	VP8LPredictorsAdd_C[int32(1)] = __ccgo_fp(PredictorAdd1_C)
  52803 	VP8LPredictorsAdd_C[int32(2)] = __ccgo_fp(PredictorAdd2_C)
  52804 	VP8LPredictorsAdd_C[int32(3)] = __ccgo_fp(PredictorAdd3_C)
  52805 	VP8LPredictorsAdd_C[int32(4)] = __ccgo_fp(PredictorAdd4_C)
  52806 	VP8LPredictorsAdd_C[int32(5)] = __ccgo_fp(PredictorAdd5_C)
  52807 	VP8LPredictorsAdd_C[int32(6)] = __ccgo_fp(PredictorAdd6_C)
  52808 	VP8LPredictorsAdd_C[int32(7)] = __ccgo_fp(PredictorAdd7_C)
  52809 	VP8LPredictorsAdd_C[int32(8)] = __ccgo_fp(PredictorAdd8_C)
  52810 	VP8LPredictorsAdd_C[int32(9)] = __ccgo_fp(PredictorAdd9_C)
  52811 	VP8LPredictorsAdd_C[int32(10)] = __ccgo_fp(PredictorAdd10_C)
  52812 	VP8LPredictorsAdd_C[int32(11)] = __ccgo_fp(PredictorAdd11_C)
  52813 	VP8LPredictorsAdd_C[int32(12)] = __ccgo_fp(PredictorAdd12_C)
  52814 	VP8LPredictorsAdd_C[int32(13)] = __ccgo_fp(PredictorAdd13_C)
  52815 	VP8LPredictorsAdd_C[int32(14)] = __ccgo_fp(PredictorAdd0_C) /* <- padding security sentinels*/
  52816 	VP8LPredictorsAdd_C[int32(15)] = __ccgo_fp(PredictorAdd0_C)
  52817 	VP8LAddGreenToBlueAndRed = __ccgo_fp(VP8LAddGreenToBlueAndRed_C)
  52818 	VP8LTransformColorInverse = __ccgo_fp(VP8LTransformColorInverse_C)
  52819 	VP8LConvertBGRAToRGBA = __ccgo_fp(VP8LConvertBGRAToRGBA_C)
  52820 	VP8LConvertBGRAToRGB = __ccgo_fp(VP8LConvertBGRAToRGB_C)
  52821 	VP8LConvertBGRAToBGR = __ccgo_fp(VP8LConvertBGRAToBGR_C)
  52822 	VP8LConvertBGRAToRGBA4444 = __ccgo_fp(VP8LConvertBGRAToRGBA4444_C)
  52823 	VP8LConvertBGRAToRGB565 = __ccgo_fp(VP8LConvertBGRAToRGB565_C)
  52824 	VP8LMapColor32b = __ccgo_fp(MapARGB_C)
  52825 	VP8LMapColor8b = __ccgo_fp(MapAlpha_C)
  52826 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  52827 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  52828 	}
  52829 }
  52830 
  52831 func VP8LEncDspInitAVX2(tls *libc.TLS) {
  52832 }
  52833 
  52834 const LOG_2_RECIPROCAL_FIXED_DOUBLE1 = 1.2102203161561485e+07
  52835 const __FLT_MIN__11 = 1.1754943508222875e-38
  52836 
  52837 func FastSLog2Slow_C(tls *libc.TLS, v uint32_t) (r uint64_t) {
  52838 	var correction, log_cnt, orig_v uint64_t
  52839 	var y uint32_t
  52840 	var v1 int32
  52841 	_, _, _, _, _ = correction, log_cnt, orig_v, y, v1
  52842 	if v < uint32(APPROX_LOG_WITH_CORRECTION_MAX) {
  52843 		orig_v = uint64(v)
  52844 		v1 = int32(31) ^ libc.X__builtin_clz(tls, v)
  52845 		goto _2
  52846 	_2:
  52847 		// use clz if available
  52848 		log_cnt = libc.Uint64FromInt32(v1 - int32(7))
  52849 		y = libc.Uint32FromInt32(int32(1) << log_cnt)
  52850 		v = uint32(uint64(v) >> log_cnt)
  52851 		// vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256
  52852 		// Xf = floor(Xf) * (1 + (v % y) / v)
  52853 		// log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)
  52854 		// The correction factor: log(1 + d) ~ d; for very small d values, so
  52855 		// log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v
  52856 		correction = libc.Uint64FromInt32(12102203) * (orig_v & uint64(y-libc.Uint32FromInt32(1)))
  52857 		return orig_v*(uint64(kLog2Table[v])+log_cnt<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)) + correction
  52858 	} else {
  52859 		return uint64(float64(float64(libc.Float64FromFloat64(1.2102203161561485e+07)*float64(v))*libc.Xlog(tls, float64(v))) + libc.Float64FromFloat64(0.5))
  52860 	}
  52861 	return r
  52862 }
  52863 
  52864 func FastLog2Slow_C(tls *libc.TLS, v uint32_t) (r uint32_t) {
  52865 	var correction uint64_t
  52866 	var log_2, log_cnt, orig_v, y uint32_t
  52867 	var v1 int32
  52868 	var v3, v4, v5 int64_t
  52869 	var v7 int64
  52870 	_, _, _, _, _, _, _, _, _, _ = correction, log_2, log_cnt, orig_v, y, v1, v3, v4, v5, v7
  52871 	if v < uint32(APPROX_LOG_WITH_CORRECTION_MAX) {
  52872 		orig_v = v
  52873 		v1 = int32(31) ^ libc.X__builtin_clz(tls, v)
  52874 		goto _2
  52875 	_2:
  52876 		// use clz if available
  52877 		log_cnt = libc.Uint32FromInt32(v1 - int32(7))
  52878 		y = libc.Uint32FromInt32(int32(1) << log_cnt)
  52879 		v = v >> log_cnt
  52880 		log_2 = kLog2Table[v] + log_cnt<<libc.Int32FromInt32(LOG_2_PRECISION_BITS)
  52881 		if orig_v >= uint32(APPROX_LOG_MAX) {
  52882 			// Since the division is still expensive, add this correction factor only
  52883 			// for large values of 'v'.
  52884 			correction = libc.Uint64FromInt32(12102203) * uint64(orig_v&(y-libc.Uint32FromInt32(1)))
  52885 			v3 = libc.Int64FromUint64(correction)
  52886 			v4 = libc.Int64FromUint32(orig_v)
  52887 			if libc.BoolInt32(v3 < 0) == libc.BoolInt32(v4 < 0) {
  52888 				v7 = (v3 + v4/int64(2)) / v4
  52889 			} else {
  52890 				v7 = (v3 - v4/int64(2)) / v4
  52891 			}
  52892 			v5 = v7
  52893 			goto _6
  52894 		_6:
  52895 			log_2 = log_2 + libc.Uint32FromInt64(v5)
  52896 		}
  52897 		return log_2
  52898 	} else {
  52899 		return uint32(float64(libc.Float64FromFloat64(1.2102203161561485e+07)*libc.Xlog(tls, float64(v))) + libc.Float64FromFloat64(0.5))
  52900 	}
  52901 	return r
  52902 }
  52903 
  52904 //------------------------------------------------------------------------------
  52905 // Methods to calculate Entropy (Shannon).
  52906 
  52907 // C documentation
  52908 //
  52909 //	// Compute the combined Shanon's entropy for distribution {X} and {X+Y}
  52910 func CombinedShannonEntropy_C(tls *libc.TLS, X uintptr, Y uintptr) (r uint64_t) {
  52911 	var i int32
  52912 	var retval, v3, v7 uint64_t
  52913 	var sumX, sumXY, x, xy, v2, v6 uint32_t
  52914 	var v5, v9 uint64
  52915 	_, _, _, _, _, _, _, _, _, _, _, _ = i, retval, sumX, sumXY, x, xy, v2, v3, v5, v6, v7, v9
  52916 	retval = uint64(0)
  52917 	sumX = uint32(0)
  52918 	sumXY = uint32(0)
  52919 	i = 0
  52920 	for {
  52921 		if !(i < int32(256)) {
  52922 			break
  52923 		}
  52924 		x = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4))
  52925 		if x != uint32(0) {
  52926 			xy = x + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52927 			sumX = sumX + x
  52928 			v2 = x
  52929 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52930 				v5 = kSLog2Table[v2]
  52931 			} else {
  52932 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52933 			}
  52934 			v3 = v5
  52935 			goto _4
  52936 		_4:
  52937 			retval = retval + v3
  52938 			sumXY = sumXY + xy
  52939 			v2 = xy
  52940 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52941 				v5 = kSLog2Table[v2]
  52942 			} else {
  52943 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52944 			}
  52945 			v3 = v5
  52946 			goto _8
  52947 		_8:
  52948 			retval = retval + v3
  52949 		} else {
  52950 			if **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4)) != uint32(0) {
  52951 				sumXY = sumXY + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52952 				v2 = **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  52953 				if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52954 					v5 = kSLog2Table[v2]
  52955 				} else {
  52956 					v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52957 				}
  52958 				v3 = v5
  52959 				goto _12
  52960 			_12:
  52961 				retval = retval + v3
  52962 			}
  52963 		}
  52964 		goto _1
  52965 	_1:
  52966 		;
  52967 		i = i + 1
  52968 	}
  52969 	v2 = sumX
  52970 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  52971 		v5 = kSLog2Table[v2]
  52972 	} else {
  52973 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  52974 	}
  52975 	v3 = v5
  52976 	goto _16
  52977 _16:
  52978 	v6 = sumXY
  52979 	if v6 < uint32(LOG_LOOKUP_IDX_MAX) {
  52980 		v9 = kSLog2Table[v6]
  52981 	} else {
  52982 		v9 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v6)
  52983 	}
  52984 	v7 = v9
  52985 	goto _20
  52986 _20:
  52987 	retval = v3 + v7 - retval
  52988 	return retval
  52989 }
  52990 
  52991 func ShannonEntropy_C(tls *libc.TLS, X uintptr, n int32) (r uint64_t) {
  52992 	var i, x int32
  52993 	var retval, v3 uint64_t
  52994 	var sumX, v2 uint32_t
  52995 	var v5 uint64
  52996 	_, _, _, _, _, _, _ = i, retval, sumX, x, v2, v3, v5
  52997 	retval = uint64(0)
  52998 	sumX = uint32(0)
  52999 	i = 0
  53000 	for {
  53001 		if !(i < n) {
  53002 			break
  53003 		}
  53004 		x = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(X + uintptr(i)*4)))
  53005 		if x != 0 {
  53006 			sumX = sumX + libc.Uint32FromInt32(x)
  53007 			v2 = libc.Uint32FromInt32(x)
  53008 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53009 				v5 = kSLog2Table[v2]
  53010 			} else {
  53011 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53012 			}
  53013 			v3 = v5
  53014 			goto _4
  53015 		_4:
  53016 			retval = retval + v3
  53017 		}
  53018 		goto _1
  53019 	_1:
  53020 		;
  53021 		i = i + 1
  53022 	}
  53023 	v2 = sumX
  53024 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53025 		v5 = kSLog2Table[v2]
  53026 	} else {
  53027 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53028 	}
  53029 	v3 = v5
  53030 	goto _8
  53031 _8:
  53032 	retval = v3 - retval
  53033 	return retval
  53034 }
  53035 
  53036 func VP8LBitEntropyInit(tls *libc.TLS, entropy uintptr) {
  53037 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy = uint64(0)
  53038 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum = uint32(0)
  53039 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros = 0
  53040 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val = uint32(0)
  53041 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzero_code = uint32(libc.Uint16FromInt32(libc.Int32FromInt32(0xffff)))
  53042 }
  53043 
  53044 func VP8LBitsEntropyUnrefined(tls *libc.TLS, array uintptr, n int32, entropy uintptr) {
  53045 	var i int32
  53046 	var v2 uint32_t
  53047 	var v3 uint64_t
  53048 	var v5 uint64
  53049 	_, _, _, _ = i, v2, v3, v5
  53050 	VP8LBitEntropyInit(tls, entropy)
  53051 	i = 0
  53052 	for {
  53053 		if !(i < n) {
  53054 			break
  53055 		}
  53056 		if **(**uint32_t)(__ccgo_up(array + uintptr(i)*4)) != uint32(0) {
  53057 			**(**uint32_t)(__ccgo_up(entropy + 8)) += **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53058 			(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzero_code = libc.Uint32FromInt32(i)
  53059 			(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fnonzeros + 1
  53060 			v2 = **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53061 			if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53062 				v5 = kSLog2Table[v2]
  53063 			} else {
  53064 				v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53065 			}
  53066 			v3 = v5
  53067 			goto _4
  53068 		_4:
  53069 			**(**uint64_t)(__ccgo_up(entropy)) += v3
  53070 			if (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val < **(**uint32_t)(__ccgo_up(array + uintptr(i)*4)) {
  53071 				(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fmax_val = **(**uint32_t)(__ccgo_up(array + uintptr(i)*4))
  53072 			}
  53073 		}
  53074 		goto _1
  53075 	_1:
  53076 		;
  53077 		i = i + 1
  53078 	}
  53079 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fsum
  53080 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53081 		v5 = kSLog2Table[v2]
  53082 	} else {
  53083 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53084 	}
  53085 	v3 = v5
  53086 	goto _8
  53087 _8:
  53088 	(*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(entropy)).Fentropy
  53089 }
  53090 
  53091 func GetEntropyUnrefinedHelper(tls *libc.TLS, val uint32_t, i int32, val_prev uintptr, i_prev uintptr, bit_entropy uintptr, stats uintptr) {
  53092 	var streak int32
  53093 	var v1 uint32_t
  53094 	var v2 uint64_t
  53095 	var v4 uint64
  53096 	_, _, _, _ = streak, v1, v2, v4
  53097 	streak = i - **(**int32)(__ccgo_up(i_prev))
  53098 	// Gather info for the bit entropy.
  53099 	if **(**uint32_t)(__ccgo_up(val_prev)) != uint32(0) {
  53100 		**(**uint32_t)(__ccgo_up(bit_entropy + 8)) += **(**uint32_t)(__ccgo_up(val_prev)) * libc.Uint32FromInt32(streak)
  53101 		**(**int32)(__ccgo_up(bit_entropy + 12)) += streak
  53102 		(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fnonzero_code = libc.Uint32FromInt32(**(**int32)(__ccgo_up(i_prev)))
  53103 		v1 = **(**uint32_t)(__ccgo_up(val_prev))
  53104 		if v1 < uint32(LOG_LOOKUP_IDX_MAX) {
  53105 			v4 = kSLog2Table[v1]
  53106 		} else {
  53107 			v4 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v1)
  53108 		}
  53109 		v2 = v4
  53110 		goto _3
  53111 	_3:
  53112 		**(**uint64_t)(__ccgo_up(bit_entropy)) += v2 * libc.Uint64FromInt32(streak)
  53113 		if (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fmax_val < **(**uint32_t)(__ccgo_up(val_prev)) {
  53114 			(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fmax_val = **(**uint32_t)(__ccgo_up(val_prev))
  53115 		}
  53116 	}
  53117 	// Gather info for the Huffman cost.
  53118 	**(**int32)(__ccgo_up(stats + libc.BoolUintptr(**(**uint32_t)(__ccgo_up(val_prev)) != uint32(0))*4)) += libc.BoolInt32(streak > int32(3))
  53119 	**(**int32)(__ccgo_up(stats + 8 + libc.BoolUintptr(**(**uint32_t)(__ccgo_up(val_prev)) != uint32(0))*8 + libc.BoolUintptr(streak > libc.Int32FromInt32(3))*4)) += streak
  53120 	**(**uint32_t)(__ccgo_up(val_prev)) = val
  53121 	**(**int32)(__ccgo_up(i_prev)) = i
  53122 }
  53123 
  53124 func GetEntropyUnrefined_C(tls *libc.TLS, X uintptr, length int32, bit_entropy uintptr, stats uintptr) {
  53125 	bp := tls.Alloc(16)
  53126 	defer tls.Free(16)
  53127 	var i int32
  53128 	var x, v2 uint32_t
  53129 	var v3 uint64_t
  53130 	var v5 uint64
  53131 	var _ /* i_prev at bp+0 */ int32
  53132 	var _ /* x_prev at bp+4 */ uint32_t
  53133 	_, _, _, _, _ = i, x, v2, v3, v5
  53134 	**(**int32)(__ccgo_up(bp)) = 0
  53135 	**(**uint32_t)(__ccgo_up(bp + 4)) = **(**uint32_t)(__ccgo_up(X))
  53136 	libc.X__builtin___memset_chk(tls, stats, 0, uint64(24), ^__predefined_size_t(0))
  53137 	VP8LBitEntropyInit(tls, bit_entropy)
  53138 	i = int32(1)
  53139 	for {
  53140 		if !(i < length) {
  53141 			break
  53142 		}
  53143 		x = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4))
  53144 		if x != **(**uint32_t)(__ccgo_up(bp + 4)) {
  53145 			GetEntropyUnrefinedHelper(tls, x, i, bp+4, bp, bit_entropy, stats)
  53146 		}
  53147 		goto _1
  53148 	_1:
  53149 		;
  53150 		i = i + 1
  53151 	}
  53152 	GetEntropyUnrefinedHelper(tls, uint32(0), i, bp+4, bp, bit_entropy, stats)
  53153 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fsum
  53154 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53155 		v5 = kSLog2Table[v2]
  53156 	} else {
  53157 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53158 	}
  53159 	v3 = v5
  53160 	goto _4
  53161 _4:
  53162 	(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy
  53163 }
  53164 
  53165 func GetCombinedEntropyUnrefined_C(tls *libc.TLS, X uintptr, Y uintptr, length int32, bit_entropy uintptr, stats uintptr) {
  53166 	bp := tls.Alloc(16)
  53167 	defer tls.Free(16)
  53168 	var i int32
  53169 	var xy, v2 uint32_t
  53170 	var v3 uint64_t
  53171 	var v5 uint64
  53172 	var _ /* i_prev at bp+0 */ int32
  53173 	var _ /* xy_prev at bp+4 */ uint32_t
  53174 	_, _, _, _, _ = i, xy, v2, v3, v5
  53175 	i = int32(1)
  53176 	**(**int32)(__ccgo_up(bp)) = 0
  53177 	**(**uint32_t)(__ccgo_up(bp + 4)) = **(**uint32_t)(__ccgo_up(X)) + **(**uint32_t)(__ccgo_up(Y))
  53178 	libc.X__builtin___memset_chk(tls, stats, 0, uint64(24), ^__predefined_size_t(0))
  53179 	VP8LBitEntropyInit(tls, bit_entropy)
  53180 	i = int32(1)
  53181 	for {
  53182 		if !(i < length) {
  53183 			break
  53184 		}
  53185 		xy = **(**uint32_t)(__ccgo_up(X + uintptr(i)*4)) + **(**uint32_t)(__ccgo_up(Y + uintptr(i)*4))
  53186 		if xy != **(**uint32_t)(__ccgo_up(bp + 4)) {
  53187 			GetEntropyUnrefinedHelper(tls, xy, i, bp+4, bp, bit_entropy, stats)
  53188 		}
  53189 		goto _1
  53190 	_1:
  53191 		;
  53192 		i = i + 1
  53193 	}
  53194 	GetEntropyUnrefinedHelper(tls, uint32(0), i, bp+4, bp, bit_entropy, stats)
  53195 	v2 = (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fsum
  53196 	if v2 < uint32(LOG_LOOKUP_IDX_MAX) {
  53197 		v5 = kSLog2Table[v2]
  53198 	} else {
  53199 		v5 = (*(*func(*libc.TLS, uint32_t) uint64_t)(unsafe.Pointer(&struct{ uintptr }{VP8LFastSLog2Slow})))(tls, v2)
  53200 	}
  53201 	v3 = v5
  53202 	goto _4
  53203 _4:
  53204 	(*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy = v3 - (*VP8LBitEntropy)(unsafe.Pointer(bit_entropy)).Fentropy
  53205 }
  53206 
  53207 //------------------------------------------------------------------------------
  53208 
  53209 func VP8LSubtractGreenFromBlueAndRed_C(tls *libc.TLS, argb_data uintptr, num_pixels int32) {
  53210 	var argb, green, i int32
  53211 	var new_b, new_r uint32_t
  53212 	_, _, _, _, _ = argb, green, i, new_b, new_r
  53213 	i = 0
  53214 	for {
  53215 		if !(i < num_pixels) {
  53216 			break
  53217 		}
  53218 		argb = libc.Int32FromUint32(**(**uint32_t)(__ccgo_up(argb_data + uintptr(i)*4)))
  53219 		green = argb >> libc.Int32FromInt32(8) & int32(0xff)
  53220 		new_r = libc.Uint32FromInt32((argb>>libc.Int32FromInt32(16)&int32(0xff) - green) & int32(0xff))
  53221 		new_b = libc.Uint32FromInt32((argb>>libc.Int32FromInt32(0)&int32(0xff) - green) & int32(0xff))
  53222 		**(**uint32_t)(__ccgo_up(argb_data + uintptr(i)*4)) = libc.Uint32FromInt32(argb)&uint32(0xff00ff00) | new_r<<libc.Int32FromInt32(16) | new_b
  53223 		goto _1
  53224 	_1:
  53225 		;
  53226 		i = i + 1
  53227 	}
  53228 }
  53229 
  53230 func ColorTransformDelta1(tls *libc.TLS, color_pred int8_t, color int8_t) (r int32) {
  53231 	return int32(color_pred) * int32(color) >> int32(5)
  53232 }
  53233 
  53234 func U32ToS8(tls *libc.TLS, v uint32_t) (r int8_t) {
  53235 	return libc.Int8FromUint32(v & libc.Uint32FromInt32(0xff))
  53236 }
  53237 
  53238 func VP8LTransformColor_C(tls *libc.TLS, m uintptr, data uintptr, num_pixels int32) {
  53239 	var argb uint32_t
  53240 	var green, red int8_t
  53241 	var i, new_blue, new_red int32
  53242 	_, _, _, _, _, _ = argb, green, i, new_blue, new_red, red
  53243 	i = 0
  53244 	for {
  53245 		if !(i < num_pixels) {
  53246 			break
  53247 		}
  53248 		argb = **(**uint32_t)(__ccgo_up(data + uintptr(i)*4))
  53249 		green = U32ToS8(tls, argb>>int32(8))
  53250 		red = U32ToS8(tls, argb>>int32(16))
  53251 		new_red = int32(red) & int32(0xff)
  53252 		new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  53253 		new_red = new_red - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_red), green)
  53254 		new_red = new_red & int32(0xff)
  53255 		new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fgreen_to_blue), green)
  53256 		new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8((*VP8LMultipliers)(unsafe.Pointer(m)).Fred_to_blue), red)
  53257 		new_blue = new_blue & int32(0xff)
  53258 		**(**uint32_t)(__ccgo_up(data + uintptr(i)*4)) = argb&uint32(0xff00ff00) | libc.Uint32FromInt32(new_red<<libc.Int32FromInt32(16)) | libc.Uint32FromInt32(new_blue)
  53259 		goto _1
  53260 	_1:
  53261 		;
  53262 		i = i + 1
  53263 	}
  53264 }
  53265 
  53266 func TransformColorRed(tls *libc.TLS, green_to_red uint8_t, argb uint32_t) (r uint8_t) {
  53267 	var green int8_t
  53268 	var new_red int32
  53269 	_, _ = green, new_red
  53270 	green = U32ToS8(tls, argb>>int32(8))
  53271 	new_red = libc.Int32FromUint32(argb >> int32(16))
  53272 	new_red = new_red - ColorTransformDelta1(tls, libc.Int8FromUint8(green_to_red), green)
  53273 	return libc.Uint8FromInt32(new_red & libc.Int32FromInt32(0xff))
  53274 }
  53275 
  53276 func TransformColorBlue(tls *libc.TLS, green_to_blue uint8_t, red_to_blue uint8_t, argb uint32_t) (r uint8_t) {
  53277 	var green, red int8_t
  53278 	var new_blue int32
  53279 	_, _, _ = green, new_blue, red
  53280 	green = U32ToS8(tls, argb>>int32(8))
  53281 	red = U32ToS8(tls, argb>>int32(16))
  53282 	new_blue = libc.Int32FromUint32(argb & uint32(0xff))
  53283 	new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8(green_to_blue), green)
  53284 	new_blue = new_blue - ColorTransformDelta1(tls, libc.Int8FromUint8(red_to_blue), red)
  53285 	return libc.Uint8FromInt32(new_blue & libc.Int32FromInt32(0xff))
  53286 }
  53287 
  53288 func VP8LCollectColorRedTransforms_C(tls *libc.TLS, argb uintptr, stride int32, tile_width int32, tile_height int32, green_to_red int32, histo uintptr) {
  53289 	var x, v1 int32
  53290 	_, _ = x, v1
  53291 	for {
  53292 		v1 = tile_height
  53293 		tile_height = tile_height - 1
  53294 		if !(v1 > 0) {
  53295 			break
  53296 		}
  53297 		x = 0
  53298 		for {
  53299 			if !(x < tile_width) {
  53300 				break
  53301 			}
  53302 			**(**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
  53303 			goto _2
  53304 		_2:
  53305 			;
  53306 			x = x + 1
  53307 		}
  53308 		argb = argb + uintptr(stride)*4
  53309 	}
  53310 }
  53311 
  53312 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) {
  53313 	var x, v1 int32
  53314 	_, _ = x, v1
  53315 	for {
  53316 		v1 = tile_height
  53317 		tile_height = tile_height - 1
  53318 		if !(v1 > 0) {
  53319 			break
  53320 		}
  53321 		x = 0
  53322 		for {
  53323 			if !(x < tile_width) {
  53324 				break
  53325 			}
  53326 			**(**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
  53327 			goto _2
  53328 		_2:
  53329 			;
  53330 			x = x + 1
  53331 		}
  53332 		argb = argb + uintptr(stride)*4
  53333 	}
  53334 }
  53335 
  53336 //------------------------------------------------------------------------------
  53337 
  53338 func VectorMismatch_C(tls *libc.TLS, array1 uintptr, array2 uintptr, length int32) (r int32) {
  53339 	var match_len int32
  53340 	_ = match_len
  53341 	match_len = 0
  53342 	for match_len < length && **(**uint32_t)(__ccgo_up(array1 + uintptr(match_len)*4)) == **(**uint32_t)(__ccgo_up(array2 + uintptr(match_len)*4)) {
  53343 		match_len = match_len + 1
  53344 	}
  53345 	return match_len
  53346 }
  53347 
  53348 // C documentation
  53349 //
  53350 //	// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
  53351 func VP8LBundleColorMap_C(tls *libc.TLS, row uintptr, width int32, xbits int32, dst uintptr) {
  53352 	var bit_depth, mask, x, xsub int32
  53353 	var code uint32_t
  53354 	_, _, _, _, _ = bit_depth, code, mask, x, xsub
  53355 	if xbits > 0 {
  53356 		bit_depth = int32(1) << (int32(3) - xbits)
  53357 		mask = int32(1)<<xbits - int32(1)
  53358 		code = uint32(0xff000000)
  53359 		x = 0
  53360 		for {
  53361 			if !(x < width) {
  53362 				break
  53363 			}
  53364 			xsub = x & mask
  53365 			if xsub == 0 {
  53366 				code = uint32(0xff000000)
  53367 			}
  53368 			code = code | libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(row + uintptr(x))))<<(int32(8)+bit_depth*xsub))
  53369 			**(**uint32_t)(__ccgo_up(dst + uintptr(x>>xbits)*4)) = code
  53370 			goto _1
  53371 		_1:
  53372 			;
  53373 			x = x + 1
  53374 		}
  53375 	} else {
  53376 		x = 0
  53377 		for {
  53378 			if !(x < width) {
  53379 				break
  53380 			}
  53381 			**(**uint32_t)(__ccgo_up(dst + uintptr(x)*4)) = uint32(0xff000000) | libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(row + uintptr(x))))<<libc.Int32FromInt32(8))
  53382 			goto _2
  53383 		_2:
  53384 			;
  53385 			x = x + 1
  53386 		}
  53387 	}
  53388 }
  53389 
  53390 //------------------------------------------------------------------------------
  53391 
  53392 func ExtraCost_C(tls *libc.TLS, population uintptr, length int32) (r uint32_t) {
  53393 	var cost uint32_t
  53394 	var i int32
  53395 	_, _ = cost, i
  53396 	cost = **(**uint32_t)(__ccgo_up(population + 4*4)) + **(**uint32_t)(__ccgo_up(population + 5*4))
  53397 	i = int32(2)
  53398 	for {
  53399 		if !(i < length/int32(2)-int32(1)) {
  53400 			break
  53401 		}
  53402 		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)))
  53403 		goto _1
  53404 	_1:
  53405 		;
  53406 		i = i + 1
  53407 	}
  53408 	return cost
  53409 }
  53410 
  53411 //------------------------------------------------------------------------------
  53412 
  53413 func AddVector_C(tls *libc.TLS, a uintptr, b uintptr, out uintptr, size int32) {
  53414 	var i int32
  53415 	_ = i
  53416 	i = 0
  53417 	for {
  53418 		if !(i < size) {
  53419 			break
  53420 		}
  53421 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = **(**uint32_t)(__ccgo_up(a + uintptr(i)*4)) + **(**uint32_t)(__ccgo_up(b + uintptr(i)*4))
  53422 		goto _1
  53423 	_1:
  53424 		;
  53425 		i = i + 1
  53426 	}
  53427 }
  53428 
  53429 func AddVectorEq_C(tls *libc.TLS, a uintptr, out uintptr, size int32) {
  53430 	var i int32
  53431 	_ = i
  53432 	i = 0
  53433 	for {
  53434 		if !(i < size) {
  53435 			break
  53436 		}
  53437 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) += **(**uint32_t)(__ccgo_up(a + uintptr(i)*4))
  53438 		goto _1
  53439 	_1:
  53440 		;
  53441 		i = i + 1
  53442 	}
  53443 }
  53444 
  53445 //------------------------------------------------------------------------------
  53446 // Image transforms.
  53447 
  53448 func PredictorSub0_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53449 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  53450 	var i int32
  53451 	_, _, _, _, _, _ = alpha_and_green, i, red_and_blue, v2, v3, v4
  53452 	i = 0
  53453 	for {
  53454 		if !(i < num_pixels) {
  53455 			break
  53456 		}
  53457 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  53458 		v3 = uint32(ARGB_BLACK3)
  53459 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53460 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53461 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53462 		goto _5
  53463 	_5:
  53464 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v4
  53465 		goto _1
  53466 	_1:
  53467 		;
  53468 		i = i + 1
  53469 	}
  53470 	_ = upper
  53471 }
  53472 
  53473 func PredictorSub1_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53474 	var alpha_and_green, red_and_blue, v2, v3, v4 uint32_t
  53475 	var i int32
  53476 	_, _, _, _, _, _ = alpha_and_green, i, red_and_blue, v2, v3, v4
  53477 	i = 0
  53478 	for {
  53479 		if !(i < num_pixels) {
  53480 			break
  53481 		}
  53482 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(i)*4))
  53483 		v3 = **(**uint32_t)(__ccgo_up(in + uintptr(i-int32(1))*4))
  53484 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53485 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53486 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53487 		goto _5
  53488 	_5:
  53489 		**(**uint32_t)(__ccgo_up(out + uintptr(i)*4)) = v4
  53490 		goto _1
  53491 	_1:
  53492 		;
  53493 		i = i + 1
  53494 	}
  53495 	_ = upper
  53496 }
  53497 
  53498 // It subtracts the prediction from the input pixel and stores the residual
  53499 // in the output pixel.
  53500 func PredictorSub2_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53501 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53502 	var x int32
  53503 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53504 	x = 0
  53505 	for {
  53506 		if !(x < num_pixels) {
  53507 			break
  53508 		}
  53509 		pred = VP8LPredictor2_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53510 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53511 		v3 = pred
  53512 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53513 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53514 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53515 		goto _5
  53516 	_5:
  53517 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53518 		goto _1
  53519 	_1:
  53520 		;
  53521 		x = x + 1
  53522 	}
  53523 }
  53524 
  53525 func PredictorSub3_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53526 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53527 	var x int32
  53528 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53529 	x = 0
  53530 	for {
  53531 		if !(x < num_pixels) {
  53532 			break
  53533 		}
  53534 		pred = VP8LPredictor3_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53535 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53536 		v3 = pred
  53537 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53538 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53539 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53540 		goto _5
  53541 	_5:
  53542 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53543 		goto _1
  53544 	_1:
  53545 		;
  53546 		x = x + 1
  53547 	}
  53548 }
  53549 
  53550 func PredictorSub4_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53551 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53552 	var x int32
  53553 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53554 	x = 0
  53555 	for {
  53556 		if !(x < num_pixels) {
  53557 			break
  53558 		}
  53559 		pred = VP8LPredictor4_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53560 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53561 		v3 = pred
  53562 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53563 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53564 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53565 		goto _5
  53566 	_5:
  53567 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53568 		goto _1
  53569 	_1:
  53570 		;
  53571 		x = x + 1
  53572 	}
  53573 }
  53574 
  53575 func PredictorSub5_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53576 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53577 	var x int32
  53578 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53579 	x = 0
  53580 	for {
  53581 		if !(x < num_pixels) {
  53582 			break
  53583 		}
  53584 		pred = VP8LPredictor5_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53585 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53586 		v3 = pred
  53587 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53588 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53589 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53590 		goto _5
  53591 	_5:
  53592 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53593 		goto _1
  53594 	_1:
  53595 		;
  53596 		x = x + 1
  53597 	}
  53598 }
  53599 
  53600 func PredictorSub6_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53601 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53602 	var x int32
  53603 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53604 	x = 0
  53605 	for {
  53606 		if !(x < num_pixels) {
  53607 			break
  53608 		}
  53609 		pred = VP8LPredictor6_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53610 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53611 		v3 = pred
  53612 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53613 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53614 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53615 		goto _5
  53616 	_5:
  53617 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53618 		goto _1
  53619 	_1:
  53620 		;
  53621 		x = x + 1
  53622 	}
  53623 }
  53624 
  53625 func PredictorSub7_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53626 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53627 	var x int32
  53628 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53629 	x = 0
  53630 	for {
  53631 		if !(x < num_pixels) {
  53632 			break
  53633 		}
  53634 		pred = VP8LPredictor7_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53635 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53636 		v3 = pred
  53637 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53638 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53639 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53640 		goto _5
  53641 	_5:
  53642 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53643 		goto _1
  53644 	_1:
  53645 		;
  53646 		x = x + 1
  53647 	}
  53648 }
  53649 
  53650 func PredictorSub8_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53651 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53652 	var x int32
  53653 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53654 	x = 0
  53655 	for {
  53656 		if !(x < num_pixels) {
  53657 			break
  53658 		}
  53659 		pred = VP8LPredictor8_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53660 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53661 		v3 = pred
  53662 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53663 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53664 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53665 		goto _5
  53666 	_5:
  53667 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53668 		goto _1
  53669 	_1:
  53670 		;
  53671 		x = x + 1
  53672 	}
  53673 }
  53674 
  53675 func PredictorSub9_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53676 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53677 	var x int32
  53678 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53679 	x = 0
  53680 	for {
  53681 		if !(x < num_pixels) {
  53682 			break
  53683 		}
  53684 		pred = VP8LPredictor9_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53685 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53686 		v3 = pred
  53687 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53688 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53689 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53690 		goto _5
  53691 	_5:
  53692 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53693 		goto _1
  53694 	_1:
  53695 		;
  53696 		x = x + 1
  53697 	}
  53698 }
  53699 
  53700 func PredictorSub10_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53701 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53702 	var x int32
  53703 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53704 	x = 0
  53705 	for {
  53706 		if !(x < num_pixels) {
  53707 			break
  53708 		}
  53709 		pred = VP8LPredictor10_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53710 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53711 		v3 = pred
  53712 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53713 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53714 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53715 		goto _5
  53716 	_5:
  53717 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53718 		goto _1
  53719 	_1:
  53720 		;
  53721 		x = x + 1
  53722 	}
  53723 }
  53724 
  53725 func PredictorSub11_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53726 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53727 	var x int32
  53728 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53729 	x = 0
  53730 	for {
  53731 		if !(x < num_pixels) {
  53732 			break
  53733 		}
  53734 		pred = VP8LPredictor11_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53735 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53736 		v3 = pred
  53737 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53738 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53739 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53740 		goto _5
  53741 	_5:
  53742 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53743 		goto _1
  53744 	_1:
  53745 		;
  53746 		x = x + 1
  53747 	}
  53748 }
  53749 
  53750 func PredictorSub12_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53751 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53752 	var x int32
  53753 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53754 	x = 0
  53755 	for {
  53756 		if !(x < num_pixels) {
  53757 			break
  53758 		}
  53759 		pred = VP8LPredictor12_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53760 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53761 		v3 = pred
  53762 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53763 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53764 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53765 		goto _5
  53766 	_5:
  53767 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53768 		goto _1
  53769 	_1:
  53770 		;
  53771 		x = x + 1
  53772 	}
  53773 }
  53774 
  53775 func PredictorSub13_C(tls *libc.TLS, in uintptr, upper uintptr, num_pixels int32, out uintptr) {
  53776 	var alpha_and_green, pred, red_and_blue, v2, v3, v4 uint32_t
  53777 	var x int32
  53778 	_, _, _, _, _, _, _ = alpha_and_green, pred, red_and_blue, x, v2, v3, v4
  53779 	x = 0
  53780 	for {
  53781 		if !(x < num_pixels) {
  53782 			break
  53783 		}
  53784 		pred = VP8LPredictor13_C(tls, in+uintptr(x-int32(1))*4, upper+uintptr(x)*4)
  53785 		v2 = **(**uint32_t)(__ccgo_up(in + uintptr(x)*4))
  53786 		v3 = pred
  53787 		alpha_and_green = uint32(0x00ff00ff) + v2&uint32(0xff00ff00) - v3&uint32(0xff00ff00)
  53788 		red_and_blue = uint32(0xff00ff00) + v2&uint32(0x00ff00ff) - v3&uint32(0x00ff00ff)
  53789 		v4 = alpha_and_green&uint32(0xff00ff00) | red_and_blue&uint32(0x00ff00ff)
  53790 		goto _5
  53791 	_5:
  53792 		**(**uint32_t)(__ccgo_up(out + uintptr(x)*4)) = v4
  53793 		goto _1
  53794 	_1:
  53795 		;
  53796 		x = x + 1
  53797 	}
  53798 }
  53799 
  53800 func VP8LEncDspInit(tls *libc.TLS) {
  53801 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  53802 		goto _1
  53803 	}
  53804 	VP8LEncDspInit_body(tls)
  53805 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  53806 	goto _2
  53807 _2:
  53808 	;
  53809 	goto _1
  53810 _1: /**/ //
  53811 }
  53812 
  53813 var VP8LEncDspInit_body_last_cpuinfo_used = uintptr(0)
  53814 
  53815 func init() {
  53816 	p := unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used)
  53817 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8LEncDspInit_body_last_cpuinfo_used))
  53818 }
  53819 
  53820 func VP8LEncDspInit_body(tls *libc.TLS) {
  53821 	VP8LDspInit(tls)
  53822 	VP8LSubtractGreenFromBlueAndRed = __ccgo_fp(VP8LSubtractGreenFromBlueAndRed_C)
  53823 	VP8LTransformColor = __ccgo_fp(VP8LTransformColor_C)
  53824 	VP8LCollectColorBlueTransforms = __ccgo_fp(VP8LCollectColorBlueTransforms_C)
  53825 	VP8LCollectColorRedTransforms = __ccgo_fp(VP8LCollectColorRedTransforms_C)
  53826 	VP8LFastLog2Slow = __ccgo_fp(FastLog2Slow_C)
  53827 	VP8LFastSLog2Slow = __ccgo_fp(FastSLog2Slow_C)
  53828 	VP8LExtraCost = __ccgo_fp(ExtraCost_C)
  53829 	VP8LCombinedShannonEntropy = __ccgo_fp(CombinedShannonEntropy_C)
  53830 	VP8LShannonEntropy = __ccgo_fp(ShannonEntropy_C)
  53831 	VP8LGetEntropyUnrefined = __ccgo_fp(GetEntropyUnrefined_C)
  53832 	VP8LGetCombinedEntropyUnrefined = __ccgo_fp(GetCombinedEntropyUnrefined_C)
  53833 	VP8LAddVector = __ccgo_fp(AddVector_C)
  53834 	VP8LAddVectorEq = __ccgo_fp(AddVectorEq_C)
  53835 	VP8LVectorMismatch = __ccgo_fp(VectorMismatch_C)
  53836 	VP8LBundleColorMap = __ccgo_fp(VP8LBundleColorMap_C)
  53837 	VP8LPredictorsSub[0] = __ccgo_fp(PredictorSub0_C)
  53838 	VP8LPredictorsSub[int32(1)] = __ccgo_fp(PredictorSub1_C)
  53839 	VP8LPredictorsSub[int32(2)] = __ccgo_fp(PredictorSub2_C)
  53840 	VP8LPredictorsSub[int32(3)] = __ccgo_fp(PredictorSub3_C)
  53841 	VP8LPredictorsSub[int32(4)] = __ccgo_fp(PredictorSub4_C)
  53842 	VP8LPredictorsSub[int32(5)] = __ccgo_fp(PredictorSub5_C)
  53843 	VP8LPredictorsSub[int32(6)] = __ccgo_fp(PredictorSub6_C)
  53844 	VP8LPredictorsSub[int32(7)] = __ccgo_fp(PredictorSub7_C)
  53845 	VP8LPredictorsSub[int32(8)] = __ccgo_fp(PredictorSub8_C)
  53846 	VP8LPredictorsSub[int32(9)] = __ccgo_fp(PredictorSub9_C)
  53847 	VP8LPredictorsSub[int32(10)] = __ccgo_fp(PredictorSub10_C)
  53848 	VP8LPredictorsSub[int32(11)] = __ccgo_fp(PredictorSub11_C)
  53849 	VP8LPredictorsSub[int32(12)] = __ccgo_fp(PredictorSub12_C)
  53850 	VP8LPredictorsSub[int32(13)] = __ccgo_fp(PredictorSub13_C)
  53851 	VP8LPredictorsSub[int32(14)] = __ccgo_fp(PredictorSub0_C) // <- padding security sentinels
  53852 	VP8LPredictorsSub[int32(15)] = __ccgo_fp(PredictorSub0_C)
  53853 	VP8LPredictorsSub_C[0] = __ccgo_fp(PredictorSub0_C)
  53854 	VP8LPredictorsSub_C[int32(1)] = __ccgo_fp(PredictorSub1_C)
  53855 	VP8LPredictorsSub_C[int32(2)] = __ccgo_fp(PredictorSub2_C)
  53856 	VP8LPredictorsSub_C[int32(3)] = __ccgo_fp(PredictorSub3_C)
  53857 	VP8LPredictorsSub_C[int32(4)] = __ccgo_fp(PredictorSub4_C)
  53858 	VP8LPredictorsSub_C[int32(5)] = __ccgo_fp(PredictorSub5_C)
  53859 	VP8LPredictorsSub_C[int32(6)] = __ccgo_fp(PredictorSub6_C)
  53860 	VP8LPredictorsSub_C[int32(7)] = __ccgo_fp(PredictorSub7_C)
  53861 	VP8LPredictorsSub_C[int32(8)] = __ccgo_fp(PredictorSub8_C)
  53862 	VP8LPredictorsSub_C[int32(9)] = __ccgo_fp(PredictorSub9_C)
  53863 	VP8LPredictorsSub_C[int32(10)] = __ccgo_fp(PredictorSub10_C)
  53864 	VP8LPredictorsSub_C[int32(11)] = __ccgo_fp(PredictorSub11_C)
  53865 	VP8LPredictorsSub_C[int32(12)] = __ccgo_fp(PredictorSub12_C)
  53866 	VP8LPredictorsSub_C[int32(13)] = __ccgo_fp(PredictorSub13_C)
  53867 	VP8LPredictorsSub_C[int32(14)] = __ccgo_fp(PredictorSub0_C) // <- padding security sentinels
  53868 	VP8LPredictorsSub_C[int32(15)] = __ccgo_fp(PredictorSub0_C)
  53869 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  53870 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  53871 	}
  53872 }
  53873 
  53874 const LOG_2_RECIPROCAL_FIXED_DOUBLE2 = 12102203.161561485379934310913085937500
  53875 const __FLT_MIN__12 = 1.17549435082228750796873653722224568e-38
  53876 
  53877 func VP8LEncDspInitMIPS32(tls *libc.TLS) {
  53878 }
  53879 
  53880 func VP8LEncDspInitMIPSdspR2(tls *libc.TLS) {
  53881 }
  53882 
  53883 func VP8LEncDspInitMSA(tls *libc.TLS) {
  53884 }
  53885 
  53886 func VP8LEncDspInitNEON(tls *libc.TLS) {
  53887 }
  53888 
  53889 func VP8LEncDspInitSSE2(tls *libc.TLS) {
  53890 }
  53891 
  53892 func VP8LEncDspInitSSE41(tls *libc.TLS) {
  53893 }
  53894 
  53895 func VP8LDspInitMIPSdspR2(tls *libc.TLS) {
  53896 }
  53897 
  53898 func VP8LDspInitMSA(tls *libc.TLS) {
  53899 }
  53900 
  53901 func VP8LDspInitNEON(tls *libc.TLS) {
  53902 }
  53903 
  53904 func VP8LDspInitSSE2(tls *libc.TLS) {
  53905 }
  53906 
  53907 func VP8LDspInitSSE41(tls *libc.TLS) {
  53908 }
  53909 
  53910 //------------------------------------------------------------------------------
  53911 
  53912 //------------------------------------------------------------------------------
  53913 // Implementations of critical functions ImportRow / ExportRow
  53914 
  53915 //------------------------------------------------------------------------------
  53916 // Row import
  53917 
  53918 func WebPRescalerImportRowExpand_C(tls *libc.TLS, wrk uintptr, src uintptr) {
  53919 	var accum, channel, x_in, x_out, x_out_max, x_stride int32
  53920 	var left, right rescaler_t
  53921 	var v2 uint32
  53922 	_, _, _, _, _, _, _, _, _ = accum, channel, left, right, x_in, x_out, x_out_max, x_stride, v2
  53923 	x_stride = (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53924 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53925 	channel = 0
  53926 	for {
  53927 		if !(channel < x_stride) {
  53928 			break
  53929 		}
  53930 		x_in = channel
  53931 		x_out = channel
  53932 		// simple bilinear interpolation
  53933 		accum = (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53934 		left = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53935 		if (*WebPRescaler)(unsafe.Pointer(wrk)).Fsrc_width > int32(1) {
  53936 			v2 = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in+x_stride))))
  53937 		} else {
  53938 			v2 = left
  53939 		}
  53940 		right = v2
  53941 		x_in = x_in + x_stride
  53942 		for int32(1) != 0 {
  53943 			**(**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)
  53944 			x_out = x_out + x_stride
  53945 			if x_out >= x_out_max {
  53946 				break
  53947 			}
  53948 			accum = accum - (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub
  53949 			if accum < 0 {
  53950 				left = right
  53951 				x_in = x_in + x_stride
  53952 				right = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53953 				accum = accum + (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53954 			}
  53955 		}
  53956 		goto _1
  53957 	_1:
  53958 		;
  53959 		channel = channel + 1
  53960 	}
  53961 }
  53962 
  53963 func WebPRescalerImportRowShrink_C(tls *libc.TLS, wrk uintptr, src uintptr) {
  53964 	var accum, channel, x_in, x_out, x_out_max, x_stride int32
  53965 	var base, sum uint32_t
  53966 	var frac rescaler_t
  53967 	_, _, _, _, _, _, _, _, _ = accum, base, channel, frac, sum, x_in, x_out, x_out_max, x_stride
  53968 	x_stride = (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53969 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  53970 	channel = 0
  53971 	for {
  53972 		if !(channel < x_stride) {
  53973 			break
  53974 		}
  53975 		x_in = channel
  53976 		x_out = channel
  53977 		sum = uint32(0)
  53978 		accum = 0
  53979 		for x_out < x_out_max {
  53980 			base = uint32(0)
  53981 			accum = accum + (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_add
  53982 			for accum > 0 {
  53983 				accum = accum - (*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub
  53984 				base = uint32(**(**uint8_t)(__ccgo_up(src + uintptr(x_in))))
  53985 				sum = sum + base
  53986 				x_in = x_in + x_stride
  53987 			}
  53988 			// Emit next horizontal pixel.
  53989 			frac = base * libc.Uint32FromInt32(-accum)
  53990 			**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow + uintptr(x_out)*4)) = sum*libc.Uint32FromInt32((*WebPRescaler)(unsafe.Pointer(wrk)).Fx_sub) - frac
  53991 			// fresh fractional start for next pixel
  53992 			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)))
  53993 			x_out = x_out + x_stride
  53994 		}
  53995 		goto _1
  53996 	_1:
  53997 		;
  53998 		channel = channel + 1
  53999 	}
  54000 }
  54001 
  54002 //------------------------------------------------------------------------------
  54003 // Row export
  54004 
  54005 func WebPRescalerExportRowExpand_C(tls *libc.TLS, wrk uintptr) {
  54006 	var A, B, J, J1 uint32_t
  54007 	var I uint64_t
  54008 	var dst, frow, irow uintptr
  54009 	var v, v1, x_out, x_out_max int32
  54010 	var v2 uint32
  54011 	_, _, _, _, _, _, _, _, _, _, _, _, _ = A, B, I, J, J1, dst, frow, irow, v, v1, x_out, x_out_max, v2
  54012 	dst = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst
  54013 	irow = (*WebPRescaler)(unsafe.Pointer(wrk)).Firow
  54014 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  54015 	frow = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow
  54016 	if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum == 0 {
  54017 		x_out = 0
  54018 		for {
  54019 			if !(x_out < x_out_max) {
  54020 				break
  54021 			}
  54022 			J = **(**rescaler_t)(__ccgo_up(frow + uintptr(x_out)*4))
  54023 			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))
  54024 			if v > int32(255) {
  54025 				v2 = uint32(255)
  54026 			} else {
  54027 				v2 = uint32(libc.Uint8FromInt32(v))
  54028 			}
  54029 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54030 			goto _1
  54031 		_1:
  54032 			;
  54033 			x_out = x_out + 1
  54034 		}
  54035 	} else {
  54036 		B = uint32(libc.Uint64FromInt32(-(*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum) << libc.Int32FromInt32(WEBP_RESCALER_RFIX) / libc.Uint64FromInt32((*WebPRescaler)(unsafe.Pointer(wrk)).Fy_sub))
  54037 		A = uint32(libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX) - uint64(B))
  54038 		x_out = 0
  54039 		for {
  54040 			if !(x_out < x_out_max) {
  54041 				break
  54042 			}
  54043 			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)))
  54044 			J1 = uint32((I + libc.Uint64FromUint64(1)<<libc.Int32FromInt32(WEBP_RESCALER_RFIX)>>libc.Int32FromInt32(1)) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54045 			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))
  54046 			if v1 > int32(255) {
  54047 				v2 = uint32(255)
  54048 			} else {
  54049 				v2 = uint32(libc.Uint8FromInt32(v1))
  54050 			}
  54051 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54052 			goto _3
  54053 		_3:
  54054 			;
  54055 			x_out = x_out + 1
  54056 		}
  54057 	}
  54058 }
  54059 
  54060 func WebPRescalerExportRowShrink_C(tls *libc.TLS, wrk uintptr) {
  54061 	var dst, frow, irow uintptr
  54062 	var frac, yscale uint32_t
  54063 	var v, v1, x_out, x_out_max int32
  54064 	var v2 uint32
  54065 	_, _, _, _, _, _, _, _, _, _ = dst, frac, frow, irow, v, v1, x_out, x_out_max, yscale, v2
  54066 	dst = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst
  54067 	irow = (*WebPRescaler)(unsafe.Pointer(wrk)).Firow
  54068 	x_out_max = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width * (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels
  54069 	frow = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffrow
  54070 	yscale = (*WebPRescaler)(unsafe.Pointer(wrk)).Ffy_scale * libc.Uint32FromInt32(-(*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum)
  54071 	if yscale != 0 {
  54072 		x_out = 0
  54073 		for {
  54074 			if !(x_out < x_out_max) {
  54075 				break
  54076 			}
  54077 			frac = uint32(uint64(**(**rescaler_t)(__ccgo_up(frow + uintptr(x_out)*4))) * uint64(yscale) >> libc.Int32FromInt32(WEBP_RESCALER_RFIX))
  54078 			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))
  54079 			if v > int32(255) {
  54080 				v2 = uint32(255)
  54081 			} else {
  54082 				v2 = uint32(libc.Uint8FromInt32(v))
  54083 			}
  54084 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54085 			**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)) = frac // new fractional start
  54086 			goto _1
  54087 		_1:
  54088 			;
  54089 			x_out = x_out + 1
  54090 		}
  54091 	} else {
  54092 		x_out = 0
  54093 		for {
  54094 			if !(x_out < x_out_max) {
  54095 				break
  54096 			}
  54097 			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))
  54098 			if v1 > int32(255) {
  54099 				v2 = uint32(255)
  54100 			} else {
  54101 				v2 = uint32(libc.Uint8FromInt32(v1))
  54102 			}
  54103 			**(**uint8_t)(__ccgo_up(dst + uintptr(x_out))) = uint8(v2)
  54104 			**(**rescaler_t)(__ccgo_up(irow + uintptr(x_out)*4)) = uint32(0)
  54105 			goto _3
  54106 		_3:
  54107 			;
  54108 			x_out = x_out + 1
  54109 		}
  54110 	}
  54111 }
  54112 
  54113 //------------------------------------------------------------------------------
  54114 // Main entry calls
  54115 
  54116 func WebPRescalerImportRow(tls *libc.TLS, wrk uintptr, src uintptr) {
  54117 	if !((*WebPRescaler)(unsafe.Pointer(wrk)).Fx_expand != 0) {
  54118 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerImportRowShrink})))(tls, wrk, src)
  54119 	} else {
  54120 		(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerImportRowExpand})))(tls, wrk, src)
  54121 	}
  54122 }
  54123 
  54124 func WebPRescalerExportRow(tls *libc.TLS, wrk uintptr) {
  54125 	var i int32
  54126 	_ = i
  54127 	if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_accum <= 0 {
  54128 		if (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_expand != 0 {
  54129 			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerExportRowExpand})))(tls, wrk)
  54130 		} else {
  54131 			if (*WebPRescaler)(unsafe.Pointer(wrk)).Ffxy_scale != 0 {
  54132 				(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{WebPRescalerExportRowShrink})))(tls, wrk)
  54133 			} else {
  54134 				i = 0
  54135 				for {
  54136 					if !(i < (*WebPRescaler)(unsafe.Pointer(wrk)).Fnum_channels*(*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_width) {
  54137 						break
  54138 					}
  54139 					**(**uint8_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Fdst + uintptr(i))) = uint8(**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Firow + uintptr(i)*4)))
  54140 					**(**rescaler_t)(__ccgo_up((*WebPRescaler)(unsafe.Pointer(wrk)).Firow + uintptr(i)*4)) = uint32(0)
  54141 					goto _1
  54142 				_1:
  54143 					;
  54144 					i = i + 1
  54145 				}
  54146 			}
  54147 		}
  54148 		**(**int32)(__ccgo_up(wrk + 24)) += (*WebPRescaler)(unsafe.Pointer(wrk)).Fy_add
  54149 		**(**uintptr)(__ccgo_up(wrk + 72)) += uintptr((*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_stride)
  54150 		(*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_y = (*WebPRescaler)(unsafe.Pointer(wrk)).Fdst_y + 1
  54151 	}
  54152 }
  54153 
  54154 func WebPRescalerDspInit(tls *libc.TLS) {
  54155 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  54156 		goto _1
  54157 	}
  54158 	WebPRescalerDspInit_body(tls)
  54159 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  54160 	goto _2
  54161 _2:
  54162 	;
  54163 	goto _1
  54164 _1: /**/ //
  54165 }
  54166 
  54167 var WebPRescalerDspInit_body_last_cpuinfo_used = uintptr(0)
  54168 
  54169 func init() {
  54170 	p := unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used)
  54171 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPRescalerDspInit_body_last_cpuinfo_used))
  54172 }
  54173 
  54174 func WebPRescalerDspInit_body(tls *libc.TLS) {
  54175 	WebPRescalerExportRowExpand = __ccgo_fp(WebPRescalerExportRowExpand_C)
  54176 	WebPRescalerExportRowShrink = __ccgo_fp(WebPRescalerExportRowShrink_C)
  54177 	WebPRescalerImportRowExpand = __ccgo_fp(WebPRescalerImportRowExpand_C)
  54178 	WebPRescalerImportRowShrink = __ccgo_fp(WebPRescalerImportRowShrink_C)
  54179 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  54180 	}
  54181 }
  54182 
  54183 func WebPRescalerDspInitMIPS32(tls *libc.TLS) {
  54184 }
  54185 
  54186 func WebPRescalerDspInitMIPSdspR2(tls *libc.TLS) {
  54187 }
  54188 
  54189 func WebPRescalerDspInitMSA(tls *libc.TLS) {
  54190 }
  54191 
  54192 func WebPRescalerDspInitNEON(tls *libc.TLS) {
  54193 }
  54194 
  54195 func WebPRescalerDspInitSSE2(tls *libc.TLS) {
  54196 }
  54197 
  54198 // Copyright 2010 Google Inc. All Rights Reserved.
  54199 //
  54200 // Use of this source code is governed by a BSD-style license
  54201 // that can be found in the COPYING file in the root of the source
  54202 // tree. An additional intellectual property rights grant can be found
  54203 // in the file PATENTS. All contributing project authors may
  54204 // be found in the AUTHORS file in the root of the source tree.
  54205 // -----------------------------------------------------------------------------
  54206 //
  54207 //  Common types + memory wrappers
  54208 //
  54209 // Author: Skal (pascal.massimino@gmail.com)
  54210 
  54211 //------------------------------------------------------------------------------
  54212 // SSIM / PSNR
  54213 
  54214 // C documentation
  54215 //
  54216 //	// hat-shaped filter. Sum of coefficients is equal to 16.
  54217 var kWeight = [7]uint32_t{
  54218 	0: uint32(1),
  54219 	1: uint32(2),
  54220 	2: uint32(3),
  54221 	3: uint32(4),
  54222 	4: uint32(3),
  54223 	5: uint32(2),
  54224 	6: uint32(1),
  54225 }
  54226 var kWeightSum = libc.Uint32FromInt32(libc.Int32FromInt32(16) * libc.Int32FromInt32(16)) // sum{kWeight}^2
  54227 
  54228 func SSIMCalculation(tls *libc.TLS, stats uintptr, N uint32_t) (r1 float64) {
  54229 	var C1, C2, C3, w2 uint32_t
  54230 	var den_S, fden, fnum, num_S, sxx, syy, xmxm, ymym uint64_t
  54231 	var r float64
  54232 	var sxy, xmym int64_t
  54233 	var v1 int64
  54234 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = C1, C2, C3, den_S, fden, fnum, num_S, r, sxx, sxy, syy, w2, xmxm, xmym, ymym, v1
  54235 	w2 = N * N
  54236 	C1 = uint32(20) * w2
  54237 	C2 = uint32(60) * w2
  54238 	C3 = libc.Uint32FromInt32(libc.Int32FromInt32(8)*libc.Int32FromInt32(8)) * w2 // 'dark' limit ~= 6
  54239 	xmxm = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm) * uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm)
  54240 	ymym = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fym) * uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fym)
  54241 	if xmxm+ymym >= uint64(C3) {
  54242 		xmym = libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fxm) * libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fym)
  54243 		sxy = libc.Int64FromUint32((*VP8DistoStats)(unsafe.Pointer(stats)).Fxym)*libc.Int64FromUint32(N) - xmym // can be negative
  54244 		sxx = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fxxm)*uint64(N) - xmxm
  54245 		syy = uint64((*VP8DistoStats)(unsafe.Pointer(stats)).Fyym)*uint64(N) - ymym
  54246 		if sxy < 0 {
  54247 			v1 = 0
  54248 		} else {
  54249 			v1 = sxy
  54250 		}
  54251 		// we descale by 8 to prevent overflow during the fnum/fden multiply.
  54252 		num_S = (uint64(2)*libc.Uint64FromInt64(v1) + uint64(C2)) >> int32(8)
  54253 		den_S = (sxx + syy + uint64(C2)) >> int32(8)
  54254 		fnum = libc.Uint64FromInt64(libc.Int64FromInt32(2)*xmym+libc.Int64FromUint32(C1)) * num_S
  54255 		fden = (xmxm + ymym + uint64(C1)) * den_S
  54256 		r = float64(fnum) / float64(fden)
  54257 		return r
  54258 	}
  54259 	return float64(1) // area is too dark to contribute meaningfully
  54260 }
  54261 
  54262 func VP8SSIMFromStats(tls *libc.TLS, stats uintptr) (r float64) {
  54263 	return SSIMCalculation(tls, stats, kWeightSum)
  54264 }
  54265 
  54266 func VP8SSIMFromStatsClipped(tls *libc.TLS, stats uintptr) (r float64) {
  54267 	return SSIMCalculation(tls, stats, (*VP8DistoStats)(unsafe.Pointer(stats)).Fw)
  54268 }
  54269 
  54270 func SSIMGetClipped_C(tls *libc.TLS, src1 uintptr, stride1 int32, src2 uintptr, stride2 int32, xo int32, yo int32, W int32, H int32) (r float64) {
  54271 	bp := tls.Alloc(32)
  54272 	defer tls.Free(32)
  54273 	var s1, s2, w uint32_t
  54274 	var x, xmax, xmin, y, ymax, ymin, v1, v2, v3, v4 int32
  54275 	var _ /* stats at bp+0 */ VP8DistoStats
  54276 	_, _, _, _, _, _, _, _, _, _, _, _, _ = s1, s2, w, x, xmax, xmin, y, ymax, ymin, v1, v2, v3, v4
  54277 	**(**VP8DistoStats)(__ccgo_up(bp)) = VP8DistoStats{}
  54278 	if yo-int32(VP8_SSIM_KERNEL) < 0 {
  54279 		v1 = 0
  54280 	} else {
  54281 		v1 = yo - int32(VP8_SSIM_KERNEL)
  54282 	}
  54283 	ymin = v1
  54284 	if yo+int32(VP8_SSIM_KERNEL) > H-int32(1) {
  54285 		v2 = H - int32(1)
  54286 	} else {
  54287 		v2 = yo + int32(VP8_SSIM_KERNEL)
  54288 	}
  54289 	ymax = v2
  54290 	if xo-int32(VP8_SSIM_KERNEL) < 0 {
  54291 		v3 = 0
  54292 	} else {
  54293 		v3 = xo - int32(VP8_SSIM_KERNEL)
  54294 	}
  54295 	xmin = v3
  54296 	if xo+int32(VP8_SSIM_KERNEL) > W-int32(1) {
  54297 		v4 = W - int32(1)
  54298 	} else {
  54299 		v4 = xo + int32(VP8_SSIM_KERNEL)
  54300 	}
  54301 	xmax = v4
  54302 	src1 = src1 + uintptr(ymin*stride1)
  54303 	src2 = src2 + uintptr(ymin*stride2)
  54304 	y = ymin
  54305 	for {
  54306 		if !(y <= ymax) {
  54307 			break
  54308 		}
  54309 		x = xmin
  54310 		for {
  54311 			if !(x <= xmax) {
  54312 				break
  54313 			}
  54314 			w = kWeight[int32(VP8_SSIM_KERNEL)+x-xo] * kWeight[int32(VP8_SSIM_KERNEL)+y-yo]
  54315 			s1 = uint32(**(**uint8_t)(__ccgo_up(src1 + uintptr(x))))
  54316 			s2 = uint32(**(**uint8_t)(__ccgo_up(src2 + uintptr(x))))
  54317 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fw += w
  54318 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxm += w * s1
  54319 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fym += w * s2
  54320 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxxm += w * s1 * s1
  54321 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxym += w * s1 * s2
  54322 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fyym += w * s2 * s2
  54323 			goto _6
  54324 		_6:
  54325 			;
  54326 			x = x + 1
  54327 		}
  54328 		goto _5
  54329 	_5:
  54330 		;
  54331 		y = y + 1
  54332 		src1 = src1 + uintptr(stride1)
  54333 		src2 = src2 + uintptr(stride2)
  54334 	}
  54335 	return VP8SSIMFromStatsClipped(tls, bp)
  54336 }
  54337 
  54338 func SSIMGet_C(tls *libc.TLS, src1 uintptr, stride1 int32, src2 uintptr, stride2 int32) (r float64) {
  54339 	bp := tls.Alloc(32)
  54340 	defer tls.Free(32)
  54341 	var s1, s2, w uint32_t
  54342 	var x, y int32
  54343 	var _ /* stats at bp+0 */ VP8DistoStats
  54344 	_, _, _, _, _ = s1, s2, w, x, y
  54345 	**(**VP8DistoStats)(__ccgo_up(bp)) = VP8DistoStats{}
  54346 	y = 0
  54347 	for {
  54348 		if !(y <= libc.Int32FromInt32(2)*libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  54349 			break
  54350 		}
  54351 		x = 0
  54352 		for {
  54353 			if !(x <= libc.Int32FromInt32(2)*libc.Int32FromInt32(VP8_SSIM_KERNEL)) {
  54354 				break
  54355 			}
  54356 			w = kWeight[x] * kWeight[y]
  54357 			s1 = uint32(**(**uint8_t)(__ccgo_up(src1 + uintptr(x))))
  54358 			s2 = uint32(**(**uint8_t)(__ccgo_up(src2 + uintptr(x))))
  54359 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxm += w * s1
  54360 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fym += w * s2
  54361 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxxm += w * s1 * s1
  54362 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fxym += w * s1 * s2
  54363 			(**(**VP8DistoStats)(__ccgo_up(bp))).Fyym += w * s2 * s2
  54364 			goto _2
  54365 		_2:
  54366 			;
  54367 			x = x + 1
  54368 		}
  54369 		goto _1
  54370 	_1:
  54371 		;
  54372 		y = y + 1
  54373 		src1 = src1 + uintptr(stride1)
  54374 		src2 = src2 + uintptr(stride2)
  54375 	}
  54376 	return VP8SSIMFromStats(tls, bp)
  54377 }
  54378 
  54379 //------------------------------------------------------------------------------
  54380 
  54381 func AccumulateSSE_C(tls *libc.TLS, src1 uintptr, src2 uintptr, len1 int32) (r uint32_t) {
  54382 	var diff int32_t
  54383 	var i int32
  54384 	var sse2 uint32_t
  54385 	_, _, _ = diff, i, sse2
  54386 	sse2 = uint32(0)
  54387 	// to ensure that accumulation fits within uint32_t
  54388 	i = 0
  54389 	for {
  54390 		if !(i < len1) {
  54391 			break
  54392 		}
  54393 		diff = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src1 + uintptr(i)))) - libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(src2 + uintptr(i))))
  54394 		sse2 = sse2 + libc.Uint32FromInt32(diff*diff)
  54395 		goto _1
  54396 	_1:
  54397 		;
  54398 		i = i + 1
  54399 	}
  54400 	return sse2
  54401 }
  54402 
  54403 func VP8SSIMDspInit(tls *libc.TLS) {
  54404 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  54405 		goto _1
  54406 	}
  54407 	VP8SSIMDspInit_body(tls)
  54408 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used)), VP8GetCPUInfo)
  54409 	goto _2
  54410 _2:
  54411 	;
  54412 	goto _1
  54413 _1: /**/ //
  54414 }
  54415 
  54416 var VP8SSIMDspInit_body_last_cpuinfo_used = uintptr(0)
  54417 
  54418 func init() {
  54419 	p := unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used)
  54420 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&VP8SSIMDspInit_body_last_cpuinfo_used))
  54421 }
  54422 
  54423 func VP8SSIMDspInit_body(tls *libc.TLS) {
  54424 	VP8SSIMGetClipped = __ccgo_fp(SSIMGetClipped_C)
  54425 	VP8SSIMGet = __ccgo_fp(SSIMGet_C)
  54426 	VP8AccumulateSSE = __ccgo_fp(AccumulateSSE_C)
  54427 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  54428 	}
  54429 }
  54430 
  54431 func VP8SSIMDspInitSSE2(tls *libc.TLS) {
  54432 }
  54433 
  54434 // Given samples laid out in a square as:
  54435 //  [a b]
  54436 //  [c d]
  54437 // we interpolate u/v as:
  54438 //  ([9*a + 3*b + 3*c +   d    3*a + 9*b + 3*c +   d] + [8 8]) / 16
  54439 //  ([3*a +   b + 9*c + 3*d      a + 3*b + 3*c + 9*d]   [8 8]) / 16
  54440 
  54441 // We process u and v together stashed into 32bit (16bit each).
  54442 
  54443 // C documentation
  54444 //
  54445 //	// All variants implemented.
  54446 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) {
  54447 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  54448 	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
  54449 	var v1, v5 uintptr
  54450 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  54451 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  54452 	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 */
  54453 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  54454 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  54455 	v1 = top_dst
  54456 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  54457 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  54458 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  54459 	v5 = v1
  54460 	v8 = v2 * int32(19077) >> int32(8)
  54461 	goto _9
  54462 _9:
  54463 	v10 = v4 * int32(26149) >> int32(8)
  54464 	goto _11
  54465 _11:
  54466 	v12 = v8 + v10 - int32(14234)
  54467 	if v12 & ^int32(YUV_MASK2) == 0 {
  54468 		v15 = v12 >> int32(YUV_FIX2)
  54469 	} else {
  54470 		if v12 < 0 {
  54471 			v16 = 0
  54472 		} else {
  54473 			v16 = int32(255)
  54474 		}
  54475 		v15 = v16
  54476 	}
  54477 	v13 = v15
  54478 	goto _14
  54479 _14:
  54480 	v6 = v13
  54481 	goto _7
  54482 _7:
  54483 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54484 	v19 = v2 * int32(19077) >> int32(8)
  54485 	goto _20
  54486 _20:
  54487 	v21 = v3 * int32(6419) >> int32(8)
  54488 	goto _22
  54489 _22:
  54490 	v23 = v4 * int32(13320) >> int32(8)
  54491 	goto _24
  54492 _24:
  54493 	v25 = v19 - v21 - v23 + int32(8708)
  54494 	if v25 & ^int32(YUV_MASK2) == 0 {
  54495 		v28 = v25 >> int32(YUV_FIX2)
  54496 	} else {
  54497 		if v25 < 0 {
  54498 			v29 = 0
  54499 		} else {
  54500 			v29 = int32(255)
  54501 		}
  54502 		v28 = v29
  54503 	}
  54504 	v26 = v28
  54505 	goto _27
  54506 _27:
  54507 	v17 = v26
  54508 	goto _18
  54509 _18:
  54510 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54511 	v32 = v2 * int32(19077) >> int32(8)
  54512 	goto _33
  54513 _33:
  54514 	v34 = v3 * int32(33050) >> int32(8)
  54515 	goto _35
  54516 _35:
  54517 	v36 = v32 + v34 - int32(17685)
  54518 	if v36 & ^int32(YUV_MASK2) == 0 {
  54519 		v39 = v36 >> int32(YUV_FIX2)
  54520 	} else {
  54521 		if v36 < 0 {
  54522 			v40 = 0
  54523 		} else {
  54524 			v40 = int32(255)
  54525 		}
  54526 		v39 = v40
  54527 	}
  54528 	v37 = v39
  54529 	goto _38
  54530 _38:
  54531 	v30 = v37
  54532 	goto _31
  54533 _31:
  54534 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54535 	**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54536 	if bottom_y != libc.UintptrFromInt32(0) {
  54537 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  54538 		v1 = bottom_dst
  54539 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  54540 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  54541 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  54542 		v5 = v1
  54543 		v8 = v2 * int32(19077) >> int32(8)
  54544 		goto _49
  54545 	_49:
  54546 		v10 = v4 * int32(26149) >> int32(8)
  54547 		goto _51
  54548 	_51:
  54549 		v12 = v8 + v10 - int32(14234)
  54550 		if v12 & ^int32(YUV_MASK2) == 0 {
  54551 			v15 = v12 >> int32(YUV_FIX2)
  54552 		} else {
  54553 			if v12 < 0 {
  54554 				v16 = 0
  54555 			} else {
  54556 				v16 = int32(255)
  54557 			}
  54558 			v15 = v16
  54559 		}
  54560 		v13 = v15
  54561 		goto _54
  54562 	_54:
  54563 		v6 = v13
  54564 		goto _47
  54565 	_47:
  54566 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54567 		v19 = v2 * int32(19077) >> int32(8)
  54568 		goto _60
  54569 	_60:
  54570 		v21 = v3 * int32(6419) >> int32(8)
  54571 		goto _62
  54572 	_62:
  54573 		v23 = v4 * int32(13320) >> int32(8)
  54574 		goto _64
  54575 	_64:
  54576 		v25 = v19 - v21 - v23 + int32(8708)
  54577 		if v25 & ^int32(YUV_MASK2) == 0 {
  54578 			v28 = v25 >> int32(YUV_FIX2)
  54579 		} else {
  54580 			if v25 < 0 {
  54581 				v29 = 0
  54582 			} else {
  54583 				v29 = int32(255)
  54584 			}
  54585 			v28 = v29
  54586 		}
  54587 		v26 = v28
  54588 		goto _67
  54589 	_67:
  54590 		v17 = v26
  54591 		goto _58
  54592 	_58:
  54593 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54594 		v32 = v2 * int32(19077) >> int32(8)
  54595 		goto _73
  54596 	_73:
  54597 		v34 = v3 * int32(33050) >> int32(8)
  54598 		goto _75
  54599 	_75:
  54600 		v36 = v32 + v34 - int32(17685)
  54601 		if v36 & ^int32(YUV_MASK2) == 0 {
  54602 			v39 = v36 >> int32(YUV_FIX2)
  54603 		} else {
  54604 			if v36 < 0 {
  54605 				v40 = 0
  54606 			} else {
  54607 				v40 = int32(255)
  54608 			}
  54609 			v39 = v40
  54610 		}
  54611 		v37 = v39
  54612 		goto _78
  54613 	_78:
  54614 		v30 = v37
  54615 		goto _71
  54616 	_71:
  54617 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54618 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54619 	}
  54620 	x = int32(1)
  54621 	for {
  54622 		if !(x <= last_pixel_pair) {
  54623 			break
  54624 		}
  54625 		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 */
  54626 		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*/
  54627 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  54628 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  54629 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  54630 		uv02 = (diag_12 + tl_uv) >> int32(1)
  54631 		uv1 = (diag_03 + t_uv) >> int32(1)
  54632 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  54633 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  54634 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  54635 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  54636 		v5 = v1
  54637 		v8 = v2 * int32(19077) >> int32(8)
  54638 		goto _90
  54639 	_90:
  54640 		v10 = v4 * int32(26149) >> int32(8)
  54641 		goto _92
  54642 	_92:
  54643 		v12 = v8 + v10 - int32(14234)
  54644 		if v12 & ^int32(YUV_MASK2) == 0 {
  54645 			v15 = v12 >> int32(YUV_FIX2)
  54646 		} else {
  54647 			if v12 < 0 {
  54648 				v16 = 0
  54649 			} else {
  54650 				v16 = int32(255)
  54651 			}
  54652 			v15 = v16
  54653 		}
  54654 		v13 = v15
  54655 		goto _95
  54656 	_95:
  54657 		v6 = v13
  54658 		goto _88
  54659 	_88:
  54660 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54661 		v19 = v2 * int32(19077) >> int32(8)
  54662 		goto _101
  54663 	_101:
  54664 		v21 = v3 * int32(6419) >> int32(8)
  54665 		goto _103
  54666 	_103:
  54667 		v23 = v4 * int32(13320) >> int32(8)
  54668 		goto _105
  54669 	_105:
  54670 		v25 = v19 - v21 - v23 + int32(8708)
  54671 		if v25 & ^int32(YUV_MASK2) == 0 {
  54672 			v28 = v25 >> int32(YUV_FIX2)
  54673 		} else {
  54674 			if v25 < 0 {
  54675 				v29 = 0
  54676 			} else {
  54677 				v29 = int32(255)
  54678 			}
  54679 			v28 = v29
  54680 		}
  54681 		v26 = v28
  54682 		goto _108
  54683 	_108:
  54684 		v17 = v26
  54685 		goto _99
  54686 	_99:
  54687 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54688 		v32 = v2 * int32(19077) >> int32(8)
  54689 		goto _114
  54690 	_114:
  54691 		v34 = v3 * int32(33050) >> int32(8)
  54692 		goto _116
  54693 	_116:
  54694 		v36 = v32 + v34 - int32(17685)
  54695 		if v36 & ^int32(YUV_MASK2) == 0 {
  54696 			v39 = v36 >> int32(YUV_FIX2)
  54697 		} else {
  54698 			if v36 < 0 {
  54699 				v40 = 0
  54700 			} else {
  54701 				v40 = int32(255)
  54702 			}
  54703 			v39 = v40
  54704 		}
  54705 		v37 = v39
  54706 		goto _119
  54707 	_119:
  54708 		v30 = v37
  54709 		goto _112
  54710 	_112:
  54711 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54712 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54713 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  54714 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  54715 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  54716 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  54717 		v5 = v1
  54718 		v8 = v2 * int32(19077) >> int32(8)
  54719 		goto _130
  54720 	_130:
  54721 		v10 = v4 * int32(26149) >> int32(8)
  54722 		goto _132
  54723 	_132:
  54724 		v12 = v8 + v10 - int32(14234)
  54725 		if v12 & ^int32(YUV_MASK2) == 0 {
  54726 			v15 = v12 >> int32(YUV_FIX2)
  54727 		} else {
  54728 			if v12 < 0 {
  54729 				v16 = 0
  54730 			} else {
  54731 				v16 = int32(255)
  54732 			}
  54733 			v15 = v16
  54734 		}
  54735 		v13 = v15
  54736 		goto _135
  54737 	_135:
  54738 		v6 = v13
  54739 		goto _128
  54740 	_128:
  54741 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54742 		v19 = v2 * int32(19077) >> int32(8)
  54743 		goto _141
  54744 	_141:
  54745 		v21 = v3 * int32(6419) >> int32(8)
  54746 		goto _143
  54747 	_143:
  54748 		v23 = v4 * int32(13320) >> int32(8)
  54749 		goto _145
  54750 	_145:
  54751 		v25 = v19 - v21 - v23 + int32(8708)
  54752 		if v25 & ^int32(YUV_MASK2) == 0 {
  54753 			v28 = v25 >> int32(YUV_FIX2)
  54754 		} else {
  54755 			if v25 < 0 {
  54756 				v29 = 0
  54757 			} else {
  54758 				v29 = int32(255)
  54759 			}
  54760 			v28 = v29
  54761 		}
  54762 		v26 = v28
  54763 		goto _148
  54764 	_148:
  54765 		v17 = v26
  54766 		goto _139
  54767 	_139:
  54768 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54769 		v32 = v2 * int32(19077) >> int32(8)
  54770 		goto _154
  54771 	_154:
  54772 		v34 = v3 * int32(33050) >> int32(8)
  54773 		goto _156
  54774 	_156:
  54775 		v36 = v32 + v34 - int32(17685)
  54776 		if v36 & ^int32(YUV_MASK2) == 0 {
  54777 			v39 = v36 >> int32(YUV_FIX2)
  54778 		} else {
  54779 			if v36 < 0 {
  54780 				v40 = 0
  54781 			} else {
  54782 				v40 = int32(255)
  54783 			}
  54784 			v39 = v40
  54785 		}
  54786 		v37 = v39
  54787 		goto _159
  54788 	_159:
  54789 		v30 = v37
  54790 		goto _152
  54791 	_152:
  54792 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54793 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54794 		if bottom_y != libc.UintptrFromInt32(0) {
  54795 			uv03 = (diag_03 + l_uv) >> int32(1)
  54796 			uv11 = (diag_12 + uv) >> int32(1)
  54797 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  54798 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  54799 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  54800 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  54801 			v5 = v1
  54802 			v8 = v2 * int32(19077) >> int32(8)
  54803 			goto _170
  54804 		_170:
  54805 			v10 = v4 * int32(26149) >> int32(8)
  54806 			goto _172
  54807 		_172:
  54808 			v12 = v8 + v10 - int32(14234)
  54809 			if v12 & ^int32(YUV_MASK2) == 0 {
  54810 				v15 = v12 >> int32(YUV_FIX2)
  54811 			} else {
  54812 				if v12 < 0 {
  54813 					v16 = 0
  54814 				} else {
  54815 					v16 = int32(255)
  54816 				}
  54817 				v15 = v16
  54818 			}
  54819 			v13 = v15
  54820 			goto _175
  54821 		_175:
  54822 			v6 = v13
  54823 			goto _168
  54824 		_168:
  54825 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54826 			v19 = v2 * int32(19077) >> int32(8)
  54827 			goto _181
  54828 		_181:
  54829 			v21 = v3 * int32(6419) >> int32(8)
  54830 			goto _183
  54831 		_183:
  54832 			v23 = v4 * int32(13320) >> int32(8)
  54833 			goto _185
  54834 		_185:
  54835 			v25 = v19 - v21 - v23 + int32(8708)
  54836 			if v25 & ^int32(YUV_MASK2) == 0 {
  54837 				v28 = v25 >> int32(YUV_FIX2)
  54838 			} else {
  54839 				if v25 < 0 {
  54840 					v29 = 0
  54841 				} else {
  54842 					v29 = int32(255)
  54843 				}
  54844 				v28 = v29
  54845 			}
  54846 			v26 = v28
  54847 			goto _188
  54848 		_188:
  54849 			v17 = v26
  54850 			goto _179
  54851 		_179:
  54852 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54853 			v32 = v2 * int32(19077) >> int32(8)
  54854 			goto _194
  54855 		_194:
  54856 			v34 = v3 * int32(33050) >> int32(8)
  54857 			goto _196
  54858 		_196:
  54859 			v36 = v32 + v34 - int32(17685)
  54860 			if v36 & ^int32(YUV_MASK2) == 0 {
  54861 				v39 = v36 >> int32(YUV_FIX2)
  54862 			} else {
  54863 				if v36 < 0 {
  54864 					v40 = 0
  54865 				} else {
  54866 					v40 = int32(255)
  54867 				}
  54868 				v39 = v40
  54869 			}
  54870 			v37 = v39
  54871 			goto _199
  54872 		_199:
  54873 			v30 = v37
  54874 			goto _192
  54875 		_192:
  54876 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54877 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54878 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  54879 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  54880 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  54881 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  54882 			v5 = v1
  54883 			v8 = v2 * int32(19077) >> int32(8)
  54884 			goto _210
  54885 		_210:
  54886 			v10 = v4 * int32(26149) >> int32(8)
  54887 			goto _212
  54888 		_212:
  54889 			v12 = v8 + v10 - int32(14234)
  54890 			if v12 & ^int32(YUV_MASK2) == 0 {
  54891 				v15 = v12 >> int32(YUV_FIX2)
  54892 			} else {
  54893 				if v12 < 0 {
  54894 					v16 = 0
  54895 				} else {
  54896 					v16 = int32(255)
  54897 				}
  54898 				v15 = v16
  54899 			}
  54900 			v13 = v15
  54901 			goto _215
  54902 		_215:
  54903 			v6 = v13
  54904 			goto _208
  54905 		_208:
  54906 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54907 			v19 = v2 * int32(19077) >> int32(8)
  54908 			goto _221
  54909 		_221:
  54910 			v21 = v3 * int32(6419) >> int32(8)
  54911 			goto _223
  54912 		_223:
  54913 			v23 = v4 * int32(13320) >> int32(8)
  54914 			goto _225
  54915 		_225:
  54916 			v25 = v19 - v21 - v23 + int32(8708)
  54917 			if v25 & ^int32(YUV_MASK2) == 0 {
  54918 				v28 = v25 >> int32(YUV_FIX2)
  54919 			} else {
  54920 				if v25 < 0 {
  54921 					v29 = 0
  54922 				} else {
  54923 					v29 = int32(255)
  54924 				}
  54925 				v28 = v29
  54926 			}
  54927 			v26 = v28
  54928 			goto _228
  54929 		_228:
  54930 			v17 = v26
  54931 			goto _219
  54932 		_219:
  54933 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  54934 			v32 = v2 * int32(19077) >> int32(8)
  54935 			goto _234
  54936 		_234:
  54937 			v34 = v3 * int32(33050) >> int32(8)
  54938 			goto _236
  54939 		_236:
  54940 			v36 = v32 + v34 - int32(17685)
  54941 			if v36 & ^int32(YUV_MASK2) == 0 {
  54942 				v39 = v36 >> int32(YUV_FIX2)
  54943 			} else {
  54944 				if v36 < 0 {
  54945 					v40 = 0
  54946 				} else {
  54947 					v40 = int32(255)
  54948 				}
  54949 				v39 = v40
  54950 			}
  54951 			v37 = v39
  54952 			goto _239
  54953 		_239:
  54954 			v30 = v37
  54955 			goto _232
  54956 		_232:
  54957 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  54958 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  54959 		}
  54960 		tl_uv = t_uv
  54961 		l_uv = uv
  54962 		goto _81
  54963 	_81:
  54964 		;
  54965 		x = x + 1
  54966 	}
  54967 	if !(len1&libc.Int32FromInt32(1) != 0) {
  54968 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  54969 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  54970 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  54971 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  54972 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  54973 		v5 = v1
  54974 		v8 = v2 * int32(19077) >> int32(8)
  54975 		goto _250
  54976 	_250:
  54977 		v10 = v4 * int32(26149) >> int32(8)
  54978 		goto _252
  54979 	_252:
  54980 		v12 = v8 + v10 - int32(14234)
  54981 		if v12 & ^int32(YUV_MASK2) == 0 {
  54982 			v15 = v12 >> int32(YUV_FIX2)
  54983 		} else {
  54984 			if v12 < 0 {
  54985 				v16 = 0
  54986 			} else {
  54987 				v16 = int32(255)
  54988 			}
  54989 			v15 = v16
  54990 		}
  54991 		v13 = v15
  54992 		goto _255
  54993 	_255:
  54994 		v6 = v13
  54995 		goto _248
  54996 	_248:
  54997 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  54998 		v19 = v2 * int32(19077) >> int32(8)
  54999 		goto _261
  55000 	_261:
  55001 		v21 = v3 * int32(6419) >> int32(8)
  55002 		goto _263
  55003 	_263:
  55004 		v23 = v4 * int32(13320) >> int32(8)
  55005 		goto _265
  55006 	_265:
  55007 		v25 = v19 - v21 - v23 + int32(8708)
  55008 		if v25 & ^int32(YUV_MASK2) == 0 {
  55009 			v28 = v25 >> int32(YUV_FIX2)
  55010 		} else {
  55011 			if v25 < 0 {
  55012 				v29 = 0
  55013 			} else {
  55014 				v29 = int32(255)
  55015 			}
  55016 			v28 = v29
  55017 		}
  55018 		v26 = v28
  55019 		goto _268
  55020 	_268:
  55021 		v17 = v26
  55022 		goto _259
  55023 	_259:
  55024 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55025 		v32 = v2 * int32(19077) >> int32(8)
  55026 		goto _274
  55027 	_274:
  55028 		v34 = v3 * int32(33050) >> int32(8)
  55029 		goto _276
  55030 	_276:
  55031 		v36 = v32 + v34 - int32(17685)
  55032 		if v36 & ^int32(YUV_MASK2) == 0 {
  55033 			v39 = v36 >> int32(YUV_FIX2)
  55034 		} else {
  55035 			if v36 < 0 {
  55036 				v40 = 0
  55037 			} else {
  55038 				v40 = int32(255)
  55039 			}
  55040 			v39 = v40
  55041 		}
  55042 		v37 = v39
  55043 		goto _279
  55044 	_279:
  55045 		v30 = v37
  55046 		goto _272
  55047 	_272:
  55048 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55049 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55050 		if bottom_y != libc.UintptrFromInt32(0) {
  55051 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55052 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  55053 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  55054 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  55055 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  55056 			v5 = v1
  55057 			v8 = v2 * int32(19077) >> int32(8)
  55058 			goto _290
  55059 		_290:
  55060 			v10 = v4 * int32(26149) >> int32(8)
  55061 			goto _292
  55062 		_292:
  55063 			v12 = v8 + v10 - int32(14234)
  55064 			if v12 & ^int32(YUV_MASK2) == 0 {
  55065 				v15 = v12 >> int32(YUV_FIX2)
  55066 			} else {
  55067 				if v12 < 0 {
  55068 					v16 = 0
  55069 				} else {
  55070 					v16 = int32(255)
  55071 				}
  55072 				v15 = v16
  55073 			}
  55074 			v13 = v15
  55075 			goto _295
  55076 		_295:
  55077 			v6 = v13
  55078 			goto _288
  55079 		_288:
  55080 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55081 			v19 = v2 * int32(19077) >> int32(8)
  55082 			goto _301
  55083 		_301:
  55084 			v21 = v3 * int32(6419) >> int32(8)
  55085 			goto _303
  55086 		_303:
  55087 			v23 = v4 * int32(13320) >> int32(8)
  55088 			goto _305
  55089 		_305:
  55090 			v25 = v19 - v21 - v23 + int32(8708)
  55091 			if v25 & ^int32(YUV_MASK2) == 0 {
  55092 				v28 = v25 >> int32(YUV_FIX2)
  55093 			} else {
  55094 				if v25 < 0 {
  55095 					v29 = 0
  55096 				} else {
  55097 					v29 = int32(255)
  55098 				}
  55099 				v28 = v29
  55100 			}
  55101 			v26 = v28
  55102 			goto _308
  55103 		_308:
  55104 			v17 = v26
  55105 			goto _299
  55106 		_299:
  55107 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55108 			v32 = v2 * int32(19077) >> int32(8)
  55109 			goto _314
  55110 		_314:
  55111 			v34 = v3 * int32(33050) >> int32(8)
  55112 			goto _316
  55113 		_316:
  55114 			v36 = v32 + v34 - int32(17685)
  55115 			if v36 & ^int32(YUV_MASK2) == 0 {
  55116 				v39 = v36 >> int32(YUV_FIX2)
  55117 			} else {
  55118 				if v36 < 0 {
  55119 					v40 = 0
  55120 				} else {
  55121 					v40 = int32(255)
  55122 				}
  55123 				v39 = v40
  55124 			}
  55125 			v37 = v39
  55126 			goto _319
  55127 		_319:
  55128 			v30 = v37
  55129 			goto _312
  55130 		_312:
  55131 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55132 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55133 		}
  55134 	}
  55135 }
  55136 
  55137 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) {
  55138 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  55139 	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
  55140 	var v1, v5 uintptr
  55141 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  55142 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  55143 	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 */
  55144 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  55145 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55146 	v1 = top_dst
  55147 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  55148 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  55149 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  55150 	v5 = v1
  55151 	v8 = v2 * int32(19077) >> int32(8)
  55152 	goto _9
  55153 _9:
  55154 	v10 = v3 * int32(33050) >> int32(8)
  55155 	goto _11
  55156 _11:
  55157 	v12 = v8 + v10 - int32(17685)
  55158 	if v12 & ^int32(YUV_MASK2) == 0 {
  55159 		v15 = v12 >> int32(YUV_FIX2)
  55160 	} else {
  55161 		if v12 < 0 {
  55162 			v16 = 0
  55163 		} else {
  55164 			v16 = int32(255)
  55165 		}
  55166 		v15 = v16
  55167 	}
  55168 	v13 = v15
  55169 	goto _14
  55170 _14:
  55171 	v6 = v13
  55172 	goto _7
  55173 _7:
  55174 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55175 	v19 = v2 * int32(19077) >> int32(8)
  55176 	goto _20
  55177 _20:
  55178 	v21 = v3 * int32(6419) >> int32(8)
  55179 	goto _22
  55180 _22:
  55181 	v23 = v4 * int32(13320) >> int32(8)
  55182 	goto _24
  55183 _24:
  55184 	v25 = v19 - v21 - v23 + int32(8708)
  55185 	if v25 & ^int32(YUV_MASK2) == 0 {
  55186 		v28 = v25 >> int32(YUV_FIX2)
  55187 	} else {
  55188 		if v25 < 0 {
  55189 			v29 = 0
  55190 		} else {
  55191 			v29 = int32(255)
  55192 		}
  55193 		v28 = v29
  55194 	}
  55195 	v26 = v28
  55196 	goto _27
  55197 _27:
  55198 	v17 = v26
  55199 	goto _18
  55200 _18:
  55201 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55202 	v32 = v2 * int32(19077) >> int32(8)
  55203 	goto _33
  55204 _33:
  55205 	v34 = v4 * int32(26149) >> int32(8)
  55206 	goto _35
  55207 _35:
  55208 	v36 = v32 + v34 - int32(14234)
  55209 	if v36 & ^int32(YUV_MASK2) == 0 {
  55210 		v39 = v36 >> int32(YUV_FIX2)
  55211 	} else {
  55212 		if v36 < 0 {
  55213 			v40 = 0
  55214 		} else {
  55215 			v40 = int32(255)
  55216 		}
  55217 		v39 = v40
  55218 	}
  55219 	v37 = v39
  55220 	goto _38
  55221 _38:
  55222 	v30 = v37
  55223 	goto _31
  55224 _31:
  55225 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55226 	**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55227 	if bottom_y != libc.UintptrFromInt32(0) {
  55228 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55229 		v1 = bottom_dst
  55230 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  55231 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  55232 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  55233 		v5 = v1
  55234 		v8 = v2 * int32(19077) >> int32(8)
  55235 		goto _49
  55236 	_49:
  55237 		v10 = v3 * int32(33050) >> int32(8)
  55238 		goto _51
  55239 	_51:
  55240 		v12 = v8 + v10 - int32(17685)
  55241 		if v12 & ^int32(YUV_MASK2) == 0 {
  55242 			v15 = v12 >> int32(YUV_FIX2)
  55243 		} else {
  55244 			if v12 < 0 {
  55245 				v16 = 0
  55246 			} else {
  55247 				v16 = int32(255)
  55248 			}
  55249 			v15 = v16
  55250 		}
  55251 		v13 = v15
  55252 		goto _54
  55253 	_54:
  55254 		v6 = v13
  55255 		goto _47
  55256 	_47:
  55257 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55258 		v19 = v2 * int32(19077) >> int32(8)
  55259 		goto _60
  55260 	_60:
  55261 		v21 = v3 * int32(6419) >> int32(8)
  55262 		goto _62
  55263 	_62:
  55264 		v23 = v4 * int32(13320) >> int32(8)
  55265 		goto _64
  55266 	_64:
  55267 		v25 = v19 - v21 - v23 + int32(8708)
  55268 		if v25 & ^int32(YUV_MASK2) == 0 {
  55269 			v28 = v25 >> int32(YUV_FIX2)
  55270 		} else {
  55271 			if v25 < 0 {
  55272 				v29 = 0
  55273 			} else {
  55274 				v29 = int32(255)
  55275 			}
  55276 			v28 = v29
  55277 		}
  55278 		v26 = v28
  55279 		goto _67
  55280 	_67:
  55281 		v17 = v26
  55282 		goto _58
  55283 	_58:
  55284 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55285 		v32 = v2 * int32(19077) >> int32(8)
  55286 		goto _73
  55287 	_73:
  55288 		v34 = v4 * int32(26149) >> int32(8)
  55289 		goto _75
  55290 	_75:
  55291 		v36 = v32 + v34 - int32(14234)
  55292 		if v36 & ^int32(YUV_MASK2) == 0 {
  55293 			v39 = v36 >> int32(YUV_FIX2)
  55294 		} else {
  55295 			if v36 < 0 {
  55296 				v40 = 0
  55297 			} else {
  55298 				v40 = int32(255)
  55299 			}
  55300 			v39 = v40
  55301 		}
  55302 		v37 = v39
  55303 		goto _78
  55304 	_78:
  55305 		v30 = v37
  55306 		goto _71
  55307 	_71:
  55308 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55309 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55310 	}
  55311 	x = int32(1)
  55312 	for {
  55313 		if !(x <= last_pixel_pair) {
  55314 			break
  55315 		}
  55316 		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 */
  55317 		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*/
  55318 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  55319 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  55320 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  55321 		uv02 = (diag_12 + tl_uv) >> int32(1)
  55322 		uv1 = (diag_03 + t_uv) >> int32(1)
  55323 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  55324 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  55325 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  55326 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  55327 		v5 = v1
  55328 		v8 = v2 * int32(19077) >> int32(8)
  55329 		goto _90
  55330 	_90:
  55331 		v10 = v3 * int32(33050) >> int32(8)
  55332 		goto _92
  55333 	_92:
  55334 		v12 = v8 + v10 - int32(17685)
  55335 		if v12 & ^int32(YUV_MASK2) == 0 {
  55336 			v15 = v12 >> int32(YUV_FIX2)
  55337 		} else {
  55338 			if v12 < 0 {
  55339 				v16 = 0
  55340 			} else {
  55341 				v16 = int32(255)
  55342 			}
  55343 			v15 = v16
  55344 		}
  55345 		v13 = v15
  55346 		goto _95
  55347 	_95:
  55348 		v6 = v13
  55349 		goto _88
  55350 	_88:
  55351 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55352 		v19 = v2 * int32(19077) >> int32(8)
  55353 		goto _101
  55354 	_101:
  55355 		v21 = v3 * int32(6419) >> int32(8)
  55356 		goto _103
  55357 	_103:
  55358 		v23 = v4 * int32(13320) >> int32(8)
  55359 		goto _105
  55360 	_105:
  55361 		v25 = v19 - v21 - v23 + int32(8708)
  55362 		if v25 & ^int32(YUV_MASK2) == 0 {
  55363 			v28 = v25 >> int32(YUV_FIX2)
  55364 		} else {
  55365 			if v25 < 0 {
  55366 				v29 = 0
  55367 			} else {
  55368 				v29 = int32(255)
  55369 			}
  55370 			v28 = v29
  55371 		}
  55372 		v26 = v28
  55373 		goto _108
  55374 	_108:
  55375 		v17 = v26
  55376 		goto _99
  55377 	_99:
  55378 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55379 		v32 = v2 * int32(19077) >> int32(8)
  55380 		goto _114
  55381 	_114:
  55382 		v34 = v4 * int32(26149) >> int32(8)
  55383 		goto _116
  55384 	_116:
  55385 		v36 = v32 + v34 - int32(14234)
  55386 		if v36 & ^int32(YUV_MASK2) == 0 {
  55387 			v39 = v36 >> int32(YUV_FIX2)
  55388 		} else {
  55389 			if v36 < 0 {
  55390 				v40 = 0
  55391 			} else {
  55392 				v40 = int32(255)
  55393 			}
  55394 			v39 = v40
  55395 		}
  55396 		v37 = v39
  55397 		goto _119
  55398 	_119:
  55399 		v30 = v37
  55400 		goto _112
  55401 	_112:
  55402 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55403 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55404 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  55405 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  55406 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  55407 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  55408 		v5 = v1
  55409 		v8 = v2 * int32(19077) >> int32(8)
  55410 		goto _130
  55411 	_130:
  55412 		v10 = v3 * int32(33050) >> int32(8)
  55413 		goto _132
  55414 	_132:
  55415 		v12 = v8 + v10 - int32(17685)
  55416 		if v12 & ^int32(YUV_MASK2) == 0 {
  55417 			v15 = v12 >> int32(YUV_FIX2)
  55418 		} else {
  55419 			if v12 < 0 {
  55420 				v16 = 0
  55421 			} else {
  55422 				v16 = int32(255)
  55423 			}
  55424 			v15 = v16
  55425 		}
  55426 		v13 = v15
  55427 		goto _135
  55428 	_135:
  55429 		v6 = v13
  55430 		goto _128
  55431 	_128:
  55432 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55433 		v19 = v2 * int32(19077) >> int32(8)
  55434 		goto _141
  55435 	_141:
  55436 		v21 = v3 * int32(6419) >> int32(8)
  55437 		goto _143
  55438 	_143:
  55439 		v23 = v4 * int32(13320) >> int32(8)
  55440 		goto _145
  55441 	_145:
  55442 		v25 = v19 - v21 - v23 + int32(8708)
  55443 		if v25 & ^int32(YUV_MASK2) == 0 {
  55444 			v28 = v25 >> int32(YUV_FIX2)
  55445 		} else {
  55446 			if v25 < 0 {
  55447 				v29 = 0
  55448 			} else {
  55449 				v29 = int32(255)
  55450 			}
  55451 			v28 = v29
  55452 		}
  55453 		v26 = v28
  55454 		goto _148
  55455 	_148:
  55456 		v17 = v26
  55457 		goto _139
  55458 	_139:
  55459 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55460 		v32 = v2 * int32(19077) >> int32(8)
  55461 		goto _154
  55462 	_154:
  55463 		v34 = v4 * int32(26149) >> int32(8)
  55464 		goto _156
  55465 	_156:
  55466 		v36 = v32 + v34 - int32(14234)
  55467 		if v36 & ^int32(YUV_MASK2) == 0 {
  55468 			v39 = v36 >> int32(YUV_FIX2)
  55469 		} else {
  55470 			if v36 < 0 {
  55471 				v40 = 0
  55472 			} else {
  55473 				v40 = int32(255)
  55474 			}
  55475 			v39 = v40
  55476 		}
  55477 		v37 = v39
  55478 		goto _159
  55479 	_159:
  55480 		v30 = v37
  55481 		goto _152
  55482 	_152:
  55483 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55484 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55485 		if bottom_y != libc.UintptrFromInt32(0) {
  55486 			uv03 = (diag_03 + l_uv) >> int32(1)
  55487 			uv11 = (diag_12 + uv) >> int32(1)
  55488 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  55489 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  55490 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  55491 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  55492 			v5 = v1
  55493 			v8 = v2 * int32(19077) >> int32(8)
  55494 			goto _170
  55495 		_170:
  55496 			v10 = v3 * int32(33050) >> int32(8)
  55497 			goto _172
  55498 		_172:
  55499 			v12 = v8 + v10 - int32(17685)
  55500 			if v12 & ^int32(YUV_MASK2) == 0 {
  55501 				v15 = v12 >> int32(YUV_FIX2)
  55502 			} else {
  55503 				if v12 < 0 {
  55504 					v16 = 0
  55505 				} else {
  55506 					v16 = int32(255)
  55507 				}
  55508 				v15 = v16
  55509 			}
  55510 			v13 = v15
  55511 			goto _175
  55512 		_175:
  55513 			v6 = v13
  55514 			goto _168
  55515 		_168:
  55516 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55517 			v19 = v2 * int32(19077) >> int32(8)
  55518 			goto _181
  55519 		_181:
  55520 			v21 = v3 * int32(6419) >> int32(8)
  55521 			goto _183
  55522 		_183:
  55523 			v23 = v4 * int32(13320) >> int32(8)
  55524 			goto _185
  55525 		_185:
  55526 			v25 = v19 - v21 - v23 + int32(8708)
  55527 			if v25 & ^int32(YUV_MASK2) == 0 {
  55528 				v28 = v25 >> int32(YUV_FIX2)
  55529 			} else {
  55530 				if v25 < 0 {
  55531 					v29 = 0
  55532 				} else {
  55533 					v29 = int32(255)
  55534 				}
  55535 				v28 = v29
  55536 			}
  55537 			v26 = v28
  55538 			goto _188
  55539 		_188:
  55540 			v17 = v26
  55541 			goto _179
  55542 		_179:
  55543 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55544 			v32 = v2 * int32(19077) >> int32(8)
  55545 			goto _194
  55546 		_194:
  55547 			v34 = v4 * int32(26149) >> int32(8)
  55548 			goto _196
  55549 		_196:
  55550 			v36 = v32 + v34 - int32(14234)
  55551 			if v36 & ^int32(YUV_MASK2) == 0 {
  55552 				v39 = v36 >> int32(YUV_FIX2)
  55553 			} else {
  55554 				if v36 < 0 {
  55555 					v40 = 0
  55556 				} else {
  55557 					v40 = int32(255)
  55558 				}
  55559 				v39 = v40
  55560 			}
  55561 			v37 = v39
  55562 			goto _199
  55563 		_199:
  55564 			v30 = v37
  55565 			goto _192
  55566 		_192:
  55567 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55568 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55569 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  55570 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  55571 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  55572 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  55573 			v5 = v1
  55574 			v8 = v2 * int32(19077) >> int32(8)
  55575 			goto _210
  55576 		_210:
  55577 			v10 = v3 * int32(33050) >> int32(8)
  55578 			goto _212
  55579 		_212:
  55580 			v12 = v8 + v10 - int32(17685)
  55581 			if v12 & ^int32(YUV_MASK2) == 0 {
  55582 				v15 = v12 >> int32(YUV_FIX2)
  55583 			} else {
  55584 				if v12 < 0 {
  55585 					v16 = 0
  55586 				} else {
  55587 					v16 = int32(255)
  55588 				}
  55589 				v15 = v16
  55590 			}
  55591 			v13 = v15
  55592 			goto _215
  55593 		_215:
  55594 			v6 = v13
  55595 			goto _208
  55596 		_208:
  55597 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55598 			v19 = v2 * int32(19077) >> int32(8)
  55599 			goto _221
  55600 		_221:
  55601 			v21 = v3 * int32(6419) >> int32(8)
  55602 			goto _223
  55603 		_223:
  55604 			v23 = v4 * int32(13320) >> int32(8)
  55605 			goto _225
  55606 		_225:
  55607 			v25 = v19 - v21 - v23 + int32(8708)
  55608 			if v25 & ^int32(YUV_MASK2) == 0 {
  55609 				v28 = v25 >> int32(YUV_FIX2)
  55610 			} else {
  55611 				if v25 < 0 {
  55612 					v29 = 0
  55613 				} else {
  55614 					v29 = int32(255)
  55615 				}
  55616 				v28 = v29
  55617 			}
  55618 			v26 = v28
  55619 			goto _228
  55620 		_228:
  55621 			v17 = v26
  55622 			goto _219
  55623 		_219:
  55624 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55625 			v32 = v2 * int32(19077) >> int32(8)
  55626 			goto _234
  55627 		_234:
  55628 			v34 = v4 * int32(26149) >> int32(8)
  55629 			goto _236
  55630 		_236:
  55631 			v36 = v32 + v34 - int32(14234)
  55632 			if v36 & ^int32(YUV_MASK2) == 0 {
  55633 				v39 = v36 >> int32(YUV_FIX2)
  55634 			} else {
  55635 				if v36 < 0 {
  55636 					v40 = 0
  55637 				} else {
  55638 					v40 = int32(255)
  55639 				}
  55640 				v39 = v40
  55641 			}
  55642 			v37 = v39
  55643 			goto _239
  55644 		_239:
  55645 			v30 = v37
  55646 			goto _232
  55647 		_232:
  55648 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55649 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55650 		}
  55651 		tl_uv = t_uv
  55652 		l_uv = uv
  55653 		goto _81
  55654 	_81:
  55655 		;
  55656 		x = x + 1
  55657 	}
  55658 	if !(len1&libc.Int32FromInt32(1) != 0) {
  55659 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55660 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  55661 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  55662 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  55663 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  55664 		v5 = v1
  55665 		v8 = v2 * int32(19077) >> int32(8)
  55666 		goto _250
  55667 	_250:
  55668 		v10 = v3 * int32(33050) >> int32(8)
  55669 		goto _252
  55670 	_252:
  55671 		v12 = v8 + v10 - int32(17685)
  55672 		if v12 & ^int32(YUV_MASK2) == 0 {
  55673 			v15 = v12 >> int32(YUV_FIX2)
  55674 		} else {
  55675 			if v12 < 0 {
  55676 				v16 = 0
  55677 			} else {
  55678 				v16 = int32(255)
  55679 			}
  55680 			v15 = v16
  55681 		}
  55682 		v13 = v15
  55683 		goto _255
  55684 	_255:
  55685 		v6 = v13
  55686 		goto _248
  55687 	_248:
  55688 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55689 		v19 = v2 * int32(19077) >> int32(8)
  55690 		goto _261
  55691 	_261:
  55692 		v21 = v3 * int32(6419) >> int32(8)
  55693 		goto _263
  55694 	_263:
  55695 		v23 = v4 * int32(13320) >> int32(8)
  55696 		goto _265
  55697 	_265:
  55698 		v25 = v19 - v21 - v23 + int32(8708)
  55699 		if v25 & ^int32(YUV_MASK2) == 0 {
  55700 			v28 = v25 >> int32(YUV_FIX2)
  55701 		} else {
  55702 			if v25 < 0 {
  55703 				v29 = 0
  55704 			} else {
  55705 				v29 = int32(255)
  55706 			}
  55707 			v28 = v29
  55708 		}
  55709 		v26 = v28
  55710 		goto _268
  55711 	_268:
  55712 		v17 = v26
  55713 		goto _259
  55714 	_259:
  55715 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55716 		v32 = v2 * int32(19077) >> int32(8)
  55717 		goto _274
  55718 	_274:
  55719 		v34 = v4 * int32(26149) >> int32(8)
  55720 		goto _276
  55721 	_276:
  55722 		v36 = v32 + v34 - int32(14234)
  55723 		if v36 & ^int32(YUV_MASK2) == 0 {
  55724 			v39 = v36 >> int32(YUV_FIX2)
  55725 		} else {
  55726 			if v36 < 0 {
  55727 				v40 = 0
  55728 			} else {
  55729 				v40 = int32(255)
  55730 			}
  55731 			v39 = v40
  55732 		}
  55733 		v37 = v39
  55734 		goto _279
  55735 	_279:
  55736 		v30 = v37
  55737 		goto _272
  55738 	_272:
  55739 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55740 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55741 		if bottom_y != libc.UintptrFromInt32(0) {
  55742 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55743 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  55744 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  55745 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  55746 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  55747 			v5 = v1
  55748 			v8 = v2 * int32(19077) >> int32(8)
  55749 			goto _290
  55750 		_290:
  55751 			v10 = v3 * int32(33050) >> int32(8)
  55752 			goto _292
  55753 		_292:
  55754 			v12 = v8 + v10 - int32(17685)
  55755 			if v12 & ^int32(YUV_MASK2) == 0 {
  55756 				v15 = v12 >> int32(YUV_FIX2)
  55757 			} else {
  55758 				if v12 < 0 {
  55759 					v16 = 0
  55760 				} else {
  55761 					v16 = int32(255)
  55762 				}
  55763 				v15 = v16
  55764 			}
  55765 			v13 = v15
  55766 			goto _295
  55767 		_295:
  55768 			v6 = v13
  55769 			goto _288
  55770 		_288:
  55771 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55772 			v19 = v2 * int32(19077) >> int32(8)
  55773 			goto _301
  55774 		_301:
  55775 			v21 = v3 * int32(6419) >> int32(8)
  55776 			goto _303
  55777 		_303:
  55778 			v23 = v4 * int32(13320) >> int32(8)
  55779 			goto _305
  55780 		_305:
  55781 			v25 = v19 - v21 - v23 + int32(8708)
  55782 			if v25 & ^int32(YUV_MASK2) == 0 {
  55783 				v28 = v25 >> int32(YUV_FIX2)
  55784 			} else {
  55785 				if v25 < 0 {
  55786 					v29 = 0
  55787 				} else {
  55788 					v29 = int32(255)
  55789 				}
  55790 				v28 = v29
  55791 			}
  55792 			v26 = v28
  55793 			goto _308
  55794 		_308:
  55795 			v17 = v26
  55796 			goto _299
  55797 		_299:
  55798 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55799 			v32 = v2 * int32(19077) >> int32(8)
  55800 			goto _314
  55801 		_314:
  55802 			v34 = v4 * int32(26149) >> int32(8)
  55803 			goto _316
  55804 		_316:
  55805 			v36 = v32 + v34 - int32(14234)
  55806 			if v36 & ^int32(YUV_MASK2) == 0 {
  55807 				v39 = v36 >> int32(YUV_FIX2)
  55808 			} else {
  55809 				if v36 < 0 {
  55810 					v40 = 0
  55811 				} else {
  55812 					v40 = int32(255)
  55813 				}
  55814 				v39 = v40
  55815 			}
  55816 			v37 = v39
  55817 			goto _319
  55818 		_319:
  55819 			v30 = v37
  55820 			goto _312
  55821 		_312:
  55822 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55823 			**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  55824 		}
  55825 	}
  55826 }
  55827 
  55828 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) {
  55829 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  55830 	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
  55831 	var v1, v5 uintptr
  55832 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  55833 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  55834 	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 */
  55835 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  55836 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  55837 	v1 = top_dst
  55838 	**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  55839 	v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  55840 	v3 = libc.Int32FromUint8(uint8(uv0 & uint32(0xff)))
  55841 	v4 = libc.Int32FromUint8(uint8(uv0 >> libc.Int32FromInt32(16)))
  55842 	v5 = v1 + uintptr(1)
  55843 	v8 = v2 * int32(19077) >> int32(8)
  55844 	goto _9
  55845 _9:
  55846 	v10 = v4 * int32(26149) >> int32(8)
  55847 	goto _11
  55848 _11:
  55849 	v12 = v8 + v10 - int32(14234)
  55850 	if v12 & ^int32(YUV_MASK2) == 0 {
  55851 		v15 = v12 >> int32(YUV_FIX2)
  55852 	} else {
  55853 		if v12 < 0 {
  55854 			v16 = 0
  55855 		} else {
  55856 			v16 = int32(255)
  55857 		}
  55858 		v15 = v16
  55859 	}
  55860 	v13 = v15
  55861 	goto _14
  55862 _14:
  55863 	v6 = v13
  55864 	goto _7
  55865 _7:
  55866 	**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55867 	v19 = v2 * int32(19077) >> int32(8)
  55868 	goto _20
  55869 _20:
  55870 	v21 = v3 * int32(6419) >> int32(8)
  55871 	goto _22
  55872 _22:
  55873 	v23 = v4 * int32(13320) >> int32(8)
  55874 	goto _24
  55875 _24:
  55876 	v25 = v19 - v21 - v23 + int32(8708)
  55877 	if v25 & ^int32(YUV_MASK2) == 0 {
  55878 		v28 = v25 >> int32(YUV_FIX2)
  55879 	} else {
  55880 		if v25 < 0 {
  55881 			v29 = 0
  55882 		} else {
  55883 			v29 = int32(255)
  55884 		}
  55885 		v28 = v29
  55886 	}
  55887 	v26 = v28
  55888 	goto _27
  55889 _27:
  55890 	v17 = v26
  55891 	goto _18
  55892 _18:
  55893 	**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55894 	v32 = v2 * int32(19077) >> int32(8)
  55895 	goto _33
  55896 _33:
  55897 	v34 = v3 * int32(33050) >> int32(8)
  55898 	goto _35
  55899 _35:
  55900 	v36 = v32 + v34 - int32(17685)
  55901 	if v36 & ^int32(YUV_MASK2) == 0 {
  55902 		v39 = v36 >> int32(YUV_FIX2)
  55903 	} else {
  55904 		if v36 < 0 {
  55905 			v40 = 0
  55906 		} else {
  55907 			v40 = int32(255)
  55908 		}
  55909 		v39 = v40
  55910 	}
  55911 	v37 = v39
  55912 	goto _38
  55913 _38:
  55914 	v30 = v37
  55915 	goto _31
  55916 _31:
  55917 	**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  55918 	if bottom_y != libc.UintptrFromInt32(0) {
  55919 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  55920 		v1 = bottom_dst
  55921 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  55922 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  55923 		v3 = libc.Int32FromUint8(uint8(uv01 & uint32(0xff)))
  55924 		v4 = libc.Int32FromUint8(uint8(uv01 >> libc.Int32FromInt32(16)))
  55925 		v5 = v1 + uintptr(1)
  55926 		v8 = v2 * int32(19077) >> int32(8)
  55927 		goto _49
  55928 	_49:
  55929 		v10 = v4 * int32(26149) >> int32(8)
  55930 		goto _51
  55931 	_51:
  55932 		v12 = v8 + v10 - int32(14234)
  55933 		if v12 & ^int32(YUV_MASK2) == 0 {
  55934 			v15 = v12 >> int32(YUV_FIX2)
  55935 		} else {
  55936 			if v12 < 0 {
  55937 				v16 = 0
  55938 			} else {
  55939 				v16 = int32(255)
  55940 			}
  55941 			v15 = v16
  55942 		}
  55943 		v13 = v15
  55944 		goto _54
  55945 	_54:
  55946 		v6 = v13
  55947 		goto _47
  55948 	_47:
  55949 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  55950 		v19 = v2 * int32(19077) >> int32(8)
  55951 		goto _60
  55952 	_60:
  55953 		v21 = v3 * int32(6419) >> int32(8)
  55954 		goto _62
  55955 	_62:
  55956 		v23 = v4 * int32(13320) >> int32(8)
  55957 		goto _64
  55958 	_64:
  55959 		v25 = v19 - v21 - v23 + int32(8708)
  55960 		if v25 & ^int32(YUV_MASK2) == 0 {
  55961 			v28 = v25 >> int32(YUV_FIX2)
  55962 		} else {
  55963 			if v25 < 0 {
  55964 				v29 = 0
  55965 			} else {
  55966 				v29 = int32(255)
  55967 			}
  55968 			v28 = v29
  55969 		}
  55970 		v26 = v28
  55971 		goto _67
  55972 	_67:
  55973 		v17 = v26
  55974 		goto _58
  55975 	_58:
  55976 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  55977 		v32 = v2 * int32(19077) >> int32(8)
  55978 		goto _73
  55979 	_73:
  55980 		v34 = v3 * int32(33050) >> int32(8)
  55981 		goto _75
  55982 	_75:
  55983 		v36 = v32 + v34 - int32(17685)
  55984 		if v36 & ^int32(YUV_MASK2) == 0 {
  55985 			v39 = v36 >> int32(YUV_FIX2)
  55986 		} else {
  55987 			if v36 < 0 {
  55988 				v40 = 0
  55989 			} else {
  55990 				v40 = int32(255)
  55991 			}
  55992 			v39 = v40
  55993 		}
  55994 		v37 = v39
  55995 		goto _78
  55996 	_78:
  55997 		v30 = v37
  55998 		goto _71
  55999 	_71:
  56000 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56001 	}
  56002 	x = int32(1)
  56003 	for {
  56004 		if !(x <= last_pixel_pair) {
  56005 			break
  56006 		}
  56007 		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 */
  56008 		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*/
  56009 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  56010 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  56011 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  56012 		uv02 = (diag_12 + tl_uv) >> int32(1)
  56013 		uv1 = (diag_03 + t_uv) >> int32(1)
  56014 		v1 = top_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  56015 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56016 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  56017 		v3 = libc.Int32FromUint8(uint8(uv02 & uint32(0xff)))
  56018 		v4 = libc.Int32FromUint8(uint8(uv02 >> libc.Int32FromInt32(16)))
  56019 		v5 = v1 + uintptr(1)
  56020 		v8 = v2 * int32(19077) >> int32(8)
  56021 		goto _90
  56022 	_90:
  56023 		v10 = v4 * int32(26149) >> int32(8)
  56024 		goto _92
  56025 	_92:
  56026 		v12 = v8 + v10 - int32(14234)
  56027 		if v12 & ^int32(YUV_MASK2) == 0 {
  56028 			v15 = v12 >> int32(YUV_FIX2)
  56029 		} else {
  56030 			if v12 < 0 {
  56031 				v16 = 0
  56032 			} else {
  56033 				v16 = int32(255)
  56034 			}
  56035 			v15 = v16
  56036 		}
  56037 		v13 = v15
  56038 		goto _95
  56039 	_95:
  56040 		v6 = v13
  56041 		goto _88
  56042 	_88:
  56043 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56044 		v19 = v2 * int32(19077) >> int32(8)
  56045 		goto _101
  56046 	_101:
  56047 		v21 = v3 * int32(6419) >> int32(8)
  56048 		goto _103
  56049 	_103:
  56050 		v23 = v4 * int32(13320) >> int32(8)
  56051 		goto _105
  56052 	_105:
  56053 		v25 = v19 - v21 - v23 + int32(8708)
  56054 		if v25 & ^int32(YUV_MASK2) == 0 {
  56055 			v28 = v25 >> int32(YUV_FIX2)
  56056 		} else {
  56057 			if v25 < 0 {
  56058 				v29 = 0
  56059 			} else {
  56060 				v29 = int32(255)
  56061 			}
  56062 			v28 = v29
  56063 		}
  56064 		v26 = v28
  56065 		goto _108
  56066 	_108:
  56067 		v17 = v26
  56068 		goto _99
  56069 	_99:
  56070 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56071 		v32 = v2 * int32(19077) >> int32(8)
  56072 		goto _114
  56073 	_114:
  56074 		v34 = v3 * int32(33050) >> int32(8)
  56075 		goto _116
  56076 	_116:
  56077 		v36 = v32 + v34 - int32(17685)
  56078 		if v36 & ^int32(YUV_MASK2) == 0 {
  56079 			v39 = v36 >> int32(YUV_FIX2)
  56080 		} else {
  56081 			if v36 < 0 {
  56082 				v40 = 0
  56083 			} else {
  56084 				v40 = int32(255)
  56085 			}
  56086 			v39 = v40
  56087 		}
  56088 		v37 = v39
  56089 		goto _119
  56090 	_119:
  56091 		v30 = v37
  56092 		goto _112
  56093 	_112:
  56094 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56095 		v1 = top_dst + uintptr((int32(2)*x-0)*int32(4))
  56096 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56097 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  56098 		v3 = libc.Int32FromUint8(uint8(uv1 & uint32(0xff)))
  56099 		v4 = libc.Int32FromUint8(uint8(uv1 >> libc.Int32FromInt32(16)))
  56100 		v5 = v1 + uintptr(1)
  56101 		v8 = v2 * int32(19077) >> int32(8)
  56102 		goto _130
  56103 	_130:
  56104 		v10 = v4 * int32(26149) >> int32(8)
  56105 		goto _132
  56106 	_132:
  56107 		v12 = v8 + v10 - int32(14234)
  56108 		if v12 & ^int32(YUV_MASK2) == 0 {
  56109 			v15 = v12 >> int32(YUV_FIX2)
  56110 		} else {
  56111 			if v12 < 0 {
  56112 				v16 = 0
  56113 			} else {
  56114 				v16 = int32(255)
  56115 			}
  56116 			v15 = v16
  56117 		}
  56118 		v13 = v15
  56119 		goto _135
  56120 	_135:
  56121 		v6 = v13
  56122 		goto _128
  56123 	_128:
  56124 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56125 		v19 = v2 * int32(19077) >> int32(8)
  56126 		goto _141
  56127 	_141:
  56128 		v21 = v3 * int32(6419) >> int32(8)
  56129 		goto _143
  56130 	_143:
  56131 		v23 = v4 * int32(13320) >> int32(8)
  56132 		goto _145
  56133 	_145:
  56134 		v25 = v19 - v21 - v23 + int32(8708)
  56135 		if v25 & ^int32(YUV_MASK2) == 0 {
  56136 			v28 = v25 >> int32(YUV_FIX2)
  56137 		} else {
  56138 			if v25 < 0 {
  56139 				v29 = 0
  56140 			} else {
  56141 				v29 = int32(255)
  56142 			}
  56143 			v28 = v29
  56144 		}
  56145 		v26 = v28
  56146 		goto _148
  56147 	_148:
  56148 		v17 = v26
  56149 		goto _139
  56150 	_139:
  56151 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56152 		v32 = v2 * int32(19077) >> int32(8)
  56153 		goto _154
  56154 	_154:
  56155 		v34 = v3 * int32(33050) >> int32(8)
  56156 		goto _156
  56157 	_156:
  56158 		v36 = v32 + v34 - int32(17685)
  56159 		if v36 & ^int32(YUV_MASK2) == 0 {
  56160 			v39 = v36 >> int32(YUV_FIX2)
  56161 		} else {
  56162 			if v36 < 0 {
  56163 				v40 = 0
  56164 			} else {
  56165 				v40 = int32(255)
  56166 			}
  56167 			v39 = v40
  56168 		}
  56169 		v37 = v39
  56170 		goto _159
  56171 	_159:
  56172 		v30 = v37
  56173 		goto _152
  56174 	_152:
  56175 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56176 		if bottom_y != libc.UintptrFromInt32(0) {
  56177 			uv03 = (diag_03 + l_uv) >> int32(1)
  56178 			uv11 = (diag_12 + uv) >> int32(1)
  56179 			v1 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(4))
  56180 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56181 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  56182 			v3 = libc.Int32FromUint8(uint8(uv03 & uint32(0xff)))
  56183 			v4 = libc.Int32FromUint8(uint8(uv03 >> libc.Int32FromInt32(16)))
  56184 			v5 = v1 + uintptr(1)
  56185 			v8 = v2 * int32(19077) >> int32(8)
  56186 			goto _170
  56187 		_170:
  56188 			v10 = v4 * int32(26149) >> int32(8)
  56189 			goto _172
  56190 		_172:
  56191 			v12 = v8 + v10 - int32(14234)
  56192 			if v12 & ^int32(YUV_MASK2) == 0 {
  56193 				v15 = v12 >> int32(YUV_FIX2)
  56194 			} else {
  56195 				if v12 < 0 {
  56196 					v16 = 0
  56197 				} else {
  56198 					v16 = int32(255)
  56199 				}
  56200 				v15 = v16
  56201 			}
  56202 			v13 = v15
  56203 			goto _175
  56204 		_175:
  56205 			v6 = v13
  56206 			goto _168
  56207 		_168:
  56208 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56209 			v19 = v2 * int32(19077) >> int32(8)
  56210 			goto _181
  56211 		_181:
  56212 			v21 = v3 * int32(6419) >> int32(8)
  56213 			goto _183
  56214 		_183:
  56215 			v23 = v4 * int32(13320) >> int32(8)
  56216 			goto _185
  56217 		_185:
  56218 			v25 = v19 - v21 - v23 + int32(8708)
  56219 			if v25 & ^int32(YUV_MASK2) == 0 {
  56220 				v28 = v25 >> int32(YUV_FIX2)
  56221 			} else {
  56222 				if v25 < 0 {
  56223 					v29 = 0
  56224 				} else {
  56225 					v29 = int32(255)
  56226 				}
  56227 				v28 = v29
  56228 			}
  56229 			v26 = v28
  56230 			goto _188
  56231 		_188:
  56232 			v17 = v26
  56233 			goto _179
  56234 		_179:
  56235 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56236 			v32 = v2 * int32(19077) >> int32(8)
  56237 			goto _194
  56238 		_194:
  56239 			v34 = v3 * int32(33050) >> int32(8)
  56240 			goto _196
  56241 		_196:
  56242 			v36 = v32 + v34 - int32(17685)
  56243 			if v36 & ^int32(YUV_MASK2) == 0 {
  56244 				v39 = v36 >> int32(YUV_FIX2)
  56245 			} else {
  56246 				if v36 < 0 {
  56247 					v40 = 0
  56248 				} else {
  56249 					v40 = int32(255)
  56250 				}
  56251 				v39 = v40
  56252 			}
  56253 			v37 = v39
  56254 			goto _199
  56255 		_199:
  56256 			v30 = v37
  56257 			goto _192
  56258 		_192:
  56259 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56260 			v1 = bottom_dst + uintptr((int32(2)*x+0)*int32(4))
  56261 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56262 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  56263 			v3 = libc.Int32FromUint8(uint8(uv11 & uint32(0xff)))
  56264 			v4 = libc.Int32FromUint8(uint8(uv11 >> libc.Int32FromInt32(16)))
  56265 			v5 = v1 + uintptr(1)
  56266 			v8 = v2 * int32(19077) >> int32(8)
  56267 			goto _210
  56268 		_210:
  56269 			v10 = v4 * int32(26149) >> int32(8)
  56270 			goto _212
  56271 		_212:
  56272 			v12 = v8 + v10 - int32(14234)
  56273 			if v12 & ^int32(YUV_MASK2) == 0 {
  56274 				v15 = v12 >> int32(YUV_FIX2)
  56275 			} else {
  56276 				if v12 < 0 {
  56277 					v16 = 0
  56278 				} else {
  56279 					v16 = int32(255)
  56280 				}
  56281 				v15 = v16
  56282 			}
  56283 			v13 = v15
  56284 			goto _215
  56285 		_215:
  56286 			v6 = v13
  56287 			goto _208
  56288 		_208:
  56289 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56290 			v19 = v2 * int32(19077) >> int32(8)
  56291 			goto _221
  56292 		_221:
  56293 			v21 = v3 * int32(6419) >> int32(8)
  56294 			goto _223
  56295 		_223:
  56296 			v23 = v4 * int32(13320) >> int32(8)
  56297 			goto _225
  56298 		_225:
  56299 			v25 = v19 - v21 - v23 + int32(8708)
  56300 			if v25 & ^int32(YUV_MASK2) == 0 {
  56301 				v28 = v25 >> int32(YUV_FIX2)
  56302 			} else {
  56303 				if v25 < 0 {
  56304 					v29 = 0
  56305 				} else {
  56306 					v29 = int32(255)
  56307 				}
  56308 				v28 = v29
  56309 			}
  56310 			v26 = v28
  56311 			goto _228
  56312 		_228:
  56313 			v17 = v26
  56314 			goto _219
  56315 		_219:
  56316 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56317 			v32 = v2 * int32(19077) >> int32(8)
  56318 			goto _234
  56319 		_234:
  56320 			v34 = v3 * int32(33050) >> int32(8)
  56321 			goto _236
  56322 		_236:
  56323 			v36 = v32 + v34 - int32(17685)
  56324 			if v36 & ^int32(YUV_MASK2) == 0 {
  56325 				v39 = v36 >> int32(YUV_FIX2)
  56326 			} else {
  56327 				if v36 < 0 {
  56328 					v40 = 0
  56329 				} else {
  56330 					v40 = int32(255)
  56331 				}
  56332 				v39 = v40
  56333 			}
  56334 			v37 = v39
  56335 			goto _239
  56336 		_239:
  56337 			v30 = v37
  56338 			goto _232
  56339 		_232:
  56340 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56341 		}
  56342 		tl_uv = t_uv
  56343 		l_uv = uv
  56344 		goto _81
  56345 	_81:
  56346 		;
  56347 		x = x + 1
  56348 	}
  56349 	if !(len1&libc.Int32FromInt32(1) != 0) {
  56350 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  56351 		v1 = top_dst + uintptr((len1-int32(1))*int32(4))
  56352 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56353 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  56354 		v3 = libc.Int32FromUint8(uint8(uv04 & uint32(0xff)))
  56355 		v4 = libc.Int32FromUint8(uint8(uv04 >> libc.Int32FromInt32(16)))
  56356 		v5 = v1 + uintptr(1)
  56357 		v8 = v2 * int32(19077) >> int32(8)
  56358 		goto _250
  56359 	_250:
  56360 		v10 = v4 * int32(26149) >> int32(8)
  56361 		goto _252
  56362 	_252:
  56363 		v12 = v8 + v10 - int32(14234)
  56364 		if v12 & ^int32(YUV_MASK2) == 0 {
  56365 			v15 = v12 >> int32(YUV_FIX2)
  56366 		} else {
  56367 			if v12 < 0 {
  56368 				v16 = 0
  56369 			} else {
  56370 				v16 = int32(255)
  56371 			}
  56372 			v15 = v16
  56373 		}
  56374 		v13 = v15
  56375 		goto _255
  56376 	_255:
  56377 		v6 = v13
  56378 		goto _248
  56379 	_248:
  56380 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56381 		v19 = v2 * int32(19077) >> int32(8)
  56382 		goto _261
  56383 	_261:
  56384 		v21 = v3 * int32(6419) >> int32(8)
  56385 		goto _263
  56386 	_263:
  56387 		v23 = v4 * int32(13320) >> int32(8)
  56388 		goto _265
  56389 	_265:
  56390 		v25 = v19 - v21 - v23 + int32(8708)
  56391 		if v25 & ^int32(YUV_MASK2) == 0 {
  56392 			v28 = v25 >> int32(YUV_FIX2)
  56393 		} else {
  56394 			if v25 < 0 {
  56395 				v29 = 0
  56396 			} else {
  56397 				v29 = int32(255)
  56398 			}
  56399 			v28 = v29
  56400 		}
  56401 		v26 = v28
  56402 		goto _268
  56403 	_268:
  56404 		v17 = v26
  56405 		goto _259
  56406 	_259:
  56407 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56408 		v32 = v2 * int32(19077) >> int32(8)
  56409 		goto _274
  56410 	_274:
  56411 		v34 = v3 * int32(33050) >> int32(8)
  56412 		goto _276
  56413 	_276:
  56414 		v36 = v32 + v34 - int32(17685)
  56415 		if v36 & ^int32(YUV_MASK2) == 0 {
  56416 			v39 = v36 >> int32(YUV_FIX2)
  56417 		} else {
  56418 			if v36 < 0 {
  56419 				v40 = 0
  56420 			} else {
  56421 				v40 = int32(255)
  56422 			}
  56423 			v39 = v40
  56424 		}
  56425 		v37 = v39
  56426 		goto _279
  56427 	_279:
  56428 		v30 = v37
  56429 		goto _272
  56430 	_272:
  56431 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56432 		if bottom_y != libc.UintptrFromInt32(0) {
  56433 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  56434 			v1 = bottom_dst + uintptr((len1-int32(1))*int32(4))
  56435 			**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  56436 			v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  56437 			v3 = libc.Int32FromUint8(uint8(uv05 & uint32(0xff)))
  56438 			v4 = libc.Int32FromUint8(uint8(uv05 >> libc.Int32FromInt32(16)))
  56439 			v5 = v1 + uintptr(1)
  56440 			v8 = v2 * int32(19077) >> int32(8)
  56441 			goto _290
  56442 		_290:
  56443 			v10 = v4 * int32(26149) >> int32(8)
  56444 			goto _292
  56445 		_292:
  56446 			v12 = v8 + v10 - int32(14234)
  56447 			if v12 & ^int32(YUV_MASK2) == 0 {
  56448 				v15 = v12 >> int32(YUV_FIX2)
  56449 			} else {
  56450 				if v12 < 0 {
  56451 					v16 = 0
  56452 				} else {
  56453 					v16 = int32(255)
  56454 				}
  56455 				v15 = v16
  56456 			}
  56457 			v13 = v15
  56458 			goto _295
  56459 		_295:
  56460 			v6 = v13
  56461 			goto _288
  56462 		_288:
  56463 			**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v6)
  56464 			v19 = v2 * int32(19077) >> int32(8)
  56465 			goto _301
  56466 		_301:
  56467 			v21 = v3 * int32(6419) >> int32(8)
  56468 			goto _303
  56469 		_303:
  56470 			v23 = v4 * int32(13320) >> int32(8)
  56471 			goto _305
  56472 		_305:
  56473 			v25 = v19 - v21 - v23 + int32(8708)
  56474 			if v25 & ^int32(YUV_MASK2) == 0 {
  56475 				v28 = v25 >> int32(YUV_FIX2)
  56476 			} else {
  56477 				if v25 < 0 {
  56478 					v29 = 0
  56479 				} else {
  56480 					v29 = int32(255)
  56481 				}
  56482 				v28 = v29
  56483 			}
  56484 			v26 = v28
  56485 			goto _308
  56486 		_308:
  56487 			v17 = v26
  56488 			goto _299
  56489 		_299:
  56490 			**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  56491 			v32 = v2 * int32(19077) >> int32(8)
  56492 			goto _314
  56493 		_314:
  56494 			v34 = v3 * int32(33050) >> int32(8)
  56495 			goto _316
  56496 		_316:
  56497 			v36 = v32 + v34 - int32(17685)
  56498 			if v36 & ^int32(YUV_MASK2) == 0 {
  56499 				v39 = v36 >> int32(YUV_FIX2)
  56500 			} else {
  56501 				if v36 < 0 {
  56502 					v40 = 0
  56503 				} else {
  56504 					v40 = int32(255)
  56505 				}
  56506 				v39 = v40
  56507 			}
  56508 			v37 = v39
  56509 			goto _319
  56510 		_319:
  56511 			v30 = v37
  56512 			goto _312
  56513 		_312:
  56514 			**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  56515 		}
  56516 	}
  56517 }
  56518 
  56519 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) {
  56520 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  56521 	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
  56522 	var v4 uintptr
  56523 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  56524 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  56525 	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 */
  56526 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  56527 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  56528 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  56529 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  56530 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  56531 	v4 = top_dst
  56532 	v7 = v1 * int32(19077) >> int32(8)
  56533 	goto _8
  56534 _8:
  56535 	v9 = v3 * int32(26149) >> int32(8)
  56536 	goto _10
  56537 _10:
  56538 	v11 = v7 + v9 - int32(14234)
  56539 	if v11 & ^int32(YUV_MASK2) == 0 {
  56540 		v14 = v11 >> int32(YUV_FIX2)
  56541 	} else {
  56542 		if v11 < 0 {
  56543 			v15 = 0
  56544 		} else {
  56545 			v15 = int32(255)
  56546 		}
  56547 		v14 = v15
  56548 	}
  56549 	v12 = v14
  56550 	goto _13
  56551 _13:
  56552 	v5 = v12
  56553 	goto _6
  56554 _6:
  56555 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56556 	v18 = v1 * int32(19077) >> int32(8)
  56557 	goto _19
  56558 _19:
  56559 	v20 = v2 * int32(6419) >> int32(8)
  56560 	goto _21
  56561 _21:
  56562 	v22 = v3 * int32(13320) >> int32(8)
  56563 	goto _23
  56564 _23:
  56565 	v24 = v18 - v20 - v22 + int32(8708)
  56566 	if v24 & ^int32(YUV_MASK2) == 0 {
  56567 		v27 = v24 >> int32(YUV_FIX2)
  56568 	} else {
  56569 		if v24 < 0 {
  56570 			v28 = 0
  56571 		} else {
  56572 			v28 = int32(255)
  56573 		}
  56574 		v27 = v28
  56575 	}
  56576 	v25 = v27
  56577 	goto _26
  56578 _26:
  56579 	v16 = v25
  56580 	goto _17
  56581 _17:
  56582 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56583 	v31 = v1 * int32(19077) >> int32(8)
  56584 	goto _32
  56585 _32:
  56586 	v33 = v2 * int32(33050) >> int32(8)
  56587 	goto _34
  56588 _34:
  56589 	v35 = v31 + v33 - int32(17685)
  56590 	if v35 & ^int32(YUV_MASK2) == 0 {
  56591 		v38 = v35 >> int32(YUV_FIX2)
  56592 	} else {
  56593 		if v35 < 0 {
  56594 			v39 = 0
  56595 		} else {
  56596 			v39 = int32(255)
  56597 		}
  56598 		v38 = v39
  56599 	}
  56600 	v36 = v38
  56601 	goto _37
  56602 _37:
  56603 	v29 = v36
  56604 	goto _30
  56605 _30:
  56606 	**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56607 	if bottom_y != libc.UintptrFromInt32(0) {
  56608 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  56609 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  56610 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  56611 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  56612 		v4 = bottom_dst
  56613 		v7 = v1 * int32(19077) >> int32(8)
  56614 		goto _47
  56615 	_47:
  56616 		v9 = v3 * int32(26149) >> int32(8)
  56617 		goto _49
  56618 	_49:
  56619 		v11 = v7 + v9 - int32(14234)
  56620 		if v11 & ^int32(YUV_MASK2) == 0 {
  56621 			v14 = v11 >> int32(YUV_FIX2)
  56622 		} else {
  56623 			if v11 < 0 {
  56624 				v15 = 0
  56625 			} else {
  56626 				v15 = int32(255)
  56627 			}
  56628 			v14 = v15
  56629 		}
  56630 		v12 = v14
  56631 		goto _52
  56632 	_52:
  56633 		v5 = v12
  56634 		goto _45
  56635 	_45:
  56636 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56637 		v18 = v1 * int32(19077) >> int32(8)
  56638 		goto _58
  56639 	_58:
  56640 		v20 = v2 * int32(6419) >> int32(8)
  56641 		goto _60
  56642 	_60:
  56643 		v22 = v3 * int32(13320) >> int32(8)
  56644 		goto _62
  56645 	_62:
  56646 		v24 = v18 - v20 - v22 + int32(8708)
  56647 		if v24 & ^int32(YUV_MASK2) == 0 {
  56648 			v27 = v24 >> int32(YUV_FIX2)
  56649 		} else {
  56650 			if v24 < 0 {
  56651 				v28 = 0
  56652 			} else {
  56653 				v28 = int32(255)
  56654 			}
  56655 			v27 = v28
  56656 		}
  56657 		v25 = v27
  56658 		goto _65
  56659 	_65:
  56660 		v16 = v25
  56661 		goto _56
  56662 	_56:
  56663 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56664 		v31 = v1 * int32(19077) >> int32(8)
  56665 		goto _71
  56666 	_71:
  56667 		v33 = v2 * int32(33050) >> int32(8)
  56668 		goto _73
  56669 	_73:
  56670 		v35 = v31 + v33 - int32(17685)
  56671 		if v35 & ^int32(YUV_MASK2) == 0 {
  56672 			v38 = v35 >> int32(YUV_FIX2)
  56673 		} else {
  56674 			if v35 < 0 {
  56675 				v39 = 0
  56676 			} else {
  56677 				v39 = int32(255)
  56678 			}
  56679 			v38 = v39
  56680 		}
  56681 		v36 = v38
  56682 		goto _76
  56683 	_76:
  56684 		v29 = v36
  56685 		goto _69
  56686 	_69:
  56687 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56688 	}
  56689 	x = int32(1)
  56690 	for {
  56691 		if !(x <= last_pixel_pair) {
  56692 			break
  56693 		}
  56694 		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 */
  56695 		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*/
  56696 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  56697 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  56698 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  56699 		uv02 = (diag_12 + tl_uv) >> int32(1)
  56700 		uv1 = (diag_03 + t_uv) >> int32(1)
  56701 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  56702 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  56703 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  56704 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  56705 		v7 = v1 * int32(19077) >> int32(8)
  56706 		goto _87
  56707 	_87:
  56708 		v9 = v3 * int32(26149) >> int32(8)
  56709 		goto _89
  56710 	_89:
  56711 		v11 = v7 + v9 - int32(14234)
  56712 		if v11 & ^int32(YUV_MASK2) == 0 {
  56713 			v14 = v11 >> int32(YUV_FIX2)
  56714 		} else {
  56715 			if v11 < 0 {
  56716 				v15 = 0
  56717 			} else {
  56718 				v15 = int32(255)
  56719 			}
  56720 			v14 = v15
  56721 		}
  56722 		v12 = v14
  56723 		goto _92
  56724 	_92:
  56725 		v5 = v12
  56726 		goto _85
  56727 	_85:
  56728 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56729 		v18 = v1 * int32(19077) >> int32(8)
  56730 		goto _98
  56731 	_98:
  56732 		v20 = v2 * int32(6419) >> int32(8)
  56733 		goto _100
  56734 	_100:
  56735 		v22 = v3 * int32(13320) >> int32(8)
  56736 		goto _102
  56737 	_102:
  56738 		v24 = v18 - v20 - v22 + int32(8708)
  56739 		if v24 & ^int32(YUV_MASK2) == 0 {
  56740 			v27 = v24 >> int32(YUV_FIX2)
  56741 		} else {
  56742 			if v24 < 0 {
  56743 				v28 = 0
  56744 			} else {
  56745 				v28 = int32(255)
  56746 			}
  56747 			v27 = v28
  56748 		}
  56749 		v25 = v27
  56750 		goto _105
  56751 	_105:
  56752 		v16 = v25
  56753 		goto _96
  56754 	_96:
  56755 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56756 		v31 = v1 * int32(19077) >> int32(8)
  56757 		goto _111
  56758 	_111:
  56759 		v33 = v2 * int32(33050) >> int32(8)
  56760 		goto _113
  56761 	_113:
  56762 		v35 = v31 + v33 - int32(17685)
  56763 		if v35 & ^int32(YUV_MASK2) == 0 {
  56764 			v38 = v35 >> int32(YUV_FIX2)
  56765 		} else {
  56766 			if v35 < 0 {
  56767 				v39 = 0
  56768 			} else {
  56769 				v39 = int32(255)
  56770 			}
  56771 			v38 = v39
  56772 		}
  56773 		v36 = v38
  56774 		goto _116
  56775 	_116:
  56776 		v29 = v36
  56777 		goto _109
  56778 	_109:
  56779 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56780 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  56781 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  56782 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  56783 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(3))
  56784 		v7 = v1 * int32(19077) >> int32(8)
  56785 		goto _126
  56786 	_126:
  56787 		v9 = v3 * int32(26149) >> int32(8)
  56788 		goto _128
  56789 	_128:
  56790 		v11 = v7 + v9 - int32(14234)
  56791 		if v11 & ^int32(YUV_MASK2) == 0 {
  56792 			v14 = v11 >> int32(YUV_FIX2)
  56793 		} else {
  56794 			if v11 < 0 {
  56795 				v15 = 0
  56796 			} else {
  56797 				v15 = int32(255)
  56798 			}
  56799 			v14 = v15
  56800 		}
  56801 		v12 = v14
  56802 		goto _131
  56803 	_131:
  56804 		v5 = v12
  56805 		goto _124
  56806 	_124:
  56807 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56808 		v18 = v1 * int32(19077) >> int32(8)
  56809 		goto _137
  56810 	_137:
  56811 		v20 = v2 * int32(6419) >> int32(8)
  56812 		goto _139
  56813 	_139:
  56814 		v22 = v3 * int32(13320) >> int32(8)
  56815 		goto _141
  56816 	_141:
  56817 		v24 = v18 - v20 - v22 + int32(8708)
  56818 		if v24 & ^int32(YUV_MASK2) == 0 {
  56819 			v27 = v24 >> int32(YUV_FIX2)
  56820 		} else {
  56821 			if v24 < 0 {
  56822 				v28 = 0
  56823 			} else {
  56824 				v28 = int32(255)
  56825 			}
  56826 			v27 = v28
  56827 		}
  56828 		v25 = v27
  56829 		goto _144
  56830 	_144:
  56831 		v16 = v25
  56832 		goto _135
  56833 	_135:
  56834 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56835 		v31 = v1 * int32(19077) >> int32(8)
  56836 		goto _150
  56837 	_150:
  56838 		v33 = v2 * int32(33050) >> int32(8)
  56839 		goto _152
  56840 	_152:
  56841 		v35 = v31 + v33 - int32(17685)
  56842 		if v35 & ^int32(YUV_MASK2) == 0 {
  56843 			v38 = v35 >> int32(YUV_FIX2)
  56844 		} else {
  56845 			if v35 < 0 {
  56846 				v39 = 0
  56847 			} else {
  56848 				v39 = int32(255)
  56849 			}
  56850 			v38 = v39
  56851 		}
  56852 		v36 = v38
  56853 		goto _155
  56854 	_155:
  56855 		v29 = v36
  56856 		goto _148
  56857 	_148:
  56858 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56859 		if bottom_y != libc.UintptrFromInt32(0) {
  56860 			uv03 = (diag_03 + l_uv) >> int32(1)
  56861 			uv11 = (diag_12 + uv) >> int32(1)
  56862 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  56863 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  56864 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  56865 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  56866 			v7 = v1 * int32(19077) >> int32(8)
  56867 			goto _165
  56868 		_165:
  56869 			v9 = v3 * int32(26149) >> int32(8)
  56870 			goto _167
  56871 		_167:
  56872 			v11 = v7 + v9 - int32(14234)
  56873 			if v11 & ^int32(YUV_MASK2) == 0 {
  56874 				v14 = v11 >> int32(YUV_FIX2)
  56875 			} else {
  56876 				if v11 < 0 {
  56877 					v15 = 0
  56878 				} else {
  56879 					v15 = int32(255)
  56880 				}
  56881 				v14 = v15
  56882 			}
  56883 			v12 = v14
  56884 			goto _170
  56885 		_170:
  56886 			v5 = v12
  56887 			goto _163
  56888 		_163:
  56889 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56890 			v18 = v1 * int32(19077) >> int32(8)
  56891 			goto _176
  56892 		_176:
  56893 			v20 = v2 * int32(6419) >> int32(8)
  56894 			goto _178
  56895 		_178:
  56896 			v22 = v3 * int32(13320) >> int32(8)
  56897 			goto _180
  56898 		_180:
  56899 			v24 = v18 - v20 - v22 + int32(8708)
  56900 			if v24 & ^int32(YUV_MASK2) == 0 {
  56901 				v27 = v24 >> int32(YUV_FIX2)
  56902 			} else {
  56903 				if v24 < 0 {
  56904 					v28 = 0
  56905 				} else {
  56906 					v28 = int32(255)
  56907 				}
  56908 				v27 = v28
  56909 			}
  56910 			v25 = v27
  56911 			goto _183
  56912 		_183:
  56913 			v16 = v25
  56914 			goto _174
  56915 		_174:
  56916 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56917 			v31 = v1 * int32(19077) >> int32(8)
  56918 			goto _189
  56919 		_189:
  56920 			v33 = v2 * int32(33050) >> int32(8)
  56921 			goto _191
  56922 		_191:
  56923 			v35 = v31 + v33 - int32(17685)
  56924 			if v35 & ^int32(YUV_MASK2) == 0 {
  56925 				v38 = v35 >> int32(YUV_FIX2)
  56926 			} else {
  56927 				if v35 < 0 {
  56928 					v39 = 0
  56929 				} else {
  56930 					v39 = int32(255)
  56931 				}
  56932 				v38 = v39
  56933 			}
  56934 			v36 = v38
  56935 			goto _194
  56936 		_194:
  56937 			v29 = v36
  56938 			goto _187
  56939 		_187:
  56940 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  56941 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  56942 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  56943 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  56944 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(3))
  56945 			v7 = v1 * int32(19077) >> int32(8)
  56946 			goto _204
  56947 		_204:
  56948 			v9 = v3 * int32(26149) >> int32(8)
  56949 			goto _206
  56950 		_206:
  56951 			v11 = v7 + v9 - int32(14234)
  56952 			if v11 & ^int32(YUV_MASK2) == 0 {
  56953 				v14 = v11 >> int32(YUV_FIX2)
  56954 			} else {
  56955 				if v11 < 0 {
  56956 					v15 = 0
  56957 				} else {
  56958 					v15 = int32(255)
  56959 				}
  56960 				v14 = v15
  56961 			}
  56962 			v12 = v14
  56963 			goto _209
  56964 		_209:
  56965 			v5 = v12
  56966 			goto _202
  56967 		_202:
  56968 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  56969 			v18 = v1 * int32(19077) >> int32(8)
  56970 			goto _215
  56971 		_215:
  56972 			v20 = v2 * int32(6419) >> int32(8)
  56973 			goto _217
  56974 		_217:
  56975 			v22 = v3 * int32(13320) >> int32(8)
  56976 			goto _219
  56977 		_219:
  56978 			v24 = v18 - v20 - v22 + int32(8708)
  56979 			if v24 & ^int32(YUV_MASK2) == 0 {
  56980 				v27 = v24 >> int32(YUV_FIX2)
  56981 			} else {
  56982 				if v24 < 0 {
  56983 					v28 = 0
  56984 				} else {
  56985 					v28 = int32(255)
  56986 				}
  56987 				v27 = v28
  56988 			}
  56989 			v25 = v27
  56990 			goto _222
  56991 		_222:
  56992 			v16 = v25
  56993 			goto _213
  56994 		_213:
  56995 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  56996 			v31 = v1 * int32(19077) >> int32(8)
  56997 			goto _228
  56998 		_228:
  56999 			v33 = v2 * int32(33050) >> int32(8)
  57000 			goto _230
  57001 		_230:
  57002 			v35 = v31 + v33 - int32(17685)
  57003 			if v35 & ^int32(YUV_MASK2) == 0 {
  57004 				v38 = v35 >> int32(YUV_FIX2)
  57005 			} else {
  57006 				if v35 < 0 {
  57007 					v39 = 0
  57008 				} else {
  57009 					v39 = int32(255)
  57010 				}
  57011 				v38 = v39
  57012 			}
  57013 			v36 = v38
  57014 			goto _233
  57015 		_233:
  57016 			v29 = v36
  57017 			goto _226
  57018 		_226:
  57019 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57020 		}
  57021 		tl_uv = t_uv
  57022 		l_uv = uv
  57023 		goto _79
  57024 	_79:
  57025 		;
  57026 		x = x + 1
  57027 	}
  57028 	if !(len1&libc.Int32FromInt32(1) != 0) {
  57029 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57030 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  57031 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  57032 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  57033 		v4 = top_dst + uintptr((len1-int32(1))*int32(3))
  57034 		v7 = v1 * int32(19077) >> int32(8)
  57035 		goto _243
  57036 	_243:
  57037 		v9 = v3 * int32(26149) >> int32(8)
  57038 		goto _245
  57039 	_245:
  57040 		v11 = v7 + v9 - int32(14234)
  57041 		if v11 & ^int32(YUV_MASK2) == 0 {
  57042 			v14 = v11 >> int32(YUV_FIX2)
  57043 		} else {
  57044 			if v11 < 0 {
  57045 				v15 = 0
  57046 			} else {
  57047 				v15 = int32(255)
  57048 			}
  57049 			v14 = v15
  57050 		}
  57051 		v12 = v14
  57052 		goto _248
  57053 	_248:
  57054 		v5 = v12
  57055 		goto _241
  57056 	_241:
  57057 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57058 		v18 = v1 * int32(19077) >> int32(8)
  57059 		goto _254
  57060 	_254:
  57061 		v20 = v2 * int32(6419) >> int32(8)
  57062 		goto _256
  57063 	_256:
  57064 		v22 = v3 * int32(13320) >> int32(8)
  57065 		goto _258
  57066 	_258:
  57067 		v24 = v18 - v20 - v22 + int32(8708)
  57068 		if v24 & ^int32(YUV_MASK2) == 0 {
  57069 			v27 = v24 >> int32(YUV_FIX2)
  57070 		} else {
  57071 			if v24 < 0 {
  57072 				v28 = 0
  57073 			} else {
  57074 				v28 = int32(255)
  57075 			}
  57076 			v27 = v28
  57077 		}
  57078 		v25 = v27
  57079 		goto _261
  57080 	_261:
  57081 		v16 = v25
  57082 		goto _252
  57083 	_252:
  57084 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57085 		v31 = v1 * int32(19077) >> int32(8)
  57086 		goto _267
  57087 	_267:
  57088 		v33 = v2 * int32(33050) >> int32(8)
  57089 		goto _269
  57090 	_269:
  57091 		v35 = v31 + v33 - int32(17685)
  57092 		if v35 & ^int32(YUV_MASK2) == 0 {
  57093 			v38 = v35 >> int32(YUV_FIX2)
  57094 		} else {
  57095 			if v35 < 0 {
  57096 				v39 = 0
  57097 			} else {
  57098 				v39 = int32(255)
  57099 			}
  57100 			v38 = v39
  57101 		}
  57102 		v36 = v38
  57103 		goto _272
  57104 	_272:
  57105 		v29 = v36
  57106 		goto _265
  57107 	_265:
  57108 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57109 		if bottom_y != libc.UintptrFromInt32(0) {
  57110 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57111 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  57112 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  57113 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  57114 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(3))
  57115 			v7 = v1 * int32(19077) >> int32(8)
  57116 			goto _282
  57117 		_282:
  57118 			v9 = v3 * int32(26149) >> int32(8)
  57119 			goto _284
  57120 		_284:
  57121 			v11 = v7 + v9 - int32(14234)
  57122 			if v11 & ^int32(YUV_MASK2) == 0 {
  57123 				v14 = v11 >> int32(YUV_FIX2)
  57124 			} else {
  57125 				if v11 < 0 {
  57126 					v15 = 0
  57127 				} else {
  57128 					v15 = int32(255)
  57129 				}
  57130 				v14 = v15
  57131 			}
  57132 			v12 = v14
  57133 			goto _287
  57134 		_287:
  57135 			v5 = v12
  57136 			goto _280
  57137 		_280:
  57138 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57139 			v18 = v1 * int32(19077) >> int32(8)
  57140 			goto _293
  57141 		_293:
  57142 			v20 = v2 * int32(6419) >> int32(8)
  57143 			goto _295
  57144 		_295:
  57145 			v22 = v3 * int32(13320) >> int32(8)
  57146 			goto _297
  57147 		_297:
  57148 			v24 = v18 - v20 - v22 + int32(8708)
  57149 			if v24 & ^int32(YUV_MASK2) == 0 {
  57150 				v27 = v24 >> int32(YUV_FIX2)
  57151 			} else {
  57152 				if v24 < 0 {
  57153 					v28 = 0
  57154 				} else {
  57155 					v28 = int32(255)
  57156 				}
  57157 				v27 = v28
  57158 			}
  57159 			v25 = v27
  57160 			goto _300
  57161 		_300:
  57162 			v16 = v25
  57163 			goto _291
  57164 		_291:
  57165 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57166 			v31 = v1 * int32(19077) >> int32(8)
  57167 			goto _306
  57168 		_306:
  57169 			v33 = v2 * int32(33050) >> int32(8)
  57170 			goto _308
  57171 		_308:
  57172 			v35 = v31 + v33 - int32(17685)
  57173 			if v35 & ^int32(YUV_MASK2) == 0 {
  57174 				v38 = v35 >> int32(YUV_FIX2)
  57175 			} else {
  57176 				if v35 < 0 {
  57177 					v39 = 0
  57178 				} else {
  57179 					v39 = int32(255)
  57180 				}
  57181 				v38 = v39
  57182 			}
  57183 			v36 = v38
  57184 			goto _311
  57185 		_311:
  57186 			v29 = v36
  57187 			goto _304
  57188 		_304:
  57189 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57190 		}
  57191 	}
  57192 }
  57193 
  57194 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) {
  57195 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  57196 	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
  57197 	var v4 uintptr
  57198 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  57199 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  57200 	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 */
  57201 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  57202 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57203 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  57204 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  57205 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  57206 	v4 = top_dst
  57207 	v7 = v1 * int32(19077) >> int32(8)
  57208 	goto _8
  57209 _8:
  57210 	v9 = v2 * int32(33050) >> int32(8)
  57211 	goto _10
  57212 _10:
  57213 	v11 = v7 + v9 - int32(17685)
  57214 	if v11 & ^int32(YUV_MASK2) == 0 {
  57215 		v14 = v11 >> int32(YUV_FIX2)
  57216 	} else {
  57217 		if v11 < 0 {
  57218 			v15 = 0
  57219 		} else {
  57220 			v15 = int32(255)
  57221 		}
  57222 		v14 = v15
  57223 	}
  57224 	v12 = v14
  57225 	goto _13
  57226 _13:
  57227 	v5 = v12
  57228 	goto _6
  57229 _6:
  57230 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57231 	v18 = v1 * int32(19077) >> int32(8)
  57232 	goto _19
  57233 _19:
  57234 	v20 = v2 * int32(6419) >> int32(8)
  57235 	goto _21
  57236 _21:
  57237 	v22 = v3 * int32(13320) >> int32(8)
  57238 	goto _23
  57239 _23:
  57240 	v24 = v18 - v20 - v22 + int32(8708)
  57241 	if v24 & ^int32(YUV_MASK2) == 0 {
  57242 		v27 = v24 >> int32(YUV_FIX2)
  57243 	} else {
  57244 		if v24 < 0 {
  57245 			v28 = 0
  57246 		} else {
  57247 			v28 = int32(255)
  57248 		}
  57249 		v27 = v28
  57250 	}
  57251 	v25 = v27
  57252 	goto _26
  57253 _26:
  57254 	v16 = v25
  57255 	goto _17
  57256 _17:
  57257 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57258 	v31 = v1 * int32(19077) >> int32(8)
  57259 	goto _32
  57260 _32:
  57261 	v33 = v3 * int32(26149) >> int32(8)
  57262 	goto _34
  57263 _34:
  57264 	v35 = v31 + v33 - int32(14234)
  57265 	if v35 & ^int32(YUV_MASK2) == 0 {
  57266 		v38 = v35 >> int32(YUV_FIX2)
  57267 	} else {
  57268 		if v35 < 0 {
  57269 			v39 = 0
  57270 		} else {
  57271 			v39 = int32(255)
  57272 		}
  57273 		v38 = v39
  57274 	}
  57275 	v36 = v38
  57276 	goto _37
  57277 _37:
  57278 	v29 = v36
  57279 	goto _30
  57280 _30:
  57281 	**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57282 	if bottom_y != libc.UintptrFromInt32(0) {
  57283 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57284 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  57285 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  57286 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  57287 		v4 = bottom_dst
  57288 		v7 = v1 * int32(19077) >> int32(8)
  57289 		goto _47
  57290 	_47:
  57291 		v9 = v2 * int32(33050) >> int32(8)
  57292 		goto _49
  57293 	_49:
  57294 		v11 = v7 + v9 - int32(17685)
  57295 		if v11 & ^int32(YUV_MASK2) == 0 {
  57296 			v14 = v11 >> int32(YUV_FIX2)
  57297 		} else {
  57298 			if v11 < 0 {
  57299 				v15 = 0
  57300 			} else {
  57301 				v15 = int32(255)
  57302 			}
  57303 			v14 = v15
  57304 		}
  57305 		v12 = v14
  57306 		goto _52
  57307 	_52:
  57308 		v5 = v12
  57309 		goto _45
  57310 	_45:
  57311 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57312 		v18 = v1 * int32(19077) >> int32(8)
  57313 		goto _58
  57314 	_58:
  57315 		v20 = v2 * int32(6419) >> int32(8)
  57316 		goto _60
  57317 	_60:
  57318 		v22 = v3 * int32(13320) >> int32(8)
  57319 		goto _62
  57320 	_62:
  57321 		v24 = v18 - v20 - v22 + int32(8708)
  57322 		if v24 & ^int32(YUV_MASK2) == 0 {
  57323 			v27 = v24 >> int32(YUV_FIX2)
  57324 		} else {
  57325 			if v24 < 0 {
  57326 				v28 = 0
  57327 			} else {
  57328 				v28 = int32(255)
  57329 			}
  57330 			v27 = v28
  57331 		}
  57332 		v25 = v27
  57333 		goto _65
  57334 	_65:
  57335 		v16 = v25
  57336 		goto _56
  57337 	_56:
  57338 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57339 		v31 = v1 * int32(19077) >> int32(8)
  57340 		goto _71
  57341 	_71:
  57342 		v33 = v3 * int32(26149) >> int32(8)
  57343 		goto _73
  57344 	_73:
  57345 		v35 = v31 + v33 - int32(14234)
  57346 		if v35 & ^int32(YUV_MASK2) == 0 {
  57347 			v38 = v35 >> int32(YUV_FIX2)
  57348 		} else {
  57349 			if v35 < 0 {
  57350 				v39 = 0
  57351 			} else {
  57352 				v39 = int32(255)
  57353 			}
  57354 			v38 = v39
  57355 		}
  57356 		v36 = v38
  57357 		goto _76
  57358 	_76:
  57359 		v29 = v36
  57360 		goto _69
  57361 	_69:
  57362 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57363 	}
  57364 	x = int32(1)
  57365 	for {
  57366 		if !(x <= last_pixel_pair) {
  57367 			break
  57368 		}
  57369 		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 */
  57370 		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*/
  57371 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  57372 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  57373 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  57374 		uv02 = (diag_12 + tl_uv) >> int32(1)
  57375 		uv1 = (diag_03 + t_uv) >> int32(1)
  57376 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  57377 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  57378 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  57379 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  57380 		v7 = v1 * int32(19077) >> int32(8)
  57381 		goto _87
  57382 	_87:
  57383 		v9 = v2 * int32(33050) >> int32(8)
  57384 		goto _89
  57385 	_89:
  57386 		v11 = v7 + v9 - int32(17685)
  57387 		if v11 & ^int32(YUV_MASK2) == 0 {
  57388 			v14 = v11 >> int32(YUV_FIX2)
  57389 		} else {
  57390 			if v11 < 0 {
  57391 				v15 = 0
  57392 			} else {
  57393 				v15 = int32(255)
  57394 			}
  57395 			v14 = v15
  57396 		}
  57397 		v12 = v14
  57398 		goto _92
  57399 	_92:
  57400 		v5 = v12
  57401 		goto _85
  57402 	_85:
  57403 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57404 		v18 = v1 * int32(19077) >> int32(8)
  57405 		goto _98
  57406 	_98:
  57407 		v20 = v2 * int32(6419) >> int32(8)
  57408 		goto _100
  57409 	_100:
  57410 		v22 = v3 * int32(13320) >> int32(8)
  57411 		goto _102
  57412 	_102:
  57413 		v24 = v18 - v20 - v22 + int32(8708)
  57414 		if v24 & ^int32(YUV_MASK2) == 0 {
  57415 			v27 = v24 >> int32(YUV_FIX2)
  57416 		} else {
  57417 			if v24 < 0 {
  57418 				v28 = 0
  57419 			} else {
  57420 				v28 = int32(255)
  57421 			}
  57422 			v27 = v28
  57423 		}
  57424 		v25 = v27
  57425 		goto _105
  57426 	_105:
  57427 		v16 = v25
  57428 		goto _96
  57429 	_96:
  57430 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57431 		v31 = v1 * int32(19077) >> int32(8)
  57432 		goto _111
  57433 	_111:
  57434 		v33 = v3 * int32(26149) >> int32(8)
  57435 		goto _113
  57436 	_113:
  57437 		v35 = v31 + v33 - int32(14234)
  57438 		if v35 & ^int32(YUV_MASK2) == 0 {
  57439 			v38 = v35 >> int32(YUV_FIX2)
  57440 		} else {
  57441 			if v35 < 0 {
  57442 				v39 = 0
  57443 			} else {
  57444 				v39 = int32(255)
  57445 			}
  57446 			v38 = v39
  57447 		}
  57448 		v36 = v38
  57449 		goto _116
  57450 	_116:
  57451 		v29 = v36
  57452 		goto _109
  57453 	_109:
  57454 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57455 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  57456 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  57457 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  57458 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(3))
  57459 		v7 = v1 * int32(19077) >> int32(8)
  57460 		goto _126
  57461 	_126:
  57462 		v9 = v2 * int32(33050) >> int32(8)
  57463 		goto _128
  57464 	_128:
  57465 		v11 = v7 + v9 - int32(17685)
  57466 		if v11 & ^int32(YUV_MASK2) == 0 {
  57467 			v14 = v11 >> int32(YUV_FIX2)
  57468 		} else {
  57469 			if v11 < 0 {
  57470 				v15 = 0
  57471 			} else {
  57472 				v15 = int32(255)
  57473 			}
  57474 			v14 = v15
  57475 		}
  57476 		v12 = v14
  57477 		goto _131
  57478 	_131:
  57479 		v5 = v12
  57480 		goto _124
  57481 	_124:
  57482 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57483 		v18 = v1 * int32(19077) >> int32(8)
  57484 		goto _137
  57485 	_137:
  57486 		v20 = v2 * int32(6419) >> int32(8)
  57487 		goto _139
  57488 	_139:
  57489 		v22 = v3 * int32(13320) >> int32(8)
  57490 		goto _141
  57491 	_141:
  57492 		v24 = v18 - v20 - v22 + int32(8708)
  57493 		if v24 & ^int32(YUV_MASK2) == 0 {
  57494 			v27 = v24 >> int32(YUV_FIX2)
  57495 		} else {
  57496 			if v24 < 0 {
  57497 				v28 = 0
  57498 			} else {
  57499 				v28 = int32(255)
  57500 			}
  57501 			v27 = v28
  57502 		}
  57503 		v25 = v27
  57504 		goto _144
  57505 	_144:
  57506 		v16 = v25
  57507 		goto _135
  57508 	_135:
  57509 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57510 		v31 = v1 * int32(19077) >> int32(8)
  57511 		goto _150
  57512 	_150:
  57513 		v33 = v3 * int32(26149) >> int32(8)
  57514 		goto _152
  57515 	_152:
  57516 		v35 = v31 + v33 - int32(14234)
  57517 		if v35 & ^int32(YUV_MASK2) == 0 {
  57518 			v38 = v35 >> int32(YUV_FIX2)
  57519 		} else {
  57520 			if v35 < 0 {
  57521 				v39 = 0
  57522 			} else {
  57523 				v39 = int32(255)
  57524 			}
  57525 			v38 = v39
  57526 		}
  57527 		v36 = v38
  57528 		goto _155
  57529 	_155:
  57530 		v29 = v36
  57531 		goto _148
  57532 	_148:
  57533 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57534 		if bottom_y != libc.UintptrFromInt32(0) {
  57535 			uv03 = (diag_03 + l_uv) >> int32(1)
  57536 			uv11 = (diag_12 + uv) >> int32(1)
  57537 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  57538 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  57539 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  57540 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(3))
  57541 			v7 = v1 * int32(19077) >> int32(8)
  57542 			goto _165
  57543 		_165:
  57544 			v9 = v2 * int32(33050) >> int32(8)
  57545 			goto _167
  57546 		_167:
  57547 			v11 = v7 + v9 - int32(17685)
  57548 			if v11 & ^int32(YUV_MASK2) == 0 {
  57549 				v14 = v11 >> int32(YUV_FIX2)
  57550 			} else {
  57551 				if v11 < 0 {
  57552 					v15 = 0
  57553 				} else {
  57554 					v15 = int32(255)
  57555 				}
  57556 				v14 = v15
  57557 			}
  57558 			v12 = v14
  57559 			goto _170
  57560 		_170:
  57561 			v5 = v12
  57562 			goto _163
  57563 		_163:
  57564 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57565 			v18 = v1 * int32(19077) >> int32(8)
  57566 			goto _176
  57567 		_176:
  57568 			v20 = v2 * int32(6419) >> int32(8)
  57569 			goto _178
  57570 		_178:
  57571 			v22 = v3 * int32(13320) >> int32(8)
  57572 			goto _180
  57573 		_180:
  57574 			v24 = v18 - v20 - v22 + int32(8708)
  57575 			if v24 & ^int32(YUV_MASK2) == 0 {
  57576 				v27 = v24 >> int32(YUV_FIX2)
  57577 			} else {
  57578 				if v24 < 0 {
  57579 					v28 = 0
  57580 				} else {
  57581 					v28 = int32(255)
  57582 				}
  57583 				v27 = v28
  57584 			}
  57585 			v25 = v27
  57586 			goto _183
  57587 		_183:
  57588 			v16 = v25
  57589 			goto _174
  57590 		_174:
  57591 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57592 			v31 = v1 * int32(19077) >> int32(8)
  57593 			goto _189
  57594 		_189:
  57595 			v33 = v3 * int32(26149) >> int32(8)
  57596 			goto _191
  57597 		_191:
  57598 			v35 = v31 + v33 - int32(14234)
  57599 			if v35 & ^int32(YUV_MASK2) == 0 {
  57600 				v38 = v35 >> int32(YUV_FIX2)
  57601 			} else {
  57602 				if v35 < 0 {
  57603 					v39 = 0
  57604 				} else {
  57605 					v39 = int32(255)
  57606 				}
  57607 				v38 = v39
  57608 			}
  57609 			v36 = v38
  57610 			goto _194
  57611 		_194:
  57612 			v29 = v36
  57613 			goto _187
  57614 		_187:
  57615 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57616 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  57617 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  57618 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  57619 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(3))
  57620 			v7 = v1 * int32(19077) >> int32(8)
  57621 			goto _204
  57622 		_204:
  57623 			v9 = v2 * int32(33050) >> int32(8)
  57624 			goto _206
  57625 		_206:
  57626 			v11 = v7 + v9 - int32(17685)
  57627 			if v11 & ^int32(YUV_MASK2) == 0 {
  57628 				v14 = v11 >> int32(YUV_FIX2)
  57629 			} else {
  57630 				if v11 < 0 {
  57631 					v15 = 0
  57632 				} else {
  57633 					v15 = int32(255)
  57634 				}
  57635 				v14 = v15
  57636 			}
  57637 			v12 = v14
  57638 			goto _209
  57639 		_209:
  57640 			v5 = v12
  57641 			goto _202
  57642 		_202:
  57643 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57644 			v18 = v1 * int32(19077) >> int32(8)
  57645 			goto _215
  57646 		_215:
  57647 			v20 = v2 * int32(6419) >> int32(8)
  57648 			goto _217
  57649 		_217:
  57650 			v22 = v3 * int32(13320) >> int32(8)
  57651 			goto _219
  57652 		_219:
  57653 			v24 = v18 - v20 - v22 + int32(8708)
  57654 			if v24 & ^int32(YUV_MASK2) == 0 {
  57655 				v27 = v24 >> int32(YUV_FIX2)
  57656 			} else {
  57657 				if v24 < 0 {
  57658 					v28 = 0
  57659 				} else {
  57660 					v28 = int32(255)
  57661 				}
  57662 				v27 = v28
  57663 			}
  57664 			v25 = v27
  57665 			goto _222
  57666 		_222:
  57667 			v16 = v25
  57668 			goto _213
  57669 		_213:
  57670 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57671 			v31 = v1 * int32(19077) >> int32(8)
  57672 			goto _228
  57673 		_228:
  57674 			v33 = v3 * int32(26149) >> int32(8)
  57675 			goto _230
  57676 		_230:
  57677 			v35 = v31 + v33 - int32(14234)
  57678 			if v35 & ^int32(YUV_MASK2) == 0 {
  57679 				v38 = v35 >> int32(YUV_FIX2)
  57680 			} else {
  57681 				if v35 < 0 {
  57682 					v39 = 0
  57683 				} else {
  57684 					v39 = int32(255)
  57685 				}
  57686 				v38 = v39
  57687 			}
  57688 			v36 = v38
  57689 			goto _233
  57690 		_233:
  57691 			v29 = v36
  57692 			goto _226
  57693 		_226:
  57694 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57695 		}
  57696 		tl_uv = t_uv
  57697 		l_uv = uv
  57698 		goto _79
  57699 	_79:
  57700 		;
  57701 		x = x + 1
  57702 	}
  57703 	if !(len1&libc.Int32FromInt32(1) != 0) {
  57704 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57705 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  57706 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  57707 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  57708 		v4 = top_dst + uintptr((len1-int32(1))*int32(3))
  57709 		v7 = v1 * int32(19077) >> int32(8)
  57710 		goto _243
  57711 	_243:
  57712 		v9 = v2 * int32(33050) >> int32(8)
  57713 		goto _245
  57714 	_245:
  57715 		v11 = v7 + v9 - int32(17685)
  57716 		if v11 & ^int32(YUV_MASK2) == 0 {
  57717 			v14 = v11 >> int32(YUV_FIX2)
  57718 		} else {
  57719 			if v11 < 0 {
  57720 				v15 = 0
  57721 			} else {
  57722 				v15 = int32(255)
  57723 			}
  57724 			v14 = v15
  57725 		}
  57726 		v12 = v14
  57727 		goto _248
  57728 	_248:
  57729 		v5 = v12
  57730 		goto _241
  57731 	_241:
  57732 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57733 		v18 = v1 * int32(19077) >> int32(8)
  57734 		goto _254
  57735 	_254:
  57736 		v20 = v2 * int32(6419) >> int32(8)
  57737 		goto _256
  57738 	_256:
  57739 		v22 = v3 * int32(13320) >> int32(8)
  57740 		goto _258
  57741 	_258:
  57742 		v24 = v18 - v20 - v22 + int32(8708)
  57743 		if v24 & ^int32(YUV_MASK2) == 0 {
  57744 			v27 = v24 >> int32(YUV_FIX2)
  57745 		} else {
  57746 			if v24 < 0 {
  57747 				v28 = 0
  57748 			} else {
  57749 				v28 = int32(255)
  57750 			}
  57751 			v27 = v28
  57752 		}
  57753 		v25 = v27
  57754 		goto _261
  57755 	_261:
  57756 		v16 = v25
  57757 		goto _252
  57758 	_252:
  57759 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57760 		v31 = v1 * int32(19077) >> int32(8)
  57761 		goto _267
  57762 	_267:
  57763 		v33 = v3 * int32(26149) >> int32(8)
  57764 		goto _269
  57765 	_269:
  57766 		v35 = v31 + v33 - int32(14234)
  57767 		if v35 & ^int32(YUV_MASK2) == 0 {
  57768 			v38 = v35 >> int32(YUV_FIX2)
  57769 		} else {
  57770 			if v35 < 0 {
  57771 				v39 = 0
  57772 			} else {
  57773 				v39 = int32(255)
  57774 			}
  57775 			v38 = v39
  57776 		}
  57777 		v36 = v38
  57778 		goto _272
  57779 	_272:
  57780 		v29 = v36
  57781 		goto _265
  57782 	_265:
  57783 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57784 		if bottom_y != libc.UintptrFromInt32(0) {
  57785 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57786 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  57787 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  57788 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  57789 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(3))
  57790 			v7 = v1 * int32(19077) >> int32(8)
  57791 			goto _282
  57792 		_282:
  57793 			v9 = v2 * int32(33050) >> int32(8)
  57794 			goto _284
  57795 		_284:
  57796 			v11 = v7 + v9 - int32(17685)
  57797 			if v11 & ^int32(YUV_MASK2) == 0 {
  57798 				v14 = v11 >> int32(YUV_FIX2)
  57799 			} else {
  57800 				if v11 < 0 {
  57801 					v15 = 0
  57802 				} else {
  57803 					v15 = int32(255)
  57804 				}
  57805 				v14 = v15
  57806 			}
  57807 			v12 = v14
  57808 			goto _287
  57809 		_287:
  57810 			v5 = v12
  57811 			goto _280
  57812 		_280:
  57813 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v5)
  57814 			v18 = v1 * int32(19077) >> int32(8)
  57815 			goto _293
  57816 		_293:
  57817 			v20 = v2 * int32(6419) >> int32(8)
  57818 			goto _295
  57819 		_295:
  57820 			v22 = v3 * int32(13320) >> int32(8)
  57821 			goto _297
  57822 		_297:
  57823 			v24 = v18 - v20 - v22 + int32(8708)
  57824 			if v24 & ^int32(YUV_MASK2) == 0 {
  57825 				v27 = v24 >> int32(YUV_FIX2)
  57826 			} else {
  57827 				if v24 < 0 {
  57828 					v28 = 0
  57829 				} else {
  57830 					v28 = int32(255)
  57831 				}
  57832 				v27 = v28
  57833 			}
  57834 			v25 = v27
  57835 			goto _300
  57836 		_300:
  57837 			v16 = v25
  57838 			goto _291
  57839 		_291:
  57840 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  57841 			v31 = v1 * int32(19077) >> int32(8)
  57842 			goto _306
  57843 		_306:
  57844 			v33 = v3 * int32(26149) >> int32(8)
  57845 			goto _308
  57846 		_308:
  57847 			v35 = v31 + v33 - int32(14234)
  57848 			if v35 & ^int32(YUV_MASK2) == 0 {
  57849 				v38 = v35 >> int32(YUV_FIX2)
  57850 			} else {
  57851 				if v35 < 0 {
  57852 					v39 = 0
  57853 				} else {
  57854 					v39 = int32(255)
  57855 				}
  57856 				v38 = v39
  57857 			}
  57858 			v36 = v38
  57859 			goto _311
  57860 		_311:
  57861 			v29 = v36
  57862 			goto _304
  57863 		_304:
  57864 			**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  57865 		}
  57866 	}
  57867 }
  57868 
  57869 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) {
  57870 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  57871 	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
  57872 	var v4 uintptr
  57873 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  57874 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  57875 	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 */
  57876 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  57877 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  57878 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  57879 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  57880 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  57881 	v4 = top_dst
  57882 	v7 = v1 * int32(19077) >> int32(8)
  57883 	goto _8
  57884 _8:
  57885 	v9 = v3 * int32(26149) >> int32(8)
  57886 	goto _10
  57887 _10:
  57888 	v11 = v7 + v9 - int32(14234)
  57889 	if v11 & ^int32(YUV_MASK2) == 0 {
  57890 		v14 = v11 >> int32(YUV_FIX2)
  57891 	} else {
  57892 		if v11 < 0 {
  57893 			v15 = 0
  57894 		} else {
  57895 			v15 = int32(255)
  57896 		}
  57897 		v14 = v15
  57898 	}
  57899 	v12 = v14
  57900 	goto _13
  57901 _13:
  57902 	v5 = v12
  57903 	goto _6
  57904 _6:
  57905 	r = v5
  57906 	v18 = v1 * int32(19077) >> int32(8)
  57907 	goto _19
  57908 _19:
  57909 	v20 = v2 * int32(6419) >> int32(8)
  57910 	goto _21
  57911 _21:
  57912 	v22 = v3 * int32(13320) >> int32(8)
  57913 	goto _23
  57914 _23:
  57915 	v24 = v18 - v20 - v22 + int32(8708)
  57916 	if v24 & ^int32(YUV_MASK2) == 0 {
  57917 		v27 = v24 >> int32(YUV_FIX2)
  57918 	} else {
  57919 		if v24 < 0 {
  57920 			v28 = 0
  57921 		} else {
  57922 			v28 = int32(255)
  57923 		}
  57924 		v27 = v28
  57925 	}
  57926 	v25 = v27
  57927 	goto _26
  57928 _26:
  57929 	v16 = v25
  57930 	goto _17
  57931 _17:
  57932 	g = v16
  57933 	v31 = v1 * int32(19077) >> int32(8)
  57934 	goto _32
  57935 _32:
  57936 	v33 = v2 * int32(33050) >> int32(8)
  57937 	goto _34
  57938 _34:
  57939 	v35 = v31 + v33 - int32(17685)
  57940 	if v35 & ^int32(YUV_MASK2) == 0 {
  57941 		v38 = v35 >> int32(YUV_FIX2)
  57942 	} else {
  57943 		if v35 < 0 {
  57944 			v39 = 0
  57945 		} else {
  57946 			v39 = int32(255)
  57947 		}
  57948 		v38 = v39
  57949 	}
  57950 	v36 = v38
  57951 	goto _37
  57952 _37:
  57953 	v29 = v36
  57954 	goto _30
  57955 _30:
  57956 	b = v29
  57957 	rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  57958 	ba = b&int32(0xf0) | int32(0x0f)
  57959 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  57960 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  57961 	if bottom_y != libc.UintptrFromInt32(0) {
  57962 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  57963 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  57964 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  57965 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  57966 		v4 = bottom_dst
  57967 		v7 = v1 * int32(19077) >> int32(8)
  57968 		goto _47
  57969 	_47:
  57970 		v9 = v3 * int32(26149) >> int32(8)
  57971 		goto _49
  57972 	_49:
  57973 		v11 = v7 + v9 - int32(14234)
  57974 		if v11 & ^int32(YUV_MASK2) == 0 {
  57975 			v14 = v11 >> int32(YUV_FIX2)
  57976 		} else {
  57977 			if v11 < 0 {
  57978 				v15 = 0
  57979 			} else {
  57980 				v15 = int32(255)
  57981 			}
  57982 			v14 = v15
  57983 		}
  57984 		v12 = v14
  57985 		goto _52
  57986 	_52:
  57987 		v5 = v12
  57988 		goto _45
  57989 	_45:
  57990 		r = v5
  57991 		v18 = v1 * int32(19077) >> int32(8)
  57992 		goto _58
  57993 	_58:
  57994 		v20 = v2 * int32(6419) >> int32(8)
  57995 		goto _60
  57996 	_60:
  57997 		v22 = v3 * int32(13320) >> int32(8)
  57998 		goto _62
  57999 	_62:
  58000 		v24 = v18 - v20 - v22 + int32(8708)
  58001 		if v24 & ^int32(YUV_MASK2) == 0 {
  58002 			v27 = v24 >> int32(YUV_FIX2)
  58003 		} else {
  58004 			if v24 < 0 {
  58005 				v28 = 0
  58006 			} else {
  58007 				v28 = int32(255)
  58008 			}
  58009 			v27 = v28
  58010 		}
  58011 		v25 = v27
  58012 		goto _65
  58013 	_65:
  58014 		v16 = v25
  58015 		goto _56
  58016 	_56:
  58017 		g = v16
  58018 		v31 = v1 * int32(19077) >> int32(8)
  58019 		goto _71
  58020 	_71:
  58021 		v33 = v2 * int32(33050) >> int32(8)
  58022 		goto _73
  58023 	_73:
  58024 		v35 = v31 + v33 - int32(17685)
  58025 		if v35 & ^int32(YUV_MASK2) == 0 {
  58026 			v38 = v35 >> int32(YUV_FIX2)
  58027 		} else {
  58028 			if v35 < 0 {
  58029 				v39 = 0
  58030 			} else {
  58031 				v39 = int32(255)
  58032 			}
  58033 			v38 = v39
  58034 		}
  58035 		v36 = v38
  58036 		goto _76
  58037 	_76:
  58038 		v29 = v36
  58039 		goto _69
  58040 	_69:
  58041 		b = v29
  58042 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58043 		ba = b&int32(0xf0) | int32(0x0f)
  58044 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58045 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58046 	}
  58047 	x = int32(1)
  58048 	for {
  58049 		if !(x <= last_pixel_pair) {
  58050 			break
  58051 		}
  58052 		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 */
  58053 		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*/
  58054 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  58055 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  58056 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  58057 		uv02 = (diag_12 + tl_uv) >> int32(1)
  58058 		uv1 = (diag_03 + t_uv) >> int32(1)
  58059 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  58060 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  58061 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  58062 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58063 		v7 = v1 * int32(19077) >> int32(8)
  58064 		goto _87
  58065 	_87:
  58066 		v9 = v3 * int32(26149) >> int32(8)
  58067 		goto _89
  58068 	_89:
  58069 		v11 = v7 + v9 - int32(14234)
  58070 		if v11 & ^int32(YUV_MASK2) == 0 {
  58071 			v14 = v11 >> int32(YUV_FIX2)
  58072 		} else {
  58073 			if v11 < 0 {
  58074 				v15 = 0
  58075 			} else {
  58076 				v15 = int32(255)
  58077 			}
  58078 			v14 = v15
  58079 		}
  58080 		v12 = v14
  58081 		goto _92
  58082 	_92:
  58083 		v5 = v12
  58084 		goto _85
  58085 	_85:
  58086 		r = v5
  58087 		v18 = v1 * int32(19077) >> int32(8)
  58088 		goto _98
  58089 	_98:
  58090 		v20 = v2 * int32(6419) >> int32(8)
  58091 		goto _100
  58092 	_100:
  58093 		v22 = v3 * int32(13320) >> int32(8)
  58094 		goto _102
  58095 	_102:
  58096 		v24 = v18 - v20 - v22 + int32(8708)
  58097 		if v24 & ^int32(YUV_MASK2) == 0 {
  58098 			v27 = v24 >> int32(YUV_FIX2)
  58099 		} else {
  58100 			if v24 < 0 {
  58101 				v28 = 0
  58102 			} else {
  58103 				v28 = int32(255)
  58104 			}
  58105 			v27 = v28
  58106 		}
  58107 		v25 = v27
  58108 		goto _105
  58109 	_105:
  58110 		v16 = v25
  58111 		goto _96
  58112 	_96:
  58113 		g = v16
  58114 		v31 = v1 * int32(19077) >> int32(8)
  58115 		goto _111
  58116 	_111:
  58117 		v33 = v2 * int32(33050) >> int32(8)
  58118 		goto _113
  58119 	_113:
  58120 		v35 = v31 + v33 - int32(17685)
  58121 		if v35 & ^int32(YUV_MASK2) == 0 {
  58122 			v38 = v35 >> int32(YUV_FIX2)
  58123 		} else {
  58124 			if v35 < 0 {
  58125 				v39 = 0
  58126 			} else {
  58127 				v39 = int32(255)
  58128 			}
  58129 			v38 = v39
  58130 		}
  58131 		v36 = v38
  58132 		goto _116
  58133 	_116:
  58134 		v29 = v36
  58135 		goto _109
  58136 	_109:
  58137 		b = v29
  58138 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58139 		ba = b&int32(0xf0) | int32(0x0f)
  58140 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58141 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58142 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  58143 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  58144 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  58145 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(2))
  58146 		v7 = v1 * int32(19077) >> int32(8)
  58147 		goto _126
  58148 	_126:
  58149 		v9 = v3 * int32(26149) >> int32(8)
  58150 		goto _128
  58151 	_128:
  58152 		v11 = v7 + v9 - int32(14234)
  58153 		if v11 & ^int32(YUV_MASK2) == 0 {
  58154 			v14 = v11 >> int32(YUV_FIX2)
  58155 		} else {
  58156 			if v11 < 0 {
  58157 				v15 = 0
  58158 			} else {
  58159 				v15 = int32(255)
  58160 			}
  58161 			v14 = v15
  58162 		}
  58163 		v12 = v14
  58164 		goto _131
  58165 	_131:
  58166 		v5 = v12
  58167 		goto _124
  58168 	_124:
  58169 		r = v5
  58170 		v18 = v1 * int32(19077) >> int32(8)
  58171 		goto _137
  58172 	_137:
  58173 		v20 = v2 * int32(6419) >> int32(8)
  58174 		goto _139
  58175 	_139:
  58176 		v22 = v3 * int32(13320) >> int32(8)
  58177 		goto _141
  58178 	_141:
  58179 		v24 = v18 - v20 - v22 + int32(8708)
  58180 		if v24 & ^int32(YUV_MASK2) == 0 {
  58181 			v27 = v24 >> int32(YUV_FIX2)
  58182 		} else {
  58183 			if v24 < 0 {
  58184 				v28 = 0
  58185 			} else {
  58186 				v28 = int32(255)
  58187 			}
  58188 			v27 = v28
  58189 		}
  58190 		v25 = v27
  58191 		goto _144
  58192 	_144:
  58193 		v16 = v25
  58194 		goto _135
  58195 	_135:
  58196 		g = v16
  58197 		v31 = v1 * int32(19077) >> int32(8)
  58198 		goto _150
  58199 	_150:
  58200 		v33 = v2 * int32(33050) >> int32(8)
  58201 		goto _152
  58202 	_152:
  58203 		v35 = v31 + v33 - int32(17685)
  58204 		if v35 & ^int32(YUV_MASK2) == 0 {
  58205 			v38 = v35 >> int32(YUV_FIX2)
  58206 		} else {
  58207 			if v35 < 0 {
  58208 				v39 = 0
  58209 			} else {
  58210 				v39 = int32(255)
  58211 			}
  58212 			v38 = v39
  58213 		}
  58214 		v36 = v38
  58215 		goto _155
  58216 	_155:
  58217 		v29 = v36
  58218 		goto _148
  58219 	_148:
  58220 		b = v29
  58221 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58222 		ba = b&int32(0xf0) | int32(0x0f)
  58223 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58224 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58225 		if bottom_y != libc.UintptrFromInt32(0) {
  58226 			uv03 = (diag_03 + l_uv) >> int32(1)
  58227 			uv11 = (diag_12 + uv) >> int32(1)
  58228 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  58229 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  58230 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  58231 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58232 			v7 = v1 * int32(19077) >> int32(8)
  58233 			goto _165
  58234 		_165:
  58235 			v9 = v3 * int32(26149) >> int32(8)
  58236 			goto _167
  58237 		_167:
  58238 			v11 = v7 + v9 - int32(14234)
  58239 			if v11 & ^int32(YUV_MASK2) == 0 {
  58240 				v14 = v11 >> int32(YUV_FIX2)
  58241 			} else {
  58242 				if v11 < 0 {
  58243 					v15 = 0
  58244 				} else {
  58245 					v15 = int32(255)
  58246 				}
  58247 				v14 = v15
  58248 			}
  58249 			v12 = v14
  58250 			goto _170
  58251 		_170:
  58252 			v5 = v12
  58253 			goto _163
  58254 		_163:
  58255 			r = v5
  58256 			v18 = v1 * int32(19077) >> int32(8)
  58257 			goto _176
  58258 		_176:
  58259 			v20 = v2 * int32(6419) >> int32(8)
  58260 			goto _178
  58261 		_178:
  58262 			v22 = v3 * int32(13320) >> int32(8)
  58263 			goto _180
  58264 		_180:
  58265 			v24 = v18 - v20 - v22 + int32(8708)
  58266 			if v24 & ^int32(YUV_MASK2) == 0 {
  58267 				v27 = v24 >> int32(YUV_FIX2)
  58268 			} else {
  58269 				if v24 < 0 {
  58270 					v28 = 0
  58271 				} else {
  58272 					v28 = int32(255)
  58273 				}
  58274 				v27 = v28
  58275 			}
  58276 			v25 = v27
  58277 			goto _183
  58278 		_183:
  58279 			v16 = v25
  58280 			goto _174
  58281 		_174:
  58282 			g = v16
  58283 			v31 = v1 * int32(19077) >> int32(8)
  58284 			goto _189
  58285 		_189:
  58286 			v33 = v2 * int32(33050) >> int32(8)
  58287 			goto _191
  58288 		_191:
  58289 			v35 = v31 + v33 - int32(17685)
  58290 			if v35 & ^int32(YUV_MASK2) == 0 {
  58291 				v38 = v35 >> int32(YUV_FIX2)
  58292 			} else {
  58293 				if v35 < 0 {
  58294 					v39 = 0
  58295 				} else {
  58296 					v39 = int32(255)
  58297 				}
  58298 				v38 = v39
  58299 			}
  58300 			v36 = v38
  58301 			goto _194
  58302 		_194:
  58303 			v29 = v36
  58304 			goto _187
  58305 		_187:
  58306 			b = v29
  58307 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58308 			ba = b&int32(0xf0) | int32(0x0f)
  58309 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58310 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58311 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  58312 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  58313 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  58314 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(2))
  58315 			v7 = v1 * int32(19077) >> int32(8)
  58316 			goto _204
  58317 		_204:
  58318 			v9 = v3 * int32(26149) >> int32(8)
  58319 			goto _206
  58320 		_206:
  58321 			v11 = v7 + v9 - int32(14234)
  58322 			if v11 & ^int32(YUV_MASK2) == 0 {
  58323 				v14 = v11 >> int32(YUV_FIX2)
  58324 			} else {
  58325 				if v11 < 0 {
  58326 					v15 = 0
  58327 				} else {
  58328 					v15 = int32(255)
  58329 				}
  58330 				v14 = v15
  58331 			}
  58332 			v12 = v14
  58333 			goto _209
  58334 		_209:
  58335 			v5 = v12
  58336 			goto _202
  58337 		_202:
  58338 			r = v5
  58339 			v18 = v1 * int32(19077) >> int32(8)
  58340 			goto _215
  58341 		_215:
  58342 			v20 = v2 * int32(6419) >> int32(8)
  58343 			goto _217
  58344 		_217:
  58345 			v22 = v3 * int32(13320) >> int32(8)
  58346 			goto _219
  58347 		_219:
  58348 			v24 = v18 - v20 - v22 + int32(8708)
  58349 			if v24 & ^int32(YUV_MASK2) == 0 {
  58350 				v27 = v24 >> int32(YUV_FIX2)
  58351 			} else {
  58352 				if v24 < 0 {
  58353 					v28 = 0
  58354 				} else {
  58355 					v28 = int32(255)
  58356 				}
  58357 				v27 = v28
  58358 			}
  58359 			v25 = v27
  58360 			goto _222
  58361 		_222:
  58362 			v16 = v25
  58363 			goto _213
  58364 		_213:
  58365 			g = v16
  58366 			v31 = v1 * int32(19077) >> int32(8)
  58367 			goto _228
  58368 		_228:
  58369 			v33 = v2 * int32(33050) >> int32(8)
  58370 			goto _230
  58371 		_230:
  58372 			v35 = v31 + v33 - int32(17685)
  58373 			if v35 & ^int32(YUV_MASK2) == 0 {
  58374 				v38 = v35 >> int32(YUV_FIX2)
  58375 			} else {
  58376 				if v35 < 0 {
  58377 					v39 = 0
  58378 				} else {
  58379 					v39 = int32(255)
  58380 				}
  58381 				v38 = v39
  58382 			}
  58383 			v36 = v38
  58384 			goto _233
  58385 		_233:
  58386 			v29 = v36
  58387 			goto _226
  58388 		_226:
  58389 			b = v29
  58390 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58391 			ba = b&int32(0xf0) | int32(0x0f)
  58392 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58393 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58394 		}
  58395 		tl_uv = t_uv
  58396 		l_uv = uv
  58397 		goto _79
  58398 	_79:
  58399 		;
  58400 		x = x + 1
  58401 	}
  58402 	if !(len1&libc.Int32FromInt32(1) != 0) {
  58403 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  58404 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  58405 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  58406 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  58407 		v4 = top_dst + uintptr((len1-int32(1))*int32(2))
  58408 		v7 = v1 * int32(19077) >> int32(8)
  58409 		goto _243
  58410 	_243:
  58411 		v9 = v3 * int32(26149) >> int32(8)
  58412 		goto _245
  58413 	_245:
  58414 		v11 = v7 + v9 - int32(14234)
  58415 		if v11 & ^int32(YUV_MASK2) == 0 {
  58416 			v14 = v11 >> int32(YUV_FIX2)
  58417 		} else {
  58418 			if v11 < 0 {
  58419 				v15 = 0
  58420 			} else {
  58421 				v15 = int32(255)
  58422 			}
  58423 			v14 = v15
  58424 		}
  58425 		v12 = v14
  58426 		goto _248
  58427 	_248:
  58428 		v5 = v12
  58429 		goto _241
  58430 	_241:
  58431 		r = v5
  58432 		v18 = v1 * int32(19077) >> int32(8)
  58433 		goto _254
  58434 	_254:
  58435 		v20 = v2 * int32(6419) >> int32(8)
  58436 		goto _256
  58437 	_256:
  58438 		v22 = v3 * int32(13320) >> int32(8)
  58439 		goto _258
  58440 	_258:
  58441 		v24 = v18 - v20 - v22 + int32(8708)
  58442 		if v24 & ^int32(YUV_MASK2) == 0 {
  58443 			v27 = v24 >> int32(YUV_FIX2)
  58444 		} else {
  58445 			if v24 < 0 {
  58446 				v28 = 0
  58447 			} else {
  58448 				v28 = int32(255)
  58449 			}
  58450 			v27 = v28
  58451 		}
  58452 		v25 = v27
  58453 		goto _261
  58454 	_261:
  58455 		v16 = v25
  58456 		goto _252
  58457 	_252:
  58458 		g = v16
  58459 		v31 = v1 * int32(19077) >> int32(8)
  58460 		goto _267
  58461 	_267:
  58462 		v33 = v2 * int32(33050) >> int32(8)
  58463 		goto _269
  58464 	_269:
  58465 		v35 = v31 + v33 - int32(17685)
  58466 		if v35 & ^int32(YUV_MASK2) == 0 {
  58467 			v38 = v35 >> int32(YUV_FIX2)
  58468 		} else {
  58469 			if v35 < 0 {
  58470 				v39 = 0
  58471 			} else {
  58472 				v39 = int32(255)
  58473 			}
  58474 			v38 = v39
  58475 		}
  58476 		v36 = v38
  58477 		goto _272
  58478 	_272:
  58479 		v29 = v36
  58480 		goto _265
  58481 	_265:
  58482 		b = v29
  58483 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58484 		ba = b&int32(0xf0) | int32(0x0f)
  58485 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58486 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58487 		if bottom_y != libc.UintptrFromInt32(0) {
  58488 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  58489 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  58490 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  58491 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  58492 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(2))
  58493 			v7 = v1 * int32(19077) >> int32(8)
  58494 			goto _282
  58495 		_282:
  58496 			v9 = v3 * int32(26149) >> int32(8)
  58497 			goto _284
  58498 		_284:
  58499 			v11 = v7 + v9 - int32(14234)
  58500 			if v11 & ^int32(YUV_MASK2) == 0 {
  58501 				v14 = v11 >> int32(YUV_FIX2)
  58502 			} else {
  58503 				if v11 < 0 {
  58504 					v15 = 0
  58505 				} else {
  58506 					v15 = int32(255)
  58507 				}
  58508 				v14 = v15
  58509 			}
  58510 			v12 = v14
  58511 			goto _287
  58512 		_287:
  58513 			v5 = v12
  58514 			goto _280
  58515 		_280:
  58516 			r = v5
  58517 			v18 = v1 * int32(19077) >> int32(8)
  58518 			goto _293
  58519 		_293:
  58520 			v20 = v2 * int32(6419) >> int32(8)
  58521 			goto _295
  58522 		_295:
  58523 			v22 = v3 * int32(13320) >> int32(8)
  58524 			goto _297
  58525 		_297:
  58526 			v24 = v18 - v20 - v22 + int32(8708)
  58527 			if v24 & ^int32(YUV_MASK2) == 0 {
  58528 				v27 = v24 >> int32(YUV_FIX2)
  58529 			} else {
  58530 				if v24 < 0 {
  58531 					v28 = 0
  58532 				} else {
  58533 					v28 = int32(255)
  58534 				}
  58535 				v27 = v28
  58536 			}
  58537 			v25 = v27
  58538 			goto _300
  58539 		_300:
  58540 			v16 = v25
  58541 			goto _291
  58542 		_291:
  58543 			g = v16
  58544 			v31 = v1 * int32(19077) >> int32(8)
  58545 			goto _306
  58546 		_306:
  58547 			v33 = v2 * int32(33050) >> int32(8)
  58548 			goto _308
  58549 		_308:
  58550 			v35 = v31 + v33 - int32(17685)
  58551 			if v35 & ^int32(YUV_MASK2) == 0 {
  58552 				v38 = v35 >> int32(YUV_FIX2)
  58553 			} else {
  58554 				if v35 < 0 {
  58555 					v39 = 0
  58556 				} else {
  58557 					v39 = int32(255)
  58558 				}
  58559 				v38 = v39
  58560 			}
  58561 			v36 = v38
  58562 			goto _311
  58563 		_311:
  58564 			v29 = v36
  58565 			goto _304
  58566 		_304:
  58567 			b = v29
  58568 			rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  58569 			ba = b&int32(0xf0) | int32(0x0f)
  58570 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58571 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  58572 		}
  58573 	}
  58574 }
  58575 
  58576 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) {
  58577 	var avg, diag_03, diag_12, l_uv, t_uv, tl_uv, uv, uv0, uv01, uv02, uv03, uv04, uv05, uv1, uv11 uint32_t
  58578 	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
  58579 	var v4 uintptr
  58580 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  58581 	last_pixel_pair = (len1 - int32(1)) >> int32(1)
  58582 	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 */
  58583 	l_uv = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_u))) | libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(cur_v)))<<libc.Int32FromInt32(16))
  58584 	uv0 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  58585 	v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y)))
  58586 	v2 = libc.Int32FromUint32(uv0 & uint32(0xff))
  58587 	v3 = libc.Int32FromUint32(uv0 >> libc.Int32FromInt32(16))
  58588 	v4 = top_dst
  58589 	v7 = v1 * int32(19077) >> int32(8)
  58590 	goto _8
  58591 _8:
  58592 	v9 = v3 * int32(26149) >> int32(8)
  58593 	goto _10
  58594 _10:
  58595 	v11 = v7 + v9 - int32(14234)
  58596 	if v11 & ^int32(YUV_MASK2) == 0 {
  58597 		v14 = v11 >> int32(YUV_FIX2)
  58598 	} else {
  58599 		if v11 < 0 {
  58600 			v15 = 0
  58601 		} else {
  58602 			v15 = int32(255)
  58603 		}
  58604 		v14 = v15
  58605 	}
  58606 	v12 = v14
  58607 	goto _13
  58608 _13:
  58609 	v5 = v12
  58610 	goto _6
  58611 _6:
  58612 	r = v5
  58613 	v18 = v1 * int32(19077) >> int32(8)
  58614 	goto _19
  58615 _19:
  58616 	v20 = v2 * int32(6419) >> int32(8)
  58617 	goto _21
  58618 _21:
  58619 	v22 = v3 * int32(13320) >> int32(8)
  58620 	goto _23
  58621 _23:
  58622 	v24 = v18 - v20 - v22 + int32(8708)
  58623 	if v24 & ^int32(YUV_MASK2) == 0 {
  58624 		v27 = v24 >> int32(YUV_FIX2)
  58625 	} else {
  58626 		if v24 < 0 {
  58627 			v28 = 0
  58628 		} else {
  58629 			v28 = int32(255)
  58630 		}
  58631 		v27 = v28
  58632 	}
  58633 	v25 = v27
  58634 	goto _26
  58635 _26:
  58636 	v16 = v25
  58637 	goto _17
  58638 _17:
  58639 	g = v16
  58640 	v31 = v1 * int32(19077) >> int32(8)
  58641 	goto _32
  58642 _32:
  58643 	v33 = v2 * int32(33050) >> int32(8)
  58644 	goto _34
  58645 _34:
  58646 	v35 = v31 + v33 - int32(17685)
  58647 	if v35 & ^int32(YUV_MASK2) == 0 {
  58648 		v38 = v35 >> int32(YUV_FIX2)
  58649 	} else {
  58650 		if v35 < 0 {
  58651 			v39 = 0
  58652 		} else {
  58653 			v39 = int32(255)
  58654 		}
  58655 		v38 = v39
  58656 	}
  58657 	v36 = v38
  58658 	goto _37
  58659 _37:
  58660 	v29 = v36
  58661 	goto _30
  58662 _30:
  58663 	b = v29
  58664 	rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58665 	gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58666 	**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58667 	**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58668 	if bottom_y != libc.UintptrFromInt32(0) {
  58669 		uv01 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  58670 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y)))
  58671 		v2 = libc.Int32FromUint32(uv01 & uint32(0xff))
  58672 		v3 = libc.Int32FromUint32(uv01 >> libc.Int32FromInt32(16))
  58673 		v4 = bottom_dst
  58674 		v7 = v1 * int32(19077) >> int32(8)
  58675 		goto _47
  58676 	_47:
  58677 		v9 = v3 * int32(26149) >> int32(8)
  58678 		goto _49
  58679 	_49:
  58680 		v11 = v7 + v9 - int32(14234)
  58681 		if v11 & ^int32(YUV_MASK2) == 0 {
  58682 			v14 = v11 >> int32(YUV_FIX2)
  58683 		} else {
  58684 			if v11 < 0 {
  58685 				v15 = 0
  58686 			} else {
  58687 				v15 = int32(255)
  58688 			}
  58689 			v14 = v15
  58690 		}
  58691 		v12 = v14
  58692 		goto _52
  58693 	_52:
  58694 		v5 = v12
  58695 		goto _45
  58696 	_45:
  58697 		r = v5
  58698 		v18 = v1 * int32(19077) >> int32(8)
  58699 		goto _58
  58700 	_58:
  58701 		v20 = v2 * int32(6419) >> int32(8)
  58702 		goto _60
  58703 	_60:
  58704 		v22 = v3 * int32(13320) >> int32(8)
  58705 		goto _62
  58706 	_62:
  58707 		v24 = v18 - v20 - v22 + int32(8708)
  58708 		if v24 & ^int32(YUV_MASK2) == 0 {
  58709 			v27 = v24 >> int32(YUV_FIX2)
  58710 		} else {
  58711 			if v24 < 0 {
  58712 				v28 = 0
  58713 			} else {
  58714 				v28 = int32(255)
  58715 			}
  58716 			v27 = v28
  58717 		}
  58718 		v25 = v27
  58719 		goto _65
  58720 	_65:
  58721 		v16 = v25
  58722 		goto _56
  58723 	_56:
  58724 		g = v16
  58725 		v31 = v1 * int32(19077) >> int32(8)
  58726 		goto _71
  58727 	_71:
  58728 		v33 = v2 * int32(33050) >> int32(8)
  58729 		goto _73
  58730 	_73:
  58731 		v35 = v31 + v33 - int32(17685)
  58732 		if v35 & ^int32(YUV_MASK2) == 0 {
  58733 			v38 = v35 >> int32(YUV_FIX2)
  58734 		} else {
  58735 			if v35 < 0 {
  58736 				v39 = 0
  58737 			} else {
  58738 				v39 = int32(255)
  58739 			}
  58740 			v38 = v39
  58741 		}
  58742 		v36 = v38
  58743 		goto _76
  58744 	_76:
  58745 		v29 = v36
  58746 		goto _69
  58747 	_69:
  58748 		b = v29
  58749 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58750 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58751 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58752 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58753 	}
  58754 	x = int32(1)
  58755 	for {
  58756 		if !(x <= last_pixel_pair) {
  58757 			break
  58758 		}
  58759 		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 */
  58760 		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*/
  58761 		avg = tl_uv + t_uv + l_uv + uv + uint32(0x00080008)
  58762 		diag_12 = (avg + uint32(2)*(t_uv+l_uv)) >> int32(3)
  58763 		diag_03 = (avg + uint32(2)*(tl_uv+uv)) >> int32(3)
  58764 		uv02 = (diag_12 + tl_uv) >> int32(1)
  58765 		uv1 = (diag_03 + t_uv) >> int32(1)
  58766 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-int32(1)))))
  58767 		v2 = libc.Int32FromUint32(uv02 & uint32(0xff))
  58768 		v3 = libc.Int32FromUint32(uv02 >> libc.Int32FromInt32(16))
  58769 		v4 = top_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58770 		v7 = v1 * int32(19077) >> int32(8)
  58771 		goto _87
  58772 	_87:
  58773 		v9 = v3 * int32(26149) >> int32(8)
  58774 		goto _89
  58775 	_89:
  58776 		v11 = v7 + v9 - int32(14234)
  58777 		if v11 & ^int32(YUV_MASK2) == 0 {
  58778 			v14 = v11 >> int32(YUV_FIX2)
  58779 		} else {
  58780 			if v11 < 0 {
  58781 				v15 = 0
  58782 			} else {
  58783 				v15 = int32(255)
  58784 			}
  58785 			v14 = v15
  58786 		}
  58787 		v12 = v14
  58788 		goto _92
  58789 	_92:
  58790 		v5 = v12
  58791 		goto _85
  58792 	_85:
  58793 		r = v5
  58794 		v18 = v1 * int32(19077) >> int32(8)
  58795 		goto _98
  58796 	_98:
  58797 		v20 = v2 * int32(6419) >> int32(8)
  58798 		goto _100
  58799 	_100:
  58800 		v22 = v3 * int32(13320) >> int32(8)
  58801 		goto _102
  58802 	_102:
  58803 		v24 = v18 - v20 - v22 + int32(8708)
  58804 		if v24 & ^int32(YUV_MASK2) == 0 {
  58805 			v27 = v24 >> int32(YUV_FIX2)
  58806 		} else {
  58807 			if v24 < 0 {
  58808 				v28 = 0
  58809 			} else {
  58810 				v28 = int32(255)
  58811 			}
  58812 			v27 = v28
  58813 		}
  58814 		v25 = v27
  58815 		goto _105
  58816 	_105:
  58817 		v16 = v25
  58818 		goto _96
  58819 	_96:
  58820 		g = v16
  58821 		v31 = v1 * int32(19077) >> int32(8)
  58822 		goto _111
  58823 	_111:
  58824 		v33 = v2 * int32(33050) >> int32(8)
  58825 		goto _113
  58826 	_113:
  58827 		v35 = v31 + v33 - int32(17685)
  58828 		if v35 & ^int32(YUV_MASK2) == 0 {
  58829 			v38 = v35 >> int32(YUV_FIX2)
  58830 		} else {
  58831 			if v35 < 0 {
  58832 				v39 = 0
  58833 			} else {
  58834 				v39 = int32(255)
  58835 			}
  58836 			v38 = v39
  58837 		}
  58838 		v36 = v38
  58839 		goto _116
  58840 	_116:
  58841 		v29 = v36
  58842 		goto _109
  58843 	_109:
  58844 		b = v29
  58845 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58846 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58847 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58848 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58849 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(int32(2)*x-0))))
  58850 		v2 = libc.Int32FromUint32(uv1 & uint32(0xff))
  58851 		v3 = libc.Int32FromUint32(uv1 >> libc.Int32FromInt32(16))
  58852 		v4 = top_dst + uintptr((int32(2)*x-0)*int32(2))
  58853 		v7 = v1 * int32(19077) >> int32(8)
  58854 		goto _126
  58855 	_126:
  58856 		v9 = v3 * int32(26149) >> int32(8)
  58857 		goto _128
  58858 	_128:
  58859 		v11 = v7 + v9 - int32(14234)
  58860 		if v11 & ^int32(YUV_MASK2) == 0 {
  58861 			v14 = v11 >> int32(YUV_FIX2)
  58862 		} else {
  58863 			if v11 < 0 {
  58864 				v15 = 0
  58865 			} else {
  58866 				v15 = int32(255)
  58867 			}
  58868 			v14 = v15
  58869 		}
  58870 		v12 = v14
  58871 		goto _131
  58872 	_131:
  58873 		v5 = v12
  58874 		goto _124
  58875 	_124:
  58876 		r = v5
  58877 		v18 = v1 * int32(19077) >> int32(8)
  58878 		goto _137
  58879 	_137:
  58880 		v20 = v2 * int32(6419) >> int32(8)
  58881 		goto _139
  58882 	_139:
  58883 		v22 = v3 * int32(13320) >> int32(8)
  58884 		goto _141
  58885 	_141:
  58886 		v24 = v18 - v20 - v22 + int32(8708)
  58887 		if v24 & ^int32(YUV_MASK2) == 0 {
  58888 			v27 = v24 >> int32(YUV_FIX2)
  58889 		} else {
  58890 			if v24 < 0 {
  58891 				v28 = 0
  58892 			} else {
  58893 				v28 = int32(255)
  58894 			}
  58895 			v27 = v28
  58896 		}
  58897 		v25 = v27
  58898 		goto _144
  58899 	_144:
  58900 		v16 = v25
  58901 		goto _135
  58902 	_135:
  58903 		g = v16
  58904 		v31 = v1 * int32(19077) >> int32(8)
  58905 		goto _150
  58906 	_150:
  58907 		v33 = v2 * int32(33050) >> int32(8)
  58908 		goto _152
  58909 	_152:
  58910 		v35 = v31 + v33 - int32(17685)
  58911 		if v35 & ^int32(YUV_MASK2) == 0 {
  58912 			v38 = v35 >> int32(YUV_FIX2)
  58913 		} else {
  58914 			if v35 < 0 {
  58915 				v39 = 0
  58916 			} else {
  58917 				v39 = int32(255)
  58918 			}
  58919 			v38 = v39
  58920 		}
  58921 		v36 = v38
  58922 		goto _155
  58923 	_155:
  58924 		v29 = v36
  58925 		goto _148
  58926 	_148:
  58927 		b = v29
  58928 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  58929 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  58930 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  58931 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  58932 		if bottom_y != libc.UintptrFromInt32(0) {
  58933 			uv03 = (diag_03 + l_uv) >> int32(1)
  58934 			uv11 = (diag_12 + uv) >> int32(1)
  58935 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x-int32(1)))))
  58936 			v2 = libc.Int32FromUint32(uv03 & uint32(0xff))
  58937 			v3 = libc.Int32FromUint32(uv03 >> libc.Int32FromInt32(16))
  58938 			v4 = bottom_dst + uintptr((int32(2)*x-int32(1))*int32(2))
  58939 			v7 = v1 * int32(19077) >> int32(8)
  58940 			goto _165
  58941 		_165:
  58942 			v9 = v3 * int32(26149) >> int32(8)
  58943 			goto _167
  58944 		_167:
  58945 			v11 = v7 + v9 - int32(14234)
  58946 			if v11 & ^int32(YUV_MASK2) == 0 {
  58947 				v14 = v11 >> int32(YUV_FIX2)
  58948 			} else {
  58949 				if v11 < 0 {
  58950 					v15 = 0
  58951 				} else {
  58952 					v15 = int32(255)
  58953 				}
  58954 				v14 = v15
  58955 			}
  58956 			v12 = v14
  58957 			goto _170
  58958 		_170:
  58959 			v5 = v12
  58960 			goto _163
  58961 		_163:
  58962 			r = v5
  58963 			v18 = v1 * int32(19077) >> int32(8)
  58964 			goto _176
  58965 		_176:
  58966 			v20 = v2 * int32(6419) >> int32(8)
  58967 			goto _178
  58968 		_178:
  58969 			v22 = v3 * int32(13320) >> int32(8)
  58970 			goto _180
  58971 		_180:
  58972 			v24 = v18 - v20 - v22 + int32(8708)
  58973 			if v24 & ^int32(YUV_MASK2) == 0 {
  58974 				v27 = v24 >> int32(YUV_FIX2)
  58975 			} else {
  58976 				if v24 < 0 {
  58977 					v28 = 0
  58978 				} else {
  58979 					v28 = int32(255)
  58980 				}
  58981 				v27 = v28
  58982 			}
  58983 			v25 = v27
  58984 			goto _183
  58985 		_183:
  58986 			v16 = v25
  58987 			goto _174
  58988 		_174:
  58989 			g = v16
  58990 			v31 = v1 * int32(19077) >> int32(8)
  58991 			goto _189
  58992 		_189:
  58993 			v33 = v2 * int32(33050) >> int32(8)
  58994 			goto _191
  58995 		_191:
  58996 			v35 = v31 + v33 - int32(17685)
  58997 			if v35 & ^int32(YUV_MASK2) == 0 {
  58998 				v38 = v35 >> int32(YUV_FIX2)
  58999 			} else {
  59000 				if v35 < 0 {
  59001 					v39 = 0
  59002 				} else {
  59003 					v39 = int32(255)
  59004 				}
  59005 				v38 = v39
  59006 			}
  59007 			v36 = v38
  59008 			goto _194
  59009 		_194:
  59010 			v29 = v36
  59011 			goto _187
  59012 		_187:
  59013 			b = v29
  59014 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59015 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59016 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59017 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59018 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(int32(2)*x+0))))
  59019 			v2 = libc.Int32FromUint32(uv11 & uint32(0xff))
  59020 			v3 = libc.Int32FromUint32(uv11 >> libc.Int32FromInt32(16))
  59021 			v4 = bottom_dst + uintptr((int32(2)*x+0)*int32(2))
  59022 			v7 = v1 * int32(19077) >> int32(8)
  59023 			goto _204
  59024 		_204:
  59025 			v9 = v3 * int32(26149) >> int32(8)
  59026 			goto _206
  59027 		_206:
  59028 			v11 = v7 + v9 - int32(14234)
  59029 			if v11 & ^int32(YUV_MASK2) == 0 {
  59030 				v14 = v11 >> int32(YUV_FIX2)
  59031 			} else {
  59032 				if v11 < 0 {
  59033 					v15 = 0
  59034 				} else {
  59035 					v15 = int32(255)
  59036 				}
  59037 				v14 = v15
  59038 			}
  59039 			v12 = v14
  59040 			goto _209
  59041 		_209:
  59042 			v5 = v12
  59043 			goto _202
  59044 		_202:
  59045 			r = v5
  59046 			v18 = v1 * int32(19077) >> int32(8)
  59047 			goto _215
  59048 		_215:
  59049 			v20 = v2 * int32(6419) >> int32(8)
  59050 			goto _217
  59051 		_217:
  59052 			v22 = v3 * int32(13320) >> int32(8)
  59053 			goto _219
  59054 		_219:
  59055 			v24 = v18 - v20 - v22 + int32(8708)
  59056 			if v24 & ^int32(YUV_MASK2) == 0 {
  59057 				v27 = v24 >> int32(YUV_FIX2)
  59058 			} else {
  59059 				if v24 < 0 {
  59060 					v28 = 0
  59061 				} else {
  59062 					v28 = int32(255)
  59063 				}
  59064 				v27 = v28
  59065 			}
  59066 			v25 = v27
  59067 			goto _222
  59068 		_222:
  59069 			v16 = v25
  59070 			goto _213
  59071 		_213:
  59072 			g = v16
  59073 			v31 = v1 * int32(19077) >> int32(8)
  59074 			goto _228
  59075 		_228:
  59076 			v33 = v2 * int32(33050) >> int32(8)
  59077 			goto _230
  59078 		_230:
  59079 			v35 = v31 + v33 - int32(17685)
  59080 			if v35 & ^int32(YUV_MASK2) == 0 {
  59081 				v38 = v35 >> int32(YUV_FIX2)
  59082 			} else {
  59083 				if v35 < 0 {
  59084 					v39 = 0
  59085 				} else {
  59086 					v39 = int32(255)
  59087 				}
  59088 				v38 = v39
  59089 			}
  59090 			v36 = v38
  59091 			goto _233
  59092 		_233:
  59093 			v29 = v36
  59094 			goto _226
  59095 		_226:
  59096 			b = v29
  59097 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59098 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59099 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59100 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59101 		}
  59102 		tl_uv = t_uv
  59103 		l_uv = uv
  59104 		goto _79
  59105 	_79:
  59106 		;
  59107 		x = x + 1
  59108 	}
  59109 	if !(len1&libc.Int32FromInt32(1) != 0) {
  59110 		uv04 = (uint32(3)*tl_uv + l_uv + uint32(0x00020002)) >> int32(2)
  59111 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(top_y + uintptr(len1-int32(1)))))
  59112 		v2 = libc.Int32FromUint32(uv04 & uint32(0xff))
  59113 		v3 = libc.Int32FromUint32(uv04 >> libc.Int32FromInt32(16))
  59114 		v4 = top_dst + uintptr((len1-int32(1))*int32(2))
  59115 		v7 = v1 * int32(19077) >> int32(8)
  59116 		goto _243
  59117 	_243:
  59118 		v9 = v3 * int32(26149) >> int32(8)
  59119 		goto _245
  59120 	_245:
  59121 		v11 = v7 + v9 - int32(14234)
  59122 		if v11 & ^int32(YUV_MASK2) == 0 {
  59123 			v14 = v11 >> int32(YUV_FIX2)
  59124 		} else {
  59125 			if v11 < 0 {
  59126 				v15 = 0
  59127 			} else {
  59128 				v15 = int32(255)
  59129 			}
  59130 			v14 = v15
  59131 		}
  59132 		v12 = v14
  59133 		goto _248
  59134 	_248:
  59135 		v5 = v12
  59136 		goto _241
  59137 	_241:
  59138 		r = v5
  59139 		v18 = v1 * int32(19077) >> int32(8)
  59140 		goto _254
  59141 	_254:
  59142 		v20 = v2 * int32(6419) >> int32(8)
  59143 		goto _256
  59144 	_256:
  59145 		v22 = v3 * int32(13320) >> int32(8)
  59146 		goto _258
  59147 	_258:
  59148 		v24 = v18 - v20 - v22 + int32(8708)
  59149 		if v24 & ^int32(YUV_MASK2) == 0 {
  59150 			v27 = v24 >> int32(YUV_FIX2)
  59151 		} else {
  59152 			if v24 < 0 {
  59153 				v28 = 0
  59154 			} else {
  59155 				v28 = int32(255)
  59156 			}
  59157 			v27 = v28
  59158 		}
  59159 		v25 = v27
  59160 		goto _261
  59161 	_261:
  59162 		v16 = v25
  59163 		goto _252
  59164 	_252:
  59165 		g = v16
  59166 		v31 = v1 * int32(19077) >> int32(8)
  59167 		goto _267
  59168 	_267:
  59169 		v33 = v2 * int32(33050) >> int32(8)
  59170 		goto _269
  59171 	_269:
  59172 		v35 = v31 + v33 - int32(17685)
  59173 		if v35 & ^int32(YUV_MASK2) == 0 {
  59174 			v38 = v35 >> int32(YUV_FIX2)
  59175 		} else {
  59176 			if v35 < 0 {
  59177 				v39 = 0
  59178 			} else {
  59179 				v39 = int32(255)
  59180 			}
  59181 			v38 = v39
  59182 		}
  59183 		v36 = v38
  59184 		goto _272
  59185 	_272:
  59186 		v29 = v36
  59187 		goto _265
  59188 	_265:
  59189 		b = v29
  59190 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59191 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59192 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59193 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59194 		if bottom_y != libc.UintptrFromInt32(0) {
  59195 			uv05 = (uint32(3)*l_uv + tl_uv + uint32(0x00020002)) >> int32(2)
  59196 			v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(bottom_y + uintptr(len1-int32(1)))))
  59197 			v2 = libc.Int32FromUint32(uv05 & uint32(0xff))
  59198 			v3 = libc.Int32FromUint32(uv05 >> libc.Int32FromInt32(16))
  59199 			v4 = bottom_dst + uintptr((len1-int32(1))*int32(2))
  59200 			v7 = v1 * int32(19077) >> int32(8)
  59201 			goto _282
  59202 		_282:
  59203 			v9 = v3 * int32(26149) >> int32(8)
  59204 			goto _284
  59205 		_284:
  59206 			v11 = v7 + v9 - int32(14234)
  59207 			if v11 & ^int32(YUV_MASK2) == 0 {
  59208 				v14 = v11 >> int32(YUV_FIX2)
  59209 			} else {
  59210 				if v11 < 0 {
  59211 					v15 = 0
  59212 				} else {
  59213 					v15 = int32(255)
  59214 				}
  59215 				v14 = v15
  59216 			}
  59217 			v12 = v14
  59218 			goto _287
  59219 		_287:
  59220 			v5 = v12
  59221 			goto _280
  59222 		_280:
  59223 			r = v5
  59224 			v18 = v1 * int32(19077) >> int32(8)
  59225 			goto _293
  59226 		_293:
  59227 			v20 = v2 * int32(6419) >> int32(8)
  59228 			goto _295
  59229 		_295:
  59230 			v22 = v3 * int32(13320) >> int32(8)
  59231 			goto _297
  59232 		_297:
  59233 			v24 = v18 - v20 - v22 + int32(8708)
  59234 			if v24 & ^int32(YUV_MASK2) == 0 {
  59235 				v27 = v24 >> int32(YUV_FIX2)
  59236 			} else {
  59237 				if v24 < 0 {
  59238 					v28 = 0
  59239 				} else {
  59240 					v28 = int32(255)
  59241 				}
  59242 				v27 = v28
  59243 			}
  59244 			v25 = v27
  59245 			goto _300
  59246 		_300:
  59247 			v16 = v25
  59248 			goto _291
  59249 		_291:
  59250 			g = v16
  59251 			v31 = v1 * int32(19077) >> int32(8)
  59252 			goto _306
  59253 		_306:
  59254 			v33 = v2 * int32(33050) >> int32(8)
  59255 			goto _308
  59256 		_308:
  59257 			v35 = v31 + v33 - int32(17685)
  59258 			if v35 & ^int32(YUV_MASK2) == 0 {
  59259 				v38 = v35 >> int32(YUV_FIX2)
  59260 			} else {
  59261 				if v35 < 0 {
  59262 					v39 = 0
  59263 				} else {
  59264 					v39 = int32(255)
  59265 				}
  59266 				v38 = v39
  59267 			}
  59268 			v36 = v38
  59269 			goto _311
  59270 		_311:
  59271 			v29 = v36
  59272 			goto _304
  59273 		_304:
  59274 			b = v29
  59275 			rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59276 			gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59277 			**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  59278 			**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  59279 		}
  59280 	}
  59281 }
  59282 
  59283 //------------------------------------------------------------------------------
  59284 
  59285 func WebPGetLinePairConverter(tls *libc.TLS, alpha_is_last int32) (r WebPUpsampleLinePairFunc) {
  59286 	var v1 int32
  59287 	_ = v1
  59288 	WebPInitUpsamplers(tls)
  59289 	if alpha_is_last != 0 {
  59290 		v1 = int32(MODE_BGRA)
  59291 	} else {
  59292 		v1 = int32(MODE_ARGB)
  59293 	}
  59294 	return WebPUpsamplers[v1]
  59295 }
  59296 
  59297 func WebPYuv444ToRgba_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59298 	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
  59299 	var v2, v61 uintptr
  59300 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59301 	i = 0
  59302 	for {
  59303 		if !(i < len1) {
  59304 			break
  59305 		}
  59306 		v2 = dst + uintptr(i*int32(4))
  59307 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59308 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59309 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59310 		v61 = v2
  59311 		v9 = v3 * int32(19077) >> int32(8)
  59312 		goto _10
  59313 	_10:
  59314 		v11 = v5 * int32(26149) >> int32(8)
  59315 		goto _12
  59316 	_12:
  59317 		v13 = v9 + v11 - int32(14234)
  59318 		if v13 & ^int32(YUV_MASK2) == 0 {
  59319 			v16 = v13 >> int32(YUV_FIX2)
  59320 		} else {
  59321 			if v13 < 0 {
  59322 				v17 = 0
  59323 			} else {
  59324 				v17 = int32(255)
  59325 			}
  59326 			v16 = v17
  59327 		}
  59328 		v14 = v16
  59329 		goto _15
  59330 	_15:
  59331 		v7 = v14
  59332 		goto _8
  59333 	_8:
  59334 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59335 		v20 = v3 * int32(19077) >> int32(8)
  59336 		goto _21
  59337 	_21:
  59338 		v22 = v4 * int32(6419) >> int32(8)
  59339 		goto _23
  59340 	_23:
  59341 		v24 = v5 * int32(13320) >> int32(8)
  59342 		goto _25
  59343 	_25:
  59344 		v26 = v20 - v22 - v24 + int32(8708)
  59345 		if v26 & ^int32(YUV_MASK2) == 0 {
  59346 			v29 = v26 >> int32(YUV_FIX2)
  59347 		} else {
  59348 			if v26 < 0 {
  59349 				v30 = 0
  59350 			} else {
  59351 				v30 = int32(255)
  59352 			}
  59353 			v29 = v30
  59354 		}
  59355 		v27 = v29
  59356 		goto _28
  59357 	_28:
  59358 		v18 = v27
  59359 		goto _19
  59360 	_19:
  59361 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59362 		v33 = v3 * int32(19077) >> int32(8)
  59363 		goto _34
  59364 	_34:
  59365 		v35 = v4 * int32(33050) >> int32(8)
  59366 		goto _36
  59367 	_36:
  59368 		v37 = v33 + v35 - int32(17685)
  59369 		if v37 & ^int32(YUV_MASK2) == 0 {
  59370 			v40 = v37 >> int32(YUV_FIX2)
  59371 		} else {
  59372 			if v37 < 0 {
  59373 				v41 = 0
  59374 			} else {
  59375 				v41 = int32(255)
  59376 			}
  59377 			v40 = v41
  59378 		}
  59379 		v38 = v40
  59380 		goto _39
  59381 	_39:
  59382 		v31 = v38
  59383 		goto _32
  59384 	_32:
  59385 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59386 		**(**uint8_t)(__ccgo_up(v2 + 3)) = uint8(0xff)
  59387 		goto _1
  59388 	_1:
  59389 		;
  59390 		i = i + 1
  59391 	}
  59392 }
  59393 
  59394 func WebPYuv444ToBgra_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59395 	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
  59396 	var v2, v61 uintptr
  59397 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59398 	i = 0
  59399 	for {
  59400 		if !(i < len1) {
  59401 			break
  59402 		}
  59403 		v2 = dst + uintptr(i*int32(4))
  59404 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59405 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59406 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59407 		v61 = v2
  59408 		v9 = v3 * int32(19077) >> int32(8)
  59409 		goto _10
  59410 	_10:
  59411 		v11 = v4 * int32(33050) >> int32(8)
  59412 		goto _12
  59413 	_12:
  59414 		v13 = v9 + v11 - int32(17685)
  59415 		if v13 & ^int32(YUV_MASK2) == 0 {
  59416 			v16 = v13 >> int32(YUV_FIX2)
  59417 		} else {
  59418 			if v13 < 0 {
  59419 				v17 = 0
  59420 			} else {
  59421 				v17 = int32(255)
  59422 			}
  59423 			v16 = v17
  59424 		}
  59425 		v14 = v16
  59426 		goto _15
  59427 	_15:
  59428 		v7 = v14
  59429 		goto _8
  59430 	_8:
  59431 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59432 		v20 = v3 * int32(19077) >> int32(8)
  59433 		goto _21
  59434 	_21:
  59435 		v22 = v4 * int32(6419) >> int32(8)
  59436 		goto _23
  59437 	_23:
  59438 		v24 = v5 * int32(13320) >> int32(8)
  59439 		goto _25
  59440 	_25:
  59441 		v26 = v20 - v22 - v24 + int32(8708)
  59442 		if v26 & ^int32(YUV_MASK2) == 0 {
  59443 			v29 = v26 >> int32(YUV_FIX2)
  59444 		} else {
  59445 			if v26 < 0 {
  59446 				v30 = 0
  59447 			} else {
  59448 				v30 = int32(255)
  59449 			}
  59450 			v29 = v30
  59451 		}
  59452 		v27 = v29
  59453 		goto _28
  59454 	_28:
  59455 		v18 = v27
  59456 		goto _19
  59457 	_19:
  59458 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59459 		v33 = v3 * int32(19077) >> int32(8)
  59460 		goto _34
  59461 	_34:
  59462 		v35 = v5 * int32(26149) >> int32(8)
  59463 		goto _36
  59464 	_36:
  59465 		v37 = v33 + v35 - int32(14234)
  59466 		if v37 & ^int32(YUV_MASK2) == 0 {
  59467 			v40 = v37 >> int32(YUV_FIX2)
  59468 		} else {
  59469 			if v37 < 0 {
  59470 				v41 = 0
  59471 			} else {
  59472 				v41 = int32(255)
  59473 			}
  59474 			v40 = v41
  59475 		}
  59476 		v38 = v40
  59477 		goto _39
  59478 	_39:
  59479 		v31 = v38
  59480 		goto _32
  59481 	_32:
  59482 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59483 		**(**uint8_t)(__ccgo_up(v2 + 3)) = uint8(0xff)
  59484 		goto _1
  59485 	_1:
  59486 		;
  59487 		i = i + 1
  59488 	}
  59489 }
  59490 
  59491 func WebPYuv444ToRgb_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59492 	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
  59493 	var v51 uintptr
  59494 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59495 	i = 0
  59496 	for {
  59497 		if !(i < len1) {
  59498 			break
  59499 		}
  59500 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59501 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59502 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59503 		v51 = dst + uintptr(i*int32(3))
  59504 		v8 = v2 * int32(19077) >> int32(8)
  59505 		goto _9
  59506 	_9:
  59507 		v10 = v4 * int32(26149) >> int32(8)
  59508 		goto _11
  59509 	_11:
  59510 		v12 = v8 + v10 - int32(14234)
  59511 		if v12 & ^int32(YUV_MASK2) == 0 {
  59512 			v15 = v12 >> int32(YUV_FIX2)
  59513 		} else {
  59514 			if v12 < 0 {
  59515 				v16 = 0
  59516 			} else {
  59517 				v16 = int32(255)
  59518 			}
  59519 			v15 = v16
  59520 		}
  59521 		v13 = v15
  59522 		goto _14
  59523 	_14:
  59524 		v6 = v13
  59525 		goto _7
  59526 	_7:
  59527 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(v6)
  59528 		v19 = v2 * int32(19077) >> int32(8)
  59529 		goto _20
  59530 	_20:
  59531 		v21 = v3 * int32(6419) >> int32(8)
  59532 		goto _22
  59533 	_22:
  59534 		v23 = v4 * int32(13320) >> int32(8)
  59535 		goto _24
  59536 	_24:
  59537 		v25 = v19 - v21 - v23 + int32(8708)
  59538 		if v25 & ^int32(YUV_MASK2) == 0 {
  59539 			v28 = v25 >> int32(YUV_FIX2)
  59540 		} else {
  59541 			if v25 < 0 {
  59542 				v29 = 0
  59543 			} else {
  59544 				v29 = int32(255)
  59545 			}
  59546 			v28 = v29
  59547 		}
  59548 		v26 = v28
  59549 		goto _27
  59550 	_27:
  59551 		v17 = v26
  59552 		goto _18
  59553 	_18:
  59554 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(v17)
  59555 		v32 = v2 * int32(19077) >> int32(8)
  59556 		goto _33
  59557 	_33:
  59558 		v34 = v3 * int32(33050) >> int32(8)
  59559 		goto _35
  59560 	_35:
  59561 		v36 = v32 + v34 - int32(17685)
  59562 		if v36 & ^int32(YUV_MASK2) == 0 {
  59563 			v39 = v36 >> int32(YUV_FIX2)
  59564 		} else {
  59565 			if v36 < 0 {
  59566 				v40 = 0
  59567 			} else {
  59568 				v40 = int32(255)
  59569 			}
  59570 			v39 = v40
  59571 		}
  59572 		v37 = v39
  59573 		goto _38
  59574 	_38:
  59575 		v30 = v37
  59576 		goto _31
  59577 	_31:
  59578 		**(**uint8_t)(__ccgo_up(v51 + 2)) = libc.Uint8FromInt32(v30)
  59579 		goto _1
  59580 	_1:
  59581 		;
  59582 		i = i + 1
  59583 	}
  59584 }
  59585 
  59586 func WebPYuv444ToBgr_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59587 	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
  59588 	var v51 uintptr
  59589 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59590 	i = 0
  59591 	for {
  59592 		if !(i < len1) {
  59593 			break
  59594 		}
  59595 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59596 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59597 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59598 		v51 = dst + uintptr(i*int32(3))
  59599 		v8 = v2 * int32(19077) >> int32(8)
  59600 		goto _9
  59601 	_9:
  59602 		v10 = v3 * int32(33050) >> int32(8)
  59603 		goto _11
  59604 	_11:
  59605 		v12 = v8 + v10 - int32(17685)
  59606 		if v12 & ^int32(YUV_MASK2) == 0 {
  59607 			v15 = v12 >> int32(YUV_FIX2)
  59608 		} else {
  59609 			if v12 < 0 {
  59610 				v16 = 0
  59611 			} else {
  59612 				v16 = int32(255)
  59613 			}
  59614 			v15 = v16
  59615 		}
  59616 		v13 = v15
  59617 		goto _14
  59618 	_14:
  59619 		v6 = v13
  59620 		goto _7
  59621 	_7:
  59622 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(v6)
  59623 		v19 = v2 * int32(19077) >> int32(8)
  59624 		goto _20
  59625 	_20:
  59626 		v21 = v3 * int32(6419) >> int32(8)
  59627 		goto _22
  59628 	_22:
  59629 		v23 = v4 * int32(13320) >> int32(8)
  59630 		goto _24
  59631 	_24:
  59632 		v25 = v19 - v21 - v23 + int32(8708)
  59633 		if v25 & ^int32(YUV_MASK2) == 0 {
  59634 			v28 = v25 >> int32(YUV_FIX2)
  59635 		} else {
  59636 			if v25 < 0 {
  59637 				v29 = 0
  59638 			} else {
  59639 				v29 = int32(255)
  59640 			}
  59641 			v28 = v29
  59642 		}
  59643 		v26 = v28
  59644 		goto _27
  59645 	_27:
  59646 		v17 = v26
  59647 		goto _18
  59648 	_18:
  59649 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(v17)
  59650 		v32 = v2 * int32(19077) >> int32(8)
  59651 		goto _33
  59652 	_33:
  59653 		v34 = v4 * int32(26149) >> int32(8)
  59654 		goto _35
  59655 	_35:
  59656 		v36 = v32 + v34 - int32(14234)
  59657 		if v36 & ^int32(YUV_MASK2) == 0 {
  59658 			v39 = v36 >> int32(YUV_FIX2)
  59659 		} else {
  59660 			if v36 < 0 {
  59661 				v40 = 0
  59662 			} else {
  59663 				v40 = int32(255)
  59664 			}
  59665 			v39 = v40
  59666 		}
  59667 		v37 = v39
  59668 		goto _38
  59669 	_38:
  59670 		v30 = v37
  59671 		goto _31
  59672 	_31:
  59673 		**(**uint8_t)(__ccgo_up(v51 + 2)) = libc.Uint8FromInt32(v30)
  59674 		goto _1
  59675 	_1:
  59676 		;
  59677 		i = i + 1
  59678 	}
  59679 }
  59680 
  59681 func WebPYuv444ToArgb_C(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  59682 	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
  59683 	var v2, v61 uintptr
  59684 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59685 	i = 0
  59686 	for {
  59687 		if !(i < len1) {
  59688 			break
  59689 		}
  59690 		v2 = dst + uintptr(i*int32(4))
  59691 		**(**uint8_t)(__ccgo_up(v2)) = uint8(0xff)
  59692 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + uintptr(i))))
  59693 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4 + uintptr(i))))
  59694 		v5 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6 + uintptr(i))))
  59695 		v61 = v2 + uintptr(1)
  59696 		v9 = v3 * int32(19077) >> int32(8)
  59697 		goto _10
  59698 	_10:
  59699 		v11 = v5 * int32(26149) >> int32(8)
  59700 		goto _12
  59701 	_12:
  59702 		v13 = v9 + v11 - int32(14234)
  59703 		if v13 & ^int32(YUV_MASK2) == 0 {
  59704 			v16 = v13 >> int32(YUV_FIX2)
  59705 		} else {
  59706 			if v13 < 0 {
  59707 				v17 = 0
  59708 			} else {
  59709 				v17 = int32(255)
  59710 			}
  59711 			v16 = v17
  59712 		}
  59713 		v14 = v16
  59714 		goto _15
  59715 	_15:
  59716 		v7 = v14
  59717 		goto _8
  59718 	_8:
  59719 		**(**uint8_t)(__ccgo_up(v61)) = libc.Uint8FromInt32(v7)
  59720 		v20 = v3 * int32(19077) >> int32(8)
  59721 		goto _21
  59722 	_21:
  59723 		v22 = v4 * int32(6419) >> int32(8)
  59724 		goto _23
  59725 	_23:
  59726 		v24 = v5 * int32(13320) >> int32(8)
  59727 		goto _25
  59728 	_25:
  59729 		v26 = v20 - v22 - v24 + int32(8708)
  59730 		if v26 & ^int32(YUV_MASK2) == 0 {
  59731 			v29 = v26 >> int32(YUV_FIX2)
  59732 		} else {
  59733 			if v26 < 0 {
  59734 				v30 = 0
  59735 			} else {
  59736 				v30 = int32(255)
  59737 			}
  59738 			v29 = v30
  59739 		}
  59740 		v27 = v29
  59741 		goto _28
  59742 	_28:
  59743 		v18 = v27
  59744 		goto _19
  59745 	_19:
  59746 		**(**uint8_t)(__ccgo_up(v61 + 1)) = libc.Uint8FromInt32(v18)
  59747 		v33 = v3 * int32(19077) >> int32(8)
  59748 		goto _34
  59749 	_34:
  59750 		v35 = v4 * int32(33050) >> int32(8)
  59751 		goto _36
  59752 	_36:
  59753 		v37 = v33 + v35 - int32(17685)
  59754 		if v37 & ^int32(YUV_MASK2) == 0 {
  59755 			v40 = v37 >> int32(YUV_FIX2)
  59756 		} else {
  59757 			if v37 < 0 {
  59758 				v41 = 0
  59759 			} else {
  59760 				v41 = int32(255)
  59761 			}
  59762 			v40 = v41
  59763 		}
  59764 		v38 = v40
  59765 		goto _39
  59766 	_39:
  59767 		v31 = v38
  59768 		goto _32
  59769 	_32:
  59770 		**(**uint8_t)(__ccgo_up(v61 + 2)) = libc.Uint8FromInt32(v31)
  59771 		goto _1
  59772 	_1:
  59773 		;
  59774 		i = i + 1
  59775 	}
  59776 }
  59777 
  59778 func WebPYuv444ToRgba4444_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59779 	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
  59780 	var v51 uintptr
  59781 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59782 	i = 0
  59783 	for {
  59784 		if !(i < len1) {
  59785 			break
  59786 		}
  59787 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59788 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59789 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59790 		v51 = dst + uintptr(i*int32(2))
  59791 		v8 = v2 * int32(19077) >> int32(8)
  59792 		goto _9
  59793 	_9:
  59794 		v10 = v4 * int32(26149) >> int32(8)
  59795 		goto _11
  59796 	_11:
  59797 		v12 = v8 + v10 - int32(14234)
  59798 		if v12 & ^int32(YUV_MASK2) == 0 {
  59799 			v15 = v12 >> int32(YUV_FIX2)
  59800 		} else {
  59801 			if v12 < 0 {
  59802 				v16 = 0
  59803 			} else {
  59804 				v16 = int32(255)
  59805 			}
  59806 			v15 = v16
  59807 		}
  59808 		v13 = v15
  59809 		goto _14
  59810 	_14:
  59811 		v6 = v13
  59812 		goto _7
  59813 	_7:
  59814 		r = v6
  59815 		v19 = v2 * int32(19077) >> int32(8)
  59816 		goto _20
  59817 	_20:
  59818 		v21 = v3 * int32(6419) >> int32(8)
  59819 		goto _22
  59820 	_22:
  59821 		v23 = v4 * int32(13320) >> int32(8)
  59822 		goto _24
  59823 	_24:
  59824 		v25 = v19 - v21 - v23 + int32(8708)
  59825 		if v25 & ^int32(YUV_MASK2) == 0 {
  59826 			v28 = v25 >> int32(YUV_FIX2)
  59827 		} else {
  59828 			if v25 < 0 {
  59829 				v29 = 0
  59830 			} else {
  59831 				v29 = int32(255)
  59832 			}
  59833 			v28 = v29
  59834 		}
  59835 		v26 = v28
  59836 		goto _27
  59837 	_27:
  59838 		v17 = v26
  59839 		goto _18
  59840 	_18:
  59841 		g = v17
  59842 		v32 = v2 * int32(19077) >> int32(8)
  59843 		goto _33
  59844 	_33:
  59845 		v34 = v3 * int32(33050) >> int32(8)
  59846 		goto _35
  59847 	_35:
  59848 		v36 = v32 + v34 - int32(17685)
  59849 		if v36 & ^int32(YUV_MASK2) == 0 {
  59850 			v39 = v36 >> int32(YUV_FIX2)
  59851 		} else {
  59852 			if v36 < 0 {
  59853 				v40 = 0
  59854 			} else {
  59855 				v40 = int32(255)
  59856 			}
  59857 			v39 = v40
  59858 		}
  59859 		v37 = v39
  59860 		goto _38
  59861 	_38:
  59862 		v30 = v37
  59863 		goto _31
  59864 	_31:
  59865 		b = v30
  59866 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  59867 		ba = b&int32(0xf0) | int32(0x0f)
  59868 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(rg)
  59869 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(ba)
  59870 		goto _1
  59871 	_1:
  59872 		;
  59873 		i = i + 1
  59874 	}
  59875 }
  59876 
  59877 func WebPYuv444ToRgb565_C(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  59878 	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
  59879 	var v51 uintptr
  59880 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  59881 	i = 0
  59882 	for {
  59883 		if !(i < len1) {
  59884 			break
  59885 		}
  59886 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + uintptr(i))))
  59887 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3 + uintptr(i))))
  59888 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5 + uintptr(i))))
  59889 		v51 = dst + uintptr(i*int32(2))
  59890 		v8 = v2 * int32(19077) >> int32(8)
  59891 		goto _9
  59892 	_9:
  59893 		v10 = v4 * int32(26149) >> int32(8)
  59894 		goto _11
  59895 	_11:
  59896 		v12 = v8 + v10 - int32(14234)
  59897 		if v12 & ^int32(YUV_MASK2) == 0 {
  59898 			v15 = v12 >> int32(YUV_FIX2)
  59899 		} else {
  59900 			if v12 < 0 {
  59901 				v16 = 0
  59902 			} else {
  59903 				v16 = int32(255)
  59904 			}
  59905 			v15 = v16
  59906 		}
  59907 		v13 = v15
  59908 		goto _14
  59909 	_14:
  59910 		v6 = v13
  59911 		goto _7
  59912 	_7:
  59913 		r = v6
  59914 		v19 = v2 * int32(19077) >> int32(8)
  59915 		goto _20
  59916 	_20:
  59917 		v21 = v3 * int32(6419) >> int32(8)
  59918 		goto _22
  59919 	_22:
  59920 		v23 = v4 * int32(13320) >> int32(8)
  59921 		goto _24
  59922 	_24:
  59923 		v25 = v19 - v21 - v23 + int32(8708)
  59924 		if v25 & ^int32(YUV_MASK2) == 0 {
  59925 			v28 = v25 >> int32(YUV_FIX2)
  59926 		} else {
  59927 			if v25 < 0 {
  59928 				v29 = 0
  59929 			} else {
  59930 				v29 = int32(255)
  59931 			}
  59932 			v28 = v29
  59933 		}
  59934 		v26 = v28
  59935 		goto _27
  59936 	_27:
  59937 		v17 = v26
  59938 		goto _18
  59939 	_18:
  59940 		g = v17
  59941 		v32 = v2 * int32(19077) >> int32(8)
  59942 		goto _33
  59943 	_33:
  59944 		v34 = v3 * int32(33050) >> int32(8)
  59945 		goto _35
  59946 	_35:
  59947 		v36 = v32 + v34 - int32(17685)
  59948 		if v36 & ^int32(YUV_MASK2) == 0 {
  59949 			v39 = v36 >> int32(YUV_FIX2)
  59950 		} else {
  59951 			if v36 < 0 {
  59952 				v40 = 0
  59953 			} else {
  59954 				v40 = int32(255)
  59955 			}
  59956 			v39 = v40
  59957 		}
  59958 		v37 = v39
  59959 		goto _38
  59960 	_38:
  59961 		v30 = v37
  59962 		goto _31
  59963 	_31:
  59964 		b = v30
  59965 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  59966 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  59967 		**(**uint8_t)(__ccgo_up(v51)) = libc.Uint8FromInt32(rg)
  59968 		**(**uint8_t)(__ccgo_up(v51 + 1)) = libc.Uint8FromInt32(gb)
  59969 		goto _1
  59970 	_1:
  59971 		;
  59972 		i = i + 1
  59973 	}
  59974 }
  59975 
  59976 func WebPInitYUV444Converters(tls *libc.TLS) {
  59977 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  59978 		goto _1
  59979 	}
  59980 	WebPInitYUV444Converters_body(tls)
  59981 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used)), VP8GetCPUInfo)
  59982 	goto _2
  59983 _2:
  59984 	;
  59985 	goto _1
  59986 _1: /**/ //
  59987 }
  59988 
  59989 var WebPInitYUV444Converters_body_last_cpuinfo_used = uintptr(0)
  59990 
  59991 func init() {
  59992 	p := unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used)
  59993 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitYUV444Converters_body_last_cpuinfo_used))
  59994 }
  59995 
  59996 func WebPInitYUV444Converters_body(tls *libc.TLS) {
  59997 	WebPYUV444Converters[int32(MODE_RGBA)] = __ccgo_fp(WebPYuv444ToRgba_C)
  59998 	WebPYUV444Converters[int32(MODE_BGRA)] = __ccgo_fp(WebPYuv444ToBgra_C)
  59999 	WebPYUV444Converters[int32(MODE_RGB)] = __ccgo_fp(WebPYuv444ToRgb_C)
  60000 	WebPYUV444Converters[int32(MODE_BGR)] = __ccgo_fp(WebPYuv444ToBgr_C)
  60001 	WebPYUV444Converters[int32(MODE_ARGB)] = __ccgo_fp(WebPYuv444ToArgb_C)
  60002 	WebPYUV444Converters[int32(MODE_RGBA_4444)] = __ccgo_fp(WebPYuv444ToRgba4444_C)
  60003 	WebPYUV444Converters[int32(MODE_RGB_565)] = __ccgo_fp(WebPYuv444ToRgb565_C)
  60004 	WebPYUV444Converters[int32(MODE_rgbA)] = __ccgo_fp(WebPYuv444ToRgba_C)
  60005 	WebPYUV444Converters[int32(MODE_bgrA)] = __ccgo_fp(WebPYuv444ToBgra_C)
  60006 	WebPYUV444Converters[int32(MODE_Argb)] = __ccgo_fp(WebPYuv444ToArgb_C)
  60007 	WebPYUV444Converters[int32(MODE_rgbA_4444)] = __ccgo_fp(WebPYuv444ToRgba4444_C)
  60008 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  60009 	}
  60010 }
  60011 
  60012 func WebPInitUpsamplers(tls *libc.TLS) {
  60013 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  60014 		goto _1
  60015 	}
  60016 	WebPInitUpsamplers_body(tls)
  60017 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used)), VP8GetCPUInfo)
  60018 	goto _2
  60019 _2:
  60020 	;
  60021 	goto _1
  60022 _1: /**/ //
  60023 }
  60024 
  60025 var WebPInitUpsamplers_body_last_cpuinfo_used = uintptr(0)
  60026 
  60027 func init() {
  60028 	p := unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used)
  60029 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitUpsamplers_body_last_cpuinfo_used))
  60030 }
  60031 
  60032 func WebPInitUpsamplers_body(tls *libc.TLS) {
  60033 	WebPUpsamplers[int32(MODE_RGBA)] = __ccgo_fp(UpsampleRgbaLinePair_C)
  60034 	WebPUpsamplers[int32(MODE_BGRA)] = __ccgo_fp(UpsampleBgraLinePair_C)
  60035 	WebPUpsamplers[int32(MODE_rgbA)] = __ccgo_fp(UpsampleRgbaLinePair_C)
  60036 	WebPUpsamplers[int32(MODE_bgrA)] = __ccgo_fp(UpsampleBgraLinePair_C)
  60037 	WebPUpsamplers[int32(MODE_RGB)] = __ccgo_fp(UpsampleRgbLinePair_C)
  60038 	WebPUpsamplers[int32(MODE_BGR)] = __ccgo_fp(UpsampleBgrLinePair_C)
  60039 	WebPUpsamplers[int32(MODE_ARGB)] = __ccgo_fp(UpsampleArgbLinePair_C)
  60040 	WebPUpsamplers[int32(MODE_RGBA_4444)] = __ccgo_fp(UpsampleRgba4444LinePair_C)
  60041 	WebPUpsamplers[int32(MODE_RGB_565)] = __ccgo_fp(UpsampleRgb565LinePair_C)
  60042 	WebPUpsamplers[int32(MODE_Argb)] = __ccgo_fp(UpsampleArgbLinePair_C)
  60043 	WebPUpsamplers[int32(MODE_rgbA_4444)] = __ccgo_fp(UpsampleRgba4444LinePair_C)
  60044 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  60045 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  60046 	}
  60047 }
  60048 
  60049 func WebPInitYUV444ConvertersMIPSdspR2(tls *libc.TLS) {
  60050 }
  60051 
  60052 func WebPInitUpsamplersMIPSdspR2(tls *libc.TLS) {
  60053 }
  60054 
  60055 func WebPInitUpsamplersMSA(tls *libc.TLS) {
  60056 }
  60057 
  60058 func WebPInitUpsamplersNEON(tls *libc.TLS) {
  60059 }
  60060 
  60061 func WebPInitYUV444ConvertersSSE2(tls *libc.TLS) {
  60062 }
  60063 
  60064 func WebPInitUpsamplersSSE2(tls *libc.TLS) {
  60065 }
  60066 
  60067 func WebPInitYUV444ConvertersSSE41(tls *libc.TLS) {
  60068 }
  60069 
  60070 func WebPInitUpsamplersSSE41(tls *libc.TLS) {
  60071 }
  60072 
  60073 // Copyright 2010 Google Inc. All Rights Reserved.
  60074 //
  60075 // Use of this source code is governed by a BSD-style license
  60076 // that can be found in the COPYING file in the root of the source
  60077 // tree. An additional intellectual property rights grant can be found
  60078 // in the file PATENTS. All contributing project authors may
  60079 // be found in the AUTHORS file in the root of the source tree.
  60080 // -----------------------------------------------------------------------------
  60081 //
  60082 //  Main decoding functions for WebP images.
  60083 //
  60084 // Author: Skal (pascal.massimino@gmail.com)
  60085 
  60086 //-----------------------------------------------------------------------------
  60087 // Plain-C version
  60088 
  60089 // C documentation
  60090 //
  60091 //	// All variants implemented.
  60092 func YuvToRgbRow(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  60093 	var end, v4 uintptr
  60094 	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
  60095 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  60096 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(3))
  60097 	for dst != end {
  60098 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60099 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60100 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60101 		v4 = dst
  60102 		v7 = v1 * int32(19077) >> int32(8)
  60103 		goto _8
  60104 	_8:
  60105 		v9 = v3 * int32(26149) >> int32(8)
  60106 		goto _10
  60107 	_10:
  60108 		v11 = v7 + v9 - int32(14234)
  60109 		if v11 & ^int32(YUV_MASK2) == 0 {
  60110 			v14 = v11 >> int32(YUV_FIX2)
  60111 		} else {
  60112 			if v11 < 0 {
  60113 				v15 = 0
  60114 			} else {
  60115 				v15 = int32(255)
  60116 			}
  60117 			v14 = v15
  60118 		}
  60119 		v12 = v14
  60120 		goto _13
  60121 	_13:
  60122 		v51 = v12
  60123 		goto _6
  60124 	_6:
  60125 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60126 		v18 = v1 * int32(19077) >> int32(8)
  60127 		goto _19
  60128 	_19:
  60129 		v20 = v2 * int32(6419) >> int32(8)
  60130 		goto _21
  60131 	_21:
  60132 		v22 = v3 * int32(13320) >> int32(8)
  60133 		goto _23
  60134 	_23:
  60135 		v24 = v18 - v20 - v22 + int32(8708)
  60136 		if v24 & ^int32(YUV_MASK2) == 0 {
  60137 			v27 = v24 >> int32(YUV_FIX2)
  60138 		} else {
  60139 			if v24 < 0 {
  60140 				v28 = 0
  60141 			} else {
  60142 				v28 = int32(255)
  60143 			}
  60144 			v27 = v28
  60145 		}
  60146 		v25 = v27
  60147 		goto _26
  60148 	_26:
  60149 		v16 = v25
  60150 		goto _17
  60151 	_17:
  60152 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60153 		v31 = v1 * int32(19077) >> int32(8)
  60154 		goto _32
  60155 	_32:
  60156 		v33 = v2 * int32(33050) >> int32(8)
  60157 		goto _34
  60158 	_34:
  60159 		v35 = v31 + v33 - int32(17685)
  60160 		if v35 & ^int32(YUV_MASK2) == 0 {
  60161 			v38 = v35 >> int32(YUV_FIX2)
  60162 		} else {
  60163 			if v35 < 0 {
  60164 				v39 = 0
  60165 			} else {
  60166 				v39 = int32(255)
  60167 			}
  60168 			v38 = v39
  60169 		}
  60170 		v36 = v38
  60171 		goto _37
  60172 	_37:
  60173 		v29 = v36
  60174 		goto _30
  60175 	_30:
  60176 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60177 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  60178 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60179 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60180 		v4 = dst + uintptr(libc.Int32FromInt32(3))
  60181 		v7 = v1 * int32(19077) >> int32(8)
  60182 		goto _47
  60183 	_47:
  60184 		v9 = v3 * int32(26149) >> int32(8)
  60185 		goto _49
  60186 	_49:
  60187 		v11 = v7 + v9 - int32(14234)
  60188 		if v11 & ^int32(YUV_MASK2) == 0 {
  60189 			v14 = v11 >> int32(YUV_FIX2)
  60190 		} else {
  60191 			if v11 < 0 {
  60192 				v15 = 0
  60193 			} else {
  60194 				v15 = int32(255)
  60195 			}
  60196 			v14 = v15
  60197 		}
  60198 		v12 = v14
  60199 		goto _52
  60200 	_52:
  60201 		v51 = v12
  60202 		goto _45
  60203 	_45:
  60204 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60205 		v18 = v1 * int32(19077) >> int32(8)
  60206 		goto _58
  60207 	_58:
  60208 		v20 = v2 * int32(6419) >> int32(8)
  60209 		goto _60
  60210 	_60:
  60211 		v22 = v3 * int32(13320) >> int32(8)
  60212 		goto _62
  60213 	_62:
  60214 		v24 = v18 - v20 - v22 + int32(8708)
  60215 		if v24 & ^int32(YUV_MASK2) == 0 {
  60216 			v27 = v24 >> int32(YUV_FIX2)
  60217 		} else {
  60218 			if v24 < 0 {
  60219 				v28 = 0
  60220 			} else {
  60221 				v28 = int32(255)
  60222 			}
  60223 			v27 = v28
  60224 		}
  60225 		v25 = v27
  60226 		goto _65
  60227 	_65:
  60228 		v16 = v25
  60229 		goto _56
  60230 	_56:
  60231 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60232 		v31 = v1 * int32(19077) >> int32(8)
  60233 		goto _71
  60234 	_71:
  60235 		v33 = v2 * int32(33050) >> int32(8)
  60236 		goto _73
  60237 	_73:
  60238 		v35 = v31 + v33 - int32(17685)
  60239 		if v35 & ^int32(YUV_MASK2) == 0 {
  60240 			v38 = v35 >> int32(YUV_FIX2)
  60241 		} else {
  60242 			if v35 < 0 {
  60243 				v39 = 0
  60244 			} else {
  60245 				v39 = int32(255)
  60246 			}
  60247 			v38 = v39
  60248 		}
  60249 		v36 = v38
  60250 		goto _76
  60251 	_76:
  60252 		v29 = v36
  60253 		goto _69
  60254 	_69:
  60255 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60256 		y4 = y4 + uintptr(2)
  60257 		u3 = u3 + 1
  60258 		v5 = v5 + 1
  60259 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(3))
  60260 	}
  60261 	if len1&int32(1) != 0 {
  60262 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60263 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60264 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60265 		v4 = dst
  60266 		v7 = v1 * int32(19077) >> int32(8)
  60267 		goto _86
  60268 	_86:
  60269 		v9 = v3 * int32(26149) >> int32(8)
  60270 		goto _88
  60271 	_88:
  60272 		v11 = v7 + v9 - int32(14234)
  60273 		if v11 & ^int32(YUV_MASK2) == 0 {
  60274 			v14 = v11 >> int32(YUV_FIX2)
  60275 		} else {
  60276 			if v11 < 0 {
  60277 				v15 = 0
  60278 			} else {
  60279 				v15 = int32(255)
  60280 			}
  60281 			v14 = v15
  60282 		}
  60283 		v12 = v14
  60284 		goto _91
  60285 	_91:
  60286 		v51 = v12
  60287 		goto _84
  60288 	_84:
  60289 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60290 		v18 = v1 * int32(19077) >> int32(8)
  60291 		goto _97
  60292 	_97:
  60293 		v20 = v2 * int32(6419) >> int32(8)
  60294 		goto _99
  60295 	_99:
  60296 		v22 = v3 * int32(13320) >> int32(8)
  60297 		goto _101
  60298 	_101:
  60299 		v24 = v18 - v20 - v22 + int32(8708)
  60300 		if v24 & ^int32(YUV_MASK2) == 0 {
  60301 			v27 = v24 >> int32(YUV_FIX2)
  60302 		} else {
  60303 			if v24 < 0 {
  60304 				v28 = 0
  60305 			} else {
  60306 				v28 = int32(255)
  60307 			}
  60308 			v27 = v28
  60309 		}
  60310 		v25 = v27
  60311 		goto _104
  60312 	_104:
  60313 		v16 = v25
  60314 		goto _95
  60315 	_95:
  60316 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60317 		v31 = v1 * int32(19077) >> int32(8)
  60318 		goto _110
  60319 	_110:
  60320 		v33 = v2 * int32(33050) >> int32(8)
  60321 		goto _112
  60322 	_112:
  60323 		v35 = v31 + v33 - int32(17685)
  60324 		if v35 & ^int32(YUV_MASK2) == 0 {
  60325 			v38 = v35 >> int32(YUV_FIX2)
  60326 		} else {
  60327 			if v35 < 0 {
  60328 				v39 = 0
  60329 			} else {
  60330 				v39 = int32(255)
  60331 			}
  60332 			v38 = v39
  60333 		}
  60334 		v36 = v38
  60335 		goto _115
  60336 	_115:
  60337 		v29 = v36
  60338 		goto _108
  60339 	_108:
  60340 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60341 	}
  60342 }
  60343 
  60344 func YuvToBgrRow(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  60345 	var end, v4 uintptr
  60346 	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
  60347 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  60348 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(3))
  60349 	for dst != end {
  60350 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60351 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60352 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60353 		v4 = dst
  60354 		v7 = v1 * int32(19077) >> int32(8)
  60355 		goto _8
  60356 	_8:
  60357 		v9 = v2 * int32(33050) >> int32(8)
  60358 		goto _10
  60359 	_10:
  60360 		v11 = v7 + v9 - int32(17685)
  60361 		if v11 & ^int32(YUV_MASK2) == 0 {
  60362 			v14 = v11 >> int32(YUV_FIX2)
  60363 		} else {
  60364 			if v11 < 0 {
  60365 				v15 = 0
  60366 			} else {
  60367 				v15 = int32(255)
  60368 			}
  60369 			v14 = v15
  60370 		}
  60371 		v12 = v14
  60372 		goto _13
  60373 	_13:
  60374 		v51 = v12
  60375 		goto _6
  60376 	_6:
  60377 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60378 		v18 = v1 * int32(19077) >> int32(8)
  60379 		goto _19
  60380 	_19:
  60381 		v20 = v2 * int32(6419) >> int32(8)
  60382 		goto _21
  60383 	_21:
  60384 		v22 = v3 * int32(13320) >> int32(8)
  60385 		goto _23
  60386 	_23:
  60387 		v24 = v18 - v20 - v22 + int32(8708)
  60388 		if v24 & ^int32(YUV_MASK2) == 0 {
  60389 			v27 = v24 >> int32(YUV_FIX2)
  60390 		} else {
  60391 			if v24 < 0 {
  60392 				v28 = 0
  60393 			} else {
  60394 				v28 = int32(255)
  60395 			}
  60396 			v27 = v28
  60397 		}
  60398 		v25 = v27
  60399 		goto _26
  60400 	_26:
  60401 		v16 = v25
  60402 		goto _17
  60403 	_17:
  60404 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60405 		v31 = v1 * int32(19077) >> int32(8)
  60406 		goto _32
  60407 	_32:
  60408 		v33 = v3 * int32(26149) >> int32(8)
  60409 		goto _34
  60410 	_34:
  60411 		v35 = v31 + v33 - int32(14234)
  60412 		if v35 & ^int32(YUV_MASK2) == 0 {
  60413 			v38 = v35 >> int32(YUV_FIX2)
  60414 		} else {
  60415 			if v35 < 0 {
  60416 				v39 = 0
  60417 			} else {
  60418 				v39 = int32(255)
  60419 			}
  60420 			v38 = v39
  60421 		}
  60422 		v36 = v38
  60423 		goto _37
  60424 	_37:
  60425 		v29 = v36
  60426 		goto _30
  60427 	_30:
  60428 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60429 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  60430 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60431 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60432 		v4 = dst + uintptr(libc.Int32FromInt32(3))
  60433 		v7 = v1 * int32(19077) >> int32(8)
  60434 		goto _47
  60435 	_47:
  60436 		v9 = v2 * int32(33050) >> int32(8)
  60437 		goto _49
  60438 	_49:
  60439 		v11 = v7 + v9 - int32(17685)
  60440 		if v11 & ^int32(YUV_MASK2) == 0 {
  60441 			v14 = v11 >> int32(YUV_FIX2)
  60442 		} else {
  60443 			if v11 < 0 {
  60444 				v15 = 0
  60445 			} else {
  60446 				v15 = int32(255)
  60447 			}
  60448 			v14 = v15
  60449 		}
  60450 		v12 = v14
  60451 		goto _52
  60452 	_52:
  60453 		v51 = v12
  60454 		goto _45
  60455 	_45:
  60456 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60457 		v18 = v1 * int32(19077) >> int32(8)
  60458 		goto _58
  60459 	_58:
  60460 		v20 = v2 * int32(6419) >> int32(8)
  60461 		goto _60
  60462 	_60:
  60463 		v22 = v3 * int32(13320) >> int32(8)
  60464 		goto _62
  60465 	_62:
  60466 		v24 = v18 - v20 - v22 + int32(8708)
  60467 		if v24 & ^int32(YUV_MASK2) == 0 {
  60468 			v27 = v24 >> int32(YUV_FIX2)
  60469 		} else {
  60470 			if v24 < 0 {
  60471 				v28 = 0
  60472 			} else {
  60473 				v28 = int32(255)
  60474 			}
  60475 			v27 = v28
  60476 		}
  60477 		v25 = v27
  60478 		goto _65
  60479 	_65:
  60480 		v16 = v25
  60481 		goto _56
  60482 	_56:
  60483 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60484 		v31 = v1 * int32(19077) >> int32(8)
  60485 		goto _71
  60486 	_71:
  60487 		v33 = v3 * int32(26149) >> int32(8)
  60488 		goto _73
  60489 	_73:
  60490 		v35 = v31 + v33 - int32(14234)
  60491 		if v35 & ^int32(YUV_MASK2) == 0 {
  60492 			v38 = v35 >> int32(YUV_FIX2)
  60493 		} else {
  60494 			if v35 < 0 {
  60495 				v39 = 0
  60496 			} else {
  60497 				v39 = int32(255)
  60498 			}
  60499 			v38 = v39
  60500 		}
  60501 		v36 = v38
  60502 		goto _76
  60503 	_76:
  60504 		v29 = v36
  60505 		goto _69
  60506 	_69:
  60507 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60508 		y4 = y4 + uintptr(2)
  60509 		u3 = u3 + 1
  60510 		v5 = v5 + 1
  60511 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(3))
  60512 	}
  60513 	if len1&int32(1) != 0 {
  60514 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  60515 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  60516 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  60517 		v4 = dst
  60518 		v7 = v1 * int32(19077) >> int32(8)
  60519 		goto _86
  60520 	_86:
  60521 		v9 = v2 * int32(33050) >> int32(8)
  60522 		goto _88
  60523 	_88:
  60524 		v11 = v7 + v9 - int32(17685)
  60525 		if v11 & ^int32(YUV_MASK2) == 0 {
  60526 			v14 = v11 >> int32(YUV_FIX2)
  60527 		} else {
  60528 			if v11 < 0 {
  60529 				v15 = 0
  60530 			} else {
  60531 				v15 = int32(255)
  60532 			}
  60533 			v14 = v15
  60534 		}
  60535 		v12 = v14
  60536 		goto _91
  60537 	_91:
  60538 		v51 = v12
  60539 		goto _84
  60540 	_84:
  60541 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(v51)
  60542 		v18 = v1 * int32(19077) >> int32(8)
  60543 		goto _97
  60544 	_97:
  60545 		v20 = v2 * int32(6419) >> int32(8)
  60546 		goto _99
  60547 	_99:
  60548 		v22 = v3 * int32(13320) >> int32(8)
  60549 		goto _101
  60550 	_101:
  60551 		v24 = v18 - v20 - v22 + int32(8708)
  60552 		if v24 & ^int32(YUV_MASK2) == 0 {
  60553 			v27 = v24 >> int32(YUV_FIX2)
  60554 		} else {
  60555 			if v24 < 0 {
  60556 				v28 = 0
  60557 			} else {
  60558 				v28 = int32(255)
  60559 			}
  60560 			v27 = v28
  60561 		}
  60562 		v25 = v27
  60563 		goto _104
  60564 	_104:
  60565 		v16 = v25
  60566 		goto _95
  60567 	_95:
  60568 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(v16)
  60569 		v31 = v1 * int32(19077) >> int32(8)
  60570 		goto _110
  60571 	_110:
  60572 		v33 = v3 * int32(26149) >> int32(8)
  60573 		goto _112
  60574 	_112:
  60575 		v35 = v31 + v33 - int32(14234)
  60576 		if v35 & ^int32(YUV_MASK2) == 0 {
  60577 			v38 = v35 >> int32(YUV_FIX2)
  60578 		} else {
  60579 			if v35 < 0 {
  60580 				v39 = 0
  60581 			} else {
  60582 				v39 = int32(255)
  60583 			}
  60584 			v38 = v39
  60585 		}
  60586 		v36 = v38
  60587 		goto _115
  60588 	_115:
  60589 		v29 = v36
  60590 		goto _108
  60591 	_108:
  60592 		**(**uint8_t)(__ccgo_up(v4 + 2)) = libc.Uint8FromInt32(v29)
  60593 	}
  60594 }
  60595 
  60596 func YuvToRgbaRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  60597 	var end, v1, v5 uintptr
  60598 	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
  60599 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  60600 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  60601 	for dst != end {
  60602 		v1 = dst
  60603 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60604 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60605 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60606 		v5 = v1
  60607 		v8 = v2 * int32(19077) >> int32(8)
  60608 		goto _9
  60609 	_9:
  60610 		v10 = v4 * int32(26149) >> int32(8)
  60611 		goto _11
  60612 	_11:
  60613 		v12 = v8 + v10 - int32(14234)
  60614 		if v12 & ^int32(YUV_MASK2) == 0 {
  60615 			v15 = v12 >> int32(YUV_FIX2)
  60616 		} else {
  60617 			if v12 < 0 {
  60618 				v16 = 0
  60619 			} else {
  60620 				v16 = int32(255)
  60621 			}
  60622 			v15 = v16
  60623 		}
  60624 		v13 = v15
  60625 		goto _14
  60626 	_14:
  60627 		v61 = v13
  60628 		goto _7
  60629 	_7:
  60630 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60631 		v19 = v2 * int32(19077) >> int32(8)
  60632 		goto _20
  60633 	_20:
  60634 		v21 = v3 * int32(6419) >> int32(8)
  60635 		goto _22
  60636 	_22:
  60637 		v23 = v4 * int32(13320) >> int32(8)
  60638 		goto _24
  60639 	_24:
  60640 		v25 = v19 - v21 - v23 + int32(8708)
  60641 		if v25 & ^int32(YUV_MASK2) == 0 {
  60642 			v28 = v25 >> int32(YUV_FIX2)
  60643 		} else {
  60644 			if v25 < 0 {
  60645 				v29 = 0
  60646 			} else {
  60647 				v29 = int32(255)
  60648 			}
  60649 			v28 = v29
  60650 		}
  60651 		v26 = v28
  60652 		goto _27
  60653 	_27:
  60654 		v17 = v26
  60655 		goto _18
  60656 	_18:
  60657 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60658 		v32 = v2 * int32(19077) >> int32(8)
  60659 		goto _33
  60660 	_33:
  60661 		v34 = v3 * int32(33050) >> int32(8)
  60662 		goto _35
  60663 	_35:
  60664 		v36 = v32 + v34 - int32(17685)
  60665 		if v36 & ^int32(YUV_MASK2) == 0 {
  60666 			v39 = v36 >> int32(YUV_FIX2)
  60667 		} else {
  60668 			if v36 < 0 {
  60669 				v40 = 0
  60670 			} else {
  60671 				v40 = int32(255)
  60672 			}
  60673 			v39 = v40
  60674 		}
  60675 		v37 = v39
  60676 		goto _38
  60677 	_38:
  60678 		v30 = v37
  60679 		goto _31
  60680 	_31:
  60681 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60682 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60683 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  60684 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  60685 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60686 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60687 		v5 = v1
  60688 		v8 = v2 * int32(19077) >> int32(8)
  60689 		goto _49
  60690 	_49:
  60691 		v10 = v4 * int32(26149) >> int32(8)
  60692 		goto _51
  60693 	_51:
  60694 		v12 = v8 + v10 - int32(14234)
  60695 		if v12 & ^int32(YUV_MASK2) == 0 {
  60696 			v15 = v12 >> int32(YUV_FIX2)
  60697 		} else {
  60698 			if v12 < 0 {
  60699 				v16 = 0
  60700 			} else {
  60701 				v16 = int32(255)
  60702 			}
  60703 			v15 = v16
  60704 		}
  60705 		v13 = v15
  60706 		goto _54
  60707 	_54:
  60708 		v61 = v13
  60709 		goto _47
  60710 	_47:
  60711 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60712 		v19 = v2 * int32(19077) >> int32(8)
  60713 		goto _60
  60714 	_60:
  60715 		v21 = v3 * int32(6419) >> int32(8)
  60716 		goto _62
  60717 	_62:
  60718 		v23 = v4 * int32(13320) >> int32(8)
  60719 		goto _64
  60720 	_64:
  60721 		v25 = v19 - v21 - v23 + int32(8708)
  60722 		if v25 & ^int32(YUV_MASK2) == 0 {
  60723 			v28 = v25 >> int32(YUV_FIX2)
  60724 		} else {
  60725 			if v25 < 0 {
  60726 				v29 = 0
  60727 			} else {
  60728 				v29 = int32(255)
  60729 			}
  60730 			v28 = v29
  60731 		}
  60732 		v26 = v28
  60733 		goto _67
  60734 	_67:
  60735 		v17 = v26
  60736 		goto _58
  60737 	_58:
  60738 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60739 		v32 = v2 * int32(19077) >> int32(8)
  60740 		goto _73
  60741 	_73:
  60742 		v34 = v3 * int32(33050) >> int32(8)
  60743 		goto _75
  60744 	_75:
  60745 		v36 = v32 + v34 - int32(17685)
  60746 		if v36 & ^int32(YUV_MASK2) == 0 {
  60747 			v39 = v36 >> int32(YUV_FIX2)
  60748 		} else {
  60749 			if v36 < 0 {
  60750 				v40 = 0
  60751 			} else {
  60752 				v40 = int32(255)
  60753 			}
  60754 			v39 = v40
  60755 		}
  60756 		v37 = v39
  60757 		goto _78
  60758 	_78:
  60759 		v30 = v37
  60760 		goto _71
  60761 	_71:
  60762 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60763 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60764 		y5 = y5 + uintptr(2)
  60765 		u4 = u4 + 1
  60766 		v6 = v6 + 1
  60767 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  60768 	}
  60769 	if len1&int32(1) != 0 {
  60770 		v1 = dst
  60771 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60772 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60773 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60774 		v5 = v1
  60775 		v8 = v2 * int32(19077) >> int32(8)
  60776 		goto _89
  60777 	_89:
  60778 		v10 = v4 * int32(26149) >> int32(8)
  60779 		goto _91
  60780 	_91:
  60781 		v12 = v8 + v10 - int32(14234)
  60782 		if v12 & ^int32(YUV_MASK2) == 0 {
  60783 			v15 = v12 >> int32(YUV_FIX2)
  60784 		} else {
  60785 			if v12 < 0 {
  60786 				v16 = 0
  60787 			} else {
  60788 				v16 = int32(255)
  60789 			}
  60790 			v15 = v16
  60791 		}
  60792 		v13 = v15
  60793 		goto _94
  60794 	_94:
  60795 		v61 = v13
  60796 		goto _87
  60797 	_87:
  60798 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60799 		v19 = v2 * int32(19077) >> int32(8)
  60800 		goto _100
  60801 	_100:
  60802 		v21 = v3 * int32(6419) >> int32(8)
  60803 		goto _102
  60804 	_102:
  60805 		v23 = v4 * int32(13320) >> int32(8)
  60806 		goto _104
  60807 	_104:
  60808 		v25 = v19 - v21 - v23 + int32(8708)
  60809 		if v25 & ^int32(YUV_MASK2) == 0 {
  60810 			v28 = v25 >> int32(YUV_FIX2)
  60811 		} else {
  60812 			if v25 < 0 {
  60813 				v29 = 0
  60814 			} else {
  60815 				v29 = int32(255)
  60816 			}
  60817 			v28 = v29
  60818 		}
  60819 		v26 = v28
  60820 		goto _107
  60821 	_107:
  60822 		v17 = v26
  60823 		goto _98
  60824 	_98:
  60825 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60826 		v32 = v2 * int32(19077) >> int32(8)
  60827 		goto _113
  60828 	_113:
  60829 		v34 = v3 * int32(33050) >> int32(8)
  60830 		goto _115
  60831 	_115:
  60832 		v36 = v32 + v34 - int32(17685)
  60833 		if v36 & ^int32(YUV_MASK2) == 0 {
  60834 			v39 = v36 >> int32(YUV_FIX2)
  60835 		} else {
  60836 			if v36 < 0 {
  60837 				v40 = 0
  60838 			} else {
  60839 				v40 = int32(255)
  60840 			}
  60841 			v39 = v40
  60842 		}
  60843 		v37 = v39
  60844 		goto _118
  60845 	_118:
  60846 		v30 = v37
  60847 		goto _111
  60848 	_111:
  60849 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60850 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60851 	}
  60852 }
  60853 
  60854 func YuvToBgraRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  60855 	var end, v1, v5 uintptr
  60856 	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
  60857 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  60858 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  60859 	for dst != end {
  60860 		v1 = dst
  60861 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  60862 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60863 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60864 		v5 = v1
  60865 		v8 = v2 * int32(19077) >> int32(8)
  60866 		goto _9
  60867 	_9:
  60868 		v10 = v3 * int32(33050) >> int32(8)
  60869 		goto _11
  60870 	_11:
  60871 		v12 = v8 + v10 - int32(17685)
  60872 		if v12 & ^int32(YUV_MASK2) == 0 {
  60873 			v15 = v12 >> int32(YUV_FIX2)
  60874 		} else {
  60875 			if v12 < 0 {
  60876 				v16 = 0
  60877 			} else {
  60878 				v16 = int32(255)
  60879 			}
  60880 			v15 = v16
  60881 		}
  60882 		v13 = v15
  60883 		goto _14
  60884 	_14:
  60885 		v61 = v13
  60886 		goto _7
  60887 	_7:
  60888 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60889 		v19 = v2 * int32(19077) >> int32(8)
  60890 		goto _20
  60891 	_20:
  60892 		v21 = v3 * int32(6419) >> int32(8)
  60893 		goto _22
  60894 	_22:
  60895 		v23 = v4 * int32(13320) >> int32(8)
  60896 		goto _24
  60897 	_24:
  60898 		v25 = v19 - v21 - v23 + int32(8708)
  60899 		if v25 & ^int32(YUV_MASK2) == 0 {
  60900 			v28 = v25 >> int32(YUV_FIX2)
  60901 		} else {
  60902 			if v25 < 0 {
  60903 				v29 = 0
  60904 			} else {
  60905 				v29 = int32(255)
  60906 			}
  60907 			v28 = v29
  60908 		}
  60909 		v26 = v28
  60910 		goto _27
  60911 	_27:
  60912 		v17 = v26
  60913 		goto _18
  60914 	_18:
  60915 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60916 		v32 = v2 * int32(19077) >> int32(8)
  60917 		goto _33
  60918 	_33:
  60919 		v34 = v4 * int32(26149) >> int32(8)
  60920 		goto _35
  60921 	_35:
  60922 		v36 = v32 + v34 - int32(14234)
  60923 		if v36 & ^int32(YUV_MASK2) == 0 {
  60924 			v39 = v36 >> int32(YUV_FIX2)
  60925 		} else {
  60926 			if v36 < 0 {
  60927 				v40 = 0
  60928 			} else {
  60929 				v40 = int32(255)
  60930 			}
  60931 			v39 = v40
  60932 		}
  60933 		v37 = v39
  60934 		goto _38
  60935 	_38:
  60936 		v30 = v37
  60937 		goto _31
  60938 	_31:
  60939 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  60940 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  60941 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  60942 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  60943 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  60944 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  60945 		v5 = v1
  60946 		v8 = v2 * int32(19077) >> int32(8)
  60947 		goto _49
  60948 	_49:
  60949 		v10 = v3 * int32(33050) >> int32(8)
  60950 		goto _51
  60951 	_51:
  60952 		v12 = v8 + v10 - int32(17685)
  60953 		if v12 & ^int32(YUV_MASK2) == 0 {
  60954 			v15 = v12 >> int32(YUV_FIX2)
  60955 		} else {
  60956 			if v12 < 0 {
  60957 				v16 = 0
  60958 			} else {
  60959 				v16 = int32(255)
  60960 			}
  60961 			v15 = v16
  60962 		}
  60963 		v13 = v15
  60964 		goto _54
  60965 	_54:
  60966 		v61 = v13
  60967 		goto _47
  60968 	_47:
  60969 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  60970 		v19 = v2 * int32(19077) >> int32(8)
  60971 		goto _60
  60972 	_60:
  60973 		v21 = v3 * int32(6419) >> int32(8)
  60974 		goto _62
  60975 	_62:
  60976 		v23 = v4 * int32(13320) >> int32(8)
  60977 		goto _64
  60978 	_64:
  60979 		v25 = v19 - v21 - v23 + int32(8708)
  60980 		if v25 & ^int32(YUV_MASK2) == 0 {
  60981 			v28 = v25 >> int32(YUV_FIX2)
  60982 		} else {
  60983 			if v25 < 0 {
  60984 				v29 = 0
  60985 			} else {
  60986 				v29 = int32(255)
  60987 			}
  60988 			v28 = v29
  60989 		}
  60990 		v26 = v28
  60991 		goto _67
  60992 	_67:
  60993 		v17 = v26
  60994 		goto _58
  60995 	_58:
  60996 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  60997 		v32 = v2 * int32(19077) >> int32(8)
  60998 		goto _73
  60999 	_73:
  61000 		v34 = v4 * int32(26149) >> int32(8)
  61001 		goto _75
  61002 	_75:
  61003 		v36 = v32 + v34 - int32(14234)
  61004 		if v36 & ^int32(YUV_MASK2) == 0 {
  61005 			v39 = v36 >> int32(YUV_FIX2)
  61006 		} else {
  61007 			if v36 < 0 {
  61008 				v40 = 0
  61009 			} else {
  61010 				v40 = int32(255)
  61011 			}
  61012 			v39 = v40
  61013 		}
  61014 		v37 = v39
  61015 		goto _78
  61016 	_78:
  61017 		v30 = v37
  61018 		goto _71
  61019 	_71:
  61020 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61021 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  61022 		y5 = y5 + uintptr(2)
  61023 		u4 = u4 + 1
  61024 		v6 = v6 + 1
  61025 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  61026 	}
  61027 	if len1&int32(1) != 0 {
  61028 		v1 = dst
  61029 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61030 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61031 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61032 		v5 = v1
  61033 		v8 = v2 * int32(19077) >> int32(8)
  61034 		goto _89
  61035 	_89:
  61036 		v10 = v3 * int32(33050) >> int32(8)
  61037 		goto _91
  61038 	_91:
  61039 		v12 = v8 + v10 - int32(17685)
  61040 		if v12 & ^int32(YUV_MASK2) == 0 {
  61041 			v15 = v12 >> int32(YUV_FIX2)
  61042 		} else {
  61043 			if v12 < 0 {
  61044 				v16 = 0
  61045 			} else {
  61046 				v16 = int32(255)
  61047 			}
  61048 			v15 = v16
  61049 		}
  61050 		v13 = v15
  61051 		goto _94
  61052 	_94:
  61053 		v61 = v13
  61054 		goto _87
  61055 	_87:
  61056 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61057 		v19 = v2 * int32(19077) >> int32(8)
  61058 		goto _100
  61059 	_100:
  61060 		v21 = v3 * int32(6419) >> int32(8)
  61061 		goto _102
  61062 	_102:
  61063 		v23 = v4 * int32(13320) >> int32(8)
  61064 		goto _104
  61065 	_104:
  61066 		v25 = v19 - v21 - v23 + int32(8708)
  61067 		if v25 & ^int32(YUV_MASK2) == 0 {
  61068 			v28 = v25 >> int32(YUV_FIX2)
  61069 		} else {
  61070 			if v25 < 0 {
  61071 				v29 = 0
  61072 			} else {
  61073 				v29 = int32(255)
  61074 			}
  61075 			v28 = v29
  61076 		}
  61077 		v26 = v28
  61078 		goto _107
  61079 	_107:
  61080 		v17 = v26
  61081 		goto _98
  61082 	_98:
  61083 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61084 		v32 = v2 * int32(19077) >> int32(8)
  61085 		goto _113
  61086 	_113:
  61087 		v34 = v4 * int32(26149) >> int32(8)
  61088 		goto _115
  61089 	_115:
  61090 		v36 = v32 + v34 - int32(14234)
  61091 		if v36 & ^int32(YUV_MASK2) == 0 {
  61092 			v39 = v36 >> int32(YUV_FIX2)
  61093 		} else {
  61094 			if v36 < 0 {
  61095 				v40 = 0
  61096 			} else {
  61097 				v40 = int32(255)
  61098 			}
  61099 			v39 = v40
  61100 		}
  61101 		v37 = v39
  61102 		goto _118
  61103 	_118:
  61104 		v30 = v37
  61105 		goto _111
  61106 	_111:
  61107 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61108 		**(**uint8_t)(__ccgo_up(v1 + 3)) = uint8(0xff)
  61109 	}
  61110 }
  61111 
  61112 func YuvToArgbRow(tls *libc.TLS, y5 uintptr, u4 uintptr, v6 uintptr, dst uintptr, len1 int32) {
  61113 	var end, v1, v5 uintptr
  61114 	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
  61115 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  61116 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(4))
  61117 	for dst != end {
  61118 		v1 = dst
  61119 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61120 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61121 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61122 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61123 		v5 = v1 + uintptr(1)
  61124 		v8 = v2 * int32(19077) >> int32(8)
  61125 		goto _9
  61126 	_9:
  61127 		v10 = v4 * int32(26149) >> int32(8)
  61128 		goto _11
  61129 	_11:
  61130 		v12 = v8 + v10 - int32(14234)
  61131 		if v12 & ^int32(YUV_MASK2) == 0 {
  61132 			v15 = v12 >> int32(YUV_FIX2)
  61133 		} else {
  61134 			if v12 < 0 {
  61135 				v16 = 0
  61136 			} else {
  61137 				v16 = int32(255)
  61138 			}
  61139 			v15 = v16
  61140 		}
  61141 		v13 = v15
  61142 		goto _14
  61143 	_14:
  61144 		v61 = v13
  61145 		goto _7
  61146 	_7:
  61147 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61148 		v19 = v2 * int32(19077) >> int32(8)
  61149 		goto _20
  61150 	_20:
  61151 		v21 = v3 * int32(6419) >> int32(8)
  61152 		goto _22
  61153 	_22:
  61154 		v23 = v4 * int32(13320) >> int32(8)
  61155 		goto _24
  61156 	_24:
  61157 		v25 = v19 - v21 - v23 + int32(8708)
  61158 		if v25 & ^int32(YUV_MASK2) == 0 {
  61159 			v28 = v25 >> int32(YUV_FIX2)
  61160 		} else {
  61161 			if v25 < 0 {
  61162 				v29 = 0
  61163 			} else {
  61164 				v29 = int32(255)
  61165 			}
  61166 			v28 = v29
  61167 		}
  61168 		v26 = v28
  61169 		goto _27
  61170 	_27:
  61171 		v17 = v26
  61172 		goto _18
  61173 	_18:
  61174 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61175 		v32 = v2 * int32(19077) >> int32(8)
  61176 		goto _33
  61177 	_33:
  61178 		v34 = v3 * int32(33050) >> int32(8)
  61179 		goto _35
  61180 	_35:
  61181 		v36 = v32 + v34 - int32(17685)
  61182 		if v36 & ^int32(YUV_MASK2) == 0 {
  61183 			v39 = v36 >> int32(YUV_FIX2)
  61184 		} else {
  61185 			if v36 < 0 {
  61186 				v40 = 0
  61187 			} else {
  61188 				v40 = int32(255)
  61189 			}
  61190 			v39 = v40
  61191 		}
  61192 		v37 = v39
  61193 		goto _38
  61194 	_38:
  61195 		v30 = v37
  61196 		goto _31
  61197 	_31:
  61198 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61199 		v1 = dst + uintptr(libc.Int32FromInt32(4))
  61200 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61201 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5 + 1)))
  61202 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61203 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61204 		v5 = v1 + uintptr(1)
  61205 		v8 = v2 * int32(19077) >> int32(8)
  61206 		goto _49
  61207 	_49:
  61208 		v10 = v4 * int32(26149) >> int32(8)
  61209 		goto _51
  61210 	_51:
  61211 		v12 = v8 + v10 - int32(14234)
  61212 		if v12 & ^int32(YUV_MASK2) == 0 {
  61213 			v15 = v12 >> int32(YUV_FIX2)
  61214 		} else {
  61215 			if v12 < 0 {
  61216 				v16 = 0
  61217 			} else {
  61218 				v16 = int32(255)
  61219 			}
  61220 			v15 = v16
  61221 		}
  61222 		v13 = v15
  61223 		goto _54
  61224 	_54:
  61225 		v61 = v13
  61226 		goto _47
  61227 	_47:
  61228 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61229 		v19 = v2 * int32(19077) >> int32(8)
  61230 		goto _60
  61231 	_60:
  61232 		v21 = v3 * int32(6419) >> int32(8)
  61233 		goto _62
  61234 	_62:
  61235 		v23 = v4 * int32(13320) >> int32(8)
  61236 		goto _64
  61237 	_64:
  61238 		v25 = v19 - v21 - v23 + int32(8708)
  61239 		if v25 & ^int32(YUV_MASK2) == 0 {
  61240 			v28 = v25 >> int32(YUV_FIX2)
  61241 		} else {
  61242 			if v25 < 0 {
  61243 				v29 = 0
  61244 			} else {
  61245 				v29 = int32(255)
  61246 			}
  61247 			v28 = v29
  61248 		}
  61249 		v26 = v28
  61250 		goto _67
  61251 	_67:
  61252 		v17 = v26
  61253 		goto _58
  61254 	_58:
  61255 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61256 		v32 = v2 * int32(19077) >> int32(8)
  61257 		goto _73
  61258 	_73:
  61259 		v34 = v3 * int32(33050) >> int32(8)
  61260 		goto _75
  61261 	_75:
  61262 		v36 = v32 + v34 - int32(17685)
  61263 		if v36 & ^int32(YUV_MASK2) == 0 {
  61264 			v39 = v36 >> int32(YUV_FIX2)
  61265 		} else {
  61266 			if v36 < 0 {
  61267 				v40 = 0
  61268 			} else {
  61269 				v40 = int32(255)
  61270 			}
  61271 			v39 = v40
  61272 		}
  61273 		v37 = v39
  61274 		goto _78
  61275 	_78:
  61276 		v30 = v37
  61277 		goto _71
  61278 	_71:
  61279 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61280 		y5 = y5 + uintptr(2)
  61281 		u4 = u4 + 1
  61282 		v6 = v6 + 1
  61283 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(4))
  61284 	}
  61285 	if len1&int32(1) != 0 {
  61286 		v1 = dst
  61287 		**(**uint8_t)(__ccgo_up(v1)) = uint8(0xff)
  61288 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y5)))
  61289 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u4)))
  61290 		v4 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v6)))
  61291 		v5 = v1 + uintptr(1)
  61292 		v8 = v2 * int32(19077) >> int32(8)
  61293 		goto _89
  61294 	_89:
  61295 		v10 = v4 * int32(26149) >> int32(8)
  61296 		goto _91
  61297 	_91:
  61298 		v12 = v8 + v10 - int32(14234)
  61299 		if v12 & ^int32(YUV_MASK2) == 0 {
  61300 			v15 = v12 >> int32(YUV_FIX2)
  61301 		} else {
  61302 			if v12 < 0 {
  61303 				v16 = 0
  61304 			} else {
  61305 				v16 = int32(255)
  61306 			}
  61307 			v15 = v16
  61308 		}
  61309 		v13 = v15
  61310 		goto _94
  61311 	_94:
  61312 		v61 = v13
  61313 		goto _87
  61314 	_87:
  61315 		**(**uint8_t)(__ccgo_up(v5)) = libc.Uint8FromInt32(v61)
  61316 		v19 = v2 * int32(19077) >> int32(8)
  61317 		goto _100
  61318 	_100:
  61319 		v21 = v3 * int32(6419) >> int32(8)
  61320 		goto _102
  61321 	_102:
  61322 		v23 = v4 * int32(13320) >> int32(8)
  61323 		goto _104
  61324 	_104:
  61325 		v25 = v19 - v21 - v23 + int32(8708)
  61326 		if v25 & ^int32(YUV_MASK2) == 0 {
  61327 			v28 = v25 >> int32(YUV_FIX2)
  61328 		} else {
  61329 			if v25 < 0 {
  61330 				v29 = 0
  61331 			} else {
  61332 				v29 = int32(255)
  61333 			}
  61334 			v28 = v29
  61335 		}
  61336 		v26 = v28
  61337 		goto _107
  61338 	_107:
  61339 		v17 = v26
  61340 		goto _98
  61341 	_98:
  61342 		**(**uint8_t)(__ccgo_up(v5 + 1)) = libc.Uint8FromInt32(v17)
  61343 		v32 = v2 * int32(19077) >> int32(8)
  61344 		goto _113
  61345 	_113:
  61346 		v34 = v3 * int32(33050) >> int32(8)
  61347 		goto _115
  61348 	_115:
  61349 		v36 = v32 + v34 - int32(17685)
  61350 		if v36 & ^int32(YUV_MASK2) == 0 {
  61351 			v39 = v36 >> int32(YUV_FIX2)
  61352 		} else {
  61353 			if v36 < 0 {
  61354 				v40 = 0
  61355 			} else {
  61356 				v40 = int32(255)
  61357 			}
  61358 			v39 = v40
  61359 		}
  61360 		v37 = v39
  61361 		goto _118
  61362 	_118:
  61363 		v30 = v37
  61364 		goto _111
  61365 	_111:
  61366 		**(**uint8_t)(__ccgo_up(v5 + 2)) = libc.Uint8FromInt32(v30)
  61367 	}
  61368 }
  61369 
  61370 func YuvToRgba4444Row(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  61371 	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
  61372 	var end, v4 uintptr
  61373 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  61374 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(2))
  61375 	for dst != end {
  61376 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61377 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61378 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61379 		v4 = dst
  61380 		v7 = v1 * int32(19077) >> int32(8)
  61381 		goto _8
  61382 	_8:
  61383 		v9 = v3 * int32(26149) >> int32(8)
  61384 		goto _10
  61385 	_10:
  61386 		v11 = v7 + v9 - int32(14234)
  61387 		if v11 & ^int32(YUV_MASK2) == 0 {
  61388 			v14 = v11 >> int32(YUV_FIX2)
  61389 		} else {
  61390 			if v11 < 0 {
  61391 				v15 = 0
  61392 			} else {
  61393 				v15 = int32(255)
  61394 			}
  61395 			v14 = v15
  61396 		}
  61397 		v12 = v14
  61398 		goto _13
  61399 	_13:
  61400 		v51 = v12
  61401 		goto _6
  61402 	_6:
  61403 		r = v51
  61404 		v18 = v1 * int32(19077) >> int32(8)
  61405 		goto _19
  61406 	_19:
  61407 		v20 = v2 * int32(6419) >> int32(8)
  61408 		goto _21
  61409 	_21:
  61410 		v22 = v3 * int32(13320) >> int32(8)
  61411 		goto _23
  61412 	_23:
  61413 		v24 = v18 - v20 - v22 + int32(8708)
  61414 		if v24 & ^int32(YUV_MASK2) == 0 {
  61415 			v27 = v24 >> int32(YUV_FIX2)
  61416 		} else {
  61417 			if v24 < 0 {
  61418 				v28 = 0
  61419 			} else {
  61420 				v28 = int32(255)
  61421 			}
  61422 			v27 = v28
  61423 		}
  61424 		v25 = v27
  61425 		goto _26
  61426 	_26:
  61427 		v16 = v25
  61428 		goto _17
  61429 	_17:
  61430 		g = v16
  61431 		v31 = v1 * int32(19077) >> int32(8)
  61432 		goto _32
  61433 	_32:
  61434 		v33 = v2 * int32(33050) >> int32(8)
  61435 		goto _34
  61436 	_34:
  61437 		v35 = v31 + v33 - int32(17685)
  61438 		if v35 & ^int32(YUV_MASK2) == 0 {
  61439 			v38 = v35 >> int32(YUV_FIX2)
  61440 		} else {
  61441 			if v35 < 0 {
  61442 				v39 = 0
  61443 			} else {
  61444 				v39 = int32(255)
  61445 			}
  61446 			v38 = v39
  61447 		}
  61448 		v36 = v38
  61449 		goto _37
  61450 	_37:
  61451 		v29 = v36
  61452 		goto _30
  61453 	_30:
  61454 		b = v29
  61455 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61456 		ba = b&int32(0xf0) | int32(0x0f)
  61457 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61458 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61459 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  61460 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61461 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61462 		v4 = dst + uintptr(libc.Int32FromInt32(2))
  61463 		v7 = v1 * int32(19077) >> int32(8)
  61464 		goto _47
  61465 	_47:
  61466 		v9 = v3 * int32(26149) >> int32(8)
  61467 		goto _49
  61468 	_49:
  61469 		v11 = v7 + v9 - int32(14234)
  61470 		if v11 & ^int32(YUV_MASK2) == 0 {
  61471 			v14 = v11 >> int32(YUV_FIX2)
  61472 		} else {
  61473 			if v11 < 0 {
  61474 				v15 = 0
  61475 			} else {
  61476 				v15 = int32(255)
  61477 			}
  61478 			v14 = v15
  61479 		}
  61480 		v12 = v14
  61481 		goto _52
  61482 	_52:
  61483 		v51 = v12
  61484 		goto _45
  61485 	_45:
  61486 		r = v51
  61487 		v18 = v1 * int32(19077) >> int32(8)
  61488 		goto _58
  61489 	_58:
  61490 		v20 = v2 * int32(6419) >> int32(8)
  61491 		goto _60
  61492 	_60:
  61493 		v22 = v3 * int32(13320) >> int32(8)
  61494 		goto _62
  61495 	_62:
  61496 		v24 = v18 - v20 - v22 + int32(8708)
  61497 		if v24 & ^int32(YUV_MASK2) == 0 {
  61498 			v27 = v24 >> int32(YUV_FIX2)
  61499 		} else {
  61500 			if v24 < 0 {
  61501 				v28 = 0
  61502 			} else {
  61503 				v28 = int32(255)
  61504 			}
  61505 			v27 = v28
  61506 		}
  61507 		v25 = v27
  61508 		goto _65
  61509 	_65:
  61510 		v16 = v25
  61511 		goto _56
  61512 	_56:
  61513 		g = v16
  61514 		v31 = v1 * int32(19077) >> int32(8)
  61515 		goto _71
  61516 	_71:
  61517 		v33 = v2 * int32(33050) >> int32(8)
  61518 		goto _73
  61519 	_73:
  61520 		v35 = v31 + v33 - int32(17685)
  61521 		if v35 & ^int32(YUV_MASK2) == 0 {
  61522 			v38 = v35 >> int32(YUV_FIX2)
  61523 		} else {
  61524 			if v35 < 0 {
  61525 				v39 = 0
  61526 			} else {
  61527 				v39 = int32(255)
  61528 			}
  61529 			v38 = v39
  61530 		}
  61531 		v36 = v38
  61532 		goto _76
  61533 	_76:
  61534 		v29 = v36
  61535 		goto _69
  61536 	_69:
  61537 		b = v29
  61538 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61539 		ba = b&int32(0xf0) | int32(0x0f)
  61540 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61541 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61542 		y4 = y4 + uintptr(2)
  61543 		u3 = u3 + 1
  61544 		v5 = v5 + 1
  61545 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))
  61546 	}
  61547 	if len1&int32(1) != 0 {
  61548 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61549 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61550 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61551 		v4 = dst
  61552 		v7 = v1 * int32(19077) >> int32(8)
  61553 		goto _86
  61554 	_86:
  61555 		v9 = v3 * int32(26149) >> int32(8)
  61556 		goto _88
  61557 	_88:
  61558 		v11 = v7 + v9 - int32(14234)
  61559 		if v11 & ^int32(YUV_MASK2) == 0 {
  61560 			v14 = v11 >> int32(YUV_FIX2)
  61561 		} else {
  61562 			if v11 < 0 {
  61563 				v15 = 0
  61564 			} else {
  61565 				v15 = int32(255)
  61566 			}
  61567 			v14 = v15
  61568 		}
  61569 		v12 = v14
  61570 		goto _91
  61571 	_91:
  61572 		v51 = v12
  61573 		goto _84
  61574 	_84:
  61575 		r = v51
  61576 		v18 = v1 * int32(19077) >> int32(8)
  61577 		goto _97
  61578 	_97:
  61579 		v20 = v2 * int32(6419) >> int32(8)
  61580 		goto _99
  61581 	_99:
  61582 		v22 = v3 * int32(13320) >> int32(8)
  61583 		goto _101
  61584 	_101:
  61585 		v24 = v18 - v20 - v22 + int32(8708)
  61586 		if v24 & ^int32(YUV_MASK2) == 0 {
  61587 			v27 = v24 >> int32(YUV_FIX2)
  61588 		} else {
  61589 			if v24 < 0 {
  61590 				v28 = 0
  61591 			} else {
  61592 				v28 = int32(255)
  61593 			}
  61594 			v27 = v28
  61595 		}
  61596 		v25 = v27
  61597 		goto _104
  61598 	_104:
  61599 		v16 = v25
  61600 		goto _95
  61601 	_95:
  61602 		g = v16
  61603 		v31 = v1 * int32(19077) >> int32(8)
  61604 		goto _110
  61605 	_110:
  61606 		v33 = v2 * int32(33050) >> int32(8)
  61607 		goto _112
  61608 	_112:
  61609 		v35 = v31 + v33 - int32(17685)
  61610 		if v35 & ^int32(YUV_MASK2) == 0 {
  61611 			v38 = v35 >> int32(YUV_FIX2)
  61612 		} else {
  61613 			if v35 < 0 {
  61614 				v39 = 0
  61615 			} else {
  61616 				v39 = int32(255)
  61617 			}
  61618 			v38 = v39
  61619 		}
  61620 		v36 = v38
  61621 		goto _115
  61622 	_115:
  61623 		v29 = v36
  61624 		goto _108
  61625 	_108:
  61626 		b = v29
  61627 		rg = r&int32(0xf0) | g>>libc.Int32FromInt32(4)
  61628 		ba = b&int32(0xf0) | int32(0x0f)
  61629 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61630 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(ba)
  61631 	}
  61632 }
  61633 
  61634 func YuvToRgb565Row(tls *libc.TLS, y4 uintptr, u3 uintptr, v5 uintptr, dst uintptr, len1 int32) {
  61635 	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
  61636 	var end, v4 uintptr
  61637 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  61638 	end = dst + uintptr(len1 & ^libc.Int32FromInt32(1) * int32(2))
  61639 	for dst != end {
  61640 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61641 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61642 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61643 		v4 = dst
  61644 		v7 = v1 * int32(19077) >> int32(8)
  61645 		goto _8
  61646 	_8:
  61647 		v9 = v3 * int32(26149) >> int32(8)
  61648 		goto _10
  61649 	_10:
  61650 		v11 = v7 + v9 - int32(14234)
  61651 		if v11 & ^int32(YUV_MASK2) == 0 {
  61652 			v14 = v11 >> int32(YUV_FIX2)
  61653 		} else {
  61654 			if v11 < 0 {
  61655 				v15 = 0
  61656 			} else {
  61657 				v15 = int32(255)
  61658 			}
  61659 			v14 = v15
  61660 		}
  61661 		v12 = v14
  61662 		goto _13
  61663 	_13:
  61664 		v51 = v12
  61665 		goto _6
  61666 	_6:
  61667 		r = v51
  61668 		v18 = v1 * int32(19077) >> int32(8)
  61669 		goto _19
  61670 	_19:
  61671 		v20 = v2 * int32(6419) >> int32(8)
  61672 		goto _21
  61673 	_21:
  61674 		v22 = v3 * int32(13320) >> int32(8)
  61675 		goto _23
  61676 	_23:
  61677 		v24 = v18 - v20 - v22 + int32(8708)
  61678 		if v24 & ^int32(YUV_MASK2) == 0 {
  61679 			v27 = v24 >> int32(YUV_FIX2)
  61680 		} else {
  61681 			if v24 < 0 {
  61682 				v28 = 0
  61683 			} else {
  61684 				v28 = int32(255)
  61685 			}
  61686 			v27 = v28
  61687 		}
  61688 		v25 = v27
  61689 		goto _26
  61690 	_26:
  61691 		v16 = v25
  61692 		goto _17
  61693 	_17:
  61694 		g = v16
  61695 		v31 = v1 * int32(19077) >> int32(8)
  61696 		goto _32
  61697 	_32:
  61698 		v33 = v2 * int32(33050) >> int32(8)
  61699 		goto _34
  61700 	_34:
  61701 		v35 = v31 + v33 - int32(17685)
  61702 		if v35 & ^int32(YUV_MASK2) == 0 {
  61703 			v38 = v35 >> int32(YUV_FIX2)
  61704 		} else {
  61705 			if v35 < 0 {
  61706 				v39 = 0
  61707 			} else {
  61708 				v39 = int32(255)
  61709 			}
  61710 			v38 = v39
  61711 		}
  61712 		v36 = v38
  61713 		goto _37
  61714 	_37:
  61715 		v29 = v36
  61716 		goto _30
  61717 	_30:
  61718 		b = v29
  61719 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61720 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61721 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61722 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61723 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4 + 1)))
  61724 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61725 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61726 		v4 = dst + uintptr(libc.Int32FromInt32(2))
  61727 		v7 = v1 * int32(19077) >> int32(8)
  61728 		goto _47
  61729 	_47:
  61730 		v9 = v3 * int32(26149) >> int32(8)
  61731 		goto _49
  61732 	_49:
  61733 		v11 = v7 + v9 - int32(14234)
  61734 		if v11 & ^int32(YUV_MASK2) == 0 {
  61735 			v14 = v11 >> int32(YUV_FIX2)
  61736 		} else {
  61737 			if v11 < 0 {
  61738 				v15 = 0
  61739 			} else {
  61740 				v15 = int32(255)
  61741 			}
  61742 			v14 = v15
  61743 		}
  61744 		v12 = v14
  61745 		goto _52
  61746 	_52:
  61747 		v51 = v12
  61748 		goto _45
  61749 	_45:
  61750 		r = v51
  61751 		v18 = v1 * int32(19077) >> int32(8)
  61752 		goto _58
  61753 	_58:
  61754 		v20 = v2 * int32(6419) >> int32(8)
  61755 		goto _60
  61756 	_60:
  61757 		v22 = v3 * int32(13320) >> int32(8)
  61758 		goto _62
  61759 	_62:
  61760 		v24 = v18 - v20 - v22 + int32(8708)
  61761 		if v24 & ^int32(YUV_MASK2) == 0 {
  61762 			v27 = v24 >> int32(YUV_FIX2)
  61763 		} else {
  61764 			if v24 < 0 {
  61765 				v28 = 0
  61766 			} else {
  61767 				v28 = int32(255)
  61768 			}
  61769 			v27 = v28
  61770 		}
  61771 		v25 = v27
  61772 		goto _65
  61773 	_65:
  61774 		v16 = v25
  61775 		goto _56
  61776 	_56:
  61777 		g = v16
  61778 		v31 = v1 * int32(19077) >> int32(8)
  61779 		goto _71
  61780 	_71:
  61781 		v33 = v2 * int32(33050) >> int32(8)
  61782 		goto _73
  61783 	_73:
  61784 		v35 = v31 + v33 - int32(17685)
  61785 		if v35 & ^int32(YUV_MASK2) == 0 {
  61786 			v38 = v35 >> int32(YUV_FIX2)
  61787 		} else {
  61788 			if v35 < 0 {
  61789 				v39 = 0
  61790 			} else {
  61791 				v39 = int32(255)
  61792 			}
  61793 			v38 = v39
  61794 		}
  61795 		v36 = v38
  61796 		goto _76
  61797 	_76:
  61798 		v29 = v36
  61799 		goto _69
  61800 	_69:
  61801 		b = v29
  61802 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61803 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61804 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61805 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61806 		y4 = y4 + uintptr(2)
  61807 		u3 = u3 + 1
  61808 		v5 = v5 + 1
  61809 		dst = dst + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))
  61810 	}
  61811 	if len1&int32(1) != 0 {
  61812 		v1 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(y4)))
  61813 		v2 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u3)))
  61814 		v3 = libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v5)))
  61815 		v4 = dst
  61816 		v7 = v1 * int32(19077) >> int32(8)
  61817 		goto _86
  61818 	_86:
  61819 		v9 = v3 * int32(26149) >> int32(8)
  61820 		goto _88
  61821 	_88:
  61822 		v11 = v7 + v9 - int32(14234)
  61823 		if v11 & ^int32(YUV_MASK2) == 0 {
  61824 			v14 = v11 >> int32(YUV_FIX2)
  61825 		} else {
  61826 			if v11 < 0 {
  61827 				v15 = 0
  61828 			} else {
  61829 				v15 = int32(255)
  61830 			}
  61831 			v14 = v15
  61832 		}
  61833 		v12 = v14
  61834 		goto _91
  61835 	_91:
  61836 		v51 = v12
  61837 		goto _84
  61838 	_84:
  61839 		r = v51
  61840 		v18 = v1 * int32(19077) >> int32(8)
  61841 		goto _97
  61842 	_97:
  61843 		v20 = v2 * int32(6419) >> int32(8)
  61844 		goto _99
  61845 	_99:
  61846 		v22 = v3 * int32(13320) >> int32(8)
  61847 		goto _101
  61848 	_101:
  61849 		v24 = v18 - v20 - v22 + int32(8708)
  61850 		if v24 & ^int32(YUV_MASK2) == 0 {
  61851 			v27 = v24 >> int32(YUV_FIX2)
  61852 		} else {
  61853 			if v24 < 0 {
  61854 				v28 = 0
  61855 			} else {
  61856 				v28 = int32(255)
  61857 			}
  61858 			v27 = v28
  61859 		}
  61860 		v25 = v27
  61861 		goto _104
  61862 	_104:
  61863 		v16 = v25
  61864 		goto _95
  61865 	_95:
  61866 		g = v16
  61867 		v31 = v1 * int32(19077) >> int32(8)
  61868 		goto _110
  61869 	_110:
  61870 		v33 = v2 * int32(33050) >> int32(8)
  61871 		goto _112
  61872 	_112:
  61873 		v35 = v31 + v33 - int32(17685)
  61874 		if v35 & ^int32(YUV_MASK2) == 0 {
  61875 			v38 = v35 >> int32(YUV_FIX2)
  61876 		} else {
  61877 			if v35 < 0 {
  61878 				v39 = 0
  61879 			} else {
  61880 				v39 = int32(255)
  61881 			}
  61882 			v38 = v39
  61883 		}
  61884 		v36 = v38
  61885 		goto _115
  61886 	_115:
  61887 		v29 = v36
  61888 		goto _108
  61889 	_108:
  61890 		b = v29
  61891 		rg = r&int32(0xf8) | g>>libc.Int32FromInt32(5)
  61892 		gb = g<<libc.Int32FromInt32(3)&int32(0xe0) | b>>libc.Int32FromInt32(3)
  61893 		**(**uint8_t)(__ccgo_up(v4)) = libc.Uint8FromInt32(rg)
  61894 		**(**uint8_t)(__ccgo_up(v4 + 1)) = libc.Uint8FromInt32(gb)
  61895 	}
  61896 }
  61897 
  61898 type __ccgo_fp__XWebPSamplerProcessPlane_9 = func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32)
  61899 
  61900 // C documentation
  61901 //
  61902 //	// Main call for processing a plane with a WebPSamplerRowFunc function:
  61903 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) {
  61904 	var j int32
  61905 	_ = j
  61906 	j = 0
  61907 	for {
  61908 		if !(j < height) {
  61909 			break
  61910 		}
  61911 		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_func})))(tls, y, u, v, dst, width)
  61912 		y = y + uintptr(y_stride)
  61913 		if j&int32(1) != 0 {
  61914 			u = u + uintptr(uv_stride)
  61915 			v = v + uintptr(uv_stride)
  61916 		}
  61917 		dst = dst + uintptr(dst_stride)
  61918 		goto _1
  61919 	_1:
  61920 		;
  61921 		j = j + 1
  61922 	}
  61923 }
  61924 
  61925 func WebPInitSamplers(tls *libc.TLS) {
  61926 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  61927 		goto _1
  61928 	}
  61929 	WebPInitSamplers_body(tls)
  61930 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used)), VP8GetCPUInfo)
  61931 	goto _2
  61932 _2:
  61933 	;
  61934 	goto _1
  61935 _1: /**/ //
  61936 }
  61937 
  61938 var WebPInitSamplers_body_last_cpuinfo_used = uintptr(0)
  61939 
  61940 func init() {
  61941 	p := unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used)
  61942 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitSamplers_body_last_cpuinfo_used))
  61943 }
  61944 
  61945 func WebPInitSamplers_body(tls *libc.TLS) {
  61946 	WebPSamplers[int32(MODE_RGB)] = __ccgo_fp(YuvToRgbRow)
  61947 	WebPSamplers[int32(MODE_RGBA)] = __ccgo_fp(YuvToRgbaRow)
  61948 	WebPSamplers[int32(MODE_BGR)] = __ccgo_fp(YuvToBgrRow)
  61949 	WebPSamplers[int32(MODE_BGRA)] = __ccgo_fp(YuvToBgraRow)
  61950 	WebPSamplers[int32(MODE_ARGB)] = __ccgo_fp(YuvToArgbRow)
  61951 	WebPSamplers[int32(MODE_RGBA_4444)] = __ccgo_fp(YuvToRgba4444Row)
  61952 	WebPSamplers[int32(MODE_RGB_565)] = __ccgo_fp(YuvToRgb565Row)
  61953 	WebPSamplers[int32(MODE_rgbA)] = __ccgo_fp(YuvToRgbaRow)
  61954 	WebPSamplers[int32(MODE_bgrA)] = __ccgo_fp(YuvToBgraRow)
  61955 	WebPSamplers[int32(MODE_Argb)] = __ccgo_fp(YuvToArgbRow)
  61956 	WebPSamplers[int32(MODE_rgbA_4444)] = __ccgo_fp(YuvToRgba4444Row)
  61957 	// If defined, use CPUInfo() to overwrite some pointers with faster versions.
  61958 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  61959 	}
  61960 }
  61961 
  61962 //-----------------------------------------------------------------------------
  61963 // ARGB -> YUV converters
  61964 
  61965 func ConvertARGBToY_C(tls *libc.TLS, argb uintptr, y uintptr, width int32) {
  61966 	var i, luma, v2 int32
  61967 	var p uint32_t
  61968 	_, _, _, _ = i, luma, p, v2
  61969 	i = 0
  61970 	for {
  61971 		if !(i < width) {
  61972 			break
  61973 		}
  61974 		p = **(**uint32_t)(__ccgo_up(argb + uintptr(i)*4))
  61975 		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))
  61976 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  61977 		goto _3
  61978 	_3:
  61979 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  61980 		goto _1
  61981 	_1:
  61982 		;
  61983 		i = i + 1
  61984 	}
  61985 }
  61986 
  61987 func WebPConvertARGBToUV_C(tls *libc.TLS, argb uintptr, u1 uintptr, v1 uintptr, src_width int32, do_store int32) {
  61988 	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
  61989 	var v0, v01, v11 uint32_t
  61990 	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = 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
  61991 	// No rounding. Last pixel is dealt with separately.
  61992 	uv_width = src_width >> int32(1)
  61993 	i = 0
  61994 	for {
  61995 		if !(i < uv_width) {
  61996 			break
  61997 		}
  61998 		v0 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+0)*4))
  61999 		v11 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+int32(1))*4))
  62000 		// VP8RGBToU/V expects four accumulated pixels. Hence we need to
  62001 		// scale r/g/b value by a factor 2. We just shift v0/v1 one bit less.
  62002 		r2 = libc.Int32FromUint32(v0>>libc.Int32FromInt32(15)&uint32(0x1fe) + v11>>libc.Int32FromInt32(15)&uint32(0x1fe))
  62003 		g2 = libc.Int32FromUint32(v0>>libc.Int32FromInt32(7)&uint32(0x1fe) + v11>>libc.Int32FromInt32(7)&uint32(0x1fe))
  62004 		b2 = libc.Int32FromUint32(v0<<libc.Int32FromInt32(1)&uint32(0x1fe) + v11<<libc.Int32FromInt32(1)&uint32(0x1fe))
  62005 		u = -int32(9719)*r2 - int32(19081)*g2 + int32(28800)*b2
  62006 		v4 = u
  62007 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62008 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62009 			v7 = v4
  62010 		} else {
  62011 			if v4 < 0 {
  62012 				v8 = 0
  62013 			} else {
  62014 				v8 = int32(255)
  62015 			}
  62016 			v7 = v8
  62017 		}
  62018 		v5 = v7
  62019 		goto _6
  62020 	_6:
  62021 		v2 = v5
  62022 		goto _3
  62023 	_3:
  62024 		tmp_u = v2
  62025 		v = +libc.Int32FromInt32(28800)*r2 - int32(24116)*g2 - int32(4684)*b2
  62026 		v111 = v
  62027 		v111 = (v111 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62028 		if v111 & ^libc.Int32FromInt32(0xff) == 0 {
  62029 			v14 = v111
  62030 		} else {
  62031 			if v111 < 0 {
  62032 				v15 = 0
  62033 			} else {
  62034 				v15 = int32(255)
  62035 			}
  62036 			v14 = v15
  62037 		}
  62038 		v12 = v14
  62039 		goto _13
  62040 	_13:
  62041 		v9 = v12
  62042 		goto _10
  62043 	_10:
  62044 		tmp_v = v9
  62045 		if do_store != 0 {
  62046 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(tmp_u)
  62047 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(tmp_v)
  62048 		} else {
  62049 			// Approximated average-of-four. But it's an acceptable diff.
  62050 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u1 + uintptr(i)))) + tmp_u + int32(1)) >> int32(1))
  62051 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + uintptr(i)))) + tmp_v + int32(1)) >> int32(1))
  62052 		}
  62053 		goto _1
  62054 	_1:
  62055 		;
  62056 		i = i + 1
  62057 	}
  62058 	if src_width&int32(1) != 0 { // last pixel
  62059 		v01 = **(**uint32_t)(__ccgo_up(argb + uintptr(int32(2)*i+0)*4))
  62060 		r3 = libc.Int32FromUint32(v01 >> libc.Int32FromInt32(14) & uint32(0x3fc))
  62061 		g3 = libc.Int32FromUint32(v01 >> libc.Int32FromInt32(6) & uint32(0x3fc))
  62062 		b3 = libc.Int32FromUint32(v01 << libc.Int32FromInt32(2) & uint32(0x3fc))
  62063 		u = -int32(9719)*r3 - int32(19081)*g3 + int32(28800)*b3
  62064 		v4 = u
  62065 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62066 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62067 			v7 = v4
  62068 		} else {
  62069 			if v4 < 0 {
  62070 				v8 = 0
  62071 			} else {
  62072 				v8 = int32(255)
  62073 			}
  62074 			v7 = v8
  62075 		}
  62076 		v5 = v7
  62077 		goto _20
  62078 	_20:
  62079 		v2 = v5
  62080 		goto _17
  62081 	_17:
  62082 		tmp_u1 = v2
  62083 		v = +libc.Int32FromInt32(28800)*r3 - int32(24116)*g3 - int32(4684)*b3
  62084 		v111 = v
  62085 		v111 = (v111 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62086 		if v111 & ^libc.Int32FromInt32(0xff) == 0 {
  62087 			v14 = v111
  62088 		} else {
  62089 			if v111 < 0 {
  62090 				v15 = 0
  62091 			} else {
  62092 				v15 = int32(255)
  62093 			}
  62094 			v14 = v15
  62095 		}
  62096 		v12 = v14
  62097 		goto _27
  62098 	_27:
  62099 		v9 = v12
  62100 		goto _24
  62101 	_24:
  62102 		tmp_v1 = v9
  62103 		if do_store != 0 {
  62104 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(tmp_u1)
  62105 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(tmp_v1)
  62106 		} else {
  62107 			**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(u1 + uintptr(i)))) + tmp_u1 + int32(1)) >> int32(1))
  62108 			**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32((libc.Int32FromUint8(**(**uint8_t)(__ccgo_up(v1 + uintptr(i)))) + tmp_v1 + int32(1)) >> int32(1))
  62109 		}
  62110 	}
  62111 }
  62112 
  62113 //-----------------------------------------------------------------------------
  62114 
  62115 func ConvertRGB24ToY_C(tls *libc.TLS, rgb uintptr, y uintptr, width int32) {
  62116 	var i, luma, v2 int32
  62117 	_, _, _ = i, luma, v2
  62118 	i = 0
  62119 	for {
  62120 		if !(i < width) {
  62121 			break
  62122 		}
  62123 		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)))
  62124 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  62125 		goto _3
  62126 	_3:
  62127 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  62128 		goto _1
  62129 	_1:
  62130 		;
  62131 		i = i + 1
  62132 		rgb = rgb + uintptr(3)
  62133 	}
  62134 }
  62135 
  62136 func ConvertBGR24ToY_C(tls *libc.TLS, bgr uintptr, y uintptr, width int32) {
  62137 	var i, luma, v2 int32
  62138 	_, _, _ = i, luma, v2
  62139 	i = 0
  62140 	for {
  62141 		if !(i < width) {
  62142 			break
  62143 		}
  62144 		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)))
  62145 		v2 = (luma + int32(YUV_HALF) + libc.Int32FromInt32(16)<<int32(YUV_FIX)) >> int32(YUV_FIX)
  62146 		goto _3
  62147 	_3:
  62148 		**(**uint8_t)(__ccgo_up(y + uintptr(i))) = libc.Uint8FromInt32(v2)
  62149 		goto _1
  62150 	_1:
  62151 		;
  62152 		i = i + 1
  62153 		bgr = bgr + uintptr(3)
  62154 	}
  62155 }
  62156 
  62157 func WebPConvertRGBA32ToUV_C(tls *libc.TLS, rgb uintptr, u1 uintptr, v1 uintptr, width int32) {
  62158 	var b2, g2, i, r2, u, v, v2, v4, v5, v7, v8 int32
  62159 	_, _, _, _, _, _, _, _, _, _, _ = b2, g2, i, r2, u, v, v2, v4, v5, v7, v8
  62160 	i = 0
  62161 	for {
  62162 		if !(i < width) {
  62163 			break
  62164 		}
  62165 		r2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb)))
  62166 		g2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 1*2)))
  62167 		b2 = libc.Int32FromUint16(**(**uint16_t)(__ccgo_up(rgb + 2*2)))
  62168 		u = -int32(9719)*r2 - int32(19081)*g2 + int32(28800)*b2
  62169 		v4 = u
  62170 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62171 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62172 			v7 = v4
  62173 		} else {
  62174 			if v4 < 0 {
  62175 				v8 = 0
  62176 			} else {
  62177 				v8 = int32(255)
  62178 			}
  62179 			v7 = v8
  62180 		}
  62181 		v5 = v7
  62182 		goto _6
  62183 	_6:
  62184 		v2 = v5
  62185 		goto _3
  62186 	_3:
  62187 		**(**uint8_t)(__ccgo_up(u1 + uintptr(i))) = libc.Uint8FromInt32(v2)
  62188 		v = +libc.Int32FromInt32(28800)*r2 - int32(24116)*g2 - int32(4684)*b2
  62189 		v4 = v
  62190 		v4 = (v4 + int32(YUV_HALF)<<libc.Int32FromInt32(2) + libc.Int32FromInt32(128)<<(int32(YUV_FIX)+libc.Int32FromInt32(2))) >> (int32(YUV_FIX) + libc.Int32FromInt32(2))
  62191 		if v4 & ^libc.Int32FromInt32(0xff) == 0 {
  62192 			v7 = v4
  62193 		} else {
  62194 			if v4 < 0 {
  62195 				v8 = 0
  62196 			} else {
  62197 				v8 = int32(255)
  62198 			}
  62199 			v7 = v8
  62200 		}
  62201 		v5 = v7
  62202 		goto _13
  62203 	_13:
  62204 		v2 = v5
  62205 		goto _10
  62206 	_10:
  62207 		**(**uint8_t)(__ccgo_up(v1 + uintptr(i))) = libc.Uint8FromInt32(v2)
  62208 		goto _1
  62209 	_1:
  62210 		;
  62211 		i = i + int32(1)
  62212 		rgb = rgb + uintptr(4)*2
  62213 	}
  62214 }
  62215 
  62216 func WebPInitConvertARGBToYUV(tls *libc.TLS) {
  62217 	if libc.AtomicLoadPUintptr(uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used))) == VP8GetCPUInfo {
  62218 		goto _1
  62219 	}
  62220 	WebPInitConvertARGBToYUV_body(tls)
  62221 	libc.AtomicStorePUintptr(uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used)), VP8GetCPUInfo)
  62222 	goto _2
  62223 _2:
  62224 	;
  62225 	goto _1
  62226 _1: /**/ //
  62227 }
  62228 
  62229 var WebPInitConvertARGBToYUV_body_last_cpuinfo_used = uintptr(0)
  62230 
  62231 func init() {
  62232 	p := unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used)
  62233 	*(*uintptr)(unsafe.Add(p, 0)) = uintptr(unsafe.Pointer(&WebPInitConvertARGBToYUV_body_last_cpuinfo_used))
  62234 }
  62235 
  62236 func WebPInitConvertARGBToYUV_body(tls *libc.TLS) {
  62237 	WebPConvertARGBToY = __ccgo_fp(ConvertARGBToY_C)
  62238 	WebPConvertARGBToUV = __ccgo_fp(WebPConvertARGBToUV_C)
  62239 	WebPConvertRGB24ToY = __ccgo_fp(ConvertRGB24ToY_C)
  62240 	WebPConvertBGR24ToY = __ccgo_fp(ConvertBGR24ToY_C)
  62241 	WebPConvertRGBA32ToUV = __ccgo_fp(WebPConvertRGBA32ToUV_C)
  62242 	if VP8GetCPUInfo != libc.UintptrFromInt32(0) {
  62243 	}
  62244 }
  62245 
  62246 func WebPInitSamplersMIPS32(tls *libc.TLS) {
  62247 }
  62248 
  62249 func WebPInitSamplersMIPSdspR2(tls *libc.TLS) {
  62250 }
  62251 
  62252 func WebPInitConvertARGBToYUVNEON(tls *libc.TLS) {
  62253 }
  62254 
  62255 func WebPInitSamplersSSE2(tls *libc.TLS) {
  62256 }
  62257 
  62258 func WebPInitConvertARGBToYUVSSE2(tls *libc.TLS) {
  62259 }
  62260 
  62261 func WebPInitSamplersSSE41(tls *libc.TLS) {
  62262 }
  62263 
  62264 func WebPInitConvertARGBToYUVSSE41(tls *libc.TLS) {
  62265 }
  62266 
  62267 type __ccgo_fp__XSharpYuvInit_0 = func(*libc.TLS, int32) int32
  62268 
  62269 func SharpYuvInit(tls *libc.TLS, __ccgo_fp_cpu_info_func VP8CPUInfo) {
  62270 	_ = __ccgo_fp_cpu_info_func
  62271 }
  62272 
  62273 func SharpYuvGetConversionMatrix(tls *libc.TLS, matrix_type SharpYuvMatrixType) (r uintptr) {
  62274 	_ = matrix_type
  62275 	return libc.UintptrFromInt32(0)
  62276 }
  62277 
  62278 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) {
  62279 	_ = r_ptr
  62280 	_ = g_ptr
  62281 	_ = b_ptr
  62282 	_ = rgb_step
  62283 	_ = rgb_stride
  62284 	_ = rgb_bit_depth
  62285 	_ = y_ptr
  62286 	_ = y_stride
  62287 	_ = u_ptr
  62288 	_ = u_stride
  62289 	_ = v_ptr
  62290 	_ = v_stride
  62291 	_ = yuv_bit_depth
  62292 	_ = width
  62293 	_ = height
  62294 	_ = yuv_matrix
  62295 	return 0
  62296 }
  62297 
  62298 func __ccgo_fp(f interface{}) uintptr {
  62299 	type iface [2]uintptr
  62300 	return (*iface)(unsafe.Pointer(&f))[1]
  62301 }
  62302 
  62303 func __ccgo_up(n uintptr) unsafe.Pointer {
  62304 	return unsafe.Pointer(&n)
  62305 }
  62306 
  62307 var VP8AccumulateSSE VP8AccumulateSSEFunc
  62308 
  62309 //------------------------------------------------------------------------------
  62310 // Tables for level coding
  62311 
  62312 var VP8Cat3 = [3]uint8_t{
  62313 	0: uint8(173),
  62314 	1: uint8(148),
  62315 	2: uint8(140),
  62316 }
  62317 
  62318 var VP8Cat4 = [4]uint8_t{
  62319 	0: uint8(176),
  62320 	1: uint8(155),
  62321 	2: uint8(140),
  62322 	3: uint8(135),
  62323 }
  62324 
  62325 var VP8Cat5 = [5]uint8_t{
  62326 	0: uint8(180),
  62327 	1: uint8(157),
  62328 	2: uint8(141),
  62329 	3: uint8(134),
  62330 	4: uint8(130),
  62331 }
  62332 
  62333 var VP8Cat6 = [11]uint8_t{
  62334 	0:  uint8(254),
  62335 	1:  uint8(254),
  62336 	2:  uint8(243),
  62337 	3:  uint8(230),
  62338 	4:  uint8(196),
  62339 	5:  uint8(177),
  62340 	6:  uint8(153),
  62341 	7:  uint8(140),
  62342 	8:  uint8(133),
  62343 	9:  uint8(130),
  62344 	10: uint8(129),
  62345 }
  62346 
  62347 //------------------------------------------------------------------------------
  62348 
  62349 // Copyright 2011 Google Inc. All Rights Reserved.
  62350 //
  62351 // Use of this source code is governed by a BSD-style license
  62352 // that can be found in the COPYING file in the root of the source
  62353 // tree. An additional intellectual property rights grant can be found
  62354 // in the file PATENTS. All contributing project authors may
  62355 // be found in the AUTHORS file in the root of the source tree.
  62356 // -----------------------------------------------------------------------------
  62357 //
  62358 // Bit writing and boolean coder
  62359 //
  62360 // Author: Skal (pascal.massimino@gmail.com)
  62361 
  62362 //------------------------------------------------------------------------------
  62363 // Default probabilities
  62364 
  62365 // C documentation
  62366 //
  62367 //	// Paragraph 13.5
  62368 
  62369 var VP8CoeffsProba0 = [4][8][3][11]uint8_t{
  62370 	0: {
  62371 		0: {
  62372 			0: {
  62373 				0:  uint8(128),
  62374 				1:  uint8(128),
  62375 				2:  uint8(128),
  62376 				3:  uint8(128),
  62377 				4:  uint8(128),
  62378 				5:  uint8(128),
  62379 				6:  uint8(128),
  62380 				7:  uint8(128),
  62381 				8:  uint8(128),
  62382 				9:  uint8(128),
  62383 				10: uint8(128),
  62384 			},
  62385 			1: {
  62386 				0:  uint8(128),
  62387 				1:  uint8(128),
  62388 				2:  uint8(128),
  62389 				3:  uint8(128),
  62390 				4:  uint8(128),
  62391 				5:  uint8(128),
  62392 				6:  uint8(128),
  62393 				7:  uint8(128),
  62394 				8:  uint8(128),
  62395 				9:  uint8(128),
  62396 				10: uint8(128),
  62397 			},
  62398 			2: {
  62399 				0:  uint8(128),
  62400 				1:  uint8(128),
  62401 				2:  uint8(128),
  62402 				3:  uint8(128),
  62403 				4:  uint8(128),
  62404 				5:  uint8(128),
  62405 				6:  uint8(128),
  62406 				7:  uint8(128),
  62407 				8:  uint8(128),
  62408 				9:  uint8(128),
  62409 				10: uint8(128),
  62410 			},
  62411 		},
  62412 		1: {
  62413 			0: {
  62414 				0:  uint8(253),
  62415 				1:  uint8(136),
  62416 				2:  uint8(254),
  62417 				3:  uint8(255),
  62418 				4:  uint8(228),
  62419 				5:  uint8(219),
  62420 				6:  uint8(128),
  62421 				7:  uint8(128),
  62422 				8:  uint8(128),
  62423 				9:  uint8(128),
  62424 				10: uint8(128),
  62425 			},
  62426 			1: {
  62427 				0:  uint8(189),
  62428 				1:  uint8(129),
  62429 				2:  uint8(242),
  62430 				3:  uint8(255),
  62431 				4:  uint8(227),
  62432 				5:  uint8(213),
  62433 				6:  uint8(255),
  62434 				7:  uint8(219),
  62435 				8:  uint8(128),
  62436 				9:  uint8(128),
  62437 				10: uint8(128),
  62438 			},
  62439 			2: {
  62440 				0:  uint8(106),
  62441 				1:  uint8(126),
  62442 				2:  uint8(227),
  62443 				3:  uint8(252),
  62444 				4:  uint8(214),
  62445 				5:  uint8(209),
  62446 				6:  uint8(255),
  62447 				7:  uint8(255),
  62448 				8:  uint8(128),
  62449 				9:  uint8(128),
  62450 				10: uint8(128),
  62451 			},
  62452 		},
  62453 		2: {
  62454 			0: {
  62455 				0:  uint8(1),
  62456 				1:  uint8(98),
  62457 				2:  uint8(248),
  62458 				3:  uint8(255),
  62459 				4:  uint8(236),
  62460 				5:  uint8(226),
  62461 				6:  uint8(255),
  62462 				7:  uint8(255),
  62463 				8:  uint8(128),
  62464 				9:  uint8(128),
  62465 				10: uint8(128),
  62466 			},
  62467 			1: {
  62468 				0:  uint8(181),
  62469 				1:  uint8(133),
  62470 				2:  uint8(238),
  62471 				3:  uint8(254),
  62472 				4:  uint8(221),
  62473 				5:  uint8(234),
  62474 				6:  uint8(255),
  62475 				7:  uint8(154),
  62476 				8:  uint8(128),
  62477 				9:  uint8(128),
  62478 				10: uint8(128),
  62479 			},
  62480 			2: {
  62481 				0:  uint8(78),
  62482 				1:  uint8(134),
  62483 				2:  uint8(202),
  62484 				3:  uint8(247),
  62485 				4:  uint8(198),
  62486 				5:  uint8(180),
  62487 				6:  uint8(255),
  62488 				7:  uint8(219),
  62489 				8:  uint8(128),
  62490 				9:  uint8(128),
  62491 				10: uint8(128),
  62492 			},
  62493 		},
  62494 		3: {
  62495 			0: {
  62496 				0:  uint8(1),
  62497 				1:  uint8(185),
  62498 				2:  uint8(249),
  62499 				3:  uint8(255),
  62500 				4:  uint8(243),
  62501 				5:  uint8(255),
  62502 				6:  uint8(128),
  62503 				7:  uint8(128),
  62504 				8:  uint8(128),
  62505 				9:  uint8(128),
  62506 				10: uint8(128),
  62507 			},
  62508 			1: {
  62509 				0:  uint8(184),
  62510 				1:  uint8(150),
  62511 				2:  uint8(247),
  62512 				3:  uint8(255),
  62513 				4:  uint8(236),
  62514 				5:  uint8(224),
  62515 				6:  uint8(128),
  62516 				7:  uint8(128),
  62517 				8:  uint8(128),
  62518 				9:  uint8(128),
  62519 				10: uint8(128),
  62520 			},
  62521 			2: {
  62522 				0:  uint8(77),
  62523 				1:  uint8(110),
  62524 				2:  uint8(216),
  62525 				3:  uint8(255),
  62526 				4:  uint8(236),
  62527 				5:  uint8(230),
  62528 				6:  uint8(128),
  62529 				7:  uint8(128),
  62530 				8:  uint8(128),
  62531 				9:  uint8(128),
  62532 				10: uint8(128),
  62533 			},
  62534 		},
  62535 		4: {
  62536 			0: {
  62537 				0:  uint8(1),
  62538 				1:  uint8(101),
  62539 				2:  uint8(251),
  62540 				3:  uint8(255),
  62541 				4:  uint8(241),
  62542 				5:  uint8(255),
  62543 				6:  uint8(128),
  62544 				7:  uint8(128),
  62545 				8:  uint8(128),
  62546 				9:  uint8(128),
  62547 				10: uint8(128),
  62548 			},
  62549 			1: {
  62550 				0:  uint8(170),
  62551 				1:  uint8(139),
  62552 				2:  uint8(241),
  62553 				3:  uint8(252),
  62554 				4:  uint8(236),
  62555 				5:  uint8(209),
  62556 				6:  uint8(255),
  62557 				7:  uint8(255),
  62558 				8:  uint8(128),
  62559 				9:  uint8(128),
  62560 				10: uint8(128),
  62561 			},
  62562 			2: {
  62563 				0:  uint8(37),
  62564 				1:  uint8(116),
  62565 				2:  uint8(196),
  62566 				3:  uint8(243),
  62567 				4:  uint8(228),
  62568 				5:  uint8(255),
  62569 				6:  uint8(255),
  62570 				7:  uint8(255),
  62571 				8:  uint8(128),
  62572 				9:  uint8(128),
  62573 				10: uint8(128),
  62574 			},
  62575 		},
  62576 		5: {
  62577 			0: {
  62578 				0:  uint8(1),
  62579 				1:  uint8(204),
  62580 				2:  uint8(254),
  62581 				3:  uint8(255),
  62582 				4:  uint8(245),
  62583 				5:  uint8(255),
  62584 				6:  uint8(128),
  62585 				7:  uint8(128),
  62586 				8:  uint8(128),
  62587 				9:  uint8(128),
  62588 				10: uint8(128),
  62589 			},
  62590 			1: {
  62591 				0:  uint8(207),
  62592 				1:  uint8(160),
  62593 				2:  uint8(250),
  62594 				3:  uint8(255),
  62595 				4:  uint8(238),
  62596 				5:  uint8(128),
  62597 				6:  uint8(128),
  62598 				7:  uint8(128),
  62599 				8:  uint8(128),
  62600 				9:  uint8(128),
  62601 				10: uint8(128),
  62602 			},
  62603 			2: {
  62604 				0:  uint8(102),
  62605 				1:  uint8(103),
  62606 				2:  uint8(231),
  62607 				3:  uint8(255),
  62608 				4:  uint8(211),
  62609 				5:  uint8(171),
  62610 				6:  uint8(128),
  62611 				7:  uint8(128),
  62612 				8:  uint8(128),
  62613 				9:  uint8(128),
  62614 				10: uint8(128),
  62615 			},
  62616 		},
  62617 		6: {
  62618 			0: {
  62619 				0:  uint8(1),
  62620 				1:  uint8(152),
  62621 				2:  uint8(252),
  62622 				3:  uint8(255),
  62623 				4:  uint8(240),
  62624 				5:  uint8(255),
  62625 				6:  uint8(128),
  62626 				7:  uint8(128),
  62627 				8:  uint8(128),
  62628 				9:  uint8(128),
  62629 				10: uint8(128),
  62630 			},
  62631 			1: {
  62632 				0:  uint8(177),
  62633 				1:  uint8(135),
  62634 				2:  uint8(243),
  62635 				3:  uint8(255),
  62636 				4:  uint8(234),
  62637 				5:  uint8(225),
  62638 				6:  uint8(128),
  62639 				7:  uint8(128),
  62640 				8:  uint8(128),
  62641 				9:  uint8(128),
  62642 				10: uint8(128),
  62643 			},
  62644 			2: {
  62645 				0:  uint8(80),
  62646 				1:  uint8(129),
  62647 				2:  uint8(211),
  62648 				3:  uint8(255),
  62649 				4:  uint8(194),
  62650 				5:  uint8(224),
  62651 				6:  uint8(128),
  62652 				7:  uint8(128),
  62653 				8:  uint8(128),
  62654 				9:  uint8(128),
  62655 				10: uint8(128),
  62656 			},
  62657 		},
  62658 		7: {
  62659 			0: {
  62660 				0:  uint8(1),
  62661 				1:  uint8(1),
  62662 				2:  uint8(255),
  62663 				3:  uint8(128),
  62664 				4:  uint8(128),
  62665 				5:  uint8(128),
  62666 				6:  uint8(128),
  62667 				7:  uint8(128),
  62668 				8:  uint8(128),
  62669 				9:  uint8(128),
  62670 				10: uint8(128),
  62671 			},
  62672 			1: {
  62673 				0:  uint8(246),
  62674 				1:  uint8(1),
  62675 				2:  uint8(255),
  62676 				3:  uint8(128),
  62677 				4:  uint8(128),
  62678 				5:  uint8(128),
  62679 				6:  uint8(128),
  62680 				7:  uint8(128),
  62681 				8:  uint8(128),
  62682 				9:  uint8(128),
  62683 				10: uint8(128),
  62684 			},
  62685 			2: {
  62686 				0:  uint8(255),
  62687 				1:  uint8(128),
  62688 				2:  uint8(128),
  62689 				3:  uint8(128),
  62690 				4:  uint8(128),
  62691 				5:  uint8(128),
  62692 				6:  uint8(128),
  62693 				7:  uint8(128),
  62694 				8:  uint8(128),
  62695 				9:  uint8(128),
  62696 				10: uint8(128),
  62697 			},
  62698 		},
  62699 	},
  62700 	1: {
  62701 		0: {
  62702 			0: {
  62703 				0:  uint8(198),
  62704 				1:  uint8(35),
  62705 				2:  uint8(237),
  62706 				3:  uint8(223),
  62707 				4:  uint8(193),
  62708 				5:  uint8(187),
  62709 				6:  uint8(162),
  62710 				7:  uint8(160),
  62711 				8:  uint8(145),
  62712 				9:  uint8(155),
  62713 				10: uint8(62),
  62714 			},
  62715 			1: {
  62716 				0:  uint8(131),
  62717 				1:  uint8(45),
  62718 				2:  uint8(198),
  62719 				3:  uint8(221),
  62720 				4:  uint8(172),
  62721 				5:  uint8(176),
  62722 				6:  uint8(220),
  62723 				7:  uint8(157),
  62724 				8:  uint8(252),
  62725 				9:  uint8(221),
  62726 				10: uint8(1),
  62727 			},
  62728 			2: {
  62729 				0:  uint8(68),
  62730 				1:  uint8(47),
  62731 				2:  uint8(146),
  62732 				3:  uint8(208),
  62733 				4:  uint8(149),
  62734 				5:  uint8(167),
  62735 				6:  uint8(221),
  62736 				7:  uint8(162),
  62737 				8:  uint8(255),
  62738 				9:  uint8(223),
  62739 				10: uint8(128),
  62740 			},
  62741 		},
  62742 		1: {
  62743 			0: {
  62744 				0:  uint8(1),
  62745 				1:  uint8(149),
  62746 				2:  uint8(241),
  62747 				3:  uint8(255),
  62748 				4:  uint8(221),
  62749 				5:  uint8(224),
  62750 				6:  uint8(255),
  62751 				7:  uint8(255),
  62752 				8:  uint8(128),
  62753 				9:  uint8(128),
  62754 				10: uint8(128),
  62755 			},
  62756 			1: {
  62757 				0:  uint8(184),
  62758 				1:  uint8(141),
  62759 				2:  uint8(234),
  62760 				3:  uint8(253),
  62761 				4:  uint8(222),
  62762 				5:  uint8(220),
  62763 				6:  uint8(255),
  62764 				7:  uint8(199),
  62765 				8:  uint8(128),
  62766 				9:  uint8(128),
  62767 				10: uint8(128),
  62768 			},
  62769 			2: {
  62770 				0:  uint8(81),
  62771 				1:  uint8(99),
  62772 				2:  uint8(181),
  62773 				3:  uint8(242),
  62774 				4:  uint8(176),
  62775 				5:  uint8(190),
  62776 				6:  uint8(249),
  62777 				7:  uint8(202),
  62778 				8:  uint8(255),
  62779 				9:  uint8(255),
  62780 				10: uint8(128),
  62781 			},
  62782 		},
  62783 		2: {
  62784 			0: {
  62785 				0:  uint8(1),
  62786 				1:  uint8(129),
  62787 				2:  uint8(232),
  62788 				3:  uint8(253),
  62789 				4:  uint8(214),
  62790 				5:  uint8(197),
  62791 				6:  uint8(242),
  62792 				7:  uint8(196),
  62793 				8:  uint8(255),
  62794 				9:  uint8(255),
  62795 				10: uint8(128),
  62796 			},
  62797 			1: {
  62798 				0:  uint8(99),
  62799 				1:  uint8(121),
  62800 				2:  uint8(210),
  62801 				3:  uint8(250),
  62802 				4:  uint8(201),
  62803 				5:  uint8(198),
  62804 				6:  uint8(255),
  62805 				7:  uint8(202),
  62806 				8:  uint8(128),
  62807 				9:  uint8(128),
  62808 				10: uint8(128),
  62809 			},
  62810 			2: {
  62811 				0:  uint8(23),
  62812 				1:  uint8(91),
  62813 				2:  uint8(163),
  62814 				3:  uint8(242),
  62815 				4:  uint8(170),
  62816 				5:  uint8(187),
  62817 				6:  uint8(247),
  62818 				7:  uint8(210),
  62819 				8:  uint8(255),
  62820 				9:  uint8(255),
  62821 				10: uint8(128),
  62822 			},
  62823 		},
  62824 		3: {
  62825 			0: {
  62826 				0:  uint8(1),
  62827 				1:  uint8(200),
  62828 				2:  uint8(246),
  62829 				3:  uint8(255),
  62830 				4:  uint8(234),
  62831 				5:  uint8(255),
  62832 				6:  uint8(128),
  62833 				7:  uint8(128),
  62834 				8:  uint8(128),
  62835 				9:  uint8(128),
  62836 				10: uint8(128),
  62837 			},
  62838 			1: {
  62839 				0:  uint8(109),
  62840 				1:  uint8(178),
  62841 				2:  uint8(241),
  62842 				3:  uint8(255),
  62843 				4:  uint8(231),
  62844 				5:  uint8(245),
  62845 				6:  uint8(255),
  62846 				7:  uint8(255),
  62847 				8:  uint8(128),
  62848 				9:  uint8(128),
  62849 				10: uint8(128),
  62850 			},
  62851 			2: {
  62852 				0:  uint8(44),
  62853 				1:  uint8(130),
  62854 				2:  uint8(201),
  62855 				3:  uint8(253),
  62856 				4:  uint8(205),
  62857 				5:  uint8(192),
  62858 				6:  uint8(255),
  62859 				7:  uint8(255),
  62860 				8:  uint8(128),
  62861 				9:  uint8(128),
  62862 				10: uint8(128),
  62863 			},
  62864 		},
  62865 		4: {
  62866 			0: {
  62867 				0:  uint8(1),
  62868 				1:  uint8(132),
  62869 				2:  uint8(239),
  62870 				3:  uint8(251),
  62871 				4:  uint8(219),
  62872 				5:  uint8(209),
  62873 				6:  uint8(255),
  62874 				7:  uint8(165),
  62875 				8:  uint8(128),
  62876 				9:  uint8(128),
  62877 				10: uint8(128),
  62878 			},
  62879 			1: {
  62880 				0:  uint8(94),
  62881 				1:  uint8(136),
  62882 				2:  uint8(225),
  62883 				3:  uint8(251),
  62884 				4:  uint8(218),
  62885 				5:  uint8(190),
  62886 				6:  uint8(255),
  62887 				7:  uint8(255),
  62888 				8:  uint8(128),
  62889 				9:  uint8(128),
  62890 				10: uint8(128),
  62891 			},
  62892 			2: {
  62893 				0:  uint8(22),
  62894 				1:  uint8(100),
  62895 				2:  uint8(174),
  62896 				3:  uint8(245),
  62897 				4:  uint8(186),
  62898 				5:  uint8(161),
  62899 				6:  uint8(255),
  62900 				7:  uint8(199),
  62901 				8:  uint8(128),
  62902 				9:  uint8(128),
  62903 				10: uint8(128),
  62904 			},
  62905 		},
  62906 		5: {
  62907 			0: {
  62908 				0:  uint8(1),
  62909 				1:  uint8(182),
  62910 				2:  uint8(249),
  62911 				3:  uint8(255),
  62912 				4:  uint8(232),
  62913 				5:  uint8(235),
  62914 				6:  uint8(128),
  62915 				7:  uint8(128),
  62916 				8:  uint8(128),
  62917 				9:  uint8(128),
  62918 				10: uint8(128),
  62919 			},
  62920 			1: {
  62921 				0:  uint8(124),
  62922 				1:  uint8(143),
  62923 				2:  uint8(241),
  62924 				3:  uint8(255),
  62925 				4:  uint8(227),
  62926 				5:  uint8(234),
  62927 				6:  uint8(128),
  62928 				7:  uint8(128),
  62929 				8:  uint8(128),
  62930 				9:  uint8(128),
  62931 				10: uint8(128),
  62932 			},
  62933 			2: {
  62934 				0:  uint8(35),
  62935 				1:  uint8(77),
  62936 				2:  uint8(181),
  62937 				3:  uint8(251),
  62938 				4:  uint8(193),
  62939 				5:  uint8(211),
  62940 				6:  uint8(255),
  62941 				7:  uint8(205),
  62942 				8:  uint8(128),
  62943 				9:  uint8(128),
  62944 				10: uint8(128),
  62945 			},
  62946 		},
  62947 		6: {
  62948 			0: {
  62949 				0:  uint8(1),
  62950 				1:  uint8(157),
  62951 				2:  uint8(247),
  62952 				3:  uint8(255),
  62953 				4:  uint8(236),
  62954 				5:  uint8(231),
  62955 				6:  uint8(255),
  62956 				7:  uint8(255),
  62957 				8:  uint8(128),
  62958 				9:  uint8(128),
  62959 				10: uint8(128),
  62960 			},
  62961 			1: {
  62962 				0:  uint8(121),
  62963 				1:  uint8(141),
  62964 				2:  uint8(235),
  62965 				3:  uint8(255),
  62966 				4:  uint8(225),
  62967 				5:  uint8(227),
  62968 				6:  uint8(255),
  62969 				7:  uint8(255),
  62970 				8:  uint8(128),
  62971 				9:  uint8(128),
  62972 				10: uint8(128),
  62973 			},
  62974 			2: {
  62975 				0:  uint8(45),
  62976 				1:  uint8(99),
  62977 				2:  uint8(188),
  62978 				3:  uint8(251),
  62979 				4:  uint8(195),
  62980 				5:  uint8(217),
  62981 				6:  uint8(255),
  62982 				7:  uint8(224),
  62983 				8:  uint8(128),
  62984 				9:  uint8(128),
  62985 				10: uint8(128),
  62986 			},
  62987 		},
  62988 		7: {
  62989 			0: {
  62990 				0:  uint8(1),
  62991 				1:  uint8(1),
  62992 				2:  uint8(251),
  62993 				3:  uint8(255),
  62994 				4:  uint8(213),
  62995 				5:  uint8(255),
  62996 				6:  uint8(128),
  62997 				7:  uint8(128),
  62998 				8:  uint8(128),
  62999 				9:  uint8(128),
  63000 				10: uint8(128),
  63001 			},
  63002 			1: {
  63003 				0:  uint8(203),
  63004 				1:  uint8(1),
  63005 				2:  uint8(248),
  63006 				3:  uint8(255),
  63007 				4:  uint8(255),
  63008 				5:  uint8(128),
  63009 				6:  uint8(128),
  63010 				7:  uint8(128),
  63011 				8:  uint8(128),
  63012 				9:  uint8(128),
  63013 				10: uint8(128),
  63014 			},
  63015 			2: {
  63016 				0:  uint8(137),
  63017 				1:  uint8(1),
  63018 				2:  uint8(177),
  63019 				3:  uint8(255),
  63020 				4:  uint8(224),
  63021 				5:  uint8(255),
  63022 				6:  uint8(128),
  63023 				7:  uint8(128),
  63024 				8:  uint8(128),
  63025 				9:  uint8(128),
  63026 				10: uint8(128),
  63027 			},
  63028 		},
  63029 	},
  63030 	2: {
  63031 		0: {
  63032 			0: {
  63033 				0:  uint8(253),
  63034 				1:  uint8(9),
  63035 				2:  uint8(248),
  63036 				3:  uint8(251),
  63037 				4:  uint8(207),
  63038 				5:  uint8(208),
  63039 				6:  uint8(255),
  63040 				7:  uint8(192),
  63041 				8:  uint8(128),
  63042 				9:  uint8(128),
  63043 				10: uint8(128),
  63044 			},
  63045 			1: {
  63046 				0:  uint8(175),
  63047 				1:  uint8(13),
  63048 				2:  uint8(224),
  63049 				3:  uint8(243),
  63050 				4:  uint8(193),
  63051 				5:  uint8(185),
  63052 				6:  uint8(249),
  63053 				7:  uint8(198),
  63054 				8:  uint8(255),
  63055 				9:  uint8(255),
  63056 				10: uint8(128),
  63057 			},
  63058 			2: {
  63059 				0:  uint8(73),
  63060 				1:  uint8(17),
  63061 				2:  uint8(171),
  63062 				3:  uint8(221),
  63063 				4:  uint8(161),
  63064 				5:  uint8(179),
  63065 				6:  uint8(236),
  63066 				7:  uint8(167),
  63067 				8:  uint8(255),
  63068 				9:  uint8(234),
  63069 				10: uint8(128),
  63070 			},
  63071 		},
  63072 		1: {
  63073 			0: {
  63074 				0:  uint8(1),
  63075 				1:  uint8(95),
  63076 				2:  uint8(247),
  63077 				3:  uint8(253),
  63078 				4:  uint8(212),
  63079 				5:  uint8(183),
  63080 				6:  uint8(255),
  63081 				7:  uint8(255),
  63082 				8:  uint8(128),
  63083 				9:  uint8(128),
  63084 				10: uint8(128),
  63085 			},
  63086 			1: {
  63087 				0:  uint8(239),
  63088 				1:  uint8(90),
  63089 				2:  uint8(244),
  63090 				3:  uint8(250),
  63091 				4:  uint8(211),
  63092 				5:  uint8(209),
  63093 				6:  uint8(255),
  63094 				7:  uint8(255),
  63095 				8:  uint8(128),
  63096 				9:  uint8(128),
  63097 				10: uint8(128),
  63098 			},
  63099 			2: {
  63100 				0:  uint8(155),
  63101 				1:  uint8(77),
  63102 				2:  uint8(195),
  63103 				3:  uint8(248),
  63104 				4:  uint8(188),
  63105 				5:  uint8(195),
  63106 				6:  uint8(255),
  63107 				7:  uint8(255),
  63108 				8:  uint8(128),
  63109 				9:  uint8(128),
  63110 				10: uint8(128),
  63111 			},
  63112 		},
  63113 		2: {
  63114 			0: {
  63115 				0:  uint8(1),
  63116 				1:  uint8(24),
  63117 				2:  uint8(239),
  63118 				3:  uint8(251),
  63119 				4:  uint8(218),
  63120 				5:  uint8(219),
  63121 				6:  uint8(255),
  63122 				7:  uint8(205),
  63123 				8:  uint8(128),
  63124 				9:  uint8(128),
  63125 				10: uint8(128),
  63126 			},
  63127 			1: {
  63128 				0:  uint8(201),
  63129 				1:  uint8(51),
  63130 				2:  uint8(219),
  63131 				3:  uint8(255),
  63132 				4:  uint8(196),
  63133 				5:  uint8(186),
  63134 				6:  uint8(128),
  63135 				7:  uint8(128),
  63136 				8:  uint8(128),
  63137 				9:  uint8(128),
  63138 				10: uint8(128),
  63139 			},
  63140 			2: {
  63141 				0:  uint8(69),
  63142 				1:  uint8(46),
  63143 				2:  uint8(190),
  63144 				3:  uint8(239),
  63145 				4:  uint8(201),
  63146 				5:  uint8(218),
  63147 				6:  uint8(255),
  63148 				7:  uint8(228),
  63149 				8:  uint8(128),
  63150 				9:  uint8(128),
  63151 				10: uint8(128),
  63152 			},
  63153 		},
  63154 		3: {
  63155 			0: {
  63156 				0:  uint8(1),
  63157 				1:  uint8(191),
  63158 				2:  uint8(251),
  63159 				3:  uint8(255),
  63160 				4:  uint8(255),
  63161 				5:  uint8(128),
  63162 				6:  uint8(128),
  63163 				7:  uint8(128),
  63164 				8:  uint8(128),
  63165 				9:  uint8(128),
  63166 				10: uint8(128),
  63167 			},
  63168 			1: {
  63169 				0:  uint8(223),
  63170 				1:  uint8(165),
  63171 				2:  uint8(249),
  63172 				3:  uint8(255),
  63173 				4:  uint8(213),
  63174 				5:  uint8(255),
  63175 				6:  uint8(128),
  63176 				7:  uint8(128),
  63177 				8:  uint8(128),
  63178 				9:  uint8(128),
  63179 				10: uint8(128),
  63180 			},
  63181 			2: {
  63182 				0:  uint8(141),
  63183 				1:  uint8(124),
  63184 				2:  uint8(248),
  63185 				3:  uint8(255),
  63186 				4:  uint8(255),
  63187 				5:  uint8(128),
  63188 				6:  uint8(128),
  63189 				7:  uint8(128),
  63190 				8:  uint8(128),
  63191 				9:  uint8(128),
  63192 				10: uint8(128),
  63193 			},
  63194 		},
  63195 		4: {
  63196 			0: {
  63197 				0:  uint8(1),
  63198 				1:  uint8(16),
  63199 				2:  uint8(248),
  63200 				3:  uint8(255),
  63201 				4:  uint8(255),
  63202 				5:  uint8(128),
  63203 				6:  uint8(128),
  63204 				7:  uint8(128),
  63205 				8:  uint8(128),
  63206 				9:  uint8(128),
  63207 				10: uint8(128),
  63208 			},
  63209 			1: {
  63210 				0:  uint8(190),
  63211 				1:  uint8(36),
  63212 				2:  uint8(230),
  63213 				3:  uint8(255),
  63214 				4:  uint8(236),
  63215 				5:  uint8(255),
  63216 				6:  uint8(128),
  63217 				7:  uint8(128),
  63218 				8:  uint8(128),
  63219 				9:  uint8(128),
  63220 				10: uint8(128),
  63221 			},
  63222 			2: {
  63223 				0:  uint8(149),
  63224 				1:  uint8(1),
  63225 				2:  uint8(255),
  63226 				3:  uint8(128),
  63227 				4:  uint8(128),
  63228 				5:  uint8(128),
  63229 				6:  uint8(128),
  63230 				7:  uint8(128),
  63231 				8:  uint8(128),
  63232 				9:  uint8(128),
  63233 				10: uint8(128),
  63234 			},
  63235 		},
  63236 		5: {
  63237 			0: {
  63238 				0:  uint8(1),
  63239 				1:  uint8(226),
  63240 				2:  uint8(255),
  63241 				3:  uint8(128),
  63242 				4:  uint8(128),
  63243 				5:  uint8(128),
  63244 				6:  uint8(128),
  63245 				7:  uint8(128),
  63246 				8:  uint8(128),
  63247 				9:  uint8(128),
  63248 				10: uint8(128),
  63249 			},
  63250 			1: {
  63251 				0:  uint8(247),
  63252 				1:  uint8(192),
  63253 				2:  uint8(255),
  63254 				3:  uint8(128),
  63255 				4:  uint8(128),
  63256 				5:  uint8(128),
  63257 				6:  uint8(128),
  63258 				7:  uint8(128),
  63259 				8:  uint8(128),
  63260 				9:  uint8(128),
  63261 				10: uint8(128),
  63262 			},
  63263 			2: {
  63264 				0:  uint8(240),
  63265 				1:  uint8(128),
  63266 				2:  uint8(255),
  63267 				3:  uint8(128),
  63268 				4:  uint8(128),
  63269 				5:  uint8(128),
  63270 				6:  uint8(128),
  63271 				7:  uint8(128),
  63272 				8:  uint8(128),
  63273 				9:  uint8(128),
  63274 				10: uint8(128),
  63275 			},
  63276 		},
  63277 		6: {
  63278 			0: {
  63279 				0:  uint8(1),
  63280 				1:  uint8(134),
  63281 				2:  uint8(252),
  63282 				3:  uint8(255),
  63283 				4:  uint8(255),
  63284 				5:  uint8(128),
  63285 				6:  uint8(128),
  63286 				7:  uint8(128),
  63287 				8:  uint8(128),
  63288 				9:  uint8(128),
  63289 				10: uint8(128),
  63290 			},
  63291 			1: {
  63292 				0:  uint8(213),
  63293 				1:  uint8(62),
  63294 				2:  uint8(250),
  63295 				3:  uint8(255),
  63296 				4:  uint8(255),
  63297 				5:  uint8(128),
  63298 				6:  uint8(128),
  63299 				7:  uint8(128),
  63300 				8:  uint8(128),
  63301 				9:  uint8(128),
  63302 				10: uint8(128),
  63303 			},
  63304 			2: {
  63305 				0:  uint8(55),
  63306 				1:  uint8(93),
  63307 				2:  uint8(255),
  63308 				3:  uint8(128),
  63309 				4:  uint8(128),
  63310 				5:  uint8(128),
  63311 				6:  uint8(128),
  63312 				7:  uint8(128),
  63313 				8:  uint8(128),
  63314 				9:  uint8(128),
  63315 				10: uint8(128),
  63316 			},
  63317 		},
  63318 		7: {
  63319 			0: {
  63320 				0:  uint8(128),
  63321 				1:  uint8(128),
  63322 				2:  uint8(128),
  63323 				3:  uint8(128),
  63324 				4:  uint8(128),
  63325 				5:  uint8(128),
  63326 				6:  uint8(128),
  63327 				7:  uint8(128),
  63328 				8:  uint8(128),
  63329 				9:  uint8(128),
  63330 				10: uint8(128),
  63331 			},
  63332 			1: {
  63333 				0:  uint8(128),
  63334 				1:  uint8(128),
  63335 				2:  uint8(128),
  63336 				3:  uint8(128),
  63337 				4:  uint8(128),
  63338 				5:  uint8(128),
  63339 				6:  uint8(128),
  63340 				7:  uint8(128),
  63341 				8:  uint8(128),
  63342 				9:  uint8(128),
  63343 				10: uint8(128),
  63344 			},
  63345 			2: {
  63346 				0:  uint8(128),
  63347 				1:  uint8(128),
  63348 				2:  uint8(128),
  63349 				3:  uint8(128),
  63350 				4:  uint8(128),
  63351 				5:  uint8(128),
  63352 				6:  uint8(128),
  63353 				7:  uint8(128),
  63354 				8:  uint8(128),
  63355 				9:  uint8(128),
  63356 				10: uint8(128),
  63357 			},
  63358 		},
  63359 	},
  63360 	3: {
  63361 		0: {
  63362 			0: {
  63363 				0:  uint8(202),
  63364 				1:  uint8(24),
  63365 				2:  uint8(213),
  63366 				3:  uint8(235),
  63367 				4:  uint8(186),
  63368 				5:  uint8(191),
  63369 				6:  uint8(220),
  63370 				7:  uint8(160),
  63371 				8:  uint8(240),
  63372 				9:  uint8(175),
  63373 				10: uint8(255),
  63374 			},
  63375 			1: {
  63376 				0:  uint8(126),
  63377 				1:  uint8(38),
  63378 				2:  uint8(182),
  63379 				3:  uint8(232),
  63380 				4:  uint8(169),
  63381 				5:  uint8(184),
  63382 				6:  uint8(228),
  63383 				7:  uint8(174),
  63384 				8:  uint8(255),
  63385 				9:  uint8(187),
  63386 				10: uint8(128),
  63387 			},
  63388 			2: {
  63389 				0:  uint8(61),
  63390 				1:  uint8(46),
  63391 				2:  uint8(138),
  63392 				3:  uint8(219),
  63393 				4:  uint8(151),
  63394 				5:  uint8(178),
  63395 				6:  uint8(240),
  63396 				7:  uint8(170),
  63397 				8:  uint8(255),
  63398 				9:  uint8(216),
  63399 				10: uint8(128),
  63400 			},
  63401 		},
  63402 		1: {
  63403 			0: {
  63404 				0:  uint8(1),
  63405 				1:  uint8(112),
  63406 				2:  uint8(230),
  63407 				3:  uint8(250),
  63408 				4:  uint8(199),
  63409 				5:  uint8(191),
  63410 				6:  uint8(247),
  63411 				7:  uint8(159),
  63412 				8:  uint8(255),
  63413 				9:  uint8(255),
  63414 				10: uint8(128),
  63415 			},
  63416 			1: {
  63417 				0:  uint8(166),
  63418 				1:  uint8(109),
  63419 				2:  uint8(228),
  63420 				3:  uint8(252),
  63421 				4:  uint8(211),
  63422 				5:  uint8(215),
  63423 				6:  uint8(255),
  63424 				7:  uint8(174),
  63425 				8:  uint8(128),
  63426 				9:  uint8(128),
  63427 				10: uint8(128),
  63428 			},
  63429 			2: {
  63430 				0:  uint8(39),
  63431 				1:  uint8(77),
  63432 				2:  uint8(162),
  63433 				3:  uint8(232),
  63434 				4:  uint8(172),
  63435 				5:  uint8(180),
  63436 				6:  uint8(245),
  63437 				7:  uint8(178),
  63438 				8:  uint8(255),
  63439 				9:  uint8(255),
  63440 				10: uint8(128),
  63441 			},
  63442 		},
  63443 		2: {
  63444 			0: {
  63445 				0:  uint8(1),
  63446 				1:  uint8(52),
  63447 				2:  uint8(220),
  63448 				3:  uint8(246),
  63449 				4:  uint8(198),
  63450 				5:  uint8(199),
  63451 				6:  uint8(249),
  63452 				7:  uint8(220),
  63453 				8:  uint8(255),
  63454 				9:  uint8(255),
  63455 				10: uint8(128),
  63456 			},
  63457 			1: {
  63458 				0:  uint8(124),
  63459 				1:  uint8(74),
  63460 				2:  uint8(191),
  63461 				3:  uint8(243),
  63462 				4:  uint8(183),
  63463 				5:  uint8(193),
  63464 				6:  uint8(250),
  63465 				7:  uint8(221),
  63466 				8:  uint8(255),
  63467 				9:  uint8(255),
  63468 				10: uint8(128),
  63469 			},
  63470 			2: {
  63471 				0:  uint8(24),
  63472 				1:  uint8(71),
  63473 				2:  uint8(130),
  63474 				3:  uint8(219),
  63475 				4:  uint8(154),
  63476 				5:  uint8(170),
  63477 				6:  uint8(243),
  63478 				7:  uint8(182),
  63479 				8:  uint8(255),
  63480 				9:  uint8(255),
  63481 				10: uint8(128),
  63482 			},
  63483 		},
  63484 		3: {
  63485 			0: {
  63486 				0:  uint8(1),
  63487 				1:  uint8(182),
  63488 				2:  uint8(225),
  63489 				3:  uint8(249),
  63490 				4:  uint8(219),
  63491 				5:  uint8(240),
  63492 				6:  uint8(255),
  63493 				7:  uint8(224),
  63494 				8:  uint8(128),
  63495 				9:  uint8(128),
  63496 				10: uint8(128),
  63497 			},
  63498 			1: {
  63499 				0:  uint8(149),
  63500 				1:  uint8(150),
  63501 				2:  uint8(226),
  63502 				3:  uint8(252),
  63503 				4:  uint8(216),
  63504 				5:  uint8(205),
  63505 				6:  uint8(255),
  63506 				7:  uint8(171),
  63507 				8:  uint8(128),
  63508 				9:  uint8(128),
  63509 				10: uint8(128),
  63510 			},
  63511 			2: {
  63512 				0:  uint8(28),
  63513 				1:  uint8(108),
  63514 				2:  uint8(170),
  63515 				3:  uint8(242),
  63516 				4:  uint8(183),
  63517 				5:  uint8(194),
  63518 				6:  uint8(254),
  63519 				7:  uint8(223),
  63520 				8:  uint8(255),
  63521 				9:  uint8(255),
  63522 				10: uint8(128),
  63523 			},
  63524 		},
  63525 		4: {
  63526 			0: {
  63527 				0:  uint8(1),
  63528 				1:  uint8(81),
  63529 				2:  uint8(230),
  63530 				3:  uint8(252),
  63531 				4:  uint8(204),
  63532 				5:  uint8(203),
  63533 				6:  uint8(255),
  63534 				7:  uint8(192),
  63535 				8:  uint8(128),
  63536 				9:  uint8(128),
  63537 				10: uint8(128),
  63538 			},
  63539 			1: {
  63540 				0:  uint8(123),
  63541 				1:  uint8(102),
  63542 				2:  uint8(209),
  63543 				3:  uint8(247),
  63544 				4:  uint8(188),
  63545 				5:  uint8(196),
  63546 				6:  uint8(255),
  63547 				7:  uint8(233),
  63548 				8:  uint8(128),
  63549 				9:  uint8(128),
  63550 				10: uint8(128),
  63551 			},
  63552 			2: {
  63553 				0:  uint8(20),
  63554 				1:  uint8(95),
  63555 				2:  uint8(153),
  63556 				3:  uint8(243),
  63557 				4:  uint8(164),
  63558 				5:  uint8(173),
  63559 				6:  uint8(255),
  63560 				7:  uint8(203),
  63561 				8:  uint8(128),
  63562 				9:  uint8(128),
  63563 				10: uint8(128),
  63564 			},
  63565 		},
  63566 		5: {
  63567 			0: {
  63568 				0:  uint8(1),
  63569 				1:  uint8(222),
  63570 				2:  uint8(248),
  63571 				3:  uint8(255),
  63572 				4:  uint8(216),
  63573 				5:  uint8(213),
  63574 				6:  uint8(128),
  63575 				7:  uint8(128),
  63576 				8:  uint8(128),
  63577 				9:  uint8(128),
  63578 				10: uint8(128),
  63579 			},
  63580 			1: {
  63581 				0:  uint8(168),
  63582 				1:  uint8(175),
  63583 				2:  uint8(246),
  63584 				3:  uint8(252),
  63585 				4:  uint8(235),
  63586 				5:  uint8(205),
  63587 				6:  uint8(255),
  63588 				7:  uint8(255),
  63589 				8:  uint8(128),
  63590 				9:  uint8(128),
  63591 				10: uint8(128),
  63592 			},
  63593 			2: {
  63594 				0:  uint8(47),
  63595 				1:  uint8(116),
  63596 				2:  uint8(215),
  63597 				3:  uint8(255),
  63598 				4:  uint8(211),
  63599 				5:  uint8(212),
  63600 				6:  uint8(255),
  63601 				7:  uint8(255),
  63602 				8:  uint8(128),
  63603 				9:  uint8(128),
  63604 				10: uint8(128),
  63605 			},
  63606 		},
  63607 		6: {
  63608 			0: {
  63609 				0:  uint8(1),
  63610 				1:  uint8(121),
  63611 				2:  uint8(236),
  63612 				3:  uint8(253),
  63613 				4:  uint8(212),
  63614 				5:  uint8(214),
  63615 				6:  uint8(255),
  63616 				7:  uint8(255),
  63617 				8:  uint8(128),
  63618 				9:  uint8(128),
  63619 				10: uint8(128),
  63620 			},
  63621 			1: {
  63622 				0:  uint8(141),
  63623 				1:  uint8(84),
  63624 				2:  uint8(213),
  63625 				3:  uint8(252),
  63626 				4:  uint8(201),
  63627 				5:  uint8(202),
  63628 				6:  uint8(255),
  63629 				7:  uint8(219),
  63630 				8:  uint8(128),
  63631 				9:  uint8(128),
  63632 				10: uint8(128),
  63633 			},
  63634 			2: {
  63635 				0:  uint8(42),
  63636 				1:  uint8(80),
  63637 				2:  uint8(160),
  63638 				3:  uint8(240),
  63639 				4:  uint8(162),
  63640 				5:  uint8(185),
  63641 				6:  uint8(255),
  63642 				7:  uint8(205),
  63643 				8:  uint8(128),
  63644 				9:  uint8(128),
  63645 				10: uint8(128),
  63646 			},
  63647 		},
  63648 		7: {
  63649 			0: {
  63650 				0:  uint8(1),
  63651 				1:  uint8(1),
  63652 				2:  uint8(255),
  63653 				3:  uint8(128),
  63654 				4:  uint8(128),
  63655 				5:  uint8(128),
  63656 				6:  uint8(128),
  63657 				7:  uint8(128),
  63658 				8:  uint8(128),
  63659 				9:  uint8(128),
  63660 				10: uint8(128),
  63661 			},
  63662 			1: {
  63663 				0:  uint8(244),
  63664 				1:  uint8(1),
  63665 				2:  uint8(255),
  63666 				3:  uint8(128),
  63667 				4:  uint8(128),
  63668 				5:  uint8(128),
  63669 				6:  uint8(128),
  63670 				7:  uint8(128),
  63671 				8:  uint8(128),
  63672 				9:  uint8(128),
  63673 				10: uint8(128),
  63674 			},
  63675 			2: {
  63676 				0:  uint8(238),
  63677 				1:  uint8(1),
  63678 				2:  uint8(255),
  63679 				3:  uint8(128),
  63680 				4:  uint8(128),
  63681 				5:  uint8(128),
  63682 				6:  uint8(128),
  63683 				7:  uint8(128),
  63684 				8:  uint8(128),
  63685 				9:  uint8(128),
  63686 				10: uint8(128),
  63687 			},
  63688 		},
  63689 	},
  63690 }
  63691 
  63692 //------------------------------------------------------------------------------
  63693 // Paragraph 13
  63694 
  63695 var VP8CoeffsUpdateProba = [4][8][3][11]uint8_t{
  63696 	0: {
  63697 		0: {
  63698 			0: {
  63699 				0:  uint8(255),
  63700 				1:  uint8(255),
  63701 				2:  uint8(255),
  63702 				3:  uint8(255),
  63703 				4:  uint8(255),
  63704 				5:  uint8(255),
  63705 				6:  uint8(255),
  63706 				7:  uint8(255),
  63707 				8:  uint8(255),
  63708 				9:  uint8(255),
  63709 				10: uint8(255),
  63710 			},
  63711 			1: {
  63712 				0:  uint8(255),
  63713 				1:  uint8(255),
  63714 				2:  uint8(255),
  63715 				3:  uint8(255),
  63716 				4:  uint8(255),
  63717 				5:  uint8(255),
  63718 				6:  uint8(255),
  63719 				7:  uint8(255),
  63720 				8:  uint8(255),
  63721 				9:  uint8(255),
  63722 				10: uint8(255),
  63723 			},
  63724 			2: {
  63725 				0:  uint8(255),
  63726 				1:  uint8(255),
  63727 				2:  uint8(255),
  63728 				3:  uint8(255),
  63729 				4:  uint8(255),
  63730 				5:  uint8(255),
  63731 				6:  uint8(255),
  63732 				7:  uint8(255),
  63733 				8:  uint8(255),
  63734 				9:  uint8(255),
  63735 				10: uint8(255),
  63736 			},
  63737 		},
  63738 		1: {
  63739 			0: {
  63740 				0:  uint8(176),
  63741 				1:  uint8(246),
  63742 				2:  uint8(255),
  63743 				3:  uint8(255),
  63744 				4:  uint8(255),
  63745 				5:  uint8(255),
  63746 				6:  uint8(255),
  63747 				7:  uint8(255),
  63748 				8:  uint8(255),
  63749 				9:  uint8(255),
  63750 				10: uint8(255),
  63751 			},
  63752 			1: {
  63753 				0:  uint8(223),
  63754 				1:  uint8(241),
  63755 				2:  uint8(252),
  63756 				3:  uint8(255),
  63757 				4:  uint8(255),
  63758 				5:  uint8(255),
  63759 				6:  uint8(255),
  63760 				7:  uint8(255),
  63761 				8:  uint8(255),
  63762 				9:  uint8(255),
  63763 				10: uint8(255),
  63764 			},
  63765 			2: {
  63766 				0:  uint8(249),
  63767 				1:  uint8(253),
  63768 				2:  uint8(253),
  63769 				3:  uint8(255),
  63770 				4:  uint8(255),
  63771 				5:  uint8(255),
  63772 				6:  uint8(255),
  63773 				7:  uint8(255),
  63774 				8:  uint8(255),
  63775 				9:  uint8(255),
  63776 				10: uint8(255),
  63777 			},
  63778 		},
  63779 		2: {
  63780 			0: {
  63781 				0:  uint8(255),
  63782 				1:  uint8(244),
  63783 				2:  uint8(252),
  63784 				3:  uint8(255),
  63785 				4:  uint8(255),
  63786 				5:  uint8(255),
  63787 				6:  uint8(255),
  63788 				7:  uint8(255),
  63789 				8:  uint8(255),
  63790 				9:  uint8(255),
  63791 				10: uint8(255),
  63792 			},
  63793 			1: {
  63794 				0:  uint8(234),
  63795 				1:  uint8(254),
  63796 				2:  uint8(254),
  63797 				3:  uint8(255),
  63798 				4:  uint8(255),
  63799 				5:  uint8(255),
  63800 				6:  uint8(255),
  63801 				7:  uint8(255),
  63802 				8:  uint8(255),
  63803 				9:  uint8(255),
  63804 				10: uint8(255),
  63805 			},
  63806 			2: {
  63807 				0:  uint8(253),
  63808 				1:  uint8(255),
  63809 				2:  uint8(255),
  63810 				3:  uint8(255),
  63811 				4:  uint8(255),
  63812 				5:  uint8(255),
  63813 				6:  uint8(255),
  63814 				7:  uint8(255),
  63815 				8:  uint8(255),
  63816 				9:  uint8(255),
  63817 				10: uint8(255),
  63818 			},
  63819 		},
  63820 		3: {
  63821 			0: {
  63822 				0:  uint8(255),
  63823 				1:  uint8(246),
  63824 				2:  uint8(254),
  63825 				3:  uint8(255),
  63826 				4:  uint8(255),
  63827 				5:  uint8(255),
  63828 				6:  uint8(255),
  63829 				7:  uint8(255),
  63830 				8:  uint8(255),
  63831 				9:  uint8(255),
  63832 				10: uint8(255),
  63833 			},
  63834 			1: {
  63835 				0:  uint8(239),
  63836 				1:  uint8(253),
  63837 				2:  uint8(254),
  63838 				3:  uint8(255),
  63839 				4:  uint8(255),
  63840 				5:  uint8(255),
  63841 				6:  uint8(255),
  63842 				7:  uint8(255),
  63843 				8:  uint8(255),
  63844 				9:  uint8(255),
  63845 				10: uint8(255),
  63846 			},
  63847 			2: {
  63848 				0:  uint8(254),
  63849 				1:  uint8(255),
  63850 				2:  uint8(254),
  63851 				3:  uint8(255),
  63852 				4:  uint8(255),
  63853 				5:  uint8(255),
  63854 				6:  uint8(255),
  63855 				7:  uint8(255),
  63856 				8:  uint8(255),
  63857 				9:  uint8(255),
  63858 				10: uint8(255),
  63859 			},
  63860 		},
  63861 		4: {
  63862 			0: {
  63863 				0:  uint8(255),
  63864 				1:  uint8(248),
  63865 				2:  uint8(254),
  63866 				3:  uint8(255),
  63867 				4:  uint8(255),
  63868 				5:  uint8(255),
  63869 				6:  uint8(255),
  63870 				7:  uint8(255),
  63871 				8:  uint8(255),
  63872 				9:  uint8(255),
  63873 				10: uint8(255),
  63874 			},
  63875 			1: {
  63876 				0:  uint8(251),
  63877 				1:  uint8(255),
  63878 				2:  uint8(254),
  63879 				3:  uint8(255),
  63880 				4:  uint8(255),
  63881 				5:  uint8(255),
  63882 				6:  uint8(255),
  63883 				7:  uint8(255),
  63884 				8:  uint8(255),
  63885 				9:  uint8(255),
  63886 				10: uint8(255),
  63887 			},
  63888 			2: {
  63889 				0:  uint8(255),
  63890 				1:  uint8(255),
  63891 				2:  uint8(255),
  63892 				3:  uint8(255),
  63893 				4:  uint8(255),
  63894 				5:  uint8(255),
  63895 				6:  uint8(255),
  63896 				7:  uint8(255),
  63897 				8:  uint8(255),
  63898 				9:  uint8(255),
  63899 				10: uint8(255),
  63900 			},
  63901 		},
  63902 		5: {
  63903 			0: {
  63904 				0:  uint8(255),
  63905 				1:  uint8(253),
  63906 				2:  uint8(254),
  63907 				3:  uint8(255),
  63908 				4:  uint8(255),
  63909 				5:  uint8(255),
  63910 				6:  uint8(255),
  63911 				7:  uint8(255),
  63912 				8:  uint8(255),
  63913 				9:  uint8(255),
  63914 				10: uint8(255),
  63915 			},
  63916 			1: {
  63917 				0:  uint8(251),
  63918 				1:  uint8(254),
  63919 				2:  uint8(254),
  63920 				3:  uint8(255),
  63921 				4:  uint8(255),
  63922 				5:  uint8(255),
  63923 				6:  uint8(255),
  63924 				7:  uint8(255),
  63925 				8:  uint8(255),
  63926 				9:  uint8(255),
  63927 				10: uint8(255),
  63928 			},
  63929 			2: {
  63930 				0:  uint8(254),
  63931 				1:  uint8(255),
  63932 				2:  uint8(254),
  63933 				3:  uint8(255),
  63934 				4:  uint8(255),
  63935 				5:  uint8(255),
  63936 				6:  uint8(255),
  63937 				7:  uint8(255),
  63938 				8:  uint8(255),
  63939 				9:  uint8(255),
  63940 				10: uint8(255),
  63941 			},
  63942 		},
  63943 		6: {
  63944 			0: {
  63945 				0:  uint8(255),
  63946 				1:  uint8(254),
  63947 				2:  uint8(253),
  63948 				3:  uint8(255),
  63949 				4:  uint8(254),
  63950 				5:  uint8(255),
  63951 				6:  uint8(255),
  63952 				7:  uint8(255),
  63953 				8:  uint8(255),
  63954 				9:  uint8(255),
  63955 				10: uint8(255),
  63956 			},
  63957 			1: {
  63958 				0:  uint8(250),
  63959 				1:  uint8(255),
  63960 				2:  uint8(254),
  63961 				3:  uint8(255),
  63962 				4:  uint8(254),
  63963 				5:  uint8(255),
  63964 				6:  uint8(255),
  63965 				7:  uint8(255),
  63966 				8:  uint8(255),
  63967 				9:  uint8(255),
  63968 				10: uint8(255),
  63969 			},
  63970 			2: {
  63971 				0:  uint8(254),
  63972 				1:  uint8(255),
  63973 				2:  uint8(255),
  63974 				3:  uint8(255),
  63975 				4:  uint8(255),
  63976 				5:  uint8(255),
  63977 				6:  uint8(255),
  63978 				7:  uint8(255),
  63979 				8:  uint8(255),
  63980 				9:  uint8(255),
  63981 				10: uint8(255),
  63982 			},
  63983 		},
  63984 		7: {
  63985 			0: {
  63986 				0:  uint8(255),
  63987 				1:  uint8(255),
  63988 				2:  uint8(255),
  63989 				3:  uint8(255),
  63990 				4:  uint8(255),
  63991 				5:  uint8(255),
  63992 				6:  uint8(255),
  63993 				7:  uint8(255),
  63994 				8:  uint8(255),
  63995 				9:  uint8(255),
  63996 				10: uint8(255),
  63997 			},
  63998 			1: {
  63999 				0:  uint8(255),
  64000 				1:  uint8(255),
  64001 				2:  uint8(255),
  64002 				3:  uint8(255),
  64003 				4:  uint8(255),
  64004 				5:  uint8(255),
  64005 				6:  uint8(255),
  64006 				7:  uint8(255),
  64007 				8:  uint8(255),
  64008 				9:  uint8(255),
  64009 				10: uint8(255),
  64010 			},
  64011 			2: {
  64012 				0:  uint8(255),
  64013 				1:  uint8(255),
  64014 				2:  uint8(255),
  64015 				3:  uint8(255),
  64016 				4:  uint8(255),
  64017 				5:  uint8(255),
  64018 				6:  uint8(255),
  64019 				7:  uint8(255),
  64020 				8:  uint8(255),
  64021 				9:  uint8(255),
  64022 				10: uint8(255),
  64023 			},
  64024 		},
  64025 	},
  64026 	1: {
  64027 		0: {
  64028 			0: {
  64029 				0:  uint8(217),
  64030 				1:  uint8(255),
  64031 				2:  uint8(255),
  64032 				3:  uint8(255),
  64033 				4:  uint8(255),
  64034 				5:  uint8(255),
  64035 				6:  uint8(255),
  64036 				7:  uint8(255),
  64037 				8:  uint8(255),
  64038 				9:  uint8(255),
  64039 				10: uint8(255),
  64040 			},
  64041 			1: {
  64042 				0:  uint8(225),
  64043 				1:  uint8(252),
  64044 				2:  uint8(241),
  64045 				3:  uint8(253),
  64046 				4:  uint8(255),
  64047 				5:  uint8(255),
  64048 				6:  uint8(254),
  64049 				7:  uint8(255),
  64050 				8:  uint8(255),
  64051 				9:  uint8(255),
  64052 				10: uint8(255),
  64053 			},
  64054 			2: {
  64055 				0:  uint8(234),
  64056 				1:  uint8(250),
  64057 				2:  uint8(241),
  64058 				3:  uint8(250),
  64059 				4:  uint8(253),
  64060 				5:  uint8(255),
  64061 				6:  uint8(253),
  64062 				7:  uint8(254),
  64063 				8:  uint8(255),
  64064 				9:  uint8(255),
  64065 				10: uint8(255),
  64066 			},
  64067 		},
  64068 		1: {
  64069 			0: {
  64070 				0:  uint8(255),
  64071 				1:  uint8(254),
  64072 				2:  uint8(255),
  64073 				3:  uint8(255),
  64074 				4:  uint8(255),
  64075 				5:  uint8(255),
  64076 				6:  uint8(255),
  64077 				7:  uint8(255),
  64078 				8:  uint8(255),
  64079 				9:  uint8(255),
  64080 				10: uint8(255),
  64081 			},
  64082 			1: {
  64083 				0:  uint8(223),
  64084 				1:  uint8(254),
  64085 				2:  uint8(254),
  64086 				3:  uint8(255),
  64087 				4:  uint8(255),
  64088 				5:  uint8(255),
  64089 				6:  uint8(255),
  64090 				7:  uint8(255),
  64091 				8:  uint8(255),
  64092 				9:  uint8(255),
  64093 				10: uint8(255),
  64094 			},
  64095 			2: {
  64096 				0:  uint8(238),
  64097 				1:  uint8(253),
  64098 				2:  uint8(254),
  64099 				3:  uint8(254),
  64100 				4:  uint8(255),
  64101 				5:  uint8(255),
  64102 				6:  uint8(255),
  64103 				7:  uint8(255),
  64104 				8:  uint8(255),
  64105 				9:  uint8(255),
  64106 				10: uint8(255),
  64107 			},
  64108 		},
  64109 		2: {
  64110 			0: {
  64111 				0:  uint8(255),
  64112 				1:  uint8(248),
  64113 				2:  uint8(254),
  64114 				3:  uint8(255),
  64115 				4:  uint8(255),
  64116 				5:  uint8(255),
  64117 				6:  uint8(255),
  64118 				7:  uint8(255),
  64119 				8:  uint8(255),
  64120 				9:  uint8(255),
  64121 				10: uint8(255),
  64122 			},
  64123 			1: {
  64124 				0:  uint8(249),
  64125 				1:  uint8(254),
  64126 				2:  uint8(255),
  64127 				3:  uint8(255),
  64128 				4:  uint8(255),
  64129 				5:  uint8(255),
  64130 				6:  uint8(255),
  64131 				7:  uint8(255),
  64132 				8:  uint8(255),
  64133 				9:  uint8(255),
  64134 				10: uint8(255),
  64135 			},
  64136 			2: {
  64137 				0:  uint8(255),
  64138 				1:  uint8(255),
  64139 				2:  uint8(255),
  64140 				3:  uint8(255),
  64141 				4:  uint8(255),
  64142 				5:  uint8(255),
  64143 				6:  uint8(255),
  64144 				7:  uint8(255),
  64145 				8:  uint8(255),
  64146 				9:  uint8(255),
  64147 				10: uint8(255),
  64148 			},
  64149 		},
  64150 		3: {
  64151 			0: {
  64152 				0:  uint8(255),
  64153 				1:  uint8(253),
  64154 				2:  uint8(255),
  64155 				3:  uint8(255),
  64156 				4:  uint8(255),
  64157 				5:  uint8(255),
  64158 				6:  uint8(255),
  64159 				7:  uint8(255),
  64160 				8:  uint8(255),
  64161 				9:  uint8(255),
  64162 				10: uint8(255),
  64163 			},
  64164 			1: {
  64165 				0:  uint8(247),
  64166 				1:  uint8(254),
  64167 				2:  uint8(255),
  64168 				3:  uint8(255),
  64169 				4:  uint8(255),
  64170 				5:  uint8(255),
  64171 				6:  uint8(255),
  64172 				7:  uint8(255),
  64173 				8:  uint8(255),
  64174 				9:  uint8(255),
  64175 				10: uint8(255),
  64176 			},
  64177 			2: {
  64178 				0:  uint8(255),
  64179 				1:  uint8(255),
  64180 				2:  uint8(255),
  64181 				3:  uint8(255),
  64182 				4:  uint8(255),
  64183 				5:  uint8(255),
  64184 				6:  uint8(255),
  64185 				7:  uint8(255),
  64186 				8:  uint8(255),
  64187 				9:  uint8(255),
  64188 				10: uint8(255),
  64189 			},
  64190 		},
  64191 		4: {
  64192 			0: {
  64193 				0:  uint8(255),
  64194 				1:  uint8(253),
  64195 				2:  uint8(254),
  64196 				3:  uint8(255),
  64197 				4:  uint8(255),
  64198 				5:  uint8(255),
  64199 				6:  uint8(255),
  64200 				7:  uint8(255),
  64201 				8:  uint8(255),
  64202 				9:  uint8(255),
  64203 				10: uint8(255),
  64204 			},
  64205 			1: {
  64206 				0:  uint8(252),
  64207 				1:  uint8(255),
  64208 				2:  uint8(255),
  64209 				3:  uint8(255),
  64210 				4:  uint8(255),
  64211 				5:  uint8(255),
  64212 				6:  uint8(255),
  64213 				7:  uint8(255),
  64214 				8:  uint8(255),
  64215 				9:  uint8(255),
  64216 				10: uint8(255),
  64217 			},
  64218 			2: {
  64219 				0:  uint8(255),
  64220 				1:  uint8(255),
  64221 				2:  uint8(255),
  64222 				3:  uint8(255),
  64223 				4:  uint8(255),
  64224 				5:  uint8(255),
  64225 				6:  uint8(255),
  64226 				7:  uint8(255),
  64227 				8:  uint8(255),
  64228 				9:  uint8(255),
  64229 				10: uint8(255),
  64230 			},
  64231 		},
  64232 		5: {
  64233 			0: {
  64234 				0:  uint8(255),
  64235 				1:  uint8(254),
  64236 				2:  uint8(254),
  64237 				3:  uint8(255),
  64238 				4:  uint8(255),
  64239 				5:  uint8(255),
  64240 				6:  uint8(255),
  64241 				7:  uint8(255),
  64242 				8:  uint8(255),
  64243 				9:  uint8(255),
  64244 				10: uint8(255),
  64245 			},
  64246 			1: {
  64247 				0:  uint8(253),
  64248 				1:  uint8(255),
  64249 				2:  uint8(255),
  64250 				3:  uint8(255),
  64251 				4:  uint8(255),
  64252 				5:  uint8(255),
  64253 				6:  uint8(255),
  64254 				7:  uint8(255),
  64255 				8:  uint8(255),
  64256 				9:  uint8(255),
  64257 				10: uint8(255),
  64258 			},
  64259 			2: {
  64260 				0:  uint8(255),
  64261 				1:  uint8(255),
  64262 				2:  uint8(255),
  64263 				3:  uint8(255),
  64264 				4:  uint8(255),
  64265 				5:  uint8(255),
  64266 				6:  uint8(255),
  64267 				7:  uint8(255),
  64268 				8:  uint8(255),
  64269 				9:  uint8(255),
  64270 				10: uint8(255),
  64271 			},
  64272 		},
  64273 		6: {
  64274 			0: {
  64275 				0:  uint8(255),
  64276 				1:  uint8(254),
  64277 				2:  uint8(253),
  64278 				3:  uint8(255),
  64279 				4:  uint8(255),
  64280 				5:  uint8(255),
  64281 				6:  uint8(255),
  64282 				7:  uint8(255),
  64283 				8:  uint8(255),
  64284 				9:  uint8(255),
  64285 				10: uint8(255),
  64286 			},
  64287 			1: {
  64288 				0:  uint8(250),
  64289 				1:  uint8(255),
  64290 				2:  uint8(255),
  64291 				3:  uint8(255),
  64292 				4:  uint8(255),
  64293 				5:  uint8(255),
  64294 				6:  uint8(255),
  64295 				7:  uint8(255),
  64296 				8:  uint8(255),
  64297 				9:  uint8(255),
  64298 				10: uint8(255),
  64299 			},
  64300 			2: {
  64301 				0:  uint8(254),
  64302 				1:  uint8(255),
  64303 				2:  uint8(255),
  64304 				3:  uint8(255),
  64305 				4:  uint8(255),
  64306 				5:  uint8(255),
  64307 				6:  uint8(255),
  64308 				7:  uint8(255),
  64309 				8:  uint8(255),
  64310 				9:  uint8(255),
  64311 				10: uint8(255),
  64312 			},
  64313 		},
  64314 		7: {
  64315 			0: {
  64316 				0:  uint8(255),
  64317 				1:  uint8(255),
  64318 				2:  uint8(255),
  64319 				3:  uint8(255),
  64320 				4:  uint8(255),
  64321 				5:  uint8(255),
  64322 				6:  uint8(255),
  64323 				7:  uint8(255),
  64324 				8:  uint8(255),
  64325 				9:  uint8(255),
  64326 				10: uint8(255),
  64327 			},
  64328 			1: {
  64329 				0:  uint8(255),
  64330 				1:  uint8(255),
  64331 				2:  uint8(255),
  64332 				3:  uint8(255),
  64333 				4:  uint8(255),
  64334 				5:  uint8(255),
  64335 				6:  uint8(255),
  64336 				7:  uint8(255),
  64337 				8:  uint8(255),
  64338 				9:  uint8(255),
  64339 				10: uint8(255),
  64340 			},
  64341 			2: {
  64342 				0:  uint8(255),
  64343 				1:  uint8(255),
  64344 				2:  uint8(255),
  64345 				3:  uint8(255),
  64346 				4:  uint8(255),
  64347 				5:  uint8(255),
  64348 				6:  uint8(255),
  64349 				7:  uint8(255),
  64350 				8:  uint8(255),
  64351 				9:  uint8(255),
  64352 				10: uint8(255),
  64353 			},
  64354 		},
  64355 	},
  64356 	2: {
  64357 		0: {
  64358 			0: {
  64359 				0:  uint8(186),
  64360 				1:  uint8(251),
  64361 				2:  uint8(250),
  64362 				3:  uint8(255),
  64363 				4:  uint8(255),
  64364 				5:  uint8(255),
  64365 				6:  uint8(255),
  64366 				7:  uint8(255),
  64367 				8:  uint8(255),
  64368 				9:  uint8(255),
  64369 				10: uint8(255),
  64370 			},
  64371 			1: {
  64372 				0:  uint8(234),
  64373 				1:  uint8(251),
  64374 				2:  uint8(244),
  64375 				3:  uint8(254),
  64376 				4:  uint8(255),
  64377 				5:  uint8(255),
  64378 				6:  uint8(255),
  64379 				7:  uint8(255),
  64380 				8:  uint8(255),
  64381 				9:  uint8(255),
  64382 				10: uint8(255),
  64383 			},
  64384 			2: {
  64385 				0:  uint8(251),
  64386 				1:  uint8(251),
  64387 				2:  uint8(243),
  64388 				3:  uint8(253),
  64389 				4:  uint8(254),
  64390 				5:  uint8(255),
  64391 				6:  uint8(254),
  64392 				7:  uint8(255),
  64393 				8:  uint8(255),
  64394 				9:  uint8(255),
  64395 				10: uint8(255),
  64396 			},
  64397 		},
  64398 		1: {
  64399 			0: {
  64400 				0:  uint8(255),
  64401 				1:  uint8(253),
  64402 				2:  uint8(254),
  64403 				3:  uint8(255),
  64404 				4:  uint8(255),
  64405 				5:  uint8(255),
  64406 				6:  uint8(255),
  64407 				7:  uint8(255),
  64408 				8:  uint8(255),
  64409 				9:  uint8(255),
  64410 				10: uint8(255),
  64411 			},
  64412 			1: {
  64413 				0:  uint8(236),
  64414 				1:  uint8(253),
  64415 				2:  uint8(254),
  64416 				3:  uint8(255),
  64417 				4:  uint8(255),
  64418 				5:  uint8(255),
  64419 				6:  uint8(255),
  64420 				7:  uint8(255),
  64421 				8:  uint8(255),
  64422 				9:  uint8(255),
  64423 				10: uint8(255),
  64424 			},
  64425 			2: {
  64426 				0:  uint8(251),
  64427 				1:  uint8(253),
  64428 				2:  uint8(253),
  64429 				3:  uint8(254),
  64430 				4:  uint8(254),
  64431 				5:  uint8(255),
  64432 				6:  uint8(255),
  64433 				7:  uint8(255),
  64434 				8:  uint8(255),
  64435 				9:  uint8(255),
  64436 				10: uint8(255),
  64437 			},
  64438 		},
  64439 		2: {
  64440 			0: {
  64441 				0:  uint8(255),
  64442 				1:  uint8(254),
  64443 				2:  uint8(254),
  64444 				3:  uint8(255),
  64445 				4:  uint8(255),
  64446 				5:  uint8(255),
  64447 				6:  uint8(255),
  64448 				7:  uint8(255),
  64449 				8:  uint8(255),
  64450 				9:  uint8(255),
  64451 				10: uint8(255),
  64452 			},
  64453 			1: {
  64454 				0:  uint8(254),
  64455 				1:  uint8(254),
  64456 				2:  uint8(254),
  64457 				3:  uint8(255),
  64458 				4:  uint8(255),
  64459 				5:  uint8(255),
  64460 				6:  uint8(255),
  64461 				7:  uint8(255),
  64462 				8:  uint8(255),
  64463 				9:  uint8(255),
  64464 				10: uint8(255),
  64465 			},
  64466 			2: {
  64467 				0:  uint8(255),
  64468 				1:  uint8(255),
  64469 				2:  uint8(255),
  64470 				3:  uint8(255),
  64471 				4:  uint8(255),
  64472 				5:  uint8(255),
  64473 				6:  uint8(255),
  64474 				7:  uint8(255),
  64475 				8:  uint8(255),
  64476 				9:  uint8(255),
  64477 				10: uint8(255),
  64478 			},
  64479 		},
  64480 		3: {
  64481 			0: {
  64482 				0:  uint8(255),
  64483 				1:  uint8(254),
  64484 				2:  uint8(255),
  64485 				3:  uint8(255),
  64486 				4:  uint8(255),
  64487 				5:  uint8(255),
  64488 				6:  uint8(255),
  64489 				7:  uint8(255),
  64490 				8:  uint8(255),
  64491 				9:  uint8(255),
  64492 				10: uint8(255),
  64493 			},
  64494 			1: {
  64495 				0:  uint8(254),
  64496 				1:  uint8(254),
  64497 				2:  uint8(255),
  64498 				3:  uint8(255),
  64499 				4:  uint8(255),
  64500 				5:  uint8(255),
  64501 				6:  uint8(255),
  64502 				7:  uint8(255),
  64503 				8:  uint8(255),
  64504 				9:  uint8(255),
  64505 				10: uint8(255),
  64506 			},
  64507 			2: {
  64508 				0:  uint8(254),
  64509 				1:  uint8(255),
  64510 				2:  uint8(255),
  64511 				3:  uint8(255),
  64512 				4:  uint8(255),
  64513 				5:  uint8(255),
  64514 				6:  uint8(255),
  64515 				7:  uint8(255),
  64516 				8:  uint8(255),
  64517 				9:  uint8(255),
  64518 				10: uint8(255),
  64519 			},
  64520 		},
  64521 		4: {
  64522 			0: {
  64523 				0:  uint8(255),
  64524 				1:  uint8(255),
  64525 				2:  uint8(255),
  64526 				3:  uint8(255),
  64527 				4:  uint8(255),
  64528 				5:  uint8(255),
  64529 				6:  uint8(255),
  64530 				7:  uint8(255),
  64531 				8:  uint8(255),
  64532 				9:  uint8(255),
  64533 				10: uint8(255),
  64534 			},
  64535 			1: {
  64536 				0:  uint8(254),
  64537 				1:  uint8(255),
  64538 				2:  uint8(255),
  64539 				3:  uint8(255),
  64540 				4:  uint8(255),
  64541 				5:  uint8(255),
  64542 				6:  uint8(255),
  64543 				7:  uint8(255),
  64544 				8:  uint8(255),
  64545 				9:  uint8(255),
  64546 				10: uint8(255),
  64547 			},
  64548 			2: {
  64549 				0:  uint8(255),
  64550 				1:  uint8(255),
  64551 				2:  uint8(255),
  64552 				3:  uint8(255),
  64553 				4:  uint8(255),
  64554 				5:  uint8(255),
  64555 				6:  uint8(255),
  64556 				7:  uint8(255),
  64557 				8:  uint8(255),
  64558 				9:  uint8(255),
  64559 				10: uint8(255),
  64560 			},
  64561 		},
  64562 		5: {
  64563 			0: {
  64564 				0:  uint8(255),
  64565 				1:  uint8(255),
  64566 				2:  uint8(255),
  64567 				3:  uint8(255),
  64568 				4:  uint8(255),
  64569 				5:  uint8(255),
  64570 				6:  uint8(255),
  64571 				7:  uint8(255),
  64572 				8:  uint8(255),
  64573 				9:  uint8(255),
  64574 				10: uint8(255),
  64575 			},
  64576 			1: {
  64577 				0:  uint8(255),
  64578 				1:  uint8(255),
  64579 				2:  uint8(255),
  64580 				3:  uint8(255),
  64581 				4:  uint8(255),
  64582 				5:  uint8(255),
  64583 				6:  uint8(255),
  64584 				7:  uint8(255),
  64585 				8:  uint8(255),
  64586 				9:  uint8(255),
  64587 				10: uint8(255),
  64588 			},
  64589 			2: {
  64590 				0:  uint8(255),
  64591 				1:  uint8(255),
  64592 				2:  uint8(255),
  64593 				3:  uint8(255),
  64594 				4:  uint8(255),
  64595 				5:  uint8(255),
  64596 				6:  uint8(255),
  64597 				7:  uint8(255),
  64598 				8:  uint8(255),
  64599 				9:  uint8(255),
  64600 				10: uint8(255),
  64601 			},
  64602 		},
  64603 		6: {
  64604 			0: {
  64605 				0:  uint8(255),
  64606 				1:  uint8(255),
  64607 				2:  uint8(255),
  64608 				3:  uint8(255),
  64609 				4:  uint8(255),
  64610 				5:  uint8(255),
  64611 				6:  uint8(255),
  64612 				7:  uint8(255),
  64613 				8:  uint8(255),
  64614 				9:  uint8(255),
  64615 				10: uint8(255),
  64616 			},
  64617 			1: {
  64618 				0:  uint8(255),
  64619 				1:  uint8(255),
  64620 				2:  uint8(255),
  64621 				3:  uint8(255),
  64622 				4:  uint8(255),
  64623 				5:  uint8(255),
  64624 				6:  uint8(255),
  64625 				7:  uint8(255),
  64626 				8:  uint8(255),
  64627 				9:  uint8(255),
  64628 				10: uint8(255),
  64629 			},
  64630 			2: {
  64631 				0:  uint8(255),
  64632 				1:  uint8(255),
  64633 				2:  uint8(255),
  64634 				3:  uint8(255),
  64635 				4:  uint8(255),
  64636 				5:  uint8(255),
  64637 				6:  uint8(255),
  64638 				7:  uint8(255),
  64639 				8:  uint8(255),
  64640 				9:  uint8(255),
  64641 				10: uint8(255),
  64642 			},
  64643 		},
  64644 		7: {
  64645 			0: {
  64646 				0:  uint8(255),
  64647 				1:  uint8(255),
  64648 				2:  uint8(255),
  64649 				3:  uint8(255),
  64650 				4:  uint8(255),
  64651 				5:  uint8(255),
  64652 				6:  uint8(255),
  64653 				7:  uint8(255),
  64654 				8:  uint8(255),
  64655 				9:  uint8(255),
  64656 				10: uint8(255),
  64657 			},
  64658 			1: {
  64659 				0:  uint8(255),
  64660 				1:  uint8(255),
  64661 				2:  uint8(255),
  64662 				3:  uint8(255),
  64663 				4:  uint8(255),
  64664 				5:  uint8(255),
  64665 				6:  uint8(255),
  64666 				7:  uint8(255),
  64667 				8:  uint8(255),
  64668 				9:  uint8(255),
  64669 				10: uint8(255),
  64670 			},
  64671 			2: {
  64672 				0:  uint8(255),
  64673 				1:  uint8(255),
  64674 				2:  uint8(255),
  64675 				3:  uint8(255),
  64676 				4:  uint8(255),
  64677 				5:  uint8(255),
  64678 				6:  uint8(255),
  64679 				7:  uint8(255),
  64680 				8:  uint8(255),
  64681 				9:  uint8(255),
  64682 				10: uint8(255),
  64683 			},
  64684 		},
  64685 	},
  64686 	3: {
  64687 		0: {
  64688 			0: {
  64689 				0:  uint8(248),
  64690 				1:  uint8(255),
  64691 				2:  uint8(255),
  64692 				3:  uint8(255),
  64693 				4:  uint8(255),
  64694 				5:  uint8(255),
  64695 				6:  uint8(255),
  64696 				7:  uint8(255),
  64697 				8:  uint8(255),
  64698 				9:  uint8(255),
  64699 				10: uint8(255),
  64700 			},
  64701 			1: {
  64702 				0:  uint8(250),
  64703 				1:  uint8(254),
  64704 				2:  uint8(252),
  64705 				3:  uint8(254),
  64706 				4:  uint8(255),
  64707 				5:  uint8(255),
  64708 				6:  uint8(255),
  64709 				7:  uint8(255),
  64710 				8:  uint8(255),
  64711 				9:  uint8(255),
  64712 				10: uint8(255),
  64713 			},
  64714 			2: {
  64715 				0:  uint8(248),
  64716 				1:  uint8(254),
  64717 				2:  uint8(249),
  64718 				3:  uint8(253),
  64719 				4:  uint8(255),
  64720 				5:  uint8(255),
  64721 				6:  uint8(255),
  64722 				7:  uint8(255),
  64723 				8:  uint8(255),
  64724 				9:  uint8(255),
  64725 				10: uint8(255),
  64726 			},
  64727 		},
  64728 		1: {
  64729 			0: {
  64730 				0:  uint8(255),
  64731 				1:  uint8(253),
  64732 				2:  uint8(253),
  64733 				3:  uint8(255),
  64734 				4:  uint8(255),
  64735 				5:  uint8(255),
  64736 				6:  uint8(255),
  64737 				7:  uint8(255),
  64738 				8:  uint8(255),
  64739 				9:  uint8(255),
  64740 				10: uint8(255),
  64741 			},
  64742 			1: {
  64743 				0:  uint8(246),
  64744 				1:  uint8(253),
  64745 				2:  uint8(253),
  64746 				3:  uint8(255),
  64747 				4:  uint8(255),
  64748 				5:  uint8(255),
  64749 				6:  uint8(255),
  64750 				7:  uint8(255),
  64751 				8:  uint8(255),
  64752 				9:  uint8(255),
  64753 				10: uint8(255),
  64754 			},
  64755 			2: {
  64756 				0:  uint8(252),
  64757 				1:  uint8(254),
  64758 				2:  uint8(251),
  64759 				3:  uint8(254),
  64760 				4:  uint8(254),
  64761 				5:  uint8(255),
  64762 				6:  uint8(255),
  64763 				7:  uint8(255),
  64764 				8:  uint8(255),
  64765 				9:  uint8(255),
  64766 				10: uint8(255),
  64767 			},
  64768 		},
  64769 		2: {
  64770 			0: {
  64771 				0:  uint8(255),
  64772 				1:  uint8(254),
  64773 				2:  uint8(252),
  64774 				3:  uint8(255),
  64775 				4:  uint8(255),
  64776 				5:  uint8(255),
  64777 				6:  uint8(255),
  64778 				7:  uint8(255),
  64779 				8:  uint8(255),
  64780 				9:  uint8(255),
  64781 				10: uint8(255),
  64782 			},
  64783 			1: {
  64784 				0:  uint8(248),
  64785 				1:  uint8(254),
  64786 				2:  uint8(253),
  64787 				3:  uint8(255),
  64788 				4:  uint8(255),
  64789 				5:  uint8(255),
  64790 				6:  uint8(255),
  64791 				7:  uint8(255),
  64792 				8:  uint8(255),
  64793 				9:  uint8(255),
  64794 				10: uint8(255),
  64795 			},
  64796 			2: {
  64797 				0:  uint8(253),
  64798 				1:  uint8(255),
  64799 				2:  uint8(254),
  64800 				3:  uint8(254),
  64801 				4:  uint8(255),
  64802 				5:  uint8(255),
  64803 				6:  uint8(255),
  64804 				7:  uint8(255),
  64805 				8:  uint8(255),
  64806 				9:  uint8(255),
  64807 				10: uint8(255),
  64808 			},
  64809 		},
  64810 		3: {
  64811 			0: {
  64812 				0:  uint8(255),
  64813 				1:  uint8(251),
  64814 				2:  uint8(254),
  64815 				3:  uint8(255),
  64816 				4:  uint8(255),
  64817 				5:  uint8(255),
  64818 				6:  uint8(255),
  64819 				7:  uint8(255),
  64820 				8:  uint8(255),
  64821 				9:  uint8(255),
  64822 				10: uint8(255),
  64823 			},
  64824 			1: {
  64825 				0:  uint8(245),
  64826 				1:  uint8(251),
  64827 				2:  uint8(254),
  64828 				3:  uint8(255),
  64829 				4:  uint8(255),
  64830 				5:  uint8(255),
  64831 				6:  uint8(255),
  64832 				7:  uint8(255),
  64833 				8:  uint8(255),
  64834 				9:  uint8(255),
  64835 				10: uint8(255),
  64836 			},
  64837 			2: {
  64838 				0:  uint8(253),
  64839 				1:  uint8(253),
  64840 				2:  uint8(254),
  64841 				3:  uint8(255),
  64842 				4:  uint8(255),
  64843 				5:  uint8(255),
  64844 				6:  uint8(255),
  64845 				7:  uint8(255),
  64846 				8:  uint8(255),
  64847 				9:  uint8(255),
  64848 				10: uint8(255),
  64849 			},
  64850 		},
  64851 		4: {
  64852 			0: {
  64853 				0:  uint8(255),
  64854 				1:  uint8(251),
  64855 				2:  uint8(253),
  64856 				3:  uint8(255),
  64857 				4:  uint8(255),
  64858 				5:  uint8(255),
  64859 				6:  uint8(255),
  64860 				7:  uint8(255),
  64861 				8:  uint8(255),
  64862 				9:  uint8(255),
  64863 				10: uint8(255),
  64864 			},
  64865 			1: {
  64866 				0:  uint8(252),
  64867 				1:  uint8(253),
  64868 				2:  uint8(254),
  64869 				3:  uint8(255),
  64870 				4:  uint8(255),
  64871 				5:  uint8(255),
  64872 				6:  uint8(255),
  64873 				7:  uint8(255),
  64874 				8:  uint8(255),
  64875 				9:  uint8(255),
  64876 				10: uint8(255),
  64877 			},
  64878 			2: {
  64879 				0:  uint8(255),
  64880 				1:  uint8(254),
  64881 				2:  uint8(255),
  64882 				3:  uint8(255),
  64883 				4:  uint8(255),
  64884 				5:  uint8(255),
  64885 				6:  uint8(255),
  64886 				7:  uint8(255),
  64887 				8:  uint8(255),
  64888 				9:  uint8(255),
  64889 				10: uint8(255),
  64890 			},
  64891 		},
  64892 		5: {
  64893 			0: {
  64894 				0:  uint8(255),
  64895 				1:  uint8(252),
  64896 				2:  uint8(255),
  64897 				3:  uint8(255),
  64898 				4:  uint8(255),
  64899 				5:  uint8(255),
  64900 				6:  uint8(255),
  64901 				7:  uint8(255),
  64902 				8:  uint8(255),
  64903 				9:  uint8(255),
  64904 				10: uint8(255),
  64905 			},
  64906 			1: {
  64907 				0:  uint8(249),
  64908 				1:  uint8(255),
  64909 				2:  uint8(254),
  64910 				3:  uint8(255),
  64911 				4:  uint8(255),
  64912 				5:  uint8(255),
  64913 				6:  uint8(255),
  64914 				7:  uint8(255),
  64915 				8:  uint8(255),
  64916 				9:  uint8(255),
  64917 				10: uint8(255),
  64918 			},
  64919 			2: {
  64920 				0:  uint8(255),
  64921 				1:  uint8(255),
  64922 				2:  uint8(254),
  64923 				3:  uint8(255),
  64924 				4:  uint8(255),
  64925 				5:  uint8(255),
  64926 				6:  uint8(255),
  64927 				7:  uint8(255),
  64928 				8:  uint8(255),
  64929 				9:  uint8(255),
  64930 				10: uint8(255),
  64931 			},
  64932 		},
  64933 		6: {
  64934 			0: {
  64935 				0:  uint8(255),
  64936 				1:  uint8(255),
  64937 				2:  uint8(253),
  64938 				3:  uint8(255),
  64939 				4:  uint8(255),
  64940 				5:  uint8(255),
  64941 				6:  uint8(255),
  64942 				7:  uint8(255),
  64943 				8:  uint8(255),
  64944 				9:  uint8(255),
  64945 				10: uint8(255),
  64946 			},
  64947 			1: {
  64948 				0:  uint8(250),
  64949 				1:  uint8(255),
  64950 				2:  uint8(255),
  64951 				3:  uint8(255),
  64952 				4:  uint8(255),
  64953 				5:  uint8(255),
  64954 				6:  uint8(255),
  64955 				7:  uint8(255),
  64956 				8:  uint8(255),
  64957 				9:  uint8(255),
  64958 				10: uint8(255),
  64959 			},
  64960 			2: {
  64961 				0:  uint8(255),
  64962 				1:  uint8(255),
  64963 				2:  uint8(255),
  64964 				3:  uint8(255),
  64965 				4:  uint8(255),
  64966 				5:  uint8(255),
  64967 				6:  uint8(255),
  64968 				7:  uint8(255),
  64969 				8:  uint8(255),
  64970 				9:  uint8(255),
  64971 				10: uint8(255),
  64972 			},
  64973 		},
  64974 		7: {
  64975 			0: {
  64976 				0:  uint8(255),
  64977 				1:  uint8(255),
  64978 				2:  uint8(255),
  64979 				3:  uint8(255),
  64980 				4:  uint8(255),
  64981 				5:  uint8(255),
  64982 				6:  uint8(255),
  64983 				7:  uint8(255),
  64984 				8:  uint8(255),
  64985 				9:  uint8(255),
  64986 				10: uint8(255),
  64987 			},
  64988 			1: {
  64989 				0:  uint8(254),
  64990 				1:  uint8(255),
  64991 				2:  uint8(255),
  64992 				3:  uint8(255),
  64993 				4:  uint8(255),
  64994 				5:  uint8(255),
  64995 				6:  uint8(255),
  64996 				7:  uint8(255),
  64997 				8:  uint8(255),
  64998 				9:  uint8(255),
  64999 				10: uint8(255),
  65000 			},
  65001 			2: {
  65002 				0:  uint8(255),
  65003 				1:  uint8(255),
  65004 				2:  uint8(255),
  65005 				3:  uint8(255),
  65006 				4:  uint8(255),
  65007 				5:  uint8(255),
  65008 				6:  uint8(255),
  65009 				7:  uint8(255),
  65010 				8:  uint8(255),
  65011 				9:  uint8(255),
  65012 				10: uint8(255),
  65013 			},
  65014 		},
  65015 	},
  65016 }
  65017 
  65018 //------------------------------------------------------------------------------
  65019 // Initialization
  65020 
  65021 // C documentation
  65022 //
  65023 //	// Speed-critical function pointers. We have to initialize them to the default
  65024 //	// implementations within VP8EncDspInit().
  65025 var VP8CollectHistogram VP8CHisto
  65026 
  65027 var VP8Copy16x8 VP8BlockCopy
  65028 
  65029 var VP8Copy4x4 VP8BlockCopy
  65030 
  65031 var VP8DitherCombine8x8 uintptr
  65032 
  65033 //------------------------------------------------------------------------------
  65034 // Compute susceptibility based on DCT-coeff histograms:
  65035 // the higher, the "easier" the macroblock is to compress.
  65036 
  65037 var VP8DspScan = [24]int32{
  65038 	1:  libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65039 	2:  libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65040 	3:  libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65041 	4:  libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65042 	5:  libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65043 	6:  libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65044 	7:  libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65045 	8:  libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65046 	9:  libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65047 	10: libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65048 	11: libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS),
  65049 	12: libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65050 	13: libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65051 	14: libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65052 	15: libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS),
  65053 	17: libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65054 	18: libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65055 	19: libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65056 	20: libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65057 	21: libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS),
  65058 	22: libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65059 	23: libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS),
  65060 }
  65061 
  65062 //------------------------------------------------------------------------------
  65063 // Tables for level coding
  65064 
  65065 var VP8EncBands = [17]uint8_t{
  65066 	1:  uint8(1),
  65067 	2:  uint8(2),
  65068 	3:  uint8(3),
  65069 	4:  uint8(6),
  65070 	5:  uint8(4),
  65071 	6:  uint8(5),
  65072 	7:  uint8(6),
  65073 	8:  uint8(6),
  65074 	9:  uint8(6),
  65075 	10: uint8(6),
  65076 	11: uint8(6),
  65077 	12: uint8(6),
  65078 	13: uint8(6),
  65079 	14: uint8(6),
  65080 	15: uint8(7),
  65081 }
  65082 
  65083 var VP8EncPredChroma8 VP8IntraPreds
  65084 
  65085 var VP8EncPredLuma16 VP8IntraPreds
  65086 
  65087 var VP8EncPredLuma4 VP8Intra4Preds
  65088 
  65089 var VP8EncQuantize2Blocks VP8Quantize2Blocks
  65090 
  65091 var VP8EncQuantizeBlock VP8QuantizeBlock
  65092 
  65093 var VP8EncQuantizeBlockWHT VP8QuantizeBlockWHT
  65094 
  65095 //------------------------------------------------------------------------------
  65096 
  65097 // Copyright 2011 Google Inc. All Rights Reserved.
  65098 //
  65099 // Use of this source code is governed by a BSD-style license
  65100 // that can be found in the COPYING file in the root of the source
  65101 // tree. An additional intellectual property rights grant can be found
  65102 // in the file PATENTS. All contributing project authors may
  65103 // be found in the AUTHORS file in the root of the source tree.
  65104 // -----------------------------------------------------------------------------
  65105 //
  65106 //   WebP encoder: internal header.
  65107 //
  65108 // Author: Skal (pascal.massimino@gmail.com)
  65109 
  65110 //------------------------------------------------------------------------------
  65111 // Boolean-cost cost table
  65112 
  65113 var VP8EntropyCost = [256]uint16_t{
  65114 	0:   uint16(1792),
  65115 	1:   uint16(1792),
  65116 	2:   uint16(1792),
  65117 	3:   uint16(1536),
  65118 	4:   uint16(1536),
  65119 	5:   uint16(1408),
  65120 	6:   uint16(1366),
  65121 	7:   uint16(1280),
  65122 	8:   uint16(1280),
  65123 	9:   uint16(1216),
  65124 	10:  uint16(1178),
  65125 	11:  uint16(1152),
  65126 	12:  uint16(1110),
  65127 	13:  uint16(1076),
  65128 	14:  uint16(1061),
  65129 	15:  uint16(1024),
  65130 	16:  uint16(1024),
  65131 	17:  uint16(992),
  65132 	18:  uint16(968),
  65133 	19:  uint16(951),
  65134 	20:  uint16(939),
  65135 	21:  uint16(911),
  65136 	22:  uint16(896),
  65137 	23:  uint16(878),
  65138 	24:  uint16(871),
  65139 	25:  uint16(854),
  65140 	26:  uint16(838),
  65141 	27:  uint16(820),
  65142 	28:  uint16(811),
  65143 	29:  uint16(794),
  65144 	30:  uint16(786),
  65145 	31:  uint16(768),
  65146 	32:  uint16(768),
  65147 	33:  uint16(752),
  65148 	34:  uint16(740),
  65149 	35:  uint16(732),
  65150 	36:  uint16(720),
  65151 	37:  uint16(709),
  65152 	38:  uint16(704),
  65153 	39:  uint16(690),
  65154 	40:  uint16(683),
  65155 	41:  uint16(672),
  65156 	42:  uint16(666),
  65157 	43:  uint16(655),
  65158 	44:  uint16(647),
  65159 	45:  uint16(640),
  65160 	46:  uint16(631),
  65161 	47:  uint16(622),
  65162 	48:  uint16(615),
  65163 	49:  uint16(607),
  65164 	50:  uint16(598),
  65165 	51:  uint16(592),
  65166 	52:  uint16(586),
  65167 	53:  uint16(576),
  65168 	54:  uint16(572),
  65169 	55:  uint16(564),
  65170 	56:  uint16(559),
  65171 	57:  uint16(555),
  65172 	58:  uint16(547),
  65173 	59:  uint16(541),
  65174 	60:  uint16(534),
  65175 	61:  uint16(528),
  65176 	62:  uint16(522),
  65177 	63:  uint16(512),
  65178 	64:  uint16(512),
  65179 	65:  uint16(504),
  65180 	66:  uint16(500),
  65181 	67:  uint16(494),
  65182 	68:  uint16(488),
  65183 	69:  uint16(483),
  65184 	70:  uint16(477),
  65185 	71:  uint16(473),
  65186 	72:  uint16(467),
  65187 	73:  uint16(461),
  65188 	74:  uint16(458),
  65189 	75:  uint16(452),
  65190 	76:  uint16(448),
  65191 	77:  uint16(443),
  65192 	78:  uint16(438),
  65193 	79:  uint16(434),
  65194 	80:  uint16(427),
  65195 	81:  uint16(424),
  65196 	82:  uint16(419),
  65197 	83:  uint16(415),
  65198 	84:  uint16(410),
  65199 	85:  uint16(406),
  65200 	86:  uint16(403),
  65201 	87:  uint16(399),
  65202 	88:  uint16(394),
  65203 	89:  uint16(390),
  65204 	90:  uint16(384),
  65205 	91:  uint16(384),
  65206 	92:  uint16(377),
  65207 	93:  uint16(374),
  65208 	94:  uint16(370),
  65209 	95:  uint16(366),
  65210 	96:  uint16(362),
  65211 	97:  uint16(359),
  65212 	98:  uint16(355),
  65213 	99:  uint16(351),
  65214 	100: uint16(347),
  65215 	101: uint16(342),
  65216 	102: uint16(342),
  65217 	103: uint16(336),
  65218 	104: uint16(333),
  65219 	105: uint16(330),
  65220 	106: uint16(326),
  65221 	107: uint16(323),
  65222 	108: uint16(320),
  65223 	109: uint16(316),
  65224 	110: uint16(312),
  65225 	111: uint16(308),
  65226 	112: uint16(305),
  65227 	113: uint16(302),
  65228 	114: uint16(299),
  65229 	115: uint16(296),
  65230 	116: uint16(293),
  65231 	117: uint16(288),
  65232 	118: uint16(287),
  65233 	119: uint16(283),
  65234 	120: uint16(280),
  65235 	121: uint16(277),
  65236 	122: uint16(274),
  65237 	123: uint16(272),
  65238 	124: uint16(268),
  65239 	125: uint16(266),
  65240 	126: uint16(262),
  65241 	127: uint16(256),
  65242 	128: uint16(256),
  65243 	129: uint16(256),
  65244 	130: uint16(251),
  65245 	131: uint16(248),
  65246 	132: uint16(245),
  65247 	133: uint16(242),
  65248 	134: uint16(240),
  65249 	135: uint16(237),
  65250 	136: uint16(234),
  65251 	137: uint16(232),
  65252 	138: uint16(228),
  65253 	139: uint16(226),
  65254 	140: uint16(223),
  65255 	141: uint16(221),
  65256 	142: uint16(218),
  65257 	143: uint16(216),
  65258 	144: uint16(214),
  65259 	145: uint16(211),
  65260 	146: uint16(208),
  65261 	147: uint16(205),
  65262 	148: uint16(203),
  65263 	149: uint16(201),
  65264 	150: uint16(198),
  65265 	151: uint16(196),
  65266 	152: uint16(192),
  65267 	153: uint16(191),
  65268 	154: uint16(188),
  65269 	155: uint16(187),
  65270 	156: uint16(183),
  65271 	157: uint16(181),
  65272 	158: uint16(179),
  65273 	159: uint16(176),
  65274 	160: uint16(175),
  65275 	161: uint16(171),
  65276 	162: uint16(171),
  65277 	163: uint16(168),
  65278 	164: uint16(165),
  65279 	165: uint16(163),
  65280 	166: uint16(160),
  65281 	167: uint16(159),
  65282 	168: uint16(156),
  65283 	169: uint16(154),
  65284 	170: uint16(152),
  65285 	171: uint16(150),
  65286 	172: uint16(148),
  65287 	173: uint16(146),
  65288 	174: uint16(144),
  65289 	175: uint16(142),
  65290 	176: uint16(139),
  65291 	177: uint16(138),
  65292 	178: uint16(135),
  65293 	179: uint16(133),
  65294 	180: uint16(131),
  65295 	181: uint16(128),
  65296 	182: uint16(128),
  65297 	183: uint16(125),
  65298 	184: uint16(123),
  65299 	185: uint16(121),
  65300 	186: uint16(119),
  65301 	187: uint16(117),
  65302 	188: uint16(115),
  65303 	189: uint16(113),
  65304 	190: uint16(111),
  65305 	191: uint16(110),
  65306 	192: uint16(107),
  65307 	193: uint16(105),
  65308 	194: uint16(103),
  65309 	195: uint16(102),
  65310 	196: uint16(100),
  65311 	197: uint16(98),
  65312 	198: uint16(96),
  65313 	199: uint16(94),
  65314 	200: uint16(92),
  65315 	201: uint16(91),
  65316 	202: uint16(89),
  65317 	203: uint16(86),
  65318 	204: uint16(86),
  65319 	205: uint16(83),
  65320 	206: uint16(82),
  65321 	207: uint16(80),
  65322 	208: uint16(77),
  65323 	209: uint16(76),
  65324 	210: uint16(74),
  65325 	211: uint16(73),
  65326 	212: uint16(71),
  65327 	213: uint16(69),
  65328 	214: uint16(67),
  65329 	215: uint16(66),
  65330 	216: uint16(64),
  65331 	217: uint16(63),
  65332 	218: uint16(61),
  65333 	219: uint16(59),
  65334 	220: uint16(57),
  65335 	221: uint16(55),
  65336 	222: uint16(54),
  65337 	223: uint16(52),
  65338 	224: uint16(51),
  65339 	225: uint16(49),
  65340 	226: uint16(47),
  65341 	227: uint16(46),
  65342 	228: uint16(44),
  65343 	229: uint16(43),
  65344 	230: uint16(41),
  65345 	231: uint16(40),
  65346 	232: uint16(38),
  65347 	233: uint16(36),
  65348 	234: uint16(35),
  65349 	235: uint16(33),
  65350 	236: uint16(32),
  65351 	237: uint16(30),
  65352 	238: uint16(29),
  65353 	239: uint16(27),
  65354 	240: uint16(25),
  65355 	241: uint16(24),
  65356 	242: uint16(22),
  65357 	243: uint16(21),
  65358 	244: uint16(19),
  65359 	245: uint16(18),
  65360 	246: uint16(16),
  65361 	247: uint16(15),
  65362 	248: uint16(13),
  65363 	249: uint16(12),
  65364 	250: uint16(10),
  65365 	251: uint16(9),
  65366 	252: uint16(7),
  65367 	253: uint16(6),
  65368 	254: uint16(4),
  65369 	255: uint16(3),
  65370 }
  65371 
  65372 var VP8FTransform VP8Fdct
  65373 
  65374 var VP8FTransform2 VP8Fdct
  65375 
  65376 var VP8FTransformWHT VP8WHT
  65377 
  65378 // C documentation
  65379 //
  65380 //	// note: these values include the fixed VP8BitCost(1, 145) mode selection cost.
  65381 var VP8FixedCostsI16 = [4]uint16_t{
  65382 	0: uint16(663),
  65383 	1: uint16(919),
  65384 	2: uint16(872),
  65385 	3: uint16(919),
  65386 }
  65387 
  65388 var VP8FixedCostsI4 = [10][10][10]uint16_t{
  65389 	0: {
  65390 		0: {
  65391 			0: uint16(40),
  65392 			1: uint16(1151),
  65393 			2: uint16(1723),
  65394 			3: uint16(1874),
  65395 			4: uint16(2103),
  65396 			5: uint16(2019),
  65397 			6: uint16(1628),
  65398 			7: uint16(1777),
  65399 			8: uint16(2226),
  65400 			9: uint16(2137),
  65401 		},
  65402 		1: {
  65403 			0: uint16(192),
  65404 			1: uint16(469),
  65405 			2: uint16(1296),
  65406 			3: uint16(1308),
  65407 			4: uint16(1849),
  65408 			5: uint16(1794),
  65409 			6: uint16(1781),
  65410 			7: uint16(1703),
  65411 			8: uint16(1713),
  65412 			9: uint16(1522),
  65413 		},
  65414 		2: {
  65415 			0: uint16(142),
  65416 			1: uint16(910),
  65417 			2: uint16(762),
  65418 			3: uint16(1684),
  65419 			4: uint16(1849),
  65420 			5: uint16(1576),
  65421 			6: uint16(1460),
  65422 			7: uint16(1305),
  65423 			8: uint16(1801),
  65424 			9: uint16(1657),
  65425 		},
  65426 		3: {
  65427 			0: uint16(559),
  65428 			1: uint16(641),
  65429 			2: uint16(1370),
  65430 			3: uint16(421),
  65431 			4: uint16(1182),
  65432 			5: uint16(1569),
  65433 			6: uint16(1612),
  65434 			7: uint16(1725),
  65435 			8: uint16(863),
  65436 			9: uint16(1007),
  65437 		},
  65438 		4: {
  65439 			0: uint16(299),
  65440 			1: uint16(1059),
  65441 			2: uint16(1256),
  65442 			3: uint16(1108),
  65443 			4: uint16(636),
  65444 			5: uint16(1068),
  65445 			6: uint16(1581),
  65446 			7: uint16(1883),
  65447 			8: uint16(869),
  65448 			9: uint16(1142),
  65449 		},
  65450 		5: {
  65451 			0: uint16(277),
  65452 			1: uint16(1111),
  65453 			2: uint16(707),
  65454 			3: uint16(1362),
  65455 			4: uint16(1089),
  65456 			5: uint16(672),
  65457 			6: uint16(1603),
  65458 			7: uint16(1541),
  65459 			8: uint16(1545),
  65460 			9: uint16(1291),
  65461 		},
  65462 		6: {
  65463 			0: uint16(214),
  65464 			1: uint16(781),
  65465 			2: uint16(1609),
  65466 			3: uint16(1303),
  65467 			4: uint16(1632),
  65468 			5: uint16(2229),
  65469 			6: uint16(726),
  65470 			7: uint16(1560),
  65471 			8: uint16(1713),
  65472 			9: uint16(918),
  65473 		},
  65474 		7: {
  65475 			0: uint16(152),
  65476 			1: uint16(1037),
  65477 			2: uint16(1046),
  65478 			3: uint16(1759),
  65479 			4: uint16(1983),
  65480 			5: uint16(2174),
  65481 			6: uint16(1358),
  65482 			7: uint16(742),
  65483 			8: uint16(1740),
  65484 			9: uint16(1390),
  65485 		},
  65486 		8: {
  65487 			0: uint16(512),
  65488 			1: uint16(1046),
  65489 			2: uint16(1420),
  65490 			3: uint16(753),
  65491 			4: uint16(752),
  65492 			5: uint16(1297),
  65493 			6: uint16(1486),
  65494 			7: uint16(1613),
  65495 			8: uint16(460),
  65496 			9: uint16(1207),
  65497 		},
  65498 		9: {
  65499 			0: uint16(424),
  65500 			1: uint16(827),
  65501 			2: uint16(1362),
  65502 			3: uint16(719),
  65503 			4: uint16(1462),
  65504 			5: uint16(1202),
  65505 			6: uint16(1199),
  65506 			7: uint16(1476),
  65507 			8: uint16(1199),
  65508 			9: uint16(538),
  65509 		},
  65510 	},
  65511 	1: {
  65512 		0: {
  65513 			0: uint16(240),
  65514 			1: uint16(402),
  65515 			2: uint16(1134),
  65516 			3: uint16(1491),
  65517 			4: uint16(1659),
  65518 			5: uint16(1505),
  65519 			6: uint16(1517),
  65520 			7: uint16(1555),
  65521 			8: uint16(1979),
  65522 			9: uint16(2099),
  65523 		},
  65524 		1: {
  65525 			0: uint16(467),
  65526 			1: uint16(242),
  65527 			2: uint16(960),
  65528 			3: uint16(1232),
  65529 			4: uint16(1714),
  65530 			5: uint16(1620),
  65531 			6: uint16(1834),
  65532 			7: uint16(1570),
  65533 			8: uint16(1676),
  65534 			9: uint16(1391),
  65535 		},
  65536 		2: {
  65537 			0: uint16(500),
  65538 			1: uint16(455),
  65539 			2: uint16(463),
  65540 			3: uint16(1507),
  65541 			4: uint16(1699),
  65542 			5: uint16(1282),
  65543 			6: uint16(1564),
  65544 			7: uint16(982),
  65545 			8: uint16(2114),
  65546 			9: uint16(2114),
  65547 		},
  65548 		3: {
  65549 			0: uint16(672),
  65550 			1: uint16(643),
  65551 			2: uint16(1372),
  65552 			3: uint16(331),
  65553 			4: uint16(1589),
  65554 			5: uint16(1667),
  65555 			6: uint16(1453),
  65556 			7: uint16(1938),
  65557 			8: uint16(996),
  65558 			9: uint16(876),
  65559 		},
  65560 		4: {
  65561 			0: uint16(458),
  65562 			1: uint16(783),
  65563 			2: uint16(1037),
  65564 			3: uint16(911),
  65565 			4: uint16(738),
  65566 			5: uint16(968),
  65567 			6: uint16(1165),
  65568 			7: uint16(1518),
  65569 			8: uint16(859),
  65570 			9: uint16(1033),
  65571 		},
  65572 		5: {
  65573 			0: uint16(504),
  65574 			1: uint16(815),
  65575 			2: uint16(504),
  65576 			3: uint16(1139),
  65577 			4: uint16(1219),
  65578 			5: uint16(719),
  65579 			6: uint16(1506),
  65580 			7: uint16(1085),
  65581 			8: uint16(1268),
  65582 			9: uint16(1268),
  65583 		},
  65584 		6: {
  65585 			0: uint16(333),
  65586 			1: uint16(630),
  65587 			2: uint16(1445),
  65588 			3: uint16(1239),
  65589 			4: uint16(1883),
  65590 			5: uint16(3672),
  65591 			6: uint16(799),
  65592 			7: uint16(1548),
  65593 			8: uint16(1865),
  65594 			9: uint16(598),
  65595 		},
  65596 		7: {
  65597 			0: uint16(399),
  65598 			1: uint16(644),
  65599 			2: uint16(746),
  65600 			3: uint16(1342),
  65601 			4: uint16(1856),
  65602 			5: uint16(1350),
  65603 			6: uint16(1493),
  65604 			7: uint16(613),
  65605 			8: uint16(1855),
  65606 			9: uint16(1015),
  65607 		},
  65608 		8: {
  65609 			0: uint16(622),
  65610 			1: uint16(749),
  65611 			2: uint16(1205),
  65612 			3: uint16(608),
  65613 			4: uint16(1066),
  65614 			5: uint16(1408),
  65615 			6: uint16(1290),
  65616 			7: uint16(1406),
  65617 			8: uint16(546),
  65618 			9: uint16(971),
  65619 		},
  65620 		9: {
  65621 			0: uint16(500),
  65622 			1: uint16(753),
  65623 			2: uint16(1041),
  65624 			3: uint16(668),
  65625 			4: uint16(1230),
  65626 			5: uint16(1617),
  65627 			6: uint16(1297),
  65628 			7: uint16(1425),
  65629 			8: uint16(1383),
  65630 			9: uint16(523),
  65631 		},
  65632 	},
  65633 	2: {
  65634 		0: {
  65635 			0: uint16(394),
  65636 			1: uint16(553),
  65637 			2: uint16(523),
  65638 			3: uint16(1502),
  65639 			4: uint16(1536),
  65640 			5: uint16(981),
  65641 			6: uint16(1608),
  65642 			7: uint16(1142),
  65643 			8: uint16(1666),
  65644 			9: uint16(2181),
  65645 		},
  65646 		1: {
  65647 			0: uint16(655),
  65648 			1: uint16(430),
  65649 			2: uint16(375),
  65650 			3: uint16(1411),
  65651 			4: uint16(1861),
  65652 			5: uint16(1220),
  65653 			6: uint16(1677),
  65654 			7: uint16(1135),
  65655 			8: uint16(1978),
  65656 			9: uint16(1553),
  65657 		},
  65658 		2: {
  65659 			0: uint16(690),
  65660 			1: uint16(640),
  65661 			2: uint16(245),
  65662 			3: uint16(1954),
  65663 			4: uint16(2070),
  65664 			5: uint16(1194),
  65665 			6: uint16(1528),
  65666 			7: uint16(982),
  65667 			8: uint16(1972),
  65668 			9: uint16(2232),
  65669 		},
  65670 		3: {
  65671 			0: uint16(559),
  65672 			1: uint16(834),
  65673 			2: uint16(741),
  65674 			3: uint16(867),
  65675 			4: uint16(1131),
  65676 			5: uint16(980),
  65677 			6: uint16(1225),
  65678 			7: uint16(852),
  65679 			8: uint16(1092),
  65680 			9: uint16(784),
  65681 		},
  65682 		4: {
  65683 			0: uint16(690),
  65684 			1: uint16(875),
  65685 			2: uint16(516),
  65686 			3: uint16(959),
  65687 			4: uint16(673),
  65688 			5: uint16(894),
  65689 			6: uint16(1056),
  65690 			7: uint16(1190),
  65691 			8: uint16(1528),
  65692 			9: uint16(1126),
  65693 		},
  65694 		5: {
  65695 			0: uint16(740),
  65696 			1: uint16(951),
  65697 			2: uint16(384),
  65698 			3: uint16(1277),
  65699 			4: uint16(1177),
  65700 			5: uint16(492),
  65701 			6: uint16(1579),
  65702 			7: uint16(1155),
  65703 			8: uint16(1846),
  65704 			9: uint16(1513),
  65705 		},
  65706 		6: {
  65707 			0: uint16(323),
  65708 			1: uint16(775),
  65709 			2: uint16(1062),
  65710 			3: uint16(1776),
  65711 			4: uint16(3062),
  65712 			5: uint16(1274),
  65713 			6: uint16(813),
  65714 			7: uint16(1188),
  65715 			8: uint16(1372),
  65716 			9: uint16(655),
  65717 		},
  65718 		7: {
  65719 			0: uint16(488),
  65720 			1: uint16(971),
  65721 			2: uint16(484),
  65722 			3: uint16(1767),
  65723 			4: uint16(1515),
  65724 			5: uint16(1775),
  65725 			6: uint16(1115),
  65726 			7: uint16(503),
  65727 			8: uint16(1539),
  65728 			9: uint16(1461),
  65729 		},
  65730 		8: {
  65731 			0: uint16(740),
  65732 			1: uint16(1006),
  65733 			2: uint16(998),
  65734 			3: uint16(709),
  65735 			4: uint16(851),
  65736 			5: uint16(1230),
  65737 			6: uint16(1337),
  65738 			7: uint16(788),
  65739 			8: uint16(741),
  65740 			9: uint16(721),
  65741 		},
  65742 		9: {
  65743 			0: uint16(522),
  65744 			1: uint16(1073),
  65745 			2: uint16(573),
  65746 			3: uint16(1045),
  65747 			4: uint16(1346),
  65748 			5: uint16(887),
  65749 			6: uint16(1046),
  65750 			7: uint16(1146),
  65751 			8: uint16(1203),
  65752 			9: uint16(697),
  65753 		},
  65754 	},
  65755 	3: {
  65756 		0: {
  65757 			0: uint16(105),
  65758 			1: uint16(864),
  65759 			2: uint16(1442),
  65760 			3: uint16(1009),
  65761 			4: uint16(1934),
  65762 			5: uint16(1840),
  65763 			6: uint16(1519),
  65764 			7: uint16(1920),
  65765 			8: uint16(1673),
  65766 			9: uint16(1579),
  65767 		},
  65768 		1: {
  65769 			0: uint16(534),
  65770 			1: uint16(305),
  65771 			2: uint16(1193),
  65772 			3: uint16(683),
  65773 			4: uint16(1388),
  65774 			5: uint16(2164),
  65775 			6: uint16(1802),
  65776 			7: uint16(1894),
  65777 			8: uint16(1264),
  65778 			9: uint16(1170),
  65779 		},
  65780 		2: {
  65781 			0: uint16(305),
  65782 			1: uint16(518),
  65783 			2: uint16(877),
  65784 			3: uint16(1108),
  65785 			4: uint16(1426),
  65786 			5: uint16(3215),
  65787 			6: uint16(1425),
  65788 			7: uint16(1064),
  65789 			8: uint16(1320),
  65790 			9: uint16(1242),
  65791 		},
  65792 		3: {
  65793 			0: uint16(683),
  65794 			1: uint16(732),
  65795 			2: uint16(1927),
  65796 			3: uint16(257),
  65797 			4: uint16(1493),
  65798 			5: uint16(2048),
  65799 			6: uint16(1858),
  65800 			7: uint16(1552),
  65801 			8: uint16(1055),
  65802 			9: uint16(947),
  65803 		},
  65804 		4: {
  65805 			0: uint16(394),
  65806 			1: uint16(814),
  65807 			2: uint16(1024),
  65808 			3: uint16(660),
  65809 			4: uint16(959),
  65810 			5: uint16(1556),
  65811 			6: uint16(1282),
  65812 			7: uint16(1289),
  65813 			8: uint16(893),
  65814 			9: uint16(1047),
  65815 		},
  65816 		5: {
  65817 			0: uint16(528),
  65818 			1: uint16(615),
  65819 			2: uint16(996),
  65820 			3: uint16(940),
  65821 			4: uint16(1201),
  65822 			5: uint16(635),
  65823 			6: uint16(1094),
  65824 			7: uint16(2515),
  65825 			8: uint16(803),
  65826 			9: uint16(1358),
  65827 		},
  65828 		6: {
  65829 			0: uint16(347),
  65830 			1: uint16(614),
  65831 			2: uint16(1609),
  65832 			3: uint16(1187),
  65833 			4: uint16(3133),
  65834 			5: uint16(1345),
  65835 			6: uint16(1007),
  65836 			7: uint16(1339),
  65837 			8: uint16(1017),
  65838 			9: uint16(667),
  65839 		},
  65840 		7: {
  65841 			0: uint16(218),
  65842 			1: uint16(740),
  65843 			2: uint16(878),
  65844 			3: uint16(1605),
  65845 			4: uint16(3650),
  65846 			5: uint16(3650),
  65847 			6: uint16(1345),
  65848 			7: uint16(758),
  65849 			8: uint16(1357),
  65850 			9: uint16(1617),
  65851 		},
  65852 		8: {
  65853 			0: uint16(672),
  65854 			1: uint16(750),
  65855 			2: uint16(1541),
  65856 			3: uint16(558),
  65857 			4: uint16(1257),
  65858 			5: uint16(1599),
  65859 			6: uint16(1870),
  65860 			7: uint16(2135),
  65861 			8: uint16(402),
  65862 			9: uint16(1087),
  65863 		},
  65864 		9: {
  65865 			0: uint16(592),
  65866 			1: uint16(684),
  65867 			2: uint16(1161),
  65868 			3: uint16(430),
  65869 			4: uint16(1092),
  65870 			5: uint16(1497),
  65871 			6: uint16(1475),
  65872 			7: uint16(1489),
  65873 			8: uint16(1095),
  65874 			9: uint16(822),
  65875 		},
  65876 	},
  65877 	4: {
  65878 		0: {
  65879 			0: uint16(228),
  65880 			1: uint16(1056),
  65881 			2: uint16(1059),
  65882 			3: uint16(1368),
  65883 			4: uint16(752),
  65884 			5: uint16(982),
  65885 			6: uint16(1512),
  65886 			7: uint16(1518),
  65887 			8: uint16(987),
  65888 			9: uint16(1782),
  65889 		},
  65890 		1: {
  65891 			0: uint16(494),
  65892 			1: uint16(514),
  65893 			2: uint16(818),
  65894 			3: uint16(942),
  65895 			4: uint16(965),
  65896 			5: uint16(892),
  65897 			6: uint16(1610),
  65898 			7: uint16(1356),
  65899 			8: uint16(1048),
  65900 			9: uint16(1363),
  65901 		},
  65902 		2: {
  65903 			0: uint16(512),
  65904 			1: uint16(648),
  65905 			2: uint16(591),
  65906 			3: uint16(1042),
  65907 			4: uint16(761),
  65908 			5: uint16(991),
  65909 			6: uint16(1196),
  65910 			7: uint16(1454),
  65911 			8: uint16(1309),
  65912 			9: uint16(1463),
  65913 		},
  65914 		3: {
  65915 			0: uint16(683),
  65916 			1: uint16(749),
  65917 			2: uint16(1043),
  65918 			3: uint16(676),
  65919 			4: uint16(841),
  65920 			5: uint16(1396),
  65921 			6: uint16(1133),
  65922 			7: uint16(1138),
  65923 			8: uint16(654),
  65924 			9: uint16(939),
  65925 		},
  65926 		4: {
  65927 			0: uint16(622),
  65928 			1: uint16(1101),
  65929 			2: uint16(1126),
  65930 			3: uint16(994),
  65931 			4: uint16(361),
  65932 			5: uint16(1077),
  65933 			6: uint16(1203),
  65934 			7: uint16(1318),
  65935 			8: uint16(877),
  65936 			9: uint16(1219),
  65937 		},
  65938 		5: {
  65939 			0: uint16(631),
  65940 			1: uint16(1068),
  65941 			2: uint16(857),
  65942 			3: uint16(1650),
  65943 			4: uint16(651),
  65944 			5: uint16(477),
  65945 			6: uint16(1650),
  65946 			7: uint16(1419),
  65947 			8: uint16(828),
  65948 			9: uint16(1170),
  65949 		},
  65950 		6: {
  65951 			0: uint16(555),
  65952 			1: uint16(727),
  65953 			2: uint16(1068),
  65954 			3: uint16(1335),
  65955 			4: uint16(3127),
  65956 			5: uint16(1339),
  65957 			6: uint16(820),
  65958 			7: uint16(1331),
  65959 			8: uint16(1077),
  65960 			9: uint16(429),
  65961 		},
  65962 		7: {
  65963 			0: uint16(504),
  65964 			1: uint16(879),
  65965 			2: uint16(624),
  65966 			3: uint16(1398),
  65967 			4: uint16(889),
  65968 			5: uint16(889),
  65969 			6: uint16(1392),
  65970 			7: uint16(808),
  65971 			8: uint16(891),
  65972 			9: uint16(1406),
  65973 		},
  65974 		8: {
  65975 			0: uint16(683),
  65976 			1: uint16(1602),
  65977 			2: uint16(1289),
  65978 			3: uint16(977),
  65979 			4: uint16(578),
  65980 			5: uint16(983),
  65981 			6: uint16(1280),
  65982 			7: uint16(1708),
  65983 			8: uint16(406),
  65984 			9: uint16(1122),
  65985 		},
  65986 		9: {
  65987 			0: uint16(399),
  65988 			1: uint16(865),
  65989 			2: uint16(1433),
  65990 			3: uint16(1070),
  65991 			4: uint16(1072),
  65992 			5: uint16(764),
  65993 			6: uint16(968),
  65994 			7: uint16(1477),
  65995 			8: uint16(1223),
  65996 			9: uint16(678),
  65997 		},
  65998 	},
  65999 	5: {
  66000 		0: {
  66001 			0: uint16(333),
  66002 			1: uint16(760),
  66003 			2: uint16(935),
  66004 			3: uint16(1638),
  66005 			4: uint16(1010),
  66006 			5: uint16(529),
  66007 			6: uint16(1646),
  66008 			7: uint16(1410),
  66009 			8: uint16(1472),
  66010 			9: uint16(2219),
  66011 		},
  66012 		1: {
  66013 			0: uint16(512),
  66014 			1: uint16(494),
  66015 			2: uint16(750),
  66016 			3: uint16(1160),
  66017 			4: uint16(1215),
  66018 			5: uint16(610),
  66019 			6: uint16(1870),
  66020 			7: uint16(1868),
  66021 			8: uint16(1628),
  66022 			9: uint16(1169),
  66023 		},
  66024 		2: {
  66025 			0: uint16(572),
  66026 			1: uint16(646),
  66027 			2: uint16(492),
  66028 			3: uint16(1934),
  66029 			4: uint16(1208),
  66030 			5: uint16(603),
  66031 			6: uint16(1580),
  66032 			7: uint16(1099),
  66033 			8: uint16(1398),
  66034 			9: uint16(1995),
  66035 		},
  66036 		3: {
  66037 			0: uint16(786),
  66038 			1: uint16(789),
  66039 			2: uint16(942),
  66040 			3: uint16(581),
  66041 			4: uint16(1018),
  66042 			5: uint16(951),
  66043 			6: uint16(1599),
  66044 			7: uint16(1207),
  66045 			8: uint16(731),
  66046 			9: uint16(768),
  66047 		},
  66048 		4: {
  66049 			0: uint16(690),
  66050 			1: uint16(1015),
  66051 			2: uint16(672),
  66052 			3: uint16(1078),
  66053 			4: uint16(582),
  66054 			5: uint16(504),
  66055 			6: uint16(1693),
  66056 			7: uint16(1438),
  66057 			8: uint16(1108),
  66058 			9: uint16(2897),
  66059 		},
  66060 		5: {
  66061 			0: uint16(768),
  66062 			1: uint16(1267),
  66063 			2: uint16(571),
  66064 			3: uint16(2005),
  66065 			4: uint16(1243),
  66066 			5: uint16(244),
  66067 			6: uint16(2881),
  66068 			7: uint16(1380),
  66069 			8: uint16(1786),
  66070 			9: uint16(1453),
  66071 		},
  66072 		6: {
  66073 			0: uint16(452),
  66074 			1: uint16(899),
  66075 			2: uint16(1293),
  66076 			3: uint16(903),
  66077 			4: uint16(1311),
  66078 			5: uint16(3100),
  66079 			6: uint16(465),
  66080 			7: uint16(1311),
  66081 			8: uint16(1319),
  66082 			9: uint16(813),
  66083 		},
  66084 		7: {
  66085 			0: uint16(394),
  66086 			1: uint16(927),
  66087 			2: uint16(942),
  66088 			3: uint16(1103),
  66089 			4: uint16(1358),
  66090 			5: uint16(1104),
  66091 			6: uint16(946),
  66092 			7: uint16(593),
  66093 			8: uint16(1363),
  66094 			9: uint16(1109),
  66095 		},
  66096 		8: {
  66097 			0: uint16(559),
  66098 			1: uint16(1005),
  66099 			2: uint16(1007),
  66100 			3: uint16(1016),
  66101 			4: uint16(658),
  66102 			5: uint16(1173),
  66103 			6: uint16(1021),
  66104 			7: uint16(1164),
  66105 			8: uint16(623),
  66106 			9: uint16(1028),
  66107 		},
  66108 		9: {
  66109 			0: uint16(564),
  66110 			1: uint16(796),
  66111 			2: uint16(632),
  66112 			3: uint16(1005),
  66113 			4: uint16(1014),
  66114 			5: uint16(863),
  66115 			6: uint16(2316),
  66116 			7: uint16(1268),
  66117 			8: uint16(938),
  66118 			9: uint16(764),
  66119 		},
  66120 	},
  66121 	6: {
  66122 		0: {
  66123 			0: uint16(266),
  66124 			1: uint16(606),
  66125 			2: uint16(1098),
  66126 			3: uint16(1228),
  66127 			4: uint16(1497),
  66128 			5: uint16(1243),
  66129 			6: uint16(948),
  66130 			7: uint16(1030),
  66131 			8: uint16(1734),
  66132 			9: uint16(1461),
  66133 		},
  66134 		1: {
  66135 			0: uint16(366),
  66136 			1: uint16(585),
  66137 			2: uint16(901),
  66138 			3: uint16(1060),
  66139 			4: uint16(1407),
  66140 			5: uint16(1247),
  66141 			6: uint16(876),
  66142 			7: uint16(1134),
  66143 			8: uint16(1620),
  66144 			9: uint16(1054),
  66145 		},
  66146 		2: {
  66147 			0: uint16(452),
  66148 			1: uint16(565),
  66149 			2: uint16(542),
  66150 			3: uint16(1729),
  66151 			4: uint16(1479),
  66152 			5: uint16(1479),
  66153 			6: uint16(1016),
  66154 			7: uint16(886),
  66155 			8: uint16(2938),
  66156 			9: uint16(1150),
  66157 		},
  66158 		3: {
  66159 			0: uint16(555),
  66160 			1: uint16(1088),
  66161 			2: uint16(1533),
  66162 			3: uint16(950),
  66163 			4: uint16(1354),
  66164 			5: uint16(895),
  66165 			6: uint16(834),
  66166 			7: uint16(1019),
  66167 			8: uint16(1021),
  66168 			9: uint16(496),
  66169 		},
  66170 		4: {
  66171 			0: uint16(704),
  66172 			1: uint16(815),
  66173 			2: uint16(1193),
  66174 			3: uint16(971),
  66175 			4: uint16(973),
  66176 			5: uint16(640),
  66177 			6: uint16(1217),
  66178 			7: uint16(2214),
  66179 			8: uint16(832),
  66180 			9: uint16(578),
  66181 		},
  66182 		5: {
  66183 			0: uint16(672),
  66184 			1: uint16(1245),
  66185 			2: uint16(579),
  66186 			3: uint16(871),
  66187 			4: uint16(875),
  66188 			5: uint16(774),
  66189 			6: uint16(872),
  66190 			7: uint16(1273),
  66191 			8: uint16(1027),
  66192 			9: uint16(949),
  66193 		},
  66194 		6: {
  66195 			0: uint16(296),
  66196 			1: uint16(1134),
  66197 			2: uint16(2050),
  66198 			3: uint16(1784),
  66199 			4: uint16(1636),
  66200 			5: uint16(3425),
  66201 			6: uint16(442),
  66202 			7: uint16(1550),
  66203 			8: uint16(2076),
  66204 			9: uint16(722),
  66205 		},
  66206 		7: {
  66207 			0: uint16(342),
  66208 			1: uint16(982),
  66209 			2: uint16(1259),
  66210 			3: uint16(1846),
  66211 			4: uint16(1848),
  66212 			5: uint16(1848),
  66213 			6: uint16(622),
  66214 			7: uint16(568),
  66215 			8: uint16(1847),
  66216 			9: uint16(1052),
  66217 		},
  66218 		8: {
  66219 			0: uint16(555),
  66220 			1: uint16(1064),
  66221 			2: uint16(1304),
  66222 			3: uint16(828),
  66223 			4: uint16(746),
  66224 			5: uint16(1343),
  66225 			6: uint16(1075),
  66226 			7: uint16(1329),
  66227 			8: uint16(1078),
  66228 			9: uint16(494),
  66229 		},
  66230 		9: {
  66231 			0: uint16(288),
  66232 			1: uint16(1167),
  66233 			2: uint16(1285),
  66234 			3: uint16(1174),
  66235 			4: uint16(1639),
  66236 			5: uint16(1639),
  66237 			6: uint16(833),
  66238 			7: uint16(2254),
  66239 			8: uint16(1304),
  66240 			9: uint16(509),
  66241 		},
  66242 	},
  66243 	7: {
  66244 		0: {
  66245 			0: uint16(342),
  66246 			1: uint16(719),
  66247 			2: uint16(767),
  66248 			3: uint16(1866),
  66249 			4: uint16(1757),
  66250 			5: uint16(1270),
  66251 			6: uint16(1246),
  66252 			7: uint16(550),
  66253 			8: uint16(1746),
  66254 			9: uint16(2151),
  66255 		},
  66256 		1: {
  66257 			0: uint16(483),
  66258 			1: uint16(653),
  66259 			2: uint16(694),
  66260 			3: uint16(1509),
  66261 			4: uint16(1459),
  66262 			5: uint16(1410),
  66263 			6: uint16(1218),
  66264 			7: uint16(507),
  66265 			8: uint16(1914),
  66266 			9: uint16(1266),
  66267 		},
  66268 		2: {
  66269 			0: uint16(488),
  66270 			1: uint16(757),
  66271 			2: uint16(447),
  66272 			3: uint16(2979),
  66273 			4: uint16(1813),
  66274 			5: uint16(1268),
  66275 			6: uint16(1654),
  66276 			7: uint16(539),
  66277 			8: uint16(1849),
  66278 			9: uint16(2109),
  66279 		},
  66280 		3: {
  66281 			0: uint16(522),
  66282 			1: uint16(1097),
  66283 			2: uint16(1085),
  66284 			3: uint16(851),
  66285 			4: uint16(1365),
  66286 			5: uint16(1111),
  66287 			6: uint16(851),
  66288 			7: uint16(901),
  66289 			8: uint16(961),
  66290 			9: uint16(605),
  66291 		},
  66292 		4: {
  66293 			0: uint16(709),
  66294 			1: uint16(716),
  66295 			2: uint16(841),
  66296 			3: uint16(728),
  66297 			4: uint16(736),
  66298 			5: uint16(945),
  66299 			6: uint16(941),
  66300 			7: uint16(862),
  66301 			8: uint16(2845),
  66302 			9: uint16(1057),
  66303 		},
  66304 		5: {
  66305 			0: uint16(512),
  66306 			1: uint16(1323),
  66307 			2: uint16(500),
  66308 			3: uint16(1336),
  66309 			4: uint16(1083),
  66310 			5: uint16(681),
  66311 			6: uint16(1342),
  66312 			7: uint16(717),
  66313 			8: uint16(1604),
  66314 			9: uint16(1350),
  66315 		},
  66316 		6: {
  66317 			0: uint16(452),
  66318 			1: uint16(1155),
  66319 			2: uint16(1372),
  66320 			3: uint16(1900),
  66321 			4: uint16(1501),
  66322 			5: uint16(3290),
  66323 			6: uint16(311),
  66324 			7: uint16(944),
  66325 			8: uint16(1919),
  66326 			9: uint16(922),
  66327 		},
  66328 		7: {
  66329 			0: uint16(403),
  66330 			1: uint16(1520),
  66331 			2: uint16(977),
  66332 			3: uint16(2132),
  66333 			4: uint16(1733),
  66334 			5: uint16(3522),
  66335 			6: uint16(1076),
  66336 			7: uint16(276),
  66337 			8: uint16(3335),
  66338 			9: uint16(1547),
  66339 		},
  66340 		8: {
  66341 			0: uint16(559),
  66342 			1: uint16(1374),
  66343 			2: uint16(1101),
  66344 			3: uint16(615),
  66345 			4: uint16(673),
  66346 			5: uint16(2462),
  66347 			6: uint16(974),
  66348 			7: uint16(795),
  66349 			8: uint16(984),
  66350 			9: uint16(984),
  66351 		},
  66352 		9: {
  66353 			0: uint16(547),
  66354 			1: uint16(1122),
  66355 			2: uint16(1062),
  66356 			3: uint16(812),
  66357 			4: uint16(1410),
  66358 			5: uint16(951),
  66359 			6: uint16(1140),
  66360 			7: uint16(622),
  66361 			8: uint16(1268),
  66362 			9: uint16(651),
  66363 		},
  66364 	},
  66365 	8: {
  66366 		0: {
  66367 			0: uint16(165),
  66368 			1: uint16(982),
  66369 			2: uint16(1235),
  66370 			3: uint16(938),
  66371 			4: uint16(1334),
  66372 			5: uint16(1366),
  66373 			6: uint16(1659),
  66374 			7: uint16(1578),
  66375 			8: uint16(964),
  66376 			9: uint16(1612),
  66377 		},
  66378 		1: {
  66379 			0: uint16(592),
  66380 			1: uint16(422),
  66381 			2: uint16(925),
  66382 			3: uint16(847),
  66383 			4: uint16(1139),
  66384 			5: uint16(1112),
  66385 			6: uint16(1387),
  66386 			7: uint16(2036),
  66387 			8: uint16(861),
  66388 			9: uint16(1041),
  66389 		},
  66390 		2: {
  66391 			0: uint16(403),
  66392 			1: uint16(837),
  66393 			2: uint16(732),
  66394 			3: uint16(770),
  66395 			4: uint16(941),
  66396 			5: uint16(1658),
  66397 			6: uint16(1250),
  66398 			7: uint16(809),
  66399 			8: uint16(1407),
  66400 			9: uint16(1407),
  66401 		},
  66402 		3: {
  66403 			0: uint16(896),
  66404 			1: uint16(874),
  66405 			2: uint16(1071),
  66406 			3: uint16(381),
  66407 			4: uint16(1568),
  66408 			5: uint16(1722),
  66409 			6: uint16(1437),
  66410 			7: uint16(2192),
  66411 			8: uint16(480),
  66412 			9: uint16(1035),
  66413 		},
  66414 		4: {
  66415 			0: uint16(640),
  66416 			1: uint16(1098),
  66417 			2: uint16(1012),
  66418 			3: uint16(1032),
  66419 			4: uint16(684),
  66420 			5: uint16(1382),
  66421 			6: uint16(1581),
  66422 			7: uint16(2106),
  66423 			8: uint16(416),
  66424 			9: uint16(865),
  66425 		},
  66426 		5: {
  66427 			0: uint16(559),
  66428 			1: uint16(1005),
  66429 			2: uint16(819),
  66430 			3: uint16(914),
  66431 			4: uint16(710),
  66432 			5: uint16(770),
  66433 			6: uint16(1418),
  66434 			7: uint16(920),
  66435 			8: uint16(838),
  66436 			9: uint16(1435),
  66437 		},
  66438 		6: {
  66439 			0: uint16(415),
  66440 			1: uint16(1258),
  66441 			2: uint16(1245),
  66442 			3: uint16(870),
  66443 			4: uint16(1278),
  66444 			5: uint16(3067),
  66445 			6: uint16(770),
  66446 			7: uint16(1021),
  66447 			8: uint16(1287),
  66448 			9: uint16(522),
  66449 		},
  66450 		7: {
  66451 			0: uint16(406),
  66452 			1: uint16(990),
  66453 			2: uint16(601),
  66454 			3: uint16(1009),
  66455 			4: uint16(1265),
  66456 			5: uint16(1265),
  66457 			6: uint16(1267),
  66458 			7: uint16(759),
  66459 			8: uint16(1017),
  66460 			9: uint16(1277),
  66461 		},
  66462 		8: {
  66463 			0: uint16(968),
  66464 			1: uint16(1182),
  66465 			2: uint16(1329),
  66466 			3: uint16(788),
  66467 			4: uint16(1032),
  66468 			5: uint16(1292),
  66469 			6: uint16(1705),
  66470 			7: uint16(1714),
  66471 			8: uint16(203),
  66472 			9: uint16(1403),
  66473 		},
  66474 		9: {
  66475 			0: uint16(732),
  66476 			1: uint16(877),
  66477 			2: uint16(1279),
  66478 			3: uint16(471),
  66479 			4: uint16(901),
  66480 			5: uint16(1161),
  66481 			6: uint16(1545),
  66482 			7: uint16(1294),
  66483 			8: uint16(755),
  66484 			9: uint16(755),
  66485 		},
  66486 	},
  66487 	9: {
  66488 		0: {
  66489 			0: uint16(111),
  66490 			1: uint16(931),
  66491 			2: uint16(1378),
  66492 			3: uint16(1185),
  66493 			4: uint16(1933),
  66494 			5: uint16(1648),
  66495 			6: uint16(1148),
  66496 			7: uint16(1714),
  66497 			8: uint16(1873),
  66498 			9: uint16(1307),
  66499 		},
  66500 		1: {
  66501 			0: uint16(406),
  66502 			1: uint16(414),
  66503 			2: uint16(1030),
  66504 			3: uint16(1023),
  66505 			4: uint16(1910),
  66506 			5: uint16(1404),
  66507 			6: uint16(1313),
  66508 			7: uint16(1647),
  66509 			8: uint16(1509),
  66510 			9: uint16(793),
  66511 		},
  66512 		2: {
  66513 			0: uint16(342),
  66514 			1: uint16(640),
  66515 			2: uint16(575),
  66516 			3: uint16(1088),
  66517 			4: uint16(1241),
  66518 			5: uint16(1349),
  66519 			6: uint16(1161),
  66520 			7: uint16(1350),
  66521 			8: uint16(1756),
  66522 			9: uint16(1502),
  66523 		},
  66524 		3: {
  66525 			0: uint16(559),
  66526 			1: uint16(766),
  66527 			2: uint16(1185),
  66528 			3: uint16(357),
  66529 			4: uint16(1682),
  66530 			5: uint16(1428),
  66531 			6: uint16(1329),
  66532 			7: uint16(1897),
  66533 			8: uint16(1219),
  66534 			9: uint16(802),
  66535 		},
  66536 		4: {
  66537 			0: uint16(473),
  66538 			1: uint16(909),
  66539 			2: uint16(1164),
  66540 			3: uint16(771),
  66541 			4: uint16(719),
  66542 			5: uint16(2508),
  66543 			6: uint16(1427),
  66544 			7: uint16(1432),
  66545 			8: uint16(722),
  66546 			9: uint16(782),
  66547 		},
  66548 		5: {
  66549 			0: uint16(342),
  66550 			1: uint16(892),
  66551 			2: uint16(785),
  66552 			3: uint16(1145),
  66553 			4: uint16(1150),
  66554 			5: uint16(794),
  66555 			6: uint16(1296),
  66556 			7: uint16(1550),
  66557 			8: uint16(973),
  66558 			9: uint16(1057),
  66559 		},
  66560 		6: {
  66561 			0: uint16(208),
  66562 			1: uint16(1036),
  66563 			2: uint16(1326),
  66564 			3: uint16(1343),
  66565 			4: uint16(1606),
  66566 			5: uint16(3395),
  66567 			6: uint16(815),
  66568 			7: uint16(1455),
  66569 			8: uint16(1618),
  66570 			9: uint16(712),
  66571 		},
  66572 		7: {
  66573 			0: uint16(228),
  66574 			1: uint16(928),
  66575 			2: uint16(890),
  66576 			3: uint16(1046),
  66577 			4: uint16(3499),
  66578 			5: uint16(1711),
  66579 			6: uint16(994),
  66580 			7: uint16(829),
  66581 			8: uint16(1720),
  66582 			9: uint16(1318),
  66583 		},
  66584 		8: {
  66585 			0: uint16(768),
  66586 			1: uint16(724),
  66587 			2: uint16(1058),
  66588 			3: uint16(636),
  66589 			4: uint16(991),
  66590 			5: uint16(1075),
  66591 			6: uint16(1319),
  66592 			7: uint16(1324),
  66593 			8: uint16(616),
  66594 			9: uint16(825),
  66595 		},
  66596 		9: {
  66597 			0: uint16(305),
  66598 			1: uint16(1167),
  66599 			2: uint16(1358),
  66600 			3: uint16(899),
  66601 			4: uint16(1587),
  66602 			5: uint16(1587),
  66603 			6: uint16(987),
  66604 			7: uint16(1988),
  66605 			8: uint16(1332),
  66606 			9: uint16(501),
  66607 		},
  66608 	},
  66609 }
  66610 
  66611 //------------------------------------------------------------------------------
  66612 // Mode cost tables.
  66613 
  66614 // C documentation
  66615 //
  66616 //	// These are the fixed probabilities (in the coding trees) turned into bit-cost
  66617 //	// by calling VP8BitCost().
  66618 var VP8FixedCostsUV = [4]uint16_t{
  66619 	0: uint16(302),
  66620 	1: uint16(984),
  66621 	2: uint16(439),
  66622 	3: uint16(642),
  66623 }
  66624 
  66625 var VP8GetCPUInfo = uintptr(0)
  66626 
  66627 //------------------------------------------------------------------------------
  66628 // init function
  66629 
  66630 var VP8GetResidualCost VP8GetResidualCostFunc
  66631 
  66632 var VP8HFilter16 VP8LumaFilterFunc
  66633 
  66634 var VP8HFilter16i VP8LumaFilterFunc
  66635 
  66636 var VP8HFilter8 VP8ChromaFilterFunc
  66637 
  66638 var VP8HFilter8i VP8ChromaFilterFunc
  66639 
  66640 //------------------------------------------------------------------------------
  66641 // Form the predictions in cache
  66642 
  66643 // C documentation
  66644 //
  66645 //	// Must be ordered using {DC_PRED, TM_PRED, V_PRED, H_PRED} as index
  66646 var VP8I16ModeOffsets = [4]uint16_t{
  66647 	1: libc.Uint16FromInt32(libc.Int32FromInt32(0)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(16)),
  66648 	2: libc.Uint16FromInt32(libc.Int32FromInt32(1) * libc.Int32FromInt32(16) * libc.Int32FromInt32(BPS)),
  66649 	3: libc.Uint16FromInt32(libc.Int32FromInt32(1)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(16)),
  66650 }
  66651 
  66652 var VP8ITransform VP8Idct
  66653 
  66654 //------------------------------------------------------------------------------
  66655 
  66656 var VP8LAddGreenToBlueAndRed VP8LProcessDecBlueAndRedFunc
  66657 
  66658 var VP8LAddGreenToBlueAndRed_SSE VP8LProcessDecBlueAndRedFunc
  66659 
  66660 var VP8LAddVector VP8LAddVectorFunc
  66661 
  66662 var VP8LAddVectorEq VP8LAddVectorEqFunc
  66663 
  66664 var VP8LBundleColorMap VP8LBundleColorMapFunc
  66665 
  66666 var VP8LBundleColorMap_SSE VP8LBundleColorMapFunc
  66667 
  66668 var VP8LCollectColorBlueTransforms VP8LCollectColorBlueTransformsFunc
  66669 
  66670 var VP8LCollectColorBlueTransforms_SSE VP8LCollectColorBlueTransformsFunc
  66671 
  66672 var VP8LCollectColorRedTransforms VP8LCollectColorRedTransformsFunc
  66673 
  66674 var VP8LCollectColorRedTransforms_SSE VP8LCollectColorRedTransformsFunc
  66675 
  66676 var VP8LCombinedShannonEntropy VP8LCombinedShannonEntropyFunc
  66677 
  66678 var VP8LConvertBGRAToBGR VP8LConvertFunc
  66679 
  66680 var VP8LConvertBGRAToRGB VP8LConvertFunc
  66681 
  66682 var VP8LConvertBGRAToRGB565 VP8LConvertFunc
  66683 
  66684 var VP8LConvertBGRAToRGBA VP8LConvertFunc
  66685 
  66686 var VP8LConvertBGRAToRGBA4444 VP8LConvertFunc
  66687 
  66688 var VP8LConvertBGRAToRGBA_SSE VP8LConvertFunc
  66689 
  66690 var VP8LConvertBGRAToRGB_SSE VP8LConvertFunc
  66691 
  66692 var VP8LExtraCost VP8LCostFunc
  66693 
  66694 var VP8LFastLog2Slow VP8LFastLog2SlowFunc
  66695 
  66696 var VP8LFastSLog2Slow VP8LFastSLog2SlowFunc
  66697 
  66698 var VP8LGetCombinedEntropyUnrefined VP8LGetCombinedEntropyUnrefinedFunc
  66699 
  66700 var VP8LGetEntropyUnrefined VP8LGetEntropyUnrefinedFunc
  66701 
  66702 var VP8LMapColor32b VP8LMapARGBFunc
  66703 
  66704 var VP8LMapColor8b VP8LMapAlphaFunc
  66705 
  66706 var VP8LPredictors [16]VP8LPredictorFunc
  66707 
  66708 var VP8LPredictorsAdd [16]VP8LPredictorAddSubFunc
  66709 
  66710 // C documentation
  66711 //
  66712 //	// exposed plain-C implementations
  66713 var VP8LPredictorsAdd_C [16]VP8LPredictorAddSubFunc
  66714 
  66715 var VP8LPredictorsAdd_SSE [16]VP8LPredictorAddSubFunc
  66716 
  66717 var VP8LPredictorsSub [16]VP8LPredictorAddSubFunc
  66718 
  66719 var VP8LPredictorsSub_C [16]VP8LPredictorAddSubFunc
  66720 
  66721 var VP8LPredictorsSub_SSE [16]VP8LPredictorAddSubFunc
  66722 
  66723 var VP8LShannonEntropy VP8LShannonEntropyFunc
  66724 
  66725 //------------------------------------------------------------------------------
  66726 
  66727 var VP8LSubtractGreenFromBlueAndRed VP8LProcessEncBlueAndRedFunc
  66728 
  66729 var VP8LSubtractGreenFromBlueAndRed_SSE VP8LProcessEncBlueAndRedFunc
  66730 
  66731 var VP8LTransformColor VP8LTransformColorFunc
  66732 
  66733 var VP8LTransformColorInverse VP8LTransformColorInverseFunc
  66734 
  66735 var VP8LTransformColorInverse_SSE VP8LTransformColorInverseFunc
  66736 
  66737 var VP8LTransformColor_SSE VP8LTransformColorFunc
  66738 
  66739 var VP8LVectorMismatch VP8LVectorMismatchFunc
  66740 
  66741 //------------------------------------------------------------------------------
  66742 // Level cost tables
  66743 
  66744 // C documentation
  66745 //
  66746 //	// fixed costs for coding levels, deduce from the coding tree.
  66747 //	// This is only the part that doesn't depend on the probability state.
  66748 var VP8LevelFixedCosts = [2048]uint16_t{
  66749 	1:    uint16(256),
  66750 	2:    uint16(256),
  66751 	3:    uint16(256),
  66752 	4:    uint16(256),
  66753 	5:    uint16(432),
  66754 	6:    uint16(618),
  66755 	7:    uint16(630),
  66756 	8:    uint16(731),
  66757 	9:    uint16(640),
  66758 	10:   uint16(640),
  66759 	11:   uint16(828),
  66760 	12:   uint16(901),
  66761 	13:   uint16(948),
  66762 	14:   uint16(1021),
  66763 	15:   uint16(1101),
  66764 	16:   uint16(1174),
  66765 	17:   uint16(1221),
  66766 	18:   uint16(1294),
  66767 	19:   uint16(1042),
  66768 	20:   uint16(1085),
  66769 	21:   uint16(1115),
  66770 	22:   uint16(1158),
  66771 	23:   uint16(1202),
  66772 	24:   uint16(1245),
  66773 	25:   uint16(1275),
  66774 	26:   uint16(1318),
  66775 	27:   uint16(1337),
  66776 	28:   uint16(1380),
  66777 	29:   uint16(1410),
  66778 	30:   uint16(1453),
  66779 	31:   uint16(1497),
  66780 	32:   uint16(1540),
  66781 	33:   uint16(1570),
  66782 	34:   uint16(1613),
  66783 	35:   uint16(1280),
  66784 	36:   uint16(1295),
  66785 	37:   uint16(1317),
  66786 	38:   uint16(1332),
  66787 	39:   uint16(1358),
  66788 	40:   uint16(1373),
  66789 	41:   uint16(1395),
  66790 	42:   uint16(1410),
  66791 	43:   uint16(1454),
  66792 	44:   uint16(1469),
  66793 	45:   uint16(1491),
  66794 	46:   uint16(1506),
  66795 	47:   uint16(1532),
  66796 	48:   uint16(1547),
  66797 	49:   uint16(1569),
  66798 	50:   uint16(1584),
  66799 	51:   uint16(1601),
  66800 	52:   uint16(1616),
  66801 	53:   uint16(1638),
  66802 	54:   uint16(1653),
  66803 	55:   uint16(1679),
  66804 	56:   uint16(1694),
  66805 	57:   uint16(1716),
  66806 	58:   uint16(1731),
  66807 	59:   uint16(1775),
  66808 	60:   uint16(1790),
  66809 	61:   uint16(1812),
  66810 	62:   uint16(1827),
  66811 	63:   uint16(1853),
  66812 	64:   uint16(1868),
  66813 	65:   uint16(1890),
  66814 	66:   uint16(1905),
  66815 	67:   uint16(1727),
  66816 	68:   uint16(1733),
  66817 	69:   uint16(1742),
  66818 	70:   uint16(1748),
  66819 	71:   uint16(1759),
  66820 	72:   uint16(1765),
  66821 	73:   uint16(1774),
  66822 	74:   uint16(1780),
  66823 	75:   uint16(1800),
  66824 	76:   uint16(1806),
  66825 	77:   uint16(1815),
  66826 	78:   uint16(1821),
  66827 	79:   uint16(1832),
  66828 	80:   uint16(1838),
  66829 	81:   uint16(1847),
  66830 	82:   uint16(1853),
  66831 	83:   uint16(1878),
  66832 	84:   uint16(1884),
  66833 	85:   uint16(1893),
  66834 	86:   uint16(1899),
  66835 	87:   uint16(1910),
  66836 	88:   uint16(1916),
  66837 	89:   uint16(1925),
  66838 	90:   uint16(1931),
  66839 	91:   uint16(1951),
  66840 	92:   uint16(1957),
  66841 	93:   uint16(1966),
  66842 	94:   uint16(1972),
  66843 	95:   uint16(1983),
  66844 	96:   uint16(1989),
  66845 	97:   uint16(1998),
  66846 	98:   uint16(2004),
  66847 	99:   uint16(2027),
  66848 	100:  uint16(2033),
  66849 	101:  uint16(2042),
  66850 	102:  uint16(2048),
  66851 	103:  uint16(2059),
  66852 	104:  uint16(2065),
  66853 	105:  uint16(2074),
  66854 	106:  uint16(2080),
  66855 	107:  uint16(2100),
  66856 	108:  uint16(2106),
  66857 	109:  uint16(2115),
  66858 	110:  uint16(2121),
  66859 	111:  uint16(2132),
  66860 	112:  uint16(2138),
  66861 	113:  uint16(2147),
  66862 	114:  uint16(2153),
  66863 	115:  uint16(2178),
  66864 	116:  uint16(2184),
  66865 	117:  uint16(2193),
  66866 	118:  uint16(2199),
  66867 	119:  uint16(2210),
  66868 	120:  uint16(2216),
  66869 	121:  uint16(2225),
  66870 	122:  uint16(2231),
  66871 	123:  uint16(2251),
  66872 	124:  uint16(2257),
  66873 	125:  uint16(2266),
  66874 	126:  uint16(2272),
  66875 	127:  uint16(2283),
  66876 	128:  uint16(2289),
  66877 	129:  uint16(2298),
  66878 	130:  uint16(2304),
  66879 	131:  uint16(2168),
  66880 	132:  uint16(2174),
  66881 	133:  uint16(2183),
  66882 	134:  uint16(2189),
  66883 	135:  uint16(2200),
  66884 	136:  uint16(2206),
  66885 	137:  uint16(2215),
  66886 	138:  uint16(2221),
  66887 	139:  uint16(2241),
  66888 	140:  uint16(2247),
  66889 	141:  uint16(2256),
  66890 	142:  uint16(2262),
  66891 	143:  uint16(2273),
  66892 	144:  uint16(2279),
  66893 	145:  uint16(2288),
  66894 	146:  uint16(2294),
  66895 	147:  uint16(2319),
  66896 	148:  uint16(2325),
  66897 	149:  uint16(2334),
  66898 	150:  uint16(2340),
  66899 	151:  uint16(2351),
  66900 	152:  uint16(2357),
  66901 	153:  uint16(2366),
  66902 	154:  uint16(2372),
  66903 	155:  uint16(2392),
  66904 	156:  uint16(2398),
  66905 	157:  uint16(2407),
  66906 	158:  uint16(2413),
  66907 	159:  uint16(2424),
  66908 	160:  uint16(2430),
  66909 	161:  uint16(2439),
  66910 	162:  uint16(2445),
  66911 	163:  uint16(2468),
  66912 	164:  uint16(2474),
  66913 	165:  uint16(2483),
  66914 	166:  uint16(2489),
  66915 	167:  uint16(2500),
  66916 	168:  uint16(2506),
  66917 	169:  uint16(2515),
  66918 	170:  uint16(2521),
  66919 	171:  uint16(2541),
  66920 	172:  uint16(2547),
  66921 	173:  uint16(2556),
  66922 	174:  uint16(2562),
  66923 	175:  uint16(2573),
  66924 	176:  uint16(2579),
  66925 	177:  uint16(2588),
  66926 	178:  uint16(2594),
  66927 	179:  uint16(2619),
  66928 	180:  uint16(2625),
  66929 	181:  uint16(2634),
  66930 	182:  uint16(2640),
  66931 	183:  uint16(2651),
  66932 	184:  uint16(2657),
  66933 	185:  uint16(2666),
  66934 	186:  uint16(2672),
  66935 	187:  uint16(2692),
  66936 	188:  uint16(2698),
  66937 	189:  uint16(2707),
  66938 	190:  uint16(2713),
  66939 	191:  uint16(2724),
  66940 	192:  uint16(2730),
  66941 	193:  uint16(2739),
  66942 	194:  uint16(2745),
  66943 	195:  uint16(2540),
  66944 	196:  uint16(2546),
  66945 	197:  uint16(2555),
  66946 	198:  uint16(2561),
  66947 	199:  uint16(2572),
  66948 	200:  uint16(2578),
  66949 	201:  uint16(2587),
  66950 	202:  uint16(2593),
  66951 	203:  uint16(2613),
  66952 	204:  uint16(2619),
  66953 	205:  uint16(2628),
  66954 	206:  uint16(2634),
  66955 	207:  uint16(2645),
  66956 	208:  uint16(2651),
  66957 	209:  uint16(2660),
  66958 	210:  uint16(2666),
  66959 	211:  uint16(2691),
  66960 	212:  uint16(2697),
  66961 	213:  uint16(2706),
  66962 	214:  uint16(2712),
  66963 	215:  uint16(2723),
  66964 	216:  uint16(2729),
  66965 	217:  uint16(2738),
  66966 	218:  uint16(2744),
  66967 	219:  uint16(2764),
  66968 	220:  uint16(2770),
  66969 	221:  uint16(2779),
  66970 	222:  uint16(2785),
  66971 	223:  uint16(2796),
  66972 	224:  uint16(2802),
  66973 	225:  uint16(2811),
  66974 	226:  uint16(2817),
  66975 	227:  uint16(2840),
  66976 	228:  uint16(2846),
  66977 	229:  uint16(2855),
  66978 	230:  uint16(2861),
  66979 	231:  uint16(2872),
  66980 	232:  uint16(2878),
  66981 	233:  uint16(2887),
  66982 	234:  uint16(2893),
  66983 	235:  uint16(2913),
  66984 	236:  uint16(2919),
  66985 	237:  uint16(2928),
  66986 	238:  uint16(2934),
  66987 	239:  uint16(2945),
  66988 	240:  uint16(2951),
  66989 	241:  uint16(2960),
  66990 	242:  uint16(2966),
  66991 	243:  uint16(2991),
  66992 	244:  uint16(2997),
  66993 	245:  uint16(3006),
  66994 	246:  uint16(3012),
  66995 	247:  uint16(3023),
  66996 	248:  uint16(3029),
  66997 	249:  uint16(3038),
  66998 	250:  uint16(3044),
  66999 	251:  uint16(3064),
  67000 	252:  uint16(3070),
  67001 	253:  uint16(3079),
  67002 	254:  uint16(3085),
  67003 	255:  uint16(3096),
  67004 	256:  uint16(3102),
  67005 	257:  uint16(3111),
  67006 	258:  uint16(3117),
  67007 	259:  uint16(2981),
  67008 	260:  uint16(2987),
  67009 	261:  uint16(2996),
  67010 	262:  uint16(3002),
  67011 	263:  uint16(3013),
  67012 	264:  uint16(3019),
  67013 	265:  uint16(3028),
  67014 	266:  uint16(3034),
  67015 	267:  uint16(3054),
  67016 	268:  uint16(3060),
  67017 	269:  uint16(3069),
  67018 	270:  uint16(3075),
  67019 	271:  uint16(3086),
  67020 	272:  uint16(3092),
  67021 	273:  uint16(3101),
  67022 	274:  uint16(3107),
  67023 	275:  uint16(3132),
  67024 	276:  uint16(3138),
  67025 	277:  uint16(3147),
  67026 	278:  uint16(3153),
  67027 	279:  uint16(3164),
  67028 	280:  uint16(3170),
  67029 	281:  uint16(3179),
  67030 	282:  uint16(3185),
  67031 	283:  uint16(3205),
  67032 	284:  uint16(3211),
  67033 	285:  uint16(3220),
  67034 	286:  uint16(3226),
  67035 	287:  uint16(3237),
  67036 	288:  uint16(3243),
  67037 	289:  uint16(3252),
  67038 	290:  uint16(3258),
  67039 	291:  uint16(3281),
  67040 	292:  uint16(3287),
  67041 	293:  uint16(3296),
  67042 	294:  uint16(3302),
  67043 	295:  uint16(3313),
  67044 	296:  uint16(3319),
  67045 	297:  uint16(3328),
  67046 	298:  uint16(3334),
  67047 	299:  uint16(3354),
  67048 	300:  uint16(3360),
  67049 	301:  uint16(3369),
  67050 	302:  uint16(3375),
  67051 	303:  uint16(3386),
  67052 	304:  uint16(3392),
  67053 	305:  uint16(3401),
  67054 	306:  uint16(3407),
  67055 	307:  uint16(3432),
  67056 	308:  uint16(3438),
  67057 	309:  uint16(3447),
  67058 	310:  uint16(3453),
  67059 	311:  uint16(3464),
  67060 	312:  uint16(3470),
  67061 	313:  uint16(3479),
  67062 	314:  uint16(3485),
  67063 	315:  uint16(3505),
  67064 	316:  uint16(3511),
  67065 	317:  uint16(3520),
  67066 	318:  uint16(3526),
  67067 	319:  uint16(3537),
  67068 	320:  uint16(3543),
  67069 	321:  uint16(3552),
  67070 	322:  uint16(3558),
  67071 	323:  uint16(2816),
  67072 	324:  uint16(2822),
  67073 	325:  uint16(2831),
  67074 	326:  uint16(2837),
  67075 	327:  uint16(2848),
  67076 	328:  uint16(2854),
  67077 	329:  uint16(2863),
  67078 	330:  uint16(2869),
  67079 	331:  uint16(2889),
  67080 	332:  uint16(2895),
  67081 	333:  uint16(2904),
  67082 	334:  uint16(2910),
  67083 	335:  uint16(2921),
  67084 	336:  uint16(2927),
  67085 	337:  uint16(2936),
  67086 	338:  uint16(2942),
  67087 	339:  uint16(2967),
  67088 	340:  uint16(2973),
  67089 	341:  uint16(2982),
  67090 	342:  uint16(2988),
  67091 	343:  uint16(2999),
  67092 	344:  uint16(3005),
  67093 	345:  uint16(3014),
  67094 	346:  uint16(3020),
  67095 	347:  uint16(3040),
  67096 	348:  uint16(3046),
  67097 	349:  uint16(3055),
  67098 	350:  uint16(3061),
  67099 	351:  uint16(3072),
  67100 	352:  uint16(3078),
  67101 	353:  uint16(3087),
  67102 	354:  uint16(3093),
  67103 	355:  uint16(3116),
  67104 	356:  uint16(3122),
  67105 	357:  uint16(3131),
  67106 	358:  uint16(3137),
  67107 	359:  uint16(3148),
  67108 	360:  uint16(3154),
  67109 	361:  uint16(3163),
  67110 	362:  uint16(3169),
  67111 	363:  uint16(3189),
  67112 	364:  uint16(3195),
  67113 	365:  uint16(3204),
  67114 	366:  uint16(3210),
  67115 	367:  uint16(3221),
  67116 	368:  uint16(3227),
  67117 	369:  uint16(3236),
  67118 	370:  uint16(3242),
  67119 	371:  uint16(3267),
  67120 	372:  uint16(3273),
  67121 	373:  uint16(3282),
  67122 	374:  uint16(3288),
  67123 	375:  uint16(3299),
  67124 	376:  uint16(3305),
  67125 	377:  uint16(3314),
  67126 	378:  uint16(3320),
  67127 	379:  uint16(3340),
  67128 	380:  uint16(3346),
  67129 	381:  uint16(3355),
  67130 	382:  uint16(3361),
  67131 	383:  uint16(3372),
  67132 	384:  uint16(3378),
  67133 	385:  uint16(3387),
  67134 	386:  uint16(3393),
  67135 	387:  uint16(3257),
  67136 	388:  uint16(3263),
  67137 	389:  uint16(3272),
  67138 	390:  uint16(3278),
  67139 	391:  uint16(3289),
  67140 	392:  uint16(3295),
  67141 	393:  uint16(3304),
  67142 	394:  uint16(3310),
  67143 	395:  uint16(3330),
  67144 	396:  uint16(3336),
  67145 	397:  uint16(3345),
  67146 	398:  uint16(3351),
  67147 	399:  uint16(3362),
  67148 	400:  uint16(3368),
  67149 	401:  uint16(3377),
  67150 	402:  uint16(3383),
  67151 	403:  uint16(3408),
  67152 	404:  uint16(3414),
  67153 	405:  uint16(3423),
  67154 	406:  uint16(3429),
  67155 	407:  uint16(3440),
  67156 	408:  uint16(3446),
  67157 	409:  uint16(3455),
  67158 	410:  uint16(3461),
  67159 	411:  uint16(3481),
  67160 	412:  uint16(3487),
  67161 	413:  uint16(3496),
  67162 	414:  uint16(3502),
  67163 	415:  uint16(3513),
  67164 	416:  uint16(3519),
  67165 	417:  uint16(3528),
  67166 	418:  uint16(3534),
  67167 	419:  uint16(3557),
  67168 	420:  uint16(3563),
  67169 	421:  uint16(3572),
  67170 	422:  uint16(3578),
  67171 	423:  uint16(3589),
  67172 	424:  uint16(3595),
  67173 	425:  uint16(3604),
  67174 	426:  uint16(3610),
  67175 	427:  uint16(3630),
  67176 	428:  uint16(3636),
  67177 	429:  uint16(3645),
  67178 	430:  uint16(3651),
  67179 	431:  uint16(3662),
  67180 	432:  uint16(3668),
  67181 	433:  uint16(3677),
  67182 	434:  uint16(3683),
  67183 	435:  uint16(3708),
  67184 	436:  uint16(3714),
  67185 	437:  uint16(3723),
  67186 	438:  uint16(3729),
  67187 	439:  uint16(3740),
  67188 	440:  uint16(3746),
  67189 	441:  uint16(3755),
  67190 	442:  uint16(3761),
  67191 	443:  uint16(3781),
  67192 	444:  uint16(3787),
  67193 	445:  uint16(3796),
  67194 	446:  uint16(3802),
  67195 	447:  uint16(3813),
  67196 	448:  uint16(3819),
  67197 	449:  uint16(3828),
  67198 	450:  uint16(3834),
  67199 	451:  uint16(3629),
  67200 	452:  uint16(3635),
  67201 	453:  uint16(3644),
  67202 	454:  uint16(3650),
  67203 	455:  uint16(3661),
  67204 	456:  uint16(3667),
  67205 	457:  uint16(3676),
  67206 	458:  uint16(3682),
  67207 	459:  uint16(3702),
  67208 	460:  uint16(3708),
  67209 	461:  uint16(3717),
  67210 	462:  uint16(3723),
  67211 	463:  uint16(3734),
  67212 	464:  uint16(3740),
  67213 	465:  uint16(3749),
  67214 	466:  uint16(3755),
  67215 	467:  uint16(3780),
  67216 	468:  uint16(3786),
  67217 	469:  uint16(3795),
  67218 	470:  uint16(3801),
  67219 	471:  uint16(3812),
  67220 	472:  uint16(3818),
  67221 	473:  uint16(3827),
  67222 	474:  uint16(3833),
  67223 	475:  uint16(3853),
  67224 	476:  uint16(3859),
  67225 	477:  uint16(3868),
  67226 	478:  uint16(3874),
  67227 	479:  uint16(3885),
  67228 	480:  uint16(3891),
  67229 	481:  uint16(3900),
  67230 	482:  uint16(3906),
  67231 	483:  uint16(3929),
  67232 	484:  uint16(3935),
  67233 	485:  uint16(3944),
  67234 	486:  uint16(3950),
  67235 	487:  uint16(3961),
  67236 	488:  uint16(3967),
  67237 	489:  uint16(3976),
  67238 	490:  uint16(3982),
  67239 	491:  uint16(4002),
  67240 	492:  uint16(4008),
  67241 	493:  uint16(4017),
  67242 	494:  uint16(4023),
  67243 	495:  uint16(4034),
  67244 	496:  uint16(4040),
  67245 	497:  uint16(4049),
  67246 	498:  uint16(4055),
  67247 	499:  uint16(4080),
  67248 	500:  uint16(4086),
  67249 	501:  uint16(4095),
  67250 	502:  uint16(4101),
  67251 	503:  uint16(4112),
  67252 	504:  uint16(4118),
  67253 	505:  uint16(4127),
  67254 	506:  uint16(4133),
  67255 	507:  uint16(4153),
  67256 	508:  uint16(4159),
  67257 	509:  uint16(4168),
  67258 	510:  uint16(4174),
  67259 	511:  uint16(4185),
  67260 	512:  uint16(4191),
  67261 	513:  uint16(4200),
  67262 	514:  uint16(4206),
  67263 	515:  uint16(4070),
  67264 	516:  uint16(4076),
  67265 	517:  uint16(4085),
  67266 	518:  uint16(4091),
  67267 	519:  uint16(4102),
  67268 	520:  uint16(4108),
  67269 	521:  uint16(4117),
  67270 	522:  uint16(4123),
  67271 	523:  uint16(4143),
  67272 	524:  uint16(4149),
  67273 	525:  uint16(4158),
  67274 	526:  uint16(4164),
  67275 	527:  uint16(4175),
  67276 	528:  uint16(4181),
  67277 	529:  uint16(4190),
  67278 	530:  uint16(4196),
  67279 	531:  uint16(4221),
  67280 	532:  uint16(4227),
  67281 	533:  uint16(4236),
  67282 	534:  uint16(4242),
  67283 	535:  uint16(4253),
  67284 	536:  uint16(4259),
  67285 	537:  uint16(4268),
  67286 	538:  uint16(4274),
  67287 	539:  uint16(4294),
  67288 	540:  uint16(4300),
  67289 	541:  uint16(4309),
  67290 	542:  uint16(4315),
  67291 	543:  uint16(4326),
  67292 	544:  uint16(4332),
  67293 	545:  uint16(4341),
  67294 	546:  uint16(4347),
  67295 	547:  uint16(4370),
  67296 	548:  uint16(4376),
  67297 	549:  uint16(4385),
  67298 	550:  uint16(4391),
  67299 	551:  uint16(4402),
  67300 	552:  uint16(4408),
  67301 	553:  uint16(4417),
  67302 	554:  uint16(4423),
  67303 	555:  uint16(4443),
  67304 	556:  uint16(4449),
  67305 	557:  uint16(4458),
  67306 	558:  uint16(4464),
  67307 	559:  uint16(4475),
  67308 	560:  uint16(4481),
  67309 	561:  uint16(4490),
  67310 	562:  uint16(4496),
  67311 	563:  uint16(4521),
  67312 	564:  uint16(4527),
  67313 	565:  uint16(4536),
  67314 	566:  uint16(4542),
  67315 	567:  uint16(4553),
  67316 	568:  uint16(4559),
  67317 	569:  uint16(4568),
  67318 	570:  uint16(4574),
  67319 	571:  uint16(4594),
  67320 	572:  uint16(4600),
  67321 	573:  uint16(4609),
  67322 	574:  uint16(4615),
  67323 	575:  uint16(4626),
  67324 	576:  uint16(4632),
  67325 	577:  uint16(4641),
  67326 	578:  uint16(4647),
  67327 	579:  uint16(3515),
  67328 	580:  uint16(3521),
  67329 	581:  uint16(3530),
  67330 	582:  uint16(3536),
  67331 	583:  uint16(3547),
  67332 	584:  uint16(3553),
  67333 	585:  uint16(3562),
  67334 	586:  uint16(3568),
  67335 	587:  uint16(3588),
  67336 	588:  uint16(3594),
  67337 	589:  uint16(3603),
  67338 	590:  uint16(3609),
  67339 	591:  uint16(3620),
  67340 	592:  uint16(3626),
  67341 	593:  uint16(3635),
  67342 	594:  uint16(3641),
  67343 	595:  uint16(3666),
  67344 	596:  uint16(3672),
  67345 	597:  uint16(3681),
  67346 	598:  uint16(3687),
  67347 	599:  uint16(3698),
  67348 	600:  uint16(3704),
  67349 	601:  uint16(3713),
  67350 	602:  uint16(3719),
  67351 	603:  uint16(3739),
  67352 	604:  uint16(3745),
  67353 	605:  uint16(3754),
  67354 	606:  uint16(3760),
  67355 	607:  uint16(3771),
  67356 	608:  uint16(3777),
  67357 	609:  uint16(3786),
  67358 	610:  uint16(3792),
  67359 	611:  uint16(3815),
  67360 	612:  uint16(3821),
  67361 	613:  uint16(3830),
  67362 	614:  uint16(3836),
  67363 	615:  uint16(3847),
  67364 	616:  uint16(3853),
  67365 	617:  uint16(3862),
  67366 	618:  uint16(3868),
  67367 	619:  uint16(3888),
  67368 	620:  uint16(3894),
  67369 	621:  uint16(3903),
  67370 	622:  uint16(3909),
  67371 	623:  uint16(3920),
  67372 	624:  uint16(3926),
  67373 	625:  uint16(3935),
  67374 	626:  uint16(3941),
  67375 	627:  uint16(3966),
  67376 	628:  uint16(3972),
  67377 	629:  uint16(3981),
  67378 	630:  uint16(3987),
  67379 	631:  uint16(3998),
  67380 	632:  uint16(4004),
  67381 	633:  uint16(4013),
  67382 	634:  uint16(4019),
  67383 	635:  uint16(4039),
  67384 	636:  uint16(4045),
  67385 	637:  uint16(4054),
  67386 	638:  uint16(4060),
  67387 	639:  uint16(4071),
  67388 	640:  uint16(4077),
  67389 	641:  uint16(4086),
  67390 	642:  uint16(4092),
  67391 	643:  uint16(3956),
  67392 	644:  uint16(3962),
  67393 	645:  uint16(3971),
  67394 	646:  uint16(3977),
  67395 	647:  uint16(3988),
  67396 	648:  uint16(3994),
  67397 	649:  uint16(4003),
  67398 	650:  uint16(4009),
  67399 	651:  uint16(4029),
  67400 	652:  uint16(4035),
  67401 	653:  uint16(4044),
  67402 	654:  uint16(4050),
  67403 	655:  uint16(4061),
  67404 	656:  uint16(4067),
  67405 	657:  uint16(4076),
  67406 	658:  uint16(4082),
  67407 	659:  uint16(4107),
  67408 	660:  uint16(4113),
  67409 	661:  uint16(4122),
  67410 	662:  uint16(4128),
  67411 	663:  uint16(4139),
  67412 	664:  uint16(4145),
  67413 	665:  uint16(4154),
  67414 	666:  uint16(4160),
  67415 	667:  uint16(4180),
  67416 	668:  uint16(4186),
  67417 	669:  uint16(4195),
  67418 	670:  uint16(4201),
  67419 	671:  uint16(4212),
  67420 	672:  uint16(4218),
  67421 	673:  uint16(4227),
  67422 	674:  uint16(4233),
  67423 	675:  uint16(4256),
  67424 	676:  uint16(4262),
  67425 	677:  uint16(4271),
  67426 	678:  uint16(4277),
  67427 	679:  uint16(4288),
  67428 	680:  uint16(4294),
  67429 	681:  uint16(4303),
  67430 	682:  uint16(4309),
  67431 	683:  uint16(4329),
  67432 	684:  uint16(4335),
  67433 	685:  uint16(4344),
  67434 	686:  uint16(4350),
  67435 	687:  uint16(4361),
  67436 	688:  uint16(4367),
  67437 	689:  uint16(4376),
  67438 	690:  uint16(4382),
  67439 	691:  uint16(4407),
  67440 	692:  uint16(4413),
  67441 	693:  uint16(4422),
  67442 	694:  uint16(4428),
  67443 	695:  uint16(4439),
  67444 	696:  uint16(4445),
  67445 	697:  uint16(4454),
  67446 	698:  uint16(4460),
  67447 	699:  uint16(4480),
  67448 	700:  uint16(4486),
  67449 	701:  uint16(4495),
  67450 	702:  uint16(4501),
  67451 	703:  uint16(4512),
  67452 	704:  uint16(4518),
  67453 	705:  uint16(4527),
  67454 	706:  uint16(4533),
  67455 	707:  uint16(4328),
  67456 	708:  uint16(4334),
  67457 	709:  uint16(4343),
  67458 	710:  uint16(4349),
  67459 	711:  uint16(4360),
  67460 	712:  uint16(4366),
  67461 	713:  uint16(4375),
  67462 	714:  uint16(4381),
  67463 	715:  uint16(4401),
  67464 	716:  uint16(4407),
  67465 	717:  uint16(4416),
  67466 	718:  uint16(4422),
  67467 	719:  uint16(4433),
  67468 	720:  uint16(4439),
  67469 	721:  uint16(4448),
  67470 	722:  uint16(4454),
  67471 	723:  uint16(4479),
  67472 	724:  uint16(4485),
  67473 	725:  uint16(4494),
  67474 	726:  uint16(4500),
  67475 	727:  uint16(4511),
  67476 	728:  uint16(4517),
  67477 	729:  uint16(4526),
  67478 	730:  uint16(4532),
  67479 	731:  uint16(4552),
  67480 	732:  uint16(4558),
  67481 	733:  uint16(4567),
  67482 	734:  uint16(4573),
  67483 	735:  uint16(4584),
  67484 	736:  uint16(4590),
  67485 	737:  uint16(4599),
  67486 	738:  uint16(4605),
  67487 	739:  uint16(4628),
  67488 	740:  uint16(4634),
  67489 	741:  uint16(4643),
  67490 	742:  uint16(4649),
  67491 	743:  uint16(4660),
  67492 	744:  uint16(4666),
  67493 	745:  uint16(4675),
  67494 	746:  uint16(4681),
  67495 	747:  uint16(4701),
  67496 	748:  uint16(4707),
  67497 	749:  uint16(4716),
  67498 	750:  uint16(4722),
  67499 	751:  uint16(4733),
  67500 	752:  uint16(4739),
  67501 	753:  uint16(4748),
  67502 	754:  uint16(4754),
  67503 	755:  uint16(4779),
  67504 	756:  uint16(4785),
  67505 	757:  uint16(4794),
  67506 	758:  uint16(4800),
  67507 	759:  uint16(4811),
  67508 	760:  uint16(4817),
  67509 	761:  uint16(4826),
  67510 	762:  uint16(4832),
  67511 	763:  uint16(4852),
  67512 	764:  uint16(4858),
  67513 	765:  uint16(4867),
  67514 	766:  uint16(4873),
  67515 	767:  uint16(4884),
  67516 	768:  uint16(4890),
  67517 	769:  uint16(4899),
  67518 	770:  uint16(4905),
  67519 	771:  uint16(4769),
  67520 	772:  uint16(4775),
  67521 	773:  uint16(4784),
  67522 	774:  uint16(4790),
  67523 	775:  uint16(4801),
  67524 	776:  uint16(4807),
  67525 	777:  uint16(4816),
  67526 	778:  uint16(4822),
  67527 	779:  uint16(4842),
  67528 	780:  uint16(4848),
  67529 	781:  uint16(4857),
  67530 	782:  uint16(4863),
  67531 	783:  uint16(4874),
  67532 	784:  uint16(4880),
  67533 	785:  uint16(4889),
  67534 	786:  uint16(4895),
  67535 	787:  uint16(4920),
  67536 	788:  uint16(4926),
  67537 	789:  uint16(4935),
  67538 	790:  uint16(4941),
  67539 	791:  uint16(4952),
  67540 	792:  uint16(4958),
  67541 	793:  uint16(4967),
  67542 	794:  uint16(4973),
  67543 	795:  uint16(4993),
  67544 	796:  uint16(4999),
  67545 	797:  uint16(5008),
  67546 	798:  uint16(5014),
  67547 	799:  uint16(5025),
  67548 	800:  uint16(5031),
  67549 	801:  uint16(5040),
  67550 	802:  uint16(5046),
  67551 	803:  uint16(5069),
  67552 	804:  uint16(5075),
  67553 	805:  uint16(5084),
  67554 	806:  uint16(5090),
  67555 	807:  uint16(5101),
  67556 	808:  uint16(5107),
  67557 	809:  uint16(5116),
  67558 	810:  uint16(5122),
  67559 	811:  uint16(5142),
  67560 	812:  uint16(5148),
  67561 	813:  uint16(5157),
  67562 	814:  uint16(5163),
  67563 	815:  uint16(5174),
  67564 	816:  uint16(5180),
  67565 	817:  uint16(5189),
  67566 	818:  uint16(5195),
  67567 	819:  uint16(5220),
  67568 	820:  uint16(5226),
  67569 	821:  uint16(5235),
  67570 	822:  uint16(5241),
  67571 	823:  uint16(5252),
  67572 	824:  uint16(5258),
  67573 	825:  uint16(5267),
  67574 	826:  uint16(5273),
  67575 	827:  uint16(5293),
  67576 	828:  uint16(5299),
  67577 	829:  uint16(5308),
  67578 	830:  uint16(5314),
  67579 	831:  uint16(5325),
  67580 	832:  uint16(5331),
  67581 	833:  uint16(5340),
  67582 	834:  uint16(5346),
  67583 	835:  uint16(4604),
  67584 	836:  uint16(4610),
  67585 	837:  uint16(4619),
  67586 	838:  uint16(4625),
  67587 	839:  uint16(4636),
  67588 	840:  uint16(4642),
  67589 	841:  uint16(4651),
  67590 	842:  uint16(4657),
  67591 	843:  uint16(4677),
  67592 	844:  uint16(4683),
  67593 	845:  uint16(4692),
  67594 	846:  uint16(4698),
  67595 	847:  uint16(4709),
  67596 	848:  uint16(4715),
  67597 	849:  uint16(4724),
  67598 	850:  uint16(4730),
  67599 	851:  uint16(4755),
  67600 	852:  uint16(4761),
  67601 	853:  uint16(4770),
  67602 	854:  uint16(4776),
  67603 	855:  uint16(4787),
  67604 	856:  uint16(4793),
  67605 	857:  uint16(4802),
  67606 	858:  uint16(4808),
  67607 	859:  uint16(4828),
  67608 	860:  uint16(4834),
  67609 	861:  uint16(4843),
  67610 	862:  uint16(4849),
  67611 	863:  uint16(4860),
  67612 	864:  uint16(4866),
  67613 	865:  uint16(4875),
  67614 	866:  uint16(4881),
  67615 	867:  uint16(4904),
  67616 	868:  uint16(4910),
  67617 	869:  uint16(4919),
  67618 	870:  uint16(4925),
  67619 	871:  uint16(4936),
  67620 	872:  uint16(4942),
  67621 	873:  uint16(4951),
  67622 	874:  uint16(4957),
  67623 	875:  uint16(4977),
  67624 	876:  uint16(4983),
  67625 	877:  uint16(4992),
  67626 	878:  uint16(4998),
  67627 	879:  uint16(5009),
  67628 	880:  uint16(5015),
  67629 	881:  uint16(5024),
  67630 	882:  uint16(5030),
  67631 	883:  uint16(5055),
  67632 	884:  uint16(5061),
  67633 	885:  uint16(5070),
  67634 	886:  uint16(5076),
  67635 	887:  uint16(5087),
  67636 	888:  uint16(5093),
  67637 	889:  uint16(5102),
  67638 	890:  uint16(5108),
  67639 	891:  uint16(5128),
  67640 	892:  uint16(5134),
  67641 	893:  uint16(5143),
  67642 	894:  uint16(5149),
  67643 	895:  uint16(5160),
  67644 	896:  uint16(5166),
  67645 	897:  uint16(5175),
  67646 	898:  uint16(5181),
  67647 	899:  uint16(5045),
  67648 	900:  uint16(5051),
  67649 	901:  uint16(5060),
  67650 	902:  uint16(5066),
  67651 	903:  uint16(5077),
  67652 	904:  uint16(5083),
  67653 	905:  uint16(5092),
  67654 	906:  uint16(5098),
  67655 	907:  uint16(5118),
  67656 	908:  uint16(5124),
  67657 	909:  uint16(5133),
  67658 	910:  uint16(5139),
  67659 	911:  uint16(5150),
  67660 	912:  uint16(5156),
  67661 	913:  uint16(5165),
  67662 	914:  uint16(5171),
  67663 	915:  uint16(5196),
  67664 	916:  uint16(5202),
  67665 	917:  uint16(5211),
  67666 	918:  uint16(5217),
  67667 	919:  uint16(5228),
  67668 	920:  uint16(5234),
  67669 	921:  uint16(5243),
  67670 	922:  uint16(5249),
  67671 	923:  uint16(5269),
  67672 	924:  uint16(5275),
  67673 	925:  uint16(5284),
  67674 	926:  uint16(5290),
  67675 	927:  uint16(5301),
  67676 	928:  uint16(5307),
  67677 	929:  uint16(5316),
  67678 	930:  uint16(5322),
  67679 	931:  uint16(5345),
  67680 	932:  uint16(5351),
  67681 	933:  uint16(5360),
  67682 	934:  uint16(5366),
  67683 	935:  uint16(5377),
  67684 	936:  uint16(5383),
  67685 	937:  uint16(5392),
  67686 	938:  uint16(5398),
  67687 	939:  uint16(5418),
  67688 	940:  uint16(5424),
  67689 	941:  uint16(5433),
  67690 	942:  uint16(5439),
  67691 	943:  uint16(5450),
  67692 	944:  uint16(5456),
  67693 	945:  uint16(5465),
  67694 	946:  uint16(5471),
  67695 	947:  uint16(5496),
  67696 	948:  uint16(5502),
  67697 	949:  uint16(5511),
  67698 	950:  uint16(5517),
  67699 	951:  uint16(5528),
  67700 	952:  uint16(5534),
  67701 	953:  uint16(5543),
  67702 	954:  uint16(5549),
  67703 	955:  uint16(5569),
  67704 	956:  uint16(5575),
  67705 	957:  uint16(5584),
  67706 	958:  uint16(5590),
  67707 	959:  uint16(5601),
  67708 	960:  uint16(5607),
  67709 	961:  uint16(5616),
  67710 	962:  uint16(5622),
  67711 	963:  uint16(5417),
  67712 	964:  uint16(5423),
  67713 	965:  uint16(5432),
  67714 	966:  uint16(5438),
  67715 	967:  uint16(5449),
  67716 	968:  uint16(5455),
  67717 	969:  uint16(5464),
  67718 	970:  uint16(5470),
  67719 	971:  uint16(5490),
  67720 	972:  uint16(5496),
  67721 	973:  uint16(5505),
  67722 	974:  uint16(5511),
  67723 	975:  uint16(5522),
  67724 	976:  uint16(5528),
  67725 	977:  uint16(5537),
  67726 	978:  uint16(5543),
  67727 	979:  uint16(5568),
  67728 	980:  uint16(5574),
  67729 	981:  uint16(5583),
  67730 	982:  uint16(5589),
  67731 	983:  uint16(5600),
  67732 	984:  uint16(5606),
  67733 	985:  uint16(5615),
  67734 	986:  uint16(5621),
  67735 	987:  uint16(5641),
  67736 	988:  uint16(5647),
  67737 	989:  uint16(5656),
  67738 	990:  uint16(5662),
  67739 	991:  uint16(5673),
  67740 	992:  uint16(5679),
  67741 	993:  uint16(5688),
  67742 	994:  uint16(5694),
  67743 	995:  uint16(5717),
  67744 	996:  uint16(5723),
  67745 	997:  uint16(5732),
  67746 	998:  uint16(5738),
  67747 	999:  uint16(5749),
  67748 	1000: uint16(5755),
  67749 	1001: uint16(5764),
  67750 	1002: uint16(5770),
  67751 	1003: uint16(5790),
  67752 	1004: uint16(5796),
  67753 	1005: uint16(5805),
  67754 	1006: uint16(5811),
  67755 	1007: uint16(5822),
  67756 	1008: uint16(5828),
  67757 	1009: uint16(5837),
  67758 	1010: uint16(5843),
  67759 	1011: uint16(5868),
  67760 	1012: uint16(5874),
  67761 	1013: uint16(5883),
  67762 	1014: uint16(5889),
  67763 	1015: uint16(5900),
  67764 	1016: uint16(5906),
  67765 	1017: uint16(5915),
  67766 	1018: uint16(5921),
  67767 	1019: uint16(5941),
  67768 	1020: uint16(5947),
  67769 	1021: uint16(5956),
  67770 	1022: uint16(5962),
  67771 	1023: uint16(5973),
  67772 	1024: uint16(5979),
  67773 	1025: uint16(5988),
  67774 	1026: uint16(5994),
  67775 	1027: uint16(5858),
  67776 	1028: uint16(5864),
  67777 	1029: uint16(5873),
  67778 	1030: uint16(5879),
  67779 	1031: uint16(5890),
  67780 	1032: uint16(5896),
  67781 	1033: uint16(5905),
  67782 	1034: uint16(5911),
  67783 	1035: uint16(5931),
  67784 	1036: uint16(5937),
  67785 	1037: uint16(5946),
  67786 	1038: uint16(5952),
  67787 	1039: uint16(5963),
  67788 	1040: uint16(5969),
  67789 	1041: uint16(5978),
  67790 	1042: uint16(5984),
  67791 	1043: uint16(6009),
  67792 	1044: uint16(6015),
  67793 	1045: uint16(6024),
  67794 	1046: uint16(6030),
  67795 	1047: uint16(6041),
  67796 	1048: uint16(6047),
  67797 	1049: uint16(6056),
  67798 	1050: uint16(6062),
  67799 	1051: uint16(6082),
  67800 	1052: uint16(6088),
  67801 	1053: uint16(6097),
  67802 	1054: uint16(6103),
  67803 	1055: uint16(6114),
  67804 	1056: uint16(6120),
  67805 	1057: uint16(6129),
  67806 	1058: uint16(6135),
  67807 	1059: uint16(6158),
  67808 	1060: uint16(6164),
  67809 	1061: uint16(6173),
  67810 	1062: uint16(6179),
  67811 	1063: uint16(6190),
  67812 	1064: uint16(6196),
  67813 	1065: uint16(6205),
  67814 	1066: uint16(6211),
  67815 	1067: uint16(6231),
  67816 	1068: uint16(6237),
  67817 	1069: uint16(6246),
  67818 	1070: uint16(6252),
  67819 	1071: uint16(6263),
  67820 	1072: uint16(6269),
  67821 	1073: uint16(6278),
  67822 	1074: uint16(6284),
  67823 	1075: uint16(6309),
  67824 	1076: uint16(6315),
  67825 	1077: uint16(6324),
  67826 	1078: uint16(6330),
  67827 	1079: uint16(6341),
  67828 	1080: uint16(6347),
  67829 	1081: uint16(6356),
  67830 	1082: uint16(6362),
  67831 	1083: uint16(6382),
  67832 	1084: uint16(6388),
  67833 	1085: uint16(6397),
  67834 	1086: uint16(6403),
  67835 	1087: uint16(6414),
  67836 	1088: uint16(6420),
  67837 	1089: uint16(6429),
  67838 	1090: uint16(6435),
  67839 	1091: uint16(3515),
  67840 	1092: uint16(3521),
  67841 	1093: uint16(3530),
  67842 	1094: uint16(3536),
  67843 	1095: uint16(3547),
  67844 	1096: uint16(3553),
  67845 	1097: uint16(3562),
  67846 	1098: uint16(3568),
  67847 	1099: uint16(3588),
  67848 	1100: uint16(3594),
  67849 	1101: uint16(3603),
  67850 	1102: uint16(3609),
  67851 	1103: uint16(3620),
  67852 	1104: uint16(3626),
  67853 	1105: uint16(3635),
  67854 	1106: uint16(3641),
  67855 	1107: uint16(3666),
  67856 	1108: uint16(3672),
  67857 	1109: uint16(3681),
  67858 	1110: uint16(3687),
  67859 	1111: uint16(3698),
  67860 	1112: uint16(3704),
  67861 	1113: uint16(3713),
  67862 	1114: uint16(3719),
  67863 	1115: uint16(3739),
  67864 	1116: uint16(3745),
  67865 	1117: uint16(3754),
  67866 	1118: uint16(3760),
  67867 	1119: uint16(3771),
  67868 	1120: uint16(3777),
  67869 	1121: uint16(3786),
  67870 	1122: uint16(3792),
  67871 	1123: uint16(3815),
  67872 	1124: uint16(3821),
  67873 	1125: uint16(3830),
  67874 	1126: uint16(3836),
  67875 	1127: uint16(3847),
  67876 	1128: uint16(3853),
  67877 	1129: uint16(3862),
  67878 	1130: uint16(3868),
  67879 	1131: uint16(3888),
  67880 	1132: uint16(3894),
  67881 	1133: uint16(3903),
  67882 	1134: uint16(3909),
  67883 	1135: uint16(3920),
  67884 	1136: uint16(3926),
  67885 	1137: uint16(3935),
  67886 	1138: uint16(3941),
  67887 	1139: uint16(3966),
  67888 	1140: uint16(3972),
  67889 	1141: uint16(3981),
  67890 	1142: uint16(3987),
  67891 	1143: uint16(3998),
  67892 	1144: uint16(4004),
  67893 	1145: uint16(4013),
  67894 	1146: uint16(4019),
  67895 	1147: uint16(4039),
  67896 	1148: uint16(4045),
  67897 	1149: uint16(4054),
  67898 	1150: uint16(4060),
  67899 	1151: uint16(4071),
  67900 	1152: uint16(4077),
  67901 	1153: uint16(4086),
  67902 	1154: uint16(4092),
  67903 	1155: uint16(3956),
  67904 	1156: uint16(3962),
  67905 	1157: uint16(3971),
  67906 	1158: uint16(3977),
  67907 	1159: uint16(3988),
  67908 	1160: uint16(3994),
  67909 	1161: uint16(4003),
  67910 	1162: uint16(4009),
  67911 	1163: uint16(4029),
  67912 	1164: uint16(4035),
  67913 	1165: uint16(4044),
  67914 	1166: uint16(4050),
  67915 	1167: uint16(4061),
  67916 	1168: uint16(4067),
  67917 	1169: uint16(4076),
  67918 	1170: uint16(4082),
  67919 	1171: uint16(4107),
  67920 	1172: uint16(4113),
  67921 	1173: uint16(4122),
  67922 	1174: uint16(4128),
  67923 	1175: uint16(4139),
  67924 	1176: uint16(4145),
  67925 	1177: uint16(4154),
  67926 	1178: uint16(4160),
  67927 	1179: uint16(4180),
  67928 	1180: uint16(4186),
  67929 	1181: uint16(4195),
  67930 	1182: uint16(4201),
  67931 	1183: uint16(4212),
  67932 	1184: uint16(4218),
  67933 	1185: uint16(4227),
  67934 	1186: uint16(4233),
  67935 	1187: uint16(4256),
  67936 	1188: uint16(4262),
  67937 	1189: uint16(4271),
  67938 	1190: uint16(4277),
  67939 	1191: uint16(4288),
  67940 	1192: uint16(4294),
  67941 	1193: uint16(4303),
  67942 	1194: uint16(4309),
  67943 	1195: uint16(4329),
  67944 	1196: uint16(4335),
  67945 	1197: uint16(4344),
  67946 	1198: uint16(4350),
  67947 	1199: uint16(4361),
  67948 	1200: uint16(4367),
  67949 	1201: uint16(4376),
  67950 	1202: uint16(4382),
  67951 	1203: uint16(4407),
  67952 	1204: uint16(4413),
  67953 	1205: uint16(4422),
  67954 	1206: uint16(4428),
  67955 	1207: uint16(4439),
  67956 	1208: uint16(4445),
  67957 	1209: uint16(4454),
  67958 	1210: uint16(4460),
  67959 	1211: uint16(4480),
  67960 	1212: uint16(4486),
  67961 	1213: uint16(4495),
  67962 	1214: uint16(4501),
  67963 	1215: uint16(4512),
  67964 	1216: uint16(4518),
  67965 	1217: uint16(4527),
  67966 	1218: uint16(4533),
  67967 	1219: uint16(4328),
  67968 	1220: uint16(4334),
  67969 	1221: uint16(4343),
  67970 	1222: uint16(4349),
  67971 	1223: uint16(4360),
  67972 	1224: uint16(4366),
  67973 	1225: uint16(4375),
  67974 	1226: uint16(4381),
  67975 	1227: uint16(4401),
  67976 	1228: uint16(4407),
  67977 	1229: uint16(4416),
  67978 	1230: uint16(4422),
  67979 	1231: uint16(4433),
  67980 	1232: uint16(4439),
  67981 	1233: uint16(4448),
  67982 	1234: uint16(4454),
  67983 	1235: uint16(4479),
  67984 	1236: uint16(4485),
  67985 	1237: uint16(4494),
  67986 	1238: uint16(4500),
  67987 	1239: uint16(4511),
  67988 	1240: uint16(4517),
  67989 	1241: uint16(4526),
  67990 	1242: uint16(4532),
  67991 	1243: uint16(4552),
  67992 	1244: uint16(4558),
  67993 	1245: uint16(4567),
  67994 	1246: uint16(4573),
  67995 	1247: uint16(4584),
  67996 	1248: uint16(4590),
  67997 	1249: uint16(4599),
  67998 	1250: uint16(4605),
  67999 	1251: uint16(4628),
  68000 	1252: uint16(4634),
  68001 	1253: uint16(4643),
  68002 	1254: uint16(4649),
  68003 	1255: uint16(4660),
  68004 	1256: uint16(4666),
  68005 	1257: uint16(4675),
  68006 	1258: uint16(4681),
  68007 	1259: uint16(4701),
  68008 	1260: uint16(4707),
  68009 	1261: uint16(4716),
  68010 	1262: uint16(4722),
  68011 	1263: uint16(4733),
  68012 	1264: uint16(4739),
  68013 	1265: uint16(4748),
  68014 	1266: uint16(4754),
  68015 	1267: uint16(4779),
  68016 	1268: uint16(4785),
  68017 	1269: uint16(4794),
  68018 	1270: uint16(4800),
  68019 	1271: uint16(4811),
  68020 	1272: uint16(4817),
  68021 	1273: uint16(4826),
  68022 	1274: uint16(4832),
  68023 	1275: uint16(4852),
  68024 	1276: uint16(4858),
  68025 	1277: uint16(4867),
  68026 	1278: uint16(4873),
  68027 	1279: uint16(4884),
  68028 	1280: uint16(4890),
  68029 	1281: uint16(4899),
  68030 	1282: uint16(4905),
  68031 	1283: uint16(4769),
  68032 	1284: uint16(4775),
  68033 	1285: uint16(4784),
  68034 	1286: uint16(4790),
  68035 	1287: uint16(4801),
  68036 	1288: uint16(4807),
  68037 	1289: uint16(4816),
  68038 	1290: uint16(4822),
  68039 	1291: uint16(4842),
  68040 	1292: uint16(4848),
  68041 	1293: uint16(4857),
  68042 	1294: uint16(4863),
  68043 	1295: uint16(4874),
  68044 	1296: uint16(4880),
  68045 	1297: uint16(4889),
  68046 	1298: uint16(4895),
  68047 	1299: uint16(4920),
  68048 	1300: uint16(4926),
  68049 	1301: uint16(4935),
  68050 	1302: uint16(4941),
  68051 	1303: uint16(4952),
  68052 	1304: uint16(4958),
  68053 	1305: uint16(4967),
  68054 	1306: uint16(4973),
  68055 	1307: uint16(4993),
  68056 	1308: uint16(4999),
  68057 	1309: uint16(5008),
  68058 	1310: uint16(5014),
  68059 	1311: uint16(5025),
  68060 	1312: uint16(5031),
  68061 	1313: uint16(5040),
  68062 	1314: uint16(5046),
  68063 	1315: uint16(5069),
  68064 	1316: uint16(5075),
  68065 	1317: uint16(5084),
  68066 	1318: uint16(5090),
  68067 	1319: uint16(5101),
  68068 	1320: uint16(5107),
  68069 	1321: uint16(5116),
  68070 	1322: uint16(5122),
  68071 	1323: uint16(5142),
  68072 	1324: uint16(5148),
  68073 	1325: uint16(5157),
  68074 	1326: uint16(5163),
  68075 	1327: uint16(5174),
  68076 	1328: uint16(5180),
  68077 	1329: uint16(5189),
  68078 	1330: uint16(5195),
  68079 	1331: uint16(5220),
  68080 	1332: uint16(5226),
  68081 	1333: uint16(5235),
  68082 	1334: uint16(5241),
  68083 	1335: uint16(5252),
  68084 	1336: uint16(5258),
  68085 	1337: uint16(5267),
  68086 	1338: uint16(5273),
  68087 	1339: uint16(5293),
  68088 	1340: uint16(5299),
  68089 	1341: uint16(5308),
  68090 	1342: uint16(5314),
  68091 	1343: uint16(5325),
  68092 	1344: uint16(5331),
  68093 	1345: uint16(5340),
  68094 	1346: uint16(5346),
  68095 	1347: uint16(4604),
  68096 	1348: uint16(4610),
  68097 	1349: uint16(4619),
  68098 	1350: uint16(4625),
  68099 	1351: uint16(4636),
  68100 	1352: uint16(4642),
  68101 	1353: uint16(4651),
  68102 	1354: uint16(4657),
  68103 	1355: uint16(4677),
  68104 	1356: uint16(4683),
  68105 	1357: uint16(4692),
  68106 	1358: uint16(4698),
  68107 	1359: uint16(4709),
  68108 	1360: uint16(4715),
  68109 	1361: uint16(4724),
  68110 	1362: uint16(4730),
  68111 	1363: uint16(4755),
  68112 	1364: uint16(4761),
  68113 	1365: uint16(4770),
  68114 	1366: uint16(4776),
  68115 	1367: uint16(4787),
  68116 	1368: uint16(4793),
  68117 	1369: uint16(4802),
  68118 	1370: uint16(4808),
  68119 	1371: uint16(4828),
  68120 	1372: uint16(4834),
  68121 	1373: uint16(4843),
  68122 	1374: uint16(4849),
  68123 	1375: uint16(4860),
  68124 	1376: uint16(4866),
  68125 	1377: uint16(4875),
  68126 	1378: uint16(4881),
  68127 	1379: uint16(4904),
  68128 	1380: uint16(4910),
  68129 	1381: uint16(4919),
  68130 	1382: uint16(4925),
  68131 	1383: uint16(4936),
  68132 	1384: uint16(4942),
  68133 	1385: uint16(4951),
  68134 	1386: uint16(4957),
  68135 	1387: uint16(4977),
  68136 	1388: uint16(4983),
  68137 	1389: uint16(4992),
  68138 	1390: uint16(4998),
  68139 	1391: uint16(5009),
  68140 	1392: uint16(5015),
  68141 	1393: uint16(5024),
  68142 	1394: uint16(5030),
  68143 	1395: uint16(5055),
  68144 	1396: uint16(5061),
  68145 	1397: uint16(5070),
  68146 	1398: uint16(5076),
  68147 	1399: uint16(5087),
  68148 	1400: uint16(5093),
  68149 	1401: uint16(5102),
  68150 	1402: uint16(5108),
  68151 	1403: uint16(5128),
  68152 	1404: uint16(5134),
  68153 	1405: uint16(5143),
  68154 	1406: uint16(5149),
  68155 	1407: uint16(5160),
  68156 	1408: uint16(5166),
  68157 	1409: uint16(5175),
  68158 	1410: uint16(5181),
  68159 	1411: uint16(5045),
  68160 	1412: uint16(5051),
  68161 	1413: uint16(5060),
  68162 	1414: uint16(5066),
  68163 	1415: uint16(5077),
  68164 	1416: uint16(5083),
  68165 	1417: uint16(5092),
  68166 	1418: uint16(5098),
  68167 	1419: uint16(5118),
  68168 	1420: uint16(5124),
  68169 	1421: uint16(5133),
  68170 	1422: uint16(5139),
  68171 	1423: uint16(5150),
  68172 	1424: uint16(5156),
  68173 	1425: uint16(5165),
  68174 	1426: uint16(5171),
  68175 	1427: uint16(5196),
  68176 	1428: uint16(5202),
  68177 	1429: uint16(5211),
  68178 	1430: uint16(5217),
  68179 	1431: uint16(5228),
  68180 	1432: uint16(5234),
  68181 	1433: uint16(5243),
  68182 	1434: uint16(5249),
  68183 	1435: uint16(5269),
  68184 	1436: uint16(5275),
  68185 	1437: uint16(5284),
  68186 	1438: uint16(5290),
  68187 	1439: uint16(5301),
  68188 	1440: uint16(5307),
  68189 	1441: uint16(5316),
  68190 	1442: uint16(5322),
  68191 	1443: uint16(5345),
  68192 	1444: uint16(5351),
  68193 	1445: uint16(5360),
  68194 	1446: uint16(5366),
  68195 	1447: uint16(5377),
  68196 	1448: uint16(5383),
  68197 	1449: uint16(5392),
  68198 	1450: uint16(5398),
  68199 	1451: uint16(5418),
  68200 	1452: uint16(5424),
  68201 	1453: uint16(5433),
  68202 	1454: uint16(5439),
  68203 	1455: uint16(5450),
  68204 	1456: uint16(5456),
  68205 	1457: uint16(5465),
  68206 	1458: uint16(5471),
  68207 	1459: uint16(5496),
  68208 	1460: uint16(5502),
  68209 	1461: uint16(5511),
  68210 	1462: uint16(5517),
  68211 	1463: uint16(5528),
  68212 	1464: uint16(5534),
  68213 	1465: uint16(5543),
  68214 	1466: uint16(5549),
  68215 	1467: uint16(5569),
  68216 	1468: uint16(5575),
  68217 	1469: uint16(5584),
  68218 	1470: uint16(5590),
  68219 	1471: uint16(5601),
  68220 	1472: uint16(5607),
  68221 	1473: uint16(5616),
  68222 	1474: uint16(5622),
  68223 	1475: uint16(5417),
  68224 	1476: uint16(5423),
  68225 	1477: uint16(5432),
  68226 	1478: uint16(5438),
  68227 	1479: uint16(5449),
  68228 	1480: uint16(5455),
  68229 	1481: uint16(5464),
  68230 	1482: uint16(5470),
  68231 	1483: uint16(5490),
  68232 	1484: uint16(5496),
  68233 	1485: uint16(5505),
  68234 	1486: uint16(5511),
  68235 	1487: uint16(5522),
  68236 	1488: uint16(5528),
  68237 	1489: uint16(5537),
  68238 	1490: uint16(5543),
  68239 	1491: uint16(5568),
  68240 	1492: uint16(5574),
  68241 	1493: uint16(5583),
  68242 	1494: uint16(5589),
  68243 	1495: uint16(5600),
  68244 	1496: uint16(5606),
  68245 	1497: uint16(5615),
  68246 	1498: uint16(5621),
  68247 	1499: uint16(5641),
  68248 	1500: uint16(5647),
  68249 	1501: uint16(5656),
  68250 	1502: uint16(5662),
  68251 	1503: uint16(5673),
  68252 	1504: uint16(5679),
  68253 	1505: uint16(5688),
  68254 	1506: uint16(5694),
  68255 	1507: uint16(5717),
  68256 	1508: uint16(5723),
  68257 	1509: uint16(5732),
  68258 	1510: uint16(5738),
  68259 	1511: uint16(5749),
  68260 	1512: uint16(5755),
  68261 	1513: uint16(5764),
  68262 	1514: uint16(5770),
  68263 	1515: uint16(5790),
  68264 	1516: uint16(5796),
  68265 	1517: uint16(5805),
  68266 	1518: uint16(5811),
  68267 	1519: uint16(5822),
  68268 	1520: uint16(5828),
  68269 	1521: uint16(5837),
  68270 	1522: uint16(5843),
  68271 	1523: uint16(5868),
  68272 	1524: uint16(5874),
  68273 	1525: uint16(5883),
  68274 	1526: uint16(5889),
  68275 	1527: uint16(5900),
  68276 	1528: uint16(5906),
  68277 	1529: uint16(5915),
  68278 	1530: uint16(5921),
  68279 	1531: uint16(5941),
  68280 	1532: uint16(5947),
  68281 	1533: uint16(5956),
  68282 	1534: uint16(5962),
  68283 	1535: uint16(5973),
  68284 	1536: uint16(5979),
  68285 	1537: uint16(5988),
  68286 	1538: uint16(5994),
  68287 	1539: uint16(5858),
  68288 	1540: uint16(5864),
  68289 	1541: uint16(5873),
  68290 	1542: uint16(5879),
  68291 	1543: uint16(5890),
  68292 	1544: uint16(5896),
  68293 	1545: uint16(5905),
  68294 	1546: uint16(5911),
  68295 	1547: uint16(5931),
  68296 	1548: uint16(5937),
  68297 	1549: uint16(5946),
  68298 	1550: uint16(5952),
  68299 	1551: uint16(5963),
  68300 	1552: uint16(5969),
  68301 	1553: uint16(5978),
  68302 	1554: uint16(5984),
  68303 	1555: uint16(6009),
  68304 	1556: uint16(6015),
  68305 	1557: uint16(6024),
  68306 	1558: uint16(6030),
  68307 	1559: uint16(6041),
  68308 	1560: uint16(6047),
  68309 	1561: uint16(6056),
  68310 	1562: uint16(6062),
  68311 	1563: uint16(6082),
  68312 	1564: uint16(6088),
  68313 	1565: uint16(6097),
  68314 	1566: uint16(6103),
  68315 	1567: uint16(6114),
  68316 	1568: uint16(6120),
  68317 	1569: uint16(6129),
  68318 	1570: uint16(6135),
  68319 	1571: uint16(6158),
  68320 	1572: uint16(6164),
  68321 	1573: uint16(6173),
  68322 	1574: uint16(6179),
  68323 	1575: uint16(6190),
  68324 	1576: uint16(6196),
  68325 	1577: uint16(6205),
  68326 	1578: uint16(6211),
  68327 	1579: uint16(6231),
  68328 	1580: uint16(6237),
  68329 	1581: uint16(6246),
  68330 	1582: uint16(6252),
  68331 	1583: uint16(6263),
  68332 	1584: uint16(6269),
  68333 	1585: uint16(6278),
  68334 	1586: uint16(6284),
  68335 	1587: uint16(6309),
  68336 	1588: uint16(6315),
  68337 	1589: uint16(6324),
  68338 	1590: uint16(6330),
  68339 	1591: uint16(6341),
  68340 	1592: uint16(6347),
  68341 	1593: uint16(6356),
  68342 	1594: uint16(6362),
  68343 	1595: uint16(6382),
  68344 	1596: uint16(6388),
  68345 	1597: uint16(6397),
  68346 	1598: uint16(6403),
  68347 	1599: uint16(6414),
  68348 	1600: uint16(6420),
  68349 	1601: uint16(6429),
  68350 	1602: uint16(6435),
  68351 	1603: uint16(5303),
  68352 	1604: uint16(5309),
  68353 	1605: uint16(5318),
  68354 	1606: uint16(5324),
  68355 	1607: uint16(5335),
  68356 	1608: uint16(5341),
  68357 	1609: uint16(5350),
  68358 	1610: uint16(5356),
  68359 	1611: uint16(5376),
  68360 	1612: uint16(5382),
  68361 	1613: uint16(5391),
  68362 	1614: uint16(5397),
  68363 	1615: uint16(5408),
  68364 	1616: uint16(5414),
  68365 	1617: uint16(5423),
  68366 	1618: uint16(5429),
  68367 	1619: uint16(5454),
  68368 	1620: uint16(5460),
  68369 	1621: uint16(5469),
  68370 	1622: uint16(5475),
  68371 	1623: uint16(5486),
  68372 	1624: uint16(5492),
  68373 	1625: uint16(5501),
  68374 	1626: uint16(5507),
  68375 	1627: uint16(5527),
  68376 	1628: uint16(5533),
  68377 	1629: uint16(5542),
  68378 	1630: uint16(5548),
  68379 	1631: uint16(5559),
  68380 	1632: uint16(5565),
  68381 	1633: uint16(5574),
  68382 	1634: uint16(5580),
  68383 	1635: uint16(5603),
  68384 	1636: uint16(5609),
  68385 	1637: uint16(5618),
  68386 	1638: uint16(5624),
  68387 	1639: uint16(5635),
  68388 	1640: uint16(5641),
  68389 	1641: uint16(5650),
  68390 	1642: uint16(5656),
  68391 	1643: uint16(5676),
  68392 	1644: uint16(5682),
  68393 	1645: uint16(5691),
  68394 	1646: uint16(5697),
  68395 	1647: uint16(5708),
  68396 	1648: uint16(5714),
  68397 	1649: uint16(5723),
  68398 	1650: uint16(5729),
  68399 	1651: uint16(5754),
  68400 	1652: uint16(5760),
  68401 	1653: uint16(5769),
  68402 	1654: uint16(5775),
  68403 	1655: uint16(5786),
  68404 	1656: uint16(5792),
  68405 	1657: uint16(5801),
  68406 	1658: uint16(5807),
  68407 	1659: uint16(5827),
  68408 	1660: uint16(5833),
  68409 	1661: uint16(5842),
  68410 	1662: uint16(5848),
  68411 	1663: uint16(5859),
  68412 	1664: uint16(5865),
  68413 	1665: uint16(5874),
  68414 	1666: uint16(5880),
  68415 	1667: uint16(5744),
  68416 	1668: uint16(5750),
  68417 	1669: uint16(5759),
  68418 	1670: uint16(5765),
  68419 	1671: uint16(5776),
  68420 	1672: uint16(5782),
  68421 	1673: uint16(5791),
  68422 	1674: uint16(5797),
  68423 	1675: uint16(5817),
  68424 	1676: uint16(5823),
  68425 	1677: uint16(5832),
  68426 	1678: uint16(5838),
  68427 	1679: uint16(5849),
  68428 	1680: uint16(5855),
  68429 	1681: uint16(5864),
  68430 	1682: uint16(5870),
  68431 	1683: uint16(5895),
  68432 	1684: uint16(5901),
  68433 	1685: uint16(5910),
  68434 	1686: uint16(5916),
  68435 	1687: uint16(5927),
  68436 	1688: uint16(5933),
  68437 	1689: uint16(5942),
  68438 	1690: uint16(5948),
  68439 	1691: uint16(5968),
  68440 	1692: uint16(5974),
  68441 	1693: uint16(5983),
  68442 	1694: uint16(5989),
  68443 	1695: uint16(6000),
  68444 	1696: uint16(6006),
  68445 	1697: uint16(6015),
  68446 	1698: uint16(6021),
  68447 	1699: uint16(6044),
  68448 	1700: uint16(6050),
  68449 	1701: uint16(6059),
  68450 	1702: uint16(6065),
  68451 	1703: uint16(6076),
  68452 	1704: uint16(6082),
  68453 	1705: uint16(6091),
  68454 	1706: uint16(6097),
  68455 	1707: uint16(6117),
  68456 	1708: uint16(6123),
  68457 	1709: uint16(6132),
  68458 	1710: uint16(6138),
  68459 	1711: uint16(6149),
  68460 	1712: uint16(6155),
  68461 	1713: uint16(6164),
  68462 	1714: uint16(6170),
  68463 	1715: uint16(6195),
  68464 	1716: uint16(6201),
  68465 	1717: uint16(6210),
  68466 	1718: uint16(6216),
  68467 	1719: uint16(6227),
  68468 	1720: uint16(6233),
  68469 	1721: uint16(6242),
  68470 	1722: uint16(6248),
  68471 	1723: uint16(6268),
  68472 	1724: uint16(6274),
  68473 	1725: uint16(6283),
  68474 	1726: uint16(6289),
  68475 	1727: uint16(6300),
  68476 	1728: uint16(6306),
  68477 	1729: uint16(6315),
  68478 	1730: uint16(6321),
  68479 	1731: uint16(6116),
  68480 	1732: uint16(6122),
  68481 	1733: uint16(6131),
  68482 	1734: uint16(6137),
  68483 	1735: uint16(6148),
  68484 	1736: uint16(6154),
  68485 	1737: uint16(6163),
  68486 	1738: uint16(6169),
  68487 	1739: uint16(6189),
  68488 	1740: uint16(6195),
  68489 	1741: uint16(6204),
  68490 	1742: uint16(6210),
  68491 	1743: uint16(6221),
  68492 	1744: uint16(6227),
  68493 	1745: uint16(6236),
  68494 	1746: uint16(6242),
  68495 	1747: uint16(6267),
  68496 	1748: uint16(6273),
  68497 	1749: uint16(6282),
  68498 	1750: uint16(6288),
  68499 	1751: uint16(6299),
  68500 	1752: uint16(6305),
  68501 	1753: uint16(6314),
  68502 	1754: uint16(6320),
  68503 	1755: uint16(6340),
  68504 	1756: uint16(6346),
  68505 	1757: uint16(6355),
  68506 	1758: uint16(6361),
  68507 	1759: uint16(6372),
  68508 	1760: uint16(6378),
  68509 	1761: uint16(6387),
  68510 	1762: uint16(6393),
  68511 	1763: uint16(6416),
  68512 	1764: uint16(6422),
  68513 	1765: uint16(6431),
  68514 	1766: uint16(6437),
  68515 	1767: uint16(6448),
  68516 	1768: uint16(6454),
  68517 	1769: uint16(6463),
  68518 	1770: uint16(6469),
  68519 	1771: uint16(6489),
  68520 	1772: uint16(6495),
  68521 	1773: uint16(6504),
  68522 	1774: uint16(6510),
  68523 	1775: uint16(6521),
  68524 	1776: uint16(6527),
  68525 	1777: uint16(6536),
  68526 	1778: uint16(6542),
  68527 	1779: uint16(6567),
  68528 	1780: uint16(6573),
  68529 	1781: uint16(6582),
  68530 	1782: uint16(6588),
  68531 	1783: uint16(6599),
  68532 	1784: uint16(6605),
  68533 	1785: uint16(6614),
  68534 	1786: uint16(6620),
  68535 	1787: uint16(6640),
  68536 	1788: uint16(6646),
  68537 	1789: uint16(6655),
  68538 	1790: uint16(6661),
  68539 	1791: uint16(6672),
  68540 	1792: uint16(6678),
  68541 	1793: uint16(6687),
  68542 	1794: uint16(6693),
  68543 	1795: uint16(6557),
  68544 	1796: uint16(6563),
  68545 	1797: uint16(6572),
  68546 	1798: uint16(6578),
  68547 	1799: uint16(6589),
  68548 	1800: uint16(6595),
  68549 	1801: uint16(6604),
  68550 	1802: uint16(6610),
  68551 	1803: uint16(6630),
  68552 	1804: uint16(6636),
  68553 	1805: uint16(6645),
  68554 	1806: uint16(6651),
  68555 	1807: uint16(6662),
  68556 	1808: uint16(6668),
  68557 	1809: uint16(6677),
  68558 	1810: uint16(6683),
  68559 	1811: uint16(6708),
  68560 	1812: uint16(6714),
  68561 	1813: uint16(6723),
  68562 	1814: uint16(6729),
  68563 	1815: uint16(6740),
  68564 	1816: uint16(6746),
  68565 	1817: uint16(6755),
  68566 	1818: uint16(6761),
  68567 	1819: uint16(6781),
  68568 	1820: uint16(6787),
  68569 	1821: uint16(6796),
  68570 	1822: uint16(6802),
  68571 	1823: uint16(6813),
  68572 	1824: uint16(6819),
  68573 	1825: uint16(6828),
  68574 	1826: uint16(6834),
  68575 	1827: uint16(6857),
  68576 	1828: uint16(6863),
  68577 	1829: uint16(6872),
  68578 	1830: uint16(6878),
  68579 	1831: uint16(6889),
  68580 	1832: uint16(6895),
  68581 	1833: uint16(6904),
  68582 	1834: uint16(6910),
  68583 	1835: uint16(6930),
  68584 	1836: uint16(6936),
  68585 	1837: uint16(6945),
  68586 	1838: uint16(6951),
  68587 	1839: uint16(6962),
  68588 	1840: uint16(6968),
  68589 	1841: uint16(6977),
  68590 	1842: uint16(6983),
  68591 	1843: uint16(7008),
  68592 	1844: uint16(7014),
  68593 	1845: uint16(7023),
  68594 	1846: uint16(7029),
  68595 	1847: uint16(7040),
  68596 	1848: uint16(7046),
  68597 	1849: uint16(7055),
  68598 	1850: uint16(7061),
  68599 	1851: uint16(7081),
  68600 	1852: uint16(7087),
  68601 	1853: uint16(7096),
  68602 	1854: uint16(7102),
  68603 	1855: uint16(7113),
  68604 	1856: uint16(7119),
  68605 	1857: uint16(7128),
  68606 	1858: uint16(7134),
  68607 	1859: uint16(6392),
  68608 	1860: uint16(6398),
  68609 	1861: uint16(6407),
  68610 	1862: uint16(6413),
  68611 	1863: uint16(6424),
  68612 	1864: uint16(6430),
  68613 	1865: uint16(6439),
  68614 	1866: uint16(6445),
  68615 	1867: uint16(6465),
  68616 	1868: uint16(6471),
  68617 	1869: uint16(6480),
  68618 	1870: uint16(6486),
  68619 	1871: uint16(6497),
  68620 	1872: uint16(6503),
  68621 	1873: uint16(6512),
  68622 	1874: uint16(6518),
  68623 	1875: uint16(6543),
  68624 	1876: uint16(6549),
  68625 	1877: uint16(6558),
  68626 	1878: uint16(6564),
  68627 	1879: uint16(6575),
  68628 	1880: uint16(6581),
  68629 	1881: uint16(6590),
  68630 	1882: uint16(6596),
  68631 	1883: uint16(6616),
  68632 	1884: uint16(6622),
  68633 	1885: uint16(6631),
  68634 	1886: uint16(6637),
  68635 	1887: uint16(6648),
  68636 	1888: uint16(6654),
  68637 	1889: uint16(6663),
  68638 	1890: uint16(6669),
  68639 	1891: uint16(6692),
  68640 	1892: uint16(6698),
  68641 	1893: uint16(6707),
  68642 	1894: uint16(6713),
  68643 	1895: uint16(6724),
  68644 	1896: uint16(6730),
  68645 	1897: uint16(6739),
  68646 	1898: uint16(6745),
  68647 	1899: uint16(6765),
  68648 	1900: uint16(6771),
  68649 	1901: uint16(6780),
  68650 	1902: uint16(6786),
  68651 	1903: uint16(6797),
  68652 	1904: uint16(6803),
  68653 	1905: uint16(6812),
  68654 	1906: uint16(6818),
  68655 	1907: uint16(6843),
  68656 	1908: uint16(6849),
  68657 	1909: uint16(6858),
  68658 	1910: uint16(6864),
  68659 	1911: uint16(6875),
  68660 	1912: uint16(6881),
  68661 	1913: uint16(6890),
  68662 	1914: uint16(6896),
  68663 	1915: uint16(6916),
  68664 	1916: uint16(6922),
  68665 	1917: uint16(6931),
  68666 	1918: uint16(6937),
  68667 	1919: uint16(6948),
  68668 	1920: uint16(6954),
  68669 	1921: uint16(6963),
  68670 	1922: uint16(6969),
  68671 	1923: uint16(6833),
  68672 	1924: uint16(6839),
  68673 	1925: uint16(6848),
  68674 	1926: uint16(6854),
  68675 	1927: uint16(6865),
  68676 	1928: uint16(6871),
  68677 	1929: uint16(6880),
  68678 	1930: uint16(6886),
  68679 	1931: uint16(6906),
  68680 	1932: uint16(6912),
  68681 	1933: uint16(6921),
  68682 	1934: uint16(6927),
  68683 	1935: uint16(6938),
  68684 	1936: uint16(6944),
  68685 	1937: uint16(6953),
  68686 	1938: uint16(6959),
  68687 	1939: uint16(6984),
  68688 	1940: uint16(6990),
  68689 	1941: uint16(6999),
  68690 	1942: uint16(7005),
  68691 	1943: uint16(7016),
  68692 	1944: uint16(7022),
  68693 	1945: uint16(7031),
  68694 	1946: uint16(7037),
  68695 	1947: uint16(7057),
  68696 	1948: uint16(7063),
  68697 	1949: uint16(7072),
  68698 	1950: uint16(7078),
  68699 	1951: uint16(7089),
  68700 	1952: uint16(7095),
  68701 	1953: uint16(7104),
  68702 	1954: uint16(7110),
  68703 	1955: uint16(7133),
  68704 	1956: uint16(7139),
  68705 	1957: uint16(7148),
  68706 	1958: uint16(7154),
  68707 	1959: uint16(7165),
  68708 	1960: uint16(7171),
  68709 	1961: uint16(7180),
  68710 	1962: uint16(7186),
  68711 	1963: uint16(7206),
  68712 	1964: uint16(7212),
  68713 	1965: uint16(7221),
  68714 	1966: uint16(7227),
  68715 	1967: uint16(7238),
  68716 	1968: uint16(7244),
  68717 	1969: uint16(7253),
  68718 	1970: uint16(7259),
  68719 	1971: uint16(7284),
  68720 	1972: uint16(7290),
  68721 	1973: uint16(7299),
  68722 	1974: uint16(7305),
  68723 	1975: uint16(7316),
  68724 	1976: uint16(7322),
  68725 	1977: uint16(7331),
  68726 	1978: uint16(7337),
  68727 	1979: uint16(7357),
  68728 	1980: uint16(7363),
  68729 	1981: uint16(7372),
  68730 	1982: uint16(7378),
  68731 	1983: uint16(7389),
  68732 	1984: uint16(7395),
  68733 	1985: uint16(7404),
  68734 	1986: uint16(7410),
  68735 	1987: uint16(7205),
  68736 	1988: uint16(7211),
  68737 	1989: uint16(7220),
  68738 	1990: uint16(7226),
  68739 	1991: uint16(7237),
  68740 	1992: uint16(7243),
  68741 	1993: uint16(7252),
  68742 	1994: uint16(7258),
  68743 	1995: uint16(7278),
  68744 	1996: uint16(7284),
  68745 	1997: uint16(7293),
  68746 	1998: uint16(7299),
  68747 	1999: uint16(7310),
  68748 	2000: uint16(7316),
  68749 	2001: uint16(7325),
  68750 	2002: uint16(7331),
  68751 	2003: uint16(7356),
  68752 	2004: uint16(7362),
  68753 	2005: uint16(7371),
  68754 	2006: uint16(7377),
  68755 	2007: uint16(7388),
  68756 	2008: uint16(7394),
  68757 	2009: uint16(7403),
  68758 	2010: uint16(7409),
  68759 	2011: uint16(7429),
  68760 	2012: uint16(7435),
  68761 	2013: uint16(7444),
  68762 	2014: uint16(7450),
  68763 	2015: uint16(7461),
  68764 	2016: uint16(7467),
  68765 	2017: uint16(7476),
  68766 	2018: uint16(7482),
  68767 	2019: uint16(7505),
  68768 	2020: uint16(7511),
  68769 	2021: uint16(7520),
  68770 	2022: uint16(7526),
  68771 	2023: uint16(7537),
  68772 	2024: uint16(7543),
  68773 	2025: uint16(7552),
  68774 	2026: uint16(7558),
  68775 	2027: uint16(7578),
  68776 	2028: uint16(7584),
  68777 	2029: uint16(7593),
  68778 	2030: uint16(7599),
  68779 	2031: uint16(7610),
  68780 	2032: uint16(7616),
  68781 	2033: uint16(7625),
  68782 	2034: uint16(7631),
  68783 	2035: uint16(7656),
  68784 	2036: uint16(7662),
  68785 	2037: uint16(7671),
  68786 	2038: uint16(7677),
  68787 	2039: uint16(7688),
  68788 	2040: uint16(7694),
  68789 	2041: uint16(7703),
  68790 	2042: uint16(7709),
  68791 	2043: uint16(7729),
  68792 	2044: uint16(7735),
  68793 	2045: uint16(7744),
  68794 	2046: uint16(7750),
  68795 	2047: uint16(7761),
  68796 }
  68797 
  68798 var VP8Mean16x4 VP8MeanMetric
  68799 
  68800 var VP8PredChroma8 [7]VP8PredFunc
  68801 
  68802 var VP8PredLuma16 [7]VP8PredFunc
  68803 
  68804 var VP8PredLuma4 [10]VP8PredFunc
  68805 
  68806 var VP8SSE16x16 VP8Metric
  68807 
  68808 var VP8SSE16x8 VP8Metric
  68809 
  68810 var VP8SSE4x4 VP8Metric
  68811 
  68812 var VP8SSE8x8 VP8Metric
  68813 
  68814 //------------------------------------------------------------------------------
  68815 
  68816 var VP8SSIMGet VP8SSIMGetFunc
  68817 
  68818 var VP8SSIMGetClipped VP8SSIMGetClippedFunc
  68819 
  68820 //------------------------------------------------------------------------------
  68821 // Quantize
  68822 
  68823 // Layout:
  68824 // +----+----+
  68825 // |YYYY|UUVV| 0
  68826 // |YYYY|UUVV| 4
  68827 // |YYYY|....| 8
  68828 // |YYYY|....| 12
  68829 // +----+----+
  68830 
  68831 var VP8Scan = [16]uint16_t{
  68832 	1:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68833 	2:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68834 	3:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(0)*libc.Int32FromInt32(BPS)),
  68835 	4:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68836 	5:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68837 	6:  libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68838 	7:  libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(4)*libc.Int32FromInt32(BPS)),
  68839 	8:  libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68840 	9:  libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68841 	10: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68842 	11: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68843 	12: libc.Uint16FromInt32(libc.Int32FromInt32(0) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68844 	13: libc.Uint16FromInt32(libc.Int32FromInt32(4) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68845 	14: libc.Uint16FromInt32(libc.Int32FromInt32(8) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68846 	15: libc.Uint16FromInt32(libc.Int32FromInt32(12) + libc.Int32FromInt32(12)*libc.Int32FromInt32(BPS)),
  68847 }
  68848 
  68849 var VP8SetResidualCoeffs VP8SetResidualCoeffsFunc
  68850 
  68851 var VP8SimpleHFilter16 VP8SimpleFilterFunc
  68852 
  68853 var VP8SimpleHFilter16i VP8SimpleFilterFunc
  68854 
  68855 var VP8SimpleVFilter16 VP8SimpleFilterFunc
  68856 
  68857 var VP8SimpleVFilter16i VP8SimpleFilterFunc
  68858 
  68859 var VP8TDisto16x16 VP8WMetric
  68860 
  68861 var VP8TDisto4x4 VP8WMetric
  68862 
  68863 //------------------------------------------------------------------------------
  68864 
  68865 var VP8Transform VP8DecIdct2
  68866 
  68867 var VP8TransformAC3 VP8DecIdct
  68868 
  68869 var VP8TransformDC VP8DecIdct
  68870 
  68871 var VP8TransformDCUV VP8DecIdct
  68872 
  68873 var VP8TransformUV VP8DecIdct
  68874 
  68875 var VP8TransformWHT VP8WHT
  68876 
  68877 var VP8UVModeOffsets = [4]uint16_t{
  68878 	0: libc.Uint16FromInt32(libc.Int32FromInt32(2) * libc.Int32FromInt32(16) * libc.Int32FromInt32(BPS)),
  68879 	1: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(1)*libc.Int32FromInt32(16)),
  68880 	2: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS)),
  68881 	3: libc.Uint16FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(16)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(8)*libc.Int32FromInt32(BPS) + libc.Int32FromInt32(1)*libc.Int32FromInt32(16)),
  68882 }
  68883 
  68884 var VP8VFilter16 VP8LumaFilterFunc
  68885 
  68886 var VP8VFilter16i VP8LumaFilterFunc
  68887 
  68888 var VP8VFilter8 VP8ChromaFilterFunc
  68889 
  68890 var VP8VFilter8i VP8ChromaFilterFunc
  68891 
  68892 var VP8kabs0 = uintptr(unsafe.Pointer(&abs0)) + 255
  68893 
  68894 var VP8kclip1 = uintptr(unsafe.Pointer(&clip11)) + 255
  68895 
  68896 var VP8ksclip1 = uintptr(unsafe.Pointer(&sclip1)) + 1020
  68897 
  68898 var VP8ksclip2 = uintptr(unsafe.Pointer(&sclip2)) + 112
  68899 
  68900 var WebPAlphaReplace uintptr
  68901 
  68902 var WebPApplyAlphaMultiply uintptr
  68903 
  68904 var WebPApplyAlphaMultiply4444 uintptr
  68905 
  68906 var WebPConvertARGBToUV uintptr
  68907 
  68908 var WebPConvertARGBToY uintptr
  68909 
  68910 var WebPConvertBGR24ToY uintptr
  68911 
  68912 //-----------------------------------------------------------------------------
  68913 
  68914 var WebPConvertRGB24ToY uintptr
  68915 
  68916 var WebPConvertRGBA32ToUV uintptr
  68917 
  68918 var WebPDispatchAlpha uintptr
  68919 
  68920 var WebPDispatchAlphaToGreen uintptr
  68921 
  68922 var WebPExtractAlpha uintptr
  68923 
  68924 var WebPExtractGreen uintptr
  68925 
  68926 //------------------------------------------------------------------------------
  68927 // Init function
  68928 
  68929 var WebPFilters [4]WebPFilterFunc
  68930 
  68931 var WebPHasAlpha32b uintptr
  68932 
  68933 var WebPHasAlpha8b uintptr
  68934 
  68935 var WebPMultARGBRow uintptr
  68936 
  68937 var WebPMultRow uintptr
  68938 
  68939 var WebPPackRGB uintptr
  68940 
  68941 var WebPRescalerExportRowExpand WebPRescalerExportRowFunc
  68942 
  68943 var WebPRescalerExportRowShrink WebPRescalerExportRowFunc
  68944 
  68945 //------------------------------------------------------------------------------
  68946 
  68947 var WebPRescalerImportRowExpand WebPRescalerImportRowFunc
  68948 
  68949 var WebPRescalerImportRowShrink WebPRescalerImportRowFunc
  68950 
  68951 //-----------------------------------------------------------------------------
  68952 // Main call
  68953 
  68954 var WebPSamplers [13]WebPSamplerRowFunc
  68955 
  68956 var WebPUnfilters [4]WebPUnfilterFunc
  68957 
  68958 // Copyright 2010 Google Inc. All Rights Reserved.
  68959 //
  68960 // Use of this source code is governed by a BSD-style license
  68961 // that can be found in the COPYING file in the root of the source
  68962 // tree. An additional intellectual property rights grant can be found
  68963 // in the file PATENTS. All contributing project authors may
  68964 // be found in the AUTHORS file in the root of the source tree.
  68965 // -----------------------------------------------------------------------------
  68966 //
  68967 //  Main decoding functions for WebP images.
  68968 //
  68969 // Author: Skal (pascal.massimino@gmail.com)
  68970 
  68971 //------------------------------------------------------------------------------
  68972 // Fancy upsampler
  68973 
  68974 // C documentation
  68975 //
  68976 //	// Fancy upsampling functions to convert YUV to RGB
  68977 var WebPUpsamplers [13]WebPUpsampleLinePairFunc
  68978 
  68979 var WebPYUV444Converters [13]WebPYUV444Converter
  68980 
  68981 // Copyright 2012 Google Inc. All Rights Reserved.
  68982 //
  68983 // Use of this source code is governed by a BSD-style license
  68984 // that can be found in the COPYING file in the root of the source
  68985 // tree. An additional intellectual property rights grant can be found
  68986 // in the file PATENTS. All contributing project authors may
  68987 // be found in the AUTHORS file in the root of the source tree.
  68988 // -----------------------------------------------------------------------------
  68989 //
  68990 // Misc. common utility functions
  68991 //
  68992 // Authors: Skal (pascal.massimino@gmail.com)
  68993 //          Urvang (urvang@google.com)
  68994 
  68995 // Copyright 2012 Google Inc. All Rights Reserved.
  68996 //
  68997 // Use of this source code is governed by a BSD-style license
  68998 // that can be found in the COPYING file in the root of the source
  68999 // tree. An additional intellectual property rights grant can be found
  69000 // in the file PATENTS. All contributing project authors may
  69001 // be found in the AUTHORS file in the root of the source tree.
  69002 // -----------------------------------------------------------------------------
  69003 //
  69004 //  Internal header for constants related to WebP file format.
  69005 //
  69006 // Author: Urvang (urvang@google.com)
  69007 
  69008 // Copyright 2010 Google Inc. All Rights Reserved.
  69009 //
  69010 // Use of this source code is governed by a BSD-style license
  69011 // that can be found in the COPYING file in the root of the source
  69012 // tree. An additional intellectual property rights grant can be found
  69013 // in the file PATENTS. All contributing project authors may
  69014 // be found in the AUTHORS file in the root of the source tree.
  69015 // -----------------------------------------------------------------------------
  69016 //
  69017 //  Common types + memory wrappers
  69018 //
  69019 // Author: Skal (pascal.massimino@gmail.com)
  69020 
  69021 // C documentation
  69022 //
  69023 //	// lookup table for small values of log2(int) * (1 << LOG_2_PRECISION_BITS).
  69024 //	// Obtained in Python with:
  69025 //	// a = [ str(round((1<<23)*math.log2(i))) if i else "0" for i in range(256)]
  69026 //	// print(',\n'.join(['  '+','.join(v)
  69027 //	//       for v in batched([i.rjust(9) for i in a],7)]))
  69028 var kLog2Table = [256]uint32_t{
  69029 	2:   uint32(8388608),
  69030 	3:   uint32(13295629),
  69031 	4:   uint32(16777216),
  69032 	5:   uint32(19477745),
  69033 	6:   uint32(21684237),
  69034 	7:   uint32(23549800),
  69035 	8:   uint32(25165824),
  69036 	9:   uint32(26591258),
  69037 	10:  uint32(27866353),
  69038 	11:  uint32(29019816),
  69039 	12:  uint32(30072845),
  69040 	13:  uint32(31041538),
  69041 	14:  uint32(31938408),
  69042 	15:  uint32(32773374),
  69043 	16:  uint32(33554432),
  69044 	17:  uint32(34288123),
  69045 	18:  uint32(34979866),
  69046 	19:  uint32(35634199),
  69047 	20:  uint32(36254961),
  69048 	21:  uint32(36845429),
  69049 	22:  uint32(37408424),
  69050 	23:  uint32(37946388),
  69051 	24:  uint32(38461453),
  69052 	25:  uint32(38955489),
  69053 	26:  uint32(39430146),
  69054 	27:  uint32(39886887),
  69055 	28:  uint32(40327016),
  69056 	29:  uint32(40751698),
  69057 	30:  uint32(41161982),
  69058 	31:  uint32(41558811),
  69059 	32:  uint32(41943040),
  69060 	33:  uint32(42315445),
  69061 	34:  uint32(42676731),
  69062 	35:  uint32(43027545),
  69063 	36:  uint32(43368474),
  69064 	37:  uint32(43700062),
  69065 	38:  uint32(44022807),
  69066 	39:  uint32(44337167),
  69067 	40:  uint32(44643569),
  69068 	41:  uint32(44942404),
  69069 	42:  uint32(45234037),
  69070 	43:  uint32(45518808),
  69071 	44:  uint32(45797032),
  69072 	45:  uint32(46069003),
  69073 	46:  uint32(46334996),
  69074 	47:  uint32(46595268),
  69075 	48:  uint32(46850061),
  69076 	49:  uint32(47099600),
  69077 	50:  uint32(47344097),
  69078 	51:  uint32(47583753),
  69079 	52:  uint32(47818754),
  69080 	53:  uint32(48049279),
  69081 	54:  uint32(48275495),
  69082 	55:  uint32(48497560),
  69083 	56:  uint32(48715624),
  69084 	57:  uint32(48929828),
  69085 	58:  uint32(49140306),
  69086 	59:  uint32(49347187),
  69087 	60:  uint32(49550590),
  69088 	61:  uint32(49750631),
  69089 	62:  uint32(49947419),
  69090 	63:  uint32(50141058),
  69091 	64:  uint32(50331648),
  69092 	65:  uint32(50519283),
  69093 	66:  uint32(50704053),
  69094 	67:  uint32(50886044),
  69095 	68:  uint32(51065339),
  69096 	69:  uint32(51242017),
  69097 	70:  uint32(51416153),
  69098 	71:  uint32(51587818),
  69099 	72:  uint32(51757082),
  69100 	73:  uint32(51924012),
  69101 	74:  uint32(52088670),
  69102 	75:  uint32(52251118),
  69103 	76:  uint32(52411415),
  69104 	77:  uint32(52569616),
  69105 	78:  uint32(52725775),
  69106 	79:  uint32(52879946),
  69107 	80:  uint32(53032177),
  69108 	81:  uint32(53182516),
  69109 	82:  uint32(53331012),
  69110 	83:  uint32(53477707),
  69111 	84:  uint32(53622645),
  69112 	85:  uint32(53765868),
  69113 	86:  uint32(53907416),
  69114 	87:  uint32(54047327),
  69115 	88:  uint32(54185640),
  69116 	89:  uint32(54322389),
  69117 	90:  uint32(54457611),
  69118 	91:  uint32(54591338),
  69119 	92:  uint32(54723604),
  69120 	93:  uint32(54854440),
  69121 	94:  uint32(54983876),
  69122 	95:  uint32(55111943),
  69123 	96:  uint32(55238669),
  69124 	97:  uint32(55364082),
  69125 	98:  uint32(55488208),
  69126 	99:  uint32(55611074),
  69127 	100: uint32(55732705),
  69128 	101: uint32(55853126),
  69129 	102: uint32(55972361),
  69130 	103: uint32(56090432),
  69131 	104: uint32(56207362),
  69132 	105: uint32(56323174),
  69133 	106: uint32(56437887),
  69134 	107: uint32(56551524),
  69135 	108: uint32(56664103),
  69136 	109: uint32(56775645),
  69137 	110: uint32(56886168),
  69138 	111: uint32(56995691),
  69139 	112: uint32(57104232),
  69140 	113: uint32(57211808),
  69141 	114: uint32(57318436),
  69142 	115: uint32(57424133),
  69143 	116: uint32(57528914),
  69144 	117: uint32(57632796),
  69145 	118: uint32(57735795),
  69146 	119: uint32(57837923),
  69147 	120: uint32(57939198),
  69148 	121: uint32(58039632),
  69149 	122: uint32(58139239),
  69150 	123: uint32(58238033),
  69151 	124: uint32(58336027),
  69152 	125: uint32(58433234),
  69153 	126: uint32(58529666),
  69154 	127: uint32(58625336),
  69155 	128: uint32(58720256),
  69156 	129: uint32(58814437),
  69157 	130: uint32(58907891),
  69158 	131: uint32(59000628),
  69159 	132: uint32(59092661),
  69160 	133: uint32(59183999),
  69161 	134: uint32(59274652),
  69162 	135: uint32(59364632),
  69163 	136: uint32(59453947),
  69164 	137: uint32(59542609),
  69165 	138: uint32(59630625),
  69166 	139: uint32(59718006),
  69167 	140: uint32(59804761),
  69168 	141: uint32(59890898),
  69169 	142: uint32(59976426),
  69170 	143: uint32(60061354),
  69171 	144: uint32(60145690),
  69172 	145: uint32(60229443),
  69173 	146: uint32(60312620),
  69174 	147: uint32(60395229),
  69175 	148: uint32(60477278),
  69176 	149: uint32(60558775),
  69177 	150: uint32(60639726),
  69178 	151: uint32(60720140),
  69179 	152: uint32(60800023),
  69180 	153: uint32(60879382),
  69181 	154: uint32(60958224),
  69182 	155: uint32(61036555),
  69183 	156: uint32(61114383),
  69184 	157: uint32(61191714),
  69185 	158: uint32(61268554),
  69186 	159: uint32(61344908),
  69187 	160: uint32(61420785),
  69188 	161: uint32(61496188),
  69189 	162: uint32(61571124),
  69190 	163: uint32(61645600),
  69191 	164: uint32(61719620),
  69192 	165: uint32(61793189),
  69193 	166: uint32(61866315),
  69194 	167: uint32(61939001),
  69195 	168: uint32(62011253),
  69196 	169: uint32(62083076),
  69197 	170: uint32(62154476),
  69198 	171: uint32(62225457),
  69199 	172: uint32(62296024),
  69200 	173: uint32(62366182),
  69201 	174: uint32(62435935),
  69202 	175: uint32(62505289),
  69203 	176: uint32(62574248),
  69204 	177: uint32(62642816),
  69205 	178: uint32(62710997),
  69206 	179: uint32(62778797),
  69207 	180: uint32(62846219),
  69208 	181: uint32(62913267),
  69209 	182: uint32(62979946),
  69210 	183: uint32(63046260),
  69211 	184: uint32(63112212),
  69212 	185: uint32(63177807),
  69213 	186: uint32(63243048),
  69214 	187: uint32(63307939),
  69215 	188: uint32(63372484),
  69216 	189: uint32(63436687),
  69217 	190: uint32(63500551),
  69218 	191: uint32(63564080),
  69219 	192: uint32(63627277),
  69220 	193: uint32(63690146),
  69221 	194: uint32(63752690),
  69222 	195: uint32(63814912),
  69223 	196: uint32(63876816),
  69224 	197: uint32(63938405),
  69225 	198: uint32(63999682),
  69226 	199: uint32(64060650),
  69227 	200: uint32(64121313),
  69228 	201: uint32(64181673),
  69229 	202: uint32(64241734),
  69230 	203: uint32(64301498),
  69231 	204: uint32(64360969),
  69232 	205: uint32(64420148),
  69233 	206: uint32(64479040),
  69234 	207: uint32(64537646),
  69235 	208: uint32(64595970),
  69236 	209: uint32(64654014),
  69237 	210: uint32(64711782),
  69238 	211: uint32(64769274),
  69239 	212: uint32(64826495),
  69240 	213: uint32(64883447),
  69241 	214: uint32(64940132),
  69242 	215: uint32(64996553),
  69243 	216: uint32(65052711),
  69244 	217: uint32(65108611),
  69245 	218: uint32(65164253),
  69246 	219: uint32(65219641),
  69247 	220: uint32(65274776),
  69248 	221: uint32(65329662),
  69249 	222: uint32(65384299),
  69250 	223: uint32(65438691),
  69251 	224: uint32(65492840),
  69252 	225: uint32(65546747),
  69253 	226: uint32(65600416),
  69254 	227: uint32(65653847),
  69255 	228: uint32(65707044),
  69256 	229: uint32(65760008),
  69257 	230: uint32(65812741),
  69258 	231: uint32(65865245),
  69259 	232: uint32(65917522),
  69260 	233: uint32(65969575),
  69261 	234: uint32(66021404),
  69262 	235: uint32(66073013),
  69263 	236: uint32(66124403),
  69264 	237: uint32(66175575),
  69265 	238: uint32(66226531),
  69266 	239: uint32(66277275),
  69267 	240: uint32(66327806),
  69268 	241: uint32(66378127),
  69269 	242: uint32(66428240),
  69270 	243: uint32(66478146),
  69271 	244: uint32(66527847),
  69272 	245: uint32(66577345),
  69273 	246: uint32(66626641),
  69274 	247: uint32(66675737),
  69275 	248: uint32(66724635),
  69276 	249: uint32(66773336),
  69277 	250: uint32(66821842),
  69278 	251: uint32(66870154),
  69279 	252: uint32(66918274),
  69280 	253: uint32(66966204),
  69281 	254: uint32(67013944),
  69282 	255: uint32(67061497),
  69283 }
  69284 
  69285 var kPrefixEncodeCode = [512]VP8LPrefixCode{
  69286 	0: {},
  69287 	1: {},
  69288 	2: {
  69289 		Fcode: int8(1),
  69290 	},
  69291 	3: {
  69292 		Fcode: int8(2),
  69293 	},
  69294 	4: {
  69295 		Fcode: int8(3),
  69296 	},
  69297 	5: {
  69298 		Fcode:       int8(4),
  69299 		Fextra_bits: int8(1),
  69300 	},
  69301 	6: {
  69302 		Fcode:       int8(4),
  69303 		Fextra_bits: int8(1),
  69304 	},
  69305 	7: {
  69306 		Fcode:       int8(5),
  69307 		Fextra_bits: int8(1),
  69308 	},
  69309 	8: {
  69310 		Fcode:       int8(5),
  69311 		Fextra_bits: int8(1),
  69312 	},
  69313 	9: {
  69314 		Fcode:       int8(6),
  69315 		Fextra_bits: int8(2),
  69316 	},
  69317 	10: {
  69318 		Fcode:       int8(6),
  69319 		Fextra_bits: int8(2),
  69320 	},
  69321 	11: {
  69322 		Fcode:       int8(6),
  69323 		Fextra_bits: int8(2),
  69324 	},
  69325 	12: {
  69326 		Fcode:       int8(6),
  69327 		Fextra_bits: int8(2),
  69328 	},
  69329 	13: {
  69330 		Fcode:       int8(7),
  69331 		Fextra_bits: int8(2),
  69332 	},
  69333 	14: {
  69334 		Fcode:       int8(7),
  69335 		Fextra_bits: int8(2),
  69336 	},
  69337 	15: {
  69338 		Fcode:       int8(7),
  69339 		Fextra_bits: int8(2),
  69340 	},
  69341 	16: {
  69342 		Fcode:       int8(7),
  69343 		Fextra_bits: int8(2),
  69344 	},
  69345 	17: {
  69346 		Fcode:       int8(8),
  69347 		Fextra_bits: int8(3),
  69348 	},
  69349 	18: {
  69350 		Fcode:       int8(8),
  69351 		Fextra_bits: int8(3),
  69352 	},
  69353 	19: {
  69354 		Fcode:       int8(8),
  69355 		Fextra_bits: int8(3),
  69356 	},
  69357 	20: {
  69358 		Fcode:       int8(8),
  69359 		Fextra_bits: int8(3),
  69360 	},
  69361 	21: {
  69362 		Fcode:       int8(8),
  69363 		Fextra_bits: int8(3),
  69364 	},
  69365 	22: {
  69366 		Fcode:       int8(8),
  69367 		Fextra_bits: int8(3),
  69368 	},
  69369 	23: {
  69370 		Fcode:       int8(8),
  69371 		Fextra_bits: int8(3),
  69372 	},
  69373 	24: {
  69374 		Fcode:       int8(8),
  69375 		Fextra_bits: int8(3),
  69376 	},
  69377 	25: {
  69378 		Fcode:       int8(9),
  69379 		Fextra_bits: int8(3),
  69380 	},
  69381 	26: {
  69382 		Fcode:       int8(9),
  69383 		Fextra_bits: int8(3),
  69384 	},
  69385 	27: {
  69386 		Fcode:       int8(9),
  69387 		Fextra_bits: int8(3),
  69388 	},
  69389 	28: {
  69390 		Fcode:       int8(9),
  69391 		Fextra_bits: int8(3),
  69392 	},
  69393 	29: {
  69394 		Fcode:       int8(9),
  69395 		Fextra_bits: int8(3),
  69396 	},
  69397 	30: {
  69398 		Fcode:       int8(9),
  69399 		Fextra_bits: int8(3),
  69400 	},
  69401 	31: {
  69402 		Fcode:       int8(9),
  69403 		Fextra_bits: int8(3),
  69404 	},
  69405 	32: {
  69406 		Fcode:       int8(9),
  69407 		Fextra_bits: int8(3),
  69408 	},
  69409 	33: {
  69410 		Fcode:       int8(10),
  69411 		Fextra_bits: int8(4),
  69412 	},
  69413 	34: {
  69414 		Fcode:       int8(10),
  69415 		Fextra_bits: int8(4),
  69416 	},
  69417 	35: {
  69418 		Fcode:       int8(10),
  69419 		Fextra_bits: int8(4),
  69420 	},
  69421 	36: {
  69422 		Fcode:       int8(10),
  69423 		Fextra_bits: int8(4),
  69424 	},
  69425 	37: {
  69426 		Fcode:       int8(10),
  69427 		Fextra_bits: int8(4),
  69428 	},
  69429 	38: {
  69430 		Fcode:       int8(10),
  69431 		Fextra_bits: int8(4),
  69432 	},
  69433 	39: {
  69434 		Fcode:       int8(10),
  69435 		Fextra_bits: int8(4),
  69436 	},
  69437 	40: {
  69438 		Fcode:       int8(10),
  69439 		Fextra_bits: int8(4),
  69440 	},
  69441 	41: {
  69442 		Fcode:       int8(10),
  69443 		Fextra_bits: int8(4),
  69444 	},
  69445 	42: {
  69446 		Fcode:       int8(10),
  69447 		Fextra_bits: int8(4),
  69448 	},
  69449 	43: {
  69450 		Fcode:       int8(10),
  69451 		Fextra_bits: int8(4),
  69452 	},
  69453 	44: {
  69454 		Fcode:       int8(10),
  69455 		Fextra_bits: int8(4),
  69456 	},
  69457 	45: {
  69458 		Fcode:       int8(10),
  69459 		Fextra_bits: int8(4),
  69460 	},
  69461 	46: {
  69462 		Fcode:       int8(10),
  69463 		Fextra_bits: int8(4),
  69464 	},
  69465 	47: {
  69466 		Fcode:       int8(10),
  69467 		Fextra_bits: int8(4),
  69468 	},
  69469 	48: {
  69470 		Fcode:       int8(10),
  69471 		Fextra_bits: int8(4),
  69472 	},
  69473 	49: {
  69474 		Fcode:       int8(11),
  69475 		Fextra_bits: int8(4),
  69476 	},
  69477 	50: {
  69478 		Fcode:       int8(11),
  69479 		Fextra_bits: int8(4),
  69480 	},
  69481 	51: {
  69482 		Fcode:       int8(11),
  69483 		Fextra_bits: int8(4),
  69484 	},
  69485 	52: {
  69486 		Fcode:       int8(11),
  69487 		Fextra_bits: int8(4),
  69488 	},
  69489 	53: {
  69490 		Fcode:       int8(11),
  69491 		Fextra_bits: int8(4),
  69492 	},
  69493 	54: {
  69494 		Fcode:       int8(11),
  69495 		Fextra_bits: int8(4),
  69496 	},
  69497 	55: {
  69498 		Fcode:       int8(11),
  69499 		Fextra_bits: int8(4),
  69500 	},
  69501 	56: {
  69502 		Fcode:       int8(11),
  69503 		Fextra_bits: int8(4),
  69504 	},
  69505 	57: {
  69506 		Fcode:       int8(11),
  69507 		Fextra_bits: int8(4),
  69508 	},
  69509 	58: {
  69510 		Fcode:       int8(11),
  69511 		Fextra_bits: int8(4),
  69512 	},
  69513 	59: {
  69514 		Fcode:       int8(11),
  69515 		Fextra_bits: int8(4),
  69516 	},
  69517 	60: {
  69518 		Fcode:       int8(11),
  69519 		Fextra_bits: int8(4),
  69520 	},
  69521 	61: {
  69522 		Fcode:       int8(11),
  69523 		Fextra_bits: int8(4),
  69524 	},
  69525 	62: {
  69526 		Fcode:       int8(11),
  69527 		Fextra_bits: int8(4),
  69528 	},
  69529 	63: {
  69530 		Fcode:       int8(11),
  69531 		Fextra_bits: int8(4),
  69532 	},
  69533 	64: {
  69534 		Fcode:       int8(11),
  69535 		Fextra_bits: int8(4),
  69536 	},
  69537 	65: {
  69538 		Fcode:       int8(12),
  69539 		Fextra_bits: int8(5),
  69540 	},
  69541 	66: {
  69542 		Fcode:       int8(12),
  69543 		Fextra_bits: int8(5),
  69544 	},
  69545 	67: {
  69546 		Fcode:       int8(12),
  69547 		Fextra_bits: int8(5),
  69548 	},
  69549 	68: {
  69550 		Fcode:       int8(12),
  69551 		Fextra_bits: int8(5),
  69552 	},
  69553 	69: {
  69554 		Fcode:       int8(12),
  69555 		Fextra_bits: int8(5),
  69556 	},
  69557 	70: {
  69558 		Fcode:       int8(12),
  69559 		Fextra_bits: int8(5),
  69560 	},
  69561 	71: {
  69562 		Fcode:       int8(12),
  69563 		Fextra_bits: int8(5),
  69564 	},
  69565 	72: {
  69566 		Fcode:       int8(12),
  69567 		Fextra_bits: int8(5),
  69568 	},
  69569 	73: {
  69570 		Fcode:       int8(12),
  69571 		Fextra_bits: int8(5),
  69572 	},
  69573 	74: {
  69574 		Fcode:       int8(12),
  69575 		Fextra_bits: int8(5),
  69576 	},
  69577 	75: {
  69578 		Fcode:       int8(12),
  69579 		Fextra_bits: int8(5),
  69580 	},
  69581 	76: {
  69582 		Fcode:       int8(12),
  69583 		Fextra_bits: int8(5),
  69584 	},
  69585 	77: {
  69586 		Fcode:       int8(12),
  69587 		Fextra_bits: int8(5),
  69588 	},
  69589 	78: {
  69590 		Fcode:       int8(12),
  69591 		Fextra_bits: int8(5),
  69592 	},
  69593 	79: {
  69594 		Fcode:       int8(12),
  69595 		Fextra_bits: int8(5),
  69596 	},
  69597 	80: {
  69598 		Fcode:       int8(12),
  69599 		Fextra_bits: int8(5),
  69600 	},
  69601 	81: {
  69602 		Fcode:       int8(12),
  69603 		Fextra_bits: int8(5),
  69604 	},
  69605 	82: {
  69606 		Fcode:       int8(12),
  69607 		Fextra_bits: int8(5),
  69608 	},
  69609 	83: {
  69610 		Fcode:       int8(12),
  69611 		Fextra_bits: int8(5),
  69612 	},
  69613 	84: {
  69614 		Fcode:       int8(12),
  69615 		Fextra_bits: int8(5),
  69616 	},
  69617 	85: {
  69618 		Fcode:       int8(12),
  69619 		Fextra_bits: int8(5),
  69620 	},
  69621 	86: {
  69622 		Fcode:       int8(12),
  69623 		Fextra_bits: int8(5),
  69624 	},
  69625 	87: {
  69626 		Fcode:       int8(12),
  69627 		Fextra_bits: int8(5),
  69628 	},
  69629 	88: {
  69630 		Fcode:       int8(12),
  69631 		Fextra_bits: int8(5),
  69632 	},
  69633 	89: {
  69634 		Fcode:       int8(12),
  69635 		Fextra_bits: int8(5),
  69636 	},
  69637 	90: {
  69638 		Fcode:       int8(12),
  69639 		Fextra_bits: int8(5),
  69640 	},
  69641 	91: {
  69642 		Fcode:       int8(12),
  69643 		Fextra_bits: int8(5),
  69644 	},
  69645 	92: {
  69646 		Fcode:       int8(12),
  69647 		Fextra_bits: int8(5),
  69648 	},
  69649 	93: {
  69650 		Fcode:       int8(12),
  69651 		Fextra_bits: int8(5),
  69652 	},
  69653 	94: {
  69654 		Fcode:       int8(12),
  69655 		Fextra_bits: int8(5),
  69656 	},
  69657 	95: {
  69658 		Fcode:       int8(12),
  69659 		Fextra_bits: int8(5),
  69660 	},
  69661 	96: {
  69662 		Fcode:       int8(12),
  69663 		Fextra_bits: int8(5),
  69664 	},
  69665 	97: {
  69666 		Fcode:       int8(13),
  69667 		Fextra_bits: int8(5),
  69668 	},
  69669 	98: {
  69670 		Fcode:       int8(13),
  69671 		Fextra_bits: int8(5),
  69672 	},
  69673 	99: {
  69674 		Fcode:       int8(13),
  69675 		Fextra_bits: int8(5),
  69676 	},
  69677 	100: {
  69678 		Fcode:       int8(13),
  69679 		Fextra_bits: int8(5),
  69680 	},
  69681 	101: {
  69682 		Fcode:       int8(13),
  69683 		Fextra_bits: int8(5),
  69684 	},
  69685 	102: {
  69686 		Fcode:       int8(13),
  69687 		Fextra_bits: int8(5),
  69688 	},
  69689 	103: {
  69690 		Fcode:       int8(13),
  69691 		Fextra_bits: int8(5),
  69692 	},
  69693 	104: {
  69694 		Fcode:       int8(13),
  69695 		Fextra_bits: int8(5),
  69696 	},
  69697 	105: {
  69698 		Fcode:       int8(13),
  69699 		Fextra_bits: int8(5),
  69700 	},
  69701 	106: {
  69702 		Fcode:       int8(13),
  69703 		Fextra_bits: int8(5),
  69704 	},
  69705 	107: {
  69706 		Fcode:       int8(13),
  69707 		Fextra_bits: int8(5),
  69708 	},
  69709 	108: {
  69710 		Fcode:       int8(13),
  69711 		Fextra_bits: int8(5),
  69712 	},
  69713 	109: {
  69714 		Fcode:       int8(13),
  69715 		Fextra_bits: int8(5),
  69716 	},
  69717 	110: {
  69718 		Fcode:       int8(13),
  69719 		Fextra_bits: int8(5),
  69720 	},
  69721 	111: {
  69722 		Fcode:       int8(13),
  69723 		Fextra_bits: int8(5),
  69724 	},
  69725 	112: {
  69726 		Fcode:       int8(13),
  69727 		Fextra_bits: int8(5),
  69728 	},
  69729 	113: {
  69730 		Fcode:       int8(13),
  69731 		Fextra_bits: int8(5),
  69732 	},
  69733 	114: {
  69734 		Fcode:       int8(13),
  69735 		Fextra_bits: int8(5),
  69736 	},
  69737 	115: {
  69738 		Fcode:       int8(13),
  69739 		Fextra_bits: int8(5),
  69740 	},
  69741 	116: {
  69742 		Fcode:       int8(13),
  69743 		Fextra_bits: int8(5),
  69744 	},
  69745 	117: {
  69746 		Fcode:       int8(13),
  69747 		Fextra_bits: int8(5),
  69748 	},
  69749 	118: {
  69750 		Fcode:       int8(13),
  69751 		Fextra_bits: int8(5),
  69752 	},
  69753 	119: {
  69754 		Fcode:       int8(13),
  69755 		Fextra_bits: int8(5),
  69756 	},
  69757 	120: {
  69758 		Fcode:       int8(13),
  69759 		Fextra_bits: int8(5),
  69760 	},
  69761 	121: {
  69762 		Fcode:       int8(13),
  69763 		Fextra_bits: int8(5),
  69764 	},
  69765 	122: {
  69766 		Fcode:       int8(13),
  69767 		Fextra_bits: int8(5),
  69768 	},
  69769 	123: {
  69770 		Fcode:       int8(13),
  69771 		Fextra_bits: int8(5),
  69772 	},
  69773 	124: {
  69774 		Fcode:       int8(13),
  69775 		Fextra_bits: int8(5),
  69776 	},
  69777 	125: {
  69778 		Fcode:       int8(13),
  69779 		Fextra_bits: int8(5),
  69780 	},
  69781 	126: {
  69782 		Fcode:       int8(13),
  69783 		Fextra_bits: int8(5),
  69784 	},
  69785 	127: {
  69786 		Fcode:       int8(13),
  69787 		Fextra_bits: int8(5),
  69788 	},
  69789 	128: {
  69790 		Fcode:       int8(13),
  69791 		Fextra_bits: int8(5),
  69792 	},
  69793 	129: {
  69794 		Fcode:       int8(14),
  69795 		Fextra_bits: int8(6),
  69796 	},
  69797 	130: {
  69798 		Fcode:       int8(14),
  69799 		Fextra_bits: int8(6),
  69800 	},
  69801 	131: {
  69802 		Fcode:       int8(14),
  69803 		Fextra_bits: int8(6),
  69804 	},
  69805 	132: {
  69806 		Fcode:       int8(14),
  69807 		Fextra_bits: int8(6),
  69808 	},
  69809 	133: {
  69810 		Fcode:       int8(14),
  69811 		Fextra_bits: int8(6),
  69812 	},
  69813 	134: {
  69814 		Fcode:       int8(14),
  69815 		Fextra_bits: int8(6),
  69816 	},
  69817 	135: {
  69818 		Fcode:       int8(14),
  69819 		Fextra_bits: int8(6),
  69820 	},
  69821 	136: {
  69822 		Fcode:       int8(14),
  69823 		Fextra_bits: int8(6),
  69824 	},
  69825 	137: {
  69826 		Fcode:       int8(14),
  69827 		Fextra_bits: int8(6),
  69828 	},
  69829 	138: {
  69830 		Fcode:       int8(14),
  69831 		Fextra_bits: int8(6),
  69832 	},
  69833 	139: {
  69834 		Fcode:       int8(14),
  69835 		Fextra_bits: int8(6),
  69836 	},
  69837 	140: {
  69838 		Fcode:       int8(14),
  69839 		Fextra_bits: int8(6),
  69840 	},
  69841 	141: {
  69842 		Fcode:       int8(14),
  69843 		Fextra_bits: int8(6),
  69844 	},
  69845 	142: {
  69846 		Fcode:       int8(14),
  69847 		Fextra_bits: int8(6),
  69848 	},
  69849 	143: {
  69850 		Fcode:       int8(14),
  69851 		Fextra_bits: int8(6),
  69852 	},
  69853 	144: {
  69854 		Fcode:       int8(14),
  69855 		Fextra_bits: int8(6),
  69856 	},
  69857 	145: {
  69858 		Fcode:       int8(14),
  69859 		Fextra_bits: int8(6),
  69860 	},
  69861 	146: {
  69862 		Fcode:       int8(14),
  69863 		Fextra_bits: int8(6),
  69864 	},
  69865 	147: {
  69866 		Fcode:       int8(14),
  69867 		Fextra_bits: int8(6),
  69868 	},
  69869 	148: {
  69870 		Fcode:       int8(14),
  69871 		Fextra_bits: int8(6),
  69872 	},
  69873 	149: {
  69874 		Fcode:       int8(14),
  69875 		Fextra_bits: int8(6),
  69876 	},
  69877 	150: {
  69878 		Fcode:       int8(14),
  69879 		Fextra_bits: int8(6),
  69880 	},
  69881 	151: {
  69882 		Fcode:       int8(14),
  69883 		Fextra_bits: int8(6),
  69884 	},
  69885 	152: {
  69886 		Fcode:       int8(14),
  69887 		Fextra_bits: int8(6),
  69888 	},
  69889 	153: {
  69890 		Fcode:       int8(14),
  69891 		Fextra_bits: int8(6),
  69892 	},
  69893 	154: {
  69894 		Fcode:       int8(14),
  69895 		Fextra_bits: int8(6),
  69896 	},
  69897 	155: {
  69898 		Fcode:       int8(14),
  69899 		Fextra_bits: int8(6),
  69900 	},
  69901 	156: {
  69902 		Fcode:       int8(14),
  69903 		Fextra_bits: int8(6),
  69904 	},
  69905 	157: {
  69906 		Fcode:       int8(14),
  69907 		Fextra_bits: int8(6),
  69908 	},
  69909 	158: {
  69910 		Fcode:       int8(14),
  69911 		Fextra_bits: int8(6),
  69912 	},
  69913 	159: {
  69914 		Fcode:       int8(14),
  69915 		Fextra_bits: int8(6),
  69916 	},
  69917 	160: {
  69918 		Fcode:       int8(14),
  69919 		Fextra_bits: int8(6),
  69920 	},
  69921 	161: {
  69922 		Fcode:       int8(14),
  69923 		Fextra_bits: int8(6),
  69924 	},
  69925 	162: {
  69926 		Fcode:       int8(14),
  69927 		Fextra_bits: int8(6),
  69928 	},
  69929 	163: {
  69930 		Fcode:       int8(14),
  69931 		Fextra_bits: int8(6),
  69932 	},
  69933 	164: {
  69934 		Fcode:       int8(14),
  69935 		Fextra_bits: int8(6),
  69936 	},
  69937 	165: {
  69938 		Fcode:       int8(14),
  69939 		Fextra_bits: int8(6),
  69940 	},
  69941 	166: {
  69942 		Fcode:       int8(14),
  69943 		Fextra_bits: int8(6),
  69944 	},
  69945 	167: {
  69946 		Fcode:       int8(14),
  69947 		Fextra_bits: int8(6),
  69948 	},
  69949 	168: {
  69950 		Fcode:       int8(14),
  69951 		Fextra_bits: int8(6),
  69952 	},
  69953 	169: {
  69954 		Fcode:       int8(14),
  69955 		Fextra_bits: int8(6),
  69956 	},
  69957 	170: {
  69958 		Fcode:       int8(14),
  69959 		Fextra_bits: int8(6),
  69960 	},
  69961 	171: {
  69962 		Fcode:       int8(14),
  69963 		Fextra_bits: int8(6),
  69964 	},
  69965 	172: {
  69966 		Fcode:       int8(14),
  69967 		Fextra_bits: int8(6),
  69968 	},
  69969 	173: {
  69970 		Fcode:       int8(14),
  69971 		Fextra_bits: int8(6),
  69972 	},
  69973 	174: {
  69974 		Fcode:       int8(14),
  69975 		Fextra_bits: int8(6),
  69976 	},
  69977 	175: {
  69978 		Fcode:       int8(14),
  69979 		Fextra_bits: int8(6),
  69980 	},
  69981 	176: {
  69982 		Fcode:       int8(14),
  69983 		Fextra_bits: int8(6),
  69984 	},
  69985 	177: {
  69986 		Fcode:       int8(14),
  69987 		Fextra_bits: int8(6),
  69988 	},
  69989 	178: {
  69990 		Fcode:       int8(14),
  69991 		Fextra_bits: int8(6),
  69992 	},
  69993 	179: {
  69994 		Fcode:       int8(14),
  69995 		Fextra_bits: int8(6),
  69996 	},
  69997 	180: {
  69998 		Fcode:       int8(14),
  69999 		Fextra_bits: int8(6),
  70000 	},
  70001 	181: {
  70002 		Fcode:       int8(14),
  70003 		Fextra_bits: int8(6),
  70004 	},
  70005 	182: {
  70006 		Fcode:       int8(14),
  70007 		Fextra_bits: int8(6),
  70008 	},
  70009 	183: {
  70010 		Fcode:       int8(14),
  70011 		Fextra_bits: int8(6),
  70012 	},
  70013 	184: {
  70014 		Fcode:       int8(14),
  70015 		Fextra_bits: int8(6),
  70016 	},
  70017 	185: {
  70018 		Fcode:       int8(14),
  70019 		Fextra_bits: int8(6),
  70020 	},
  70021 	186: {
  70022 		Fcode:       int8(14),
  70023 		Fextra_bits: int8(6),
  70024 	},
  70025 	187: {
  70026 		Fcode:       int8(14),
  70027 		Fextra_bits: int8(6),
  70028 	},
  70029 	188: {
  70030 		Fcode:       int8(14),
  70031 		Fextra_bits: int8(6),
  70032 	},
  70033 	189: {
  70034 		Fcode:       int8(14),
  70035 		Fextra_bits: int8(6),
  70036 	},
  70037 	190: {
  70038 		Fcode:       int8(14),
  70039 		Fextra_bits: int8(6),
  70040 	},
  70041 	191: {
  70042 		Fcode:       int8(14),
  70043 		Fextra_bits: int8(6),
  70044 	},
  70045 	192: {
  70046 		Fcode:       int8(14),
  70047 		Fextra_bits: int8(6),
  70048 	},
  70049 	193: {
  70050 		Fcode:       int8(15),
  70051 		Fextra_bits: int8(6),
  70052 	},
  70053 	194: {
  70054 		Fcode:       int8(15),
  70055 		Fextra_bits: int8(6),
  70056 	},
  70057 	195: {
  70058 		Fcode:       int8(15),
  70059 		Fextra_bits: int8(6),
  70060 	},
  70061 	196: {
  70062 		Fcode:       int8(15),
  70063 		Fextra_bits: int8(6),
  70064 	},
  70065 	197: {
  70066 		Fcode:       int8(15),
  70067 		Fextra_bits: int8(6),
  70068 	},
  70069 	198: {
  70070 		Fcode:       int8(15),
  70071 		Fextra_bits: int8(6),
  70072 	},
  70073 	199: {
  70074 		Fcode:       int8(15),
  70075 		Fextra_bits: int8(6),
  70076 	},
  70077 	200: {
  70078 		Fcode:       int8(15),
  70079 		Fextra_bits: int8(6),
  70080 	},
  70081 	201: {
  70082 		Fcode:       int8(15),
  70083 		Fextra_bits: int8(6),
  70084 	},
  70085 	202: {
  70086 		Fcode:       int8(15),
  70087 		Fextra_bits: int8(6),
  70088 	},
  70089 	203: {
  70090 		Fcode:       int8(15),
  70091 		Fextra_bits: int8(6),
  70092 	},
  70093 	204: {
  70094 		Fcode:       int8(15),
  70095 		Fextra_bits: int8(6),
  70096 	},
  70097 	205: {
  70098 		Fcode:       int8(15),
  70099 		Fextra_bits: int8(6),
  70100 	},
  70101 	206: {
  70102 		Fcode:       int8(15),
  70103 		Fextra_bits: int8(6),
  70104 	},
  70105 	207: {
  70106 		Fcode:       int8(15),
  70107 		Fextra_bits: int8(6),
  70108 	},
  70109 	208: {
  70110 		Fcode:       int8(15),
  70111 		Fextra_bits: int8(6),
  70112 	},
  70113 	209: {
  70114 		Fcode:       int8(15),
  70115 		Fextra_bits: int8(6),
  70116 	},
  70117 	210: {
  70118 		Fcode:       int8(15),
  70119 		Fextra_bits: int8(6),
  70120 	},
  70121 	211: {
  70122 		Fcode:       int8(15),
  70123 		Fextra_bits: int8(6),
  70124 	},
  70125 	212: {
  70126 		Fcode:       int8(15),
  70127 		Fextra_bits: int8(6),
  70128 	},
  70129 	213: {
  70130 		Fcode:       int8(15),
  70131 		Fextra_bits: int8(6),
  70132 	},
  70133 	214: {
  70134 		Fcode:       int8(15),
  70135 		Fextra_bits: int8(6),
  70136 	},
  70137 	215: {
  70138 		Fcode:       int8(15),
  70139 		Fextra_bits: int8(6),
  70140 	},
  70141 	216: {
  70142 		Fcode:       int8(15),
  70143 		Fextra_bits: int8(6),
  70144 	},
  70145 	217: {
  70146 		Fcode:       int8(15),
  70147 		Fextra_bits: int8(6),
  70148 	},
  70149 	218: {
  70150 		Fcode:       int8(15),
  70151 		Fextra_bits: int8(6),
  70152 	},
  70153 	219: {
  70154 		Fcode:       int8(15),
  70155 		Fextra_bits: int8(6),
  70156 	},
  70157 	220: {
  70158 		Fcode:       int8(15),
  70159 		Fextra_bits: int8(6),
  70160 	},
  70161 	221: {
  70162 		Fcode:       int8(15),
  70163 		Fextra_bits: int8(6),
  70164 	},
  70165 	222: {
  70166 		Fcode:       int8(15),
  70167 		Fextra_bits: int8(6),
  70168 	},
  70169 	223: {
  70170 		Fcode:       int8(15),
  70171 		Fextra_bits: int8(6),
  70172 	},
  70173 	224: {
  70174 		Fcode:       int8(15),
  70175 		Fextra_bits: int8(6),
  70176 	},
  70177 	225: {
  70178 		Fcode:       int8(15),
  70179 		Fextra_bits: int8(6),
  70180 	},
  70181 	226: {
  70182 		Fcode:       int8(15),
  70183 		Fextra_bits: int8(6),
  70184 	},
  70185 	227: {
  70186 		Fcode:       int8(15),
  70187 		Fextra_bits: int8(6),
  70188 	},
  70189 	228: {
  70190 		Fcode:       int8(15),
  70191 		Fextra_bits: int8(6),
  70192 	},
  70193 	229: {
  70194 		Fcode:       int8(15),
  70195 		Fextra_bits: int8(6),
  70196 	},
  70197 	230: {
  70198 		Fcode:       int8(15),
  70199 		Fextra_bits: int8(6),
  70200 	},
  70201 	231: {
  70202 		Fcode:       int8(15),
  70203 		Fextra_bits: int8(6),
  70204 	},
  70205 	232: {
  70206 		Fcode:       int8(15),
  70207 		Fextra_bits: int8(6),
  70208 	},
  70209 	233: {
  70210 		Fcode:       int8(15),
  70211 		Fextra_bits: int8(6),
  70212 	},
  70213 	234: {
  70214 		Fcode:       int8(15),
  70215 		Fextra_bits: int8(6),
  70216 	},
  70217 	235: {
  70218 		Fcode:       int8(15),
  70219 		Fextra_bits: int8(6),
  70220 	},
  70221 	236: {
  70222 		Fcode:       int8(15),
  70223 		Fextra_bits: int8(6),
  70224 	},
  70225 	237: {
  70226 		Fcode:       int8(15),
  70227 		Fextra_bits: int8(6),
  70228 	},
  70229 	238: {
  70230 		Fcode:       int8(15),
  70231 		Fextra_bits: int8(6),
  70232 	},
  70233 	239: {
  70234 		Fcode:       int8(15),
  70235 		Fextra_bits: int8(6),
  70236 	},
  70237 	240: {
  70238 		Fcode:       int8(15),
  70239 		Fextra_bits: int8(6),
  70240 	},
  70241 	241: {
  70242 		Fcode:       int8(15),
  70243 		Fextra_bits: int8(6),
  70244 	},
  70245 	242: {
  70246 		Fcode:       int8(15),
  70247 		Fextra_bits: int8(6),
  70248 	},
  70249 	243: {
  70250 		Fcode:       int8(15),
  70251 		Fextra_bits: int8(6),
  70252 	},
  70253 	244: {
  70254 		Fcode:       int8(15),
  70255 		Fextra_bits: int8(6),
  70256 	},
  70257 	245: {
  70258 		Fcode:       int8(15),
  70259 		Fextra_bits: int8(6),
  70260 	},
  70261 	246: {
  70262 		Fcode:       int8(15),
  70263 		Fextra_bits: int8(6),
  70264 	},
  70265 	247: {
  70266 		Fcode:       int8(15),
  70267 		Fextra_bits: int8(6),
  70268 	},
  70269 	248: {
  70270 		Fcode:       int8(15),
  70271 		Fextra_bits: int8(6),
  70272 	},
  70273 	249: {
  70274 		Fcode:       int8(15),
  70275 		Fextra_bits: int8(6),
  70276 	},
  70277 	250: {
  70278 		Fcode:       int8(15),
  70279 		Fextra_bits: int8(6),
  70280 	},
  70281 	251: {
  70282 		Fcode:       int8(15),
  70283 		Fextra_bits: int8(6),
  70284 	},
  70285 	252: {
  70286 		Fcode:       int8(15),
  70287 		Fextra_bits: int8(6),
  70288 	},
  70289 	253: {
  70290 		Fcode:       int8(15),
  70291 		Fextra_bits: int8(6),
  70292 	},
  70293 	254: {
  70294 		Fcode:       int8(15),
  70295 		Fextra_bits: int8(6),
  70296 	},
  70297 	255: {
  70298 		Fcode:       int8(15),
  70299 		Fextra_bits: int8(6),
  70300 	},
  70301 	256: {
  70302 		Fcode:       int8(15),
  70303 		Fextra_bits: int8(6),
  70304 	},
  70305 	257: {
  70306 		Fcode:       int8(16),
  70307 		Fextra_bits: int8(7),
  70308 	},
  70309 	258: {
  70310 		Fcode:       int8(16),
  70311 		Fextra_bits: int8(7),
  70312 	},
  70313 	259: {
  70314 		Fcode:       int8(16),
  70315 		Fextra_bits: int8(7),
  70316 	},
  70317 	260: {
  70318 		Fcode:       int8(16),
  70319 		Fextra_bits: int8(7),
  70320 	},
  70321 	261: {
  70322 		Fcode:       int8(16),
  70323 		Fextra_bits: int8(7),
  70324 	},
  70325 	262: {
  70326 		Fcode:       int8(16),
  70327 		Fextra_bits: int8(7),
  70328 	},
  70329 	263: {
  70330 		Fcode:       int8(16),
  70331 		Fextra_bits: int8(7),
  70332 	},
  70333 	264: {
  70334 		Fcode:       int8(16),
  70335 		Fextra_bits: int8(7),
  70336 	},
  70337 	265: {
  70338 		Fcode:       int8(16),
  70339 		Fextra_bits: int8(7),
  70340 	},
  70341 	266: {
  70342 		Fcode:       int8(16),
  70343 		Fextra_bits: int8(7),
  70344 	},
  70345 	267: {
  70346 		Fcode:       int8(16),
  70347 		Fextra_bits: int8(7),
  70348 	},
  70349 	268: {
  70350 		Fcode:       int8(16),
  70351 		Fextra_bits: int8(7),
  70352 	},
  70353 	269: {
  70354 		Fcode:       int8(16),
  70355 		Fextra_bits: int8(7),
  70356 	},
  70357 	270: {
  70358 		Fcode:       int8(16),
  70359 		Fextra_bits: int8(7),
  70360 	},
  70361 	271: {
  70362 		Fcode:       int8(16),
  70363 		Fextra_bits: int8(7),
  70364 	},
  70365 	272: {
  70366 		Fcode:       int8(16),
  70367 		Fextra_bits: int8(7),
  70368 	},
  70369 	273: {
  70370 		Fcode:       int8(16),
  70371 		Fextra_bits: int8(7),
  70372 	},
  70373 	274: {
  70374 		Fcode:       int8(16),
  70375 		Fextra_bits: int8(7),
  70376 	},
  70377 	275: {
  70378 		Fcode:       int8(16),
  70379 		Fextra_bits: int8(7),
  70380 	},
  70381 	276: {
  70382 		Fcode:       int8(16),
  70383 		Fextra_bits: int8(7),
  70384 	},
  70385 	277: {
  70386 		Fcode:       int8(16),
  70387 		Fextra_bits: int8(7),
  70388 	},
  70389 	278: {
  70390 		Fcode:       int8(16),
  70391 		Fextra_bits: int8(7),
  70392 	},
  70393 	279: {
  70394 		Fcode:       int8(16),
  70395 		Fextra_bits: int8(7),
  70396 	},
  70397 	280: {
  70398 		Fcode:       int8(16),
  70399 		Fextra_bits: int8(7),
  70400 	},
  70401 	281: {
  70402 		Fcode:       int8(16),
  70403 		Fextra_bits: int8(7),
  70404 	},
  70405 	282: {
  70406 		Fcode:       int8(16),
  70407 		Fextra_bits: int8(7),
  70408 	},
  70409 	283: {
  70410 		Fcode:       int8(16),
  70411 		Fextra_bits: int8(7),
  70412 	},
  70413 	284: {
  70414 		Fcode:       int8(16),
  70415 		Fextra_bits: int8(7),
  70416 	},
  70417 	285: {
  70418 		Fcode:       int8(16),
  70419 		Fextra_bits: int8(7),
  70420 	},
  70421 	286: {
  70422 		Fcode:       int8(16),
  70423 		Fextra_bits: int8(7),
  70424 	},
  70425 	287: {
  70426 		Fcode:       int8(16),
  70427 		Fextra_bits: int8(7),
  70428 	},
  70429 	288: {
  70430 		Fcode:       int8(16),
  70431 		Fextra_bits: int8(7),
  70432 	},
  70433 	289: {
  70434 		Fcode:       int8(16),
  70435 		Fextra_bits: int8(7),
  70436 	},
  70437 	290: {
  70438 		Fcode:       int8(16),
  70439 		Fextra_bits: int8(7),
  70440 	},
  70441 	291: {
  70442 		Fcode:       int8(16),
  70443 		Fextra_bits: int8(7),
  70444 	},
  70445 	292: {
  70446 		Fcode:       int8(16),
  70447 		Fextra_bits: int8(7),
  70448 	},
  70449 	293: {
  70450 		Fcode:       int8(16),
  70451 		Fextra_bits: int8(7),
  70452 	},
  70453 	294: {
  70454 		Fcode:       int8(16),
  70455 		Fextra_bits: int8(7),
  70456 	},
  70457 	295: {
  70458 		Fcode:       int8(16),
  70459 		Fextra_bits: int8(7),
  70460 	},
  70461 	296: {
  70462 		Fcode:       int8(16),
  70463 		Fextra_bits: int8(7),
  70464 	},
  70465 	297: {
  70466 		Fcode:       int8(16),
  70467 		Fextra_bits: int8(7),
  70468 	},
  70469 	298: {
  70470 		Fcode:       int8(16),
  70471 		Fextra_bits: int8(7),
  70472 	},
  70473 	299: {
  70474 		Fcode:       int8(16),
  70475 		Fextra_bits: int8(7),
  70476 	},
  70477 	300: {
  70478 		Fcode:       int8(16),
  70479 		Fextra_bits: int8(7),
  70480 	},
  70481 	301: {
  70482 		Fcode:       int8(16),
  70483 		Fextra_bits: int8(7),
  70484 	},
  70485 	302: {
  70486 		Fcode:       int8(16),
  70487 		Fextra_bits: int8(7),
  70488 	},
  70489 	303: {
  70490 		Fcode:       int8(16),
  70491 		Fextra_bits: int8(7),
  70492 	},
  70493 	304: {
  70494 		Fcode:       int8(16),
  70495 		Fextra_bits: int8(7),
  70496 	},
  70497 	305: {
  70498 		Fcode:       int8(16),
  70499 		Fextra_bits: int8(7),
  70500 	},
  70501 	306: {
  70502 		Fcode:       int8(16),
  70503 		Fextra_bits: int8(7),
  70504 	},
  70505 	307: {
  70506 		Fcode:       int8(16),
  70507 		Fextra_bits: int8(7),
  70508 	},
  70509 	308: {
  70510 		Fcode:       int8(16),
  70511 		Fextra_bits: int8(7),
  70512 	},
  70513 	309: {
  70514 		Fcode:       int8(16),
  70515 		Fextra_bits: int8(7),
  70516 	},
  70517 	310: {
  70518 		Fcode:       int8(16),
  70519 		Fextra_bits: int8(7),
  70520 	},
  70521 	311: {
  70522 		Fcode:       int8(16),
  70523 		Fextra_bits: int8(7),
  70524 	},
  70525 	312: {
  70526 		Fcode:       int8(16),
  70527 		Fextra_bits: int8(7),
  70528 	},
  70529 	313: {
  70530 		Fcode:       int8(16),
  70531 		Fextra_bits: int8(7),
  70532 	},
  70533 	314: {
  70534 		Fcode:       int8(16),
  70535 		Fextra_bits: int8(7),
  70536 	},
  70537 	315: {
  70538 		Fcode:       int8(16),
  70539 		Fextra_bits: int8(7),
  70540 	},
  70541 	316: {
  70542 		Fcode:       int8(16),
  70543 		Fextra_bits: int8(7),
  70544 	},
  70545 	317: {
  70546 		Fcode:       int8(16),
  70547 		Fextra_bits: int8(7),
  70548 	},
  70549 	318: {
  70550 		Fcode:       int8(16),
  70551 		Fextra_bits: int8(7),
  70552 	},
  70553 	319: {
  70554 		Fcode:       int8(16),
  70555 		Fextra_bits: int8(7),
  70556 	},
  70557 	320: {
  70558 		Fcode:       int8(16),
  70559 		Fextra_bits: int8(7),
  70560 	},
  70561 	321: {
  70562 		Fcode:       int8(16),
  70563 		Fextra_bits: int8(7),
  70564 	},
  70565 	322: {
  70566 		Fcode:       int8(16),
  70567 		Fextra_bits: int8(7),
  70568 	},
  70569 	323: {
  70570 		Fcode:       int8(16),
  70571 		Fextra_bits: int8(7),
  70572 	},
  70573 	324: {
  70574 		Fcode:       int8(16),
  70575 		Fextra_bits: int8(7),
  70576 	},
  70577 	325: {
  70578 		Fcode:       int8(16),
  70579 		Fextra_bits: int8(7),
  70580 	},
  70581 	326: {
  70582 		Fcode:       int8(16),
  70583 		Fextra_bits: int8(7),
  70584 	},
  70585 	327: {
  70586 		Fcode:       int8(16),
  70587 		Fextra_bits: int8(7),
  70588 	},
  70589 	328: {
  70590 		Fcode:       int8(16),
  70591 		Fextra_bits: int8(7),
  70592 	},
  70593 	329: {
  70594 		Fcode:       int8(16),
  70595 		Fextra_bits: int8(7),
  70596 	},
  70597 	330: {
  70598 		Fcode:       int8(16),
  70599 		Fextra_bits: int8(7),
  70600 	},
  70601 	331: {
  70602 		Fcode:       int8(16),
  70603 		Fextra_bits: int8(7),
  70604 	},
  70605 	332: {
  70606 		Fcode:       int8(16),
  70607 		Fextra_bits: int8(7),
  70608 	},
  70609 	333: {
  70610 		Fcode:       int8(16),
  70611 		Fextra_bits: int8(7),
  70612 	},
  70613 	334: {
  70614 		Fcode:       int8(16),
  70615 		Fextra_bits: int8(7),
  70616 	},
  70617 	335: {
  70618 		Fcode:       int8(16),
  70619 		Fextra_bits: int8(7),
  70620 	},
  70621 	336: {
  70622 		Fcode:       int8(16),
  70623 		Fextra_bits: int8(7),
  70624 	},
  70625 	337: {
  70626 		Fcode:       int8(16),
  70627 		Fextra_bits: int8(7),
  70628 	},
  70629 	338: {
  70630 		Fcode:       int8(16),
  70631 		Fextra_bits: int8(7),
  70632 	},
  70633 	339: {
  70634 		Fcode:       int8(16),
  70635 		Fextra_bits: int8(7),
  70636 	},
  70637 	340: {
  70638 		Fcode:       int8(16),
  70639 		Fextra_bits: int8(7),
  70640 	},
  70641 	341: {
  70642 		Fcode:       int8(16),
  70643 		Fextra_bits: int8(7),
  70644 	},
  70645 	342: {
  70646 		Fcode:       int8(16),
  70647 		Fextra_bits: int8(7),
  70648 	},
  70649 	343: {
  70650 		Fcode:       int8(16),
  70651 		Fextra_bits: int8(7),
  70652 	},
  70653 	344: {
  70654 		Fcode:       int8(16),
  70655 		Fextra_bits: int8(7),
  70656 	},
  70657 	345: {
  70658 		Fcode:       int8(16),
  70659 		Fextra_bits: int8(7),
  70660 	},
  70661 	346: {
  70662 		Fcode:       int8(16),
  70663 		Fextra_bits: int8(7),
  70664 	},
  70665 	347: {
  70666 		Fcode:       int8(16),
  70667 		Fextra_bits: int8(7),
  70668 	},
  70669 	348: {
  70670 		Fcode:       int8(16),
  70671 		Fextra_bits: int8(7),
  70672 	},
  70673 	349: {
  70674 		Fcode:       int8(16),
  70675 		Fextra_bits: int8(7),
  70676 	},
  70677 	350: {
  70678 		Fcode:       int8(16),
  70679 		Fextra_bits: int8(7),
  70680 	},
  70681 	351: {
  70682 		Fcode:       int8(16),
  70683 		Fextra_bits: int8(7),
  70684 	},
  70685 	352: {
  70686 		Fcode:       int8(16),
  70687 		Fextra_bits: int8(7),
  70688 	},
  70689 	353: {
  70690 		Fcode:       int8(16),
  70691 		Fextra_bits: int8(7),
  70692 	},
  70693 	354: {
  70694 		Fcode:       int8(16),
  70695 		Fextra_bits: int8(7),
  70696 	},
  70697 	355: {
  70698 		Fcode:       int8(16),
  70699 		Fextra_bits: int8(7),
  70700 	},
  70701 	356: {
  70702 		Fcode:       int8(16),
  70703 		Fextra_bits: int8(7),
  70704 	},
  70705 	357: {
  70706 		Fcode:       int8(16),
  70707 		Fextra_bits: int8(7),
  70708 	},
  70709 	358: {
  70710 		Fcode:       int8(16),
  70711 		Fextra_bits: int8(7),
  70712 	},
  70713 	359: {
  70714 		Fcode:       int8(16),
  70715 		Fextra_bits: int8(7),
  70716 	},
  70717 	360: {
  70718 		Fcode:       int8(16),
  70719 		Fextra_bits: int8(7),
  70720 	},
  70721 	361: {
  70722 		Fcode:       int8(16),
  70723 		Fextra_bits: int8(7),
  70724 	},
  70725 	362: {
  70726 		Fcode:       int8(16),
  70727 		Fextra_bits: int8(7),
  70728 	},
  70729 	363: {
  70730 		Fcode:       int8(16),
  70731 		Fextra_bits: int8(7),
  70732 	},
  70733 	364: {
  70734 		Fcode:       int8(16),
  70735 		Fextra_bits: int8(7),
  70736 	},
  70737 	365: {
  70738 		Fcode:       int8(16),
  70739 		Fextra_bits: int8(7),
  70740 	},
  70741 	366: {
  70742 		Fcode:       int8(16),
  70743 		Fextra_bits: int8(7),
  70744 	},
  70745 	367: {
  70746 		Fcode:       int8(16),
  70747 		Fextra_bits: int8(7),
  70748 	},
  70749 	368: {
  70750 		Fcode:       int8(16),
  70751 		Fextra_bits: int8(7),
  70752 	},
  70753 	369: {
  70754 		Fcode:       int8(16),
  70755 		Fextra_bits: int8(7),
  70756 	},
  70757 	370: {
  70758 		Fcode:       int8(16),
  70759 		Fextra_bits: int8(7),
  70760 	},
  70761 	371: {
  70762 		Fcode:       int8(16),
  70763 		Fextra_bits: int8(7),
  70764 	},
  70765 	372: {
  70766 		Fcode:       int8(16),
  70767 		Fextra_bits: int8(7),
  70768 	},
  70769 	373: {
  70770 		Fcode:       int8(16),
  70771 		Fextra_bits: int8(7),
  70772 	},
  70773 	374: {
  70774 		Fcode:       int8(16),
  70775 		Fextra_bits: int8(7),
  70776 	},
  70777 	375: {
  70778 		Fcode:       int8(16),
  70779 		Fextra_bits: int8(7),
  70780 	},
  70781 	376: {
  70782 		Fcode:       int8(16),
  70783 		Fextra_bits: int8(7),
  70784 	},
  70785 	377: {
  70786 		Fcode:       int8(16),
  70787 		Fextra_bits: int8(7),
  70788 	},
  70789 	378: {
  70790 		Fcode:       int8(16),
  70791 		Fextra_bits: int8(7),
  70792 	},
  70793 	379: {
  70794 		Fcode:       int8(16),
  70795 		Fextra_bits: int8(7),
  70796 	},
  70797 	380: {
  70798 		Fcode:       int8(16),
  70799 		Fextra_bits: int8(7),
  70800 	},
  70801 	381: {
  70802 		Fcode:       int8(16),
  70803 		Fextra_bits: int8(7),
  70804 	},
  70805 	382: {
  70806 		Fcode:       int8(16),
  70807 		Fextra_bits: int8(7),
  70808 	},
  70809 	383: {
  70810 		Fcode:       int8(16),
  70811 		Fextra_bits: int8(7),
  70812 	},
  70813 	384: {
  70814 		Fcode:       int8(16),
  70815 		Fextra_bits: int8(7),
  70816 	},
  70817 	385: {
  70818 		Fcode:       int8(17),
  70819 		Fextra_bits: int8(7),
  70820 	},
  70821 	386: {
  70822 		Fcode:       int8(17),
  70823 		Fextra_bits: int8(7),
  70824 	},
  70825 	387: {
  70826 		Fcode:       int8(17),
  70827 		Fextra_bits: int8(7),
  70828 	},
  70829 	388: {
  70830 		Fcode:       int8(17),
  70831 		Fextra_bits: int8(7),
  70832 	},
  70833 	389: {
  70834 		Fcode:       int8(17),
  70835 		Fextra_bits: int8(7),
  70836 	},
  70837 	390: {
  70838 		Fcode:       int8(17),
  70839 		Fextra_bits: int8(7),
  70840 	},
  70841 	391: {
  70842 		Fcode:       int8(17),
  70843 		Fextra_bits: int8(7),
  70844 	},
  70845 	392: {
  70846 		Fcode:       int8(17),
  70847 		Fextra_bits: int8(7),
  70848 	},
  70849 	393: {
  70850 		Fcode:       int8(17),
  70851 		Fextra_bits: int8(7),
  70852 	},
  70853 	394: {
  70854 		Fcode:       int8(17),
  70855 		Fextra_bits: int8(7),
  70856 	},
  70857 	395: {
  70858 		Fcode:       int8(17),
  70859 		Fextra_bits: int8(7),
  70860 	},
  70861 	396: {
  70862 		Fcode:       int8(17),
  70863 		Fextra_bits: int8(7),
  70864 	},
  70865 	397: {
  70866 		Fcode:       int8(17),
  70867 		Fextra_bits: int8(7),
  70868 	},
  70869 	398: {
  70870 		Fcode:       int8(17),
  70871 		Fextra_bits: int8(7),
  70872 	},
  70873 	399: {
  70874 		Fcode:       int8(17),
  70875 		Fextra_bits: int8(7),
  70876 	},
  70877 	400: {
  70878 		Fcode:       int8(17),
  70879 		Fextra_bits: int8(7),
  70880 	},
  70881 	401: {
  70882 		Fcode:       int8(17),
  70883 		Fextra_bits: int8(7),
  70884 	},
  70885 	402: {
  70886 		Fcode:       int8(17),
  70887 		Fextra_bits: int8(7),
  70888 	},
  70889 	403: {
  70890 		Fcode:       int8(17),
  70891 		Fextra_bits: int8(7),
  70892 	},
  70893 	404: {
  70894 		Fcode:       int8(17),
  70895 		Fextra_bits: int8(7),
  70896 	},
  70897 	405: {
  70898 		Fcode:       int8(17),
  70899 		Fextra_bits: int8(7),
  70900 	},
  70901 	406: {
  70902 		Fcode:       int8(17),
  70903 		Fextra_bits: int8(7),
  70904 	},
  70905 	407: {
  70906 		Fcode:       int8(17),
  70907 		Fextra_bits: int8(7),
  70908 	},
  70909 	408: {
  70910 		Fcode:       int8(17),
  70911 		Fextra_bits: int8(7),
  70912 	},
  70913 	409: {
  70914 		Fcode:       int8(17),
  70915 		Fextra_bits: int8(7),
  70916 	},
  70917 	410: {
  70918 		Fcode:       int8(17),
  70919 		Fextra_bits: int8(7),
  70920 	},
  70921 	411: {
  70922 		Fcode:       int8(17),
  70923 		Fextra_bits: int8(7),
  70924 	},
  70925 	412: {
  70926 		Fcode:       int8(17),
  70927 		Fextra_bits: int8(7),
  70928 	},
  70929 	413: {
  70930 		Fcode:       int8(17),
  70931 		Fextra_bits: int8(7),
  70932 	},
  70933 	414: {
  70934 		Fcode:       int8(17),
  70935 		Fextra_bits: int8(7),
  70936 	},
  70937 	415: {
  70938 		Fcode:       int8(17),
  70939 		Fextra_bits: int8(7),
  70940 	},
  70941 	416: {
  70942 		Fcode:       int8(17),
  70943 		Fextra_bits: int8(7),
  70944 	},
  70945 	417: {
  70946 		Fcode:       int8(17),
  70947 		Fextra_bits: int8(7),
  70948 	},
  70949 	418: {
  70950 		Fcode:       int8(17),
  70951 		Fextra_bits: int8(7),
  70952 	},
  70953 	419: {
  70954 		Fcode:       int8(17),
  70955 		Fextra_bits: int8(7),
  70956 	},
  70957 	420: {
  70958 		Fcode:       int8(17),
  70959 		Fextra_bits: int8(7),
  70960 	},
  70961 	421: {
  70962 		Fcode:       int8(17),
  70963 		Fextra_bits: int8(7),
  70964 	},
  70965 	422: {
  70966 		Fcode:       int8(17),
  70967 		Fextra_bits: int8(7),
  70968 	},
  70969 	423: {
  70970 		Fcode:       int8(17),
  70971 		Fextra_bits: int8(7),
  70972 	},
  70973 	424: {
  70974 		Fcode:       int8(17),
  70975 		Fextra_bits: int8(7),
  70976 	},
  70977 	425: {
  70978 		Fcode:       int8(17),
  70979 		Fextra_bits: int8(7),
  70980 	},
  70981 	426: {
  70982 		Fcode:       int8(17),
  70983 		Fextra_bits: int8(7),
  70984 	},
  70985 	427: {
  70986 		Fcode:       int8(17),
  70987 		Fextra_bits: int8(7),
  70988 	},
  70989 	428: {
  70990 		Fcode:       int8(17),
  70991 		Fextra_bits: int8(7),
  70992 	},
  70993 	429: {
  70994 		Fcode:       int8(17),
  70995 		Fextra_bits: int8(7),
  70996 	},
  70997 	430: {
  70998 		Fcode:       int8(17),
  70999 		Fextra_bits: int8(7),
  71000 	},
  71001 	431: {
  71002 		Fcode:       int8(17),
  71003 		Fextra_bits: int8(7),
  71004 	},
  71005 	432: {
  71006 		Fcode:       int8(17),
  71007 		Fextra_bits: int8(7),
  71008 	},
  71009 	433: {
  71010 		Fcode:       int8(17),
  71011 		Fextra_bits: int8(7),
  71012 	},
  71013 	434: {
  71014 		Fcode:       int8(17),
  71015 		Fextra_bits: int8(7),
  71016 	},
  71017 	435: {
  71018 		Fcode:       int8(17),
  71019 		Fextra_bits: int8(7),
  71020 	},
  71021 	436: {
  71022 		Fcode:       int8(17),
  71023 		Fextra_bits: int8(7),
  71024 	},
  71025 	437: {
  71026 		Fcode:       int8(17),
  71027 		Fextra_bits: int8(7),
  71028 	},
  71029 	438: {
  71030 		Fcode:       int8(17),
  71031 		Fextra_bits: int8(7),
  71032 	},
  71033 	439: {
  71034 		Fcode:       int8(17),
  71035 		Fextra_bits: int8(7),
  71036 	},
  71037 	440: {
  71038 		Fcode:       int8(17),
  71039 		Fextra_bits: int8(7),
  71040 	},
  71041 	441: {
  71042 		Fcode:       int8(17),
  71043 		Fextra_bits: int8(7),
  71044 	},
  71045 	442: {
  71046 		Fcode:       int8(17),
  71047 		Fextra_bits: int8(7),
  71048 	},
  71049 	443: {
  71050 		Fcode:       int8(17),
  71051 		Fextra_bits: int8(7),
  71052 	},
  71053 	444: {
  71054 		Fcode:       int8(17),
  71055 		Fextra_bits: int8(7),
  71056 	},
  71057 	445: {
  71058 		Fcode:       int8(17),
  71059 		Fextra_bits: int8(7),
  71060 	},
  71061 	446: {
  71062 		Fcode:       int8(17),
  71063 		Fextra_bits: int8(7),
  71064 	},
  71065 	447: {
  71066 		Fcode:       int8(17),
  71067 		Fextra_bits: int8(7),
  71068 	},
  71069 	448: {
  71070 		Fcode:       int8(17),
  71071 		Fextra_bits: int8(7),
  71072 	},
  71073 	449: {
  71074 		Fcode:       int8(17),
  71075 		Fextra_bits: int8(7),
  71076 	},
  71077 	450: {
  71078 		Fcode:       int8(17),
  71079 		Fextra_bits: int8(7),
  71080 	},
  71081 	451: {
  71082 		Fcode:       int8(17),
  71083 		Fextra_bits: int8(7),
  71084 	},
  71085 	452: {
  71086 		Fcode:       int8(17),
  71087 		Fextra_bits: int8(7),
  71088 	},
  71089 	453: {
  71090 		Fcode:       int8(17),
  71091 		Fextra_bits: int8(7),
  71092 	},
  71093 	454: {
  71094 		Fcode:       int8(17),
  71095 		Fextra_bits: int8(7),
  71096 	},
  71097 	455: {
  71098 		Fcode:       int8(17),
  71099 		Fextra_bits: int8(7),
  71100 	},
  71101 	456: {
  71102 		Fcode:       int8(17),
  71103 		Fextra_bits: int8(7),
  71104 	},
  71105 	457: {
  71106 		Fcode:       int8(17),
  71107 		Fextra_bits: int8(7),
  71108 	},
  71109 	458: {
  71110 		Fcode:       int8(17),
  71111 		Fextra_bits: int8(7),
  71112 	},
  71113 	459: {
  71114 		Fcode:       int8(17),
  71115 		Fextra_bits: int8(7),
  71116 	},
  71117 	460: {
  71118 		Fcode:       int8(17),
  71119 		Fextra_bits: int8(7),
  71120 	},
  71121 	461: {
  71122 		Fcode:       int8(17),
  71123 		Fextra_bits: int8(7),
  71124 	},
  71125 	462: {
  71126 		Fcode:       int8(17),
  71127 		Fextra_bits: int8(7),
  71128 	},
  71129 	463: {
  71130 		Fcode:       int8(17),
  71131 		Fextra_bits: int8(7),
  71132 	},
  71133 	464: {
  71134 		Fcode:       int8(17),
  71135 		Fextra_bits: int8(7),
  71136 	},
  71137 	465: {
  71138 		Fcode:       int8(17),
  71139 		Fextra_bits: int8(7),
  71140 	},
  71141 	466: {
  71142 		Fcode:       int8(17),
  71143 		Fextra_bits: int8(7),
  71144 	},
  71145 	467: {
  71146 		Fcode:       int8(17),
  71147 		Fextra_bits: int8(7),
  71148 	},
  71149 	468: {
  71150 		Fcode:       int8(17),
  71151 		Fextra_bits: int8(7),
  71152 	},
  71153 	469: {
  71154 		Fcode:       int8(17),
  71155 		Fextra_bits: int8(7),
  71156 	},
  71157 	470: {
  71158 		Fcode:       int8(17),
  71159 		Fextra_bits: int8(7),
  71160 	},
  71161 	471: {
  71162 		Fcode:       int8(17),
  71163 		Fextra_bits: int8(7),
  71164 	},
  71165 	472: {
  71166 		Fcode:       int8(17),
  71167 		Fextra_bits: int8(7),
  71168 	},
  71169 	473: {
  71170 		Fcode:       int8(17),
  71171 		Fextra_bits: int8(7),
  71172 	},
  71173 	474: {
  71174 		Fcode:       int8(17),
  71175 		Fextra_bits: int8(7),
  71176 	},
  71177 	475: {
  71178 		Fcode:       int8(17),
  71179 		Fextra_bits: int8(7),
  71180 	},
  71181 	476: {
  71182 		Fcode:       int8(17),
  71183 		Fextra_bits: int8(7),
  71184 	},
  71185 	477: {
  71186 		Fcode:       int8(17),
  71187 		Fextra_bits: int8(7),
  71188 	},
  71189 	478: {
  71190 		Fcode:       int8(17),
  71191 		Fextra_bits: int8(7),
  71192 	},
  71193 	479: {
  71194 		Fcode:       int8(17),
  71195 		Fextra_bits: int8(7),
  71196 	},
  71197 	480: {
  71198 		Fcode:       int8(17),
  71199 		Fextra_bits: int8(7),
  71200 	},
  71201 	481: {
  71202 		Fcode:       int8(17),
  71203 		Fextra_bits: int8(7),
  71204 	},
  71205 	482: {
  71206 		Fcode:       int8(17),
  71207 		Fextra_bits: int8(7),
  71208 	},
  71209 	483: {
  71210 		Fcode:       int8(17),
  71211 		Fextra_bits: int8(7),
  71212 	},
  71213 	484: {
  71214 		Fcode:       int8(17),
  71215 		Fextra_bits: int8(7),
  71216 	},
  71217 	485: {
  71218 		Fcode:       int8(17),
  71219 		Fextra_bits: int8(7),
  71220 	},
  71221 	486: {
  71222 		Fcode:       int8(17),
  71223 		Fextra_bits: int8(7),
  71224 	},
  71225 	487: {
  71226 		Fcode:       int8(17),
  71227 		Fextra_bits: int8(7),
  71228 	},
  71229 	488: {
  71230 		Fcode:       int8(17),
  71231 		Fextra_bits: int8(7),
  71232 	},
  71233 	489: {
  71234 		Fcode:       int8(17),
  71235 		Fextra_bits: int8(7),
  71236 	},
  71237 	490: {
  71238 		Fcode:       int8(17),
  71239 		Fextra_bits: int8(7),
  71240 	},
  71241 	491: {
  71242 		Fcode:       int8(17),
  71243 		Fextra_bits: int8(7),
  71244 	},
  71245 	492: {
  71246 		Fcode:       int8(17),
  71247 		Fextra_bits: int8(7),
  71248 	},
  71249 	493: {
  71250 		Fcode:       int8(17),
  71251 		Fextra_bits: int8(7),
  71252 	},
  71253 	494: {
  71254 		Fcode:       int8(17),
  71255 		Fextra_bits: int8(7),
  71256 	},
  71257 	495: {
  71258 		Fcode:       int8(17),
  71259 		Fextra_bits: int8(7),
  71260 	},
  71261 	496: {
  71262 		Fcode:       int8(17),
  71263 		Fextra_bits: int8(7),
  71264 	},
  71265 	497: {
  71266 		Fcode:       int8(17),
  71267 		Fextra_bits: int8(7),
  71268 	},
  71269 	498: {
  71270 		Fcode:       int8(17),
  71271 		Fextra_bits: int8(7),
  71272 	},
  71273 	499: {
  71274 		Fcode:       int8(17),
  71275 		Fextra_bits: int8(7),
  71276 	},
  71277 	500: {
  71278 		Fcode:       int8(17),
  71279 		Fextra_bits: int8(7),
  71280 	},
  71281 	501: {
  71282 		Fcode:       int8(17),
  71283 		Fextra_bits: int8(7),
  71284 	},
  71285 	502: {
  71286 		Fcode:       int8(17),
  71287 		Fextra_bits: int8(7),
  71288 	},
  71289 	503: {
  71290 		Fcode:       int8(17),
  71291 		Fextra_bits: int8(7),
  71292 	},
  71293 	504: {
  71294 		Fcode:       int8(17),
  71295 		Fextra_bits: int8(7),
  71296 	},
  71297 	505: {
  71298 		Fcode:       int8(17),
  71299 		Fextra_bits: int8(7),
  71300 	},
  71301 	506: {
  71302 		Fcode:       int8(17),
  71303 		Fextra_bits: int8(7),
  71304 	},
  71305 	507: {
  71306 		Fcode:       int8(17),
  71307 		Fextra_bits: int8(7),
  71308 	},
  71309 	508: {
  71310 		Fcode:       int8(17),
  71311 		Fextra_bits: int8(7),
  71312 	},
  71313 	509: {
  71314 		Fcode:       int8(17),
  71315 		Fextra_bits: int8(7),
  71316 	},
  71317 	510: {
  71318 		Fcode:       int8(17),
  71319 		Fextra_bits: int8(7),
  71320 	},
  71321 	511: {
  71322 		Fcode:       int8(17),
  71323 		Fextra_bits: int8(7),
  71324 	},
  71325 }
  71326 
  71327 var kPrefixEncodeExtraBitsValue = [512]uint8_t{
  71328 	6:   uint8(1),
  71329 	8:   uint8(1),
  71330 	10:  uint8(1),
  71331 	11:  uint8(2),
  71332 	12:  uint8(3),
  71333 	14:  uint8(1),
  71334 	15:  uint8(2),
  71335 	16:  uint8(3),
  71336 	18:  uint8(1),
  71337 	19:  uint8(2),
  71338 	20:  uint8(3),
  71339 	21:  uint8(4),
  71340 	22:  uint8(5),
  71341 	23:  uint8(6),
  71342 	24:  uint8(7),
  71343 	26:  uint8(1),
  71344 	27:  uint8(2),
  71345 	28:  uint8(3),
  71346 	29:  uint8(4),
  71347 	30:  uint8(5),
  71348 	31:  uint8(6),
  71349 	32:  uint8(7),
  71350 	34:  uint8(1),
  71351 	35:  uint8(2),
  71352 	36:  uint8(3),
  71353 	37:  uint8(4),
  71354 	38:  uint8(5),
  71355 	39:  uint8(6),
  71356 	40:  uint8(7),
  71357 	41:  uint8(8),
  71358 	42:  uint8(9),
  71359 	43:  uint8(10),
  71360 	44:  uint8(11),
  71361 	45:  uint8(12),
  71362 	46:  uint8(13),
  71363 	47:  uint8(14),
  71364 	48:  uint8(15),
  71365 	50:  uint8(1),
  71366 	51:  uint8(2),
  71367 	52:  uint8(3),
  71368 	53:  uint8(4),
  71369 	54:  uint8(5),
  71370 	55:  uint8(6),
  71371 	56:  uint8(7),
  71372 	57:  uint8(8),
  71373 	58:  uint8(9),
  71374 	59:  uint8(10),
  71375 	60:  uint8(11),
  71376 	61:  uint8(12),
  71377 	62:  uint8(13),
  71378 	63:  uint8(14),
  71379 	64:  uint8(15),
  71380 	66:  uint8(1),
  71381 	67:  uint8(2),
  71382 	68:  uint8(3),
  71383 	69:  uint8(4),
  71384 	70:  uint8(5),
  71385 	71:  uint8(6),
  71386 	72:  uint8(7),
  71387 	73:  uint8(8),
  71388 	74:  uint8(9),
  71389 	75:  uint8(10),
  71390 	76:  uint8(11),
  71391 	77:  uint8(12),
  71392 	78:  uint8(13),
  71393 	79:  uint8(14),
  71394 	80:  uint8(15),
  71395 	81:  uint8(16),
  71396 	82:  uint8(17),
  71397 	83:  uint8(18),
  71398 	84:  uint8(19),
  71399 	85:  uint8(20),
  71400 	86:  uint8(21),
  71401 	87:  uint8(22),
  71402 	88:  uint8(23),
  71403 	89:  uint8(24),
  71404 	90:  uint8(25),
  71405 	91:  uint8(26),
  71406 	92:  uint8(27),
  71407 	93:  uint8(28),
  71408 	94:  uint8(29),
  71409 	95:  uint8(30),
  71410 	96:  uint8(31),
  71411 	98:  uint8(1),
  71412 	99:  uint8(2),
  71413 	100: uint8(3),
  71414 	101: uint8(4),
  71415 	102: uint8(5),
  71416 	103: uint8(6),
  71417 	104: uint8(7),
  71418 	105: uint8(8),
  71419 	106: uint8(9),
  71420 	107: uint8(10),
  71421 	108: uint8(11),
  71422 	109: uint8(12),
  71423 	110: uint8(13),
  71424 	111: uint8(14),
  71425 	112: uint8(15),
  71426 	113: uint8(16),
  71427 	114: uint8(17),
  71428 	115: uint8(18),
  71429 	116: uint8(19),
  71430 	117: uint8(20),
  71431 	118: uint8(21),
  71432 	119: uint8(22),
  71433 	120: uint8(23),
  71434 	121: uint8(24),
  71435 	122: uint8(25),
  71436 	123: uint8(26),
  71437 	124: uint8(27),
  71438 	125: uint8(28),
  71439 	126: uint8(29),
  71440 	127: uint8(30),
  71441 	128: uint8(31),
  71442 	130: uint8(1),
  71443 	131: uint8(2),
  71444 	132: uint8(3),
  71445 	133: uint8(4),
  71446 	134: uint8(5),
  71447 	135: uint8(6),
  71448 	136: uint8(7),
  71449 	137: uint8(8),
  71450 	138: uint8(9),
  71451 	139: uint8(10),
  71452 	140: uint8(11),
  71453 	141: uint8(12),
  71454 	142: uint8(13),
  71455 	143: uint8(14),
  71456 	144: uint8(15),
  71457 	145: uint8(16),
  71458 	146: uint8(17),
  71459 	147: uint8(18),
  71460 	148: uint8(19),
  71461 	149: uint8(20),
  71462 	150: uint8(21),
  71463 	151: uint8(22),
  71464 	152: uint8(23),
  71465 	153: uint8(24),
  71466 	154: uint8(25),
  71467 	155: uint8(26),
  71468 	156: uint8(27),
  71469 	157: uint8(28),
  71470 	158: uint8(29),
  71471 	159: uint8(30),
  71472 	160: uint8(31),
  71473 	161: uint8(32),
  71474 	162: uint8(33),
  71475 	163: uint8(34),
  71476 	164: uint8(35),
  71477 	165: uint8(36),
  71478 	166: uint8(37),
  71479 	167: uint8(38),
  71480 	168: uint8(39),
  71481 	169: uint8(40),
  71482 	170: uint8(41),
  71483 	171: uint8(42),
  71484 	172: uint8(43),
  71485 	173: uint8(44),
  71486 	174: uint8(45),
  71487 	175: uint8(46),
  71488 	176: uint8(47),
  71489 	177: uint8(48),
  71490 	178: uint8(49),
  71491 	179: uint8(50),
  71492 	180: uint8(51),
  71493 	181: uint8(52),
  71494 	182: uint8(53),
  71495 	183: uint8(54),
  71496 	184: uint8(55),
  71497 	185: uint8(56),
  71498 	186: uint8(57),
  71499 	187: uint8(58),
  71500 	188: uint8(59),
  71501 	189: uint8(60),
  71502 	190: uint8(61),
  71503 	191: uint8(62),
  71504 	192: uint8(63),
  71505 	194: uint8(1),
  71506 	195: uint8(2),
  71507 	196: uint8(3),
  71508 	197: uint8(4),
  71509 	198: uint8(5),
  71510 	199: uint8(6),
  71511 	200: uint8(7),
  71512 	201: uint8(8),
  71513 	202: uint8(9),
  71514 	203: uint8(10),
  71515 	204: uint8(11),
  71516 	205: uint8(12),
  71517 	206: uint8(13),
  71518 	207: uint8(14),
  71519 	208: uint8(15),
  71520 	209: uint8(16),
  71521 	210: uint8(17),
  71522 	211: uint8(18),
  71523 	212: uint8(19),
  71524 	213: uint8(20),
  71525 	214: uint8(21),
  71526 	215: uint8(22),
  71527 	216: uint8(23),
  71528 	217: uint8(24),
  71529 	218: uint8(25),
  71530 	219: uint8(26),
  71531 	220: uint8(27),
  71532 	221: uint8(28),
  71533 	222: uint8(29),
  71534 	223: uint8(30),
  71535 	224: uint8(31),
  71536 	225: uint8(32),
  71537 	226: uint8(33),
  71538 	227: uint8(34),
  71539 	228: uint8(35),
  71540 	229: uint8(36),
  71541 	230: uint8(37),
  71542 	231: uint8(38),
  71543 	232: uint8(39),
  71544 	233: uint8(40),
  71545 	234: uint8(41),
  71546 	235: uint8(42),
  71547 	236: uint8(43),
  71548 	237: uint8(44),
  71549 	238: uint8(45),
  71550 	239: uint8(46),
  71551 	240: uint8(47),
  71552 	241: uint8(48),
  71553 	242: uint8(49),
  71554 	243: uint8(50),
  71555 	244: uint8(51),
  71556 	245: uint8(52),
  71557 	246: uint8(53),
  71558 	247: uint8(54),
  71559 	248: uint8(55),
  71560 	249: uint8(56),
  71561 	250: uint8(57),
  71562 	251: uint8(58),
  71563 	252: uint8(59),
  71564 	253: uint8(60),
  71565 	254: uint8(61),
  71566 	255: uint8(62),
  71567 	256: uint8(63),
  71568 	258: uint8(1),
  71569 	259: uint8(2),
  71570 	260: uint8(3),
  71571 	261: uint8(4),
  71572 	262: uint8(5),
  71573 	263: uint8(6),
  71574 	264: uint8(7),
  71575 	265: uint8(8),
  71576 	266: uint8(9),
  71577 	267: uint8(10),
  71578 	268: uint8(11),
  71579 	269: uint8(12),
  71580 	270: uint8(13),
  71581 	271: uint8(14),
  71582 	272: uint8(15),
  71583 	273: uint8(16),
  71584 	274: uint8(17),
  71585 	275: uint8(18),
  71586 	276: uint8(19),
  71587 	277: uint8(20),
  71588 	278: uint8(21),
  71589 	279: uint8(22),
  71590 	280: uint8(23),
  71591 	281: uint8(24),
  71592 	282: uint8(25),
  71593 	283: uint8(26),
  71594 	284: uint8(27),
  71595 	285: uint8(28),
  71596 	286: uint8(29),
  71597 	287: uint8(30),
  71598 	288: uint8(31),
  71599 	289: uint8(32),
  71600 	290: uint8(33),
  71601 	291: uint8(34),
  71602 	292: uint8(35),
  71603 	293: uint8(36),
  71604 	294: uint8(37),
  71605 	295: uint8(38),
  71606 	296: uint8(39),
  71607 	297: uint8(40),
  71608 	298: uint8(41),
  71609 	299: uint8(42),
  71610 	300: uint8(43),
  71611 	301: uint8(44),
  71612 	302: uint8(45),
  71613 	303: uint8(46),
  71614 	304: uint8(47),
  71615 	305: uint8(48),
  71616 	306: uint8(49),
  71617 	307: uint8(50),
  71618 	308: uint8(51),
  71619 	309: uint8(52),
  71620 	310: uint8(53),
  71621 	311: uint8(54),
  71622 	312: uint8(55),
  71623 	313: uint8(56),
  71624 	314: uint8(57),
  71625 	315: uint8(58),
  71626 	316: uint8(59),
  71627 	317: uint8(60),
  71628 	318: uint8(61),
  71629 	319: uint8(62),
  71630 	320: uint8(63),
  71631 	321: uint8(64),
  71632 	322: uint8(65),
  71633 	323: uint8(66),
  71634 	324: uint8(67),
  71635 	325: uint8(68),
  71636 	326: uint8(69),
  71637 	327: uint8(70),
  71638 	328: uint8(71),
  71639 	329: uint8(72),
  71640 	330: uint8(73),
  71641 	331: uint8(74),
  71642 	332: uint8(75),
  71643 	333: uint8(76),
  71644 	334: uint8(77),
  71645 	335: uint8(78),
  71646 	336: uint8(79),
  71647 	337: uint8(80),
  71648 	338: uint8(81),
  71649 	339: uint8(82),
  71650 	340: uint8(83),
  71651 	341: uint8(84),
  71652 	342: uint8(85),
  71653 	343: uint8(86),
  71654 	344: uint8(87),
  71655 	345: uint8(88),
  71656 	346: uint8(89),
  71657 	347: uint8(90),
  71658 	348: uint8(91),
  71659 	349: uint8(92),
  71660 	350: uint8(93),
  71661 	351: uint8(94),
  71662 	352: uint8(95),
  71663 	353: uint8(96),
  71664 	354: uint8(97),
  71665 	355: uint8(98),
  71666 	356: uint8(99),
  71667 	357: uint8(100),
  71668 	358: uint8(101),
  71669 	359: uint8(102),
  71670 	360: uint8(103),
  71671 	361: uint8(104),
  71672 	362: uint8(105),
  71673 	363: uint8(106),
  71674 	364: uint8(107),
  71675 	365: uint8(108),
  71676 	366: uint8(109),
  71677 	367: uint8(110),
  71678 	368: uint8(111),
  71679 	369: uint8(112),
  71680 	370: uint8(113),
  71681 	371: uint8(114),
  71682 	372: uint8(115),
  71683 	373: uint8(116),
  71684 	374: uint8(117),
  71685 	375: uint8(118),
  71686 	376: uint8(119),
  71687 	377: uint8(120),
  71688 	378: uint8(121),
  71689 	379: uint8(122),
  71690 	380: uint8(123),
  71691 	381: uint8(124),
  71692 	382: uint8(125),
  71693 	383: uint8(126),
  71694 	384: uint8(127),
  71695 	386: uint8(1),
  71696 	387: uint8(2),
  71697 	388: uint8(3),
  71698 	389: uint8(4),
  71699 	390: uint8(5),
  71700 	391: uint8(6),
  71701 	392: uint8(7),
  71702 	393: uint8(8),
  71703 	394: uint8(9),
  71704 	395: uint8(10),
  71705 	396: uint8(11),
  71706 	397: uint8(12),
  71707 	398: uint8(13),
  71708 	399: uint8(14),
  71709 	400: uint8(15),
  71710 	401: uint8(16),
  71711 	402: uint8(17),
  71712 	403: uint8(18),
  71713 	404: uint8(19),
  71714 	405: uint8(20),
  71715 	406: uint8(21),
  71716 	407: uint8(22),
  71717 	408: uint8(23),
  71718 	409: uint8(24),
  71719 	410: uint8(25),
  71720 	411: uint8(26),
  71721 	412: uint8(27),
  71722 	413: uint8(28),
  71723 	414: uint8(29),
  71724 	415: uint8(30),
  71725 	416: uint8(31),
  71726 	417: uint8(32),
  71727 	418: uint8(33),
  71728 	419: uint8(34),
  71729 	420: uint8(35),
  71730 	421: uint8(36),
  71731 	422: uint8(37),
  71732 	423: uint8(38),
  71733 	424: uint8(39),
  71734 	425: uint8(40),
  71735 	426: uint8(41),
  71736 	427: uint8(42),
  71737 	428: uint8(43),
  71738 	429: uint8(44),
  71739 	430: uint8(45),
  71740 	431: uint8(46),
  71741 	432: uint8(47),
  71742 	433: uint8(48),
  71743 	434: uint8(49),
  71744 	435: uint8(50),
  71745 	436: uint8(51),
  71746 	437: uint8(52),
  71747 	438: uint8(53),
  71748 	439: uint8(54),
  71749 	440: uint8(55),
  71750 	441: uint8(56),
  71751 	442: uint8(57),
  71752 	443: uint8(58),
  71753 	444: uint8(59),
  71754 	445: uint8(60),
  71755 	446: uint8(61),
  71756 	447: uint8(62),
  71757 	448: uint8(63),
  71758 	449: uint8(64),
  71759 	450: uint8(65),
  71760 	451: uint8(66),
  71761 	452: uint8(67),
  71762 	453: uint8(68),
  71763 	454: uint8(69),
  71764 	455: uint8(70),
  71765 	456: uint8(71),
  71766 	457: uint8(72),
  71767 	458: uint8(73),
  71768 	459: uint8(74),
  71769 	460: uint8(75),
  71770 	461: uint8(76),
  71771 	462: uint8(77),
  71772 	463: uint8(78),
  71773 	464: uint8(79),
  71774 	465: uint8(80),
  71775 	466: uint8(81),
  71776 	467: uint8(82),
  71777 	468: uint8(83),
  71778 	469: uint8(84),
  71779 	470: uint8(85),
  71780 	471: uint8(86),
  71781 	472: uint8(87),
  71782 	473: uint8(88),
  71783 	474: uint8(89),
  71784 	475: uint8(90),
  71785 	476: uint8(91),
  71786 	477: uint8(92),
  71787 	478: uint8(93),
  71788 	479: uint8(94),
  71789 	480: uint8(95),
  71790 	481: uint8(96),
  71791 	482: uint8(97),
  71792 	483: uint8(98),
  71793 	484: uint8(99),
  71794 	485: uint8(100),
  71795 	486: uint8(101),
  71796 	487: uint8(102),
  71797 	488: uint8(103),
  71798 	489: uint8(104),
  71799 	490: uint8(105),
  71800 	491: uint8(106),
  71801 	492: uint8(107),
  71802 	493: uint8(108),
  71803 	494: uint8(109),
  71804 	495: uint8(110),
  71805 	496: uint8(111),
  71806 	497: uint8(112),
  71807 	498: uint8(113),
  71808 	499: uint8(114),
  71809 	500: uint8(115),
  71810 	501: uint8(116),
  71811 	502: uint8(117),
  71812 	503: uint8(118),
  71813 	504: uint8(119),
  71814 	505: uint8(120),
  71815 	506: uint8(121),
  71816 	507: uint8(122),
  71817 	508: uint8(123),
  71818 	509: uint8(124),
  71819 	510: uint8(125),
  71820 	511: uint8(126),
  71821 }
  71822 
  71823 // C documentation
  71824 //
  71825 //	// lookup table for small values of int*log2(int) * (1 << LOG_2_PRECISION_BITS).
  71826 //	// Obtained in Python with:
  71827 //	// a=[ "%d"%i if i<(1<<32) else "%dull"%i
  71828 //	//     for i in [ round((1<<LOG_2_PRECISION_BITS)*math.log2(i)*i) if i
  71829 //	//     else 0 for i in range(256)]]
  71830 //	// print(',\n '.join([','.join(v) for v in batched([i.rjust(15)
  71831 //	//                      for i in a],4)]))
  71832 var kSLog2Table = [256]uint64_t{
  71833 	2:   uint64(16777216),
  71834 	3:   uint64(39886887),
  71835 	4:   uint64(67108864),
  71836 	5:   uint64(97388723),
  71837 	6:   uint64(130105423),
  71838 	7:   uint64(164848600),
  71839 	8:   uint64(201326592),
  71840 	9:   uint64(239321324),
  71841 	10:  uint64(278663526),
  71842 	11:  uint64(319217973),
  71843 	12:  uint64(360874141),
  71844 	13:  uint64(403539997),
  71845 	14:  uint64(447137711),
  71846 	15:  uint64(491600606),
  71847 	16:  uint64(536870912),
  71848 	17:  uint64(582898099),
  71849 	18:  uint64(629637592),
  71850 	19:  uint64(677049776),
  71851 	20:  uint64(725099212),
  71852 	21:  uint64(773754010),
  71853 	22:  uint64(822985323),
  71854 	23:  uint64(872766924),
  71855 	24:  uint64(923074875),
  71856 	25:  uint64(973887230),
  71857 	26:  uint64(1025183802),
  71858 	27:  uint64(1076945958),
  71859 	28:  uint64(1129156447),
  71860 	29:  uint64(1181799249),
  71861 	30:  uint64(1234859451),
  71862 	31:  uint64(1288323135),
  71863 	32:  uint64(1342177280),
  71864 	33:  uint64(1396409681),
  71865 	34:  uint64(1451008871),
  71866 	35:  uint64(1505964059),
  71867 	36:  uint64(1561265072),
  71868 	37:  uint64(1616902301),
  71869 	38:  uint64(1672866655),
  71870 	39:  uint64(1729149526),
  71871 	40:  uint64(1785742744),
  71872 	41:  uint64(1842638548),
  71873 	42:  uint64(1899829557),
  71874 	43:  uint64(1957308741),
  71875 	44:  uint64(2015069397),
  71876 	45:  uint64(2073105127),
  71877 	46:  uint64(2131409817),
  71878 	47:  uint64(2189977618),
  71879 	48:  uint64(2248802933),
  71880 	49:  uint64(2307880396),
  71881 	50:  uint64(2367204859),
  71882 	51:  uint64(2426771383),
  71883 	52:  uint64(2486575220),
  71884 	53:  uint64(2546611805),
  71885 	54:  uint64(2606876748),
  71886 	55:  uint64(2667365819),
  71887 	56:  uint64(2728074942),
  71888 	57:  uint64(2789000187),
  71889 	58:  uint64(2850137762),
  71890 	59:  uint64(2911484006),
  71891 	60:  uint64(2973035382),
  71892 	61:  uint64(3034788471),
  71893 	62:  uint64(3096739966),
  71894 	63:  uint64(3158886666),
  71895 	64:  uint64(3221225472),
  71896 	65:  uint64(3283753383),
  71897 	66:  uint64(3346467489),
  71898 	67:  uint64(3409364969),
  71899 	68:  uint64(3472443085),
  71900 	69:  uint64(3535699182),
  71901 	70:  uint64(3599130679),
  71902 	71:  uint64(3662735070),
  71903 	72:  uint64(3726509920),
  71904 	73:  uint64(3790452862),
  71905 	74:  uint64(3854561593),
  71906 	75:  uint64(3918833872),
  71907 	76:  uint64(3983267519),
  71908 	77:  uint64(4047860410),
  71909 	78:  uint64(4112610476),
  71910 	79:  uint64(4177515704),
  71911 	80:  uint64(4242574127),
  71912 	81:  uint64(4307783833),
  71913 	82:  uint64(4373142952),
  71914 	83:  uint64(4438649662),
  71915 	84:  uint64(4504302186),
  71916 	85:  uint64(4570098787),
  71917 	86:  uint64(4636037770),
  71918 	87:  uint64(4702117480),
  71919 	88:  uint64(4768336298),
  71920 	89:  uint64(4834692645),
  71921 	90:  uint64(4901184974),
  71922 	91:  uint64(4967811774),
  71923 	92:  uint64(5034571569),
  71924 	93:  uint64(5101462912),
  71925 	94:  uint64(5168484389),
  71926 	95:  uint64(5235634615),
  71927 	96:  uint64(5302912235),
  71928 	97:  uint64(5370315922),
  71929 	98:  uint64(5437844376),
  71930 	99:  uint64(5505496324),
  71931 	100: uint64(5573270518),
  71932 	101: uint64(5641165737),
  71933 	102: uint64(5709180782),
  71934 	103: uint64(5777314477),
  71935 	104: uint64(5845565671),
  71936 	105: uint64(5913933235),
  71937 	106: uint64(5982416059),
  71938 	107: uint64(6051013057),
  71939 	108: uint64(6119723161),
  71940 	109: uint64(6188545324),
  71941 	110: uint64(6257478518),
  71942 	111: uint64(6326521733),
  71943 	112: uint64(6395673979),
  71944 	113: uint64(6464934282),
  71945 	114: uint64(6534301685),
  71946 	115: uint64(6603775250),
  71947 	116: uint64(6673354052),
  71948 	117: uint64(6743037185),
  71949 	118: uint64(6812823756),
  71950 	119: uint64(6882712890),
  71951 	120: uint64(6952703725),
  71952 	121: uint64(7022795412),
  71953 	122: uint64(7092987118),
  71954 	123: uint64(7163278025),
  71955 	124: uint64(7233667324),
  71956 	125: uint64(7304154222),
  71957 	126: uint64(7374737939),
  71958 	127: uint64(7445417707),
  71959 	128: uint64(7516192768),
  71960 	129: uint64(7587062379),
  71961 	130: uint64(7658025806),
  71962 	131: uint64(7729082328),
  71963 	132: uint64(7800231234),
  71964 	133: uint64(7871471825),
  71965 	134: uint64(7942803410),
  71966 	135: uint64(8014225311),
  71967 	136: uint64(8085736859),
  71968 	137: uint64(8157337394),
  71969 	138: uint64(8229026267),
  71970 	139: uint64(8300802839),
  71971 	140: uint64(8372666477),
  71972 	141: uint64(8444616560),
  71973 	142: uint64(8516652476),
  71974 	143: uint64(8588773618),
  71975 	144: uint64(8660979393),
  71976 	145: uint64(8733269211),
  71977 	146: uint64(8805642493),
  71978 	147: uint64(8878098667),
  71979 	148: uint64(8950637170),
  71980 	149: uint64(9023257446),
  71981 	150: uint64(9095958945),
  71982 	151: uint64(9168741125),
  71983 	152: uint64(9241603454),
  71984 	153: uint64(9314545403),
  71985 	154: uint64(9387566451),
  71986 	155: uint64(9460666086),
  71987 	156: uint64(9533843800),
  71988 	157: uint64(9607099093),
  71989 	158: uint64(9680431471),
  71990 	159: uint64(9753840445),
  71991 	160: uint64(9827325535),
  71992 	161: uint64(9900886263),
  71993 	162: uint64(9974522161),
  71994 	163: uint64(10048232765),
  71995 	164: uint64(10122017615),
  71996 	165: uint64(10195876260),
  71997 	166: uint64(10269808253),
  71998 	167: uint64(10343813150),
  71999 	168: uint64(10417890516),
  72000 	169: uint64(10492039919),
  72001 	170: uint64(10566260934),
  72002 	171: uint64(10640553138),
  72003 	172: uint64(10714916116),
  72004 	173: uint64(10789349456),
  72005 	174: uint64(10863852751),
  72006 	175: uint64(10938425600),
  72007 	176: uint64(11013067604),
  72008 	177: uint64(11087778372),
  72009 	178: uint64(11162557513),
  72010 	179: uint64(11237404645),
  72011 	180: uint64(11312319387),
  72012 	181: uint64(11387301364),
  72013 	182: uint64(11462350205),
  72014 	183: uint64(11537465541),
  72015 	184: uint64(11612647010),
  72016 	185: uint64(11687894253),
  72017 	186: uint64(11763206912),
  72018 	187: uint64(11838584638),
  72019 	188: uint64(11914027082),
  72020 	189: uint64(11989533899),
  72021 	190: uint64(12065104750),
  72022 	191: uint64(12140739296),
  72023 	192: uint64(12216437206),
  72024 	193: uint64(12292198148),
  72025 	194: uint64(12368021795),
  72026 	195: uint64(12443907826),
  72027 	196: uint64(12519855920),
  72028 	197: uint64(12595865759),
  72029 	198: uint64(12671937032),
  72030 	199: uint64(12748069427),
  72031 	200: uint64(12824262637),
  72032 	201: uint64(12900516358),
  72033 	202: uint64(12976830290),
  72034 	203: uint64(13053204134),
  72035 	204: uint64(13129637595),
  72036 	205: uint64(13206130381),
  72037 	206: uint64(13282682202),
  72038 	207: uint64(13359292772),
  72039 	208: uint64(13435961806),
  72040 	209: uint64(13512689025),
  72041 	210: uint64(13589474149),
  72042 	211: uint64(13666316903),
  72043 	212: uint64(13743217014),
  72044 	213: uint64(13820174211),
  72045 	214: uint64(13897188225),
  72046 	215: uint64(13974258793),
  72047 	216: uint64(14051385649),
  72048 	217: uint64(14128568535),
  72049 	218: uint64(14205807192),
  72050 	219: uint64(14283101363),
  72051 	220: uint64(14360450796),
  72052 	221: uint64(14437855239),
  72053 	222: uint64(14515314443),
  72054 	223: uint64(14592828162),
  72055 	224: uint64(14670396151),
  72056 	225: uint64(14748018167),
  72057 	226: uint64(14825693972),
  72058 	227: uint64(14903423326),
  72059 	228: uint64(14981205995),
  72060 	229: uint64(15059041743),
  72061 	230: uint64(15136930339),
  72062 	231: uint64(15214871554),
  72063 	232: uint64(15292865160),
  72064 	233: uint64(15370910930),
  72065 	234: uint64(15449008641),
  72066 	235: uint64(15527158071),
  72067 	236: uint64(15605359001),
  72068 	237: uint64(15683611210),
  72069 	238: uint64(15761914485),
  72070 	239: uint64(15840268608),
  72071 	240: uint64(15918673369),
  72072 	241: uint64(15997128556),
  72073 	242: uint64(16075633960),
  72074 	243: uint64(16154189373),
  72075 	244: uint64(16232794589),
  72076 	245: uint64(16311449405),
  72077 	246: uint64(16390153617),
  72078 	247: uint64(16468907026),
  72079 	248: uint64(16547709431),
  72080 	249: uint64(16626560636),
  72081 	250: uint64(16705460444),
  72082 	251: uint64(16784408661),
  72083 	252: uint64(16863405094),
  72084 	253: uint64(16942449552),
  72085 	254: uint64(17021541845),
  72086 	255: uint64(17100681785),
  72087 }
  72088 
  72089 var kVP8Log2Range = [128]uint8_t{
  72090 	0:   uint8(7),
  72091 	1:   uint8(6),
  72092 	2:   uint8(6),
  72093 	3:   uint8(5),
  72094 	4:   uint8(5),
  72095 	5:   uint8(5),
  72096 	6:   uint8(5),
  72097 	7:   uint8(4),
  72098 	8:   uint8(4),
  72099 	9:   uint8(4),
  72100 	10:  uint8(4),
  72101 	11:  uint8(4),
  72102 	12:  uint8(4),
  72103 	13:  uint8(4),
  72104 	14:  uint8(4),
  72105 	15:  uint8(3),
  72106 	16:  uint8(3),
  72107 	17:  uint8(3),
  72108 	18:  uint8(3),
  72109 	19:  uint8(3),
  72110 	20:  uint8(3),
  72111 	21:  uint8(3),
  72112 	22:  uint8(3),
  72113 	23:  uint8(3),
  72114 	24:  uint8(3),
  72115 	25:  uint8(3),
  72116 	26:  uint8(3),
  72117 	27:  uint8(3),
  72118 	28:  uint8(3),
  72119 	29:  uint8(3),
  72120 	30:  uint8(3),
  72121 	31:  uint8(2),
  72122 	32:  uint8(2),
  72123 	33:  uint8(2),
  72124 	34:  uint8(2),
  72125 	35:  uint8(2),
  72126 	36:  uint8(2),
  72127 	37:  uint8(2),
  72128 	38:  uint8(2),
  72129 	39:  uint8(2),
  72130 	40:  uint8(2),
  72131 	41:  uint8(2),
  72132 	42:  uint8(2),
  72133 	43:  uint8(2),
  72134 	44:  uint8(2),
  72135 	45:  uint8(2),
  72136 	46:  uint8(2),
  72137 	47:  uint8(2),
  72138 	48:  uint8(2),
  72139 	49:  uint8(2),
  72140 	50:  uint8(2),
  72141 	51:  uint8(2),
  72142 	52:  uint8(2),
  72143 	53:  uint8(2),
  72144 	54:  uint8(2),
  72145 	55:  uint8(2),
  72146 	56:  uint8(2),
  72147 	57:  uint8(2),
  72148 	58:  uint8(2),
  72149 	59:  uint8(2),
  72150 	60:  uint8(2),
  72151 	61:  uint8(2),
  72152 	62:  uint8(2),
  72153 	63:  uint8(1),
  72154 	64:  uint8(1),
  72155 	65:  uint8(1),
  72156 	66:  uint8(1),
  72157 	67:  uint8(1),
  72158 	68:  uint8(1),
  72159 	69:  uint8(1),
  72160 	70:  uint8(1),
  72161 	71:  uint8(1),
  72162 	72:  uint8(1),
  72163 	73:  uint8(1),
  72164 	74:  uint8(1),
  72165 	75:  uint8(1),
  72166 	76:  uint8(1),
  72167 	77:  uint8(1),
  72168 	78:  uint8(1),
  72169 	79:  uint8(1),
  72170 	80:  uint8(1),
  72171 	81:  uint8(1),
  72172 	82:  uint8(1),
  72173 	83:  uint8(1),
  72174 	84:  uint8(1),
  72175 	85:  uint8(1),
  72176 	86:  uint8(1),
  72177 	87:  uint8(1),
  72178 	88:  uint8(1),
  72179 	89:  uint8(1),
  72180 	90:  uint8(1),
  72181 	91:  uint8(1),
  72182 	92:  uint8(1),
  72183 	93:  uint8(1),
  72184 	94:  uint8(1),
  72185 	95:  uint8(1),
  72186 	96:  uint8(1),
  72187 	97:  uint8(1),
  72188 	98:  uint8(1),
  72189 	99:  uint8(1),
  72190 	100: uint8(1),
  72191 	101: uint8(1),
  72192 	102: uint8(1),
  72193 	103: uint8(1),
  72194 	104: uint8(1),
  72195 	105: uint8(1),
  72196 	106: uint8(1),
  72197 	107: uint8(1),
  72198 	108: uint8(1),
  72199 	109: uint8(1),
  72200 	110: uint8(1),
  72201 	111: uint8(1),
  72202 	112: uint8(1),
  72203 	113: uint8(1),
  72204 	114: uint8(1),
  72205 	115: uint8(1),
  72206 	116: uint8(1),
  72207 	117: uint8(1),
  72208 	118: uint8(1),
  72209 	119: uint8(1),
  72210 	120: uint8(1),
  72211 	121: uint8(1),
  72212 	122: uint8(1),
  72213 	123: uint8(1),
  72214 	124: uint8(1),
  72215 	125: uint8(1),
  72216 	126: uint8(1),
  72217 }
  72218 
  72219 // C documentation
  72220 //
  72221 //	// range = ((range - 1) << kVP8Log2Range[range]) + 1
  72222 var kVP8NewRange = [128]uint8_t{
  72223 	0:   uint8(127),
  72224 	1:   uint8(127),
  72225 	2:   uint8(191),
  72226 	3:   uint8(127),
  72227 	4:   uint8(159),
  72228 	5:   uint8(191),
  72229 	6:   uint8(223),
  72230 	7:   uint8(127),
  72231 	8:   uint8(143),
  72232 	9:   uint8(159),
  72233 	10:  uint8(175),
  72234 	11:  uint8(191),
  72235 	12:  uint8(207),
  72236 	13:  uint8(223),
  72237 	14:  uint8(239),
  72238 	15:  uint8(127),
  72239 	16:  uint8(135),
  72240 	17:  uint8(143),
  72241 	18:  uint8(151),
  72242 	19:  uint8(159),
  72243 	20:  uint8(167),
  72244 	21:  uint8(175),
  72245 	22:  uint8(183),
  72246 	23:  uint8(191),
  72247 	24:  uint8(199),
  72248 	25:  uint8(207),
  72249 	26:  uint8(215),
  72250 	27:  uint8(223),
  72251 	28:  uint8(231),
  72252 	29:  uint8(239),
  72253 	30:  uint8(247),
  72254 	31:  uint8(127),
  72255 	32:  uint8(131),
  72256 	33:  uint8(135),
  72257 	34:  uint8(139),
  72258 	35:  uint8(143),
  72259 	36:  uint8(147),
  72260 	37:  uint8(151),
  72261 	38:  uint8(155),
  72262 	39:  uint8(159),
  72263 	40:  uint8(163),
  72264 	41:  uint8(167),
  72265 	42:  uint8(171),
  72266 	43:  uint8(175),
  72267 	44:  uint8(179),
  72268 	45:  uint8(183),
  72269 	46:  uint8(187),
  72270 	47:  uint8(191),
  72271 	48:  uint8(195),
  72272 	49:  uint8(199),
  72273 	50:  uint8(203),
  72274 	51:  uint8(207),
  72275 	52:  uint8(211),
  72276 	53:  uint8(215),
  72277 	54:  uint8(219),
  72278 	55:  uint8(223),
  72279 	56:  uint8(227),
  72280 	57:  uint8(231),
  72281 	58:  uint8(235),
  72282 	59:  uint8(239),
  72283 	60:  uint8(243),
  72284 	61:  uint8(247),
  72285 	62:  uint8(251),
  72286 	63:  uint8(127),
  72287 	64:  uint8(129),
  72288 	65:  uint8(131),
  72289 	66:  uint8(133),
  72290 	67:  uint8(135),
  72291 	68:  uint8(137),
  72292 	69:  uint8(139),
  72293 	70:  uint8(141),
  72294 	71:  uint8(143),
  72295 	72:  uint8(145),
  72296 	73:  uint8(147),
  72297 	74:  uint8(149),
  72298 	75:  uint8(151),
  72299 	76:  uint8(153),
  72300 	77:  uint8(155),
  72301 	78:  uint8(157),
  72302 	79:  uint8(159),
  72303 	80:  uint8(161),
  72304 	81:  uint8(163),
  72305 	82:  uint8(165),
  72306 	83:  uint8(167),
  72307 	84:  uint8(169),
  72308 	85:  uint8(171),
  72309 	86:  uint8(173),
  72310 	87:  uint8(175),
  72311 	88:  uint8(177),
  72312 	89:  uint8(179),
  72313 	90:  uint8(181),
  72314 	91:  uint8(183),
  72315 	92:  uint8(185),
  72316 	93:  uint8(187),
  72317 	94:  uint8(189),
  72318 	95:  uint8(191),
  72319 	96:  uint8(193),
  72320 	97:  uint8(195),
  72321 	98:  uint8(197),
  72322 	99:  uint8(199),
  72323 	100: uint8(201),
  72324 	101: uint8(203),
  72325 	102: uint8(205),
  72326 	103: uint8(207),
  72327 	104: uint8(209),
  72328 	105: uint8(211),
  72329 	106: uint8(213),
  72330 	107: uint8(215),
  72331 	108: uint8(217),
  72332 	109: uint8(219),
  72333 	110: uint8(221),
  72334 	111: uint8(223),
  72335 	112: uint8(225),
  72336 	113: uint8(227),
  72337 	114: uint8(229),
  72338 	115: uint8(231),
  72339 	116: uint8(233),
  72340 	117: uint8(235),
  72341 	118: uint8(237),
  72342 	119: uint8(239),
  72343 	120: uint8(241),
  72344 	121: uint8(243),
  72345 	122: uint8(245),
  72346 	123: uint8(247),
  72347 	124: uint8(249),
  72348 	125: uint8(251),
  72349 	126: uint8(253),
  72350 	127: uint8(127),
  72351 }
  72352 
  72353 var __ccgo_ts = (*reflect.StringHeader)(unsafe.Pointer(&__ccgo_ts1)).Data
  72354 
  72355 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"