NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_image_jpeg.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_IMAGE_JPEG__
12#define __BE_IMAGE_JPEG__
13
14#include <cstdio>
15
16#include <be_image_image.h>
17
18/* jpeglib.h forward-declares */
19extern "C" {
20/* libjpeg 9b no longer needs "boolean" defined */
21#if JPEG_LIB_VERSION <= 90
22 #if JPEG_LIB_VERSION == 90
23 #if JPEG_LIB_VERSION_MINOR < 2
24 #ifdef _WIN32
25 typedef unsigned char boolean;
26 #else
27 typedef int boolean;
28 #endif /* _WIN32 */
29 #endif /* JPEG_LIB_VERSION_MINOR < 2 */
30 #else /* JPEG_LIB_VERSION == 90 */
31 #ifndef HAVE_BOOLEAN
32 #ifdef _WIN32
33 typedef unsigned char boolean;
34 #else
35 typedef int boolean;
36 #endif /* _WIN32 */
37 #endif /* HAVE_BOOLEAN */
38 #endif /* JPEG_LIB_VERSION == 90 */
39#endif /* JPEG_LIB_VERSION */
40
41 struct jpeg_decompress_struct;
42 struct jpeg_common_struct;
43 typedef struct jpeg_common_struct *j_common_ptr;
44 typedef struct jpeg_decompress_struct *j_decompress_ptr;
45}
46
47namespace BiometricEvaluation
48{
49 namespace Image
50 {
55 class JPEG : public Image
56 {
57 public:
59 const uint8_t *data,
60 const uint64_t size,
61 const std::string &identifier = "",
62 const statusCallback_t &statusCallback =
64
66 const Memory::uint8Array &data,
67 const std::string &identifier = "",
68 const statusCallback_t &statusCallback =
70
71 ~JPEG() = default;
72
75 uint8_t depth) const;
76
79 const;
80
93 static bool
95 const uint8_t *data,
96 uint64_t size);
97
98 static int
100 const unsigned short marker,
101 unsigned char **cbufptr,
102 unsigned char *ebufptr);
103
104 protected:
105
106 private:
116 static void
117 callStatusCallback(
118 const j_common_ptr cinfo,
119 const Framework::Status::Type statusType);
120
131 static void
132 error_exit(
133 j_common_ptr cinfo);
134
143 static void
144 output_message(
145 j_common_ptr cinfo);
146
156 static void
157 emit_message(
158 j_common_ptr cinfo,
159 int msg_level);
160
161 /*
162 * libjpeg 8.0 has code for handling a JPEG image
163 * in a buffer location, so don't compile ours.
164 */
165#if JPEG_LIB_VERSION < 80
166 /*
167 * JPEG memory source manager based on
168 * http://stackoverflow.com/questions/5280756/
169 * libjpeg-ver-6b-jpeg-stdio-src-vs-jpeg-mem-src
170 */
171 static void
172 jpeg_mem_src(
173 j_decompress_ptr cinfo,
174 uint8_t *buffer,
175 long size);
176
177 static void
178 init_source_mem(
179 j_decompress_ptr cinfo);
180
181 static boolean
182 fill_input_buffer_mem(
183 j_decompress_ptr cinfo);
184
185 static void
186 skip_input_data_mem(
187 j_decompress_ptr cinfo,
188 long num_bytes);
189
190 static void
191 term_source_mem(
192 j_decompress_ptr cinfo);
193#endif /* JPEG_LIB_VERSION */
194 };
195 }
196}
197
198#endif /* __BE_IMAGE_JPEG__ */
199
struct jpeg_decompress_struct * j_decompress_ptr
Definition: be_image_jpeg.h:44
struct jpeg_common_struct * j_common_ptr
Definition: be_image_jpeg.h:43
int boolean
Definition: be_image_jpeg.h:35
Represent attributes common to all images.
static void defaultStatusCallback(const Framework::Status &status)
Default handling of statuses sent from image processing libraries.
std::function< void(const Framework::Status)> statusCallback_t
JPEG(const uint8_t *data, const uint64_t size, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
Memory::uint8Array getRawData() const
Accessor for the raw image data.
static bool isJPEG(const uint8_t *data, uint64_t size)
Whether or not data is a Lossy JPEG image.
JPEG(const Memory::uint8Array &data, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
Memory::uint8Array getRawGrayscaleData(uint8_t depth) const
Accessor for decompressed data in grayscale.
static int getc_skip_marker_segment(const unsigned short marker, unsigned char **cbufptr, unsigned char *ebufptr)
This software was developed at the National Institute of Standards and Technology (NIST) by employees...