* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../libopenjpeg/opj_includes.h"
+#include "opj_includes.h"
#include "mj2.h"
/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
/** @name Local static functions */
/*@{*/
-/**
-Read box headers
-@param cinfo Codec context info
-@param cio Input stream
-@param box
-@return Returns true if successful, returns false otherwise
-*/
-/*-- UNUSED
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
---*/
/*
*
* Read box headers
*/
void mj2_stsc_decompact(mj2_tk_t * tk)
{
- int j, i;
- unsigned int k;
- int sampleno=0;
+ unsigned int i, j, k, sampleno = 0;
if (tk->num_samplestochunk == 1) {
tk->num_chunks =
*/
void mj2_stco_decompact(mj2_tk_t * tk)
{
- int j;
- unsigned int i;
- int k = 0;
- int intra_chunk_offset;
+ unsigned int i, j, k = 0;
+ unsigned int intra_chunk_offset;
for (i = 0; i < tk->num_chunks; i++) {
intra_chunk_offset = 0;
*/
void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
{
- int i;
+ unsigned int i;
mj2_box_t box;
box.init_pos = cio_tell(cio);
*/
int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio)
{
- int i;
+ unsigned int i;
mj2_box_t box;
mj2_read_boxhdr(&box, cio); /* Box Size */
{
mj2_box_t box;
mj2_box_t box2;
- int i;
opj_jp2_color_t color;
+ int i;
+ opj_bool ok;
mj2_read_boxhdr(&box, cio);
tk->or_fieldorder = 0;
cio_skip(cio,2); /* Pre-defined = -1 */
+
memset(&color, 0, sizeof(opj_jp2_color_t));
-
- if (!jp2_read_jp2h(&tk->jp2_struct, cio, &color)) {
- opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
+ tk->jp2_struct.cinfo = tk->cinfo;
+
+ ok = jp2_read_jp2h(&tk->jp2_struct, cio, &color);
+
+ tk->jp2_struct.cinfo = NULL;
+
+ if(ok == OPJ_FALSE)
+ {
+ opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
return 1;
- }
+ }
tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
tk->jp2_struct.cl = (unsigned int*) opj_malloc(sizeof(unsigned int));
opj_dinfo_t *dinfo = (opj_dinfo_t*) opj_calloc(1, sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
- dinfo->is_decompressor = true;
+ dinfo->is_decompressor = OPJ_TRUE;
mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
dinfo->mj2_handle = mj2;
if (tk->name_size != 0)
opj_free(tk->name);
if (tk->track_type == 0) {// Video track
- if (tk->jp2_struct.comps != 0)
+ if (tk->jp2_struct.comps != NULL)
opj_free(tk->jp2_struct.comps);
- if (tk->jp2_struct.cl != 0)
+ if (tk->jp2_struct.cl != NULL)
opj_free(tk->jp2_struct.cl);
if (tk->num_jp2x != 0)
opj_free(tk->jp2xdata);
if (tk->name_size != 0)
opj_free(tk->name);
if (tk->track_type == 0) {// Video track
- if (tk->jp2_struct.comps != 0)
+ if (tk->jp2_struct.comps != NULL)
opj_free(tk->jp2_struct.comps);
- if (tk->jp2_struct.cl != 0)
+ if (tk->jp2_struct.cl != NULL)
opj_free(tk->jp2_struct.cl);
if (tk->num_jp2x != 0)
opj_free(tk->jp2xdata);