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 
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 
73 };
74 
76  PJPEG_STRICT = 1, // Don't try to recover from errors.
77  PJPEG_MJPEG = 2, // Support JPGs with missing DHT segments.
78 };
79 
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 
100 
101 #ifdef __cplusplus
102 }
103 #endif
uint32_t stride
Definition: pjpeg.h:46
image_u8x3_t * pjpeg_to_u8x3_baseline(pjpeg_t *pj)
Definition: pjpeg.c:738
uint8_t id
Definition: pjpeg.h:54
uint32_t width
Definition: pjpeg.h:69
uint8_t scaley
Definition: pjpeg.h:56
void pjpeg_destroy(pjpeg_t *pj)
Definition: pjpeg.c:689
pjpeg_t * pjpeg_create_from_file(const char *path, uint32_t flags, int *error)
Definition: pjpeg.c:825
uint32_t width
Definition: pjpeg.h:42
pjpeg_component_t * components
Definition: pjpeg.h:72
PJPEG_ERROR
Definition: pjpeg.h:80
Definition: pjpeg.h:64
int error
Definition: pjpeg.h:67
pjpeg_t * pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error)
Definition: pjpeg.c:857
uint32_t height
Definition: pjpeg.h:42
uint8_t hv
Definition: pjpeg.h:55
uint8_t * data
Definition: pjpeg.h:49
uint8_t tda
Definition: pjpeg.h:60
int ncomponents
Definition: pjpeg.h:71
PJPEG_FLAGS
Definition: pjpeg.h:75
uint8_t scalex
Definition: pjpeg.h:56
uint8_t tq
Definition: pjpeg.h:57
image_u8_t * pjpeg_to_u8_baseline(pjpeg_t *pj)
Definition: pjpeg.c:703


apriltag
Author(s): Edwin Olson , Max Krogius
autogenerated on Mon Jun 26 2023 02:26:12