Imported Upstream version 3.0.1
[platform/upstream/libjpeg-turbo.git] / jlossls.h
1 /*
2  * jlossls.h
3  *
4  * This file was part of the Independent JPEG Group's software:
5  * Copyright (C) 1998, Thomas G. Lane.
6  * Lossless JPEG Modifications:
7  * Copyright (C) 1999, Ken Murchison.
8  * libjpeg-turbo Modifications:
9  * Copyright (C) 2022, D. R. Commander.
10  * For conditions of distribution and use, see the accompanying README.ijg
11  * file.
12  *
13  * This include file contains common declarations for the lossless JPEG
14  * codec modules.
15  */
16
17 #ifndef JLOSSLS_H
18 #define JLOSSLS_H
19
20 #if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
21
22 #define JPEG_INTERNALS
23 #include "jpeglib.h"
24 #include "jsamplecomp.h"
25
26
27 #define ALLOC_DARRAY(pool_id, diffsperrow, numrows) \
28   (JDIFFARRAY)(*cinfo->mem->alloc_sarray) \
29     ((j_common_ptr)cinfo, pool_id, \
30      (diffsperrow) * sizeof(JDIFF) / sizeof(_JSAMPLE), numrows)
31
32
33 /*
34  * Table H.1: Predictors for lossless coding.
35  */
36
37 #define PREDICTOR1  Ra
38 #define PREDICTOR2  Rb
39 #define PREDICTOR3  Rc
40 #define PREDICTOR4  (int)((JLONG)Ra + (JLONG)Rb - (JLONG)Rc)
41 #define PREDICTOR5  (int)((JLONG)Ra + RIGHT_SHIFT((JLONG)Rb - (JLONG)Rc, 1))
42 #define PREDICTOR6  (int)((JLONG)Rb + RIGHT_SHIFT((JLONG)Ra - (JLONG)Rc, 1))
43 #define PREDICTOR7  (int)RIGHT_SHIFT((JLONG)Ra + (JLONG)Rb, 1)
44
45 #endif
46
47
48 #ifdef C_LOSSLESS_SUPPORTED
49
50 typedef void (*predict_difference_method_ptr) (j_compress_ptr cinfo, int ci,
51                                                _JSAMPROW input_buf,
52                                                _JSAMPROW prev_row,
53                                                JDIFFROW diff_buf,
54                                                JDIMENSION width);
55
56 /* Lossless compressor */
57 typedef struct {
58   struct jpeg_forward_dct pub;  /* public fields */
59
60   /* It is useful to allow each component to have a separate diff method. */
61   predict_difference_method_ptr predict_difference[MAX_COMPONENTS];
62
63   /* MCU rows left in the restart interval for each component */
64   unsigned int restart_rows_to_go[MAX_COMPONENTS];
65
66   /* Sample scaling */
67   void (*scaler_scale) (j_compress_ptr cinfo, _JSAMPROW input_buf,
68                         _JSAMPROW output_buf, JDIMENSION width);
69 } jpeg_lossless_compressor;
70
71 typedef jpeg_lossless_compressor *lossless_comp_ptr;
72
73 #endif /* C_LOSSLESS_SUPPORTED */
74
75
76 #ifdef D_LOSSLESS_SUPPORTED
77
78 typedef void (*predict_undifference_method_ptr) (j_decompress_ptr cinfo,
79                                                  int comp_index,
80                                                  JDIFFROW diff_buf,
81                                                  JDIFFROW prev_row,
82                                                  JDIFFROW undiff_buf,
83                                                  JDIMENSION width);
84
85 /* Lossless decompressor */
86 typedef struct {
87   struct jpeg_inverse_dct pub;  /* public fields */
88
89   /* It is useful to allow each component to have a separate undiff method. */
90   predict_undifference_method_ptr predict_undifference[MAX_COMPONENTS];
91
92   /* Sample scaling */
93   void (*scaler_scale) (j_decompress_ptr cinfo, JDIFFROW diff_buf,
94                         _JSAMPROW output_buf, JDIMENSION width);
95 } jpeg_lossless_decompressor;
96
97 typedef jpeg_lossless_decompressor *lossless_decomp_ptr;
98
99 #endif /* D_LOSSLESS_SUPPORTED */
100
101 #endif /* JLOSSLS_H */