示例#1
0
OPJ_BOOL gene_JPIPstream( query_param_t query_param,
		      target_param_t *target,
		      session_param_t *cursession, 
		      channel_param_t *curchannel,
		      msgqueue_param_t **msgqueue)
{
  index_param_t *codeidx;
  cachemodel_param_t *cachemodel;
  
  if( !cursession || !curchannel){ /* stateless */
    if( !target)
      return OPJ_FALSE;
    if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
      return OPJ_FALSE;
    *msgqueue = gene_msgqueue( OPJ_TRUE, cachemodel);
  }
  else{ /* session */
    cachemodel  = curchannel->cachemodel;
    target = cachemodel->target;
    *msgqueue = gene_msgqueue( OPJ_FALSE, cachemodel);
  }
  
  codeidx = target->codeidx;

  if( cachemodel->jppstream)
    fprintf( FCGI_stdout, "Content-type: image/jpp-stream\r\n");
  else
    fprintf( FCGI_stdout, "Content-type: image/jpt-stream\r\n");
  
  if( query_param.layers != -1){
    if( query_param.layers  > codeidx->COD.numOflayers){
      fprintf( FCGI_stdout, "JPIP-layers: %d\r\n", codeidx->COD.numOflayers);
      query_param.layers = codeidx->COD.numOflayers;
    }
  }

  /*meta*/
  if( query_param.box_type[0][0] != 0  && query_param.len != 0)
    if( !enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue))
      return OPJ_FALSE;
  
  if( query_param.metadata_only)
    return OPJ_TRUE;

  /* main header */
  if( !cachemodel->mhead_model && query_param.len != 0)
      enqueue_mainheader( *msgqueue);

  /* image codestream */
  if( (query_param.fx > 0 && query_param.fy > 0))
    enqueue_imagedata( query_param, *msgqueue);
  
  return OPJ_TRUE;
}
示例#2
0
int main(int argc,char *argv[])
{
  msgqueue_param_t *msgqueue;
  int infd, outfd;
  Byte8_t jptlen, j2klen;
  struct stat sb;
  Byte_t *jptstream, *j2kstream;
  
  if( argc < 3){
    fprintf( stderr, "Too few arguments:\n");
    fprintf( stderr, " - input  jpt file\n");
    fprintf( stderr, " - output j2k file\n");
    return -1;
  }

  if(( infd = open( argv[1], O_RDONLY)) == -1){
    fprintf( stderr, "file %s not exist\n", argv[1]);
    return -1;
  }
  
  if( fstat( infd, &sb) == -1){
    fprintf( stderr, "input file stream is broken\n");
    return -1;
  }
  jptlen = (Byte8_t)sb.st_size;

  jptstream = (Byte_t *)malloc( jptlen);

  if( read( infd, jptstream, jptlen) != jptlen){
    fprintf( stderr, "file reading error\n");
    free( jptstream);
    return -1;
  }
  close(infd);

  msgqueue = gene_msgqueue( true, NULL);
  parse_stream( jptstream, jptlen, 0, msgqueue);
  
  //print_msgqueue( msgqueue);

  j2kstream = recons_j2k( msgqueue, jptstream, msgqueue->first->csn, 0, &j2klen);
  
  delete_msgqueue( &msgqueue);
  free( jptstream);


  if(( outfd = open( argv[2], O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
    fprintf( stderr, "file %s open error\n", argv[2]);
    return -1;
  }
  
  if( write( outfd, j2kstream, j2klen) != j2klen)
    fprintf( stderr, "j2k file write error\n");

  free( j2kstream);
  close(outfd);

  return 0;
}
示例#3
0
文件: openjpip.c 项目: 7sam7/openjpeg
dec_server_record_t * OPJ_CALLCONV init_dec_server( int port)
{
  dec_server_record_t *record = (dec_server_record_t *)opj_malloc( sizeof(dec_server_record_t));

  record->cachelist = gene_cachelist();
  record->jpipstream = NULL;
  record->jpipstreamlen = 0;
  record->msgqueue = gene_msgqueue( OPJ_TRUE, NULL);
  record->listening_socket = open_listeningsocket( (uint16_t)port);

  return record;
}
示例#4
0
文件: openjpip.c 项目: 7sam7/openjpeg
jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( OPJ_BOOL jp2)
{
  jpip_dec_param_t *dec;
  
  dec = (jpip_dec_param_t *)opj_calloc( 1, sizeof(jpip_dec_param_t));

  dec->msgqueue = gene_msgqueue( OPJ_TRUE, NULL);
  
  if( jp2)
    dec->metadatalist = gene_metadatalist();

  return dec;
}