caleb | 4a466aa | 2023-04-14 19:14:41 | [diff] [blame] | 1 | /* |
| 2 | * JPEG 2000 image decoder |
| 3 | * Copyright (c) 2007 Kamil Nowosad |
| 4 | * Copyright (c) 2013 Nicolas Bertrand <[email protected]> |
| 5 | * Copyright (c) 2022 Caleb Etemesi <[email protected]> |
| 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; |
| 41 | } Jpeg2000POCEntry; |
| 42 | |
| 43 | typedef struct Jpeg2000POC { |
| 44 | Jpeg2000POCEntry poc[MAX_POCS]; |
| 45 | int nb_poc; |
| 46 | int is_default; |
| 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 |
| 54 | } Jpeg2000TilePart; |
| 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 { |
| 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; |
| 72 | |
| 73 | typedef struct Jpeg2000DecoderContext { |
| 74 | AVClass *class; |
| 75 | AVCodecContext *avctx; |
| 76 | GetByteContext g; |
| 77 | |
| 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]; |
| 84 | |
| 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; |
| 89 | uint8_t in_tile_headers; |
| 90 | |
| 91 | int cdx[4], cdy[4]; |
| 92 | int precision; |
| 93 | int ncomponents; |
| 94 | int colour_space; |
| 95 | uint32_t palette[256]; |
| 96 | int8_t pal8; |
| 97 | int cdef[4]; |
| 98 | int tile_width, tile_height; |
| 99 | unsigned numXtiles, numYtiles; |
| 100 | int maxtilelen; |
| 101 | AVRational sar; |
| 102 | |
| 103 | Jpeg2000CodingStyle codsty[4]; |
| 104 | Jpeg2000QuantStyle qntsty[4]; |
| 105 | Jpeg2000POC poc; |
| 106 | uint8_t roi_shift[4]; |
| 107 | |
| 108 | int bit_index; |
| 109 | |
| 110 | int curtileno; |
| 111 | |
| 112 | Jpeg2000Tile *tile; |
| 113 | Jpeg2000DSPContext dsp; |
| 114 | |
Osamu Watanabe | fe1b196 | 2024-08-07 03:48:43 | [diff] [blame^] | 115 | uint8_t isHT; // HTJ2K? |
| 116 | uint8_t Ccap15_b14_15; // HTONLY(= 0) or HTDECLARED(= 1) or MIXED(= 3) ? |
| 117 | uint8_t Ccap15_b12; // RGNFREE(= 0) or RGN(= 1)? |
| 118 | uint8_t Ccap15_b11; // HOMOGENEOUS(= 0) or HETEROGENEOUS(= 1) ? |
| 119 | uint8_t Ccap15_b05; // HTREV(= 0) or HTIRV(= 1) ? |
| 120 | uint8_t HT_B; // MAGB value |
| 121 | |
caleb | 4a466aa | 2023-04-14 19:14:41 | [diff] [blame] | 122 | /*options parameters*/ |
| 123 | int reduction_factor; |
| 124 | } Jpeg2000DecoderContext; |
| 125 | |
| 126 | #endif //AVCODEC_JPEG2000DEC_H |