FFmpeg
jpeg2000dec.h
Go to the documentation of this file.
1 /*
2  * JPEG 2000 image decoder
3  * Copyright (c) 2007 Kamil Nowosad
4  * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
5  * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_JPEG2000DEC_H
25 #define AVCODEC_JPEG2000DEC_H
26 
27 #include "bytestream.h"
28 #include "jpeg2000.h"
29 #include "jpeg2000dsp.h"
30 
31 
32 #define MAX_POCS 32
33 
34 typedef struct Jpeg2000POCEntry {
35  uint16_t LYEpoc;
36  uint16_t CSpoc;
37  uint16_t CEpoc;
38  uint8_t RSpoc;
39  uint8_t REpoc;
40  uint8_t Ppoc;
42 
43 typedef struct Jpeg2000POC {
45  int nb_poc;
47 } Jpeg2000POC;
48 
49 typedef struct Jpeg2000TilePart {
50  uint8_t tile_index; // Tile index who refers the tile-part
51  const uint8_t *tp_end;
52  GetByteContext header_tpg; // bit stream of header if PPM header is used
53  GetByteContext tpg; // bit stream in tile-part
55 
56 /* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
57  * one per component, so tile_part elements have a size of 3 */
58 typedef struct Jpeg2000Tile {
60  uint8_t properties[4];
65  uint8_t has_ppt; // whether this tile has a ppt marker
66  uint8_t *packed_headers; // contains packed headers. Used only along with PPT marker
67  int packed_headers_size; // size in bytes of the packed headers
68  GetByteContext packed_headers_stream; // byte context corresponding to packed headers
69  uint16_t tp_idx; // Tile-part index
70  int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
71 } Jpeg2000Tile;
72 
73 typedef struct Jpeg2000DecoderContext {
74  AVClass *class;
77 
78  int width, height;
81  uint8_t cbps[4]; // bits per sample in particular components
82  uint8_t sgnd[4]; // if a component is signed
83  uint8_t properties[4];
84 
85  uint8_t has_ppm;
86  uint8_t *packed_headers; // contains packed headers. Used only along with PPM marker
89 
90  int cdx[4], cdy[4];
91  int precision;
94  uint32_t palette[256];
95  int8_t pal8;
96  int cdef[4];
98  unsigned numXtiles, numYtiles;
101 
105  uint8_t roi_shift[4];
106 
108 
110 
113 
114  uint8_t isHT; // HTJ2K?
115  uint8_t Ccap15_b14_15; // HTONLY(= 0) or HTDECLARED(= 1) or MIXED(= 3) ?
116  uint8_t Ccap15_b12; // RGNFREE(= 0) or RGN(= 1)?
117  uint8_t Ccap15_b11; // HOMOGENEOUS(= 0) or HETEROGENEOUS(= 1) ?
118  uint8_t Ccap15_b05; // HTREV(= 0) or HTIRV(= 1) ?
119  uint8_t HT_B; // The parameter B for MAGBp value (see Table 4 in the Rec. ITU-T T.814 | ISO/IEC 15444-15)
120 
121  /*options parameters*/
124 
125 #endif //AVCODEC_JPEG2000DEC_H
Jpeg2000POCEntry::CEpoc
uint16_t CEpoc
Definition: jpeg2000dec.h:37
Jpeg2000DecoderContext::packed_headers_size
int packed_headers_size
Definition: jpeg2000dec.h:87
Jpeg2000DecoderContext::palette
uint32_t palette[256]
Definition: jpeg2000dec.h:94
Jpeg2000POC::is_default
int is_default
Definition: jpeg2000dec.h:46
GetByteContext
Definition: bytestream.h:33
Jpeg2000POCEntry::REpoc
uint8_t REpoc
Definition: jpeg2000dec.h:39
Jpeg2000DecoderContext::width
int width
Definition: jpeg2000dec.h:78
Jpeg2000DecoderContext::tile_width
int tile_width
Definition: jpeg2000dec.h:97
Jpeg2000DecoderContext::curtileno
int curtileno
Definition: jpeg2000dec.h:109
Jpeg2000POCEntry
Definition: jpeg2000dec.h:34
Jpeg2000DecoderContext::numXtiles
unsigned numXtiles
Definition: jpeg2000dec.h:98
Jpeg2000POCEntry::CSpoc
uint16_t CSpoc
Definition: jpeg2000dec.h:36
Jpeg2000Tile
Definition: j2kenc.c:107
Jpeg2000Tile::packed_headers
uint8_t * packed_headers
Definition: jpeg2000dec.h:66
Jpeg2000DecoderContext::cdef
int cdef[4]
Definition: jpeg2000dec.h:96
Jpeg2000DecoderContext::sgnd
uint8_t sgnd[4]
Definition: jpeg2000dec.h:82
Jpeg2000DecoderContext::image_offset_x
int image_offset_x
Definition: jpeg2000dec.h:79
Jpeg2000DecoderContext::maxtilelen
int maxtilelen
Definition: jpeg2000dec.h:99
Jpeg2000DecoderContext::g
GetByteContext g
Definition: jpeg2000dec.h:76
Jpeg2000DecoderContext::precision
int precision
Definition: jpeg2000dec.h:91
Jpeg2000DecoderContext::cdx
int cdx[4]
Definition: jpeg2000dec.h:90
Jpeg2000DecoderContext::poc
Jpeg2000POC poc
Definition: jpeg2000dec.h:104
Jpeg2000DecoderContext::reduction_factor
int reduction_factor
Definition: jpeg2000dec.h:122
Jpeg2000DecoderContext::roi_shift
uint8_t roi_shift[4]
Definition: jpeg2000dec.h:105
Jpeg2000DecoderContext::avctx
AVCodecContext * avctx
Definition: jpeg2000dec.h:75
Jpeg2000DecoderContext::ncomponents
int ncomponents
Definition: jpeg2000dec.h:92
Jpeg2000Tile::comp
Jpeg2000Component * comp
Definition: j2kenc.c:108
Jpeg2000POCEntry::Ppoc
uint8_t Ppoc
Definition: jpeg2000dec.h:40
Jpeg2000DecoderContext::codsty
Jpeg2000CodingStyle codsty[4]
Definition: jpeg2000dec.h:102
Jpeg2000Tile::packed_headers_stream
GetByteContext packed_headers_stream
Definition: jpeg2000dec.h:68
jpeg2000.h
Jpeg2000DSPContext
Definition: jpeg2000dsp.h:29
Jpeg2000DecoderContext::isHT
uint8_t isHT
Definition: jpeg2000dec.h:114
Jpeg2000POC::nb_poc
int nb_poc
Definition: jpeg2000dec.h:45
Jpeg2000DecoderContext::Ccap15_b14_15
uint8_t Ccap15_b14_15
Definition: jpeg2000dec.h:115
Jpeg2000Tile::has_ppt
uint8_t has_ppt
Definition: jpeg2000dec.h:65
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
Jpeg2000DecoderContext::sar
AVRational sar
Definition: jpeg2000dec.h:100
Jpeg2000POC
Definition: jpeg2000dec.h:43
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Jpeg2000DecoderContext::tile
Jpeg2000Tile * tile
Definition: jpeg2000dec.h:111
Jpeg2000DecoderContext::Ccap15_b05
uint8_t Ccap15_b05
Definition: jpeg2000dec.h:118
Jpeg2000DecoderContext::HT_B
uint8_t HT_B
Definition: jpeg2000dec.h:119
Jpeg2000DecoderContext::tile_offset_y
int tile_offset_y
Definition: jpeg2000dec.h:80
Jpeg2000TilePart::tp_end
const uint8_t * tp_end
Definition: jpeg2000dec.h:51
Jpeg2000Component
Definition: jpeg2000.h:233
Jpeg2000Tile::codsty
Jpeg2000CodingStyle codsty[4]
Definition: jpeg2000dec.h:61
Jpeg2000Tile::tp_idx
uint16_t tp_idx
Definition: jpeg2000dec.h:69
Jpeg2000POC::poc
Jpeg2000POCEntry poc[MAX_POCS]
Definition: jpeg2000dec.h:44
Jpeg2000DecoderContext::image_offset_y
int image_offset_y
Definition: jpeg2000dec.h:79
Jpeg2000DecoderContext::height
int height
Definition: jpeg2000dec.h:78
Jpeg2000DecoderContext::tile_height
int tile_height
Definition: jpeg2000dec.h:97
Jpeg2000DecoderContext::qntsty
Jpeg2000QuantStyle qntsty[4]
Definition: jpeg2000dec.h:103
Jpeg2000DecoderContext::Ccap15_b12
uint8_t Ccap15_b12
Definition: jpeg2000dec.h:116
Jpeg2000Tile::coord
int coord[2][2]
Definition: jpeg2000dec.h:70
Jpeg2000Tile::properties
uint8_t properties[4]
Definition: jpeg2000dec.h:60
Jpeg2000TilePart::tile_index
uint8_t tile_index
Definition: jpeg2000dec.h:50
Jpeg2000DecoderContext::tile_offset_x
int tile_offset_x
Definition: jpeg2000dec.h:80
Jpeg2000DecoderContext::bit_index
int bit_index
Definition: jpeg2000dec.h:107
Jpeg2000DecoderContext::properties
uint8_t properties[4]
Definition: jpeg2000dec.h:83
Jpeg2000DecoderContext::cdy
int cdy[4]
Definition: jpeg2000dec.h:90
Jpeg2000TilePart
Definition: jpeg2000dec.h:49
Jpeg2000DecoderContext::packed_headers
uint8_t * packed_headers
Definition: jpeg2000dec.h:86
Jpeg2000Tile::poc
Jpeg2000POC poc
Definition: jpeg2000dec.h:63
Jpeg2000DecoderContext::cbps
uint8_t cbps[4]
Definition: jpeg2000dec.h:81
Jpeg2000TilePart::tpg
GetByteContext tpg
Definition: jpeg2000dec.h:53
AVCodecContext
main external API structure.
Definition: avcodec.h:451
jpeg2000dsp.h
Jpeg2000POCEntry::LYEpoc
uint16_t LYEpoc
Definition: jpeg2000dec.h:35
Jpeg2000DecoderContext::dsp
Jpeg2000DSPContext dsp
Definition: jpeg2000dec.h:112
Jpeg2000DecoderContext::colour_space
int colour_space
Definition: jpeg2000dec.h:93
Jpeg2000DecoderContext::has_ppm
uint8_t has_ppm
Definition: jpeg2000dec.h:85
Jpeg2000DecoderContext::Ccap15_b11
uint8_t Ccap15_b11
Definition: jpeg2000dec.h:117
Jpeg2000DecoderContext::pal8
int8_t pal8
Definition: jpeg2000dec.h:95
Jpeg2000POCEntry::RSpoc
uint8_t RSpoc
Definition: jpeg2000dec.h:38
Jpeg2000Tile::packed_headers_size
int packed_headers_size
Definition: jpeg2000dec.h:67
Jpeg2000Tile::tile_part
Jpeg2000TilePart tile_part[32]
Definition: jpeg2000dec.h:64
Jpeg2000DecoderContext::numYtiles
unsigned numYtiles
Definition: jpeg2000dec.h:98
bytestream.h
Jpeg2000DecoderContext::packed_headers_stream
GetByteContext packed_headers_stream
Definition: jpeg2000dec.h:88
MAX_POCS
#define MAX_POCS
Definition: jpeg2000dec.h:32
Jpeg2000CodingStyle
Definition: jpeg2000.h:145
Jpeg2000QuantStyle
Definition: jpeg2000.h:161
Jpeg2000DecoderContext
Definition: jpeg2000dec.h:73
Jpeg2000Tile::qntsty
Jpeg2000QuantStyle qntsty[4]
Definition: jpeg2000dec.h:62
Jpeg2000TilePart::header_tpg
GetByteContext header_tpg
Definition: jpeg2000dec.h:52