-
Notifications
You must be signed in to change notification settings - Fork 0
/
ijl.h
executable file
·1529 lines (1318 loc) · 53.4 KB
/
ijl.h
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
/*M*
//
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 1998 Intel Corporation. All Rights Reserved.
//
//
// File:
// ijl.h
//
// Purpose:
// IJL Common Header File
// This file contains: definitions for data types, data
// structures, error codes, and function prototypes used
// in the Intel(R) JPEG Library (IJL).
//
// Version:
// 1.51
//
*M*/
#ifndef __IJL_H__
#define __IJL_H__
#if defined( __cplusplus )
extern "C" {
#endif
#ifndef IJL_ALL_WARNINGS
#if defined (_WIN32)
#if _MSC_VER >= 1000
/* nonstandard extension used : nameless struct/union */
#pragma warning(disable : 4201)
/* nonstandard extension used : bit field types other than int */
#pragma warning(disable : 4214)
/* unreferenced inline function has been removed */
#pragma warning(disable : 4514)
/* named type definition in parentheses */
#pragma warning(disable : 4115)
#endif /* _MSC_VER >= 1000 */
#endif /* _WIN32 */
#endif /* IJL_ALL_WARNINGS */
#if defined (_WIN32)
#define IJL_STDCALL __stdcall
#else
#define IJL_STDCALL
#endif
/* align struct on 8 bytes boundary */
#if defined (_WIN32)
#pragma pack (8)
#else
#endif
/* /////////////////////////////////////////////////////////////////////////
// Macros/Constants */
/* Size of file I/O buffer (4K). */
#define JBUFSIZE 4096
#if defined (_WIN32)
#define IJL_INT64 __int64
#else
#define IJL_INT64 long long
#endif
#define IJL_UINT64 unsigned IJL_INT64
#ifndef IJLAPI
#ifdef IJL_MSEXPORTS
#define IJLAPI(type,name,arg) \
extern __declspec(dllimport) type IJL_STDCALL name arg
#else
#define IJLAPI(type,name,arg) \
extern type IJL_STDCALL name arg
#endif
#endif
#define IJL_DIB_ALIGN (sizeof(int) - 1)
#define IJL_DIB_UWIDTH(width,nchannels) \
((width) * (nchannels))
#define IJL_DIB_AWIDTH(width,nchannels) \
( ((IJL_DIB_UWIDTH(width,nchannels) + IJL_DIB_ALIGN) & (~IJL_DIB_ALIGN)) )
#define IJL_DIB_PAD_BYTES(width,nchannels) \
( IJL_DIB_AWIDTH(width,nchannels) - IJL_DIB_UWIDTH(width,nchannels) )
#define IJL_DIB_SCALE_SIZE(jpgsize,scale) \
( ((jpgsize) + (scale) - 1) / (scale) )
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJLibVersion
//
// Purpose: Stores library version info.
//
// Context:
//
// Example:
// major - 1
// minor - 0
// build - 1
// Name - "ijl10.dll"
// Version - "1.0.1 Beta1"
// InternalVersion - "1.0.1.1"
// BuildDate - "Sep 22 1998"
// CallConv - "DLL"
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _IJLibVersion
{
int major;
int minor;
int build;
const char* Name;
const char* Version;
const char* InternalVersion;
const char* BuildDate;
const char* CallConv;
} IJLibVersion;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJL_RECT
//
// Purpose: Keep coordinates for rectangle region of image
//
// Context: Used to specify roi
//
// Fields:
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _IJL_RECT
{
long left;
long top;
long right;
long bottom;
} IJL_RECT;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJL_HANDLE
//
// Purpose: file handle
//
// Context: used internally
//
// Fields:
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef void* IJL_HANDLE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJLIOTYPE
//
// Purpose: Possible types of data read/write/other operations to be
// performed by the functions IJL_Read and IJL_Write.
//
// See the Developer's Guide for details on appropriate usage.
//
// Fields:
//
// IJL_JFILE_XXXXXXX Indicates JPEG data in a stdio file.
//
// IJL_JBUFF_XXXXXXX Indicates JPEG data in an addressable buffer.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _IJLIOTYPE
{
IJL_SETUP = -1,
/* Read JPEG parameters (i.e., height, width, channels, sampling, etc.) */
/* from a JPEG bit stream. */
IJL_JFILE_READPARAMS = 0,
IJL_JBUFF_READPARAMS = 1,
/* Read a JPEG Interchange Format image. */
IJL_JFILE_READWHOLEIMAGE = 2,
IJL_JBUFF_READWHOLEIMAGE = 3,
/* Read JPEG tables from a JPEG Abbreviated Format bit stream. */
IJL_JFILE_READHEADER = 4,
IJL_JBUFF_READHEADER = 5,
/* Read image info from a JPEG Abbreviated Format bit stream. */
IJL_JFILE_READENTROPY = 6,
IJL_JBUFF_READENTROPY = 7,
/* Write an entire JFIF bit stream. */
IJL_JFILE_WRITEWHOLEIMAGE = 8,
IJL_JBUFF_WRITEWHOLEIMAGE = 9,
/* Write a JPEG Abbreviated Format bit stream. */
IJL_JFILE_WRITEHEADER = 10,
IJL_JBUFF_WRITEHEADER = 11,
/* Write image info to a JPEG Abbreviated Format bit stream. */
IJL_JFILE_WRITEENTROPY = 12,
IJL_JBUFF_WRITEENTROPY = 13,
/* Scaled Decoding Options: */
/* Reads a JPEG image scaled to 1/2 size. */
IJL_JFILE_READONEHALF = 14,
IJL_JBUFF_READONEHALF = 15,
/* Reads a JPEG image scaled to 1/4 size. */
IJL_JFILE_READONEQUARTER = 16,
IJL_JBUFF_READONEQUARTER = 17,
/* Reads a JPEG image scaled to 1/8 size. */
IJL_JFILE_READONEEIGHTH = 18,
IJL_JBUFF_READONEEIGHTH = 19,
/* Reads an embedded thumbnail from a JFIF bit stream. */
IJL_JFILE_READTHUMBNAIL = 20,
IJL_JBUFF_READTHUMBNAIL = 21
} IJLIOTYPE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJL_COLOR
//
// Purpose: Possible color space formats.
//
// Note these formats do *not* necessarily denote
// the number of channels in the color space.
// There exists separate "channel" fields in the
// JPEG_CORE_PROPERTIES data structure specifically
// for indicating the number of channels in the
// JPEG and/or DIB color spaces.
//
// See the Developer's Guide for details on appropriate usage.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _IJL_COLOR
{
IJL_RGB = 1, /* Red-Green-Blue color space. */
IJL_BGR = 2, /* Reversed channel ordering from IJL_RGB. */
IJL_YCBCR = 3, /* Luminance-Chrominance color space as defined */
/* by CCIR Recommendation 601. */
IJL_G = 4, /* Grayscale color space. */
IJL_RGBA_FPX = 5, /* FlashPix RGB 4 channel color space that */
/* has pre-multiplied opacity. */
IJL_YCBCRA_FPX = 6, /* FlashPix YCbCr 4 channel color space that */
/* has pre-multiplied opacity. */
IJL_OTHER = 255 /* Some other color space not defined by the IJL. */
/* (This means no color space conversion will */
/* be done by the IJL.) */
} IJL_COLOR;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJL_JPGSUBSAMPLING
//
// Purpose: Possible subsampling formats used in the JPEG.
//
// See the Developer's Guide for details on appropriate usage.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _IJL_JPGSUBSAMPLING
{
IJL_NONE = 0, /* Corresponds to "No Subsampling". */
/* Valid on a JPEG w/ any number of channels. */
IJL_411 = 1, /* Valid on a JPEG w/ 3 channels. */
IJL_422 = 2, /* Valid on a JPEG w/ 3 channels. */
IJL_4114 = 3, /* Valid on a JPEG w/ 4 channels. */
IJL_4224 = 4 /* Valid on a JPEG w/ 4 channels. */
} IJL_JPGSUBSAMPLING;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: IJL_DIBSUBSAMPLING
//
// Purpose: Possible subsampling formats used in the DIB.
//
// See the Developer's Guide for details on appropriate usage.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef IJL_JPGSUBSAMPLING IJL_DIBSUBSAMPLING;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: HUFFMAN_TABLE
//
// Purpose: Stores Huffman table information in a fast-to-use format.
//
// Context: Used by Huffman encoder/decoder to access Huffman table
// data. Raw Huffman tables are formatted to fit this
// structure prior to use.
//
// Fields:
// huff_class 0 == DC Huffman or lossless table, 1 == AC table.
// ident Huffman table identifier, 0-3 valid (Extended Baseline).
// huffelem Huffman elements for codes <= 8 bits long;
// contains both zero run-length and symbol length in bits.
// huffval Huffman values for codes 9-16 bits in length.
// mincode Smallest Huffman code of length n.
// maxcode Largest Huffman code of length n.
// valptr Starting index into huffval[] for symbols of length k.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _HUFFMAN_TABLE
{
int huff_class;
int ident;
unsigned int huffelem[256];
unsigned short huffval[256];
unsigned short mincode[17];
short maxcode[18];
unsigned short valptr[17];
} HUFFMAN_TABLE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: JPEGHuffTable
//
// Purpose: Stores pointers to JPEG-binary spec compliant
// Huffman table information.
//
// Context: Used by interface and table methods to specify encoder
// tables to generate and store JPEG images.
//
// Fields:
// bits Points to number of codes of length i (<=16 supported).
// vals Value associated with each Huffman code.
// hclass 0 == DC table, 1 == AC table.
// ident Specifies the identifier for this table.
// 0-3 for extended JPEG compliance.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _JPEGHuffTable
{
unsigned char* bits;
unsigned char* vals;
unsigned char hclass;
unsigned char ident;
} JPEGHuffTable;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: QUANT_TABLE
//
// Purpose: Stores quantization table information in a
// fast-to-use format.
//
// Context: Used by quantizer/dequantizer to store formatted
// quantization tables.
//
// Fields:
// precision 0 => elements contains 8-bit elements,
// 1 => elements contains 16-bit elements.
// ident Table identifier (0-3).
// elements Pointer to 64 table elements + 16 extra elements to catch
// input data errors that may cause malfunction of the
// Huffman decoder.
// elarray Space for elements (see above) plus 8 bytes to align
// to a quadword boundary.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _QUANT_TABLE
{
int precision;
int ident;
short* elements;
short elarray [84];
} QUANT_TABLE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: JPEGQuantTable
//
// Purpose: Stores pointers to JPEG binary spec compliant
// quantization table information.
//
// Context: Used by interface and table methods to specify encoder
// tables to generate and store JPEG images.
//
// Fields:
// quantizer Zig-zag order elements specifying quantization factors.
// ident Specifies identifier for this table.
// 0-3 valid for Extended Baseline JPEG compliance.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _JPEGQuantTable
{
unsigned char* quantizer;
unsigned char ident;
} JPEGQuantTable;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: FRAME_COMPONENT
//
// Purpose: One frame-component structure is allocated per component
// in a frame.
//
// Context: Used by Huffman decoder to manage components.
//
// Fields:
// ident Component identifier. The tables use this ident to
// determine the correct table for each component.
// hsampling Horizontal subsampling factor for this component,
// 1-4 are legal.
// vsampling Vertical subsampling factor for this component,
// 1-4 are legal.
// quant_sel Quantization table selector. The quantization table
// used by this component is determined via this selector.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _FRAME_COMPONENT
{
int ident;
int hsampling;
int vsampling;
int quant_sel;
} FRAME_COMPONENT;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: FRAME
//
// Purpose: Stores frame-specific data.
//
// Context: One Frame structure per image.
//
// Fields:
// precision Sample precision in bits.
// width Width of the source image in pixels.
// height Height of the source image in pixels.
// MCUheight Height of a frame MCU.
// MCUwidth Width of a frame MCU.
// max_hsampling Max horiz sampling ratio of any component in the frame.
// max_vsampling Max vert sampling ratio of any component in the frame.
// ncomps Number of components/channels in the frame.
// horMCU Number of horizontal MCUs in the frame.
// totalMCU Total number of MCUs in the frame.
// comps Array of 'ncomps' component descriptors.
// restart_interv Indicates number of MCUs after which to restart the
// entropy parameters.
// SeenAllDCScans Used when decoding Multiscan images to determine if
// all channels of an image have been decoded.
// SeenAllACScans (See SeenAllDCScans)
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _FRAME
{
int precision;
int width;
int height;
int MCUheight;
int MCUwidth;
int max_hsampling;
int max_vsampling;
int ncomps;
int horMCU;
long totalMCU;
FRAME_COMPONENT* comps;
int restart_interv;
int SeenAllDCScans;
int SeenAllACScans;
} FRAME;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: SCAN_COMPONENT
//
// Purpose: One scan-component structure is allocated per component
// of each scan in a frame.
//
// Context: Used by Huffman decoder to manage components within scans.
//
// Fields:
// comp Component number, index to the comps member of FRAME.
// hsampling Horizontal sampling factor.
// vsampling Vertical sampling factor.
// dc_table DC Huffman table pointer for this scan.
// ac_table AC Huffman table pointer for this scan.
// quant_table Quantization table pointer for this scan.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _SCAN_COMPONENT
{
int comp;
int hsampling;
int vsampling;
HUFFMAN_TABLE* dc_table;
HUFFMAN_TABLE* ac_table;
QUANT_TABLE* quant_table;
} SCAN_COMPONENT;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: SCAN
//
// Purpose: One SCAN structure is allocated per scan in a frame.
//
// Context: Used by Huffman decoder to manage scans.
//
// Fields:
// ncomps Number of image components in a scan, 1-4 legal.
// gray_scale If TRUE, decode only the Y channel.
// start_spec Start coefficient of spectral or predictor selector.
// end_spec End coefficient of spectral selector.
// approx_high High bit position in successive approximation
// Progressive coding.
// approx_low Low bit position in successive approximation
// Progressive coding.
// restart_interv Restart interval, 0 if disabled.
// curxMCU Next horizontal MCU index to be processed after
// an interrupted SCAN.
// curyMCU Next vertical MCU index to be processed after
// an interrupted SCAN.
// dc_diff Array of DC predictor values for DPCM modes.
// comps Array of ncomps SCAN_COMPONENT component identifiers.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _SCAN
{
int ncomps;
int gray_scale;
int start_spec;
int end_spec;
int approx_high;
int approx_low;
unsigned int restart_interv;
int curxMCU;
int curyMCU;
int dc_diff[4];
SCAN_COMPONENT* comps;
} SCAN;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: DCTTYPE
//
// Purpose: Possible algorithms to be used to perform the discrete
// cosine transform (DCT).
//
// Fields:
// IJL_AAN The AAN (Arai, Agui, and Nakajima) algorithm from
// Trans. IEICE, vol. E 71(11), 1095-1097, Nov. 1988.
// IJL_IPP The modified K. R. Rao and P. Yip algorithm from
// Intel Performance Primitives Library
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _DCTTYPE
{
IJL_AAN = 0,
IJL_IPP = 1
} DCTTYPE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: UPSAMPLING_TYPE
//
// Purpose: - Possible algorithms to be used to perform upsampling
//
// Fields:
// IJL_BOX_FILTER - the algorithm is simple replication of the input pixel
// onto the corresponding output pixels (box filter);
// IJL_TRIANGLE_FILTER - 3/4 * nearer pixel + 1/4 * further pixel in each
// dimension
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _UPSAMPLING_TYPE
{
IJL_BOX_FILTER = 0,
IJL_TRIANGLE_FILTER = 1
} UPSAMPLING_TYPE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: SAMPLING_STATE
//
// Purpose: Stores current conditions of sampling. Only for upsampling
// with triangle filter is used now.
//
// Fields:
// top_row - pointer to buffer with MCUs, that are located above than
// current row of MCUs;
// cur_row - pointer to buffer with current row of MCUs;
// bottom_row - pointer to buffer with MCUs, that are located below than
// current row of MCUs;
// last_row - pointer to bottom boundary of last row of MCUs
// cur_row_number - number of row of MCUs, that is decoding;
// user_interrupt - field to store jprops->interrupt, because of we prohibit
// interrupts while top row of MCUs is upsampling.
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _SAMPLING_STATE
{
short* top_row;
short* cur_row;
short* bottom_row;
short* last_row;
int cur_row_number;
} SAMPLING_STATE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: PROCESSOR_TYPE
//
// Purpose: Possible types of processors.
// Note that the enums are defined in ascending order
// depending upon their various IA32 instruction support.
//
// Fields:
//
// IJL_OTHER_PROC
// Does not support the CPUID instruction and
// assumes no Pentium(R) processor instructions.
//
// IJL_PENTIUM_PROC
// Corresponds to an Intel(R) Pentium(R) processor
// (or a 100% compatible) that supports the
// Pentium(R) processor instructions.
//
// IJL_PENTIUM_PRO_PROC
// Corresponds to an Intel(R) Pentium(R) Pro processor
// (or a 100% compatible) that supports the
// Pentium(R) Pro processor instructions.
//
// IJL_PENTIUM_PROC_MMX_TECH
// Corresponds to an Intel(R) Pentium(R) processor
// with MMX(TM) technology (or a 100% compatible)
// that supports the MMX(TM) instructions.
//
// IJL_PENTIUM_II_PROC
// Corresponds to an Intel(R) Pentium(R) II processor
// (or a 100% compatible) that supports both the
// Pentium(R) Pro processor instructions and the
// MMX(TM) instructions.
//
// IJL_PENTIUM_III_PROC
// Corresponds to an Intel(R) Pentium(R) III processor
//
// IJL_PENTIUM_4_PROC
// Corresponds to an Intel(R) Pentium(R) 4 processor
//
// IJL_NEW_PROCESSOR
// Correponds to new processor
//
// Any additional processor types that support a superset
// of both the Pentium(R) Pro processor instructions and the
// MMX(TM) instructions should be given an enum value greater
// than IJL_PENTIUM_4_PROC.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _PROCESSOR_TYPE
{
IJL_OTHER_PROC = 0,
IJL_PENTIUM_PROC = 1,
IJL_PENTIUM_PRO_PROC = 2,
IJL_PENTIUM_PROC_MMX_TECH = 3,
IJL_PENTIUM_II_PROC = 4,
IJL_PENTIUM_III_PROC = 5,
IJL_PENTIUM_4_PROC = 6,
IJL_NEW_PROCESSOR = 7
} PROCESSOR_TYPE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: RAW_DATA_TYPES_STATE
//
// Purpose: Stores data types: raw dct coefficients or raw sampled data.
// Pointer to structure in JPEG_PROPERTIES is NULL, if any raw
// data isn't request (DIBBytes!=NULL).
//
// Fields:
// short* raw_ptrs[4] - pointers to buffers with raw data; one pointer
// corresponds one JPG component;
// data_type - 0 - raw dct coefficients, 1 - raw sampled data.
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _RAW_DATA_TYPES_STATE
{
int data_type;
unsigned short* raw_ptrs[4];
} RAW_DATA_TYPES_STATE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: ENTROPYSTRUCT
//
// Purpose: Stores the decoder state information necessary to "jump"
// to a particular MCU row in a compressed entropy stream.
//
// Context: Used to persist the decoder state within Decode_Scan when
// decoding using ROIs.
//
// Fields:
// offset Offset (in bytes) into the entropy stream
// from the beginning.
// dcval1 DC val at the beginning of the MCU row
// for component 1.
// dcval2 DC val at the beginning of the MCU row
// for component 2.
// dcval3 DC val at the beginning of the MCU row
// for component 3.
// dcval4 DC val at the beginning of the MCU row
// for component 4.
// bit_buffer_64 64-bit Huffman bit buffer. Stores current
// bit buffer at the start of a MCU row.
// Also used as a 32-bit buffer on 32-bit
// architectures.
// bitbuf_bits_valid Number of valid bits in the above bit buffer.
// unread_marker Have any markers been decoded but not
// processed at the beginning of a MCU row?
// This entry holds the unprocessed marker, or
// 0 if none.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _ENTROPYSTRUCT
{
unsigned int offset;
int dcval1;
int dcval2;
int dcval3;
int dcval4;
IJL_UINT64 bit_buffer_64;
int bitbuf_bits_valid;
unsigned char unread_marker;
} ENTROPYSTRUCT;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: STATE
//
// Purpose: Stores the active state of the IJL.
//
// Context: Used by all low-level routines to store pseudo-global or
// state variables.
//
// Fields:
// bit_buffer_64 64-bit bitbuffer utilized by Huffman
// encoder/decoder algorithms utilizing routines
// designed for MMX(TM) technology.
// bit_buffer_32 32-bit bitbuffer for all other Huffman
// encoder/decoder algorithms.
// bitbuf_bits_valid Number of bits in the above two fields that
// are valid.
//
// cur_entropy_ptr Current position (absolute address) in
// the entropy buffer.
// start_entropy_ptr Starting position (absolute address) of
// the entropy buffer.
// end_entropy_ptr Ending position (absolute address) of
// the entropy buffer.
// entropy_bytes_processed Number of bytes actually processed
// (passed over) in the entropy buffer.
// entropy_buf_maxsize Max size of the entropy buffer.
// entropy_bytes_left Number of bytes left in the entropy buffer.
// Prog_EndOfBlock_Run Progressive block run counter.
//
// DIB_ptr Temporary offset into the input/output DIB.
//
// unread_marker If a marker has been read but not processed,
// stick it in this field.
// processor_type (0, 1, or 2) == current processor does not
// support MMX(TM) instructions.
// (3 or 4) == current processor does
// support MMX(TM) instructions.
// cur_scan_comp On which component of the scan are we working?
// file Process file handle, or
// 0x00000000 if no file is defined.
// JPGBuffer Entropy buffer (~4K).
//
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef struct _STATE
{
/* Bit buffer. */
IJL_UINT64 bit_buffer_64;
void* ctx;
int bitbuf_bits_valid;
/* Entropy. */
unsigned char* cur_entropy_ptr;
unsigned char* start_entropy_ptr;
unsigned char* end_entropy_ptr;
int entropy_bytes_processed;
int entropy_buf_maxsize;
int entropy_bytes_left;
int Prog_EndOfBlock_Run;
/* Input or output DIB. */
unsigned char* DIB_ptr;
/* Control. */
unsigned char unread_marker;
PROCESSOR_TYPE processor_type;
int cur_scan_comp;
IJL_HANDLE file;
unsigned char JPGBuffer [JBUFSIZE];
} STATE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: FAST_MCU_PROCESSING_TYPE
//
// Purpose: Advanced Control Option. Do NOT modify.
// WARNING: Used for internal reference only.
//
// Fields:
//
// IJL_(sampling)_(JPEG color space)_(sampling)_(DIB color space)
// Decode is read left to right w/ upsampling.
// Encode is read right to left w/ subsampling.
//
////////////////////////////////////////////////////////////////////////////
*D*/
typedef enum _FAST_MCU_PROCESSING_TYPE
{
IJL_NO_CC_OR_US = 0,
IJL_111_YCBCR_111_RGB = 1,
IJL_111_YCBCR_111_BGR = 2,
IJL_411_YCBCR_111_RGB = 3,
IJL_411_YCBCR_111_BGR = 4,
IJL_422_YCBCR_111_RGB = 5,
IJL_422_YCBCR_111_BGR = 6,
IJL_111_YCBCR_1111_RGBA_FPX = 7,
IJL_411_YCBCR_1111_RGBA_FPX = 8,
IJL_422_YCBCR_1111_RGBA_FPX = 9,
IJL_1111_YCBCRA_FPX_1111_RGBA_FPX = 10,
IJL_4114_YCBCRA_FPX_1111_RGBA_FPX = 11,
IJL_4224_YCBCRA_FPX_1111_RGBA_FPX = 12,
IJL_111_RGB_1111_RGBA_FPX = 13,
IJL_1111_RGBA_FPX_1111_RGBA_FPX = 14,
IJL_111_OTHER_111_OTHER = 15,
IJL_411_OTHER_111_OTHER = 16,
IJL_422_OTHER_111_OTHER = 17,
IJL_YCBYCR_YCBCR = 18,
IJL_YCBCR_YCBYCR = 19,
IJL_1_G_1_G = 20
} FAST_MCU_PROCESSING_TYPE;
/*D*
////////////////////////////////////////////////////////////////////////////
// Name: JPEG_PROPERTIES
//
// Purpose: Stores low-level and control information. It is used by
// both the encoder and decoder. An advanced external user
// may access this structure to expand the interface
// capability.
//
// See the Developer's Guide for an expanded description
// of this structure and its use.
//
// Context: Used by all interface methods and most IJL routines.
//
// Fields:
//
// iotype IN: Specifies type of data operation
// (read/write/other) to be
// performed by IJL_Read or IJL_Write.
// roi IN: Rectangle-Of-Interest to read from, or
// write to, in pixels.
// dcttype IN: DCT alogrithm to be used.
// fast_processing OUT: Supported fast pre/post-processing path.
// This is set by the IJL.
// interrupt IN: Signals an interrupt has been requested.
//
// DIBBytes IN: Pointer to buffer of uncompressed data.
// DIBWidth IN: Width of uncompressed data.
// DIBHeight IN: Height of uncompressed data.
// DIBPadBytes IN: Padding (in bytes) at end of each
// row in the uncompressed data.
// DIBChannels IN: Number of components in the
// uncompressed data.
// DIBColor IN: Color space of uncompressed data.
// DIBSubsampling IN: Required to be IJL_NONE or IJL_422.
// DIBLineBytes OUT: Number of bytes in an output DIB line
// including padding.
//
// JPGFile IN: Pointer to file based JPEG.
// JPGBytes IN: Pointer to buffer based JPEG.
// JPGSizeBytes IN: Max buffer size. Used with JPGBytes.