예제 #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;
}
예제 #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;
}
예제 #4
0
OPJ_BOOL check_JP2boxidx( boxlist_param_t *toplev_boxlist)
{
  box_param_t *iptr, *fidx, *prxy;
  box_param_t *cidx, *jp2c;
  Byte8_t off;
  Byte8_t len;
  int pos;
  Byte8_t ooff;
  boxheader_param_t *obh;
  Byte_t ni;
  Byte8_t ioff;
  boxheader_param_t *ibh;

  iptr = search_box( "iptr", toplev_boxlist);
  fidx = search_box( "fidx", toplev_boxlist);
  cidx = search_box( "cidx", toplev_boxlist);
  jp2c = search_box( "jp2c", toplev_boxlist);
  prxy = gene_childboxbyType( fidx, 0, "prxy");

  off = fetch_DBox8bytebigendian( iptr, 0);
  if( off != (Byte8_t)fidx->offset)
    fprintf( FCGI_stderr, "Reference File Index box offset in Index Finder box not correct\n");

  len = fetch_DBox8bytebigendian( iptr, 8);
  if( len != fidx->length)
    fprintf( FCGI_stderr, "Reference File Index box length in Index Finder box not correct\n");

  pos = 0;
  ooff = fetch_DBox8bytebigendian( prxy, pos);
  if( ooff != (Byte8_t)jp2c->offset)
    fprintf( FCGI_stderr, "Reference jp2c offset in prxy box not correct\n");
  pos += 8;

  obh = gene_childboxheader( prxy, pos);
  if( obh->length != jp2c->length || strncmp( obh->type, "jp2c",4)!=0)
    fprintf( FCGI_stderr, "Reference jp2c header in prxy box not correct\n");
  pos += obh->headlen;
  opj_free(obh);

  ni = fetch_DBox1byte( prxy, pos);
  if( ni != 1){
    fprintf( FCGI_stderr, "Multiple indexes not supported\n");
    return OPJ_FALSE;
  }
  pos += 1;

  ioff = fetch_DBox8bytebigendian( prxy, pos);
  if( ioff != (Byte8_t)cidx->offset)
    fprintf( FCGI_stderr, "Reference cidx offset in prxy box not correct\n");
  pos += 8;

  ibh = gene_childboxheader( prxy, pos);
  if( ibh->length != cidx->length || strncmp( ibh->type, "cidx",4)!=0)
    fprintf( FCGI_stderr, "Reference cidx header in prxy box not correct\n");
  pos += ibh->headlen;
  opj_free(ibh);

  opj_free(prxy);

  return OPJ_TRUE;
}
예제 #5
0
faixbox_param_t * gene_faixbox( box_param_t *box)
{
  faixbox_param_t *faix;
  size_t numOfelem;
  long pos = 0;

  faix = ( faixbox_param_t *)malloc( sizeof(faixbox_param_t));
  
  faix->version = fetch_DBox1byte( box, (pos+=1)-1);
  
  if( 3< faix->version){
    fprintf( FCGI_stderr, "Error: version %d in faix box is reserved for ISO use.\n", faix->version);
    free(faix);
    return NULL;
  }

  if( faix->version%2){
    subfaixbox8_param_t *subfaixbox;
    size_t i;
    
    faix->subfaixbox.byte8_params = (subfaixbox8_param_t *)malloc( sizeof(subfaixbox8_param_t));
    
    subfaixbox = faix->subfaixbox.byte8_params;
    subfaixbox->nmax = fetch_DBox8bytebigendian( box, (pos+=8)-8);
    subfaixbox->m    = fetch_DBox8bytebigendian( box, (pos+=8)-8);
    
    numOfelem = subfaixbox->nmax*subfaixbox->m;
    
    subfaixbox->elem = ( faixelem8_param_t *)malloc( numOfelem*sizeof(faixelem8_param_t));
    
    if( faix->version == 3)
      subfaixbox->aux = ( Byte4_t *)malloc( numOfelem*sizeof(Byte4_t));
    
    for( i=0; i<numOfelem; i++){
      subfaixbox->elem[i].off = fetch_DBox8bytebigendian( box, (pos+=8)-8);
      subfaixbox->elem[i].len = fetch_DBox8bytebigendian( box, (pos+=8)-8);
      if( faix->version == 3)
	subfaixbox->aux[i] = fetch_DBox4bytebigendian( box, (pos+=4)-4);
    }
  }
  else{
    subfaixbox4_param_t *subfaixbox;
    size_t i;

    faix->subfaixbox.byte4_params = (subfaixbox4_param_t *)malloc( sizeof(subfaixbox4_param_t));
    
    subfaixbox = faix->subfaixbox.byte4_params;
    subfaixbox->nmax = fetch_DBox4bytebigendian( box, (pos+=4)-4);
    subfaixbox->m    = fetch_DBox4bytebigendian( box, (pos+=4)-4);
    
    numOfelem = subfaixbox->nmax*subfaixbox->m;
    
    subfaixbox->elem = ( faixelem4_param_t *)malloc( numOfelem*sizeof(faixelem4_param_t));
    
    if( faix->version == 2)
      subfaixbox->aux = ( Byte4_t *)malloc( numOfelem*sizeof(Byte4_t));
    
    for( i=0; i<numOfelem; i++){
      subfaixbox->elem[i].off = fetch_DBox4bytebigendian( box, (pos+=4)-4);
      subfaixbox->elem[i].len = fetch_DBox4bytebigendian( box, (pos+=4)-4);
      if( faix->version == 2)
	subfaixbox->aux[i] = fetch_DBox4bytebigendian( box, (pos+=4)-4);
    }
  }
  return faix;
}