Esempio n. 1
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;
}
Esempio n. 2
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;
}