-
Notifications
You must be signed in to change notification settings - Fork 3
/
jpgd_o1.js
18674 lines (18163 loc) · 532 KB
/
jpgd_o1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function readJpeg(data) {
var Module = {
data: data
};
Module["preRun"] = (function() {
FS.createDataFile("/", "input.jpg", Module["intArrayFromString"](Module["data"]), true, true);
});
Module["arguments"] = [ "" ];
Module["return"] = "";
Module["print"] = (function(text) {
Module["return"] += text + "\n";
});
try {
this["Module"] = Module;
} catch (e) {
this["Module"] = Module = {};
}
var ENVIRONMENT_IS_NODE = typeof process === "object";
var ENVIRONMENT_IS_WEB = typeof window === "object";
var ENVIRONMENT_IS_WORKER = typeof importScripts === "function";
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
if (ENVIRONMENT_IS_NODE) {
Module["print"] = (function(x) {
process["stdout"].write(x + "\n");
});
Module["printErr"] = (function(x) {
process["stderr"].write(x + "\n");
});
var nodeFS = require("fs");
var nodePath = require("path");
Module["read"] = (function(filename) {
filename = nodePath["normalize"](filename);
var ret = nodeFS["readFileSync"](filename).toString();
if (!ret && filename != nodePath["resolve"](filename)) {
filename = path.join(__dirname, "..", "src", filename);
ret = nodeFS["readFileSync"](filename).toString();
}
return ret;
});
Module["load"] = (function(f) {
globalEval(read(f));
});
if (!Module["arguments"]) {
Module["arguments"] = process["argv"].slice(2);
}
} else if (ENVIRONMENT_IS_SHELL) {
Module["print"] = print;
Module["printErr"] = printErr;
if (typeof read != "undefined") {
Module["read"] = read;
} else {
Module["read"] = (function(f) {
snarf(f);
});
}
if (!Module["arguments"]) {
if (typeof scriptArgs != "undefined") {
Module["arguments"] = scriptArgs;
} else if (typeof arguments != "undefined") {
Module["arguments"] = arguments;
}
}
} else if (ENVIRONMENT_IS_WEB) {
if (!Module["print"]) {
Module["print"] = (function(x) {
console.log(x);
});
}
if (!Module["printErr"]) {
Module["printErr"] = (function(x) {
console.log(x);
});
}
Module["read"] = (function(url) {
var xhr = new XMLHttpRequest;
xhr.open("GET", url, false);
xhr.send(null);
return xhr.responseText;
});
if (!Module["arguments"]) {
if (typeof arguments != "undefined") {
Module["arguments"] = arguments;
}
}
} else if (ENVIRONMENT_IS_WORKER) {
Module["load"] = importScripts;
} else {
throw "Unknown runtime environment. Where are we?";
}
function globalEval(x) {
eval.call(null, x);
}
if (!Module["load"] == "undefined" && Module["read"]) {
Module["load"] = (function(f) {
globalEval(Module["read"](f));
});
}
if (!Module["printErr"]) {
Module["printErr"] = (function() {});
}
if (!Module["print"]) {
Module["print"] = Module["printErr"];
}
if (!Module["arguments"]) {
Module["arguments"] = [];
}
Module.print = Module["print"];
Module.printErr = Module["printErr"];
if (!Module["preRun"]) Module["preRun"] = [];
if (!Module["postRun"]) Module["postRun"] = [];
var Runtime = {
stackSave: (function() {
return STACKTOP;
}),
stackRestore: (function(stackTop) {
STACKTOP = stackTop;
}),
forceAlign: (function(target, quantum) {
quantum = quantum || 4;
if (quantum == 1) return target;
if (isNumber(target) && isNumber(quantum)) {
return Math.ceil(target / quantum) * quantum;
} else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
var logg = log2(quantum);
return "((((" + target + ")+" + (quantum - 1) + ")>>" + logg + ")<<" + logg + ")";
}
return "Math.ceil((" + target + ")/" + quantum + ")*" + quantum;
}),
isNumberType: (function(type) {
return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
}),
isPointerType: function isPointerType(type) {
return type[type.length - 1] == "*";
},
isStructType: function isStructType(type) {
if (isPointerType(type)) return false;
if (/^\[\d+\ x\ (.*)\]/.test(type)) return true;
if (/<?{ ?[^}]* ?}>?/.test(type)) return true;
return type[0] == "%";
},
INT_TYPES: {
"i1": 0,
"i8": 0,
"i16": 0,
"i32": 0,
"i64": 0
},
FLOAT_TYPES: {
"float": 0,
"double": 0
},
bitshift64: (function(low, high, op, bits) {
var ander = Math.pow(2, bits) - 1;
if (bits < 32) {
switch (op) {
case "shl":
return [ low << bits, high << bits | (low & ander << 32 - bits) >>> 32 - bits ];
case "ashr":
return [ (low >>> bits | (high & ander) << 32 - bits) >> 0 >>> 0, high >> bits >>> 0 ];
case "lshr":
return [ (low >>> bits | (high & ander) << 32 - bits) >>> 0, high >>> bits ];
}
} else if (bits == 32) {
switch (op) {
case "shl":
return [ 0, low ];
case "ashr":
return [ high, (high | 0) < 0 ? ander : 0 ];
case "lshr":
return [ high, 0 ];
}
} else {
switch (op) {
case "shl":
return [ 0, low << bits - 32 ];
case "ashr":
return [ high >> bits - 32 >>> 0, (high | 0) < 0 ? ander : 0 ];
case "lshr":
return [ high >>> bits - 32, 0 ];
}
}
abort("unknown bitshift64 op: " + [ value, op, bits ]);
}),
or64: (function(x, y) {
var l = x | 0 | (y | 0);
var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
return l + h;
}),
and64: (function(x, y) {
var l = (x | 0) & (y | 0);
var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
return l + h;
}),
xor64: (function(x, y) {
var l = (x | 0) ^ (y | 0);
var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
return l + h;
}),
getNativeTypeSize: (function(type, quantumSize) {
if (Runtime.QUANTUM_SIZE == 1) return 1;
var size = {
"%i1": 1,
"%i8": 1,
"%i16": 2,
"%i32": 4,
"%i64": 8,
"%float": 4,
"%double": 8
}["%" + type];
if (!size) {
if (type[type.length - 1] == "*") {
size = Runtime.QUANTUM_SIZE;
} else if (type[0] == "i") {
var bits = parseInt(type.substr(1));
assert(bits % 8 == 0);
size = bits / 8;
}
}
return size;
}),
getNativeFieldSize: (function(type) {
return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
}),
dedup: function dedup(items, ident) {
var seen = {};
if (ident) {
return items.filter((function(item) {
if (seen[item[ident]]) return false;
seen[item[ident]] = true;
return true;
}));
} else {
return items.filter((function(item) {
if (seen[item]) return false;
seen[item] = true;
return true;
}));
}
},
set: function set() {
var args = typeof arguments[0] === "object" ? arguments[0] : arguments;
var ret = {};
for (var i = 0; i < args.length; i++) {
ret[args[i]] = 0;
}
return ret;
},
calculateStructAlignment: function calculateStructAlignment(type) {
type.flatSize = 0;
type.alignSize = 0;
var diffs = [];
var prev = -1;
type.flatIndexes = type.fields.map((function(field) {
var size, alignSize;
if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
size = Runtime.getNativeTypeSize(field);
alignSize = size;
} else if (Runtime.isStructType(field)) {
size = Types.types[field].flatSize;
alignSize = Types.types[field].alignSize;
} else {
throw "Unclear type in struct: " + field + ", in " + type.name_ + " :: " + dump(Types.types[type.name_]);
}
alignSize = type.packed ? 1 : Math.min(alignSize, Runtime.QUANTUM_SIZE);
type.alignSize = Math.max(type.alignSize, alignSize);
var curr = Runtime.alignMemory(type.flatSize, alignSize);
type.flatSize = curr + size;
if (prev >= 0) {
diffs.push(curr - prev);
}
prev = curr;
return curr;
}));
type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
if (diffs.length == 0) {
type.flatFactor = type.flatSize;
} else if (Runtime.dedup(diffs).length == 1) {
type.flatFactor = diffs[0];
}
type.needsFlattening = type.flatFactor != 1;
return type.flatIndexes;
},
generateStructInfo: (function(struct, typeName, offset) {
var type, alignment;
if (typeName) {
offset = offset || 0;
type = (typeof Types === "undefined" ? Runtime.typeInfo : Types.types)[typeName];
if (!type) return null;
assert(type.fields.length === struct.length, "Number of named fields must match the type for " + typeName);
alignment = type.flatIndexes;
} else {
var type = {
fields: struct.map((function(item) {
return item[0];
}))
};
alignment = Runtime.calculateStructAlignment(type);
}
var ret = {
__size__: type.flatSize
};
if (typeName) {
struct.forEach((function(item, i) {
if (typeof item === "string") {
ret[item] = alignment[i] + offset;
} else {
var key;
for (var k in item) key = k;
ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
}
}));
} else {
struct.forEach((function(item, i) {
ret[item[1]] = alignment[i];
}));
}
return ret;
}),
addFunction: (function(func) {
var ret = FUNCTION_TABLE.length;
FUNCTION_TABLE.push(func);
FUNCTION_TABLE.push(0);
return ret;
}),
warnOnce: (function(text) {
if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
if (!Runtime.warnOnce.shown[text]) {
Runtime.warnOnce.shown[text] = 1;
Module.printErr(text);
}
}),
funcWrappers: {},
getFuncWrapper: (function(func) {
if (!Runtime.funcWrappers[func]) {
Runtime.funcWrappers[func] = (function() {
FUNCTION_TABLE[func].apply(null, arguments);
});
}
return Runtime.funcWrappers[func];
}),
stackAlloc: function stackAlloc(size) {
var ret = STACKTOP;
STACKTOP += size;
STACKTOP = STACKTOP + 3 >> 2 << 2;
return ret;
},
staticAlloc: function staticAlloc(size) {
var ret = STATICTOP;
STATICTOP += size;
STATICTOP = STATICTOP + 3 >> 2 << 2;
if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();
return ret;
},
alignMemory: function alignMemory(size, quantum) {
var ret = size = Math.ceil(size / (quantum ? quantum : 4)) * (quantum ? quantum : 4);
return ret;
},
makeBigInt: function makeBigInt(low, high, unsigned) {
var ret = unsigned ? (low >>> 0) + (high >>> 0) * 4294967296 : (low >>> 0) + (high | 0) * 4294967296;
return ret;
},
QUANTUM_SIZE: 4,
__dummy__: 0
};
var CorrectionsMonitor = {
MAX_ALLOWED: 0,
corrections: 0,
sigs: {},
note: (function(type, succeed, sig) {
if (!succeed) {
this.corrections++;
if (this.corrections >= this.MAX_ALLOWED) abort("\n\nToo many corrections!");
}
}),
print: (function() {})
};
var __THREW__ = false;
var ABORT = false;
var undef = 0;
var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
var tempI64, tempI64b;
function abort(text) {
Module.print(text + ":\n" + (new Error).stack);
ABORT = true;
throw "Assertion: " + text;
}
function assert(condition, text) {
if (!condition) {
abort("Assertion failed: " + text);
}
}
var globalScope = this;
function ccall(ident, returnType, argTypes, args) {
var stack = 0;
function toC(value, type) {
if (type == "string") {
if (value === null || value === undefined || value === 0) return 0;
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length + 1);
writeStringToMemory(value, ret);
return ret;
} else if (type == "array") {
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length);
writeArrayToMemory(value, ret);
return ret;
}
return value;
}
function fromC(value, type) {
if (type == "string") {
return Pointer_stringify(value);
}
assert(type != "array");
return value;
}
try {
var func = eval("_" + ident);
} catch (e) {
try {
func = globalScope["Module"]["_" + ident];
} catch (e) {}
}
assert(func, "Cannot call unknown function " + ident + " (perhaps LLVM optimizations or closure removed it?)");
var i = 0;
var cArgs = args ? args.map((function(arg) {
return toC(arg, argTypes[i++]);
})) : [];
var ret = fromC(func.apply(null, cArgs), returnType);
if (stack) Runtime.stackRestore(stack);
return ret;
}
Module["ccall"] = ccall;
function cwrap(ident, returnType, argTypes) {
return (function() {
return ccall(ident, returnType, argTypes, Array.prototype.slice.call(arguments));
});
}
Module["cwrap"] = cwrap;
function setValue(ptr, value, type, noSafe) {
type = type || "i8";
if (type[type.length - 1] === "*") type = "i32";
switch (type) {
case "i1":
HEAP8[ptr] = value;
break;
case "i8":
HEAP8[ptr] = value;
break;
case "i16":
HEAP16[ptr >> 1] = value;
break;
case "i32":
HEAP32[ptr >> 2] = value;
break;
case "i64":
HEAP32[ptr >> 2] = value;
break;
case "float":
HEAPF32[ptr >> 2] = value;
break;
case "double":
tempDoubleF64[0] = value, HEAP32[ptr >> 2] = tempDoubleI32[0], HEAP32[ptr + 4 >> 2] = tempDoubleI32[1];
break;
default:
abort("invalid type for setValue: " + type);
}
}
Module["setValue"] = setValue;
function getValue(ptr, type, noSafe) {
type = type || "i8";
if (type[type.length - 1] === "*") type = "i32";
switch (type) {
case "i1":
return HEAP8[ptr];
case "i8":
return HEAP8[ptr];
case "i16":
return HEAP16[ptr >> 1];
case "i32":
return HEAP32[ptr >> 2];
case "i64":
return HEAP32[ptr >> 2];
case "float":
return HEAPF32[ptr >> 2];
case "double":
return tempDoubleI32[0] = HEAP32[ptr >> 2], tempDoubleI32[1] = HEAP32[ptr + 4 >> 2], tempDoubleF64[0];
default:
abort("invalid type for setValue: " + type);
}
return null;
}
Module["getValue"] = getValue;
var ALLOC_NORMAL = 0;
var ALLOC_STACK = 1;
var ALLOC_STATIC = 2;
Module["ALLOC_NORMAL"] = ALLOC_NORMAL;
Module["ALLOC_STACK"] = ALLOC_STACK;
Module["ALLOC_STATIC"] = ALLOC_STATIC;
function allocate(slab, types, allocator) {
var zeroinit, size;
if (typeof slab === "number") {
zeroinit = true;
size = slab;
} else {
zeroinit = false;
size = slab.length;
}
var singleType = typeof types === "string" ? types : null;
var ret = [ _malloc, Runtime.stackAlloc, Runtime.staticAlloc ][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
if (zeroinit) {
_memset(ret, 0, size);
return ret;
}
var i = 0, type;
while (i < size) {
var curr = slab[i];
if (typeof curr === "function") {
curr = Runtime.getFunctionIndex(curr);
}
type = singleType || types[i];
if (type === 0) {
i++;
continue;
}
if (type == "i64") type = "i32";
setValue(ret + i, curr, type);
i += Runtime.getNativeTypeSize(type);
}
return ret;
}
Module["allocate"] = allocate;
function Pointer_stringify(ptr, length) {
var nullTerminated = typeof length == "undefined";
var ret = "";
var i = 0;
var t;
var nullByte = String.fromCharCode(0);
while (1) {
t = String.fromCharCode(HEAPU8[ptr + i]);
if (nullTerminated && t == nullByte) {
break;
} else {}
ret += t;
i += 1;
if (!nullTerminated && i == length) {
break;
}
}
return ret;
}
Module["Pointer_stringify"] = Pointer_stringify;
function Array_stringify(array) {
var ret = "";
for (var i = 0; i < array.length; i++) {
ret += String.fromCharCode(array[i]);
}
return ret;
}
Module["Array_stringify"] = Array_stringify;
var FUNCTION_TABLE;
var PAGE_SIZE = 4096;
function alignMemoryPage(x) {
return x + 4095 >> 12 << 12;
}
var HEAP;
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
var STACK_ROOT, STACKTOP, STACK_MAX;
var STATICTOP;
function enlargeMemory() {
while (TOTAL_MEMORY <= STATICTOP) {
TOTAL_MEMORY = alignMemoryPage(2 * TOTAL_MEMORY);
}
var oldHEAP8 = HEAP8;
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
HEAP16 = new Int16Array(buffer);
HEAP32 = new Int32Array(buffer);
HEAPU8 = new Uint8Array(buffer);
HEAPU16 = new Uint16Array(buffer);
HEAPU32 = new Uint32Array(buffer);
HEAPF32 = new Float32Array(buffer);
HEAPF64 = new Float64Array(buffer);
HEAP8.set(oldHEAP8);
}
var TOTAL_STACK = Module["TOTAL_STACK"] || 5242880;
var TOTAL_MEMORY = Module["TOTAL_MEMORY"] || 10485760;
var FAST_MEMORY = Module["FAST_MEMORY"] || 2097152;
assert(!!Int32Array && !!Float64Array && !!(new Int32Array(1))["subarray"] && !!(new Int32Array(1))["set"], "Cannot fallback to non-typed array case: Code is too specialized");
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
HEAP16 = new Int16Array(buffer);
HEAP32 = new Int32Array(buffer);
HEAPU8 = new Uint8Array(buffer);
HEAPU16 = new Uint16Array(buffer);
HEAPU32 = new Uint32Array(buffer);
HEAPF32 = new Float32Array(buffer);
HEAPF64 = new Float64Array(buffer);
HEAP32[0] = 255;
assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, "Typed arrays 2 must be run on a little-endian system");
var base = intArrayFromString("(null)");
STATICTOP = base.length;
for (var i = 0; i < base.length; i++) {
HEAP8[i] = base[i];
}
Module["HEAP"] = HEAP;
Module["HEAP8"] = HEAP8;
Module["HEAP16"] = HEAP16;
Module["HEAP32"] = HEAP32;
Module["HEAPU8"] = HEAPU8;
Module["HEAPU16"] = HEAPU16;
Module["HEAPU32"] = HEAPU32;
Module["HEAPF32"] = HEAPF32;
Module["HEAPF64"] = HEAPF64;
STACK_ROOT = STACKTOP = Runtime.alignMemory(STATICTOP);
STACK_MAX = STACK_ROOT + TOTAL_STACK;
var tempDoublePtr = Runtime.alignMemory(STACK_MAX, 8);
var tempDoubleI8 = HEAP8.subarray(tempDoublePtr);
var tempDoubleI32 = HEAP32.subarray(tempDoublePtr >> 2);
var tempDoubleF32 = HEAPF32.subarray(tempDoublePtr >> 2);
var tempDoubleF64 = HEAPF64.subarray(tempDoublePtr >> 3);
function copyTempFloat(ptr) {
tempDoubleI8[0] = HEAP8[ptr];
tempDoubleI8[1] = HEAP8[ptr + 1];
tempDoubleI8[2] = HEAP8[ptr + 2];
tempDoubleI8[3] = HEAP8[ptr + 3];
}
function copyTempDouble(ptr) {
tempDoubleI8[0] = HEAP8[ptr];
tempDoubleI8[1] = HEAP8[ptr + 1];
tempDoubleI8[2] = HEAP8[ptr + 2];
tempDoubleI8[3] = HEAP8[ptr + 3];
tempDoubleI8[4] = HEAP8[ptr + 4];
tempDoubleI8[5] = HEAP8[ptr + 5];
tempDoubleI8[6] = HEAP8[ptr + 6];
tempDoubleI8[7] = HEAP8[ptr + 7];
}
STACK_MAX = tempDoublePtr + 8;
STATICTOP = alignMemoryPage(STACK_MAX);
function callRuntimeCallbacks(callbacks) {
while (callbacks.length > 0) {
var callback = callbacks.shift();
var func = callback.func;
if (typeof func === "number") {
func = FUNCTION_TABLE[func];
}
func(callback.arg === undefined ? null : callback.arg);
}
}
var __ATINIT__ = [];
var __ATMAIN__ = [];
var __ATEXIT__ = [];
function initRuntime() {
callRuntimeCallbacks(__ATINIT__);
}
function preMain() {
callRuntimeCallbacks(__ATMAIN__);
}
function exitRuntime() {
callRuntimeCallbacks(__ATEXIT__);
CorrectionsMonitor.print();
}
function String_len(ptr) {
var i = 0;
while (HEAP8[ptr + i]) i++;
return i;
}
Module["String_len"] = String_len;
function intArrayFromString(stringy, dontAddNull, length) {
var ret = [];
var t;
var i = 0;
if (length === undefined) {
length = stringy.length;
}
while (i < length) {
var chr = stringy.charCodeAt(i);
if (chr > 255) {
chr &= 255;
}
ret.push(chr);
i = i + 1;
}
if (!dontAddNull) {
ret.push(0);
}
return ret;
}
Module["intArrayFromString"] = intArrayFromString;
function intArrayToString(array) {
var ret = [];
for (var i = 0; i < array.length; i++) {
var chr = array[i];
if (chr > 255) {
chr &= 255;
}
ret.push(String.fromCharCode(chr));
}
return ret.join("");
}
Module["intArrayToString"] = intArrayToString;
function writeStringToMemory(string, buffer, dontAddNull) {
var i = 0;
while (i < string.length) {
var chr = string.charCodeAt(i);
if (chr > 255) {
chr &= 255;
}
HEAP8[buffer + i] = chr;
i = i + 1;
}
if (!dontAddNull) {
HEAP8[buffer + i] = 0;
}
}
Module["writeStringToMemory"] = writeStringToMemory;
function writeArrayToMemory(array, buffer) {
for (var i = 0; i < array.length; i++) {
HEAP8[buffer + i] = array[i];
}
}
Module["writeArrayToMemory"] = writeArrayToMemory;
var STRING_TABLE = [];
function unSign(value, bits, ignore, sig) {
if (value >= 0) {
return value;
}
return bits <= 32 ? 2 * Math.abs(1 << bits - 1) + value : Math.pow(2, bits) + value;
}
function reSign(value, bits, ignore, sig) {
if (value <= 0) {
return value;
}
var half = bits <= 32 ? Math.abs(1 << bits - 1) : Math.pow(2, bits - 1);
if (value >= half && (bits <= 32 || value > half)) {
value = -2 * half + value;
}
return value;
}
var runDependencies = 0;
function addRunDependency() {
runDependencies++;
if (Module["monitorRunDependencies"]) {
Module["monitorRunDependencies"](runDependencies);
}
}
Module["addRunDependency"] = addRunDependency;
function removeRunDependency() {
runDependencies--;
if (Module["monitorRunDependencies"]) {
Module["monitorRunDependencies"](runDependencies);
}
if (runDependencies == 0) run();
}
Module["removeRunDependency"] = removeRunDependency;
function __ZN4jpgd3RowILi1EE4idctEPiPKs($pTemp, $pSrc_val) {
var $2 = $pSrc_val << 16 >> 16 << 2;
HEAP32[$pTemp >> 2] = $2;
HEAP32[$pTemp + 4 >> 2] = $2;
HEAP32[$pTemp + 8 >> 2] = $2;
HEAP32[$pTemp + 12 >> 2] = $2;
HEAP32[$pTemp + 16 >> 2] = $2;
HEAP32[$pTemp + 20 >> 2] = $2;
HEAP32[$pTemp + 24 >> 2] = $2;
HEAP32[$pTemp + 28 >> 2] = $2;
return;
}
function __ZN4jpgd3RowILi2EE4idctEPiPKs($pTemp, $pSrc_val, $pSrc_1_val) {
var $3 = $pSrc_1_val << 16 >> 16;
var $4 = $3 * 9633 | 0;
var $5 = $3 * 6437 | 0;
var $6 = $3 * 2260 | 0;
var $7 = $3 * 11363 | 0;
var $8 = $pSrc_val << 16 >> 16 << 13 | 1024;
HEAP32[$pTemp >> 2] = $8 + $7 >> 11;
HEAP32[$pTemp + 28 >> 2] = $8 - $7 >> 11;
HEAP32[$pTemp + 4 >> 2] = $8 + $4 >> 11;
HEAP32[$pTemp + 24 >> 2] = $8 - $4 >> 11;
HEAP32[$pTemp + 8 >> 2] = $8 + $5 >> 11;
HEAP32[$pTemp + 20 >> 2] = $8 - $5 >> 11;
HEAP32[$pTemp + 12 >> 2] = $8 + $6 >> 11;
HEAP32[$pTemp + 16 >> 2] = $8 - $6 >> 11;
return;
}
function __ZN4jpgd3RowILi3EE4idctEPiPKs($pTemp, $pSrc_val, $pSrc_1_val, $pSrc_2_val) {
var $1 = $pSrc_2_val << 16 >> 16;
var $2 = $1 * 4433 | 0;
var $3 = $1 * 10703 | 0;
var $5 = $pSrc_val << 16 >> 16 << 13;
var $6 = $5 + $3 | 0;
var $7 = $5 - $3 | 0;
var $8 = $5 + $2 | 0;
var $9 = $5 - $2 | 0;
var $10 = $pSrc_1_val << 16 >> 16;
var $11 = $10 * 9633 | 0;
var $12 = $10 * 6437 | 0;
var $13 = $10 * 2260 | 0;
var $14 = $10 * 11363 | 0;
HEAP32[$pTemp >> 2] = $14 + 1024 + $6 >> 11;
HEAP32[$pTemp + 28 >> 2] = 1024 - $14 + $6 >> 11;
HEAP32[$pTemp + 4 >> 2] = $11 + 1024 + $8 >> 11;
HEAP32[$pTemp + 24 >> 2] = 1024 - $11 + $8 >> 11;
HEAP32[$pTemp + 8 >> 2] = $12 + 1024 + $9 >> 11;
HEAP32[$pTemp + 20 >> 2] = 1024 - $12 + $9 >> 11;
HEAP32[$pTemp + 12 >> 2] = $13 + 1024 + $7 >> 11;
HEAP32[$pTemp + 16 >> 2] = 1024 - $13 + $7 >> 11;
return;
}
__ZN4jpgd3RowILi3EE4idctEPiPKs["X"] = 1;
function __ZN4jpgd3RowILi4EE4idctEPiPKs($pTemp, $pSrc) {
var $3 = HEAP16[$pSrc + 4 >> 1] << 16 >> 16;
var $4 = $3 * 4433 | 0;
var $5 = $3 * 10703 | 0;
var $8 = HEAP16[$pSrc >> 1] << 16 >> 16 << 13;
var $10 = $8 - $5 | 0;
var $11 = $8 + $4 | 0;
var $12 = $8 - $4 | 0;
var $15 = HEAP16[$pSrc + 6 >> 1] << 16 >> 16;
var $18 = HEAP16[$pSrc + 2 >> 1] << 16 >> 16;
var $20 = ($18 + $15) * 9633 | 0;
var $24 = $20 + $15 * -16069 | 0;
var $26 = $20 + $18 * -3196 | 0;
var $27 = $24 + $18 * -7373 | 0;
var $28 = $26 + $15 * -20995 | 0;
var $30 = $24 + $15 * 4177 | 0;
var $32 = $26 + $18 * 4926 | 0;
var $33 = $8 + $5 + 1024 | 0;
HEAP32[$pTemp >> 2] = $33 + $32 >> 11;
HEAP32[$pTemp + 28 >> 2] = $33 - $32 >> 11;
var $39 = $11 + 1024 | 0;
HEAP32[$pTemp + 4 >> 2] = $39 + $30 >> 11;
HEAP32[$pTemp + 24 >> 2] = $39 - $30 >> 11;
var $46 = $12 + 1024 | 0;
HEAP32[$pTemp + 8 >> 2] = $46 + $28 >> 11;
HEAP32[$pTemp + 20 >> 2] = $46 - $28 >> 11;
var $53 = $10 + 1024 | 0;
HEAP32[$pTemp + 12 >> 2] = $53 + $27 >> 11;
HEAP32[$pTemp + 16 >> 2] = $53 - $27 >> 11;
return;
}
__ZN4jpgd3RowILi4EE4idctEPiPKs["X"] = 1;
function __ZN4jpgd3RowILi5EE4idctEPiPKs($pTemp, $pSrc) {
var $3 = HEAP16[$pSrc + 4 >> 1] << 16 >> 16;
var $4 = $3 * 4433 | 0;
var $5 = $3 * 10703 | 0;
var $7 = HEAP16[$pSrc >> 1] << 16 >> 16;
var $10 = HEAP16[$pSrc + 8 >> 1] << 16 >> 16;
var $12 = $10 + $7 << 13;
var $14 = $7 - $10 << 13;
var $16 = $12 - $5 | 0;
var $17 = $14 + $4 | 0;
var $18 = $14 - $4 | 0;
var $21 = HEAP16[$pSrc + 6 >> 1] << 16 >> 16;
var $24 = HEAP16[$pSrc + 2 >> 1] << 16 >> 16;
var $26 = ($24 + $21) * 9633 | 0;
var $30 = $26 + $21 * -16069 | 0;
var $32 = $26 + $24 * -3196 | 0;
var $33 = $30 + $24 * -7373 | 0;
var $34 = $32 + $21 * -20995 | 0;
var $36 = $30 + $21 * 4177 | 0;
var $38 = $32 + $24 * 4926 | 0;
var $39 = $12 + $5 + 1024 | 0;
HEAP32[$pTemp >> 2] = $39 + $38 >> 11;
HEAP32[$pTemp + 28 >> 2] = $39 - $38 >> 11;
var $45 = $17 + 1024 | 0;
HEAP32[$pTemp + 4 >> 2] = $45 + $36 >> 11;
HEAP32[$pTemp + 24 >> 2] = $45 - $36 >> 11;
var $52 = $18 + 1024 | 0;
HEAP32[$pTemp + 8 >> 2] = $52 + $34 >> 11;
HEAP32[$pTemp + 20 >> 2] = $52 - $34 >> 11;
var $59 = $16 + 1024 | 0;
HEAP32[$pTemp + 12 >> 2] = $59 + $33 >> 11;
HEAP32[$pTemp + 16 >> 2] = $59 - $33 >> 11;
return;