UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
jpeg_reader.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2018 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef UTILS_JPEG_READER_H_
39#define UTILS_JPEG_READER_H_
40
41#ifndef __cplusplus
42#include <stdbool.h>
43#include <stddef.h>
44#include <stdint.h>
45#else
46#include <cstddef>
47#include <cstdint>
48#endif
49
57
58enum {
60};
61
62struct jpeg_info {
68 int restart_interval; // content of DRI marker
72 uint8_t *data; // entropy-coded segment start
73 char com[65536 - 2 + 1]; // comment (COM marker)
74 uint8_t huff_lum_dc[16 + 256]; // if first byte is 255, table was not defined
75 uint8_t huff_lum_ac[16 + 256];
76 uint8_t huff_chm_dc[16 + 256];
77 uint8_t huff_chm_ac[16 + 256];
78};
79
82 int type; // RTP JPEG type
83 int q; // either 0..100 or 255 (dynamic QT - included in quantization_tables)
84 int restart_interval; // content of DRI marker
85 uint8_t *quantization_tables[2]; // assuming 8-bit tables
86 uint8_t *data; // entropy-coded data start
87};
88
89#ifdef __cplusplus
90extern "C" {
91#endif // defined __cplusplus
92
93int jpeg_read_info(uint8_t *image, int len, struct jpeg_info *info);
94bool jpeg_get_rtp_hdr_data(uint8_t *jpeg_data, int len, struct jpeg_rtp_data *hdr_data);
95
96// for writer
98 const uint8_t *bits; // 16 items
99 const uint8_t *bufval;
100};
106};
107extern const struct huffman_table default_huffman_tables[4];
108
109#ifdef __cplusplus
110}
111#endif // defined __cplusplus
112
113#endif// UTILS_JPEG_READER_H_
114
int void size_t * len
jpeg_color_spec
Definition jpeg_reader.h:50
@ JPEG_COLOR_SPEC_YCBCR
Definition jpeg_reader.h:52
@ JPEG_COLOR_SPEC_CMYK
Definition jpeg_reader.h:54
@ JPEG_COLOR_SPEC_RGB
Definition jpeg_reader.h:53
@ JPEG_COLOR_SPEC_NONE
Definition jpeg_reader.h:51
@ JPEG_COLOR_SPEC_YCCK
Definition jpeg_reader.h:55
const struct huffman_table default_huffman_tables[4]
huff_type
@ CHR_DC
@ CHR_AC
@ LUM_DC
order of tables in default_huffman_tables
@ LUM_AC
int jpeg_read_info(uint8_t *image, int len, struct jpeg_info *info)
@ JPEG_MAX_COMPONENT_COUNT
Definition jpeg_reader.h:59
bool jpeg_get_rtp_hdr_data(uint8_t *jpeg_data, int len, struct jpeg_rtp_data *hdr_data)
const uint8_t * bits
Definition jpeg_reader.h:98
const uint8_t * bufval
Definition jpeg_reader.h:99
int comp_table_quantization_map[JPEG_MAX_COMPONENT_COUNT]
mapping component -> index to table_quantization
Definition jpeg_reader.h:71
int sampling_factor_h[JPEG_MAX_COMPONENT_COUNT]
Definition jpeg_reader.h:67
enum jpeg_color_spec color_spec
Definition jpeg_reader.h:64
uint8_t huff_chm_dc[16+256]
Definition jpeg_reader.h:76
bool interleaved
Definition jpeg_reader.h:65
uint8_t * quantization_tables[JPEG_MAX_COMPONENT_COUNT]
Definition jpeg_reader.h:69
int restart_interval
Definition jpeg_reader.h:68
int sampling_factor_v[JPEG_MAX_COMPONENT_COUNT]
Definition jpeg_reader.h:66
uint8_t huff_chm_ac[16+256]
Definition jpeg_reader.h:77
uint8_t huff_lum_dc[16+256]
Definition jpeg_reader.h:74
uint8_t huff_lum_ac[16+256]
Definition jpeg_reader.h:75
int comp_count
Definition jpeg_reader.h:63
uint8_t * data
Definition jpeg_reader.h:72
char com[65536 - 2+1]
Definition jpeg_reader.h:73
uint8_t * data
Definition jpeg_reader.h:86
uint8_t * quantization_tables[2]
Definition jpeg_reader.h:85