Beispiel #1
0
size_t write_phix( size_t coff, opj_codestream_info_t cstr_info, opj_bool EPHused, size_t j2klen, opj_cio_t *cio)
{
  size_t len, lenp=0;
  int compno, i;
  opj_jp2_box_t *box;

  box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
  
  for( i=0;i<2;i++){
    if (i) cio_seek( cio, lenp);
      
    lenp = cio_tell( cio);
    cio_skip( cio, 4);              /* L [at the end] */
    cio_write( cio, JPIP_PHIX, 4);  /* PHIX           */
      
    write_manf( i, cstr_info.numcomps, box, cio);

    for( compno=0; compno<cstr_info.numcomps; compno++){       
      box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
      box[compno].type = JPIP_FAIX;
    }

    len = cio_tell( cio)-lenp;
    cio_seek( cio, lenp);
    cio_write( cio, len, 4);        /* L              */
    cio_seek( cio, lenp+len);
  }

  opj_free(box);

  return len;
}
Beispiel #2
0
static int write_fidx_v2( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_stream_private_t *cio,
              opj_event_mgr_t * p_manager )
{  
  OPJ_BYTE l_data_header [4];
  int len, lenp;
  
#if 0
  lenp = cio_tell( cio);
  cio_skip( cio, 4);              /* L [at the end] */
  cio_write( cio, JPIP_FIDX, 4);  /* IPTR           */
#else
  lenp = opj_stream_tell(cio);
  opj_stream_skip(cio, 4, p_manager);
  opj_write_bytes(l_data_header,JPIP_FIDX,4); /* FIDX */
  opj_stream_write_data(cio,l_data_header,4,p_manager);
#endif
  
  write_prxy_v2( offset_jp2c, length_jp2c, offset_idx, length_idx, cio,p_manager);

#if 0
  len = cio_tell( cio)-lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L              */
  cio_seek( cio, lenp+len);  
#else
  len = opj_stream_tell(cio)-lenp;
  opj_stream_skip(cio, lenp, p_manager);
  opj_write_bytes(l_data_header,len,4);/* L              */
  opj_stream_write_data(cio,l_data_header,4,p_manager);
  opj_stream_seek(cio, lenp+len,p_manager);
#endif

  return len;
}
Beispiel #3
0
int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
{
  int len, lenp, i;
  int tileno;
  opj_jp2_box_t *box;

  lenp = 0;
  box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));

  for ( i = 0; i < 2 ; i++ ){
    if (i)
      cio_seek( cio, lenp);

    lenp = cio_tell( cio);
    cio_skip( cio, 4);              /* L [at the end] */
    cio_write( cio, JPIP_THIX, 4);  /* THIX           */
    write_manf( i, cstr_info.tw*cstr_info.th, box, cio);
    
    for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
      box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio);
      box[tileno].type = JPIP_MHIX;
    }
 
    len = cio_tell( cio)-lenp;
    cio_seek( cio, lenp);
    cio_write( cio, len, 4);        /* L              */
    cio_seek( cio, lenp+len);
  }

  opj_free(box);

  return len;
}
Beispiel #4
0
int write_tpix_v2( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio,
              opj_event_mgr_t * p_manager )
{
  OPJ_BYTE l_data_header [4];
  int len, lenp;
#if 0
  lenp = cio_tell( cio);
  cio_skip( cio, 4);              /* L [at the end] */
  cio_write( cio, JPIP_TPIX, 4);  /* TPIX           */
#else
  lenp = opj_stream_tell(cio);
  opj_stream_skip(cio, 4, p_manager);
  opj_write_bytes(l_data_header,JPIP_TPIX,4); /* TPIX */
  opj_stream_write_data(cio,l_data_header,4,p_manager);
#endif
  
  write_tpixfaix_v2( coff, 0, cstr_info, j2klen, cio,p_manager);

#if 0
  len = cio_tell( cio)-lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L              */
  cio_seek( cio, lenp+len);
#else
  len = opj_stream_tell(cio)-lenp;
  opj_stream_skip(cio, lenp, p_manager);
  opj_write_bytes(l_data_header,len,4);/* L              */
  opj_stream_write_data(cio,l_data_header,4,p_manager);
  opj_stream_seek(cio, lenp+len,p_manager);
#endif

  return len;
}
Beispiel #5
0
void j2k_write_qcx(int compno)
{
  j2k_tcp_t *tcp;
  j2k_tccp_t *tccp;
  int bandno, numbands;
  int expn, mant;

  tcp = &j2k_cp->tcps[j2k_curtileno];
  tccp = &tcp->tccps[compno];

  cio_write(tccp->qntsty + (tccp->numgbits << 5), 1);	/* Sqcx */
  numbands =
    tccp->qntsty ==
    J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;

  for (bandno = 0; bandno < numbands; bandno++) {
    expn = tccp->stepsizes[bandno].expn;
    mant = tccp->stepsizes[bandno].mant;

    if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
      cio_write(expn << 3, 1);	/* SPqcx_i */
    } else {
      cio_write((expn << 11) + mant, 2);	/* SPqcx_i */
    }
  }

}
Beispiel #6
0
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
	unsigned int j2k_codestream_offset, j2k_codestream_length;
	opj_jp2_box_t box;

	opj_j2k_t *j2k = jp2->j2k;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_JP2C, 4);	/* JP2C */

	/* J2K encoding */
	j2k_codestream_offset = cio_tell(cio);
	if(!j2k_encode(j2k, cio, image, cstr_info)) {
		opj_event_msg(j2k->cinfo, EVT_ERROR, "Failed to encode image\n");
		return 0;
	}
	j2k_codestream_length = cio_tell(cio) - j2k_codestream_offset;

	jp2->j2k_codestream_offset = j2k_codestream_offset;
	jp2->j2k_codestream_length = j2k_codestream_length;

	box.length = 8 + jp2->j2k_codestream_length;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);

	return box.length;
}
Beispiel #7
0
int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen)
{
  int len, i, lenp;
  opj_jp2_box_t *box;
  int num_box = 0;
  opj_bool  EPHused;
  (void)image; /* unused ? */

  lenp = -1;
  box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));

  for (i=0;i<2;i++){
  
    if(i)
      cio_seek( cio, lenp);

    lenp = cio_tell( cio);

    cio_skip( cio, 4);              /* L [at the end] */
    cio_write( cio, JPIP_CIDX, 4);  /* CIDX           */
    write_cptr( offset, cstr_info.codestream_size, cio);

    write_manf( i, num_box, box, cio);
    
    num_box = 0;
    box[num_box].length = write_mainmhix( offset, cstr_info, cio);
    box[num_box].type = JPIP_MHIX;
    num_box++;

    box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio);
    box[num_box].type = JPIP_TPIX;
    num_box++;
      
    box[num_box].length = write_thix( offset, cstr_info, cio);
    box[num_box].type = JPIP_THIX;
    num_box++;

    EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio);
      
    box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio);
    box[num_box].type = JPIP_PPIX;
    num_box++;
    
    box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio);
    box[num_box].type = JPIP_PHIX;
    num_box++;
      
    len = cio_tell( cio)-lenp;
    cio_seek( cio, lenp);
    cio_write( cio, len, 4);        /* L             */
    cio_seek( cio, lenp+len);
  }

  opj_free( box);
  
  return len;
}
Beispiel #8
0
int write_thix_v2( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
              opj_event_mgr_t * p_manager )
{
  OPJ_BYTE l_data_header [4];
  int len, lenp, i;
  int tileno;
  opj_jp2_box_t *box;

  lenp = 0;
  box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));

  for ( i = 0; i < 2 ; i++ ){
    if (i)
#if 0
      cio_seek( cio, lenp);
#else
      opj_stream_seek( cio, lenp, p_manager);
#endif

#if 0
    lenp = cio_tell( cio);
    cio_skip( cio, 4);              /* L [at the end] */
    cio_write( cio, JPIP_THIX, 4);  /* THIX           */
#else
    lenp = opj_stream_tell(cio);
    opj_stream_skip(cio, 4, p_manager);             /* L [at the end] */
    opj_write_bytes(l_data_header,JPIP_THIX,4); /* THIX */
    opj_stream_write_data(cio,l_data_header,4,p_manager);
#endif
    write_manf_v2( i, cstr_info.tw*cstr_info.th, box, cio);
    
    for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
      box[tileno].length = write_tilemhix_v2( coff, cstr_info, tileno, cio);
      box[tileno].type = JPIP_MHIX;
    }
 
#if 0
    len = cio_tell( cio)-lenp;
    cio_seek( cio, lenp);
    cio_write( cio, len, 4);        /* L              */
    cio_seek( cio, lenp+len);
#else
    len = opj_stream_tell(cio)-lenp;
    opj_stream_seek(cio, lenp, p_manager);
    opj_write_bytes(l_data_header,len,4); /* L              */
    opj_stream_write_data(cio,l_data_header,4,p_manager);
    opj_stream_seek( cio, lenp+len,p_manager);
#endif
  }

  opj_free(box);

  return len;
}
Beispiel #9
0
static void jp2_write_jp(opj_cio_t *cio) {
	opj_jp2_box_t box;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_JP, 4);		/* JP2 signature */
	cio_write(cio, 0x0d0a870a, 4);

	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}
Beispiel #10
0
void jp2_write_jp()
{
  jp2_box_t box;

  box.init_pos = cio_tell();
  cio_skip(4);
  cio_write(JP2_JP, 4);		// JP
  cio_write(0x0d0a870a, 4);

  box.length = cio_tell() - box.init_pos;
  cio_seek(box.init_pos);
  cio_write(box.length, 4);	/*    L       */
  cio_seek(box.init_pos + box.length);
}
Beispiel #11
0
static void jp2_write_res(opj_jp2_t *jp2, opj_cio_t *cio) {
	opj_jp2_box_t box;
	
	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_RES, 4);	/* RES */
	
	jp2_write_resc(jp2, cio);
	
	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}
Beispiel #12
0
int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
{
  int len, lenp;
  lenp = cio_tell( cio);
  cio_skip( cio, 4);              /* L [at the end] */
  cio_write( cio, JPIP_TPIX, 4);  /* TPIX           */
  
  write_tpixfaix( coff, 0, cstr_info, j2klen, cio);

  len = cio_tell( cio)-lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L              */
  cio_seek( cio, lenp+len);

  return len;
}
Beispiel #13
0
void j2k_write_coc(int compno) {
    j2k_tcp_t *tcp;
    int lenp, len;
    //fprintf(stderr, "%.8x: COC\n", cio_tell());
    cio_write(J2K_MS_COC, 2);
    lenp=cio_tell();
    cio_skip(2);
    tcp=&j2k_cp->tcps[j2k_curtileno];
    cio_write(compno, j2k_img->numcomps<=256?1:2);
    cio_write(tcp->tccps[compno].csty, 1);
    j2k_write_cox(compno);
    len=cio_tell()-lenp;
    cio_seek(lenp);
    cio_write(len, 2);
    cio_seek(lenp+len);
}
Beispiel #14
0
static void write_iptr( int offset, int length, opj_cio_t *cio)
{
  int len, lenp;
  
  lenp = cio_tell( cio);
  cio_skip( cio, 4);              /* L [at the end] */
  cio_write( cio, JPIP_IPTR, 4);  /* IPTR           */
  
  cio_write( cio, offset, 8);
  cio_write( cio, length, 8);

  len = cio_tell( cio)-lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L             */
  cio_seek( cio, lenp+len);
}
Beispiel #15
0
void jp2_write_bpcc(jp2_struct_t * jp2_struct)
{
  unsigned int i;
  jp2_box_t box;

  box.init_pos = cio_tell();
  cio_skip(4);
  cio_write(JP2_BPCC, 4);	// BPCC

  for (i = 0; i < jp2_struct->numcomps; i++)
    cio_write(jp2_struct->comps[i].bpcc, 1);

  box.length = cio_tell() - box.init_pos;
  cio_seek(box.init_pos);
  cio_write(box.length, 4);	/*    L       */
  cio_seek(box.init_pos + box.length);
}
Beispiel #16
0
static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
	unsigned int i;
	opj_jp2_box_t box;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_BPCC, 4);	/* BPCC */

	for (i = 0; i < jp2->numcomps; i++) {
		cio_write(cio, jp2->comps[i].bpcc, 1);
	}

	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}
Beispiel #17
0
static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio)
{  
  int len, lenp;
  
  lenp = cio_tell( cio);
  cio_skip( cio, 4);              /* L [at the end] */
  cio_write( cio, JPIP_FIDX, 4);  /* IPTR           */
  
  write_prxy( offset_jp2c, length_jp2c, offset_idx, length_idx, cio);

  len = cio_tell( cio)-lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L              */
  cio_seek( cio, lenp+len);  

  return len;
}
Beispiel #18
0
void j2k_write_coc(int compno)
{
  j2k_tcp_t *tcp;
  int lenp, len;

  cio_write(J2K_MS_COC, 2);	/* COC */
  lenp = cio_tell();
  cio_skip(2);
  tcp = &j2k_cp->tcps[j2k_curtileno];
  cio_write(compno, j2k_img->numcomps <= 256 ? 1 : 2);	/* Ccoc */
  cio_write(tcp->tccps[compno].csty, 1);	/* Scoc */
  j2k_write_cox(compno);
  len = cio_tell() - lenp;
  cio_seek(lenp);
  cio_write(len, 2);		/* Lcoc */
  cio_seek(lenp + len);
}
Beispiel #19
0
static void ns_jp2_write_xml(opj_cio_t *cio, unsigned char * xml) {
    unsigned int i;
    opj_jp2_box_t box;
	size_t len;

    box.init_pos = cio_tell(cio);
    cio_skip(cio, 4);
    cio_write(cio, JP2_XML, 4); /* box type is 'xml ' */
	len = strlen((const char *)xml);
    for (i = 0; i < len; i++) {
       cio_write(cio, xml[i], 1);
    }
    box.length = cio_tell(cio) - box.init_pos;
    cio_seek(cio, box.init_pos);
    cio_write(cio, box.length, 4);  
    cio_seek(cio, box.init_pos + box.length);
}
Beispiel #20
0
int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
{
  int i;
  int len, lenp;
  
  lenp = cio_tell( cio);
  cio_skip( cio, 4);                               /* L [at the end]                    */
  cio_write( cio, JPIP_MHIX, 4);                   /* MHIX                              */

  cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8);        /* TLEN                              */

  for(i = 1; i < cstr_info.marknum; i++){    /* Marker restricted to 1 apparition, skip SOC marker */
    cio_write( cio, cstr_info.marker[i].type, 2);
    cio_write( cio, 0, 2);
    cio_write( cio, cstr_info.marker[i].pos-coff, 8);
    cio_write( cio, cstr_info.marker[i].len, 2);
  }

  len = cio_tell( cio) - lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L           */
  cio_seek( cio, lenp+len);
  
  return len;
}
Beispiel #21
0
size_t write_tilemhix( size_t coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio)
{
  int i;
  opj_tile_info_t tile;
  opj_tp_info_t tp;
  size_t len, lenp;
  opj_marker_info_t *marker;

  lenp = cio_tell( cio);
  cio_skip( cio, 4);                               /* L [at the end]                    */
  cio_write( cio, JPIP_MHIX, 4);                   /* MHIX                              */

  tile = cstr_info.tile[tileno];
  tp = tile.tp[0];

  cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8);  /* TLEN                              */ 

  marker = cstr_info.tile[tileno].marker;

  for( i=0; i<cstr_info.tile[tileno].marknum; i++){             /* Marker restricted to 1 apparition */
    cio_write( cio, marker[i].type, 2);
    cio_write( cio, 0, 2);
    cio_write( cio, marker[i].pos-coff, 8);
    cio_write( cio, marker[i].len, 2);
  }
     
  /*  free( marker);*/

  len = cio_tell( cio) - lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);        /* L           */
  cio_seek( cio, lenp+len);

  return len;
}
Beispiel #22
0
int jp2_write_jp2c(j2k_image_t * img, j2k_cp_t * cp, char *jp2_buffer,
		   char *index)
{
  int len;
  jp2_box_t box;

  box.init_pos = cio_tell();
  cio_skip(4);
  cio_write(JP2_JP2C, 4);	// JP2C

  len = j2k_encode(img, cp, jp2_buffer, cp->tdx * cp->tdy * cp->th * cp->tw * 2, index);

  box.length = cio_tell() - box.init_pos;
  cio_seek(box.init_pos);
  cio_write(box.length, 4);	/*    L       */
  cio_seek(box.init_pos + box.length);
  return box.length;
}
Beispiel #23
0
void j2k_write_com(void) {
    unsigned int i;
    int lenp, len;
    char str[256];
    sprintf(str, "Creator: J2000 codec");
    //fprintf(stderr, "%.8x: COM\n", cio_tell());
    cio_write(J2K_MS_COM, 2);
    lenp=cio_tell();
    cio_skip(2);
    cio_write(0, 2);
    for (i=0; i<strlen(str); i++) {
        cio_write(str[i], 1);
    }
    len=cio_tell()-lenp;
    cio_seek(lenp);
    cio_write(len, 2);
    cio_seek(lenp+len);
}
Beispiel #24
0
void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) {
	opj_jp2_box_t box;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_JP2H, 4);	/* JP2H */

	jp2_write_ihdr(jp2, cio);

	if (jp2->bpc == 255) {
		jp2_write_bpcc(jp2, cio);
	}
	jp2_write_colr(jp2, cio);

	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}
Beispiel #25
0
/*
* Write the JP2H box
*
* JP2 Header box
*
*/
void jp2_write_jp2h(jp2_struct_t * jp2_struct)
{
  jp2_box_t box;

  box.init_pos = cio_tell();
  cio_skip(4);;
  cio_write(JP2_JP2H, 4);	/* JP2H */

  jp2_write_ihdr(jp2_struct);

  if (jp2_struct->bpc == 255)
    jp2_write_bpcc(jp2_struct);
  jp2_write_colr(jp2_struct);

  box.length = cio_tell() - box.init_pos;
  cio_seek(box.init_pos);
  cio_write(box.length, 4);	/*    L       */
  cio_seek(box.init_pos + box.length);
}
Beispiel #26
0
void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio)
{
  int len, lenp, i;
  
  lenp = cio_tell( cio); 
  cio_skip( cio, 4);                         /* L [at the end]                    */
  cio_write( cio, JPIP_MANF,4);              /* T                                 */

  if (second){                          /* Write only during the second pass */
    for( i=0; i<v; i++){
      cio_write( cio, box[i].length, 4);  /* Box length                     */ 
      cio_write( cio, box[i].type, 4); /* Box type                       */
    }
  }

  len = cio_tell( cio) - lenp;
  cio_seek( cio, lenp);
  cio_write( cio, len, 4);                   /* L                                 */
  cio_seek( cio, lenp+len);
}
Beispiel #27
0
void j2k_write_com()
{
  unsigned int i;
  int lenp, len;
  char str[256];
  sprintf(str, "%s", j2k_cp->comment);

  cio_write(J2K_MS_COM, 2);
  lenp = cio_tell();
  cio_skip(2);
  cio_write(0, 2);
  for (i = 0; i < strlen(str); i++) {
    cio_write(str[i], 1);
  }
  len = cio_tell() - lenp;
  cio_seek(lenp);
  cio_write(len, 2);
  cio_seek(lenp + len);

}
Beispiel #28
0
/*
* Write the FTYP box
*
* File type box
*
*/
void jp2_write_ftyp(jp2_struct_t * jp2_struct)
{
  unsigned int i;
  jp2_box_t box;

  box.init_pos = cio_tell();
  cio_skip(4);
  cio_write(JP2_FTYP, 4);	/* FTYP       */

  cio_write(jp2_struct->brand, 4);	/* BR         */
  cio_write(jp2_struct->minversion, 4);	/* MinV       */

  for (i = 0; i < jp2_struct->numcl; i++)
    cio_write(jp2_struct->cl[i], 4);	/* CL           */

  box.length = cio_tell() - box.init_pos;
  cio_seek(box.init_pos);
  cio_write(box.length, 4);	/*    L       */
  cio_seek(box.init_pos + box.length);
}
Beispiel #29
0
static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
	unsigned int i;
	opj_jp2_box_t box;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_FTYP, 4);		/* FTYP */

	cio_write(cio, jp2->brand, 4);		/* BR */
	cio_write(cio, jp2->minversion, 4);	/* MinV */

	for (i = 0; i < jp2->numcl; i++) {
		cio_write(cio, jp2->cl[i], 4);	/* CL */
	}

	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}
Beispiel #30
0
static void jp2_write_url(opj_cio_t *cio, char *Idx_file) {
	unsigned int i;
	opj_jp2_box_t box;

	box.init_pos = cio_tell(cio);
	cio_skip(cio, 4);
	cio_write(cio, JP2_URL, 4);	/* DBTL */
	cio_write(cio, 0, 1);		/* VERS */
	cio_write(cio, 0, 3);		/* FLAG */

	if(Idx_file) {
		for (i = 0; i < strlen(Idx_file); i++) {
			cio_write(cio, Idx_file[i], 1);
		}
	}

	box.length = cio_tell(cio) - box.init_pos;
	cio_seek(cio, box.init_pos);
	cio_write(cio, box.length, 4);	/* L */
	cio_seek(cio, box.init_pos + box.length);
}