2 * Copyright (C) 2010 Oblong Industries, Inc.
3 * Copyright (C) 2010 Collabora Multimedia
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.
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.
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., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __JP2K_CODESTREAM_H__
22 #define __JP2K_CODESTREAM_H__
25 #include <gst/base/gstbytereader.h>
26 #include <gst/base/gstbitreader.h>
27 #include <gst/base/gstbytewriter.h>
29 #include "gstjp2kdecimator.h"
31 /* Used to represent codestream packets */
42 /* Used to represent unparsed markers for passthrough */
51 guint8 s; /* sample precision */
52 guint8 xr, yr; /* resolution */
58 guint16 caps; /* capabilities */
59 guint32 x, y; /* reference grid size */
60 guint32 xo, yo; /* origin */
61 ComponentSize *components;
63 guint32 xt, yt; /* tile sizes */
64 guint32 xto, yto; /* tile origin */
69 * R - resolution/decomposition level
71 * P - position/precinct
75 PROGRESSION_ORDER_LRCP = 0,
76 PROGRESSION_ORDER_RLCP,
77 PROGRESSION_ORDER_RPCL,
78 PROGRESSION_ORDER_PCRL,
79 PROGRESSION_ORDER_CPRL,
89 ProgressionOrder progression_order;
91 guint8 multi_component_transform;
93 guint8 n_decompositions;
94 guint8 xcb, ycb; /* code block dimensions */
95 guint8 code_block_style;
96 guint8 transformation;
97 guint8 *PPx, *PPy; /* precinct sizes (default:15,
98 * otherwise n_decompositions+1 elements) */
105 guint32 tile_part_size;
106 guint8 tile_part_index, n_tile_parts;
113 GArray *packet_lengths; /* array of guint32 */
114 } PacketLengthTilePart;
119 CodingStyleDefault *cod;
122 GList *qcc; /* list of Buffer */
124 GList *plt; /* list of PacketLengthTilePart */
126 GList *com; /* list of Buffer */
128 GList *packets; /* list of Packet, codestream */
132 /* Calculated value */
134 gint tx0, tx1, ty0, ty1; /* tile dimensions */
141 CodingStyleDefault cod;
144 GList *qcc; /* list of Buffer */
145 GList *crg, *com; /* lists of Buffer */
147 /* TODO: COC, PPM, TLM, PLM */
149 guint n_tiles_x, n_tiles_y, n_tiles; /* calculated */
153 typedef struct _PacketIterator PacketIterator;
154 struct _PacketIterator
156 gboolean (*next) (PacketIterator * it);
157 const MainHeader *header;
171 gint n_precincts, n_precincts_w, n_precincts_h;
173 gint tx0, tx1, ty0, ty1;
176 /* cached calculated values */
177 /* depends on resolution and component */
178 gint tcx0, tcx1, tcy0, tcy1;
179 gint trx0, trx1, try0, try1;
180 gint tpx0, tpx1, tpy0, tpy1;
182 gint two_nl_r, two_ppx, two_ppy;
187 GstFlowReturn parse_main_header (GstJP2kDecimator * self, GstByteReader * reader, MainHeader * header);
188 guint sizeof_main_header (GstJP2kDecimator * self, const MainHeader * header);
189 void reset_main_header (GstJP2kDecimator * self, MainHeader * header);
190 GstFlowReturn write_main_header (GstJP2kDecimator * self, GstByteWriter * writer, const MainHeader * header);
191 GstFlowReturn decimate_main_header (GstJP2kDecimator * self, MainHeader * header);
193 #endif /* __JP2K_CODESTREAM_H__ */