[trunk] reverted to revision 1536

This commit is contained in:
Mickael Savinaud 2012-03-09 17:34:05 +00:00
parent 345b5cfc5c
commit ab7b5e48c4
7 changed files with 83 additions and 691 deletions

View File

@ -6,7 +6,6 @@
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -212,8 +211,6 @@ void encode_help_display(void) {
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stdout,"\n");
fprintf(stdout,"-m : use array-based MCT, values are coma separated, line by line\n");
fprintf(stdout," no specific separators between lines, no space allowed between values\n");
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
fprintf(stdout,"\n");
@ -1057,73 +1054,6 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
}
break;
/* ------------------------------------------------------ */
case 'm': /* mct input file */
{
char *lFilename = opj_optarg;
char *lMatrix;
char *lCurrentPtr ;
float *lCurrentDoublePtr;
float *lSpace;
int *l_int_ptr;
int lNbComp = 0, lTotalComp, lMctComp, i, lStrLen;
/* Open file */
FILE * lFile = fopen(lFilename,"r");
if (lFile == NULL) {
return 1;
}
/* Set size of file and read its content*/
fseek(lFile,0,SEEK_END);
lStrLen = ftell(lFile);
fseek(lFile,0,SEEK_SET);
lMatrix = (char *) malloc(lStrLen + 1);
fread(lMatrix, lStrLen, 1, lFile);
fclose(lFile);
lMatrix[lStrLen] = 0;
lCurrentPtr = lMatrix;
/* replace ',' by 0 */
while (*lCurrentPtr != 0 ) {
if (*lCurrentPtr == ' ') {
*lCurrentPtr = 0;
++lNbComp;
}
++lCurrentPtr;
}
++lNbComp;
lCurrentPtr = lMatrix;
lNbComp = (int) (sqrt(4*lNbComp + 1)/2. - 0.5);
lMctComp = lNbComp * lNbComp;
lTotalComp = lMctComp + lNbComp;
lSpace = (float *) malloc(lTotalComp * sizeof(float));
lCurrentDoublePtr = lSpace;
for (i=0;i<lMctComp;++i) {
lStrLen = strlen(lCurrentPtr) + 1;
*lCurrentDoublePtr++ = (float) atof(lCurrentPtr);
lCurrentPtr += lStrLen;
}
l_int_ptr = (int*) lCurrentDoublePtr;
for (i=0;i<lNbComp;++i) {
lStrLen = strlen(lCurrentPtr) + 1;
*l_int_ptr++ = atoi(lCurrentPtr);
lCurrentPtr += lStrLen;
}
/* TODO should not be here ! */
opj_set_MCT(parameters, lSpace, (int *)(lSpace + lMctComp), lNbComp);
/* Free memory*/
free(lSpace);
free(lMatrix);
}
break;
/* ------------------------------------------------------ */
/* UniPG>> */
@ -1556,30 +1486,20 @@ void info_callback(const char *msg, void *client_data) {
}
/* -------------------------------------------------------------------------- */
/**
* IMAGE_TO_J2K MAIN
*/
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
FILE *f = NULL;
opj_bool bSuccess;
opj_cparameters_t parameters; /* compression parameters */
img_fol_t img_fol;
opj_event_mgr_t event_mgr; /* event manager */
opj_stream_t *cio = 00;
opj_codec_t* cinfo = 00;
opj_image_t *image = NULL;
int i,num_images;
int imageno;
dircnt_t *dirptr = NULL;
raw_cparameters_t raw_cp;
opj_codestream_info_t cstr_info; /* Codestream information structure */
char indexfilename[OPJ_PATH_LEN]; /* index file name */
int i, num_images, imageno;
img_fol_t img_fol;
dircnt_t *dirptr = NULL;
opj_bool bSuccess;
/*
configure the event callbacks (not required)
setting of each callback is optionnal
@ -1660,7 +1580,6 @@ int main(int argc, char **argv) {
continue;
}
}
switch(parameters.decod_format) {
case PGX_DFMT:
break;
@ -1681,124 +1600,90 @@ int main(int argc, char **argv) {
continue;
}
/* decode the source image */
/* ----------------------- */
/* decode the source image */
/* ----------------------- */
switch (parameters.decod_format) {
case PGX_DFMT:
image = pgxtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load pgx file\n");
return 1;
}
break;
switch (parameters.decod_format) {
case PGX_DFMT:
image = pgxtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load pgx file\n");
return 1;
}
break;
case PXM_DFMT:
image = pnmtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load pnm file\n");
return 1;
}
break;
case BMP_DFMT:
image = bmptoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load bmp file\n");
return 1;
}
break;
case PXM_DFMT:
image = pnmtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load pnm file\n");
return 1;
}
break;
case BMP_DFMT:
image = bmptoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load bmp file\n");
return 1;
}
break;
#ifdef HAVE_LIBTIFF
case TIF_DFMT:
image = tiftoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load tiff file\n");
return 1;
}
break;
#endif /* HAVE_LIBTIFF */
case RAW_DFMT:
image = rawtoimage(parameters.infile, &parameters, &raw_cp);
if (!image) {
fprintf(stderr, "Unable to load raw file\n");
return 1;
}
break;
case TGA_DFMT:
image = tgatoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load tga file\n");
return 1;
}
break;
#ifdef HAVE_LIBPNG
case PNG_DFMT:
image = pngtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load png file\n");
return 1;
}
case TIF_DFMT:
image = tiftoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load tiff file\n");
return 1;
}
break;
#endif /* HAVE_LIBTIFF */
case RAW_DFMT:
image = rawtoimage(parameters.infile, &parameters, &raw_cp);
if (!image) {
fprintf(stderr, "Unable to load raw file\n");
return 1;
}
break;
case TGA_DFMT:
image = tgatoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load tga file\n");
return 1;
}
break;
#ifdef HAVE_LIBPNG
case PNG_DFMT:
image = pngtoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load png file\n");
return 1;
}
break;
#endif /* HAVE_LIBPNG */
}
/* Can happen if input file is TIFF or PNG
* and HAVE_LIBTIF or HAVE_LIBPNG is undefined
*/
if( !image) {
if( !image)
{
fprintf(stderr, "Unable to load file: got no image\n");
return 1;
}
}
/* Decide if MCT should be used */
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
/* Decide if MCT should be used */
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
if(parameters.cp_cinema){
cinema_setup_encoder(&parameters,image,&img_fol);
}
/* encode the destination image */
/* ---------------------------- */
switch(parameters.decod_format) {
case J2K_CFMT: /* JPEG-2000 codestream */
{
/* Get a decoder handle */
cinfo = opj_create_compress_v2(CODEC_J2K);
break;
if(parameters.cp_cinema){
cinema_setup_encoder(&parameters,image,&img_fol);
}
case JP2_CFMT: /* JPEG 2000 compressed image data */
{
/* Get a decoder handle */
cinfo = opj_create_compress_v2(CODEC_JP2);
break;
}
default:
fprintf(stderr, "skipping file..\n");
opj_stream_destroy(cio);
continue;
}
opj_setup_encoder(cinfo, &parameters, image);
/* encode the destination image */
/* ---------------------------- */
/* Open the output file*/
f = fopen(parameters.outfile, "wb");
if (! f) {
fprintf(stderr, "Not enable to create output file!\n");
opj_stream_destroy(cio);
return 1;
}
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
int codestream_length;
size_t res;
opj_cio_t *cio = NULL;
FILE *f = NULL;
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
int codestream_length;
size_t res;
opj_cio_t *cio = NULL;
FILE *f = NULL;
/* get a J2K compressor handle */
opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);

View File

@ -195,25 +195,12 @@ static void j2k_copy_tile_quantization_parameters(
/**
* Reads the tiles.
*/
opj_bool j2k_decode_tiles ( opj_j2k_v2_t *p_j2k,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager);
static opj_bool j2k_pre_write_tile ( opj_j2k_v2_t * p_j2k,
OPJ_UINT32 p_tile_index,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager );
opj_bool j2k_decode_tiles ( opj_j2k_v2_t *p_j2k,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager);
static opj_bool j2k_update_image_data (opj_tcd_v2_t * p_tcd, OPJ_BYTE * p_data, opj_image_t* p_output_image);
static void j2k_get_tile_data (opj_tcd_v2_t * p_tcd, OPJ_BYTE * p_data);
static opj_bool j2k_post_write_tile (opj_j2k_v2_t * p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager );
/*
* -----------------------------------------------------------------------
@ -8530,308 +8517,3 @@ opj_bool j2k_set_decoded_resolution_factor(opj_j2k_v2_t *p_j2k, OPJ_UINT32 res_f
return OPJ_FALSE;
}
/**
* Encodes all the tiles in a row.
*/
opj_bool j2k_encode_v2( opj_j2k_v2_t * p_j2k,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager )
{
OPJ_UINT32 i;
OPJ_UINT32 l_nb_tiles;
OPJ_UINT32 l_max_tile_size, l_current_tile_size;
OPJ_BYTE * l_current_data;
/* preconditions */
assert(p_j2k != 00);
assert(p_stream != 00);
assert(p_manager != 00);
l_current_data = (OPJ_BYTE*)opj_malloc(1000);
if (! l_current_data) {
return OPJ_FALSE;
}
l_max_tile_size = 1000;
l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
for (i=0;i<l_nb_tiles;++i) {
if (! j2k_pre_write_tile(p_j2k,i,p_stream,p_manager)) {
opj_free(l_current_data);
return OPJ_FALSE;
}
l_current_tile_size = tcd_get_encoded_tile_size(p_j2k->m_tcd);
if (l_current_tile_size > l_max_tile_size) {
l_current_data = (OPJ_BYTE*)opj_realloc(l_current_data,l_current_tile_size);
if (! l_current_data) {
return OPJ_FALSE;
}
l_max_tile_size = l_current_tile_size;
}
j2k_get_tile_data(p_j2k->m_tcd,l_current_data);
if (! j2k_post_write_tile (p_j2k,l_current_data,l_current_tile_size,p_stream,p_manager)) {
return OPJ_FALSE;
}
}
opj_free(l_current_data);
return OPJ_TRUE;
}
/**
* Ends the compression procedures and possibility add data to be read after the
* codestream.
*/
opj_bool j2k_end_compress( opj_j2k_v2_t *p_j2k,
opj_stream_private_t *p_stream,
struct opj_event_mgr * p_manager)
{
/* customization of the encoding */
j2k_setup_end_compress(p_j2k);
if (! j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager))
{
return OPJ_FALSE;
}
return OPJ_TRUE;
}
/**
* Starts a compression scheme, i.e. validates the codec parameters, writes the header.
*
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream object.
* @param p_manager the user event manager.
*
* @return true if the codec is valid.
*/
opj_bool j2k_start_compress(opj_j2k_v2_t *p_j2k,
opj_stream_private_t *p_stream,
opj_image_t * p_image,
opj_event_mgr_t * p_manager)
{
// preconditions
assert(p_j2k != 00);
assert(p_stream != 00);
assert(p_manager != 00);
p_j2k->m_image = p_image;
/* customization of the validation */
j2k_setup_encoding_validation (p_j2k);
/* validation of the parameters codec */
if (! j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager)) {
return OPJ_FALSE;
}
/* customization of the encoding */
j2k_setup_header_writting(p_j2k);
/* write header */
if (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
return OPJ_FALSE;
}
return OPJ_TRUE;
}
/*
*
*/
opj_bool j2k_pre_write_tile ( opj_j2k_v2_t * p_j2k,
OPJ_UINT32 p_tile_index,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager )
{
if (p_tile_index != p_j2k->m_current_tile_number) {
opj_event_msg_v2(p_manager, EVT_ERROR, "The given tile index does not match." );
return OPJ_FALSE;
}
opj_event_msg_v2(p_manager, EVT_INFO, "tile number %d / %d\n", p_j2k->m_current_tile_number + 1, p_j2k->m_cp.tw * p_j2k->m_cp.th);
p_j2k->m_specific_param.m_encoder.m_current_tile_part_number = 0;
p_j2k->m_tcd->cur_totnum_tp = p_j2k->m_cp.tcps[p_tile_index].m_nb_tile_parts;
p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
/* initialisation before tile encoding */
if (! tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number)) {
return OPJ_FALSE;
}
return OPJ_TRUE;
}
/*
*
*/
void j2k_get_tile_data (opj_tcd_v2_t * p_tcd, OPJ_BYTE * p_data)
{
OPJ_UINT32 i,j,k = 0;
OPJ_UINT32 l_width,l_height,l_stride, l_offset_x,l_offset_y, l_image_width;
opj_image_comp_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tilec = 00;
opj_image_t * l_image = 00;
OPJ_UINT32 l_size_comp, l_remaining;
OPJ_INT32 * l_src_ptr;
l_tilec = p_tcd->tcd_image->tiles->comps;
l_image = p_tcd->image;
l_img_comp = l_image->comps;
for (i=0;i<p_tcd->image->numcomps;++i) {
l_size_comp = l_img_comp->prec >> 3; /* (/8) */
l_remaining = l_img_comp->prec & 7; /* (%8) */
if (l_remaining) {
++l_size_comp;
}
if (l_size_comp == 3) {
l_size_comp = 4;
}
l_width = (l_tilec->x1 - l_tilec->x0);
l_height = (l_tilec->y1 - l_tilec->y0);
l_offset_x = int_ceildiv(l_image->x0, l_img_comp->dx);
l_offset_y = int_ceildiv(l_image->y0, l_img_comp->dy);
l_image_width = int_ceildiv(l_image->x1 - l_image->x0, l_img_comp->dx);
l_stride = l_image_width - l_width;
l_src_ptr = l_img_comp->data + (l_tilec->x0 - l_offset_x) + (l_tilec->y0 - l_offset_y) * l_image_width;
switch (l_size_comp) {
case 1:
{
OPJ_CHAR * l_dest_ptr = (OPJ_CHAR*) p_data;
if (l_img_comp->sgnd) {
for (j=0;j<l_height;++j) {
for (k=0;k<l_width;++k) {
*(l_dest_ptr) = (OPJ_CHAR) (*l_src_ptr);
++l_dest_ptr;
++l_src_ptr;
}
l_src_ptr += l_stride;
}
}
else {
for (j=0;j<l_height;++j) {
for (k=0;k<l_width;++k) {
*(l_dest_ptr) = (*l_src_ptr)&0xff;
++l_dest_ptr;
++l_src_ptr;
}
l_src_ptr += l_stride;
}
}
p_data = (OPJ_BYTE*) l_dest_ptr;
}
break;
case 2:
{
OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
if (l_img_comp->sgnd) {
for (j=0;j<l_height;++j) {
for (k=0;k<l_width;++k) {
*(l_dest_ptr++) = (OPJ_INT16) (*(l_src_ptr++));
}
l_src_ptr += l_stride;
}
}
else {
for (j=0;j<l_height;++j) {
for (k=0;k<l_width;++k) {
*(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
}
l_src_ptr += l_stride;
}
}
p_data = (OPJ_BYTE*) l_dest_ptr;
}
break;
case 4:
{
OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
for (j=0;j<l_height;++j) {
for (k=0;k<l_width;++k) {
*(l_dest_ptr++) = *(l_src_ptr++);
}
l_src_ptr += l_stride;
}
p_data = (OPJ_BYTE*) l_dest_ptr;
}
break;
}
++l_img_comp;
++l_tilec;
}
}
/**
* Write a tile.
* @param p_j2k the jpeg2000 codec.
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
opj_bool j2k_post_write_tile ( opj_j2k_v2_t * p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager )
{
opj_tcd_v2_t * l_tcd = 00;
opj_cp_v2_t * l_cp = 00;
opj_tcp_v2_t * l_tcp = 00;
OPJ_UINT32 l_nb_bytes_written;
OPJ_BYTE * l_current_data = 00;
OPJ_UINT32 l_tile_size = 0;
OPJ_UINT32 l_available_data;
/* preconditions */
assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
l_tcd = p_j2k->m_tcd;
l_cp = &(p_j2k->m_cp);
l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size;
l_available_data = l_tile_size;
l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data;
if (! tcd_copy_tile_data(l_tcd,p_data,p_data_size)) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Size mismtach between tile data and sent data." );
return OPJ_FALSE;
}
l_nb_bytes_written = 0;
if (! j2k_write_first_tile_part(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager)) {
return OPJ_FALSE;
}
l_current_data += l_nb_bytes_written;
l_available_data -= l_nb_bytes_written;
l_nb_bytes_written = 0;
if (! j2k_write_all_tile_parts(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager)) {
return OPJ_FALSE;
}
l_available_data -= l_nb_bytes_written;
l_nb_bytes_written = l_tile_size - l_available_data;
if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_encoded_tile_data,l_nb_bytes_written,p_manager) != l_nb_bytes_written) {
return OPJ_FALSE;
}
++p_j2k->m_current_tile_number;
return OPJ_TRUE;
}

View File

@ -1024,20 +1024,4 @@ opj_bool j2k_get_tile( opj_j2k_v2_t *p_j2k,
opj_bool j2k_set_decoded_resolution_factor(opj_j2k_v2_t *p_j2k, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager);
/**
* Encodes an image into a JPEG-2000 codestream
*/
opj_bool j2k_encode_v2( opj_j2k_v2_t * p_j2k,
opj_stream_private_t *cio,
struct opj_event_mgr * p_manager );
/**
* Ends the compression procedures and possibiliy add data to be read after the
* codestream.
*/
opj_bool j2k_end_compress( opj_j2k_v2_t *p_j2k,
opj_stream_private_t *cio,
struct opj_event_mgr * p_manager);
#endif /* __J2K_H */

View File

@ -529,74 +529,6 @@ opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
return cinfo;
}
opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT p_format)
{
opj_codec_private_t *l_info = 00;
l_info = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
if (!l_info) {
return 00;
}
memset(l_info, 0, sizeof(opj_codec_private_t));
l_info->is_decompressor = 0;
switch(p_format) {
case CODEC_J2K:
l_info->m_codec_data.m_compression.opj_encode = (opj_bool (*) ( void *,
struct opj_stream_private *,
struct opj_event_mgr * ) ) j2k_encode_v2;
l_info->m_codec_data.m_compression.opj_end_compress = (opj_bool (*) ( void *,
struct opj_stream_private *,
struct opj_event_mgr *)) j2k_end_compress;
l_info->m_codec_data.m_compression.opj_start_compress = (opj_bool (*) ( void *,
struct opj_stream_private *,
struct opj_image * ,
struct opj_event_mgr *) ) j2k_start_compress;
l_info->m_codec_data.m_compression.opj_write_tile = (opj_bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr *)) j2k_write_tile;
l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy;
l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) j2k_setup_encoder;
l_info->m_codec = j2k_create_compress();
if (! l_info->m_codec)
{
opj_free(l_info);
return 00;
}
break;
case CODEC_JP2:
/* get a JP2 decoder handle */
l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) opj_jp2_encode;
l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) jp2_end_compress;
l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * , struct opj_event_mgr *)) jp2_start_compress;
l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr *)) jp2_write_tile;
l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy;
l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) jp2_setup_encoder;
l_info->m_codec = jp2_create(false);
if (! l_info->m_codec) {
opj_free(l_info);
return 00;
}
break;
case CODEC_UNKNOWN:
case CODEC_JPT:
default:
opj_free(l_info);
return 00;
}
set_default_event_handler(&(l_info->m_event_mgr));
return (opj_codec_t*) l_info;
}
void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
if(cinfo) {
/* destroy the codec */
@ -1102,31 +1034,3 @@ opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OP
return OPJ_TRUE;
}
opj_bool OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,OPJ_FLOAT32 * pEncodingMatrix,OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp)
{
OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * sizeof(OPJ_FLOAT32);
OPJ_UINT32 l_dc_shift_size = pNbComp * sizeof(OPJ_INT32);
OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
/* add MCT capability */
int rsiz = (int)parameters->cp_rsiz | (int)MCT;
parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz;
parameters->irreversible = 1;
/* use array based MCT */
parameters->tcp_mct = 2;
parameters->mct_data = opj_malloc(l_mct_total_size);
if (! parameters->mct_data) {
return OPJ_FALSE;
}
memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size);
memcpy(((OPJ_BYTE *) parameters->mct_data) + l_matrix_size,p_dc_shift,l_dc_shift_size);
return OPJ_TRUE;
}

View File

@ -165,8 +165,7 @@ typedef OPJ_INT64 OPJ_OFF_T;
typedef enum RSIZ_CAPABILITIES {
STD_RSIZ = 0, /** Standard JPEG2000 profile*/
CINEMA2K = 3, /** Profile name for a 2K image*/
CINEMA4K = 4, /** Profile name for a 4K image*/
MCT = 0x8100
CINEMA4K = 4 /** Profile name for a 4K image*/
} OPJ_RSIZ_CAPABILITIES;
/**
@ -418,9 +417,6 @@ typedef struct opj_cparameters {
char tcp_mct;
/** Enable JPIP indexing*/
opj_bool jpip_on;
/** Naive implementation of MCT restricted to a single reversible array based encoding without offset concerning all the components. */
void * mct_data;
} opj_cparameters_t;
#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
@ -1395,15 +1391,6 @@ Creates a J2K/JP2 compression structure
@return Returns a handle to a compressor if successful, returns NULL otherwise
*/
OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
/**
Creates a J2K/JP2 compression structure
@param format Coder to select
@return Returns a handle to a compressor if successful, returns NULL otherwise
*/
OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT format);
/**
Destroy a compressor handle
@param cinfo compressor handle to destroy
@ -1542,26 +1529,6 @@ OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(opj_codec_t *p_cod
OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
/*
==========================================================
new functions
==========================================================
*/
/**
* Sets the MCT matrix to use.
*
* @param parameters the parameters to change.
* @param pEncodingMatrix the encoding matrix.
* @param p_dc_shift the dc shift coefficients to use.
* @param pNbComp the number of components of the image.
*
* @return true if the parameters could be set.
*/
OPJ_API opj_bool OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters,
OPJ_FLOAT32 * pEncodingMatrix,
OPJ_INT32 * p_dc_shift,
OPJ_UINT32 pNbComp);

View File

@ -2623,31 +2623,4 @@ void tcd_code_block_dec_deallocate (opj_tcd_precinct_v2_t * p_precinct)
}
}
OPJ_UINT32 tcd_get_encoded_tile_size ( opj_tcd_v2_t *p_tcd )
{
OPJ_UINT32 i,l_data_size = 0;
opj_image_comp_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tilec = 00;
OPJ_UINT32 l_size_comp, l_remaining;
l_tilec = p_tcd->tcd_image->tiles->comps;
l_img_comp = p_tcd->image->comps;
for (i=0;i<p_tcd->image->numcomps;++i) {
l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
l_remaining = l_img_comp->prec & 7; /* (%8) */
if (l_remaining) {
++l_size_comp;
}
if (l_size_comp == 3) {
l_size_comp = 4;
}
l_data_size += l_size_comp * (l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0);
++l_img_comp;
++l_tilec;
}
return l_data_size;
}

View File

@ -486,14 +486,11 @@ opj_bool tcd_decode_tile_v2(opj_tcd_v2_t *tcd,
/**
* Copies tile data from the system onto the given memory block.
*/
opj_bool tcd_update_tile_data ( opj_tcd_v2_t *p_tcd,
OPJ_BYTE * p_dest,
OPJ_UINT32 p_dest_length );
/**
*
*/
OPJ_UINT32 tcd_get_encoded_tile_size ( opj_tcd_v2_t *p_tcd );
opj_bool tcd_update_tile_data (
opj_tcd_v2_t *p_tcd,
OPJ_BYTE * p_dest,
OPJ_UINT32 p_dest_length
);
/* ----------------------------------------------------------------------- */
/*@}*/