yencode 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +6 -6
- package/crcutil-1.0/code/multiword_64_64_intrinsic_i386_mmx.cc +1 -1
- package/package.json +1 -1
- package/src/common.h +74 -12
- package/src/crc.cc +50 -24
- package/src/crc.h +20 -6
- package/src/crc_arm.cc +121 -23
- package/src/crc_common.h +3 -10
- package/src/{crc_folding.c → crc_folding.cc} +40 -74
- package/src/decoder.cc +6 -3
- package/src/decoder.h +16 -2
- package/src/decoder_avx2_base.h +12 -12
- package/src/decoder_common.h +2 -2
- package/src/decoder_neon.cc +34 -34
- package/src/decoder_neon64.cc +36 -34
- package/src/decoder_sse_base.h +5 -5
- package/src/encoder.cc +5 -2
- package/src/encoder.h +17 -1
- package/src/encoder_avx_base.h +6 -6
- package/src/encoder_common.h +3 -3
- package/src/encoder_neon.cc +30 -30
- package/src/encoder_sse_base.h +3 -3
- package/src/platform.cc +34 -6
- package/src/yencode.cc +33 -44
package/src/yencode.cc
CHANGED
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
using namespace v8;
|
|
14
14
|
|
|
15
|
-
union crc32 {
|
|
16
|
-
uint32_t u32;
|
|
17
|
-
unsigned char u8a[4];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
15
|
static void free_buffer(char* data, void* _size) {
|
|
21
16
|
#if !NODE_VERSION_AT_LEAST(0, 11, 0)
|
|
22
17
|
int size = (int)(size_t)_size;
|
|
@@ -252,7 +247,7 @@ FUNC(Decode) {
|
|
|
252
247
|
isRaw = ARG_TO_BOOL(args[1]);
|
|
253
248
|
|
|
254
249
|
unsigned char *result = (unsigned char*) malloc(arg_len);
|
|
255
|
-
size_t len = (isRaw
|
|
250
|
+
size_t len = do_decode(isRaw, (const unsigned char*)node::Buffer::Data(args[0]), result, arg_len, NULL);
|
|
256
251
|
result = (unsigned char*)realloc(result, len);
|
|
257
252
|
MARK_EXT_MEM(len);
|
|
258
253
|
RETURN_VAL( NEW_BUFFER((char*)result, len, free_buffer, (void*)len) );
|
|
@@ -276,7 +271,7 @@ FUNC(DecodeTo) {
|
|
|
276
271
|
if (args.Length() > 2)
|
|
277
272
|
isRaw = ARG_TO_BOOL(args[2]);
|
|
278
273
|
|
|
279
|
-
size_t len = (isRaw
|
|
274
|
+
size_t len = do_decode(isRaw, (const unsigned char*)node::Buffer::Data(args[0]), (unsigned char*)node::Buffer::Data(args[1]), arg_len, NULL);
|
|
280
275
|
RETURN_VAL( Integer::New(ISOLATE len) );
|
|
281
276
|
}
|
|
282
277
|
|
|
@@ -336,17 +331,23 @@ FUNC(DecodeIncr) {
|
|
|
336
331
|
}
|
|
337
332
|
|
|
338
333
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
#else
|
|
347
|
-
#define RETURN_CRC(x) RETURN_VAL( NEW_BUFFER((char*)x.u8a, 4) )
|
|
334
|
+
static inline uint32_t read_crc32(const Local<Value>& buf) {
|
|
335
|
+
const uint8_t* arr = (const uint8_t*)node::Buffer::Data(buf);
|
|
336
|
+
return (((uint_fast32_t)arr[0] << 24) | ((uint_fast32_t)arr[1] << 16) | ((uint_fast32_t)arr[2] << 8) | (uint_fast32_t)arr[3]);
|
|
337
|
+
}
|
|
338
|
+
static inline Local<Object> pack_crc32(
|
|
339
|
+
#if NODE_VERSION_AT_LEAST(0, 11, 0)
|
|
340
|
+
Isolate* isolate,
|
|
348
341
|
#endif
|
|
349
|
-
|
|
342
|
+
uint32_t crc) {
|
|
343
|
+
Local<Object> buff = NEW_BUFFER(4);
|
|
344
|
+
unsigned char* d = (unsigned char*)node::Buffer::Data(buff);
|
|
345
|
+
d[0] = (unsigned char)(crc >> 24) & 0xFF;
|
|
346
|
+
d[1] = (unsigned char)(crc >> 16) & 0xFF;
|
|
347
|
+
d[2] = (unsigned char)(crc >> 8) & 0xFF;
|
|
348
|
+
d[3] = (unsigned char)crc & 0xFF;
|
|
349
|
+
return buff;
|
|
350
|
+
}
|
|
350
351
|
|
|
351
352
|
// crc32(str, init)
|
|
352
353
|
FUNC(CRC32) {
|
|
@@ -356,25 +357,18 @@ FUNC(CRC32) {
|
|
|
356
357
|
RETURN_ERROR("You must supply a Buffer");
|
|
357
358
|
// TODO: support string args??
|
|
358
359
|
|
|
359
|
-
|
|
360
|
-
init.u32 = 0;
|
|
360
|
+
uint32_t crc = 0;
|
|
361
361
|
if (args.Length() >= 2) {
|
|
362
362
|
if (!node::Buffer::HasInstance(args[1]) || node::Buffer::Length(args[1]) != 4)
|
|
363
363
|
RETURN_ERROR("Second argument must be a 4 byte buffer");
|
|
364
|
-
|
|
365
|
-
do_crc32_incremental(
|
|
366
|
-
(const void*)node::Buffer::Data(args[0]),
|
|
367
|
-
node::Buffer::Length(args[0]),
|
|
368
|
-
init.u8a
|
|
369
|
-
);
|
|
370
|
-
} else {
|
|
371
|
-
do_crc32(
|
|
372
|
-
(const void*)node::Buffer::Data(args[0]),
|
|
373
|
-
node::Buffer::Length(args[0]),
|
|
374
|
-
init.u8a
|
|
375
|
-
);
|
|
364
|
+
crc = read_crc32(args[1]);
|
|
376
365
|
}
|
|
377
|
-
|
|
366
|
+
crc = do_crc32(
|
|
367
|
+
(const void*)node::Buffer::Data(args[0]),
|
|
368
|
+
node::Buffer::Length(args[0]),
|
|
369
|
+
crc
|
|
370
|
+
);
|
|
371
|
+
RETURN_VAL(pack_crc32(ISOLATE crc));
|
|
378
372
|
}
|
|
379
373
|
|
|
380
374
|
FUNC(CRC32Combine) {
|
|
@@ -386,14 +380,11 @@ FUNC(CRC32Combine) {
|
|
|
386
380
|
|| !node::Buffer::HasInstance(args[1]) || node::Buffer::Length(args[1]) != 4)
|
|
387
381
|
RETURN_ERROR("You must supply a 4 byte Buffer for the first two arguments");
|
|
388
382
|
|
|
389
|
-
|
|
383
|
+
uint32_t crc1 = read_crc32(args[0]), crc2 = read_crc32(args[1]);
|
|
390
384
|
size_t len = (size_t)ARG_TO_INT(args[2]);
|
|
391
385
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
do_crc32_combine(crc1.u8a, crc2.u8a, len);
|
|
396
|
-
RETURN_CRC(crc1);
|
|
386
|
+
crc1 = do_crc32_combine(crc1, crc2, len);
|
|
387
|
+
RETURN_VAL(pack_crc32(ISOLATE crc1));
|
|
397
388
|
}
|
|
398
389
|
|
|
399
390
|
FUNC(CRC32Zeroes) {
|
|
@@ -402,17 +393,15 @@ FUNC(CRC32Zeroes) {
|
|
|
402
393
|
if (args.Length() < 1)
|
|
403
394
|
RETURN_ERROR("At least 1 argument required");
|
|
404
395
|
|
|
405
|
-
|
|
396
|
+
uint32_t crc1 = 0;
|
|
406
397
|
if (args.Length() >= 2) {
|
|
407
398
|
if (!node::Buffer::HasInstance(args[1]) || node::Buffer::Length(args[1]) != 4)
|
|
408
399
|
RETURN_ERROR("Second argument must be a 4 byte buffer");
|
|
409
|
-
|
|
410
|
-
} else {
|
|
411
|
-
crc1.u32 = 0;
|
|
400
|
+
crc1 = read_crc32(args[1]);
|
|
412
401
|
}
|
|
413
402
|
size_t len = (size_t)ARG_TO_INT(args[0]);
|
|
414
|
-
do_crc32_zeros(crc1
|
|
415
|
-
|
|
403
|
+
crc1 = do_crc32_zeros(crc1, len);
|
|
404
|
+
RETURN_VAL(pack_crc32(ISOLATE crc1));
|
|
416
405
|
}
|
|
417
406
|
|
|
418
407
|
static void init_all() {
|