Esempio n. 1
0
OPJ_BOOL set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
  box_param_t *ppix_box, *faix_box, *manf_box;
  manfbox_param_t *manf;     /**< manf*/
  boxheader_param_t *bh;     /**< box headers*/
  faixbox_param_t *faix;     /**< faix*/
  OPJ_OFF_T inbox_offset;
  int comp_idx;

  if( !(ppix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "ppix"))){
    fprintf( FCGI_stderr, "Error: ppix box not present in cidx box\n");
    return OPJ_FALSE;
  }

  inbox_offset = get_DBoxoff( ppix_box);
  if( !(manf_box = gene_boxbyType( ppix_box->fd, inbox_offset, get_DBoxlen( ppix_box), "manf"))){
    fprintf( FCGI_stderr, "Error: manf box not present in ppix box\n");
    opj_free( ppix_box);
    return OPJ_FALSE;
  }

  opj_free( ppix_box);

  manf = gene_manfbox( manf_box);
  bh = search_boxheader( "faix", manf);
  inbox_offset = manf_box->offset + (OPJ_OFF_T)manf_box->length;

  opj_free( manf_box);

  jp2idx->precpacket = (faixbox_param_t **)opj_malloc( jp2idx->SIZ.Csiz*sizeof(faixbox_param_t *));

  for( comp_idx=0; bh!=NULL; bh=bh->next, comp_idx++){
    if( jp2idx->SIZ.Csiz <= comp_idx ){
      fprintf( FCGI_stderr, "Error: num of faix boxes is not identical to num of components in ppix box\n");
      return OPJ_FALSE;
    }

    if( !(faix_box = gene_boxbyOffset( cidx_box->fd, inbox_offset))){
      fprintf( FCGI_stderr, "Error: faix box not present in ppix box\n");
      return OPJ_FALSE;
    }

    faix = gene_faixbox( faix_box);
    jp2idx->precpacket[comp_idx] = faix;

    inbox_offset = faix_box->offset + (OPJ_OFF_T)faix_box->length;
    opj_free( faix_box);
  }

  delete_manfbox( &manf);

  return OPJ_TRUE;
}
Esempio n. 2
0
OPJ_BOOL set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
  box_param_t *thix_box, *manf_box, *mhix_box;
  manfbox_param_t *manf;
  boxheader_param_t *ptr;
  mhixbox_param_t *mhix;
  Byte8_t pos;
  OPJ_OFF_T mhixseqoff;
  Byte2_t tile_no;

  if( !(thix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "thix"))){
    fprintf( FCGI_stderr, "Error: thix box not present in cidx box\n");
    return OPJ_FALSE;
  }

  if( !(manf_box = gene_boxbyType( thix_box->fd, get_DBoxoff( thix_box), get_DBoxlen( thix_box), "manf"))){
    fprintf( FCGI_stderr, "Error: manf box not present in thix box\n");
    opj_free( thix_box);
    return OPJ_FALSE;
  }

  manf = gene_manfbox( manf_box);
  ptr = manf->first;
  mhixseqoff = manf_box->offset+(OPJ_OFF_T)manf_box->length;
  pos = 0;
  tile_no = 0;
  jp2idx->tileheader = (mhixbox_param_t **)opj_malloc( jp2idx->SIZ.XTnum*jp2idx->SIZ.YTnum*sizeof(mhixbox_param_t *));

  while( ptr){
    if( !(mhix_box = gene_boxbyType( thix_box->fd, mhixseqoff+(OPJ_OFF_T)pos, get_DBoxlen( thix_box)-manf_box->length-pos, "mhix"))){
      fprintf( FCGI_stderr, "Error: mhix box not present in thix box\n");
      delete_manfbox( &manf);
      opj_free( manf_box);
      opj_free( thix_box);
      return OPJ_FALSE;
    }
    mhix = gene_mhixbox( mhix_box);

    pos += mhix_box->length;
    ptr = ptr->next;

    opj_free( mhix_box);
    jp2idx->tileheader[tile_no++] = mhix;
  }

  delete_manfbox( &manf);
  opj_free( manf_box);
  opj_free( thix_box);

  return OPJ_TRUE;
}
Esempio n. 3
0
OPJ_BOOL set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx)
{
  box_param_t *mhix_box;
  mhixbox_param_t *mhix;
  markeridx_param_t *sizmkidx;
  markeridx_param_t *codmkidx;

  if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix")))
    return OPJ_FALSE;

  jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0);

  mhix = gene_mhixbox( mhix_box);
  opj_free( mhix_box);

  sizmkidx = search_markeridx( 0xff51, mhix);
  set_SIZmkrdata( sizmkidx, codestream, &(jp2idx->SIZ));

  codmkidx = search_markeridx( 0xff52, mhix);
  set_CODmkrdata( codmkidx, codestream, &(jp2idx->COD));

  delete_mhixbox( &mhix);

  return OPJ_TRUE;
}
Esempio n. 4
0
OPJ_BOOL set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
  box_param_t *box;   /**< cptr box*/
  Byte2_t dr, cont;

  if( !(box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "cptr")))
    return OPJ_FALSE;

  /* DR: Data Reference. */
  /* If 0, the codestream or its Fragment Table box exists in the current file*/
  if(( dr = fetch_DBox2bytebigendian( box, 0))){
    fprintf( FCGI_stderr, "Error: Codestream not present in current file\n");
    opj_free( box);
    return OPJ_FALSE;
  }

  /* CONT: Container Type*/
  /* If 0, the entire codestream appears as a contiguous range of*/
  /* bytes within its file or resource.*/
  if(( cont = fetch_DBox2bytebigendian( box, 2))){
    fprintf( FCGI_stderr, "Error: Can't cope with fragmented codestreams yet\n");
    opj_free( box);
    return OPJ_FALSE;
  }

  jp2idx->offset = (OPJ_OFF_T)fetch_DBox8bytebigendian( box, 4);
  jp2idx->length = fetch_DBox8bytebigendian( box, 12);

  opj_free( box);

  return OPJ_TRUE;
}
Esempio n. 5
0
box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, const char TBox[])
{
  OPJ_SIZE_T DBOXlen = get_DBoxlen(superbox);
  assert( offset >= 0 );
  if( DBOXlen < (OPJ_SIZE_T)offset )
    {
    fprintf( FCGI_stderr, "Error: Impossible happen %lu < %ld\n", DBOXlen, offset);
    return NULL;
    }
  return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, DBOXlen-(OPJ_SIZE_T)offset, TBox);
}
Esempio n. 6
0
OPJ_BOOL set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
  box_param_t *tpix_box;   /**< tpix box*/
  box_param_t *faix_box;   /**< faix box*/

  if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix"))){
    fprintf( FCGI_stderr, "Error: tpix box not present in cidx box\n");
    return OPJ_FALSE;
  }

  if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix"))){
    fprintf( FCGI_stderr, "Error: faix box not present in tpix box\n");
    return OPJ_FALSE;
  }

  jp2idx->tilepart = gene_faixbox( faix_box);

  opj_free( tpix_box);
  opj_free( faix_box);

  return OPJ_TRUE;
}
Esempio n. 7
0
OPJ_BOOL set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
  box_param_t *manf_box;
  manfbox_param_t *manf;
  codestream_param_t codestream;

  set_cptrdata( cidx_box, jp2idx);

  codestream = set_codestream( cidx_box->fd, jp2idx->offset, jp2idx->length);

  manf_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "manf");
  manf = gene_manfbox( manf_box);

  if( !search_boxheader( "mhix", manf)){
    fprintf( FCGI_stderr, "Error: mhix box not present in manfbox\n");
    opj_free(jp2idx);
    return OPJ_FALSE;
  }
  set_mainmhixdata( cidx_box, codestream, jp2idx);

  if( !search_boxheader( "tpix", manf)){
    fprintf( FCGI_stderr, "Error: tpix box not present in manfbox\n");
    opj_free(jp2idx);
    return OPJ_FALSE;
  }
  set_tpixdata( cidx_box, jp2idx);

  if( !search_boxheader( "thix", manf)){
    fprintf( FCGI_stderr, "Error: thix box not present in manfbox\n");
    opj_free(jp2idx);
    return OPJ_FALSE;
  }
  set_thixdata( cidx_box, jp2idx);

  if( !search_boxheader( "ppix", manf)){
    fprintf( FCGI_stderr, "Error: ppix box not present in manfbox\n");
    opj_free(jp2idx);
    return OPJ_FALSE;
  }
  set_ppixdata( cidx_box, jp2idx);

  delete_manfbox( &manf);
  opj_free( manf_box);

  return OPJ_TRUE;
}
Esempio n. 8
0
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[])
{
  return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
}