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
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
extern crate libc;
pub use self::libc::FILE;
pub use std::os::raw::{c_int, c_uint, c_void, c_long, c_ulong};
use std::mem;
use std::default::Default;
pub use J_COLOR_SPACE::*;
pub use J_BOOLEAN_PARAM::*;
pub use J_FLOAT_PARAM::*;
pub use J_INT_PARAM::*;
pub use JINT_COMPRESS_PROFILE_VALUE::*;
pub use J_DCT_METHOD::JDCT_ISLOW as JDCT_DEFAULT;
pub use J_DCT_METHOD::JDCT_IFAST as JDCT_FASTEST;
#[cfg(feature = "jpeg80_abi")]
pub const JPEG_LIB_VERSION: c_int = 80;
#[cfg(all(feature = "jpeg70_abi", not(feature = "jpeg80_abi")))]
pub const JPEG_LIB_VERSION: c_int = 70;
#[cfg(not(feature = "jpeg70_abi"))]
pub const JPEG_LIB_VERSION: c_int = 62;
pub const DCTSIZE: usize = 8;
pub const DCTSIZE2: usize = DCTSIZE*DCTSIZE;
pub const JPOOL_PERMANENT: c_int = 0;
pub const JPOOL_IMAGE: c_int = 1;
pub const NUM_QUANT_TBLS: usize = 4;
pub type boolean = c_int;
pub type JSAMPLE = u8;
pub type JCOEF = i16;
pub type JDIMENSION = c_uint;
pub type JSAMPROW = *const JSAMPLE;
pub type JSAMPROW_MUT = *mut JSAMPLE;
pub type JSAMPARRAY = *const JSAMPROW;
pub type JSAMPARRAY_MUT = *mut JSAMPROW_MUT;
pub type JSAMPIMAGE = *const JSAMPARRAY;
pub type JSAMPIMAGE_MUT = *mut JSAMPARRAY_MUT;
pub type JBLOCK = [JCOEF; 64usize];
pub type JBLOCKROW = *mut JBLOCK;
pub type JBLOCKARRAY = *mut JBLOCKROW;
#[cfg(feature = "nasm_simd")]
pub type DCTELEM = i16;
#[cfg(not(feature = "nasm_simd"))]
pub type DCTELEM = c_int;
#[repr(C)]
pub struct JQUANT_TBL {
pub quantval: [u16; 64usize],
sent_table: boolean,
}
impl Default for JQUANT_TBL {
fn default() -> JQUANT_TBL { unsafe { mem::zeroed() } }
}
#[repr(C)]
pub struct JHUFF_TBL {
pub bits: [u8; 17usize],
pub huffval: [u8; 256usize],
sent_table: boolean,
}
impl Default for JHUFF_TBL {
fn default() -> JHUFF_TBL { unsafe { mem::zeroed() } }
}
#[repr(C)]
pub struct jpeg_component_info {
pub component_id: c_int,
pub component_index: c_int,
pub h_samp_factor: c_int,
pub v_samp_factor: c_int,
pub quant_tbl_no: c_int,
pub dc_tbl_no: c_int,
pub ac_tbl_no: c_int,
pub width_in_blocks: JDIMENSION,
pub height_in_blocks: JDIMENSION,
#[cfg(feature = "jpeg70_abi")]
DCT_h_scaled_size: c_int,
#[cfg(feature = "jpeg70_abi")]
DCT_v_scaled_size: c_int,
#[cfg(not(feature = "jpeg70_abi"))]
DCT_scaled_size: c_int,
downsampled_width: JDIMENSION,
downsampled_height: JDIMENSION,
component_needed: boolean,
MCU_width: c_int,
MCU_height: c_int,
MCU_blocks: c_int,
MCU_sample_width: c_int,
last_col_width: c_int,
last_row_height: c_int,
pub quant_table: *mut JQUANT_TBL,
dct_table: *mut c_void,
}
impl Default for jpeg_component_info {
fn default() -> jpeg_component_info { unsafe { mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct jpeg_scan_info {
pub comps_in_scan: c_int,
pub component_index: [c_int; 4usize],
pub Ss: c_int,
pub Se: c_int,
pub Ah: c_int,
pub Al: c_int,
}
impl Default for jpeg_scan_info {
fn default() -> jpeg_scan_info { unsafe { mem::zeroed() } }
}
#[repr(C)]
pub struct jpeg_marker_struct {
pub next: *mut jpeg_marker_struct,
pub marker: u8,
pub original_length: c_uint,
pub data_length: c_uint,
pub data: *mut u8,
}
pub enum jpeg_marker {
APP0 = 0xE0,
COM = 0xFE,
}
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum J_COLOR_SPACE {
JCS_UNKNOWN,
JCS_GRAYSCALE,
JCS_RGB,
JCS_YCbCr,
JCS_CMYK,
JCS_YCCK,
JCS_EXT_RGB,
JCS_EXT_RGBX,
JCS_EXT_BGR,
JCS_EXT_BGRX,
JCS_EXT_XBGR,
JCS_EXT_XRGB,
JCS_EXT_RGBA,
JCS_EXT_BGRA,
JCS_EXT_ABGR,
JCS_EXT_ARGB,
JCS_RGB565,
}
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum J_DCT_METHOD {
JDCT_ISLOW = 0,
JDCT_IFAST = 1,
JDCT_FLOAT = 2,
}
#[repr(C)]
pub enum J_DITHER_MODE {
JDITHER_NONE = 0,
JDITHER_ORDERED = 1,
JDITHER_FS = 2,
}
#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum J_BOOLEAN_PARAM {
JBOOLEAN_OPTIMIZE_SCANS = 0x680C061E,
JBOOLEAN_TRELLIS_QUANT = 0xC5122033,
JBOOLEAN_TRELLIS_QUANT_DC = 0x339D4C0C,
JBOOLEAN_TRELLIS_EOB_OPT = 0xD7F73780,
JBOOLEAN_USE_LAMBDA_WEIGHT_TBL = 0x339DB65F,
JBOOLEAN_USE_SCANS_IN_TRELLIS = 0xFD841435,
JBOOLEAN_TRELLIS_Q_OPT = 0xE12AE269,
JBOOLEAN_OVERSHOOT_DERINGING = 0x3F4BBBF9,
}
#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum J_FLOAT_PARAM {
JFLOAT_LAMBDA_LOG_SCALE1 = 0x5B61A599,
JFLOAT_LAMBDA_LOG_SCALE2 = 0xB9BBAE03,
JFLOAT_TRELLIS_DELTA_DC_WEIGHT = 0x13775453
}
#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum J_INT_PARAM {
JINT_COMPRESS_PROFILE = 0xE9918625,
JINT_TRELLIS_FREQ_SPLIT = 0x6FAFF127,
JINT_TRELLIS_NUM_LOOPS = 0xB63EBF39,
JINT_BASE_QUANT_TBL_IDX = 0x44492AB1,
JINT_DC_SCAN_OPT_MODE = 0x0BE7AD3C
}
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum JINT_COMPRESS_PROFILE_VALUE {
JCP_MAX_COMPRESSION = 0x5D083AAD,
JCP_FASTEST = 0x2AEA5CB4
}
#[repr(C)]
pub struct jpeg_common_struct {
pub err: *mut jpeg_error_mgr,
pub mem: *mut jpeg_memory_mgr,
pub progress: *mut jpeg_progress_mgr,
pub client_data: *mut c_void,
pub is_decompressor: boolean,
pub global_state: c_int,
}
enum jpeg_comp_master {}
enum jpeg_c_main_controller {}
enum jpeg_c_prep_controller {}
enum jpeg_c_coef_controller {}
enum jpeg_marker_writer {}
enum jpeg_color_converter {}
enum jpeg_downsampler {}
enum jpeg_forward_dct {}
enum jpeg_entropy_encoder {}
#[repr(C)]
pub struct jpeg_compress_struct {
pub common : jpeg_common_struct,
pub dest: *mut jpeg_destination_mgr,
pub image_width: JDIMENSION,
pub image_height: JDIMENSION,
pub input_components: c_int,
pub in_color_space: J_COLOR_SPACE,
pub input_gamma: f64,
#[cfg(feature = "jpeg70_abi")]
scale_num: c_uint,
#[cfg(feature = "jpeg70_abi")]
scale_denom: c_uint,
#[cfg(feature = "jpeg70_abi")]
jpeg_width: JDIMENSION,
#[cfg(feature = "jpeg70_abi")]
jpeg_height: JDIMENSION,
pub data_precision: c_int,
pub num_components: c_int,
pub jpeg_color_space: J_COLOR_SPACE,
pub comp_info: *mut jpeg_component_info,
pub quant_tbl_ptrs: [*mut JQUANT_TBL; 4usize],
#[cfg(feature = "jpeg70_abi")]
q_scale_factor: [c_int; NUM_QUANT_TBLS],
pub dc_huff_tbl_ptrs: [*mut JHUFF_TBL; 4usize],
pub ac_huff_tbl_ptrs: [*mut JHUFF_TBL; 4usize],
pub arith_dc_L: [u8; 16usize],
pub arith_dc_U: [u8; 16usize],
pub arith_ac_K: [u8; 16usize],
pub num_scans: c_int,
pub scan_info: *const jpeg_scan_info,
pub raw_data_in: boolean,
pub arith_code: boolean,
pub optimize_coding: boolean,
pub CCIR601_sampling: boolean,
#[cfg(feature = "jpeg70_abi")]
pub do_fancy_downsampling: boolean,
pub smoothing_factor: c_int,
pub dct_method: J_DCT_METHOD,
pub restart_interval: c_uint,
pub restart_in_rows: c_int,
pub write_JFIF_header: boolean,
pub JFIF_major_version: u8,
pub JFIF_minor_version: u8,
pub density_unit: u8,
pub X_density: u16,
pub Y_density: u16,
pub write_Adobe_marker: boolean,
pub next_scanline: JDIMENSION,
progressive_mode: boolean,
pub max_h_samp_factor: c_int,
pub max_v_samp_factor: c_int,
#[cfg(feature = "jpeg70_abi")]
min_DCT_h_scaled_size: c_int,
#[cfg(feature = "jpeg70_abi")]
min_DCT_v_scaled_size: c_int,
total_iMCU_rows: JDIMENSION,
comps_in_scan: c_int,
cur_comp_info: [*mut jpeg_component_info; 4usize],
MCUs_per_row: JDIMENSION,
MCU_rows_in_scan: JDIMENSION,
blocks_in_MCU: c_int,
MCU_membership: [c_int; 10usize],
Ss: c_int,
Se: c_int,
Ah: c_int,
Al: c_int,
#[cfg(feature = "jpeg80_abi")]
block_size: c_int,
#[cfg(feature = "jpeg80_abi")]
natural_order: *const c_int,
#[cfg(feature = "jpeg80_abi")]
lim_Se: c_int,
master: *mut jpeg_comp_master,
main: *mut jpeg_c_main_controller,
prep: *mut jpeg_c_prep_controller,
coef: *mut jpeg_c_coef_controller,
marker: *mut jpeg_marker_writer,
cconvert: *mut jpeg_color_converter,
downsample: *mut jpeg_downsampler,
fdct: *mut jpeg_forward_dct,
entropy: *mut jpeg_entropy_encoder,
script_space: *mut jpeg_scan_info,
script_space_size: c_int,
}
enum jpeg_decomp_master {}
enum jpeg_d_main_controller {}
enum jpeg_d_coef_controller {}
enum jpeg_d_post_controller {}
enum jpeg_input_controller {}
enum jpeg_marker_reader {}
enum jpeg_entropy_decoder {}
enum jpeg_inverse_dct {}
enum jpeg_upsampler {}
enum jpeg_color_deconverter {}
enum jpeg_color_quantizer {}
#[repr(C)]
pub struct jpeg_decompress_struct {
pub common: jpeg_common_struct,
pub src: *mut jpeg_source_mgr,
pub image_width: JDIMENSION,
pub image_height: JDIMENSION,
pub num_components: c_int,
pub jpeg_color_space: J_COLOR_SPACE,
pub out_color_space: J_COLOR_SPACE,
pub scale_num: c_uint,
pub scale_denom: c_uint,
pub output_gamma: f64,
pub buffered_image: boolean,
pub raw_data_out: boolean,
pub dct_method: J_DCT_METHOD,
pub do_fancy_upsampling: boolean,
pub do_block_smoothing: boolean,
pub quantize_colors: boolean,
pub dither_mode: J_DITHER_MODE,
pub two_pass_quantize: boolean,
pub desired_number_of_colors: c_int,
pub enable_1pass_quant: boolean,
pub enable_external_quant: boolean,
pub enable_2pass_quant: boolean,
pub output_width: JDIMENSION,
pub output_height: JDIMENSION,
pub out_color_components: c_int,
pub output_components: c_int,
pub rec_outbuf_height: c_int,
pub actual_number_of_colors: c_int,
pub colormap: JSAMPARRAY_MUT,
pub output_scanline: JDIMENSION,
pub input_scan_number: c_int,
pub input_iMCU_row: JDIMENSION,
pub output_scan_number: c_int,
pub output_iMCU_row: JDIMENSION,
pub coef_bits: *mut c_void,
pub quant_tbl_ptrs: [*mut JQUANT_TBL; 4usize],
dc_huff_tbl_ptrs: [*mut JHUFF_TBL; 4usize],
ac_huff_tbl_ptrs: [*mut JHUFF_TBL; 4usize],
data_precision: c_int,
pub comp_info: *mut jpeg_component_info,
#[cfg(feature = "jpeg80_abi")]
is_baseline: boolean,
progressive_mode: boolean,
arith_code: boolean,
arith_dc_L: [u8; 16usize],
arith_dc_U: [u8; 16usize],
arith_ac_K: [u8; 16usize],
restart_interval: c_uint,
saw_JFIF_marker: boolean,
JFIF_major_version: u8,
JFIF_minor_version: u8,
density_unit: u8,
X_density: u16,
Y_density: u16,
saw_Adobe_marker: boolean,
Adobe_transform: u8,
CCIR601_sampling: boolean,
pub marker_list: *mut jpeg_marker_struct,
pub max_h_samp_factor: c_int,
pub max_v_samp_factor: c_int,
#[cfg(feature = "jpeg70_abi")]
min_DCT_h_scaled_size: c_int,
#[cfg(feature = "jpeg70_abi")]
min_DCT_v_scaled_size: c_int,
#[cfg(not(feature = "jpeg70_abi"))]
min_DCT_scaled_size: c_int,
total_iMCU_rows: JDIMENSION,
sample_range_limit: *mut JSAMPLE,
comps_in_scan: c_int,
cur_comp_info: [*mut jpeg_component_info; 4usize],
MCUs_per_row: JDIMENSION,
MCU_rows_in_scan: JDIMENSION,
blocks_in_MCU: c_int,
MCU_membership: [c_int; 10usize],
Ss: c_int,
Se: c_int,
Ah: c_int,
Al: c_int,
#[cfg(feature = "jpeg80_abi")]
block_size: c_int,
#[cfg(feature = "jpeg80_abi")]
natural_order: *const c_int,
#[cfg(feature = "jpeg80_abi")]
lim_Se: c_int,
unread_marker: c_int,
master: *mut jpeg_decomp_master,
main: *mut jpeg_d_main_controller,
coef: *mut jpeg_d_coef_controller,
post: *mut jpeg_d_post_controller,
inputctl: *mut jpeg_input_controller,
marker: *mut jpeg_marker_reader,
entropy: *mut jpeg_entropy_decoder,
idct: *mut jpeg_inverse_dct,
upsample: *mut jpeg_upsampler,
cconvert: *mut jpeg_color_deconverter,
cquantize: *mut jpeg_color_quantizer,
}
#[repr(C)]
pub struct jpeg_error_mgr {
pub error_exit: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub emit_message: Option<extern "C" fn(cinfo: &mut jpeg_common_struct, msg_level: c_int)>,
pub output_message: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub format_message: Option<extern "C" fn(cinfo: &mut jpeg_common_struct, buffer: &[u8; 80usize])>,
pub reset_error_mgr: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub msg_code: c_int,
pub msg_parm: msg_parm_union,
pub trace_level: c_int,
pub num_warnings: c_long,
pub jpeg_message_table: *const *const i8,
pub last_jpeg_message: c_int,
pub addon_message_table: *const *const i8,
pub first_addon_message: c_int,
pub last_addon_message: c_int,
}
#[repr(C)]
pub struct msg_parm_union {
pub _bindgen_data_: [u32; 20usize],
}
impl msg_parm_union {
pub unsafe fn i(&mut self) -> *mut [c_int; 8usize] {
::std::mem::transmute(&self._bindgen_data_)
}
pub unsafe fn s(&mut self) -> *mut [i8; 80usize] {
::std::mem::transmute(&self._bindgen_data_)
}
}
impl Default for msg_parm_union {
fn default() -> msg_parm_union { unsafe { mem::zeroed() } }
}
#[repr(C)]
pub struct jpeg_progress_mgr {
pub progress_monitor: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub pass_counter: c_long,
pub pass_limit: c_long,
pub completed_passes: c_int,
pub total_passes: c_int,
}
#[repr(C)]
pub struct jpeg_destination_mgr {
pub next_output_byte: *mut u8,
pub free_in_buffer: usize,
pub init_destination: Option<extern "C" fn(cinfo: &mut jpeg_compress_struct)>,
pub empty_output_buffer: Option<extern "C" fn(cinfo: &mut jpeg_compress_struct)
-> boolean>,
pub term_destination: Option<extern "C" fn(cinfo: &mut jpeg_compress_struct)>,
}
#[repr(C)]
pub struct jpeg_source_mgr {
pub next_input_byte: *const u8,
pub bytes_in_buffer: usize,
pub init_source: Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct)>,
pub fill_input_buffer: Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct)
-> boolean>,
pub skip_input_data: Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct,
num_bytes:
c_long)>,
pub resync_to_restart: Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct,
desired: c_int)
-> boolean>,
pub term_source: Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct)>,
}
pub enum jvirt_sarray_control {}
pub enum jvirt_barray_control {}
#[repr(C)]
pub struct jpeg_memory_mgr {
pub alloc_small: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id: c_int,
sizeofobject: usize) -> *mut c_void>,
pub alloc_large: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id: c_int,
sizeofobject: usize) -> *mut c_void>,
pub alloc_sarray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id: c_int,
samplesperrow: JDIMENSION,
numrows: JDIMENSION) -> JSAMPARRAY_MUT>,
pub alloc_barray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id: c_int,
blocksperrow: JDIMENSION,
numrows: JDIMENSION) -> JBLOCKARRAY>,
pub request_virt_sarray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id: c_int,
pre_zero: boolean,
samplesperrow: JDIMENSION,
numrows: JDIMENSION,
maxaccess: JDIMENSION) -> *mut jvirt_sarray_control>,
pub request_virt_barray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
pool_id:
c_int,
pre_zero: boolean,
blocksperrow:
JDIMENSION,
numrows: JDIMENSION,
maxaccess: JDIMENSION) -> *mut jvirt_barray_control>,
pub realize_virt_arrays: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub access_virt_sarray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
ptr: *mut jvirt_sarray_control,
start_row: JDIMENSION,
num_rows: JDIMENSION,
writable: boolean) -> JSAMPARRAY_MUT>,
pub access_virt_barray: Option<extern "C" fn(cinfo: &mut jpeg_common_struct,
ptr: *mut jvirt_barray_control,
start_row: JDIMENSION,
num_rows: JDIMENSION,
writable: boolean) -> JBLOCKARRAY>,
pub free_pool: Option<extern "C" fn(cinfo: &mut jpeg_common_struct, pool_id: c_int)>,
pub self_destruct: Option<extern "C" fn(cinfo: &mut jpeg_common_struct)>,
pub max_memory_to_use: c_long,
pub max_alloc_chunk: c_long,
}
pub type jpeg_marker_parser_method = Option<extern "C" fn(cinfo: &mut jpeg_decompress_struct) -> boolean>;
pub unsafe fn jpeg_create_decompress(dinfo: *mut jpeg_decompress_struct) {
jpeg_CreateDecompress(dinfo, JPEG_LIB_VERSION, mem::size_of::<jpeg_decompress_struct>());
}
pub unsafe fn jpeg_create_compress(cinfo: *mut jpeg_compress_struct) {
jpeg_CreateCompress(cinfo, JPEG_LIB_VERSION, mem::size_of::<jpeg_compress_struct>());
}
extern "C" {
pub fn jpeg_std_error<'a>(err: &'a mut jpeg_error_mgr) -> &'a mut jpeg_error_mgr;
pub fn jpeg_CreateCompress(cinfo: *mut jpeg_compress_struct, version: c_int, structsize: usize);
pub fn jpeg_CreateDecompress(cinfo: *mut jpeg_decompress_struct, version: c_int, structsize: usize);
pub fn jpeg_destroy_compress(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_destroy_decompress(cinfo: &mut jpeg_decompress_struct);
pub fn jpeg_stdio_dest(cinfo: &mut jpeg_compress_struct, outfile: *mut FILE);
pub fn jpeg_stdio_src(cinfo: &mut jpeg_decompress_struct, infile: *mut FILE);
pub fn jpeg_mem_dest(cinfo: &mut jpeg_compress_struct,
outbuffer: *mut *mut u8,
outsize: *mut c_ulong);
pub fn jpeg_mem_src(cinfo: &mut jpeg_decompress_struct,
inbuffer: *const u8,
insize: c_ulong);
pub fn jpeg_set_defaults(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_set_colorspace(cinfo: &mut jpeg_compress_struct, colorspace: J_COLOR_SPACE);
pub fn jpeg_default_colorspace(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_set_quality(cinfo: &mut jpeg_compress_struct, quality: c_int, force_baseline: boolean);
pub fn jpeg_set_linear_quality(cinfo: &mut jpeg_compress_struct,
scale_factor: c_int,
force_baseline: boolean);
pub fn jpeg_add_quant_table(cinfo: &mut jpeg_compress_struct,
which_tbl: c_int,
basic_table: *const c_uint,
scale_factor: c_int,
force_baseline: boolean);
pub fn jpeg_float_add_quant_table(cinfo: &mut jpeg_compress_struct,
which_tbl: c_int,
basic_table: *const c_uint,
scale_factor: f32,
force_baseline: boolean);
pub fn jpeg_quality_scaling(quality: c_int) -> c_int;
pub fn jpeg_float_quality_scaling(quality: f32) -> f32;
pub fn jpeg_simple_progression(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_suppress_tables(cinfo: &mut jpeg_compress_struct, suppress: boolean);
pub fn jpeg_alloc_quant_table(cinfo: &mut jpeg_common_struct) -> *mut JQUANT_TBL;
pub fn jpeg_alloc_huff_table(cinfo: &mut jpeg_common_struct) -> *mut JHUFF_TBL;
pub fn jpeg_start_compress(cinfo: &mut jpeg_compress_struct, write_all_tables: boolean);
pub fn jpeg_write_scanlines(cinfo: &mut jpeg_compress_struct, scanlines: JSAMPARRAY,
num_lines: JDIMENSION) -> JDIMENSION;
pub fn jpeg_finish_compress(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_write_raw_data(cinfo: &mut jpeg_compress_struct, data: JSAMPIMAGE,
num_lines: JDIMENSION) -> JDIMENSION;
pub fn jpeg_write_marker(cinfo: &mut jpeg_compress_struct, marker: c_int,
dataptr: *const u8, datalen: c_uint);
pub fn jpeg_write_m_header(cinfo: &mut jpeg_compress_struct, marker: c_int, datalen: c_uint);
pub fn jpeg_write_m_byte(cinfo: &mut jpeg_compress_struct, val: c_int);
pub fn jpeg_write_tables(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_read_header(cinfo: &mut jpeg_decompress_struct, require_image: boolean) -> c_int;
pub fn jpeg_start_decompress(cinfo: &mut jpeg_decompress_struct) -> boolean;
pub fn jpeg_read_scanlines(cinfo: &mut jpeg_decompress_struct, scanlines: JSAMPARRAY_MUT,
max_lines: JDIMENSION) -> JDIMENSION;
pub fn jpeg_finish_decompress(cinfo: &mut jpeg_decompress_struct) -> boolean;
pub fn jpeg_read_raw_data(cinfo: &mut jpeg_decompress_struct, data: JSAMPIMAGE_MUT,
max_lines: JDIMENSION) -> JDIMENSION;
pub fn jpeg_has_multiple_scans(cinfo: &jpeg_decompress_struct) -> boolean;
pub fn jpeg_start_output(cinfo: &mut jpeg_decompress_struct, scan_number: c_int) -> boolean;
pub fn jpeg_finish_output(cinfo: &mut jpeg_decompress_struct) -> boolean;
pub fn jpeg_input_complete(cinfo: &jpeg_decompress_struct) -> boolean;
#[deprecated]
pub fn jpeg_new_colormap(cinfo: &mut jpeg_decompress_struct);
pub fn jpeg_consume_input(cinfo: &mut jpeg_decompress_struct) -> c_int;
#[cfg(feature = "jpeg70_abi")]
pub fn jpeg_calc_jpeg_dimensions(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_calc_output_dimensions(cinfo: &mut jpeg_decompress_struct);
pub fn jpeg_save_markers(cinfo: &mut jpeg_decompress_struct,
marker_code: c_int,
length_limit: c_uint);
pub fn jpeg_set_marker_processor(cinfo: &mut jpeg_decompress_struct,
marker_code: c_int,
routine: jpeg_marker_parser_method);
pub fn jpeg_read_coefficients(cinfo: &mut jpeg_decompress_struct) -> *mut *mut jvirt_barray_control;
pub fn jpeg_write_coefficients(cinfo: &mut jpeg_compress_struct,
coef_arrays: *mut *mut jvirt_barray_control);
pub fn jpeg_copy_critical_parameters(srcinfo: &jpeg_decompress_struct,
dstinfo: &mut jpeg_compress_struct);
pub fn jpeg_abort_compress(cinfo: &mut jpeg_compress_struct);
pub fn jpeg_abort_decompress(cinfo: &mut jpeg_decompress_struct);
pub fn jpeg_resync_to_restart(cinfo: &mut jpeg_decompress_struct, desired: c_int) -> boolean;
pub fn jpeg_c_bool_param_supported(cinfo: &jpeg_compress_struct,
param: J_BOOLEAN_PARAM) -> boolean;
pub fn jpeg_c_set_bool_param(cinfo: &mut jpeg_compress_struct,
param: J_BOOLEAN_PARAM, value: boolean);
pub fn jpeg_c_get_bool_param(cinfo: &jpeg_compress_struct,
param: J_BOOLEAN_PARAM) -> boolean;
pub fn jpeg_c_float_param_supported(cinfo: &jpeg_compress_struct, param: J_FLOAT_PARAM) -> boolean;
pub fn jpeg_c_set_float_param(cinfo: &mut jpeg_compress_struct, param: J_FLOAT_PARAM, value: f32);
pub fn jpeg_c_get_float_param(cinfo: &jpeg_compress_struct, param: J_FLOAT_PARAM) -> f32;
pub fn jpeg_c_int_param_supported(cinfo: &jpeg_compress_struct, param: J_INT_PARAM) -> boolean;
pub fn jpeg_c_set_int_param(cinfo: &mut jpeg_compress_struct, param: J_INT_PARAM, value: c_int);
pub fn jpeg_c_get_int_param(cinfo: &jpeg_compress_struct, param: J_INT_PARAM) -> c_int;
pub fn jpeg_set_idct_method_selector(cinfo: &jpeg_compress_struct, param: *const c_void);
#[cfg(test)] fn jsimd_can_rgb_ycc() -> c_int;
#[cfg(test)] #[allow(dead_code)] fn jsimd_can_fdct_ifast() -> c_int;
#[cfg(test)] #[allow(dead_code)] fn jsimd_fdct_ifast_sse2(block: *mut DCTELEM);
}
#[test]
pub fn enum_32bit() {
assert_eq!(JBOOLEAN_TRELLIS_QUANT as u64, 0xC5122033);
}
#[test]
pub fn simd_is_detectable() {
unsafe {
jsimd_can_rgb_ycc();
}
}
#[test]
#[cfg(all(target_arch="x86_64", feature="nasm_simd"))]
pub fn simd_works_sse2() {
unsafe {
assert!(jsimd_can_fdct_ifast() != 0);
jsimd_fdct_ifast_sse2([0 as DCTELEM; 64].as_mut_ptr());
}
}
#[test]
pub fn try_decompress() {
unsafe {
let mut err = mem::zeroed();
jpeg_std_error(&mut err);
let mut cinfo: jpeg_decompress_struct = mem::zeroed();
cinfo.common.err = &mut err;
jpeg_create_decompress(&mut cinfo);
jpeg_destroy_decompress(&mut cinfo);
}
}
#[test]
pub fn try_compress() {
unsafe {
let mut err = mem::zeroed();
jpeg_std_error(&mut err);
let mut cinfo: jpeg_compress_struct = mem::zeroed();
cinfo.common.err = &mut err;
if 0 == jpeg_c_bool_param_supported(&cinfo, JBOOLEAN_TRELLIS_QUANT) {
panic!("Not linked to mozjpeg?");
}
jpeg_create_compress(&mut cinfo);
jpeg_destroy_compress(&mut cinfo);
}
}