bare-jpeg 1.1.3 → 1.1.5
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.c +28 -1
- package/cmake/ports/libjpeg/port.cmake +30 -0
- package/package.json +2 -1
- package/prebuilds/android-arm/bare-jpeg.bare +0 -0
- package/prebuilds/android-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/android-ia32/bare-jpeg.bare +0 -0
- package/prebuilds/android-x64/bare-jpeg.bare +0 -0
- package/prebuilds/darwin-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/darwin-x64/bare-jpeg.bare +0 -0
- package/prebuilds/ios-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-jpeg.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-jpeg.bare +0 -0
- package/prebuilds/linux-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-jpeg.bare +0 -0
- package/prebuilds/win32-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/win32-x64/bare-jpeg.bare +0 -0
package/binding.c
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
#include <stdlib.h>
|
|
7
7
|
#include <string.h>
|
|
8
8
|
|
|
9
|
+
#define BARE_JPEG_MAX_PIXELS (1ull << 28)
|
|
10
|
+
|
|
9
11
|
typedef struct {
|
|
10
12
|
struct jpeg_error_mgr handle;
|
|
11
13
|
jmp_buf jump;
|
|
@@ -71,12 +73,32 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
71
73
|
|
|
72
74
|
if (jpeg_read_header(&decoder, true) != JPEG_HEADER_OK) goto err;
|
|
73
75
|
|
|
76
|
+
if (decoder.out_color_space == JCS_GRAYSCALE) decoder.out_color_space = JCS_RGB;
|
|
77
|
+
|
|
74
78
|
jpeg_start_decompress(&decoder);
|
|
75
79
|
|
|
76
80
|
JDIMENSION width = decoder.output_width;
|
|
77
81
|
JDIMENSION height = decoder.output_height;
|
|
78
82
|
JDIMENSION channels = decoder.output_components;
|
|
79
83
|
|
|
84
|
+
if (channels < 3) {
|
|
85
|
+
jpeg_destroy_decompress(&decoder);
|
|
86
|
+
|
|
87
|
+
err = js_throw_error(env, NULL, "Unsupported JPEG color space");
|
|
88
|
+
assert(err == 0);
|
|
89
|
+
|
|
90
|
+
return NULL;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ((uint64_t) width * height > BARE_JPEG_MAX_PIXELS) {
|
|
94
|
+
jpeg_destroy_decompress(&decoder);
|
|
95
|
+
|
|
96
|
+
err = js_throw_error(env, NULL, "JPEG dimensions exceed maximum");
|
|
97
|
+
assert(err == 0);
|
|
98
|
+
|
|
99
|
+
return NULL;
|
|
100
|
+
}
|
|
101
|
+
|
|
80
102
|
js_value_t *result;
|
|
81
103
|
err = js_create_object(env, &result);
|
|
82
104
|
assert(err == 0);
|
|
@@ -100,7 +122,12 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
100
122
|
|
|
101
123
|
uint8_t *data;
|
|
102
124
|
err = js_create_unsafe_arraybuffer(env, len, (void **) &data, &buffer);
|
|
103
|
-
|
|
125
|
+
|
|
126
|
+
if (err < 0) {
|
|
127
|
+
jpeg_destroy_decompress(&decoder);
|
|
128
|
+
|
|
129
|
+
return NULL;
|
|
130
|
+
}
|
|
104
131
|
|
|
105
132
|
err = js_set_named_property(env, result, "data", buffer);
|
|
106
133
|
assert(err == 0);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
include_guard(GLOBAL)
|
|
2
|
+
|
|
3
|
+
if(WIN32)
|
|
4
|
+
set(lib lib/jpeg-static.lib)
|
|
5
|
+
else()
|
|
6
|
+
set(lib lib/libjpeg.a)
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
declare_port(
|
|
10
|
+
"github:libjpeg-turbo/libjpeg-turbo#3.2.0"
|
|
11
|
+
jpeg
|
|
12
|
+
BYPRODUCTS ${lib}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
add_library(jpeg STATIC IMPORTED GLOBAL)
|
|
16
|
+
|
|
17
|
+
add_dependencies(jpeg ${jpeg})
|
|
18
|
+
|
|
19
|
+
set_target_properties(
|
|
20
|
+
jpeg
|
|
21
|
+
PROPERTIES
|
|
22
|
+
IMPORTED_LOCATION "${jpeg_PREFIX}/${lib}"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
file(MAKE_DIRECTORY "${jpeg_PREFIX}/include")
|
|
26
|
+
|
|
27
|
+
target_include_directories(
|
|
28
|
+
jpeg
|
|
29
|
+
INTERFACE "${jpeg_PREFIX}/include"
|
|
30
|
+
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-jpeg",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "JPEG support for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"binding.c",
|
|
12
12
|
"binding.js",
|
|
13
13
|
"CMakeLists.txt",
|
|
14
|
+
"cmake",
|
|
14
15
|
"prebuilds"
|
|
15
16
|
],
|
|
16
17
|
"addon": true,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|