1 /* GStreamer JPEG 2000 Parser 2 * Copyright (C) <2016-2017> Grok Image Compression Inc. 3 * @author Aaron Boxer <boxerab@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_JPEG2000_PARSE_H__ 22 #define __GST_JPEG2000_PARSE_H__ 23 24 #include <gst/gst.h> 25 #include <gst/base/gstadapter.h> 26 #include <gst/base/gstbaseparse.h> 27 #include <gst/codecparsers/gstjpeg2000sampling.h> 28 29 G_BEGIN_DECLS 30 #define GST_TYPE_JPEG2000_PARSE \ 31 (gst_jpeg2000_parse_get_type()) 32 #define GST_JPEG2000_PARSE(obj) \ 33 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JPEG2000_PARSE,GstJPEG2000Parse)) 34 #define GST_JPEG2000_PARSE_CLASS(klass) \ 35 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JPEG2000_PARSE,GstJPEG2000ParseClass)) 36 #define GST_IS_JPEG2000_PARSE(obj) \ 37 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JPEG2000_PARSE)) 38 #define GST_IS_JPEG2000_PARSE_CLASS(klass) \ 39 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JPEG2000_PARSE)) 40 GType gst_jpeg2000_parse_get_type (void); 41 42 typedef struct _GstJPEG2000Parse GstJPEG2000Parse; 43 typedef struct _GstJPEG2000ParseClass GstJPEG2000ParseClass; 44 45 46 /** 47 * JPEG 2000 Profiles (stored in rsiz/capabilities field in code stream header) 48 * See Table A.10 from 15444-1 (updated in various AMDs) 49 * 50 * For broadcast profiles, the GST_JPEG2000_PARSE_PROFILE_BC_XXXX profile value must be combined with the target 51 * main level (3-0 LSBs, with value between 0 and 11). 52 * Example: 53 * capabilities GST_JPEG2000_PARSE_PROFILE_BC_MULTI | 0x0005 (in this case, main level equals 5) 54 * 55 * For IMF profiles, the GST_JPEG2000_PARSE_PROFILE_IMF_XXXX profile value must be combined with the target main level 56 * (3-0 LSBs, with value between 0 and 11), and target sub level (7-4 LSBs, with value between 0 and 9). 57 * Example: 58 * capabilities GST_JPEG2000_PARSE_PROFILE_IMF_2K | 0x0040 | 0x0005 (in this case, main level equals 5 and sub level equals 4) 59 * 60 * 61 * Broadcast main level (15444-1 AMD4,AMD8) 62 * 63 * Note: Mbit/s == 10^6 bits/s; Msamples/s == 10^6 samples/s 64 * 65 * Level 0: no max rate 66 * Level 1: 200 Mbits/s, 65 Msamples/s 67 * Level 2: 200 Mbits/s, 130 Msamples/s 68 * Level 3: 200 Mbits/s, 195 Msamples/s 69 * Level 4: 400 Mbits/s, 260 Msamples/s 70 * Level 5: 800Mbits/s, 520 Msamples/s 71 * Level >= 6: 2^(Level-6) * 1600 Mbits/s, 2^(Level-6) * 1200 Msamples/s 72 * 73 * Broadcast tiling 74 * 75 * Either single-tile or multi-tile. Multi-tile only permits 76 * 1 or 4 tiles per frame, where multiple tiles have identical 77 * sizes, and are configured in either 2x2 or 1x4 layout. 78 * 79 * */ 80 81 #define GST_JPEG2000_PARSE_PROFILE_NONE 0x0000 /** no profile - defined in 15444-1 */ 82 #define GST_JPEG2000_PARSE_PROFILE_0 0x0001 /** Profile 0 - defined in 15444-1,Table A.45 */ 83 #define GST_JPEG2000_PARSE_PROFILE_1 0x0002 /** Profile 1 - defined in 15444-1,Table A.45 */ 84 #define GST_JPEG2000_PARSE_PROFILE_CINEMA_2K 0x0003 /** 2K Cinema profile - defined in 15444-1 AMD1 */ 85 #define GST_JPEG2000_PARSE_PROFILE_CINEMA_4K 0x0004 /** 4K Cinema profile - defined in 15444-1 AMD1 */ 86 #define GST_JPEG2000_PARSE_PROFILE_CINEMA_S2K 0x0005 /** Scalable 2K Cinema profile - defined in 15444-1 AMD2 */ 87 #define GST_JPEG2000_PARSE_PROFILE_CINEMA_S4K 0x0006 /** Scalable 4K Cinema profile - defined in 15444-1 AMD2 */ 88 #define GST_JPEG2000_PARSE_PROFILE_CINEMA_LTS 0x0007/** Long Term Storage Cinema profile - defined in 15444-1 AMD2 */ 89 #define GST_JPEG2000_PARSE_PROFILE_BC_SINGLE 0x0100 /** Single Tile Broadcast profile - defined in 15444-1 AMD3 */ 90 #define GST_JPEG2000_PARSE_PROFILE_BC_MULTI 0x0200 /** Multi Tile Broadcast profile - defined in 15444-1 AMD3 */ 91 #define GST_JPEG2000_PARSE_PROFILE_BC_MULTI_R 0x0300 /** Multi Tile Reversible Broadcast profile - defined in 15444-1 AMD3 */ 92 #define GST_JPEG2000_PARSE_PROFILE_BC_MASK 0x0F0F /** Mask for broadcast profile, including main level */ 93 #define GST_JPEG2000_PARSE_PROFILE_IMF_2K 0x0400 /** 2K Single Tile Lossy IMF profile - defined in 15444-1 AMD 8 */ 94 #define GST_JPEG2000_PARSE_PROFILE_IMF_4K 0x0401 /** 4K Single Tile Lossy IMF profile - defined in 15444-1 AMD 8 */ 95 #define GST_JPEG2000_PARSE_PROFILE_IMF_8K 0x0402 /** 8K Single Tile Lossy IMF profile - defined in 15444-1 AMD 8 */ 96 #define GST_JPEG2000_PARSE_PROFILE_IMF_2K_R 0x0403 /** 2K Single/Multi Tile Reversible IMF profile - defined in 15444-1 AMD 8 */ 97 #define GST_JPEG2000_PARSE_PROFILE_IMF_4K_R 0x0800 /** 4K Single/Multi Tile Reversible IMF profile - defined in 15444-1 AMD 8 */ 98 #define GST_JPEG2000_PARSE_PROFILE_IMF_8K_R 0x0801 /** 8K Single/Multi Tile Reversible IMF profile - defined in 15444-1 AMD 8 */ 99 #define GST_JPEG2000_PARSE_PROFILE_MASK 0xBFFF /** Mask for profile bits */ 100 #define GST_JPEG2000_PARSE_PROFILE_PART2 0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */ 101 102 #define GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS 4 103 104 typedef enum 105 { 106 GST_JPEG2000_PARSE_NO_CODEC, 107 GST_JPEG2000_PARSE_JPC, /* jpeg 2000 code stream */ 108 GST_JPEG2000_PARSE_J2C, /* jpeg 2000 contiguous code stream box plus code stream */ 109 GST_JPEG2000_PARSE_JP2, /* jpeg 2000 part I file format */ 110 111 } GstJPEG2000ParseFormats; 112 113 114 struct _GstJPEG2000Parse 115 { 116 GstBaseParse baseparse; 117 118 119 guint width; 120 guint height; 121 122 GstJPEG2000Sampling sampling; 123 GstJPEG2000Colorspace colorspace; 124 GstJPEG2000ParseFormats src_codec_format; 125 GstJPEG2000ParseFormats sink_codec_format; 126 gboolean parsed_j2c_box; 127 guint frame_size; 128 }; 129 130 struct _GstJPEG2000ParseClass 131 { 132 GstBaseParseClass parent_class; 133 134 135 }; 136 137 138 G_END_DECLS 139 #endif 140