Skip to content

Commit aefb855

Browse files
benoit-pierreneheb
authored andcommitted
jbig2dec: add 0.20
1 parent 1c5a17e commit aefb855

File tree

11 files changed

+325
-0
lines changed

11 files changed

+325
-0
lines changed

ci_config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@
184184
"htslib:tests=true"
185185
]
186186
},
187+
"jbig2dec": {
188+
"msys_packages": [
189+
"libpng"
190+
]
191+
},
187192
"json-glib": {
188193
"_comment": "gettext is not optional: https://gitlab.gnome.org/GNOME/json-glib/-/merge_requests/50",
189194
"debian_packages": [

releases.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,14 @@
10751075
"2.11-1"
10761076
]
10771077
},
1078+
"jbig2dec": {
1079+
"versions": [
1080+
"0.20-1"
1081+
],
1082+
"dependency_names": [
1083+
"jbig2dec"
1084+
]
1085+
},
10781086
"jbigkit": {
10791087
"versions": [
10801088
"2.1-2",

subprojects/jbig2dec.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-file]
2+
directory = jbig2dec-0.20
3+
source_url = https://github.com/ArtifexSoftware/jbig2dec/archive/refs/tags/0.20.tar.gz
4+
source_filename = jbig2dec-0.20.tar.gz
5+
source_hash = a9705369a6633aba532693450ec802c562397e1b824662de809ede92f67aff21
6+
patch_directory = jbig2dec
7+
8+
[provide]
9+
dependency_names = jbig2dec
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
jbig2_h = fs.copyfile(
2+
'../jbig2.h',
3+
'jbig2.h',
4+
install: true,
5+
install_dir: get_option('includedir'),
6+
install_tag: 'devel',
7+
)
8+
9+
public_include = include_directories('.')
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
project(
2+
'jbig2dec',
3+
'c',
4+
version: '0.20',
5+
meson_version: '>=0.64.0',
6+
)
7+
8+
cc = meson.get_compiler('c')
9+
10+
fs = import('fs')
11+
12+
progs_opt = get_option('progs')
13+
tests_opt = get_option('tests')
14+
15+
lib_inc = [
16+
'jbig2_arith.h',
17+
'jbig2_arith_iaid.h',
18+
'jbig2_arith_int.h',
19+
'jbig2_generic.h',
20+
'jbig2_halftone.h',
21+
'jbig2_huffman.h',
22+
'jbig2_hufftab.h',
23+
'jbig2_image.h',
24+
'jbig2_image_rw.h',
25+
'jbig2_mmr.h',
26+
'jbig2_page.h',
27+
'jbig2_priv.h',
28+
'jbig2_refinement.h',
29+
'jbig2_segment.h',
30+
'jbig2_symbol_dict.h',
31+
'jbig2_text.h',
32+
'memento.h',
33+
'os_types.h',
34+
'sha1.h',
35+
]
36+
lib_src = [
37+
'jbig2.c',
38+
'jbig2_arith.c',
39+
'jbig2_arith_iaid.c',
40+
'jbig2_arith_int.c',
41+
'jbig2_generic.c',
42+
'jbig2_halftone.c',
43+
'jbig2_huffman.c',
44+
'jbig2_hufftab.c',
45+
'jbig2_image.c',
46+
'jbig2_image_pbm.c',
47+
'jbig2_mmr.c',
48+
'jbig2_page.c',
49+
'jbig2_refinement.c',
50+
'jbig2_segment.c',
51+
'jbig2_symbol_dict.c',
52+
'jbig2_text.c',
53+
]
54+
progs_src = [
55+
'jbig2dec.c',
56+
'sha1.c',
57+
]
58+
tests_src = [
59+
]
60+
61+
m_dep = cc.find_library('m', required: false)
62+
63+
png_dep = dependency('libpng', required: progs_opt.disabled() ? progs_opt : false)
64+
if png_dep.found()
65+
progs_src += 'jbig2_image_png.c'
66+
endif
67+
68+
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
69+
70+
cdata = configuration_data()
71+
cdata.set('HAVE_LIBPNG', png_dep.found())
72+
cdata.set('WORDS_BIGENDIAN', host_machine.endian() == 'big' ? 1 : false)
73+
74+
foreach _header : [
75+
'stdint.h',
76+
'string.h',
77+
]
78+
cdata.set(
79+
'HAVE_' + _header.underscorify().to_upper(),
80+
cc.has_header(_header) ? 1 : false,
81+
)
82+
endforeach
83+
84+
if (
85+
progs_opt.allowed()
86+
and cc.has_function('getopt_long', prefix: '#include<getopt.h>')
87+
)
88+
cdata.set('HAVE_GETOPT_H', 1)
89+
else
90+
progs_src += [
91+
'getopt.c',
92+
'getopt.h',
93+
'getopt1.c',
94+
]
95+
endif
96+
97+
# Optional replacement for int…_t / uint…_t types.
98+
cdata.set('JBIG2_STDINT_H', '')
99+
cdata.set('JBIG2_INT8_T' , '')
100+
cdata.set('JBIG2_INT16_T' , '')
101+
cdata.set('JBIG2_INT32_T' , '')
102+
if cdata.get('HAVE_STDINT_H').to_string() != '1'
103+
sizeof_types = {}
104+
foreach _type : ['char', 'short', 'int', 'long']
105+
sizeof_types += {_type: cc.sizeof(_type)}
106+
endforeach
107+
foreach _spec : [
108+
['int8' , 1, 'char' ],
109+
['int16', 2, 'short char int'],
110+
['int32', 4, 'int long short'],
111+
]
112+
_name = _spec[0]
113+
_size = _spec[1]
114+
_typelist = _spec[2]
115+
_type = ''
116+
foreach _candidate : _typelist.split()
117+
if _size == sizeof_types[_candidate]
118+
_type = _candidate
119+
break
120+
endif
121+
endforeach
122+
if _type == ''
123+
error('could not find a suitable replacement type for @0@_t / u@0@_t'.format(_name))
124+
endif
125+
message('using @0@ for @1@_t / u@1@_t'.format(_type, _name))
126+
cdata.set('JBIG2_@0@_T'.format(_name.to_upper()), _type)
127+
endforeach
128+
endif
129+
130+
subdir('include')
131+
subdir('src')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
option('progs', type: 'feature')
2+
option('tests', type: 'feature')
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* config.h. Generated from config.h.meson by meson. */
2+
3+
/* Define to 1 if you have the <getopt.h> header
4+
* with a compatible `getopt_long` function. */
5+
#mesondefine HAVE_GETOPT_H
6+
7+
/* Define to 1 if you have the <libintl.h> header file. */
8+
#mesondefine HAVE_LIBINTL_H
9+
10+
/* Define if libpng is available (-lpng) */
11+
#mesondefine HAVE_LIBPNG
12+
13+
/* Define to 1 if you have the <stdint.h> header file. */
14+
#mesondefine HAVE_STDINT_H
15+
16+
/* Define to 1 if you have the <string.h> header file. */
17+
#mesondefine HAVE_STRING_H
18+
19+
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
20+
significant byte first (like Motorola and SPARC, unlike Intel). */
21+
#mesondefine WORDS_BIGENDIAN
22+
23+
/* vim: set ft=c: */
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
generated header with missing types for the
3+
jbig2dec program and library. include this
4+
after config.h, within the HAVE_CONFIG_H
5+
ifdef
6+
*/
7+
8+
#ifdef HAVE_STDINT_H
9+
# include <stdint.h>
10+
#else
11+
# ifdef JBIG2_REPLACE_STDINT_H
12+
# include <@JBIG2_STDINT_H@>
13+
# else
14+
typedef unsigned @JBIG2_INT32_T@ uint32_t;
15+
typedef unsigned @JBIG2_INT16_T@ uint16_t;
16+
typedef unsigned @JBIG2_INT8_T@ uint8_t;
17+
typedef signed @JBIG2_INT32_T@ int32_t;
18+
typedef signed @JBIG2_INT16_T@ int16_t;
19+
typedef signed @JBIG2_INT8_T@ int8_t;
20+
# endif /* JBIG2_REPLACE_STDINT */
21+
#endif /* HAVE_STDINT_H */
22+
23+
/* vim: set ft=c: */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
EXPORTS
2+
; Public API.
3+
jbig2_complete_page
4+
jbig2_ctx_free
5+
jbig2_ctx_new_imp
6+
jbig2_data_in
7+
jbig2_global_ctx_free
8+
jbig2_make_global_ctx
9+
jbig2_page_out
10+
jbig2_release_page
11+
; Private, but used by the jbig2dec executable.
12+
jbig2_error
13+
jbig2_image_write_pbm
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Because of the presence of `getopt.h` alongside the standard source files,
2+
# and the mix of private and public headers in the same directory, we copy
3+
# only the files needed to the build directory.
4+
foreach _listname, _needed : {
5+
'lib_inc' : true,
6+
'lib_src' : true,
7+
'progs_src': progs_opt.allowed(),
8+
'tests_src': progs_opt.allowed(),
9+
}
10+
if not _needed
11+
continue
12+
endif
13+
_srclist = get_variable(_listname)
14+
_dstlist = []
15+
foreach _file : _srclist
16+
_filecopy = fs.copyfile('..' / _file, _file)
17+
set_variable(_file.underscorify(), _filecopy)
18+
_dstlist += _filecopy
19+
endforeach
20+
set_variable(_listname, _dstlist)
21+
endforeach
22+
23+
config_h = configure_file(
24+
configuration: cdata,
25+
input: 'config.h.meson',
26+
output: 'config.h',
27+
)
28+
29+
config_types_h = configure_file(
30+
configuration: cdata,
31+
input: 'config_types.h.meson',
32+
output: 'config_types.h',
33+
)
34+
35+
lib_inc += [
36+
config_h,
37+
config_types_h,
38+
jbig2_h,
39+
]
40+
41+
jbig2dec_lib = library(
42+
'jbig2dec',
43+
[
44+
lib_inc,
45+
lib_src,
46+
],
47+
dependencies: m_dep,
48+
install: true,
49+
version: '0.0.0',
50+
vs_module_defs: 'jbig2dec.def',
51+
)
52+
53+
jbig2dec_dep = declare_dependency(
54+
include_directories: public_include,
55+
link_with: jbig2dec_lib,
56+
sources: jbig2_h,
57+
)
58+
meson.override_dependency('jbig2dec', jbig2dec_dep)
59+
60+
pkg = import('pkgconfig')
61+
pkg.generate(
62+
jbig2dec_lib,
63+
description: 'JBIG2 decoder library.',
64+
filebase: 'jbig2dec',
65+
name: 'libjbig2dec',
66+
)
67+
68+
if progs_opt.allowed()
69+
executable(
70+
'jbig2dec',
71+
[lib_inc, progs_src],
72+
dependencies: [jbig2dec_dep, png_dep],
73+
install: true,
74+
)
75+
endif
76+
77+
if tests_opt.allowed()
78+
# Tests need access to all symbols, including on Windows.
79+
jbig2dec_priv_lib = static_library(
80+
'jbig2dec_priv',
81+
objects: jbig2dec_lib.extract_all_objects(recursive: true),
82+
)
83+
foreach _name, _src : {
84+
'arith' : jbig2_arith_c,
85+
'huffman': jbig2_huffman_c,
86+
'sha1' : sha1_c,
87+
}
88+
test(
89+
_name,
90+
executable(
91+
_name,
92+
[lib_inc, _src],
93+
c_args: '-DTEST',
94+
include_directories: public_include,
95+
link_with: jbig2dec_priv_lib,
96+
),
97+
)
98+
endforeach
99+
endif

0 commit comments

Comments
 (0)