示例#1
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;
}
mhixbox_param_t * gene_mhixbox( box_param_t *box)
{
    mhixbox_param_t *mhix;
    markeridx_param_t  *mkridx, *lastmkidx;
    long pos = 0;

    mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));

    mhix->tlen = fetch_DBox8bytebigendian( box, (pos+=8)-8);

    mhix->first = lastmkidx = NULL;
    while( pos < get_DBoxlen( box)) {

        mkridx = ( markeridx_param_t *)malloc( sizeof( markeridx_param_t));
        mkridx->code       = fetch_DBox2bytebigendian( box, (pos+=2)-2);
        mkridx->num_remain = fetch_DBox2bytebigendian( box, (pos+=2)-2);
        mkridx->offset     = fetch_DBox8bytebigendian( box, (pos+=8)-8);
        mkridx->length     = fetch_DBox2bytebigendian( box, (pos+=2)-2);
        mkridx->next = NULL;

        if( mhix->first)
            lastmkidx->next = mkridx;
        else
            mhix->first = mkridx;
        lastmkidx = mkridx;
    }
    return mhix;
}