opj_codec_t* OPJ_CALLCONV opj_create_compress(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 = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) j2k_encode; l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_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 *)) j2k_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 *)) 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 * )) 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; }
opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) { opj_codec_private_t *l_codec = 00; l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t)); if (!l_codec){ return 00; } memset(l_codec, 0, sizeof(opj_codec_private_t)); l_codec->is_decompressor = 1; switch (p_format) { case CODEC_J2K: l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) j2k_dump; l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) j2k_get_cstr_info; l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) j2k_get_cstr_index; l_codec->m_codec_data.m_decompression.opj_decode = (opj_bool (*) ( void *, struct opj_stream_private *, opj_image_t*, struct opj_event_mgr * )) j2k_decode_v2; l_codec->m_codec_data.m_decompression.opj_end_decompress = (opj_bool (*) ( void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_end_decompress; l_codec->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) ( struct opj_stream_private *, void *, opj_image_t **, struct opj_event_mgr * )) j2k_read_header; l_codec->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))j2k_destroy; l_codec->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * , opj_dparameters_t * )) j2k_setup_decoder_v2; l_codec->m_codec_data.m_decompression.opj_read_tile_header = (opj_bool (*) ( void *, OPJ_UINT32*, OPJ_UINT32*, OPJ_INT32*, OPJ_INT32*, OPJ_INT32*, OPJ_INT32*, OPJ_UINT32*, opj_bool*, struct opj_stream_private *, struct opj_event_mgr * )) j2k_read_tile_header; l_codec->m_codec_data.m_decompression.opj_decode_tile_data = (opj_bool (*) (void *, OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32, struct opj_stream_private *, struct opj_event_mgr *)) j2k_decode_tile; l_codec->m_codec_data.m_decompression.opj_set_decode_area = (opj_bool (*) (void *, opj_image_t*, OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32, struct opj_event_mgr *)) j2k_set_decode_area; l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) (void *p_codec, opj_stream_private_t *p_cio, opj_image_t *p_image, struct opj_event_mgr * p_manager, OPJ_UINT32 tile_index)) j2k_get_tile; l_codec->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_codec->m_codec = j2k_create_decompress_v2(); if (! l_codec->m_codec) { opj_free(l_codec); return NULL; } break; case CODEC_JP2: /* get a JP2 decoder handle */ l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) jp2_dump; l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) jp2_get_cstr_info; l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) jp2_get_cstr_index; l_codec->m_codec_data.m_decompression.opj_decode = (opj_bool (*) ( void *, struct opj_stream_private *, opj_image_t*, struct opj_event_mgr * )) jp2_decode_v2; l_codec->m_codec_data.m_decompression.opj_end_decompress = (opj_bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *)) jp2_end_decompress; l_codec->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) ( struct opj_stream_private *, void *, opj_image_t **, struct opj_event_mgr * )) jp2_read_header; l_codec->m_codec_data.m_decompression.opj_read_tile_header = ( opj_bool (*) ( void *, OPJ_UINT32*, OPJ_UINT32*, OPJ_INT32*, OPJ_INT32*, OPJ_INT32 * , OPJ_INT32 * , OPJ_UINT32 * , opj_bool *, struct opj_stream_private *, struct opj_event_mgr * )) jp2_read_tile_header; l_codec->m_codec_data.m_decompression.opj_decode_tile_data = (opj_bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr * )) jp2_decode_tile; l_codec->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))jp2_destroy; l_codec->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) jp2_setup_decoder_v2; l_codec->m_codec_data.m_decompression.opj_set_decode_area = (opj_bool (*) (void *,opj_image_t*, OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) jp2_set_decode_area; l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) (void *p_codec, opj_stream_private_t *p_cio, opj_image_t *p_image, struct opj_event_mgr * p_manager, OPJ_UINT32 tile_index)) jp2_get_tile; l_codec->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_codec->m_codec = jp2_create(OPJ_TRUE); if (! l_codec->m_codec) { opj_free(l_codec); return 00; } break; case CODEC_UNKNOWN: case CODEC_JPT: default: opj_free(l_codec); return 00; } set_default_event_handler(&(l_codec->m_event_mgr)); return (opj_codec_t*) l_codec; }