common
pjpeg.h
Go to the documentation of this file.
1
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
2
All rights reserved.
3
This software was developed in the APRIL Robotics Lab under the
4
direction of Edwin Olson, ebolson@umich.edu. This software may be
5
available under alternative licensing terms; contact the address above.
6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions are met:
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
2. Redistributions in binary form must reproduce the above copyright notice,
11
this list of conditions and the following disclaimer in the documentation
12
and/or other materials provided with the distribution.
13
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
The views and conclusions contained in the software and documentation are those
24
of the authors and should not be interpreted as representing official policies,
25
either expressed or implied, of the Regents of The University of Michigan.
26
*/
27
28
#pragma once
29
30
#include "
image_u8.h
"
31
#include "
image_u8x3.h
"
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
37
typedef
struct
pjpeg_component
pjpeg_component_t
;
38
struct
pjpeg_component
39
{
40
// resolution of this component (which is smaller than the
41
// dimensions of the image if the channel has been sub-sampled.)
42
uint32_t
width
,
height
;
43
44
// number of bytes per row. May be larger than width for alignment
45
// reasons.
46
uint32_t
stride
;
47
48
// data[y*stride + x]
49
uint8_t *
data
;
50
52
// These items probably not of great interest to most
53
// applications.
54
uint8_t
id
;
// the identifier associated with this component
55
uint8_t
hv
;
// horiz scale (high 4 bits) / vert scale (low 4 bits)
56
uint8_t
scalex
,
scaley
;
// derived from hv above
57
uint8_t
tq
;
// quantization table index
58
59
// this filled in at the last moment by SOS
60
uint8_t
tda
;
// which huff tables will we use for DC (high 4 bits) and AC (low 4 bits)
61
};
62
63
typedef
struct
pjpeg
pjpeg_t
;
64
struct
pjpeg
65
{
66
// status of the decode is put here. Non-zero means error.
67
int
error
;
68
69
uint32_t
width
,
height
;
// pixel dimensions
70
71
int
ncomponents
;
72
pjpeg_component_t
*
components
;
73
};
74
75
enum
PJPEG_FLAGS
{
76
PJPEG_STRICT
= 1,
// Don't try to recover from errors.
77
PJPEG_MJPEG
= 2,
// Support JPGs with missing DHT segments.
78
};
79
80
enum
PJPEG_ERROR
{
81
PJPEG_OKAY
= 0,
82
PJPEG_ERR_FILE
,
// something wrong reading file
83
PJPEG_ERR_DQT
,
// something wrong with DQT marker
84
PJPEG_ERR_SOF
,
// something wrong with SOF marker
85
PJPEG_ERR_DHT
,
// something wrong with DHT marker
86
PJPEG_ERR_SOS
,
// something wrong with SOS marker
87
PJPEG_ERR_MISSING_DHT
,
// missing a necessary huffman table
88
PJPEG_ERR_DRI
,
// something wrong with DRI marker
89
PJPEG_ERR_RESET
,
// didn't get a reset marker where we expected. Corruption?
90
PJPEG_ERR_EOF
,
// ran out of bytes while decoding
91
PJEPG_ERR_UNSUPPORTED
,
// an unsupported format
92
};
93
94
pjpeg_t
*
pjpeg_create_from_file
(
const
char
*path, uint32_t flags,
int
*error);
95
pjpeg_t
*
pjpeg_create_from_buffer
(uint8_t *buf,
int
buflen, uint32_t flags,
int
*error);
96
void
pjpeg_destroy
(
pjpeg_t
*pj);
97
98
image_u8_t
*
pjpeg_to_u8_baseline
(
pjpeg_t
*pj);
99
image_u8x3_t
*
pjpeg_to_u8x3_baseline
(
pjpeg_t
*pj);
100
101
#ifdef __cplusplus
102
}
103
#endif
pjpeg_component::stride
uint32_t stride
Definition:
pjpeg.h:46
pjpeg_to_u8x3_baseline
image_u8x3_t * pjpeg_to_u8x3_baseline(pjpeg_t *pj)
Definition:
pjpeg.c:738
image_u8x3.h
pjpeg_component::id
uint8_t id
Definition:
pjpeg.h:54
pjpeg::width
uint32_t width
Definition:
pjpeg.h:69
pjpeg_component::scaley
uint8_t scaley
Definition:
pjpeg.h:56
pjpeg_destroy
void pjpeg_destroy(pjpeg_t *pj)
Definition:
pjpeg.c:689
pjpeg_create_from_file
pjpeg_t * pjpeg_create_from_file(const char *path, uint32_t flags, int *error)
Definition:
pjpeg.c:825
pjpeg_component::width
uint32_t width
Definition:
pjpeg.h:42
PJPEG_STRICT
Definition:
pjpeg.h:76
PJPEG_ERR_EOF
Definition:
pjpeg.h:90
PJPEG_ERR_DQT
Definition:
pjpeg.h:83
PJPEG_ERR_MISSING_DHT
Definition:
pjpeg.h:87
pjpeg::components
pjpeg_component_t * components
Definition:
pjpeg.h:72
PJPEG_ERROR
PJPEG_ERROR
Definition:
pjpeg.h:80
PJPEG_ERR_SOS
Definition:
pjpeg.h:86
pjpeg
Definition:
pjpeg.h:64
pjpeg::error
int error
Definition:
pjpeg.h:67
pjpeg_create_from_buffer
pjpeg_t * pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error)
Definition:
pjpeg.c:857
pjpeg_component::height
uint32_t height
Definition:
pjpeg.h:42
PJPEG_ERR_FILE
Definition:
pjpeg.h:82
pjpeg_component
Definition:
pjpeg.h:38
image_u8
Definition:
image_types.h:37
PJPEG_ERR_RESET
Definition:
pjpeg.h:89
PJEPG_ERR_UNSUPPORTED
Definition:
pjpeg.h:91
PJPEG_MJPEG
Definition:
pjpeg.h:77
image_u8x3
Definition:
image_types.h:47
pjpeg_component::hv
uint8_t hv
Definition:
pjpeg.h:55
PJPEG_ERR_SOF
Definition:
pjpeg.h:84
pjpeg_component::data
uint8_t * data
Definition:
pjpeg.h:49
PJPEG_OKAY
Definition:
pjpeg.h:81
pjpeg_component::tda
uint8_t tda
Definition:
pjpeg.h:60
pjpeg::ncomponents
int ncomponents
Definition:
pjpeg.h:71
PJPEG_FLAGS
PJPEG_FLAGS
Definition:
pjpeg.h:75
pjpeg_component::scalex
uint8_t scalex
Definition:
pjpeg.h:56
PJPEG_ERR_DHT
Definition:
pjpeg.h:85
pjpeg_component::tq
uint8_t tq
Definition:
pjpeg.h:57
pjpeg_to_u8_baseline
image_u8_t * pjpeg_to_u8_baseline(pjpeg_t *pj)
Definition:
pjpeg.c:703
image_u8.h
PJPEG_ERR_DRI
Definition:
pjpeg.h:88
apriltag
Author(s): Edwin Olson
, Max Krogius
autogenerated on Mon Jun 26 2023 02:26:12