avformat/mpeg: demux ivtv captions
[ffmpeg.git] / libavcodec / jpeg2000dec.h
blobfce3823164aed86d551a0450e114d91fbbb54c79
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>
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"
28 #include "jpeg2000.h"
29 #include "jpeg2000dsp.h"
32 #define MAX_POCS 32
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;
41 } Jpeg2000POCEntry;
43 typedef struct Jpeg2000POC {
44 Jpeg2000POCEntry poc[MAX_POCS];
45 int nb_poc;
46 int is_default;
47 } Jpeg2000POC;
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
54 } Jpeg2000TilePart;
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];
63 Jpeg2000POC poc;
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}}
71 } Jpeg2000Tile;
73 typedef struct Jpeg2000DecoderContext {
74 AVClass *class;
75 AVCodecContext *avctx;
76 GetByteContext g;
78 int width, height;
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];
85 uint8_t has_ppm;
86 uint8_t *packed_headers; // contains packed headers. Used only along with PPM marker
87 int packed_headers_size;
88 GetByteContext packed_headers_stream;
90 int cdx[4], cdy[4];
91 int precision;
92 int ncomponents;
93 int colour_space;
94 uint32_t palette[256];
95 int8_t pal8;
96 int cdef[4];
97 int tile_width, tile_height;
98 unsigned numXtiles, numYtiles;
99 int maxtilelen;
100 AVRational sar;
102 Jpeg2000CodingStyle codsty[4];
103 Jpeg2000QuantStyle qntsty[4];
104 Jpeg2000POC poc;
105 uint8_t roi_shift[4];
107 int bit_index;
109 int curtileno;
111 Jpeg2000Tile *tile;
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