[trunk] WIP: add a set decoded resolution factor function and update j2k_to_image help about decoded region

This commit is contained in:
Mickael Savinaud 2011-11-17 14:21:11 +00:00
parent b41cad58cb
commit 8026d0b2e7
8 changed files with 75 additions and 2 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed
+ : added
November 17, 2011
+ [mickael] WIP: add a set decoded resolution factor function and update j2k_to_image help about decoded region.
November 9, 2011
* [mickael] WIP: fix tests/nonregresion/CMakeList.txt

View File

@ -140,7 +140,7 @@ void decode_help_display(void) {
fprintf(stdout," are decoded.\n");
fprintf(stdout," -x \n");
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout," -d <x0,x1,y0,y1>\n");
fprintf(stdout," -d <x0,y0,x1,y1>\n");
fprintf(stdout," OPTIONAL\n");
fprintf(stdout," Decoding area\n");
fprintf(stdout," By default all tiles header are read.\n");

View File

@ -8445,5 +8445,23 @@ opj_bool j2k_get_tile( opj_j2k_v2_t *p_j2k,
p_j2k->m_output_image->comps[compno].data = NULL;
}
return OPJ_TRUE;
}
opj_bool j2k_set_decoded_resolution_factor(opj_j2k_v2_t *p_j2k, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager)
{
OPJ_UINT32 it_comp;
p_j2k->m_cp.m_specific_param.m_dec.m_reduce = res_factor;
if (!p_j2k->m_private_image)
for (it_comp = 0 ; it_comp < p_j2k->m_private_image->numcomps; it_comp++)
{
p_j2k->m_private_image->comps[it_comp].factor = res_factor;
}
return OPJ_TRUE;
}

View File

@ -1021,5 +1021,7 @@ opj_bool j2k_get_tile( opj_j2k_v2_t *p_j2k,
struct opj_event_mgr * p_manager,
OPJ_UINT32 tile_index );
opj_bool j2k_set_decoded_resolution_factor(opj_j2k_v2_t *p_j2k, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager);
#endif /* __J2K_H */

View File

@ -2764,3 +2764,8 @@ opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_v2_t* p_jp2)
return j2k_get_cstr_info(p_jp2->j2k);
}
opj_bool jp2_set_decoded_resolution_factor(opj_jp2_v2_t *p_jp2, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager)
{
return j2k_set_decoded_resolution_factor(p_jp2->j2k, res_factor, p_manager);
}

View File

@ -453,6 +453,8 @@ opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_v2_t* p_jp2);
*/
opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_v2_t* p_jp2);
opj_bool jp2_set_decoded_resolution_factor(opj_jp2_v2_t *p_jp2, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager);
/*@}*/
/*@}*/

View File

@ -85,6 +85,10 @@ typedef struct opj_decompression
opj_image_t *p_image,
struct opj_event_mgr * p_manager,
OPJ_UINT32 tile_index);
/** Set the decoded resolution factor */
opj_bool (*opj_set_decoded_resolution_factor) (void * p_codec, OPJ_UINT32 res_factor, struct opj_event_mgr * p_manager);
}opj_decompression_t;
/**
@ -299,6 +303,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format)
struct opj_event_mgr * p_manager,
OPJ_UINT32 tile_index)) j2k_get_tile;
l_info->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec,
OPJ_UINT32 res_factor,
struct opj_event_mgr * p_manager)) j2k_set_decoded_resolution_factor;
l_info->m_codec = j2k_create_decompress_v2();
if (! l_info->m_codec) {
@ -357,6 +365,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format)
struct opj_event_mgr * p_manager,
OPJ_UINT32 tile_index)) jp2_get_tile;
l_info->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager)) jp2_set_decoded_resolution_factor;
l_info->m_codec = jp2_create(OPJ_TRUE);
if (! l_info->m_codec) {
@ -1002,3 +1014,22 @@ opj_bool OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec,
return OPJ_FALSE;
}
/*
*
*
*/
opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor)
{
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
if ( !l_codec ){
fprintf(stderr, "[ERROR] Input parameters of the setup_decoder function are incorrect.\n");
return OPJ_FALSE;
}
l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(l_codec->m_codec, res_factor, l_codec->m_event_mgr);
return OPJ_TRUE;
}

View File

@ -1277,13 +1277,25 @@ OPJ_API opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_decompressor,
* @param p_image output image
* @param tile_index index of the tile which will be decode
*
* @return a pointer to a JP2 index structure.
* @return opj_true if all is ok.
*/
OPJ_API opj_bool OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec,
opj_stream_t *p_cio,
opj_image_t *p_image,
OPJ_UINT32 tile_index);
/**
* Set the resolution factor of the decoded image
* @param p_codec the jpeg2000 codec.
* @param res_factor resolution factor to set
*
* @return opj_true if all is ok.
*/
OPJ_API opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor);
/**
* Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded.
* The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.