WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
pjpeg.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
2All rights reserved.
3This software was developed in the APRIL Robotics Lab under the
4direction of Edwin Olson, ebolson@umich.edu. This software may be
5available under alternative licensing terms; contact the address above.
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
81. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
102. 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.
13THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20ON 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
22SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23The views and conclusions contained in the software and documentation are those
24of the authors and should not be interpreted as representing official policies,
25either 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
34extern "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
51 ////////////////////////////////////////////////////////////////
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
63typedef struct pjpeg pjpeg_t;
64struct 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
94pjpeg_t *pjpeg_create_from_file(const char *path, uint32_t flags, int *error);
95pjpeg_t *pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error);
97
100
101#ifdef __cplusplus
102}
103#endif
pjpeg_t * pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error)
void pjpeg_destroy(pjpeg_t *pj)
image_u8_t * pjpeg_to_u8_baseline(pjpeg_t *pj)
PJPEG_FLAGS
Definition pjpeg.h:75
@ PJPEG_STRICT
Definition pjpeg.h:76
@ PJPEG_MJPEG
Definition pjpeg.h:77
PJPEG_ERROR
Definition pjpeg.h:80
@ PJPEG_ERR_FILE
Definition pjpeg.h:82
@ PJPEG_ERR_DRI
Definition pjpeg.h:88
@ PJPEG_ERR_SOS
Definition pjpeg.h:86
@ PJPEG_ERR_RESET
Definition pjpeg.h:89
@ PJPEG_ERR_MISSING_DHT
Definition pjpeg.h:87
@ PJPEG_ERR_SOF
Definition pjpeg.h:84
@ PJPEG_ERR_DHT
Definition pjpeg.h:85
@ PJPEG_ERR_EOF
Definition pjpeg.h:90
@ PJEPG_ERR_UNSUPPORTED
Definition pjpeg.h:91
@ PJPEG_OKAY
Definition pjpeg.h:81
@ PJPEG_ERR_DQT
Definition pjpeg.h:83
image_u8x3_t * pjpeg_to_u8x3_baseline(pjpeg_t *pj)
pjpeg_t * pjpeg_create_from_file(const char *path, uint32_t flags, int *error)
Definition image_types.h:38
Definition image_types.h:48
Definition pjpeg.h:39
uint32_t width
Definition pjpeg.h:42
uint8_t tda
Definition pjpeg.h:60
uint32_t height
Definition pjpeg.h:42
uint8_t scaley
Definition pjpeg.h:56
uint8_t tq
Definition pjpeg.h:57
uint8_t hv
Definition pjpeg.h:55
uint8_t * data
Definition pjpeg.h:49
uint8_t scalex
Definition pjpeg.h:56
uint8_t id
Definition pjpeg.h:54
uint32_t stride
Definition pjpeg.h:46
Definition pjpeg.h:65
int ncomponents
Definition pjpeg.h:71
int error
Definition pjpeg.h:67
uint32_t height
Definition pjpeg.h:69
uint32_t width
Definition pjpeg.h:69
pjpeg_component_t * components
Definition pjpeg.h:72