reorganization of indexer before importing extentional libopenjpeg files

This commit is contained in:
Kaori Hagihara
2011-08-28 21:43:57 +00:00
parent 13c5f806c6
commit 0c65d2cc0c
15 changed files with 388 additions and 285 deletions

View File

@@ -29,19 +29,9 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include "ext_openjpeg.h"
#include "j2k_to_idxjp2.h"
#include "event_mgr_handler.h"
#include "cio.h"
#include "j2k.h"
/*
* Decode and Add main header marker information
*
* @param[in] cio file input handle
* @param[in,out] cstr_info codestream information
*/
void add_mainheader_marker_info( opj_cio_t *cio, opj_codestream_info_t *cstr_info);
opj_image_t * decode_j2k( unsigned char *j2kstream, int j2klen, opj_codestream_info_t *cstr_info)
{
@@ -83,7 +73,7 @@ opj_image_t * decode_j2k( unsigned char *j2kstream, int j2klen, opj_codestream_i
if( cstr_info->marknum == 0)
add_mainheader_marker_info( cio, cstr_info);
/* close the byte stream */
opj_cio_close(cio);
@@ -94,64 +84,3 @@ opj_image_t * decode_j2k( unsigned char *j2kstream, int j2klen, opj_codestream_i
return image;
}
/*
* Get main headr marker size
*
* @param[in] type marker type
* @param[in] cstr_info codestream information
* @param[in] cio file input handle
* @return marker size
*/
unsigned short get_mh_markersize( unsigned short type, opj_codestream_info_t cstr_info, opj_cio_t *cio);
void add_mainheader_marker_info( opj_cio_t *cio, opj_codestream_info_t *cstr_info)
{
opj_marker_info_t marker;
int pos;
cstr_info->marker = (opj_marker_info_t *)malloc( 100*sizeof(opj_marker_info_t)); // max 100
pos = cstr_info->main_head_start;
cio_seek( cio, pos);
while( pos <= cstr_info->main_head_end){
marker.type = cio_read( cio, 2);
marker.pos = cio_tell( cio);
marker.len = get_mh_markersize( marker.type, *cstr_info, cio);
cio_skip( cio, marker.len);
cstr_info->marker[ cstr_info->marknum] = marker;
cstr_info->marknum++;
pos = cio_tell( cio);
}
}
unsigned short get_mh_markersize( unsigned short type, opj_codestream_info_t cstr_info, opj_cio_t *cio)
{
unsigned short siz;
int pos;
siz = 0;
switch( type){
case J2K_MS_SOC:
siz = 0;
break;
case J2K_MS_SIZ:
siz = 38+3*cstr_info.numcomps;
break;
case J2K_MS_COD:
case J2K_MS_QCD:
case J2K_MS_COM:
pos = cio_tell( cio);
siz = cio_read( cio, 2);
cio_seek( cio, pos);
break;
default:
fprintf( stderr, "marker %x length not defined yet!\n", type);
}
return siz;
}