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>
7 * This file is part of FFmpeg.
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.
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.
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
24 #ifndef AVCODEC_JPEG2000DEC_H
25 #define AVCODEC_JPEG2000DEC_H
27 #include "bytestream.h"
29 #include "jpeg2000dsp.h"
34 typedef struct Jpeg2000POCEntry
{
43 typedef struct Jpeg2000POC
{
44 Jpeg2000POCEntry poc
[MAX_POCS
];
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
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
{
59 Jpeg2000Component
*comp
;
60 uint8_t properties
[4];
61 Jpeg2000CodingStyle codsty
[4];
62 Jpeg2000QuantStyle qntsty
[4];
64 Jpeg2000TilePart tile_part
[32];
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}}
73 typedef struct Jpeg2000DecoderContext
{
75 AVCodecContext
*avctx
;
79 int image_offset_x
, image_offset_y
;
80 int tile_offset_x
, tile_offset_y
;
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];
86 uint8_t *packed_headers
; // contains packed headers. Used only along with PPM marker
87 int packed_headers_size
;
88 GetByteContext packed_headers_stream
;
94 uint32_t palette
[256];
97 int tile_width
, tile_height
;
98 unsigned numXtiles
, numYtiles
;
102 Jpeg2000CodingStyle codsty
[4];
103 Jpeg2000QuantStyle qntsty
[4];
105 uint8_t roi_shift
[4];
112 Jpeg2000DSPContext dsp
;
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)
121 /*options parameters*/
122 int reduction_factor
;
123 } Jpeg2000DecoderContext
;
125 #endif //AVCODEC_JPEG2000DEC_H